| | |
| | | Thread executeThread = new Thread(() -> { |
| | | while (true) { |
| | | try { |
| | | ShuttleAction shuttleAction = SpringUtils.getBean(ShuttleAction.class); |
| | | ShuttleAction shuttleAction = null; |
| | | try { |
| | | shuttleAction = SpringUtils.getBean(ShuttleAction.class); |
| | | }catch (Exception e){ |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleAction == null) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | //----------读取四向穿梭车状态----------- |
| | | DeviceMsgUtils deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class); |
| | | DeviceMsgUtils deviceMsgUtils = null; |
| | | try { |
| | | deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | if(deviceMsgUtils == null){ |
| | | return; |
| | | } |
| | | |
| | | NyShuttleHttpCommand readStatusCommand = getReadStatusCommand(slave.getId()); |
| | | //指令超过五条,不再下发任务状态请求 |
| | | TreeSet<String> deviceCommandMsgListKey = deviceMsgUtils.getDeviceCommandMsgListKey(SlaveType.Shuttle, slave.getId()); |
| | | if (deviceCommandMsgListKey.size() < 5) { |
| | | requestCommand(readStatusCommand);//请求状态 |
| | | requestCommandAsync(readStatusCommand);//请求状态 |
| | | } |
| | | |
| | | if (this.socketReadResults.isEmpty()) { |
| | |
| | | return httpStandard; |
| | | } |
| | | |
| | | //发出请求 |
| | | //发出请求-同步 |
| | | private JSONObject requestCommand(NyShuttleHttpCommand httpCommand) throws IOException { |
| | | try { |
| | | DeviceMsgUtils deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class); |
| | |
| | | return null; |
| | | } |
| | | |
| | | //发出请求-移步 |
| | | private void requestCommandAsync(NyShuttleHttpCommand httpCommand) throws IOException { |
| | | try { |
| | | DeviceMsgUtils deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class); |
| | | if (deviceMsgUtils == null) { |
| | | return; |
| | | } |
| | | |
| | | //压缩数据包 |
| | | JSONObject data = JSON.parseObject(JSON.toJSONString(httpCommand)); |
| | | data.remove("nodes"); |
| | | |
| | | String key = deviceMsgUtils.sendDeviceCommand(SlaveType.Shuttle, slave.getId(), data); |
| | | |
| | | String requestType = null; |
| | | String taskId = null; |
| | | try { |
| | | requestType = httpCommand.getRequest().getBody().get("requestType").toString(); |
| | | taskId = httpCommand.getRequest().getBody().get("taskId").toString(); |
| | | } catch (Exception e) { |
| | | // return null; |
| | | //taskId可能取空,不报错,正常情况 |
| | | } |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private JSONObject filterBodyData(JSONObject data) { |
| | | Object response = data.get("response"); |
| | | if (response == null) { |