Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/develop' into develop

linhuili 3 rokov pred
rodič
commit
b34f6af3ef
39 zmenil súbory, kde vykonal 782 pridanie a 342 odobranie
  1. 4 3
      src/main/java/com/persagy/proxy/adm/constant/AdmRelationTypeEnum.java
  2. 3 1
      src/main/java/com/persagy/proxy/adm/controller/AdmEquipShaftController.java
  3. 23 45
      src/main/java/com/persagy/proxy/adm/controller/AdmShaftController.java
  4. 3 3
      src/main/java/com/persagy/proxy/adm/controller/AdmSpaceController.java
  5. 38 11
      src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java
  6. 97 6
      src/main/java/com/persagy/proxy/adm/controller/RelationReportController.java
  7. 11 14
      src/main/java/com/persagy/proxy/adm/controller/RelationShInBdController.java
  8. 180 0
      src/main/java/com/persagy/proxy/adm/handler/RelationReportHandler.java
  9. 6 1
      src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java
  10. 3 64
      src/main/java/com/persagy/proxy/adm/model/AdmSBaseEntity.java
  11. 2 2
      src/main/java/com/persagy/proxy/adm/model/AdmShaft.java
  12. 2 2
      src/main/java/com/persagy/proxy/adm/model/AdmSpace.java
  13. 5 0
      src/main/java/com/persagy/proxy/adm/model/AdmSystem.java
  14. 60 0
      src/main/java/com/persagy/proxy/adm/model/EquipmentExcel.java
  15. 96 0
      src/main/java/com/persagy/proxy/adm/model/EquipmentExcel2.java
  16. 4 4
      src/main/java/com/persagy/proxy/adm/service/IRelationReportService.java
  17. 4 1
      src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java
  18. 1 0
      src/main/java/com/persagy/proxy/adm/service/impl/AdmFloorServiceImpl.java
  19. 2 2
      src/main/java/com/persagy/proxy/adm/service/impl/AdmSpaceServiceImpl.java
  20. 208 116
      src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java
  21. 12 51
      src/main/java/com/persagy/proxy/adm/strategy/RelationObjectContext.java
  22. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2BdRelationObject.java
  23. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2FlRelationObject.java
  24. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2ShRelationObject.java
  25. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2SpRelationObject.java
  26. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSp2BdRelationObject.java
  27. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSp2FlRelationObject.java
  28. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchEq2BdRelationObject.java
  29. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchEq2FlRelationObject.java
  30. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchEq2ShRelationObject.java
  31. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2BdRelationObject.java
  32. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2FlRelationObject.java
  33. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2ShRelationObject.java
  34. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2SpRelationObject.java
  35. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechInArchEq2BdRelationObject.java
  36. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechInArchEq2FlRelationObject.java
  37. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechInArchEq2SpRelationObject.java
  38. 2 0
      src/main/java/com/persagy/proxy/adm/utils/AdmQueryCriteriaHelper.java
  39. BIN
      src/main/resources/template/设备.xlsx

+ 4 - 3
src/main/java/com/persagy/proxy/adm/constant/AdmRelationTypeEnum.java

@@ -382,7 +382,8 @@ public enum AdmRelationTypeEnum {
      */
     public static Map<String,AdmRelationTypeEnum> getRelationTypeMap(){
         List<AdmRelationTypeEnum> enumList = EnumUtils.getEnumList(AdmRelationTypeEnum.class);
-        return enumList.stream().collect(Collectors.toMap(AdmRelationTypeEnum::getRelationType,admRelationTypeEnum -> admRelationTypeEnum));
+        return enumList.stream().collect(Collectors.toMap(AdmRelationTypeEnum::getRelationType,
+                admRelationTypeEnum -> admRelationTypeEnum,(k1,k2)->k1));
     }
     
     /***
@@ -395,8 +396,8 @@ public enum AdmRelationTypeEnum {
      */
     public static Map<String,AdmRelationTypeEnum> getGraphRelTypeMap(){
         List<AdmRelationTypeEnum> enumList = EnumUtils.getEnumList(AdmRelationTypeEnum.class);
-        return enumList.stream().collect(Collectors.toMap(k -> k.getGraphCode() + AdmCommonConstant.UNDERLINE + k.getRelCode(),
-        		admRelationTypeEnum -> admRelationTypeEnum));
+        return enumList.stream().collect(Collectors.toMap(k -> (k.getGraphCode() + AdmCommonConstant.UNDERLINE + k.getRelCode()),
+        		admRelationTypeEnum -> admRelationTypeEnum,(k1,k2)->k1));
     }
 
 }

+ 3 - 1
src/main/java/com/persagy/proxy/adm/controller/AdmEquipShaftController.java

@@ -67,6 +67,8 @@ public class AdmEquipShaftController {
         request.setName(AdmEquipment.OBJ_TYPE);
         // 设置关系条件
         request.resetRelationCond(true, "MechInArch", "Eq2Sh", shaftId, false);
+        // TODO 级别获取设备类别对象未处理,再单独查一次即可
+
         return equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
     }
 
@@ -241,7 +243,7 @@ public class AdmEquipShaftController {
         ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
         criteriaRel.put("graphCode", "ArchSubset");
         criteriaRel.put("relCode", "Sh2Sp");
-        criteriaRel.put("refValue", objectType);
+        criteriaRel.put("relValue", objectType);
         criteriaRel.put("objFrom", shaftId);
         queryRequest.setCriteria(criteriaRel);
         List<ObjectRelation> relations = relationService.queryByCondition(context, queryRequest);

+ 23 - 45
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);
     }
 
     /**
@@ -152,24 +147,7 @@ public class AdmShaftController {
     @PostMapping("/query")
     public AdmResponse query(@RequestBody AdmQueryCriteria request) throws Exception {      
         request.setName(AdmShaft.OBJ_TYPE);
-        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
-        ObjectNode criteria = queryCriteria.getCriteria();
-        //查询参数特殊处理 处理成中台可以识别的条件
-        if(!JSONUtil.isNull(criteria)){
-           Map<String, Object> criteriaMap = objectMapper.convertValue(criteria, Map.class);
-           if(CollUtil.isNotEmpty(criteriaMap)){
-               ObjectNode criteriaNew = JsonNodeFactory.instance.objectNode();
-               criteriaMap.keySet().stream().forEach(key -> {
-                   if(key.startsWith("infos.")){
-                        criteriaNew.put(key.substring(6), criteriaMap.get(key).toString());
-                   }else{
-                       criteriaNew.put(key, criteriaMap.get(key).toString());
-                   }
-               });
-               queryCriteria.setCriteria(criteriaNew);
-           }
-        }
-        return service.doQuery(AdmContextUtil.toDmpContext(), queryCriteria, AdmShaft.class);
+        return service.doQuery(AdmContextUtil.toDmpContext(), request, AdmShaft.class);
     }
 
     /**

+ 3 - 3
src/main/java/com/persagy/proxy/adm/controller/AdmSpaceController.java

@@ -65,7 +65,7 @@ public class AdmSpaceController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmSpace> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmSpace> createRequest) throws Exception {
         List<AdmSpace> vos = CollUtil.newArrayList(createRequest.getContent());
         String msg = null;
         for (AdmSpace admSpace : vos) {
@@ -255,7 +255,7 @@ public class AdmSpaceController {
      * @throws Exception
      */
     @PostMapping("/update-outline")
-    public AdmResponse updateOutLine(@RequestBody AdmCreateRequest<AdmSpace> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse updateOutLine(@RequestBody AdmCreateRequest<AdmSpace> createRequest) throws Exception {
         List<AdmSpace> vos = CollUtil.newArrayList(createRequest.getContent());
         vos = service.doUpdate( AdmContextUtil.toDmpContext(), AdmSpace.class, vos);
         //TODO 更新计算关系ZoneSpaceBaseService.upDateOutline
@@ -295,7 +295,7 @@ public class AdmSpaceController {
      * @throws Exception
      */
     @PostMapping("/space-type")
-    public List<JSONObject> querySpaceType(@QueryParam("projectId") String projectId) throws Exception {
+    public List<JSONObject> querySpaceType() throws Exception {
         return service.doQuerySpaceTypes( AdmContextUtil.toDmpContext());
     }
 

+ 38 - 11
src/main/java/com/persagy/proxy/adm/controller/AdmSystemController.java

@@ -20,24 +20,19 @@ 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.service.*;
 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.DmpResult;
+import com.persagy.proxy.common.entity.RelationDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.json.JsonObject;
 import javax.validation.constraints.NotNull;
 import javax.ws.rs.QueryParam;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Adm 系统 API
@@ -56,6 +51,8 @@ public class AdmSystemController {
     private IAdmFloorService floorService;
     @Autowired
     private IAdmDictService dictService;
+    @Autowired
+    private IAdmRelationService relationService;
 
     /**
      * 统计
@@ -91,7 +88,7 @@ public class AdmSystemController {
      * @throws Exception
      */
     @PostMapping("/create-bd-fl")
-    public AdmResponse createBdFl(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse createBdFl(@RequestBody AdmCreateRequest<AdmSystem> createRequest) throws Exception {
         List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
 
         Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(vos, "classCode");
@@ -112,8 +109,38 @@ public class AdmSystemController {
                 }
             }
         });
-        vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmSystem.class, vos);
-        return AdmResponse.success(vos);
+        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();
+
+                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();
+                    if(StrUtil.isNotEmpty(floorId)){
+                        relationDTOS.add(new RelationDTO(null, "MechInArch", "Bd2Fl", null, systemId , floorId));
+                    }
+                    if(StrUtil.isNotEmpty(buildID)){
+                        relationDTOS.add(new RelationDTO(null, "MechForArch", "Sy2Bd", null, systemId , buildID));
+                    }
+                });
+                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);
+        }
+        return AdmResponse.success(admSystemList);
     }
 
     /**

+ 97 - 6
src/main/java/com/persagy/proxy/adm/controller/RelationReportController.java

@@ -33,7 +33,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 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.constant.AdmRelationTypeEnum;
+import com.persagy.proxy.adm.handler.RelationReportHandler;
 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;
@@ -62,6 +65,8 @@ public class RelationReportController {
 	@Value("${middleware.group.code}")
 	private String defaultCode;
 	
+	private final RelationReportHandler relationReportHandler;
+	
 	private final RelationObjectContext relationObjectContext;
 	
 	private final IRelationReportService relationReportService;
@@ -92,7 +97,7 @@ public class RelationReportController {
 	public AdmResponse countRelationObjects(@RequestParam String type, HttpServletRequest request) {
 		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
 		String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
-		ObjectNode objectNode = this.relationReportService.getRelationProjectCal(groupCode, projectId, type);
+		JSONObject objectNode = this.relationReportService.getRelationProjectCal(groupCode, projectId, type);
  		return AdmResponse.success(Lists.newArrayList(objectNode));
 	}
 	
@@ -119,11 +124,86 @@ public class RelationReportController {
 	public AdmResponse queryRelationObjects(@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);
+		List<JSONObject> relationProjectCal = this.relationReportService.getAllRelationProjectCal(groupCode, projectId);
 		return AdmResponse.success(relationProjectCal);
 	}
 	
 	/**
+	 * 下载报告-查询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 projectId
+	 * @param request
+	 * @param response
+	 * @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.relationReportHandler.findEquipByNotSpace(groupCode, projectId);
+            EasyExcel.write(response.getOutputStream(), EquipmentExcel.class).sheet("设备").doWrite(equipByNotSpace);
+		} catch(Exception e) {
+			log.error("设备数据导出异常", e);
+		}
+	}
+	
+	/**
+	 * 下载报告-统计项目下已有的设备,信息点,每个设备
+	 * 设备.xlsx 是个空模板,所以这里未使用 
+	 * 
+	 * @param projectId
+	 * @param request
+	 * @param response
+	 * @return
+	 */
+	@RequestMapping("/graphic/downloads/project/binding/point")
+	public void downloadsProjectBindingPoint(@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("设备实例交付", encode);
+            response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+            
+            List<EquipmentExcel> equipByNotSpace = this.relationReportHandler.findEquipByNotSpace(groupCode, projectId);
+            EasyExcel.write(response.getOutputStream(), EquipmentExcel.class).sheet(0).doWrite(equipByNotSpace);
+		} catch(Exception e) {
+			log.error("设备数据导出异常", e);
+		}
+	}
+	
+	/**
 	 * 下载报告-设备静态信息维护模板
 	 * 
 	 * @param request
@@ -291,7 +371,13 @@ public class RelationReportController {
 			response.setHeader("Content-disposition", "attachment;filename=relation-template.xlsx");
 			
 			log.info("下载报表: groupCode[{}], projectId[{}], relType[{}], code[{}]", groupCode, projectId, relType, code);
-			List<AdmRelationObject> relationObjects = this.relationObjectContext.findRelationObject(groupCode, projectId, relType);
+			AdmRelationTypeEnum typeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
+			
+			List<AdmRelationObject> relationObjects = null;
+			if (typeEnum != null) {
+				String graphAndRelKey = typeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + typeEnum.getRelCode();
+				relationObjects = this.relationObjectContext.findRelationObject(groupCode, projectId, graphAndRelKey);
+			}
 			
 			File templateFile = this.getTemplateFile("relation-template.xlsx");
 			EasyExcel.write(response.getOutputStream()).withTemplate(templateFile).sheet(EXPORT_SHEET_NAME).needHead(false).doWrite(relationObjects);
@@ -326,6 +412,11 @@ public class RelationReportController {
 			if (file == null) {
 				return AdmResponse.failure("未选择文件");
 			}
+			AdmRelationTypeEnum typeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
+			if (typeEnum == null) {
+				return AdmResponse.failure("不支持的关系类型");
+			}
+			String graphAndRelKey = typeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + typeEnum.getRelCode();
 			
 			int failurNum = 0;
 			int successNum = 0;
@@ -361,7 +452,7 @@ public class RelationReportController {
 		    	relationObject.setSlaveId(slaveIdCell == null ? null : slaveIdCell.getStringCellValue());
 		    	
 		    	// 校验数据
-				Object result = this.relationObjectContext.checkRelationObject(relationObject, groupCode, projectId, relType, code);
+				Object result = this.relationObjectContext.checkRelationObject(relationObject, groupCode, projectId, graphAndRelKey, code);
 				if (result instanceof String) {
 					failurNum++;
 					xssfRow.createCell(16).setCellValue((String)result);
@@ -374,7 +465,7 @@ public class RelationReportController {
 				rowNums.add(i);
 				relationObjects.add(relation);
 				if (relationObjects.size() >= 1000) {
-					boolean objects = this.relationObjectContext.saveRelationObjects(relationObjects, groupCode, projectId, relType);
+					boolean objects = this.relationObjectContext.saveRelationObjects(relationObjects, groupCode, projectId, graphAndRelKey);
 					if (objects) {
 						successNum += relationObjects.size();
 					} else {
@@ -389,7 +480,7 @@ public class RelationReportController {
 			}
 		    // 最后一次遗留数据录入
 		    if (CollectionUtil.isNotEmpty(relationObjects)) {
-		    	boolean objects = this.relationObjectContext.saveRelationObjects(relationObjects, groupCode, projectId, relType);
+		    	boolean objects = this.relationObjectContext.saveRelationObjects(relationObjects, groupCode, projectId, graphAndRelKey);
 				if (objects) {
 					successNum += relationObjects.size();
 				} else {

+ 11 - 14
src/main/java/com/persagy/proxy/adm/controller/RelationShInBdController.java

@@ -5,21 +5,22 @@ import com.persagy.proxy.adm.model.relation.ShInBdList;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.common.entity.RelationDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
 import java.util.List;
 
 /**
+ * 关系-竖井所在建筑
  * @author zhangwencheng
- *关系-竖井所在建筑
  */
 @Slf4j
 @RestController
@@ -29,14 +30,11 @@ public class RelationShInBdController {
     @Autowired
     private IAdmRelationService service;
 
-    @Value("${middleware.group.code}")
-    private String groupCode;
     /**
      * 创建竖井所在建筑关系
      * @param shInBdList
      * @return
      */
-
     @PostMapping("link-bd")
     public AdmResponse createBd(@RequestBody ShInBdList shInBdList){
         log.info("创建系统所在建筑关系link-bd");
@@ -47,16 +45,15 @@ public class RelationShInBdController {
             return AdmResponse.failure("必填项:shaftId(竖井id)、BuildingIdList(建筑id列表)");
         }
         List<RelationDTO> voList = new ArrayList<>();
-        AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.BD2SH_ARCHFORARCH;
-        String graphCode = typeEnum.getGraphCode();
-        String relCode = typeEnum.getRelCode();
+        String graphCode = AdmRelationTypeEnum.BD2SH_ARCHFORARCH.getGraphCode();
+        String relCode = AdmRelationTypeEnum.BD2SH_ARCHFORARCH.getRelCode();
+        // 组装关系
         for (String buildingId : buildingIdList) {
-                                                                 //ArchForArch
-            RelationDTO relation = new RelationDTO(null, graphCode, relCode, "", shaftId,buildingId);
+            RelationDTO relation = RelationDTO.builder().graphCode(graphCode).relCode(relCode)
+                    .objFrom(buildingId).objTo(shaftId).build();
             voList.add(relation);
         }
-        InstanceUrlParam context = AdmContextUtil.toDmpContext();
-        service.doSave(context, voList);
+        service.doSave(AdmContextUtil.toDmpContext(), voList);
         return AdmResponse.success();
     }
 

+ 180 - 0
src/main/java/com/persagy/proxy/adm/handler/RelationReportHandler.java

@@ -0,0 +1,180 @@
+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;
+import java.util.Map;
+import java.util.Set;
+
+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.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.EquipmentExcel;
+import com.persagy.proxy.adm.service.IRelationReportService;
+import com.persagy.proxy.adm.strategy.RelationObjectContext;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年10月15日 下午3:09:10
+ */
+@Component
+@RequiredArgsConstructor
+public class RelationReportHandler {
+	
+	@Value("${middleware.group.code}")
+	private String defaultCode;
+
+	private final RelationObjectContext relationObjectContext;
+	
+	private final IRelationReportService relationReportService;
+
+	/**
+	 * 查询出不在空间内的设备数据
+	 * 
+	 * @param groupCode
+	 * @param projectId
+	 */
+	public List<EquipmentExcel> findEquipByNotSpace(String groupCode, String projectId) {
+		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
+		
+		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);
+		// 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());
+			}
+		}
+		// 2.获取所有的设备对象数据
+		objectCriteria.setOrders(Collections.singletonList(OrderItem.asc("classCode")));
+		List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, objectCriteria);
+		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());
+			}
+		}
+		
+		return this.exportEquipmentExcel(equipList, classDefine, equipIds, groupCode, projectId);
+	}
+	
+	/**
+	 * 构造 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>();
+		
+		// 获取建筑名称
+		//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());
+				}
+			}
+		}
+		
+		// 结果封装
+		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;
+	}
+	
+}

+ 6 - 1
src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java

@@ -2,6 +2,7 @@ package com.persagy.proxy.adm.model;
 
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.proxy.adm.annotations.CascadeColumn;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -109,7 +110,7 @@ public class AdmEquipment extends AdmSBaseEntity<AdmEquipment>{
     private String qrcodePic;
 
     /** 对象类型 */
-    private String objectType;
+    private String objectType = OBJ_TYPE;
 
     /** 资产信息实体类   资产对应设备设施关系 资产→设备设施*/
     @CascadeColumn(graphCode = "Property2Mech", relCode = "Pe2Eq", selectToObj = false)
@@ -187,4 +188,8 @@ public class AdmEquipment extends AdmSBaseEntity<AdmEquipment>{
     //@CascadeColumn(table="equipment", idColumn="class_code", childIdColumn="parent_id")
     private List<AdmObjectType> componentCategory;
 
+    /** 级联-设备分类 */
+    //@SCascade(table="equipment", idColumn="id", childIdColumn="class_code")
+    private ObjectNode equipCategory;
+
 }

+ 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();
-    }
-
 }

+ 2 - 2
src/main/java/com/persagy/proxy/adm/model/AdmShaft.java

@@ -44,12 +44,12 @@ public class AdmShaft extends AdmSBaseEntity<AdmShaft>{
     /** BIM模型中轮廓坐标 */
     private List<AdmPointPosition> outline;
     /** 对象类型 */
-    private String objectType;
+    private String objectType = OBJ_TYPE;
     /** 级联-竖井内的设备 */
     @CascadeColumn(graphCode = "MechInArch", relCode = "Eq2Sh", selectToObj = false)
     private List<AdmEquipment> equipmentList;
     /** 级联-竖井内的建筑 */
-    @CascadeColumn(graphCode = "ArchForArch", relCode = "Sh2Bd")
+    @CascadeColumn(graphCode = "ArchSubset", relCode = "Bd2Sh", selectToObj = false)
     private List<AdmBuilding> buildingList;
     /** 级联-竖井内的系统 */
     @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Sh", selectToObj = false)

+ 2 - 2
src/main/java/com/persagy/proxy/adm/model/AdmSpace.java

@@ -40,8 +40,8 @@ public class AdmSpace extends AdmSBaseEntity<AdmSpace>{
     private ArrayList<ArrayList<ArrayList<AdmPointPosition>>> outline;
     /** 轮廓线2 未使用*/
     private ArrayList<ArrayList<ArrayList<AdmPointPosition>>> outline2;
-    /** 图片 */
-    private ArrayList<AdmTaskPic> pic;
+    /** 图片 - 信息点里已存在的信息点不应在实体中重复定义为其他格式 */
+//    private ArrayList<AdmTaskPic> pic;
     /** 空间是否受影响 */
     private String state;
     /** 空间常驻人数 */

+ 5 - 0
src/main/java/com/persagy/proxy/adm/model/AdmSystem.java

@@ -49,6 +49,11 @@ public class AdmSystem extends AdmSBaseEntity<AdmSystem> {
     /** 级联-设备 */
     @CascadeColumn(graphCode = "MechSubset", relCode = "Sy2Eq")
     private List<AdmEquipment> equipmentList;
+
+    /** 级联-竖井*/
+    @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Sh")
+    private List<AdmShaft> shaftList;
+
     /** 级联-空间 */
     @CascadeColumn(graphCode = "MechInArch", relCode = "Sy2Sp")
     private List<AdmSpace> zoneSpaceBaseTableList;

+ 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(20)
+	@ExcelProperty(value = "设备名称", index=1)
+	private String name;
+
+	@ColumnWidth(20)
+	@ExcelProperty(value = "设备本地名称", index=2)
+	private String localId;
+
+	@ColumnWidth(20)
+	@ExcelProperty(value = "设备本地编码", index=3)
+	private String localName;
+	
+	@ColumnWidth(50)
+	@ExcelProperty(value = "BIMID", index=4)
+	private String bimId;
+
+	@ColumnWidth(20)
+	@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(20)
+	@ExcelProperty(value = "模型文件名", index=8)
+	private String modelFileName;
+	
+}

+ 96 - 0
src/main/java/com/persagy/proxy/adm/model/EquipmentExcel2.java

@@ -0,0 +1,96 @@
+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 EquipmentExcel2 {
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "序号", index=0)
+	private String index;
+	
+	@ColumnWidth(25)
+	@ExcelProperty(value = "项目名称", index=1)
+	private String projectName;
+
+	@ColumnWidth(20)
+	@ExcelProperty(value = "建筑", index=2)
+	private String buildName;
+
+	@ColumnWidth(20)
+	@ExcelProperty(value = "楼层", index=3)
+	private String floorName;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "系统编码", index=4)
+	private String systemCode;
+
+	@ColumnWidth(20)
+	@ExcelProperty(value = "系统名称", index=5)
+	private String systemName;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "设备类型编码", index=6)
+	private String equipCode;
+	
+	@ColumnWidth(20)
+	@ExcelProperty(value = "设备类型名称", index=7)
+	private String equipName; 
+	
+	@ColumnWidth(50)
+	@ExcelProperty(value = "设备ID", index=8)
+	private String equipId;
+	
+	@ColumnWidth(50)
+	@ExcelProperty(value = "BIMID", index=9)
+	private String bimId;
+	
+	@ColumnWidth(20)
+	@ExcelProperty(value = "本地编码", index=10)
+	private String localId;
+	
+	@ColumnWidth(20)
+	@ExcelProperty(value = "本地名称", index=11)
+	private String localName;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "【信息点】应绑点位总数", index=12)
+	private String needPointCount;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "【信息点】已绑点位总数", index=13)
+	private String nowPointCount;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "【信息点】静态应绑点", index=14)
+	private String needStaticPointCount;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "【信息点】静态已绑点", index=15)
+	private String nowStaticPointCount;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "【信息点】动态应绑点", index=16)
+	private String needDynamicPointCount;
+	
+	@ColumnWidth(10)
+	@ExcelProperty(value = "【信息点】动态已绑点", index=17)
+	private String nowDynamicPointCount;
+	
+}

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

@@ -67,7 +67,7 @@ public interface IRelationReportService {
 	 * @param projectId
 	 * @return
 	 */
-	List<ObjectNode> getAllRelationProjectCal(String groupCode, String projectId);
+	List<JSONObject> getAllRelationProjectCal(String groupCode, String projectId);
 	
 	/**
 	 * 获取项目计算关系
@@ -77,7 +77,7 @@ public interface IRelationReportService {
 	 * @param relType	ADM-类型
 	 * @return
 	 */
-	ObjectNode getRelationProjectCal(String groupCode, String projectId, String relType);
+	JSONObject getRelationProjectCal(String groupCode, String projectId, String relType);
 	
 	/**
 	 * 获取项目计算关系
@@ -169,8 +169,8 @@ public interface IRelationReportService {
 	/**
 	 * 初始化项目关系计算数据
 	 * 
-	 * @param groupCode
-	 * @param projectId
+	 * @param groupCode: 集团编码
+	 * @param projectId: 项目id
 	 * @return
 	 */
 	boolean createRelationProjectCal(String groupCode, String projectId) throws JsonProcessingException;

+ 4 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmBaseServiceImpl.java

@@ -103,8 +103,11 @@ public class AbstractAdmBaseServiceImpl<T> implements IAdmBaseService<T> {
             }
             // 获取关联对象的Class
             Field casField = ReflectUtil.getField(simpleVO.getClass(), cascade.getName());
+            if(casField == null) {
+                continue;
+            }
+            // 获取级联信息
             CascadeColumn annotationInfo = casField.getAnnotation(CascadeColumn.class);
-            // 没有扩展信息不处理
             if(annotationInfo == null) {
                 continue;
             }

+ 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();
     }

+ 2 - 2
src/main/java/com/persagy/proxy/adm/service/impl/AdmSpaceServiceImpl.java

@@ -210,7 +210,7 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
         ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
         criteriaRel.put("graphCode", "ArchSubset");
         criteriaRel.put("relCode", "Fl2Sp");
-        criteriaRel.put("refValue", spaceType);
+        criteriaRel.put("relValue", spaceType);
         ArrayNode objNode = criteriaRel.putArray("objFrom");
         floorIds.forEach(floorId -> objNode.add(floorId));
         queryRequest.setCriteria(criteriaRel);
@@ -243,7 +243,7 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
         QueryCriteria queryRequest = new QueryCriteria();
         ObjectNode criteriaRel = JsonNodeFactory.instance.objectNode();
         criteriaRel.put("graphCode", "TrafficNetwork");
-        criteriaRel.put("refValue", spaceType);
+        criteriaRel.put("relValue", spaceType);
         ArrayNode objNode = criteriaRel.putArray(isFrom?"objFrom":"objTo");
         spaceIds.forEach(spaceId -> objNode.add(spaceId));
         queryRequest.setCriteria(criteriaRel);

+ 208 - 116
src/main/java/com/persagy/proxy/adm/service/impl/RelationReportService.java

@@ -3,11 +3,14 @@ package com.persagy.proxy.adm.service.impl;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 
-import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -18,6 +21,7 @@ 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;
@@ -35,13 +39,13 @@ 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.AdmRelationTypeEnum;
-import com.persagy.proxy.adm.constant.ObjTypeMapping;
 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;
 
 /**
@@ -102,11 +106,11 @@ public class RelationReportService implements IRelationReportService {
 		List<RelationDefine> relationDefines = DigitalRelationDefineFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
 		return relationDefines;
 	}
-	
+
 	@Override
-	public List<ObjectNode> getAllRelationProjectCal(String groupCode, String projectId) {
+	public List<JSONObject> getAllRelationProjectCal(String groupCode, String projectId) {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
-		
+
 		// 查询出对应项目关系计算数据
 		QueryCriteria projectCriteria = new QueryCriteria();
 		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
@@ -117,20 +121,22 @@ public class RelationReportService implements IRelationReportService {
 		if (CollectionUtil.isEmpty(projectList)) {
 			return Lists.newArrayList();
 		}
+		List<JSONObject> result = Lists.newArrayList();
+		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);
-			this.fillRelationProjectCal(objectNode, relationTypeEnum, groupCode, projectId);
+			//AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(graphCode + AdmCommonConstant.UNDERLINE + relCode);
+			result.add(this.fillRelationProjectCal(objectNode, graphCode, relCode, graphRelTypeMap, relationDefineMap, groupCode, projectId));
 		}
-		
-		return projectList;
+		return result;
 	}
-	
+
 	@Override
 	public List<JSONObject> getAllRelationProjectCalTree(String groupCode, String projectId) {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
-		
+
 		// 获取所有的二级标签
 		QueryCriteria secondCriteria = new QueryCriteria();
 		List<GraphDefine> secondList = DigitalGraphDefineFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, secondCriteria);
@@ -138,11 +144,13 @@ public class RelationReportService implements IRelationReportService {
 			return Lists.newArrayList();
 		}
 		// 获取此图类型对应项目计算数据
-		List<JSONObject> resultList = new ArrayList<JSONObject>();
+		List<JSONObject> resultList = new ArrayList<>();
+		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP;
+		Map<String, RelationDefine> relationDefineMap = queryAllRelationDefineMap(groupCode, projectId);
 		for (GraphDefine graphDefine : secondList) {
 			String graphCode = graphDefine.getCode();
 			JSONObject graphObject = this.transfer(graphDefine);
-			
+
 			// 查询出对应项目关系计算数据
 			QueryCriteria projectCriteria = new QueryCriteria();
 			ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
@@ -156,20 +164,20 @@ public class RelationReportService implements IRelationReportService {
 				continue;
 			}
 			// 再根据图类型、边类型,统计此类型下的数量
+			List<JSONObject> tempList = new ArrayList<>();
 			for (ObjectNode objectNode : projectList) {
 				String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
-				AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(graphCode + AdmCommonConstant.UNDERLINE + relCode);
-				this.fillRelationProjectCal(objectNode, relationTypeEnum, groupCode, projectId);
+				tempList.add(this.fillRelationProjectCal(objectNode, graphDefine.getCode(), relCode, graphRelTypeMap,relationDefineMap, groupCode, projectId));
 			}
 			graphObject.put("relationTypeProjectList", projectList);
 			resultList.add(graphObject);
 		}
-		
+
 		return resultList;
 	}
-	
+
 	@Override
-	public ObjectNode getRelationProjectCal(String groupCode, String projectId, String relType) {
+	public JSONObject getRelationProjectCal(String groupCode, String projectId, String relType) {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
 		
 		AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
@@ -177,12 +185,15 @@ public class RelationReportService implements IRelationReportService {
 			return null;
 		}
 		
-		ObjectNode objectNode = this.getRelationProjectCal(groupCode, projectId, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode(), null);
+		ObjectNode objectNode = this.getRelationProjectCal(groupCode, projectId, relationTypeEnum.getGraphCode(),
+				relationTypeEnum.getRelCode(), null);
+		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP;
+		Map<String, RelationDefine> relationDefineMap = queryAllRelationDefineMap(groupCode, projectId);
 		if (objectNode != null) {
-			this.fillRelationProjectCal(objectNode, relationTypeEnum, groupCode, projectId);
+			return this.fillRelationProjectCal(objectNode, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode(), graphRelTypeMap, relationDefineMap, groupCode, projectId);
 		}
 		
-		return objectNode;
+		return new JSONObject();
 	}
 	
 	@Override
@@ -315,13 +326,7 @@ 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 boolean createRelationProjectCal(String groupCode, String projectId) throws JsonProcessingException {
 		groupCode = StrUtil.isBlank(groupCode) ? defaultCode : groupCode;
@@ -365,6 +370,7 @@ public class RelationReportService implements IRelationReportService {
 				AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, nodes);
 		return CollectionUtil.isNotEmpty(result);
 	}
+	
 	/***
 	 * Description: 创建存储的对象
 	 * @param groupCode : 集团编码
@@ -380,7 +386,6 @@ public class RelationReportService implements IRelationReportService {
 												  		String projectId, RelationDefine relationDefine,
 														String zoneType) throws JsonProcessingException {
 		ObjectNode objectNode = objectMapper.createObjectNode();
-		// 缺少业务分区类型
 		objectNode.put("groupCode", groupCode);
 		objectNode.put("projectId", projectId);
 		objectNode.put("id", IdWorker.getIdStr());
@@ -394,24 +399,20 @@ 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())
-						?objectMapper.writeValueAsString(relationDefine.getMepSystemType()):null);	// 机电系统类型
+		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);	// 最后修改人
 		return objectNode;
 	}
 
-	/**
-	 * 查询关系总览(空表,先插入)
-	 * @param content: 模糊查询卡片名称关键字
-	 */
 	@Override
 	public JSONObject overview(String content) throws JsonProcessingException {
 		JSONObject result = new JSONObject();
 		if (StrUtil.isBlank(content)) {
 			this.createRelationProjectCal(AppContext.getContext().getGroupCode(), AppContext.getContext().getProjectId());
 		}
-		List<JSONObject> parentList = new ArrayList<JSONObject>();
+		List<JSONObject> parentList = new ArrayList<>();
 		// 获取树结构
 		this.getGraphRelationProjectTree(parentList, AppContext.getContext().getGroupCode(),
 				AppContext.getContext().getProjectId(), content);
@@ -433,64 +434,143 @@ 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> topList = DigitalGraphDefineFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, parentCriteria);
-		for (int i = topList.size() - 1; i >= 0; i--) {
-			// 获取所有的二级图类型定义
-			QueryCriteria childCriteria = new QueryCriteria();
-			List<GraphDefine> childList = DigitalGraphDefineFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, childCriteria);
-			if (CollectionUtil.isEmpty(childList)) {
-				if (isQuery) {
-					topList.remove(i);		//移除
-				}
+		List<GraphDefine> graphDefines = DigitalGraphDefineFacade.query(groupCode, projectId,
+				AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, parentCriteria);
+		if (CollUtil.isEmpty(graphDefines)){
+			return;
+		}
+		// 2.查询所有的边类型定义
+		Map<String, RelationDefine> relationDefineMap = queryAllRelationDefineMap(groupCode,projectId);
+		// 3.查询出对应项目关系计算数据
+		List<ObjectNode> projectRelList = queryRelationProjectCalsByProjectId(groupCode,projectId,content);
+		if (CollUtil.isEmpty(projectRelList)){
+			return;
+		}
+		Map<String,List<JSONObject>> levelMap = new HashMap<>();
+		Map<String, AdmRelationTypeEnum> graphRelTypeMap = AdmRelationTypeEnum.getGraphRelTypeMap();
+		for (ObjectNode projectRel : projectRelList) {
+			if (!projectRel.has("relCode")
+					|| StrUtil.isBlank(projectRel.get("relCode").asText())){
 				continue;
 			}
-			
-			GraphDefine topGraph = topList.get(i);
-			JSONObject parent = this.transfer(topGraph);
-			// 二级数据封装
-			for (int j = childList.size() - 1; j >= 0; j--) {
-				GraphDefine childGraph = topList.get(i);
-				JSONObject child = this.transfer(childGraph);
-				// 查询出对应项目关系计算数据
-				QueryCriteria projectCriteria = new QueryCriteria();
-				ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
-				ObjectNode criteria = objectMapper.createObjectNode();
-				criteria.put("projectId", projectId);
-				if (isQuery) {
-					ObjectNode condition = objectMapper.createObjectNode();
-					condition.put("$like", content);
-					criteria.putPOJO("name", condition); // 模糊查询
-				}
-				projectCriteria.setCriteria(criteria);
-				projectCriteria.setOrders(Collections.singletonList(OrderItem.asc("relCode")));
-				List<ObjectNode> projectList = DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
-				if (CollectionUtil.isEmpty(projectList)) {
-					if (isQuery) {
-						childList.remove(i);		//移除
-					}
-					continue;
-				}
-				// 三级数据封装
-				for (ObjectNode objectNode : projectList) {
-					String relCode = objectNode.get("relCode") == null ? null : objectNode.get("relCode").asText();
-					AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.GRAPH_RELATION_TYPE_MAP.get(childGraph.getCode() + AdmCommonConstant.UNDERLINE + relCode);
-					this.fillRelationProjectCal(objectNode, relationTypeEnum, null, null);
-				}
-				child.put("relationTypeProjectList", projectList);
+			String relCode = projectRel.get("relCode").asText();
+			String graphCode = projectRel.get("graphCode").asText();
+			if (!graphRelTypeMap.containsKey(graphCode+StrUtil.UNDERLINE+relCode)){
+				continue;
+			}
+			List<JSONObject> sonList = levelMap.getOrDefault(graphCode, new ArrayList<>());
+			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);
+		}
+		// 3.使用图类型定义的二级标签作为第一级
+		List<JSONObject> topList = new ArrayList<>();
+		for (GraphDefine graphDefine : graphDefines) {
+			GraphParentMes secondCategoryMes = graphDefine.getSecondCategoryMes();
+			if (null==secondCategoryMes){
+				continue;
 			}
-			// 再判断一次,防止当二级有数据但被清除了的情况下,一级还会存在
-			if (isQuery && CollectionUtil.isEmpty(childList)) {
-				childList.remove(i);		//移除
+			if (!levelMap.containsKey(secondCategoryMes.getId())){
+				topList.add(this.transfer(secondCategoryMes));
+			}
+			List<JSONObject> threeLevelList = levelMap.getOrDefault(graphDefine.getCode(), new ArrayList<>());
+			if (CollUtil.isEmpty(threeLevelList)){
+				continue;
+			}
+			List<JSONObject> sonList = levelMap.getOrDefault(secondCategoryMes.getId(), new ArrayList<>());
+			JSONObject secondLevel = this.transfer(graphDefine);
+			secondLevel.put("relationTypeProjectList",threeLevelList);
+			sonList.add(secondLevel);
+			sonList.sort(Comparator.comparing(b -> b.getString("graphTypeCode")));
+			levelMap.put(secondCategoryMes.getId(),sonList);
+		}
+		if (CollUtil.isEmpty(topList)){
+			return;
+		}
+		for (int i = topList.size() - 1; i >= 0; i--) {
+			JSONObject top = topList.get(i);
+			List<JSONObject> secondLevelList = levelMap.getOrDefault(top.getString("graphTypeId"), new ArrayList<>());
+			if (CollUtil.isEmpty(secondLevelList)){
+				topList.remove(i);
 				continue;
 			}
-			parent.put("childGraphicTypeList", childList);
-			parentList.add(parent);
+			top.put("childGraphicTypeList",secondLevelList);
 		}
+		// 顶级按sort排序
+		topList.sort(Comparator.comparing(b -> b.getIntValue("sort")));
+		parentList.addAll(topList);
 	}
+	/***
+	 * Description: 根据项目id查询项目计算关系
+	 * @param groupCode : 集团编码
+	 * @param projectId : 项目id
+	 * @param content : 查询关键字
+	 * @return : java.util.List<com.fasterxml.jackson.databind.node.ObjectNode>
+	 * @author : lijie
+	 * @date :2021/10/15 11:26
+	 * Update By lijie 2021/10/15 11:26
+	 */
+	private List<ObjectNode> queryRelationProjectCalsByProjectId(String groupCode, String projectId,String content) {
+		QueryCriteria projectCriteria = new QueryCriteria();
+		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
+		ObjectNode criteria = objectMapper.createObjectNode();
+		criteria.put("projectId", projectId);
+		if (StrUtil.isNotBlank(content)) {
+			ObjectNode condition = objectMapper.createObjectNode();
+			condition.put("$like", content);
+			criteria.putPOJO("name", condition); // 模糊查询
+		}
+		projectCriteria.setCriteria(criteria);
+		projectCriteria.setOrders(Collections.singletonList(OrderItem.asc("relCode")));
+		return DigitalRelationProjectCalFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, projectCriteria);
+	}
+
+	/***
+	 * Description: 查询所有关系类型
 	
+	 * @return : java.util.Map<java.lang.String,com.persagy.dmp.define.entity.RelationDefine>  
+	 * @author : lijie
+	 * @date :2021/10/15 11:22
+	 * Update By lijie 2021/10/15 11:22
+	 */
+	private Map<String, RelationDefine> queryAllRelationDefineMap(String groupCode,String projectId) {
+		List<RelationDefine> relationDefines = DigitalRelationDefineFacade.query(groupCode, projectId,
+				AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, new QueryCriteria());
+		if (CollUtil.isEmpty(relationDefines)){
+			return new HashMap<>();
+		}
+		return relationDefines.stream()
+				.collect(Collectors.toMap(relationDefine ->
+								relationDefine.getGraphCode() + StrUtil.UNDERLINE + relationDefine.getCode(),
+						relationDefine -> relationDefine, (k1, k2) -> k1));
+	}
+
+	/***
+	 * Description: 创建一级返回数据
+	 * @param graphParentMes : 一级信息对象
+	 * @return : com.alibaba.fastjson.JSONObject
+	 * @author : lijie
+	 * @date :2021/10/14 20:56
+	 * Update By lijie 2021/10/14 20:56
+	 */
+	private JSONObject transfer(GraphParentMes graphParentMes) {
+		JSONObject top = new JSONObject();
+		top.put("sort", graphParentMes.getSort());
+		top.put("note", "");
+		top.put("statistics", new JSONObject());
+		top.put("graphTypeName", graphParentMes.getName());
+		top.put("graphTypeId", graphParentMes.getId());
+		top.put("graphTypeCode", graphParentMes.getCode());
+		top.put("code", graphParentMes.getCode());
+		top.put("lastUpdate", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
+		top.put("createTime", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
+		return top;
+	}
+
 	/**
 	 * 获取转换后的数据,图类型数据转换
 	 * 
@@ -499,51 +579,63 @@ public class RelationReportService implements IRelationReportService {
 	 */
 	private JSONObject transfer(GraphDefine graphDefine) {
 		JSONObject top = new JSONObject();
-		top.put("sort", 1);
+		top.put("sort", 10);
 		top.put("note", "");
-		top.put("statistics", Lists.newArrayList());
+		top.put("statistics", new JSONObject());
 		top.put("graphTypeName", graphDefine.getName());
 		top.put("graphTypeId", graphDefine.getId());
 		top.put("graphTypeCode", graphDefine.getCode());
+		top.put("code", graphDefine.getCode());
 		top.put("lastUpdate", graphDefine.getModifiedTime() == null ? null : graphDefine.getModifiedTime().toString(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
 		top.put("createTime", graphDefine.getCreationTime() == null ? null : graphDefine.getCreationTime().toString(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
 		return top;
 	}
 	
 	/**
-	 * 填充项目关系计算ADM所需的数据
-	 * @param objectNode 项目关系计算的数据记录
-	 * @param relationTypeEnum 枚举类
-	 * @param groupCode 集团编码
-	 * @param projectId 项目ID
+	 * 获取转换后的数据,项目计算数据转换
+	 * 
+	 * @param relationProject :项目对象
+	 * @param relCode :边类型编码
+	 * @param graphRelTypeMap :与旧数据中心的code的映射关系
+	 * @param relationDefineMap
+	 * @return
 	 */
-	private void fillRelationProjectCal(ObjectNode objectNode, AdmRelationTypeEnum relationTypeEnum, String groupCode, String projectId) {
+	private JSONObject fillRelationProjectCal(ObjectNode relationProject, String graphicId, String relCode,
+								Map<String, AdmRelationTypeEnum> graphRelTypeMap,
+								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 = objectNode.get("zoneType") == null ? null : objectNode.get("zoneType").asText();
-			long count = this.countRelationObject(groupCode, projectId, relationTypeEnum.getGraphCode(), relationTypeEnum.getRelCode(), zoneType);
-			objectNode.put("count", count);
+			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 == 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);
+		result.put("statistics", new JSONObject());
+		result.put("automatic", relationProject.has("automaticFlag") && relationProject.get("automaticFlag").asBoolean());
+		result.put("source", relationProject.has("sourceFlag") && relationProject.get("sourceFlag").asBoolean());
+		result.put("conneObject", relationDefine.getTargetObjs());
 		
-		objectNode.put("relationTypeCode", relationTypeEnum.getRelCode());
-		objectNode.put("relationType", relationTypeEnum.getRelationType());
-		objectNode.put("relationTypeName", objectNode.get("relCodeName") == null ? null : objectNode.get("relCodeName").asText());
-	
-		objectNode.put("graphicId", objectNode.get("graphCode") == null ? null : objectNode.get("graphCode").asText());
-		objectNode.put("automatic", "1".equals(objectNode.get("automaticFlag") == null ? null : objectNode.get("automaticFlag").asText()));
-		objectNode.put("source", "1".equals(objectNode.get("sourceFlag") == null ? null : objectNode.get("sourceFlag").asText()));
-		objectNode.put("conneObject", ObjTypeMapping.getConneObject(relationTypeEnum.getRelCode()));
-		
-		Long modifiedTime = objectNode.get("modifiedTime") == null ? null : objectNode.get("modifiedTime").asLong();
-		Long creationTime = objectNode.get("creationTime") == null ? null : objectNode.get("creationTime").asLong();
-		objectNode.put("lastUpdate", modifiedTime == null ? null : new DateTime(modifiedTime).toString());
-		objectNode.put("createTime", creationTime == null ? null : new DateTime(creationTime).toString());
-	
-		
-		String prefix = ObjTypeMapping.getRelCodePrefix(relationTypeEnum.getRelCode());
-		String suffix = ObjTypeMapping.getRelCodeSuffix(relationTypeEnum.getRelCode());
-		objectNode.put("mainObject", ObjTypeMapping.PREFIX_NAME.get(prefix));
-		objectNode.put("fromObject", ObjTypeMapping.PREFIX_NAME.get(suffix));
-		objectNode.putPOJO("statistics", new JSONObject());
+		Long modifiedTime = relationProject.get("modifiedTime") == null ? null : relationProject.get("modifiedTime").asLong();
+		Long creationTime = relationProject.get("creationTime") == null ? null : relationProject.get("creationTime").asLong();
+
+		result.put("lastUpdate", modifiedTime == null ? null : new DateTime(modifiedTime).toString());
+		result.put("createTime", creationTime == null ? null : new DateTime(creationTime).toString());
+		result.put("mainObject", relationDefine.getFromObjType());
+		result.put("fromObject", relationDefine.getToObjType());
+		return result;
 	}
 
 }

+ 12 - 51
src/main/java/com/persagy/proxy/adm/strategy/RelationObjectContext.java

@@ -12,8 +12,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Lists;
 import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.digital.entity.ObjectDigital;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.adm.model.AdmRelationObject;
 import com.persagy.proxy.adm.strategy.relationdata.RelationObjectStrategy;
 
@@ -46,16 +44,11 @@ public class RelationObjectContext {
 	 * 
 	 * @param groupCode
 	 * @param projectId
-	 * @param relType
+	 * @param relType graphCode_relCode
 	 * @return
 	 */
 	public List<AdmRelationObject> findRelationObject(String groupCode, String projectId, String relType) {
-		AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
-		if (relationTypeEnum == null) {
-			return Lists.newArrayList();
-		}
-		String className = relationTypeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + relationTypeEnum.getRelCode();
-		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(className);
+		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
 		return strategy == null ? Lists.newArrayList() : strategy.findRelationObject(groupCode, projectId);
 	}
 	
@@ -63,22 +56,13 @@ public class RelationObjectContext {
 	 * 检查关联对象的合法性
 	 * 
 	 * @param relationObject 当前需要校验的对象
-	 * @param relType ADM-类型
+	 * @param relType graphCode_relCode
 	 * @param code 获取对象的依据
 	 * @return String - 校验失败的原因, ObjectNode -- BDTP接口的参数,不会返回null,请用instanceOf 判断返回值
 	 */
 	public Object checkRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String relType, String code) {
-		AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
-		if (relationTypeEnum == null) {
-			return "未知类型";
-		}
-		String className = relationTypeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + relationTypeEnum.getRelCode();
-		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(className);
-		if (strategy == null) {
-			return "不存在此策略类";
-		}
-		
-		return strategy.beforeSaveRelationObject(relationObject, groupCode, projectId, code);
+		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
+		return strategy == null ? "不存在此策略类" : strategy.beforeSaveRelationObject(relationObject, groupCode, projectId, code);
 	}
 	
 	/**
@@ -87,21 +71,12 @@ public class RelationObjectContext {
 	 * @param admRelationObject
 	 * @param groupCode
 	 * @param projectId
-	 * @param relType ADM-传过来的边类型
+	 * @param relType graphCode_relCode
 	 * @return 
 	 */
 	public boolean saveRelationObjects(List<ObjectNode> relationObjects, String groupCode, String projectId, String relType) {
-		AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
-		if (relationTypeEnum == null) {
-			return false;
-		}
-		String className = relationTypeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + relationTypeEnum.getRelCode();
-		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(className);
-		if (strategy == null) {
-			return false;
-		}
-		
-		return strategy.saveRelationObjects(relationObjects, groupCode, projectId);
+		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
+		return strategy == null ? false : strategy.saveRelationObjects(relationObjects, groupCode, projectId);
 	}
 
 	/**
@@ -109,21 +84,12 @@ public class RelationObjectContext {
 	 * 
 	 * @param groupCode
 	 * @param projectId
-	 * @param relType ADM-传过来的边类型
+	 * @param relType graphCode_relCode
 	 * @return 
 	 */
 	public long countRelationObjects(String groupCode, String projectId, String relType) {
-		AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
-		if (relationTypeEnum == null) {
-			return 0;
-		}
-		String className = relationTypeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + relationTypeEnum.getRelCode();
-		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(className);
-		if (strategy == null) {
-			return 0;
-		}
-		
-		return strategy.countRelationObjects(groupCode, projectId);
+		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
+		return strategy == null ? 0 : strategy.countRelationObjects(groupCode, projectId);
 	}
 	
 	/**
@@ -133,15 +99,10 @@ public class RelationObjectContext {
 	 * @param requestData 请求参数
 	 * @param groupCode 集团编码
 	 * @param projectId 项目ID
-	 * @param relType  graphCode_relCode;
+	 * @param relType  graphCode_relCode
 	 */
 	public List<ObjectDigital> queryPageObjectInfo(RequestData requestData, String groupCode, String projectId, String relType) {
 		List<ObjectDigital> masterObjs = new ArrayList<ObjectDigital>();
-		/*AdmRelationTypeEnum relationTypeEnum = AdmCommonConstant.RELATION_TYPE_MAP.get(relType);
-		if (relationTypeEnum == null) {
-			return masterObjs;
-		}
-		String className = relationTypeEnum.getGraphCode() + AdmCommonConstant.UNDERLINE + relationTypeEnum.getRelCode();*/
 		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
 		if (strategy == null) {
 			return masterObjs;

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2BdRelationObject.java

@@ -52,7 +52,7 @@ public class ArchForArchSh2BdRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.ArchForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sh2Bd.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2FlRelationObject.java

@@ -52,7 +52,7 @@ public class ArchForArchSh2FlRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.ArchForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sh2Fl.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2ShRelationObject.java

@@ -52,7 +52,7 @@ public class ArchForArchSh2ShRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.ArchForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sh2Sh.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSh2SpRelationObject.java

@@ -54,7 +54,7 @@ public class ArchForArchSh2SpRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.ArchForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sh2Sp.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSp2BdRelationObject.java

@@ -54,7 +54,7 @@ public class ArchForArchSp2BdRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.ArchForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sp2Bd.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ArchForArchSp2FlRelationObject.java

@@ -54,7 +54,7 @@ public class ArchForArchSp2FlRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.ArchForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sp2Fl.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchEq2BdRelationObject.java

@@ -54,7 +54,7 @@ public class MechForArchEq2BdRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(AdmRelationTypeEnum.EQ2BD_FOR.getGraphCode());
 		requestData.setRelCode(AdmRelationTypeEnum.EQ2BD_FOR.getRelCode());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchEq2FlRelationObject.java

@@ -54,7 +54,7 @@ public class MechForArchEq2FlRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechForArch.name());
 		requestData.setRelCode(RelCodeEnum.Eq2Fl.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchEq2ShRelationObject.java

@@ -54,7 +54,7 @@ public class MechForArchEq2ShRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechForArch.name());
 		requestData.setRelCode(RelCodeEnum.Eq2Sh.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2BdRelationObject.java

@@ -52,7 +52,7 @@ public class MechForArchSy2BdRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sy2Bd.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2FlRelationObject.java

@@ -52,7 +52,7 @@ public class MechForArchSy2FlRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sy2Fl.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2ShRelationObject.java

@@ -52,7 +52,7 @@ public class MechForArchSy2ShRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sy2Sh.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechForArchSy2SpRelationObject.java

@@ -54,7 +54,7 @@ public class MechForArchSy2SpRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechForArch.name());
 		requestData.setRelCode(RelCodeEnum.Sy2Sp.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechInArchEq2BdRelationObject.java

@@ -52,7 +52,7 @@ public class MechInArchEq2BdRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechInArch.name());
 		requestData.setRelCode(RelCodeEnum.Eq2Bd.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechInArchEq2FlRelationObject.java

@@ -52,7 +52,7 @@ public class MechInArchEq2FlRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechInArch.name());
 		requestData.setRelCode(RelCodeEnum.Eq2Fl.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/MechInArchEq2SpRelationObject.java

@@ -52,7 +52,7 @@ public class MechInArchEq2SpRelationObject extends AbstractReportRelationObject
 		requestData.setGraphCode(GraphCodeEnum.MechInArch.name());
 		requestData.setRelCode(RelCodeEnum.Eq2Sp.name());
 		requestData.setPage(1L);
-		requestData.setSize(1000L);
+		requestData.setSize(500L);
 		
 		return this.queryAllObjectInfo(requestData, groupCode, projectId);
 	}

+ 2 - 0
src/main/java/com/persagy/proxy/adm/utils/AdmQueryCriteriaHelper.java

@@ -221,6 +221,8 @@ public class AdmQueryCriteriaHelper {
      * @param value
      */
     private static void addCondition(String name, ObjectNode criteria, String column, String operator, String value) {
+        // 20211015 移除列名中的infos.
+        column = StrUtil.replaceIgnoreCase(column, "infos.", "");
         // 替换列名
         column = replaceColumns(name, column);
         if("=".equals(operator)) {

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