| | |
| | | try { |
| | | //发出请求 |
| | | NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class); |
| | | JSONObject result = requestCommand(httpCommand); |
| | | if (result == null) { |
| | | return false;//请求失败 |
| | | Map<String, Object> body = httpCommand.getRequest().getBody(); |
| | | Object pathObj = body.get("path"); |
| | | List<JSONObject> path = JSON.parseArray(JSON.toJSONString(pathObj), JSONObject.class); |
| | | ArrayList<NyShuttleHttpCommand> commandList = new ArrayList<>(); |
| | | while (!path.isEmpty()) { |
| | | ArrayList<Map<String, Object>> list = new ArrayList<>(); |
| | | if (path.size() > 10) { |
| | | List<JSONObject> subList = path.subList(0, 10); |
| | | list.addAll(subList); |
| | | subList.clear(); |
| | | }else { |
| | | list.addAll(path); |
| | | path.clear(); |
| | | } |
| | | |
| | | NyShuttleHttpCommand httpCommandCopy = JSON.parseObject(JSON.toJSONString(httpCommand), NyShuttleHttpCommand.class); |
| | | JSONObject bodyCopy = JSON.parseObject(JSON.toJSONString(body)); |
| | | |
| | | NyShuttleHttpCommand.NyRequest request = httpCommandCopy.getRequest(); |
| | | bodyCopy.put("path", list); |
| | | request.setBody(bodyCopy); |
| | | httpCommandCopy.setRequest(request); |
| | | |
| | | commandList.add(httpCommandCopy);//add copy |
| | | } |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | |
| | | for (NyShuttleHttpCommand requestCommand : commandList) { |
| | | JSONObject result = requestCommand(requestCommand); |
| | | if (result == null) { |
| | | return false;//请求失败 |
| | | } |
| | | this.shuttleProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | } |
| | | return true; |
| | | } catch (IOException e) { |
| | | return false; |