| | |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService; |
| | | 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; |
| | |
| | | |
| | | @PostMapping("/generate-from-sale-order") |
| | | @Operation(summary = "从销售订单生成发货通知单") |
| | | @Parameter(name = "saleOrderId", description = "销售订单ID", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:create')") |
| | | public CommonResult<Long> generateFromSaleOrder(@RequestParam("saleOrderId") Long saleOrderId) { |
| | | public CommonResult<Long> generateFromSaleOrder(@RequestBody Map<String, Long> params) { |
| | | Long saleOrderId = params.get("saleOrderId"); |
| | | return success(salesNoticeService.generateSalesNoticeFromSaleOrder(saleOrderId)); |
| | | } |
| | | |
| | | @PostMapping("/generate-product-sales") |
| | | @Operation(summary = "从发货通知单生成销售出库单") |
| | | @Parameter(name = "id", description = "发货通知单编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:create')") |
| | | public CommonResult<Long> generateProductSales(@RequestParam("id") Long id) { |
| | | return success(salesNoticeService.generateProductSalesFromNotice(id)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得发货通知单导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesWmSalesNoticeImportExcelVO> list = Collections.singletonList( |
| | | MesWmSalesNoticeImportExcelVO.builder() |
| | | .code("SN001").name("示例发货通知单").saleOrderCode("SO001") |
| | | .salesDate(java.time.LocalDateTime.now()).recipientName("") |
| | | .remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "发货通知单导入模板.xls", "发货通知单列表", MesWmSalesNoticeImportExcelVO.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:wm-sales-notice:import')") |
| | | public CommonResult<MesWmSalesNoticeImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesWmSalesNoticeImportExcelVO> list = ExcelUtils.read(file, MesWmSalesNoticeImportExcelVO.class); |
| | | return success(salesNoticeService.importSalesNoticeList(list, updateSupport)); |
| | | } |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | private List<MesWmSalesNoticeRespVO> buildRespVOList(List<MesWmSalesNoticeDO> list) { |