From eb51cf4365f8a8eefc3c0a605071813e86ba0194 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期五, 09 五月 2025 13:40:56 +0800 Subject: [PATCH] 命令生成器模块增加功能码97、98、99、A0、A1实现 --- pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA0.java | 153 +++++++++ pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd97.java | 120 +++++++ pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_98_Down.java | 2 pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd98.java | 64 +++ pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/console/Command.java | 2 pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd99.java | 153 +++++++++ pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd21.java | 2 pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA2.java | 236 +++++++++++++ pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA1.java | 236 +++++++++++++ pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Deal.java | 6 10 files changed, 971 insertions(+), 3 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_98_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_98_Down.java index 59ee2a9..54f8c78 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_98_Down.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_98_Down.java @@ -82,7 +82,7 @@ String json = obj.toJSONString(); Com98Vo cvo = JSON.parseObject(json, Com98Vo.class) ; if(cvo == null){ - throw new Exception("json杞珻om97Vo涓簄ull") ; + throw new Exception("json杞珻om98Vo涓簄ull") ; } if(cvo.icCardNo == null){ throw new Exception("铏氭嫙IC鍗$紪鍙蜂笉鑳戒负绌�") ; diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/console/Command.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/console/Command.java index 3a2aaa6..2f31671 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/console/Command.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/console/Command.java @@ -14,7 +14,7 @@ static{ commands = new String[]{ "config 鏌ョ湅閰嶇疆淇℃伅", - "XY ... 鍗忚鍛戒护", + "XY ... 鍗忚鍛戒护(3C銆�10銆�21銆�37銆�50銆�65銆�66銆�67銆�91銆�92銆�93銆�97銆�98銆�99銆丄0銆丄1銆丄2)", "XY -h 鍗忚鍛戒护甯姪", "exit 閫�鍑�", }; diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd21.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd21.java index 2b5da21..bd6c92b 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd21.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd21.java @@ -35,7 +35,7 @@ return null ; } public String helpInfo() { - return ComCode + " *...* *...*[Enter](璁剧疆鏈嶅姟绔疘P鍜岀鍙�)" ; + return ComCode + " *...*(IP) *...*(绔彛)[Enter](璁剧疆鏈嶅姟绔疘P鍜岀鍙�)" ; } /** * 鏋勯�犲懡浠ゆ暟鎹紙鍗佸叚杩涘埗锛� 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 diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd98.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd98.java new file mode 100644 index 0000000..2a40f90 --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd98.java @@ -0,0 +1,64 @@ +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.NumUtil; + +/** + * @Author: liurunyu + * @Date: 2025/5/7 11:25 + * @Description + */ +public class P206V1Cd98 extends P206V1Cd { + + public static final String ComCode = "98" ; + + public String checkParams(String ...params){ + if(params.length != 1){ + return "鍙湁铏氭嫙IC鍗$紪鍙蜂竴涓弬鏁�" ; + } + //62090200300400001 + if(!NumUtil.isPlusIntNumber(params[0])){ + return "铏氭嫙IC鍗$紪鍙峰繀椤绘槸姝f暣鏁�" ; + } + if(params[0].length() != 17){ + return "铏氭嫙IC鍗$紪鍙峰繀椤绘槸17浣嶆暟瀛�" ; + } + 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[8] ; + GlCreate.createIcCardNo(params[0], bs, 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 diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd99.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd99.java new file mode 100644 index 0000000..3e3d445 --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Cd99.java @@ -0,0 +1,153 @@ +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.NumUtil; + +/** + * @Author: liurunyu + * @Date: 2025/5/7 11:25 + * @Description + */ +public class P206V1Cd99 extends P206V1Cd { + + public static final String ComCode = "99" ; + + public String checkParams(String ...params){ + if(params.length != 4){ + 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鐨勬鏁�" ; + } + + if(!NumUtil.isPlusIntNumber(params[3])){ + return "鐢ㄦ按鏃堕暱蹇呴』鏄鏁存暟" ; + } + temp = Integer.parseInt(params[3]) ; + if(temp <= 0){ + return "鐢ㄦ按鏃堕暱蹇呴』鏄ぇ浜�0鐨勬鏁存暟" ; + } + if(temp > 9999){ + return "鐢ㄦ按鏃堕暱蹇呴』鏄皬浜�9999鐨勬鏁存暟" ; + } + return null ; + } + public String helpInfo() { + return ComCode + " *...*(铏氭嫙IC鍗$紪鍙�) *...*(鍓╀綑閲戦) *...*(姘翠环) *...*(鍒嗛挓鏃堕暱)[Enter](瀹氭椂鍏抽榾寮忓紑闃�)" ; + } + /** + * 鏋勯�犲懡浠ゆ暟鎹紙鍗佸叚杩涘埗锛� + * @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[8] ; + GlCreate.createIcCardNo(params[0], bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[4] ; + byte index = 0 ; + 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 4){ + break ; + } + } + for(; count < 4; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[2] ; + index = 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 2){ + break ; + } + } + for(; count < 2; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[2] ; + index = 0 ; + Integer minutes = Integer.parseInt(params[3]) ; + bTemp = ByteUtil.int2BCD_LE(minutes) ; + 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 ; + } + 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 diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA0.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA0.java new file mode 100644 index 0000000..f0a1809 --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA0.java @@ -0,0 +1,153 @@ +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.NumUtil; + +/** + * @Author: liurunyu + * @Date: 2025/5/7 11:25 + * @Description + */ +public class P206V1CdA0 extends P206V1Cd { + + public static final String ComCode = "A0" ; + + public String checkParams(String ...params){ + if(params.length != 4){ + 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鐨勬鏁�" ; + } + + if(!NumUtil.isPlusIntNumber(params[3])){ + return "鐢ㄦ按閲忓繀椤绘槸姝f暣鏁�" ; + } + temp = Integer.parseInt(params[3]) ; + if(temp <= 0){ + return "鐢ㄦ按閲忓繀椤绘槸澶т簬0鐨勬鏁存暟" ; + } + if(temp > 9999){ + return "鐢ㄦ按閲忓繀椤绘槸灏忎簬9999鐨勬鏁存暟" ; + } + return null ; + } + public String helpInfo() { + return ComCode + " *...*(铏氭嫙IC鍗$紪鍙�) *...*(鍓╀綑閲戦) *...*(姘翠环) *...*(绔嬫柟姘撮噺)[Enter](瀹氶噺鍏抽榾寮忓紑闃�)" ; + } + /** + * 鏋勯�犲懡浠ゆ暟鎹紙鍗佸叚杩涘埗锛� + * @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[8] ; + GlCreate.createIcCardNo(params[0], bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[4] ; + byte index = 0 ; + 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 4){ + break ; + } + } + for(; count < 4; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[2] ; + index = 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 2){ + break ; + } + } + for(; count < 2; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[2] ; + index = 0 ; + Integer amount = Integer.parseInt(params[3]) ; + bTemp = ByteUtil.int2BCD_LE(amount) ; + 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 ; + } + 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 diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA1.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA1.java new file mode 100644 index 0000000..b4583ad --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA1.java @@ -0,0 +1,236 @@ +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.DateTime; +import com.dy.common.util.NumUtil; + +/** + * @Author: liurunyu + * @Date: 2025/5/7 11:25 + * @Description + */ +public class P206V1CdA1 extends P206V1Cd { + + public static final String ComCode = "A1" ; + + public String checkParams(String ...params){ + if(params.length != 9){ + 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鐨勬鏁�" ; + } + + if(!NumUtil.isPlusIntNumber(params[3])){ + return "鐢ㄦ按鏃堕暱蹇呴』鏄鏁存暟" ; + } + temp = Integer.parseInt(params[3]) ; + if(temp <= 0){ + return "鐢ㄦ按鏃堕暱蹇呴』鏄ぇ浜�0鐨勬鏁存暟" ; + } + if(temp > 9999){ + return "鐢ㄦ按鏃堕暱蹇呴』鏄皬浜�9999鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[4])){ + return "骞村繀椤绘槸姝f暣鏁�" ; + } + int year = Integer.parseInt(params[4]) ; + if(year < 2025){ + return "骞村繀椤绘槸澶т簬绛変簬2025鐨勬鏁存暟" ; + } + if(year > 9999){ + return "骞村繀椤绘槸灏忎簬9999鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[5])){ + return "鏈堝繀椤绘槸姝f暣鏁�" ; + } + int month = Integer.parseInt(params[5]) ; + if(month <= 0){ + return "鏈堝繀椤绘槸澶т簬0鐨勬鏁存暟" ; + } + if(month > 12){ + return "鏈堝繀椤绘槸灏忎簬12鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[6])){ + return "鏃ュ繀椤绘槸姝f暣鏁�" ; + } + temp = Integer.parseInt(params[6]) ; + if(temp <= 0){ + return "鏃ュ繀椤绘槸澶т簬0鐨勬鏁存暟" ; + } + if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){ + if(temp > 31){ + return "鏃ュ繀椤绘槸灏忎簬31鐨勬鏁存暟" ; + } + }else if(month == 4 || month == 6 || month == 9 || month == 11){ + if(temp > 30){ + return "鏃ュ繀椤绘槸灏忎簬30鐨勬鏁存暟" ; + } + }else if(month == 2){ + if(DateTime.isLeapYear(year)){ + //娑﹀勾 + if(temp > 29){ + return "鏃ュ繀椤绘槸灏忎簬29鐨勬鏁存暟" ; + } + }else{ + if(temp > 28){ + return "鏃ュ繀椤绘槸灏忎簬28鐨勬鏁存暟" ; + } + } + } + + if(!NumUtil.isPlusIntNumber(params[7])){ + return "鏃跺繀椤绘槸姝f暣鏁�" ; + } + temp = Integer.parseInt(params[7]) ; + if(temp < 0){ + return "鏃跺繀椤绘槸澶т簬绛変簬0鐨勬鏁存暟" ; + } + if(temp >= 24){ + return "鏃跺繀椤绘槸灏忎簬24鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[8])){ + return "鍒嗛挓蹇呴』鏄鏁存暟" ; + } + temp = Integer.parseInt(params[8]) ; + if(temp < 0){ + return "鍒嗛挓蹇呴』鏄ぇ浜庣瓑浜�0鐨勬鏁存暟" ; + } + if(temp > 59){ + return "鍒嗛挓蹇呴』鏄皬浜庣瓑浜�59鐨勬鏁存暟" ; + } + return null ; + } + public String helpInfo() { + return ComCode + " *...*(铏氭嫙IC鍗$紪鍙�) *...*(鍓╀綑閲戦) *...*(姘翠环) *...*(鍒嗛挓鏃堕暱) ****(骞�) **(鏈�) **(鏃�) **(鏃�) **(鍒�)[Enter](瀹氭椂鍏抽榾寮忚鍒掑紑闃�)" ; + } + /** + * 鏋勯�犲懡浠ゆ暟鎹紙鍗佸叚杩涘埗锛� + * @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[8] ; + GlCreate.createIcCardNo(params[0], bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[4] ; + byte index = 0 ; + 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 4){ + break ; + } + } + for(; count < 4; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[2] ; + index = 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 2){ + break ; + } + } + for(; count < 2; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[2] ; + index = 0 ; + Integer minutes = Integer.parseInt(params[3]) ; + bTemp = ByteUtil.int2BCD_LE(minutes) ; + 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 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[5] ; + Integer year = Integer.parseInt(params[4]) ; + if(year >= 2024){ + year = year - 2000 ; + } + bs[0] = ByteUtil.int2BCD_LE(Integer.parseInt(params[8]))[0] ; + bs[1] = ByteUtil.int2BCD_LE(Integer.parseInt(params[7]))[0] ; + bs[2] = ByteUtil.int2BCD_LE(Integer.parseInt(params[6]))[0] ; + bs[3] = ByteUtil.int2BCD_LE(Integer.parseInt(params[5]))[0] ; + bs[4] = ByteUtil.int2BCD_LE(year)[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 diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA2.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA2.java new file mode 100644 index 0000000..825fd0d --- /dev/null +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1CdA2.java @@ -0,0 +1,236 @@ +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.DateTime; +import com.dy.common.util.NumUtil; + +/** + * @Author: liurunyu + * @Date: 2025/5/7 11:25 + * @Description + */ +public class P206V1CdA2 extends P206V1Cd { + + public static final String ComCode = "A2" ; + + public String checkParams(String ...params){ + if(params.length != 9){ + 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鐨勬鏁�" ; + } + + if(!NumUtil.isPlusIntNumber(params[3])){ + return "鐢ㄦ按閲忓繀椤绘槸姝f暣鏁�" ; + } + temp = Integer.parseInt(params[3]) ; + if(temp <= 0){ + return "鐢ㄦ按閲忓繀椤绘槸澶т簬0鐨勬鏁存暟" ; + } + if(temp > 9999){ + return "鐢ㄦ按閲忓繀椤绘槸灏忎簬9999鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[4])){ + return "骞村繀椤绘槸姝f暣鏁�" ; + } + int year = Integer.parseInt(params[4]) ; + if(year < 2025){ + return "骞村繀椤绘槸澶т簬绛変簬2025鐨勬鏁存暟" ; + } + if(year > 9999){ + return "骞村繀椤绘槸灏忎簬9999鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[5])){ + return "鏈堝繀椤绘槸姝f暣鏁�" ; + } + int month = Integer.parseInt(params[5]) ; + if(month <= 0){ + return "鏈堝繀椤绘槸澶т簬0鐨勬鏁存暟" ; + } + if(month > 12){ + return "鏈堝繀椤绘槸灏忎簬12鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[6])){ + return "鏃ュ繀椤绘槸姝f暣鏁�" ; + } + temp = Integer.parseInt(params[6]) ; + if(temp <= 0){ + return "鏃ュ繀椤绘槸澶т簬0鐨勬鏁存暟" ; + } + if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){ + if(temp > 31){ + return "鏃ュ繀椤绘槸灏忎簬31鐨勬鏁存暟" ; + } + }else if(month == 4 || month == 6 || month == 9 || month == 11){ + if(temp > 30){ + return "鏃ュ繀椤绘槸灏忎簬30鐨勬鏁存暟" ; + } + }else if(month == 2){ + if(DateTime.isLeapYear(year)){ + //娑﹀勾 + if(temp > 29){ + return "鏃ュ繀椤绘槸灏忎簬29鐨勬鏁存暟" ; + } + }else{ + if(temp > 28){ + return "鏃ュ繀椤绘槸灏忎簬28鐨勬鏁存暟" ; + } + } + } + + if(!NumUtil.isPlusIntNumber(params[7])){ + return "鏃跺繀椤绘槸姝f暣鏁�" ; + } + temp = Integer.parseInt(params[7]) ; + if(temp < 0){ + return "鏃跺繀椤绘槸澶т簬绛変簬0鐨勬鏁存暟" ; + } + if(temp >= 24){ + return "鏃跺繀椤绘槸灏忎簬24鐨勬鏁存暟" ; + } + + if(!NumUtil.isPlusIntNumber(params[8])){ + return "鍒嗛挓蹇呴』鏄鏁存暟" ; + } + temp = Integer.parseInt(params[8]) ; + if(temp < 0){ + return "鍒嗛挓蹇呴』鏄ぇ浜庣瓑浜�0鐨勬鏁存暟" ; + } + if(temp > 59){ + return "鍒嗛挓蹇呴』鏄皬浜庣瓑浜�59鐨勬鏁存暟" ; + } + return null ; + } + public String helpInfo() { + return ComCode + " *...*(铏氭嫙IC鍗$紪鍙�) *...*(鍓╀綑閲戦) *...*(姘翠环) *...*(绔嬫柟姘撮噺) ****(骞�) **(鏈�) **(鏃�) **(鏃�) **(鍒�)[Enter](瀹氶噺鍏抽榾寮忚鍒掑紑闃�)" ; + } + /** + * 鏋勯�犲懡浠ゆ暟鎹紙鍗佸叚杩涘埗锛� + * @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[8] ; + GlCreate.createIcCardNo(params[0], bs, 0); + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[4] ; + byte index = 0 ; + 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 4){ + break ; + } + } + for(; count < 4; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[2] ; + index = 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[index++] = bTemp[i] ; + count ++ ; + if(count >= 2){ + break ; + } + } + for(; count < 2; count++){ + bs[index++] = 0 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + + bs = new byte[2] ; + index = 0 ; + Integer amount = Integer.parseInt(params[3]) ; + bTemp = ByteUtil.int2BCD_LE(amount) ; + 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 ; + } + bytes = ByteUtil.bytesMerge(bytes, bs) ; + + bs = new byte[5] ; + Integer year = Integer.parseInt(params[4]) ; + if(year >= 2024){ + year = year - 2000 ; + } + bs[0] = ByteUtil.int2BCD_LE(Integer.parseInt(params[8]))[0] ; + bs[1] = ByteUtil.int2BCD_LE(Integer.parseInt(params[7]))[0] ; + bs[2] = ByteUtil.int2BCD_LE(Integer.parseInt(params[6]))[0] ; + bs[3] = ByteUtil.int2BCD_LE(Integer.parseInt(params[5]))[0] ; + bs[4] = ByteUtil.int2BCD_LE(year)[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 diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Deal.java b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Deal.java index ae53541..79e7f34 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Deal.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-com-creator/src/main/java/com/dy/pipirrComCreator/p206V1/P206V1Deal.java @@ -37,6 +37,12 @@ case CodeV1.cd_91: cdWithoutParam(new P206V1Cd91(), comList, prtWrt); break; case CodeV1.cd_92: cdWithoutParam(new P206V1Cd92(), comList, prtWrt); break; case CodeV1.cd_93: cdWithoutParam(new P206V1Cd93(), comList, prtWrt); break; + case CodeV1.cd_97: cdWithParam(new P206V1Cd97(), comList, prtWrt); break; + case CodeV1.cd_98: cdWithParam(new P206V1Cd98(), comList, prtWrt); break; + case CodeV1.cd_99: cdWithParam(new P206V1Cd99(), comList, prtWrt); break; + case CodeV1.cd_A0: cdWithParam(new P206V1CdA0(), comList, prtWrt); break; + case CodeV1.cd_A1: cdWithParam(new P206V1CdA1(), comList, prtWrt); break; + case CodeV1.cd_A2: cdWithParam(new P206V1CdA2(), comList, prtWrt); break; default: Command.outNoIdentify(prtWrt); break; } } -- Gitblit v1.8.0