浏览代码

fix : 设备 信息点统计

lvxianyun 3 年之前
父节点
当前提交
ae590ad263

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

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

+ 74 - 57
src/main/java/com/persagy/proxy/report/controller/AdmReportEquipController.java

@@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 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.constant.ResponseCode;
 import com.persagy.dmp.common.model.entity.BaseEntity;
 import com.persagy.dmp.define.client.DigitalObjectInfoFacade;
@@ -21,21 +22,20 @@ import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.constant.AdmDictCategoryEnum;
-import com.persagy.proxy.object.model.EquipUpDateEnclosure;
 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.request.AdmZoneEquipQueryRequest;
-import com.persagy.proxy.object.service.IAdmComponentService;
-import com.persagy.proxy.dictionary.service.IAdmDictService;
-import com.persagy.proxy.object.service.IAdmEquipmentService;
-import com.persagy.proxy.object.service.IAdmSystemService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.dictionary.model.AdmDict;
 import com.persagy.proxy.dictionary.model.AdmObjectType;
+import com.persagy.proxy.dictionary.service.IAdmDictService;
 import com.persagy.proxy.object.model.*;
+import com.persagy.proxy.object.service.IAdmComponentService;
+import com.persagy.proxy.object.service.IAdmEquipmentService;
+import com.persagy.proxy.object.service.IAdmSystemService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -837,13 +837,14 @@ public class AdmReportEquipController {
     /**
      * 计算动态、静态信息点
      */
-    private Map<String, Integer> calculate(List<ObjectInfoDefine> dynamicInfoPointCodes, List<ObjectInfoDefine> staticInfoPointCodes, List<ObjectNode> objectNodeList, Integer num) {
-        Map<String, Integer> hashMap = new HashMap<String, Integer>();
-        int dynamicInfoPoint = 0;
-        int staticInfoPoint = 0;
-        int customInfoPoint=0;
+    private Map<String, Integer> calculate(List<ObjectInfoDefine> dynamicInfoPointCodes, List<ObjectInfoDefine> staticInfoPointCodes, List objList, Integer num,Map<String, Integer> hashMap) {
+        int dynamicInfoPoint = hashMap.get("dynamicInfoPoint");
+        int staticInfoPoint = hashMap.get("staticInfoPoint");
+        int customInfoPoint = hashMap.get("customInfoPoint");
+
         Iterator<ObjectInfoDefine> iterator1 = staticInfoPointCodes.iterator();
-        for (ObjectNode objectNode : objectNodeList) {
+        for (int i=0;i<objList.size();i++) {
+            JsonNode objectNode = JsonNodeUtils.toObjectNode(objList.get(i),null,null);
             while (iterator1.hasNext()) {
                 ObjectInfoDefine infoDefine = iterator1.next();
                 if (objectNode.get("id") != null && "id" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
@@ -898,7 +899,8 @@ public class AdmReportEquipController {
             }
         }
 
-        for (ObjectNode objectNode : objectNodeList) {
+        for (int i=0;i<objList.size();i++) {
+            JsonNode objectNode = JsonNodeUtils.toObjectNode(objList.get(i),null,null);
             if (objectNode.get("infos") != null) {
                 Map<String,Object> dynamic = calculateInfoPoints(objectNode.get("infos").toString(), objectNode.get("classCode").textValue().toString(), dynamicInfoPointCodes);
                 Map<String,Object> staticMap = calculateInfoPoints(objectNode.get("infos").toString(), objectNode.get("classCode").textValue().toString(), staticInfoPointCodes);
@@ -938,88 +940,103 @@ public class AdmReportEquipController {
     }
 
     private JSONObject calInfoPointByObjType(String objType, Boolean visible, Boolean getInfoCounts){
-        //1 查询项目下所有现有的系统
-        AdmQueryCriteria admQueryCriteriaObj =  new AdmQueryCriteria();
-        if(objType.equals(AdmEquipment.OBJ_TYPE)){
-            admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","bimLocation","infos","classCode","equipSerial","bimFamilyName","bimFamilySymbol"));
-        }else{
-            admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","infos","classCode"));
-        }
-        admQueryCriteriaObj.setName(objType);
-        QueryCriteria queryCriteriaSys = AdmQueryCriteriaHelper.toDmpCriteria(admQueryCriteriaObj);
-        List<ObjectNode> admObjList = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteriaSys);
-
-        //2 获取动态 静态 信息点
-        // 2.1 根据objType获取定义
+        JSONObject gatherInfoPoint = new JSONObject();
+        gatherInfoPoint.put("gatherInfoPointCounts", 0);
+        gatherInfoPoint.put("gatherCustomInfoPointCounts",0);
+        gatherInfoPoint.put("gatherDynamicInfoPointCounts",0);
+        gatherInfoPoint.put("gatherStaticInfoPointCounts",0);
+
+        Map<String, Integer> hashMap = new HashMap<>(16);
+        hashMap.put("dynamicInfoPoint", 0);
+        hashMap.put("staticInfoPoint", 0);
+        hashMap.put("customInfoPoint", 0);
+        //查询当前实例所有信息点总数
+        long controlInfoCounts = 0L;
         Set<String> classCodeSet = new HashSet<>();
-        if(AdmSystem.OBJ_TYPE.equals(objType)){
-            QueryCriteria queryCriteriaType = new QueryCriteria();
-            ObjectNode criteria = JsonNodeFactory.instance.objectNode();
-            criteria.put("objType", objType);
-            queryCriteriaType.setCriteria(criteria);
-            AdmResponse admResponseType = dictService.doQueryObjectType(AdmContextUtil.toDmpContext(), queryCriteriaType, AdmObjectType.class);
-            if(CollUtil.isEmpty(admResponseType.getContent())){
-                return null;
+        //2 获取动态 静态 信息点
+        // 2.1 根据objType获取定义 获取采集的设备的classcode
+        Set<String> objTypes = new HashSet<>(1);
+        objTypes.add(objType);
+        List<Map<String, Object>> codes = DigitalObjectSimpleFacade.queryDefineInfoByObjType(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null, RequestData.builder().objTypes(objTypes).build());
+        if(CollUtil.isEmpty(codes)){
+            return gatherInfoPoint;
+        }else{
+            codes.stream().forEach(stringObjectMap -> classCodeSet.add(stringObjectMap.get("code").toString()));
+            //1 查询项目下所有现有的系统
+            AdmQueryCriteria admQueryCriteriaObj =  new AdmQueryCriteria();
+            admQueryCriteriaObj.setPageNumber(1);
+            admQueryCriteriaObj.setPageSize(500);
+            admQueryCriteriaObj.setName(objType);
+            AdmResponse admResponse = new AdmResponse();
+            if(objType.equals(AdmEquipment.OBJ_TYPE)){
+                admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","bimLocation","infos","classCode","equipSerial","bimFamilyName","bimFamilySymbol"));
+                admResponse = equipmentService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteriaObj, AdmEquipment.class);
+            }else{
+                admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","infos","classCode"));
+                admResponse = systemService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteriaObj, AdmSystem.class);
             }
-            List<AdmObjectType> admObjectTypes = (List<AdmObjectType>) admResponseType.getContent();
-            Map<String, AdmObjectType> admObjectTypeMap = CollUtil.fieldValueMap(admObjectTypes, "code");
-            classCodeSet = admObjectTypeMap.keySet();
-        }else {
-            List<AdmEquipment> equipmentList = JSONUtil.toList(admObjList.toString(), AdmEquipment.class);
-            Map<String, AdmEquipment> admObjectTypeMap = CollUtil.fieldValueMap(equipmentList, "classCode");
-            classCodeSet = admObjectTypeMap.keySet();
-        }
 
-        JSONObject gatherInfoPoint = new JSONObject();
-        if(CollUtil.isEmpty(admObjList)){
-            gatherInfoPoint.put("gatherInfoPointCounts", 0);
-            gatherInfoPoint.put("gatherCustomInfoPointCounts",0);
-            gatherInfoPoint.put("gatherDynamicInfoPointCounts",0);
-            gatherInfoPoint.put("gatherStaticInfoPointCounts",0);
-        } else {
-            // 2.2 根据定义获取信息点
-            //查询当前实例所有信息点总数
-            long controlInfoCounts = 0L;
+            //获取信息点
             QueryCriteria queryCriteria = new QueryCriteria();
             ObjectNode criteria = JsonNodeFactory.instance.objectNode();
             criteria = JsonNodeFactory.instance.objectNode();
             ArrayNode arrayNode = criteria.putObject("classCode").putArray("$in");
             classCodeSet.stream().forEach(classCode -> arrayNode.add(classCode));
+
+            //查询当前实例所有信息点总数
             if(getInfoCounts){
                 queryCriteria.setCriteria(criteria);
                 queryCriteria.setOnlyCount(true);
                 List<ObjectInfoDefine> totalInfo = DigitalObjectInfoFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
                 controlInfoCounts = totalInfo.size();
             }
+
             //静态信息点
+            criteria.put("groupCode","0");
+            criteria.put("projectId","0");
             criteria.put("category","STATIC");
             if(visible){
                 criteria.put("valid", "1");
             }else{
                 criteria.remove("valid");
             }
+
+            queryCriteria.setOnlyCount(false);
             queryCriteria.setCriteria(criteria);
             List<ObjectInfoDefine> staticInfoCode = DigitalObjectInfoFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
+
             criteria.remove("category");
 
-            //动态信息点
+            //动态信息点9
             JSONObject category = new JSONObject();
             category.put("$ne","STATIC");
             criteria.putPOJO("category", category);
             queryCriteria.setCriteria(criteria);
             List<ObjectInfoDefine> dynamicInfoCode = DigitalObjectInfoFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
+
+            // 2.2 根据定义获取信息点
             //4 计算已采集的和需要采集的信息点占比
             //return customSqlService.systemInfoPoins()
-            Map<String, Integer> hashMap = calculate(dynamicInfoCode, staticInfoCode, admObjList, 1);
-            gatherInfoPoint.put("gatherCustomInfoPointCounts",hashMap.get("customInfoPoint"));
-            gatherInfoPoint.put("gatherDynamicInfoPointCounts",hashMap.get("dynamicInfoPoint"));
-            gatherInfoPoint.put("gatherStaticInfoPointCounts",hashMap.get("staticInfoPoint"));
-            gatherInfoPoint.put("gatherInfoPointCounts", controlInfoCounts);
+            List admObjList = admResponse.getContent();
+            hashMap = calculate(dynamicInfoCode, staticInfoCode, admObjList, 1, hashMap);
+            long totalPage = admResponse.getTotal() / admResponse.getPageSize();
+            if(totalPage > 0l){
+                for (long page = admResponse.getPageSize() +1; page <= totalPage; page++){
+                    hashMap = calculate(dynamicInfoCode, staticInfoCode, admObjList, 1, hashMap);
+                }
+            }
+            if(CollUtil.isNotEmpty(hashMap)){
+                gatherInfoPoint.put("gatherCustomInfoPointCounts",hashMap.get("customInfoPoint"));
+                gatherInfoPoint.put("gatherDynamicInfoPointCounts",hashMap.get("dynamicInfoPoint"));
+                gatherInfoPoint.put("gatherStaticInfoPointCounts",hashMap.get("staticInfoPoint"));
+            }
         }
+        gatherInfoPoint.put("gatherInfoPointCounts", controlInfoCounts);
         return gatherInfoPoint;
     }
 
 
+
     /**
      * 处理设备属性文件 -> 设备的信息点
      * @param equip