DeviceController.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. package com.bizmatics.controller.web;
  2. import com.bizmatics.common.core.bean.ApiResult;
  3. import com.bizmatics.common.core.bean.CommonPage;
  4. import com.bizmatics.common.core.util.DateUtils;
  5. import com.bizmatics.model.Device;
  6. import com.bizmatics.model.DeviceList;
  7. import com.bizmatics.model.HtAnalogData;
  8. import com.bizmatics.model.vo.CorrespondDeviceListVO;
  9. import com.bizmatics.model.vo.CorrespondDeviceVO;
  10. import com.bizmatics.model.vo.DeviceOneVo;
  11. import com.bizmatics.persistence.mapper.DeviceMapper;
  12. import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
  13. import com.bizmatics.service.DeviceService;
  14. import com.bizmatics.service.vo.CorrespondDeviceVOT;
  15. import com.bizmatics.service.vo.DeviceCountVO;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.web.bind.annotation.*;
  19. import java.util.ArrayList;
  20. import java.util.Date;
  21. import java.util.List;
  22. /**
  23. * 设备
  24. *
  25. * @author ya
  26. * @since 2021-07-07
  27. */
  28. @Slf4j
  29. @RestController
  30. @RequestMapping("/device")
  31. public class DeviceController {
  32. @Autowired
  33. private DeviceService deviceService;
  34. @Autowired
  35. private DeviceMapper deviceMapper;
  36. @Autowired
  37. private HtAnalogDataMapper htAnalogDataMapper;
  38. /**
  39. * 查询设备总数
  40. *
  41. * @param startTime
  42. * @param endTime
  43. * @return
  44. */
  45. @GetMapping("/count")
  46. public ApiResult<DeviceCountVO> count(@RequestParam Date startTime, @RequestParam Date endTime) {
  47. return ApiResult.success(deviceService.selectDeviceCount(startTime, endTime));
  48. }
  49. /**
  50. * 查询不同类型的设备数量
  51. *
  52. * @param site 站点id
  53. * @return
  54. */
  55. @GetMapping("/deviceTypeCount")
  56. public ApiResult<DeviceCountVO> selectDeviceCountByType(@RequestParam Integer site) {
  57. return ApiResult.success(deviceService.selectDeviceCountByType(site));
  58. }
  59. @GetMapping("/test")
  60. public List<String> test() {
  61. List<Device> list = deviceMapper.list(1, null, null, null, null, null);
  62. List<String> list1 = new ArrayList<>();
  63. for (Device device : list) {
  64. long l = System.currentTimeMillis();
  65. List<HtAnalogData> list2 = htAnalogDataMapper.list(DateUtils.addYears(new Date(), -10), new Date(), device.getDeviceCode());
  66. long e = System.currentTimeMillis();
  67. log.info("一个站点的数据获取时间" + (e - l));
  68. }
  69. return list1;
  70. }
  71. @GetMapping("deviceList")
  72. public ApiResult<List<DeviceList>> deviceList(@RequestParam String siteId) {
  73. return ApiResult.success(deviceService.deviceList(siteId));
  74. }
  75. /**
  76. * 数据管理-同比分析报表-右侧设备查询
  77. *
  78. * @param siteId 站点ID
  79. * @param deviceType 设备类型 默认1、用电设备
  80. * @return
  81. */
  82. @GetMapping("dataManagementDeviceList")
  83. public ApiResult<List<DeviceOneVo>> dataManagementDeviceList(@RequestParam int siteId,
  84. @RequestParam(value = "deviceType", required = false, defaultValue = "1") int deviceType) {
  85. return ApiResult.success(deviceService.dataManagementDeviceList(siteId, deviceType));
  86. }
  87. /**
  88. * 设备管理-通信设备-新增
  89. *
  90. * @param device
  91. * @return
  92. */
  93. @PostMapping("correspondDeviceAdd")
  94. public ApiResult<Void> correspondDeviceAdd(@RequestBody Device device) {
  95. deviceService.correspondDeviceAdd(device);
  96. return ApiResult.success();
  97. }
  98. /**
  99. * 设备管理-通信设备-修改
  100. *
  101. * @param device
  102. * @return
  103. */
  104. @PostMapping("correspondDeviceUpdate")
  105. public ApiResult<Void> correspondDeviceUpdate(@RequestBody Device device) {
  106. deviceService.correspondDeviceUpdate(device);
  107. return ApiResult.success();
  108. }
  109. /**
  110. * 设备管理-通信设备-注销
  111. *
  112. * @param id
  113. * @return
  114. */
  115. @GetMapping("correspondDeviceDel")
  116. public ApiResult<Void> correspondDeviceDel(@RequestParam int id) {
  117. deviceService.correspondDeviceDel(id);
  118. return ApiResult.success();
  119. }
  120. /**
  121. * 设备管理-通信设备-查询
  122. *
  123. * @param deviceName 设备名称
  124. * @param size 条数
  125. * @param current 页数
  126. * @return
  127. */
  128. @GetMapping("correspondDeviceList")
  129. public ApiResult<CommonPage<CorrespondDeviceVO>> correspondDeviceList(@RequestParam(required = false) String deviceName,
  130. @RequestParam(value = "size", required = false, defaultValue = "15") int size,
  131. @RequestParam(value = "current", required = false, defaultValue = "1") int current) {
  132. return ApiResult.success(deviceService.correspondDeviceList(deviceName, size, current));
  133. }
  134. /**
  135. * 设备管理-通信设备-修改回显
  136. *
  137. * @param id 通信设备表主键ID
  138. * @return
  139. */
  140. @GetMapping("correspondDeviceListEcho")
  141. public ApiResult<List<CorrespondDeviceListVO>> correspondDeviceListEcho(@RequestParam int id) {
  142. return ApiResult.success(deviceService.correspondDeviceListEcho(id));
  143. }
  144. /**
  145. * 设备管理-视频监测-列表查询
  146. *
  147. * @param siteId 站点ID
  148. * @param deviceName 设备名称
  149. * @param size 页数
  150. * @param current 条数
  151. * @param deviceType 1:183用电设备,2:视频监控设备,3:171用电设备,4:173用电设备,5:158智能网关,6:其他 0:所有
  152. * @return
  153. */
  154. @GetMapping("videoMonitoringDeviceList")
  155. public ApiResult<CommonPage<Device>> videoMonitoringDeviceList(@RequestParam Integer siteId,
  156. @RequestParam(required = false) String deviceName,
  157. @RequestParam(value = "size", required = false, defaultValue = "1") Integer size,
  158. @RequestParam(value = "current", required = false, defaultValue = "10") Integer current,
  159. @RequestParam(value = "deviceType", required = false, defaultValue = "2") Integer deviceType
  160. ) {
  161. return ApiResult.success(deviceService.videoMonitoringDeviceList(deviceName, deviceType, siteId, size, current));
  162. }
  163. }