| | |
| | | package com.dy.rtuMw.web.com; |
| | | |
| | | import com.dy.common.softUpgrade.state.UpgradeTaskVo; |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.rtuMw.resource.ResourceUnit; |
| | | import com.dy.rtuMw.server.ServerProperties; |
| | | import com.dy.rtuMw.server.forTcp.TcpSessionCache; |
| | | import com.dy.rtuMw.server.local.CommandInnerDeaLer; |
| | | import com.dy.rtuMw.server.local.ReturnCommand; |
| | | import com.dy.rtuMw.server.tasks.RtuDownTask; |
| | | import com.dy.rtuMw.server.tasks.WebDownComTask; |
| | | import com.dy.common.mw.core.CoreUnit; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.mw.protocol.CommandType; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.rtuMw.server.upgrade.UpgradeUnit; |
| | | import jakarta.servlet.ServletOutputStream; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | } |
| | | } |
| | | /** |
| | | * 接收web系统发来升级任务 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "upgradeRtu", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | public BaseResponse<Boolean> upgradeRtu(@RequestBody UpgradeTaskVo vo) { |
| | | log.info("收到RTU升级任务:\n" + vo.toString()) ; |
| | | try{ |
| | | UpgradeUnit.getInstance().setUpgradeTask(vo); |
| | | }catch (Exception e){ |
| | | log.error("设置RTU升级任务时发生异常", e); |
| | | return BaseResponseUtils.buildError("设置RTU升级任务时发生异常" + (e.getMessage() == null?"":(":" + e.getMessage()))); |
| | | } |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } |
| | | |
| | | /** |
| | | * 接收web系统发来停止升级任务 |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "ugForceStop", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | public BaseResponse<String> ugForceStop() { |
| | | log.info("收到停止RTU升级任务命令") ; |
| | | try{ |
| | | String mes = UpgradeUnit.getInstance().overUpgradeTask(); |
| | | if(mes == null){ |
| | | mes = "停止升级任务成功" ; |
| | | } |
| | | return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, mes, mes); |
| | | }catch (Exception e){ |
| | | log.error("停止RTU升级任务时发生异常", e); |
| | | return BaseResponseUtils.buildError("停止RTU升级任务时发生异常" + (e.getMessage() == null?"":(":" + e.getMessage()))); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 接收web系统发来的命令 |
| | | * @param com |
| | | * @return |
| | |
| | | } |
| | | |
| | | //生成异步任务 |
| | | RtuDownTask task = new RtuDownTask() ; |
| | | WebDownComTask task = new WebDownComTask() ; |
| | | task.data = command ; |
| | | try{ |
| | | log.info("构造下发远程命令" + command.getCode() + "的核心任务,并放入任务队列中"); |