AdmSpaceInfoController.java 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. package com.persagy.proxy.report.controller;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.persagy.dmp.common.constant.ResponseCode;
  5. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  6. import com.persagy.proxy.adm.request.AdmDCSQueryRequest;
  7. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  8. import com.persagy.proxy.adm.request.AdmResponse;
  9. import com.persagy.proxy.adm.utils.AdmContextUtil;
  10. import com.persagy.proxy.object.model.AdmEquipment;
  11. import com.persagy.proxy.object.model.AdmISpace;
  12. import com.persagy.proxy.object.model.AdmSystem;
  13. import com.persagy.proxy.object.service.*;
  14. import lombok.RequiredArgsConstructor;
  15. import org.springframework.web.bind.annotation.PostMapping;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import javax.servlet.http.HttpServletRequest;
  20. import javax.ws.rs.QueryParam;
  21. import java.util.Set;
  22. /**
  23. *
  24. * @version 1.0.0
  25. * @company persagy
  26. * @author zhangqiankun
  27. * @date 2021年10月18日 上午10:55:24
  28. */
  29. @RestController
  30. @RequiredArgsConstructor
  31. @RequestMapping("/space")
  32. public class AdmSpaceInfoController {
  33. private final IAdmISpaceService ispaceService;
  34. private final IAdmFloorService floorService;
  35. private final IAdmSystemService systemService;
  36. private final IAdmEquipmentService equipmentService;
  37. private final IAdmSpaceService spaceService;
  38. /**
  39. * 统计 属于多建筑楼层的空间
  40. *
  41. * @param request
  42. * @return
  43. */
  44. @RequestMapping("/space-bd-fl")
  45. public JSONObject queryCount(HttpServletRequest request) {
  46. Set<String> spaceIds = spaceService.queryMultiBuildingOrFloorSpaceIds(request);
  47. JSONObject result = new JSONObject();
  48. result.put("count", spaceIds.size());
  49. result.put("message", "");
  50. result.put("result", "success");
  51. return result;
  52. }
  53. /**
  54. * 统计 属于多建筑楼层的空间数据
  55. *
  56. * @param request
  57. * @return
  58. */
  59. @RequestMapping("/space-bd-fl-data")
  60. public AdmResponse querySpaceBdFlObj(HttpServletRequest request) {
  61. return spaceService.queryMultiBuildingOrFloorSpaces(request);
  62. }
  63. /**
  64. * 查询没有和当前空间绑定的系统
  65. * description= "例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " + "spaceId 为当前空间id type为当前空间类型 "
  66. * @param type 空间类型 空间id确定,空间类型一定确定,此参数可以不用
  67. * @param spaceId 空间id
  68. *
  69. * @author lxy
  70. */
  71. @RequestMapping("/unspace-in-sys")
  72. public AdmResponse unSpaceSys(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request){
  73. request.setName(AdmSystem.OBJ_TYPE);
  74. // 设置关系条件
  75. request.resetRelationCond(true, "MechInArch", "Sy2Sp", spaceId, false);
  76. return systemService.query(request);
  77. }
  78. /**
  79. * 查询没有和当前空间绑定的设备
  80. * description ="例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " + "spaceId 为当前空间id type为当前空间类型 "
  81. * @return
  82. */
  83. @PostMapping("/unspace-in-eq")
  84. public AdmResponse unSpaceEq(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request) {
  85. return unSpaceEq(type, spaceId, request, "MechInArch");
  86. }
  87. /**
  88. * 查询没有服务于当前空间的设备
  89. * description ="例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " +
  90. * "spaceId 为当前空间id type为当前空间类型
  91. *
  92. * @return
  93. */
  94. @PostMapping("/unspace-for-eq")
  95. public AdmResponse unSpaceForEq(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request) {
  96. return unSpaceForEqPoint(type, spaceId, request);
  97. }
  98. /**
  99. * 空间内没有服务于当前空间的设备
  100. */
  101. @PostMapping("/unspace-for-eq-point")
  102. public AdmResponse unSpaceForEqPoint(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request) {
  103. return unSpaceEq(type, spaceId, request, "MechForArch");
  104. }
  105. /**
  106. * 空间内没有和空间关联的设备
  107. */
  108. @PostMapping("/unspace-fIn-eq-point")
  109. public AdmResponse unSpaceInEqPoint(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request) {
  110. return unSpaceEq(type, spaceId, request, "MechInArch");
  111. }
  112. /**
  113. * 未关联业务空间的元空间 Sp2Si
  114. */
  115. @PostMapping("/unspace-ispace")
  116. public AdmResponse unSpaceIspace(@QueryParam("objectType") String objectType, @RequestBody AdmDCSQueryRequest request) {
  117. //因现有floor没有轮廓线,先不做元空间和floor的轮廓的判断,使用关系查询
  118. request.setName(AdmISpace.OBJ_TYPE);
  119. // 设置关系条件
  120. AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.SP2SI;
  121. request.resetRelationCond(false, null, typeEnum.getRelCode(), objectType, null, false);
  122. request.addFilters("floorId = '"+request.getFloorId()+"'");
  123. AdmResponse responseIspace = ispaceService.doQuery(AdmContextUtil.toDmpContext(),request, AdmISpace.class);
  124. responseIspace.setFloorId(request.getFloorId());
  125. responseIspace.setZoneType(objectType);
  126. return responseIspace;
  127. }
  128. /*
  129. @PostMapping("/unspace-ispace")
  130. public AdmResponse unSpaceIspace(@QueryParam("objectType") String objectType, @RequestBody AdmDCSQueryRequest request) {
  131. // 查询楼层信息 需要楼层信息中的outline modelId
  132. AdmQueryCriteria admQueryCriteriaFl = new AdmQueryCriteria();
  133. admQueryCriteriaFl.setName(AdmFloor.OBJ_TYPE);
  134. admQueryCriteriaFl.setFilters(" id = '"+request.getFloorId()+"' ");
  135. AdmResponse responseFl = floorService.doQuery(AdmContextUtil.toDmpContext(), admQueryCriteriaFl, AdmFloor.class);
  136. if(CollUtil.isEmpty(responseFl.getContent())){
  137. return AdmResponse.failure("floorId 为空");
  138. }
  139. AdmFloor floor = (AdmFloor) responseFl.getContent().get(0);
  140. request.setName(AdmISpace.OBJ_TYPE);
  141. // 设置关系条件
  142. AdmRelationTypeEnum typeEnum = AdmRelationTypeEnum.SP2SI;
  143. request.resetRelationCond(false, null, typeEnum.getRelCode(), objectType, null, false);
  144. // 补充楼层条件
  145. if(StrUtil.isNotBlank(request.getFloorId())) {
  146. request.addFilters("bimId startwith '"+floor.getBimIdPre()+"' ");
  147. }
  148. AdmResponse responseIspace = ispaceService.doQuery(AdmContextUtil.toDmpContext(),request, AdmISpace.class);
  149. // 按照楼层轮廓线计算出不在轮廓线内的空间
  150. if(CollUtil.isNotEmpty(floor.getOutline())){
  151. // 计算ispace.outLine 在floor.outLine 内的ispace
  152. List<AdmISpace> iSpaceListTarget = new ArrayList<>(responseIspace.getTotal().intValue());
  153. List<AdmISpace> iSpaceList = (List<AdmISpace>) responseIspace.getContent();
  154. for(AdmISpace iSpace : iSpaceListTarget){
  155. if(CollUtil.isEmpty(iSpace.getOutline())){
  156. continue;
  157. }
  158. List<ObjectNode> ispaceOutLine = JSONArray.parseArray(iSpace.getOutline().toString(), ObjectNode.class);
  159. // if(GeoToolsUtil.isPolyInPoly(ispaceOutLine, floor.getOutline())){
  160. // iSpaceList.add(iSpace);
  161. // }
  162. }
  163. AdmResponse admResponse = AdmResponse.success(iSpaceList,request);
  164. admResponse.setFloorId(request.getFloorId());
  165. admResponse.setZoneType(objectType);
  166. admResponse.setTotal(responseIspace.getTotal());
  167. return admResponse;
  168. }else{
  169. responseIspace.setFloorId(request.getFloorId());
  170. responseIspace.setZoneType(objectType);
  171. return responseIspace;
  172. }
  173. }*/
  174. private AdmResponse unSpaceEq(String type, String spaceId, AdmQueryCriteria request, String graphCode) {
  175. if (StrUtil.isBlank(spaceId)) {
  176. return AdmResponse.failure(ResponseCode.A0400.getDesc() + "空间id为空");
  177. }
  178. request.setName(AdmEquipment.OBJ_TYPE);
  179. // 设置关系条件
  180. request.resetRelationCond(true, graphCode, "Eq2Sp", type, spaceId, false);
  181. return equipmentService.query(request);
  182. }
  183. }