| | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.meteringcheck.vo.MesDvMeteringCheckImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.meteringcheck.vo.MesDvMeteringCheckImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 计量检测记录") |
| | | @RestController |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得计量检测记录") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-metering-check:query')") |
| | | public CommonResult<MesDvMeteringCheckRespVO> getMeteringCheck(@RequestParam("id") Long id) { |
| | | MesDvMeteringCheckDO check = meteringCheckService.getMeteringCheck(id); |
| | | if (check == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得计量检测记录分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-metering-check:query')") |
| | | public CommonResult<PageResult<MesDvMeteringCheckRespVO>> getMeteringCheckPage( |
| | | @Valid MesDvMeteringCheckPageReqVO pageReqVO) { |
| | | PageResult<MesDvMeteringCheckDO> pageResult = meteringCheckService.getMeteringCheckPage(pageReqVO); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得计量检测记录导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesDvMeteringCheckImportExcelVO> list = Collections.singletonList( |
| | | MesDvMeteringCheckImportExcelVO.builder() |
| | | .checkCode("CK-001").meteringCode("MD-001") |
| | | .checkDate(java.time.LocalDate.of(2026, 12, 31)) |
| | | .checkOrg("市计量院").checkResult(1).certNo("") |
| | | .checkUserId(1L).nextCheckDate(java.time.LocalDate.of(2027, 12, 31)) |
| | | .remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "计量检测记录导入模板.xls", "计量检测记录列表", MesDvMeteringCheckImportExcelVO.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:dv-metering-check:import')") |
| | | public CommonResult<MesDvMeteringCheckImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesDvMeteringCheckImportExcelVO> list = ExcelUtils.read(file, MesDvMeteringCheckImportExcelVO.class); |
| | | return success(meteringCheckService.importMeteringCheckList(list, updateSupport)); |
| | | } |
| | | |
| | | } |