|
@@ -14,7 +14,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import com.persagy.dmp.basic.dto.RequestData;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
-import com.persagy.dmp.basic.utils.JsonNodeUtils;
|
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
|
import com.persagy.dmp.common.exception.BusinessException;
|
|
|
import com.persagy.dmp.common.helper.SpringHelper;
|
|
@@ -177,15 +176,54 @@ public class AdmEquipmentController {
|
|
|
ObjectNode node = JsonNodeFactory.instance.objectNode();
|
|
|
node.put("graphCode", graphCode);
|
|
|
admEquipmentMap.keySet().stream().forEach(equipId -> {
|
|
|
- node.put("relCode", "Eq2Bd");
|
|
|
- node.put("objFrom", equipId);
|
|
|
- criteria.setCriteria(node);
|
|
|
- relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
|
|
|
-
|
|
|
- node.put("relCode", "Eq2Fl");
|
|
|
- node.put("objFrom", equipId);
|
|
|
- criteria.setCriteria(node);
|
|
|
- relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
|
|
|
+ AdmEquipment admEquipment = admEquipmentMap.get(equipId);
|
|
|
+ //处理建筑 楼层信息点
|
|
|
+ int removeflBd = 0 ;//关系处理 0不删除 1删除bd 2删除fl 3都删除
|
|
|
+ String flowBuild = admEquipment.getFlowBuild();
|
|
|
+ if(StrUtil.isNotEmpty(flowBuild)){
|
|
|
+ if(!flowBuild.contains("-")){
|
|
|
+ if(flowBuild.startsWith("Bd")){
|
|
|
+ admEquipment.setBuildingId(flowBuild);
|
|
|
+ if(StrUtil.isNotEmpty(admEquipment.getFloorId())){
|
|
|
+ Map<String, Object> infos = new HashMap<String,Object>(16);
|
|
|
+ infos.put("$remove", Arrays.asList("floorId"));
|
|
|
+ admEquipment.setInfos(infos);
|
|
|
+ removeflBd = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String[] str = flowBuild.split("-");
|
|
|
+ if(str[0].startsWith("Bd")){
|
|
|
+ admEquipment.setBuildingId(str[0]);
|
|
|
+ admEquipment.setFloorId(str[1]);
|
|
|
+ }else{
|
|
|
+ admEquipment.setBuildingId(str[1]);
|
|
|
+ admEquipment.setFloorId(str[0]);
|
|
|
+ }
|
|
|
+ removeflBd = 3;
|
|
|
+ }
|
|
|
+ admEquipment.setFlowBuild(null);
|
|
|
+ }else{
|
|
|
+ if(StrUtil.isAllNotEmpty(admEquipment.getBuildingId(),admEquipment.getFloorId())){
|
|
|
+ Map<String, Object> infos = new HashMap<String,Object>(16);
|
|
|
+ infos.put("$remove",Arrays.asList("floorId","buildingId"));
|
|
|
+ admEquipment.setInfos(infos);
|
|
|
+ removeflBd = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //删除关系 然后重建
|
|
|
+ if(removeflBd == 3 || removeflBd == 2){
|
|
|
+ node.put("relCode", "Eq2Fl");
|
|
|
+ node.put("objFrom", equipId);
|
|
|
+ criteria.setCriteria(node);
|
|
|
+ relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
|
|
|
+ }
|
|
|
+ if(removeflBd == 3 || removeflBd == 1){
|
|
|
+ node.put("relCode", "Eq2Bd");
|
|
|
+ node.put("objFrom", equipId);
|
|
|
+ criteria.setCriteria(node);
|
|
|
+ relationService.doDelete(AdmContextUtil.toDmpContext(), criteria);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
List<RelationDTO> relationDTOList = new ArrayList<>(vos.size());
|
|
@@ -204,27 +242,23 @@ public class AdmEquipmentController {
|
|
|
relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOList);
|
|
|
}
|
|
|
//处理设备更新特殊数据
|
|
|
- List<AdmEquipment> equipmentList = new ArrayList<>(vos.size());
|
|
|
vos.stream().forEach(equipment -> {
|
|
|
- if(CollUtil.isNotEmpty(equipment.getInfos())){
|
|
|
- AdmEquipment admEquipment = new AdmEquipment();
|
|
|
- admEquipment.setId(equipment.getId());
|
|
|
- admEquipment.setInfos(equipment.getInfos());
|
|
|
- ObjectNode objectNode = JsonNodeUtils.toObjectNode(admEquipment, "infos", null);
|
|
|
- AdmEquipment admEquipmentNew = JsonNodeUtils.toEntity(objectNode, AdmEquipment.class, "infos");
|
|
|
- if(CollUtil.isNotEmpty(equipment.getNullList())){
|
|
|
- admEquipmentNew.setNullList(equipment.getNullList());
|
|
|
- }
|
|
|
- if(StrUtil.isNotEmpty(equipment.getFloorId())){
|
|
|
- admEquipmentNew.setFloorId(equipment.getFloorId());
|
|
|
+ //特殊处理位置信息
|
|
|
+ if(StrUtil.isNotEmpty(equipment.getBimLocation())){
|
|
|
+ Map<String,Object> infos = equipment.getInfos();
|
|
|
+ if(CollUtil.isEmpty(infos)){
|
|
|
+ infos = new HashMap<String, Object>();
|
|
|
+ infos.put("bimLocation", equipment.getBimLocation());
|
|
|
+ equipment.setInfos(infos);
|
|
|
}
|
|
|
- if(StrUtil.isNotEmpty(equipment.getBuildingId())){
|
|
|
- admEquipmentNew.setBuildingId(equipment.getBuildingId());
|
|
|
- }
|
|
|
- equipmentList.add(admEquipmentNew);
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(equipment.getInfos())){
|
|
|
+ Object localId = equipment.getInfos().get("localId");
|
|
|
+ if(localId != null && StrUtil.isNotEmpty(localId.toString())){
|
|
|
+ equipment.setLocalId(localId.toString());
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
- vos = equipmentList;
|
|
|
}
|
|
|
vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
return AdmResponse.success(vos);
|