AdmRelCalController.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. package com.persagy.proxy.adm.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.persagy.dmp.common.exception.BusinessException;
  5. import com.persagy.proxy.adm.constant.AdmCommonConstant;
  6. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  7. import com.persagy.proxy.adm.constant.BusinessErrorRwdCode;
  8. import com.persagy.proxy.adm.request.AdmResponse;
  9. import com.persagy.proxy.adm.service.AdmRelCalService;
  10. import com.persagy.proxy.common.entity.InstanceUrlParam;
  11. import lombok.RequiredArgsConstructor;
  12. import org.springframework.beans.factory.annotation.Value;
  13. import org.springframework.web.bind.annotation.*;
  14. import javax.servlet.http.HttpServletRequest;
  15. import javax.ws.rs.QueryParam;
  16. import java.util.ArrayList;
  17. import java.util.Map;
  18. /***
  19. * Description:关系计算输入类
  20. * @author : lijie
  21. * @date :2021/8/31 11:37
  22. * Update By lijie 2021/8/31 11:37
  23. */
  24. @RestController
  25. @RequestMapping("/relation-calc/")
  26. @RequiredArgsConstructor
  27. public class AdmRelCalController {
  28. private final AdmRelCalService admRelCalService;
  29. @Value("${middleware.group.code}")
  30. private String groupCode;
  31. /***
  32. * Description: 添加关系(图类型关系为ArchSubset)
  33. * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
  34. * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
  35. * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
  36. * bd2sp: 建筑下的空间
  37. * fl2sp: 楼层下的空间
  38. * sh2bd: 建筑下的竖井,实际关系应该是bd2sh
  39. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  40. * @author : lijie
  41. * @date :2021/8/31 12:10
  42. * Update By lijie 2021/8/31 12:10
  43. */
  44. @PostMapping(value = {"bd2sp","fl2sp","sh2bd"})
  45. public AdmResponse archSubsetCalcRelation(@RequestParam("projectId") String projectId,
  46. @RequestParam("groupCode") String groupCode,
  47. @RequestParam("appId") String appId,
  48. @RequestParam("userId") String userId,
  49. @RequestParam("objectTypes") String objectTypeStr,
  50. @RequestParam("relationType") String relationTypeStr,
  51. HttpServletRequest request) throws Exception {
  52. // 组装上下文条件
  53. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  54. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  55. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  56. admRelCalService.calcRelation(context,CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
  57. return AdmResponse.success(new ArrayList<>());
  58. }
  59. /***
  60. * Description: 添加关系(图类型关系为MechInArch)
  61. * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
  62. * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
  63. * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
  64. * eq2bd:设备所在建筑
  65. * eq2fl:设备所在楼层
  66. * eq2sh:设备所在竖井
  67. * eq2sp_in:设备所在业务空间
  68. * sy2bd: 系统所在建筑
  69. * sy2fl: 系统所在楼层
  70. * sy2sh: 系统所在竖井
  71. * sy2sp: 系统所在业务空间
  72. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  73. * @author : lijie
  74. * @date :2021/8/31 12:10
  75. * Update By lijie 2021/8/31 12:10
  76. */
  77. @PostMapping(value = {"eq2bd","eq2fl","eq2sh","eq2sp_in","sy2bd","sy2fl","sy2sh","sy2sp"})
  78. public AdmResponse mechInArchCalcRelation(@RequestParam("projectId") String projectId,
  79. @RequestParam("groupCode") String groupCode,
  80. @RequestParam("appId") String appId,
  81. @RequestParam("userId") String userId,
  82. @RequestParam("objectTypes") String objectTypeStr,
  83. @RequestParam("relationType") String relationTypeStr,
  84. HttpServletRequest request) throws Exception {
  85. // 组装上下文条件
  86. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  87. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  88. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  89. admRelCalService.calcRelation(context, CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
  90. return AdmResponse.success(new ArrayList<>());
  91. }
  92. /***
  93. * Description: 添加关系(图类型关系为PropertyInArch)
  94. * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
  95. * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
  96. * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
  97. * pe2bd:资产所在建筑
  98. * pe2fl:资产所在楼层
  99. * pe2sh:资产所在竖井
  100. * pe2sp:资产所在业务空间
  101. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  102. * @author : lijie
  103. * @date :2021/8/31 12:10
  104. * Update By lijie 2021/8/31 12:10
  105. */
  106. @PostMapping(value = {"pe2bd","pe2fl","pe2sh","pe2sp"})
  107. public AdmResponse propertyInArchCalcRelation(@RequestParam("projectId") String projectId,
  108. @RequestParam("groupCode") String groupCode,
  109. @RequestParam("appId") String appId,
  110. @RequestParam("userId") String userId,
  111. @RequestParam("objectTypes") String objectTypeStr,
  112. @RequestParam("relationType") String relationTypeStr) throws Exception {
  113. // 资产暂时未引入,直接返回成功
  114. // 组装上下文条件
  115. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  116. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  117. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  118. // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
  119. return AdmResponse.success(new ArrayList<>());
  120. }
  121. /***
  122. * Description: 添加关系(图类型关系为MechForArch)
  123. * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
  124. * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
  125. * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
  126. * eq2sp_for:设备服务空间关系
  127. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  128. * @author : lijie
  129. * @date :2021/8/31 12:10
  130. * Update By lijie 2021/8/31 12:10
  131. */
  132. @PostMapping(value = {"eq2sp_for"})
  133. public AdmResponse mechForArchCalcRelation(@RequestParam("projectId") String projectId,
  134. @RequestParam("groupCode") String groupCode,
  135. @RequestParam("appId") String appId,
  136. @RequestParam("userId") String userId,
  137. @RequestParam("objectTypes") String objectTypeStr,
  138. @RequestParam("relationType") String relationTypeStr) throws Exception {
  139. // 资产暂时未引入,直接返回成功
  140. // 组装上下文条件
  141. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  142. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  143. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  144. // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
  145. return AdmResponse.success(new ArrayList<>());
  146. }
  147. /***
  148. * Description: 添加关系(图类型关系为ArchForArch)
  149. * @param buildingId : 建筑id
  150. * @param objectType : 对象分类
  151. * @param type : 对象类型
  152. * @param projectId : 项目id
  153. * @param groupCode : 集团编码
  154. * @param appId : APP的id
  155. * @param userId : 账号id
  156. * sp2sp:空间服务于空间
  157. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  158. * @author : lijie
  159. * @date :2021/8/31 12:10
  160. * Update By lijie 2021/8/31 12:10
  161. */
  162. @PostMapping(value = {"sp2sp"})
  163. public AdmResponse archForArchCalcRelation( @RequestParam("buildingId") String buildingId,
  164. @RequestParam("objectType") String objectType,
  165. @RequestParam("type") String type,
  166. @RequestParam("projectId") String projectId,
  167. @RequestParam("groupCode") String groupCode,
  168. @RequestParam("appId") String appId,
  169. @RequestParam("userId") String userId) throws Exception {
  170. // 资产暂时未引入,直接返回成功
  171. // 组装上下文条件
  172. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  173. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  174. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  175. admRelCalService.calcRelationForArchForArchSpToSp(context,buildingId,objectType,type,AdmRelationTypeEnum.SP2SP_ARCHFORARCH);
  176. return AdmResponse.success(new ArrayList<>());
  177. }
  178. /***
  179. * Description: 添加关系(图类型关系为SensorRelationship)
  180. * eq2sp_SensorRelationship_ss2sp:传感器测量空间关系
  181. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  182. * @author : lijie
  183. * @date :2021/8/31 12:10
  184. * Update By lijie 2021/8/31 12:10
  185. */
  186. @PostMapping(value = {"eq2sp_SensorRelationship_ss2sp"})
  187. public AdmResponse sensorRelationshipCalcRelation(@RequestParam("projectId") String projectId,
  188. @RequestParam("groupCode") String groupCode,
  189. @RequestParam("appId") String appId,
  190. @RequestParam("userId") String userId) throws Exception {
  191. // 资产暂时未引入,直接返回成功
  192. // 组装上下文条件
  193. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  194. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  195. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  196. admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.EQ2SP_SENSORRELATIONSHIP_SS2SP),"AirConditioningZone");
  197. return AdmResponse.success(new ArrayList<>());
  198. }
  199. /***
  200. * Description: 添加关系(图类型关系为ConvectionNetwork)
  201. * sp2sp_ConvectionNetwork_1:Natural-空气自然对流
  202. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  203. * @author : lijie
  204. * @date :2021/8/31 12:10
  205. * Update By lijie 2021/8/31 12:10
  206. */
  207. @PostMapping(value = {"sp2sp_ConvectionNetwork_1"})
  208. public AdmResponse convectionNetworkCalcRelation(@RequestParam("projectId") String projectId,
  209. @RequestParam("groupCode") String groupCode,
  210. @RequestParam("appId") String appId,
  211. @RequestParam("userId") String userId) throws Exception {
  212. // 资产暂时未引入,直接返回成功
  213. // 组装上下文条件
  214. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  215. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  216. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  217. admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_CONVECTIONNETWORK_1),null);
  218. return AdmResponse.success(new ArrayList<>());
  219. }
  220. /***
  221. * Description: 添加关系(图类型关系为RadiationNetwork)
  222. * sp2sp_RadiationNetwork_1:光照辐射网络-Connect-光照连通
  223. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  224. * @author : lijie
  225. * @date :2021/8/31 12:10
  226. * Update By lijie 2021/8/31 12:10
  227. */
  228. @PostMapping(value = {"sp2sp_RadiationNetwork_1"})
  229. public AdmResponse radiationNetworkCalcRelation(@RequestParam("projectId") String projectId,
  230. @RequestParam("groupCode") String groupCode,
  231. @RequestParam("appId") String appId,
  232. @RequestParam("userId") String userId) throws Exception {
  233. // 资产暂时未引入,直接返回成功
  234. // 组装上下文条件
  235. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  236. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  237. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  238. admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_RADIATIONNETWORK_1),null);
  239. return AdmResponse.success(new ArrayList<>());
  240. }
  241. /***
  242. * Description: 添加关系(图类型关系为SpaceNeighborhood)
  243. * sp2sp_SpaceNeighborhood_5:业务空间(同类)邻接关系-Connect-空间连通
  244. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  245. * @author : lijie
  246. * @date :2021/8/31 12:10
  247. * Update By lijie 2021/8/31 12:10
  248. */
  249. @PostMapping(value = {"sp2sp_SpaceNeighborhood_5"})
  250. public AdmResponse spaceNeighborhoodCalcRelation(@RequestParam("projectId") String projectId,
  251. @RequestParam("groupCode") String groupCode,
  252. @RequestParam("appId") String appId,
  253. @RequestParam("userId") String userId) throws Exception {
  254. // 资产暂时未引入,直接返回成功
  255. // 组装上下文条件
  256. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  257. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  258. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  259. admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_SPACENEIGHBORHOOD_5),null);
  260. return AdmResponse.success(new ArrayList<>());
  261. }
  262. /***
  263. * Description: 添加关系(计算设备所在建筑,系统所在建筑,图类型关系为MechInArch)
  264. * syeq2bd:建筑下的系统设备部件,计算设备所在建筑(eq2bd),系统所在建筑(sy2bd)
  265. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  266. * @author : lijie
  267. * @date :2021/8/31 12:10
  268. * Update By lijie 2021/8/31 12:10
  269. */
  270. @PostMapping(value = {"syeq2bd"})
  271. public AdmResponse syeq2bdCalcRelation(@RequestParam("projectId") String projectId,
  272. @RequestParam("groupCode") String groupCode,
  273. @RequestParam("appId") String appId,
  274. @RequestParam("userId") String userId) throws Exception {
  275. // 资产暂时未引入,直接返回成功
  276. // 组装上下文条件
  277. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  278. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  279. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  280. Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
  281. if (!relationTypeMap.containsKey("eq2bd") || !relationTypeMap.containsKey("sy2bd")){
  282. throw new BusinessException(BusinessErrorRwdCode.A7201.getCode(),BusinessErrorRwdCode.A7201.getDesc());
  283. }
  284. ArrayList<AdmRelationTypeEnum> admRelationTypeEnums =
  285. CollUtil.newArrayList(relationTypeMap.get("eq2bd"), relationTypeMap.get("sy2bd"));
  286. admRelCalService.calcRelation(context,admRelationTypeEnums,null);
  287. return AdmResponse.success(new ArrayList<>());
  288. }
  289. /***
  290. * Description: 添加关系(图类型关系为TrafficNetwork)
  291. * sp2sp_TrafficNetwork_1:建筑交通网络(同类)-Normal-普通交通
  292. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  293. * @author : lijie
  294. * @date :2021/8/31 12:10
  295. * Update By lijie 2021/8/31 12:10
  296. */
  297. @PostMapping(value = {"sp2sp_TrafficNetwork_1"})
  298. public AdmResponse trafficNetworkCalcRelation(@RequestParam("projectId") String projectId,
  299. @RequestParam("groupCode") String groupCode,
  300. @RequestParam("appId") String appId,
  301. @RequestParam("userId") String userId) throws Exception {
  302. // 资产暂时未引入,直接返回成功
  303. // 组装上下文条件
  304. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  305. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  306. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  307. admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_TRAFFICNETWORK_1),null);
  308. return AdmResponse.success(new ArrayList<>());
  309. }
  310. /***
  311. * Description: 添加关系(图类型关系为ThroughRelationship)
  312. * fl2fl:楼层贯通关系
  313. * sh2sh:竖井贯通关系
  314. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  315. * @author : lijie
  316. * @date :2021/8/31 12:10
  317. * Update By lijie 2021/8/31 12:10
  318. */
  319. @PostMapping(value = {"fl2fl","sh2sh"})
  320. public AdmResponse throughRelationshipCalcRelation(@RequestParam("projectId") String projectId,
  321. @RequestParam("groupCode") String groupCode,
  322. @RequestParam("appId") String appId,
  323. @RequestParam("userId") String userId,
  324. HttpServletRequest request) throws Exception {
  325. // 资产暂时未引入,直接返回成功
  326. // 组装上下文条件
  327. InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
  328. null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
  329. StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
  330. admRelCalService.calcRelation(context,CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
  331. return AdmResponse.success(new ArrayList<>());
  332. }
  333. /***
  334. * Description: 更改计算标记
  335. * @param relType : 关系类型
  336. * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
  337. * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
  338. * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
  339. * sign: 更改计算标记
  340. * @return : com.persagy.proxy.adm.request.AdmCreateResponse
  341. * @author : lijie
  342. * @date :2021/8/31 12:10
  343. * Update By lijie 2021/8/31 12:10
  344. */
  345. @PostMapping(value = {"sign"})
  346. public AdmResponse changeSign( @PathVariable("relType") String relType,
  347. @QueryParam("projectId") String projectId,
  348. @QueryParam("objectTypes") String objectTypeStr,
  349. @QueryParam("relationType") String relationTypeStr) throws Exception {
  350. // 资产暂时未引入,直接返回成功
  351. // 组装上下文条件
  352. InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
  353. // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
  354. return AdmResponse.success(new ArrayList<>());
  355. }
  356. /***
  357. * Description: 获得关系枚举类型
  358. * @param request : 请求体
  359. * @return : com.persagy.proxy.adm.constant.AdmRelationTypeEnum
  360. * @author : lijie
  361. * @date :2021/9/11 22:33
  362. * Update By lijie 2021/9/11 22:33
  363. */
  364. private AdmRelationTypeEnum getAdmRelationTypeEnum(HttpServletRequest request) {
  365. String suffix = getSuffixRequestUrl(request);
  366. Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
  367. if (!relationTypeMap.containsKey(suffix)){
  368. throw new BusinessException(BusinessErrorRwdCode.A7201.getCode(),BusinessErrorRwdCode.A7201.getDesc());
  369. }
  370. return relationTypeMap.get(suffix);
  371. }
  372. /***
  373. * Description: 获得最后一个/后请求地址
  374. * @param request : 请求对象
  375. * @return : void
  376. * @author : lijie
  377. * @date :2021/9/11 22:09
  378. * Update By lijie 2021/9/11 22:09
  379. */
  380. private String getSuffixRequestUrl(HttpServletRequest request) {
  381. String requestURI = request.getRequestURI();
  382. return requestURI.substring(requestURI.lastIndexOf("/")+1);
  383. }
  384. }