|
@@ -1,8 +1,16 @@
|
|
|
package com.persagy.proxy.calculation.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.basic.dto.RequestData;
|
|
|
+import com.persagy.dmp.common.constant.ResponseCode;
|
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectClient;
|
|
@@ -25,6 +33,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
@@ -316,10 +325,12 @@ public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
|
|
|
*/
|
|
|
@Override
|
|
|
public AdmResponse query(InstanceUrlParam context, AdmManualRelCalRequest admManualRelCalRequest) {
|
|
|
+ // 1.获取关系枚举类型映射
|
|
|
Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
|
|
|
if (!relationTypeMap.containsKey(admManualRelCalRequest.getRelType())){
|
|
|
return AdmManualRelCalResponse.failure("不存在的关系类型");
|
|
|
}
|
|
|
+ // 2.构建查询参数
|
|
|
AdmRelationTypeEnum relationTypeEnum = relationTypeMap.get(admManualRelCalRequest.getRelType());
|
|
|
RequestData requestData = RequestData.builder()
|
|
|
.graphCode(relationTypeEnum.getGraphCode())
|
|
@@ -336,11 +347,64 @@ public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
|
|
|
if (StrUtil.isNotBlank(admManualRelCalRequest.getVagueTo())){
|
|
|
requestData.setSlaveContent(CollUtil.newHashSet(admManualRelCalRequest.getVagueTo()));
|
|
|
}
|
|
|
+ // 3.查询参数
|
|
|
CommonResult<List<ObjectDigital>> commonResult = digitalObjectClient
|
|
|
.queryObjectListByGraphCodeAndRelCode(context.getGroupCode(), context.getProjectId(),
|
|
|
context.getAppId(), "0", requestData);
|
|
|
+ // 4.处理参数
|
|
|
+ List<ObjectNode> result = new ArrayList<>();
|
|
|
+ ObjectMapper objectMapper = SpringUtil.getBean(ObjectMapper.class);
|
|
|
+ if (ResponseCode.A00000.getDesc().equals(commonResult.getResult())
|
|
|
+ && CollUtil.isNotEmpty(commonResult.getData())){
|
|
|
+ List<ObjectDigital> objectDigitals = commonResult.getData();
|
|
|
+ for (ObjectDigital objectDigital : objectDigitals) {
|
|
|
+ ObjectNode temp = objectMapper.createObjectNode();
|
|
|
+ createCommonResultObj(objectDigital,temp);
|
|
|
+ ArrayNode objectInfos = objectMapper.createArrayNode();
|
|
|
+ List<ObjectDigital> relObjs = objectDigital.getRelObjs();
|
|
|
+ if (CollUtil.isNotEmpty(relObjs)){
|
|
|
+ for (ObjectDigital relObj : relObjs) {
|
|
|
+ ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
+ createCommonResultObj(relObj,objectNode);
|
|
|
+ objectInfos.add(objectNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ temp.set("objectInfo",objectInfos);
|
|
|
+ result.add(temp);
|
|
|
+ }
|
|
|
+ }
|
|
|
return new AdmManualRelCalResponse(commonResult.getResult(),commonResult.getMessage(),commonResult.getCount(),
|
|
|
admManualRelCalRequest.getPageNumber(),admManualRelCalRequest.getPageSize(),
|
|
|
- commonResult.getData(),"Left");
|
|
|
+ result,"Left");
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * Description: 通用的创建结果对象
|
|
|
+ * @param objectDigital : 物理世界对象
|
|
|
+ * @param temp : 存储对象信息
|
|
|
+ * @return : void
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/30 14:57
|
|
|
+ * Update By lijie 2021/10/30 14:57
|
|
|
+ */
|
|
|
+ private void createCommonResultObj(ObjectDigital objectDigital,ObjectNode temp) {
|
|
|
+ ObjectNode infos = objectDigital.getInfos();
|
|
|
+ temp.set("bimId",infos.get("bimId"));
|
|
|
+ temp.set("buildingId",infos.get("buildingId"));
|
|
|
+ temp.set("floorId",infos.get("floorId"));
|
|
|
+ temp.set("cadId",infos.get("cADID"));
|
|
|
+ temp.put("id",objectDigital.getId());
|
|
|
+ if (null!=objectDigital.getCreationTime()){
|
|
|
+ temp.put("createTime", DateUtil.format(objectDigital.getCreationTime().getDate(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ if (null!=objectDigital.getModifiedTime()){
|
|
|
+ temp.put("lastUpdate", DateUtil.format(objectDigital.getModifiedTime().getDate(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ temp.put("localId", objectDigital.getLocalId());
|
|
|
+ temp.put("localName", objectDigital.getLocalName());
|
|
|
+ temp.put("name", objectDigital.getName());
|
|
|
+ temp.put("objectType", objectDigital.getObjType());
|
|
|
+ temp.put("objectType", objectDigital.getObjType());
|
|
|
+ temp.put("projectId", objectDigital.getProjectId());
|
|
|
+ temp.putObject("statistics");
|
|
|
}
|
|
|
}
|