|
@@ -1,11 +1,36 @@
|
|
package com.persagy.dmp.middleware.service.impl;
|
|
package com.persagy.dmp.middleware.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
+import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
|
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
|
+import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
|
+import com.persagy.dmp.common.utils.JsonHelper;
|
|
|
|
+import com.persagy.dmp.middleware.client.DmpRwdClient;
|
|
|
|
+import com.persagy.dmp.middleware.constant.CommonConsant;
|
|
|
|
+import com.persagy.dmp.middleware.constant.enums.RelationTypeEnum;
|
|
|
|
+import com.persagy.dmp.middleware.dao.DefineTypeRelMapper;
|
|
import com.persagy.dmp.middleware.entity.dto.CommonRequestDTO;
|
|
import com.persagy.dmp.middleware.entity.dto.CommonRequestDTO;
|
|
import com.persagy.dmp.middleware.entity.dto.InstanceUrlParam;
|
|
import com.persagy.dmp.middleware.entity.dto.InstanceUrlParam;
|
|
import com.persagy.dmp.middleware.entity.response.CommonResult;
|
|
import com.persagy.dmp.middleware.entity.response.CommonResult;
|
|
-import com.persagy.dmp.middleware.service.IEquipService;
|
|
|
|
|
|
+import com.persagy.dmp.middleware.entity.response.DmpResult;
|
|
|
|
+import com.persagy.dmp.middleware.entity.vo.DefineTypeRel;
|
|
|
|
+import com.persagy.dmp.middleware.service.IBaseService;
|
|
|
|
+import com.persagy.dmp.middleware.service.ISpaceService;
|
|
|
|
+import com.persagy.dmp.middleware.utils.EntityTransferUtil;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @ClassName ObjectInstanceServiceImpl
|
|
* @ClassName ObjectInstanceServiceImpl
|
|
* @Description: 广联达:查询空间信息
|
|
* @Description: 广联达:查询空间信息
|
|
@@ -14,7 +39,16 @@ import org.springframework.stereotype.Service;
|
|
* @Version V1.0
|
|
* @Version V1.0
|
|
**/
|
|
**/
|
|
@Service
|
|
@Service
|
|
-public class SpaceServiceImpl implements IEquipService {
|
|
|
|
|
|
+public class SpaceServiceImpl implements ISpaceService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DefineTypeRelMapper defineTypeRelMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DmpRwdClient dmpRwdClient;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBaseService baseService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询设备设施模块下的设备/阀门
|
|
* 查询设备设施模块下的设备/阀门
|
|
@@ -28,4 +62,269 @@ public class SpaceServiceImpl implements IEquipService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询万达映射表中的空间类型
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<DefineTypeRel> queryGldSpaceTypeRel(){
|
|
|
|
+ QueryWrapper<DefineTypeRel> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.eq("obj_type","space");
|
|
|
|
+ List<DefineTypeRel> defineTypeRels = defineTypeRelMapper.selectList(wrapper);
|
|
|
|
+ return defineTypeRels;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据广联达空间类型查询空间信息
|
|
|
|
+ * @param context
|
|
|
|
+ * @param defineTypeRels
|
|
|
|
+ * @param request
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<JSONObject> querySpaceByGldTypeRel(InstanceUrlParam context,List<DefineTypeRel> defineTypeRels,CommonRequestDTO request){
|
|
|
|
+ //1. 筛选出bimTypeId为空间类型的数据:bimTypeId:FireZone
|
|
|
|
+ List<DefineTypeRel> spaceTypeRels = filterSpaceType(context, defineTypeRels);
|
|
|
|
+
|
|
|
|
+ //2. 根据bimTypeId查询楼层下的空间
|
|
|
|
+ List<JSONObject> bimTypeSpace = querySpaceObjectByInfoCode(context, defineTypeRels, request, "bimTypeId");
|
|
|
|
+ //3. 数据组装:根据bimTypeId查询楼层下的空间结果
|
|
|
|
+ List<JSONObject> bimTypeSpaceResult = combineQuerySpaceResultData(defineTypeRels, bimTypeSpace, "bimTypeId");
|
|
|
|
+
|
|
|
|
+ //4. 根据空间类型查询楼层下的空间
|
|
|
|
+ List<JSONObject> classCodeSpace = querySpaceObjectByInfoCode(context, spaceTypeRels, request, "classCode");
|
|
|
|
+ //5. 数据组装:根据空间类型查询楼层下的空间结果
|
|
|
|
+ List<JSONObject> classCodeSpaceResult = combineQuerySpaceResultData(spaceTypeRels, classCodeSpace, "classCode");
|
|
|
|
+
|
|
|
|
+ //6. 数据合并:根据bimTypeId查询的空间+根据空间类型查询到的空间
|
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
|
+ if(CollUtil.isNotEmpty(bimTypeSpaceResult)){
|
|
|
|
+ result.addAll(bimTypeSpaceResult);
|
|
|
|
+ }
|
|
|
|
+ if(CollUtil.isNotEmpty(classCodeSpaceResult)){
|
|
|
|
+ result.addAll(classCodeSpaceResult);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询空间内的设备/阀门
|
|
|
|
+ * @param context
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public CommonResult relQuery(InstanceUrlParam context, CommonRequestDTO request) throws Exception{
|
|
|
|
+ //查询空间信息
|
|
|
|
+ List<JSONObject> spaceList = querySpaceInfo(context, request);
|
|
|
|
+ if(CollUtil.isEmpty(spaceList)){
|
|
|
|
+ throw new Exception("空间不存在");
|
|
|
|
+ }
|
|
|
|
+ JSONObject space = spaceList.get(0);
|
|
|
|
+
|
|
|
|
+ //获取空间的BIM构建编码
|
|
|
|
+ String bimTypeId = space.getString(CommonConsant.BIM_TYPE_ID);
|
|
|
|
+
|
|
|
|
+ JSONArray baseSpaceTypes = getDmpBaseSpaceType(context);
|
|
|
|
+ if(baseSpaceTypes.contains(space.getString(CommonConsant.CLASS_CODE))){
|
|
|
|
+ bimTypeId = space.getString(CommonConsant.CLASS_CODE);
|
|
|
|
+ }
|
|
|
|
+ //查询指定空间类型下的设备
|
|
|
|
+ List<JSONObject> content = queryEquipInSpace(context, request, bimTypeId);
|
|
|
|
+ return CommonResult.success(content);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询指定空间下的设备
|
|
|
|
+ * @param context
|
|
|
|
+ * @param request
|
|
|
|
+ * @param bimTypeId
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ private List<JSONObject> queryEquipInSpace(InstanceUrlParam context, CommonRequestDTO request,String bimTypeId) throws Exception{
|
|
|
|
+
|
|
|
|
+ //根据空间的BimTypeId构建编码获取所在系统
|
|
|
|
+ List<DefineTypeRel> spaceTypeRelList = queryGldSpaceTypeRel();
|
|
|
|
+ Map<String, List<DefineTypeRel>> spaceTypeRelMap = spaceTypeRelList.stream().collect(Collectors.groupingBy(DefineTypeRel::getBimTypeId));
|
|
|
|
+ List<DefineTypeRel> defineTypeRels = spaceTypeRelMap.get(bimTypeId);
|
|
|
|
+ if(CollUtil.isEmpty(defineTypeRels)){
|
|
|
|
+ throw new Exception("空间所属系统不存在");
|
|
|
|
+ }
|
|
|
|
+ Set<String> wdSystemCodes = defineTypeRels.stream().filter(k-> StringUtils.isNotEmpty(k.getWdSystemCode())).map(k->k.getWdSystemCode()).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ //获取万达系统类下的设备类/阀门
|
|
|
|
+ List<DefineTypeRel> equipByWdObjectType = getEquipByWdObjectType(wdSystemCodes);
|
|
|
|
+ List<JSONObject> objects = new ArrayList<>();
|
|
|
|
+ Set<String> bimTypeIds = new HashSet<>();
|
|
|
|
+ if(CollUtil.isNotEmpty(equipByWdObjectType)){
|
|
|
|
+ //查询空间下的设备/阀门
|
|
|
|
+ bimTypeIds = equipByWdObjectType.stream().filter(k-> StringUtils.isNotEmpty(k.getBimTypeId())).map(k->k.getBimTypeId()).collect(Collectors.toSet());
|
|
|
|
+ objects = queryDmpEquipInSpace(context, request, bimTypeIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //结果集封装
|
|
|
|
+ List<JSONObject> content = combineQuerySpaceResultData(equipByWdObjectType, objects, CommonConsant.BIM_TYPE_ID);
|
|
|
|
+ return objects;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 查询中台空间下的设备/阀门
|
|
|
|
+ * @param context
|
|
|
|
+ * @param request
|
|
|
|
+ * @param bimTypeIds
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<JSONObject> queryDmpEquipInSpace(InstanceUrlParam context, CommonRequestDTO request,Set<String> bimTypeIds){
|
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
|
+ ArrayNode arrayNode = criteria.withArray("bimTypeId");
|
|
|
|
+ bimTypeIds.forEach(item->arrayNode.add(item));
|
|
|
|
+
|
|
|
|
+ QueryCriteria queryCriteria = EntityTransferUtil.transDmpRelationCriteria(criteria,RelationTypeEnum.MECHINARCH_EQ2SP.getGraphCode(),
|
|
|
|
+ RelationTypeEnum.MECHINARCH_EQ2SP.getRelCode(), request.getSpaceId(), 0);
|
|
|
|
+ // 查询空间下的设备
|
|
|
|
+ CommonResult response = baseService.doQuery(context,queryCriteria ,null);
|
|
|
|
+ return (List<JSONObject>) response.getContent();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据万达对象类型查询设备/阀门信息
|
|
|
|
+ * @param wdSystemCodes
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<DefineTypeRel> getEquipByWdObjectType(Set<String> wdSystemCodes){
|
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ QueryWrapper<DefineTypeRel> wrapper = new QueryWrapper<>();
|
|
|
|
+
|
|
|
|
+ Set<String> objTypes = new HashSet<>();
|
|
|
|
+ objTypes.add("equipment");
|
|
|
|
+ objTypes.add("material");
|
|
|
|
+
|
|
|
|
+ wrapper.in("obj_type",objTypes);
|
|
|
|
+ wrapper.in("wd_system_code",wdSystemCodes);
|
|
|
|
+ List<DefineTypeRel> defineTypeRels = defineTypeRelMapper.selectList(wrapper);
|
|
|
|
+ return defineTypeRels;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 组装查询空间结果
|
|
|
|
+ * @param defineTypeRels
|
|
|
|
+ * @param spaceList
|
|
|
|
+ * @param infoCode
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<JSONObject> combineQuerySpaceResultData(List<DefineTypeRel> defineTypeRels,List<JSONObject> spaceList,String infoCode){
|
|
|
|
+ if(CollUtil.isEmpty(defineTypeRels)){
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, List<JSONObject>> spaceMap = spaceList.stream().collect(Collectors.groupingBy(k->k.getString(infoCode)));
|
|
|
|
+
|
|
|
|
+ //数据组装
|
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
|
+ for (DefineTypeRel defineTypeRel : defineTypeRels) {
|
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
|
+ data.put("bimTypeId",defineTypeRel.getBimTypeId());
|
|
|
|
+ data.put("className",defineTypeRel.getWdClassName());
|
|
|
|
+ data.put("systemCode",defineTypeRel.getWdSystemCode());
|
|
|
|
+
|
|
|
|
+ List<JSONObject> objects = new ArrayList<>();
|
|
|
|
+ if(CollUtil.isNotEmpty(spaceMap)){
|
|
|
|
+ spaceMap.get(defineTypeRel.getBimTypeId());
|
|
|
|
+ }
|
|
|
|
+ data.put("objects",objects);
|
|
|
|
+ data.put("count",objects.size());
|
|
|
|
+ result.add(data);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据信息点查询空间对象信息
|
|
|
|
+ * @param context
|
|
|
|
+ * @param defineTypeRels
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<JSONObject> querySpaceObjectByInfoCode(InstanceUrlParam context,List<DefineTypeRel> defineTypeRels,CommonRequestDTO request,String infoCode){
|
|
|
|
+ //1. 根据bimTypeId查询楼层下的空间
|
|
|
|
+ Set<String> bimTypeIdSets = defineTypeRels.stream().filter(k-> StringUtils.isNotEmpty(k.getBimTypeId())).map(k->k.getBimTypeId()).collect(Collectors.toSet());
|
|
|
|
+ ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
|
+ ArrayNode bimTypeIds = criteria.withArray(infoCode);
|
|
|
|
+ bimTypeIdSets.forEach(item->{bimTypeIds.add(item);});
|
|
|
|
+
|
|
|
|
+ QueryCriteria queryCriteria = EntityTransferUtil.transDmpRelationCriteria(criteria, RelationTypeEnum.ARCHSUBSET_FL2SP.getGraphCode(),
|
|
|
|
+ RelationTypeEnum.ARCHSUBSET_FL2SP.getRelCode(), request.getFloorId(), 1);
|
|
|
|
+ CommonResult commonResult = baseService.doQuery(context, queryCriteria, JsonNode.class);
|
|
|
|
+ return (List<JSONObject>)commonResult.getContent();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取所有的空间类型
|
|
|
|
+ * @param instanceUrlParam
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ private JSONArray getDmpBaseSpaceType(InstanceUrlParam instanceUrlParam){
|
|
|
|
+ //封装查询条件
|
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
|
+ ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
|
+ criteria.put("objType","space");
|
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
|
+
|
|
|
|
+ //查询空间类型
|
|
|
|
+ JSONObject object = null;
|
|
|
|
+ try {
|
|
|
|
+ object = JsonHelper.toJSONObject(queryCriteria);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ DmpResult<JSONArray> typeResult = dmpRwdClient.queryObjectType(instanceUrlParam, object);
|
|
|
|
+ return typeResult.getData();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 筛选出bimTypeId为空间类型的数据:bimTypeId:FireZone
|
|
|
|
+ * @param instanceUrlParam
|
|
|
|
+ * @param defineTypeRels
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<DefineTypeRel> filterSpaceType(InstanceUrlParam instanceUrlParam,List<DefineTypeRel> defineTypeRels){
|
|
|
|
+ if(CollUtil.isEmpty(defineTypeRels)){
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ List<DefineTypeRel> spaceTypeRels = new ArrayList<>();
|
|
|
|
+ //获取中台基础空间类型
|
|
|
|
+ JSONArray dmpSpaceType = getDmpBaseSpaceType(instanceUrlParam);
|
|
|
|
+ for (DefineTypeRel defineTypeRel : defineTypeRels) {
|
|
|
|
+ if(dmpSpaceType.contains(defineTypeRel.getBimTypeId())){
|
|
|
|
+ defineTypeRels.remove(defineTypeRel);
|
|
|
|
+ spaceTypeRels.add(defineTypeRel);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return spaceTypeRels;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询空间信息
|
|
|
|
+ * @param context
|
|
|
|
+ * @param requestDTO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<JSONObject> querySpaceInfo(InstanceUrlParam context, CommonRequestDTO requestDTO){
|
|
|
|
+ ObjectNode jsonNodes = JsonNodeFactory.instance.objectNode();
|
|
|
|
+ jsonNodes.put("id",requestDTO.getSpaceId());
|
|
|
|
+ QueryCriteria criteria = new QueryCriteria();
|
|
|
|
+ criteria.setCriteria(jsonNodes);
|
|
|
|
+
|
|
|
|
+ CommonResult response = baseService.doQuery(context, criteria, JSONObject.class);
|
|
|
|
+ return (List<JSONObject>)response.getContent();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|