Bläddra i källkod

fix bug:兼容旧数据,根据楼层id查询空间数据查询不到的问题

lijie 3 år sedan
förälder
incheckning
b9b4b39b3a

+ 1 - 5
src/main/java/com/persagy/proxy/object/controller/AdmFloorController.java

@@ -249,11 +249,7 @@ public class AdmFloorController {
     @PostMapping("/query")
     public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
         request.setName(AdmFloor.OBJ_TYPE);
-        AdmResponse rs = service.doQuery(AdmContextUtil.toDmpContext(), request, AdmFloor.class);
-        List<AdmFloor> vos = (List<AdmFloor>) rs.getContent();
-        service.ensureSpecialValues(AdmContextUtil.toDmpContext(), vos, AdmFloorServiceImpl.QUERY);
-        rs.setContent(vos);
-        return rs;
+        return service.query(request);
     }
 
 

+ 3 - 2
src/main/java/com/persagy/proxy/object/controller/AdmSpaceController.java

@@ -60,9 +60,10 @@ public class AdmSpaceController {
      */
     @PostMapping("/count")
     public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
-        request.setName("space");
+        request.setName(AdmSpace.OBJ_TYPE);
         request.setOnlyCount(true);
-        return service.doQuery( AdmContextUtil.toDmpContext(), request, AdmSpace.class);
+        //return service.doQuery( AdmContextUtil.toDmpContext(), request, AdmSpace.class);
+        return service.query(request);
     }
     /**
      * 创建

+ 10 - 0
src/main/java/com/persagy/proxy/object/service/IAdmSpaceService.java

@@ -2,6 +2,7 @@ package com.persagy.proxy.object.service;
 
 import com.alibaba.fastjson.JSONObject;
 import com.persagy.proxy.adm.request.AdmDCSQueryRequest;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.service.IAdmBaseService;
 import com.persagy.proxy.object.model.AdmSpace;
 import com.persagy.proxy.adm.request.AdmResponse;
@@ -91,4 +92,13 @@ public interface IAdmSpaceService extends IAdmBaseService<AdmSpace> {
      * Update By lijie 2021/10/28 17:56
      */
     AdmResponse queryMultiBuildingOrFloorSpaces(HttpServletRequest request);
+    /***
+     * Description: 根据查询条件查询空间统计数据
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/10/28 21:07
+     * Update By lijie 2021/10/28 21:07
+     */
+    AdmResponse query(AdmQueryCriteria request);
 }

+ 45 - 4
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -191,8 +191,7 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
             request.setRelationTo(relationTo);
         }else if(StrUtil.isEmpty(request.getBuildingId()) && StrUtil.isEmpty(request.getFloorId())){
         }
-
-        AdmResponse response = doQuery(AdmContextUtil.toDmpContext(), request, AdmSpace.class);
+        AdmResponse response = query(request);
         //空间需要补充分类名称属性
         ensureSpecialValues(context, (List<AdmSpace>) response.getContent());
         return response;
@@ -238,7 +237,7 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
         AdmQueryCriteria request = new AdmQueryCriteria();
         request.setName(AdmSpace.OBJ_TYPE);
         request.resetRelationCond(false, "ArchSubset", "Sh2Sp", spaceType, shaftId, true);
-        AdmResponse rs = doQuery(context, request, AdmSpace.class);
+        AdmResponse rs = query(request);
         return (List<AdmSpace>) rs.getContent();
     }
 
@@ -247,7 +246,7 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
         AdmQueryCriteria request = new AdmQueryCriteria();
         request.setName(AdmSpace.OBJ_TYPE);
         request.resetRelationCond(false, "ArchSubset", "Bd2Sp", spaceType, buildingId, true);
-        AdmResponse rs = doQuery(context, request, AdmSpace.class);
+        AdmResponse rs = query(request);
         return (List<AdmSpace>) rs.getContent();
     }
 
@@ -329,6 +328,48 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
         spaceCriteria.setCascade(CollUtil.newArrayList(floorCriteria));
         return super.doQuery(AdmContextUtil.toDmpContext(), spaceCriteria, AdmSpace.class);
     }
+    /***
+     * Description: 根据查询条件查询空间统计数据
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmResponse
+     * @author : lijie
+     * @date :2021/10/28 21:07
+     * Update By lijie 2021/10/28 21:07
+     */
+    @Override
+    public AdmResponse query(AdmQueryCriteria request) {
+        InstanceUrlParam context = AdmContextUtil.toDmpContext();
+        AdmResponse response = super.doQuery(AdmContextUtil.toDmpContext(), request, AdmSpace.class);
+        // 系统需要补充分类名称属性
+        ensureSpecialValues(context, (List<AdmSpace>) response.getContent());
+        return response;
+    }
+
+    /***
+     * Description: 子类重写,以便处理带buildingId
+     * @param dmpRequest : 中台查询参数
+     * @return : void
+     * @author : lijie
+     * @date :2021/10/28 20:25
+     * Update By lijie 2021/10/28 20:25
+     */
+    @Override
+    protected void processDmpCriteria(QueryCriteria dmpRequest) {
+        ObjectNode criteria = dmpRequest.getCriteria();
+        if (null==criteria){
+            return;
+        }
+        if (criteria.has("floorId")){
+            // 有建筑id过滤
+            ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+            ObjectNode relationTo = objectMapper.createObjectNode();
+            relationTo.put("graphCode", GraphCodeEnum.ArchSubset.name());
+            relationTo.put("relCode", RelCodeEnum.Fl2Sp.name());
+            relationTo.set("objFrom",criteria.get("floorId"));
+            criteria.set("relationTo",relationTo);
+            criteria.remove("floorId");
+        }
+    }
 
     /***
      * Description: 获得多建筑楼层下的空间的查询条件

+ 1 - 0
src/main/java/com/persagy/proxy/report/controller/AdmEquipFloorController.java

@@ -30,6 +30,7 @@ public class AdmEquipFloorController {
      */
     @PostMapping("/query")
     public AdmResponse query(@RequestBody AdmQueryCriteria criteria) {
+        criteria.setName(AdmFloor.OBJ_TYPE);
         return service.query(criteria);
     }
 }

+ 2 - 2
src/main/java/com/persagy/proxy/report/controller/AdmSpaceInfoController.java

@@ -156,11 +156,11 @@ public class AdmSpaceInfoController {
 		StringBuilder sb = new StringBuilder();
 		// 补充filter条件
 		if(StrUtil.isNotBlank(request.getFilters())) {
-			sb.append(request.getFilters() + ";");
+			sb.append(request.getFilters()).append(";");
 		}
 		// 补充楼层条件
 		if(StrUtil.isNotBlank(request.getFloorId())) {
-			sb.append("floorId = '" + request.getFloorId()+"';");
+			sb.append("floorId = '").append(request.getFloorId()).append("';");
 		}
 		if(sb.length() > 0) {
 			request.setFilters(sb.substring(0, sb.length() - 1));