gaoluyang
昨天 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineServiceImpl.java
@@ -30,6 +30,7 @@
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;
/**
@@ -104,11 +105,15 @@
    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);
    }
@@ -171,8 +176,10 @@
    }
    @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
@@ -189,6 +196,7 @@
    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()) // 盘点数量
@@ -197,6 +205,15 @@
        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);
        }
    }
    /**
     * 计算盘点任务行状态
     *