|
@@ -1,7 +1,6 @@
|
|
|
package com.persagy.proxy.adm.handler;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
@@ -12,23 +11,18 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.google.common.collect.Lists;
|
|
|
-import com.persagy.dmp.basic.dto.RequestData;
|
|
|
-import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
-import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
-import com.persagy.dmp.define.client.DigitalDefineFacade;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
+import com.persagy.dmp.define.entity.ObjectInfoDefine;
|
|
|
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.ObjectDigital;
|
|
|
import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
import com.persagy.proxy.adm.constant.AdmObjectType;
|
|
|
import com.persagy.proxy.adm.constant.GraphCodeEnum;
|
|
|
import com.persagy.proxy.adm.constant.RelCodeEnum;
|
|
|
+import com.persagy.proxy.adm.model.EquipmentBindPointExcel;
|
|
|
import com.persagy.proxy.adm.model.EquipmentExcel;
|
|
|
import com.persagy.proxy.adm.service.IRelationReportService;
|
|
|
import com.persagy.proxy.adm.strategy.RelationObjectContext;
|
|
@@ -63,96 +57,100 @@ public class RelationReportHandler {
|
|
|
*/
|
|
|
public List<EquipmentExcel> findEquipByNotSpace(String groupCode, String projectId) {
|
|
|
groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
+ String equipment = AdmObjectType.EQUIPMENT.getIndex();
|
|
|
|
|
|
- ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
|
|
|
- QueryCriteria objectCriteria = new QueryCriteria();
|
|
|
- ObjectNode object = objectMapper.createObjectNode();
|
|
|
- object.put("objType", AdmObjectType.EQUIPMENT.getIndex());
|
|
|
- objectCriteria.setCriteria(object);
|
|
|
-
|
|
|
- // 1.获取所有的设备类定义的className
|
|
|
- List<ObjectTypeDefine> classList = DigitalDefineFacade.queryObjectType(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, objectCriteria);
|
|
|
+ // 1.获取所有的设备对象数据
|
|
|
+ List<ObjectNode> equipList = this.relationReportService.queryObjects(groupCode, projectId, null, null, equipment, "classCode");
|
|
|
+ if (CollectionUtil.isEmpty(equipList)) {
|
|
|
+ return Lists.newArrayList();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.获取所有的设备类定义的className
|
|
|
+ List<ObjectTypeDefine> classList = this.relationReportService.queryClassList(groupCode, projectId, null, equipment, null);
|
|
|
// key-classCode, value-className
|
|
|
Map<String, String> classDefine = new HashMap<String, String>();
|
|
|
- if (CollectionUtil.isNotEmpty(classList)) {
|
|
|
- for (ObjectTypeDefine objectTypeDefine : classList) {
|
|
|
- classDefine.put(objectTypeDefine.getCode(), objectTypeDefine.getName());
|
|
|
+ for (ObjectTypeDefine objectTypeDefine : classList) {
|
|
|
+ classDefine.put(objectTypeDefine.getCode(), objectTypeDefine.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.查询出所有的边类型为 Eq2Sp 的关系数据
|
|
|
+ List<ObjectRelation> relationObjects = this.relationReportService.findRelationObjects(groupCode, projectId, null, RelCodeEnum.Eq2Sp.name());
|
|
|
+ Set<String> excludeIds = new HashSet<String>();
|
|
|
+ if (CollectionUtil.isNotEmpty(relationObjects)) {
|
|
|
+ for (ObjectRelation relationInfo : relationObjects) {
|
|
|
+ excludeIds.add(relationInfo.getObjFrom());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return this.exportEquipmentExcel(equipList, classDefine, excludeIds, groupCode, projectId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计项目下已有的设备,信息点,每个设备
|
|
|
+ *
|
|
|
+ * @param groupCode
|
|
|
+ * @param projectId
|
|
|
+ */
|
|
|
+ public List<EquipmentBindPointExcel> queryProjectBindPoint(String groupCode, String projectId) {
|
|
|
+ groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
|
|
|
+ String equipment = AdmObjectType.EQUIPMENT.getIndex();
|
|
|
+
|
|
|
+ // 1.获取项目名称
|
|
|
+ List<ObjectNode> projects = this.relationReportService.queryObjects(groupCode, projectId, projectId, AdmObjectType.PROJECT.getIndex(), null, null);
|
|
|
+ if (CollectionUtil.isEmpty(projects)) {
|
|
|
+ return Lists.newArrayList();
|
|
|
+ }
|
|
|
+ String projectName = projects.get(0).has("localName") ? projects.get(0).get("localName").asText() : null;
|
|
|
+
|
|
|
// 2.获取所有的设备对象数据
|
|
|
- objectCriteria.setOrders(Collections.singletonList(OrderItem.asc("classCode")));
|
|
|
- List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, objectCriteria);
|
|
|
+ List<ObjectNode> equipList = this.relationReportService.queryObjects(groupCode, projectId, null, null, equipment, "classCode");
|
|
|
if (CollectionUtil.isEmpty(equipList)) {
|
|
|
return Lists.newArrayList();
|
|
|
}
|
|
|
|
|
|
- // 3.查询出所有的边类型为 Eq2Sp 的关系数据
|
|
|
- QueryCriteria relationCriteria = new QueryCriteria();
|
|
|
- ObjectNode relation = objectMapper.createObjectNode();
|
|
|
- relation.put("relCode", RelCodeEnum.Eq2Sp.name());
|
|
|
- relationCriteria.setCriteria(relation);
|
|
|
- List<ObjectRelation> relationList = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, relationCriteria);
|
|
|
- Set<String> equipIds = new HashSet<String>();
|
|
|
- if (CollectionUtil.isNotEmpty(relationList)) {
|
|
|
- for (ObjectRelation relationInfo : relationList) {
|
|
|
- equipIds.add(relationInfo.getObjFrom());
|
|
|
- }
|
|
|
+ // 3.获取所有的设备、系统类定义信息
|
|
|
+ List<ObjectTypeDefine> equipClass = this.relationReportService.queryClassList(groupCode, projectId, null, equipment, null);
|
|
|
+ List<ObjectTypeDefine> systemClass = this.relationReportService.queryClassList(groupCode, projectId, null, AdmObjectType.SYSTEM.getIndex(), null);
|
|
|
+ // key-equipCode, value-equipName
|
|
|
+ Map<String, String> equipTemp = new HashMap<String, String>();
|
|
|
+ for (ObjectTypeDefine equip : equipClass) {
|
|
|
+ equipTemp.put(equip.getCode(), equip.getName());
|
|
|
+ }
|
|
|
+ // key-systemCode, value-systemName
|
|
|
+ Map<String, String> systemTemp = new HashMap<String, String>();
|
|
|
+ for (ObjectTypeDefine system : systemClass) {
|
|
|
+ systemTemp.put(system.getCode(), system.getName());
|
|
|
}
|
|
|
|
|
|
- return this.exportEquipmentExcel(equipList, classDefine, equipIds, groupCode, projectId);
|
|
|
+ // 4.获取所有的信息点
|
|
|
+ Set<String> equipCodes = equipTemp.keySet();
|
|
|
+ List<ObjectInfoDefine> funidList = this.relationReportService.queryFunidList(groupCode, projectId, equipCodes, null, null);
|
|
|
+ return this.exportEquipmentBindPointExcel(equipList, equipTemp, systemTemp, funidList, groupCode, projectId, projectName);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 构造 excel 设备数据
|
|
|
+ * 构造 excel 设备数据--不在空间内的设备数据
|
|
|
*
|
|
|
* @param equipList 设备数据集合
|
|
|
* @param classDefine 类定义信息
|
|
|
- * @param equipIds 需要剔除的设备ID集合
|
|
|
+ * @param excludeIds 需要剔除的设备ID集合
|
|
|
* @param groupCode
|
|
|
* @param projectId
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<EquipmentExcel> exportEquipmentExcel(List<ObjectNode> equipList, Map<String, String> classDefine, Set<String> equipIds, String groupCode, String projectId) {
|
|
|
+ private List<EquipmentExcel> exportEquipmentExcel(List<ObjectNode> equipList, Map<String, String> classDefine, Set<String> excludeIds, String groupCode, String projectId) {
|
|
|
// key: 设备ID,value: 建筑名称
|
|
|
Map<String, String> buildTemp = new HashMap<String, String>();
|
|
|
// key: 设备ID,value: 楼层名称
|
|
|
Map<String, String> floorTemp = new HashMap<String, String>();
|
|
|
|
|
|
- // 获取建筑名称
|
|
|
- //this.relationObjectContext.findRelationObject(groupCode, projectId, projectId);
|
|
|
- RequestData requestData = new RequestData();
|
|
|
- requestData.setGraphCode(GraphCodeEnum.MechInArch.name());
|
|
|
- requestData.setRelCode(RelCodeEnum.Eq2Bd.name());
|
|
|
- requestData.setPage(1L);
|
|
|
- requestData.setSize(500L);
|
|
|
- List<ObjectDigital> buildDigitals = DigitalObjectFacade.queryObjectListByGraphCodeAndRelCode(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, requestData);
|
|
|
- if (CollectionUtil.isNotEmpty(buildDigitals)) {
|
|
|
- for (ObjectDigital master : buildDigitals) {
|
|
|
- List<ObjectDigital> slaveDigitals = master.getRelObjs();
|
|
|
- ObjectDigital slave = CollectionUtil.isEmpty(slaveDigitals) ? null : slaveDigitals.get(0);
|
|
|
- if (slave != null) {
|
|
|
- buildTemp.put(master.getId(), slave.getLocalName());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 楼层名称
|
|
|
- requestData.setRelCode(RelCodeEnum.Eq2Fl.name());
|
|
|
- List<ObjectDigital> floorDigitals = DigitalObjectFacade.queryObjectListByGraphCodeAndRelCode(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, requestData);
|
|
|
- if (CollectionUtil.isNotEmpty(floorDigitals)) {
|
|
|
- for (ObjectDigital master : floorDigitals) {
|
|
|
- List<ObjectDigital> slaveDigitals = master.getRelObjs();
|
|
|
- ObjectDigital slave = CollectionUtil.isEmpty(slaveDigitals) ? null : slaveDigitals.get(0);
|
|
|
- if (slave != null) {
|
|
|
- floorTemp.put(master.getId(), slave.getLocalName());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ this.findBuildAndFloorName(buildTemp, floorTemp, groupCode, projectId);
|
|
|
|
|
|
// 结果封装
|
|
|
List<EquipmentExcel> excelList = new ArrayList<EquipmentExcel>();
|
|
|
for (ObjectNode equip : equipList) {
|
|
|
String id = equip.get("id") == null ? null : equip.get("id").asText();
|
|
|
- if (id != null && !equipIds.contains(id)) {
|
|
|
+ if (id != null && !excludeIds.contains(id)) {
|
|
|
EquipmentExcel excel = new EquipmentExcel();
|
|
|
excel.setId(id);
|
|
|
excel.setName(equip.get("name") == null ? null : equip.get("name").asText());
|
|
@@ -176,5 +174,144 @@ public class RelationReportHandler {
|
|
|
}
|
|
|
return excelList;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构造 excel 设备数据--统计项目下已有的设备,信息点,每个设备
|
|
|
+ *
|
|
|
+ * @param equipList
|
|
|
+ * @param equipTemp
|
|
|
+ * @param systemTemp
|
|
|
+ * @param groupCode
|
|
|
+ * @param projectId
|
|
|
+ * @param projectName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<EquipmentBindPointExcel> exportEquipmentBindPointExcel(List<ObjectNode> equipList, Map<String, String> equipTemp,
|
|
|
+ Map<String, String> systemTemp, List<ObjectInfoDefine> funidList, String groupCode, String projectId, String projectName) {
|
|
|
+ // key: 设备ID,value: 建筑名称
|
|
|
+ Map<String, String> buildTemp = new HashMap<String, String>();
|
|
|
+ // key: 设备ID,value: 楼层名称
|
|
|
+ Map<String, String> floorTemp = new HashMap<String, String>();
|
|
|
+
|
|
|
+ this.findBuildAndFloorName(buildTemp, floorTemp, groupCode, projectId);
|
|
|
+
|
|
|
+ // 信息点分类信息统计
|
|
|
+ // key: classCode, value: 信息点
|
|
|
+ Map<String, Set<String>> infoCodes = new HashMap<String, Set<String>>();
|
|
|
+ // key: classCode, value: 静态信息点的数量
|
|
|
+ Map<String, Integer> staticCount = new HashMap<String, Integer>();
|
|
|
+ // key: classCode, value: 动态信息点的数量
|
|
|
+ Map<String, Integer> dynamicCount = new HashMap<String, Integer>();
|
|
|
+ // key: classCode_infoCode, value: 动静态
|
|
|
+ Map<String, String> codeAttrbut = new HashMap<String, String>();
|
|
|
+ for (ObjectInfoDefine infoDefine : funidList) {
|
|
|
+ String classCode = infoDefine.getClassCode();
|
|
|
+ String category = infoDefine.getCategory();
|
|
|
+ if ("STATIC".equals(category)) {
|
|
|
+ int count = (staticCount.get(classCode) == null ? 0 : staticCount.get(classCode)) + 1;
|
|
|
+ staticCount.put(classCode, count);
|
|
|
+ } else {
|
|
|
+ int count = (dynamicCount.get(classCode) == null ? 0 : dynamicCount.get(classCode)) + 1;
|
|
|
+ dynamicCount.put(classCode, count);
|
|
|
+ }
|
|
|
+
|
|
|
+ codeAttrbut.put(classCode + AdmCommonConstant.UNDERLINE + infoDefine.getCode(), category);
|
|
|
+ if (infoCodes.containsKey(classCode)) {
|
|
|
+ infoCodes.get(classCode).add(infoDefine.getCode());
|
|
|
+ } else {
|
|
|
+ infoCodes.put(classCode, Sets.newHashSet(infoDefine.getCode()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 结果封装
|
|
|
+ List<EquipmentBindPointExcel> excelList = new ArrayList<EquipmentBindPointExcel>();
|
|
|
+ for (int i = 0; i < equipList.size(); i++) {
|
|
|
+ ObjectNode equip = equipList.get(i);
|
|
|
+ String id = equip.get("id") == null ? null : equip.get("id").asText();
|
|
|
+ String equipCode = equip.get("classCode") == null ? null : equip.get("classCode").asText();
|
|
|
+ String systemCode = (equipCode == null || equipCode.length() < 5) ? null : equipCode.substring(0, 4);
|
|
|
+
|
|
|
+ EquipmentBindPointExcel excel = new EquipmentBindPointExcel();
|
|
|
+ excel.setIndex(i + 1);
|
|
|
+ excel.setProjectName(projectName);
|
|
|
+ excel.setBuildName(buildTemp.get(id));
|
|
|
+ excel.setFloorName(floorTemp.get(id));
|
|
|
+ excel.setSystemCode(systemCode);
|
|
|
+ excel.setSystemName(systemTemp.get(systemCode));
|
|
|
+ excel.setEquipCode(equipCode);
|
|
|
+ excel.setEquipName(equipTemp.get(equipCode));
|
|
|
+ excel.setEquipId(id);
|
|
|
+ excel.setLocalId(equip.get("localId") == null ? null : equip.get("localId").asText());
|
|
|
+ excel.setLocalName(equip.get("localName") == null ? null : equip.get("localName").asText());
|
|
|
+
|
|
|
+ // 获取此classCode下有多少信息点、静态信息点、动态信息点
|
|
|
+ int staticNum = staticCount.get(equipCode) == null ? 0 : staticCount.get(equipCode);
|
|
|
+ int dynamicNum = dynamicCount.get(equipCode) == null ? 0 : dynamicCount.get(equipCode);
|
|
|
+ excel.setNeedPointCount(staticNum + dynamicNum);
|
|
|
+ excel.setNeedStaticPointCount(staticNum);
|
|
|
+ excel.setNeedDynamicPointCount(dynamicNum);
|
|
|
+
|
|
|
+ int nowStatic = 0;
|
|
|
+ int nowDynamic = 0;
|
|
|
+ Set<String> needCodes = infoCodes.get(equipCode);
|
|
|
+ String infos = equip.get("infos") == null ? null : equip.get("infos").asText();
|
|
|
+ if (StrUtil.isNotBlank(infos)) {
|
|
|
+ JSONObject parseObject = JSONObject.parseObject(infos);
|
|
|
+ excel.setBimId(parseObject.getString("bimId"));
|
|
|
+
|
|
|
+ // 判断已绑定多少信息点
|
|
|
+ Set<String> nowCodes = parseObject.keySet();
|
|
|
+ for (String key : nowCodes) {
|
|
|
+ if (needCodes.contains(key)) {
|
|
|
+ if ("STATIC".equals(codeAttrbut.get(equipCode + AdmCommonConstant.UNDERLINE + key))) {
|
|
|
+ nowStatic++;
|
|
|
+ } else {
|
|
|
+ nowDynamic++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ excel.setNowPointCount(nowStatic + nowDynamic);
|
|
|
+ excel.setNowStaticPointCount(nowStatic);
|
|
|
+ excel.setNowDynamicPointCount(nowDynamic);
|
|
|
+ excelList.add(excel);
|
|
|
+ }
|
|
|
+ return excelList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取建筑、楼层的名称
|
|
|
+ *
|
|
|
+ * @param buildTemp key: 设备ID,value: 建筑名称
|
|
|
+ * @param floorTemp key: 设备ID,value: 楼层名称
|
|
|
+ * @param groupCode
|
|
|
+ * @param projectId
|
|
|
+ */
|
|
|
+ private void findBuildAndFloorName(Map<String, String> buildTemp, Map<String, String> floorTemp, String groupCode, String projectId) {
|
|
|
+ // 获取建筑名称
|
|
|
+ String graphAndRelKey = GraphCodeEnum.MechInArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Eq2Bd.name();
|
|
|
+ List<ObjectDigital> buildDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey);
|
|
|
+ if (CollectionUtil.isNotEmpty(buildDigitals)) {
|
|
|
+ for (ObjectDigital master : buildDigitals) {
|
|
|
+ List<ObjectDigital> slaveDigitals = master.getRelObjs();
|
|
|
+ ObjectDigital slave = CollectionUtil.isEmpty(slaveDigitals) ? null : slaveDigitals.get(0);
|
|
|
+ if (slave != null) {
|
|
|
+ buildTemp.put(master.getId(), slave.getLocalName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取楼层名称
|
|
|
+ graphAndRelKey = GraphCodeEnum.MechInArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Eq2Fl.name();
|
|
|
+ List<ObjectDigital> floorDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey);
|
|
|
+ if (CollectionUtil.isNotEmpty(floorDigitals)) {
|
|
|
+ for (ObjectDigital master : floorDigitals) {
|
|
|
+ List<ObjectDigital> slaveDigitals = master.getRelObjs();
|
|
|
+ ObjectDigital slave = CollectionUtil.isEmpty(slaveDigitals) ? null : slaveDigitals.get(0);
|
|
|
+ if (slave != null) {
|
|
|
+ floorTemp.put(master.getId(), slave.getLocalName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|