Browse Source

查询已有的对象类型

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

+ 22 - 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,27 @@ 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);
+        //查询对象类型
+        List<String> classCodes = service.queryObjectClassCode(criteria);
+        //设置返回结果
+        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

@@ -5,8 +5,10 @@ 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 +151,12 @@ public interface IObjectDigitalService extends IService<ObjectDigital> {
      */
     CommonResult<List<ObjectDigital>> batchUpdateClassCodesByIds(List<ObjectDigital> objectDigitals);
 
+    /**
+     * 查询已有的对象类型
+     * @param criteria
+     * @return
+     * @throws Exception
+     */
+    List<String> queryObjectClassCode(@RequestBody QueryCriteria criteria) throws Exception;
+
 }

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

@@ -10,11 +10,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.constant.DigitalMessageConstant;
 import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.basic.model.CodeTableTypeEnum;
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.codetable.client.CodeTableDataFacade;
 import com.persagy.dmp.codetable.entity.CodeTableData;
 import com.persagy.dmp.common.constant.CommonConstant;
@@ -456,6 +458,34 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
         return ResultHelper.multi(new ArrayList<>());
     }
 
+    /**
+     * 查询已有的对象类型
+     * @param queryCriteria
+     * @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);
+    }
+
 
     /***
      * Description: 通用处理分页数据方法

+ 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>