| | |
| | | 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.metering.vo.MesDvMeteringImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.metering.vo.MesDvMeteringImportRespVO; |
| | | |
| | | @Tag(name = "管理后台 - MES 计量器具") |
| | | @RestController |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得计量器具导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesDvMeteringImportExcelVO> list = Collections.singletonList( |
| | | MesDvMeteringImportExcelVO.builder() |
| | | .code("MD-001").name("数显卡尺").specification("0-150mm").brand("三丰") |
| | | .category(1).precision("0.01mm").range("0-150mm") |
| | | .checkCycleCount(12).useDate(java.time.LocalDate.of(2026, 1, 1)) |
| | | .status(1).remark("") |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "计量器具导入模板.xls", "计量器具列表", MesDvMeteringImportExcelVO.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:import')") |
| | | public CommonResult<MesDvMeteringImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesDvMeteringImportExcelVO> list = ExcelUtils.read(file, MesDvMeteringImportExcelVO.class); |
| | | return success(meteringService.importMeteringList(list, updateSupport)); |
| | | } |
| | | |
| | | } |