|
@@ -144,27 +144,34 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
|
|
|
// 待新增关系
|
|
|
List<RelationDTO> relations = new ArrayList();
|
|
|
for(AdmEquipment vo:voList) {
|
|
|
- // 加入删除关系
|
|
|
- arrayNode.add(vo.getId());
|
|
|
- // 如果建筑ID为空,不用增加关系
|
|
|
- if(isDelete || StrUtil.isBlank(vo.getBuildingId())) {
|
|
|
+ // 如果为删除或是清除buildingId和floorId,则直接删除
|
|
|
+ if(isDelete || CollUtil.containsAll(vo.getNullList(), CollUtil.newHashSet("buildingId", "floorId"))) {
|
|
|
+ arrayNode.add(vo.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 不用增加关系
|
|
|
+ if(StrUtil.isBlank(vo.getBuildingId())) {
|
|
|
continue;
|
|
|
}
|
|
|
+ // 先清除原来的关系
|
|
|
+ arrayNode.add(vo.getId());
|
|
|
// 增加BD关系
|
|
|
relations.add(RelationDTO.builder().graphCode(graphCode).relCode(buildingRelCode).objFrom(vo.getId()).objTo(vo.getBuildingId()).build());
|
|
|
- if(StrUtil.isBlank(vo.getFloorId())) {
|
|
|
+ // 如果有删除楼层关系
|
|
|
+ if(StrUtil.isBlank(vo.getFloorId()) || CollUtil.contains(vo.getNullList(), "floorId")) {
|
|
|
continue;
|
|
|
}
|
|
|
// 增加FL关系
|
|
|
relations.add(RelationDTO.builder().graphCode(graphCode).relCode(floorRelCode).objFrom(vo.getId()).objTo(vo.getFloorId()).build());
|
|
|
}
|
|
|
// 先删除旧关系
|
|
|
- relationService.doDelete(context, criteria);
|
|
|
+ if(arrayNode.size() > 0) {
|
|
|
+ relationService.doDelete(context, criteria);
|
|
|
+ }
|
|
|
// 再创建新关系
|
|
|
- if(CollUtil.isEmpty(relations)) {
|
|
|
- return;
|
|
|
+ if(CollUtil.isNotEmpty(relations)) {
|
|
|
+ relationService.doSave(context, relations);
|
|
|
}
|
|
|
- relationService.doSave(context, relations);
|
|
|
}
|
|
|
|
|
|
@Override
|