| | |
| | | import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.stocktaking.plan.MesWmStockTakingPlanParamService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | private MesWmMaterialStockService materialStockService; |
| | | @Resource |
| | | private MesWmStockTakingTaskService stockTakingTaskService; |
| | | // 与 ResultService 相互引用(ResultServiceImpl 已注入 LineService),须用 @Lazy 打破循环 |
| | | @Lazy |
| | | @Resource |
| | | private MesWmStockTakingTaskResultService stockTakingTaskResultService; |
| | | @Resource |
| | | private cn.iocoder.yudao.module.mdm.api.item.MdmItemApi mdmItemApi; |
| | | |
| | |
| | | // 3. 批量生成明细行 |
| | | List<MesWmStockTakingTaskLineDO> lines = convertList(stocks, stock -> MesWmStockTakingTaskLineDO.builder() |
| | | .taskId(task.getId()).materialStockId(stock.getId()).itemId(stock.getItemId()) |
| | | .batchId(stock.getBatchId()).quantity(stock.getQuantity()).takingQuantity(BigDecimal.ZERO) |
| | | .batchId(stock.getBatchId()).batchCode(stock.getBatchCode()) |
| | | .quantity(stock.getQuantity()).takingQuantity(BigDecimal.ZERO) |
| | | .warehouseId(stock.getWarehouseId()).locationId(stock.getLocationId()).areaId(stock.getAreaId()) |
| | | .status(MesWmStockTakingTaskLineStatusEnum.LOSS.getStatus()).build()); |
| | | stockTakingTaskLineMapper.insertBatch(lines); |
| | |
| | | if (CollUtil.isEmpty(list)) { |
| | | return respVO; |
| | | } |
| | | // 0. 校验盘点任务处于盘点中状态(与人工录入盘点结果口径一致,仅盘点中可导入) |
| | | stockTakingTaskService.validateStockTakingTaskExistsAndApproving(taskId); |
| | | // 1. 获取盘点任务行 |
| | | List<MesWmStockTakingTaskLineDO> lines = stockTakingTaskLineMapper.selectListByTaskId(taskId); |
| | | if (CollUtil.isEmpty(lines)) { |
| | |
| | | continue; |
| | | } |
| | | updateStockTakingTaskLineTakingQuantity(matched.getId(), row.getTakingQuantity()); |
| | | // 同步写盘点结果,保证差异核销来源(task_result)一致 |
| | | stockTakingTaskResultService.upsertResultForImport(matched, row.getTakingQuantity()); |
| | | respVO.setSuccessCount(respVO.getSuccessCount() + 1); |
| | | } |
| | | return respVO; |