Browse Source

Merge remote-tracking branch 'origin/develop' into develop

lijie 3 years ago
parent
commit
bab9fe93bf

+ 32 - 31
src/main/java/com/persagy/proxy/report/controller/AdmReportEquipController.java

@@ -766,9 +766,9 @@ public class AdmReportEquipController {
             codes.stream().forEach(stringObjectMap -> classCodeSet.add(stringObjectMap.get("code").toString()));
 
             //项目下所有已采集的动态信息点编码
-            List<ObjectInfoDefine> dynamicInfoPointCodes = gatherDynamicInfoCode(false, classCodeSet);
+            List<ObjectInfoDefine> dynamicInfoPointCodes = gatherDynamicInfoCode(false, classCodeSet, false);
             //项目下所有已采集静态信息点编码
-            List<ObjectInfoDefine> staticInfoPointCodes = gatherStaticInfoCode(false, classCodeSet);
+            List<ObjectInfoDefine> staticInfoPointCodes = gatherStaticInfoCode(false, classCodeSet, false);
             //项目下所有的设备  分页查询
             AdmQueryCriteria admQueryCriteriaObj = new AdmQueryCriteria();
             admQueryCriteriaObj.setPageNumber(1);
@@ -812,7 +812,7 @@ public class AdmReportEquipController {
         }
         AdmGatherInfoPoint gatherInfoPoint = new AdmGatherInfoPoint();
 
-        Integer controlInfoCounts = controlInfoCounts(AdmEquipment.OBJ_TYPE);
+        Integer controlInfoCounts = controlInfoCounts(AdmEquipment.OBJ_TYPE, false);
         // 根据objType获取定义 获取采集的设备的classcode
         Set<String> objTypes = new HashSet<>(1);
         objTypes.add(AdmEquipment.OBJ_TYPE);
@@ -822,9 +822,9 @@ public class AdmReportEquipController {
             codes.stream().forEach(stringObjectMap -> classCodeSet.add(stringObjectMap.get("code").toString()));
 
             //项目下所有已采集的动态信息点编码
-            List<ObjectInfoDefine> gatherDynamicInfoCode = gatherDynamicInfoCode(true, classCodeSet);
+            List<ObjectInfoDefine> gatherDynamicInfoCode = gatherDynamicInfoCode(true, classCodeSet, false);
             //项目下所有已采集静态信息点编码
-            List<ObjectInfoDefine> gatherStaticInfoCode =  gatherStaticInfoCode(true, classCodeSet);
+            List<ObjectInfoDefine> gatherStaticInfoCode =  gatherStaticInfoCode(true, classCodeSet, false);
 
             //项目下所有的设备  分页查询
             AdmQueryCriteria admQueryCriteriaObj =  new AdmQueryCriteria();
@@ -870,7 +870,7 @@ public class AdmReportEquipController {
     @PostMapping("/system-info-point")
     public AdmResponse systemInfoPoin() {
         AdmGatherInfoPoint gatherInfoPoint = new AdmGatherInfoPoint();
-        Integer controlInfoCounts = controlInfoCounts(AdmSpace.OBJ_TYPE);
+        Integer controlInfoCounts = controlInfoCounts(AdmSystem.OBJ_TYPE, true);
         // 根据objType获取定义 获取采集的设备的classcode
         Set<String> objTypes = new HashSet<>(1);
         objTypes.add(AdmSystem.OBJ_TYPE);
@@ -880,9 +880,9 @@ public class AdmReportEquipController {
             codes.stream().forEach(stringObjectMap -> classCodeSet.add(stringObjectMap.get("code").toString()));
 
             //项目下所有已采集的动态信息点编码
-            List<ObjectInfoDefine> gatherDynamicInfoCode = gatherDynamicInfoCode(true, classCodeSet);
+            List<ObjectInfoDefine> gatherDynamicInfoCode = gatherDynamicInfoCode(true, classCodeSet, true);
             //项目下所有已采集静态信息点编码
-            List<ObjectInfoDefine> gatherStaticInfoCode =  gatherStaticInfoCode(true, classCodeSet);
+            List<ObjectInfoDefine> gatherStaticInfoCode =  gatherStaticInfoCode(true, classCodeSet, true);
 
             //项目下所有的设备  分页查询
             AdmQueryCriteria admQueryCriteriaObj =  new AdmQueryCriteria();
@@ -890,7 +890,7 @@ public class AdmReportEquipController {
             admQueryCriteriaObj.setPageSize(500);
             admQueryCriteriaObj.setName(AdmSystem.OBJ_TYPE);
 
-            admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","infos","classCode"));
+            //admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","infos","classCode"));
             AdmResponse admResponse = systemService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteriaObj, AdmSystem.class);
 
             Map<String,Integer> hashMap = new HashMap<>();
@@ -912,11 +912,6 @@ public class AdmReportEquipController {
             gatherInfoPoint.setGatherCustomInfoPointCounts(hashMap.get("customInfoPoint"));
             gatherInfoPoint.setGatherDynamicInfoPointCounts(hashMap.get("dynamicInfoPoint"));
             gatherInfoPoint.setGatherStaticInfoPointCounts(hashMap.get("staticInfoPoint"));
-        }else{
-            gatherInfoPoint.setGatherInfoPointCounts(controlInfoCounts);
-            gatherInfoPoint.setGatherCustomInfoPointCounts(0);
-            gatherInfoPoint.setGatherDynamicInfoPointCounts(0);
-            gatherInfoPoint.setGatherStaticInfoPointCounts(0);
         }
         return AdmResponse.success(CollUtil.newArrayList(gatherInfoPoint));
     }
@@ -983,7 +978,7 @@ public class AdmReportEquipController {
 
         if(CollUtil.isNotEmpty(objList)) {
             for (int i = 0; i < objList.size(); i++) {
-                JsonNode objectNode = JsonNodeUtils.toObjectNode(objList.get(i), "infos", null);
+                JsonNode objectNode = objList.get(i);//JsonNodeUtils.toObjectNode(objList.get(i), "infos", null);
                 Iterator<ObjectInfoDefine> iterator1 = staticInfoPointCodes.iterator();
                 while (iterator1.hasNext()) {
                     ObjectInfoDefine infoDefine = iterator1.next();
@@ -1046,10 +1041,10 @@ public class AdmReportEquipController {
                     }
                 }
 
-                JsonNode objectNode1 = JsonNodeUtils.toObjectNode(objList.get(i), null, null);
-                if (!JSONUtil.isNull(objectNode1.get("infos")) && StrUtil.isNotEmpty(objectNode1.get("infos").textValue())) {
-                    Map<String, Object> dynamic = calculateInfoPoints(objectNode1.get("infos").toString(), objectNode1.get("classCode").textValue(), dynamicInfoPointCodes);
-                    Map<String, Object> staticMap = calculateInfoPoints(objectNode1.get("infos").toString(), objectNode1.get("classCode").textValue(), staticInfoPointCodes);
+                ObjectNode infos = (ObjectNode) objectNode.get("infos");
+                if (!JSONUtil.isNull(infos)) {
+                    Map<String, Object> dynamic = calculateInfoPoints(infos.toString(), objectNode.get("classCode").textValue(), dynamicInfoPointCodes);
+                    Map<String, Object> staticMap = calculateInfoPoints(infos.toString(), objectNode.get("classCode").textValue(), staticInfoPointCodes);
                     dynamicInfoPoint += Integer.parseInt(dynamic.get("counts").toString());
                     staticInfoPoint += Integer.parseInt(staticMap.get("counts").toString());
                     dynamicInfoPointCodes.remove(dynamic.get("next"));
@@ -1091,39 +1086,41 @@ public class AdmReportEquipController {
      * @param objtype
      * @return
      */
-    private Integer controlInfoCounts(String objtype){
+    private Integer controlInfoCounts(String objtype, Boolean common){
         AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
         admQueryCriteria.setOnlyCount(true);
-        admQueryCriteria.setFilters(" projectId = '0' and groupCode = '0' ");
+        if(common){
+            admQueryCriteria.setFilters(" projectId = '0' and groupCode = '0' ");
+        }
         AdmResponse response = dictService.doQueryObjectInfo(AdmContextUtil.toDmpContext(), admQueryCriteria, objtype, AdmObjectInfo.class);
         return response.getTotal().intValue();
     }
 
     /** 项目下所有已采集的动态信息点编码
-     *
+     * common flase 全部  true 通用
      */
-    private List<ObjectInfoDefine> gatherDynamicInfoCode(Boolean visible, Set<String> classCodeSet){
+    private List<ObjectInfoDefine> gatherDynamicInfoCode(Boolean visible, Set<String> classCodeSet, Boolean common){
         //获取信息点
         AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
-
-        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
-        ArrayNode arrayNode = criteria.putObject("classCode").putArray("$in");
-        classCodeSet.stream().forEach(classCode -> arrayNode.add(classCode));
         //静态信息点
         String filters = " category != 'STATIC'";
         if(visible){
             filters = filters + " and valid = '1' ";
         }
+        if(common){
+            filters = filters +" and projectId = '0' and groupCode = '0' ";
+        }
         filters = filters +" and classCode in ['"+StrUtil.join("','",classCodeSet)+"']";
         admQueryCriteria.setFilters(filters);
-        AdmResponse dynamicInfoCode = dictService.doQueryObjectInfo(AdmContextUtil.toDmpContext(), admQueryCriteria,null, AdmObjectInfo.class);
-        return (List<ObjectInfoDefine>) dynamicInfoCode.getContent();
+        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(admQueryCriteria);
+        List<ObjectInfoDefine> staticInfoCode = DigitalObjectInfoFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
+        return staticInfoCode;
     }
 
     /** 项目下所有已采集静态信息点编码
-     *
+     * common flase 全部  true 通用
      */
-    private List<ObjectInfoDefine> gatherStaticInfoCode(Boolean visible, Set<String> classCodeSet){
+    private List<ObjectInfoDefine> gatherStaticInfoCode(Boolean visible, Set<String> classCodeSet, Boolean common){
         //获取信息点
         QueryCriteria queryCriteria = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
@@ -1136,6 +1133,10 @@ public class AdmReportEquipController {
         }else{
             criteria.remove("valid");
         }
+        if(common){
+            criteria.put("projectId", "0");
+            criteria.put("groupCode", "0");
+        }
         queryCriteria.setOnlyCount(false);
         queryCriteria.setCriteria(criteria);
         List<ObjectInfoDefine> staticInfoCode = DigitalObjectInfoFacade.query(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);