Browse Source

解决元空间查询不到问题

yucheng 3 năm trước cách đây
mục cha
commit
30168941a5

+ 17 - 19
src/main/java/com/persagy/proxy/object/controller/AdmISpaceController.java

@@ -109,27 +109,25 @@ public class AdmISpaceController {
      */
     @PostMapping("/query")
     public AdmResponse query(@RequestBody JSONObject param) throws Exception {
-        AdmQueryCriteria admQueryCriteriaFl = new AdmQueryCriteria();
-        admQueryCriteriaFl.setName(AdmFloor.OBJ_TYPE);
-
-        if (StrUtil.isNotBlank(param.getString("floorId"))){
-            String filters = " id = '"+param.getString("floorId")+"' ";
-            admQueryCriteriaFl.addFilters(filters);
-        }
-        AdmResponse response = floorService.query(admQueryCriteriaFl);
-        AdmResponse admResponse = new AdmResponse();
-        if(CollUtil.isNotEmpty(response.getContent())){
-            AdmFloor admFloor = (AdmFloor) response.getContent().get(0);
-            if(admFloor!= null && StrUtil.isNotEmpty(admFloor.getBimIdPre())){
-                AdmQueryCriteria request = JsonHelper.toSingleEntity(param, AdmQueryCriteria.class);
-                request.setName(AdmISpace.OBJ_TYPE);
-                request.setFilters(" bimId startwith '"+admFloor.getBimIdPre()+"';");
-                admResponse = service.doQuery(AdmContextUtil.toDmpContext(), request, AdmISpace.class);
+        AdmQueryCriteria request = JsonHelper.toSingleEntity(param, AdmQueryCriteria.class);
+        request.setName(AdmISpace.OBJ_TYPE);
+        // 如果楼层ID不为空
+        String floorId = param.getString("floorId");
+        if (StrUtil.isNotBlank(floorId)){
+            AdmQueryCriteria floorCriteria = new AdmQueryCriteria();
+            floorCriteria.setName(AdmFloor.OBJ_TYPE);
+            floorCriteria.addFilters(" id = '" + floorId + "' ");
+            AdmResponse floorRes = floorService.query(floorCriteria);
+            if(CollUtil.isNotEmpty(floorRes.getContent())){
+                // 得到楼层信息,用bimId查询
+                AdmFloor floor = (AdmFloor) floorRes.getContent().get(0);
+                if(floor!= null && StrUtil.isNotEmpty(floor.getBimIdPre())){
+                    request.setFilters(" bimId startwith '" + floor.getBimIdPre() + "' ");
+                }
             }
-        }else{
-            admResponse = AdmResponse.success();
         }
-        admResponse.setMessage(param.getString("floorId"));
+        AdmResponse admResponse = service.doQuery(AdmContextUtil.toDmpContext(), request, AdmISpace.class);
+        admResponse.setMessage(floorId);
         return admResponse;
     }