zjj
2 天以前 a4112a5d31fa3a66daafdc009ff3b3047bb98f67
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -390,14 +390,72 @@
            if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
                //1.入库
                complateInstock(task);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                //53.拣料再入库
                pickComplateInStock(task);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                //57.盘点再入库
                pickComplateInStock(task);
            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                //移库
                moveInStock(task);
            }
        }
    }
    @Transactional(rollbackFor = Exception.class)
    public void moveInStock(Task task) {
        if (Objects.isNull(task)) {
            return;
        }
        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()));
        if (Objects.isNull(loc)) {
            throw new CoolException("目标库位不存在!");
        }
        Loc orgLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));
        if (Objects.isNull(orgLoc)) {
            throw new CoolException("目标库位不存在!");
        }
        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
            throw new CoolException("当前库位状态不处于S.入库预约,不可执行入库操作!");
        }
        if (!orgLoc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
            throw new CoolException("当前库位状态不处于R.出库预约,不可执行入库操作!");
        }
        List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
        if (taskItems.isEmpty()) {
            throw new CoolException("任务明细不存在!!");
        }
        try {
            //更新库位明细
            saveLocItem(taskItems, task.getId());
        } catch (Exception e) {
            throw new CoolException("库位明细更新失败!!");
        }
//        /**对任务明细按组拖明细进行分组*/
//        try {
//            //保存库存明细
//            saveStockItems(taskItems, null, null, pakinItem.getWkType(), pakinItem.getType());
//        } catch (Exception e) {
//            log.error("<UNK>", e);
//            throw new CoolException(e.getMessage());
//        }
        /**修改库位状态为F.在库*/
        if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) {
            throw new CoolException("库位状态修改失败!!");
        }
        if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type).eq(Loc::getCode, task.getOrgLoc()))) {
            throw new CoolException("库位状态修改失败!!");
        }
        if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
            throw new CoolException("任务状态修改失败!!");
        }
    }
@@ -465,12 +523,17 @@
            if (Objects.isNull(locWorking)) {
                throw new CoolException("数据错误,作业中库存数据丢失!!");
            }
            if (locWorking.getAnfme().compareTo(taskItem.getAnfme()) >= 0) {
                locWorking.setAnfme(Math.round((locWorking.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0);
            if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                locWorking.setWorkQty(0.0);
                locWorking.setAnfme(taskItem.getAnfme());
            } else {
                continue;
                if (locWorking.getAnfme().compareTo(taskItem.getAnfme()) >= 0) {
                    locWorking.setWorkQty(0.0);
                    locWorking.setAnfme(Math.round((locWorking.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0);
                } else {
                    continue;
                }
            }
            BeanUtils.copyProperties(locWorking, locItem);
            locItem.setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null);
            items.add(locItem);
@@ -482,7 +545,7 @@
        TaskItem taskItem = taskItems.stream().findFirst().get();
        //保存入出库流水
        saveStockItems(taskItems, null, null, taskItem.getWkType(), taskItem.getOrderType());
        saveStockItems(taskItems, task, null, null, taskItem.getWkType(), taskItem.getOrderType());
        if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) {
@@ -717,6 +780,7 @@
        /**修改为库位状态为O.空库*/
        if (!locService.update(new LambdaUpdateWrapper<Loc>()
                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
                .set(Loc::getBarcode, null)
                .eq(Loc::getId, loc.getId()))) {
            throw new CoolException("库位状态修改失败!!");
        }
@@ -837,7 +901,7 @@
            List<TaskItem> items = orderMap.get(key);
            try {
                //保存库存明细
                saveStockItems(items, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType());
                saveStockItems(items, task,  pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType());
                //移出收货区库存, 修改组托状态
                removeReceiptStock(pakinItem);
            } catch (Exception e) {
@@ -901,6 +965,7 @@
        if (Objects.isNull(task)) {
            throw new CoolException("任务不存在!!");
        }
        List<LocItem> locItems = new ArrayList<>();
        items.forEach(taskItem -> {
            Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()), false);
@@ -924,7 +989,7 @@
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void saveStockItems(List<TaskItem> items, Long id, String code, Short wkType, String type) throws
    public void saveStockItems(List<TaskItem> items, Task task, Long id, String code, Short wkType, String type) throws
            Exception {
        Stock stock = new Stock();
        String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
@@ -937,7 +1002,17 @@
                .setSourceCode(code)
                .setAnfme(sum)
                .setWkType(wkType)
                .setBarcode(task.getBarcode())
                .setType(type);
        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) ||
                task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) ||
                task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type) ||
                task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type) ||
                task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) ) {
            stock.setLocCode(task.getTargLoc());
        } else {
            stock.setLocCode(task.getOrgLoc());
        }
        if (!stockService.save(stock)) {
            throw new CoolException("库存保存失败!!");
        }
@@ -949,6 +1024,7 @@
            BeanUtils.copyProperties(item, stockItem);
            stockItem.setSourceItemId(item.getOrderItemId())
                    .setStockCode(stock.getCode())
                    .setBarcode(task.getBarcode())
                    .setSourceItemId(item.getOrderItemId())
                    .setId(null)
                    .setStockId(stock.getId());