16进制错误码改成10进制

This commit is contained in:
jiangr.wu@sunyard.com 2025-08-12 15:04:10 +08:00
parent 4ad5250026
commit 7fe4118083

View File

@ -300,9 +300,6 @@ public class SydApiBaseFunction implements SydApi {
@Override @Override
public byte[] SYD_SM4_ShortData(int iKeyIndex, byte[] pcData, int iFlag) { public byte[] SYD_SM4_ShortData(int iKeyIndex, byte[] pcData, int iFlag) {
if (iKeyIndex < 0) {
throw new SydApiException(0x01000001);
}
if ( log.isDebugEnabled() ) { if ( log.isDebugEnabled() ) {
log.debug("SYD_SM4_ShortData方法接收参数iKeyIndex{},pcData{},iFlag{}", iKeyIndex, Arrays.toString(pcData), iFlag); 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 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} else { } else {
@ -375,6 +376,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} }
@ -426,9 +431,6 @@ public class SydApiBaseFunction implements SydApi {
String[] keys = new String[iKeyIndex.length]; String[] keys = new String[iKeyIndex.length];
updateLastUseTime(); updateLastUseTime();
for (int i = 0; i < iKeyIndex.length; i++) { 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])); keys[i] = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex[i]));
} }
@ -451,6 +453,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} else { } else {
@ -468,6 +474,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; 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); 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){ if(iFlag != Consts.ECB_ENC && iFlag != Consts.ECB_DEC){
throw new SydApiException("加解密标识错误", 0x01000001); throw new SydApiException("加解密标识错误", 0x01000001);
} }
@ -537,6 +543,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} else { } else {
@ -564,6 +574,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} }
@ -630,6 +644,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} else { } else {
@ -651,6 +669,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} }
@ -723,6 +745,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} else { } else {
@ -752,6 +778,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} }
@ -821,6 +851,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} else { } else {
@ -835,6 +869,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} }
@ -1252,9 +1290,6 @@ public class SydApiBaseFunction implements SydApi {
String[] keys = new String[iKeyIndex.length]; String[] keys = new String[iKeyIndex.length];
updateLastUseTime(); updateLastUseTime();
for (int i = 0; i < iKeyIndex.length; i++) { 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])); keys[i] = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex[i]));
} }
SydApiException le = new SydApiException(-1); SydApiException le = new SydApiException(-1);
@ -1280,6 +1315,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} else { } else {
@ -1301,6 +1340,10 @@ public class SydApiBaseFunction implements SydApi {
log.error("HA 重试"); log.error("HA 重试");
continue; continue;
} }
SydApiException exception = dealException(e);
if(exception != null){
throw exception;
}
throw e; throw e;
} }
} }
@ -1437,4 +1480,20 @@ public class SydApiBaseFunction implements SydApi {
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
this.SYD_Disconnect_Ex(); 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;
}
} }