From ca612d869c4f1fad2dc36b06623e55cbabd88246 Mon Sep 17 00:00:00 2001 From: wangsq Date: Tue, 11 Aug 2026 10:14:15 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=87=E4=BB=B6=E8=BD=ACbase64?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96=202?= =?UTF-8?q?=E3=80=81=E9=83=A8=E5=88=86=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BA=E6=A1=86=E6=9E=B6=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ynxbd/common/TestA.java | 13 --- .../com/ynxbd/common/helper/ProperHelper.java | 6 +- .../ynxbd/common/helper/cache/TextCache.java | 5 +- .../common/helper/common/Base64Helper.java | 26 +++-- .../common/helper/common/CodeHelper.java | 7 +- .../common/helper/common/DateHelper.java | 33 +++---- .../common/helper/common/FileHelper.java | 73 +++++++------- .../ynxbd/common/helper/common/FtpHelper.java | 19 ++-- .../common/helper/common/HMACHelper.java | 7 +- .../common/helper/common/JsonHelper.java | 2 +- .../common/helper/common/ParamHelper.java | 4 +- .../common/helper/common/XmlConfigHelper.java | 8 +- .../com/ynxbd/common/his/old/HisHelper.java | 97 ++++++++++++++++--- 13 files changed, 188 insertions(+), 112 deletions(-) diff --git a/src/main/java/com/ynxbd/common/TestA.java b/src/main/java/com/ynxbd/common/TestA.java index 0d0ea01..62457ad 100644 --- a/src/main/java/com/ynxbd/common/TestA.java +++ b/src/main/java/com/ynxbd/common/TestA.java @@ -10,23 +10,10 @@ import com.ynxbd.wx.wxfactory.AesWxHelper; import java.math.BigDecimal; public class TestA { - private static final String PUB_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5klqI5STWTcbfjR093j+hvCEjNlZMQscIJg8jxZGqKW84AdFmSqPWEPu9ilqP+QUASiVSZ1QevGr2DWODFZ8Zw35aDA2bqCEprUx81gDdVPO7H7Bij+r8zAg8fT2c0Bi5rFq0xWMEQiTI+CyWwc5prOpquJU/P5yauEAdkRzlDwIDAQAB"; public static void main(String[] args) throws Exception{ -// String content = "533103198212184014"; -// byte[] bytes = RSAHelper.enPKCS1PaddingToByte(content, PUB_KEY); -// System.out.println("【Java最终hex】:" + HexUtil.encodeHexStr(bytes)); -// RSA rsa = new RSA(AsymmetricAlgorithm.RSA_ECB_PKCS1.getValue(), -// "你的私钥base64", -// "你的公钥base64"); - -// System.out.println(AesWxHelper.encode("192970")); - String totalFee = "0.01"; - String cents = new BigDecimal(totalFee).movePointRight(2).toString(); - System.out.println(cents); } -// diff --git a/src/main/java/com/ynxbd/common/helper/ProperHelper.java b/src/main/java/com/ynxbd/common/helper/ProperHelper.java index 9631081..6ecc109 100644 --- a/src/main/java/com/ynxbd/common/helper/ProperHelper.java +++ b/src/main/java/com/ynxbd/common/helper/ProperHelper.java @@ -74,7 +74,7 @@ public class ProperHelper { String val = properties.getProperty(rootNode); return val == null ? defaultVal : val.trim(); } catch (Exception e) { - e.printStackTrace(); + log.error("[数据类型转换异常]", e); return null; } } @@ -95,7 +95,7 @@ public class ProperHelper { String val = properties.getProperty(rootNode); return val == null ? defaultVal : Boolean.parseBoolean(val.trim()); } catch (Exception e) { - e.printStackTrace(); + log.error("[数据类型转换异常]", e); return defaultVal; } } @@ -112,7 +112,7 @@ public class ProperHelper { String val = getString(rootNode, null); return val == null ? null : Integer.parseInt(val.trim()); } catch (Exception e) { - e.printStackTrace(); + log.error("[数据类型转换异常]", e); return null; } } diff --git a/src/main/java/com/ynxbd/common/helper/cache/TextCache.java b/src/main/java/com/ynxbd/common/helper/cache/TextCache.java index 845d2e0..2d0c662 100644 --- a/src/main/java/com/ynxbd/common/helper/cache/TextCache.java +++ b/src/main/java/com/ynxbd/common/helper/cache/TextCache.java @@ -1,6 +1,7 @@ package com.ynxbd.common.helper.cache; import com.ynxbd.common.helper.common.FileHelper; +import org.apache.commons.lang3.ObjectUtils; import java.util.List; @@ -17,7 +18,7 @@ public class TextCache { public static String textFilter(String text) { - if (text == null || "".equals(text)) { + if (ObjectUtils.isEmpty(text)) { return null; } if (textList == null) { // 初始化 @@ -27,7 +28,7 @@ public class TextCache { return text; } - if (textList.size() == 0) { + if (textList.isEmpty()) { return text; } StringBuilder sb; diff --git a/src/main/java/com/ynxbd/common/helper/common/Base64Helper.java b/src/main/java/com/ynxbd/common/helper/common/Base64Helper.java index 4dc6668..6b88168 100644 --- a/src/main/java/com/ynxbd/common/helper/common/Base64Helper.java +++ b/src/main/java/com/ynxbd/common/helper/common/Base64Helper.java @@ -1,5 +1,6 @@ package com.ynxbd.common.helper.common; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.rendering.ImageType; @@ -19,6 +20,7 @@ import java.util.UUID; * @Date 2020/8/3 15:37 * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved. */ +@Slf4j public class Base64Helper { /** @@ -144,14 +146,24 @@ public class Base64Helper { * @return base64 */ public static String imageToBase(File imgFile) { + if (imgFile == null) { + throw new NullPointerException("图片文件不能为null"); + } + if (!imgFile.exists() || !imgFile.isFile() || !imgFile.canRead()) { + return null; + } try (FileInputStream fis = new FileInputStream(imgFile)) { - byte[] buffer = new byte[(int) imgFile.length()]; - fis.read(buffer); - return java.util.Base64.getEncoder().encodeToString(buffer); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + byte[] buf = new byte[4096]; + int len; + while ((len = fis.read(buf)) != -1) { + bos.write(buf, 0, len); + } + return java.util.Base64.getEncoder().encodeToString(bos.toByteArray()); } catch (Exception e) { - e.printStackTrace(); + log.error("[图片转base64异常]", e); + return null; } - return null; } public static String pdfBaseToImgBase(String base64) { @@ -231,7 +243,7 @@ public class Base64Helper { imgBase64 = "data:image/png;base64," + imgBase64.replaceAll("\n", "").replaceAll("\r", ""); //删除 \r\n return imgBase64; } catch (IOException e) { - e.printStackTrace(); + log.error("", e); } finally { try { if (bos != null) { @@ -243,7 +255,7 @@ public class Base64Helper { pdDoc.close(); } } catch (Exception e) { - e.printStackTrace(); + log.error("", e); } } return null; diff --git a/src/main/java/com/ynxbd/common/helper/common/CodeHelper.java b/src/main/java/com/ynxbd/common/helper/common/CodeHelper.java index 60efbcb..2cd8ccf 100644 --- a/src/main/java/com/ynxbd/common/helper/common/CodeHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/CodeHelper.java @@ -58,10 +58,6 @@ public class CodeHelper { // } - public static void main(String[] args) { - System.out.println(UUID.randomUUID()); - } - /** * 生成数字验证码 * @@ -213,7 +209,7 @@ public class CodeHelper { /** * 中文數字转阿拉伯数组【十万九千零六十 --> 109060】 * - * @param chineseNumber + * @param chineseNumber 中文数字 * @return 阿拉伯数字 */ public static int chineseNumber2Int(String chineseNumber) { @@ -229,7 +225,6 @@ public class CodeHelper { if (c == cnArr[j]) { if (0 != count) {//添加下一个单位之前,先把上一个单位值添加到结果中 result += temp; - temp = 1; count = 0; } // 下标+1,就是对应的值 diff --git a/src/main/java/com/ynxbd/common/helper/common/DateHelper.java b/src/main/java/com/ynxbd/common/helper/common/DateHelper.java index a95d797..b3713fd 100644 --- a/src/main/java/com/ynxbd/common/helper/common/DateHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/DateHelper.java @@ -8,7 +8,6 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.ParsePosition; import java.text.SimpleDateFormat; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Calendar; @@ -122,7 +121,7 @@ public class DateHelper { return new SimpleDateFormat(DateEnum.HH_mm_ss.TYPE) .format(new SimpleDateFormat(DateEnum.yyyy_MM_dd_HH_mm_ss.TYPE).parse(dateStr)); } catch (Exception e) { - ErrorHelper.println(e); + log.error("", e); return null; } } @@ -139,7 +138,7 @@ public class DateHelper { try { return new SimpleDateFormat(format).parse(dateStr); } catch (Exception e) { - ErrorHelper.println(e); + log.error("", e); return null; } } @@ -168,7 +167,7 @@ public class DateHelper { try { return new SimpleDateFormat(format).format(date); } catch (Exception e) { - ErrorHelper.println(e); + log.error("", e); return null; } } @@ -207,7 +206,7 @@ public class DateHelper { } return Integer.parseInt(String.valueOf(between_days)) + (isInclude ? 1 : -1); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return -1; } } @@ -263,7 +262,7 @@ public class DateHelper { long curTime = format.parse(dateTime).getTime(); // 当前时间点 return curTime > spotTime; } catch (Exception e) { - ErrorHelper.println(e); + log.error("", e); } return null; } @@ -290,7 +289,7 @@ public class DateHelper { return moveTime > dateTime; } catch (Exception e) { - ErrorHelper.println(e); + log.error("", e); } return null; } @@ -346,7 +345,7 @@ public class DateHelper { * @return 转换后的时间 */ public static String timeToHms(String timeStr, String defaultTimeStr) { - if (timeStr == null || "".equals(timeStr)) { + if (ObjectUtils.isEmpty(timeStr)) { timeStr = defaultTimeStr; } else { @@ -375,8 +374,7 @@ public class DateHelper { SimpleDateFormat hmsFormat = new SimpleDateFormat(DateEnum.HH_mm_ss.TYPE); return hmsFormat.format(hmDate); } catch (Exception e) { - e.printStackTrace(); - ErrorHelper.println(e); + log.error("", e); } return null; } @@ -447,7 +445,7 @@ public class DateHelper { return nowCalendar.after(beginCalendar) && nowCalendar.before(endCalendar); } catch (ParseException e) { - e.printStackTrace(); + log.error("", e); } return false; } @@ -503,6 +501,7 @@ public class DateHelper { day.setTime(time * 1000); return format.format(day); } catch (Exception e) { + log.error("", e); return null; } } @@ -528,11 +527,11 @@ public class DateHelper { day.setTime(time * 1000); return format.format(day); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return null; } } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return null; } } @@ -567,7 +566,7 @@ public class DateHelper { day.setTime(time * 1000); return format.format(day); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return null; } } @@ -585,7 +584,7 @@ public class DateHelper { SimpleDateFormat format = new SimpleDateFormat(DateEnum.yyyy_MM_dd.TYPE); return getMoveDate(format.format(date), moveDays); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return null; } } @@ -619,7 +618,7 @@ public class DateHelper { day.setTime(time * 1000); return format.format(day); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return null; } } @@ -637,7 +636,7 @@ public class DateHelper { Date tempDate = timeSdf.parse(inTime); outTime = dateSdf.format(dateSdf.parse(timeSdf.format(tempDate))); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); } return outTime; } diff --git a/src/main/java/com/ynxbd/common/helper/common/FileHelper.java b/src/main/java/com/ynxbd/common/helper/common/FileHelper.java index 8819552..3fd02fa 100644 --- a/src/main/java/com/ynxbd/common/helper/common/FileHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/FileHelper.java @@ -18,6 +18,9 @@ import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.security.AccessController; import java.security.PrivilegedAction; import java.text.SimpleDateFormat; @@ -41,33 +44,37 @@ public class FileHelper { * @return 读取到的字符串内容 */ public static String readFile(String filePath, boolean isRelative) { - if (isRelative) filePath = ROOT_PATH + filePath; - - log.info("读取文件-{filePath:{}}", filePath); + if (ObjectUtils.isEmpty(filePath)) { + log.warn("文件路径为空"); + return ""; + } - File file = new File(filePath); + Path path; + if (isRelative) { + path = Paths.get(ROOT_PATH, filePath); + } else { + path = Paths.get(filePath); + } + String absPath = path.toAbsolutePath().toString(); + log.info("读取文件,path:{}", absPath); - StringBuilder result = new StringBuilder(); + File file = path.toFile(); + if (!file.exists() || !file.isFile() || !file.canRead()) { + log.warn("文件不存在或不可读:{}", absPath); + return ""; + } - if (file.exists()) { - BufferedReader br = null; - try { - br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - String str; - while ((str = br.readLine()) != null) { - result.append(str); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (br != null) br.close(); - } catch (IOException e) { - e.printStackTrace(); - } + StringBuilder sb = new StringBuilder(); + try (BufferedReader br = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { + String line; + while ((line = br.readLine()) != null) { + sb.append(line); } + } catch (IOException e) { + log.error("读取文件异常,path:{}", absPath, e); + return ""; } - return result.toString(); + return sb.toString(); } @@ -81,15 +88,15 @@ public class FileHelper { String line; while ((line = br.readLine()) != null) { line = line.trim(); - if (!"".equals(line)) { + if (!line.isEmpty()) { dataList.add(line); } } } catch (Exception e) { - e.printStackTrace(); + log.error("", e); } } catch (Exception e) { - e.printStackTrace(); + log.error("", e); } return dataList; } @@ -115,7 +122,7 @@ public class FileHelper { out = new FileOutputStream(path); out.write(data); } catch (IOException e) { - e.printStackTrace(); + log.error("", e); return null; } finally { if (out != null) { @@ -123,7 +130,7 @@ public class FileHelper { out.flush(); out.close(); } catch (IOException e) { - e.printStackTrace(); + log.error("", e); } } } @@ -200,7 +207,7 @@ public class FileHelper { return file.isFile() ? filePath : null; // 文件存在返回路径,不存在返回null } } catch (IOException e) { - e.printStackTrace(); + log.error("", e); } return null; } @@ -270,7 +277,7 @@ public class FileHelper { bw = new BufferedWriter(new FileWriter(path, append)); bw.write(content); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return null; } finally { try { @@ -279,7 +286,7 @@ public class FileHelper { bw.close(); } } catch (IOException e) { - e.printStackTrace(); + log.error("", e); } } log.info(isRelative ? "相对路径:{}" : "绝对路径:{}", relativePath, path); @@ -310,7 +317,7 @@ public class FileHelper { // decodedBytes = base64Decoder.decodeBuffer(data); decodedBytes = java.util.Base64.getDecoder().decode(data); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); return null; } @@ -389,7 +396,7 @@ public class FileHelper { if (in != null) in.close(); } catch (IOException e) { - e.printStackTrace(); + log.error("", e); } } return null; @@ -444,7 +451,7 @@ public class FileHelper { log.info("临时文件[{}]清除 {}", fileName, (file.delete() ? "成功" : "失败")); } } catch (Exception e) { - e.printStackTrace(); + log.error("", e); } } return content.toString(); diff --git a/src/main/java/com/ynxbd/common/helper/common/FtpHelper.java b/src/main/java/com/ynxbd/common/helper/common/FtpHelper.java index 1fff1da..0d3a5dd 100644 --- a/src/main/java/com/ynxbd/common/helper/common/FtpHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/FtpHelper.java @@ -25,9 +25,9 @@ public class FtpHelper { private final String pass; - public byte[] getFile(String path){ + public byte[] getFile(String path) { FTPClient ftpClient = new FTPClient(); - ftpClient.setConnectTimeout(60*000); //连接超时为60秒 + ftpClient.setConnectTimeout(60 * 000); //连接超时为60秒 ftpClient.setControlEncoding("utf-8"); ftpClient.enterLocalPassiveMode(); try { @@ -37,25 +37,24 @@ public class FtpHelper { log.info("[FTP]登陆成功"); FTPFile ftpFile = ftpClient.mlistFile(path); if (ftpFile != null) { - log.info("[FTP]读取到文件:{}",ftpFile.getName()); + log.info("[FTP]读取到文件:{}", ftpFile.getName()); InputStream inputStream = ftpClient.retrieveFileStream(path); - byte[] fileData = IOUtils.toByteArray(inputStream); - return fileData; + return IOUtils.toByteArray(inputStream); } else { - log.error("[FTP]读取共享文件失败 路径---{}",path); + log.error("[FTP]读取共享文件失败 路径---{}", path); } ftpClient.logout(); ftpClient.disconnect(); - } catch (IOException ex) { + } catch (IOException e) { log.error("[FTP]ftp连接失败"); - ex.printStackTrace(); + log.error("", e); } finally { if (ftpClient.isConnected()) { try { ftpClient.disconnect(); - } catch (IOException ex) { - ex.printStackTrace(); + } catch (IOException e) { + log.error("", e); } } } diff --git a/src/main/java/com/ynxbd/common/helper/common/HMACHelper.java b/src/main/java/com/ynxbd/common/helper/common/HMACHelper.java index d5f46af..331958d 100644 --- a/src/main/java/com/ynxbd/common/helper/common/HMACHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/HMACHelper.java @@ -1,5 +1,7 @@ package com.ynxbd.common.helper.common; +import lombok.extern.slf4j.Slf4j; + import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; @@ -7,6 +9,7 @@ import java.nio.charset.StandardCharsets; /** * HMAC算法 */ +@Slf4j public class HMACHelper { public static String sha256(String data, String key) { @@ -22,11 +25,11 @@ public class HMACHelper { StringBuilder sb = new StringBuilder(); for (byte item : array) { - sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); + sb.append(Integer.toHexString((item & 0xFF) | 0x100), 1, 3); } return sb.toString(); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); } return null; } diff --git a/src/main/java/com/ynxbd/common/helper/common/JsonHelper.java b/src/main/java/com/ynxbd/common/helper/common/JsonHelper.java index 4cdc305..04a76dd 100644 --- a/src/main/java/com/ynxbd/common/helper/common/JsonHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/JsonHelper.java @@ -113,7 +113,7 @@ public class JsonHelper { try { return JSON.parseObject(json, typeReference); } catch (Exception e) { - e.printStackTrace(); + log.error("", e); } return null; } diff --git a/src/main/java/com/ynxbd/common/helper/common/ParamHelper.java b/src/main/java/com/ynxbd/common/helper/common/ParamHelper.java index 9a681ec..09ab8ff 100644 --- a/src/main/java/com/ynxbd/common/helper/common/ParamHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/ParamHelper.java @@ -80,7 +80,7 @@ public class ParamHelper { * @return id集 */ public static String verifyIds(List idList) { - if (idList.size() == 0) { + if (idList.isEmpty()) { return null; } @@ -293,7 +293,7 @@ public class ParamHelper { * @return 是否有效 */ public static boolean isValid(String idNumber) { - if (idNumber == null || "".equals(idNumber)) { + if (ObjectUtils.isEmpty(idNumber)) { return false; } diff --git a/src/main/java/com/ynxbd/common/helper/common/XmlConfigHelper.java b/src/main/java/com/ynxbd/common/helper/common/XmlConfigHelper.java index 2a7ef03..117d242 100644 --- a/src/main/java/com/ynxbd/common/helper/common/XmlConfigHelper.java +++ b/src/main/java/com/ynxbd/common/helper/common/XmlConfigHelper.java @@ -71,7 +71,7 @@ public class XmlConfigHelper { config.root = root.element(nodeName); return config; } catch (Exception e) { - log.error("", e); + log.error("[数据类型转换异常]", e); return null; } } @@ -91,7 +91,7 @@ public class XmlConfigHelper { String val = root.elementTextTrim(rootNode); return ObjectUtils.isEmpty(val) ? defaultVal : Boolean.parseBoolean(val); } catch (Exception e) { - log.error("", e); + log.error("[数据类型转换异常]", e); return defaultVal; } } @@ -126,7 +126,7 @@ public class XmlConfigHelper { String val = root.elementTextTrim(rootNode); return ObjectUtils.isEmpty(val) ? defaultVal : val; } catch (Exception e) { - log.error("", e); + log.error("[数据类型转换异常]", e); return null; } } @@ -143,7 +143,7 @@ public class XmlConfigHelper { String val = getString(rootNode, null); return ObjectUtils.isEmpty(val) ? null : Integer.parseInt(val.trim()); } catch (Exception e) { - log.error("", e); + log.error("[数据类型转换异常]", e); return null; } } diff --git a/src/main/java/com/ynxbd/common/his/old/HisHelper.java b/src/main/java/com/ynxbd/common/his/old/HisHelper.java index 2c1936c..754f371 100644 --- a/src/main/java/com/ynxbd/common/his/old/HisHelper.java +++ b/src/main/java/com/ynxbd/common/his/old/HisHelper.java @@ -1,4 +1,4 @@ -//package com.ynxbd.common.his; +//package com.ynxbd.common.his.old; // //import com.ynxbd.common.action.pay.PEnum; //import com.ynxbd.common.bean.enums.MerchantEnum; @@ -8,6 +8,7 @@ //import com.ynxbd.common.helper.common.ErrorHelper; //import com.ynxbd.common.helper.common.SnowHelper; //import com.ynxbd.common.helper.common.SoapHelper; +//import com.ynxbd.common.his.HisEnum; //import com.ynxbd.common.result.JsonResult; //import com.ynxbd.common.result.JsonResultEnum; //import lombok.extern.slf4j.Slf4j; @@ -20,10 +21,82 @@ //import java.util.HashMap; //import java.util.List; //import java.util.Map; -//import java.util.UUID; // //@Slf4j -//public class HisHelper { +//public class HisHelper2 { +// public static final String SOAP_ENV = ""阻止解析 +// private static final Boolean IS_REQ_CDATA; +// +// // 是否传递openid给HIS推送消息 +// public static final Boolean IS_PUSH_MSG; +// // 是否开启支付宝蓝旗调用call_no +// public static final Boolean IS_ALI_MER; +// +// // 开启预结算(第1开关)(如果HIS未限制-则存在直接入库风险!!!!!!!!!!!!!!!!!!) +// public static final boolean IS_RECIPE_PREPAY; +// +// static { +// ProperHelper config = new ProperHelper().read("webservice.properties"); +// +// String url = config.getString("his.url"); +// String devUrl = config.getString("his.dev_url"); +// +// // 医保--------------------------------------------------------- +// String mdUrl = config.getString("his.md_url"); // 微信医保旧版地址 +// String wxMedUrl = config.getString("his.wx_med_url"); +// String aliMedUrl = config.getString("his.ali_med_url"); +// +// IS_LOG_RESP = config.getBoolean("his.is_log_resp", false); +// IS_PUSH_MSG = config.getBoolean("his.is_push_msg", false); +// IS_ALI_MER = config.getBoolean("his.is_ali_mer", false); +// IS_REQ_CDATA = config.getBoolean("his.is_req_cdata", false); +// IS_RX_PREPAY = config.getBoolean("his.is_recipe_prepay", false); +// +// if (url == null) { +// log.error("WebService配置文件读取失败"); +// } +// HIS_SOAP_URL = initSoapURL(url); +// HIS_SOAP_DEV_URL = initSoapURL(devUrl); +// +// // 医保--------------------------------- +// HIS_WX_MED_URL = initSoapURL(wxMedUrl == null ? mdUrl : wxMedUrl); +// HIS_ALI_MED_URL = initSoapURL(aliMedUrl); +// } +// +// private static String initSoapURL(String ip) { +// if (ObjectUtils.isEmpty(ip)) { +// return null; +// } +// if (ip.contains("http")) { +// return ip; +// } +// return "http://" + ip + "/WebService_AB.dll/soap/IInterface_AB"; +// } +// // /** // * 生成HIS订单号 // */ @@ -63,7 +136,7 @@ // * @return 响应的xml数据 // */ // public static String getResponseXml(HisEnum hisEnum, Map params) { -// return getResponseXml(hisEnum, HisConfig.HIS_SOAP_URL, params); +// return getResponseXml(hisEnum, HIS_SOAP_URL, params); // } // // /** @@ -96,22 +169,22 @@ // } // Object callNo = params.get("CallNo"); // if (ObjectUtils.isEmpty(callNo)) { -// params.put("CallNo", HisConfig.WECHAT_CALL_NO); +// params.put("CallNo", WECHAT_CALL_NO); // } // params.put("TransactionCode", transactionCode); // // String result = null; // try { -// String reqId = UUID.randomUUID().toString(); +// String reqId = SnowHelper.nextStrId(); // long begTime = System.currentTimeMillis(); // 开始时间 -// String hisResponse = SoapHelper.post("HIS", soapUrl, null, HisConfig.SOAP_ENV + +// String hisResponse = SoapHelper.post("HIS", soapUrl, null, SOAP_ENV + // "xmlns:urn=\"urn:Interface_ABIntf-IInterface_AB\">" + // "" + // "" + // "" + -// (HisConfig.IS_REQ_CDATA ? "" + SoapHelper.requestParams("HIS", transactionCode, reqId, params) + "" + -// (HisConfig.IS_REQ_CDATA ? "]]>" : "") + +// (IS_REQ_CDATA ? "]]>" : "") + // "" // ); // long endTime = System.currentTimeMillis(); // 结束时间 @@ -140,7 +213,7 @@ // log.info("[{}]HIS请求成功[rid:{}]-耗时:[{}]-返回xml={}", transactionCode, reqId, takeTime, result); // // } else { -// if (HisConfig.IS_LOG_RESP) { // 配置文件强制要求打印xml +// if (IS_LOG_RESP) { // 配置文件强制要求打印xml // if (!HisEnum.AP_Query_Statement.equals(hisEnum) && !HisEnum.Query_Area.equals(hisEnum)) { // log.info("[强制打印][{}]HIS请求成功[rid:{}]-耗时:[{}]-返回xml={}", transactionCode, reqId, takeTime, result); // } @@ -167,9 +240,9 @@ // } // // public static void putAliCallNo(MerchantEnum merchantEnum, Map params) { -// if (HisConfig.IS_ALI_MER && params != null && merchantEnum != null) { +// if (IS_ALI_MER && params != null && merchantEnum != null) { // if (merchantEnum.equals(MerchantEnum.ALI) || merchantEnum.equals(MerchantEnum.ALI_MEDICAL)) { -// params.put("CallNo", HisConfig.ALI_CALL_NO); +// params.put("CallNo", ALI_CALL_NO); // } // } // }