| | |
| | | package cn.iocoder.yudao.module.mes.service.wm.salesnotice; |
| | | |
| | | import cn.iocoder.yudao.module.mes.api.mps.MesProMpsApi; |
| | | |
| | | import cn.iocoder.yudao.module.erp.api.sale.enums.ErpSaleOrderAuditStatus; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | |
| | | @Resource |
| | | private ErpSaleOrderApi saleOrderApi; |
| | | @Resource |
| | | private MesProMpsApi mpsApi; |
| | | @Resource |
| | | private MesMdAutoCodeRecordService autoCodeRecordService; |
| | | |
| | |
| | | throw exception(WM_SALES_NOTICE_SALE_ORDER_NOT_EXISTS); |
| | | } |
| | | |
| | | if (!Integer.valueOf(ErpSaleOrderAuditStatus.APPROVED).equals(saleOrder.getStatus())) { |
| | | throw exception(WM_SALES_NOTICE_SALE_ORDER_NOT_APPROVED); |
| | | } |
| | | |
| | | // 3. 获取销售订单明细 |
| | | List<ErpSaleOrderItemRespDTO> saleOrderItems = saleOrderApi.getSaleOrderItemList(saleOrderId).getCheckedData(); |
| | | if (CollUtil.isEmpty(saleOrderItems)) { |
| | | throw exception(WM_SALES_NOTICE_SALE_ORDER_ITEM_EMPTY); |
| | | } |
| | | |
| | | List<Long> productionItemIds = saleOrderItems.stream() |
| | | .filter(item -> Integer.valueOf(1).equals(item.getNeedProduction())) |
| | | .map(ErpSaleOrderItemRespDTO::getId).toList(); |
| | | if (!Boolean.TRUE.equals(mpsApi.checkCanCreateSalesNotice(productionItemIds))) { |
| | | throw exception(WM_SALES_NOTICE_PRODUCTION_NOT_READY); |
| | | } |
| | | // 4. 生成发货通知单编码 |
| | | String code = autoCodeRecordService.generateAutoCode(MesMdAutoCodeRuleCodeEnum.WM_SALES_NOTICE_CODE.getCode(), null); |
| | | |