From 7fe4118083e8917cc9cf333309ca84ab6c9aefa5 Mon Sep 17 00:00:00 2001 From: "jiangr.wu@sunyard.com" Date: Tue, 12 Aug 2025 15:04:10 +0800 Subject: [PATCH] =?UTF-8?q?16=E8=BF=9B=E5=88=B6=E9=94=99=E8=AF=AF=E7=A0=81?= =?UTF-8?q?=E6=94=B9=E6=88=9010=E8=BF=9B=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sge/database/SydApiBaseFunction.java | 85 ++++++++++++++++--- 1 file changed, 72 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java b/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java index 261c65b..8fe1b42 100644 --- a/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java +++ b/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java @@ -300,9 +300,6 @@ public class SydApiBaseFunction implements SydApi { @Override public byte[] SYD_SM4_ShortData(int iKeyIndex, byte[] pcData, int iFlag) { - if (iKeyIndex < 0) { - throw new SydApiException(0x01000001); - } if ( log.isDebugEnabled() ) { log.debug("SYD_SM4_ShortData方法接收参数:iKeyIndex:{},pcData:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData), iFlag); } @@ -351,6 +348,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } else { @@ -375,6 +376,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } @@ -426,9 +431,6 @@ public class SydApiBaseFunction implements SydApi { String[] keys = new String[iKeyIndex.length]; updateLastUseTime(); for (int i = 0; i < iKeyIndex.length; i++) { - if (iKeyIndex[i] < 0) { - throw new SydApiException(0x01000001); - } keys[i] = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex[i])); } @@ -451,6 +453,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } else { @@ -468,6 +474,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } @@ -486,10 +496,6 @@ public class SydApiBaseFunction implements SydApi { log.debug("SYD_SM4_LongData方法接收参数:iKeyIndex:{},pcData:{},iPkgNum:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData), iPkgNum, iFlag); } - if (iKeyIndex < 0) { - throw new SydApiException(0x01000001); - } - if(iFlag != Consts.ECB_ENC && iFlag != Consts.ECB_DEC){ throw new SydApiException("加解密标识错误", 0x01000001); } @@ -537,6 +543,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } else { @@ -564,6 +574,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } @@ -630,6 +644,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } else { @@ -651,6 +669,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } @@ -723,6 +745,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } else { @@ -752,6 +778,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } @@ -821,6 +851,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } else { @@ -835,6 +869,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } @@ -1252,9 +1290,6 @@ public class SydApiBaseFunction implements SydApi { String[] keys = new String[iKeyIndex.length]; updateLastUseTime(); for (int i = 0; i < iKeyIndex.length; i++) { - if (iKeyIndex[i] < 0) { - throw new SydApiException(0x01000001); - } keys[i] = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex[i])); } SydApiException le = new SydApiException(-1); @@ -1280,6 +1315,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } else { @@ -1301,6 +1340,10 @@ public class SydApiBaseFunction implements SydApi { log.error("HA 重试"); continue; } + SydApiException exception = dealException(e); + if(exception != null){ + throw exception; + } throw e; } } @@ -1437,4 +1480,20 @@ public class SydApiBaseFunction implements SydApi { protected void finalize() throws Throwable { this.SYD_Disconnect_Ex(); } + + //底层jar返回的错误吗和文档对不上,修改下 + private SydApiException dealException(SydApiException e){ + SydApiException exception = null; + switch (e.getRetCode()){ + case 21: + exception = new SydApiException(0x21); + break; + case 44: + exception = new SydApiException(0x44); + break; + } + + return exception; + } + }