| | |
| | | import com.zy.acs.common.utils.GsonUtils; |
| | | import com.zy.acs.common.utils.Utils; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.core.utils.HttpHandler; |
| | | import com.zy.acs.manager.manager.controller.param.LocSiteParams; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.manager.service.impl.LocStsServiceImpl; |
| | | import com.zy.acs.manager.manager.service.impl.WebsocketServiceImpl; |
| | | import com.zy.acs.manager.manager.utils.ActionSorter; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | |
| | | private TaskReportService taskReportService; |
| | | @Autowired |
| | | private AgvDurationService agvDurationService; |
| | | @Autowired |
| | | private LocStsService locStsService; |
| | | |
| | | @SuppressWarnings("all") |
| | | @Transactional |
| | |
| | | } |
| | | Boolean locStaStatusCheck = configService.getVal("LOC_STA_STATUS_CHECK", Boolean.class, true); |
| | | Integer locStaTaskNum = configService.getVal("LOC_STA_TASK_NUM", Integer.class, 2); |
| | | |
| | | |
| | | // 保存任务 |
| | | for (Task task : taskList) { |
| | |
| | | |
| | | boolean first = true; |
| | | for (Segment segment : segmentList) { |
| | | |
| | | // 分段所属的Task |
| | | Task task = taskService.getById(segment.getTaskId()); |
| | | |
| | | TaskPosDto.PosType posType = Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())); |
| | | // 目标是否为站点 |
| | | boolean isStation = posType == TaskPosDto.PosType.ORI_STA || posType == TaskPosDto.PosType.DEST_STA; |
| | | // 目标是否为库位 |
| | | boolean isLoc = posType == TaskPosDto.PosType.ORI_LOC || posType == TaskPosDto.PosType.DEST_LOC; |
| | | // 站点地码 |
| | | List<String> turnCodes = Arrays.asList("00000050", "00000051", "00000052", "00000053", "00000054"); |
| | | // 库位地码 |
| | | List<String> locTurnCodes = Arrays.asList("00000080", "00000081", "00000082", "00000083", "00000084"); |
| | | // 节点条码 |
| | | Code code = codeService.getCacheById(segment.getEndNode()); |
| | | |
| | | // 需要走行 |
| | | if (!lastCode.getData().equals(code.getData())) { |
| | | |
| | | // 走行路径节点 |
| | | // List<String> pathList = mapService.checkoutPath(agv.getUuid(), lastCode, code); |
| | | List<String> pathListPart = pathList.subList(pathList.indexOf(lastCode.getData()), pathList.indexOf(code.getData()) + 1); |
| | | |
| | | for (int i = 0; i < pathListPart.size(); i++) { |
| | | if (i == 0) { |
| | | continue; |
| | | } |
| | | |
| | | String next = pathListPart.get(i); |
| | | |
| | | Code nextCode = codeService.getCacheByData(next); |
| | | Double nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal); |
| | | |
| | | // 第一步:如果下一个方向正好是作业方向的相反方向,则重置下一个方向为作业方向,标记 reverse = true |
| | | boolean reverse = false; |
| | | if (nextDirection.equals((workDirection + 180) % 360)) { |
| | | List<String> list = Arrays.asList("00000051", "00000052", "00000053", "00000054"); |
| | | if ((Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())).equals(TaskPosDto.PosType.ORI_STA) |
| | | || Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())) |
| | | .equals(TaskPosDto.PosType.DEST_STA)) && list.contains(lastCode.getData())) { |
| | | if ((isStation && turnCodes.contains(lastCode.getData())) || (isLoc && locTurnCodes.contains(nextCode.getData()) && locTurnCodes.contains(lastCode.getData()))) { |
| | | reverse = false; |
| | | lastDirection = nextDirection; |
| | | } else { |
| | | nextDirection = workDirection; |
| | | reverse = true; |
| | |
| | | nextDirection = lastDirection; |
| | | reverse = true; |
| | | } else { |
| | | if ((Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())) |
| | | .equals(TaskPosDto.PosType.ORI_STA) || Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())) |
| | | .equals(TaskPosDto.PosType.DEST_STA)) && lastCode.getData().equals("00000050")) { |
| | | if ((isStation && lastCode.getData().equals("00000050")) || (isLoc && locTurnCodes.contains(nextCode.getData()) && lastCode.getData().equals("00000080"))) { |
| | | // turn |
| | | reverse = false; |
| | | |
| | | actionList.add(new Action( |
| | | null, // 编号s |
| | | task.getBusId(), // 总线 |
| | |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | log.info("1TurnCorner posType={}, code={}, corner={}, nextDirection={}, finalAngle={}", |
| | | posType, |
| | | lastCode.getData(), |
| | | lastCode.getCornerBool(), |
| | | nextDirection, |
| | | 180); |
| | | } else { |
| | | Double turnDirection = nextDirection; |
| | | if (turnCodes.contains(nextCode.getData()) && lastCode.getData().equals("00000050") || (isLoc && locTurnCodes.contains(nextCode.getData()) && lastCode.getData().equals("00000080"))) { |
| | | turnDirection = 180.0; |
| | | reverse = false; |
| | | } |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号s |
| | |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(nextDirection), // 动作参数 |
| | | String.valueOf(turnDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | log.info("2TurnCorner posType={}, code={}, corner={}, nextDirection={}, finalAngle={}", |
| | | posType, |
| | | lastCode.getData(), |
| | | lastCode.getCornerBool(), |
| | | nextDirection, |
| | | nextDirection); |
| | | } |
| | | |
| | | lastDirection = nextDirection; |
| | | } |
| | | } else { |
| | | if ((Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())) |
| | | .equals(TaskPosDto.PosType.ORI_STA) || Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())) |
| | | .equals(TaskPosDto.PosType.DEST_STA)) && lastCode.getData().equals("00000050")) { |
| | | if ((isStation && lastCode.getData().equals("00000050")) || (isLoc && locTurnCodes.contains(nextCode.getData()) && lastCode.getData().equals("00000080"))) { |
| | | // turn |
| | | reverse = false; |
| | | |
| | | actionList.add(new Action( |
| | | null, // 编号s |
| | | task.getBusId(), // 总线 |
| | |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | |
| | | log.info("3TurnCorner posType={}, code={}, corner={}, nextDirection={}, finalAngle={}", |
| | | posType, |
| | | lastCode.getData(), |
| | | lastCode.getCornerBool(), |
| | | nextDirection, |
| | | 180); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 第一个动作一定是 turn |
| | | if (actionList.isEmpty()) { |
| | | if (actionList.isEmpty() && lastCode.getCornerBool()) { |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | log.info("4TurnCorner posType={}, code={}, corner={}, nextDirection={}, finalAngle={}", |
| | | posType, |
| | | lastCode.getData(), |
| | | lastCode.getCornerBool(), |
| | | nextDirection, |
| | | nextDirection); |
| | | |
| | | lastDirection = nextDirection; |
| | | } |
| | |
| | | lastCode = nextCode; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | // 初始方向值补丁 |
| | | if (first) { |
| | | if (Cools.isEmpty(actionList) || !actionList.get(0).getActionType().equals(ActionTypeType.TurnCorner.val())) { |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(workDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | |
| | | lastDirection = workDirection; |
| | | |
| | | Double turnDirection = workDirection; |
| | | Code nextCode = null; |
| | | //添加判断是否存在下一个地码 |
| | | int index = pathList.indexOf(lastCode.getData()); |
| | | if (index != -1 && index + 1 < pathList.size()) { |
| | | String nextCodeData = pathList.get(index + 1); |
| | | nextCode = codeService.getCacheByData(nextCodeData); |
| | | } else { |
| | | nextCode = codeService.getCacheByData(lastCode.getData()); |
| | | } |
| | | if ((isStation && turnCodes.contains(lastCode.getData())) || (isLoc && locTurnCodes.contains(nextCode.getData()) && lastCode.getData().equals("00000080"))) { |
| | | turnDirection = workDirection + 180.0; |
| | | } |
| | | if (lastCode.getCornerBool()) { |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(turnDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | log.info("5TurnCorner posType={}, code={}, corner={}, nextDirection={}, finalAngle={}", |
| | | posType, |
| | | lastCode.getData(), |
| | | lastCode.getCornerBool(), |
| | | null, |
| | | turnDirection); |
| | | lastDirection = workDirection; |
| | | } |
| | | } |
| | | first = false; |
| | | } |
| | |
| | | assert backpackType != null; |
| | | // 检验方向 |
| | | if (!lastDirection.equals(workDirection)) { |
| | | throw new CoolException(agvNo + "号小车方向错误,请推至转弯点手动调整"); |
| | | lastDirection = workDirection; |
| | | // throw new CoolException(agvNo agvNo+ "号小车方向错误,请推至转弯点手动调整"); |
| | | } |
| | | // 货架取货 |
| | | Loc oriLoc = locService.getById(task.getOriLoc()); |
| | |
| | | assert backpackType != null; |
| | | // 检验方向 |
| | | if (!lastDirection.equals(workDirection)) { |
| | | throw new CoolException(agvNo + "号小车方向错误,请推至转弯点手动调整"); |
| | | lastDirection = workDirection; |
| | | // throw new CoolException(agvNo + "号小车方向错误,请推至转弯点手动调整"); |
| | | } |
| | | // 暂存点取货货 |
| | | actionList.add(new Action( |
| | |
| | | // 检验方向 |
| | | FuncSta chargeFuncSta = funcStaService.query(lastCode.getId(), FuncStaType.CHARGE.toString()); |
| | | Double chargeDirection = Double.parseDouble(chargeFuncSta.getAngle()); |
| | | if (!lastDirection.equals(chargeDirection)&&lastCode.getCornerBool()) { |
| | | if (!lastDirection.equals(chargeDirection) && lastCode.getCornerBool()) { |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | null, // 总线 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据分片生成动作 ( 车辆可能已经做过一些任务了,正在等待下一段任务 ) |
| | | */ |
| | | @Transactional |
| | | public synchronized void generateActionV2(Long agvId, List<Segment> segmentList, List<String> pathList, Date algoStartTime) { |
| | | public synchronized void generateActionV2(Long agvId, List<Segment> segmentList, List<String> pathList, |
| | | Date algoStartTime) { |
| | | try { |
| | | if (Cools.isEmpty(agvId, segmentList)) { |
| | | return; |
| | | } |
| | | Date now = new Date(); |
| | | long actionPrepareSts = ActionStsType.PREPARE.val(); |
| | | // JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class); |
| | | // JSONObject storeDirection = configService.getVal("storeDirection", |
| | | // JSONObject.class); |
| | | int angleOffsetVal = configService.getVal("mapAngleOffsetVal", Integer.class); |
| | | String agvNo = agvService.getAgvNo(agvId); |
| | | // if (!agvService.judgeEnable(agvId)) { |
| | | // throw new CoolException("AGV[" + agvNo + "]当前不可用..."); |
| | | // } |
| | | // if (!agvService.judgeEnable(agvId)) { |
| | | // throw new CoolException("AGV[" + agvNo + "]当前不可用..."); |
| | | // } |
| | | |
| | | AgvModel agvModel = agvModelService.getByAgvId(agvId); |
| | | Double workDirection = agvModel.getWorkDirection(); |
| | |
| | | nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal); |
| | | |
| | | // 第一步:如果下一个方向正好是作业方向的相反方向,则重置下一个方向为作业方向,标记 reverse = true |
| | | if (!nextDirection.equals((workDirection+180) % 360)) { |
| | | if (!nextDirection.equals((workDirection + 180) % 360)) { |
| | | nextDirection = workDirection; |
| | | reverse = true; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 第一个动作一定是 turn |
| | | if (actionList.isEmpty()) { |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(nextDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(nextDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | |
| | | lastDirection = nextDirection; |
| | |
| | | } |
| | | CodeGap gap = codeGapService.findByCodeOfBoth(lastCode.getId(), nextCode.getId()); |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | actionType.desc, // 名称 |
| | | (double) agvSpeedType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(gap.getDistance()), // 动作参数 |
| | | actionType.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | actionType.desc, // 名称 |
| | | (double) agvSpeedType.val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(gap.getDistance()), // 动作参数 |
| | | actionType.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | |
| | | lastCode = nextCode; |
| | |
| | | |
| | | // 初始方向值补丁 |
| | | if (first) { |
| | | if (Cools.isEmpty(actionList) || !actionList.get(0).getActionType().equals(ActionTypeType.TurnCorner.val())) { |
| | | if (Cools.isEmpty(actionList) |
| | | || !actionList.get(0).getActionType().equals(ActionTypeType.TurnCorner.val())) { |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(workDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(workDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | |
| | | lastDirection = workDirection; |
| | |
| | | } |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(destStaWorkDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(destStaWorkDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | lastDirection = destStaWorkDirection; |
| | | } |
| | | // 暂存点取货 |
| | | assert backpackType != null; |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyTakeFromAgvSite.desc, // 名称 |
| | | (double) backpackType.lev, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(backpackType.height), // 动作参数 |
| | | ActionTypeType.ReadyTakeFromAgvSite.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyTakeFromAgvSite.desc, // 名称 |
| | | (double) backpackType.lev, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(backpackType.height), // 动作参数 |
| | | ActionTypeType.ReadyTakeFromAgvSite.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | |
| | | )); |
| | | // 计算货叉工作方向 |
| | | staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection); |
| | | staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, |
| | | lastDirection); |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyReleaseToConveyorSta.desc, // 名称 |
| | | staWorkDirection, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(destSta.getOffset()), // 动作参数 |
| | | ActionTypeType.ReadyReleaseToConveyorSta.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now, // 工作时间 |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.ReadyReleaseToConveyorSta.desc, // 名称 |
| | | staWorkDirection, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(destSta.getOffset()), // 动作参数 |
| | | ActionTypeType.ReadyReleaseToConveyorSta.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now, // 工作时间 |
| | | destSta.getStaTypeIsCheck() == 1 ? 2 : 0, |
| | | destSta.getStaNo() |
| | | )); |
| | | destSta.getStaNo())); |
| | | break; |
| | | case TO_CHARGE: |
| | | // 检验方向 |
| | |
| | | Double chargeDirection = Double.parseDouble(chargeFuncSta.getAngle()); |
| | | if (!lastDirection.equals(chargeDirection) && lastCode.getCornerBool()) { |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | null, // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(chargeDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | null, // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(chargeDirection), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | lastDirection = chargeDirection; |
| | | } |
| | | |
| | | // charge |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | null, // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.DockingCharge.desc, // 名称 |
| | | null, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | null, // 动作参数 |
| | | ActionTypeType.DockingCharge.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | null, // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.DockingCharge.desc, // 名称 |
| | | null, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | null, // 动作参数 |
| | | ActionTypeType.DockingCharge.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | break; |
| | | case TO_STANDBY: |
| | | // FuncSta standByFuncSta = funcStaService.query(agvId, lastCode.getId(), 2); |
| | | // Double standByDirection = Double.parseDouble(standByFuncSta.getAngle()); |
| | | // if (!lastDirection.equals(standByDirection)) { |
| | | // actionList.add(new Action( |
| | | // null, // 编号 |
| | | // null, // 总线 |
| | | // task.getId(), // 任务 |
| | | // null, // 动作号 |
| | | // null, // 优先级 |
| | | // ActionTypeType.TurnCorner.desc, // 名称 |
| | | // null, // 属性값 |
| | | // lastCode.getData(), // 地面码 |
| | | // String.valueOf(standByDirection), // 动作参数 |
| | | // ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | // actionPrepareSts, // 动作进度 |
| | | // agvId, // AGV |
| | | // now // 工作时间 |
| | | // )); |
| | | // lastDirection = standByDirection; |
| | | // } |
| | | // FuncSta standByFuncSta = funcStaService.query(agvId, lastCode.getId(), 2); |
| | | // Double standByDirection = Double.parseDouble(standByFuncSta.getAngle()); |
| | | // if (!lastDirection.equals(standByDirection)) { |
| | | // actionList.add(new Action( |
| | | // null, // 编号 |
| | | // null, // 总线 |
| | | // task.getId(), // 任务 |
| | | // null, // 动作号 |
| | | // null, // 优先级 |
| | | // ActionTypeType.TurnCorner.desc, // 名称 |
| | | // null, // 属性값 |
| | | // lastCode.getData(), // 地面码 |
| | | // String.valueOf(standByDirection), // 动作参数 |
| | | // ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | // actionPrepareSts, // 动作进度 |
| | | // agvId, // AGV |
| | | // now // 工作时间 |
| | | // )); |
| | | // lastDirection = standByDirection; |
| | | // } |
| | | String runToWaitHeightFlag = configService.getVal("RunToWaitHeightFlag", String.class); |
| | | if (!Cools.isEmpty(runToWaitHeightFlag) && runToWaitHeightFlag.contains(agvId.toString())) { |
| | | String runToWaitHeight = configService.getVal("RunToWaitHeight", String.class); |
| | |
| | | throw new BusinessException("AGV定位信息异常,无法生成待机动作"); |
| | | } |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.RunToWaitHeight.desc, // 名称 |
| | | runToWaitHeightValue, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | runToWaitHeight, // 动作参数 |
| | | ActionTypeType.RunToWaitHeight.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | null, // 编号 |
| | | task.getBusId(), // 总线 |
| | | task.getId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.RunToWaitHeight.desc, // 名称 |
| | | runToWaitHeightValue, // 属性값 |
| | | lastCode.getData(), // 地面码 |
| | | runToWaitHeight, // 动作参数 |
| | | ActionTypeType.RunToWaitHeight.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | } |
| | | break; |
| | |
| | | if (agv_11_up.getCompleteType().equals(AgvCompleteType.RELEASE_FROM_SHELVES_COMPLETE)) { |
| | | WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); |
| | | |
| | | // Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | // if (null == loc) { |
| | | // log.warn("Agv [{}] 上报往货架放货完成时,库位码[{}]无效。", protocol.getAgvNo(), agv_11_up.getLocCode()); |
| | | // } else { |
| | | // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | // for (Long taskId : taskIds) { |
| | | // Task task = taskService.getById(taskId); |
| | | // if (task.getDestLoc().equals(loc.getId())) { |
| | | // |
| | | // Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | // .eq(Action::getTaskId, task.getId()) |
| | | // .eq(Action::getActionType, ActionTypeType.ReadyReleaseToShelvesLoc.val()) |
| | | // .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | // ); |
| | | // |
| | | // if (null != action) { |
| | | // action.setActionSts(ActionStsType.FINISH.val()); |
| | | // action.setEndTime(now); |
| | | // action.setUpdateTime(now); |
| | | // if (!actionService.updateById(action)) { |
| | | // log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName()); |
| | | // } |
| | | // } |
| | | // //插入一条 |
| | | // report(task, TaskReportStsType.END); |
| | | // } |
| | | // } |
| | | // } |
| | | // Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, |
| | | // String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | // if (null == loc) { |
| | | // log.warn("Agv [{}] 上报往货架放货完成时,库位码[{}]无效。", protocol.getAgvNo(), |
| | | // agv_11_up.getLocCode()); |
| | | // } else { |
| | | // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | // for (Long taskId : taskIds) { |
| | | // Task task = taskService.getById(taskId); |
| | | // if (task.getDestLoc().equals(loc.getId())) { |
| | | // |
| | | // Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | // .eq(Action::getTaskId, task.getId()) |
| | | // .eq(Action::getActionType, ActionTypeType.ReadyReleaseToShelvesLoc.val()) |
| | | // .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | // ); |
| | | // |
| | | // if (null != action) { |
| | | // action.setActionSts(ActionStsType.FINISH.val()); |
| | | // action.setEndTime(now); |
| | | // action.setUpdateTime(now); |
| | | // if (!actionService.updateById(action)) { |
| | | // log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + |
| | | // action.getName()); |
| | | // } |
| | | // } |
| | | // //插入一条 |
| | | // report(task, 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); |
| | | // } |
| | | // 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.TAKE_FROM_SHELVES_COMPLETE)) { |
| | | WebsocketServiceImpl.taskShelfBarcode = agv_11_up.getLocCode(); |
| | | |
| | | // Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | // if (null == loc) { |
| | | // log.warn("Agv [{}] 上报从货架取货完成,库位码[{}]无效。", protocol.getAgvNo(), agv_11_up.getLocCode()); |
| | | // } else { |
| | | // |
| | | // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | // for (Long taskId : taskIds) { |
| | | // Task task = taskService.getById(taskId); |
| | | // if (task.getOriLoc().equals(loc.getId())) { |
| | | // |
| | | // Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | // .eq(Action::getTaskId, task.getId()) |
| | | // .eq(Action::getActionType, ActionTypeType.ReadyTakeFromShelvesLoc.val()) |
| | | // .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | // ); |
| | | // if (null != action) { |
| | | // action.setActionSts(ActionStsType.FINISH.val()); |
| | | // action.setEndTime(now); |
| | | // action.setUpdateTime(now); |
| | | // if (!actionService.updateById(action)) { |
| | | // log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + action.getName()); |
| | | // } |
| | | // } |
| | | // report(task, 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); |
| | | // } |
| | | // Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, |
| | | // String.valueOf(Integer.parseInt(agv_11_up.getLocCode())))); |
| | | // if (null == loc) { |
| | | // log.warn("Agv [{}] 上报从货架取货完成,库位码[{}]无效。", protocol.getAgvNo(), |
| | | // agv_11_up.getLocCode()); |
| | | // } else { |
| | | // |
| | | // List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo); |
| | | // for (Long taskId : taskIds) { |
| | | // Task task = taskService.getById(taskId); |
| | | // if (task.getOriLoc().equals(loc.getId())) { |
| | | // |
| | | // Action action = actionService.getOne(new LambdaQueryWrapper<Action>() |
| | | // .eq(Action::getTaskId, task.getId()) |
| | | // .eq(Action::getActionType, ActionTypeType.ReadyTakeFromShelvesLoc.val()) |
| | | // .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | // ); |
| | | // if (null != action) { |
| | | // action.setActionSts(ActionStsType.FINISH.val()); |
| | | // action.setEndTime(now); |
| | | // action.setUpdateTime(now); |
| | | // if (!actionService.updateById(action)) { |
| | | // log.error("Action [{}] 更新失败 !!!", action.getPriority() + " - " + |
| | | // action.getName()); |
| | | // } |
| | | // } |
| | | // report(task, 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.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.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.ENTIRE_PATH_COMPLETE) |
| | |
| | | |
| | | // segment list |
| | | List<Segment> segmentList = segmentService.list(new LambdaQueryWrapper<Segment>() |
| | | .eq(Segment::getGroupId, serialNo) |
| | | // .eq(Segment::getState, SegmentStateType.RUNNING.toString()) |
| | | .orderByAsc(Segment::getSerial) |
| | | ); |
| | | .eq(Segment::getGroupId, serialNo) |
| | | // .eq(Segment::getState, SegmentStateType.RUNNING.toString()) |
| | | .orderByAsc(Segment::getSerial)); |
| | | |
| | | // settlement |
| | | this.settleSegmentList(segmentList, serialNo); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public void settleSegmentList(List<Segment> segmentList, String serialNo) { |
| | | if (Cools.isEmpty(segmentList)) { |
| | |
| | | for (Segment segment : segmentList) { |
| | | boolean taskComplete = false; |
| | | boolean otbin = false; |
| | | |
| | | |
| | | Task task = taskService.getById(segment.getTaskId()); |
| | | assert null != task; |
| | |
| | | report(task, null, TaskReportStsType.OTBIN); |
| | | } |
| | | |
| | | |
| | | if (taskComplete) { |
| | | locService.taskCallBackEnd(task); |
| | | |
| | |
| | | if (!Cools.isEmpty(serialNo)) { |
| | | List<Action> actionList = actionService.list(new LambdaQueryWrapper<Action>() |
| | | .eq(Action::getGroupId, serialNo) |
| | | .eq(Action::getActionSts, ActionStsType.ISSUED.val()) |
| | | ); |
| | | .eq(Action::getActionSts, ActionStsType.ISSUED.val())); |
| | | for (Action action : actionList) { |
| | | action.setActionSts(ActionStsType.FINISH.val()); |
| | | action.setEndTime(now); |
| | |
| | | if (task.getBusId() == null) { |
| | | return; |
| | | } |
| | | List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getSeqNum, task.getSeqNum()).eq(TaskReport::getBusNo, task.getBusId$()).eq(TaskReport::getTaskSts, taskReportStsType.status)); |
| | | 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 [{},{}] 已重复,不再插入 ==========>> ", taskReportStsType, JSON.toJSONString(task)); |
| | | return; |
| | |
| | | return false; |
| | | } |
| | | Integer time = configService.getVal("TIMEOUT", Integer.class, 5); |
| | | //Integer times = configService.getVal("REPORT_TIMES", Integer.class, 2); |
| | | // Integer times = configService.getVal("REPORT_TIMES", Integer.class, 2); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("askType", askType); |
| | | data.put("askSta", askSta); |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/11/10 |
| | | * @description: 修改库位状态 |
| | | * @version 1.0 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R modifyStatus(LocSiteParams params) { |
| | | if (Objects.isNull(params.getStatus())) { |
| | | return R.error("修改状态不能为空!!"); |
| | | } |
| | | LocSts locSts = locStsService.getOne(new LambdaQueryWrapper<LocSts>().eq(LocSts::getUuid, params.getStatus())); |
| | | if (Objects.isNull(locSts)) { |
| | | return R.error("数据错误,未找到对应工作状态!!"); |
| | | } |
| | | if (params.getType().equals("loc")) { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, params.getCode())); |
| | | if (Objects.isNull(loc)) { |
| | | return R.error("库位信息不存在!!"); |
| | | } |
| | | loc.setLocSts(locSts.getId()); |
| | | if (!locService.updateById(loc)) { |
| | | return R.ok("库位状态修改失败!!"); |
| | | } |
| | | } else { |
| | | Sta sta = staService.getOne(new LambdaQueryWrapper<Sta>().eq(Sta::getStaNo, params.getCode())); |
| | | if (Objects.isNull(sta)) { |
| | | return R.error("站点信息不存在!!"); |
| | | } |
| | | sta.setStatus(locSts.getStatus()); |
| | | if (!staService.updateById(sta)) { |
| | | return R.error("站点状态修改失败!!"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |