|
@@ -30,8 +30,11 @@ import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
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.model.QueryCriteria;
|
|
|
+import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
|
import com.persagy.proxy.adm.handler.RelationReportHandler;
|
|
@@ -42,6 +45,7 @@ import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
import com.persagy.proxy.adm.service.IRelationReportService;
|
|
|
import com.persagy.proxy.adm.strategy.RelationObjectContext;
|
|
|
+import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
@@ -116,16 +120,77 @@ public class RelationReportController {
|
|
|
|
|
|
/**
|
|
|
* 项目关系类型查询
|
|
|
+ * {"filters":"relationType in [\"bd2sp\",\"fl2sp\"];computationalState>1"}
|
|
|
*
|
|
|
* @param queryCriteria
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/graphic/relation_type_project")
|
|
|
- public AdmResponse queryRelationObjects(@RequestBody AdmQueryCriteria queryCriteria, HttpServletRequest request) {
|
|
|
+ public AdmResponse queryRelationObjects(@RequestBody AdmQueryCriteria requestCriteria, HttpServletRequest request) {
|
|
|
String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
|
|
|
String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
|
|
|
- List<JSONObject> relationProjectCal = this.relationReportService.getAllRelationProjectCal(groupCode, projectId);
|
|
|
+ String filters = requestCriteria.getFilters();
|
|
|
+
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
+ ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
+ ObjectNode criteria = objectMapper.createObjectNode();
|
|
|
+ criteria.put("projectId", projectId);
|
|
|
+
|
|
|
+ Set<String> graphs = new HashSet<String>();
|
|
|
+ Set<String> relCodes = new HashSet<String>();
|
|
|
+ if (StrUtil.isNotBlank(filters)) {
|
|
|
+ if (filters.contains("relationType")) {
|
|
|
+ String condition = filters.substring(filters.indexOf("in [") + 4, filters.lastIndexOf("]"));
|
|
|
+ String[] split = condition.split(",");
|
|
|
+ for (String relType : split) {
|
|
|
+ relType = relType.replaceAll("\"", "");
|
|
|
+ AdmRelationTypeEnum typeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
|
|
|
+ if (typeEnum != null) {
|
|
|
+ graphs.add(typeEnum.getGraphCode());
|
|
|
+ relCodes.add(typeEnum.getRelCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] split = filters.split(";");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ if (i == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String express = split[i];
|
|
|
+ String cond = StrUtil.getContainsStr(express, AdmQueryCriteriaHelper.COND_STR);
|
|
|
+ cond = StrUtil.isBlank(cond) ? StrUtil.getContainsStr(express, AdmQueryCriteriaHelper.COND_STR_TRIM) : cond;
|
|
|
+ if(StrUtil.isBlank(cond)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int condIndex = StrUtil.indexOfIgnoreCase(express, cond, 0);
|
|
|
+ String condLeft = StrUtil.subPre(express, condIndex).trim();
|
|
|
+ String condRight = StrUtil.subSuf(express, condIndex+cond.length()).trim();
|
|
|
+ // condLeft 替换为中台的字段名称
|
|
|
+ condLeft = this.convert2BDTPField(condLeft);
|
|
|
+ if ("=".equals(cond)) {
|
|
|
+ criteria.put(condLeft, condRight);
|
|
|
+ } else {
|
|
|
+ JSONObject condition = new JSONObject();
|
|
|
+ condition.put(AdmQueryCriteriaHelper.OPERATOR_MAP.get(cond), condRight);
|
|
|
+ criteria.putPOJO(condLeft, condition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(graphs)) {
|
|
|
+ JSONObject graphObject = new JSONObject();
|
|
|
+ graphObject.put("$in", graphs);
|
|
|
+ criteria.putPOJO("graphCode", graphObject);
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(relCodes)) {
|
|
|
+ JSONObject relObject = new JSONObject();
|
|
|
+ relObject.put("$in", relCodes);
|
|
|
+ criteria.putPOJO("relCode", relObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
+ List<JSONObject> relationProjectCal = this.relationReportService.getAllRelationProjectCal(queryCriteria, groupCode, projectId);
|
|
|
return AdmResponse.success(relationProjectCal);
|
|
|
}
|
|
|
|
|
@@ -606,5 +671,24 @@ public class RelationReportController {
|
|
|
result.put("state", state);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将前端所传的字段,转为BDTP中台所需要的字段
|
|
|
+ *
|
|
|
+ * @param condLeft
|
|
|
+ * @return 转换后的,或原字段
|
|
|
+ */
|
|
|
+ private String convert2BDTPField(String condLeft) {
|
|
|
+ if ("automatic".equals(condLeft)) {
|
|
|
+ return "automaticFlag";
|
|
|
+ }
|
|
|
+ if ("source".equals(condLeft)) {
|
|
|
+ return "sourceFlag";
|
|
|
+ }
|
|
|
+ /*if ("graphicId".equals(condLeft)) {
|
|
|
+ return "graphCode";
|
|
|
+ }*/
|
|
|
+ return condLeft;
|
|
|
+ }
|
|
|
|
|
|
}
|