From 85d774d0e46563b3a06205ac9bda5717a9c18cb3 Mon Sep 17 00:00:00 2001 From: "junj2.liang" Date: Fri, 2 Sep 2022 12:10:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sunyard/sge/database/SydApi4Database.java | 33 +++++++++---------- .../java/com/sunyard/sge/log/LogFactory.java | 12 +++---- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/sunyard/sge/database/SydApi4Database.java b/src/main/java/com/sunyard/sge/database/SydApi4Database.java index adb9f5a..405f447 100644 --- a/src/main/java/com/sunyard/sge/database/SydApi4Database.java +++ b/src/main/java/com/sunyard/sge/database/SydApi4Database.java @@ -132,8 +132,7 @@ public class SydApi4Database implements SydApi { if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } - @CheckForNull - SydApiException le = null; + SydApiException le = new SydApiException(0); updateLastUseTime(); for (SydApi4j api : this.hsms) { @@ -191,8 +190,8 @@ public class SydApi4Database implements SydApi { log.debug("Util.hexString2Bytes方法返回值:{}", Arrays.toString(procData)); } - @CheckForNull - SydApiException le = null; + + SydApiException le = new SydApiException(0); updateLastUseTime(); for (SydApi4j api : this.hsms) { if (null == api) { @@ -236,6 +235,7 @@ public class SydApi4Database implements SydApi { } } } + throw le; } @@ -254,8 +254,7 @@ public class SydApi4Database implements SydApi { updateLastUseTime(); String keyIndex = String.format("%08d", iKeyIndex); - @CheckForNull - SydApiException le = null; + SydApiException le = new SydApiException(0); for (SydApi4j api : this.hsms) { if (null == api) { continue; @@ -335,8 +334,8 @@ public class SydApi4Database implements SydApi { for (int i = 0; i < iKeyIndex.length; i++) { keys[i] = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex[i])); } - @CheckForNull - SydApiException le = null; + + SydApiException le = new SydApiException(0); for (SydApi4j api : this.hsms) { if (null == api) { continue; @@ -394,8 +393,8 @@ public class SydApi4Database implements SydApi { } updateLastUseTime(); String keyIndex = String.format("%08d", iKeyIndex); - @CheckForNull - SydApiException le = null; + + SydApiException le = new SydApiException(0); for (SydApi4j api : this.hsms) { if (null == api) { continue; @@ -478,8 +477,7 @@ public class SydApi4Database implements SydApi { for (int i = 0; i < iKeyIndex.length; i++) { keys[i] = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex[i])); } - @CheckForNull - SydApiException le = null; + SydApiException le = new SydApiException(0); for (SydApi4j api : this.hsms) { if (null == api) { continue; @@ -546,8 +544,8 @@ public class SydApi4Database implements SydApi { for (int i = 0; i < iKeyIndex.length; i++) { keys[i] = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex[i])); } - @CheckForNull - SydApiException le = null; + + SydApiException le = new SydApiException(0); for (SydApi4j api : this.hsms) { if (null == api) { continue; @@ -617,8 +615,7 @@ public class SydApi4Database implements SydApi { if (Consts.PkgNumAll != iPkgNum && Consts.PkgNumHead != iPkgNum) { iv = pcProcData.getBytes(); } - @CheckForNull - SydApiException le = null; + SydApiException le = new SydApiException(0); updateLastUseTime(); for (SydApi4j api : this.hsms) { if (null == api) { @@ -716,8 +713,8 @@ public class SydApi4Database implements SydApi { } String keyIndex = "SK" + SYMUtil.genPrivateKeyMark("000000", "00A", String.format("%08d", iKeyIndex)); log.debug("\"SK\" + SYMUtil.genPrivateKeyMark方法返回值:{}", keyIndex); - @CheckForNull - SydApiException le = null; + + SydApiException le = new SydApiException(0); updateLastUseTime(); for (SydApi4j api : this.hsms) { if (null == api) { diff --git a/src/main/java/com/sunyard/sge/log/LogFactory.java b/src/main/java/com/sunyard/sge/log/LogFactory.java index bb98509..a7e9170 100644 --- a/src/main/java/com/sunyard/sge/log/LogFactory.java +++ b/src/main/java/com/sunyard/sge/log/LogFactory.java @@ -35,8 +35,8 @@ public class LogFactory { // 日志目录 public static String pcLogPath = "./sydapi-logs/"; - // 日期格式 - public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); +// // 日期格式 +// private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); private LogFactory() { } @@ -59,10 +59,10 @@ public class LogFactory { // "/logs/test/" + jobID + "/syncshows-job-" + jobID + ".log.gz", // "true", jobID, null, null, null, tp, null, layout, null, // null, null, null, config); - + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); // 日志打印方式——输出为文件    Appender appender = FileAppender.createAppender( - String.format( pcLogPath +"sydapi_"+getToday() + ".log"), + String.format( pcLogPath +"sydapi_"+ format.format(new Date()) + ".log"), "true", "false", logName, null, "true", "true", null, layout, null, null, null, config); @@ -88,10 +88,6 @@ public class LogFactory { } - public static String getToday(){ - return format.format( new Date()); - } - /** * 创建 Logger * @return Logger