| | |
| | | |
| | | private ScheduledExecutorService scheduler = null; |
| | | |
| | | private List<String> CODE_DATA_CACHE = new ArrayList<>(); |
| | | private List<String> ALL_CODE_DATA_CACHE = new ArrayList<>(); |
| | | |
| | | private List<String> LOC_CODE_DATA_CACHE = new ArrayList<>(); |
| | | |
| | |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private AgvModelService agvModelService; |
| | | @Autowired |
| | | private AgvAreaDispatcher agvAreaDispatcher; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | int count = agvService.count(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); |
| | | if (count > 0) { |
| | | this.scheduler = Executors.newScheduledThreadPool(count); |
| | | } |
| | | // init all code data |
| | | List<Code> codeList = codeService.list(new LambdaQueryWrapper<Code>().eq(Code::getStatus, StatusType.ENABLE.val)); |
| | | this.ALL_CODE_DATA_CACHE = codeList.stream().map(Code::getData).distinct().collect(Collectors.toList()); |
| | | |
| | | // int all loc code data |
| | | List<Code> locCodeList = codeService.getAllLocCode(); |
| | | this.LOC_CODE_DATA_CACHE = locCodeList.stream().map(Code::getData).distinct().collect(Collectors.toList()); |
| | | |
| | | } |
| | | |
| | | // pick & drop logic -------------------------------------------------- |
| | | |
| | |
| | | * agv地图图标变化 |
| | | */ |
| | | public String getDestinationCode(String agvNo, AgvDetail agvDetail) { |
| | | |
| | | Code startCode = codeService.getCacheById(agvDetail.getRecentCode()); |
| | | |
| | | Set<String> notInCodeSet = new HashSet<>(); |
| | | notInCodeSet.add("00000301"); |
| | | notInCodeSet.add("00000302"); |
| | | notInCodeSet.add("00000303"); |
| | | notInCodeSet.add("00000351"); |
| | | notInCodeSet.add("00000353"); |
| | | notInCodeSet.add("00000401"); |
| | | notInCodeSet.add("00000402"); |
| | | Long agvId = agvDetail.getAgvId(); |
| | | |
| | | notInCodeSet.add("00000311"); |
| | | notInCodeSet.add("00000312"); |
| | | notInCodeSet.add("00000313"); |
| | | notInCodeSet.add("00000361"); |
| | | notInCodeSet.add("00000363"); |
| | | notInCodeSet.add("00000411"); |
| | | notInCodeSet.add("00000412"); |
| | | List<String> codeList = null; |
| | | if (agvAreaDispatcher.isAgvExistsInAnyArea(agvId)) { |
| | | codeList = agvAreaDispatcher.getCodesByAgvId(agvId); |
| | | } else { |
| | | codeList = ALL_CODE_DATA_CACHE; |
| | | } |
| | | Collections.shuffle(codeList); |
| | | |
| | | notInCodeSet.add("00000046"); |
| | | notInCodeSet.add("00000047"); |
| | | |
| | | Collections.shuffle(CODE_DATA_CACHE); |
| | | |
| | | for (String endCodeData : CODE_DATA_CACHE) { |
| | | for (String endCodeData : codeList) { |
| | | if (notInCodeSet.contains(endCodeData)) { continue; } |
| | | Code endCode = codeService.getCacheByData(endCodeData); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | return CODE_DATA_CACHE.stream().findFirst().orElse(null); |
| | | return codeList.stream().findFirst().orElse(null); |
| | | } |
| | | |
| | | // --------------------------------------------------------------------------- |
| | |
| | | |
| | | Runnable patrolTask = () -> { |
| | | try { |
| | | // executePatrolLogic(agvNo); |
| | | executeUShapeConveyor(agvNo); |
| | | executePatrolLogic(agvNo); |
| | | // executeUShapeConveyor(agvNo); |
| | | } catch (Exception e) { |
| | | log.error("执行AGV{}跑库任务时发生异常: {}", agvNo, e.getMessage()); |
| | | log.error("执行AGV{}跑库任务时发生异常", agvNo, e); |
| | | } |
| | | }; |
| | | |
| | |
| | | log.error("未能成功停止AGV " + agvNo + " 的跑库任务。"); |
| | | return R.error("未能成功停止AGV " + agvNo + " 的跑库任务。"); |
| | | } |
| | | } |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | int count = agvService.count(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); |
| | | if (count > 0) { |
| | | this.scheduler = Executors.newScheduledThreadPool(count); |
| | | } |
| | | // init all code data |
| | | List<Code> codeList = codeService.list(new LambdaQueryWrapper<Code>().eq(Code::getStatus, StatusType.ENABLE.val)); |
| | | this.CODE_DATA_CACHE = codeList.stream().map(Code::getData).distinct().collect(Collectors.toList()); |
| | | |
| | | // int all loc code data |
| | | List<Code> locCodeList = codeService.getAllLocCode(); |
| | | this.LOC_CODE_DATA_CACHE = locCodeList.stream().map(Code::getData).distinct().collect(Collectors.toList()); |
| | | |
| | | } |
| | | |
| | | @PreDestroy |