| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | |
| | | } |
| | | |
| | | private void executeMoveWithSeg(StationCommand original) { |
| | | int stationCommandSendLength = 20; |
| | | Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (systemConfigMapObj != null) { |
| | | try { |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj; |
| | | String stationCommandSendLengthStr = systemConfigMap.get("stationCommandSendLength"); |
| | | if(stationCommandSendLengthStr != null){ |
| | | stationCommandSendLength = Integer.parseInt(stationCommandSendLengthStr); |
| | | } |
| | | } catch (Exception ignore) {} |
| | | } |
| | | |
| | | if(original.getCommandType() == StationCommandType.MOVE){ |
| | | List<Integer> path = original.getNavigatePath(); |
| | | if (path == null || path.isEmpty()) { |
| | | path = calcPathStationIds(original.getStationId(), original.getTargetStaNo()); |
| | | } |
| | | List<Integer> path = JSON.parseArray(JSON.toJSONString(original.getNavigatePath(), SerializerFeature.DisableCircularReferenceDetect), Integer.class); |
| | | if (path == null || path.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | List<Integer> segmentEndIndices = new ArrayList<>(); |
| | | int idx = 0; |
| | | while (idx < total) { |
| | | int end = Math.min(idx + 3, total) - 1; |
| | | int end = Math.min(idx + stationCommandSendLength, total) - 1; |
| | | segmentTargets.add(path.get(end)); |
| | | segmentEndIndices.add(end); |
| | | idx = end + 1; |
| | |
| | | sendCommand(segCmd); |
| | | |
| | | long runTime = System.currentTimeMillis(); |
| | | boolean firstRun = true; |
| | | while (true) { |
| | | try { |
| | | StationProtocol currentStation = findCurrentStationByTask(original.getTaskNo()); |
| | |
| | | } |
| | | |
| | | runTime = System.currentTimeMillis(); |
| | | if (currentStation.isRunBlock()) { |
| | | if (!firstRun && currentStation.isRunBlock()) { |
| | | break; |
| | | } |
| | | int currentIndex = path.indexOf(currentStation.getStationId()); |
| | |
| | | nextCmd.setCommandType(original.getCommandType()); |
| | | nextCmd.setPalletSize(original.getPalletSize()); |
| | | nextCmd.setNavigatePath(new ArrayList<>(path.subList(currentStartIdx, currentEndIdx + 1))); |
| | | sendCommand(nextCmd); |
| | | nextCmd.setOriginalNavigatePath(path); |
| | | while (true) { |
| | | CommandResponse commandResponse = sendCommand(nextCmd); |
| | | if (commandResponse == null) { |
| | | Thread.sleep(200); |
| | | continue; |
| | | } |
| | | |
| | | if (commandResponse.getResult()) { |
| | | break; |
| | | } |
| | | |
| | | Thread.sleep(200); |
| | | } |
| | | } |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | break; |
| | | } |
| | | firstRun = false; |
| | | } |
| | | }else { |
| | | sendCommand(original); |