| | |
| | | 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.tm.tool.vo.MesTmToolImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.MesTmToolImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.MesTmToolPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.MesTmToolRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.MesTmToolSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.tm.tool.MesTmToolTypeService; |
| | | 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 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 cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得工具") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:tm-tool:query')") |
| | | public CommonResult<MesTmToolRespVO> getTool(@RequestParam("id") Long id) { |
| | | MesTmToolDO tool = toolService.getTool(id); |
| | | MesTmToolRespVO respVO = BeanUtils.toBean(tool, MesTmToolRespVO.class); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得工具分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:tm-tool:query')") |
| | | public CommonResult<PageResult<MesTmToolRespVO>> getToolPage(@Valid MesTmToolPageReqVO pageReqVO) { |
| | | PageResult<MesTmToolDO> pageResult = toolService.getToolPage(pageReqVO); |
| | | return success(new PageResult<>(buildToolRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | ExcelUtils.write(response, "工具台账.xls", "数据", MesTmToolRespVO.class, voList); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得工具导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesTmToolImportExcelVO> list = Collections.singletonList( |
| | | MesTmToolImportExcelVO.builder() |
| | | .code("T-001").name("示例工具").brand("").specification("") |
| | | .toolTypeName("").quantity(1).availableQuantity(1) |
| | | .maintenType(1).nextMaintenPeriod(100) |
| | | .nextMaintenDate(java.time.LocalDateTime.of(2026, 12, 31, 0, 0)) |
| | | .status(1).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "工具导入模板.xls", "工具列表", MesTmToolImportExcelVO.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:tm-tool:import')") |
| | | public CommonResult<MesTmToolImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesTmToolImportExcelVO> list = ExcelUtils.read(file, MesTmToolImportExcelVO.class); |
| | | return success(toolService.importToolList(list, updateSupport)); |
| | | } |
| | | |
| | | @GetMapping("/simple-list") |
| | | @Operation(summary = "获得工具精简列表") |
| | | @PreAuthorize("@ss.hasPermission('mes:tm-tool:query')") |
| | | public CommonResult<List<MesTmToolRespVO>> getToolSimpleList() { |
| | | List<MesTmToolDO> list = toolService.getToolList(); |
| | | return success(BeanUtils.toBean(list, MesTmToolRespVO.class)); |