|
@@ -5,6 +5,9 @@ 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.digital.entity.ObjectRelation;
|
|
|
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
+import com.persagy.proxy.adm.service.IAdmRelationService;
|
|
|
import com.persagy.proxy.adm.service.impl.AbstractAdmBaseServiceImpl;
|
|
|
import com.persagy.proxy.object.model.AdmEquipment;
|
|
|
import com.persagy.proxy.dictionary.model.AdmPlanarEquipRequests;
|
|
@@ -14,6 +17,7 @@ import com.persagy.proxy.object.service.IAdmEquipmentService;
|
|
|
import com.persagy.proxy.dictionary.service.IAdmPlanarService;
|
|
|
import com.persagy.proxy.object.service.IAdmSpaceService;
|
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,6 +25,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
/**
|
|
|
* @ClassName AdmPlanarServiceImpl
|
|
@@ -30,6 +35,7 @@ import java.util.stream.Collectors;
|
|
|
* @Version V1.0
|
|
|
**/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implements IAdmPlanarService {
|
|
|
|
|
|
@Autowired
|
|
@@ -37,7 +43,10 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
|
|
|
@Autowired
|
|
|
private IAdmEquipmentService equipmentService;
|
|
|
-
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAdmRelationService relationService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询平面图设备信息
|
|
|
* @param context
|
|
@@ -48,15 +57,110 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
*/
|
|
|
@Override
|
|
|
public AdmResponse queryPlanarEquip(InstanceUrlParam context, AdmPlanarEquipRequests requests, Class<AdmEquipment> clazz) throws Exception {
|
|
|
- List<AdmSpace> spaces = new ArrayList<>();
|
|
|
+
|
|
|
+ if(CollUtil.isEmpty(requests.getZoneTypes()) && CollUtil.isEmpty(requests.getSpaceIds()) && CollUtil.isEmpty(requests.getFuncTypes())){
|
|
|
+ //查询建筑楼层下的所有设备(或指定类型下的设备)
|
|
|
+ return queryAdmEquip(context,requests,clazz);
|
|
|
+ }else{
|
|
|
+ //查询空间下的设备
|
|
|
+ return queryAdmEquipInSpace(context,requests,clazz);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询ADM设备信息
|
|
|
+ * @param context
|
|
|
+ * @param request
|
|
|
+ * @param clazz
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private AdmResponse queryAdmEquip(InstanceUrlParam context, AdmPlanarEquipRequests request,Class<AdmEquipment> clazz){
|
|
|
+ //增加过滤条件
|
|
|
+ StringBuilder filters = new StringBuilder();
|
|
|
+ filters.append("buildingId = "+ request.getBuildingId() +";");
|
|
|
+ if(StringUtils.isNotEmpty(request.getFloorId())){
|
|
|
+ filters.append("floorId = "+ request.getFloorId() +";");
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(request.getEquipTypes())){
|
|
|
+ filters.append("classCode in "+"(\'" + java.lang.String.join("\',\'", request.getEquipTypes()) + "\')");
|
|
|
+ }
|
|
|
+ AdmQueryCriteria equipQueryCriteria = new AdmQueryCriteria();
|
|
|
+ equipQueryCriteria.setFilters(filters.toString());
|
|
|
+ equipQueryCriteria.setOrders("createTime desc, id desc");
|
|
|
+
|
|
|
+ //级联查询建筑楼层
|
|
|
+ /* List<AdmQueryCriteria> cascades = new ArrayList<>();
|
|
|
+ AdmQueryCriteria buildCascade = new AdmQueryCriteria();
|
|
|
+ buildCascade.setName("building");
|
|
|
+ cascades.add(buildCascade);
|
|
|
+ AdmQueryCriteria floorCascade = new AdmQueryCriteria();
|
|
|
+ floorCascade.setName("floor");
|
|
|
+ cascades.add(floorCascade);
|
|
|
+ equipQueryCriteria.setCascade(cascades);*/
|
|
|
+
|
|
|
+ log.info(equipQueryCriteria.toString());
|
|
|
+ return equipmentService.doQuery(context, equipQueryCriteria, clazz);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询ADM设备信息
|
|
|
+ * @param context
|
|
|
+ * @param request
|
|
|
+ * @param clazz
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private AdmResponse queryAdmSpace(InstanceUrlParam context, AdmPlanarEquipRequests request,Class<AdmSpace> clazz){
|
|
|
+ //增加过滤条件
|
|
|
+ StringBuilder filters = new StringBuilder();
|
|
|
+ filters.append("buildingId = "+ request.getBuildingId() +";");
|
|
|
+ if(StringUtils.isNotEmpty(request.getFloorId())){
|
|
|
+ filters.append("floorId = "+ request.getFloorId() +";");
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(request.getZoneTypes())){
|
|
|
+ filters.append("classCode in "+"(\'" + java.lang.String.join("\',\'", request.getZoneTypes()) + "\')");
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(request.getSpaceIds())){
|
|
|
+ filters.append("id in "+"(\'" + java.lang.String.join("\',\'", request.getSpaceIds()) + "\')");
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(request.getFuncTypes())){
|
|
|
+ filters.append("roomFuncType in "+"(\'" + java.lang.String.join("\',\'", request.getFuncTypes()) + "\')");
|
|
|
+ }
|
|
|
+ AdmQueryCriteria equipQueryCriteria = new AdmQueryCriteria();
|
|
|
+ equipQueryCriteria.setFilters(filters.toString());
|
|
|
+ equipQueryCriteria.setOrders("createTime desc, id desc");
|
|
|
+
|
|
|
+ //级联查询建筑楼层-测试用
|
|
|
+ /* List<AdmQueryCriteria> cascades = new ArrayList<>();
|
|
|
+ AdmQueryCriteria buildCascade = new AdmQueryCriteria();
|
|
|
+ buildCascade.setName("building");
|
|
|
+ cascades.add(buildCascade);
|
|
|
+ AdmQueryCriteria floorCascade = new AdmQueryCriteria();
|
|
|
+ floorCascade.setName("floor");
|
|
|
+ cascades.add(floorCascade);
|
|
|
+ equipQueryCriteria.setCascade(cascades);*/
|
|
|
+ log.info(equipQueryCriteria.toString());
|
|
|
+ return spaceService.doQuery(context, equipQueryCriteria, clazz);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询ADM空间下的设备信息
|
|
|
+ * @param context
|
|
|
+ * @param requests
|
|
|
+ * @param clazz
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private AdmResponse queryAdmEquipInSpace(InstanceUrlParam context, AdmPlanarEquipRequests requests,Class<AdmEquipment> clazz){
|
|
|
//获取空间信息
|
|
|
- if(CollUtil.isEmpty(requests.getSpaceIds())){
|
|
|
+ /*if(CollUtil.isEmpty(requests.getSpaceIds())){
|
|
|
//查询建筑/楼层下的空间信息
|
|
|
spaces = querySpInFl(context, requests, AdmSpace.class);
|
|
|
}else{
|
|
|
//根据空间功能类型等过滤空间信息
|
|
|
spaces = queryDmpSpace(context, requests, AdmSpace.class);
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ AdmResponse admSpaceResponse = queryAdmSpace(context, requests, AdmSpace.class);
|
|
|
+ List<AdmSpace> spaces = (List<AdmSpace>) admSpaceResponse.getContent();
|
|
|
if(CollUtil.isEmpty(spaces)){
|
|
|
return AdmResponse.success(new ArrayList<>());
|
|
|
}
|
|
@@ -68,7 +172,6 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
response.setTotal(result == null ? 0 : Long.valueOf(result.size()));
|
|
|
return response;
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 查询平面图空间
|
|
|
* @param context
|
|
@@ -79,7 +182,7 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
*/
|
|
|
@Override
|
|
|
public AdmResponse queryPlanarSpace(InstanceUrlParam context, AdmPlanarEquipRequests requests, Class<AdmSpace> clazz) throws Exception {
|
|
|
- List<AdmSpace> spaces = new ArrayList<>();
|
|
|
+ /* List<AdmSpace> spaces = new ArrayList<>();
|
|
|
//获取空间信息
|
|
|
if(CollUtil.isEmpty(requests.getSpaceIds())){
|
|
|
//查询建筑/楼层下的空间信息
|
|
@@ -87,10 +190,8 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
}else{
|
|
|
//根据空间功能类型等过滤空间信息
|
|
|
spaces = queryDmpSpace(context, requests, AdmSpace.class);
|
|
|
- }
|
|
|
- AdmResponse response = AdmResponse.success(spaces);
|
|
|
- response.setTotal(spaces == null ? 0 : Long.valueOf(spaces.size()));
|
|
|
- return response;
|
|
|
+ }*/
|
|
|
+ return queryAdmSpace(context, requests, clazz);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -100,11 +201,14 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
* @return
|
|
|
*/
|
|
|
private List<AdmSpace> querySpInFl(InstanceUrlParam context, AdmPlanarEquipRequests requests, Class<AdmSpace> clazz){
|
|
|
+ if(CollUtil.isEmpty(requests.getZoneTypes()) && CollUtil.isNotEmpty(requests.getFuncTypes())){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
|
|
|
//设置空间基础查询条件
|
|
|
ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
if(CollUtil.isNotEmpty(requests.getZoneTypes())){
|
|
|
- ArrayNode array = criteria.putObject("objType").putArray("$in");
|
|
|
+ ArrayNode array = criteria.putObject("classCode").putArray("$in");
|
|
|
requests.getZoneTypes().forEach(code -> array.add(code));
|
|
|
}
|
|
|
|
|
@@ -112,11 +216,6 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
ArrayNode array = criteria.putObject("roomFuncType").putArray("$in");
|
|
|
requests.getFuncTypes().forEach(code -> array.add(code));
|
|
|
}
|
|
|
- if(CollUtil.isNotEmpty(requests.getEquipTypes())){
|
|
|
- ArrayNode array = criteria.putObject("classCode").putArray("$in");
|
|
|
- requests.getEquipTypes().forEach(code -> array.add(code));
|
|
|
- }
|
|
|
-
|
|
|
//设置空间关系查询条件
|
|
|
QueryCriteria dmpRequest = new QueryCriteria();
|
|
|
if(StringUtils.isEmpty(requests.getFloorId())){
|
|
@@ -142,20 +241,28 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
if(CollUtil.isEmpty(spaceIds)){
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- //默认业务空间数量不会太多,若多的话后期进行优化
|
|
|
- List<AdmEquipment> result = new ArrayList<>();
|
|
|
- for (String spaceId : spaceIds) {
|
|
|
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
- //设置设备关系查询条件
|
|
|
- QueryCriteria dmpRequest = transDmpRelationCriteria(criteria,"MechInArch", "Eq2Sp", spaceId, 1);
|
|
|
- //查询物理世界对象信息
|
|
|
- AdmResponse response = equipmentService.doQuery(context, dmpRequest, clazz);
|
|
|
- List<AdmEquipment> content = (List<AdmEquipment>) response.getContent();
|
|
|
- if(CollUtil.isNotEmpty(content)){
|
|
|
- result.addAll(content);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
+ //查询关系数据
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
+ ObjectNode criteria = JsonNodeFactory.instance.objectNode();
|
|
|
+ criteria.put("graphCode","MechInArch");
|
|
|
+ criteria.put("relCode","Eq2Sp");
|
|
|
+ ArrayNode objNode = criteria.putArray("objTo");
|
|
|
+ spaceIds.forEach(id -> objNode.add(id));
|
|
|
+ queryCriteria.setCriteria(criteria);
|
|
|
+ List<ObjectRelation> relationList = relationService.queryByCondition(context, queryCriteria);
|
|
|
+ Set<String> equipIds = relationList.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ //查询设备信息
|
|
|
+ QueryCriteria equipQueryCriteria = new QueryCriteria();
|
|
|
+ ObjectNode equipCriteria = JsonNodeFactory.instance.objectNode();
|
|
|
+ ArrayNode idNode = equipCriteria.putArray("id");
|
|
|
+ equipIds.forEach(id -> idNode.add(id));
|
|
|
+ ArrayNode classCodeNode = equipCriteria.putArray("classCode");
|
|
|
+ requests.getEquipTypes().forEach(classCode -> classCodeNode.add(classCode));
|
|
|
+ equipQueryCriteria.setCriteria(equipCriteria);
|
|
|
+ AdmResponse admResponse = equipmentService.doQuery(context, equipQueryCriteria, clazz);
|
|
|
+
|
|
|
+ return (List<AdmEquipment>) admResponse.getContent();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -178,10 +285,6 @@ public class AdmPlanarServiceImpl extends AbstractAdmBaseServiceImpl<T> implemen
|
|
|
ArrayNode array = criteria.putObject("objType").putArray("$in");
|
|
|
requests.getZoneTypes().forEach(code -> array.add(code));
|
|
|
}
|
|
|
- if(CollUtil.isNotEmpty(requests.getEquipTypes())){
|
|
|
- ArrayNode array = criteria.putObject("classCode").putArray("$in");
|
|
|
- requests.getEquipTypes().forEach(code -> array.add(code));
|
|
|
- }
|
|
|
QueryCriteria dmpRequest = new QueryCriteria();
|
|
|
dmpRequest.setCriteria(criteria);
|
|
|
|