Quellcode durchsuchen

Merge branch 'develop' of http://39.106.8.246:3003/BDTP/adm-middleware into develop

lijie vor 3 Jahren
Ursprung
Commit
1d74c6edc4

+ 22 - 27
src/main/java/com/persagy/proxy/adm/controller/AdmShaftController.java

@@ -82,39 +82,34 @@ public class AdmShaftController {
     @PostMapping("/create")
     public AdmResponse create(@RequestBody AdmCreateRequest<AdmShaft> createRequest, @QueryParam("projectId") String projectId) throws Exception {       
         List<AdmShaft> vos = CollUtil.newArrayList(createRequest.getContent());
+        List<AdmShaft> unRelationShaft = new ArrayList<>();
+        List<AdmShaft> admShafts = new ArrayList<>(vos.size());
+        List<RelationDTO> relationDTOS = new ArrayList<>(vos.size());
         vos.stream().forEach(admShaft -> {
             if (StrUtil.isEmpty(admShaft.getName())) {
                 admShaft.setName(ObjectNameUtil.objectName("竖井-"));
             }
-        });
-        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmShaft.class, vos);
-
-        //TODO 创建竖井和建筑的关系
-        /*if (!entity.buildingList.isNullOrEmpty()){
-            for (building in entity.buildingList!!) {
-                try {
-                    val rShInBd = RShInBd()
-                    rShInBd.buildingId = building.id
-                    rShInBd.shaftId = entity.id
-                    rShInBd.projectId = entity.projectId
-                    rShInBd.type = "bd2sh"
-                    val insert = rShInBdService.insert(rShInBd)
-                    if (insert) {
-                        try {
-                            *//** 发送消息 *//*
-                            RService.rabbitMqService.sendRel(Opt.projectId!!, "sh2bd","11",rShInBd.buildingId!!,rShInBd.shaftId!!)
-                        } catch (e: Exception) {
-                            e.printStackTrace()
-                        }
+            if(CollUtil.isEmpty(admShaft.getBuildingList())){
+                unRelationShaft.add(admShaft);
+            }else{
+                //插入对象 添加关系
+                List<AdmShaft> shafts = service.doInsert(AdmContextUtil.toDmpContext(), AdmShaft.class, unRelationShaft);
+                admShaft.getBuildingList().stream().forEach(admBuilding ->{
+                    if(StrUtil.isNotEmpty(admBuilding.getId())){
+                        relationDTOS.add(new RelationDTO(null, "ArchSubset", "Bd2Sh", null, shafts.get(0).getId() , admBuilding.getId()));
                     }
-                } catch (e: Exception) {
-                    e.printStackTrace()
-                }
+                });
+                admShafts.addAll(shafts);
             }
-        }*/
-
-
-        return AdmResponse.success(vos);
+        });
+        if(CollUtil.isNotEmpty(relationDTOS)){
+            relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOS);
+        }
+        if(CollUtil.isNotEmpty(unRelationShaft)){
+            List shaftList = service.doInsert(AdmContextUtil.toDmpContext(), AdmShaft.class, unRelationShaft);
+            admShafts.addAll(shaftList);
+        }
+        return AdmResponse.success(admShafts);
     }
 
     /**

+ 5 - 4
src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java

@@ -111,12 +111,13 @@ public class AdmSystemController {
         });
         List<AdmSystem> unRelationSys = new ArrayList<>();
         List<AdmSystem> admSystemList = new ArrayList<>(vos.size());
+        List<RelationDTO> relationDTOS = new ArrayList<>(vos.size());
         vos.stream().forEach(admSystem -> {
             if(CollUtil.isNotEmpty(admSystem.getBuildingFloorInfoList())){
                 List<AdmSystem> admSystems = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, CollUtil.newArrayList(admSystem));
                 //添加关系
                 String systemId = admSystems.get(0).getId();
-                List<RelationDTO> relationDTOS = new ArrayList<>(admSystem.getBuildingFloorInfoList().size());
+
                 admSystem.getBuildingFloorInfoList().forEach(info -> {
                     String floorId = info.get("FloorID") == null ? null : info.get("FloorID").textValue();
                     String buildID = info.get("BuildID") == null ? null : info.get("BuildID").textValue();
@@ -127,14 +128,14 @@ public class AdmSystemController {
                         relationDTOS.add(new RelationDTO(null, "MechForArch", "Sy2Bd", null, systemId , buildID));
                     }
                 });
-                if(CollUtil.isNotEmpty(relationDTOS)){
-                    relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOS);
-                }
                 admSystemList.addAll(admSystems);
             }else{
                 unRelationSys.add(admSystem);
             }
         });
+        if(CollUtil.isNotEmpty(relationDTOS)){
+            relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOS);
+        }
         if(CollUtil.isNotEmpty(unRelationSys)){
             List<AdmSystem> systemList = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, unRelationSys);
             admSystemList.addAll(systemList);

+ 45 - 0
src/main/java/com/persagy/proxy/adm/controller/RelationReportController.java

@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Lists;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmRelationObject;
+import com.persagy.proxy.adm.model.EquipmentExcel;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IRelationReportService;
@@ -124,6 +125,50 @@ public class RelationReportController {
 	}
 	
 	/**
+	 * 下载报告-查询key值
+	 * 
+	 * @param queryCriteria
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping("/graphic/downloads/point/key")
+	public AdmResponse downloadsPointKey(@RequestBody AdmQueryCriteria queryCriteria, HttpServletRequest request) {
+		//String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
+		//String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
+		//List<ObjectNode> relationProjectCal = this.relationReportService.getAllRelationProjectCal(groupCode, projectId);
+		return AdmResponse.success(null);
+	}
+	
+	/**
+	 * 下载报告-设备-未关联空间的设备
+	 * 设备.xlsx 是个空模板,所以这里未使用 
+	 * 
+	 * @param queryCriteria
+	 * @param request
+	 * @return
+	 */
+	@RequestMapping("/graphic/downloads/eq/not/sp")
+	public void downloadsEqNotSp(@RequestParam(required = false) String projectId, HttpServletRequest request, HttpServletResponse response) {
+		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
+		if (StrUtil.isBlank(projectId)) {
+			projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
+		}
+		try {
+            response.setContentType("application/vnd.ms-excel");
+            String encode = StandardCharsets.UTF_8.name();
+            response.setCharacterEncoding(encode);
+            // 防止中文乱码
+            String fileName = URLEncoder.encode("equipment", encode);
+            response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+            
+            List<EquipmentExcel> equipByNotSpace = this.relationReportService.findEquipByNotSpace(groupCode, projectId);
+            EasyExcel.write(response.getOutputStream(), EquipmentExcel.class).sheet(0).doWrite(equipByNotSpace);
+		} catch(Exception e) {
+			log.error("设备数据导出异常", e);
+		}
+	}
+	
+	/**
 	 * 下载报告-设备静态信息维护模板
 	 * 
 	 * @param request

+ 3 - 64
src/main/java/com/persagy/proxy/adm/model/AdmSBaseEntity.java

@@ -1,8 +1,7 @@
 package com.persagy.proxy.adm.model;
-import lombok.*;
+import com.persagy.dmp.common.model.entity.BaseEntity;
+import lombok.Data;
 
-import java.io.Serializable;
-import java.util.Date;
 import java.util.Map;
 
 /**
@@ -10,71 +9,11 @@ import java.util.Map;
  * @date 2021/9/13
  */
 @Data
-public abstract class AdmSBaseEntity<T> implements Serializable, Cloneable, Comparable {
-    /** 序列id */
-    private static final long serialVersionUID = -323111418861154334L;
-    /** hash码 */
-    @Getter(AccessLevel.NONE)
-    @Setter(AccessLevel.NONE)
-    private transient int hashCode = Integer.MIN_VALUE;
-
-    private String id;
+public abstract class AdmSBaseEntity<T> extends BaseEntity {
     /** 统计信息 */
     private Map<String, Object> statistics;
-    /** 创建时间 */
-    private Date createTime;
-    /** 最后更新日期 */
-    private Date lastUpdate;
     /** 信息点 */
     private Map<String, Object> infos;
     /** 集团编码 */
     private String groupCode;
-
-
-    @Override
-    public boolean equals (Object obj) {
-        if (null == obj) {
-            return false;
-        }
-        if (!(obj instanceof AdmSBaseEntity)) {
-            return false;
-        } else {
-            AdmSBaseEntity entity = (AdmSBaseEntity) obj;
-            if (null == this.getId() || null == entity.getId()) {
-                return false;
-            } else {
-                return (this.getId().equals(entity.getId()));
-            }
-        }
-    }
-
-    @Override
-    public int hashCode () {
-        if (Integer.MIN_VALUE != this.hashCode) {
-            return this.hashCode;
-        }
-        if (null == this.getId()) {
-            return super.hashCode();
-        }
-        String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
-        this.hashCode = hashStr.hashCode();
-        return this.hashCode;
-    }
-
-    @Override
-    public int compareTo (Object obj) {
-        if (obj.hashCode() > hashCode()) {
-            return 1;
-        } else if (obj.hashCode() < hashCode()) {
-            return -1;
-        } else {
-            return 0;
-        }
-    }
-
-    @Override
-    public Object clone() throws CloneNotSupportedException {
-        return super.clone();
-    }
-
 }

+ 60 - 0
src/main/java/com/persagy/proxy/adm/model/EquipmentExcel.java

@@ -0,0 +1,60 @@
+package com.persagy.proxy.adm.model;
+
+import org.apache.poi.ss.usermodel.Font;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.HeadFontStyle;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @version 
+ * @description 不在空间内的设备数据导出实体类
+ * @company persagy
+ * @author zhangqiankun
+ * @since 2020年11月26日:	下午12:30:39
+ */
+@Getter
+@Setter
+@HeadFontStyle(color = Font.COLOR_NORMAL)
+public class EquipmentExcel {
+	
+	@ColumnWidth(50)
+	@ExcelProperty(value = "设备id", index=0)
+	private String id;
+	
+	@ColumnWidth(25)
+	@ExcelProperty(value = "设备名称", index=1)
+	private String name;
+
+	@ColumnWidth(25)
+	@ExcelProperty(value = "设备本地名称", index=2)
+	private String localId;
+
+	@ColumnWidth(25)
+	@ExcelProperty(value = "设备本地编码", index=3)
+	private String localName;
+	
+	@ColumnWidth(50)
+	@ExcelProperty(value = "BIMID", index=4)
+	private String bimId;
+
+	@ColumnWidth(25)
+	@ExcelProperty(value = "设备类", index=5)
+	private String classCodeName;
+	
+	@ColumnWidth(25)
+	@ExcelProperty(value = "建筑", index=6)
+	private String buildName;
+	
+	@ColumnWidth(25)
+	@ExcelProperty(value = "楼层", index=7)
+	private String floorName; 
+	
+	@ColumnWidth(30)
+	@ExcelProperty(value = "模型文件名", index=8)
+	private String modelFileName;
+	
+}

+ 11 - 2
src/main/java/com/persagy/proxy/adm/service/IRelationReportService.java

@@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.define.entity.GraphDefine;
 import com.persagy.dmp.define.entity.RelationDefine;
 import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.proxy.adm.model.EquipmentExcel;
 
 /**
  * 报表/模板下载
@@ -161,6 +162,14 @@ public interface IRelationReportService {
 	List<ObjectRelation> findObjectRelationList(String groupCode, String projectId, String graphCode, String relCode);
 
 	/**
+	 * 找到不在空间内的设备数据
+	 * 
+	 * @param groupCode
+	 * @param projectId
+	 */
+	List<EquipmentExcel> findEquipByNotSpace(String groupCode, String projectId);
+	
+	/**
 	 * 查询关系总览(空表,先插入)
 	 * @param content: 模糊查询卡片名称关键字
 	 */
@@ -169,8 +178,8 @@ public interface IRelationReportService {
 	/**
 	 * 初始化项目关系计算数据
 	 * 
-	 * @param groupCode
-	 * @param projectId
+	 * @param groupCode: 集团编码
+	 * @param projectId: 项目id
 	 * @return
 	 */
 	boolean createRelationProjectCal(String groupCode, String projectId) throws JsonProcessingException;

+ 1 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AdmFloorServiceImpl.java

@@ -40,6 +40,7 @@ public class AdmFloorServiceImpl extends AbstractAdmBaseServiceImpl<AdmFloor> im
         AdmQueryCriteria request = new AdmQueryCriteria();
         request.setName(AdmFloor.OBJ_TYPE);
         request.resetRelationCond(false, "ArchSubset", "Bd2Fl", buildingId);
+        request.setOrders("floorSequenceId desc");
         AdmResponse rs = doQuery(context, request, AdmFloor.class);
         return (List<AdmFloor>) rs.getContent();
     }

+ 148 - 32
src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java

@@ -1,23 +1,17 @@
 package com.persagy.proxy.adm.service.impl;
 
 import java.time.format.DateTimeFormatter;
-import java.util.*;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.stream.Collectors;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.persagy.dmp.basic.dto.GraphParentMes;
-import com.persagy.dmp.common.context.AppContext;
-import com.persagy.dmp.common.utils.JsonHelper;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -28,30 +22,38 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 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.GraphParentMes;
 import com.persagy.dmp.basic.dto.RequestData;
 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.response.CommonResult;
+import com.persagy.dmp.define.client.DigitalDefineFacade;
 import com.persagy.dmp.define.client.DigitalGraphDefineFacade;
 import com.persagy.dmp.define.client.DigitalRelationDefineFacade;
 import com.persagy.dmp.define.entity.GraphDefine;
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.dmp.define.entity.RelationDefine;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
 import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.digital.client.DigitalRelationProjectCalFacade;
+import com.persagy.dmp.digital.entity.ObjectDigital;
 import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.dmp.digital.entity.ObjectRelationProjectCal;
 import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.constant.AdmObjectType;
 import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
-import com.persagy.proxy.adm.constant.ObjTypeMapping;
+import com.persagy.proxy.adm.constant.GraphCodeEnum;
+import com.persagy.proxy.adm.constant.RelCodeEnum;
+import com.persagy.proxy.adm.model.EquipmentExcel;
 import com.persagy.proxy.adm.service.IRelationReportService;
 import com.persagy.proxy.adm.strategy.relationdata.RelationObjectStrategy;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 
 /**
@@ -128,13 +130,13 @@ public class RelationReportService implements IRelationReportService {
 			return Lists.newArrayList();
 		}
 		List<JSONObject> result = Lists.newArrayList();
-		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmRelationTypeEnum.getGraphRelTypeMap();
+		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP;
 		Map<String, RelationDefine> relationDefineMap = queryAllRelationDefineMap(groupCode, projectId);
 		for (ObjectNode objectNode : projectList) {
 			String graphCode = objectNode.get("graphCode") == null ? null : objectNode.get("graphCode").asText();
 			String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
-			AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(graphCode + AdmCommonConstant.UNDERLINE + relCode);
-			result.add(this.fillRelationProjectCal(objectNode, graphCode,relCode,graphRelTypeMap, relationDefineMap));
+			//AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(graphCode + AdmCommonConstant.UNDERLINE + relCode);
+			result.add(this.fillRelationProjectCal(objectNode, graphCode, relCode, graphRelTypeMap, relationDefineMap, groupCode, projectId));
 		}
 		return result;
 	}
@@ -151,7 +153,7 @@ public class RelationReportService implements IRelationReportService {
 		}
 		// 获取此图类型对应项目计算数据
 		List<JSONObject> resultList = new ArrayList<>();
-		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmRelationTypeEnum.getGraphRelTypeMap();
+		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP;
 		Map<String, RelationDefine> relationDefineMap = queryAllRelationDefineMap(groupCode, projectId);
 		for (GraphDefine graphDefine : secondList) {
 			String graphCode = graphDefine.getCode();
@@ -173,7 +175,7 @@ public class RelationReportService implements IRelationReportService {
 			List<JSONObject> tempList = new ArrayList<>();
 			for (ObjectNode objectNode : projectList) {
 				String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
-				tempList.add(this.fillRelationProjectCal(objectNode,graphDefine.getCode(),relCode,graphRelTypeMap,relationDefineMap));
+				tempList.add(this.fillRelationProjectCal(objectNode, graphDefine.getCode(), relCode, graphRelTypeMap,relationDefineMap, groupCode, projectId));
 			}
 			graphObject.put("relationTypeProjectList", projectList);
 			resultList.add(graphObject);
@@ -193,10 +195,10 @@ public class RelationReportService implements IRelationReportService {
 		
 		ObjectNode objectNode = this.getRelationProjectCal(groupCode, projectId, relationTypeEnum.getGraphCode(),
 				relationTypeEnum.getRelCode(), null);
-		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmRelationTypeEnum.getGraphRelTypeMap();
+		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP;
 		Map<String, RelationDefine> relationDefineMap = queryAllRelationDefineMap(groupCode, projectId);
 		if (objectNode != null) {
-			return this.fillRelationProjectCal(objectNode,groupCode,relationTypeEnum.getRelCode(),graphRelTypeMap,relationDefineMap);
+			return this.fillRelationProjectCal(objectNode, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode(), graphRelTypeMap, relationDefineMap, groupCode, projectId);
 		}
 		
 		return new JSONObject();
@@ -332,13 +334,47 @@ public class RelationReportService implements IRelationReportService {
 		List<ObjectRelation> objectRelations = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
 		return CollectionUtil.isEmpty(objectRelations) ? Lists.newArrayList() : objectRelations;
 	}
-	/**
-	 * 初始化项目关系计算数据
-	 *
-	 * @param groupCode: 集团编码
-	 * @param projectId: 项目id
-	 * @return
-	 */
+	
+	@Override
+	public List<EquipmentExcel> findEquipByNotSpace(String groupCode, String projectId) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		// 1.获取所有的设备对象数据
+		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+		QueryCriteria objectCriteria = new QueryCriteria();
+		ObjectNode object = objectMapper.createObjectNode();
+		object.put("objType", AdmObjectType.EQUIPMENT.getIndex());
+		objectCriteria.setCriteria(object);
+		List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, objectCriteria);
+		if (CollectionUtil.isEmpty(equipList)) {
+			return Lists.newArrayList();
+		}
+		
+		// 2.获取所有的设备类定义的className
+		List<ObjectTypeDefine> classList = DigitalDefineFacade.queryObjectType(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, objectCriteria);
+		// 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());
+			}
+		}
+		
+		// 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());
+			}
+		}
+		
+		return this.exportEquipmentExcel(equipList, classDefine, equipIds, groupCode, projectId);
+	}
+	
 	@Override
 	public boolean createRelationProjectCal(String groupCode, String projectId) throws JsonProcessingException {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
@@ -410,7 +446,7 @@ public class RelationReportService implements IRelationReportService {
 		objectNode.put("zoneType", zoneType);	// 业务分区类型
 		objectNode.put("systemType", relationDefine.getSystemType());	// 风系统1,水系统0
 		objectNode.put("computeVersion", 0);	// 计算版本
-		objectNode.put("mepSystemType", CollUtil.isNotEmpty(relationDefine.getMepSystemType())
+		objectNode.putPOJO("mepSystemType", CollUtil.isNotEmpty(relationDefine.getMepSystemType())
 						? objectMapper.valueToTree(relationDefine.getMepSystemType()) :objectMapper.createArrayNode());	// 机电系统类型
 		objectNode.put("creator", AdmCommonConstant.USER_ID);	// 创建人
 		objectNode.put("modifier", AdmCommonConstant.USER_ID);	// 最后修改人
@@ -449,7 +485,7 @@ public class RelationReportService implements IRelationReportService {
 	 * @param content
 	 */
 	private void getGraphRelationProjectTree(List<JSONObject> parentList, String groupCode, String projectId, String content) {
-		boolean isQuery = StringUtils.isNotBlank(content);
+		//boolean isQuery = StringUtils.isNotBlank(content);
 		// 1.获取所有的一级,二级图类型定义
 		QueryCriteria parentCriteria = new QueryCriteria();
 		List<GraphDefine> graphDefines = DigitalGraphDefineFacade.query(groupCode, projectId,
@@ -477,7 +513,7 @@ public class RelationReportService implements IRelationReportService {
 				continue;
 			}
 			List<JSONObject> sonList = levelMap.getOrDefault(graphCode, new ArrayList<>());
-			JSONObject son = this.fillRelationProjectCal(projectRel, graphCode,relCode,graphRelTypeMap,relationDefineMap);
+			JSONObject son = this.fillRelationProjectCal(projectRel, graphCode,relCode,graphRelTypeMap,relationDefineMap, null, null);
 			sonList.add(son);
 			sonList.sort(Comparator.comparing(b -> b.getString("relationTypeCode")));
 			levelMap.put(graphCode,sonList);
@@ -611,18 +647,24 @@ public class RelationReportService implements IRelationReportService {
 	 */
 	private JSONObject fillRelationProjectCal(ObjectNode relationProject, String graphicId, String relCode,
 								Map<String, AdmRelationTypeEnum> graphRelTypeMap,
-								Map<String, RelationDefine> relationDefineMap) {
+								Map<String, RelationDefine> relationDefineMap,
+								String groupCode, String projectId) {
 		String key = graphicId + StrUtil.UNDERLINE + relCode;
 		AdmRelationTypeEnum typeEnum = graphRelTypeMap.get(key);
 		RelationDefine relationDefine = relationDefineMap.getOrDefault(key,new RelationDefine());
 		JSONObject result = new JSONObject();
+		if (StrUtil.isAllNotBlank(groupCode, projectId)) {
+			String zoneType = relationProject.has("zoneType") ? relationProject.get("zoneType").asText() : null;
+			long count = this.countRelationObject(groupCode, projectId, graphicId, relCode, zoneType);
+			result.put("count", count);
+		}
 		result.put("graphicId", graphicId);
 		result.put("computationalState",relationProject.has("computationalState")?relationProject.get("computationalState").asText():null);
 		result.put("id",relationProject.has("id")?relationProject.get("id").asText():null);
 		result.put("manual",relationProject.has("manual")?relationProject.get("manual").asText():null);
 		result.put("projectId",relationProject.has("projectId")?relationProject.get("projectId").asText():null);
-		result.put("relationType",typeEnum.getRelationType());
-		result.put("relManualType",typeEnum.getRelationType());
+		result.put("relationType", typeEnum == null ? null : typeEnum.getRelationType());
+		result.put("relManualType",typeEnum == null ? null : typeEnum.getRelationType());
 		result.put("relationTypeCode",relationProject.has("relCode")?relationProject.get("relCode").asText():null);
 		result.put("code", relationProject.has("relCode")?relationProject.get("relCode").asText():null);
 		result.put("relationTypeName",relationProject.has("relCodeName")?relationProject.get("relCodeName").asText():null);
@@ -641,4 +683,78 @@ public class RelationReportService implements IRelationReportService {
 		return result;
 	}
 
+	/**
+	 * 构造 excel 设备数据
+	 * 
+	 * @param equipList 设备数据集合
+	 * @param classDefine 类定义信息
+	 * @param equipIds 需要剔除的设备ID集合
+	 * @param groupCode 
+	 * @param projectId 
+	 * @return
+	 */
+	private List<EquipmentExcel> exportEquipmentExcel(List<ObjectNode> equipList, Map<String, String> classDefine, Set<String> equipIds, 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>();
+		
+		// 建筑名称		
+		RequestData requestData = new RequestData();
+		requestData.setGraphCode(GraphCodeEnum.MechInArch.name());
+		requestData.setRelCode(RelCodeEnum.Eq2Bd.name());
+		requestData.setPage(1L);
+		requestData.setSize(10000000L);
+		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());
+				}
+			}
+		}
+		
+		// 结果封装
+		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)) {
+				EquipmentExcel excel = new EquipmentExcel();
+				excel.setId(id);
+				excel.setName(equip.get("name") == null ? null : equip.get("name").asText());
+				excel.setLocalId(equip.get("localId") == null ? null : equip.get("localId").asText());
+				excel.setLocalName(equip.get("localName") == null ? null : equip.get("localName").asText());
+				
+				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"));
+				}
+				
+				String classCode = equip.get("classCode") == null ? null : equip.get("classCode").asText();
+				excel.setClassCodeName(classCode == null ? null : classDefine.get(classCode));
+				
+				excel.setBuildName(buildTemp.get(id));
+				excel.setFloorName(floorTemp.get(id));
+				excel.setModelFileName("T1F10模型文件v18.rvt");	// 这里写死是不对的,需要后续再补充改变
+				excelList.add(excel);
+			}
+		}
+		return excelList;
+	}
+	
 }

BIN
src/main/resources/template/设备.xlsx