Преглед на файлове

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

linhuili преди 3 години
родител
ревизия
075046f4a0
променени са 21 файла, в които са добавени 1444 реда и са изтрити 27 реда
  1. 31 0
      src/main/java/com/persagy/proxy/adm/constant/AdmObjectInfoConstant.java
  2. 1 0
      src/main/java/com/persagy/proxy/adm/constant/AdmObjectType.java
  3. 346 0
      src/main/java/com/persagy/proxy/adm/constant/AdmRelationTypeEnum.java
  4. 12 14
      src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java
  5. 5 4
      src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java
  6. 48 0
      src/main/java/com/persagy/proxy/adm/controller/AdmManualRelationCalcController.java
  7. 144 0
      src/main/java/com/persagy/proxy/adm/controller/REqForSpConreoller.java
  8. 1 1
      src/main/java/com/persagy/proxy/adm/controller/ReportDownloadController.java
  9. 1 1
      src/main/java/com/persagy/proxy/adm/model/AdmComponent.java
  10. 27 5
      src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java
  11. 39 0
      src/main/java/com/persagy/proxy/adm/model/AdmRelationAddRequest.java
  12. 66 0
      src/main/java/com/persagy/proxy/adm/request/AdmCreateResponse.java
  13. 21 0
      src/main/java/com/persagy/proxy/adm/service/AdmManualRelationCalcService.java
  14. 49 0
      src/main/java/com/persagy/proxy/adm/service/IAdmComAndEquipService.java
  15. 11 0
      src/main/java/com/persagy/proxy/adm/service/IAdmComponentService.java
  16. 33 0
      src/main/java/com/persagy/proxy/adm/service/IAdmEquipmentService.java
  17. 235 0
      src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmManualRelationCalcServiceImpl.java
  18. 55 1
      src/main/java/com/persagy/proxy/adm/service/impl/AdmComponentServiceImpl.java
  19. 272 1
      src/main/java/com/persagy/proxy/adm/service/impl/AdmEquipmentServiceImpl.java
  20. 39 0
      src/main/java/com/persagy/proxy/adm/utils/ObjectNameUtil.java
  21. 8 0
      src/main/java/com/persagy/proxy/common/client/DmpRwdClient.java

+ 31 - 0
src/main/java/com/persagy/proxy/adm/constant/AdmObjectInfoConstant.java

@@ -0,0 +1,31 @@
+package com.persagy.proxy.adm.constant;
+
+import cn.hutool.core.collection.CollUtil;
+import lombok.Data;
+import lombok.Getter;
+
+import java.util.Set;
+
+/**
+ * 对象类型
+ * @author Charlie Yu
+ * @date 2021-06-25
+ */
+public interface AdmObjectInfoConstant {
+    /** CADID图纸编码*/
+    String CADID = "cadId";
+    /**名称*/
+    String NAME = "name";
+    /**ID*/
+    String ID = "ID";
+    /**本地编码*/
+    String LOCAL_ID = "localId";
+    /**本地名称*/
+    String LOCAL_NAME = "localName";
+    /**是否检查classCode使用的classCodes列表*/
+    Set<String> CHECK_CLASS_CODES= CollUtil.newHashSet("SETDLS","SETDHS");
+    /**是否检查传感器使用的传感器类型*/
+    Set<String> CHECK_SENSOR_CODES= CollUtil.newHashSet("SPVSCM","FFEALS","FFFPSE","FFFASE","SPIASE",
+            "WEGMCM","WEOFCM","WEGMPD","FFGASE","OTSESP","OTSESD","OTSETP","OTSEVD","OTSEPS","OTSEPF","OTSERH",
+            "OTSEIP","OTSEIL","OTSEHT","OTSECB","OTSECT","OTSEEE","OTSEDP","OTSEFL");
+}

+ 1 - 0
src/main/java/com/persagy/proxy/adm/constant/AdmObjectType.java

@@ -19,6 +19,7 @@ public enum AdmObjectType {
     SHAFT("shaft", "竖井"),
     COMPONENT("component", "部件"),
     VIRTUAL("virtual", "虚拟对象"),
+    PROPERTY("property", "资产"),
     TOOL("tool", "工具"),
     MATERIAL("material", "耗材");
 

+ 346 - 0
src/main/java/com/persagy/proxy/adm/constant/AdmRelationTypeEnum.java

@@ -0,0 +1,346 @@
+package com.persagy.proxy.adm.constant;
+
+import cn.hutool.core.collection.CollUtil;
+import lombok.Getter;
+import org.apache.commons.lang3.EnumUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/***
+ * Description: ADM关系类型枚举,直接用枚举类表示,以前是在数据库里存储的
+ * @author : lijie
+ * @date :2021/9/2 14:54
+ * Update By lijie 2021/9/2 14:54
+ */
+@Getter
+public enum AdmRelationTypeEnum {
+
+
+    /**燃气旁通-气体管道-*/
+    EQ2EQ_GASNETWORK_2("eq2eq_GasNetwork_2","GasNetwork","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**设备所在楼层-设备→楼层-【设备台账】*/
+    EQ2FL("eq2fl","MechInArch","Eq2Fl",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.FLOOR.getIndex(),false,false,false,false,false,false),
+    /**空间隔断有窗-空间-空间-【全部关系总览】*/
+    SP2SP_SPACENEIGHBORHOOD_3("sp2sp_SpaceNeighborhood_3","SpaceNeighborhood","Window",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,false),
+    /**设备所在物业分区-设备→业务空间-【业务空间台账】*/
+    EQ2SP_IN("eq2sp_in","MechInArch","Eq2Sp",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**建筑下的竖井-竖井→建筑-【竖井台账】*/
+    SH2BD("sh2bd","ShaftandBuilding","Bd2Sh",AdmObjectType.BUILDING.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,false,false),
+    /**空间隔断有门-空间-空间-【全部关系总览】*/
+    SP2SP_SPACENEIGHBORHOOD_2("sp2sp_SpaceNeighborhood_2","SpaceNeighborhood","Door",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,false),
+    /**空间连通-空间-空间-【全部关系总览】*/
+    SP2SP_SPACENEIGHBORHOOD_5("sp2sp_SpaceNeighborhood_5","SpaceNeighborhood","Connect",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,false),
+    /**系统服务于竖井-系统→竖井-【竖井台账】*/
+    SY2SH_FOR("sy2sh_for","MechForArch","Sy2Sh",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,true,false),
+    /**污水排水-污水排水相关设备,沿水流方向-*/
+    EQ2EQ_DRAININGWATERNETWORK_1("eq2eq_DrainingWaterNetwork_1","DrainingWaterNetwork","Discharge",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**设备服务于功能分区-设备→业务空间-【业务空间台账】*/
+    EQ2SP_FOR("eq2sp_for","MechForArch","Eq2Sp",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**空调回风-空调回风相关设备,沿气流方向-*/
+    EQ2EQ_ACAIRNETWORK_2("eq2eq_ACAirNetwork_2","ACAirNetwork","Return",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**系统下的设备-系统→设备-【系统台账】,【设备台账】*/
+    EQ2SY("eq2sy","SystemEquip","Sy2Eq",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,false,false,false,false,false),
+    /**空调冷冻水补水-空调冷冻水补水相关设备,沿水流方向-*/
+    EQ2EQ_CHILLWATERLOOP_4("eq2eq_ChillWaterLoop_4","ChillWaterLoop","Fill",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**设备服务于建筑-设备→建筑-【设备台账】*/
+    EQ2BD_FOR("eq2bd_for","MechForArch","Eq2Bd",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.BUILDING.getIndex(),false,false,false,false,true,false),
+    /**空调冷凝水排水-空调冷凝水排水相关设备,沿水流方向-*/
+    EQ2EQ_CONDWATERNETWORK_1("eq2eq_CondWaterNetwork_1","CondWaterNetwork","Discharge",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**空间隔断无门窗-空间-空间-【全部关系总览】*/
+    SP2SP_SPACENEIGHBORHOOD_1("sp2sp_SpaceNeighborhood_1","SpaceNeighborhood","None",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,false),
+    /**阀门限制设备关系-阀门→被限设备-【全部关系总览】*/
+    EQ2EQ_VALVERELATIONSHIP_VV2EQ("eq2eq_ValveRelationship_vv2eq","ValveRelationship","Vv2Eq",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**资产所在业务空间-资产→业务空间-*/
+    PE2SP("pe2sp","PropertyInArch","Pe2Sp",AdmObjectType.PROPERTY.getIndex(),AdmObjectType.SPACE.getIndex(),true,false,false,false,true,false),
+    /**通风排风-通风排风相关设备,沿气流方向-*/
+    EQ2EQ_VENTNETWORK_2("eq2eq_VentNetwork_2","VentNetwork","Discharge",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**弱电通信连接-上位机→下位机,连接弱电、消防、安防等专业设备-*/
+    EQ2EQ_SENSORNETWORK_1("eq2eq_SensorNetwork_1","SensorNetwork","Normal",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**空调冷却水旁通-液体管道-*/
+    EQ2EQ_COOLINGWATERLOOP_3("eq2eq_CoolingWaterLoop_3","CoolingWaterLoop","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**设备服务于楼层-设备→楼层-【设备台账】*/
+    EQ2FL_FOR("eq2fl_for","MechForArch","Eq2Fl",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.FLOOR.getIndex(),false,false,false,false,true,false),
+    /**系统常规电源-低/高压开关柜→用电设备-【全部关系总览】*/
+    EQ2EQ_EQUIPPOWER_3("eq2eq_EquipPower_3","EquipPower","SyNormal",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,true),
+    /**空调排风-空调排风相关设备,沿气流方向-*/
+    EQ2EQ_ACAIRNETWORK_3("eq2eq_ACAirNetwork_3","ACAirNetwork","Discharge",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**生活给水旁通-液体管道-*/
+    EQ2EQ_SUPPLYWATERNETWORK_2("eq2eq_SupplyWaterNetwork_2","SupplyWaterNetwork","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**系统控制关系-控制设备→被控系统-【全部关系总览】*/
+    EQ2SY_CONTROLRELATION_2("eq2sy_ControlRelation_2","ControlRelation","SyCtrl",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SYSTEM.getIndex(),false,false,false,false,true,false),
+    /**采暖水补水-采暖水补水相关设备,沿水流方向-*/
+    EQ2EQ_HEATWATERLOOP_4("eq2eq_HeatWaterLoop_4","HeatWaterLoop","Fill",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**建筑下的空间-建筑→空间-【业务空间台账】*/
+    BD2SP("bd2sp","ArchSubset","Bd2Sp",AdmObjectType.BUILDING.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**消防常开交通-业务空间-业务空间-【全部关系总览】*/
+    SP2SP_TRAFFICNETWORK_2("sp2sp_TrafficNetwork_2","TrafficNetwork","FFOpen",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("GeneralZone")),
+    /**楼层下的业务空间-楼层→业务空间-【业务空间台账】*/
+    FL2SP("fl2sp","ArchSubset","Fl2Sp",AdmObjectType.FLOOR.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**竖井下的业务空间-竖井→空间-【竖井台账】*/
+    SH2SP_ARCHSUBSET("Sh2Sp_ArchSubset","ArchSubset","Sh2Sp",AdmObjectType.SHAFT.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**空气混合机械通风-空间-空间-【全部关系总览】*/
+    SP2SP_CONVECTIONNETWORK_2("sp2sp_ConvectionNetwork_2","ConvectionNetwork","MixMech",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("AirConditioningZone")),
+    /**系统所在竖井-系统→竖井-【系统台账】,【竖井台账】*/
+    SY2SH("sy2sh","MechInArch","Sy2Sh",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,false,false),
+    /**系统所在建筑-系统→建筑-【系统台账】*/
+    SY2BD_MECHINARCH("sy2bd_MechInArch","MechInArch","Sy2Bd",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.BUILDING.getIndex(),false,false,false,false,false,false),
+    /**生活热水旁通-液体管道-*/
+    EQ2EQ_DHWNETWORK_2("eq2eq_DHWNetwork_2","DHWNetwork","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**采暖水供水-采暖水供水相关设备,沿水流方向-*/
+    EQ2EQ_HEATWATERLOOP_1("eq2eq_HeatWaterLoop_1","HeatWaterLoop","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**空气单向机械通风-空间→空间-【全部关系总览】*/
+    SP2SP_CONVECTIONNETWORK_3("sp2sp_ConvectionNetwork_3","ConvectionNetwork","OnewayMech",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("AirConditioningZone")),
+    /**弱电通信连接-弱电通信相关设备,沿弱电信号方向-*/
+    EQ2EQ_CONTROLEQUIPNETWORK("eq2eq_ControlEquipNetwork","ControlEquipNetwork","Normal",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**系统服务于楼层-系统→楼层-【系统台账】*/
+    SY2FL_FOR("sy2fl_for","MechForArch","Sy2Fl",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.FLOOR.getIndex(),false,false,false,false,true,false),
+    /**生活热水供水-生活热水供水相关设备,沿水流方向-*/
+    EQ2EQ_DHWNETWORK_1("eq2eq_DHWNetwork_1","DHWNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**中水旁通-液体管道-*/
+    EQ2EQ_RECYCLEWATERNETWORK_2("eq2eq_RecycleWaterNetwork_2","RecycleWaterNetwork","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**传感器测量系统关系-传感器→被测系统-【全部关系总览】*/
+    EQ2SY_SENSORRELATIONSHIP_SS2SY("eq2sy_SensorRelationship_ss2sy","SensorRelationship","Ss2Sy",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SYSTEM.getIndex(),false,false,false,true,true,false),
+    /**空间隔断有门窗-空间-空间-【全部关系总览】*/
+    SP2SP_SPACENEIGHBORHOOD_4("sp2sp_SpaceNeighborhood_4","SpaceNeighborhood","DoorWindow",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,false),
+    /**资产所在楼层-楼层→资产-【资产台账】*/
+    PE2FL("pe2fl","ArchSubset","Pe2Fl",AdmObjectType.PROPERTY.getIndex(),AdmObjectType.FLOOR.getIndex(),false,false,false,false,false,false),
+    /**中水供水-中水供水相关设备,沿水流方向-*/
+    EQ2EQ_RECYCLEWATERNETWORK_1("eq2eq_RecycleWaterNetwork_1","RecycleWaterNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**竖井贯通关系-竖井-竖井-【竖井台账】*/
+    SH2SH("sh2sh","ThroughRelationship","Sh2Sh",AdmObjectType.SHAFT.getIndex(),AdmObjectType.SHAFT.getIndex(),false,true,false,false,false,false),
+    /**低压配电普通连接-低压配电相关设备,沿电流方向-【调研录入参考资料CAD图纸】*/
+    EQ2EQ_LUDISTRIBUTION_1("eq2eq_LUDistribution_1","LUDistribution","Normal",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**消防排烟-消防排烟相关设备,沿气流方向-*/
+    EQ2EQ_FIREVENTNETWORK_1("eq2eq_FireVentNetwork_1","FireVentNetwork","Discharge",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**消防给水供水-消防给水供水相关设备,沿水流方向-*/
+    EQ2EQ_FIREWATERNETWORK_1("eq2eq_FireWaterNetwork_1","FireWaterNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**高压变配电互备连接-分段主柜,分段辅柜-【调研录入参考资料CAD图纸】*/
+    EQ2EQ_HUDISTRIBUTION_2("eq2eq_HUDistribution_2","HUDistribution","Backup",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**污水旁通-液体管道-*/
+    EQ2EQ_DRAININGWATERNETWORK_2("eq2eq_DrainingWaterNetwork_2","DrainingWaterNetwork","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**楼层贯通关系-楼层-楼层-【建筑楼层管理】*/
+    FL2FL("fl2fl","ThroughRelationship","Fl2Fl",AdmObjectType.FLOOR.getIndex(),AdmObjectType.FLOOR.getIndex(),false,true,false,false,false,false),
+    /**多联机供回制冷剂-多联机室外机→多联机室内机-*/
+    EQ2EQ_VRFNETWORK_1("eq2eq_VRFNetwork_1","VRFNetwork","SupplyReturn",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**低压配电互备连接-低压开关柜-母联柜-【调研录入参考资料CAD图纸】*/
+    EQ2EQ_LUDISTRIBUTION_2("eq2eq_LUDistribution_2","LUDistribution","Backup",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**直饮水旁通-液体管道-*/
+    EQ2EQ_DRINKINGWATERNETWORK_2("eq2eq_DrinkingWaterNetwork_2","DrinkingWaterNetwork","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**传感器测量空间关系-传感器→被测空间-【全部关系总览】*/
+    EQ2SP_SENSORRELATIONSHIP_SS2SP("eq2sp_SensorRelationship_ss2sp","SensorRelationship","Ss2Sp",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SPACE.getIndex(),true,false,false,true,true,false),
+    /**租户租用业务空间-租户→租赁业务空间-【租户台账】*/
+    TN2SP("tn2sp","TenentInArch","Tn2Sp",AdmObjectType.PROPERTY.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**空调冷冻水旁通-供冷集水器-供冷分水器,液体管道-*/
+    EQ2EQ_CHILLWATERLOOP_3("eq2eq_ChillWaterLoop_3","ChillWaterLoop","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**空调冷冻水回水-空调冷冻水回水相关设备,沿水流方向-*/
+    EQ2EQ_CHILLWATERLOOP_2("eq2eq_ChillWaterLoop_2","ChillWaterLoop","Return",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**燃气供气-燃气供气相关设备,沿气流方向-*/
+    EQ2EQ_GASNETWORK_1("eq2eq_GasNetwork_1","GasNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**系统服务于建筑-系统→建筑-【系统台账】*/
+    SY2BD_FOR("sy2bd_for","MechForArch","Sy2Bd",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.BUILDING.getIndex(),false,false,false,false,true,false),
+    /**新风送风-新风送风相关设备,沿气流方向-*/
+    EQ2EQFRESHAIRNETWORK_1("eq2eqFreshAirNetwork_1","FreshAirNetwork","Fresh",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**系统备用电源-低/高压开关柜→用电设备-【全部关系总览】*/
+    EQ2EQ_EQUIPPOWER_4("eq2eq_EquipPower_4","EquipPower","SyBackup",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,true),
+    /**空调冷却水补水-空调冷却水补水相关设备,沿水流方向-*/
+    EQ2EQ_COOLINGWATERLOOP_4("eq2eq_CoolingWaterLoop_4","CoolingWaterLoop","Fill",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**设备所在竖井-设备→竖井-【竖井台账】*/
+    EQ2SH("eq2sh","MechInArch","Eq2Sh",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,false,false),
+    /**空调冷冻水供水-空调冷冻水供水相关设备,沿水流方向-*/
+    EQ2EQ_CHILLWATERLOOP_1("eq2eq_ChillWaterLoop_1","ChillWaterLoop","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**直饮水供水-直饮水供水相关设备,沿水流方向-*/
+    EQ2EQ_DRINKINGWATERNETWORK_1("eq2eq_DrinkingWaterNetwork_1","DrinkingWaterNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**资产属于建筑-建筑→资产-【资产台账】*/
+    PE2BD("pe2bd","ArchSubset","Pe2Bd",AdmObjectType.PROPERTY.getIndex(),AdmObjectType.BUILDING.getIndex(),false,false,false,false,false,false),
+    /**设备服务于竖井-设备→竖井-【竖井台账】*/
+    EQ2SH_FOR("eq2sh_for","MechForArch","Eq2Sh",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,true,false),
+    /**设备备用电源-低/高压开关柜→用电设备-【全部关系总览】*/
+    EQ2EQ_EQUIPPOWER_2("eq2eq_EquipPower_2","EquipPower","EqBackup",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,true),
+    /**空调冷却水回水-空调冷却水回水相关设备,沿水流方向-*/
+    EQ2EQ_COOLINGWATERLOOP_2("eq2eq_CoolingWaterLoop_2","CoolingWaterLoop","Return",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**阀门限制系统关系-阀门→被限系统-【全部关系总览】*/
+    EQ2SY_VALVERELATIONSHIP_VV2SY("eq2sy_ValveRelationship_vv2sy","ValveRelationship","Vv2Sy",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.SYSTEM.getIndex(),false,false,false,false,true,false),
+    /**普通交通-空间-空间-【全部关系总览】*/
+    SP2SP_TRAFFICNETWORK_1("sp2sp_TrafficNetwork_1","TrafficNetwork","Normal",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("GeneralZone")),
+    /**光照透明隔断-空间-空间-【全部关系总览】*/
+    SP2SP_RADIATIONNETWORK_2("sp2sp_RadiationNetwork_2","RadiationNetwork","Transparent",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("LightingZone")),
+    /**消防给水旁通-液体管道-*/
+    EQ2EQ_FIREWATERNETWORK_2("eq2eq_FireWaterNetwork_2","FireWaterNetwork","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**空气自然对流-空间-空间-【全部关系总览】*/
+    SP2SP_CONVECTIONNETWORK_1("sp2sp_ConvectionNetwork_1","ConvectionNetwork","Natural",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("AirConditioningZone")),
+    /**通风送风-通风送风相关设备,沿气流方向-*/
+    EQ2EQ_VENTNETWORK_1("eq2eq_VentNetwork_1","VentNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**消防常关交通-空间-空间-【全部关系总览】*/
+    SP2SP_TRAFFICNETWORK_3("sp2sp_TrafficNetwork_3","TrafficNetwork","FFClose",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("GeneralZone")),
+    /**设备常规电源-低/高压开关柜→用电设备-【全部关系总览】*/
+    EQ2EQ_EQUIPPOWER_1("eq2eq_EquipPower_1","EquipPower","EqNormal",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,true),
+    /**系统所在楼层-系统→楼层-【系统台账】*/
+    SY2FL("sy2fl","MechInArch","Sy2Fl",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.FLOOR.getIndex(),false,false,false,false,false,false),
+    /**传感器测量设备关系-传感器→被测设备-【全部关系总览】*/
+    EQ2EQ_SENSORRELATIONSHIP_SS2EQ("eq2eq_SensorRelationship_ss2eq","SensorRelationship","Ss2Eq",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,true,false,false),
+    /**资产所在竖井-资产→竖井-*/
+    PE2SH("pe2sh","PropertyInArch","Pe2Sh",AdmObjectType.PROPERTY.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,true,false),
+    /**采暖水回水-采暖水回水相关设备,沿水流方向-*/
+    EQ2EQ_HEATWATERLOOP_2("eq2eq_HeatWaterLoop_2","HeatWaterLoop","Return",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**设备控制关系-控制设备→被控设备-【全部关系总览】*/
+    EQ2EQ_CONTROLRELATION_1("eq2eq_ControlRelation_1","ControlRelation","MechCtrl",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**光照连通-空间-空间-【全部关系总览】*/
+    SP2SP_RADIATIONNETWORK_1("sp2sp_RadiationNetwork_1","RadiationNetwork","Connect",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,true,false,true,true,CollUtil.newHashSet("LightingZone")),
+    /**竖井下的业务空间-竖井→空间-【竖井台账】*/
+    SH2SP("sh2sp","ShaftandSpace","Sh2Sp",AdmObjectType.SHAFT.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**采暖水旁通-供暖集水器-供暖分水器,液体管道-*/
+    EQ2EQ_HEATWATERLOOP_3("eq2eq_HeatWaterLoop_3","HeatWaterLoop","Bypass",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**空调冷却水供水-空调冷却水供水相关设备,沿水流方向-*/
+    EQ2EQ_COOLINGWATERLOOP_1("eq2eq_CoolingWaterLoop_1","CoolingWaterLoop","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**建筑服务于建筑-建筑→建筑-*/
+    BD2BD_ARCHFORARCH("bd2bd_ArchForArch","ArchForArch","Bd2Bd",AdmObjectType.BUILDING.getIndex(),AdmObjectType.BUILDING.getIndex(),false,true,false,false,true,false),
+    /**竖井服务于楼层-竖井→楼层-*/
+    SH2FL_ARCHFORARCH("sh2fl_ArchForArch","ArchForArch","Sh2Fl",AdmObjectType.SHAFT.getIndex(),AdmObjectType.FLOOR.getIndex(),false,false,false,false,true,false),
+    /**竖井服务于竖井-竖井→竖井-*/
+    SH2SH_ARCHFORARCH("sh2sh_ArchForArch","ArchForArch","Sh2Sh",AdmObjectType.SHAFT.getIndex(),AdmObjectType.SHAFT.getIndex(),false,true,false,false,true,false),
+    /**竖井服务于空间-竖井→空间-*/
+    SH2SP_ARCHFORARCH("sh2sp_ArchForArch","ArchForArch","Sh2Sp",AdmObjectType.SHAFT.getIndex(),AdmObjectType.SPACE.getIndex(),true,false,false,false,true,false),
+    /**空间服务于建筑-空间→建筑-*/
+    SP2BD_ARCHFORARCH("sp2bd_ArchForArch","ArchForArch","Sp2Bd",AdmObjectType.SPACE.getIndex(),AdmObjectType.BUILDING.getIndex(),true,false,false,false,true,false),
+    /**空间服务于楼层-空间→楼层-*/
+    SP2FL_ARCHFORARCH("sp2fl_ArchForArch","ArchForArch","Sp2Fl",AdmObjectType.SPACE.getIndex(),AdmObjectType.FLOOR.getIndex(),true,false,false,false,true,false),
+    /**空间服务于竖井-空间→竖井-*/
+    SP2SH_ARCHFORARCH("sp2sh_ArchForArch","ArchForArch","Sp2Sh",AdmObjectType.SPACE.getIndex(),AdmObjectType.SHAFT.getIndex(),true,false,false,false,true,false),
+    /**空间服务于空间-空间→空间-*/
+    SP2SP_ARCHFORARCH("sp2sp_ArchForArch","ArchForArch","Sp2Sp",AdmObjectType.SPACE.getIndex(),AdmObjectType.SPACE.getIndex(),true,true,false,false,true,false),
+    /**建筑服务于楼层-建筑→楼层-*/
+    BD2FL_ARCHFORARCH("bd2fl_ArchForArch","ArchForArch","Bd2Fl",AdmObjectType.BUILDING.getIndex(),AdmObjectType.FLOOR.getIndex(),false,false,false,false,true,false),
+    /**建筑服务于竖井-建筑→竖井-*/
+    BD2SH_ARCHFORARCH("bd2sh_ArchForArch","ArchForArch","Bd2Sh",AdmObjectType.BUILDING.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,true,false),
+    /**建筑下的竖井-建筑→竖井-【系统台账】*/
+    BD2SH_ARCHSUBSET("bd2sh_ArchSubset","ArchSubset","Bd2Sh",AdmObjectType.BUILDING.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,false,false),
+    /**建筑服务于空间-建筑→空间-*/
+    BD2SP_ARCHFORARCH("bd2sp_ArchForArch","ArchForArch","Bd2Sp",AdmObjectType.BUILDING.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,true,false),
+    /**楼层服务于建筑-楼层→建筑-*/
+    FL2BD_ARCHFORARCH("fl2bd_ArchForArch","ArchForArch","Fl2Bd",AdmObjectType.FLOOR.getIndex(),AdmObjectType.BUILDING.getIndex(),false,false,false,false,true,false),
+    /**楼层服务于楼层-楼层→楼层-*/
+    FL2FL_ARCHFORARCH("fl2fl_ArchForArch","ArchForArch","Fl2Fl",AdmObjectType.FLOOR.getIndex(),AdmObjectType.FLOOR.getIndex(),false,true,false,false,true,false),
+    /**楼层服务于竖井-楼层→竖井-*/
+    FL2SH_ARCHFORARCH("fl2sh_ArchForArch","ArchForArch","Fl2Sh",AdmObjectType.FLOOR.getIndex(),AdmObjectType.SHAFT.getIndex(),false,false,false,false,true,false),
+    /**楼层服务于空间-楼层→空间-*/
+    FL2SP_ARCHFORARCH("fl2sp_ArchForArch","ArchForArch","Fl2Sp",AdmObjectType.FLOOR.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,true,false),
+    /**竖井服务于建筑-竖井→建筑-*/
+    SH2BD_ARCHFORARCH("sh2bd_ArchForArch","ArchForArch","Sh2Bd",AdmObjectType.SHAFT.getIndex(),AdmObjectType.BUILDING.getIndex(),false,false,false,false,true,false),
+    /**系统所在空间-系统→业务空间-【系统台账】,【业务空间台账】*/
+    SY2SP("sy2sp","MechInArch","Sy2Sp",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.SPACE.getIndex(),false,false,false,false,false,false),
+    /**设备所在建筑-设备→建筑-【设备台账】*/
+    SYEQ2BD("syeq2bd","MechInArch","Eq2Bd",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.BUILDING.getIndex(),false,false,false,false,false,false),
+    /**系统服务于空间-系统→业务空间-【业务空间台账】*/
+    SY2SP_FOR("sy2sp_for","MechForArch","Sy2Sp",AdmObjectType.SYSTEM.getIndex(),AdmObjectType.SPACE.getIndex(),true,false,false,false,true,false),
+    /**空调送风-空调送风相关设备,沿气流方向-*/
+    EQ2EQ_ACAIRNETWORK_1("eq2eq_ACAirNetwork_1","ACAirNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**生活给水供水-生活给水供水相关设备,沿水流方向-*/
+    EQ2EQ_SUPPLYWATERNETWORK_1("eq2eq_SupplyWaterNetwork_1","SupplyWaterNetwork","Supply",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**通风不确定-通风相关设备-*/
+    EQ2EQ_VENTNETWORK_3("eq2eq_VentNetwork_3","VentNetwork","Uncertain",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false),
+    /**高压变配电普通连接-高压变配电相关设备,沿电流方向-【调研录入参考资料CAD图纸】*/
+    EQ2EQ_HUDISTRIBUTION_1("eq2eq_HUDistribution_1","HUDistribution","Normal",AdmObjectType.EQUIPMENT.getIndex(),AdmObjectType.EQUIPMENT.getIndex(),false,true,false,false,false,false);
+
+    /**数据中心的关系类型*/
+    private String relationType;
+    /**图类型编码*/
+    private String graphCode;
+    /**边类型编码*/
+    private String relCode;
+    /**主对象分类*/
+    private String masterObjType;
+    /**从对象分类*/
+    private String slaveObjType;
+    /**拥有关系值的标识,true-有,false-无,一般空间对象分类有,为其class_code*/
+    private Boolean hasRelValue;
+    /**是否过滤主对象id,true-过滤,false-不过滤*/
+    private Boolean hasFilterMasterId;
+    /**是否过滤classCode,true-过滤,false-不过滤*/
+    private Boolean hasFilterClassCode;
+    /**是否检查传感器类型,true-检查,false-不检查*/
+    private Boolean hasCheckSensor;
+    /**是否检查CADID,true-检查,false-不检查*/
+    private Boolean hasCheckCadId;
+    /**是否检查classCode,true-检查,false-不检查*/
+    private Boolean hasCheckClassCode;
+    /**是否检查classCode使用的classCodes列表*/
+    private Set<String> checkClassCodes;
+    /**是否检查传感器使用的传感器类型*/
+    private Set<String> checkSensorCodes;
+
+    /***
+     * Description: 构造函数
+     * @param relationType : 数据中心的关系类型
+     * @param graphCode : 标准字典定义的图类型编码
+     * @param relCode : 标准字典定义的边类型编码
+     * @param hasRelValue : 拥有关系值的标识,true-有,false-无,一般空间对象分类有,为其class_code
+     * @param hasFilterMasterId : 是否过滤主对象id,true-过滤,false-不过滤
+     * @param hasCheckSensor : 是否检查传感器类型,true-检查,false-不检查
+     * @param hasCheckCadId : 是否检查CADID,true-检查,false-不检查
+     * @param hasCheckClassCode : 是否检查classCode,true-检查,false-不检查
+     * @author : lijie
+     * Update By lijie 2021/9/2 14:53
+     */
+    AdmRelationTypeEnum(String relationType, String graphCode, String relCode, String masterObjType, String slaveObjType,
+                        Boolean hasRelValue, Boolean hasFilterMasterId, Boolean hasFilterClassCode,
+                        Boolean hasCheckSensor, Boolean hasCheckCadId, Boolean hasCheckClassCode) {
+        this.relationType = relationType;
+        this.graphCode = graphCode;
+        this.relCode = relCode;
+        this.masterObjType = masterObjType;
+        this.slaveObjType = slaveObjType;
+        this.hasRelValue = hasRelValue;
+        this.hasFilterMasterId = hasFilterMasterId;
+        this.hasFilterClassCode = hasFilterClassCode;
+        this.hasCheckSensor = hasCheckSensor;
+        this.hasCheckCadId = hasCheckCadId;
+        this.hasCheckClassCode = hasCheckClassCode;
+        this.checkClassCodes = CollUtil.newHashSet(AdmObjectInfoConstant.CHECK_CLASS_CODES);
+        this.checkSensorCodes = CollUtil.newHashSet(AdmObjectInfoConstant.CHECK_SENSOR_CODES);
+    }
+    /***
+     * Description: 构造函数
+     * @param relationType : 数据中心的关系类型
+     * @param graphCode : 标准字典定义的图类型编码
+     * @param relCode : 标准字典定义的边类型编码
+     * @param hasRelValue : 拥有关系值的标识,true-有,false-无,一般空间对象分类有,为其class_code
+     * @param hasFilterMasterId : 是否过滤主对象id,true-过滤,false-不过滤
+     * @param hasCheckSensor : 是否检查传感器类型,true-检查,false-不检查
+     * @param hasCheckCadId : 是否检查CADID,true-检查,false-不检查
+     * @param hasCheckClassCode : 是否检查classCode,true-检查,false-不检查
+     * @author : lijie
+     * Update By lijie 2021/9/2 14:53
+     */
+    AdmRelationTypeEnum(String relationType, String graphCode, String relCode, String masterObjType, String slaveObjType,
+                        Boolean hasRelValue, Boolean hasFilterMasterId, Boolean hasFilterClassCode,
+                        Boolean hasCheckSensor, Boolean hasCheckCadId, Boolean hasCheckClassCode,
+                        Set<String> checkClassCodes) {
+        this.relationType = relationType;
+        this.graphCode = graphCode;
+        this.relCode = relCode;
+        this.masterObjType = masterObjType;
+        this.slaveObjType = slaveObjType;
+        this.hasRelValue = hasRelValue;
+        this.hasFilterMasterId = hasFilterMasterId;
+        this.hasFilterClassCode = hasFilterClassCode;
+        this.hasCheckSensor = hasCheckSensor;
+        this.hasCheckCadId = hasCheckCadId;
+        this.hasCheckClassCode = hasCheckClassCode;
+        this.checkClassCodes = checkClassCodes;
+        this.checkSensorCodes = CollUtil.newHashSet(AdmObjectInfoConstant.CHECK_SENSOR_CODES);
+    }
+    /***
+     * Description: 获取枚举类的映射
+     * @return : java.util.Map<java.lang.String,com.persagy.proxy.enumeration.AdmRelationTypeEnum>
+     * @author : lijie
+     * date :2021/9/2 17:22
+     * Update By lijie 2021/9/2 17:22
+     */
+    public static Map<String,AdmRelationTypeEnum> getRelationTypeMap(){
+        List<AdmRelationTypeEnum> enumList = EnumUtils.getEnumList(AdmRelationTypeEnum.class);
+        return enumList.stream().collect(Collectors.toMap(AdmRelationTypeEnum::getRelationType,admRelationTypeEnum -> admRelationTypeEnum));
+    }
+
+
+}

+ 12 - 14
src/main/java/com/persagy/proxy/adm/controller/AdmComponentController.java

@@ -1,14 +1,12 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSONArray;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmComponent;
 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.IAdmEquipmentService;
-import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.adm.service.IAdmComponentService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -30,7 +28,7 @@ import java.util.List;
 @RequestMapping("/object/component")
 public class AdmComponentController {
     @Autowired
-    private IAdmEquipmentService service;
+    private IAdmComponentService service;
     @Value("${middleware.group.code}")
     private String groupCode;
 
@@ -48,7 +46,7 @@ public class AdmComponentController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("component");
         request.setOnlyCount(true);
-        return service.doQuery(context, request, AdmEquipment.class);
+        return service.doQuery(context, request, AdmComponent.class);
     }
     /**
      * 创建
@@ -57,11 +55,11 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/create")
-    public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmComponent> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsert(context, AdmEquipment.class, vos);
+        List<AdmComponent> vos = CollUtil.newArrayList(createRequest.getContent());
+        vos = service.doInsertExt(context, AdmComponent.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -72,7 +70,7 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/delete")
-    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmEquipment> vos) throws Exception {
+    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmComponent> vos) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         service.doDelete(context, vos);
@@ -86,11 +84,11 @@ public class AdmComponentController {
      * @throws Exception
      */
     @PostMapping("/update")
-    public AdmResponse update(@RequestBody AdmCreateRequest<AdmEquipment> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmComponent> createRequest, @QueryParam("projectId") String projectId) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doUpdate(context, AdmEquipment.class, vos);
+        List<AdmComponent> vos = CollUtil.newArrayList(createRequest.getContent());
+        vos = service.doUpdate(context, AdmComponent.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -107,6 +105,6 @@ public class AdmComponentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName("component");
-        return service.doQuery(context, request, AdmEquipment.class);
+        return service.doQuery(context, request, AdmComponent.class);
     }
 }

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

@@ -1,7 +1,7 @@
 package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import cn.hutool.core.util.StrUtil;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmEquipment;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
@@ -58,7 +58,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
-        vos = service.doInsert(context, AdmEquipment.class, vos);
+        vos = service.doInsertEuip(context, AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 
@@ -88,6 +88,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
+        //vos = service.doUpdateEuip(context, AdmEquipment.class, vos);
         vos = service.doUpdate(context, AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
@@ -152,7 +153,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         //request.setName("equipment");
-        if(StringUtils.isNotEmpty(request.getFilters())){
+        if(StrUtil.isNotEmpty(request.getFilters())){
             request.setFilters(String.join(";",request.getFilters(),"objType in ['equipment','component']"));
         }else{
             request.setFilters("objType in ['equipment','component']");
@@ -171,7 +172,7 @@ public class AdmEquipmentController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
-        vos = service.doInsert(context, AdmEquipment.class, vos);
+        vos = service.doInsertExt(context, AdmEquipment.class, vos);
         return AdmResponse.success(vos);
     }
 

+ 48 - 0
src/main/java/com/persagy/proxy/adm/controller/AdmManualRelationCalcController.java

@@ -0,0 +1,48 @@
+package com.persagy.proxy.adm.controller;
+
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmRelationAddRequest;
+import com.persagy.proxy.adm.model.AdmTenant;
+import com.persagy.proxy.adm.request.AdmCreateResponse;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.AdmManualRelationCalcService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.RequiredArgsConstructor;
+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 javax.ws.rs.QueryParam;
+
+/***
+ * Description:手动计算输入类
+ * @author : lijie
+ * @date :2021/8/31 11:37
+ * Update By lijie 2021/8/31 11:37
+ */
+@RestController
+@RequestMapping("/rel-manual-calc/")
+@RequiredArgsConstructor
+public class AdmManualRelationCalcController {
+
+    private final AdmManualRelationCalcService admManualRelationCalcService;
+    
+    /***
+     * Description: 添加关系
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmCreateResponse  
+     * @author : lijie
+     * @date :2021/8/31 12:10
+     * Update By lijie 2021/8/31 12:10
+     */
+    @PostMapping(value = "add")
+    public AdmCreateResponse addRels(@RequestBody AdmRelationAddRequest request) throws Exception {
+        return admManualRelationCalcService.addRels(request);
+    }
+
+
+
+
+}

+ 144 - 0
src/main/java/com/persagy/proxy/adm/controller/REqForSpConreoller.java

@@ -0,0 +1,144 @@
+package com.persagy.proxy.adm.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmRelationService;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.common.entity.RelationDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description:设备服务于业务空间
+ * 018、关系-设备服务于业务空间
+ * @author:lgy
+ * @data:2021/9/1 10:23
+ */
+@RestController
+@RequestMapping("/rel/eq-for-sp-base")
+public class REqForSpConreoller {
+
+    @Autowired
+    private IAdmRelationService service;
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    /**
+     * create 创建设备服务于业务空间关系
+     * @param projectId projectId
+     * @param type type
+     * @param param param
+     * @return {@link com.persagy.proxy.adm.request.AdmResponse}
+     * @author lgy
+     * @date 2021/9/1 10:28
+     */
+    @PostMapping("/link-list")
+    public AdmResponse create(@RequestParam("projectId") String projectId,
+                              @RequestParam(value = "type", required = false) String type,
+                              @RequestBody JSONObject param) throws Exception {
+
+        JSONArray content = param == null ? null : param.getJSONArray("content");
+        if(CollUtil.isEmpty(content)) {
+            return AdmResponse.success();
+        }
+        // 创建关系对象
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < content.size();i++) {
+            JSONObject para = content.getJSONObject(i);
+            String equipId = para.getString("equipId");
+            String spaceId = para.getString("spaceId");
+            if(StrUtil.isBlank(equipId) || StrUtil.isBlank(spaceId)) {
+                return AdmResponse.failure("必填项:EquipId(设备id)、SpaceId(业务空间id)");
+            }
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "EquipforSpace", "Eq2Sp", type, equipId, spaceId));
+        }
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+
+    /**
+     * 创建服务于业务空间的设备关系
+     * 服务于业务空间的设备,业务空间一对多,累计添加不会覆盖以前记(必填项:EquipIdList(设备id列表)、SpaceId(业务空间id))
+     * @param type
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/link-eq-sp")
+    public AdmResponse createEq(@RequestParam("projectId") String projectId,
+                                @RequestParam(value = "type", required = false) String type,
+                                @RequestBody JSONObject param) throws Exception {
+        String spaceId = param.getString("spaceId");
+        JSONArray equipIdList = param.getJSONArray("equipIdList");
+        if(StrUtil.isBlank(spaceId) || CollUtil.isEmpty(equipIdList)) {
+            return AdmResponse.failure("必填项:EquipId(设备id)、SpaceId(业务空间id)");
+        }
+        // 创建关系对象
+        List<RelationDTO> voList = new ArrayList<>();
+        for(int i = 0;i < equipIdList.size();i++) {
+            String equipId = equipIdList.getString(i);
+            if(StrUtil.isBlank(equipId)) {
+                continue;
+            }
+            // 创建关系对象 - 参考(datasyn中DataCenterSync.kt)
+            voList.add(new RelationDTO(null, "EquipforSpace", "Eq2Sp", type, equipId, spaceId));
+        }
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doSave(context, voList);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 根据对象删除关系
+     * 根据对象删除设备服务于业务空间关系(必填项:EquipId(设备id)、SpaceId(业务空间id))
+     * @param type
+     * @param param
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/unlink-list")
+    public AdmResponse delete(@RequestParam String projectId,
+                              @RequestParam(value = "type", required = false) String type,
+                              @RequestBody JSONArray param) throws Exception {
+        if(CollUtil.isEmpty(param)) {
+            return AdmResponse.success();
+        }
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 组装条件
+        QueryCriteria criteria = new QueryCriteria();
+        for(int i = 0;i < param.size();i++) {
+            JSONObject para = param.getJSONObject(i);
+            String equipId = para.getString("equipId");
+            String spaceId = para.getString("spaceId");
+            if(StrUtil.isBlank(equipId) || StrUtil.isBlank(spaceId)) {
+                return AdmResponse.failure("必填项:EquipId(设备id)、SpaceId(业务空间id)");
+            }
+            ObjectNode node = JsonNodeFactory.instance.objectNode();
+            node.put("graphCode", "EquipforSpace");
+            node.put("relCode", "Eq2Sp");
+            node.put("relValue", type);
+            node.put("objFrom", equipId);
+            node.put("objTo", spaceId);
+            criteria.setCriteria(node);
+            service.doDelete(context, criteria);
+        }
+        return AdmResponse.success();
+    }
+}

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

@@ -8,13 +8,13 @@ import java.nio.charset.StandardCharsets;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.excel.ExcelWriter;
 import org.springframework.util.ResourceUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.ExcelWriter;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 
 import lombok.extern.slf4j.Slf4j;

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

@@ -88,7 +88,7 @@ public class AdmComponent {
         /** 最后更新日期 */
         private Date lastUpdate;
         /** 对象类型 */
-        private String objectType = "equipment";
+        private String objectType = "component";
 
         /** 信息点 */
         private Map<String, Object> infos;

+ 27 - 5
src/main/java/com/persagy/proxy/adm/model/AdmEquipment.java

@@ -50,6 +50,27 @@ public class AdmEquipment {
     /** 设备关联的资产id */
     private String propertyId;
 
+    /** 参见 EquipmentProSy **/
+    /** 品牌型号id */
+    private String dpManufacturerId;
+
+    /** 供应商信息id */
+    private String dpSupplierId;
+
+    /** 维修商信息id */
+    private String dpMaintainerId;
+
+    /** 保险公司信息id */
+    private String dpInsurerId;
+
+    /** 设备型号id */
+    private String dpSpecificationId;
+
+    /** 品牌id */
+    private String dpBrandId;
+    
+    
+
     /** Revit族 */
     private String bimFamilyName;
     /** Revit族类型 */
@@ -95,8 +116,9 @@ public class AdmEquipment {
     private Map<String, Object> infos;
     /** 统计信息 */
     private Map<String, Object> statistics;
-    /** 资产信息实体类 */
-    @CascadeColumn
+
+    /** 资产信息实体类   资产对应设备设施关系 资产→设备设施*/
+    @CascadeColumn(graphCode = "Property2Mech", relCode = "Pe2Eq", selectToObj = false)
     private AdmProperty property;
     /** 建筑信息实体类 */
     @CascadeColumn(graphCode = "MechForArch", relCode = "Eq2Bd")
@@ -119,10 +141,10 @@ public class AdmEquipment {
     @CascadeColumn(graphCode = "MechInArch", relCode = "Eq2Sh")
     private List<AdmShaft> shaftList;
     /** 资产列表 */
-    @CascadeColumn
+    @CascadeColumn(graphCode = "Property2Mech", relCode = "Pe2Eq", selectToObj = false)
     private List<AdmProperty> propertyList;
     /** 级联-部件 */
-    @CascadeColumn
-    private List<AdmEquipment> component;
+    @CascadeColumn(graphCode = "MechSubset", relCode = "Eq2Ec")
+    private List<AdmComponent> component;
 
 }

+ 39 - 0
src/main/java/com/persagy/proxy/adm/model/AdmRelationAddRequest.java

@@ -0,0 +1,39 @@
+package com.persagy.proxy.adm.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class AdmRelationAddRequest implements Serializable {
+    /**需要计算的类型*/
+    private String relType;
+
+    /**编码类型,CADID图纸编码(cadId),设备名称(name),设备ID(id),本地编码(localId),本地名称(localName)*/
+    private String type;
+
+    /**主对象内容*/
+    private String mainContent;
+
+    /**从对象内容*/
+    private List<String> fromContent;
+
+    /**图类型编码*/
+    @JsonAlias({"graphicType","graphic_type"})
+    @JsonProperty("graphicType")
+    @JSONField(name = "graphicType",alternateNames = {"parentCode","graphic_type"})
+    private String graphicType;
+
+
+}

+ 66 - 0
src/main/java/com/persagy/proxy/adm/request/AdmCreateResponse.java

@@ -0,0 +1,66 @@
+package com.persagy.proxy.adm.request;
+
+import com.alibaba.fastjson.JSONArray;
+import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
+import com.persagy.proxy.common.entity.DmpResult;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ADM 通用创建返回结果
+ * @author Charlie Yu
+ * @date 2021-08-16
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class AdmCreateResponse {
+    private final static String SUCCESS = "success";
+    private final static String FAILURE = "failure";
+    /** 结果 */
+    private String result;
+    /** 消息 */
+    private String message;
+    /** 错误数据主从对象 1 主对象  2 从对象 */
+    private String errorType;
+    /** 查询到的数据列表 */
+    private List<?> entityList;
+
+    public static AdmCreateResponse success() {
+        return new AdmCreateResponse(SUCCESS, null, null, null);
+    }
+
+    public static AdmCreateResponse failure(String message) {
+        return new AdmCreateResponse(FAILURE, message, null, new ArrayList<>());
+    }
+
+    public static AdmCreateResponse failure(String message,String errorType) {
+        return new AdmCreateResponse(FAILURE, message, errorType, new ArrayList<>());
+    }
+
+    public static AdmCreateResponse success(List<?> content) {
+        return new AdmCreateResponse(SUCCESS, null, null, content);
+    }
+
+    /**
+     * 从数据中台结果转换
+     * @param admRequest
+     * @param dmpResult
+     * @param clazz
+     * @param <T>
+     * @return
+     */
+    public static <T> AdmCreateResponse fromDmp(AdmQueryCriteria admRequest, DmpResult<JSONArray> dmpResult, Class<T> clazz) {
+        if(!DmpResult.SUCCESS.equals(dmpResult.getResult())) {
+            return failure("调用中台查询接口出错:" + dmpResult.getMessage());
+        }
+        // 转换为结果
+        List<T> admVOs = AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.getData(), admRequest.getProjection(), clazz);
+        Long total = dmpResult.getCount() == null ? null : dmpResult.getCount().longValue();
+        return new AdmCreateResponse(SUCCESS, null, null, admVOs);
+    }
+}

+ 21 - 0
src/main/java/com/persagy/proxy/adm/service/AdmManualRelationCalcService.java

@@ -0,0 +1,21 @@
+package com.persagy.proxy.adm.service;
+
+import com.persagy.proxy.adm.model.AdmRelationAddRequest;
+import com.persagy.proxy.adm.request.AdmCreateResponse;
+/***
+ * Description: 手动关系计算逻辑处理接口
+ * @author : lijie
+ * @date :2021/8/31 12:14
+ * Update By lijie 2021/8/31 12:14
+ */
+public interface AdmManualRelationCalcService {
+    /***
+     * Description: 添加关系
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmCreateResponse  
+     * @author : lijie
+     * @date :2021/8/31 12:14
+     * Update By lijie 2021/8/31 12:14
+     */
+    AdmCreateResponse addRels(AdmRelationAddRequest request);
+}

+ 49 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmComAndEquipService.java

@@ -0,0 +1,49 @@
+package com.persagy.proxy.adm.service;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author lvxy
+ * @date 2021/9/2
+ */
+
+public interface IAdmComAndEquipService {
+    default QueryCriteria getDmpCriteria(InstanceUrlParam context, Set<String> classCodes, String objType){
+        QueryCriteria criteriaObject = new QueryCriteria();
+        ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode();
+
+        ArrayNode array = criteriaEq.putObject("code").putArray("$in");
+        classCodes.forEach(code -> array.add(code));
+
+        criteriaEq.put("objType", objType);
+        criteriaObject.setCriteria(criteriaEq);
+        criteriaObject.setSize(classCodes.size() * 1L);
+        criteriaObject.setPage(1L);
+        criteriaObject.setWithoutCount(true);
+        return criteriaObject;
+    }
+
+    default Map<String, ObjectTypeDefine> getDefineMap(DmpResult<JSONArray> resultDef){
+        Map<String, ObjectTypeDefine> defClassMap = new HashMap<String, ObjectTypeDefine>();
+        if(resultDef.getResult().equals(DmpResult.SUCCESS)){
+            JSONArray defArr = resultDef.getData();
+            List<ObjectTypeDefine> defineList = JSONUtil.toList(defArr.toString(), ObjectTypeDefine.class);
+            defClassMap = CollUtil.fieldValueMap(defineList, "code");
+        }
+        return defClassMap;
+    }
+}

+ 11 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmComponentService.java

@@ -1,6 +1,9 @@
 package com.persagy.proxy.adm.service;
 
 import com.persagy.proxy.adm.model.AdmComponent;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+import java.util.List;
 
 /**
  * ADM 组件 接口
@@ -8,4 +11,12 @@ import com.persagy.proxy.adm.model.AdmComponent;
  * @date 2021/8/19
  */
 public interface IAdmComponentService extends IAdmBaseService<AdmComponent>{
+    /**
+     * 新增
+     * @param context
+     * @param clazz
+     * @param voList
+     * @return
+     */
+    List<AdmComponent> doInsertExt(InstanceUrlParam context, Class<AdmComponent> clazz, List<AdmComponent> voList);
 }

+ 33 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmEquipmentService.java

@@ -1,6 +1,9 @@
 package com.persagy.proxy.adm.service;
 
 import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+
+import java.util.List;
 
 /**
  * ADM 设备接口
@@ -8,4 +11,34 @@ import com.persagy.proxy.adm.model.AdmEquipment;
  * @date 2021/8/18
  */
 public interface IAdmEquipmentService extends IAdmBaseService<AdmEquipment>{
+
+    /**
+     * 新增
+     * @param context
+     * @param clazz
+     * @param voList
+     * @return
+     */
+    List<AdmEquipment> doInsertEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
+
+    /**
+     * 修改 资产现在前端隐藏
+     * @param context
+     * @param clazz
+     * @param voList
+     * @return
+     */
+    @Deprecated
+    List<AdmEquipment> doUpdateEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
+
+    /**
+     * 删除 资产现在前端隐藏
+     * @param context
+     * @param voList
+     * @return
+     */
+    @Deprecated
+    void doDeleteEuip(InstanceUrlParam context, List<AdmEquipment> voList);
+    @Deprecated
+    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
 }

+ 235 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmManualRelationCalcServiceImpl.java

@@ -0,0 +1,235 @@
+package com.persagy.proxy.adm.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.persagy.dmp.common.context.AppContext;
+import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
+import com.persagy.proxy.adm.model.AdmRelationAddRequest;
+import com.persagy.proxy.adm.request.AdmCreateResponse;
+import com.persagy.proxy.adm.service.AdmManualRelationCalcService;
+import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/***
+ * Description: 手动计算逻辑处理类
+ * @author : lijie
+ * @date :2021/8/31 11:51
+ * Update By lijie 2021/8/31 11:51
+ */
+@Service
+@Slf4j
+public class AbstractAdmManualRelationCalcServiceImpl implements AdmManualRelationCalcService {
+
+    /***
+     * Description: 添加关系
+     * @param request : 请求参数
+     * @return : com.persagy.proxy.adm.request.AdmCreateResponse
+     * @author : lijie
+     * @date :2021/8/31 12:14
+     * Update By lijie 2021/8/31 12:14
+     */
+    @Override
+    public AdmCreateResponse addRels(AdmRelationAddRequest request) {
+        // 获取项目id
+        String projectId = AppContext.getContext().getProjectId();
+        if (StrUtil.isBlank(request.getRelType())){
+            return AdmCreateResponse.failure("关系类型不能为空");
+        }
+        if (StrUtil.isBlank(request.getType())){
+            return AdmCreateResponse.failure("识别不能为空");
+        }
+        if (StrUtil.isBlank(request.getMainContent())){
+            return AdmCreateResponse.failure("主对象不能为空","1");
+        }
+        if (CollUtil.isEmpty(request.getFromContent())){
+            return AdmCreateResponse.failure("从对象不能为空","2");
+        }
+        // 2.1 pe2sp,pe2sh,eq2sh_for,eq2fl_for,eq2bd_for,sy2sp_for,sy2sh_for,sy2fl_for,sy2bd_for
+        // sp2sp_ConvectionNetwork_1,sp2sp_ConvectionNetwork_2,sp2sp_ConvectionNetwork_3,sp2sp_SpaceNeighborhood_5
+        // sp2sp_SpaceNeighborhood_2,sp2sp_SpaceNeighborhood_4,sp2sp_TrafficNetwork_3,sp2sp_TrafficNetwork_2,
+        // sp2sp_RadiationNetwork_1,sp2sp_RadiationNetwork_2,sp2sp_SpaceNeighborhood_1,sp2sp_TrafficNetwork_1,
+        // sp2sp_SpaceNeighborhood_3,eq2sy_ControlRelation_2,eq2sy_ValveRelationship_vv2sy,
+        // eq2sy_SensorRelationship_ss2sy,eq2sp_SensorRelationship_ss2sp,eq2sp_x,bd2bd_ArchForArch,bd2fl_ArchForArch,
+        // bd2sh_ArchForArch,bd2sp_ArchForArch,fl2bd_ArchForArch,fl2fl_ArchForArch,fl2sh_ArchForArch,fl2sp_ArchForArch,
+        // sh2bd_ArchForArch,sh2fl_ArchForArch,sh2sh_ArchForArch,sh2sp_ArchForArch,sp2bd_ArchForArch,sp2fl_ArchForArch,
+        // sp2sh_ArchForArch,sp2sp_ArchForArch
+        // 校验关系类型是否存在
+        Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
+        if (relationTypeMap.containsKey(request.getRelType())){
+            return AdmCreateResponse.failure("不存在的关系类型");
+        }
+        AdmRelationTypeEnum relationTypeEnum = relationTypeMap.get(request.getRelType());
+        // type为cadId直接提示从对象不存在CADID编码并且errorType=2
+        if (AdmObjectInfoConstant.CADID.equals(request.getType()) && relationTypeEnum.getHasCheckCadId()){
+            return AdmCreateResponse.failure("从对象不存在CADID编码","2");
+        }
+
+
+
+
+        // 1.根据项目id和关系类型更新计算时间为当前时间
+        // 2.根据不同关系类型进行处理
+
+
+        // 2.2 特殊类型的判断
+        // *******
+        // sp2sp_RadiationNetwork_2,sp2sp_RadiationNetwork_1 && classCode!=LightingZone errorType=1,不是照明分区类型
+        // sp2sp_ConvectionNetwork_2,sp2sp_ConvectionNetwork_3,sp2sp_ConvectionNetwork_1 && classCode!=AirConditioningZone errorType=1,不是空调分区类型
+        // sp2sp_TrafficNetwork_3,sp2sp_TrafficNetwork_2,sp2sp_TrafficNetwork_1 && classCode!=GeneralZone errorType=1,不是物业分区类型
+        // relType为上面几种的规定从对象不能重复,主对象和从对象不能重复
+        // *******
+        // eq2eq_EquipPower_1,eq2eq_EquipPower_2,eq2eq_EquipPower_3,eq2eq_EquipPower_4
+        // 主对象的class_code必须等于SETDLS,SETDHS,其他的报不符合主对象条件限制错误
+        // *******
+
+
+        // 2.3 根据对象信息点和对象内容(主/副)查询对象,然后添加关系及计算标记
+        // 1.obj_type,project_id,type(设备名称(name),设备ID(id),本地编码(localId),本地名称(localName))查询主对象
+        // 2.obj_type,project_id,type(设备名称(name),设备ID(id),本地编码(localId),本地名称(localName)),是否排除主对象id,是否主对象的class_code查询从对象
+        // 3.不存在/多实例,errorType为1,2(1-主实例,2-从实例),结束
+        // 4.插入关系from_id,to_id,图类型编码,边类型编码,项目id,如果rel_value有值则加上,结束
+        // 5.处理sign:计算标记 1 为手动 2为自动
+        // pe2sp:from_id为资产id,to_id为空间id,主对象obj_type为property,从对象obj_type为space,图类型为PropertyInArch,边类型为Pe2Sp,rel_value为查询的空间对应的class_code
+        // pe2sh:from_id为资产id,to_id为竖井id,主对象obj_type为property,从对象obj_type为shaft,图类型为PropertyInArch,边类型为Pe2Sh
+        // eq2sh_for:from_id为设备id,to_id为竖井id,主对象obj_type为equipment,从对象obj_type为shaft,图类型为MechForArch,边类型为Eq2Sh
+        // eq2fl_for:from_id为设备id,to_id为楼层id,主对象obj_type为equipment,从对象obj_type为floor,图类型为MechForArch,边类型为Eq2Fl
+        // eq2bd_for:from_id为设备id,to_id为建筑id,主对象obj_type为equipment,从对象obj_type为building,图类型为MechForArch,边类型为Eq2Bd
+        // sy2sp_for:from_id为系统id,to_id为空间id,主对象obj_type为system,从对象obj_type为space,图类型为MechForArch,边类型为Sy2Sp
+        // sy2sh_for:from_id为系统id,to_id为竖井id,主对象obj_type为system,从对象obj_type为shaft,图类型为MechForArch,边类型为Sy2Sh
+        // sy2fl_for:from_id为系统id,to_id为楼层id,主对象obj_type为system,从对象obj_type为floor,图类型为MechForArch,边类型为Sy2Fl
+        // sy2bd_for:from_id为系统id,to_id为建筑id,主对象obj_type为system,从对象obj_type为building,图类型为MechForArch,边类型为Sy2Bd
+        // sy2bd_for:from_id为系统id,to_id为建筑id,主对象obj_type为system,从对象obj_type为floor,图类型为MechForArch,边类型为Sy2Bd
+        // *******
+        // 从对象查询排除主对象id,主对象的class_code查询从对象
+        // sp2sp_ConvectionNetwork_1,sp2sp_ConvectionNetwork_2,sp2sp_ConvectionNetwork_3,sp2sp_SpaceNeighborhood_5
+        // sp2sp_SpaceNeighborhood_2,sp2sp_SpaceNeighborhood_4,sp2sp_TrafficNetwork_3,sp2sp_TrafficNetwork_2,
+        // sp2sp_RadiationNetwork_1,sp2sp_RadiationNetwork_2,sp2sp_SpaceNeighborhood_1,sp2sp_TrafficNetwork_1,
+        // sp2sp_SpaceNeighborhood_3
+        // from_id为空间id,to_id为空间id,主对象obj_type为space,从对象obj_type为space,rel_value为查询的主对象空间对应的class_code
+        // sp2sp_ConvectionNetwork_1:图类型为ConvectionNetwork,边类型为Natural
+        // sp2sp_ConvectionNetwork_2:图类型为ConvectionNetwork,边类型为MixMech
+        // sp2sp_ConvectionNetwork_3:图类型为ConvectionNetwork,边类型为OnewayMech
+        // sp2sp_SpaceNeighborhood_1:图类型为SpaceNeighborhood,边类型为None
+        // sp2sp_SpaceNeighborhood_2:图类型为SpaceNeighborhood,边类型为Door
+        // sp2sp_SpaceNeighborhood_3:图类型为SpaceNeighborhood,边类型为Window
+        // sp2sp_SpaceNeighborhood_4:图类型为SpaceNeighborhood,边类型为DoorWindow
+        // sp2sp_SpaceNeighborhood_5:图类型为SpaceNeighborhood,边类型为Connect
+        // sp2sp_TrafficNetwork_1:图类型为TrafficNetwork,边类型为Normal
+        // sp2sp_TrafficNetwork_2:图类型为TrafficNetwork,边类型为FFOpen
+        // sp2sp_TrafficNetwork_3:图类型为TrafficNetwork,边类型为FFClose
+        // sp2sp_RadiationNetwork_1:图类型为RadiationNetwork,边类型为Connect
+        // sp2sp_RadiationNetwork_2:图类型为RadiationNetwork,边类型为Transparent
+        // *******
+        // 从对象查询排除主对象id
+        // eq2eq_LUDistribution_1,eq2eq_LUDistribution_2,eq2eq_HUDistribution_1,eq2eq_HUDistribution_2,
+        // eq2eq_EquipPower_1,eq2eq_EquipPower_2,eq2eq_EquipPower_3,eq2eq_EquipPower_4
+        // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
+        // eq2eq_LUDistribution_1:图类型为LUDistribution,边类型为Normal
+        // eq2eq_LUDistribution_2:图类型为LUDistribution,边类型为Backup
+        // eq2eq_HUDistribution_1:图类型为LUDistribution,边类型为Normal
+        // eq2eq_HUDistribution_2:图类型为LUDistribution,边类型为Backup
+        // eq2eq_EquipPower_1:图类型为EquipPower,边类型为EqNormal
+        // eq2eq_EquipPower_2:图类型为EquipPower,边类型为EqBackup
+        // eq2eq_EquipPower_3:图类型为EquipPower,边类型为SyNormal
+        // eq2eq_EquipPower_4:图类型为EquipPower,边类型为SyBackup
+        // ******
+        // 从对象查询排除主对象id
+        // eq2eq_ACAirNetwork_1,eq2eq_ACAirNetwork_2,eq2eq_ACAirNetwork_3
+        // eq2eq_ChillWaterLoop_1,eq2eq_ChillWaterLoop_2,eq2eq_ChillWaterLoop_3,eq2eq_ChillWaterLoop_4
+        // eq2eq_CoolingWaterLoop_1,eq2eq_CoolingWaterLoop_2,eq2eq_CoolingWaterLoop_3,eq2eq_CoolingWaterLoop_4
+        // eq2eq_CondWaterNetwork_1
+        // eq2eqFreshAirNetwork_1
+        // eq2eq_HeatWaterLoop_1,eq2eq_HeatWaterLoop_2,eq2eq_HeatWaterLoop_3,eq2eq_HeatWaterLoop_4
+        // eq2eq_VentNetwork_1,eq2eq_VentNetwork_2,eq2eq_VentNetwork_3
+        // eq2eq_VRFNetwork_1
+        // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
+        // eq2eq_ACAirNetwork_1:图类型为ACAirNetwork,边类型为Supply
+        // eq2eq_ACAirNetwork_2:图类型为ACAirNetwork,边类型为Return
+        // eq2eq_ACAirNetwork_3:图类型为ACAirNetwork,边类型为Discharge
+        // eq2eq_ChillWaterLoop_1:图类型为ChillWaterLoop,边类型为Supply
+        // eq2eq_ChillWaterLoop_2:图类型为ChillWaterLoop,边类型为Return
+        // eq2eq_ChillWaterLoop_3:图类型为ChillWaterLoop,边类型为Bypass
+        // eq2eq_ChillWaterLoop_4:图类型为ChillWaterLoop,边类型为Fill
+        // eq2eq_CoolingWaterLoop_1:图类型为CoolingWaterLoop,边类型为Supply
+        // eq2eq_CoolingWaterLoop_2:图类型为CoolingWaterLoop,边类型为Return
+        // eq2eq_CoolingWaterLoop_3:图类型为CoolingWaterLoop,边类型为Bypass
+        // eq2eq_CoolingWaterLoop_4:图类型为CoolingWaterLoop,边类型为Fill
+        // eq2eq_CondWaterNetwork_1:图类型为CondWaterNetwork,边类型为Discharge
+        // eq2eqFreshAirNetwork_1:图类型为FreshAirNetwork,边类型为Fresh
+        // eq2eq_HeatWaterLoop_1:图类型为HeatWaterLoop,边类型为Supply
+        // eq2eq_HeatWaterLoop_2:图类型为HeatWaterLoop,边类型为Return
+        // eq2eq_HeatWaterLoop_3:图类型为HeatWaterLoop,边类型为Bypass
+        // eq2eq_HeatWaterLoop_4:图类型为HeatWaterLoop,边类型为Fill
+        // eq2eq_VentNetwork_1:图类型为VentNetwork,边类型为Supply
+        // eq2eq_VentNetwork_2:图类型为VentNetwork,边类型为Discharge
+        // eq2eq_VentNetwork_3:图类型为VentNetwork,边类型为Uncertain
+        // eq2eq_VRFNetwork_1:图类型为VRFNetwork,边类型为SupplyReturn
+        // ******
+        // 从对象查询排除主对象id
+        // eq2eq_SupplyWaterNetwork_1,eq2eq_SupplyWaterNetwork_2
+        // eq2eq_DrainingWaterNetwork_1,eq2eq_DrainingWaterNetwork_2
+        // eq2eq_DrinkingWaterNetwork_1,eq2eq_DrinkingWaterNetwork_2
+        // eq2eq_DHWNetwork_1,eq2eq_DHWNetwork_2
+        // eq2eq_GasNetwork_1,eq2eq_GasNetwork_2
+        // eq2eq_FireWaterNetwork_1,eq2eq_FireWaterNetwork_2
+        // eq2eq_FireVentNetwork_1
+        // eq2eq_RecycleWaterNetwork_1,eq2eq_RecycleWaterNetwork_2
+        // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
+        // eq2eq_SupplyWaterNetwork_1:图类型为SupplyWaterNetwork,边类型为Supply
+        // eq2eq_SupplyWaterNetwork_2:图类型为SupplyWaterNetwork,边类型为Bypass
+        // eq2eq_DrainingWaterNetwork_1:图类型为DrainingWaterNetwork,边类型为Discharge
+        // eq2eq_DrainingWaterNetwork_2:图类型为DrainingWaterNetwork,边类型为Bypass
+        // eq2eq_DrinkingWaterNetwork_1:图类型为DrinkingWaterNetwork,边类型为Supply
+        // eq2eq_DrinkingWaterNetwork_2:图类型为DrinkingWaterNetwork,边类型为Bypass
+        // eq2eq_DHWNetwork_1:图类型为DHWNetwork,边类型为Supply
+        // eq2eq_DHWNetwork_2:图类型为DHWNetwork,边类型为Bypass
+        // eq2eq_GasNetwork_1:图类型为GasNetwork,边类型为Supply
+        // eq2eq_GasNetwork_2:图类型为GasNetwork,边类型为Bypass
+        // eq2eq_FireWaterNetwork_1:图类型为FireWaterNetwork,边类型为Supply
+        // eq2eq_FireWaterNetwork_2:图类型为FireWaterNetwork,边类型为Bypass
+        // eq2eq_FireVentNetwork_1:图类型为FireVentNetwork,边类型为Discharge
+        // eq2eq_RecycleWaterNetwork_1:图类型为RecycleWaterNetwork,边类型为Supply
+        // eq2eq_RecycleWaterNetwork_2:图类型为RecycleWaterNetwork,边类型为Bypass
+        // ******
+        // eq2eq_SensorNetwork_1,eq2eq_ControlRelation_1,eq2eq_ValveRelationship_vv2eq,eq2eq_ControlEquipNetwork
+        // 从对象查询排除主对象id
+        // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
+        // eq2eq_SensorNetwork_1:图类型为SensorNetwork,边类型为Normal
+        // eq2eq_ControlRelation_1:图类型为ControlRelation,边类型为MechCtrl
+        // eq2eq_ValveRelationship_vv2eq:图类型为ValveRelationship,边类型为Vv2Eq
+        // eq2eq_ControlEquipNetwork:图类型为ControlEquipNetwork,边类型为Normal
+        // ******
+        // eq2eq_SensorRelationship_ss2eq
+        // 从对象查询排除主对象id
+        // 传感器类型检查
+        // eq2eq_SensorRelationship_ss2eq:图类型为SensorRelationship,边类型为Ss2Eq
+        // *****
+        // eq2sy_ControlRelation_2,eq2sy_ValveRelationship_vv2sy
+        // eq2sy_ControlRelation_2:图类型为ControlRelation,边类型为SyCtrl
+        // eq2sy_ValveRelationship_vv2sy:图类型为ValveRelationship,边类型为Vv2Sy
+        // *****
+        // eq2sy_SensorRelationship_ss2sy
+        // 传感器类型检查
+        // eq2sy_SensorRelationship_ss2sy:图类型为SensorRelationship,边类型为Ss2Sy
+        // *****
+        // eq2sp_SensorRelationship_ss2sp
+        // 传感器类型检查
+        // eq2sp_SensorRelationship_ss2sp:图类型为SensorRelationship,边类型为Ss2Sp
+        // *****
+        // eq2sp_x
+        // bd2bd_ArchForArch,bd2fl_ArchForArch,bd2sh_ArchForArch,bd2sp_ArchForArch,fl2bd_ArchForArch,fl2fl_ArchForArch
+        // fl2sh_ArchForArch,fl2sp_ArchForArch,sh2bd_ArchForArch,sh2fl_ArchForArch,sh2sh_ArchForArch,sh2sp_ArchForArch
+        // sp2bd_ArchForArch,sp2fl_ArchForArch,sp2sh_ArchForArch,sp2sp_ArchForArch
+
+
+
+
+
+
+
+        return null;
+    }
+}

+ 55 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AdmComponentServiceImpl.java

@@ -1,14 +1,68 @@
 package com.persagy.proxy.adm.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.proxy.adm.model.AdmComponent;
+import com.persagy.proxy.adm.service.IAdmComAndEquipService;
 import com.persagy.proxy.adm.service.IAdmComponentService;
+import com.persagy.proxy.adm.utils.ObjectNameUtil;
+import com.persagy.proxy.common.client.DmpRwdClient;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
  * ADM 组件 服务
  * @author lvxy
  * @date 2021/8/19
  */
 @Service
-public class AdmComponentServiceImpl extends AbstractAdmBaseServiceImpl<AdmComponent> implements IAdmComponentService {
+public class AdmComponentServiceImpl extends AbstractAdmBaseServiceImpl<AdmComponent> implements IAdmComponentService, IAdmComAndEquipService {
+
+    @Autowired
+    private DmpRwdClient rwdClient;
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public List<AdmComponent> doInsertExt(InstanceUrlParam context, Class<AdmComponent> clazz, List<AdmComponent> voList) {
+        if(CollUtil.isEmpty(voList)) {
+            return null;
+        }
+        Set<String> classCodes = voList.stream().map(AdmComponent::getClassCode).collect(Collectors.toSet());
+        //查询定义类型
+        QueryCriteria criteriaObject = getDmpCriteria(context, classCodes, "component");
+        JSONObject paraPe = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(criteriaObject);
+            paraPe = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException("转换查询条件出错:" + e.getMessage());
+        }
+        DmpResult<JSONArray> resultDef = rwdClient.queryDefClass(context, paraPe);
+        Map<String, ObjectTypeDefine> finalDefClassMap = getDefineMap(resultDef);
+        // 设备名字处理
+        voList.forEach(component -> {
+            if (StrUtil.isNotEmpty(component.getName()) && CollUtil.isNotEmpty(finalDefClassMap) && finalDefClassMap.containsKey(component.getClassCode())) {
+                ObjectTypeDefine defclass = finalDefClassMap.get(component.getClassCode());
+                component.setName(ObjectNameUtil.objectName(defclass.getName()+"-"));
+            }else{
+                component.setName(ObjectNameUtil.objectName("部件-"));
+            }
+        });
+        return doInsert(context, clazz, voList);
+    }
+
 }

+ 272 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AdmEquipmentServiceImpl.java

@@ -1,14 +1,285 @@
 package com.persagy.proxy.adm.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.model.entity.BaseEntity;
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
+import com.persagy.dmp.digital.client.DigitalRelationFacade;
+import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmProperty;
+import com.persagy.proxy.adm.service.IAdmComAndEquipService;
 import com.persagy.proxy.adm.service.IAdmEquipmentService;
+import com.persagy.proxy.adm.utils.AdmEntityTransferUtil;
+import com.persagy.proxy.adm.utils.ObjectNameUtil;
+import com.persagy.proxy.common.client.DmpRwdClient;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import com.persagy.proxy.common.entity.ObjRelationDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
  * ADM 设备 实现
  * @author lvxy
  * @date 2021/8/18
  */
+@Slf4j
 @Service
-public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquipment> implements IAdmEquipmentService {
+public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquipment> implements IAdmEquipmentService, IAdmComAndEquipService {
+
+    @Autowired
+    private DmpRwdClient rwdClient;
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Override
+    public List<AdmEquipment> doInsertEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
+        if(CollUtil.isEmpty(voList)) {
+            return null;
+        }
+        Set<String> classCodes = voList.stream().map(AdmEquipment::getClassCode).collect(Collectors.toSet());
+        //查询定义类型
+        QueryCriteria criteriaObject = getDmpCriteria(context, classCodes, "equipment");
+        JSONObject paraPe = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(criteriaObject);
+            paraPe = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException("转换查询条件出错:" + e.getMessage());
+        }
+        DmpResult<JSONArray> resultDef = rwdClient.queryDefClass(context, paraPe);
+        Map<String, ObjectTypeDefine> finalDefClassMap = getDefineMap(resultDef);
+        // 设备名字处理
+        voList.forEach(equip -> {
+            if (StrUtil.isNotEmpty(equip.getName())) {
+                if(CollUtil.isNotEmpty(finalDefClassMap) && finalDefClassMap.containsKey(equip.getClassCode())){
+                    ObjectTypeDefine defclass = finalDefClassMap.get(equip.getClassCode());
+                    equip.setName(ObjectNameUtil.objectName(defclass.getName()+"-"));
+                }else{
+                    equip.setName(ObjectNameUtil.objectName("设备-"));
+                }
+            }
+        });
+        return doInsert(context, clazz, voList);
+    }
+
+    @Override
+    public List<AdmEquipment> doUpdateEuip(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
+        //TODO 处理关系标记
+        /*try {
+         *//** 处理关系标记 *//*
+            val listtype = ArrayList<String>()
+            listtype.add("pe2bd")
+            listtype.add("pe2fl")
+            listtype.add("pe2sh")
+            listtype.add("pe2sp")
+            for (type in listtype){
+                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("relationType", type)).entity()
+                if (entity!=null){
+                    entity.computationalState = 2
+                    relationTypeProjectservice.update(entity)
+                }
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }*/
+        Map<String, AdmEquipment> voMap = CollUtil.fieldValueMap(voList, BaseEntity.PROP_ID);
+        //查询设备对应的资产 关系 Pe2Eq (1:N,一个资产关联多个设备,设备是最小单位 by:lvxianyun)
+        DmpResult<List<ObjRelationDTO>> relationRes = queryRelation(context, voMap);
+        boolean isDealDataSucc = false;
+        //不是绑定关系,清理绑定关系,重新绑定
+        if(CollUtil.isNotEmpty(relationRes.getData())){
+            isDealDataSucc = updateRelation2Pe(context, relationRes, voMap);
+        }else {
+            //不存在关系,需要新绑定关系,更新per,插入关系
+            isDealDataSucc = insertRelation2Pe(context, voList, voMap);
+        }
+        return isDealDataSucc ? doUpdate(context, clazz, voList) : null;
+    }
+
+    @Override
+    public void doDeleteEuip(InstanceUrlParam context, List<AdmEquipment> voList) {
+        Map<String, AdmEquipment> voMap = CollUtil.fieldValueMap(voList, BaseEntity.PROP_ID);
+        DmpResult<List<ObjRelationDTO>> relationRes = queryRelation(context, voMap);
+        //清理绑定关系
+        if(CollUtil.isNotEmpty(relationRes.getData())){
+            updateRelation2Pe(context, relationRes, voMap);
+        }
+        doDelete(context,voList);
+    }
+
+    @Override
+    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
+
+        //创建设备
+        List<AdmEquipment> vos = doInsert(context, AdmEquipment.class, voList);
+        //创建资产
+        //创建设备和系统关系 systemList
+        return null;
+    }
+
+
+
+
+    private DmpResult<List<ObjRelationDTO>> queryRelation(InstanceUrlParam context, Map<String, AdmEquipment> voMap){
+        QueryCriteria dmpRequest = new QueryCriteria();
+        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+        ArrayNode array = criteria.putObject("objTo").putArray("$in");
+        voMap.keySet().forEach(equipId -> array.add(equipId));
+        criteria.put("relCode", "Pe2Eq");
+        criteria.put("graphCode", "Property2Mech");
+        dmpRequest.setCriteria(criteria);
+        dmpRequest.setSize(voMap.size() * 1L);
+        dmpRequest.setPage(1L);
+        dmpRequest.setWithoutCount(true);
+        // 转换参数
+        JSONObject paraRel = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(dmpRequest);
+            paraRel = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            log.error(e.getMessage(), e);
+            return null;
+        }
+        return rwdClient.queryRelation(context, dmpRequest);
+    }
+
+    private DmpResult<JSONArray> queryObject(InstanceUrlParam context, Map<String, AdmEquipment> peMap){
+        QueryCriteria criteriaObject = new QueryCriteria();
+        ObjectNode criteriaPe = JsonNodeFactory.instance.objectNode();
+        ArrayNode array = criteriaPe.putObject("id").putArray("$in");
+        peMap.keySet().forEach(equipId -> array.add(equipId));
+        criteriaPe.put("classCode", "property");
+        criteriaPe.put("objType", "property");
+        criteriaObject.setCriteria(criteriaPe);
+        criteriaObject.setSize(peMap.size() * 1L);
+        criteriaObject.setPage(1L);
+        criteriaObject.setWithoutCount(true);
+        // 转换参数
+        JSONObject paraPe = null;
+        try {
+            String paraStr = objectMapper.writeValueAsString(criteriaObject);
+            paraPe = JSONObject.parseObject(paraStr);
+        } catch (JsonProcessingException e) {
+            log.error(e.getMessage(), e);
+            return null;
+        }
+        return rwdClient.queryObject(context, paraPe);
+    }
+
+    private AdmProperty createPropertyObj(String id, String equipId, Boolean isBimIdNull){
+        AdmProperty admProperty = new AdmProperty();
+        admProperty.setId(id);
+        admProperty.setEquipId(equipId);
+        if(isBimIdNull){
+            admProperty.setBimId(null);
+        }
+        return admProperty;
+    }
+
+    private ObjectNode creatRelationObj(String objTo,String objFrom){
+        ObjectNode relationNew = JsonNodeFactory.instance.objectNode();
+        relationNew.put("relCode", "Pe2Eq");
+        relationNew.put("graphCode", "Property2Mech");
+        relationNew.put("graphCode", "Property2Mech001");
+        relationNew.put("objTo", objTo);
+        relationNew.put("objFrom", objFrom);
+        return relationNew;
+    }
+
+
+    /**
+     * 更新设备关联的资产(资产中的equipId 信息点) 以及设备资产关系
+     * @return
+     */
+    private Boolean updateRelation2Pe(InstanceUrlParam context, DmpResult<List<ObjRelationDTO>> relationRes, Map<String, AdmEquipment> voMap){
+        boolean isDealDataSucc = false;
+        List<AdmProperty> updatePropertyList = new ArrayList<AdmProperty>();
+        List<String> del_relationIds = new ArrayList<>(relationRes.getData().size());
+        Map<String, ObjRelationDTO> relationMap = CollUtil.fieldValueMap(relationRes.getData(), "objTo");
+        relationMap.keySet().forEach(euipId -> {
+            //存在绑定的资产
+            if(voMap.keySet().contains(euipId)){
+                AdmEquipment admEquipment = voMap.get(euipId);
+                ObjRelationDTO relation = relationMap.get(euipId);
+                String propertyId = relation.getObjFrom();
+                if(StrUtil.isNotEmpty(admEquipment.getPropertyId()) && StrUtil.isNotEmpty(propertyId)
+                        && !admEquipment.getPropertyId().equals(propertyId)){
+                    //1 与设备提供的资产绑定
+                    AdmProperty propertyFrom = createPropertyObj(admEquipment.getPropertyId(), euipId, false);
+                    propertyFrom.setId(admEquipment.getPropertyId());
+                    propertyFrom.setEquipId(euipId);
+                    updatePropertyList.add(propertyFrom);
+
+                    //2 从关系中查询出的资产与当前设备解绑
+                    //更新资产中的信息点
+                    AdmProperty property = createPropertyObj(propertyId, null, true);
+                    updatePropertyList.add(property);
+
+                    //更新关系
+                    del_relationIds.add(relation.getId());
+                }
+            }
+        });
+        DigitalRelationFacade.delete(context.getGroupCode(),context.getProjectId(), AdmCommonConstant.APP_ID,null,del_relationIds);
+        DmpResult propertyResult = rwdClient.updateObject(context, JSONArray.parseArray(updatePropertyList.toString()));
+        if(propertyResult.getResult().equals(DmpResult.SUCCESS)){
+            isDealDataSucc = true;
+        }
+        return isDealDataSucc;
+    }
+
+
+    /**
+     * 不存在关系,需要新绑定关系,更新per,插入关系
+     * @param context
+     * @param voList
+     * @param voMap
+     * @return
+     */
+    private Boolean insertRelation2Pe(InstanceUrlParam context, List<AdmEquipment> voList, Map<String, AdmEquipment> voMap){
+        boolean isDealDataSucc = false;
+        Map<String, AdmEquipment> peMap = CollUtil.fieldValueMap(voList, "propertyId");
+        //查询资产
+        DmpResult<JSONArray> resultPe = queryObject(context, peMap);
+        if (CollUtil.isNotEmpty(resultPe.getData())) {
+            //更新资产 创建资产设备关系
+            List<AdmProperty> propertyList = AdmEntityTransferUtil.toAdmMultiEntity(resultPe.getData(), null, AdmProperty.class);
+            List<ObjectNode> objRelationDTONews = new ArrayList<>();
+            propertyList.forEach(property -> {
+                //存在绑定的资产 更新
+                AdmEquipment admEquipment = peMap.get(property.getId());
+                property.setEquipId(admEquipment.getId());
+                //创建新的设备资产关系
+                ObjectNode relationNew = creatRelationObj( admEquipment.getId(), property.getId());
+                objRelationDTONews.add(relationNew);
+            });
+
+            List<ObjectRelation> relationList = DigitalRelationFacade.create(context.getGroupCode(),context.getProjectId(), AdmCommonConstant.APP_ID,null,objRelationDTONews);
+            if(CollUtil.isNotEmpty(relationList)){
+                DmpResult<JSONArray> propertyRes = rwdClient.updateObject(context, JSONArray.parseArray(propertyList.toString()));
+                if(propertyRes.getResult().equals(DmpResult.SUCCESS)){
+                    isDealDataSucc = true;
+                }
+            }
+        }
+        return isDealDataSucc;
+    }
 }

+ 39 - 0
src/main/java/com/persagy/proxy/adm/utils/ObjectNameUtil.java

@@ -0,0 +1,39 @@
+package com.persagy.proxy.adm.utils;
+
+import cn.hutool.core.util.RandomUtil;
+
+/**
+ * 根据中心数据规则生成对象名字
+ * 参见 datacenterShaftNameUtil
+ * @author lvxy
+ * @date 2021/8/31
+ */
+public class ObjectNameUtil {
+
+    /**
+     * 竖井名字
+     *
+     * @param   name    名字
+     */
+    public static String objectName(String name){
+        return name + getCode(5);
+    } // Function shaftName()
+
+    /**
+     * 字母和数字组合的随机数
+     *
+     * @param   n   随机数的位数
+     */
+    private static String getCode(int n) {
+        String str = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";//保存数字0-9 和 大小写字母
+        char[] ch = new char[n]; //声明一个字符数组对象ch 保存 验证码
+        for (int i=0 ; i< n; i++) {
+            //创建一个新的随机数生成器
+            int index = RandomUtil.getRandom().nextInt(str.length());//返回[0,string.length)范围的int值    作用:保存下标
+            ch[i] = str.charAt(index);//charAt() : 返回指定索引处的 char 值   ==》保存到字符数组对象ch里面
+        }
+        //将char数组类型转换为String类型保存到result
+        return  String.valueOf(ch);
+    }
+
+}

+ 8 - 0
src/main/java/com/persagy/proxy/common/client/DmpRwdClient.java

@@ -40,6 +40,14 @@ public interface DmpRwdClient {
      */
     @PostMapping(DmpUrlConstant.OBJECT_QUERY)
     DmpResult<JSONArray> queryObject(@SpringQueryMap InstanceUrlParam objectUrlParam, @RequestBody JSONObject criteria);
+    /**
+     * @description: 查询定义类型
+     * @param: objectUrlParam 对象请求url通用参数
+     * @param: criteria post请求参数
+     * @return: com.persagy.dmp.common.DmpResult
+     */
+    @PostMapping(DmpUrlConstant.DEF_CLASS)
+    DmpResult<JSONArray> queryDefClass(@SpringQueryMap InstanceUrlParam objectUrlParam, @RequestBody JSONObject criteria);
 
     /**
      * @description: 创建对象