|
@@ -2,20 +2,23 @@ package com.persagy.dmp.middleware.controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.persagy.dmp.common.constant.CommonConstant;
|
|
import com.persagy.dmp.common.constant.CommonConstant;
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
import com.persagy.dmp.middleware.constant.CommonConsant;
|
|
import com.persagy.dmp.middleware.constant.CommonConsant;
|
|
|
|
+import com.persagy.dmp.middleware.constant.enums.RelationTypeEnum;
|
|
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.dto.ObjRelationDTO;
|
|
import com.persagy.dmp.middleware.entity.response.CommonResult;
|
|
import com.persagy.dmp.middleware.entity.response.CommonResult;
|
|
import com.persagy.dmp.middleware.entity.vo.WdConstructDescription;
|
|
import com.persagy.dmp.middleware.entity.vo.WdConstructDescription;
|
|
|
|
+import com.persagy.dmp.middleware.service.IBaseService;
|
|
import com.persagy.dmp.middleware.service.IConstructDescriptionService;
|
|
import com.persagy.dmp.middleware.service.IConstructDescriptionService;
|
|
import com.persagy.dmp.middleware.service.IEquipService;
|
|
import com.persagy.dmp.middleware.service.IEquipService;
|
|
import com.persagy.dmp.middleware.utils.EntityTransferUtil;
|
|
import com.persagy.dmp.middleware.utils.EntityTransferUtil;
|
|
import com.persagy.dmp.middleware.utils.SortUtil;
|
|
import com.persagy.dmp.middleware.utils.SortUtil;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
-import org.checkerframework.checker.units.qual.C;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -23,9 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
import javax.ws.rs.QueryParam;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -45,6 +46,9 @@ public class EquipController {
|
|
@Autowired
|
|
@Autowired
|
|
private IConstructDescriptionService constructDescriptionService;
|
|
private IConstructDescriptionService constructDescriptionService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBaseService baseService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询/统计设备设施下的设备/阀门
|
|
* 查询/统计设备设施下的设备/阀门
|
|
* @param projectId
|
|
* @param projectId
|
|
@@ -67,6 +71,8 @@ public class EquipController {
|
|
content = EntityTransferUtil.combineData(content);
|
|
content = EntityTransferUtil.combineData(content);
|
|
//按首字母,对象数量为0放后的规则进行排序
|
|
//按首字母,对象数量为0放后的规则进行排序
|
|
content = SortUtil.sortByCharacter(content,CommonConsant.OBJ_TYPE, CommonConsant.CLASS_NAME);
|
|
content = SortUtil.sortByCharacter(content,CommonConsant.OBJ_TYPE, CommonConsant.CLASS_NAME);
|
|
|
|
+ //设置关系id
|
|
|
|
+ setRelId(context,content, request);
|
|
//设置返回值
|
|
//设置返回值
|
|
CommonResult<List<JSONObject>> response = CommonResult.success(content);
|
|
CommonResult<List<JSONObject>> response = CommonResult.success(content);
|
|
response.setCount(content == null ? 0 : Long.valueOf(content.size()));
|
|
response.setCount(content == null ? 0 : Long.valueOf(content.size()));
|
|
@@ -74,20 +80,6 @@ public class EquipController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private void setFloorId(List<JSONObject> content,CommonRequestDTO requestDTO){
|
|
|
|
- if(CollUtil.isEmpty(content)){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if(StringUtils.isNotEmpty(requestDTO.getFloorId())){
|
|
|
|
- //直接设置对象所属楼层id
|
|
|
|
- content.forEach(item->{
|
|
|
|
- item.put("floorId",requestDTO.getFloorId());
|
|
|
|
- });
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- Set<String> spaceIds = content.stream().map(k->k.getString("id")).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
/**
|
|
/**
|
|
* 查询设备设施-暖通系统-全局-3D原理图相关的设备/阀门
|
|
* 查询设备设施-暖通系统-全局-3D原理图相关的设备/阀门
|
|
* @param projectId
|
|
* @param projectId
|
|
@@ -282,4 +274,78 @@ public class EquipController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 设置关系id
|
|
|
|
+ * @param context
|
|
|
|
+ * @param content
|
|
|
|
+ * @param requestDTO
|
|
|
|
+ */
|
|
|
|
+ private void setRelId(InstanceUrlParam context,List<JSONObject> content,CommonRequestDTO requestDTO){
|
|
|
|
+ if(CollUtil.isEmpty(content)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotEmpty(requestDTO.getFloorId())){
|
|
|
|
+ //直接设置对象所属楼层id
|
|
|
|
+ content.forEach(item->{
|
|
|
|
+ item.put("floorId",requestDTO.getFloorId());
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ setEquipInFloorId(context,content,requestDTO);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置设备所在楼层id
|
|
|
|
+ * @param content
|
|
|
|
+ * @param requestDTO
|
|
|
|
+ */
|
|
|
|
+ private void setEquipInFloorId(InstanceUrlParam context,List<JSONObject> content,CommonRequestDTO requestDTO){
|
|
|
|
+ if(CollUtil.isEmpty(content)){
|
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ //获取所有的设备id
|
|
|
|
+ Set<String> equipId = getEquipId(content);
|
|
|
|
+ //获取设备所在楼层id
|
|
|
|
+ List<ObjRelationDTO> objTo = baseService.queryRelations(context, equipId, RelationTypeEnum.MECHINARCH_EQ2FL.getGraphCode(), RelationTypeEnum.MECHINARCH_EQ2FL.getRelCode(), "objTo");
|
|
|
|
+ if(CollUtil.isEmpty(objTo)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Map<String, String> map = objTo.stream().collect(Collectors.toMap(ObjRelationDTO::getObjFrom, ObjRelationDTO::getObjTo));
|
|
|
|
+ for (JSONObject object : content) {
|
|
|
|
+ JSONArray array = object.getJSONArray("objects");
|
|
|
|
+ if(CollUtil.isEmpty(array)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ array.forEach(item->{
|
|
|
|
+ JSONObject equip = (JSONObject) item;
|
|
|
|
+ equip.put("floorId",map.get(equip.getString("id")));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取设备id
|
|
|
|
+ * @param content
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private Set<String> getEquipId(List<JSONObject> content){
|
|
|
|
+ if(CollUtil.isEmpty(content)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Set<String> equipIds = new HashSet<>();
|
|
|
|
+ for (JSONObject object : content) {
|
|
|
|
+ JSONArray array = object.getJSONArray("objects");
|
|
|
|
+ if(CollUtil.isEmpty(array)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ array.forEach(item->{
|
|
|
|
+ JSONObject equip = (JSONObject) item;
|
|
|
|
+ equipIds.add(equip.getString("id"));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return equipIds;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|