|  |  |  | 
|---|
|  |  |  | import com.alibaba.excel.EasyExcel; | 
|---|
|  |  |  | import com.alibaba.excel.support.ExcelTypeEnum; | 
|---|
|  |  |  | import com.dy.common.aop.SsoAop; | 
|---|
|  |  |  | import com.dy.common.softUpgrade.state.UpgradeRtu; | 
|---|
|  |  |  | import com.dy.common.softUpgrade.state.UpgradeTaskVo; | 
|---|
|  |  |  | import com.dy.common.springUtil.SpringContextUtil; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.common.webUtil.ResultCodeMsg; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoUg.UgRtuTask; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voPr.VoDivide; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voUg.VoUgRtuResult; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Failure; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Success; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voUg.VoWatch; | 
|---|
|  |  |  | import io.swagger.v3.oas.annotations.Operation; | 
|---|
|  |  |  | import io.swagger.v3.oas.annotations.media.Content; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.UnsupportedEncodingException; | 
|---|
|  |  |  | import java.net.URLEncoder; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Base64; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Tag(name = "rtu远程升级任务", description = "rtu远程升级任务相关操作") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping(path = "rtuUpgrade") | 
|---|
|  |  |  | public class RtuUpgradeCtrl extends ToRtuMwCom { | 
|---|
|  |  |  | public class RtuUpgradeCtrl extends Web2RtuMw { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RtuUpgradeSv sv ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | RtuUpgradeResSv resSv ; | 
|---|
|  |  |  | private RtuUpgradeResSv resSv ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Environment env; | 
|---|
|  |  |  | 
|---|
|  |  |  | vo.rtuAddrList = taskRtuAddrs ; | 
|---|
|  |  |  | vo.callbackWebUrl = ugCallbackUrl_rm ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String ugSendUrl = this.getToMwUgUrl(this.env) ; | 
|---|
|  |  |  | BaseResponse res = sendUpgradeTask2Mw(restTemplate, ugSendUrl, vo) ; | 
|---|
|  |  |  | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ; | 
|---|
|  |  |  | 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") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("通信中间件返回结果为null") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 下发强制结束当前rtu远程升级任务 | 
|---|
|  |  |  | * @return 操作结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Operation(summary = "下发强制结束当前rtu远程升级任务", description = "下发强制结束当前rtu远程升级任务") | 
|---|
|  |  |  | @ApiResponses(value = { | 
|---|
|  |  |  | @ApiResponse( | 
|---|
|  |  |  | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, | 
|---|
|  |  |  | description = "返回操作成功与否数据(BaseResponse.content:Boolean)", | 
|---|
|  |  |  | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, | 
|---|
|  |  |  | schema = @Schema(implementation = String.class))} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(path = "/forceOver") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<String> forceOver() { | 
|---|
|  |  |  | String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ; | 
|---|
|  |  |  | BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ; | 
|---|
|  |  |  | if(res != null){ | 
|---|
|  |  |  | if(res.isSuccess()){ | 
|---|
|  |  |  | RtuUpgradeStateReceiverCtrl.afterMwForceOverCurUgTask(); | 
|---|
|  |  |  | String msg = res.getContent()==null?null:(String)res.getContent() ; | 
|---|
|  |  |  | if(msg == null){ | 
|---|
|  |  |  | msg = res.getMsg() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, msg, msg) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | String msg = res.getContent()==null?null:(String)res.getContent() ; | 
|---|
|  |  |  | if(msg == null){ | 
|---|
|  |  |  | msg = res.getMsg() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.error("通信中间件执行下发强制结束当前rtu远程升级任务失败:" + msg) ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("通信中间件执行强制结束当前rtu远程升级任务失败:" + msg) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("通信中间件返回结果为null") ; | 
|---|
|  |  |  | return BaseResponseUtils.buildErrorMsg("通信中间件返回结果为null") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void valueFromPo(UpgradeTaskVo vo, UgRtuTask tpo, UgRtuProgram ppo){ | 
|---|
|  |  |  | vo.id = "" + tpo.id ; | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/exportUgFail", method = RequestMethod.GET) | 
|---|
|  |  |  | public void exportUgFail(HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | setExcelRespProp(response, "升级失败RTU列表"); | 
|---|
|  |  |  | List<VoUgRtuResult> rsList = resSv.exportUgFail(); | 
|---|
|  |  |  | List<VoUgRtuResult4Failure> rsList = resSv.exportUgFail(); | 
|---|
|  |  |  | EasyExcel.write(response.getOutputStream()) | 
|---|
|  |  |  | .head(VoUgRtuResult.class) | 
|---|
|  |  |  | .head(VoUgRtuResult4Failure.class) | 
|---|
|  |  |  | .excelType(ExcelTypeEnum.XLSX) | 
|---|
|  |  |  | .sheet("升级失败RTU列表") | 
|---|
|  |  |  | .doWrite(rsList); | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/exportUgSuccess", method = RequestMethod.GET) | 
|---|
|  |  |  | public void exportUgSuccess(HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | setExcelRespProp(response, "升级成功RTU列表"); | 
|---|
|  |  |  | List<VoUgRtuResult> rsList = resSv.exportUgSuccess(); | 
|---|
|  |  |  | List<VoUgRtuResult4Success> rsList = resSv.exportUgSuccess(); | 
|---|
|  |  |  | EasyExcel.write(response.getOutputStream()) | 
|---|
|  |  |  | .head(VoUgRtuResult.class) | 
|---|
|  |  |  | .head(VoUgRtuResult4Success.class) | 
|---|
|  |  |  | .excelType(ExcelTypeEnum.XLSX) | 
|---|
|  |  |  | .sheet("升级成功RTU列表") | 
|---|
|  |  |  | .doWrite(rsList); | 
|---|