DeviceController.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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.model.Device;
  5. import com.bizmatics.model.DeviceList;
  6. import com.bizmatics.model.vo.CorrespondDeviceListVO;
  7. import com.bizmatics.model.vo.CorrespondDeviceVO;
  8. import com.bizmatics.model.vo.DeviceOneVo;
  9. import com.bizmatics.service.DeviceService;
  10. import com.bizmatics.service.vo.DeviceCountVO;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.*;
  14. import org.springframework.web.multipart.MultipartFile;
  15. import java.util.Date;
  16. import java.util.List;
  17. /**
  18. * 设备管理-通信设备
  19. *
  20. * @author ya
  21. * @since 2021-07-07
  22. */
  23. @Slf4j
  24. @RestController
  25. @RequestMapping("/device")
  26. public class DeviceController {
  27. @Autowired
  28. private DeviceService deviceService;
  29. /**
  30. * 查询设备总数
  31. *
  32. * @param startTime
  33. * @param endTime
  34. * @return
  35. */
  36. @GetMapping("/count")
  37. public ApiResult<DeviceCountVO> count(@RequestParam Date startTime, @RequestParam Date endTime) {
  38. return ApiResult.success(deviceService.selectDeviceCount(startTime, endTime));
  39. }
  40. /**
  41. * 查询不同类型的设备数量
  42. *
  43. * @param site 站点id
  44. * @return
  45. */
  46. @GetMapping("/deviceTypeCount")
  47. public ApiResult<DeviceCountVO> selectDeviceCountByType(@RequestParam Integer site) {
  48. return ApiResult.success(deviceService.selectDeviceCountByType(site));
  49. }
  50. /**
  51. * 通信设备-设备下拉框查询
  52. *
  53. * @param siteId 站点ID
  54. * @return
  55. */
  56. @GetMapping("deviceList")
  57. public ApiResult<List<DeviceList>> deviceList(@RequestParam(value = "siteId", required = false, defaultValue = "0") String siteId) {
  58. return ApiResult.success(deviceService.deviceList(siteId));
  59. }
  60. /**
  61. * 数据管理-同比分析报表-右侧设备查询
  62. *
  63. * @param siteId 站点ID
  64. * @param deviceType 设备类型 默认1、用电设备
  65. * @return
  66. */
  67. @GetMapping("dataManagementDeviceList")
  68. public ApiResult<List<DeviceOneVo>> dataManagementDeviceList(@RequestParam int siteId,
  69. @RequestParam(value = "deviceType", required = false, defaultValue = "1") int deviceType) {
  70. return ApiResult.success(deviceService.dataManagementDeviceList(siteId, deviceType));
  71. }
  72. /**
  73. * 设备管理-通信设备-新增
  74. *
  75. * @param device
  76. * @return
  77. */
  78. @PostMapping("correspondDeviceAdd")
  79. public ApiResult<Void> correspondDeviceAdd(@RequestBody Device device) {
  80. deviceService.correspondDeviceAdd(device);
  81. return ApiResult.success();
  82. }
  83. /**
  84. * 设备管理-通信设备-修改
  85. *
  86. * @param device
  87. * @return
  88. */
  89. @PostMapping("correspondDeviceUpdate")
  90. public ApiResult<Void> correspondDeviceUpdate(@RequestBody Device device) {
  91. deviceService.correspondDeviceUpdate(device);
  92. return ApiResult.success();
  93. }
  94. /**
  95. * 设备管理-通信设备-注销
  96. *
  97. * @param id
  98. * @return
  99. */
  100. @GetMapping("correspondDeviceDel")
  101. public ApiResult<Void> correspondDeviceDel(@RequestParam int id) {
  102. deviceService.correspondDeviceDel(id);
  103. return ApiResult.success();
  104. }
  105. /**
  106. * 设备管理-通信设备-查询
  107. *
  108. * @param deviceName 设备名称
  109. * @param size 条数
  110. * @param current 页数
  111. * @return
  112. */
  113. @GetMapping("correspondDeviceList")
  114. public ApiResult<CommonPage<CorrespondDeviceVO>> correspondDeviceList(@RequestParam(required = false) String deviceName,
  115. @RequestParam(value = "size", required = false, defaultValue = "15") int size,
  116. @RequestParam(value = "current", required = false, defaultValue = "1") int current) {
  117. return ApiResult.success(deviceService.correspondDeviceList(deviceName, size, current));
  118. }
  119. /**
  120. * 设备管理-通信设备-修改回显
  121. *
  122. * @param id 通信设备表主键ID
  123. * @return
  124. */
  125. @GetMapping("correspondDeviceListEcho")
  126. public ApiResult<List<CorrespondDeviceListVO>> correspondDeviceListEcho(@RequestParam int id) {
  127. return ApiResult.success(deviceService.correspondDeviceListEcho(id));
  128. }
  129. /**
  130. * 设备管理-视频监测-列表查询
  131. *
  132. * @param siteId 站点ID
  133. * @param deviceName 设备名称
  134. * @param size 页数
  135. * @param current 条数
  136. * @param deviceType 1:183用电设备,2:视频监控设备,3:171用电设备,4:173用电设备,5:158智能网关,6:其他 0:所有
  137. * @return
  138. */
  139. @GetMapping("videoMonitoringDeviceList")
  140. public ApiResult<CommonPage<Device>> videoMonitoringDeviceList(@RequestParam Integer siteId,
  141. @RequestParam(required = false) String deviceName,
  142. @RequestParam(value = "size", required = false, defaultValue = "10") Integer size,
  143. @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
  144. @RequestParam(value = "deviceType", required = false, defaultValue = "2") Integer deviceType
  145. ) {
  146. return ApiResult.success(deviceService.videoMonitoringDeviceList(deviceName, deviceType, siteId, size, current));
  147. }
  148. /**
  149. * 设备管理-通信设备-克隆
  150. *
  151. * @param type 1 新设备 2 已有设备
  152. * @param newDeviceCode 克隆设备对象
  153. * @param oldDeviceCode 设备编号
  154. * @param deviceName 设备名称
  155. * @return
  156. */
  157. @GetMapping("variableCloning")
  158. public ApiResult<Void> variableCloning(@RequestParam Integer type,
  159. @RequestParam String newDeviceCode,
  160. @RequestParam String oldDeviceCode,
  161. @RequestParam(required = false) String deviceName
  162. ) {
  163. deviceService.variableCloning(type, newDeviceCode, oldDeviceCode, deviceName);
  164. return ApiResult.success();
  165. }
  166. /**
  167. * 通信设备列表查询-无分页
  168. *
  169. * @param siteId 站点ID
  170. * @param deviceType 1电力 2视频
  171. * @return
  172. */
  173. @GetMapping("deviceListOne")
  174. public ApiResult<List<Device>> deviceListOne(@RequestParam Integer siteId,
  175. @RequestParam(value = "deviceType", required = false, defaultValue = "1") Integer deviceType) {
  176. return ApiResult.success(deviceService.deviceListOne(siteId, deviceType));
  177. }
  178. /**
  179. * 站点管理-摄像头-导出
  180. *
  181. * @param siteId 站点Id
  182. * @param deviceName 设备名称
  183. * @param deviceType 1:183用电设备,2:视频监控设备,3:171用电设备,4:173用电设备,5:158智能网关,6:其他
  184. * @return
  185. */
  186. @GetMapping("deviceExport")
  187. public ApiResult<String> deviceExport(@RequestParam(value = "siteId", required = false, defaultValue = "0") Integer siteId,
  188. @RequestParam(required = false) String deviceName,
  189. @RequestParam(value = "deviceType", required = false, defaultValue = "2") Integer deviceType) {
  190. return ApiResult.success(deviceService.deviceExport(deviceName, deviceType, siteId));
  191. }
  192. /**
  193. * 设备管理-通信设备-导出
  194. *
  195. * @param deviceName 设备名称
  196. * @return
  197. */
  198. @GetMapping("correspondDeviceExport")
  199. public ApiResult<String> correspondDeviceExport(@RequestParam(required = false) String deviceName) {
  200. return ApiResult.success(deviceService.correspondDeviceExport(deviceName));
  201. }
  202. /**
  203. * 通信设备-导入
  204. *
  205. * @param file 导入文件
  206. * @return
  207. * @throws Exception
  208. */
  209. @PostMapping("/deviceImport")
  210. public ApiResult<Void> deviceImport(@RequestParam("file") MultipartFile file){
  211. deviceService.deviceImport(file);
  212. return ApiResult.success();
  213. }
  214. /**
  215. * 数据管理-需量分析-用能月报查询
  216. * @param siteId 站点ID
  217. * @return
  218. */
  219. @GetMapping("deviceBoxList")
  220. public ApiResult<List<DeviceOneVo>> deviceBoxList(@RequestParam (required = false) Integer siteId) {
  221. return ApiResult.success(deviceService.deviceBoxList(siteId));
  222. }
  223. }