| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | 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.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.pro.alternativeplan.MesProAlternativePlanService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得作业替代方案") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:query')") |
| | | public CommonResult<MesProAlternativePlanRespVO> getPlan(@RequestParam("id") Long id) { |
| | | MesProAlternativePlanDO plan = planService.getPlan(id); |
| | | return success(plan != null ? BeanUtils.toBean(plan, MesProAlternativePlanRespVO.class) : null); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得作业替代方案分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:query')") |
| | | public CommonResult<PageResult<MesProAlternativePlanRespVO>> getPlanPage(@Valid MesProAlternativePlanPageReqVO pageReqVO) { |
| | | PageResult<MesProAlternativePlanDO> pageResult = planService.getPlanPage(pageReqVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得作业替代方案导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | List<MesProAlternativePlanImportExcelVO> list = Collections.singletonList( |
| | | MesProAlternativePlanImportExcelVO.builder() |
| | | .name("线路巡检替代方案").mainProcessName("线路巡检").altProcessName("无人机巡检") |
| | | .altCondition("设备故障/负荷受限/人员不足").scope("110kV 线路").remark("").build() |
| | | ); |
| | | ExcelUtils.write(response, "作业替代方案导入模板.xls", "作业替代方案列表", MesProAlternativePlanImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入作业替代方案") |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "Excel 文件", required = true), |
| | | @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:import')") |
| | | public CommonResult<MesProAlternativePlanImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesProAlternativePlanImportExcelVO> list = ExcelUtils.read(file, MesProAlternativePlanImportExcelVO.class); |
| | | return success(planService.importPlanList(list, updateSupport)); |
| | | } |
| | | |
| | | } |