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/P206V1CdA0.java |  153 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 153 insertions(+), 0 deletions(-)

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

--
Gitblit v1.8.0