From 959dcca95276888cd9c092d93d276ef9aa580aef Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期三, 30 四月 2025 16:26:19 +0800 Subject: [PATCH] 1、增加远程透传命令; 2、表阀一体机协议优化; --- pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 44 insertions(+), 1 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java index f50db60..3c4781f 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java @@ -14,6 +14,7 @@ import com.dy.common.mw.protocol.CommandType; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.rtuMw.server.tasks.WebDownTransparentComTask; import com.dy.rtuMw.server.upgrade.UpgradeUnit; import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServletRequest; @@ -233,11 +234,18 @@ return BaseResponseUtils.buildError(ReturnCommand.errored("澶勭悊鍐呴儴鍛戒护鍑洪敊" + (e.getMessage() == null?"":("锛�" + e.getMessage())), com.getId(), com.getCode()) ); } }else if(commandType.equals(CommandType.outerCommand)){ - //鍙戝悜RTU鐨勫閮ㄥ懡浠わ紝寮傛澶勭悊锛寃eb绔痡roups鎴愬憳鍚屾寰楀埌鍛戒护澶勭悊缁撴灉锛屼絾鏋勯�犲懡浠ゅ強涓嬪彂鍛戒护鍜屽懡浠ょ粨鏋滄帴鏀惰寮傛寰楀埌 + //鍙戝悜RTU鐨勫閮ㄥ懡浠� try{ return this.dealOuterCommand(com) ; }catch(Exception e){ return BaseResponseUtils.buildError(ReturnCommand.errored("澶勭悊鍙戝悜RTU鐨勫閮ㄥ懡浠ゅ嚭閿�" + (e.getMessage() == null?"":("锛�" + e.getMessage())), com.getId(), com.getCode()) ); + } + }else if(commandType.equals(CommandType.outerTransCommand)){ + //鍙戝悜RTU鐨勫閮ㄩ�忎紶鍛戒护 + try{ + return this.dealOutTransparentCommand(com) ; + }catch(Exception e){ + return BaseResponseUtils.buildError(ReturnCommand.errored("澶勭悊鍙戝悜RTU鐨勫閮ㄩ�忎紶鍛戒护鍑洪敊" + (e.getMessage() == null?"":("锛�" + e.getMessage())), com.getId(), com.getCode()) ); } }else if(commandType.equals(CommandType.resultCommand)){ return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛岄�氫俊涓棿浠朵笉鎺ョ粨鏋滅被鍨嬬殑鍛戒护锛�", com.getId(), com.getCode())); @@ -293,4 +301,39 @@ return BaseResponseUtils.buildSuccess(ReturnCommand.successed("鍛戒护宸叉帴鍙楋紝鍗冲皢鏋勯�犲苟涓嬪彂鍛戒护銆�", command.getId(), command.getCode())); } + + + /** + * 澶勭悊鍙戝悜RTU鐨勫閮ㄥ懡浠� + * @return 缁撴灉 + */ + private BaseResponse<Command> dealOutTransparentCommand(Command command){ + String rtuAddr = command.getRtuAddr() ; + if(rtuAddr == null || rtuAddr.trim().equals("")){ + return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛孯TU鍦板潃涓虹┖锛�", command.getId(), command.getCode())) ; + } + rtuAddr = rtuAddr.trim() ; + Boolean onLine = TcpSessionCache.isConnect(rtuAddr); + if(onLine == null){ + return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛孯TU锛堝湴鍧�=" + rtuAddr + "锛夋湭涓婄嚎锛�", command.getId(), command.getCode())) ; + }else if(!onLine.booleanValue()){ + if(!ServerProperties.isLowPower){ + return BaseResponseUtils.buildError(ReturnCommand.errored("鍑洪敊锛孯TU锛堝湴鍧�=" + rtuAddr + "锛夌绾匡紒", command.getId(), command.getCode())) ; + } + } + + //鐢熸垚寮傛浠诲姟 + WebDownTransparentComTask task = new WebDownTransparentComTask() ; + task.data = command ; + try{ + log.info("鏋勯�犱笅鍙戣繙绋嬮�忎紶鍛戒护" + command.getCode() + "鐨勬牳蹇冧换鍔★紝骞舵斁鍏ヤ换鍔¢槦鍒椾腑"); + CoreUnit.getInstance().pushCoreTask(task); + }catch(Exception e){ + log.error(e.getMessage(), e); + return BaseResponseUtils.buildError(ReturnCommand.successed("閫忎紶鍛戒护澶勭悊澶辫触" + e.getMessage(), command.getId(), command.getCode())) ; + } + + return BaseResponseUtils.buildSuccess(ReturnCommand.successed("閫忎紶鍛戒护宸叉帴鍙楋紝鍗冲皢鏋勯�犲苟涓嬪彂鍛戒护銆�", command.getId(), command.getCode())); + } + } -- Gitblit v1.8.0