From 0cba67398a247b8f1a6db09cc3aed26aff17dfc0 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 23 十月 2024 08:42:17 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java | 52 +++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java
index 4dc4781..96b5166 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java
@@ -1,14 +1,13 @@
package com.dy.common.mw.protocol.p206V202404.parse;
import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.*;
import com.dy.common.mw.protocol.p206V202404.CodeV202404;
import com.dy.common.mw.protocol.p206V202404.ParseParamsForDownV202404;
import com.dy.common.mw.protocol.p206V202404.downVos.ComCd16Vo;
import com.dy.common.mw.protocol.p206V202404.parse.global.GlCreate;
import com.dy.common.util.ByteUtil;
-import com.dy.common.util.ByteUtilUnsigned;
-import com.dy.common.util.NumUtil;
@AnnotationCodeDown(ifAny={
CodeV202404.cd_16
@@ -22,9 +21,11 @@
MidResultToRtu midRs = new MidResultToRtu() ;
midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ;
midRs.rtuAddr = para.rtuAddr ;//Rtu鍦板潃
midRs.commandId = para.commandId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
midRs.downCode = para.commandCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ midRs.downCodeName = CodeV202404.getCodeName(para.commandCode) ;//涓嬭鍛戒护鍔熻兘鐮佸悕绉�;
midRs.downBuffer = bs ;//涓嬭鍛戒护鏁版嵁
midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
midRs.hasResponse = true ;//鏄惁鏈夊簲绛�
@@ -48,18 +49,18 @@
public byte[] doParse(ParseParamsForDownV202404 para) throws Exception {
byte[] bytes = GlCreate.createStart2Cd(para.rtuAddr, para.commandCode);
if(para.param != null){
- String json = (String)para.param;
+ JSONObject obj = (JSONObject)para.param;
+ String json = obj.toJSONString();
ComCd16Vo cvo = JSON.parseObject(json, ComCd16Vo.class) ;
if(cvo == null){
throw new Exception("json杞珻omCd16Vo涓簄ull") ;
}
- if(cvo.moneyAlarm < 0 || cvo.moneyAlarm > 65535){
- throw new Exception("鍓╀綑閲戦鎶ヨ鍊煎繀椤绘槸0~65535鑼冨洿鍐呯殑鏁存暟") ;
+ if(cvo.moneyAlarm < 0 || cvo.moneyAlarm > 9999){
+ throw new Exception("鍓╀綑閲戦鎶ヨ鍊煎繀椤绘槸0~9999鑼冨洿鍐呯殑鏁存暟") ;
}
- if(cvo.waterAlarm < 0 || cvo.waterAlarm > 65535){
- throw new Exception("鍓╀綑姘撮噺鎶ヨ鍊煎繀椤绘槸0~65535鑼冨洿鍐呯殑鏁存暟") ;
+ if(cvo.waterAlarm < 0 || cvo.waterAlarm > 9999){
+ throw new Exception("鍓╀綑姘撮噺鎶ヨ鍊煎繀椤绘槸0~9999鑼冨洿鍐呯殑鏁存暟") ;
}
-
byte[] bs = new byte[13] ;
int index = 0 ;
@@ -68,16 +69,41 @@
index ++ ;
bs[index] = cvo.projectNo.byteValue() ;
- index ++ ;
- ByteUtilUnsigned.short2Bytes_BE(bs, cvo.waterAlarm, index);
index ++ ;
- ByteUtilUnsigned.short2Bytes_BE(bs, cvo.moneyAlarm, index);
+ String strTemp = "" + cvo.waterAlarm ;
+ byte[] bTemp = ByteUtil.string2BCD_LE(strTemp) ;
+ int bTempLen = bTemp.length ;
+ int count = 0 ;
+ for(int i = 0 ; i < bTempLen; i++){
+ bs[index++] = bTemp[i] ;
+ count ++ ;
+ if(count >= 2){
+ break ;
+ }
+ }
+ for(; count < 2; count++){
+ bs[index++] = 0 ;
+ }
- index ++ ;
+ strTemp = "" + cvo.moneyAlarm ;
+ bTemp = ByteUtil.string2BCD_LE(strTemp) ;
+ bTempLen = bTemp.length ;
+ count = 0 ;
+ for(int i = 0 ; i < bTempLen; i++){
+ bs[index++] = bTemp[i] ;
+ count ++ ;
+ if(count >= 2){
+ break ;
+ }
+ }
+ for(; count < 2; count++){
+ bs[index++] = 0 ;
+ }
+
GlCreate.createPw(bs, index);
- index ++ ;
+ index += 2 ;
GlCreate.createS2D(bs, index) ;
index += 4 ;
--
Gitblit v1.8.0