|
@@ -1,12 +1,12 @@
|
|
package com.persagy.proxy.adm.service.impl;
|
|
package com.persagy.proxy.adm.service.impl;
|
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
-import java.util.ArrayList;
|
|
+import java.util.*;
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
+import com.persagy.dmp.common.context.AppContext;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -123,7 +123,7 @@ public class RelationReportService implements IRelationReportService {
|
|
objectNode.put("conneObject", relationDefine.getTargetObjs());
|
|
objectNode.put("conneObject", relationDefine.getTargetObjs());
|
|
objectNode.put("relationTypeCode", relationDefine.getCode());
|
|
objectNode.put("relationTypeCode", relationDefine.getCode());
|
|
objectNode.put("relationTypeName", relationDefine.getName());
|
|
objectNode.put("relationTypeName", relationDefine.getName());
|
|
- objectNode.put("automatic", (null == relationDefine.getAutomaticFlag() || 0 == relationDefine.getAutomaticFlag()) ? false : true);
|
|
+ objectNode.put("automatic", (null == relationDefine.getAutomaticFlag() || relationDefine.getAutomaticFlag()) ? false : true);
|
|
}
|
|
}
|
|
|
|
|
|
String prefix = ObjTypeMapping.getRelCodePrefix(relationTypeEnum.getRelCode());
|
|
String prefix = ObjTypeMapping.getRelCodePrefix(relationTypeEnum.getRelCode());
|
|
@@ -266,82 +266,112 @@ public class RelationReportService implements IRelationReportService {
|
|
List<ObjectRelation> objectRelations = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
List<ObjectRelation> objectRelations = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
return CollectionUtil.isEmpty(objectRelations) ? Lists.newArrayList() : objectRelations;
|
|
return CollectionUtil.isEmpty(objectRelations) ? Lists.newArrayList() : objectRelations;
|
|
}
|
|
}
|
|
-
|
|
+
|
|
|
|
+ * 初始化项目关系计算数据
|
|
|
|
+ *
|
|
|
|
+ * @param groupCode: 集团编码
|
|
|
|
+ * @param projectId: 项目id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
- public boolean createRelationProjectCal(String groupCode, String projectId) {
|
|
+ public boolean createRelationProjectCal(String groupCode, String projectId) throws JsonProcessingException {
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
-
|
|
+
|
|
-
|
|
|
|
QueryCriteria queryCriteria = new QueryCriteria();
|
|
QueryCriteria queryCriteria = new QueryCriteria();
|
|
queryCriteria.setOnlyCount(true);
|
|
queryCriteria.setOnlyCount(true);
|
|
- CommonResult<List<ObjectNode>> prototype = DigitalRelationProjectCalFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
+ CommonResult<List<ObjectNode>> prototype = DigitalRelationProjectCalFacade.queryPrototype(groupCode, projectId,
|
|
|
|
+ AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
if (prototype != null && prototype.getCount() != null && prototype.getCount() > 0) {
|
|
if (prototype != null && prototype.getCount() != null && prototype.getCount() > 0) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
QueryCriteria criteria = new QueryCriteria();
|
|
QueryCriteria criteria = new QueryCriteria();
|
|
- List<RelationDefine> list = DigitalRelationDefineFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, criteria);
|
|
+ List<RelationDefine> list = DigitalRelationDefineFacade.query(groupCode, projectId,
|
|
|
|
+ AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, criteria);
|
|
if (CollectionUtil.isEmpty(list)) {
|
|
if (CollectionUtil.isEmpty(list)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
List<ObjectNode> nodes = new ArrayList<ObjectNode>();
|
|
List<ObjectNode> nodes = new ArrayList<ObjectNode>();
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
for (RelationDefine relationDefine : list) {
|
|
for (RelationDefine relationDefine : list) {
|
|
- ObjectNode objectNode = objectMapper.createObjectNode();
|
|
+
|
|
-
|
|
+ if (null==relationDefine.getCalFlag()
|
|
- String key = relationDefine.getGraphCode() + AdmCommonConstant.UNDERLINE + relationDefine.getCode();
|
|
+ || !relationDefine.getCalFlag()){
|
|
- AdmRelationTypeEnum typeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(key);
|
|
+ continue;
|
|
-
|
|
+ }
|
|
-
|
|
+
|
|
-
|
|
+ if (CollUtil.isNotEmpty(relationDefine.getZoneTypes())){
|
|
- objectNode.put("projectId", projectId);
|
|
+ for (String zoneType : relationDefine.getZoneTypes()) {
|
|
- objectNode.put("id", IdUtil.fastSimpleUUID());
|
|
+ nodes.add(createRelationProjectCalInternal(objectMapper,groupCode,projectId,relationDefine,zoneType));
|
|
- objectNode.put("graphCode", relationDefine.getGraphCode());
|
|
+ }
|
|
- objectNode.put("name", relationDefine.getName());
|
|
+ continue;
|
|
- objectNode.put("relCode", relationDefine.getCode());
|
|
+ }
|
|
- objectNode.put("sourceFlag", typeEnum == null ? null : typeEnum.getSourceFlag());
|
|
+
|
|
- objectNode.put("automaticFlag", relationDefine.getAutomaticFlag());
|
|
+ nodes.add(createRelationProjectCalInternal(objectMapper,groupCode,projectId,relationDefine,null));
|
|
- objectNode.put("manual", typeEnum == null ? null : typeEnum.getManualFlag());
|
|
|
|
-
|
|
|
|
- objectNode.put("computationalState", 1);
|
|
|
|
-
|
|
|
|
- objectNode.put("systemType", typeEnum == null ? null : typeEnum.getSystemType());
|
|
|
|
- objectNode.put("relManualType", typeEnum == null ? null : typeEnum.getRelationType());
|
|
|
|
-
|
|
|
|
- objectNode.put("creator", AdmCommonConstant.USER_ID);
|
|
|
|
- objectNode.put("modifier", AdmCommonConstant.USER_ID);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- nodes.add(objectNode);
|
|
|
|
}
|
|
}
|
|
-
|
|
+ List<ObjectRelationProjectCal> result = DigitalRelationProjectCalFacade.create(groupCode, projectId,
|
|
- List<ObjectRelationProjectCal> result = DigitalRelationProjectCalFacade.create(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, nodes);
|
|
+ AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, nodes);
|
|
return CollectionUtil.isNotEmpty(result);
|
|
return CollectionUtil.isNotEmpty(result);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ * Description: 创建存储的对象
|
|
|
|
+ * @param groupCode : 集团编码
|
|
|
|
+ * @param projectId : 项目id
|
|
|
|
+ * @param relationDefine : 关系定义
|
|
|
|
+ * @param zoneType : 空间分区类型
|
|
|
|
+ * @return : void
|
|
|
|
+ * @author : lijie
|
|
|
|
+ * @date :2021/10/14 16:14
|
|
|
|
+ * Update By lijie 2021/10/14 16:14
|
|
|
|
+ */
|
|
|
|
+ private ObjectNode createRelationProjectCalInternal(ObjectMapper objectMapper, String groupCode,
|
|
|
|
+ String projectId, RelationDefine relationDefine,
|
|
|
|
+ String zoneType) throws JsonProcessingException {
|
|
|
|
+ ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
|
+
|
|
|
|
+ objectNode.put("groupCode", groupCode);
|
|
|
|
+ objectNode.put("projectId", projectId);
|
|
|
|
+ objectNode.put("id", IdWorker.getIdStr());
|
|
|
|
+ objectNode.put("graphCode", relationDefine.getGraphCode());
|
|
|
|
+ objectNode.put("relCodeName", relationDefine.getName());
|
|
|
|
+ objectNode.put("relCode", relationDefine.getCode());
|
|
|
|
+ objectNode.put("sourceFlag", relationDefine.getSourceFlag());
|
|
|
|
+ objectNode.put("automaticFlag", relationDefine.getAutomaticFlag());
|
|
|
|
+ objectNode.put("manual", relationDefine.getManual());
|
|
|
|
+ objectNode.put("computationalState", 1);
|
|
|
|
+ objectNode.put("zoneType", zoneType);
|
|
|
|
+ objectNode.put("systemType", relationDefine.getSystemType());
|
|
|
|
+ objectNode.put("computeVersion", 0);
|
|
|
|
+ objectNode.put("mepSystemType", CollUtil.isNotEmpty(relationDefine.getMepSystemType())
|
|
|
|
+ ?objectMapper.writeValueAsString(relationDefine.getMepSystemType()):null);
|
|
|
|
+ objectNode.put("creator", AdmCommonConstant.USER_ID);
|
|
|
|
+ objectNode.put("modifier", AdmCommonConstant.USER_ID);
|
|
|
|
+ return objectNode;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * 查询关系总览(空表,先插入)
|
|
|
|
+ * @param content: 模糊查询卡片名称关键字
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
- public JSONObject overview(String groupCode, String projectId, String content) {
|
|
+ public JSONObject overview(String content) throws JsonProcessingException {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
-
|
|
|
|
if (StrUtil.isBlank(content)) {
|
|
if (StrUtil.isBlank(content)) {
|
|
- this.createRelationProjectCal(groupCode, projectId);
|
|
+ this.createRelationProjectCal(AppContext.getContext().getGroupCode(), AppContext.getContext().getProjectId());
|
|
}
|
|
}
|
|
-
|
|
|
|
List<JSONObject> parentList = new ArrayList<JSONObject>();
|
|
List<JSONObject> parentList = new ArrayList<JSONObject>();
|
|
-
|
|
|
|
|
|
|
|
- this.getGraphRelationProjectTree(parentList, groupCode, projectId, content);
|
|
+ this.getGraphRelationProjectTree(parentList, AppContext.getContext().getGroupCode(),
|
|
-
|
|
+ AppContext.getContext().getProjectId(), content);
|
|
result.put("content", parentList);
|
|
result.put("content", parentList);
|
|
result.put("message", "");
|
|
result.put("message", "");
|
|
result.put("pageNumber", 1);
|
|
result.put("pageNumber", 1);
|
|
result.put("pageSize", 1000);
|
|
result.put("pageSize", 1000);
|
|
result.put("result", "success");
|
|
result.put("result", "success");
|
|
result.put("total", parentList.size());
|
|
result.put("total", parentList.size());
|
|
-
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -371,12 +401,10 @@ public class RelationReportService implements IRelationReportService {
|
|
|
|
|
|
GraphDefine topGraph = topList.get(i);
|
|
GraphDefine topGraph = topList.get(i);
|
|
JSONObject parent = this.transfer(topGraph);
|
|
JSONObject parent = this.transfer(topGraph);
|
|
-
|
|
|
|
|
|
|
|
for (int j = childList.size() - 1; j >= 0; j--) {
|
|
for (int j = childList.size() - 1; j >= 0; j--) {
|
|
GraphDefine childGraph = topList.get(i);
|
|
GraphDefine childGraph = topList.get(i);
|
|
JSONObject child = this.transfer(childGraph);
|
|
JSONObject child = this.transfer(childGraph);
|
|
-
|
|
|
|
|
|
|
|
QueryCriteria projectCriteria = new QueryCriteria();
|
|
QueryCriteria projectCriteria = new QueryCriteria();
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
@@ -388,7 +416,7 @@ public class RelationReportService implements IRelationReportService {
|
|
criteria.putPOJO("name", condition);
|
|
criteria.putPOJO("name", condition);
|
|
}
|
|
}
|
|
projectCriteria.setCriteria(criteria);
|
|
projectCriteria.setCriteria(criteria);
|
|
- projectCriteria.setOrders(Arrays.asList(OrderItem.asc("relCode")));
|
|
+ projectCriteria.setOrders(Collections.singletonList(OrderItem.asc("relCode")));
|
|
List<ObjectNode> projectList = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
|
|
List<ObjectNode> projectList = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
|
|
if (CollectionUtil.isEmpty(projectList)) {
|
|
if (CollectionUtil.isEmpty(projectList)) {
|
|
if (isQuery) {
|
|
if (isQuery) {
|
|
@@ -396,20 +424,17 @@ public class RelationReportService implements IRelationReportService {
|
|
}
|
|
}
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
for (ObjectNode objectNode : projectList) {
|
|
for (ObjectNode objectNode : projectList) {
|
|
this.transfer(objectNode, childGraph.getId());
|
|
this.transfer(objectNode, childGraph.getId());
|
|
}
|
|
}
|
|
child.put("relationTypeProjectList", projectList);
|
|
child.put("relationTypeProjectList", projectList);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
if (isQuery && CollectionUtil.isEmpty(childList)) {
|
|
if (isQuery && CollectionUtil.isEmpty(childList)) {
|
|
childList.remove(i);
|
|
childList.remove(i);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
parent.put("childGraphicTypeList", childList);
|
|
parent.put("childGraphicTypeList", childList);
|
|
parentList.add(parent);
|
|
parentList.add(parent);
|
|
}
|
|
}
|