|
@@ -11,12 +11,14 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
+import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectFacade;
|
|
|
import com.persagy.dmp.digital.client.DigitalRelationFacade;
|
|
|
+import com.persagy.dmp.digital.client.DigitalRelationProjectCalFacade;
|
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
|
-import com.persagy.proxy.adm.constant.RelCodeEnum;
|
|
|
+import com.persagy.proxy.adm.constant.ObjTypeMapping;
|
|
|
import com.persagy.proxy.adm.model.AdmRelationObject;
|
|
|
import com.persagy.proxy.adm.service.IRelationReportService;
|
|
|
import com.persagy.proxy.adm.strategy.RelationObjectContext;
|
|
@@ -38,11 +40,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@Service
|
|
|
public class RelationReportService implements IRelationReportService {
|
|
|
|
|
|
- public static final String cADID = "cADID";
|
|
|
-
|
|
|
- public static final String pe2bd = "pe2bd";
|
|
|
- public static final String pe2fl = "pe2fl";
|
|
|
-
|
|
|
@Value("${middleware.group.code}")
|
|
|
private String defaultCode;
|
|
|
|
|
@@ -50,12 +47,103 @@ public class RelationReportService implements IRelationReportService {
|
|
|
private RelationObjectContext relationObjectContext;
|
|
|
|
|
|
@Override
|
|
|
+ public void getGraphRelDefine(String groupCode, String graphCode, String relCode) {
|
|
|
+ ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ if (StrUtil.isNotBlank(graphCode)) {
|
|
|
+ criteria.put("graphCode", graphCode);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(relCode)) {
|
|
|
+ criteria.put("relCode", relCode);
|
|
|
+ }
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ObjectNode getRelationProjectCal(String groupCode, String projectId, String relType) {
|
|
|
+ AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
|
|
|
+ if (relationTypeEnum == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ // 获取此图类型和边类型对应的数据记录
|
|
|
+
|
|
|
+ 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.put("relationTypeCode", relationTypeEnum.getRelCode());
|
|
|
+ boolean automatic = objectNode.get("automaticFlag") == null ? false : objectNode.get("automaticFlag").asBoolean(false);
|
|
|
+ objectNode.put("automatic", automatic);
|
|
|
+ }
|
|
|
+
|
|
|
+ return objectNode;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ObjectNode getRelationProjectCal(String groupCode, String projectId, String graphCode, String relCode, String zoneType) {
|
|
|
+ ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("graphCode", graphCode);
|
|
|
+ criteria.put("relCode", relCode);
|
|
|
+ if (StrUtil.isNotBlank(zoneType)) {
|
|
|
+ criteria.put("zoneType", zoneType);
|
|
|
+ }
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
+ List<ObjectNode> objectNodes = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
+ if (CollectionUtil.isEmpty(objectNodes)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return objectNodes.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long countRelationObject(String groupCode, String projectId, String graphCode, String relCode, String zoneType) {
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
+ ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("graphCode", graphCode);
|
|
|
+ criteria.put("relCode", relCode);
|
|
|
+ if (StrUtil.isNotBlank(zoneType)) {
|
|
|
+ criteria.put("relValue", zoneType);
|
|
|
+ }
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
+ queryCriteria.setOnlyCount(true);
|
|
|
+ CommonResult<List<ObjectRelation>> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
+ return result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long countObject(String groupCode, String projectId, String classCode, String objType) {
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
+ ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("classCode", classCode);
|
|
|
+ if (StrUtil.isNotBlank(objType)) {
|
|
|
+ criteria.put("objType", objType);
|
|
|
+ }
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
+ queryCriteria.setOnlyCount(true);
|
|
|
+ CommonResult<List<ObjectNode>> result = DigitalObjectFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
+ return result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public ObjectNode getObjectNode(String groupCode, String projectId, String id) {
|
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
- ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
- objectNode.put("id", id);
|
|
|
- queryCriteria.setCriteria(objectNode);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("id", id);
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
List<ObjectNode> objectNodes = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
return CollectionUtil.isEmpty(objectNodes) ? objectMapper.createObjectNode() : objectNodes.get(0);
|
|
|
}
|
|
@@ -72,10 +160,10 @@ public class RelationReportService implements IRelationReportService {
|
|
|
|
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
- ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
- objectNode.put(key, value);
|
|
|
- objectNode.put("objType", objType);
|
|
|
- queryCriteria.setCriteria(objectNode);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put(key, value);
|
|
|
+ criteria.put("objType", objType);
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
List<ObjectNode> objectNodes = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
return objectNodes;
|
|
|
}
|
|
@@ -88,12 +176,12 @@ public class RelationReportService implements IRelationReportService {
|
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
|
|
|
QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
- ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
- objectNode.put("graphCode", graphCode);
|
|
|
- objectNode.put("relCode", relCode);
|
|
|
- objectNode.put("objFrom", objFrom);
|
|
|
- objectNode.put("objTo", objTo);
|
|
|
- queryCriteria.setCriteria(objectNode);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("graphCode", graphCode);
|
|
|
+ criteria.put("relCode", relCode);
|
|
|
+ criteria.put("objFrom", objFrom);
|
|
|
+ criteria.put("objTo", objTo);
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
List<ObjectRelation> objectRelations = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
if (CollectionUtil.isEmpty(objectRelations)) {
|
|
|
return objectMapper.createObjectNode();
|
|
@@ -125,9 +213,6 @@ public class RelationReportService implements IRelationReportService {
|
|
|
@Override
|
|
|
public List<AdmRelationObject> reportRelationObject(String groupCode, String projectId, String relType, String code, String zoneType) {
|
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
- if (AdmRelationTypeEnum.EQ2SP_SENSORRELATIONSHIP_SS2SP.getRelationType().equals(relType)){
|
|
|
- relType = RelCodeEnum.Eq2Sp.name();
|
|
|
- }
|
|
|
log.info("下载报表: groupCode[{}], projectId[{}], relType[{}], code[{}]", groupCode, projectId, relType, code);
|
|
|
return this.relationObjectContext.findRelationObject(groupCode, projectId, relType);
|
|
|
}
|