|
@@ -6,12 +6,15 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
+import com.persagy.dmp.basic.utils.JsonNodeUtils;
|
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
|
import com.persagy.proxy.adm.model.*;
|
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
@@ -21,6 +24,7 @@ import com.persagy.proxy.common.entity.DmpResult;
|
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
import com.persagy.proxy.common.entity.ObjRelationDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -97,7 +101,9 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
@Override
|
|
|
public AdmResponse doQueryType(InstanceUrlParam context, AdmDCSQueryRequest request) {
|
|
|
//查询定义类型
|
|
|
- DmpResult<JSONArray> resultDef = queryDefineType(context);
|
|
|
+ ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode();
|
|
|
+ criteriaEq.put("parentCode", "space");
|
|
|
+ DmpResult<JSONArray> resultDef = queryDefineType(context, criteriaEq);
|
|
|
List<JSONObject> defineList = null;
|
|
|
if(resultDef.getResult().equals(DmpResult.SUCCESS)){
|
|
|
defineList = JSONUtil.toList(resultDef.getData().toString(), JSONObject.class);
|
|
@@ -115,10 +121,95 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AdmResponse doQuerySpaces(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmSpace> clazz) {
|
|
|
+ public AdmResponse doQuerySpaces(InstanceUrlParam context, AdmDCSQueryRequest request) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 空间的类型是根据项目自定义的
|
|
|
+ * 参见中心
|
|
|
+ * @Select("SELECT s.object_type as type,d.name FROM zone_space_base s
|
|
|
+ * LEFT JOIN dict.dict_space_project d ON s.object_type = d.id WHERE s.project_id = #{projectId} AND d.project_id = #{projectId}
|
|
|
+ * GROUP BY object_type, d.name")
|
|
|
+ * @param context
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> doQuerySpaceTypes(InstanceUrlParam context) {
|
|
|
+ //根据项目id查询空间类型
|
|
|
+ Map<String, String> codeNameMap = queryProjectDefineType(context);
|
|
|
+ if(CollUtil.isNotEmpty(codeNameMap)){
|
|
|
+ //查询object
|
|
|
+ JSONArray demObjs = queryAndDealObjs(context, codeNameMap.keySet());
|
|
|
+ if(CollUtil.isNotEmpty(demObjs)){
|
|
|
+ List<AdmSpace> spaceList = JSONArray.parseArray(JSONUtil.toJsonStr(demObjs), AdmSpace.class);
|
|
|
+ Set<String> classCodes = spaceList.stream().map(space -> space.getClassCode()).collect(Collectors.toSet());
|
|
|
+ if(CollUtil.isNotEmpty(classCodes)){
|
|
|
+ codeNameMap.keySet().removeIf(code -> !classCodes.contains(code));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(codeNameMap)){
|
|
|
+ List<JSONObject> list = new ArrayList<>(codeNameMap.size());
|
|
|
+ codeNameMap.keySet().stream().forEach(code ->{
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("name",codeNameMap.get(code));
|
|
|
+ jsonObject.put("code",code);
|
|
|
+ list.add(jsonObject);
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private DmpResult<JSONArray> queryObj(InstanceUrlParam context, QueryCriteria criteriaObject){
|
|
|
+ JSONObject paraPe = null;
|
|
|
+ try {
|
|
|
+ String paraStr = objectMapper.writeValueAsString(criteriaObject);
|
|
|
+ paraPe = JSONObject.parseObject(paraStr);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ throw new RuntimeException("转换查询条件出错:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return rwdClient.queryObject(context, paraPe);
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONArray queryAndDealObjs(InstanceUrlParam context, Set<String> codes){
|
|
|
+ QueryCriteria criteriaObject = new QueryCriteria();
|
|
|
+ ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode();
|
|
|
+ ArrayNode array = criteriaEq.putObject("classCode").putArray("$in");
|
|
|
+ codes.forEach(code -> array.add(code));
|
|
|
+ criteriaEq.put("objType", "space");
|
|
|
+ criteriaObject.setSize(1000L);
|
|
|
+ criteriaObject.setPage(1L);
|
|
|
+ criteriaObject.setCriteria(criteriaEq);
|
|
|
+
|
|
|
+ DmpResult<JSONArray> dmpResult = queryObj(context, criteriaObject);
|
|
|
+ if(CollUtil.isEmpty(dmpResult.getData())){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONArray demObjs = dmpResult.getData();
|
|
|
+ if(dmpResult.getCount() > criteriaObject.getSize()){
|
|
|
+ for(int page = 2; page < dmpResult.getCount()/criteriaObject.getSize()+1; page++){
|
|
|
+ criteriaObject.setPage(page*1L);
|
|
|
+ demObjs.addAll(queryObj(context, criteriaObject).getData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return demObjs;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, String> queryProjectDefineType(InstanceUrlParam context){
|
|
|
+ Map<String, String> codeNameMap = null;
|
|
|
+ ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode();
|
|
|
+ criteriaEq.put("projectId", context.getProjectId());
|
|
|
+ criteriaEq.put("objType", "space");
|
|
|
+ DmpResult<JSONArray> resultDef = queryDefineType(context, criteriaEq);
|
|
|
+ if(resultDef.getResult().equals(DmpResult.SUCCESS) && CollUtil.isNotEmpty(resultDef.getData())){
|
|
|
+ List<ObjectTypeDefine> defineList = JSONUtil.toList(resultDef.getData().toString(), ObjectTypeDefine.class);
|
|
|
+ codeNameMap = defineList.stream().collect(Collectors.toMap(ObjectTypeDefine::getCode, ObjectTypeDefine::getName, (k1,k2)->k1));
|
|
|
+ }
|
|
|
+ return codeNameMap;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询空间flooId对应的infos中height存在的 flool
|
|
@@ -303,10 +394,8 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
}
|
|
|
|
|
|
|
|
|
- private DmpResult<JSONArray> queryDefineType(InstanceUrlParam context){
|
|
|
+ private DmpResult<JSONArray> queryDefineType(InstanceUrlParam context, ObjectNode criteriaEq){
|
|
|
QueryCriteria criteriaObject = new QueryCriteria();
|
|
|
- ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode();
|
|
|
- criteriaEq.put("parentCode", "space");
|
|
|
criteriaObject.setCriteria(criteriaEq);
|
|
|
JSONObject paraPe = null;
|
|
|
try {
|