From 7aab004601e77890b158f19d1735594a8326feaa Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 24 四月 2025 17:11:17 +0800 Subject: [PATCH] 数据库事务注解位置调整 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 206 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java new file mode 100644 index 0000000..a67201e --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java @@ -0,0 +1,206 @@ +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.ComCd92_A2Vo; +import com.dy.common.mw.protocol.p206V202404.parse.global.GlCreate; +import com.dy.common.util.ByteUtil; +import com.dy.common.util.NumUtil; + +@AnnotationCodeDown(ifAny={ + CodeV202404.cd_92, + CodeV202404.cd_A2 +}) +public class Cd_92_A2_Down implements CodeParse { + + @Override + public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { + ParseParamsForDownV202404 para = (ParseParamsForDownV202404) params ; + byte[] bs = this.doParse(para) ; + + MidResultToRtu midRs = new MidResultToRtu() ; + midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О + midRs.protocolVersion = para.protocolVersion ;//鍗忚鐗堟湰鍙� + 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 ;//鏄惁鏈夊簲绛� + midRs.maxSendTimes = null ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆 + midRs.isCachForOffLine = false ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨锛屼綆鍔熻�楁椂涓簍rue + + midRs.isSendFirst = false ;//鍛戒护搴旂瓟锛岄鍏堝彂閫侊紝闃叉RTU閲嶆柊涓婃姤 + if(isLowPower != null && isLowPower.booleanValue()){ + //浣庡姛鑰楁椂锛屽敖蹇彂閫� + midRs.isQuickSend = true ; + } + + return new MidResult[]{midRs} ; + } + /** + * 鏋勯�犱笅琛屾暟鎹� + * @param para 鍙傛暟 + * @return 瀛楄妭鏁扮粍 + * @throws Exception 寮傚父 + */ + public byte[] doParse(ParseParamsForDownV202404 para) throws Exception { + byte[] bytes = GlCreate.createStart2Cd(para.rtuAddr, para.commandCode); + if(para.param != null){ + JSONObject obj = (JSONObject)para.param; + String json = obj.toJSONString(); + ComCd92_A2Vo cvo = JSON.parseObject(json, ComCd92_A2Vo.class) ; + if(cvo == null){ + throw new Exception("json杞珻omCd92_A2Vo涓簄ull") ; + } + if(cvo.waterRemain != null){ + if(cvo.waterRemain < 0 || cvo.waterRemain > 99999999.99){ + throw new Exception("鐢ㄦ埛鍓╀綑姘撮噺蹇呴』鏄�0~99999999.99鑼冨洿鍐呯殑鏁版嵁") ; + } + } + if(cvo.moneyRemain != null){ + if(cvo.moneyRemain < 0 || cvo.moneyRemain > 999999.99){ + throw new Exception("鐢ㄦ埛鍓╀綑閲戦蹇呴』鏄�0~999999.99鑼冨洿鍐呯殑鏁版嵁") ; + } + } + if(cvo.waterPrice != null){ + if(cvo.waterPrice < 0 || cvo.waterPrice > 99.99){ + throw new Exception("姘撮噺鍗曚环蹇呴』鏄�0~99.99鑼冨洿鍐呯殑鏁版嵁") ; + } + } + if(cvo.elePrice != null){ + if(cvo.elePrice < 0 || cvo.elePrice > 99.99){ + throw new Exception("鐢甸噺鍗曚环蹇呴』鏄�0~99.99鑼冨洿鍐呯殑鏁版嵁") ; + } + } + if(!NumUtil.isPlusIntNumber(cvo.orderNo)){ + throw new Exception("璁㈠崟鍙峰繀椤绘槸16浣嶆暟瀛�") ; + } + if(cvo.orderNo.length() != 16){ + throw new Exception("璁㈠崟鍙峰繀椤绘槸16浣嶆暟瀛�") ; + } + + + byte[] bs = new byte[45] ; + int index = 0 ; + bs[index] = (byte)(Integer.parseInt(cvo.controllerType, 16)); + + index ++ ; + bs[index] = cvo.projectNo.byteValue() ; + + index ++ ; + GlCreate.createValveOrPump(cvo.controllerType, bs, index) ; + + index ++ ; + GlCreate.createIcCardNo(cvo.icCardNo, bs, index); + + index += 8 ; + if(cvo.waterRemain == null){ + cvo.waterRemain = 0.0 ; + } + String strTemp = "" + Double.valueOf(cvo.waterRemain * 100).intValue() ; + 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 >= 5){ + break ; + } + } + for(; count < 5; count++){ + bs[index++] = 0 ; + } + + if(cvo.moneyRemain == null){ + cvo.moneyRemain = 0.0 ; + } + strTemp = "" + (Double.valueOf(cvo.moneyRemain * 10000)).intValue() ; + bTemp = ByteUtil.string2BCD_LE(strTemp) ; + bTempLen = bTemp.length ; + count = 0 ; + for(int i = 0 ; i < bTempLen; i++){ + bs[index++] = bTemp[i] ; + count ++ ; + if(count >= 4){ + break ; + } + } + for(; count < 4; count++){ + bs[index++] = 0 ; + } + + + if(cvo.waterPrice == null){ + cvo.waterPrice = 0.0 ; + } + strTemp = "" + (Double.valueOf(cvo.waterPrice * 100)).intValue() ; + 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 ; + } + + + if(cvo.elePrice == null){ + cvo.elePrice = 0.0 ; + } + strTemp = "" + (Double.valueOf(cvo.elePrice * 100)).intValue() ; + 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 ; + } + + + ByteUtil.string2BCD_BE(bs, cvo.orderNo, index) ; + + index += 8 ; + GlCreate.createDt(bs, index); + + index += 6 ; + GlCreate.createPw(bs, index); + + index += 2 ; + GlCreate.createS2D(bs, index) ; + + index += 4 ; + bs[index] = 0 ; //鏃跺欢 + + bytes = ByteUtil.bytesMerge(bytes, bs) ; + }else{ + throw new Exception("涓嬭鍛戒护鍙傛暟鎹负null") ; + } + GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑 + + byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬 + + bytes = ByteUtil.bytesMerge(bytes, bsTail) ; + + return bytes ; + } + + +} -- Gitblit v1.8.0