Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / java / com / newfiber / termite / controller / DeviceInfoController.java
  1. package com.newfiber.termite.controller;
  2.  
  3. import com.newfiber.common.core.exception.ServiceException;
  4. import com.newfiber.common.core.utils.poi.ExcelUtil;
  5. import com.newfiber.common.core.web.controller.BaseController;
  6. import com.newfiber.common.core.web.domain.Result;
  7. import com.newfiber.common.core.web.page.PageResult;
  8. import com.newfiber.common.log.annotation.Log;
  9. import com.newfiber.common.log.enums.BusinessType;
  10. import com.newfiber.termite.domain.DeviceInfo;
  11. import com.newfiber.termite.domain.SnDeviceInfo;
  12. import com.newfiber.termite.domain.request.deviceInfo.*;
  13. import com.newfiber.termite.service.IDeviceInfoService;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiOperation;
  16. import java.util.List;
  17. import javax.annotation.Resource;
  18. import javax.validation.Valid;
  19. import org.springframework.web.bind.annotation.DeleteMapping;
  20. import org.springframework.web.bind.annotation.GetMapping;
  21. import org.springframework.web.bind.annotation.PathVariable;
  22. import org.springframework.web.bind.annotation.PostMapping;
  23. import org.springframework.web.bind.annotation.PutMapping;
  24. import org.springframework.web.bind.annotation.RequestBody;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.RestController;
  27. import org.springframework.web.multipart.MultipartFile;
  28.  
  29. /**
  30. * 设备信息Controller
  31. *
  32. * @author X.K
  33. * @date 2024-05-27
  34. */
  35. @RestController
  36. @RequestMapping("/deviceInfo")
  37. @Api(value = "设备信息", tags = "设备信息")
  38. public class DeviceInfoController extends BaseController {
  39.  
  40. @Resource
  41. private IDeviceInfoService deviceInfoService;
  42.  
  43. /**
  44. * 新增设备信息
  45. */
  46. @PostMapping("add")
  47. @ApiOperation(value = "新增设备信息", position = 10)
  48. @Log(title = "设备信息", businessType = BusinessType.INSERT)
  49. public Result<Long> add(@Valid @RequestBody DeviceInfoSaveRequest request) {
  50. return success(deviceInfoService.insert(request));
  51. }
  52.  
  53. /**
  54. * 新增设备信息
  55. */
  56. @PostMapping("addBatch")
  57. @ApiOperation(value = "批量新增设备信息", position = 10)
  58. @Log(title = "设备信息", businessType = BusinessType.INSERT)
  59. public Result<String> addBatch(@Valid @RequestBody DeviceInfoBatchSaveRequest request) {
  60. deviceInfoService.insert(request);
  61. return success();
  62. }
  63.  
  64. @PostMapping("/parseExcel")
  65. public Result<List<DeviceInfoImportRequest>> parseExcel(MultipartFile file) throws Exception{
  66. ExcelUtil<DeviceInfoImportRequest> util = new ExcelUtil<>(DeviceInfoImportRequest.class);
  67. List<DeviceInfoImportRequest> deviceInfoImportRequestList = util.importExcel(file.getInputStream());
  68. return success(deviceInfoImportRequestList);
  69. }
  70.  
  71. @PostMapping("/importExcel")
  72. public Result<List<DeviceInfo>> importExcel(MultipartFile file, String projectCode) throws Exception{
  73. if(null == file){
  74. throw new ServiceException("请上传文件");
  75. }
  76. ExcelUtil<DeviceInfoImportRequest> util = new ExcelUtil<>(DeviceInfoImportRequest.class);
  77. List<DeviceInfoImportRequest> deviceInfoImportRequestList = util.importExcel(file.getInputStream());
  78. DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList);
  79. return success(deviceInfoService.insert(batchSaveRequest));
  80. }
  81.  
  82. /**
  83. * 修改设备信息
  84. */
  85. @PutMapping("edit")
  86. @ApiOperation(value = "修改设备信息", position = 20)
  87. @Log(title = "设备信息", businessType = BusinessType.UPDATE)
  88. public Result<Object> edit(@Valid @RequestBody DeviceInfoUpdateRequest request) {
  89. return success(deviceInfoService.update(request));
  90. }
  91.  
  92. /**
  93. * 删除设备信息
  94. */
  95. @DeleteMapping("/{ids}")
  96. @ApiOperation(value = "删除设备信息", notes = "传入ids(,隔开)", position = 30)
  97. @Log(title = "设备信息", businessType = BusinessType.DELETE)
  98. public Result<Object> remove(@PathVariable String ids) {
  99. return success(deviceInfoService.delete(ids));
  100. }
  101.  
  102. /**
  103. * 详细查询设备信息
  104. */
  105. @GetMapping(value = "/{sn}")
  106. @ApiOperation(value = "详细查询设备信息", position = 40)
  107. public Result<DeviceInfo> detail(@PathVariable("sn") String sn) {
  108. return success(deviceInfoService.selectDetail(sn));
  109. }
  110.  
  111. /**
  112. * 分页查询设备信息
  113. */
  114. @GetMapping("/page")
  115. @ApiOperation(value = "分页查询设备信息", position = 50)
  116. public PageResult<List<DeviceInfo>> page(DeviceInfoQueryRequest request) {
  117. startPage();
  118. List<DeviceInfo> list = deviceInfoService.selectPage(request);
  119. return pageResult(list);
  120. }
  121.  
  122. /**
  123. * 列表查询设备信息
  124. */
  125. @GetMapping("/list")
  126. @ApiOperation(value = "列表查询设备信息", position = 60)
  127. public Result<List<DeviceInfo>> list(DeviceInfoQueryRequest request) {
  128. List<DeviceInfo> list = deviceInfoService.selectList(request);
  129. return success(list);
  130. }
  131.  
  132.  
  133. // /**
  134. // * 列表查询当前用户设备sn信息
  135. // */
  136. // @GetMapping("/snList")
  137. // @ApiOperation(value = "列表查询当前用户设备信息", position = 60)
  138. // public Result<List<SnDeviceInfo>> snlist(DeviceSnInfoQueryRequest request) {
  139. // List<SnDeviceInfo> list = deviceInfoService.selectSnList(request);
  140. // return success(list);
  141. // }
  142. //
  143. //
  144. // /**
  145. // * 分页查询当前用户设备sn信息
  146. // */
  147. // @GetMapping("/snPage")
  148. // @ApiOperation(value = "列表查询当前用户设备信息", position = 60)
  149. // public Result<List<DeviceInfo>> snPage(DeviceInfoQueryRequest request) {
  150. // startPage();
  151. // List<DeviceInfo> list = deviceInfoService.selectSnPage(request);
  152. // return pageResult(list);
  153. // }
  154. //
  155. // /**
  156. // * SN编号查询监测记录
  157. // */
  158. // @GetMapping("/snQuerMonitoryList")
  159. // @ApiOperation(value = "SN编号查询用户设备监测信息", position = 60)
  160. // public Result<List<SnDeviceInfo>> snQuerMonitoryList(DeviceInfoQueryRequest request) {
  161. // List<SnDeviceInfo> list = deviceInfoService.snQuerMonitoryList(request);
  162. // return success(list);
  163. //
  164. // }
  165.  
  166.  
  167. }