ComponentStatisticsController.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. package com.persagy.proxy.report.controller;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.google.common.collect.Lists;
  5. import com.google.common.collect.Sets;
  6. import com.persagy.proxy.adm.constant.AdmCommonConstant;
  7. import com.persagy.proxy.adm.constant.AdmObjectType;
  8. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  9. import com.persagy.proxy.adm.constant.SpaceTypeEnum;
  10. import com.persagy.proxy.adm.request.AdmCountResponse;
  11. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  12. import com.persagy.proxy.adm.request.AdmResponse;
  13. import com.persagy.proxy.adm.utils.AdmContextUtil;
  14. import com.persagy.proxy.common.entity.InstanceUrlParam;
  15. import com.persagy.proxy.object.model.AdmEquipment;
  16. import com.persagy.proxy.object.model.AdmShaft;
  17. import com.persagy.proxy.object.service.IAdmEquipmentService;
  18. import com.persagy.proxy.object.service.IAdmShaftService;
  19. import com.persagy.proxy.report.service.IRelationReportService;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import javax.servlet.http.HttpServletRequest;
  25. import java.util.HashMap;
  26. import java.util.List;
  27. import java.util.Map;
  28. /**
  29. * 统计接口
  30. *
  31. * @version 1.0.0
  32. * @company persagy
  33. * @author zhangqiankun
  34. * @date 2021年9月8日 下午7:51:56
  35. */
  36. @RestController
  37. @RequestMapping("/statistics")
  38. public class ComponentStatisticsController {
  39. @Autowired
  40. private IRelationReportService relationReportService;
  41. @Autowired
  42. private IAdmShaftService shaftService;
  43. /**
  44. * 台账中待删除的对象
  45. * <p>条件:"filters": "taskState = -1"</p>
  46. * @param request
  47. * @return
  48. */
  49. @RequestMapping(value = "/object-delete-count")
  50. public AdmCountResponse objectDeleteCount(@RequestBody JSONObject params, HttpServletRequest request) {
  51. return AdmCountResponse.success(0L);
  52. }
  53. /**
  54. * 不能同步到物理世界的关系数据
  55. * @param request
  56. * @return
  57. */
  58. @RequestMapping(value = "/unsyn-relation-count")
  59. public AdmCountResponse unsynRelationCount(HttpServletRequest request) {
  60. return AdmCountResponse.success(0L);
  61. }
  62. /**
  63. * 岗位和关联的资产信息点值不一致
  64. *
  65. * @param request
  66. * @return
  67. */
  68. @RequestMapping(value = "/eq2pe-count")
  69. public AdmCountResponse eq2peCount(HttpServletRequest request) {
  70. return AdmCountResponse.success(0L);
  71. }
  72. /**
  73. * 岗位和关联的资产信息点值不一致的数据
  74. *
  75. * @param request
  76. * @return
  77. */
  78. @RequestMapping(value = "/eq2pe-different")
  79. public AdmCountResponse eq2peDifferent(HttpServletRequest request) {
  80. return AdmCountResponse.success(0L);
  81. }
  82. /**
  83. * 设备-未关联资产的设备,这里返回所有的设备
  84. * @param request
  85. * @return
  86. */
  87. @RequestMapping(value = "/uneq2pe-count")
  88. public AdmCountResponse uneq2peCount(HttpServletRequest request) {
  89. String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
  90. String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
  91. long count = this.relationReportService.countObject(groupCode, projectId, AdmObjectType.EQUIPMENT.getIndex(), null);
  92. return AdmCountResponse.success(count);
  93. }
  94. /**
  95. * 业务空间-各分区占比
  96. * @param request
  97. * @return
  98. */
  99. @RequestMapping(value = "/sp-objecttype-count")
  100. public AdmResponse spObjectTypeCount(HttpServletRequest request) {
  101. String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
  102. List<Map<String,Object>> list = this.relationReportService.queryObjectCountByObjInfos(groupCode, null,
  103. Sets.newHashSet(AdmObjectType.SPACE.getIndex()), Lists.newArrayList("classCode"));
  104. for (Map<String, Object> map : list) {
  105. map.put("name", map.get("classCode"));
  106. }
  107. return AdmResponse.success(list);
  108. }
  109. /**
  110. * 业务空间-默认分区功能类型占比
  111. * @param request
  112. * @return
  113. */
  114. @RequestMapping(value = "/general-sp-functype-count")
  115. public AdmResponse generalSpFunctypeCount(HttpServletRequest request) {
  116. String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
  117. List<Map<String,Object>> list = this.relationReportService.queryObjectCountByObjInfos(groupCode, Sets.newHashSet(SpaceTypeEnum.GeneralZone.getCode()),
  118. Sets.newHashSet(AdmObjectType.SPACE.getIndex()), Lists.newArrayList("roomFuncType"));
  119. for (Map<String, Object> map : list) {
  120. map.put("name", map.get("roomFuncType"));
  121. }
  122. return AdmResponse.success(list);
  123. }
  124. /**
  125. * 租户-关联业务空间完成度
  126. * @param request
  127. * @return
  128. */
  129. @RequestMapping(value = "/tenant2sp-count")
  130. public AdmCountResponse tenant2spCount(HttpServletRequest request) {
  131. String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
  132. String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
  133. long count = this.relationReportService.countRelationObject(groupCode, projectId, AdmRelationTypeEnum.TN2SP.getGraphCode(),
  134. AdmRelationTypeEnum.TN2SP.getRelCode(), null);
  135. return AdmCountResponse.success(count);
  136. }
  137. /**
  138. * 竖井-关联业务空间完成度
  139. * @return
  140. */
  141. @RequestMapping(value = "/shaft2sp-count")
  142. public AdmResponse shaft2spCount() {
  143. AdmQueryCriteria request = new AdmQueryCriteria();
  144. request.setName("shaft");
  145. request.setOnlyCount(true);
  146. request.resetRelationCond(true, AdmRelationTypeEnum.SH2SP.getGraphCode(),
  147. AdmRelationTypeEnum.SH2SP.getRelCode(), null);
  148. return shaftService.doQuery(AdmContextUtil.toDmpContext(), request, AdmShaft.class);
  149. }
  150. /**
  151. * 竖井-按功能类型占比
  152. * @param request
  153. * @return
  154. */
  155. @RequestMapping(value = "/shaft-functype-count")
  156. public AdmResponse shaftFunctypeCount(HttpServletRequest request) {
  157. String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
  158. List<Map<String,Object>> list = this.relationReportService.queryObjectCountByObjInfos(groupCode, null,
  159. Sets.newHashSet(AdmObjectType.SHAFT.getIndex()), Lists.newArrayList("shaftFuncType"));
  160. for (Map<String, Object> map : list) {
  161. map.put("name", map.get("shaftFuncType"));
  162. }
  163. return AdmResponse.success(list);
  164. }
  165. @Autowired
  166. private IAdmEquipmentService equipmentService;
  167. /**
  168. * 设备所在空间占比统计
  169. * @return
  170. */
  171. @RequestMapping(value = "/eq2sp")
  172. public AdmResponse queryEquip2Space() {
  173. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  174. // 查询设备数量
  175. AdmQueryCriteria criteria = new AdmQueryCriteria();
  176. criteria.setName(AdmEquipment.OBJ_TYPE);
  177. criteria.setOnlyCount(true);
  178. AdmResponse rs = equipmentService.query(criteria);
  179. long equipCount = rs.getCount() == null ? 0L : rs.getCount().longValue();
  180. // 查询关系数量
  181. long relCount = relationReportService.countRelationObject(context.getGroupCode(), context.getProjectId(),
  182. AdmRelationTypeEnum.EQ2SP_IN.getGraphCode(),AdmRelationTypeEnum.EQ2SP_IN.getRelCode(), "GeneralZone");
  183. // 组装返回结果
  184. Map<String, Long> countMap = new HashMap<>(2);
  185. countMap.put("equipCount", equipCount);
  186. countMap.put("relCount", relCount);
  187. return AdmResponse.success(CollUtil.newArrayList(countMap));
  188. }
  189. }