浏览代码

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

# Conflicts:
#	src/main/java/com/persagy/proxy/object/service/IAdmEquipmentService.java
lijie 3 年之前
父节点
当前提交
ff4950c57d

+ 63 - 7
src/main/java/com/persagy/proxy/dictionary/controller/AdmLabslController.java

@@ -1,13 +1,18 @@
 package com.persagy.proxy.dictionary.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.object.model.AdmEquipment;
 import com.persagy.proxy.object.model.AdmObjectInfo;
 import com.persagy.proxy.dictionary.model.AdmObjectType;
 import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.object.service.IAdmEquipmentService;
 import com.persagy.proxy.report.service.IAdmLabslService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -16,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.ws.rs.QueryParam;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -36,7 +42,10 @@ public class AdmLabslController {
     private IAdmLabslService service;
 
     @Value("${middleware.group.code}")
-    private String groupCode;
+    private String groupCode ="XG";
+
+    @Autowired
+    private IAdmEquipmentService iAdmEquipmentService;
 
     /**
      * 查询项目下的设备类型
@@ -46,6 +55,9 @@ public class AdmLabslController {
     @PostMapping("/category")
     public AdmResponse queryCategory() throws Exception {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
+        if(StringUtils.isEmpty(context.getGroupCode())){
+            context.setGroupCode(groupCode);
+        }
         return service.queryCategory(context, AdmObjectInfo.class);
     }
 
@@ -58,6 +70,9 @@ public class AdmLabslController {
     @PostMapping("/zone/type")
     public AdmResponse queryZoneType() throws Exception {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
+        if(StringUtils.isEmpty(context.getGroupCode())){
+            context.setGroupCode(groupCode);
+        }
         return service.queryZoneType(context, AdmObjectInfo.class);
     }
 
@@ -69,21 +84,59 @@ public class AdmLabslController {
     @PostMapping("/building/floor")
     public AdmResponse queryBuildFloor(@QueryParam("projectId") String projectId) throws Exception {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
+        if(StringUtils.isEmpty(context.getGroupCode())){
+            context.setGroupCode(groupCode);
+        }
         return service.queryBuildFloor(context, AdmObjectInfo.class);
     }
 
 
+  /*  *//**
+     * 查询设备包含设备类型
+     * @return
+     * @throws Exception
+     *//*
+    @PostMapping("/query/equip")
+    public AdmResponse queryEquipType(@QueryParam("projectId") AdmQueryCriteria request) throws Exception {
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
+        return iAdmEquipmentService.doQuery(context, AdmObjectInfo.class);
+    }*/
+
+
     /**
      * 查询设备包含设备类型
      * @return
      * @throws Exception
      */
     @PostMapping("/query/equip")
-    public AdmResponse queryEquipType(@QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse queryEquipType(@RequestBody AdmQueryCriteria request) throws Exception {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
-        return service.queryBuildFloor(context, AdmObjectInfo.class);
-    }
+        if(StringUtils.isEmpty(context.getGroupCode())){
+            context.setGroupCode(groupCode);
+        }
+        // 组装上下文条件
+        request.setName(AdmEquipment.OBJ_TYPE);
+        //过滤条件处理
+        String filters = request.getFilters();
 
+        StringBuilder newFilters = new StringBuilder();
+        if(StringUtils.isNotEmpty(filters)){
+            String[] filter = filters.split(";");
+            for(int i =0 ;i< filter.length;i++){
+                if(filter[i].contains("not")){
+                    String[] param = filter[i].split(" ");
+                    filter[i] = StrUtil.format("{} $notcontains {}",param[1],param[3]);
+                }
+                newFilters.append(filter[i]);
+                if(i != filter.length -1){
+                    newFilters.append(" ; ");
+                }
+            }
+            request.setFilters(newFilters.toString());
+        }
+
+        return iAdmEquipmentService.doQuery(context, request, AdmEquipment.class);
+    }
 
     /**
      * 根据设备id统计设备所属的专业
@@ -94,12 +147,15 @@ public class AdmLabslController {
     public AdmResponse queryMajorCategory(@QueryParam("projectId") String projectId,
                                           @RequestBody List<String> ids) throws Exception {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
+        if(StringUtils.isEmpty(context.getGroupCode())){
+            context.setGroupCode(groupCode);
+        }
         if(CollUtil.isEmpty(ids)){
-            return AdmResponse.failure("项目下没有设备类型");
+            return AdmResponse.success(new ArrayList<>());
         }
-        List<String> newIds = ids.stream().filter(id->"fisnull".equals(id)).collect(Collectors.toList());
+        List<String> newIds = ids.stream().filter(id->!"fisnull".equals(id)).collect(Collectors.toList());
         if(CollUtil.isEmpty(newIds)){
-            return AdmResponse.failure("项目下没有设备类型");
+            return AdmResponse.success(new ArrayList<>());
         }
         return service.queryMajorCategory(context, newIds , AdmObjectType.class);
     }

+ 8 - 10
src/main/java/com/persagy/proxy/object/controller/AdmShaftController.java

@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -20,15 +19,15 @@ import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
 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.object.service.IAdmBuildingService;
 import com.persagy.proxy.adm.service.IAdmRelationService;
-import com.persagy.proxy.object.service.IAdmShaftService;
-import com.persagy.proxy.object.service.IAdmSpaceService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
 import com.persagy.proxy.common.entity.RelationDTO;
 import com.persagy.proxy.object.model.*;
+import com.persagy.proxy.object.service.IAdmBuildingService;
+import com.persagy.proxy.object.service.IAdmShaftService;
+import com.persagy.proxy.object.service.IAdmSpaceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -53,8 +52,6 @@ public class AdmShaftController {
     private IAdmBuildingService buildingService;
     @Autowired
     private IAdmSpaceService spaceService;
-    @Autowired
-    private ObjectMapper objectMapper;
 
     /**
      * 统计
@@ -353,10 +350,11 @@ public class AdmShaftController {
 
             List<AdmSpace> vos = JSONUtil.toList(spaceList.toString(), AdmSpace.class);
             Map<String, AdmSpace> admSpaceMap = CollUtil.fieldValueMap(vos, "buildingId");
-            StringBuilder filter = new StringBuilder(" id in ['");
-            admSpaceMap.keySet().stream().forEach(spaceId -> filter.append(spaceId).append("','"));
-            String filters = StrUtil.sub(filter.toString(), 0,-2)+"]";
-            queryCriteriaBd.setFilters(filters);
+            ObjectNode relationFrom = JsonNodeFactory.instance.objectNode();
+            relationFrom.put("relCode", "Bd2Sp");
+            relationFrom.put("graphCode","ArchSubset");
+            ArrayNode arrayNode = relationFrom.putObject("objTo").putArray("$in");
+            admSpaceMap.keySet().stream().forEach(spaceId -> arrayNode.add(spaceId));
             AdmResponse response =  buildingService.doQuery(AdmContextUtil.toDmpContext(), queryCriteriaBd, AdmBuilding.class);
             return response;
         }else{

+ 0 - 2
src/main/java/com/persagy/proxy/object/controller/AdmSystemController.java

@@ -99,7 +99,6 @@ public class AdmSystemController {
         List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
 
         Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(vos, "classCode");
-
         QueryCriteria defineCriteria = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         ArrayNode array = criteria.putObject("code").putArray("$in");
@@ -124,7 +123,6 @@ public class AdmSystemController {
                 List<AdmSystem> admSystems = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, CollUtil.newArrayList(admSystem));
                 //添加关系
                 String systemId = admSystems.get(0).getId();
-
                 admSystem.getBuildingFloorInfoList().forEach(info -> {
                     String floorId = info.get("FloorID") == null ? null : info.get("FloorID").textValue();
                     String buildID = info.get("BuildID") == null ? null : info.get("BuildID").textValue();

+ 3 - 1
src/main/java/com/persagy/proxy/object/service/IAdmEquipmentService.java

@@ -1,10 +1,11 @@
 package com.persagy.proxy.object.service;
 
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmBaseService;
-import com.persagy.proxy.object.model.AdmEquipment;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.object.model.AdmEquipment;
 
 import java.util.List;
 
@@ -49,6 +50,7 @@ public interface IAdmEquipmentService extends IAdmBaseService<AdmEquipment> {
      * @param vos
      */
     void ensureSpecialValues(InstanceUrlParam context, List<AdmEquipment> vos);
+    void processDmpCriteria(QueryCriteria dmpRequest);
     /***
      * Description: 将原来重写的doQuery方法改为该方法,用于使用钩子方法调整查询参数
      * @param admQueryCriteria : 请求参数

+ 38 - 1
src/main/java/com/persagy/proxy/object/service/impl/AdmEquipmentServiceImpl.java

@@ -22,6 +22,7 @@ import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
+import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
 import com.persagy.proxy.common.client.DmpRwdClient;
 import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -113,7 +114,9 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
 
     @Override
     public AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmEquipment> clazz) {
-        AdmResponse response = super.doQuery(context, request, clazz);
+        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
+        processDmpCriteria(queryCriteria);
+        AdmResponse response = super.doQuery(context, queryCriteria, clazz);
         // 系统需要补充分类名称属性
         ensureSpecialValues(context, (List<AdmEquipment>) response.getContent());
         return response;
@@ -190,6 +193,40 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
         }
     }
 
+    /**
+     * 设备按照楼层id建筑id查询
+     * @param dmpRequest : 中台查询参数
+     */
+    @Override
+    public void processDmpCriteria(QueryCriteria dmpRequest) {
+        ObjectNode criteria = dmpRequest.getCriteria();
+        if (null==criteria){
+            return;
+        }
+        if (criteria.has("floorId") && criteria.has("buildingId")){
+            // 有建筑id过滤
+            ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+            ObjectNode relationFrom = objectMapper.createObjectNode();
+            relationFrom.put("graphCode", GraphCodeEnum.MechInArch.name());
+            relationFrom.put("relCode", RelCodeEnum.Eq2Fl.name());
+            relationFrom.set("objTo",criteria.get("floorId"));
+            criteria.set("relationFrom",relationFrom);
+            criteria.remove("floorId");
+            criteria.remove("buildingId");
+            return;
+        }
+        if (criteria.has("buildingId")){
+            // 有建筑id过滤
+            ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+            ObjectNode relationFrom = objectMapper.createObjectNode();
+            relationFrom.put("graphCode", GraphCodeEnum.MechInArch.name());
+            relationFrom.put("relCode", RelCodeEnum.Eq2Bd.name());
+            relationFrom.set("objTo",criteria.get("buildingId"));
+            criteria.set("relationFrom",relationFrom);
+            criteria.remove("buildingId");
+        }
+    }
+
     private DmpResult<List<ObjRelationDTO>> queryRelation(InstanceUrlParam context, Map<String, AdmEquipment> voMap){
         QueryCriteria dmpRequest = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();

+ 5 - 2
src/main/java/com/persagy/proxy/report/service/impl/AdmLabslServiceImpl.java

@@ -181,7 +181,9 @@ public class AdmLabslServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> im
         request.setFilters("id in ["+filters+"]");
         AdmResponse equipResponse = equipmentService.query(request);
         if(CollUtil.isEmpty(equipResponse.getContent())){
-            throw new Exception("设备不存在");
+            log.info("设备不存在");
+            return AdmResponse.success(new ArrayList<>());
+
         }
         List<AdmEquipment> equipments = (List<AdmEquipment>)equipResponse.getContent();
         Set<String> classCodes = equipments.stream().map(k -> k.getClassCode()).collect(Collectors.toSet());
@@ -195,7 +197,8 @@ public class AdmLabslServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> im
         dictCriteria.setCriteria(node);
         AdmResponse dictResponse = doQueryObjectType(context, dictCriteria, clazz);
         if(CollUtil.isEmpty(dictResponse.getContent())){
-            throw new Exception("项目下没有设备类型");
+            log.info("项目下没有设备类型");
+            return AdmResponse.success(new ArrayList<>());
         }
 
         //获取设备类对应的专业编码