| | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_STOCK_TAKING_TASK_LINE_NOT_EXISTS; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_STOCK_TAKING_TASK_LINE_TASK_MISMATCH; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_STOCK_TAKING_TASK_NO_STOCK; |
| | | |
| | | /** |
| | |
| | | public void updateStockTakingTaskLine(MesWmStockTakingTaskLineSaveReqVO updateReqVO) { |
| | | // 1.1 校验盘点任务行存在 |
| | | MesWmStockTakingTaskLineDO line = validateStockTakingTaskLineExists(updateReqVO.getId()); |
| | | if (!Objects.equals(line.getTaskId(), updateReqVO.getTaskId())) { |
| | | throw exception(WM_STOCK_TAKING_TASK_LINE_TASK_MISMATCH); |
| | | } |
| | | // 1.2 校验盘点任务存在,并且处于【准备中】状态 |
| | | stockTakingTaskService.validateStockTakingTaskExistsAndPrepare(updateReqVO.getTaskId()); |
| | | stockTakingTaskService.validateStockTakingTaskExistsAndPrepare(line.getTaskId()); |
| | | |
| | | // 2. 更新盘点任务行 |
| | | MesWmStockTakingTaskLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmStockTakingTaskLineDO.class); |
| | | updateObj.setTaskId(line.getTaskId()); |
| | | stockTakingTaskLineMapper.updateById(updateObj); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public MesWmStockTakingTaskLineDO getStockTakingTaskLine(Long taskId, Long itemId, Long areaId) { |
| | | return stockTakingTaskLineMapper.selectByTaskIdAndItemIdAndAreaId(taskId, itemId, areaId); |
| | | public MesWmStockTakingTaskLineDO getStockTakingTaskLine(Long taskId, Long itemId, Long warehouseId, |
| | | Long locationId, Long areaId, Long batchId) { |
| | | return stockTakingTaskLineMapper.selectByStockDimensions(taskId, itemId, warehouseId, |
| | | locationId, areaId, batchId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public Long createStockTakingTaskLine(MesWmStockTakingTaskResultSaveReqVO createReqVO) { |
| | | MesWmStockTakingTaskLineDO line = new MesWmStockTakingTaskLineDO() |
| | | .setTaskId(createReqVO.getTaskId()).setItemId(createReqVO.getItemId()).setBatchId(createReqVO.getBatchId()) |
| | | .setBatchCode(createReqVO.getBatchCode()) |
| | | .setWarehouseId(createReqVO.getWarehouseId()).setLocationId(createReqVO.getLocationId()).setAreaId(createReqVO.getAreaId()) |
| | | .setQuantity(BigDecimal.ZERO) // 账面数量默认为 0 |
| | | .setTakingQuantity(createReqVO.getTakingQuantity()) // 盘点数量 |
| | |
| | | return line.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAutoGeneratedLine(Long lineId) { |
| | | MesWmStockTakingTaskLineDO line = validateStockTakingTaskLineExists(lineId); |
| | | if (line.getMaterialStockId() == null && line.getQuantity() != null |
| | | && line.getQuantity().compareTo(BigDecimal.ZERO) == 0) { |
| | | stockTakingTaskLineMapper.deleteById(lineId); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 计算盘点任务行状态 |
| | | * |