From 52cd0fe6f2224b0bd17b19ddaf475406a92b9ed4 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期五, 09 五月 2025 13:42:00 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd97.java | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 120 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd97.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd97.java new file mode 100644 index 0000000..9b1c38c --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd97.java @@ -0,0 +1,120 @@ +package com.dy.pipirrComCreator.p206V1; + +import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; +import com.dy.common.util.ByteUtil; +import com.dy.common.util.ByteUtilUnsigned; +import com.dy.common.util.IPUtils; +import com.dy.common.util.NumUtil; + +/** + * @Author: liurunyu + * @Date: 2025/5/7 11:25 + * @Description + */ +public class P206V1Cd97 extends P206V1Cd { + + public static final String ComCode = "97" ; + + public String checkParams(String ...params){ + if(params.length != 3){ + return "鍙湁铏氭嫙IC鍗$紪鍙枫�佸墿浣欓噾棰濄�佹按浠蜂笁涓弬鏁�" ; + } + //62090200300400001 + if(!NumUtil.isPlusIntNumber(params[0])){ + return "铏氭嫙IC鍗$紪鍙峰繀椤绘槸姝f暣鏁�" ; + } + if(params[0].length() != 17){ + return "铏氭嫙IC鍗$紪鍙峰繀椤绘槸17浣嶆暟瀛�" ; + } + //2.10 + if(!NumUtil.isPlusDoubleNumber(params[1])){ + return "鍓╀綑閲戦蹇呴』鏄鏁�" ; + } + Integer temp = (Double.valueOf(Double.parseDouble(params[1]) * 100.0D)).intValue() ; + if(temp <= 0){ + return "鍓╀綑閲戦蹇呴』鏄ぇ浜�0鐨勬鏁�" ; + } + if(temp >= 99999999){ + return "鍓╀綑閲戦蹇呴』鏄皬浜�999999.99鐨勬鏁�" ; + } + //1.23 + if(!NumUtil.isPlusDoubleNumber(params[2])){ + return "姘翠环蹇呴』鏄鏁�" ; + } + temp = (Double.valueOf(Double.parseDouble(params[2]) * 100.0D)).intValue() ; + if(temp <= 0){ + return "姘翠环蹇呴』鏄ぇ浜�0鐨勬鏁�" ; + } + if(temp >= 9999){ + return "姘翠环蹇呴』鏄皬浜�99.99鐨勬鏁�" ; + } + return null ; + } + public String helpInfo() { + return ComCode + " *...*(铏氭嫙IC鍗$紪鍙�) *...*(鍓╀綑閲戦) *...*(姘翠环)[Enter](APP杩滅▼寮�闃�)" ; + } + /** + * 鏋勯�犲懡浠ゆ暟鎹紙鍗佸叚杩涘埗锛� + * @return 瀛楃涓� + * @throws Exception 寮傚父 + */ + public String hex(String rtuAddr, String ...params) throws Exception { + byte[] bytes = bs(rtuAddr, params) ; + return ByteUtil.bytes2Hex(bytes, false) ; + } + + /** + * 鏋勯�犲懡浠ゆ暟鎹紙瀛楄妭鏁扮粍锛� + * @return 瀛楄妭鏁扮粍 + * @throws Exception 寮傚父 + */ + public byte[] bs(String rtuAddr, String ...params) throws Exception { + byte[] bytes = createHead(rtuAddr, ComCode, P206V1Cd.CTRL); + + byte[] bs = new byte[14] ; + byte n = 0 ; + GlCreate.createIcCardNo(params[0], bs, n); + + n += 8 ; + Integer money = Double.valueOf(Double.parseDouble(params[1]) * 100.0D).intValue() ; + byte[] bTemp = ByteUtil.int2BCD_LE(money) ; + int bTempLen = bTemp.length ; + int count = 0 ; + for(int i = 0 ; i < bTempLen; i++){ + bs[n++] = bTemp[i] ; + count ++ ; + if(count >= 4){ + break ; + } + } + for(; count < 4; count++){ + bs[n++] = 0 ; + } + + Integer price = Double.valueOf(Double.parseDouble(params[2]) * 100.0D).intValue() ; + bTemp = ByteUtil.int2BCD_LE(price) ; + bTempLen = bTemp.length ; + count = 0 ; + for(int i = 0 ; i < bTempLen; i++){ + bs[n++] = bTemp[i] ; + count ++ ; + if(count >= 2){ + break ; + } + } + for(; count < 2; count++){ + bs[n++] = 0 ; + } + + bytes = ByteUtil.bytesMerge(bytes, bs); + + GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑 + + byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓� + + bytes = ByteUtil.bytesMerge(bytes, bsTail) ; + + return bytes ; + } + +} \ No newline at end of file -- Gitblit v1.8.0