|
@@ -1,23 +1,26 @@
|
|
|
package com.persagy.proxy.adm.service.impl;
|
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+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.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.persagy.dmp.basic.dto.RequestData;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
+import com.persagy.dmp.common.context.AppContext;
|
|
|
import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.define.client.DigitalGraphDefineFacade;
|
|
@@ -36,9 +39,9 @@ import com.persagy.proxy.adm.constant.ObjTypeMapping;
|
|
|
import com.persagy.proxy.adm.service.IRelationReportService;
|
|
|
import com.persagy.proxy.adm.strategy.relationdata.RelationObjectStrategy;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
/**
|
|
@@ -101,6 +104,71 @@ public class RelationReportService implements IRelationReportService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<ObjectNode> getAllRelationProjectCal(String groupCode, String projectId) {
|
|
|
+ groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
+
|
|
|
+ // 查询出对应项目关系计算数据
|
|
|
+ QueryCriteria projectCriteria = new QueryCriteria();
|
|
|
+ ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("projectId", projectId);
|
|
|
+ projectCriteria.setCriteria(criteria);
|
|
|
+ List<ObjectNode> projectList = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
|
|
|
+ if (CollectionUtil.isEmpty(projectList)) {
|
|
|
+ return Lists.newArrayList();
|
|
|
+ }
|
|
|
+ for (ObjectNode objectNode : projectList) {
|
|
|
+ String graphCode = objectNode.get("graphCode") == null ? null : objectNode.get("graphCode").asText();
|
|
|
+ String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
|
|
|
+ AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(graphCode + AdmCommonConstant.UNDERLINE + relCode);
|
|
|
+ this.fillRelationProjectCal(objectNode, relationTypeEnum, groupCode, projectId);
|
|
|
+ }
|
|
|
+
|
|
|
+ return projectList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> getAllRelationProjectCalTree(String groupCode, String projectId) {
|
|
|
+ groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
+
|
|
|
+ // 获取所有的二级标签
|
|
|
+ QueryCriteria secondCriteria = new QueryCriteria();
|
|
|
+ List<GraphDefine> secondList = DigitalGraphDefineFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, secondCriteria);
|
|
|
+ if (CollectionUtil.isEmpty(secondList)) {
|
|
|
+ return Lists.newArrayList();
|
|
|
+ }
|
|
|
+ // 获取此图类型对应项目计算数据
|
|
|
+ List<JSONObject> resultList = new ArrayList<JSONObject>();
|
|
|
+ for (GraphDefine graphDefine : secondList) {
|
|
|
+ String graphCode = graphDefine.getCode();
|
|
|
+ JSONObject graphObject = this.transfer(graphDefine);
|
|
|
+
|
|
|
+ // 查询出对应项目关系计算数据
|
|
|
+ QueryCriteria projectCriteria = new QueryCriteria();
|
|
|
+ ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("projectId", projectId);
|
|
|
+ criteria.put("graphCode", graphCode);
|
|
|
+ projectCriteria.setCriteria(criteria);
|
|
|
+ List<ObjectNode> projectList = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
|
|
|
+ if (CollectionUtil.isEmpty(projectList)) {
|
|
|
+ graphObject.put("relationTypeProjectList", Lists.newArrayList());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 再根据图类型、边类型,统计此类型下的数量
|
|
|
+ for (ObjectNode objectNode : projectList) {
|
|
|
+ String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
|
|
|
+ AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(graphCode + AdmCommonConstant.UNDERLINE + relCode);
|
|
|
+ this.fillRelationProjectCal(objectNode, relationTypeEnum, groupCode, projectId);
|
|
|
+ }
|
|
|
+ graphObject.put("relationTypeProjectList", projectList);
|
|
|
+ resultList.add(graphObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public ObjectNode getRelationProjectCal(String groupCode, String projectId, String relType) {
|
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
|
|
@@ -111,26 +179,7 @@ public class RelationReportService implements IRelationReportService {
|
|
|
|
|
|
ObjectNode objectNode = this.getRelationProjectCal(groupCode, projectId, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode(), null);
|
|
|
if (objectNode != null) {
|
|
|
- String zoneType = objectNode.get("zoneType") == null ? null : objectNode.get("zoneType").asText();
|
|
|
- long count = this.countRelationObject(groupCode, projectId, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode(), zoneType);
|
|
|
- objectNode.put("count", count);
|
|
|
- objectNode.put("relationType", relType);
|
|
|
-
|
|
|
- // 获取此图类型和边类型对应的数据记录
|
|
|
- List<RelationDefine> relationDefines = this.getRelationDefine(groupCode, projectId, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode());
|
|
|
- if (CollectionUtil.isNotEmpty(relationDefines)) {
|
|
|
- RelationDefine relationDefine = relationDefines.get(0);
|
|
|
- objectNode.put("conneObject", relationDefine.getTargetObjs());
|
|
|
- objectNode.put("relationTypeCode", relationDefine.getCode());
|
|
|
- objectNode.put("relationTypeName", relationDefine.getName());
|
|
|
- objectNode.put("automatic", (null == relationDefine.getAutomaticFlag() || relationDefine.getAutomaticFlag()) ? false : true);
|
|
|
- }
|
|
|
-
|
|
|
- String prefix = ObjTypeMapping.getRelCodePrefix(relationTypeEnum.getRelCode());
|
|
|
- String suffix = ObjTypeMapping.getRelCodeSuffix(relationTypeEnum.getRelCode());
|
|
|
- objectNode.put("mainObject", ObjTypeMapping.PREFIX_NAME.get(prefix));
|
|
|
- objectNode.put("fromObject", ObjTypeMapping.PREFIX_NAME.get(suffix));
|
|
|
- objectNode.putPOJO("statistics", new JSONObject());
|
|
|
+ this.fillRelationProjectCal(objectNode, relationTypeEnum, groupCode, projectId);
|
|
|
}
|
|
|
|
|
|
return objectNode;
|
|
@@ -426,7 +475,9 @@ public class RelationReportService implements IRelationReportService {
|
|
|
}
|
|
|
// 三级数据封装
|
|
|
for (ObjectNode objectNode : projectList) {
|
|
|
- this.transfer(objectNode, childGraph.getId());
|
|
|
+ String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
|
|
|
+ AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(childGraph.getCode() + AdmCommonConstant.UNDERLINE + relCode);
|
|
|
+ this.fillRelationProjectCal(objectNode, relationTypeEnum, null, null);
|
|
|
}
|
|
|
child.put("relationTypeProjectList", projectList);
|
|
|
}
|
|
@@ -460,25 +511,39 @@ public class RelationReportService implements IRelationReportService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取转换后的数据,项目计算数据转换
|
|
|
- *
|
|
|
- * @param relationProject
|
|
|
- * @return
|
|
|
+ * 填充项目关系计算ADM所需的数据
|
|
|
+ * @param objectNode 项目关系计算的数据记录
|
|
|
+ * @param relationTypeEnum 枚举类
|
|
|
+ * @param groupCode 集团编码
|
|
|
+ * @param projectId 项目ID
|
|
|
*/
|
|
|
- private void transfer(ObjectNode relationProject, String graphicId) {
|
|
|
- String relCode = relationProject.get("relCode") == null ? null : relationProject.get("relCode").asText();
|
|
|
+ private void fillRelationProjectCal(ObjectNode objectNode, AdmRelationTypeEnum relationTypeEnum, String groupCode, String projectId) {
|
|
|
+ if (StrUtil.isAllNotBlank(groupCode, projectId)) {
|
|
|
+ String zoneType = objectNode.get("zoneType") == null ? null : objectNode.get("zoneType").asText();
|
|
|
+ long count = this.countRelationObject(groupCode, projectId, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode(), zoneType);
|
|
|
+ objectNode.put("count", count);
|
|
|
+ }
|
|
|
|
|
|
- relationProject.put("graphicId", graphicId);
|
|
|
- relationProject.putPOJO("statistics", Lists.newArrayList());
|
|
|
- relationProject.put("automatic", "1".equals(relationProject.get("automaticFlag") == null ? null : relationProject.get("automaticFlag").asText()));
|
|
|
- relationProject.put("source", "1".equals(relationProject.get("sourceFlag") == null ? null : relationProject.get("sourceFlag").asText()));
|
|
|
- relationProject.put("conneObject", ObjTypeMapping.getConneObject(relCode));
|
|
|
+ objectNode.put("relationTypeCode", relationTypeEnum.getRelCode());
|
|
|
+ objectNode.put("relationType", relationTypeEnum.getRelationType());
|
|
|
+ objectNode.put("relationTypeName", objectNode.get("relCodeName") == null ? null : objectNode.get("relCodeName").asText());
|
|
|
+
|
|
|
+ objectNode.put("graphicId", objectNode.get("graphCode") == null ? null : objectNode.get("graphCode").asText());
|
|
|
+ objectNode.put("automatic", "1".equals(objectNode.get("automaticFlag") == null ? null : objectNode.get("automaticFlag").asText()));
|
|
|
+ objectNode.put("source", "1".equals(objectNode.get("sourceFlag") == null ? null : objectNode.get("sourceFlag").asText()));
|
|
|
+ objectNode.put("conneObject", ObjTypeMapping.getConneObject(relationTypeEnum.getRelCode()));
|
|
|
|
|
|
- Long modifiedTime = relationProject.get("modifiedTime") == null ? null : relationProject.get("modifiedTime").asLong();
|
|
|
- Long creationTime = relationProject.get("creationTime") == null ? null : relationProject.get("creationTime").asLong();
|
|
|
+ Long modifiedTime = objectNode.get("modifiedTime") == null ? null : objectNode.get("modifiedTime").asLong();
|
|
|
+ Long creationTime = objectNode.get("creationTime") == null ? null : objectNode.get("creationTime").asLong();
|
|
|
+ objectNode.put("lastUpdate", modifiedTime == null ? null : new DateTime(modifiedTime).toString());
|
|
|
+ objectNode.put("createTime", creationTime == null ? null : new DateTime(creationTime).toString());
|
|
|
+
|
|
|
|
|
|
- relationProject.put("lastUpdate", modifiedTime == null ? null : new DateTime(modifiedTime).toString());
|
|
|
- relationProject.put("createTime", creationTime == null ? null : new DateTime(creationTime).toString());
|
|
|
+ String prefix = ObjTypeMapping.getRelCodePrefix(relationTypeEnum.getRelCode());
|
|
|
+ String suffix = ObjTypeMapping.getRelCodeSuffix(relationTypeEnum.getRelCode());
|
|
|
+ objectNode.put("mainObject", ObjTypeMapping.PREFIX_NAME.get(prefix));
|
|
|
+ objectNode.put("fromObject", ObjTypeMapping.PREFIX_NAME.get(suffix));
|
|
|
+ objectNode.putPOJO("statistics", new JSONObject());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|