| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductAuditReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.product.vo.MesPdProductSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.service.pd.product.MesPdProductService; |
| | | 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; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | ExcelUtils.write(response, "产品档案.xls", "数据", MesPdProductRespVO.class, pageResult.getList()); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得产品档案导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesPdProductImportExcelVO> list = Collections.singletonList( |
| | | MesPdProductImportExcelVO.builder() |
| | | .archiveType(1).name("示例产品").spec("").unit("") |
| | | .price(new java.math.BigDecimal("100.00")) |
| | | .status(1).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "产品档案导入模板.xls", "产品档案列表", MesPdProductImportExcelVO.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-product:import')") |
| | | public CommonResult<MesPdProductImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesPdProductImportExcelVO> list = ExcelUtils.read(file, MesPdProductImportExcelVO.class); |
| | | return success(productService.importProductList(list, updateSupport)); |
| | | } |
| | | |
| | | @PutMapping("/submit") |
| | | @Operation(summary = "提交审批(未提交/驳回→审批中)") |
| | | @Parameter(name = "id", description = "编号", required = true) |