|
@@ -2,9 +2,12 @@ package com.persagy.proxy.adm.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
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.dto.RequestData;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.define.client.DigitalDefineFacade;
|
|
@@ -12,19 +15,20 @@ import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectFacade;
|
|
|
import com.persagy.dmp.digital.client.DigitalRelationFacade;
|
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
+import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
|
|
|
import com.persagy.proxy.adm.model.*;
|
|
|
import com.persagy.proxy.adm.request.AdmCreateRequest;
|
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
import com.persagy.proxy.adm.service.IAdmBuildingService;
|
|
|
+import com.persagy.proxy.adm.service.IAdmDictService;
|
|
|
import com.persagy.proxy.adm.service.IAdmFloorService;
|
|
|
import com.persagy.proxy.adm.service.IAdmSystemService;
|
|
|
+import com.persagy.proxy.adm.utils.AdmContextUtil;
|
|
|
import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
|
|
|
import com.persagy.proxy.adm.utils.ObjectNameUtil;
|
|
|
-import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
+import com.persagy.proxy.common.entity.DmpResult;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.json.JsonObject;
|
|
@@ -49,24 +53,21 @@ public class AdmSystemController {
|
|
|
private IAdmBuildingService buildingService;
|
|
|
@Autowired
|
|
|
private IAdmFloorService floorService;
|
|
|
- @Value("${middleware.group.code}")
|
|
|
- private String groupCode;
|
|
|
+ @Autowired
|
|
|
+ private IAdmDictService dictService;
|
|
|
|
|
|
/**
|
|
|
* 统计
|
|
|
- * @param projectId
|
|
|
+
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/count")
|
|
|
- public AdmResponse count(@QueryParam("projectId") String projectId,
|
|
|
- @RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ public AdmResponse count(@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
request.setName(AdmSystem.OBJ_TYPE);
|
|
|
request.setOnlyCount(true);
|
|
|
- return service.doQuery(context, request, AdmSystem.class);
|
|
|
+ return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -77,10 +78,8 @@ public class AdmSystemController {
|
|
|
*/
|
|
|
@PostMapping("/create")
|
|
|
public AdmResponse create(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
- vos = service.doInsert(context, AdmSystem.class, vos);
|
|
|
+ vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, vos);
|
|
|
return AdmResponse.success(vos);
|
|
|
}
|
|
|
|
|
@@ -92,8 +91,6 @@ public class AdmSystemController {
|
|
|
*/
|
|
|
@PostMapping("/create-bd-fl")
|
|
|
public AdmResponse createBdFl(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
|
|
|
Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(vos, "classCode");
|
|
@@ -103,7 +100,7 @@ public class AdmSystemController {
|
|
|
ArrayNode array = criteria.putObject("code").putArray("$in");
|
|
|
admSystemMap.keySet().stream().forEach(classCode -> array.add(classCode));
|
|
|
defineCriteria.setCriteria(criteria);
|
|
|
- List<ObjectTypeDefine> defineList = DigitalDefineFacade.queryObjectType(context.getGroupCode(),context.getProjectId(),context.getAppId(),null,defineCriteria);
|
|
|
+ List<ObjectTypeDefine> defineList = DigitalDefineFacade.queryObjectType(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),null,defineCriteria);
|
|
|
Map<String, ObjectTypeDefine> defineMap = CollUtil.fieldValueMap(defineList, "code");
|
|
|
vos.stream().forEach(admSystem -> {
|
|
|
if(StrUtil.isEmpty(admSystem.getName())){
|
|
@@ -114,7 +111,7 @@ public class AdmSystemController {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- vos = service.doInsert(context, AdmSystem.class, vos);
|
|
|
+ vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, vos);
|
|
|
return AdmResponse.success(vos);
|
|
|
}
|
|
|
|
|
@@ -125,10 +122,8 @@ public class AdmSystemController {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/delete")
|
|
|
- public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmSystem> vos) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
- service.doDelete(context, vos);
|
|
|
+ public AdmResponse delete( @RequestBody List<AdmSystem> vos) throws Exception {
|
|
|
+ service.doDelete(AdmContextUtil.toDmpContext(), vos);
|
|
|
return AdmResponse.success();
|
|
|
}
|
|
|
|
|
@@ -140,28 +135,24 @@ public class AdmSystemController {
|
|
|
*/
|
|
|
@PostMapping("/update")
|
|
|
public AdmResponse update(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
- vos = service.doUpdate(context, AdmSystem.class, vos);
|
|
|
+ vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmSystem.class, vos);
|
|
|
return AdmResponse.success(vos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 系统绑定的动态信息点或静态信息点
|
|
|
* type: static(静态),iot (动态)
|
|
|
- * @param projectId
|
|
|
+
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@GetMapping("/export")
|
|
|
- public AdmResponse exportInfos(@QueryParam("projectId") String projectId,
|
|
|
+ public AdmResponse exportInfos(
|
|
|
@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
request.setName(AdmSystem.OBJ_TYPE);
|
|
|
- return service.doQuery(context, request, AdmSystem.class);
|
|
|
+ return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -172,8 +163,6 @@ public class AdmSystemController {
|
|
|
*/
|
|
|
@PostMapping("/link-equip")
|
|
|
public AdmResponse createRelateEquip(@RequestBody JsonObject createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
String sysId = createRequest.get("sysId").toString();
|
|
|
List<String> equipIdList = (List<String>)createRequest.get("equipIdList");
|
|
|
List<ObjectNode> relations = new ArrayList<>(equipIdList.size());
|
|
@@ -184,24 +173,39 @@ public class AdmSystemController {
|
|
|
objectNode.put("objFrom", sysId);
|
|
|
objectNode.put("objTo", euipId);
|
|
|
});
|
|
|
- List<ObjectRelation> list = DigitalRelationFacade.create(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, relations);
|
|
|
+ List<ObjectRelation> list = DigitalRelationFacade.create(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, relations);
|
|
|
return AdmResponse.success(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询
|
|
|
- * @param projectId
|
|
|
+
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/query")
|
|
|
- public AdmResponse query(@QueryParam("projectId") String projectId,
|
|
|
- @RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
request.setName(AdmSystem.OBJ_TYPE);
|
|
|
- return service.doQuery(context, request, AdmSystem.class);
|
|
|
+ AdmResponse admResponse = service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
|
|
|
+ List<AdmSystem> systemList = (List<AdmSystem>) admResponse.getContent();
|
|
|
+ if(CollUtil.isNotEmpty(systemList)){
|
|
|
+ AdmDict admDict = new AdmDict();
|
|
|
+ admDict.setType(AdmSystem.OBJ_TYPE);
|
|
|
+ AdmResponse admResponseDic = dictService.queryCategory(AdmContextUtil.toDmpContext(), admDict, AdmObjectType.class);
|
|
|
+ if(CollUtil.isNotEmpty(admResponseDic.getContent())){
|
|
|
+ List<AdmObjectType> admDictList = (List<AdmObjectType>) admResponseDic.getContent();
|
|
|
+ Map<String, AdmObjectType> admDictMap = CollUtil.fieldValueMap(admDictList, "code");
|
|
|
+ systemList.stream().forEach(admSystem -> {
|
|
|
+ if(admDictMap.keySet().contains(admSystem.getClassCode())){
|
|
|
+ AdmObjectType admDictTemp = admDictMap.get(admSystem.getClassCode());
|
|
|
+ admSystem.setCategoryName(admDictTemp.getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ admResponse.setContent(systemList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return admResponse;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -209,8 +213,10 @@ public class AdmSystemController {
|
|
|
* 查询系统信息-系统建筑楼层一对多
|
|
|
* MajorName 专业名称 ,级联查询 系统分类名(categoryNames),系统下的设备(equipmentList),系统下的竖井(shaftList),业务空间(zoneSpaceBaseTableList)
|
|
|
*
|
|
|
+ * 明确建筑楼层的 adm级联 查询获取建筑楼层信息 使用正常接口 先查询楼层 再根据楼层信息拼接建筑
|
|
|
+ * 未明确建筑/未明确楼层 中台定制接口
|
|
|
+ *
|
|
|
* 这个参见中心代码,
|
|
|
- * @param projectId
|
|
|
* @param buildingId buildingId=1,未明确建筑
|
|
|
* @param floorId floorId=1,未明确楼层
|
|
|
* @param request
|
|
@@ -218,196 +224,219 @@ public class AdmSystemController {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/query-new")
|
|
|
- public AdmResponse queryNew(@QueryParam("projectId") String projectId, @QueryParam("buildingId") String buildingId,
|
|
|
+ public AdmResponse queryNew(@QueryParam("buildingId") String buildingId,
|
|
|
@QueryParam("floorId") String floorId, @RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- if(StrUtil.isEmpty(projectId)){
|
|
|
- return AdmResponse.failure("项目id为空");
|
|
|
- }
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
- if(StrUtil.isAllNotEmpty(buildingId, floorId) && !"1".equals(buildingId) && !"1".equals(floorId)){
|
|
|
- //系统级联建筑 楼层
|
|
|
- AdmResponse syses = service.doQuery(context, request, AdmSystem.class);
|
|
|
- if(CollUtil.isEmpty(syses.getContent())){
|
|
|
- return syses;
|
|
|
- }
|
|
|
- AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
|
|
|
- admQueryCriteria.setName(AdmBuilding.OBJ_TYPE);
|
|
|
- admQueryCriteria.setFilters("id = "+buildingId);
|
|
|
- AdmResponse buildings = buildingService.doQuery(context, request, AdmBuilding.class);
|
|
|
-
|
|
|
- admQueryCriteria = new AdmQueryCriteria();
|
|
|
- admQueryCriteria.setName(AdmFloor.OBJ_TYPE);
|
|
|
- admQueryCriteria.setFilters("id = "+floorId);
|
|
|
- AdmResponse floors = floorService.doQuery(context, request, AdmFloor.class);
|
|
|
+ AdmResponse syses = new AdmResponse();
|
|
|
+ if(StrUtil.isAllEmpty(buildingId,floorId)){
|
|
|
+ //case one 查询全部系统,级联建筑,建筑级联楼层
|
|
|
+ AdmQueryCriteria admQueryCriteriaBd = new AdmQueryCriteria();
|
|
|
+ admQueryCriteriaBd.setName("buildingList");
|
|
|
+ List<AdmQueryCriteria> cascadeBd = new ArrayList<>(1);
|
|
|
+ AdmQueryCriteria admQueryCriteriaFl = new AdmQueryCriteria();
|
|
|
+ admQueryCriteriaFl.setName("floor");
|
|
|
+ cascadeBd.add(admQueryCriteriaFl);
|
|
|
+ admQueryCriteriaBd.setCascade(cascadeBd);
|
|
|
+
|
|
|
+ List<AdmQueryCriteria> cascade = new ArrayList<>(1);
|
|
|
+ cascade.add(admQueryCriteriaBd);
|
|
|
+ request.setCascade(cascade);
|
|
|
+ syses = service.doQuery(AdmContextUtil.toDmpContext(),request,AdmSystem.class);
|
|
|
//处理数据 BuildingFloorInfo
|
|
|
- AdmBuildingFloorInfo buildingFloorInfo = new AdmBuildingFloorInfo();
|
|
|
- if(CollUtil.isNotEmpty(floors.getContent())){
|
|
|
- AdmFloor floor = (AdmFloor) floors.getContent().get(0);
|
|
|
- buildingFloorInfo.setFloorName(floor.getLocalName());
|
|
|
- buildingFloorInfo.setFloorID(floorId);
|
|
|
- }
|
|
|
- if(CollUtil.isNotEmpty(buildings.getContent())){
|
|
|
- AdmBuilding building = (AdmBuilding) floors.getContent().get(0);
|
|
|
- buildingFloorInfo.setBuildName(building.getLocalName());
|
|
|
- buildingFloorInfo.setBuildID(buildingId);
|
|
|
- }
|
|
|
- List<AdmSystem> admSystemList = (List<AdmSystem>) syses.getContent();
|
|
|
- admSystemList.stream().forEach( admSystem -> {
|
|
|
- admSystem.setBuildingFloorInfoList(CollUtil.newArrayList(buildingFloorInfo));
|
|
|
- });
|
|
|
- syses.setContent(admSystemList);
|
|
|
- return syses;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return null;
|
|
|
- /*
|
|
|
- QueryCriteria queryCriteria_sysInFl = new QueryCriteria();
|
|
|
- ObjectNode criteria_sysInFl = JsonNodeFactory.instance.objectNode();
|
|
|
- criteria_sysInFl.put("relCode","Sy2Fl");
|
|
|
- criteria_sysInFl.put("graphCode", "MechInArch");
|
|
|
-
|
|
|
- QueryCriteria queryCriteria_sysInBd = new QueryCriteria();
|
|
|
- ObjectNode criteria_sysInBd= JsonNodeFactory.instance.objectNode();
|
|
|
- criteria_sysInBd.put("graphCode", "MechInArch");
|
|
|
- criteria_sysInBd.put("relCode","Sy2Bd");
|
|
|
-
|
|
|
- QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
|
|
|
- ObjectNode criteria_obj = JsonNodeFactory.instance.objectNode();
|
|
|
- criteria_obj.put("objType", AdmSystem.OBJ_TYPE);
|
|
|
-
|
|
|
- Set<String> sysIds = new HashSet<>();
|
|
|
- List<ObjectRelation> relations_SysInFl = null;
|
|
|
- if(StrUtil.isAllNotEmpty(buildingId,floorId)&&!floorId.equals("1")){
|
|
|
- *//** 楼层id不为空且不为1,建筑id为空 ---> 系统和楼层关系表 取系统id 408 --> 明确建筑明确楼层->空间*//*
|
|
|
- criteria_sysInFl.put("objTo", floorId);
|
|
|
- queryCriteria_sysInFl.setCriteria(criteria_sysInFl);
|
|
|
- relations_SysInFl = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria_sysInFl);
|
|
|
- if(CollUtil.isNotEmpty(relations_SysInFl)){
|
|
|
- sysIds = relations_SysInFl.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toSet());
|
|
|
+ if(CollUtil.isNotEmpty(syses.getContent())){
|
|
|
+ List<AdmSystem> admSystemList = (List<AdmSystem>) syses.getContent();
|
|
|
+ admSystemList.stream().forEach(admSystem -> {
|
|
|
+ List<AdmBuildingFloorInfo> buildingFloorInfoList = new ArrayList<>();
|
|
|
+ List<AdmBuilding> buildingList = admSystem.getBuildingList();
|
|
|
+ if(CollUtil.isNotEmpty(buildingList)){
|
|
|
+ buildingList.stream().forEach(admBuilding -> {
|
|
|
+ List<AdmFloor> admFloorList = admBuilding.getFloor();
|
|
|
+ if(CollUtil.isNotEmpty(admFloorList)){
|
|
|
+ admFloorList.stream().forEach(floor -> {
|
|
|
+ AdmBuildingFloorInfo info = new AdmBuildingFloorInfo();
|
|
|
+ info.setBuildID(admBuilding.getId());
|
|
|
+ info.setBuildName(admBuilding.getLocalName());
|
|
|
+ info.setFloorID(floor.getId());
|
|
|
+ info.setFloorName(floor.getLocalName());
|
|
|
+ buildingFloorInfoList.add(info);
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ AdmBuildingFloorInfo info = new AdmBuildingFloorInfo();
|
|
|
+ info.setBuildID(admBuilding.getId());
|
|
|
+ info.setBuildName(admBuilding.getLocalName());
|
|
|
+ buildingFloorInfoList.add(info);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ admSystem.setBuildingFloorInfoList(buildingFloorInfoList);
|
|
|
+ admSystem.setBuildingList(null);
|
|
|
+ } else{
|
|
|
+ admSystem.setBuildingFloorInfoList(buildingFloorInfoList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ syses.setContent(admSystemList);
|
|
|
}
|
|
|
- ensureCondion(context, null, sysIds, criteria_obj,true);
|
|
|
- }else if(StrUtil.isAllNotEmpty(buildingId,floorId)&&floorId.equals("1")&&!buildingId.equals("1")){
|
|
|
- *//** 楼层id为空,建筑id不为空且不为1 ---> 系统和建筑关系表 取系统id 421*//*
|
|
|
- // 明确建筑 未明确楼层
|
|
|
- relations_SysInFl = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria_sysInFl);
|
|
|
- if(CollUtil.isNotEmpty(relations_SysInFl)){
|
|
|
- List<String> sysIds_floor = relations_SysInFl.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toList());
|
|
|
- criteria_sysInBd.put("objTo", buildingId);
|
|
|
- ArrayNode arrayNode = criteria_sysInBd.putObject("$notcontains").putArray("objFrom");
|
|
|
- sysIds_floor.stream().forEach(id -> arrayNode.add(id));
|
|
|
- queryCriteria_sysInBd.setCriteria(criteria_sysInBd);
|
|
|
- ensureCondion(context, queryCriteria_sysInBd, sysIds, criteria_obj,true);
|
|
|
+ }else{
|
|
|
+ QueryCriteria rwdQueryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
|
|
|
+ ObjectNode criteria = rwdQueryCriteria.getCriteria();
|
|
|
+ if(JSONUtil.isNull(criteria)){
|
|
|
+ return AdmResponse.failure("请求参数错误");
|
|
|
}
|
|
|
- }else if(StrUtil.isEmpty(floorId) && StrUtil.isNotEmpty(buildingId) && buildingId.equals("1")){
|
|
|
- *//** 楼层id为1,建筑id为1 ---> 系统id不在(系统和楼层关系表 取系统id 系统和建筑关系表 取系统id)之内 450*//*
|
|
|
- //未明确建筑 没有Sy2Bd关系的系统
|
|
|
- ensureCondion(context, queryCriteria_sysInBd, sysIds, criteria_obj,false);
|
|
|
- }else if(StrUtil.isEmpty(floorId) && StrUtil.isNotEmpty(buildingId) && !buildingId.equals("1")){
|
|
|
- *//** 楼层id不为空,建筑id不为空 ---> 系统和楼层关系表 取系统id 将建筑id作为条件 461*//*
|
|
|
- criteria_sysInBd.put("objTo", buildingId);
|
|
|
- queryCriteria_sysInBd.setCriteria(criteria_sysInBd);
|
|
|
- ensureCondion(context, queryCriteria_sysInBd, sysIds, criteria_obj,true);
|
|
|
- } else if(StrUtil.isAllEmpty(floorId, buildingId)){
|
|
|
- *//** 楼层id为空,建筑id为空 ---> 查询所有 *//*
|
|
|
- }
|
|
|
- queryCriteriaObj.setCriteria(criteria_obj);
|
|
|
- List<ObjectNode> systems = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
|
|
|
- if(CollUtil.isNotEmpty(systems)){
|
|
|
- List<AdmSystem> admSystemList = JSONUtil.toList(systems.toString(), AdmSystem.class);
|
|
|
- if(StrUtil.isNotEmpty(buildingId)){
|
|
|
- if(!buildingId.equals("1")){
|
|
|
- //处理数据 添加每个系统关联的建筑楼层信息, 查看全部信息展示所在建筑
|
|
|
- //查询关联的建筑信息
|
|
|
- QueryCriteria queryCriteriaInfo = new QueryCriteria();
|
|
|
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
- ArrayNode arrayNode = criteria.putObject("id").putArray("$in");
|
|
|
- arrayNode.add(buildingId);
|
|
|
- if(StrUtil.isNotEmpty(floorId)){
|
|
|
- //明确的建筑,明确的楼层 查询建筑关联的楼层信息 如果Sy2Fl -> Sy2Bd & Bd2Fl
|
|
|
- if(!floorId.equals("1")){
|
|
|
- arrayNode.add(floorId);
|
|
|
- }
|
|
|
- queryCriteriaInfo.setCriteria(criteria);
|
|
|
- List<ObjectNode> objs = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaInfo);
|
|
|
- if(CollUtil.isNotEmpty(objs)){
|
|
|
- List<ObjectDigital> objectDigitals = JSONUtil.toList(objs.toString(), ObjectDigital.class);
|
|
|
- AdmBuildingFloorInfo admBuildingFloorInfo = new AdmBuildingFloorInfo();
|
|
|
- objectDigitals.forEach(objectDigital -> {
|
|
|
- if(objectDigital.getObjType().equals(AdmFloor.OBJ_TYPE)){
|
|
|
- admBuildingFloorInfo.setFloorID(objectDigital.getId());
|
|
|
- admBuildingFloorInfo.setFloorName(objectDigital.getLocalName());
|
|
|
- }
|
|
|
- if(objectDigital.getObjType().equals(AdmBuilding.OBJ_TYPE)){
|
|
|
- admBuildingFloorInfo.setBuildID(objectDigital.getId());
|
|
|
- admBuildingFloorInfo.setBuildName(objectDigital.getLocalName());
|
|
|
- }
|
|
|
- });
|
|
|
- admSystemList.stream().forEach(admSystem -> admSystem.setBuildingFloorInfoList(CollUtil.newArrayList(admBuildingFloorInfo)));
|
|
|
- }
|
|
|
+ criteria.put("objType", AdmSystem.OBJ_TYPE);
|
|
|
+ List<AdmSystem> admSystemList = null;
|
|
|
+ if (StrUtil.isAllNotEmpty(buildingId, floorId)) {
|
|
|
+ if(!"1".equals(floorId)){
|
|
|
+ //case two 明确建筑、明确楼层的 系统
|
|
|
+ JSONObject relationFrom = new JSONObject();
|
|
|
+ relationFrom.put("relCode", "Sy2Fl");
|
|
|
+ relationFrom.put("graphCode", "MechInArch");
|
|
|
+ relationFrom.put("objTo", floorId);
|
|
|
+ criteria.putPOJO("relationFrom",relationFrom);
|
|
|
+ rwdQueryCriteria.setCriteria(criteria);
|
|
|
+ syses = service.doQuery(AdmContextUtil.toDmpContext(), rwdQueryCriteria, AdmSystem.class);
|
|
|
+ if (CollUtil.isNotEmpty(syses.getContent())) {
|
|
|
+ admSystemList = (List<AdmSystem>) syses.getContent();
|
|
|
}
|
|
|
+
|
|
|
+ }else if("1".equals(floorId)){
|
|
|
+ //case three 明确建筑 不明确楼层
|
|
|
+ admSystemList = queryNotSureObj(buildingId, rwdQueryCriteria);
|
|
|
+ //处理通用返回结果
|
|
|
+ dealRespose(syses, request);
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(admSystemList)){
|
|
|
+ //处理数据 BuildingFloorInfo
|
|
|
+ admSystemList = dealBdFlInfo(floorId,buildingId,admSystemList);
|
|
|
+ syses.setContent(admSystemList);
|
|
|
}
|
|
|
}else{
|
|
|
- //查询每个系统的建筑楼层信息
|
|
|
- Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(admSystemList, BaseEntity.PROP_ID);
|
|
|
- //查询
|
|
|
- //查询楼层
|
|
|
+ //处理通用返回结果
|
|
|
+ dealRespose(syses, request);
|
|
|
+ if(StrUtil.isNotEmpty(buildingId) && buildingId.equals("1")){
|
|
|
+ //case four 未明确建筑
|
|
|
+ admSystemList = queryNotSureObj(null, rwdQueryCriteria);
|
|
|
+ if(CollUtil.isNotEmpty(admSystemList)){
|
|
|
+ //处理数据 BuildingFloorInfo
|
|
|
+ admSystemList = dealBdFlInfo(null,null, admSystemList);
|
|
|
+ syses.setContent(admSystemList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return AdmResponse.success(systems);
|
|
|
+ if(CollUtil.isNotEmpty(admSystemList))
|
|
|
+ syses.setTotal(admSystemList.size()*1l);
|
|
|
+
|
|
|
+ }
|
|
|
+ return syses;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void dealRespose(AdmResponse syses, AdmQueryCriteria request){
|
|
|
+ syses.setPageSize(request.getPageSize());
|
|
|
+ syses.setPageNumber(request.getPageNumber());
|
|
|
+ syses.setResult(DmpResult.SUCCESS);
|
|
|
+ syses.setTotal(0L);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 查询不确定建筑/楼层的系统
|
|
|
+ * @param buildingId
|
|
|
+ * @param rwdQueryCriteria
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<AdmSystem> queryNotSureObj(String buildingId, QueryCriteria rwdQueryCriteria){
|
|
|
+ RequestData requestData = new RequestData();
|
|
|
+ String classCode = rwdQueryCriteria.getCriteria().get("classCode").textValue();
|
|
|
+ if(StrUtil.isNotEmpty(classCode)){
|
|
|
+ requestData.setClassCode(classCode);
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(buildingId)){
|
|
|
+ requestData.setBuildingId(buildingId);
|
|
|
+ }
|
|
|
+ requestData.setObjType(AdmSystem.OBJ_TYPE);
|
|
|
+ requestData.setPage(rwdQueryCriteria.getPage());
|
|
|
+ requestData.setSize(rwdQueryCriteria.getSize());
|
|
|
+ List result = DigitalObjectSimpleFacade.queryNotSureSystem(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(),null, requestData);
|
|
|
+ if(CollUtil.isNotEmpty(result)){
|
|
|
+ List<AdmSystem> admSystemList = JSONUtil.toList(result.toString(), AdmSystem.class);
|
|
|
+ return admSystemList;
|
|
|
}else{
|
|
|
- return AdmResponse.success();
|
|
|
- }*/
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- /*private void ensureCondion(InstanceUrlParam context, QueryCriteria queryCriteria_sysInBd, Set<String>sysIds, ObjectNode criteria_obj, boolean ifInCondition){
|
|
|
- if(queryCriteria_sysInBd != null){
|
|
|
- List<ObjectRelation> relations_SysInBd = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria_sysInBd);
|
|
|
- if(CollUtil.isNotEmpty(relations_SysInBd)){
|
|
|
- sysIds = relations_SysInBd.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toSet());
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 处理建筑楼层信息 建筑确定,楼层可为空
|
|
|
+ * @param floorId
|
|
|
+ * @param buildingId
|
|
|
+ * @param admSystemList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<AdmSystem> dealBdFlInfo(String floorId, String buildingId, List<AdmSystem> admSystemList){
|
|
|
+ if(CollUtil.isEmpty(admSystemList)){
|
|
|
+ return null;
|
|
|
}
|
|
|
- if(CollUtil.isNotEmpty(sysIds)){
|
|
|
- if(ifInCondition){
|
|
|
- criteria_obj.put("id", sysIds.toArray().toString());
|
|
|
- }else {
|
|
|
- ArrayNode arrayNode = criteria_obj.putObject("$notcontains").putArray("id");
|
|
|
- sysIds.stream().forEach(id -> arrayNode.add(id));
|
|
|
- }
|
|
|
+ if(StrUtil.isEmpty(buildingId)){//处理成adm目标格式
|
|
|
+ List<AdmBuildingFloorInfo> nullList = new ArrayList<>(0);
|
|
|
+ admSystemList.stream().forEach(admSystem -> {
|
|
|
+ admSystem.setBuildingFloorInfoList(nullList);
|
|
|
+ });
|
|
|
+ return admSystemList;
|
|
|
+ }
|
|
|
+ AdmResponse buildings = null;
|
|
|
+ if(StrUtil.isNotEmpty(buildingId)){
|
|
|
+ AdmQueryCriteria admQueryCriteria = getAdmQueryCriteria(AdmBuilding.OBJ_TYPE, buildingId);
|
|
|
+ buildings = buildingService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmBuilding.class);
|
|
|
}
|
|
|
- }*/
|
|
|
+ AdmResponse floors = null;
|
|
|
+ if(StrUtil.isNotEmpty(floorId)){
|
|
|
+ AdmQueryCriteria admQueryCriteria = getAdmQueryCriteria(AdmFloor.OBJ_TYPE, floorId);
|
|
|
+ floors = floorService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteria, AdmFloor.class);
|
|
|
+ }
|
|
|
+ AdmBuildingFloorInfo buildingFloorInfo = new AdmBuildingFloorInfo();
|
|
|
+ if (CollUtil.isNotEmpty(buildings.getContent())) {
|
|
|
+ AdmBuilding building = (AdmBuilding) buildings.getContent().get(0);
|
|
|
+ buildingFloorInfo.setBuildName(building.getLocalName());
|
|
|
+ buildingFloorInfo.setBuildID(buildingId);
|
|
|
+ }
|
|
|
+ if (null!=floors && CollUtil.isNotEmpty(floors.getContent())) {
|
|
|
+ AdmFloor floor = (AdmFloor) floors.getContent().get(0);
|
|
|
+ buildingFloorInfo.setFloorName(floor.getLocalName());
|
|
|
+ buildingFloorInfo.setFloorID(floorId);
|
|
|
+ }
|
|
|
+ admSystemList.stream().forEach(admSystem -> {
|
|
|
+ admSystem.setBuildingFloorInfoList(CollUtil.newArrayList(buildingFloorInfo));
|
|
|
+ });
|
|
|
+ return admSystemList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private AdmQueryCriteria getAdmQueryCriteria(String objType, String Id){
|
|
|
+ AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
|
|
|
+ admQueryCriteria.setName(objType);
|
|
|
+ admQueryCriteria.setFilters("id = " + Id);
|
|
|
+ return admQueryCriteria;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询系统信息-试图级联建筑楼层 暂未使用
|
|
|
- * @param projectId
|
|
|
+
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/query-bdfl")
|
|
|
- public AdmResponse queryUnBdFl(@QueryParam("projectId") String projectId,
|
|
|
- @RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
+ public AdmResponse queryUnBdFl(@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
request.setName(AdmSystem.OBJ_TYPE);
|
|
|
- return service.doQuery(context, request, AdmSystem.class);
|
|
|
+ return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmSystem.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询没有和当前系统关联的设备
|
|
|
* id 为系统id
|
|
|
- * @param projectId
|
|
|
+
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/un-sys-equip")
|
|
|
- public AdmResponse queryUnEquip(@QueryParam("projectId") String projectId, @NotNull @QueryParam("sysId") String sysId,
|
|
|
+ public AdmResponse queryUnEquip( @NotNull @QueryParam("sysId") String sysId,
|
|
|
@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
- AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Eq","MechSubset", AdmEquipment.OBJ_TYPE);
|
|
|
+ AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Eq","MechSubset", AdmEquipment.OBJ_TYPE);
|
|
|
return admResponse;
|
|
|
}
|
|
|
|
|
@@ -415,17 +444,15 @@ public class AdmSystemController {
|
|
|
/**
|
|
|
* 查询没有和当前系统关联的竖井
|
|
|
* id 为系统id
|
|
|
- * @param projectId
|
|
|
+
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/un-sys-shaft")
|
|
|
- public AdmResponse queryUnSh(@QueryParam("projectId") String projectId, @NotNull @QueryParam("sysId") String sysId,
|
|
|
+ public AdmResponse queryUnSh( @NotNull @QueryParam("sysId") String sysId,
|
|
|
@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
- AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Sh",null, AdmShaft.OBJ_TYPE);
|
|
|
+ AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sh",null, AdmShaft.OBJ_TYPE);
|
|
|
return admResponse;
|
|
|
}
|
|
|
|
|
@@ -433,17 +460,14 @@ public class AdmSystemController {
|
|
|
/**
|
|
|
* 查询没有和当前系统关联的业务空间
|
|
|
* id 为系统id
|
|
|
- * @param projectId
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/un-sys-zoneSpaceBaseTable")
|
|
|
- public AdmResponse queryUnZoneSp(@QueryParam("projectId") String projectId,@NotNull @QueryParam("sysId") String sysId,
|
|
|
+ public AdmResponse queryUnZoneSp(@NotNull @QueryParam("sysId") String sysId,
|
|
|
@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
- AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Sp",null, AdmSpace.OBJ_TYPE);
|
|
|
+ AdmResponse admResponse = queryObjectByType(sysId,request,"Sy2Sp",null, AdmSpace.OBJ_TYPE);
|
|
|
return admResponse;
|
|
|
}
|
|
|
|
|
@@ -451,18 +475,15 @@ public class AdmSystemController {
|
|
|
/**
|
|
|
* 查询没有和当前空间绑定的系统
|
|
|
* 例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 spaceId 为当前空间id type为当前空间类型
|
|
|
- * @param projectId
|
|
|
* @param request
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/unspace-sys")
|
|
|
- public AdmResponse queryUnSpSy(@QueryParam("projectId") String projectId, @QueryParam("type") String type, @QueryParam("spaceId") String spaceId,
|
|
|
+ public AdmResponse queryUnSpSy( @QueryParam("type") String type, @QueryParam("spaceId") String spaceId,
|
|
|
@RequestBody AdmQueryCriteria request) throws Exception {
|
|
|
- // 组装上下文条件
|
|
|
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
|
|
|
if(StrUtil.isNotEmpty(spaceId)){
|
|
|
- AdmResponse admResponse = queryObjectByType(context, spaceId, request,"Sy2Sp",null, AdmSystem.OBJ_TYPE);
|
|
|
+ AdmResponse admResponse = queryObjectByType(spaceId, request,"Sy2Sp",null, AdmSystem.OBJ_TYPE);
|
|
|
return admResponse;
|
|
|
}else{
|
|
|
if(StrUtil.isNotEmpty(type)){
|
|
@@ -470,7 +491,7 @@ public class AdmSystemController {
|
|
|
ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
|
|
|
criteriaObj.put("objType", AdmSpace.OBJ_TYPE);
|
|
|
queryCriteriaObj.setCriteria(criteriaObj);
|
|
|
- List<ObjectNode> objs = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
|
|
|
+ List<ObjectNode> objs = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
|
|
|
|
|
|
QueryCriteria queryCriteriaObjSys = AdmQueryCriteriaHelper.toDmpCriteria(request);
|
|
|
ObjectNode criteriaSys = JsonNodeFactory.instance.objectNode();
|
|
@@ -482,7 +503,7 @@ public class AdmSystemController {
|
|
|
}
|
|
|
}
|
|
|
queryCriteriaObj.setCriteria(criteriaObj);
|
|
|
- List<ObjectNode> syses = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObjSys);
|
|
|
+ List<ObjectNode> syses = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObjSys);
|
|
|
return AdmResponse.success(syses);
|
|
|
}
|
|
|
return AdmResponse.success();
|
|
@@ -490,7 +511,7 @@ public class AdmSystemController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private AdmResponse queryObjectByType(InstanceUrlParam context, String sysId, AdmQueryCriteria request, String relCode, String graphCode, String objType){
|
|
|
+ private AdmResponse queryObjectByType(String sysId, AdmQueryCriteria request, String relCode, String graphCode, String objType){
|
|
|
QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
criteria.put("objFrom", sysId);
|
|
@@ -501,7 +522,7 @@ public class AdmSystemController {
|
|
|
queryCriteria.setCriteria(criteria);
|
|
|
queryCriteria.setSize(request.getPageSize()*1L);
|
|
|
queryCriteria.setPage(request.getPageNumber()*1L);
|
|
|
- List<ObjectRelation> relations = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria);
|
|
|
+ List<ObjectRelation> relations = DigitalRelationFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteria);
|
|
|
|
|
|
QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
|
|
|
ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
|
|
@@ -512,7 +533,7 @@ public class AdmSystemController {
|
|
|
objectRelationMap.keySet().stream().forEach(id -> arrayNode.add(id));
|
|
|
}
|
|
|
queryCriteriaObj.setCriteria(criteriaObj);
|
|
|
- List<ObjectNode> obj = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
|
|
|
+ List<ObjectNode> obj = DigitalObjectFacade.query(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(), null, queryCriteriaObj);
|
|
|
return AdmResponse.success(obj);
|
|
|
}
|
|
|
}
|