skyouc
2 天以前 ceab656e93edafbdaa0d908a2f723336af811b5a
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
@@ -173,10 +173,10 @@
                }
                orderItems.forEach(orderItem -> {
                   orderItem.setOrderId(order.getId()).setOrderCode(order.getCode()).setId(null);
                   if (!asnOrderItemService.save(orderItem)) {
                       throw new CoolException("入库单明细保存失败!!");
                   }
                    orderItem.setOrderId(order.getId()).setOrderCode(order.getCode()).setId(null);
                    if (!asnOrderItemService.save(orderItem)) {
                        throw new CoolException("入库单明细保存失败!!");
                    }
                });
                Transfer transfer = transferService.getById(order.getPoId());
@@ -240,11 +240,11 @@
     * @throws Exception
     */
    @Scheduled(cron = "0/5 * * * * ?  ")
    @Transactional(rollbackFor = Exception.class)
    public void taskToWCS() throws Exception {
    public void taskToWCS() {
        Long loginUserId = SystemAuthUtils.getLoginUserId();
        List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_LOC_MOVE.type, TaskType.TASK_TYPE_EMPITY_IN.type
        ,TaskType.TASK_TYPE_CHECK_IN.type, TaskType.TASK_TYPE_MERGE_IN.type, TaskType.TASK_TYPE_EMPITY_OUT.type,
                , TaskType.TASK_TYPE_CHECK_IN.type, TaskType.TASK_TYPE_MERGE_IN.type, TaskType.TASK_TYPE_EMPITY_OUT.type,
                TaskType.TASK_TYPE_PICK_AGAIN_OUT.type, TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type);
        List<Integer> integers = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id);
        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>()
@@ -252,33 +252,37 @@
                .in(Task::getTaskStatus, integers)
                .orderByDesc(Task::getSort));
        for (Task task : tasks) {
            Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, task.getBarcode()));
            if (Objects.isNull(loc)) {
                continue;
            }
            //判断是否深库位
            if (!LocUtils.isShallowLoc(loc.getCode())) {
                //获取深库位对应的浅库位
                String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
                if (StringUtils.isBlank(shallowLoc)) {
                    continue;
                }
                Loc shalloc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
                if (Objects.isNull(shalloc) || !shalloc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
                    //如果浅库位不在库跳出循环
                    continue;
                }
                LocToTaskParams params = new LocToTaskParams();
                params.setOrgLoc(shallowLoc).setType(TaskType.TASK_TYPE_LOC_MOVE.type + "");
                //生成移库任务
                Task moveTask = locItemService.genMoveTask(params, loginUserId);
                moveTask.setSort(!Objects.isNull(task.getSort()) ? task.getSort() + 1 : Constants.TASK_SORT_DEFAULT_VALUE + 1);
                if (!taskService.updateById(moveTask)) {
                    throw new Exception("任务优先级更新失败!!");
                }
            }
//            Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, task.getBarcode()));
//            if (Objects.isNull(loc)) {
//                continue;
//            }
//            //判断是否深库位
//            if (!LocUtils.isShallowLoc(loc.getCode())) {
//                //获取深库位对应的浅库位
//                String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
//                if (StringUtils.isBlank(shallowLoc)) {
//                    continue;
//                }
//                Loc shalloc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
//                if (Objects.isNull(shalloc) || !shalloc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
//                    //如果浅库位不在库跳出循环
//                    continue;
//                }
//                LocToTaskParams params = new LocToTaskParams();
//                params.setOrgLoc(shallowLoc).setType(TaskType.TASK_TYPE_LOC_MOVE.type + "");
//                //生成移库任务
//                Task moveTask = locItemService.genMoveTask(params, loginUserId);
//                moveTask.setSort(!Objects.isNull(task.getSort()) ? task.getSort() + 1 : Constants.TASK_SORT_DEFAULT_VALUE + 1);
//                if (!taskService.updateById(moveTask)) {
//                    throw new Exception("任务优先级更新失败!!");
//                }
//            }
            //TODO 调用下发任务接口
            pubTaskToWcs(task);
            try {
                pubTaskToWcs(task);
            } catch (Exception e) {
                log.error(e.getMessage());
            }
        }
    }
@@ -307,10 +311,11 @@
    /**
     * 下发任务至WCS
     *
     * @param task
     */
    @Transactional(rollbackFor = Exception.class)
    public void pubTaskToWcs(Task task) throws Exception{
    public void pubTaskToWcs(Task task) {
        WcsTaskParams taskParams = new WcsTaskParams();
        TaskItemParam itemParam = new TaskItemParam();
        //任务类型,任务编码
@@ -321,20 +326,18 @@
        taskParams.setBatch(task.getBarcode());
        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type )
                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)
                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
            itemParam.setDestLoc(task.getTargLoc())
                    .setOriSta(task.getOrgSite());
        } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
            itemParam.setDestLoc(task.getTargLoc())
                    .setOriSta(task.getTargSite());
        } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
                || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
                || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
        ) {
                || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) {
            itemParam.setOriLoc(task.getOrgLoc())
                    .setDestSta(task.getTargSite());
@@ -352,7 +355,7 @@
        String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask;
        /**RCS基础配置链接*/
        log.info("任务下发,请求地址: {}, 请求参数: {}", pubTakUrl , JSONObject.toJSONString(taskParams));
        log.info("任务下发,请求地址: {}, 请求参数: {}", pubTakUrl, JSONObject.toJSONString(taskParams));
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        headers.add("api-version", "v2.0");
@@ -362,10 +365,10 @@
        if (Objects.isNull(exchange.getBody())) {
            throw new CoolException("任务下发失败!!");
        } else {
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.coercionConfigDefaults()
                    .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
            try {
                ObjectMapper objectMapper = new ObjectMapper();
                objectMapper.coercionConfigDefaults()
                        .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
                CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
                if (result.getCode() == 200) {
                    if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
@@ -378,13 +381,17 @@
                                .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_IN.id))) {
                            throw new CoolException("任务状态修改失败!!");
                        }
                    } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
                    } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
                            || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
                            || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
                            || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
                            || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
                    ) {
                        if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
                                .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_OUT.id))) {
                            throw new CoolException("任务状态修改失败!!");
                        }
                    }
                } else {
                    throw new CoolException("任务下发失败!!");
                }