Sfoglia il codice sorgente

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

# Conflicts:
#	dmp-business/dmp-rwd/src/main/resources/mapper/DefineInfoMapper.xml
lijie 3 anni fa
parent
commit
463c994c13

+ 29 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/controller/ObjectDigitalController.java

@@ -27,6 +27,7 @@ import com.persagy.dmp.common.utils.ParamCheckUtil;
 import com.persagy.dmp.common.utils.ResultHelper;
 import com.persagy.dmp.digital.entity.ObjectDigital;
 import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.dmp.mybatis.utils.ConditionUtil;
 import com.persagy.dmp.rwd.basic.constant.DigitalObjectType;
 import com.persagy.dmp.rwd.basic.constant.DigitalRelCode;
 import com.persagy.dmp.rwd.digital.service.IObjectDigitalService;
@@ -416,6 +417,34 @@ public class ObjectDigitalController{
         return service.queryObjectListByGraphCodeAndRelCode(requestData);
     }
 
+    /**
+     * 查询已有的对象类型
+     * @param criteria
+     * @return
+     * @throws IOException
+     */
+    @PostMapping("/queryObjectClassCode")
+    @Deprecated
+    public CommonResult<List<String>> queryObjectClassCode(@RequestBody QueryCriteria criteria) throws Exception {
+        if(criteria == null) {
+            throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
+        }
+        //基础参数校验
+        ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE);
+        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()));
+        return result;
+    }
 
     /**
      * 创建默认条件

+ 7 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/dao/ObjectDigitalMapper.java

@@ -175,4 +175,11 @@ public interface ObjectDigitalMapper extends BaseMapper<ObjectDigital> {
      * Update By lijie 2021/10/13 14:18
      */
     List<ObjectDigital> queryModelElements(String groupCode, String projectId, String modelId);
+
+    /**
+     * 查询对象中已存在的设备类型
+     * @param requestData
+     * @return
+     */
+    List<String> queryObjectClassCode(@Param("param") RequestData requestData);
 }

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

@@ -1,12 +1,15 @@
 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;
 import com.persagy.dmp.basic.dto.RequestData;
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.digital.entity.ObjectDigital;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import java.io.IOException;
 import java.util.List;
@@ -149,4 +152,11 @@ public interface IObjectDigitalService extends IService<ObjectDigital> {
      */
     CommonResult<List<ObjectDigital>> batchUpdateClassCodesByIds(List<ObjectDigital> objectDigitals);
 
+    /**
+     * 按条件查询
+     * @param queryWrapper 查询条件
+     * @return 列表
+     */
+    List<String> queryObjectClassCode(QueryWrapper<ObjectDigital> queryWrapper);
+
 }

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

@@ -457,6 +457,22 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
     }
 
 
+    /**
+     * 查询对象类型
+     * @param queryWrapper 查询条件
+     * @return
+     */
+    @Override
+    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());
+    }
+
+
     /***
      * Description: 通用处理分页数据方法
      * @param dataResult : 分页数据
@@ -706,7 +722,13 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
                     continue;
                 }
                 // 校验信息点值
-                InfoDataFactory.parse(infoMap.get(infoCode), infos.get(infoCode));
+                try {
+                    InfoDataFactory.parse(infoMap.get(infoCode), infos.get(infoCode));
+                } catch (BusinessException e) {
+                    // 校验不通过的移除
+                    infoKeys.remove();;
+                    continue;
+                }
             }
         }
         // 只保留能找到对象类型的

+ 2 - 2
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/parser/service/impl/EnumInfoParser.java

@@ -33,8 +33,8 @@ public class EnumInfoParser extends AbstractInfoDataParser {
         // 数据源定义信息
         List<EnumVO> dataSource = formatListValue(result.getInfoDefine().getDataSource(), EnumVO.class);
         Set<String> codeSet = new HashSet<>();
-        for(EnumVO enumVO:dataSource) {
-            codeSet.add(enumVO.getCode());
+        for(int i = 0,j = CollUtil.size(dataSource);i < j;i++) {
+            codeSet.add(dataSource.get(i).getCode());
         }
         // 复数
         if(result.isMulti()) {

+ 2 - 2
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/parser/service/impl/MenumInfoParser.java

@@ -34,8 +34,8 @@ public class MenumInfoParser extends AbstractInfoDataParser {
         // 数据源定义信息
         List<EnumVO> dataSource = formatListValue(result.getInfoDefine().getDataSource(), EnumVO.class);
         Set<String> codeSet = new HashSet<>();
-        for(EnumVO enumVO:dataSource) {
-            codeSet.add(enumVO.getCode());
+        for(int i = 0,j = CollUtil.size(dataSource);i < j;i++) {
+            codeSet.add(dataSource.get(i).getCode());
         }
         // 复数
         if(result.isMulti()) {

File diff suppressed because it is too large
+ 985 - 2475
dmp-business/dmp-rwd/src/main/resources/db/init/data.sql


+ 20 - 0
dmp-business/dmp-rwd/src/main/resources/mapper/ObjectDigitalMapper.xml

@@ -693,5 +693,25 @@
         </if>
     </select>
 
+    <select id="queryObjectClassCode" resultType="java.lang.String">
+        SELECT DISTINCT class_code FROM dt_object AS dto
+        WHERE dto.valid = TRUE
+        <if test="null!=param.projectId and param.projectId.length>0">
+            AND dto.project_id = #{param.projectId}
+        </if>
+        <if test="null!=param.groupCode and param.groupCode.length>0">
+            AND dto.group_code = #{param.groupCode}
+        </if>
+        <if test="null!=param.buildingId and param.buildingId.length>0">
+            AND JSON_UNQUOTE(JSON_EXTRACT(dto.infos, '$.buildingId')) = #{param.buildingId}
+        </if>
+        <if test="null!=param.floorId and param.floorId.length>0">
+            AND JSON_UNQUOTE(JSON_EXTRACT(dto.infos, '$.floorId')) = #{param.floorId}
+        </if>
+        <if test="null!=param.objType and param.objType.length>0">
+            AND dto.obj_type = #{param.objType}
+        </if>
+    </select>
+
 
 </mapper>