Explorar el Código

fix:设备 creat-equip-pro 增加设备时增加关系 Sy2Eq Eq2Bd Eq2Fl

lvxianyun hace 3 años
padre
commit
3673a40e51

+ 32 - 3
src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java

@@ -9,8 +9,10 @@ import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmEquipmentService;
+import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
+import com.persagy.proxy.common.entity.RelationDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -28,6 +30,8 @@ import java.util.List;
 public class AdmEquipmentController {
     @Autowired
     private IAdmEquipmentService service;
+    @Autowired
+    private IAdmRelationService relationService;
 
     /**
      * 统计
@@ -175,7 +179,7 @@ public class AdmEquipmentController {
      */
     @PostMapping("/creat-equip-pro")
     public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
-        List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
+        List<AdmEquipment> vos = admEquipment.getContent();
         if(CollUtil.isEmpty(vos)){
             return AdmResponse.success();
         }
@@ -185,8 +189,33 @@ public class AdmEquipmentController {
                 equipment.setName(ObjectNameUtil.objectName("设备-"));
             }
         });
-        vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
-        return AdmResponse.success(vos);
+        List<AdmEquipment> reVos = new ArrayList<>(vos.size());
+        List<RelationDTO> relationDTOS = new ArrayList<>(16);
+        vos.stream().forEach(admEq -> {
+            //创建设备
+            List<AdmEquipment> vosR = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, CollUtil.newArrayList(admEq));
+            //TODO 创建资产
+            //添加设备和系统、建筑、楼层的关系
+            if(CollUtil.isNotEmpty(vosR)){
+                String equipId = vosR.get(0).getId();
+                if(StrUtil.isNotEmpty(equipId)){
+                    if(CollUtil.isNotEmpty(admEq.getLinkSystem())){
+                        admEq.getLinkSystem().stream().forEach(admSystem -> {
+                            relationDTOS.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null , admSystem.getId(), equipId));
+                        });
+                    }
+                    if(StrUtil.isNotEmpty(admEq.getBuildingId())){
+                        relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Bd", null , equipId, admEq.getBuildingId()));
+                    }
+                    if(StrUtil.isNotEmpty(admEq.getFloorId())){
+                        relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Fl", null , equipId, admEq.getBuildingId()));
+                    }
+                }
+            }
+            reVos.addAll(vosR);
+        });
+        relationService.doSave(AdmContextUtil.toDmpContext(),relationDTOS);
+        return AdmResponse.success(reVos);
     }
 
 

+ 0 - 2
src/main/java/com/persagy/proxy/adm/service/IAdmEquipmentService.java

@@ -39,8 +39,6 @@ public interface IAdmEquipmentService extends IAdmBaseService<AdmEquipment>{
      */
     @Deprecated
     void doDeleteEuip(InstanceUrlParam context, List<AdmEquipment> voList);
-    @Deprecated
-    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
 
     /**
      * 补充设备类型属性

+ 4 - 8
src/main/java/com/persagy/proxy/adm/service/impl/AdmEquipmentServiceImpl.java

@@ -15,7 +15,10 @@ import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.model.*;
+import com.persagy.proxy.adm.model.AdmDict;
+import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmObjectType;
+import com.persagy.proxy.adm.model.AdmProperty;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmComAndEquipService;
@@ -162,13 +165,6 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
         }
     }
 
-    @Override
-    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
-        List<AdmEquipment> vos = doInsert(context, AdmEquipment.class, voList);
-        //TODO 创建资产
-        //TODO 创建设备和系统关系 systemList
-        return vos;
-    }
     private DmpResult<List<ObjRelationDTO>> queryRelation(InstanceUrlParam context, Map<String, AdmEquipment> voMap){
         QueryCriteria dmpRequest = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();