1
4 天以前 ee536f9aedaf642d64ba2681778fd4e74731d00c
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -55,6 +55,74 @@
    /**
     * 库存出库生成出库任务
     * type: 空板出库
     *
     * @param resouce
     * @param map
     * @param loginUserId
     * @return
     */
    @Override
    @Synchronized
    @Transactional(rollbackFor = Exception.class)
    public synchronized void generateTaskEmpty(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
        if (Objects.isNull(map.getSiteNo())) {
            throw new CoolException("目标站点不能为空!");
        }
        if (Objects.isNull(map.getOrgLoc())) {
            throw new CoolException("源库位不能为空!");
        }
        String siteNo = map.getSiteNo();
        Task task = new Task();
        Loc loc = locService.getById(Long.decode(map.getOrgLoc()));
        logger.info("库位:>{}", loc.getCode());
        if (Objects.isNull(loc)) {
            throw new CoolException("数据错误:所选库存信息不存在!!");
        }
        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_D.type)) {
            throw new CoolException("库位:" + loc.getCode() + ",不处于D.空板状态,不可执行R.出库预约操作!!");
        }
        loc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
        if (!locService.updateById(loc)) {
            throw new CoolException("库位状态更新失败!!");
        }
        String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
        task.setOrgLoc(loc.getCode())
                .setTaskCode(ruleCode)
                .setResource(resouce)
                .setTargSite(siteNo)
                .setSort(Constants.TASK_SORT_DEFAULT_VALUE)
                .setUpdateBy(loginUserId)
                .setCreateBy(loginUserId)
                .setCreateTime(new Date())
                .setUpdateTime(new Date())
                .setTaskStatus(TaskStsType.GENERATE_OUT.id)
                .setBarcode(loc.getBarcode())
                .setMemo(map.getMemo());
        if (map.getType().equals(Constants.TASK_TYPE_OUT_STOCK_EMPTY)) {
                //空容器出库
                DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                        .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                        .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_EMPITY_OUT.type));
                if (Objects.isNull(deviceSite)) {
                    throw new CoolException("站点不支持空容器出库!!");
                }
                task.setTaskType(TaskType.TASK_TYPE_EMPITY_OUT.type).setWarehType(deviceSite.getDevice());
        } else {
            throw new CoolException("空容器出库!!其他类型无效,进入类型:"+map.getType());
        }
        if (!taskService.save(task)) {
            throw new CoolException("任务创建失败!!");
        }
    }
    /**
     * 库存出库生成出库任务
     * type: check 盘点, stock: 库存出库
     *
     * @param resouce
@@ -170,27 +238,27 @@
                throw new CoolException("任务创建失败!!");
            }
            if (!LocUtils.isShallowLoc(loc.getCode())) {
                //获取深库位对应浅库位
                String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
                Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
                if (Objects.isNull(one)) {
                    throw new CoolException("对应库位不存在!!");
                }
                Task workTask = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, one.getBarcode()));
                if (Objects.isNull(workTask)) {
                    map.setOrgLoc(one.getCode());
                    //优先生成移库任务
                    if (one.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
                        moveTask = genMoveTask(map, loginUserId);
                    }
                } else {
                    workTask.setSort(task.getSort() + 1).setParentId(task.getId());
                    if (!taskService.updateById(workTask)) {
                        throw new CoolException("优先级修改失败!!");
                    }
                }
            }
//            if (!LocUtils.isShallowLoc(loc.getCode())) {
//                //获取深库位对应浅库位
//                String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
//                Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
//                if (Objects.isNull(one)) {
//                    throw new CoolException("对应库位不存在!!");
//                }
//                Task workTask = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, one.getBarcode()));
//                if (Objects.isNull(workTask)) {
//                    map.setOrgLoc(one.getCode());
//                    //优先生成移库任务
//                    if (one.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
//                        moveTask = genMoveTask(map, loginUserId);
//                    }
//                } else {
//                    workTask.setSort(task.getSort() + 1).setParentId(task.getId());
//                    if (!taskService.updateById(workTask)) {
//                        throw new CoolException("优先级修改失败!!");
//                    }
//                }
//            }
            if (!Objects.isNull(moveTask.getId())) {
                moveTask.setParentId(task.getId()).setSort(moveTask.getSort() + 1);