|
@@ -0,0 +1,96 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.failure;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.failure.vo.IotFailureReportPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.failure.vo.IotFailureReportRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.failure.vo.IotFailureReportSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.failure.IotFailureReportDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.failure.IotFailureReportService;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import javax.validation.*;
|
|
|
+import javax.servlet.http.*;
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 故障上报")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rq/iot-failure-report")
|
|
|
+@Validated
|
|
|
+public class IotFailureReportController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotFailureReportService iotFailureReportService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建故障上报")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-failure-report:create')")
|
|
|
+ public CommonResult<Long> createIotFailureReport(@Valid @RequestBody IotFailureReportSaveReqVO createReqVO) {
|
|
|
+ return success(iotFailureReportService.createIotFailureReport(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新故障上报")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-failure-report:update')")
|
|
|
+ public CommonResult<Boolean> updateIotFailureReport(@Valid @RequestBody IotFailureReportSaveReqVO updateReqVO) {
|
|
|
+ iotFailureReportService.updateIotFailureReport(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除故障上报")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-failure-report:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotFailureReport(@RequestParam("id") Long id) {
|
|
|
+ iotFailureReportService.deleteIotFailureReport(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得故障上报")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-failure-report:query')")
|
|
|
+ public CommonResult<IotFailureReportRespVO> getIotFailureReport(@RequestParam("id") Long id) {
|
|
|
+ IotFailureReportDO iotFailureReport = iotFailureReportService.getIotFailureReport(id);
|
|
|
+ return success(BeanUtils.toBean(iotFailureReport, IotFailureReportRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得故障上报分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-failure-report:query')")
|
|
|
+ public CommonResult<PageResult<IotFailureReportRespVO>> getIotFailureReportPage(@Valid IotFailureReportPageReqVO pageReqVO) {
|
|
|
+ PageResult<IotFailureReportDO> pageResult = iotFailureReportService.getIotFailureReportPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotFailureReportRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出故障上报 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-failure-report:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotFailureReportExcel(@Valid IotFailureReportPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotFailureReportDO> list = iotFailureReportService.getIotFailureReportPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "故障上报.xls", "数据", IotFailureReportRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotFailureReportRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|