| | |
| | | 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") |
| | | @Operation(summary = "获得计量器具") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-metering:query')") |
| | | public CommonResult<MesDvMeteringRespVO> getMetering(@RequestParam("id") Long id) { |
| | | MesDvMeteringDO metering = meteringService.getMetering(id); |
| | | if (metering == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得计量器具分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-metering:query')") |
| | | public CommonResult<PageResult<MesDvMeteringRespVO>> getMeteringPage(@Valid MesDvMeteringPageReqVO pageReqVO) { |
| | | PageResult<MesDvMeteringDO> pageResult = meteringService.getMeteringPage(pageReqVO); |
| | | return success(new PageResult<>(buildMeteringRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | |
| | | @GetMapping("/simple-list") |
| | | @Operation(summary = "获得计量器具精简列表", description = "主要用于前端的下拉选项") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-metering:query')") |
| | | public CommonResult<List<MesDvMeteringRespVO>> getMeteringSimpleList() { |
| | | List<MesDvMeteringDO> list = meteringService.getMeteringList(); |
| | | return success(buildMeteringRespVOList(list)); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | @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.writeTemplate(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)); |
| | | } |
| | | |
| | | } |