From 8910275656c9bf398832dc14957a03684a593e96 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期五, 30 八月 2024 15:16:58 +0800
Subject: [PATCH] 2024-08-30 朱宝民 修改配置文件bug
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_37_Down.java | 83 ++++++++++++++++++++++++-----------------
1 files changed, 49 insertions(+), 34 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_37_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_37_Down.java
index af6f4ac..25a28d6 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_37_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_37_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.Com21Vo;
+import com.dy.common.mw.protocol.p206V1_0_0.downVos.Com37Vo;
import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate;
import com.dy.common.util.ByteUtil;
import com.dy.common.util.ByteUtilUnsigned;
@@ -28,7 +32,7 @@
MidResultToRtu midRs = new MidResultToRtu() ;
midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;//rtu杩斿洖鍛戒护缁撴灉 鍙戝悜鐩殑鍦皐eb URL
midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
- midRs.rtuAddr = para.rtuAddr ;//Rtu鍦板潃锛堢數淇″钩鍙拌澶嘔MEI锛�
+ midRs.rtuAddr = para.rtuAddr ;//Rtu鍦板潃
midRs.commandId = para.commandId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
midRs.downCode = para.commandCode ;//涓嬭鍛戒护鍔熻兘鐮�;
midRs.downBuffer = bs ;//涓嬭鍛戒护鏁版嵁
@@ -52,48 +56,59 @@
* @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("鍛戒护鍙傛暟涓簄ull") ;
+ }else {
+ JSONObject obj = (JSONObject) para.param;
+ String json = obj.toJSONString();
+ Com37Vo cvo = JSON.parseObject(json, Com37Vo.class);
+ if (cvo == null) {
+ throw new Exception("json杞珻om21Vo涓簄ull");
+ }
+ if (cvo.seconds == null) {
+ throw new Exception("閲囬泦鍛ㄦ湡涓嶈兘涓虹┖");
+ }
+ if (cvo.seconds < 1) {
+ throw new Exception("閲囬泦鍛ㄦ湡涓嶈兘灏忎簬1");
+ }
+ 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] = 0 ;//甯ч暱搴�
+ index++;
+ bsHead[index] = 0;//甯ч暱搴�
- index++ ;
- bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
+ index++;
+ bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte;
- index++ ;
- bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ;
+ index++;
+ bsHead[index] = commonV1_0_1.createCtrl((byte) 0, (byte) 0);
- index++ ;
- GlCreate.createRtuAddr(para.rtuAddr, bsHead, index);
- index += 5 ;
+ index++;
+ GlCreate.createRtuAddr(para.rtuAddr, bsHead, index);
+ index += 5;
- ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ;
+ ByteUtil.hex2Bytes(para.commandCode, bsHead, index);
- if(para.param == null){
- throw new Exception("鏈彁渚涘懡浠ゅ弬鏁版暟鎹紝涓嶈兘鏋勯�犲姛鑳界爜涓�" + para.commandCode + "鐨勪笅琛屽懡浠�") ;
- }else{
- index = 0 ;
- byte[] bs = new byte[10] ;
- Integer second = (Integer)para.param ;
- ByteUtilUnsigned.short2Bytes_LE(bs, second.shortValue(), index);
- index += 2 ;
+ index = 0;
+ byte[] bs = new byte[10];
+ ByteUtilUnsigned.short2Bytes_LE(bs, cvo.seconds.shortValue(), index);
+ index += 2;
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 ;
}
}
--
Gitblit v1.8.0