Compare commits
8 Commits
1.0
...
9e7fc2d5a2
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e7fc2d5a2 | |||
| 547bdb6d08 | |||
| 235306ae33 | |||
| 789d0d17cb | |||
| 26e504232e | |||
| 367429587f | |||
| 1343d01478 | |||
| c6e3d65245 |
@@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RequestMapping("/chs/hispay")
|
@RequestMapping("/chs/hispay")
|
||||||
public class HispayController {
|
public class HispayController {
|
||||||
|
|
||||||
private final IHispayService iHispayService;
|
private final IHispayService hispayService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,7 +38,7 @@ public class HispayController {
|
|||||||
@PostMapping("findReadCode")
|
@PostMapping("findReadCode")
|
||||||
public Result<?> findReadCode() {
|
public Result<?> findReadCode() {
|
||||||
try {
|
try {
|
||||||
JSONObject res = iHispayService.readCode();
|
JSONObject res = hispayService.readCode();
|
||||||
return Result.ok("成功", res);
|
return Result.ok("成功", res);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -63,7 +63,7 @@ public class HispayController {
|
|||||||
throw new RuntimeException("密码不可为空");
|
throw new RuntimeException("密码不可为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject res = iHispayService.readCard(password);
|
JSONObject res = hispayService.readCard(password);
|
||||||
return Result.ok("成功", res);
|
return Result.ok("成功", res);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -84,7 +84,7 @@ public class HispayController {
|
|||||||
public Result<?> chsCodeAsOutpatientBegin(@RequestBody @Validated OutpatientBeginModel data) {
|
public Result<?> chsCodeAsOutpatientBegin(@RequestBody @Validated OutpatientBeginModel data) {
|
||||||
try {
|
try {
|
||||||
log.info("[HispayController][chsCodeAsOutpatientBegin][门诊缴费-预算-电子医保凭证] 参数:{}", data);
|
log.info("[HispayController][chsCodeAsOutpatientBegin][门诊缴费-预算-电子医保凭证] 参数:{}", data);
|
||||||
ResultData res = iHispayService.chsCodeAsOutpatientBegin(data);
|
ResultData res = hispayService.chsCodeAsOutpatientBegin(data);
|
||||||
return Result.ok("成功", res);
|
return Result.ok("成功", res);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -105,7 +105,7 @@ public class HispayController {
|
|||||||
public Result<?> chsCodeAsOutpatientFinal(@RequestBody @Validated OutpatientFinalModel data) {
|
public Result<?> chsCodeAsOutpatientFinal(@RequestBody @Validated OutpatientFinalModel data) {
|
||||||
try {
|
try {
|
||||||
log.info("[HispayController][chsCodeAsOutpatientFinal][门诊缴费-结算-电子医保凭证] 参数:{}", data);
|
log.info("[HispayController][chsCodeAsOutpatientFinal][门诊缴费-结算-电子医保凭证] 参数:{}", data);
|
||||||
ResultData res = iHispayService.chsCodeAsOutpatientFinal(data);
|
ResultData res = hispayService.chsCodeAsOutpatientFinal(data);
|
||||||
return Result.ok("成功", res);
|
return Result.ok("成功", res);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -114,4 +114,5 @@ public class HispayController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,5 +43,4 @@ public interface IHispayService {
|
|||||||
*/
|
*/
|
||||||
ResultData chsCodeAsOutpatientFinal(OutpatientFinalModel data);
|
ResultData chsCodeAsOutpatientFinal(OutpatientFinalModel data);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,20 +7,19 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.dpkj.common.config.ChsConfig;
|
import com.dpkj.common.config.ChsConfig;
|
||||||
import com.dpkj.common.config.HisConfig;
|
import com.dpkj.common.config.HisConfig;
|
||||||
import com.dpkj.common.utils.IDGenerator;
|
|
||||||
import com.dpkj.common.vo.ResultData;
|
import com.dpkj.common.vo.ResultData;
|
||||||
import com.dpkj.modules.chs.service.IHispayService;
|
import com.dpkj.modules.chs.service.IHispayService;
|
||||||
import com.dpkj.modules.chs.vo.OutpatientBeginModel;
|
import com.dpkj.modules.chs.vo.OutpatientBeginModel;
|
||||||
import com.dpkj.modules.chs.vo.OutpatientFinalModel;
|
import com.dpkj.modules.chs.vo.OutpatientFinalModel;
|
||||||
import com.jacob.activeX.ActiveXComponent;
|
import com.jacob.activeX.ActiveXComponent;
|
||||||
import com.jacob.com.ComThread;
|
|
||||||
import com.jacob.com.Dispatch;
|
import com.jacob.com.Dispatch;
|
||||||
import com.jacob.com.Variant;
|
import com.jacob.com.Variant;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@@ -31,11 +30,21 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
// @AllArgsConstructor
|
||||||
public class HispayServiceImpl implements IHispayService {
|
public class HispayServiceImpl implements IHispayService {
|
||||||
|
|
||||||
private final HisConfig hisConfig;
|
@Autowired
|
||||||
private final ChsConfig chsConfig;
|
private HisConfig hisConfig;
|
||||||
|
@Autowired
|
||||||
|
private ChsConfig chsConfig;
|
||||||
|
|
||||||
|
// COM对象
|
||||||
|
private static ActiveXComponent dispatch;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void postConstruct() {
|
||||||
|
dispatch = instanceActive();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取HIS医保实例
|
* 获取HIS医保实例
|
||||||
@@ -43,14 +52,13 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
* @return com.jacob.activeX.ActiveXComponent
|
* @return com.jacob.activeX.ActiveXComponent
|
||||||
* @author 萧道子 2025/5/21
|
* @author 萧道子 2025/5/21
|
||||||
*/
|
*/
|
||||||
private ActiveXComponent instanceActive() {
|
private static ActiveXComponent instanceActive() {
|
||||||
try {
|
try {
|
||||||
// 初始化
|
// 初始化
|
||||||
ComThread.InitSTA();
|
// ComThread.InitSTA(); //容易导致线程发生阻塞
|
||||||
// 获取COM对象
|
ActiveXComponent activeXComponent = new ActiveXComponent("PayClient.clsPayClient");
|
||||||
ActiveXComponent active = new ActiveXComponent("PayClient.clsPayClient");
|
|
||||||
log.info("[HispayServiceImpl][instanceActive][HIS医保COM库] 加载成功");
|
log.info("[HispayServiceImpl][instanceActive][HIS医保COM库] 加载成功");
|
||||||
return active;
|
return activeXComponent;
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
log.info("[HispayServiceImpl][instanceActive][HIS医保COM库] 加载失败:{}", e.getMessage());
|
log.info("[HispayServiceImpl][instanceActive][HIS医保COM库] 加载失败:{}", e.getMessage());
|
||||||
throw new RuntimeException("HIS医保COM库加载失败:" + e.getMessage(), e);
|
throw new RuntimeException("HIS医保COM库加载失败:" + e.getMessage(), e);
|
||||||
@@ -65,7 +73,7 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
* @author 萧道子 2025/5/21
|
* @author 萧道子 2025/5/21
|
||||||
*/
|
*/
|
||||||
private void releaseActive() {
|
private void releaseActive() {
|
||||||
ComThread.Release();
|
// ComThread.Release(); //容易导致线程发生阻塞
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,9 +86,9 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
*/
|
*/
|
||||||
private String processParameters(JSONObject params, String password) {
|
private String processParameters(JSONObject params, String password) {
|
||||||
JSONObject req = new JSONObject() {{
|
JSONObject req = new JSONObject() {{
|
||||||
put("timestamp", DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss")); // 请求发送时间
|
put("timestamp", ""); // 请求发送时间 DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss")
|
||||||
put("requestid", IDGenerator.getSnowflakeIdToStr()); // 唯一请求id
|
put("requestid", ""); // 唯一请求id IDGenerator.getSnowflakeIdToStr()
|
||||||
put("operid", hisConfig.getOperationId()); // 调用者代码
|
put("operid", ""); // 调用者代码 hisConfig.getOperationId()
|
||||||
put("password", password); // 密码
|
put("password", password); // 密码
|
||||||
put("params", params);
|
put("params", params);
|
||||||
}};
|
}};
|
||||||
@@ -120,9 +128,6 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject readCode() {
|
public JSONObject readCode() {
|
||||||
// 加载资源
|
|
||||||
Dispatch dispatch = instanceActive();
|
|
||||||
|
|
||||||
/** 1、组装参数 */
|
/** 1、组装参数 */
|
||||||
JSONObject val = new JSONObject()
|
JSONObject val = new JSONObject()
|
||||||
.fluentPut("cardtype", "9") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
.fluentPut("cardtype", "9") // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
||||||
@@ -140,8 +145,6 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
String resStr = vres.getStringRef();
|
String resStr = vres.getStringRef();
|
||||||
log.info("[HispayServiceImpl][readCode][医保读卡-电子凭证] call返回值:{} 结果:{}", call, resStr);
|
log.info("[HispayServiceImpl][readCode][医保读卡-电子凭证] call返回值:{} 结果:{}", call, resStr);
|
||||||
|
|
||||||
// 释放资源
|
|
||||||
releaseActive();
|
|
||||||
|
|
||||||
/** 3、处理读卡结果 */
|
/** 3、处理读卡结果 */
|
||||||
JSONObject result = verifyResult(resStr);
|
JSONObject result = verifyResult(resStr);
|
||||||
@@ -154,8 +157,6 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject readCard(String password) {
|
public JSONObject readCard(String password) {
|
||||||
// 加载资源
|
|
||||||
Dispatch dispatch = instanceActive();
|
|
||||||
|
|
||||||
/** 1、组装参数 */
|
/** 1、组装参数 */
|
||||||
JSONObject val = new JSONObject()
|
JSONObject val = new JSONObject()
|
||||||
@@ -174,9 +175,6 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
String resStr = vres.getStringRef();
|
String resStr = vres.getStringRef();
|
||||||
log.info("[HispayServiceImpl][readCard][医保读卡-医保卡] call返回值:{} 结果:{}", call, resStr);
|
log.info("[HispayServiceImpl][readCard][医保读卡-医保卡] call返回值:{} 结果:{}", call, resStr);
|
||||||
|
|
||||||
// 释放资源
|
|
||||||
releaseActive();
|
|
||||||
|
|
||||||
/** 3、处理读卡结果 */
|
/** 3、处理读卡结果 */
|
||||||
JSONObject result = verifyResult(resStr);
|
JSONObject result = verifyResult(resStr);
|
||||||
if (!result.containsKey("item")) {
|
if (!result.containsKey("item")) {
|
||||||
@@ -187,67 +185,7 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public JSONObject getPatientInfo_old(String type, String content) {
|
|
||||||
// Dispatch dispatch = instanceActive();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 1、删除保存HIS读卡内容的文件 避免读取到错误信息
|
|
||||||
// */
|
|
||||||
// // 获取HIS-CHS医保库路径
|
|
||||||
// String chsPath = System.getProperty("java.library.path");
|
|
||||||
// String filePath = chsPath + "/" + chsConfig.getFileName();
|
|
||||||
// // 删除文件
|
|
||||||
// FileUtil.del(FileUtil.file(filePath));
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 2、组装参数
|
|
||||||
// */
|
|
||||||
// JSONObject val = new JSONObject()
|
|
||||||
// .fluentPut("cardtype", type) // 1.就诊卡,2.医保卡,5.门诊号,6.患者姓名和电话号码,8.电子健康码/卡,9.医保电子凭证
|
|
||||||
// .fluentPut("cardno", "") // 患者就诊卡号
|
|
||||||
// .fluentPut("sfzh", "") // 身份证号
|
|
||||||
// .fluentPut("hzxm", "") // 患者姓名
|
|
||||||
// .fluentPut("phone", ""); // 患者电话号码
|
|
||||||
// String params = processParameters(val, content);
|
|
||||||
// log.info("[HispayServiceImpl][getPatientInfo][医保读卡] 接口入参:{}", params);
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 3、调用COM函数
|
|
||||||
// */
|
|
||||||
// Variant rest = new Variant();
|
|
||||||
// Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, rest);
|
|
||||||
// log.info("[HispayServiceImpl][getPatientInfo][医保读卡] call返回值:{}", call);
|
|
||||||
//
|
|
||||||
// // 释放资源
|
|
||||||
// releaseActive();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 4、处理读卡结果
|
|
||||||
// */
|
|
||||||
// // COM函数调用之后会生成新的文件 需要判断
|
|
||||||
// File file = FileUtil.file(filePath);
|
|
||||||
// if (!file.exists()) {
|
|
||||||
// throw new RuntimeException("读卡失败:数据未读取");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 获取读卡结果
|
|
||||||
// FileReader fileReader = new FileReader(file, "GBK");
|
|
||||||
// String data = fileReader.readString();
|
|
||||||
//
|
|
||||||
// JSONObject result;
|
|
||||||
// try {
|
|
||||||
// result = JSONObject.parseObject(data);
|
|
||||||
// log.info("[HispayServiceImpl][getPatientInfo][医保读卡] 读卡值:{}", result);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// throw new RuntimeException("读卡失败:" + data);
|
|
||||||
// }
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
private ResultData outpatientBudget(OutpatientBeginModel data) {
|
private ResultData outpatientBudget(OutpatientBeginModel data) {
|
||||||
// 加载资源
|
|
||||||
ActiveXComponent dispatch = instanceActive();
|
|
||||||
|
|
||||||
/** 1、组装参数 */
|
/** 1、组装参数 */
|
||||||
JSONObject val = new JSONObject()
|
JSONObject val = new JSONObject()
|
||||||
@@ -269,8 +207,6 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
String resStr = resVariant.getStringRef();
|
String resStr = resVariant.getStringRef();
|
||||||
log.info("[HispayServiceImpl][outpatientBudget][门诊缴费-预算] call返回值:{} 结果:{}", call, resStr);
|
log.info("[HispayServiceImpl][outpatientBudget][门诊缴费-预算] call返回值:{} 结果:{}", call, resStr);
|
||||||
|
|
||||||
// 释放资源
|
|
||||||
releaseActive();
|
|
||||||
|
|
||||||
/** 3、处理结果 */
|
/** 3、处理结果 */
|
||||||
JSONObject result = verifyResult(resStr);
|
JSONObject result = verifyResult(resStr);
|
||||||
@@ -297,16 +233,19 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultData chsCodeAsOutpatientFinal(OutpatientFinalModel data) {
|
public ResultData chsCodeAsOutpatientFinal(OutpatientFinalModel data) {
|
||||||
// 加载资源
|
|
||||||
ActiveXComponent dispatch = instanceActive();
|
|
||||||
|
|
||||||
/** 1、组装参数 */
|
/** 1、组装参数 */
|
||||||
JSONObject val = (JSONObject) JSON.toJSON(data);
|
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);
|
String params = processParameters(val, null);
|
||||||
log.info("[HispayServiceImpl][chsCodeAsOutpatientFinal][门诊缴费-结算] 接口入参:{}", params);
|
log.info("[HispayServiceImpl][chsCodeAsOutpatientFinal][门诊缴费-结算] 接口入参:{}", params);
|
||||||
|
|
||||||
String requestTime = DateUtil.now();
|
|
||||||
|
|
||||||
/** 2、调用COM函数 */
|
/** 2、调用COM函数 */
|
||||||
Variant resVariant = new Variant("", true);
|
Variant resVariant = new Variant("", true);
|
||||||
Variant call = Dispatch.call(dispatch, "fRun", "BMZJF002", params, resVariant);
|
Variant call = Dispatch.call(dispatch, "fRun", "BMZJF002", params, resVariant);
|
||||||
@@ -315,13 +254,6 @@ public class HispayServiceImpl implements IHispayService {
|
|||||||
String resStr = resVariant.getStringRef();
|
String resStr = resVariant.getStringRef();
|
||||||
log.info("[HispayServiceImpl][chsCodeAsOutpatientFinal][门诊缴费-结算] call返回值:{} 结果:{}", call, resStr);
|
log.info("[HispayServiceImpl][chsCodeAsOutpatientFinal][门诊缴费-结算] call返回值:{} 结果:{}", call, resStr);
|
||||||
|
|
||||||
// 释放资源
|
|
||||||
releaseActive();
|
|
||||||
|
|
||||||
// TODO BEGIN 萧道子 2025/6/10 : 模拟参数
|
|
||||||
// String resStr = "<response><resultCode>0</resultCode><resultMessage/><result><sjh>123456789</sjh><sfrq>2025-06-10 10:23:14</sfrq><bz/><pyckjh/><fyckjh/><yflshjh/><ybcc/></result></response>";
|
|
||||||
// TODO END 萧道子 2025/6/10 : 模拟参数
|
|
||||||
|
|
||||||
/** 3、处理结果 */
|
/** 3、处理结果 */
|
||||||
JSONObject result = verifyResult(resStr);
|
JSONObject result = verifyResult(resStr);
|
||||||
|
|
||||||
|
|||||||
@@ -43,5 +43,7 @@ public class OutpatientFinalModel implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 支付时间
|
* 支付时间
|
||||||
*/
|
*/
|
||||||
|
// @NotEmpty(message = "支付时间不可为空!")
|
||||||
private String paytime;
|
private String paytime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,14 @@
|
|||||||
<span style="margin-right: 25px;">费用总额:<span th:text="${totalFee}"></span></span>
|
<span style="margin-right: 25px;">费用总额:<span th:text="${totalFee}"></span></span>
|
||||||
<span>个人支付:<span th:text="${personalPayment}"></span></span>
|
<span>个人支付:<span th:text="${personalPayment}"></span></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-top: 10px;word-break: break-all;" th:if="${chs==1}">
|
||||||
|
<span style="margin-right: 25px;">医保统筹基金:<span th:text="${ybtcjj}"></span></span>
|
||||||
|
<span>个人医保账户:<span th:text="${ybgrzh}"></span></span>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top: 10px;word-break: break-all;" th:if="${chs==1}">
|
||||||
|
<span style="margin-right: 25px;">医院优惠金额:<span th:text="${yyyh}"></span></span>
|
||||||
|
<span>医院账户支付:<span th:text="${yyzh}"></span></span>
|
||||||
|
</div>
|
||||||
<div style="margin-top: 10px;word-break: break-all;">
|
<div style="margin-top: 10px;word-break: break-all;">
|
||||||
<span>实收金额:</span><span
|
<span>实收金额:</span><span
|
||||||
th:text="${actualReceiptAmount}"></span></div>
|
th:text="${actualReceiptAmount}"></span></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user