|
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
@@ -25,7 +26,6 @@ import com.google.common.collect.Sets;
|
|
|
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.entity.BaseEntity;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectFacade;
|
|
@@ -40,6 +40,8 @@ import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
import com.persagy.proxy.adm.service.IAdmRelationService;
|
|
|
import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
|
|
|
import com.persagy.proxy.adm.utils.AdmContextUtil;
|
|
|
+import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
|
|
|
+import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
|
|
|
import com.persagy.proxy.common.client.DmpRwdClient;
|
|
|
import com.persagy.proxy.common.entity.DmpResult;
|
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
@@ -50,8 +52,10 @@ import com.persagy.proxy.object.model.AdmSystem;
|
|
|
import com.persagy.proxy.object.service.IAdmEquipmentService;
|
|
|
import com.persagy.proxy.object.service.IAdmSpaceService;
|
|
|
import com.persagy.proxy.object.service.IAdmSystemService;
|
|
|
+import com.persagy.proxy.report.service.IRelationReportService;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -74,6 +78,8 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
private IAdmEquipmentService equipmentService;
|
|
|
@Autowired
|
|
|
private IAdmSystemService systemService;
|
|
|
+ @Autowired
|
|
|
+ private IRelationReportService relationReportService;
|
|
|
|
|
|
@Override
|
|
|
public AdmResponse doQuery(InstanceUrlParam context, AdmQueryCriteria request, Class<AdmSpace> clazz) {
|
|
@@ -148,44 +154,11 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
relationTo.put("objFrom", request.getFloorId());
|
|
|
request.setRelationTo(relationTo);
|
|
|
}else if(StrUtil.isNotEmpty(request.getBuildingId()) && StrUtil.isNotEmpty(request.getFloorId()) && request.getFloorId().equals("isnull")){
|
|
|
-
|
|
|
-
|
|
|
- QueryCriteria queryCriteriaRelation = new QueryCriteria();
|
|
|
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
- criteria.put("relCode", "Bd2Fl");
|
|
|
- criteria.put("graphCode", "ArchSubset");
|
|
|
- criteria.put("objFrom", request.getBuildingId());
|
|
|
- queryCriteriaRelation.setCriteria(criteria);
|
|
|
- List<ObjectRelation> relations = relationService.queryByCondition(AdmContextUtil.toDmpContext(), queryCriteriaRelation);
|
|
|
- if(CollUtil.isNotEmpty(relations)){
|
|
|
- Map<String, ObjectRelation> objectRelationMap = CollUtil.fieldValueMap(relations, "objTo");
|
|
|
-
|
|
|
-
|
|
|
- ObjectNode relationTo = JsonNodeFactory.instance.objectNode();
|
|
|
- relationTo.put("relCode", "Fl2Sp");
|
|
|
- relationTo.put("graphCode", "ArchSubset");
|
|
|
- ArrayNode arrayNode = relationTo.putObject("objFrom").putArray("$in");
|
|
|
- objectRelationMap.keySet().stream().forEach(floorId -> arrayNode.add(floorId));
|
|
|
- request.setRelationTo(relationTo);
|
|
|
- AdmResponse spaceFl = doQuery(AdmContextUtil.toDmpContext(), request, AdmSpace.class);
|
|
|
- request.setRelationTo(null);
|
|
|
-
|
|
|
- if(CollUtil.isNotEmpty(spaceFl.getContent())){
|
|
|
- List<AdmSpace> admSpaceList = (List<AdmSpace>) spaceFl.getContent();
|
|
|
- Map<String, AdmSpace> admSpaceMap = CollUtil.fieldValueMap(admSpaceList, BaseEntity.PROP_ID);
|
|
|
- String ids = request.getFilters() +"; not id in ['"+ String.join("', '", admSpaceMap.keySet())+"']";
|
|
|
- request.setFilters(ids);
|
|
|
- }
|
|
|
- request.setFilters(request.getFilters() + "; buildingId = '"+request.getBuildingId()+"'");
|
|
|
- }else{
|
|
|
-
|
|
|
- ObjectNode relationTo = JsonNodeFactory.instance.objectNode();
|
|
|
- relationTo.put("relCode", "Bd2Sp");
|
|
|
- relationTo.put("graphCode", "ArchSubset");
|
|
|
- relationTo.put("objFrom", request.getBuildingId());
|
|
|
- request.setRelationTo(relationTo);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ AdmResponse response = this.query(request);
|
|
|
+
|
|
|
+ ensureSpecialValues(context, (List<AdmSpace>) response.getContent());
|
|
|
+ return response;
|
|
|
}else if(StrUtil.isNotEmpty(request.getBuildingId()) && StrUtil.isEmpty(request.getFloorId()) && !request.getBuildingId().equals("isnull")){
|
|
|
|
|
|
ObjectNode relationTo = JsonNodeFactory.instance.objectNode();
|
|
@@ -358,6 +331,43 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
}
|
|
|
|
|
|
|
|
|
+ * Description: 根据查询条件查询空间统计数据,定制接口,后续可优化口
|
|
|
+ * @param request : 请求参数
|
|
|
+ * @return : com.persagy.proxy.adm.request.AdmResponse
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/10/28 21:07
|
|
|
+ * Update By lijie 2021/10/28 21:07
|
|
|
+ */
|
|
|
+ private AdmResponse query(AdmDCSQueryRequest request) {
|
|
|
+ String orders = request.getOrders();
|
|
|
+ List<OrderItem> orderItem = AdmQueryCriteriaHelper.toOrderItem(orders);
|
|
|
+ Set<String> classCodes = StrUtil.isBlank(request.getZoneType()) ? request.getZoneTypeList() : Sets.newHashSet(request.getZoneType());
|
|
|
+ ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
+ ObjectNode condition = objectMapper.createObjectNode();
|
|
|
+ condition.put("$null", true);
|
|
|
+ objectNode.putPOJO("floorId", condition);
|
|
|
+ List<ObjectNode> queryObjects = this.relationReportService.queryObjects(objectNode, AppContext.getContext().getGroupCode(), AppContext.getContext().getProjectId(),
|
|
|
+ null, classCodes, Sets.newHashSet("space"), orderItem);
|
|
|
+
|
|
|
+ List<AdmSpace> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(queryObjects, request.getProjection(), AdmSpace.class);
|
|
|
+
|
|
|
+ processCascade(AdmContextUtil.toDmpContext(), admVOs, request.getName(), request.getCascade());
|
|
|
+
|
|
|
+ AdmResponse response = AdmResponse.success(admVOs);
|
|
|
+ if(CollectionUtil.isEmpty(queryObjects)){
|
|
|
+ response.setTotal(0L);
|
|
|
+ response.setCount(0L);
|
|
|
+ }else {
|
|
|
+ response.setTotal((long) queryObjects.size());
|
|
|
+ }
|
|
|
+ response.setPageNumber(request.getPageNumber());
|
|
|
+ response.setPageSize(request.getPageSize());
|
|
|
+
|
|
|
+ ensureSpecialValues(AdmContextUtil.toDmpContext(), admVOs);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
* Description: 子类重写,以便处理带buildingId
|
|
|
* @param dmpRequest : 中台查询参数
|
|
|
* @return : void
|
|
@@ -373,13 +383,6 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
}
|
|
|
|
|
|
ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
- if (criteria.has("not id")) {
|
|
|
- ObjectNode objectNode = objectMapper.createObjectNode();
|
|
|
- objectNode.putPOJO("$not in", criteria.get("not id"));
|
|
|
- criteria.putPOJO("id", objectNode);
|
|
|
- criteria.remove("not id");
|
|
|
- }
|
|
|
-
|
|
|
if (criteria.has("floorId")){
|
|
|
|
|
|
ObjectNode relationTo = objectMapper.createObjectNode();
|