DeviceController.java 10 KB

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