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

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

--
Gitblit v1.8.0