|
@@ -21,11 +21,12 @@ import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
import com.persagy.proxy.adm.service.IAdmRelationService;
|
|
|
import com.persagy.proxy.adm.service.IAdmSpaceService;
|
|
|
+import com.persagy.proxy.adm.utils.AdmContextUtil;
|
|
|
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;
|
|
|
-import com.persagy.proxy.common.entity.ObjRelationDTO;
|
|
|
+import com.persagy.proxy.common.entity.RelationDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -50,22 +51,22 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
|
|
|
@Override
|
|
|
public List<AdmSpace> doInsertExt(InstanceUrlParam context, Class<AdmSpace> clazz, List<AdmSpace> voList) {
|
|
|
- Map<String, AdmSpace> spaceIdMap = CollUtil.fieldValueMap(voList, BaseEntity.PROP_ID);
|
|
|
- //key spid, value floorId
|
|
|
- Map<String, String> spId2FlId_map = voList.stream().filter(admSpace -> StrUtil.isNotEmpty(admSpace.getFloorId())).collect(Collectors.toMap(AdmSpace::getId,AdmSpace::getFloorId));
|
|
|
+ Map<String, AdmSpace> spaceMapByFlId = CollUtil.fieldValueMap(voList, "floorId");
|
|
|
//查询空间中floorId 对应的floor
|
|
|
- DmpResult<JSONArray> floors = queryFloorsByFloorIds(context, spId2FlId_map.values());
|
|
|
- ArrayList<AdmFloor> floorList = CollUtil.newArrayList(JSONUtil.toList(floors.getData().toString(),AdmFloor.class));
|
|
|
- //space.height = floor.infos.height
|
|
|
- List<AdmSpace> vos = processHeight(spaceIdMap, floorList, spId2FlId_map);
|
|
|
+ DmpResult<JSONArray> floors = queryFloorsByFloorIds(context, spaceMapByFlId.keySet());
|
|
|
+ if(CollUtil.isNotEmpty(floors.getData())){
|
|
|
+ ArrayList<AdmFloor> floorList = CollUtil.newArrayList(JSONUtil.toList(floors.getData().toString(),AdmFloor.class));
|
|
|
+ //space.height = floor.infos.height
|
|
|
+ voList = processHeight(spaceMapByFlId, floorList);
|
|
|
+ }
|
|
|
//插入空间
|
|
|
- List<AdmSpace> vosR = doInsert(context, clazz, vos);
|
|
|
+ List<AdmSpace> vosR = doInsert(context, clazz, voList);
|
|
|
//添加绑定关系
|
|
|
- DmpResult<List<ObjRelationDTO>> dmpResult = processRelations(context, vosR);
|
|
|
+ processRelations(vosR);
|
|
|
//处理关系标记
|
|
|
//TODO 处理关系标记
|
|
|
//processRelationType();
|
|
|
- return doInsert(context, clazz, vosR);
|
|
|
+ return vosR;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -139,33 +140,23 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
}
|
|
|
}else if(StrUtil.isEmpty(request.getBuildingId()) && StrUtil.isEmpty(request.getFloorId())){
|
|
|
QueryCriteria queryCriteria = ensureQueryCommParm(dmpRequest, context, zoneTypeList, "space");
|
|
|
- ObjectNode criteriaPe = queryCriteria.getCriteria();
|
|
|
+ /* ObjectNode criteriaPe = queryCriteria.getCriteria();
|
|
|
JSONObject isnull = new JSONObject();
|
|
|
- isnull.put("$null", false);
|
|
|
+ isnull.put("$null", true);
|
|
|
criteriaPe.putPOJO("floorId", isnull);
|
|
|
- queryCriteria.setCriteria(criteriaPe);
|
|
|
+ queryCriteria.setCriteria(criteriaPe);*/
|
|
|
dmpResult = queryObj(context, queryCriteria);
|
|
|
if(CollUtil.isNotEmpty(dmpResult.getData())){
|
|
|
spaceArray.addAll(dmpResult.getData());
|
|
|
}
|
|
|
}
|
|
|
- //处理查询结果转化为目标返回值
|
|
|
- List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
|
|
|
- if(CollUtil.isNotEmpty(spaceArray)){
|
|
|
- List<AdmSpace> spaceList = JSONUtil.toList(JSONUtil.toJsonStr(spaceArray), AdmSpace.class);
|
|
|
- Map<String, AdmSpace> admSpaceMap = CollUtil.fieldValueMap(spaceList, BaseEntity.PROP_ID);
|
|
|
- admSpaceMap.values().stream().forEach(admSpace -> {
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("zoneType", admSpace.getClassCode());
|
|
|
- jsonObject.put("floorId", admSpace.getFloorId());
|
|
|
- jsonObjects.add(jsonObject);
|
|
|
- });
|
|
|
- }
|
|
|
AdmResponse admResponse = new AdmResponse();
|
|
|
- admResponse.setContent(jsonObjects);
|
|
|
- admResponse.setTotal(jsonObjects.size()*1l);
|
|
|
+ admResponse.setContent(spaceArray);
|
|
|
+ admResponse.setTotal(spaceArray.size()*1l);
|
|
|
admResponse.setPageSize(request.getPageSize());
|
|
|
admResponse.setPageNumber(request.getPageNumber());
|
|
|
+ admResponse.setResult(DmpResult.SUCCESS);
|
|
|
+ admResponse.setMessage("");
|
|
|
return admResponse;
|
|
|
}
|
|
|
|
|
@@ -377,94 +368,41 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
|
|
|
|
|
|
/**
|
|
|
* space.height = floor.infos.height
|
|
|
- * @param spaceIdMap
|
|
|
+ * @param spaceMapByFlId
|
|
|
* @param floorList
|
|
|
- * @param spId2FlId_map
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<AdmSpace> processHeight(Map<String, AdmSpace> spaceIdMap, List<AdmFloor> floorList, Map<String, String> spId2FlId_map){
|
|
|
- Map<String, String> newMap = spId2FlId_map.entrySet().stream().collect(Collectors.toMap(entry -> entry.getValue(), entry -> entry.getKey()));
|
|
|
+ private List<AdmSpace> processHeight(Map<String, AdmSpace> spaceMapByFlId, List<AdmFloor> floorList){
|
|
|
floorList.forEach(admFloor -> {
|
|
|
if(CollUtil.isNotEmpty(admFloor.getInfos())){
|
|
|
Float height = (Float) admFloor.getInfos().get("height");
|
|
|
- AdmSpace admSpace = spaceIdMap.get(newMap.get(admFloor.getId()));
|
|
|
+ AdmSpace admSpace = spaceMapByFlId.get(admFloor.getId());
|
|
|
admSpace.setHeight(height);
|
|
|
}
|
|
|
});
|
|
|
- return (List<AdmSpace>) spaceIdMap.values();
|
|
|
+ return (List<AdmSpace>) spaceMapByFlId.values();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加绑定关系
|
|
|
*/
|
|
|
- private DmpResult<List<ObjRelationDTO>> processRelations(InstanceUrlParam context, List<AdmSpace> vosR){
|
|
|
- if(CollUtil.isNotEmpty(vosR)){
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
+ private void processRelations(List<AdmSpace> vosR){
|
|
|
+ if(CollUtil.isNotEmpty(vosR)) {
|
|
|
+ List<RelationDTO> relationDTOS = new ArrayList<>(vosR.size());
|
|
|
vosR.forEach(admSpace -> {
|
|
|
- JSONObject requestData = new JSONObject();
|
|
|
if (StrUtil.isNotEmpty(admSpace.getBuildingId())) {
|
|
|
- addXParam("Bd2Sp", admSpace.getBuildingId(), admSpace.getId(), requestData);
|
|
|
- addCommParam(context, requestData);
|
|
|
- jsonArray.add(requestData);
|
|
|
+ relationDTOS.add(new RelationDTO(null, "ArchSubset", "Bd2Sp", null, admSpace.getBuildingId(), admSpace.getId()));
|
|
|
}
|
|
|
if (StrUtil.isNotEmpty(admSpace.getFloorId())) {
|
|
|
- addXParam("Fl2Sp", admSpace.getFloorId(), admSpace.getId(), requestData);
|
|
|
- addCommParam(context, requestData);
|
|
|
- jsonArray.add(requestData);
|
|
|
+ relationDTOS.add(new RelationDTO(null, "ArchSubset", "Fl2Sp", null, admSpace.getFloorId(), admSpace.getId()));
|
|
|
}
|
|
|
});
|
|
|
- DmpResult<List<ObjRelationDTO>> dmpResult = rwdClient.createObjRelations(context,jsonArray);
|
|
|
- return dmpResult;
|
|
|
- }else{
|
|
|
- return null;
|
|
|
+ if (CollUtil.isNotEmpty(relationDTOS)) {
|
|
|
+ relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOS);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private JSONObject addXParam(String relCode, String masterObjType, String slaveObjType, JSONObject requestData){
|
|
|
- requestData.put("relCode", "Bd2Sp");
|
|
|
- requestData.put("graphCode", "ArchSubset");
|
|
|
- requestData.put("masterObjType", masterObjType);
|
|
|
- requestData.put("slaveObjType", slaveObjType);
|
|
|
- return requestData;
|
|
|
- }
|
|
|
-
|
|
|
- private JSONObject addCommParam(InstanceUrlParam context, JSONObject requestData){
|
|
|
- requestData.put("sign", 1);
|
|
|
- requestData.put("graphCode", context.getGroupCode());
|
|
|
- requestData.put("projectId", context.getProjectId());
|
|
|
- return requestData;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * TODO 处理关系标记
|
|
|
- */
|
|
|
- private void processRelationType(InstanceUrlParam context, List<AdmSpace> vosR){
|
|
|
- String[] relationTypes = {"sp2sp_SpaceNeighborhood_5", "sp2sp_TrafficNetwork_1", "sp2sp_ConvectionNetwork_1", "sp2sp_RadiationNetwork_1"};
|
|
|
- List<String> listtype = Arrays.asList(relationTypes);
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- listtype.forEach(type -> {
|
|
|
- JSONObject relationProjectCal = new JSONObject();
|
|
|
- addCommParam(context, relationProjectCal);
|
|
|
- //relationProjectCal.put("");
|
|
|
-
|
|
|
- });
|
|
|
- String relationType = "eq2sp_in";
|
|
|
- /**
|
|
|
- * val relationType = relationTypeProjectservice.select(SFilter.eq("projectId", projectId!!), SFilter.eq("relationType", "eq2sp_in"),SFilter.eq("zoneType", zoneSpace.classCode!!)).entity()
|
|
|
- * if (relationType!=null){
|
|
|
- * relationType.computationalState = 2
|
|
|
- * relationTypeProjectservice.update(relationType)
|
|
|
- * }
|
|
|
- */
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 清楚和空间关联的数据
|
|
|
- */
|
|
|
- private void deleteRelation(InstanceUrlParam context, String relCode, String ObjType){
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 转换为目标实体,并增加属性
|
|
|
*/
|