Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
| | |
| | | * 向通信中间件发送rtu远程升级任务 |
| | | * @param restTemplate SpringBoot的RestTemplate |
| | | * @param toMwUrl 到通信中间件的web请求Url |
| | | * @param param 请求参数 |
| | | * @param body 请求数据 |
| | | * @return |
| | | */ |
| | | protected BaseResponse sendRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object param) { |
| | | protected BaseResponse sendPostRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object body) { |
| | | String url = UriComponentsBuilder.fromUriString(toMwUrl) |
| | | .build() |
| | | .toUriString(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity<?> httpEntity ; |
| | | if(param != null){ |
| | | httpEntity = new HttpEntity<>(param, headers); |
| | | }else{ |
| | | httpEntity = new HttpEntity<>(headers); |
| | | } |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(body, headers); |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | | // 通过Post方式调用接口 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 向通信中间件发送rtu远程升级任务 |
| | | * @param restTemplate SpringBoot的RestTemplate |
| | | * @param toMwUrl 到通信中间件的web请求Url |
| | | * @return |
| | | */ |
| | | protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl) { |
| | | String url = UriComponentsBuilder.fromUriString(toMwUrl) |
| | | .build() |
| | | .toUriString(); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(headers); |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | | // 通过Post方式调用接口 |
| | | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("后端系统出错,中间件调用异常"); |
| | | } |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("后端系统出错,中间件调用异常"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建外部命令(发给控制器) |
| | | * @param code 命令code |
| | | * @return |
| | |
| | | */ |
| | | @Schema(description = "升级是否结束" ) |
| | | @ExcelProperty("升级结束") |
| | | @ColumnWidth(10) |
| | | @ColumnWidth(14) |
| | | @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER) |
| | | public String isOverStr; |
| | | |
| | |
| | | * 接收web系统发来强制结束升级任务 |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "ugForceOver", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @GetMapping(path = "ugForceOver", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | public BaseResponse<String> ugForceOver() { |
| | | log.info("收到停止RTU升级任务命令") ; |
| | | try{ |
| | |
| | | Command com = this.createInnerCommand(CodeLocal.onLinePart); |
| | | com.setParam(rtuAddrs) ; |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ; |
| | | BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ; |
| | |
| | | //向通信中间件发关命令,查询部分RTU在线情况 |
| | | Command com = this.createInnerCommand(CodeLocal.onLineAll); |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ; |
| | | BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ; |
| | |
| | | vo.callbackWebUrl = ugCallbackUrl_rm ; |
| | | |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, vo) ; |
| | | BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, vo) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | this.sv.setUpgradeTaskExecuted(id); |
| | |
| | | if(msg == null){ |
| | | msg = res.getMsg() ; |
| | | } |
| | | log.error("通信中间件执行下发升级任务失败" + msg) ; |
| | | return BaseResponseUtils.buildErrorMsg("通信中间件执行失败" + msg) ; |
| | | log.error("通信中间件执行下发升级任务失败," + msg) ; |
| | | return BaseResponseUtils.buildErrorMsg("通信中间件执行失败," + msg) ; |
| | | } |
| | | }else{ |
| | | log.error("通信中间件返回结果为null") ; |
| | |
| | | @SsoAop() |
| | | public BaseResponse<String> forceOver() { |
| | | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ; |
| | | BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, null) ; |
| | | BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ; |
| | | if(res != null){ |
| | | if(res.isSuccess()){ |
| | | return BaseResponseUtils.buildSuccess(true) ; |