AbstractAdmManualRelationCalcServiceImpl.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. package com.persagy.proxy.adm.service.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.persagy.dmp.common.context.AppContext;
  5. import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
  6. import com.persagy.proxy.adm.model.AdmRelationAddRequest;
  7. import com.persagy.proxy.adm.request.AdmCreateResponse;
  8. import com.persagy.proxy.adm.service.AdmManualRelationCalcService;
  9. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.springframework.stereotype.Service;
  12. import java.util.Map;
  13. /***
  14. * Description: 手动计算逻辑处理类
  15. * @author : lijie
  16. * @date :2021/8/31 11:51
  17. * Update By lijie 2021/8/31 11:51
  18. */
  19. @Service
  20. @Slf4j
  21. public class AbstractAdmManualRelationCalcServiceImpl implements AdmManualRelationCalcService {
  22. /***
  23. * Description: 添加关系
  24. * @param request : 请求参数
  25. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  26. * @author : lijie
  27. * @date :2021/8/31 12:14
  28. * Update By lijie 2021/8/31 12:14
  29. */
  30. @Override
  31. public AdmCreateResponse addRels(AdmRelationAddRequest request) {
  32. // 获取项目id
  33. String projectId = AppContext.getContext().getProjectId();
  34. if (StrUtil.isBlank(request.getRelType())){
  35. return AdmCreateResponse.failure("关系类型不能为空");
  36. }
  37. if (StrUtil.isBlank(request.getType())){
  38. return AdmCreateResponse.failure("识别不能为空");
  39. }
  40. if (StrUtil.isBlank(request.getMainContent())){
  41. return AdmCreateResponse.failure("主对象不能为空","1");
  42. }
  43. if (CollUtil.isEmpty(request.getFromContent())){
  44. return AdmCreateResponse.failure("从对象不能为空","2");
  45. }
  46. // 2.1 pe2sp,pe2sh,eq2sh_for,eq2fl_for,eq2bd_for,sy2sp_for,sy2sh_for,sy2fl_for,sy2bd_for
  47. // sp2sp_ConvectionNetwork_1,sp2sp_ConvectionNetwork_2,sp2sp_ConvectionNetwork_3,sp2sp_SpaceNeighborhood_5
  48. // sp2sp_SpaceNeighborhood_2,sp2sp_SpaceNeighborhood_4,sp2sp_TrafficNetwork_3,sp2sp_TrafficNetwork_2,
  49. // sp2sp_RadiationNetwork_1,sp2sp_RadiationNetwork_2,sp2sp_SpaceNeighborhood_1,sp2sp_TrafficNetwork_1,
  50. // sp2sp_SpaceNeighborhood_3,eq2sy_ControlRelation_2,eq2sy_ValveRelationship_vv2sy,
  51. // eq2sy_SensorRelationship_ss2sy,eq2sp_SensorRelationship_ss2sp,eq2sp_x,bd2bd_ArchForArch,bd2fl_ArchForArch,
  52. // bd2sh_ArchForArch,bd2sp_ArchForArch,fl2bd_ArchForArch,fl2fl_ArchForArch,fl2sh_ArchForArch,fl2sp_ArchForArch,
  53. // sh2bd_ArchForArch,sh2fl_ArchForArch,sh2sh_ArchForArch,sh2sp_ArchForArch,sp2bd_ArchForArch,sp2fl_ArchForArch,
  54. // sp2sh_ArchForArch,sp2sp_ArchForArch
  55. // 校验关系类型是否存在
  56. Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
  57. if (relationTypeMap.containsKey(request.getRelType())){
  58. return AdmCreateResponse.failure("不存在的关系类型");
  59. }
  60. AdmRelationTypeEnum relationTypeEnum = relationTypeMap.get(request.getRelType());
  61. // type为cadId直接提示从对象不存在CADID编码并且errorType=2
  62. if (AdmObjectInfoConstant.CADID.equals(request.getType()) && relationTypeEnum.getHasCheckCadId()){
  63. return AdmCreateResponse.failure("从对象不存在CADID编码","2");
  64. }
  65. // 1.根据项目id和关系类型更新计算时间为当前时间
  66. // 2.根据不同关系类型进行处理
  67. // 2.2 特殊类型的判断
  68. // *******
  69. // sp2sp_RadiationNetwork_2,sp2sp_RadiationNetwork_1 && classCode!=LightingZone errorType=1,不是照明分区类型
  70. // sp2sp_ConvectionNetwork_2,sp2sp_ConvectionNetwork_3,sp2sp_ConvectionNetwork_1 && classCode!=AirConditioningZone errorType=1,不是空调分区类型
  71. // sp2sp_TrafficNetwork_3,sp2sp_TrafficNetwork_2,sp2sp_TrafficNetwork_1 && classCode!=GeneralZone errorType=1,不是物业分区类型
  72. // relType为上面几种的规定从对象不能重复,主对象和从对象不能重复
  73. // *******
  74. // eq2eq_EquipPower_1,eq2eq_EquipPower_2,eq2eq_EquipPower_3,eq2eq_EquipPower_4
  75. // 主对象的class_code必须等于SETDLS,SETDHS,其他的报不符合主对象条件限制错误
  76. // *******
  77. // 2.3 根据对象信息点和对象内容(主/副)查询对象,然后添加关系及计算标记
  78. // 1.obj_type,project_id,type(设备名称(name),设备ID(id),本地编码(localId),本地名称(localName))查询主对象
  79. // 2.obj_type,project_id,type(设备名称(name),设备ID(id),本地编码(localId),本地名称(localName)),是否排除主对象id,是否主对象的class_code查询从对象
  80. // 3.不存在/多实例,errorType为1,2(1-主实例,2-从实例),结束
  81. // 4.插入关系from_id,to_id,图类型编码,边类型编码,项目id,如果rel_value有值则加上,结束
  82. // 5.处理sign:计算标记 1 为手动 2为自动
  83. // pe2sp:from_id为资产id,to_id为空间id,主对象obj_type为property,从对象obj_type为space,图类型为PropertyInArch,边类型为Pe2Sp,rel_value为查询的空间对应的class_code
  84. // pe2sh:from_id为资产id,to_id为竖井id,主对象obj_type为property,从对象obj_type为shaft,图类型为PropertyInArch,边类型为Pe2Sh
  85. // eq2sh_for:from_id为设备id,to_id为竖井id,主对象obj_type为equipment,从对象obj_type为shaft,图类型为MechForArch,边类型为Eq2Sh
  86. // eq2fl_for:from_id为设备id,to_id为楼层id,主对象obj_type为equipment,从对象obj_type为floor,图类型为MechForArch,边类型为Eq2Fl
  87. // eq2bd_for:from_id为设备id,to_id为建筑id,主对象obj_type为equipment,从对象obj_type为building,图类型为MechForArch,边类型为Eq2Bd
  88. // sy2sp_for:from_id为系统id,to_id为空间id,主对象obj_type为system,从对象obj_type为space,图类型为MechForArch,边类型为Sy2Sp
  89. // sy2sh_for:from_id为系统id,to_id为竖井id,主对象obj_type为system,从对象obj_type为shaft,图类型为MechForArch,边类型为Sy2Sh
  90. // sy2fl_for:from_id为系统id,to_id为楼层id,主对象obj_type为system,从对象obj_type为floor,图类型为MechForArch,边类型为Sy2Fl
  91. // sy2bd_for:from_id为系统id,to_id为建筑id,主对象obj_type为system,从对象obj_type为building,图类型为MechForArch,边类型为Sy2Bd
  92. // sy2bd_for:from_id为系统id,to_id为建筑id,主对象obj_type为system,从对象obj_type为floor,图类型为MechForArch,边类型为Sy2Bd
  93. // *******
  94. // 从对象查询排除主对象id,主对象的class_code查询从对象
  95. // sp2sp_ConvectionNetwork_1,sp2sp_ConvectionNetwork_2,sp2sp_ConvectionNetwork_3,sp2sp_SpaceNeighborhood_5
  96. // sp2sp_SpaceNeighborhood_2,sp2sp_SpaceNeighborhood_4,sp2sp_TrafficNetwork_3,sp2sp_TrafficNetwork_2,
  97. // sp2sp_RadiationNetwork_1,sp2sp_RadiationNetwork_2,sp2sp_SpaceNeighborhood_1,sp2sp_TrafficNetwork_1,
  98. // sp2sp_SpaceNeighborhood_3
  99. // from_id为空间id,to_id为空间id,主对象obj_type为space,从对象obj_type为space,rel_value为查询的主对象空间对应的class_code
  100. // sp2sp_ConvectionNetwork_1:图类型为ConvectionNetwork,边类型为Natural
  101. // sp2sp_ConvectionNetwork_2:图类型为ConvectionNetwork,边类型为MixMech
  102. // sp2sp_ConvectionNetwork_3:图类型为ConvectionNetwork,边类型为OnewayMech
  103. // sp2sp_SpaceNeighborhood_1:图类型为SpaceNeighborhood,边类型为None
  104. // sp2sp_SpaceNeighborhood_2:图类型为SpaceNeighborhood,边类型为Door
  105. // sp2sp_SpaceNeighborhood_3:图类型为SpaceNeighborhood,边类型为Window
  106. // sp2sp_SpaceNeighborhood_4:图类型为SpaceNeighborhood,边类型为DoorWindow
  107. // sp2sp_SpaceNeighborhood_5:图类型为SpaceNeighborhood,边类型为Connect
  108. // sp2sp_TrafficNetwork_1:图类型为TrafficNetwork,边类型为Normal
  109. // sp2sp_TrafficNetwork_2:图类型为TrafficNetwork,边类型为FFOpen
  110. // sp2sp_TrafficNetwork_3:图类型为TrafficNetwork,边类型为FFClose
  111. // sp2sp_RadiationNetwork_1:图类型为RadiationNetwork,边类型为Connect
  112. // sp2sp_RadiationNetwork_2:图类型为RadiationNetwork,边类型为Transparent
  113. // *******
  114. // 从对象查询排除主对象id
  115. // eq2eq_LUDistribution_1,eq2eq_LUDistribution_2,eq2eq_HUDistribution_1,eq2eq_HUDistribution_2,
  116. // eq2eq_EquipPower_1,eq2eq_EquipPower_2,eq2eq_EquipPower_3,eq2eq_EquipPower_4
  117. // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
  118. // eq2eq_LUDistribution_1:图类型为LUDistribution,边类型为Normal
  119. // eq2eq_LUDistribution_2:图类型为LUDistribution,边类型为Backup
  120. // eq2eq_HUDistribution_1:图类型为LUDistribution,边类型为Normal
  121. // eq2eq_HUDistribution_2:图类型为LUDistribution,边类型为Backup
  122. // eq2eq_EquipPower_1:图类型为EquipPower,边类型为EqNormal
  123. // eq2eq_EquipPower_2:图类型为EquipPower,边类型为EqBackup
  124. // eq2eq_EquipPower_3:图类型为EquipPower,边类型为SyNormal
  125. // eq2eq_EquipPower_4:图类型为EquipPower,边类型为SyBackup
  126. // ******
  127. // 从对象查询排除主对象id
  128. // eq2eq_ACAirNetwork_1,eq2eq_ACAirNetwork_2,eq2eq_ACAirNetwork_3
  129. // eq2eq_ChillWaterLoop_1,eq2eq_ChillWaterLoop_2,eq2eq_ChillWaterLoop_3,eq2eq_ChillWaterLoop_4
  130. // eq2eq_CoolingWaterLoop_1,eq2eq_CoolingWaterLoop_2,eq2eq_CoolingWaterLoop_3,eq2eq_CoolingWaterLoop_4
  131. // eq2eq_CondWaterNetwork_1
  132. // eq2eqFreshAirNetwork_1
  133. // eq2eq_HeatWaterLoop_1,eq2eq_HeatWaterLoop_2,eq2eq_HeatWaterLoop_3,eq2eq_HeatWaterLoop_4
  134. // eq2eq_VentNetwork_1,eq2eq_VentNetwork_2,eq2eq_VentNetwork_3
  135. // eq2eq_VRFNetwork_1
  136. // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
  137. // eq2eq_ACAirNetwork_1:图类型为ACAirNetwork,边类型为Supply
  138. // eq2eq_ACAirNetwork_2:图类型为ACAirNetwork,边类型为Return
  139. // eq2eq_ACAirNetwork_3:图类型为ACAirNetwork,边类型为Discharge
  140. // eq2eq_ChillWaterLoop_1:图类型为ChillWaterLoop,边类型为Supply
  141. // eq2eq_ChillWaterLoop_2:图类型为ChillWaterLoop,边类型为Return
  142. // eq2eq_ChillWaterLoop_3:图类型为ChillWaterLoop,边类型为Bypass
  143. // eq2eq_ChillWaterLoop_4:图类型为ChillWaterLoop,边类型为Fill
  144. // eq2eq_CoolingWaterLoop_1:图类型为CoolingWaterLoop,边类型为Supply
  145. // eq2eq_CoolingWaterLoop_2:图类型为CoolingWaterLoop,边类型为Return
  146. // eq2eq_CoolingWaterLoop_3:图类型为CoolingWaterLoop,边类型为Bypass
  147. // eq2eq_CoolingWaterLoop_4:图类型为CoolingWaterLoop,边类型为Fill
  148. // eq2eq_CondWaterNetwork_1:图类型为CondWaterNetwork,边类型为Discharge
  149. // eq2eqFreshAirNetwork_1:图类型为FreshAirNetwork,边类型为Fresh
  150. // eq2eq_HeatWaterLoop_1:图类型为HeatWaterLoop,边类型为Supply
  151. // eq2eq_HeatWaterLoop_2:图类型为HeatWaterLoop,边类型为Return
  152. // eq2eq_HeatWaterLoop_3:图类型为HeatWaterLoop,边类型为Bypass
  153. // eq2eq_HeatWaterLoop_4:图类型为HeatWaterLoop,边类型为Fill
  154. // eq2eq_VentNetwork_1:图类型为VentNetwork,边类型为Supply
  155. // eq2eq_VentNetwork_2:图类型为VentNetwork,边类型为Discharge
  156. // eq2eq_VentNetwork_3:图类型为VentNetwork,边类型为Uncertain
  157. // eq2eq_VRFNetwork_1:图类型为VRFNetwork,边类型为SupplyReturn
  158. // ******
  159. // 从对象查询排除主对象id
  160. // eq2eq_SupplyWaterNetwork_1,eq2eq_SupplyWaterNetwork_2
  161. // eq2eq_DrainingWaterNetwork_1,eq2eq_DrainingWaterNetwork_2
  162. // eq2eq_DrinkingWaterNetwork_1,eq2eq_DrinkingWaterNetwork_2
  163. // eq2eq_DHWNetwork_1,eq2eq_DHWNetwork_2
  164. // eq2eq_GasNetwork_1,eq2eq_GasNetwork_2
  165. // eq2eq_FireWaterNetwork_1,eq2eq_FireWaterNetwork_2
  166. // eq2eq_FireVentNetwork_1
  167. // eq2eq_RecycleWaterNetwork_1,eq2eq_RecycleWaterNetwork_2
  168. // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
  169. // eq2eq_SupplyWaterNetwork_1:图类型为SupplyWaterNetwork,边类型为Supply
  170. // eq2eq_SupplyWaterNetwork_2:图类型为SupplyWaterNetwork,边类型为Bypass
  171. // eq2eq_DrainingWaterNetwork_1:图类型为DrainingWaterNetwork,边类型为Discharge
  172. // eq2eq_DrainingWaterNetwork_2:图类型为DrainingWaterNetwork,边类型为Bypass
  173. // eq2eq_DrinkingWaterNetwork_1:图类型为DrinkingWaterNetwork,边类型为Supply
  174. // eq2eq_DrinkingWaterNetwork_2:图类型为DrinkingWaterNetwork,边类型为Bypass
  175. // eq2eq_DHWNetwork_1:图类型为DHWNetwork,边类型为Supply
  176. // eq2eq_DHWNetwork_2:图类型为DHWNetwork,边类型为Bypass
  177. // eq2eq_GasNetwork_1:图类型为GasNetwork,边类型为Supply
  178. // eq2eq_GasNetwork_2:图类型为GasNetwork,边类型为Bypass
  179. // eq2eq_FireWaterNetwork_1:图类型为FireWaterNetwork,边类型为Supply
  180. // eq2eq_FireWaterNetwork_2:图类型为FireWaterNetwork,边类型为Bypass
  181. // eq2eq_FireVentNetwork_1:图类型为FireVentNetwork,边类型为Discharge
  182. // eq2eq_RecycleWaterNetwork_1:图类型为RecycleWaterNetwork,边类型为Supply
  183. // eq2eq_RecycleWaterNetwork_2:图类型为RecycleWaterNetwork,边类型为Bypass
  184. // ******
  185. // eq2eq_SensorNetwork_1,eq2eq_ControlRelation_1,eq2eq_ValveRelationship_vv2eq,eq2eq_ControlEquipNetwork
  186. // 从对象查询排除主对象id
  187. // from_id为设备id,to_id为设备id,主对象obj_type为equipment,从对象obj_type为equipment,
  188. // eq2eq_SensorNetwork_1:图类型为SensorNetwork,边类型为Normal
  189. // eq2eq_ControlRelation_1:图类型为ControlRelation,边类型为MechCtrl
  190. // eq2eq_ValveRelationship_vv2eq:图类型为ValveRelationship,边类型为Vv2Eq
  191. // eq2eq_ControlEquipNetwork:图类型为ControlEquipNetwork,边类型为Normal
  192. // ******
  193. // eq2eq_SensorRelationship_ss2eq
  194. // 从对象查询排除主对象id
  195. // 传感器类型检查
  196. // eq2eq_SensorRelationship_ss2eq:图类型为SensorRelationship,边类型为Ss2Eq
  197. // *****
  198. // eq2sy_ControlRelation_2,eq2sy_ValveRelationship_vv2sy
  199. // eq2sy_ControlRelation_2:图类型为ControlRelation,边类型为SyCtrl
  200. // eq2sy_ValveRelationship_vv2sy:图类型为ValveRelationship,边类型为Vv2Sy
  201. // *****
  202. // eq2sy_SensorRelationship_ss2sy
  203. // 传感器类型检查
  204. // eq2sy_SensorRelationship_ss2sy:图类型为SensorRelationship,边类型为Ss2Sy
  205. // *****
  206. // eq2sp_SensorRelationship_ss2sp
  207. // 传感器类型检查
  208. // eq2sp_SensorRelationship_ss2sp:图类型为SensorRelationship,边类型为Ss2Sp
  209. // *****
  210. // eq2sp_x
  211. // bd2bd_ArchForArch,bd2fl_ArchForArch,bd2sh_ArchForArch,bd2sp_ArchForArch,fl2bd_ArchForArch,fl2fl_ArchForArch
  212. // fl2sh_ArchForArch,fl2sp_ArchForArch,sh2bd_ArchForArch,sh2fl_ArchForArch,sh2sh_ArchForArch,sh2sp_ArchForArch
  213. // sp2bd_ArchForArch,sp2fl_ArchForArch,sp2sh_ArchForArch,sp2sp_ArchForArch
  214. return null;
  215. }
  216. }