| | |
| | | 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.emergencyplan.vo.MesProEmergencyPlanImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan.vo.MesProEmergencyPlanImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan.vo.MesProEmergencyPlanPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan.vo.MesProEmergencyPlanRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan.vo.MesProEmergencyPlanSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.pro.emergencyplan.MesProEmergencyPlanService; |
| | | 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-emergency-plan:query')") |
| | | public CommonResult<MesProEmergencyPlanRespVO> getPlan(@RequestParam("id") Long id) { |
| | | MesProEmergencyPlanDO plan = planService.getPlan(id); |
| | | return success(plan != null ? BeanUtils.toBean(plan, MesProEmergencyPlanRespVO.class) : null); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得应急处置预案分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-emergency-plan:query')") |
| | | public CommonResult<PageResult<MesProEmergencyPlanRespVO>> getPlanPage(@Valid MesProEmergencyPlanPageReqVO pageReqVO) { |
| | | PageResult<MesProEmergencyPlanDO> 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<MesProEmergencyPlanImportExcelVO> list = Collections.singletonList( |
| | | MesProEmergencyPlanImportExcelVO.builder() |
| | | .name("变电站停电处置预案").planType(1).content("1. 立即隔离故障...") |
| | | .orgUnit("运维部").remark("").build() |
| | | ); |
| | | ExcelUtils.write(response, "应急处置预案导入模板.xls", "应急处置预案列表", MesProEmergencyPlanImportExcelVO.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-emergency-plan:import')") |
| | | public CommonResult<MesProEmergencyPlanImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesProEmergencyPlanImportExcelVO> list = ExcelUtils.read(file, MesProEmergencyPlanImportExcelVO.class); |
| | | return success(planService.importPlanList(list, updateSupport)); |
| | | } |
| | | |
| | | } |