| | |
| | | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| | | 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.pd.processparamtemplate.vo.MesPdProcessParamTemplateImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.processparamtemplate.vo.MesPdProcessParamTemplateImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.processparamtemplate.vo.MesPdProcessParamTemplatePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.processparamtemplate.vo.MesPdProcessParamTemplateRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.processparamtemplate.vo.MesPdProcessParamTemplateSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.pd.processparamtemplate.MesPdProcessParamTemplateService; |
| | | 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 java.io.IOException; |
| | | import java.util.*; |
| | |
| | | buildTemplateRespVOList(list)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得工艺参数模板导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesPdProcessParamTemplateImportExcelVO> list = Collections.singletonList( |
| | | MesPdProcessParamTemplateImportExcelVO.builder() |
| | | .templateName("示例模板").templateType(1).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "工艺参数模板导入模板.xls", "工艺参数模板列表", |
| | | MesPdProcessParamTemplateImportExcelVO.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:pd-process-param-template:import')") |
| | | public CommonResult<MesPdProcessParamTemplateImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesPdProcessParamTemplateImportExcelVO> list = ExcelUtils.read(file, MesPdProcessParamTemplateImportExcelVO.class); |
| | | return success(templateService.importProcessParamTemplateList(list, updateSupport)); |
| | | } |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | private MesPdProcessParamTemplateRespVO buildTemplateRespVO(MesPdProcessParamTemplateDO template) { |