From e8b2da689041fa095902090bd72f43fa2cbedbab Mon Sep 17 00:00:00 2001 From: wangsq Date: Tue, 21 Jul 2026 10:09:58 +0800 Subject: [PATCH] =?UTF-8?q?AI=E6=99=BA=E8=83=BD=E5=AF=BC=E8=AF=8A=E5=85=A5?= =?UTF-8?q?=E5=8F=82=E8=A7=81=E5=85=BC=E5=AE=B9=E6=97=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E5=AF=BC=E8=AF=8A=20=E5=8C=BB=E4=BF=9D?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=85=A5=E5=8F=82=E8=BF=9B=E8=A1=8C=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ynxbd/common/TestA.java | 12 +++-- .../action/healthcard/AIGuidanceAction.java | 44 ++++++++++++++++--- .../action/healthcard/HCReportAction.java | 11 +++-- .../common/action/pay/MedicalAction.java | 13 +++--- .../config/healthcard/HCAIGuidanceConfig.java | 6 +-- .../config/healthcard/HCReportConfig.java | 6 ++- .../config/healthcard/HCSignHelper.java | 6 +-- .../java/com/ynxbd/common/result/Result.java | 2 +- .../ynxbd/common/service/MedicalService.java | 19 +++++--- src/main/resources/hc-config.xml | 8 ++-- 10 files changed, 86 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/ynxbd/common/TestA.java b/src/main/java/com/ynxbd/common/TestA.java index ac79c10..9d223c6 100644 --- a/src/main/java/com/ynxbd/common/TestA.java +++ b/src/main/java/com/ynxbd/common/TestA.java @@ -22,7 +22,6 @@ public class TestA { // } - // public static void main(String[] args) { // System.out.println(AesWxHelper.encode("524404")); // @@ -34,11 +33,10 @@ public class TestA { // } - public static void main(String[] args) { - System.out.println(AesWxHelper.encode("624091")); - -// System.out.println(AesWxHelper.decode("A25BF2DD5820B151B8AB2E333E05565E")); - } - +// public static void main(String[] args) { +// // System.out.println(AesWxHelper.encode("624091")); +// +// // System.out.println(AesWxHelper.decode("A25BF2DD5820B151B8AB2E333E05565E")); +// } } diff --git a/src/main/java/com/ynxbd/common/action/healthcard/AIGuidanceAction.java b/src/main/java/com/ynxbd/common/action/healthcard/AIGuidanceAction.java index 1ccaea1..861882f 100644 --- a/src/main/java/com/ynxbd/common/action/healthcard/AIGuidanceAction.java +++ b/src/main/java/com/ynxbd/common/action/healthcard/AIGuidanceAction.java @@ -29,7 +29,7 @@ import java.util.Map; public class AIGuidanceAction extends BaseAction { /** - * 查询平台所有医院列表信息 + * 4.1.1 查询平台所有医院列表信息(必选) */ @Action("getAllHospInfo") public Result getAllHospInfo() { @@ -47,10 +47,14 @@ public class AIGuidanceAction extends BaseAction { } /** - * 查询医院详细信息 + * 4.1.2 查询医院详细信息(必选) */ @Action("getHospDetail") public Result getHospDetail(String hosId) { + JSONObject body = getBody(); + if (ObjectUtils.isEmpty(hosId)) { + hosId = body.getString("hosId"); + } if (!HCAIGuidanceConfig.IS_DEBUG && !HCAIGuidanceConfig.isVerifySign(request)) { return Result.error(ResultEnum.SIGN_ERROR); // 签名异常 } @@ -58,10 +62,17 @@ public class AIGuidanceAction extends BaseAction { } /** - * 查询科室信息 + * 4.1.3 查询科室信息(必选) */ @Action("getDeptList") public Result getDeptList(String hosId, String branchId) { + JSONObject body = getBody(); + if (ObjectUtils.isEmpty(hosId)) { + hosId = body.getString("hosId"); + } + if (ObjectUtils.isEmpty(branchId)) { + branchId = body.getString("branchId"); + } if (!HCAIGuidanceConfig.IS_DEBUG && !HCAIGuidanceConfig.isVerifySign(request)) { return Result.error(ResultEnum.SIGN_ERROR); // 签名异常 } @@ -69,10 +80,20 @@ public class AIGuidanceAction extends BaseAction { } /** - * 查询医生信息 + * 4.1.4 查询医生信息(必选) */ @Action("getDoctorList") public Result getDoctorList(String hosId, String branchId, String deptId) { + JSONObject body = getBody(); + if (ObjectUtils.isEmpty(hosId)) { + hosId = body.getString("hosId"); + } + if (ObjectUtils.isEmpty(branchId)) { + branchId = body.getString("branchId"); + } + if (ObjectUtils.isEmpty(deptId)) { + deptId = body.getString("deptId"); + } if (!HCAIGuidanceConfig.IS_DEBUG && !HCAIGuidanceConfig.isVerifySign(request)) { return Result.error(ResultEnum.SIGN_ERROR); // 签名异常 } @@ -85,6 +106,16 @@ public class AIGuidanceAction extends BaseAction { */ @Action("getPatientCardList") public Result getPatientCardList(String hosId, String branchId, String deptId) { + JSONObject body = getBody(); + if (ObjectUtils.isEmpty(hosId)) { + hosId = body.getString("hosId"); + } + if (ObjectUtils.isEmpty(branchId)) { + branchId = body.getString("branchId"); + } + if (ObjectUtils.isEmpty(deptId)) { + deptId = body.getString("deptId"); + } if (!HCAIGuidanceConfig.IS_DEBUG && !HCAIGuidanceConfig.isVerifySign(request)) { return Result.error(ResultEnum.SIGN_ERROR); // 签名异常 } @@ -112,7 +143,10 @@ public class AIGuidanceAction extends BaseAction { * 4.2.1.1 查询医院的首页服务列表(必选) */ @Action("getHospitalHomeService") - public Result getHospitalHomeService(String hosId) { + public Result getHospitalHomeService() { + JSONObject body = getBody(); + String hosId = body.getString("hosId"); + log.info("[查询医院的首页服务列表]hosId={}", hosId); if (!HCAIGuidanceConfig.IS_DEBUG && !HCAIGuidanceConfig.isVerifySign(request)) { return Result.error(ResultEnum.SIGN_ERROR); // 签名异常 diff --git a/src/main/java/com/ynxbd/common/action/healthcard/HCReportAction.java b/src/main/java/com/ynxbd/common/action/healthcard/HCReportAction.java index c297f03..b34460f 100644 --- a/src/main/java/com/ynxbd/common/action/healthcard/HCReportAction.java +++ b/src/main/java/com/ynxbd/common/action/healthcard/HCReportAction.java @@ -2,7 +2,6 @@ package com.ynxbd.common.action.healthcard; import com.alibaba.fastjson.JSONObject; import com.ynxbd.common.action.base.BaseAction; -import com.ynxbd.common.config.HealthCardConfig; import com.ynxbd.common.config.healthcard.HCReportConfig; import com.ynxbd.common.config.healthcard.HCSignHelper; import com.ynxbd.common.config.interceptor.AesDecode; @@ -33,28 +32,28 @@ public class HCReportAction extends BaseAction { Map reqHead = new HashMap<>(); reqHead.put("requestId", requestId); -// Map textReportInfo = new HashMap<>(); + Map textReportInfo = new HashMap<>(); // Map patientInfo = new HashMap<>(); // Map reportInfo = new HashMap<>(); // partnerId:合作方ID 腾讯健康提供 - JSONObject jsonObject = OkHttpHelper.postJson(url + "合作方ID 腾讯健康提供", params -> { + JSONObject jsonObject = OkHttpHelper.postJson(url + HCReportConfig.PARTNER_ID, params -> { params.put("reqHead", reqHead); - params.put("hospitalId", HealthCardConfig.H_HOSPITAL_ID); + params.put("hospitalId", HCReportConfig.HOSP_ID); params.put("outerId", reportId); params.put("healthCardId", healthCardId); params.put("patientId", patientId); params.put("msgId", msgId); params.put("reportFileType", 2); // [ 1:pdf;2:图片;3:文本] params.put("reportContent", reportContent); // 报告内容:报告文件base64编码、体积需要在30MB以内 当reportFileType 取值为 1, 2时,将报告文件base64编码放在该字段 - params.put("textReportInfo", ""); // 当reportFileType 取值为 3 时,将文本报告内容放下该字段。 + params.put("textReportInfo", textReportInfo); // 当reportFileType 取值为 3 时,将文本报告内容放下该字段。 }, headers -> { headers.add("Content-Type", "application/json"); headers.add("god-portal-signature", config.getSignature()); headers.add("god-portal-timestamp", config.getTimestamp()); headers.add("god-portal-request-id", requestId); }); - log.info("[报告解读] resp={}", jsonObject); + log.warn("[报告解读] resp={}", jsonObject); return Result.success(); } } diff --git a/src/main/java/com/ynxbd/common/action/pay/MedicalAction.java b/src/main/java/com/ynxbd/common/action/pay/MedicalAction.java index 5f96f64..93a28d5 100644 --- a/src/main/java/com/ynxbd/common/action/pay/MedicalAction.java +++ b/src/main/java/com/ynxbd/common/action/pay/MedicalAction.java @@ -47,9 +47,9 @@ public class MedicalAction extends BaseAction { * 用户信息获取 | 医保上传 | 医保支付下单 */ @Action("getFeeDetails") - public Result getFeeDetails(String callNo, String payCode, String openid, String qrCode, String patientId, String cardNo, String realName, BigDecimal totalFee, Boolean isSplitTime, String ybAttrib, String ybBZCode, String ybBZName) { + public Result getFeeDetails(String callNo, String payCode, String qrCode, @AesDecode String openid, @AesDecode String patientId, @AesDecode String cardNo, @AesDecode String hisPatientId, String realName, BigDecimal totalFee, Boolean isSplitTime, String ybAttrib, String ybBZCode, String ybBZName) { try { - log.info("[医保]上传明细下单 callNo={}, payCode={}, openid={}, qrCode={}, patientId={}, cardNo={}, realName={}, totalFee={}, ybAttrib={}, ybBZCode={}, ybBZName={}", callNo, payCode, openid, qrCode, patientId, ParamHelper.hideIdCardNo(cardNo), realName, totalFee, ybAttrib, ybBZCode, ybBZName); + log.info("[医保]上传明细下单 callNo={}, payCode={}, openid={}, qrCode={}, patientId={}, cardNo={}, realName={}, hisPatientId={}, totalFee={}, ybAttrib={}, ybBZCode={}, ybBZName={}", callNo, payCode, openid, qrCode, patientId, ParamHelper.hideIdCardNo(cardNo), realName, hisPatientId, totalFee, ybAttrib, ybBZCode, ybBZName); if (callNo == null || payCode == null || openid == null || qrCode == null || patientId == null || cardNo == null || totalFee == null) { return Result.error(ResultEnum.PARAM_IS_DEFECT); } @@ -70,7 +70,7 @@ public class MedicalAction extends BaseAction { if (!DateHelper.isToday(reg.getRegDate())) { return Result.error("医保支付仅支持今日挂号"); } - medicalInfo = new MedicalService().hisRegMedUploadDetails(merchantEnum, qrCode, openid, patientId, cardNo, realName, reg, isSplitTime); + medicalInfo = new MedicalService().hisRegMedUploadDetails(merchantEnum, qrCode, openid, patientId, cardNo, realName, hisPatientId, reg, isSplitTime); break; case RECIPE: @@ -176,10 +176,10 @@ public class MedicalAction extends BaseAction { * @param familyCardNo 家人证件号码(非必传) */ @Action("order") - public Result order(String callNo, String payCode, String payOpenId, String openid, String patientId, String cardNo, String realName, String treatNum, String payOrdId, String payAuthNo, String mdTrtId, String chrgBchno, String mdUserId, + public Result order(String callNo, String payCode, String payOpenId, @AesDecode String openid, @AesDecode String patientId, @AesDecode String cardNo, @AesDecode String hisPatientId, String realName, String treatNum, String payOrdId, String payAuthNo, String mdTrtId, String chrgBchno, String mdUserId, BigDecimal totalFee, BigDecimal acctFee, BigDecimal hifpFee, BigDecimal insuranceFee, BigDecimal cashFee, String familyType, String familyName, String familyCardNo, String medicalCardInstId, String medicalCardId) { try { - log.info("[医保]下单入参 callNo={}, payCode={}, openid={}, patientId={}, totalFee={}", callNo, payCode, openid, patientId, totalFee); + log.info("[医保]下单入参 callNo={}, payCode={}, openid={}, patientId={}, totalFee={}, hisPatientId={}, cardNo={}", callNo, payCode, openid, patientId, totalFee, hisPatientId, ParamHelper.hideIdCardNo(cardNo)); if (callNo == null || payCode == null || openid == null || patientId == null || cardNo == null || totalFee == null) { return Result.error(ResultEnum.PARAM_IS_DEFECT); } @@ -188,7 +188,8 @@ public class MedicalAction extends BaseAction { case REG: Register reg = new Register().getRegParams(new RequestParams(request), true); - return new MedicalService().createRegOrder(payCode, payOpenId, openid, cardNo, realName, ip, payOrdId, payAuthNo, mdTrtId, chrgBchno, mdUserId, + return new MedicalService().createRegOrder(payCode, payOpenId, openid, patientId, cardNo, realName, hisPatientId, ip, + payOrdId, payAuthNo, mdTrtId, chrgBchno, mdUserId, totalFee, acctFee, hifpFee, insuranceFee, cashFee, callNo, reg, familyType, familyName, familyCardNo, medicalCardInstId, medicalCardId); diff --git a/src/main/java/com/ynxbd/common/config/healthcard/HCAIGuidanceConfig.java b/src/main/java/com/ynxbd/common/config/healthcard/HCAIGuidanceConfig.java index 4e5edfc..901f2ae 100644 --- a/src/main/java/com/ynxbd/common/config/healthcard/HCAIGuidanceConfig.java +++ b/src/main/java/com/ynxbd/common/config/healthcard/HCAIGuidanceConfig.java @@ -31,7 +31,7 @@ public class HCAIGuidanceConfig { * AI版:电子健康卡AppSecret(管理>开发商接入) * 旧版:Token(腾讯提供) */ - public final static String PARTNER_KEY; + public final static String PARTNER_SECRET; public final static String HOSP_NAME; @@ -52,7 +52,7 @@ public class HCAIGuidanceConfig { IS_DEBUG = config.getBoolean("is_debug", false); IS_SPLIT_TIME_REG = config.getBoolean("is_split_time_reg", true); - PARTNER_KEY = config.getString(IS_DEV ? "dev_partner_key" : "partner_key"); + PARTNER_SECRET = config.getString(IS_DEV ? "dev_partner_secret" : "partner_secret"); PARTNER_ID = config.getString("partner_id"); HOSP_ID = config.getString("hosp_id"); @@ -85,7 +85,7 @@ public class HCAIGuidanceConfig { log.info("[智能导诊]验签 timestamp={}, signature={}", timestamp, signature); String str = PARTNER_ID + timestamp; - String cacheSign = HMACHelper.sha256(str, PARTNER_KEY); + String cacheSign = HMACHelper.sha256(str, PARTNER_SECRET); return signature.equals(cacheSign); } } diff --git a/src/main/java/com/ynxbd/common/config/healthcard/HCReportConfig.java b/src/main/java/com/ynxbd/common/config/healthcard/HCReportConfig.java index 1e646f7..501bbf9 100644 --- a/src/main/java/com/ynxbd/common/config/healthcard/HCReportConfig.java +++ b/src/main/java/com/ynxbd/common/config/healthcard/HCReportConfig.java @@ -12,12 +12,16 @@ public class HCReportConfig { public static final String TOKEN; - public static final String PARTNER_ID; // 医院ID(每家医院不一样) + public static final String PARTNER_ID; // 合作方ID(每家医院不一样) + + public static final String HOSP_ID; // 医院ID(每家医院不一样) static { XmlConfigHelper config = new XmlConfigHelper().read("hc-config.xml", "report"); IS_DEV = config.getBoolean("is_dev", false); + HOSP_ID = config.getString("hosp_id"); + TOKEN = config.getString(IS_DEV ? "dev_token" : "token"); PARTNER_ID = config.getString(IS_DEV ? "dev_partner_id" : "partner_id"); } diff --git a/src/main/java/com/ynxbd/common/config/healthcard/HCSignHelper.java b/src/main/java/com/ynxbd/common/config/healthcard/HCSignHelper.java index 6767b91..593c4b4 100644 --- a/src/main/java/com/ynxbd/common/config/healthcard/HCSignHelper.java +++ b/src/main/java/com/ynxbd/common/config/healthcard/HCSignHelper.java @@ -30,12 +30,12 @@ public class HCSignHelper { public static void main(String[] args) { - String TOKEN = "795b207e12572839976d9310bdde32be"; - String PARTNER_ID = "100000317"; + String PARTNER_ID = "e4a05c13301f2f6a8b07b3de872dfe2d"; + String PARTNER_KEY_TOKEN = "e5322dfd9bfab939851319812c30f9f1"; String timestamp = System.currentTimeMillis() + ""; String str = PARTNER_ID + timestamp; - String cacheSign = HMACHelper.sha256(str, TOKEN); + String cacheSign = HMACHelper.sha256(str, PARTNER_KEY_TOKEN); System.out.println(timestamp); System.out.println(cacheSign); } diff --git a/src/main/java/com/ynxbd/common/result/Result.java b/src/main/java/com/ynxbd/common/result/Result.java index b001ce4..c575e57 100644 --- a/src/main/java/com/ynxbd/common/result/Result.java +++ b/src/main/java/com/ynxbd/common/result/Result.java @@ -165,7 +165,7 @@ public class Result extends BaseResult { if (serviceException.getMessage() != null) { message = serviceException.getMessage(); if (serviceException.isLog()) { - log.error("[异常][{}]{}", stackPosition, e.getMessage(), e); + log.error("[业务异常][{}]{}", stackPosition, e.getMessage()); } } if (serviceException.getResultEnum() != null) { diff --git a/src/main/java/com/ynxbd/common/service/MedicalService.java b/src/main/java/com/ynxbd/common/service/MedicalService.java index 9bcb661..f428778 100644 --- a/src/main/java/com/ynxbd/common/service/MedicalService.java +++ b/src/main/java/com/ynxbd/common/service/MedicalService.java @@ -85,7 +85,13 @@ public class MedicalService { * @param realName 真实姓名 * @param reg 挂号信息 */ - public MedicalInfo hisRegMedUploadDetails(MerchantEnum merchantEnum, String qrCode, String openid, String patientId, String cardNo, String realName, Register reg, Boolean isSplitTime) throws ServiceException { + public MedicalInfo hisRegMedUploadDetails(MerchantEnum merchantEnum, String qrCode, String openid, String patientId, String cardNo, String realName, String hisPatientId, Register reg, Boolean isSplitTime) throws ServiceException { + // 以传递的数据为主 + reg.setOpenid(openid); + reg.setPatientId(patientId); + reg.setHisPatientId(hisPatientId); + reg.setIdCardNo(cardNo); + String payAuthNo = getPayAuthNo(merchantEnum, openid, qrCode, cardNo, realName); log.info("[医保]上传明细:patientId={}, cardNo={}, realName={}, reg={}", patientId, cardNo, realName, reg); JsonResult result = HisMedDao.regMedUploadDetails(merchantEnum, reg, payAuthNo, cardNo, isSplitTime); @@ -346,8 +352,7 @@ public class MedicalService { } return Result.success(map); - } catch (ServiceException e) { - log.error(e.getMessage()); + } catch (Exception e) { return Result.error(e); } } @@ -356,8 +361,13 @@ public class MedicalService { /** * [医保]挂号下单 */ - public Result createRegOrder(String payCode, String payOpenId, String openid, String cardNo, String realName, String ip, String payOrdId, String payAuthNo, String mdTrtId, String chrgBchno, String mdUserId, BigDecimal totalFee, BigDecimal acctFee, BigDecimal hifpFee, BigDecimal insuranceFee, BigDecimal cashFee, String notifyType, Register reg, + public Result createRegOrder(String payCode, String payOpenId, String openid, String patientId, String cardNo, String realName, String hisPatientId, String ip, String payOrdId, String payAuthNo, String mdTrtId, String chrgBchno, String mdUserId, BigDecimal totalFee, BigDecimal acctFee, BigDecimal hifpFee, BigDecimal insuranceFee, BigDecimal cashFee, String notifyType, Register reg, String familyType, String familyName, String familyCardNo, String medicalCardInstId, String medicalCardId) { + reg.setOpenid(openid); + reg.setPatientId(patientId); + reg.setHisPatientId(hisPatientId); + reg.setIdCardNo(cardNo); + Result result = PayService.isPaymentPermittedByTime(); if (result != null) { return result; @@ -384,7 +394,6 @@ public class MedicalService { } String treatNum = reg.getTreatNum(); - String patientId = reg.getPatientId(); log.info("[医保][挂号]下单 hasDBOrder={}, openid={}, patientId={}, treatNum={}, outTradeNo={}, payOrdId={}, payAuthNo={}, totalFee={}, acctFee={}, hifpFee={}, cashFee={}, idCardNo={}, realName={}, familyType={}, familyName={}, medicalCardId={}, medicalCardInstId={}", hasDBOrder, openid, patientId, treatNum, outTradeNo, payOrdId, payAuthNo, totalFee, acctFee, hifpFee, cashFee, cardNo, realName, familyType, familyName, medicalCardId, medicalCardInstId); String orderTitle = "挂号"; diff --git a/src/main/resources/hc-config.xml b/src/main/resources/hc-config.xml index ea05258..1425b1c 100644 --- a/src/main/resources/hc-config.xml +++ b/src/main/resources/hc-config.xml @@ -1,8 +1,8 @@ - true + 31737 20009251 3bee9edc0a2f41ac911b9b714c854cad @@ -20,11 +20,11 @@ true - e4a05c13301f2f6a8b07b3de872dfe2d + e4a05c13301f2f6a8b07b3de872dfe2d - e5322dfd9bfab939851319812c30f9f1 + e5322dfd9bfab939851319812c30f9f1 - e5322dfd9bfab939851319812c30f9f1 + e5322dfd9bfab939851319812c30f9f1 800002580 红河州第一人民医院