| | |
| | | public class MesWmArrivalNoticeServiceImpl implements MesWmArrivalNoticeService { |
| | | |
| | | @Resource |
| | | private cn.iocoder.yudao.module.mes.service.qc.ncr.MesQcArrivalDispositionService arrivalDispositionService; |
| | | |
| | | @Resource |
| | | private MesWmArrivalNoticeMapper arrivalNoticeMapper; |
| | | |
| | | @Resource |
| | |
| | | |
| | | // 插入 |
| | | MesWmArrivalNoticeDO notice = BeanUtils.toBean(createReqVO, MesWmArrivalNoticeDO.class); |
| | | fillContractNoFromPurchaseOrder(notice); |
| | | notice.setStatus(MesWmArrivalNoticeStatusEnum.PREPARE.getStatus()); |
| | | arrivalNoticeMapper.insert(notice); |
| | | return notice.getId(); |
| | |
| | | |
| | | // 更新 |
| | | MesWmArrivalNoticeDO updateObj = BeanUtils.toBean(updateReqVO, MesWmArrivalNoticeDO.class); |
| | | fillContractNoFromPurchaseOrder(updateObj); |
| | | arrivalNoticeMapper.updateById(updateObj); |
| | | } |
| | | |
| | | /** |
| | | * 采购合同号未显式传入时,从关联的采购订单带入(换货到货必须能追溯到原采购合同) |
| | | */ |
| | | private void fillContractNoFromPurchaseOrder(MesWmArrivalNoticeDO notice) { |
| | | if (notice.getPurchaseOrderId() == null || cn.hutool.core.util.StrUtil.isNotBlank(notice.getContractNo())) { |
| | | return; |
| | | } |
| | | ErpPurchaseOrderRespDTO purchaseOrder = purchaseOrderApi.getPurchaseOrder(notice.getPurchaseOrderId()).getCheckedData(); |
| | | if (purchaseOrder != null) { |
| | | notice.setContractNo(purchaseOrder.getContractNo()); |
| | | } |
| | | } |
| | | |
| | | private void validateArrivalNoticeSaveData(MesWmArrivalNoticeSaveReqVO reqVO) { |
| | |
| | | // 2. 更新到货通知单行:绑定 iqcId + 质检结果 + 合格数量 |
| | | arrivalNoticeLineService.updateArrivalNoticeLineWhenIqcFinish(lineId, iqcId, checkResult, qualifiedQuantity); |
| | | |
| | | // 3.1 判断是否所有需检行都已完成质检 |
| | | List<MesWmArrivalNoticeLineDO> lines = arrivalNoticeLineService.getArrivalNoticeLineListByNoticeId(id); |
| | | boolean hasUnchecked = CollectionUtils.anyMatch(lines, |
| | | line -> Boolean.TRUE.equals(line.getIqcCheckFlag()) && line.getIqcCheckResult() == null); |
| | | if (hasUnchecked) { |
| | | log.info("[updateArrivalNoticeWhenIqcFinish][到货通知单({}) 还有未完成检验的行,暂不更新状态]", id); |
| | | return; |
| | | } |
| | | |
| | | // 3.2 判断是否所有需检行都可以入库(合格或特采) |
| | | boolean hasNonInbound = CollectionUtils.anyMatch(lines, |
| | | line -> Boolean.TRUE.equals(line.getIqcCheckFlag()) |
| | | && !MesQcCheckResultEnum.canInbound(line.getIqcCheckResult())); |
| | | if (hasNonInbound) { |
| | | log.info("[updateArrivalNoticeWhenIqcFinish][到货通知单({}) 存在不可入库的行(退货/报废),状态保持待质检]", id); |
| | | return; |
| | | } |
| | | |
| | | // 3.3 所有行检验完成且可入库,更新主表状态 PENDING_QC → PENDING_RECEIPT |
| | | arrivalNoticeMapper.updateById(new MesWmArrivalNoticeDO() |
| | | .setId(id).setStatus(MesWmArrivalNoticeStatusEnum.PENDING_RECEIPT.getStatus())); |
| | | // 同时认可仓库已确认的来料退货;保留原始不合格结论。 |
| | | arrivalDispositionService.refresh(id); |
| | | } |
| | | |
| | | @Override |
| | |
| | | notice.setName(purchaseOrder.getNo() + "到货通知"); |
| | | notice.setPurchaseOrderId(purchaseOrderId); |
| | | notice.setPurchaseOrderCode(purchaseOrder.getNo()); |
| | | notice.setContractNo(purchaseOrder.getContractNo()); |
| | | notice.setVendorId(purchaseOrder.getSupplierId()); |
| | | notice.setArrivalDate(java.time.LocalDateTime.now()); // 到货时间为当前时间 |
| | | notice.setStatus(MesWmArrivalNoticeStatusEnum.PENDING_RECEIPT.getStatus()); |
| | |
| | | notice.setName(returnVendor.getCode() + "换货到货"); |
| | | notice.setPurchaseOrderId(returnVendor.getPurchaseOrderId()); |
| | | notice.setPurchaseOrderCode(returnVendor.getPurchaseOrderCode()); |
| | | // 换货重新关联原采购合同号:优先取退货单快照,退货单未快照时回填采购订单合同号 |
| | | notice.setContractNo(returnVendor.getContractNo()); |
| | | fillContractNoFromPurchaseOrder(notice); |
| | | notice.setVendorId(returnVendor.getVendorId()); |
| | | notice.setArrivalDate(java.time.LocalDateTime.now()); |
| | | notice.setStatus(MesWmArrivalNoticeStatusEnum.PENDING_QC.getStatus()); |