Преглед изворни кода

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

lvxianyun пре 3 година
родитељ
комит
e4ff9f3c5f

+ 5 - 1
src/main/java/com/persagy/proxy/adm/request/AdmDictQueryCriteria.java

@@ -1,6 +1,6 @@
 package com.persagy.proxy.adm.request;
 
-import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -20,4 +20,8 @@ public class AdmDictQueryCriteria extends AdmQueryCriteria {
 
     /** 信息点类型 */
     private String type;
+
+    /** 信息点类型 ,兼容拓扑图查询参数*/
+    @JsonProperty(value = "Type")
+    private String labslType;
 }

+ 66 - 2
src/main/java/com/persagy/proxy/calculation/service/impl/AdmManualRelCalServiceImpl.java

@@ -1,8 +1,16 @@
 package com.persagy.proxy.calculation.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.dto.RequestData;
+import com.persagy.dmp.common.constant.ResponseCode;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.digital.client.DigitalObjectClient;
@@ -25,6 +33,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -316,10 +325,12 @@ public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
      */
     @Override
     public AdmResponse query(InstanceUrlParam context, AdmManualRelCalRequest admManualRelCalRequest) {
+        // 1.获取关系枚举类型映射
         Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
         if (!relationTypeMap.containsKey(admManualRelCalRequest.getRelType())){
-            return AdmManualRelCalResponse.failure("不存在的关系类型");
+            return AdmManualRelCalResponse.success(new ArrayList<>());
         }
+        // 2.构建查询参数
         AdmRelationTypeEnum relationTypeEnum = relationTypeMap.get(admManualRelCalRequest.getRelType());
         RequestData requestData = RequestData.builder()
                 .graphCode(relationTypeEnum.getGraphCode())
@@ -336,11 +347,64 @@ public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
         if (StrUtil.isNotBlank(admManualRelCalRequest.getVagueTo())){
             requestData.setSlaveContent(CollUtil.newHashSet(admManualRelCalRequest.getVagueTo()));
         }
+        // 3.查询参数
         CommonResult<List<ObjectDigital>> commonResult = digitalObjectClient
                 .queryObjectListByGraphCodeAndRelCode(context.getGroupCode(), context.getProjectId(),
                         context.getAppId(), "0", requestData);
+        // 4.处理参数
+        List<ObjectNode> result = new ArrayList<>();
+        ObjectMapper objectMapper = SpringUtil.getBean(ObjectMapper.class);
+        if (ResponseCode.A00000.getDesc().equals(commonResult.getResult())
+                && CollUtil.isNotEmpty(commonResult.getData())){
+            List<ObjectDigital> objectDigitals = commonResult.getData();
+            for (ObjectDigital objectDigital : objectDigitals) {
+                ObjectNode temp = objectMapper.createObjectNode();
+                createCommonResultObj(objectDigital,temp);
+                ArrayNode objectInfos = objectMapper.createArrayNode();
+                List<ObjectDigital> relObjs = objectDigital.getRelObjs();
+                if (CollUtil.isNotEmpty(relObjs)){
+                    for (ObjectDigital relObj : relObjs) {
+                        ObjectNode objectNode = objectMapper.createObjectNode();
+                        createCommonResultObj(relObj,objectNode);
+                        objectInfos.add(objectNode);
+                    }
+                }
+                temp.set("objectInfo",objectInfos);
+                result.add(temp);
+            }
+        }
         return new AdmManualRelCalResponse(commonResult.getResult(),commonResult.getMessage(),commonResult.getCount(),
                 admManualRelCalRequest.getPageNumber(),admManualRelCalRequest.getPageSize(),
-                commonResult.getData(),"Left");
+                result,"Left");
+    }
+    /***
+     * Description: 通用的创建结果对象
+     * @param objectDigital : 物理世界对象
+     * @param temp : 存储对象信息
+     * @return : void
+     * @author : lijie
+     * @date :2021/10/30 14:57
+     * Update By lijie 2021/10/30 14:57
+     */
+    private void createCommonResultObj(ObjectDigital objectDigital,ObjectNode temp) {
+        ObjectNode infos = objectDigital.getInfos();
+        temp.set("bimId",infos.get("bimId"));
+        temp.set("buildingId",infos.get("buildingId"));
+        temp.set("floorId",infos.get("floorId"));
+        temp.set("cadId",infos.get("cADID"));
+        temp.put("id",objectDigital.getId());
+        if (null!=objectDigital.getCreationTime()){
+            temp.put("createTime", DateUtil.format(objectDigital.getCreationTime().getDate(),"yyyy-MM-dd HH:mm:ss"));
+        }
+        if (null!=objectDigital.getModifiedTime()){
+            temp.put("lastUpdate", DateUtil.format(objectDigital.getModifiedTime().getDate(),"yyyy-MM-dd HH:mm:ss"));
+        }
+        temp.put("localId", objectDigital.getLocalId());
+        temp.put("localName", objectDigital.getLocalName());
+        temp.put("name", objectDigital.getName());
+        temp.put("objectType", objectDigital.getObjType());
+        temp.put("objectType", objectDigital.getObjType());
+        temp.put("projectId", objectDigital.getProjectId());
+        temp.putObject("statistics");
     }
 }

+ 8 - 10
src/main/java/com/persagy/proxy/dictionary/controller/AdmDictController.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.dictionary.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.persagy.dmp.define.entity.ObjectInfoCollect;
 import com.persagy.proxy.adm.constant.AdmDictConstant;
 import com.persagy.proxy.adm.constant.AdmDictCategoryEnum;
@@ -41,7 +42,6 @@ public class AdmDictController {
 
     /**
      * 字典类型查询:所有设备类型、部件类型、系统类型、专业类型
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -59,7 +59,6 @@ public class AdmDictController {
 
     /**
      * 批量处理字典信息操作:方案设定(BDTP暂不支持)
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -75,7 +74,6 @@ public class AdmDictController {
 
     /**
      * 查询项目下类型的信息点
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -84,13 +82,18 @@ public class AdmDictController {
     public AdmResponse query(@RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
-        request.setName(request.getType());
+        if(StringUtils.isNotEmpty(request.getLabslType())){
+            request.setName(request.getLabslType());
+        }
+        if(StringUtils.isNotEmpty(request.getType())){
+            request.setName(request.getType());
+        }
         return service.query(context, request, AdmDictConstant.CLASS_CODE, AdmObjectInfo.class);
     }
 
+
     /**
      * 查询设备对应的设备族(废弃)
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -105,7 +108,6 @@ public class AdmDictController {
 
     /**
      * 重置项目下所有得定制信息点
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -120,7 +122,6 @@ public class AdmDictController {
 
     /**
      * 根据类型,项目id重置信息点
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -138,7 +139,6 @@ public class AdmDictController {
 
     /**
      * 设置-项目定制化字典
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -152,7 +152,6 @@ public class AdmDictController {
 
     /**
      * 查询项目下已有的设备类型带系统
-     * @param projectId
      * @param request
      * @return
      * @throws Exception
@@ -168,7 +167,6 @@ public class AdmDictController {
 
     /**
      * 查询类型下所有字典信息 M 和 L 类型,包括自定义信息点
-     * @param projectId
      * @param dictTypeList
      * @return
      * @throws Exception

+ 1 - 1
src/main/java/com/persagy/proxy/object/model/AdmSpace.java

@@ -44,7 +44,7 @@ public class AdmSpace extends AdmBaseEntity<AdmSpace> {
     /** 图片 - 信息点里已存在的信息点不应在实体中重复定义为其他格式 */
     private ArrayNode pic;
     /** 空间是否受影响 */
-    private String state;
+    private Integer state;
     /** 空间常驻人数 */
     private Integer permanentPeopleNum;
 

+ 0 - 1
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -138,7 +138,6 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
             relationTo.put("graphCode", "ArchSubset");
             relationTo.put("objFrom", request.getFloorId());
             request.setRelationTo(relationTo);
-
         }else if(StrUtil.isNotEmpty(request.getBuildingId()) && StrUtil.isNotEmpty(request.getFloorId()) && request.getFloorId().equals("isnull")){
             //明确建筑,不明确楼层
             //查询建筑下的楼层

+ 86 - 81
src/main/java/com/persagy/proxy/report/controller/AdmReportEquipController.java

@@ -43,13 +43,12 @@ import org.springframework.web.bind.annotation.*;
 import javax.ws.rs.QueryParam;
 import java.lang.reflect.Field;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
-*  设备报表API
-* @author lvxy
-* @date 2021/9/18
-*/
+ *  设备报表API
+ * @author lvxy
+ * @date 2021/9/18
+ */
 @RestController
 @RequestMapping("/equip-query")
 public class AdmReportEquipController {
@@ -171,7 +170,7 @@ public class AdmReportEquipController {
      */
     @GetMapping("/equip-compon")
     public AdmResponse getEquipCompon(@QueryParam("id") String id, @QueryParam("category") String category){
-        //return  rEquipComponService.getEquipCompon(id,category)        
+        //return  rEquipComponService.getEquipCompon(id,category)
         RequestData requestData = new RequestData();
         if(StrUtil.isNotEmpty(id)){
             requestData.setEquipmentId(id);
@@ -284,7 +283,7 @@ public class AdmReportEquipController {
             request.setName(AdmComponent.OBJ_TYPE);
             return pageQuery(request);
         }
-       return null;
+        return null;
     }
 
     /**
@@ -435,7 +434,7 @@ public class AdmReportEquipController {
         if(JSONUtil.isNull(equipUpDateEnclosureRequest)){
             return AdmResponse.failure(ResponseCode.A0400.getDesc()+",不能为空");
         }
-        
+
         List<EquipUpDateEnclosure> equipUpDateEnclosure = JSONUtil.toList(equipUpDateEnclosureRequest.get("content").toString(), EquipUpDateEnclosure.class);
         if(CollUtil.isNotEmpty(equipUpDateEnclosure)){
             Map<String, EquipUpDateEnclosure> equipUpDateEnclosureMap = CollUtil.fieldValueMap(equipUpDateEnclosure, BaseEntity.PROP_ID);
@@ -491,30 +490,39 @@ public class AdmReportEquipController {
         ObjectNode criteriaEquip = JsonNodeFactory.instance.objectNode();
         criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
         criteriaEquip.put("taskState",-1);
-        ArrayNode array = criteriaEquip.putObject("modelId").putArray("$in");
-        equipComDelList.stream().forEach(nodeObj -> {
-            if(StrUtil.isNotEmpty(nodeObj.get("modelId").textValue())) {
-                array.add(nodeObj.get("modelId").textValue());
+        ArrayNode idList = criteriaEquip.putObject("modelId").putArray("$in");
+        // 组装结果Map 并 设置modelId数组
+        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
+        for (ObjectNode equipComDel : equipComDelList) {
+            // 取id
+            JsonNode idNode = equipComDel.get("modelId");
+            if(idNode == null || !idNode.isTextual()) {
+                continue;
             }
-        });
+            // 设置默认count
+            JsonNode countNode = equipComDel.get("count");
+            if(countNode == null || !countNode.isIntegralNumber()) {
+                // 没有count,则设置为0
+                equipComDel.put("count", 0);
+            }
+            idList.add(idNode.textValue());
+            equipDelMap.put(idNode.textValue(), equipComDel);
+        }
         queryCriteriaEuip.setCriteria(criteriaEquip);
         List<ObjectNode> equipList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
         if(CollUtil.isEmpty(equipList)){
             return AdmResponse.success(equipComDelList);
         }
-        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
-        for (ObjectNode equipComDel : equipComDelList) {
-            String modelIdObj = equipComDel.get("modelId").toString();
-            equipDelMap.put(modelIdObj, equipComDel);
-        }
-        equipList.stream().forEach(euip -> {
-            String modelIdEq = euip.get("modelId").textValue();
-            if(equipDelMap.containsKey(modelIdEq)){
-                Integer count = Integer.parseInt(equipDelMap.get(modelIdEq).get("count").textValue()) + 1;
-                equipDelMap.get(modelIdEq).put("count", count);
+        // 按查询到的设备计数
+        equipList.stream().forEach(eq -> {
+            String modelId = eq.get("modelId").textValue();
+            if(equipDelMap.containsKey(modelId)){
+                ObjectNode delCounter = equipDelMap.get(modelId);
+                int count = delCounter.get("count").intValue() + 1;
+                delCounter.put("count", count);
             }
         });
-        return AdmResponse.success(equipDelMap.values().stream().collect(Collectors.toList()));
+        return AdmResponse.success(equipComDelList);
     }
 
 
@@ -527,8 +535,6 @@ public class AdmReportEquipController {
      */
     @PostMapping("/equip-supply")
     public AdmResponse equipPropertySupply(@RequestBody List<ObjectNode> equipComDelList){
-        //return EquipmentService.equipPropertySupplys(equipComDelList)
-        //
         if(CollUtil.isEmpty(equipComDelList)){
             return AdmResponse.success();
         }
@@ -536,14 +542,28 @@ public class AdmReportEquipController {
         QueryCriteria queryCriteria = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         criteria.put("objType", AdmFloor.OBJ_TYPE);
-        ArrayNode arrayNode = criteria.putObject("modelId").putArray("$in");
-        equipComDelList.stream().forEach(node -> {
-            arrayNode.add(node.get("modelId").textValue());
-        });
+        ArrayNode idList = criteria.putObject("modelId").putArray("$in");
+        // 组装结果Map 并 设置modelId数组
+        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
+        for (ObjectNode equipComDel : equipComDelList) {
+            // 取id
+            JsonNode idNode = equipComDel.get("modelId");
+            if(idNode == null || !idNode.isTextual()) {
+                continue;
+            }
+            // 设置默认count
+            JsonNode countNode = equipComDel.get("count");
+            if(countNode == null || !countNode.isIntegralNumber()) {
+                // 没有count,则设置为0
+                equipComDel.put("count", 0);
+            }
+            idList.add(idNode.textValue());
+            equipDelMap.put(idNode.textValue(), equipComDel);
+        }
         queryCriteria.setCriteria(criteria);
         List<ObjectNode> floorList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
         if(CollUtil.isEmpty(floorList)){
-            return AdmResponse.success();
+            return AdmResponse.success(equipComDelList);
         }
         List<AdmFloor> admFloorList = JSONUtil.toList(floorList.toString(), AdmFloor.class);
         Map<String, AdmFloor> admFloorMap = CollUtil.fieldValueMap(admFloorList, BaseEntity.PROP_ID);
@@ -553,46 +573,33 @@ public class AdmReportEquipController {
         criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
         ArrayNode array = criteriaEquip.putObject("floorId").putArray("$in");
         admFloorMap.keySet().stream().forEach(id -> array.add(id));
-
-        JSONObject bimId = new JSONObject();
-        bimId.put("$null", true);
-        criteria.putPOJO("bimId", bimId);
-
-        JSONObject bimLocation = new JSONObject();
-        bimId.put("$null", false);
-        criteriaEquip.putPOJO("bimLocation", bimLocation);
-
-        JSONObject modelId = new JSONObject();
-        modelId.put("$null", true);
-        criteriaEquip.putPOJO("modelId", modelId);
-
+        criteria.putObject("bimId").put("$null", true);
+        criteria.putObject("bimLocation").put("$null", false);
+        criteria.putObject("modelId").put("$null", true);
         queryCriteriaEuip.setCriteria(criteriaEquip);
         List<ObjectNode> equipList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
         if(CollUtil.isEmpty(equipList)){
             return AdmResponse.success(equipComDelList);
         }
+        // 按楼层统计设备数量
         equipList.stream().forEach(equip -> {
-            String floolId = equip.get("floorId").textValue();
-            if(admFloorMap.containsKey(floolId)){
-                Integer count = Integer.parseInt(admFloorMap.get(floolId).getCount()) + 1;
-                admFloorMap.get(floolId).setCount(count.toString());
+            String floorId = equip.get("floorId").textValue();
+            if(admFloorMap.containsKey(floorId)){
+                AdmFloor floor = admFloorMap.get(floorId);
+                Integer count = floor.getCount() == null ? 0 : Integer.parseInt(floor.getCount());
+                floor.setCount(String.valueOf(count+1));
             }
         });
-
         // 3 根据floorId,modelId 汇总
-        Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
-        for (ObjectNode equipComDel : equipComDelList) {
-           String modelIdObj = equipComDel.get("modelId").toString();
-           equipDelMap.put(modelIdObj, equipComDel);
-        }
         admFloorMap.values().stream().forEach(floor -> {
-            String modelIdFl = floor.getModelId();
-            if(equipDelMap.containsKey(modelIdFl)){
-                Integer count = Integer.parseInt(equipDelMap.get(modelIdFl).get("count").textValue()) + Integer.parseInt(floor.getCount());
-                equipDelMap.get(modelIdFl).put("count", count);
+            String modelId = floor.getModelId();
+            if(equipDelMap.containsKey(modelId)){
+                ObjectNode delCounter = equipDelMap.get(modelId);
+                int count = delCounter.get("count").intValue() + Integer.parseInt(floor.getCount());
+                delCounter.put("count", count);
             }
         });
-        return AdmResponse.success(equipDelMap.values().stream().collect(Collectors.toList()));
+        return AdmResponse.success(equipComDelList);
     }
 
     /**
@@ -624,7 +631,7 @@ public class AdmReportEquipController {
      */
     @PostMapping("/property-equip-supp")
     public AdmResponse propertyEquip(@RequestBody AdmQueryCriteria request){
-        
+
         //return EquipmentService.equipPropertySupp(sQueryRequest)
         //equipment.bim_id IS NULL
         //  AND equipment.model_id IS NULL
@@ -669,23 +676,23 @@ public class AdmReportEquipController {
             filter =  filter + ";id in "+arrayNode.toString();
             request.setFilters(filter);
 
-           AdmResponse admResponse = equipmentService.query(request);
-           if(CollUtil.isNotEmpty(admResponse.getContent())){
-               //处理数据
-               List<ObjectNode> objectNodeList = (List<ObjectNode>) admResponse.getContent();
-               objectNodeList.stream().forEach(equip ->{
-                   JsonNode building = equip.get("building");
-                   JsonNode floor = equip.get("floor");
-                   if(!JSONUtil.isNull(building)){
-                       equip.put("buildingName", building.get("localName").textValue());
-                   }
-                   if(!JSONUtil.isNull(floor)){
-                       equip.put("floorName", floor.get("localName").textValue());
-                       equip.put("modelId", floor.get("modelId").textValue());
-                   }
-               });
-           }
-           return admResponse;
+            AdmResponse admResponse = equipmentService.query(request);
+            if(CollUtil.isNotEmpty(admResponse.getContent())){
+                //处理数据
+                List<ObjectNode> objectNodeList = (List<ObjectNode>) admResponse.getContent();
+                objectNodeList.stream().forEach(equip ->{
+                    JsonNode building = equip.get("building");
+                    JsonNode floor = equip.get("floor");
+                    if(!JSONUtil.isNull(building)){
+                        equip.put("buildingName", building.get("localName").textValue());
+                    }
+                    if(!JSONUtil.isNull(floor)){
+                        equip.put("floorName", floor.get("localName").textValue());
+                        equip.put("modelId", floor.get("modelId").textValue());
+                    }
+                });
+            }
+            return admResponse;
         }else{
             return AdmResponse.success();
         }
@@ -814,7 +821,7 @@ public class AdmReportEquipController {
         AdmGatherInfoPoint gatherInfoPoint = new AdmGatherInfoPoint();
 
         Integer controlInfoCounts = controlInfoCounts(AdmEquipment.OBJ_TYPE);
-       // 根据objType获取定义 获取采集的设备的classcode
+        // 根据objType获取定义 获取采集的设备的classcode
         Set<String> objTypes = new HashSet<>(1);
         objTypes.add(AdmEquipment.OBJ_TYPE);
         List<Map<String, Object>> codes = DigitalObjectSimpleFacade.queryDefineInfoByObjType(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null, RequestData.builder().objTypes(objTypes).build());
@@ -935,7 +942,7 @@ public class AdmReportEquipController {
         queryCriteria.setOnlyCount(true);
         List<ObjectNode> euipCom = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
         if(CollUtil.isNotEmpty(euipCom)){
-           return AdmResponse.success(euipCom);
+            return AdmResponse.success(euipCom);
         }else{
             return AdmResponse.success();
         }
@@ -1165,6 +1172,4 @@ public class AdmReportEquipController {
             infos.put(attribute, upTarget);
         }
     }
-
-
 }