pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/CommonV1_0_1.java
@@ -99,7 +99,7 @@ public String parseRtuAddr(byte[] bs, int index)throws Exception{ String rtuAddrBCD = "" + ByteUtil.BCD2Long_BE(bs, index, index + 2) ;//地址是大端模式 String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, index + 3) ; while(rtuAddrStr.length() < 5){ while(rtuAddrStr.length() <= 5){ rtuAddrStr = "0" + rtuAddrStr ; } return rtuAddrBCD + rtuAddrStr ; pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/downVos/Com10Vo.java
New file @@ -0,0 +1,10 @@ package com.dy.common.mw.protocol.p206V1_0_0.downVos; /** * @Author: liurunyu * @Date: 2024/7/25 15:27 * @Description */ public class Com10Vo { public String rtuAddr ; } pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_10_Down.java
@@ -1,10 +1,14 @@ package com.dy.common.mw.protocol.p206V1_0_0.parse; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.dy.common.mw.protocol.*; import com.dy.common.mw.protocol.p206V1_0_0.CodeV1_0_1; import com.dy.common.mw.protocol.p206V1_0_0.CommonV1_0_1; import com.dy.common.mw.protocol.p206V1_0_0.ParseParamsForDownV1_0_1; import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; import com.dy.common.mw.protocol.p206V1_0_0.downVos.Com10Vo; import com.dy.common.mw.protocol.p206V1_0_0.downVos.Com3AVo; import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate; import com.dy.common.util.ByteUtil; @@ -51,48 +55,58 @@ * @throws Exception 异常 */ public byte[] doParse(ParseParamsForDownV1_0_1 para) throws Exception { CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ; byte[] bytes ; byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ; byte index = 0 ; bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; if(para.param == null) { throw new Exception("命令参数为null") ; }else { JSONObject obj = (JSONObject) para.param; String json = obj.toJSONString(); Com10Vo cvo = JSON.parseObject(json, Com10Vo.class); if (cvo == null) { throw new Exception("json转Com10Vo为null"); } if (cvo.rtuAddr == null) { throw new Exception("测试新地址不能为空"); } index++ ; bsHead[index] = 0 ;//帧长度 CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1(); byte[] bytes; byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code]; byte index = 0; bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte; index++ ; bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; index++; bsHead[index] = 0;//帧长度 index++ ; bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; index++; bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte; index++ ; GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); index += 5 ; index++; bsHead[index] = commonV1_0_1.createCtrl((byte) 0, (byte) 0); ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; index++; GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); index += 5; if(para.param == null){ throw new Exception("未提供命令参数数据,不能构造功能码为" + para.commandCode + "的下行命令") ; }else{ index = 0 ; byte[] bs = new byte[13] ; String newRtuAddr = (String)para.param ; GlCreate.createRtuAddr(newRtuAddr, bs, index); index += 5 ; ByteUtil.hex2Bytes(para.commandCode, bsHead, index); index = 0; byte[] bs = new byte[13]; GlCreate.createRtuAddr(cvo.rtuAddr, bs, index); index += 5; GlCreate.createPw(bs, index); index += 2 ; index += 2; GlCreate.createTp(bs, index); bytes = ByteUtil.bytesMerge(bsHead, bs) ; bytes = ByteUtil.bytesMerge(bsHead, bs); GlCreate.createLen(bytes);//长度放字节数组中 byte[] bsTail = GlCreate.createCrcTail(bytes);//CRC和尾叠加字节数组中 bytes = ByteUtil.bytesMerge(bytes, bsTail); return bytes; } GlCreate.createLen(bytes);//长度放字节数组中 byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC和尾叠加字节数组中 bytes = ByteUtil.bytesMerge(bytes, bsTail) ; return bytes ; } } pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlParse.java
@@ -48,12 +48,12 @@ * @throws Exception 异常 */ public static String parseIcCardNo(byte[] bs, int index)throws Exception{ String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, index) ; String rtuAddrBCD = "" + ByteUtil.BCD2Long_LE(bs, index + 2, index + 7) ; while(rtuAddrStr.length() < 5){ rtuAddrStr = "0" + rtuAddrStr ; String icNoStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, index) ; String icNoBCD = "" + ByteUtil.BCD2Long_LE(bs, index + 2, index + 7) ; while(icNoStr.length() < 5){ icNoStr = "0" + icNoStr ; } return rtuAddrBCD + rtuAddrStr ; return icNoBCD + icNoStr ; } pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/upVos/DataCd83CloseVo.java
@@ -35,7 +35,7 @@ sb.append(" IC卡编号:"); sb.append(icCardNo); sb.append("\n"); sb.append(" ic卡地址:"); sb.append(" IC卡地址:"); sb.append(icCardAddr); sb.append("\n"); sb.append(" 剩余金额(元):"); pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/upVos/DataCd83OpenVo.java
@@ -30,7 +30,7 @@ sb.append(" IC卡编号:"); sb.append(icCardNo); sb.append("\n"); sb.append(" ic卡地址:"); sb.append(" IC卡地址:"); sb.append(icCardAddr); sb.append("\n"); sb.append(" 剩余金额(元):"); pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSt/StClientAmountMonth.java
@@ -15,7 +15,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @TableName(value="rm_client_amount_month", autoResultMap = true) @TableName(value="st_client_amount_month", autoResultMap = true) @Data @Builder @ToString pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSt/StClientAmountYear.java
@@ -15,7 +15,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @TableName(value="rm_client_amount_year", autoResultMap = true) @TableName(value="st_client_amount_year", autoResultMap = true) @Data @Builder @ToString pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSt/StIntakeAmountMonth.java
@@ -15,7 +15,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @TableName(value="rm_intake_amount_month", autoResultMap = true) @TableName(value="st_intake_amount_month", autoResultMap = true) @Data @Builder @ToString pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSt/StIntakeAmountYear.java
@@ -15,7 +15,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @TableName(value="rm_intake_amount_year", autoResultMap = true) @TableName(value="st_intake_amount_year", autoResultMap = true) @Data @Builder @ToString pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSt/StLossMonth.java
@@ -15,7 +15,7 @@ * @Description 取水口漏损月统计 */ @TableName(value="rm_loss_month", autoResultMap = true) @TableName(value="st_loss_month", autoResultMap = true) @Data @Builder @ToString pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSt/StLossYear.java
@@ -15,7 +15,7 @@ * @Description 取水口漏损年统计 */ @TableName(value="rm_loss_year", autoResultMap = true) @TableName(value="st_loss_year", autoResultMap = true) @Data @Builder @ToString pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/CommandP206V1_0_0Ctrl.java
@@ -29,7 +29,9 @@ if(com == null){ rt = this.connect() ;//连接通信中间件测试 }else{ if(com.equals("21")){ if(com.equals("10")){ rt = this.cd10() ; }else if(com.equals("21")){ rt = this.cd21() ; }else if(com.equals("37")){ rt = this.cd37() ; @@ -65,6 +67,10 @@ 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("B0")){ rt = this.cdB0() ; } @@ -79,6 +85,12 @@ */ private BaseResponse connect(){ return this.sendTest() ; } private BaseResponse cd10(){ Com10Vo comVo = new Com10Vo() ; comVo.rtuAddr = "532328059995" ;//前6位是行政区划码,后6位是序列号最大是065535 return this.sendCom2Mw(this.command(CodeV1_0_1.cd_10, comVo, null)) ; } private BaseResponse cd21(){ @@ -140,7 +152,7 @@ private BaseResponse cd3C(){ Com3CVo comVo = new Com3CVo() ; comVo.minute = 60 ; comVo.minute = 5 ; return this.sendCom2Mw(this.command(CodeV1_0_1.cd_3C, comVo, null)) ; } @@ -175,6 +187,26 @@ return this.sendCom2Mw(this.command(CodeV1_0_1.cd_98, comVo, null)) ; } //定时关阀开阀 private BaseResponse cd99(){ Com99Vo comVo = new Com99Vo() ; comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo; comVo.moneyRemain = 234.56 ; comVo.waterPrice = 1.2 ; comVo.minutes = 5 ; return this.sendCom2Mw(this.command(CodeV1_0_1.cd_99, comVo, null)) ; } //定量关阀开阀 private BaseResponse cdA0(){ ComA0Vo comVo = new ComA0Vo() ; comVo.icCardNo = CommandP206V1_0_0Ctrl.vsIcCardNo; comVo.moneyRemain = 234.56 ; comVo.waterPrice = 1.2 ; comVo.waterAmount = 10 ; return this.sendCom2Mw(this.command(CodeV1_0_1.cd_98, comVo, null)) ; } private BaseResponse cdB0(){ return this.sendCom2Mw(this.command(CodeV1_0_1.cd_B0, null, null)) ; }