Browse Source

根据关系查询对象中存在的对象类型-bug修复

linhuili 3 năm trước cách đây
mục cha
commit
8b1705e251

+ 9 - 2
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/controller/ObjectDigitalController.java

@@ -431,8 +431,15 @@ public class ObjectDigitalController{
         }
         //基础参数校验
         ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE);
-        //查询对象类型
-        List<String> classCodes = service.queryObjectClassCode(criteria);
+        QueryWrapper<ObjectDigital> wrapper = new QueryWrapper<>();
+        // 添加所属项目条件
+        String projectId = AppContext.getContext().getProjectId();
+        wrapper.eq(StrUtil.isNotBlank(projectId), StrUtil.toUnderlineCase(AppContext.PROJECT_ID), projectId);
+        // 处理扩展条件
+        ObjectDigitalCriteriaHelper.presetDigitalCriteria(criteria);
+        // 转换查询条件
+        QueryCriteriaHelper.toWrapper(wrapper, criteria, ObjectDigital.class);
+        List<String> classCodes = service.queryObjectClassCode(wrapper);
         //设置返回结果
         CommonResult<List<String>> result = CommonResult.success(classCodes);
         result.setCount(classCodes == null ? 0 : Long.valueOf(classCodes.size()));

+ 5 - 5
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/IObjectDigitalService.java

@@ -1,6 +1,7 @@
 package com.persagy.dmp.rwd.digital.service;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -152,11 +153,10 @@ public interface IObjectDigitalService extends IService<ObjectDigital> {
     CommonResult<List<ObjectDigital>> batchUpdateClassCodesByIds(List<ObjectDigital> objectDigitals);
 
     /**
-     * 查询已有的对象类型
-     * @param criteria
-     * @return
-     * @throws Exception
+     * 按条件查询
+     * @param queryWrapper 查询条件
+     * @return 列表
      */
-    List<String> queryObjectClassCode(@RequestBody QueryCriteria criteria) throws Exception;
+    List<String> queryObjectClassCode(QueryWrapper<ObjectDigital> queryWrapper);
 
 }

+ 11 - 22
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/impl/ObjectDigitalServiceImpl.java

@@ -42,6 +42,7 @@ import com.persagy.dmp.rwd.digital.service.IObjectDigitalService;
 import com.persagy.dmp.rwd.parser.service.InfoDataFactory;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -458,32 +459,20 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
         return ResultHelper.multi(new ArrayList<>());
     }
 
+
     /**
-     * 查询已有的对象类型
-     * @param queryCriteria
+     * 查询对象类型
+     * @param queryWrapper 查询条件
      * @return
-     * @throws Exception
      */
     @Override
-    public List<String> queryObjectClassCode(QueryCriteria queryCriteria) throws Exception {
-        ObjectNode criteria = queryCriteria.getCriteria();
-        //查询存在的对象类型
-        RequestData requestData = new RequestData();
-        requestData.setGroupCode(AppContext.getContext().getGroupCode());
-        requestData.setProjectId(AppContext.getContext().getProjectId());
-        JsonNode buildingId = criteria.get("buildingId");
-        if(buildingId != null){
-            requestData.setBuildingId(buildingId.textValue());
-        }
-        JsonNode floorId = criteria.get("floorId");
-        if(floorId != null){
-            requestData.setFloorId(floorId.textValue());
-        }
-        JsonNode objType = criteria.get("objType");
-        if(objType != null){
-            requestData.setObjType(objType.textValue());
-        }
-        return objectDigitalMapper.queryObjectClassCode(requestData);
+    public List<String> queryObjectClassCode(QueryWrapper<ObjectDigital> queryWrapper) {
+        queryWrapper.select("distinct class_code");
+        List<ObjectDigital> objectDigitals = objectDigitalMapper.selectList(queryWrapper);
+        if(CollUtil.isEmpty(objectDigitals)){
+            return new ArrayList<>();
+        }
+        return objectDigitals.stream().map(item -> item.getClassCode()).collect(Collectors.toList());
     }