| | |
| | | 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.pro.process.vo.MesProProcessImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService; |
| | | 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.Collections; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | ExcelUtils.write(response, "生产工序.xls", "数据", MesProProcessRespVO.class, data); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得生产工序导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesProProcessImportExcelVO> list = Collections.singletonList( |
| | | MesProProcessImportExcelVO.builder() |
| | | .code("PROCESS001").name("示例工序").type(1).attention("") |
| | | .status(0).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "生产工序导入模板.xls", "生产工序列表", MesProProcessImportExcelVO.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:pro-process:import')") |
| | | public CommonResult<MesProProcessImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesProProcessImportExcelVO> list = ExcelUtils.read(file, MesProProcessImportExcelVO.class); |
| | | return success(processService.importProcessList(list, updateSupport)); |
| | | } |
| | | |
| | | } |