|
@@ -0,0 +1,102 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.inspect.plan;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.inspect.plan.vo.IotInspectPlanPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.inspect.plan.vo.IotInspectPlanRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.inspect.plan.vo.IotInspectPlanSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectPlanDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.inspect.IotInspectPlanService;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserUpdateStatusReqVO;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 巡检计划")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rq/iot-inspect-plan")
|
|
|
+@Validated
|
|
|
+public class IotInspectPlanController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotInspectPlanService iotInspectPlanService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建巡检计划")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-plan:create')")
|
|
|
+ public CommonResult<Long> createIotInspectPlan(@Valid @RequestBody IotInspectPlanSaveReqVO createReqVO) {
|
|
|
+ return success(iotInspectPlanService.createIotInspectPlan(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新巡检计划")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-plan:update')")
|
|
|
+ public CommonResult<Boolean> updateIotInspectPlan(@Valid @RequestBody IotInspectPlanSaveReqVO updateReqVO) {
|
|
|
+ iotInspectPlanService.updateIotInspectPlan(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除巡检计划")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-plan:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotInspectPlan(@RequestParam("id") Long id) {
|
|
|
+ iotInspectPlanService.deleteIotInspectPlan(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得巡检计划")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-plan:query')")
|
|
|
+ public CommonResult<IotInspectPlanRespVO> getIotInspectPlan(@RequestParam("id") Long id) {
|
|
|
+ IotInspectPlanDO iotInspectPlan = iotInspectPlanService.getIotInspectPlan(id);
|
|
|
+ return success(BeanUtils.toBean(iotInspectPlan, IotInspectPlanRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得巡检计划分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-plan:query')")
|
|
|
+ public CommonResult<PageResult<IotInspectPlanRespVO>> getIotInspectPlanPage(@Valid IotInspectPlanPageReqVO pageReqVO) {
|
|
|
+ PageResult<IotInspectPlanDO> pageResult = iotInspectPlanService.getIotInspectPlanPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotInspectPlanRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出巡检计划 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-plan:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotInspectPlanExcel(@Valid IotInspectPlanPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotInspectPlanDO> list = iotInspectPlanService.getIotInspectPlanPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "巡检计划.xls", "数据", IotInspectPlanRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotInspectPlanRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update-status")
|
|
|
+ @Operation(summary = "修改巡检计划状态")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-inspect-plan:update')")
|
|
|
+ public CommonResult<Boolean> updateUserStatus(@Valid @RequestBody UserUpdateStatusReqVO reqVO) {
|
|
|
+ iotInspectPlanService.updateInspectPlanStatus(reqVO.getId(), reqVO.getStatus());
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+}
|