1
zhang
2 天以前 3fa7cdec6ce44f07a0dc7e1910511ead606990f3
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -137,6 +137,7 @@
            throw new BusinessException("Internal Server Error!");
        }
        Boolean locStaStatusCheck = configService.getVal("LOC_STA_STATUS_CHECK", Boolean.class, true);
        Integer locStaTaskNum = configService.getVal("LOC_STA_TASK_NUM", Integer.class, 2);
        // 保存任务
@@ -190,6 +191,11 @@
                        if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) {
                            throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status");
                        }
                    } else {
                        List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getDestSta, destSta.getId()).in(Task::getTaskSts, TaskStsType.INIT.val(), TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val()));
                        if (!Cools.isEmpty(list) && list.size() >= locStaTaskNum) {
                            throw new BusinessException("destSta:" + task.getDestSta$() + " task more");
                        }
                    }
                    destSta.setStaSts(StaStsType.READY_RELEASE.val());
                    destSta.setUpdateTime(now);
@@ -237,6 +243,11 @@
                    if (destSta.getStaTypeIsCheck() != 1) {
                        if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) {
                            throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status");
                        }
                    } else {
                        List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getDestSta, destSta.getId()).in(Task::getTaskSts, TaskStsType.INIT.val(), TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val()));
                        if (!Cools.isEmpty(list) && list.size() >= locStaTaskNum) {
                            throw new BusinessException("destSta:" + task.getDestSta$() + " task more");
                        }
                    }
                    destSta.setStaSts(StaStsType.READY_RELEASE.val());
@@ -1093,9 +1104,8 @@
                                ActionTypeType.ReadyTakeFromAgvSite.val(),    // 动作类型
                                actionPrepareSts,    // 动作进度
                                agvId,    // AGV
                                now,    // 工作时间
                                destSta.getStaTypeIsCheck() == 1 ? 2 : 0,
                                destSta.getStaNo()
                                now    // 工作时间
                        ));
                        // 计算货叉工作方向
                        staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection);
@@ -1112,7 +1122,9 @@
                                ActionTypeType.ReadyReleaseToConveyorSta.val(),    // 动作类型
                                actionPrepareSts,    // 动作进度
                                agvId,    // AGV
                                now    // 工作时间
                                now,    // 工作时间
                                destSta.getStaTypeIsCheck() == 1 ? 2 : 0,
                                destSta.getStaNo()
                        ));
                        break;
                    case TO_CHARGE:
@@ -1490,11 +1502,11 @@
//                    }
//                }
                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                for (Long taskId : taskIds) {
                    Task task = taskService.getById(taskId);
                    report(task, agv_11_up.getQrCode(), TaskReportStsType.END);
                }
//                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
//                for (Long taskId : taskIds) {
//                    Task task = taskService.getById(taskId);
//                    report(task, agv_11_up.getQrCode(), TaskReportStsType.END);
//                }
            }
            // 出库取货
@@ -1528,31 +1540,31 @@
//                        }
//                    }
//                }
                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                for (Long taskId : taskIds) {
                    Task task = taskService.getById(taskId);
                    report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN);
                }
//                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
//                for (Long taskId : taskIds) {
//                    Task task = taskService.getById(taskId);
//                    report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN);
//                }
            }
            //从输送线取货完成
            if (agv_11_up.getCompleteType().equals(AgvCompleteType.TAKE_FROM_STA_COMPLETE)) {
                WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode();
                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                for (Long taskId : taskIds) {
                    Task task = taskService.getById(taskId);
                    report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN);
                }
            }
//            if (agv_11_up.getCompleteType().equals(AgvCompleteType.TAKE_FROM_STA_COMPLETE)) {
//                WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode();
//                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
//                for (Long taskId : taskIds) {
//                    Task task = taskService.getById(taskId);
//                    report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN);
//                }
//            }
            //往输送线放货完成
            if (agv_11_up.getCompleteType().equals(AgvCompleteType.RELEASE_FROM_STA_COMPLETE)) {
                WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode();
                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                for (Long taskId : taskIds) {
                    Task task = taskService.getById(taskId);
                    report(task, agv_11_up.getQrCode(), TaskReportStsType.END);
                }
            }
//            if (agv_11_up.getCompleteType().equals(AgvCompleteType.RELEASE_FROM_STA_COMPLETE)) {
//                WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode();
//                List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
//                for (Long taskId : taskIds) {
//                    Task task = taskService.getById(taskId);
//                    report(task, agv_11_up.getQrCode(), TaskReportStsType.END);
//                }
//            }
            // 路径完成 || 充电完成
            if (agv_11_up.getCompleteType().equals(AgvCompleteType.ENTIRE_PATH_COMPLETE)
@@ -1592,6 +1604,8 @@
        // task
        for (Segment segment : segmentList) {
            boolean taskComplete = false;
            boolean otbin = false;
            Task task = taskService.getById(segment.getTaskId());
            assert null != task;
@@ -1602,6 +1616,7 @@
            switch (Objects.requireNonNull(posType)) {
                case ORI_STA:
                case ORI_LOC:
                    otbin = true;
                    break;
                case DEST_STA:
                case DEST_LOC:
@@ -1622,16 +1637,24 @@
                    break;
            }
            if (otbin) {
                locService.taskCallBackOtbin(task);
                report(task, null, TaskReportStsType.OTBIN);
            }
            if (taskComplete) {
                locService.taskCallBack(task);
                locService.taskCallBackEnd(task);
                task.setTaskSts(TaskStsType.COMPLETE.val());
                task.setEndTime(now);
                task.setUpdateTime(now);
                if (!taskService.updateById(task)) {
                    log.error("Task [{}] 更新失败 !!!", task.getSeqNum());
                } else {
                    report(task, null, TaskReportStsType.END);
                }
                report(task, null, TaskReportStsType.END);
                if (task.getSeqNum() != null && task.getSeqNum().contains("SSX-CK")) {
                    report(task, "1001", TaskReportStsType.COMPLETED);
                }
            }
        }
@@ -1675,11 +1698,12 @@
        }
        List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getSeqNum, task.getSeqNum()).eq(TaskReport::getBusNo, task.getBusId$()).eq(TaskReport::getTaskSts, taskReportStsType.status));
        if (!Cools.isEmpty(list)) {
            log.info("TaskReport [{}] 已重复,不再插入 ==========>> ", JSON.toJSONString(task));
            log.info("TaskReport [{},{}] 已重复,不再插入 ==========>> ", taskReportStsType, JSON.toJSONString(task));
            return;
        }
        TaskReport taskReport = new TaskReport();
        taskReport.setAgvId(task.getAgvId());
        taskReport.setAgvNo(task.getAgvId$());
        taskReport.setBusNo(task.getBusId$());
        taskReport.setCreateTime(new Date());
        taskReport.setCompleted(0);
@@ -1689,6 +1713,7 @@
        taskReport.setEventType(taskReportStsType.name);
        taskReport.setSeqNum(task.getSeqNum());
        taskReport.setZpallet(task.getZpallet());
        if (!taskReportService.save(taskReport)) {
            log.info("TaskReport [{}] 插入失败 ==========>> ", JSON.toJSONString(taskReport));
        } else {
@@ -1698,10 +1723,10 @@
    private boolean askSta(Integer askType, String askSta) {
        log.info("来询问输送线了,{},{}", askType, askSta);
        String wmsUrl = configService.getVal("WMS_URL", String.class);
        String wmsUrl = configService.getVal("WCS_URL", String.class);
        String wmsPath = configService.getVal("WMS_STA", String.class);
        if (Cools.isEmpty(wmsPath) || Cools.isEmpty(wmsUrl)) {
            return true;
            return false;
        }
        Integer time = configService.getVal("TIMEOUT", Integer.class, 5);
        //Integer times = configService.getVal("REPORT_TIMES", Integer.class, 2);