| | |
| | | com.type = commandTypeOuter; |
| | | com.rtuResultSendWebUrl = rtuResultSendWebUrl; |
| | | |
| | | com.param = param; |
| | | |
| | | if(param != null) { |
| | | com.param = param; |
| | | } |
| | | return com; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | protected BaseResponse<Data> dealWithCallBack(Long comId, Command com) { |
| | | CompletableFuture<Data> feature = new CompletableFuture<>(); |
| | | CompletableFuture<JSONObject> feature = new CompletableFuture<>(); |
| | | features.put(comId, feature); |
| | | try { |
| | | // 发送命令 |
| | |
| | | return BaseResponseUtils.buildErrorMsg(job_param.getString("message")); |
| | | } |
| | | |
| | | Data resultData = feature.get(180, TimeUnit.SECONDS); |
| | | JSONObject resultData = feature.get(180, TimeUnit.SECONDS); |
| | | features.remove(comId); |
| | | Long commandId = Long.parseLong(resultData.getCommandId()); |
| | | |
| | | Long commandId = resultData.getLong("commandId"); |
| | | if (commandId.equals(comId)) { |
| | | return BaseResponseUtils.buildSuccess(resultData); |
| | | } else { |
| | |
| | | rmCommandHistory.setComId(comId); |
| | | rmCommandHistory.setResult((byte) 0); |
| | | rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory); |
| | | return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString()); |
| | | //return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString()); |
| | | return BaseResponseUtils.buildErrorMsg(response_CallBack.getMsg()); |
| | | } |
| | | |
| | | // 回调超时 |
| | |
| | | return BaseResponseUtils.buildErrorMsg(CommandResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage()); |
| | | } |
| | | |
| | | // 回调成功,再判断执行是否成功 |
| | | JSONObject job_content = (JSONObject) JSON.toJSON(response_CallBack.getContent()); |
| | | JSONObject job_subData = (JSONObject) job_content.getJSONObject("subData").getJSONObject("subData"); |
| | | Boolean dealResult = job_subData.getBoolean("success"); |
| | | if (!dealResult) { |
| | | /** |
| | | * 执行失败 |
| | | * 更新执行结果、返回结果时间、结果内容 |
| | | */ |
| | | rmCommandHistory = new RmCommandHistory(); |
| | | rmCommandHistory.setComId(comId); |
| | | rmCommandHistory.setResult((byte) 0); |
| | | rmCommandHistory.setResultTime(new Date()); |
| | | //rmCommandHistory.setResultText((JSONObject)JSON.toJSON(response_CallBack.getContent())); |
| | | rmCommandHistory.setResultText(response_CallBack.getContent().toString()); |
| | | rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory); |
| | | return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString()); |
| | | } |
| | | |
| | | /** |
| | | * 执行成功 |
| | | * 如果是开关阀:更改虚拟卡状态:是否使用中、最后操作、最后操作时间 |
| | | * 更新执行结果、返回结果时间、结果内容 |
| | | * 返回回调内容 |
| | |
| | | } |
| | | |
| | | // 回调返回的内容,回调结果写入命令日志表的任务由中间件完成 |
| | | Data myData = (Data) response_CallBack.getContent(); |
| | | return BaseResponseUtils.buildSuccess(myData); |
| | | return response_CallBack; |
| | | |
| | | } |
| | | } |