|
@@ -15,6 +15,7 @@ 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.google.common.collect.Sets;
|
|
|
import com.persagy.dmp.basic.dto.GraphParentMes;
|
|
|
import com.persagy.dmp.basic.dto.RequestData;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
@@ -190,7 +191,7 @@ public class RelationReportService implements IRelationReportService {
|
|
|
String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
|
|
|
tempList.add(this.fillRelationProjectCal(objectNode, graphDefine.getCode(), relCode, graphRelTypeMap,relationDefineMap, groupCode, projectId));
|
|
|
}
|
|
|
- graphObject.put("relationTypeProjectList", projectList);
|
|
|
+ graphObject.put("relationTypeProjectList", tempList);
|
|
|
resultList.add(graphObject);
|
|
|
}
|
|
|
|
|
@@ -273,16 +274,20 @@ public class RelationReportService implements IRelationReportService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ObjectNode getObjectNode(String groupCode, String projectId, String id) {
|
|
|
+ public List<ObjectNode> getObjectNode(String groupCode, String projectId, Set<String> ids) {
|
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
|
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
- criteria.put("id", id);
|
|
|
+ if (CollectionUtil.isNotEmpty(ids)) {
|
|
|
+ JSONObject arrays = new JSONObject();
|
|
|
+ arrays.put("$in", ids);
|
|
|
+ criteria.putPOJO("id", ids);
|
|
|
+ }
|
|
|
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);
|
|
|
+ return objectNodes;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -322,8 +327,12 @@ public class RelationReportService implements IRelationReportService {
|
|
|
ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
criteria.put("graphCode", graphCode);
|
|
|
criteria.put("relCode", relCode);
|
|
|
- criteria.put("objFrom", objFrom);
|
|
|
- criteria.put("objTo", objTo);
|
|
|
+ if (StrUtil.isNotBlank(objFrom)) {
|
|
|
+ criteria.put("objFrom", objFrom);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(objTo)) {
|
|
|
+ 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)) {
|
|
@@ -333,30 +342,41 @@ public class RelationReportService implements IRelationReportService {
|
|
|
// 获取关联对象的本地名称
|
|
|
ObjectRelation objectRelation = objectRelations.get(0);
|
|
|
String relationId = StrUtil.isBlank(objFrom) ? objectRelation.getObjFrom() : objectRelation.getObjTo();
|
|
|
- return this.getObjectNode(groupCode, projectId, relationId);
|
|
|
+ List<ObjectNode> objectNodes = this.getObjectNode(groupCode, projectId, Sets.newHashSet(relationId));
|
|
|
+ return CollectionUtil.isEmpty(objectNodes) ? objectMapper.createObjectNode() : objectNodes.get(0);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ObjectNode> queryObjects(String groupCode, String projectId, String id, String classCode, String objType, String ascOrder) {
|
|
|
+ public List<ObjectNode> queryObjects(String groupCode, String projectId, Set<String> ids, Set<String> classCodes, Set<String> objTypes,
|
|
|
+ Set<String> ascOrder, Set<String> descOrder) {
|
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
|
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
QueryCriteria objectCriteria = new QueryCriteria();
|
|
|
ObjectNode object = objectMapper.createObjectNode();
|
|
|
- if (StrUtil.isNotBlank(id)) {
|
|
|
- object.put("id", id);
|
|
|
+ if (CollectionUtil.isNotEmpty(ids)) {
|
|
|
+ JSONObject arrays = new JSONObject();
|
|
|
+ arrays.put("$in", ids);
|
|
|
+ object.putPOJO("id", ids);
|
|
|
}
|
|
|
- if (StrUtil.isNotBlank(classCode)) {
|
|
|
- object.put("classCode", classCode);
|
|
|
+ if (CollectionUtil.isNotEmpty(classCodes)) {
|
|
|
+ JSONObject arrays = new JSONObject();
|
|
|
+ arrays.put("$in", classCodes);
|
|
|
+ object.putPOJO("classCode", classCodes);
|
|
|
}
|
|
|
- if (StrUtil.isNotBlank(objType)) {
|
|
|
- object.put("objType", objType);
|
|
|
+ if (CollectionUtil.isNotEmpty(objTypes)) {
|
|
|
+ JSONObject arrays = new JSONObject();
|
|
|
+ arrays.put("$in", objTypes);
|
|
|
+ object.putPOJO("objType", objTypes);
|
|
|
}
|
|
|
objectCriteria.setPage(1L);
|
|
|
objectCriteria.setSize(500L);
|
|
|
objectCriteria.setCriteria(object);
|
|
|
- if (StrUtil.isNotBlank(ascOrder)) {
|
|
|
- objectCriteria.setOrders(Collections.singletonList(OrderItem.asc(ascOrder)));
|
|
|
+ if (CollectionUtil.isNotEmpty(ascOrder)) {
|
|
|
+ objectCriteria.setOrders(OrderItem.ascs(ascOrder.toArray(new String[ascOrder.size()])));
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(descOrder)) {
|
|
|
+ objectCriteria.setOrders(OrderItem.descs(descOrder.toArray(new String[descOrder.size()])));
|
|
|
}
|
|
|
List<ObjectNode> all = new ArrayList<ObjectNode>();
|
|
|
this.queryPageObjects(all, objectCriteria, groupCode, projectId);
|
|
@@ -364,7 +384,7 @@ public class RelationReportService implements IRelationReportService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ObjectRelation> findRelationObjects(String groupCode, String projectId, String graphCode, String relCode) {
|
|
|
+ public List<ObjectRelation> findRelationObjects(String groupCode, String projectId, String graphCode, String relCode, Set<String> objFroms, Set<String> objTos) {
|
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
|
|
|
// 获取出关联对象
|
|
@@ -378,9 +398,24 @@ public class RelationReportService implements IRelationReportService {
|
|
|
if (StrUtil.isNotBlank(relCode)) {
|
|
|
criteria.put("relCode", relCode);
|
|
|
}
|
|
|
+ if (CollectionUtil.isNotEmpty(objFroms)) {
|
|
|
+ JSONObject arrays = new JSONObject();
|
|
|
+ arrays.put("$in", objFroms);
|
|
|
+ criteria.putPOJO("objFrom", objFroms);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(objTos)) {
|
|
|
+ JSONObject arrays = new JSONObject();
|
|
|
+ arrays.put("$in", objTos);
|
|
|
+ criteria.putPOJO("objTo", objTos);
|
|
|
+ }
|
|
|
+
|
|
|
+ queryCriteria.setPage(1L);
|
|
|
+ queryCriteria.setSize(500L);
|
|
|
queryCriteria.setCriteria(criteria);
|
|
|
- List<ObjectRelation> objectRelations = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
- return CollectionUtil.isEmpty(objectRelations) ? Lists.newArrayList() : objectRelations;
|
|
|
+
|
|
|
+ List<ObjectRelation> all = new ArrayList<ObjectRelation>();
|
|
|
+ this.queryPageRelations(all, queryCriteria, groupCode, projectId);
|
|
|
+ return all;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -775,12 +810,30 @@ public class RelationReportService implements IRelationReportService {
|
|
|
objectCriteria.setPage((objectCriteria.getPage() + 1));
|
|
|
this.queryPageObjects(all, objectCriteria, groupCode, projectId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询关系数据
|
|
|
+ *
|
|
|
+ * @param all
|
|
|
+ * @param queryCriteria
|
|
|
+ * @param groupCode
|
|
|
+ * @param projectId
|
|
|
+ */
|
|
|
+ private void queryPageRelations(List<ObjectRelation> all, QueryCriteria queryCriteria, String groupCode, String projectId) {
|
|
|
+ List<ObjectRelation> objectRelations = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
|
|
|
+ if (CollectionUtil.isEmpty(objectRelations)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ all.addAll(objectRelations);
|
|
|
+ queryCriteria.setPage((queryCriteria.getPage() + 1));
|
|
|
+ this.queryPageRelations(all, queryCriteria, groupCode, projectId);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 分页查询信息点定义数据
|
|
|
*
|
|
|
* @param all
|
|
|
- * @param classCriteria
|
|
|
+ * @param queryCriteria
|
|
|
* @param groupCode
|
|
|
* @param projectId
|
|
|
*/
|