移动医保

This commit is contained in:
2025-08-13 21:49:30 +08:00
parent a4992af643
commit e444971364
4 changed files with 33 additions and 305 deletions

View File

@@ -13,7 +13,7 @@ echo 1、关闭端口进程%PROT%
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%PROT%"') do taskkill /pid %%m -t -f
echo 2、启动本地程序
start %CHSPATH%/javaw.exe -Dfile.encoding=utf-8 -Djava.library.path=%CHSPATH% -Dlog.path=%~dp0 -jar %~dp0\%NAME%.jar --server.port=%PROT%
start %CHSPATH%/javaw.exe -Dfile.encoding=utf-8 -Djava.library.path="%CHSPATH%;%CHSPATH%/CHSInterfaceYn" -Dlog.path=%~dp0 -jar %~dp0\%NAME%.jar --server.port=%PROT%
:: 延迟5秒
timeout /NOBREAK /T 5 >nul

View File

@@ -1,275 +0,0 @@
package com.dpkj.modules.chs.hispad.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.XmlUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dpkj.common.config.PadChsConfig;
import com.dpkj.common.config.HisConfig;
import com.dpkj.common.vo.ResultData;
import com.dpkj.modules.chs.hispad.constant.ChsPayStateConst;
import com.dpkj.modules.chs.hispad.service.IHispayService;
import com.dpkj.modules.chs.hispad.vo.OutpatientBeginModel;
import com.dpkj.modules.chs.hispad.vo.OutpatientFinalModel;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import javax.annotation.PostConstruct;
import java.util.Map;
/**
* @Auther: 萧道子
* @Date: 2025/3/22 16:29
* @Description:
*/
@Slf4j
@Service
// @AllArgsConstructor
public class HispayServiceImpl implements IHispayService {
@Autowired
private HisConfig hisConfig;
@Autowired
private PadChsConfig chsPadConfig;
// COM对象
private static ActiveXComponent dispatch;
@PostConstruct
public void postConstruct() {
dispatch = instanceActive();
}
/**
* 获取HIS医保实例
*
* @return com.jacob.activeX.ActiveXComponent
* @author 萧道子 2025/5/21
*/
private static ActiveXComponent instanceActive() {
try {
// 初始化
// ComThread.InitSTA(); //容易导致线程发生阻塞
ActiveXComponent activeXComponent = new ActiveXComponent("PayClient.clsPayClient");
log.info("[HispayServiceImpl][instanceActive][HIS医保COM库] 加载成功");
return activeXComponent;
} catch (UnsatisfiedLinkError e) {
log.error("[HispayServiceImpl][instanceActive][HIS医保COM库] 加载失败:{}", e.getMessage());
throw new RuntimeException("HIS医保COM库加载失败" + e.getMessage(), e);
}
}
/**
* 释放资源
*
* @return void
* @author 萧道子 2025/5/21
*/
private void releaseActive() {
// ComThread.Release(); //容易导致线程发生阻塞
}
/**
* 处理参数
*
* @param params : 请求参数
* @param password : 密码
* @return java.lang.String
* @author 萧道子 2025/5/27
*/
private String processParameters(JSONObject params, String password) {
JSONObject req = new JSONObject() {{
put("timestamp", ""); // 请求发送时间 DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss")
put("requestid", ""); // 唯一请求id IDGenerator.getSnowflakeIdToStr()
put("operid", ""); // 调用者代码 hisConfig.getOperationId()
put("password", password); // 密码
put("params", params);
}};
Document document = XmlUtil.mapToXml(req, "request");
return XmlUtil.toStr(document, "UTF-8", false, true);
}
/**
* 校验结果
*
* @param resStr :
* @return com.alibaba.fastjson.JSONObject
* @author 萧道子 2025/5/28
*/
private JSONObject verifyResult(String resStr) {
if (StrUtil.isBlank(resStr)) {
throw new RuntimeException("信息获取失败");
}
Map<String, Object> resMap = XmlUtil.xmlToMap(resStr);
JSONObject resJson = new JSONObject(resMap);
if (StrUtil.equals(resJson.getString("resultCode"), "1")) {
throw new RuntimeException(resJson.getString("resultMessage"));
}
if (!resJson.containsKey("result")) {
throw new RuntimeException("result数据为空");
}
return resJson.getJSONObject("result");
}
@Override
public JSONObject readCode() {
/** 1、组装参数 */
JSONObject val = new JSONObject()
.fluentPut("cardtype", "9") // 1.就诊卡2.医保卡5.门诊号6.患者姓名和电话号码8.电子健康码/卡9.医保电子凭证
.fluentPut("cardno", "") // 患者就诊卡号
.fluentPut("sfzh", "") // 身份证号
.fluentPut("hzxm", "") // 患者姓名
.fluentPut("phone", ""); // 患者电话号码
String params = processParameters(val, null);
log.debug("[HispayServiceImpl][readCode][医保读卡-电子凭证] 接口入参:{}", params);
/** 2、调用COM函数 */
Variant vres = new Variant("", true);
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, vres);
String resStr = vres.getStringRef();
log.debug("[HispayServiceImpl][readCode][医保读卡-电子凭证] call返回值{} 结果:{}", call, resStr);
/** 3、处理读卡结果 */
JSONObject result = verifyResult(resStr);
if (!result.containsKey("item")) {
throw new RuntimeException("item数据为空");
}
return result.getJSONObject("item");
}
@Override
public JSONObject readCard(String password) {
/** 1、组装参数 */
JSONObject val = new JSONObject()
.fluentPut("cardtype", "2") // 1.就诊卡2.医保卡5.门诊号6.患者姓名和电话号码8.电子健康码/卡9.医保电子凭证
.fluentPut("cardno", "") // 患者就诊卡号
.fluentPut("sfzh", "") // 身份证号
.fluentPut("hzxm", "") // 患者姓名
.fluentPut("phone", ""); // 患者电话号码
String params = processParameters(val, password);
log.debug("[HispayServiceImpl][readCard][医保读卡-医保卡] 接口入参:{}", params);
/** 2、调用COM函数 */
Variant vres = new Variant("", true);
Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, vres);
String resStr = vres.getStringRef();
log.debug("[HispayServiceImpl][readCard][医保读卡-医保卡] call返回值{} 结果:{}", call, resStr);
/** 3、处理读卡结果 */
JSONObject result = verifyResult(resStr);
if (!result.containsKey("item")) {
throw new RuntimeException("item数据为空");
}
return result.getJSONObject("item");
}
private ResultData outpatientBudget(OutpatientBeginModel data) {
/** 1、组装参数 */
JSONObject val = new JSONObject()
.fluentPut("patid", data.getPatientId()) // 病人ID
.fluentPut("cfxhhj", data.getPrescriptionNo()) // 划价单据,格式:单据1,单据2,单据3
.fluentPut("czksfbz", "0") // 是否扣院内账户0不使用院内账户1使用院内账户默认不使用院内账户
.fluentPut("zfjsbz", "0") // 是否自费结算0根据医保代码缴费1自费结算默认自费结算
.fluentPut("ybrc", ""); // 医保入参xml节点
String params = processParameters(val, data.getPassword());
log.debug("[HispayServiceImpl][outpatientBudget][门诊缴费-预算] 接口入参:{}", params);
String requestTime = DateUtil.now();
/** 2、调用COM函数 */
Variant resVariant = new Variant("", true);
Variant call = Dispatch.call(dispatch, "fRun", "BMZJF001", params, resVariant);
String responseTime = DateUtil.now();
String resStr = resVariant.getStringRef();
log.debug("[HispayServiceImpl][outpatientBudget][门诊缴费-预算] call返回值{} 结果:{}", call, resStr);
/** 3、处理结果 */
JSONObject result = verifyResult(resStr);
return new ResultData()
.setRequestTime(requestTime)
.setRequestContent(params)
.setResponseTime(responseTime)
.setPatientId(data.getPatientId())
.setResponseContent(resStr)
.setResult(result);
}
@Override
public ResultData chsCodeAsOutpatientBegin(OutpatientBeginModel data) {
// 用户读卡-生成token
JSONObject userInfo = readCode();
String patientId = userInfo.getString("patid");
data.setPatientId(patientId);
// 更新常量状态 已读卡
ChsPayStateConst.put(data.getPrescriptionNo(), 1);
return outpatientBudget(data);
}
@Override
public ResultData chsCodeAsOutpatientFinal(OutpatientFinalModel data) {
/** 1、组装参数 */
String requestTime = DateUtil.now();
data.setPaytime(requestTime);
JSONObject val = ((JSONObject) JSON.toJSON(data))
.fluentPut("czksfbz", "0") // 是否扣院内账户,与预算保持一致
.fluentPut("zfjsbz", "0") // 是否自费结算与预算保持一致0根据病人医保代码结算1自费结算
.fluentPut("ybrc", "")
.fluentPut("ptlsh", "")
.fluentPut("jysm", "");
String params = processParameters(val, null);
log.debug("[HispayServiceImpl][chsCodeAsOutpatientFinal][门诊缴费-结算] 接口入参:{}", params);
/** 2、调用COM函数 */
Variant resVariant = new Variant("", true);
Variant call = Dispatch.call(dispatch, "fRun", "BMZJF002", params, resVariant);
String responseTime = DateUtil.now();
String resStr = resVariant.getStringRef();
log.debug("[HispayServiceImpl][chsCodeAsOutpatientFinal][门诊缴费-结算] call返回值{} 结果:{}", call, resStr);
/** 3、处理结果 */
JSONObject result = verifyResult(resStr);
return new ResultData()
.setRequestTime(requestTime)
.setRequestContent(params)
.setResponseTime(responseTime)
.setPatientId(data.getPatid())
.setResponseContent(resStr)
.setResult(result);
}
}

View File

@@ -24,12 +24,12 @@ public class PadChsPayDll {
EcDll dll = Native.load("NationECCode", EcDll.class);
// 加载动态库
Native.load("libeay32", EcDll.class);
Native.load("ssleay32", EcDll.class);
/*Native.load("libeay32", EcDll.class);
Native.load("ssleay32", EcDll.class);*/
return dll;
} catch (UnsatisfiedLinkError e) {
log.info("[PadChsPayDll][instance][国家级医保动态库] SDK注册失败{}", e.getMessage());
log.info("[PadChsPayDll][instance][PAD医保DLL] SDK注册失败{}", e.getMessage());
throw new DllRegistrationException("Failed to load PadChsPayDll library: ", e);
}
}

View File

@@ -51,11 +51,14 @@ public class AliScanFaceServiceImpl implements IAliScanFaceService {
@PostConstruct
public void postConstruct() {
log.info("[AliScanFaceServiceImpl][postConstruct][支付宝刷脸DLL] 初始化动态链接库");
Thread thread = new Thread(() -> {
try {
this.iniAbcpAbsolute();
iniAbcpAbsolute();
} catch (Exception e) {
log.info("[AliScanFaceServiceImpl][postConstruct][56][支付宝刷脸初始化失败:] {}", e.getMessage());
}
});
thread.start();
}
/**