Browse Source

Merge branch 'develop' of http://39.106.8.246:3003/BDTP/adm-middleware.git into develop

zhangqiankun 3 years ago
parent
commit
ae5858653f

+ 12 - 2
src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java

@@ -1,12 +1,14 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.persagy.proxy.adm.model.AdmComponent;
 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.IAdmComponentService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
+import com.persagy.proxy.adm.utils.ObjectNameUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -36,8 +38,7 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(
-                             @RequestBody AdmQueryCriteria request) throws Exception {
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmComponent.OBJ_TYPE);
         request.setOnlyCount(true);
         return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmComponent.class);
@@ -51,6 +52,15 @@ public class AdmComponentController {
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmComponent> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         List<AdmComponent> vos = CollUtil.newArrayList(createRequest.getContent());
+        if(CollUtil.isEmpty(vos)){
+            return AdmResponse.success();
+        }
+        //创建部件
+        vos.stream().forEach(component -> {
+            if (StrUtil.isEmpty(component.getName())){
+                component.setName(ObjectNameUtil.objectName("部件-"));
+            }
+        });
         vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmComponent.class, vos);
         return AdmResponse.success(vos);
     }

+ 39 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java

@@ -2,15 +2,19 @@ package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.utils.JsonNodeUtils;
 import com.persagy.proxy.adm.model.AdmEquipment;
 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.utils.AdmContextUtil;
+import com.persagy.proxy.adm.utils.ObjectNameUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -33,8 +37,7 @@ public class AdmEquipmentController {
      * @throws Exception
      */
     @PostMapping("/count")
-    public AdmResponse count(
-                             @RequestBody AdmQueryCriteria request) throws Exception {
+    public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmEquipment.OBJ_TYPE);
         request.setOnlyCount(true);
         return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
@@ -49,6 +52,15 @@ public class AdmEquipmentController {
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
+        if(CollUtil.isEmpty(vos)){
+            return AdmResponse.success();
+        }
+        //创建设备
+        vos.stream().forEach(equipment -> {
+            if (StrUtil.isEmpty(equipment.getName())){
+                equipment.setName(ObjectNameUtil.objectName("设备-"));
+            }
+        });
         vos = service.doInsertEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
@@ -77,6 +89,21 @@ public class AdmEquipmentController {
     public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
         //vos = service.doUpdateEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
+        //针对设备更新时,所有更新的字段都放到信息点中的情况特殊处理
+        if(CollUtil.isNotEmpty(vos)){
+            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");
+                    equipmentList.add(admEquipmentNew);
+                }
+            });
+            vos = equipmentList;
+        }
         vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
@@ -130,8 +157,7 @@ public class AdmEquipmentController {
      * @throws Exception
      */
     @GetMapping("/query-equip")
-    public AdmResponse queryEquip(
-                                  @RequestBody AdmQueryCriteria request) throws Exception {
+    public AdmResponse queryEquip(@RequestBody AdmQueryCriteria request) throws Exception {
         //request.setName("equipment");
         if(StrUtil.isNotEmpty(request.getFilters())){
             request.setFilters(String.join(";",request.getFilters(),"objType in ['equipment','component']"));
@@ -150,6 +176,15 @@ public class AdmEquipmentController {
     @PostMapping("/creat-equip-pro")
     public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
         List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
+        if(CollUtil.isEmpty(vos)){
+            return AdmResponse.success();
+        }
+        //创建设备
+        vos.stream().forEach(equipment -> {
+            if (StrUtil.isEmpty(equipment.getName())){
+                equipment.setName(ObjectNameUtil.objectName("设备-"));
+            }
+        });
         vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }

+ 10 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java

@@ -227,6 +227,7 @@ public class AdmSystemController {
     public AdmResponse queryNew(@QueryParam("buildingId") String buildingId,
                                 @QueryParam("floorId") String floorId, @RequestBody AdmQueryCriteria request) throws Exception {
         AdmResponse syses = new AdmResponse();
+        List<AdmSystem> admSystemList = new ArrayList<>();
         if(StrUtil.isAllEmpty(buildingId,floorId)){
             //case one 查询全部系统,级联建筑,建筑级联楼层
             AdmQueryCriteria admQueryCriteriaBd = new AdmQueryCriteria();
@@ -243,7 +244,7 @@ public class AdmSystemController {
             syses = service.doQuery(AdmContextUtil.toDmpContext(),request,AdmSystem.class);
             //处理数据 BuildingFloorInfo
             if(CollUtil.isNotEmpty(syses.getContent())){
-                List<AdmSystem> admSystemList = (List<AdmSystem>) syses.getContent();
+                admSystemList = (List<AdmSystem>) syses.getContent();
                 admSystemList.stream().forEach(admSystem -> {
                     List<AdmBuildingFloorInfo> buildingFloorInfoList = new ArrayList<>();
                     List<AdmBuilding> buildingList = admSystem.getBuildingList();
@@ -272,7 +273,7 @@ public class AdmSystemController {
                         admSystem.setBuildingFloorInfoList(buildingFloorInfoList);
                     }
                 });
-                syses.setContent(admSystemList);
+                syses.setContent(CollUtil.isEmpty(admSystemList) ? new ArrayList<>(1) : admSystemList);
             }
         }else{
             QueryCriteria rwdQueryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
@@ -281,7 +282,7 @@ public class AdmSystemController {
                 return AdmResponse.failure("请求参数错误");
             }
             criteria.put("objType", AdmSystem.OBJ_TYPE);
-            List<AdmSystem> admSystemList = null;
+
             if (StrUtil.isAllNotEmpty(buildingId, floorId)) {
                 if(!"1".equals(floorId)){
                     //case two 明确建筑、明确楼层的 系统
@@ -316,7 +317,7 @@ public class AdmSystemController {
                     if(CollUtil.isNotEmpty(admSystemList)){
                         //处理数据 BuildingFloorInfo
                         admSystemList = dealBdFlInfo(null,null, admSystemList);
-                        syses.setContent(admSystemList);
+
                     }
                 }
             }
@@ -324,6 +325,11 @@ public class AdmSystemController {
                 syses.setTotal(admSystemList.size()*1l);
 
         }
+        if(CollUtil.isNotEmpty(admSystemList)){
+            syses.setContent(admSystemList);
+        }else{
+            syses.setContent(new ArrayList<>(1));
+        }
         return syses;
     }
 

+ 3 - 1
src/main/java/com/persagy/proxy/adm/controller/RelationSyInFlController.java

@@ -86,7 +86,9 @@ public class RelationSyInFlController {
         //楼层Id
         List<String> floorIdList = syInFlList.getFloorIdList();
         if (StringUtils.isBlank(sysId) || CollectionUtils.isEmpty(floorIdList)) {
-            return AdmResponse.failure("必填项:sysId(系统id)、floorIdList(楼层Id)");
+            //return AdmResponse.failure("必填项:sysId(系统id)、floorIdList(楼层Id)");
+            //兼容adm历史逻辑,若楼层id为空时,返回success
+            return AdmResponse.success();
         }
         List<RelationDTO> voList = new ArrayList<>();
         AdmRelationTypeEnum sy2fl = AdmRelationTypeEnum.SY2FL;

+ 20 - 0
src/main/java/com/persagy/proxy/adm/model/AdmBuildingFloorInfo.java

@@ -25,4 +25,24 @@ public class AdmBuildingFloorInfo {
     /** 楼层名称 */
     @JSONField(name = "FloorName")
     private String floorName;
+
+    @JSONField(name = "BuildName")
+    public String getBuildName() {
+        return buildName;
+    }
+
+    @JSONField(name = "FloorID")
+    public String getFloorID() {
+        return floorID;
+    }
+
+    @JSONField(name = "FloorName")
+    public String getFloorName() {
+        return floorName;
+    }
+
+    @JSONField(name = "BuildID")
+    public String getBuildID() {
+        return buildID;
+    }
 }

+ 3 - 2
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmDictBaseServiceImpl.java

@@ -209,11 +209,12 @@ public class AbstractAdmDictBaseServiceImpl<T> implements IAdmDictBaseService<T>
 
             //信息点是否可见
             if(admVO.getVisible() == null){
-                if("localName".equals(admVO.getCode()) || "localId".equals(admVO.getCode())){
+                /*if("localName".equals(admVO.getCode()) || "localId".equals(admVO.getCode())){
                     admVO.setVisible(true);
                 }else{
                     admVO.setVisible(false);
-                }
+                }*/
+                admVO.setVisible(true);
             }
             //信息点是否可编辑
             if(admVO.getEditable() == null){

+ 1 - 7
src/main/java/com/persagy/proxy/adm/service/impl/AdmEquipmentServiceImpl.java

@@ -127,17 +127,11 @@ 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 null;
+        return vos;
     }
-
-
-
-
     private DmpResult<List<ObjRelationDTO>> queryRelation(InstanceUrlParam context, Map<String, AdmEquipment> voMap){
         QueryCriteria dmpRequest = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();