Merge remote-tracking branch 'origin/1.0' into 1.0
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package com.dpkj.modules.chs.controller;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.dpkj.common.config.ChsConfig;
|
||||
import com.dpkj.common.constant.ChsConst;
|
||||
import com.dpkj.common.vo.Result;
|
||||
import com.dpkj.modules.chs.dll.AlipayDll;
|
||||
import com.dpkj.modules.chs.entity.AlipayEcRequestData;
|
||||
import com.dpkj.modules.chs.service.IAlipayService;
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Pointer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2025/3/22 16:25
|
||||
* @Description: 医保模块-阿里设备
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/chs/alipay")
|
||||
public class AlipayController {
|
||||
|
||||
private final IAlipayService alipayService;
|
||||
|
||||
private final ChsConfig charsConfig;
|
||||
|
||||
|
||||
@GetMapping("test")
|
||||
public Result<?> test() {
|
||||
try {
|
||||
AlipayDll.Dll dll = AlipayDll.instance();
|
||||
// Native.load("libeay32", AlipayDll.Dll.class);
|
||||
// Native.load("ssleay32", AlipayDll.Dll.class);
|
||||
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
AlipayEcRequestData alipayEcRequestData = new AlipayEcRequestData()
|
||||
.setOrgId(charsConfig.getOrgcode())
|
||||
.setTransType(ChsConst.APITYPE_DECODE)
|
||||
.setData(data);
|
||||
String dataJson = JSONObject.toJSONString(alipayEcRequestData);
|
||||
|
||||
Pointer resultStr = new Memory(1024 * 10);
|
||||
String rs = dll.NationEcTrans(
|
||||
"http://172.16.11.13:5946/api/chs/qrCodeQuery",
|
||||
dataJson,
|
||||
resultStr
|
||||
);
|
||||
String rsStrString = resultStr.getString(0, "GB18030");
|
||||
Console.log(rsStrString);
|
||||
Console.log(rs);
|
||||
|
||||
return Result.ok("成功", rsStrString);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("qrCodeQuery")
|
||||
public Result<?> qrCodeQuery(@RequestBody JSONObject data) {
|
||||
try {
|
||||
|
||||
Console.log(data);
|
||||
return Result.ok("成功", null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.dpkj.modules.chs.controller;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.dpkj.common.config.ChsConfig;
|
||||
import com.dpkj.common.constant.ChsConst;
|
||||
import com.dpkj.common.vo.Result;
|
||||
import com.dpkj.modules.chs.dll.AlipayDll;
|
||||
import com.dpkj.modules.chs.entity.AlipayEcRequestData;
|
||||
import com.dpkj.modules.chs.service.IAlipayService;
|
||||
import com.dpkj.modules.chs.service.IHispayService;
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Pointer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2025/3/22 16:25
|
||||
* @Description: 医保模块-HIS医保
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/chs/hispay")
|
||||
public class HispayController {
|
||||
|
||||
private final IHispayService hispayService;
|
||||
|
||||
private final ChsConfig charsConfig;
|
||||
|
||||
|
||||
@GetMapping("test")
|
||||
public Result<?> test() {
|
||||
try {
|
||||
|
||||
return Result.ok("成功", null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
59
src/main/java/com/dpkj/modules/chs/dll/AlipayDll.java
Normal file
59
src/main/java/com/dpkj/modules/chs/dll/AlipayDll.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.dpkj.modules.chs.dll;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2025/3/22 17:48
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
public class AlipayDll {
|
||||
|
||||
/**
|
||||
* 获取 AlipayDll 实例,同时注册 AlipayDll 控件。
|
||||
*
|
||||
* @return AlipayDll 实例
|
||||
* @throws DllRegistrationException 如果注册控件失败,抛出此异常
|
||||
*/
|
||||
public static Dll instance() throws DllRegistrationException {
|
||||
try {
|
||||
return Native.load("NationECCode", Dll.class);
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
log.info("[AlipayDll][getPrintSDK][医保动态库] SDK注册失败:{}", e.getMessage());
|
||||
throw new DllRegistrationException("Failed to load AlipayDll library: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义自定义异常类,用于表示注册控件时发生的错误
|
||||
*/
|
||||
public static class DllRegistrationException extends Exception {
|
||||
public DllRegistrationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DllRegistrationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定义接口映射本地库中的函数。
|
||||
*/
|
||||
public interface Dll extends Library {
|
||||
|
||||
/**
|
||||
* 设置打印端口和波特率。
|
||||
*
|
||||
* @return 返回操作结果代码
|
||||
*/
|
||||
String NationEcTrans(String strUrl, String InData, Pointer OutData);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
59
src/main/java/com/dpkj/modules/chs/dll/HispayDll.java
Normal file
59
src/main/java/com/dpkj/modules/chs/dll/HispayDll.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.dpkj.modules.chs.dll;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2025/3/22 17:48
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
public class HispayDll {
|
||||
|
||||
/**
|
||||
* 获取 AlipayDll 实例,同时注册 AlipayDll 控件。
|
||||
*
|
||||
* @return AlipayDll 实例
|
||||
* @throws DllRegistrationException 如果注册控件失败,抛出此异常
|
||||
*/
|
||||
public static Dll instance() throws DllRegistrationException {
|
||||
try {
|
||||
return Native.load("PayClient", Dll.class);
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
log.info("[HispayDll][getPrintSDK][医保动态库] SDK注册失败:{}", e.getMessage());
|
||||
throw new DllRegistrationException("Failed to load AlipayDll library: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义自定义异常类,用于表示注册控件时发生的错误
|
||||
*/
|
||||
public static class DllRegistrationException extends Exception {
|
||||
public DllRegistrationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DllRegistrationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定义接口映射本地库中的函数。
|
||||
*/
|
||||
public interface Dll extends Library {
|
||||
|
||||
/**
|
||||
* 设置打印端口和波特率。
|
||||
*
|
||||
* @return 返回操作结果代码
|
||||
*/
|
||||
String NationEcTrans(String strUrl, String InData, Pointer OutData);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.dpkj.modules.chs.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2025/3/23 11:56
|
||||
* @Description: 医保请求
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AlipayEcRequestData implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 机构 ID 必填
|
||||
*/
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 交易类型 必填
|
||||
* ec.query: 电子凭证二维码解码接口
|
||||
* cn.nhsa.qrcode.get: 终端医保电子凭证码解码接口
|
||||
* cn.nhsa.auth.check:刷脸授权获取医保身份接口
|
||||
* cn.nhsa.ec.pwd: 医保电子凭证密码核验接口
|
||||
*/
|
||||
private String transType;
|
||||
|
||||
/**
|
||||
* 接口请求参数 JSON格式字符串 必填
|
||||
*/
|
||||
private JSONObject data;
|
||||
|
||||
/**
|
||||
* 扩展参数 JSON格式字符串
|
||||
*/
|
||||
private JSONObject extra;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.dpkj.modules.chs.service;
|
||||
|
||||
public interface IAlipayService {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.dpkj.modules.chs.service;
|
||||
|
||||
public interface IHispayService {
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.dpkj.modules.chs.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.dpkj.modules.chs.dll.AlipayDll;
|
||||
import com.dpkj.modules.chs.service.IAlipayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2025/3/22 16:29
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AlipayServiceImpl implements IAlipayService {
|
||||
|
||||
private AlipayDll.Dll dll = AlipayDll.instance();
|
||||
|
||||
|
||||
public AlipayServiceImpl() throws AlipayDll.DllRegistrationException {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
log.info("[AlipayServiceImpl][postConstruct][医保DLL] 初始化动态链接库");
|
||||
initPrinter();
|
||||
}
|
||||
|
||||
|
||||
private void initPrinter() {
|
||||
Console.log(dll);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.dpkj.modules.chs.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.dpkj.modules.chs.dll.HispayDll;
|
||||
import com.dpkj.modules.chs.service.IHispayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2025/3/22 16:29
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HispayServiceImpl implements IHispayService {
|
||||
|
||||
private HispayDll.Dll dll = HispayDll.instance();
|
||||
|
||||
|
||||
public HispayServiceImpl() throws HispayDll.DllRegistrationException {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
log.info("[HispayServiceImpl][postConstruct][医保DLL-HIS] 初始化动态链接库");
|
||||
initPrinter();
|
||||
}
|
||||
|
||||
|
||||
private void initPrinter() {
|
||||
Console.log(dll);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user