From 1e3eeec2d3a470d066d21900586b912dfef58c91 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期四, 17 四月 2025 15:07:41 +0800 Subject: [PATCH] 优化代码 --- pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/CommandP206V1Ctrl.java | 296 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 296 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/CommandP206V1Ctrl.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/CommandP206V1Ctrl.java new file mode 100644 index 0000000..2e2d7c9 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/CommandP206V1Ctrl.java @@ -0,0 +1,296 @@ +package com.dy.pipIrrMwTestWeb.p206V1; + +import com.dy.common.mw.protocol.Command; +import com.dy.common.mw.protocol.CommandType; +import com.dy.common.mw.protocol.p206V1.CodeV1; +import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; +import com.dy.common.mw.protocol.p206V1.downVos.*; +import com.dy.common.util.DateTime; +import com.dy.common.webUtil.BaseResponse; +import com.dy.pipIrrMwTestWeb.common.CodeLocal; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: liurunyu + * @Date: 2024/6/29 6:46 + * @Description + */ +@Slf4j +@RestController +@RequestMapping(path="comP206V1") +@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class CommandP206V1Ctrl extends ComSupportP206V1 { + + @GetMapping(path = "test") + public BaseResponse<String> test(String com) { + BaseResponse<String> rt = null ; + if(com == null){ + rt = this.connect() ;//杩炴帴閫氫俊涓棿浠舵祴璇� + }else{ + try{ + if(com.equals(CodeLocal.stopTcpSv)){ + rt = this.stopTcpSv() ; + }else if(com.equals(CodeLocal.recoverTcpSv)){ + rt = this.recoverTcpSv() ; + }else if(com.equals(CodeLocal.mwState)){ + rt = this.mwState() ; + }else if(com.equals(CodeLocal.onLine)){ + rt = this.mwAllOnLine() ; + }else if(com.equals("10")){ + rt = this.cd10() ; + }else if(com.equals("21")){ + rt = this.cd21() ; + }else if(com.equals("37")){ + rt = this.cd37() ; + }else if(com.equals("67")){ + rt = this.cd67() ; + }else if(com.equals("38")){ + rt = this.cd38() ; + }else if(com.equals("68")){ + rt = this.cd68() ; + }else if(com.equals("39")){ + rt = this.cd39() ; + }else if(com.equals("69")){ + rt = this.cd69() ; + }else if(com.equals("3A")){ + rt = this.cd3A() ; + }else if(com.equals("6A")){ + rt = this.cd6A() ; + }else if(com.equals("3B")){ + rt = this.cd3B() ; + }else if(com.equals("6B")){ + rt = this.cd6B() ; + }else if(com.equals("3C")){ + rt = this.cd3C() ; + }else if(com.equals("65")){ + rt = this.cd65() ; + }else if(com.equals("91")){ + rt = this.cd91() ; + }else if(com.equals("92")){ + rt = this.cd92() ; + }else if(com.equals("93")){ + rt = this.cd93() ; + }else if(com.equals("97")){ + rt = this.cd97() ; + }else if(com.equals("98")){ + rt = this.cd98() ; + }else if(com.equals("99")){ + rt = this.cd99() ; + }else if(com.equals("A0")){ + rt = this.cdA0() ; + }else if(com.equals("A1")){ + rt = this.cdA1() ; + }else if(com.equals("A2")){ + rt = this.cdA2() ; + }else if(com.equals("B0")){ + rt = this.cdB0() ; + } + }catch (Exception e){ + e.printStackTrace(); + } + } + return rt ; + } + + + /** + * 娴嬭瘯杩為�氭�� + * @return + */ + private BaseResponse connect(){ + return this.sendTest() ; + } + + private BaseResponse stopTcpSv(){ + return this.sendCom2Mw(this.commandLocal(CodeLocal.stopTcpSv, null, null)) ; + } + + private BaseResponse recoverTcpSv(){ + return this.sendCom2Mw(this.commandLocal(CodeLocal.recoverTcpSv, null, null)) ; + } + + private BaseResponse mwState(){ + return this.sendCom2Mw(this.commandLocal(CodeLocal.mwState, null, null)) ; + } + + private BaseResponse mwAllOnLine(){ + return this.sendCom2Mw(this.commandLocal(CodeLocal.onLine, null, null)) ; + } + + private BaseResponse cd10(){ + Com10Vo comVo = new Com10Vo() ; + comVo.rtuAddr = "532328059995" ;//鍓�6浣嶆槸琛屾斂鍖哄垝鐮侊紝鍚�6浣嶆槸搴忓垪鍙锋渶澶ф槸065535 + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_10, comVo, null)) ; + } + + private BaseResponse cd21(){ + Com21Vo comVo = new Com21Vo() ; + comVo.ip = "8.140.180.59" ;//IP锛堜緥濡� 125.235.35.89锛� + comVo.port = 6001 ;///绔彛鍙凤紙0~65536锛� + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_21, comVo, null)) ; + } + + private BaseResponse cd37(){ + Com37Vo comVo = new Com37Vo() ; + comVo.seconds = 20 ;//鍗曚綅绉� + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_37, comVo, null)) ; + } + private BaseResponse cd67(){ + Com37Vo comVo = new Com37Vo() ; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_67, comVo, null)) ; + } + + private BaseResponse cd38(){ + Com38Vo comVo = new Com38Vo() ; + comVo.remainMoneyAlarm = 10.0 ;//鐢ㄦ埛浣欓鎶ヨ鍊�(澶т簬1.0) + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_38, comVo, null)) ; + } + + private BaseResponse cd68(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_68, null, null)) ; + } + + private BaseResponse cd39(){ + Com39Vo comVo = new Com39Vo() ; + comVo.batteryVoltAlarm = 7.0 ;//鐢垫睜鐢靛帇鎶ヨ鍊�(澶т簬0.1) + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_39, comVo, null)) ; + } + + private BaseResponse cd69(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_69, null, null)) ; + } + + private BaseResponse cd3A(){ + Com3AVo comVo = new Com3AVo() ; + comVo.current = 1.0 ;//闃�闂ㄥ牭杞數娴�(澶т簬0) + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_3A, comVo, null)) ; + } + + private BaseResponse cd6A(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_6A, null, null)) ; + } + + private BaseResponse cd3B(){ + Com3BVo comVo = new Com3BVo() ; + comVo.second = 120 ;//闃�闂ㄨ秴鏃舵椂闂�(绉�)(澶т簬1) + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_3B, comVo, null)) ; + } + + private BaseResponse cd6B(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_6B, null, null)) ; + } + + private BaseResponse cd3C(){ + Com3CVo comVo = new Com3CVo() ; + comVo.minute = 5 ; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_3C, comVo, null)) ; + } + + private BaseResponse cd65(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_65, null, null)) ; + } + + private BaseResponse<String> cd91() { + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_91, null, null)) ; + } + + private BaseResponse cd92(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_92, null, null)) ; + } + + private BaseResponse cd93(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_93, null, null)) ; + } + + //APP杩滅▼寮�闃� + private BaseResponse cd97(){ + Com97Vo comVo = new Com97Vo() ; + comVo.icCardNo = CommandP206V1Ctrl.vsIcCardNo; + comVo.moneyRemain = 234.56 ; + comVo.waterPrice = 1.2 ; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_97, comVo, null)) ; + } + //APP杩滅▼鍏抽榾 + private BaseResponse cd98(){ + Com98Vo comVo = new Com98Vo() ; + comVo.icCardNo = CommandP206V1Ctrl.vsIcCardNo; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_98, comVo, null)) ; + } + + //瀹氭椂鍏抽榾寮�闃� + private BaseResponse cd99(){ + Com99Vo comVo = new Com99Vo() ; + comVo.icCardNo = CommandP206V1Ctrl.vsIcCardNo; + comVo.moneyRemain = 234.56 ; + comVo.waterPrice = 1.2 ; + comVo.minutes = 3 ; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_99, comVo, null)) ; + } + + //瀹氶噺鍏抽榾寮�闃� + private BaseResponse cdA0(){ + ComA0Vo comVo = new ComA0Vo() ; + comVo.icCardNo = CommandP206V1Ctrl.vsIcCardNo; + comVo.moneyRemain = 1.23 ; + comVo.waterPrice = 1.2 ; + comVo.waterAmount = 10 ; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_A0, comVo, null)) ; + } + + + //瀹氭椂鍏抽榾璁″垝寮�闃� + private BaseResponse cdA1() throws Exception { + ComA1Vo comVo = new ComA1Vo() ; + comVo.icCardNo = CommandP206V1Ctrl.vsIcCardNo; + comVo.moneyRemain = 1.23 ; + comVo.waterPrice = 1.2 ; + comVo.minutes = 30 ; + String nextDtStr = DateTime.nextXMinute_yyyy_MM_dd_HH_mm_ss(DateTime.yyyy_MM_dd_HH_mm_ss(), 3) ;//灏嗘潵X鍒嗛挓 + int[] nextDt = DateTime.yyyy_MM_dd_HH_MM_SS_2_ymdhmsGroup(nextDtStr) ; + comVo.year = nextDt[0] ; + comVo.month = nextDt[1] ; + comVo.day = nextDt[2] ; + comVo.hour = nextDt[3] ; + comVo.minute = nextDt[4] ; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_A1, comVo, null)) ; + } + + //瀹氶噺鍏抽榾璁″垝寮�闃� + private BaseResponse cdA2() throws Exception { + ComA2Vo comVo = new ComA2Vo() ; + comVo.icCardNo = CommandP206V1Ctrl.vsIcCardNo; + comVo.moneyRemain = 234.56 ; + comVo.waterPrice = 1.2 ; + comVo.waterAmount = 10 ; + String nextDtStr = DateTime.nextXMinute_yyyy_MM_dd_HH_mm_ss(DateTime.yyyy_MM_dd_HH_mm_ss(), 3) ;//灏嗘潵X鍒嗛挓 + int[] nextDt = DateTime.yyyy_MM_dd_HH_MM_SS_2_ymdhmsGroup(nextDtStr) ; + comVo.year = nextDt[0] ; + comVo.month = nextDt[1] ; + comVo.day = nextDt[2] ; + comVo.hour = nextDt[3] ; + comVo.minute = nextDt[4] ; + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_A2, comVo, null)) ; + } + + + private BaseResponse cdB0(){ + return this.sendCom2Mw(this.commandOuter(CodeV1.cd_B0, null, null)) ; + } + + //鍦ㄧ嚎鎯呭喌 + private BaseResponse online(){ + Command com = new Command() ; + com.id = Command.defaultId;//瀹為檯搴旂敤涓紝鏇挎崲鎴愭暟鎹簱璁板綍id + com.protocol = ProtocolConstantV206V1.protocolName ; + com.code = CodeLocal.onLine ; + com.type = CommandType.innerCommand ; + com.rtuResultSendWebUrl = rtuResultSendWebUrl ; + return this.sendCom2Mw(com) ; + } + + +} + -- Gitblit v1.8.0