#
vincentlu
1 天以前 60fda68af793008947c9b26950421a40363a73a2
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -20,10 +20,11 @@
import com.zy.acs.manager.common.exception.BusinessException;
import com.zy.acs.manager.core.domain.AgvBackpackDto;
import com.zy.acs.manager.core.domain.LaneDto;
import com.zy.acs.manager.core.domain.PathDto;
import com.zy.acs.manager.core.domain.TaskPosDto;
import com.zy.acs.manager.core.integrate.conveyor.ConveyorStationService;
import com.zy.acs.manager.core.service.astart.MapDataDispatcher;
import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam;
import com.zy.acs.manager.core.service.astart.MapDataDispatcher;
import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.*;
import com.zy.acs.manager.manager.service.*;
@@ -383,7 +384,7 @@
                            int idx = -1;
                            for (int i = 0; i < destPosList.size(); i++) {
                                if (Objects.equals(destPosList.get(i).getTaskId(), newDto.getTaskId())
                                 && Objects.equals(destPosList.get(i).getCodeId(), newDto.getCodeId())) {
                                        && Objects.equals(destPosList.get(i).getCodeId(), newDto.getCodeId())) {
                                    idx = i;
                                    break;
                                }
@@ -893,9 +894,10 @@
     * 根据分片生成动作 ( 车辆可能已经做过一些任务了,正在等待下一段任务 )
     */
    @Transactional
    public synchronized void generateAction(Long agvId, List<Segment> segmentList, List<String> pathList, Date algoStartTime) {
    public synchronized List<PathDto> generateAction(Long agvId, List<Segment> segmentList, List<String> pathList, Date algoStartTime) {
        List<PathDto> pathTrace = new ArrayList<>();
        try {
            if (Cools.isEmpty(agvId, segmentList)) { return; }
            if (Cools.isEmpty(agvId, segmentList)) { return pathTrace; }
            Date now = new Date();
            long actionPrepareSts = ActionStsType.PREPARE.val();
//            JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class);
@@ -924,6 +926,7 @@
            if (!lastCode.getData().equals(pathList.get(0))) {
                throw new CoolException("AGV[" + agvNo + "]定位偏移...");
            }
            pathTrace.add(new PathDto(lastCode.getData(), lastDirection, false));
            boolean first = true;
            for (Segment segment : segmentList) {
@@ -989,6 +992,7 @@
                                        now    // 工作时间
                                ));
                                lastDirection = nextLaneDir;
                                PathDto.markTurn(pathTrace, lastDirection);
                            }
                            if (nextDirection.equals(oppNextLaneDir)) {
@@ -1057,6 +1061,7 @@
                                        ));
                                        lastDirection = nextDirection;
                                        PathDto.markTurn(pathTrace, lastDirection);
                                    }
                                }
                            }
@@ -1082,6 +1087,7 @@
                            ));
                            lastDirection = nextDirection;
                            PathDto.markTurn(pathTrace, lastDirection);
                        }
                        // run
@@ -1104,6 +1110,7 @@
                        ));
                        lastCode = nextCode;
                        pathTrace.add(new PathDto(lastCode.getData(), lastDirection, false));
                    }
@@ -1149,6 +1156,7 @@
                        ));
                        lastDirection = firstTurnDir;
                        PathDto.markTurn(pathTrace, lastDirection);
                    }
                    first = false;
@@ -1239,7 +1247,7 @@
                                task.getBusId(),    // 总线
                                task.getId(),    // 任务
                                null,    // 动作号
                                 null,    // 优先级
                                null,    // 优先级
                                ActionTypeType.ReadyReleaseToShelvesLoc.desc,    // 名称
                                (double) actuatorDirectionType.val,    // 属性值
                                lastCode.getData(),    // 地面码
@@ -1253,9 +1261,9 @@
                    case ORI_STA:
                        // 站点取货
                        Sta oriSta = staService.getById(task.getOriSta());
                        Double angle = oriSta.getAngle() == null ? mapService.getStaAngle(oriSta, workDirection) : Double.valueOf(oriSta.getAngle());
                        Double oriStaWorkDirection = mapService.getStaAngle(oriSta);
                        // 检验方向
                        if (!lastDirection.equals(Double.valueOf(angle))) {
                        if (!lastDirection.equals(oriStaWorkDirection)) {
                            if (!lastCode.getCornerBool()) {
                                throw new CoolException(agvNo + "号小车方向错误,请推至转弯点手动调整");
                            }
@@ -1267,15 +1275,16 @@
                                    null,    // 动作号
                                    null,    // 优先级
                                    ActionTypeType.TurnCorner.desc,    // 名称
                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, angle).val,   // 属性值
                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, oriStaWorkDirection).val,   // 属性值
                                    lastCode.getData(),    // 地面码
                                    String.valueOf(angle),   // 动作参数
                                    String.valueOf(oriStaWorkDirection),   // 动作参数
                                    ActionTypeType.TurnCorner.val(),    // 动作类型
                                    actionPrepareSts,    // 动作进度
                                    agvId,    // AGV
                                    now    // 工作时间
                            ));
                            lastDirection = angle;
                            lastDirection = oriStaWorkDirection;
                            PathDto.markTurn(pathTrace, lastDirection);
                        }
                        // 计算货叉工作方向
                        actuatorDirectionType = ActuatorDirectionType.fromVal(oriSta.getActDir());
@@ -1318,9 +1327,9 @@
                    case DEST_STA:
                        // 站点放货
                        Sta destSta = staService.getById(task.getDestSta());
                        angle = destSta.getAngle() == null ? mapService.getStaAngle(destSta, workDirection) : Double.valueOf(destSta.getAngle());
                        Double destStaWorkDirection = mapService.getStaAngle(destSta);
                        // 检验方向
                        if (!lastDirection.equals(angle)) {
                        if (!lastDirection.equals(destStaWorkDirection)) {
                            if (!lastCode.getCornerBool()) {
                                throw new CoolException(agvNo + "号小车方向错误,请推至转弯点手动调整");
                            }
@@ -1332,15 +1341,16 @@
                                    null,    // 动作号
                                    null,    // 优先级
                                    ActionTypeType.TurnCorner.desc,    // 名称
                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, angle).val,    // 属性值
                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, destStaWorkDirection).val,    // 属性值
                                    lastCode.getData(),    // 地面码
                                    String.valueOf(angle),   // 动作参数
                                    String.valueOf(destStaWorkDirection),   // 动作参数
                                    ActionTypeType.TurnCorner.val(),    // 动作类型
                                    actionPrepareSts,    // 动作进度
                                    agvId,    // AGV
                                    now    // 工作时间
                            ));
                            lastDirection = angle;
                            lastDirection = destStaWorkDirection;
                            PathDto.markTurn(pathTrace, lastDirection);
                        }
                        // 背篓取货
                        if (backupAction) {
@@ -1401,6 +1411,7 @@
                                    now    // 工作时间
                            ));
                            lastDirection = chargeDirection;
                            PathDto.markTurn(pathTrace, lastDirection);
                        }
                        // charge
@@ -1555,6 +1566,7 @@
            }
            log.info("{}号Agv动作组装完成,指令数量:{}", agvNo, newActionList.size());
            return pathTrace;
        } catch (Exception e) {
            log.error("mainService.generateAction", e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -1610,8 +1622,9 @@
                    task.setUpdateTime(now);
                    if (!taskService.updateById(task)) {
                        throw new BusinessException(task.getSeqNum() + "任务更新失败");
                    }
                }
    }
}
            }
            AgvAction agvAction = new AgvAction(agvNo, actionGroupId);
@@ -1833,9 +1846,9 @@
                // segment list
                List<Segment> segmentList = segmentService.list(new LambdaQueryWrapper<Segment>()
                        .eq(Segment::getGroupId, serialNo)
                                .eq(Segment::getGroupId, serialNo)
//                        .eq(Segment::getState, SegmentStateType.RUNNING.toString())
                        .orderByAsc(Segment::getSerial)
                                .orderByAsc(Segment::getSerial)
                );
                // settlement