diff --git a/doc/win/yinyitong-dll-hang.bat b/doc/win/yinyitong-dll-hang.bat
index 5a28e10..7360bb6 100644
--- a/doc/win/yinyitong-dll-hang.bat
+++ b/doc/win/yinyitong-dll-hang.bat
@@ -1,22 +1,22 @@
@echo off
-:: 医保程序地址
+:: 鍖讳繚绋嬪簭鍦板潃
set CHSPATH=D:/Project/CHS
-:: jar名称
+:: jar鍚嶇О
set NAME=yinyitong-dll-hang
-:: 端口号
+:: 绔彛鍙
set PROT=5946
-echo 关闭%PROT%端口进程
+echo 鍏抽棴%PROT%绔彛杩涚▼
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr ":%PROT%"') do taskkill /pid %%m -t -f
-echo 启动%NAME%
+echo 鍚姩%NAME%
cd %CHSPATH%
start javaw.exe -Dfile.encoding=UTF-8 -Djava.library.path=%CHSPATH% -Dlog.path=%~dp0 -jar %~dp0\%NAME%.jar --server.port=%PROT%
-echo 启动完成
+echo 鍚姩瀹屾垚
exit
::pause
diff --git a/pom.xml b/pom.xml
index 0aa86e1..2ceceab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,18 +19,11 @@
1.8
5.8.36
- 3.0.2
- 1.2.83
5.17.0
+ 3.0.2
-
- org.springframework
- spring-core
-
-
-
org.springframework.boot
spring-boot-starter-web
@@ -41,11 +34,19 @@
lombok
true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
org.springframework.boot
spring-boot-starter-test
test
+
junit
junit
@@ -59,11 +60,22 @@
+
net.java.dev.jna
jna-jpms
${jna.version}
+
+
net.java.dev.jna
jna-platform-jpms
@@ -88,7 +100,7 @@
com.alibaba
fastjson
- ${fastjson.version}
+ 1.2.83
@@ -129,18 +141,41 @@
3.1.28
-
+
+
- javax.validation
- validation-api
- 2.0.1.Final
+ com.github.binarywang
+ weixin-java-pay
+ 4.7.0
+
+
+
+ org.jdom
+ jdom2
+ 2.0.6
+
+
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+
+
${project.artifactId}
+
+
+
-
org.springframework.boot
spring-boot-maven-plugin
@@ -155,59 +190,106 @@
-
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ true
+
+ lib/
+
+ false
+
+ com.dpkj.StandDllApplication
+
+
+
+ resources/
+
+
+
+
+
+
+
+ ${project.build.directory}/output
+
+
+
org.apache.maven.plugins
maven-dependency-plugin
copy-dependencies
- prepare-package
+ package
copy-dependencies
- ${project.build.directory}/lib
- false
- false
- true
+ ${project.build.directory}/output/lib/
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 3.0.0
-
+
+
-
-
-
-
- src/main/resources
-
- **/**
-
- false
-
-
dev
+
+
+ true
+
-
+
+ dev
pro
-
+
+ pro
diff --git a/src/main/java/com/dpkj/Application.java b/src/main/java/com/dpkj/HangDllApplication.java
similarity index 93%
rename from src/main/java/com/dpkj/Application.java
rename to src/main/java/com/dpkj/HangDllApplication.java
index 5a4672d..e1e0417 100644
--- a/src/main/java/com/dpkj/Application.java
+++ b/src/main/java/com/dpkj/HangDllApplication.java
@@ -12,10 +12,10 @@ import java.net.UnknownHostException;
@Slf4j
@SpringBootApplication
-public class Application {
+public class HangDllApplication {
public static void main(String[] args) throws UnknownHostException {
- ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);
+ ConfigurableApplicationContext application = SpringApplication.run(HangDllApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
diff --git a/src/main/java/com/dpkj/common/config/ChsConfig.java b/src/main/java/com/dpkj/common/config/ChsConfig.java
new file mode 100644
index 0000000..17ef7b5
--- /dev/null
+++ b/src/main/java/com/dpkj/common/config/ChsConfig.java
@@ -0,0 +1,22 @@
+package com.dpkj.common.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Auther: 钀ч亾瀛
+ * @Date: 2024/4/28 14:55
+ * @Description:
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "dpkj.chs")
+public class ChsConfig {
+
+ /**
+ * 鍖讳繚鏈烘瀯缂栫爜
+ */
+ private String orgcode;
+
+}
diff --git a/src/main/java/com/dpkj/common/config/HisConfig.java b/src/main/java/com/dpkj/common/config/HisConfig.java
new file mode 100644
index 0000000..5937159
--- /dev/null
+++ b/src/main/java/com/dpkj/common/config/HisConfig.java
@@ -0,0 +1,22 @@
+package com.dpkj.common.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Auther: 钀ч亾瀛
+ * @Date: 2024/4/28 14:55
+ * @Description:
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "dpkj.his")
+public class HisConfig {
+
+ /**
+ * 璋冪敤鑰匢D
+ */
+ private String operationId;
+
+}
diff --git a/src/main/java/com/dpkj/common/vo/ResultData.java b/src/main/java/com/dpkj/common/vo/ResultData.java
new file mode 100644
index 0000000..a6e2f18
--- /dev/null
+++ b/src/main/java/com/dpkj/common/vo/ResultData.java
@@ -0,0 +1,45 @@
+package com.dpkj.common.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 鎺ュ彛杩斿洖鏁版嵁鏍煎紡
+ */
+@Data
+@Accessors(chain = true)
+public class ResultData implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 璇锋眰鏃堕棿
+ */
+ private String requestTime;
+
+ /**
+ * 璇锋眰鍐呭
+ */
+ private String requestContent;
+
+ /**
+ * 鍝嶅簲鏃堕棿
+ */
+ private String responseTime;
+
+ /**
+ * 鍝嶅簲鍐呭
+ */
+ private String responseContent;
+
+ /**
+ * 鎮h匢D
+ */
+ private String patientId;
+
+ /**
+ * 澶勭悊鍚庣殑鍝嶅簲鍐呭
+ */
+ private Object result;
+}
diff --git a/src/main/java/com/dpkj/modules/chs/constant/ChsPayStateConst.java b/src/main/java/com/dpkj/modules/chs/constant/ChsPayStateConst.java
new file mode 100644
index 0000000..7be7570
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/constant/ChsPayStateConst.java
@@ -0,0 +1,59 @@
+package com.dpkj.modules.chs.constant;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Auther: 钀ч亾瀛
+ * @Date: 2025/6/18 15:57
+ * @Description: 鍖讳繚鐘舵佽褰曞父閲忕被
+ */
+public class ChsPayStateConst {
+
+ private static Map chsPayState = new HashMap(1);
+
+
+ /**
+ * 娓呴櫎鎵鏈
+ *
+ * @return void
+ * @author 钀ч亾瀛 2025/6/18
+ */
+ public static void clear() {
+ chsPayState.clear();
+ }
+
+ /**
+ * 鎸塳ey鍒犻櫎
+ *
+ * @return void
+ * @author 钀ч亾瀛 2025/6/18
+ */
+ public static void remove(String key) {
+ chsPayState.remove(key);
+ }
+
+
+ /**
+ * 娣诲姞
+ *
+ * @return void
+ * @author 钀ч亾瀛 2025/6/18
+ */
+ public static void put(String key, Integer val) {
+ chsPayState.put(key, val);
+ }
+
+
+ /**
+ * 鑾峰彇
+ *
+ * @return void
+ * @author 钀ч亾瀛 2025/6/18
+ */
+ public static Integer get(String key) {
+ return chsPayState.get(key);
+ }
+
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/controller/AlipayController.java b/src/main/java/com/dpkj/modules/chs/controller/AlipayController.java
new file mode 100644
index 0000000..b45ddd5
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/controller/AlipayController.java
@@ -0,0 +1,21 @@
+package com.dpkj.modules.chs.controller;
+
+import com.dpkj.modules.chs.service.IAlipayService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+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;
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/controller/HispayController.java b/src/main/java/com/dpkj/modules/chs/controller/HispayController.java
new file mode 100644
index 0000000..5517c48
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/controller/HispayController.java
@@ -0,0 +1,137 @@
+package com.dpkj.modules.chs.controller;
+
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.dpkj.common.vo.Result;
+import com.dpkj.common.vo.ResultData;
+import com.dpkj.modules.chs.constant.ChsPayStateConst;
+import com.dpkj.modules.chs.service.IHispayService;
+import com.dpkj.modules.chs.vo.OutpatientBeginModel;
+import com.dpkj.modules.chs.vo.OutpatientFinalModel;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+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;
+
+
+ /**
+ * 閫氳繃鍖讳繚鍗℃垨鍖讳繚鐢靛瓙鍑瘉璇诲崱
+ *
+ * @return com.dpkj.common.vo.Result>
+ * @author 钀ч亾瀛 2025/5/20
+ */
+ @PostMapping("findReadCode")
+ public Result> findReadCode() {
+ try {
+ JSONObject res = hispayService.readCode();
+ return Result.ok("鎴愬姛", res);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("[HispayController][getPatientInfo][鎸夊尰淇濈數瀛愬嚟璇佽鍗 ERR锛歿}", e.getMessage());
+ return Result.error(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 閫氳繃鍖讳繚鍗¤幏鍙栨偅鑰呬俊鎭
+ *
+ * @param data :
+ * @return com.dpkj.common.vo.Result>
+ * @author 钀ч亾瀛 2025/5/28
+ */
+ @PostMapping("findReadCard")
+ public Result> findReadCard(@RequestBody JSONObject data) {
+ try {
+ String password = data.getString("password");
+ if (StrUtil.isEmpty(password)) {
+ throw new RuntimeException("瀵嗙爜涓嶅彲涓虹┖");
+ }
+
+ JSONObject res = hispayService.readCard(password);
+ return Result.ok("鎴愬姛", res);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("[HispayController][readCardByCard][鎸夊尰淇濆崱璇诲崱] ERR锛歿}", e.getMessage());
+ return Result.error(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 闂ㄨ瘖缂磋垂-棰勭畻
+ *
+ * @param data :
+ * @return com.dpkj.common.vo.Result>
+ * @author 钀ч亾瀛 2025/5/27
+ */
+ @PostMapping("chsCodeAsOutpatientBegin")
+ public Result> chsCodeAsOutpatientBegin(@RequestBody @Validated OutpatientBeginModel data) {
+ try {
+ // 娓呯┖鐘舵佸父閲
+ ChsPayStateConst.clear();
+
+ log.info("[HispayController][chsCodeAsOutpatientBegin][闂ㄨ瘖缂磋垂-棰勭畻-鐢靛瓙鍖讳繚鍑瘉] 鍙傛暟锛歿}", data);
+ ResultData res = hispayService.chsCodeAsOutpatientBegin(data);
+ return Result.ok("鎴愬姛", res);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.info("[HispayController][chsCodeAsOutpatientBegin][闂ㄨ瘖缂磋垂-棰勭畻-鐢靛瓙鍖讳繚鍑瘉] 澶辫触锛歿}", e.getMessage());
+ return Result.error(e.getMessage());
+ }
+ }
+
+
+ /**
+ * 闂ㄨ瘖缂磋垂-缁撶畻
+ *
+ * @param data :
+ * @return com.dpkj.common.vo.Result>
+ * @author 钀ч亾瀛 2025/5/27
+ */
+ @PostMapping("chsCodeAsOutpatientFinal")
+ public Result> chsCodeAsOutpatientFinal(@RequestBody @Validated OutpatientFinalModel data) {
+ try {
+ log.info("[HispayController][chsCodeAsOutpatientFinal][闂ㄨ瘖缂磋垂-缁撶畻-鐢靛瓙鍖讳繚鍑瘉] 鍙傛暟锛歿}", data);
+ ResultData res = hispayService.chsCodeAsOutpatientFinal(data);
+ return Result.ok("鎴愬姛", res);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.info("[HispayController][chsCodeAsOutpatientFinal][闂ㄨ瘖缂磋垂-缁撶畻-鐢靛瓙鍖讳繚鍑瘉] 澶辫触锛歿}", e.getMessage());
+ return Result.error(e.getMessage());
+ }
+ }
+
+ /**
+ * 鑾峰彇鍖讳繚鏀粯鐘舵
+ *
+ * @return com.dpkj.common.vo.Result>
+ * @author 钀ч亾瀛 2025/6/18
+ */
+ @PostMapping("getChsPayState")
+ public Result> getChsPayState(@RequestBody OutpatientBeginModel data) {
+ String no = data.getPrescriptionNo();
+ if (StrUtil.isEmpty(no)) {
+ return Result.error("鏀舵嵁鍙蜂笉鍙负绌");
+ }
+ Integer num = ChsPayStateConst.get(no);
+ return Result.ok("鎴愬姛", num);
+ }
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/dll/AlipayDll.java b/src/main/java/com/dpkj/modules/chs/dll/AlipayDll.java
new file mode 100644
index 0000000..09242b0
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/dll/AlipayDll.java
@@ -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("AlipayChs", 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 杩斿洖鎿嶄綔缁撴灉浠g爜
+ */
+ String NationEcTrans(String strUrl, String InData, Pointer OutData);
+
+ }
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/dll/HispayDll.java b/src/main/java/com/dpkj/modules/chs/dll/HispayDll.java
new file mode 100644
index 0000000..3b7e024
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/dll/HispayDll.java
@@ -0,0 +1,14 @@
+package com.dpkj.modules.chs.dll;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @Auther: 钀ч亾瀛
+ * @Date: 2025/3/22 17:48
+ * @Description:
+ */
+@Slf4j
+public class HispayDll {
+
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/entity/AlipayEcRequestData.java b/src/main/java/com/dpkj/modules/chs/entity/AlipayEcRequestData.java
new file mode 100644
index 0000000..2b75ded
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/entity/AlipayEcRequestData.java
@@ -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;
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/service/IAlipayService.java b/src/main/java/com/dpkj/modules/chs/service/IAlipayService.java
new file mode 100644
index 0000000..e4dc9b4
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/service/IAlipayService.java
@@ -0,0 +1,4 @@
+package com.dpkj.modules.chs.service;
+
+public interface IAlipayService {
+}
diff --git a/src/main/java/com/dpkj/modules/chs/service/IHispayService.java b/src/main/java/com/dpkj/modules/chs/service/IHispayService.java
new file mode 100644
index 0000000..cc02f00
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/service/IHispayService.java
@@ -0,0 +1,46 @@
+package com.dpkj.modules.chs.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.dpkj.common.vo.ResultData;
+import com.dpkj.modules.chs.vo.OutpatientBeginModel;
+import com.dpkj.modules.chs.vo.OutpatientFinalModel;
+
+public interface IHispayService {
+
+ /**
+ * 閫氳繃鍖讳繚鐢靛瓙鍑瘉璇诲崱
+ *
+ * @return com.alibaba.fastjson.JSONObject
+ * @author 钀ч亾瀛 2025/5/28
+ */
+ JSONObject readCode();
+
+
+ /**
+ * 閫氳繃鍖讳繚鍗-璇诲崱
+ *
+ * @return com.alibaba.fastjson.JSONObject
+ * @author 钀ч亾瀛 2025/5/28
+ */
+ JSONObject readCard(String password);
+
+
+ /**
+ * 闂ㄨ瘖缂磋垂-棰勭畻 鐢靛瓙鍑瘉鏀粯
+ *
+ * @param data :
+ * @return com.dpkj.common.vo.Result>
+ * @author 钀ч亾瀛 2025/5/27
+ */
+ ResultData chsCodeAsOutpatientBegin(OutpatientBeginModel data);
+
+ /**
+ * 闂ㄨ瘖缂磋垂-缁撶畻 鐢靛瓙鍑瘉鏀粯
+ *
+ * @param data :
+ * @return com.dpkj.common.vo.Result>
+ * @author 钀ч亾瀛 2025/5/27
+ */
+ ResultData chsCodeAsOutpatientFinal(OutpatientFinalModel data);
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/service/impl/AlipayServiceImpl.java b/src/main/java/com/dpkj/modules/chs/service/impl/AlipayServiceImpl.java
new file mode 100644
index 0000000..f6bc781
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/service/impl/AlipayServiceImpl.java
@@ -0,0 +1,37 @@
+package com.dpkj.modules.chs.service.impl;
+
+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;
+
+
+ @PostConstruct
+ public void postConstruct() {
+ log.info("[AlipayServiceImpl][postConstruct][鍖讳繚DLL] 鍒濆鍖栧姩鎬侀摼鎺ュ簱");
+ try {
+ dll = AlipayDll.instance();
+ } catch (AlipayDll.DllRegistrationException e) {
+ // TODO 钀ч亾瀛 2025/6/19 :
+ }
+ initPrinter();
+ }
+
+
+ private void initPrinter() {
+
+ }
+}
diff --git a/src/main/java/com/dpkj/modules/chs/service/impl/HispayServiceImpl.java b/src/main/java/com/dpkj/modules/chs/service/impl/HispayServiceImpl.java
new file mode 100644
index 0000000..e443387
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/service/impl/HispayServiceImpl.java
@@ -0,0 +1,275 @@
+package com.dpkj.modules.chs.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.ChsConfig;
+import com.dpkj.common.config.HisConfig;
+import com.dpkj.common.vo.ResultData;
+import com.dpkj.modules.chs.constant.ChsPayStateConst;
+import com.dpkj.modules.chs.service.IHispayService;
+import com.dpkj.modules.chs.vo.OutpatientBeginModel;
+import com.dpkj.modules.chs.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 ChsConfig chsConfig;
+
+ // 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.info("[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 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.鎮h呭鍚嶅拰鐢佃瘽鍙风爜锛8.鐢靛瓙鍋ュ悍鐮/鍗★紝9.鍖讳繚鐢靛瓙鍑瘉
+ .fluentPut("cardno", "") // 鎮h呭氨璇婂崱鍙
+ .fluentPut("sfzh", "") // 韬唤璇佸彿
+ .fluentPut("hzxm", "") // 鎮h呭鍚
+ .fluentPut("phone", ""); // 鎮h呯數璇濆彿鐮
+ String params = processParameters(val, null);
+ log.info("[HispayServiceImpl][readCode][鍖讳繚璇诲崱-鐢靛瓙鍑瘉] 鎺ュ彛鍏ュ弬锛歿}", params);
+
+ /** 2銆佽皟鐢–OM鍑芥暟 */
+ Variant vres = new Variant("", true);
+ Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, vres);
+
+ String resStr = vres.getStringRef();
+ log.info("[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.鎮h呭鍚嶅拰鐢佃瘽鍙风爜锛8.鐢靛瓙鍋ュ悍鐮/鍗★紝9.鍖讳繚鐢靛瓙鍑瘉
+ .fluentPut("cardno", "") // 鎮h呭氨璇婂崱鍙
+ .fluentPut("sfzh", "") // 韬唤璇佸彿
+ .fluentPut("hzxm", "") // 鎮h呭鍚
+ .fluentPut("phone", ""); // 鎮h呯數璇濆彿鐮
+ String params = processParameters(val, password);
+ log.info("[HispayServiceImpl][readCard][鍖讳繚璇诲崱-鍖讳繚鍗 鎺ュ彛鍏ュ弬锛歿}", params);
+
+ /** 2銆佽皟鐢–OM鍑芥暟 */
+ Variant vres = new Variant("", true);
+ Variant call = Dispatch.call(dispatch, "fRun", "BMZXX010", params, vres);
+
+ String resStr = vres.getStringRef();
+ log.info("[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") // 鏄惁鎵i櫌鍐呰处鎴凤紝0涓嶄娇鐢ㄩ櫌鍐呰处鎴凤紝1浣跨敤闄㈠唴璐︽埛锛堥粯璁や笉浣跨敤闄㈠唴璐︽埛锛
+ .fluentPut("zfjsbz", "0") // 鏄惁鑷垂缁撶畻锛0鏍规嵁鍖讳繚浠g爜缂磋垂锛1鑷垂缁撶畻锛堥粯璁よ嚜璐圭粨绠楋級
+ .fluentPut("ybrc", ""); // 鍖讳繚鍏ュ弬锛寈ml鑺傜偣
+ String params = processParameters(val, data.getPassword());
+ log.info("[HispayServiceImpl][outpatientBudget][闂ㄨ瘖缂磋垂-棰勭畻] 鎺ュ彛鍏ュ弬锛歿}", params);
+
+ String requestTime = DateUtil.now();
+
+ /** 2銆佽皟鐢–OM鍑芥暟 */
+ Variant resVariant = new Variant("", true);
+ Variant call = Dispatch.call(dispatch, "fRun", "BMZJF001", params, resVariant);
+
+ String responseTime = DateUtil.now();
+ String resStr = resVariant.getStringRef();
+ log.info("[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") // 鏄惁鎵i櫌鍐呰处鎴凤紝涓庨绠椾繚鎸佷竴鑷
+ .fluentPut("zfjsbz", "0") // 鏄惁鑷垂缁撶畻锛屼笌棰勭畻淇濇寔涓鑷达紝0鏍规嵁鐥呬汉鍖讳繚浠g爜缁撶畻锛1鑷垂缁撶畻
+ .fluentPut("ybrc", "")
+ .fluentPut("ptlsh", "")
+ .fluentPut("jysm", "");
+ String params = processParameters(val, null);
+ log.info("[HispayServiceImpl][chsCodeAsOutpatientFinal][闂ㄨ瘖缂磋垂-缁撶畻] 鎺ュ彛鍏ュ弬锛歿}", params);
+
+ /** 2銆佽皟鐢–OM鍑芥暟 */
+ Variant resVariant = new Variant("", true);
+ Variant call = Dispatch.call(dispatch, "fRun", "BMZJF002", params, resVariant);
+
+ String responseTime = DateUtil.now();
+ String resStr = resVariant.getStringRef();
+ log.info("[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);
+ }
+
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/vo/OutpatientBeginModel.java b/src/main/java/com/dpkj/modules/chs/vo/OutpatientBeginModel.java
new file mode 100644
index 0000000..21f36f9
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/vo/OutpatientBeginModel.java
@@ -0,0 +1,37 @@
+package com.dpkj.modules.chs.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotEmpty;
+import java.io.Serializable;
+
+/**
+ * @Auther: 钀ч亾瀛
+ * @Date: 2025/5/27 16:52
+ * @Description:
+ */
+@Data
+@Accessors(chain = true)
+public class OutpatientBeginModel implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 鐥呬汉ID
+ */
+ // @NotEmpty(message = "鎮h匢D涓嶅彲涓虹┖!")
+ private String patientId;
+
+ /**
+ * 澶勬柟鍗曞彿 - 澶氫釜閫楀彿鎷兼帴
+ */
+ @NotEmpty(message = "澶勬柟鍗曞彿涓嶅彲涓虹┖!")
+ private String prescriptionNo;
+
+ /**
+ * 鐥呬汉ID
+ */
+ // @NotEmpty(message = "瀵嗙爜涓嶅彲涓虹┖!")
+ private String password;
+
+}
diff --git a/src/main/java/com/dpkj/modules/chs/vo/OutpatientFinalModel.java b/src/main/java/com/dpkj/modules/chs/vo/OutpatientFinalModel.java
new file mode 100644
index 0000000..1040031
--- /dev/null
+++ b/src/main/java/com/dpkj/modules/chs/vo/OutpatientFinalModel.java
@@ -0,0 +1,49 @@
+package com.dpkj.modules.chs.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotEmpty;
+import java.io.Serializable;
+
+/**
+ * @Auther: 钀ч亾瀛
+ * @Date: 2025/5/27 16:52
+ * @Description: 缁撶畻
+ */
+@Data
+@Accessors(chain = true)
+public class OutpatientFinalModel implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @NotEmpty(message = "鎮h匢D涓嶅彲涓虹┖!")
+ private String patid;
+
+ @NotEmpty(message = "鏀舵嵁鍙蜂笉鍙负绌!")
+ private String sjh;
+
+ @NotEmpty(message = "鎬婚噾棰濅笉鍙负绌!")
+ private String zje;
+
+ @NotEmpty(message = "搴斾粯閲戦涓嶅彲涓虹┖!")
+ private String ysje;
+
+ @NotEmpty(message = "鏀粯鏂瑰紡涓嶅彲涓虹┖!")
+ private String paytype;
+
+ @NotEmpty(message = "鏀粯閲戦涓嶅彲涓虹┖!")
+ private String paymoney;
+
+ @NotEmpty(message = "鏀粯娴佹按鍙蜂笉鍙负绌!")
+ private String paylsh;
+
+ @NotEmpty(message = "鍖讳繚鎶ラ攢閲戦涓嶅彲涓虹┖!")
+ private String ybzf;
+
+ /**
+ * 鏀粯鏃堕棿
+ */
+ // @NotEmpty(message = "鏀粯鏃堕棿涓嶅彲涓虹┖!")
+ private String paytime;
+
+}
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index d800a93..b4f3e3c 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -1,10 +1,35 @@
+server:
+ port: 5948
+ servlet:
+ context-path: /api
+ tomcat:
+ max-swallow-size: -1
+ error:
+ include-exception: true
+ include-stacktrace: ALWAYS
+ include-message: ALWAYS
+ compression:
+ enabled: true
+ min-response-size: 1024
+ mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
+
+spring:
+ servlet:
+ multipart:
+ max-file-size: 10MB
+ max-request-size: 10MB
+ resource:
+ static-locations: classpath:/static/,classpath:/public/
+
+logging:
+ level:
+ com.dpkj: debug
+
dpkj:
# 鍖讳繚閰嶇疆
chs:
# 鍖讳繚鏈烘瀯缂栫爜
orgcode: H53082800070
- # 鍖讳繚璇诲崱涔嬪悗淇濆瓨淇℃伅鐨勬枃浠跺悕
- file-name: outfile1191.txt
file:
# 鏂囦欢淇濆瓨鍦板潃
path: G:\Temp\img
diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml
index bc814d7..6e527c3 100644
--- a/src/main/resources/application-pro.yml
+++ b/src/main/resources/application-pro.yml
@@ -1,10 +1,36 @@
+server:
+ port: 5946
+ servlet:
+ context-path: /api
+ tomcat:
+ max-swallow-size: -1
+ error:
+ include-exception: true
+ include-stacktrace: ALWAYS
+ include-message: ALWAYS
+ compression:
+ enabled: true
+ min-response-size: 1024
+ mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
+
+spring:
+ servlet:
+ multipart:
+ max-file-size: 10MB
+ max-request-size: 10MB
+ resource:
+ static-locations: classpath:/static/,classpath:/public/
+
+logging:
+ level:
+ com.dpkj: debug
+
+
dpkj:
# 鍖讳繚閰嶇疆
chs:
# 鍖讳繚鏈烘瀯缂栫爜
orgcode: H53082800070
- # 鍖讳繚璇诲崱涔嬪悗淇濆瓨淇℃伅鐨勬枃浠跺悕
- file-name: outfile1191.txt
file:
# 鏂囦欢淇濆瓨鍦板潃
path: D:\Project\Express\upload
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0fc081b..0371f70 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,27 +1,6 @@
spring:
- servlet:
- multipart:
- max-file-size: 10MB
- max-request-size: 10MB
- resource:
- static-locations: classpath:/static/,classpath:/public/
application:
- name: ems-express-bridge
+ name: yinyitong-zhongyuyuan-dll-hang
profiles:
- #active: '@profile.name@'
- active: pro
+ active: '@profile.name@'
-server:
- port: 5946
- servlet:
- context-path: /api
- tomcat:
- max-swallow-size: -1
- error:
- include-exception: true
- include-stacktrace: ALWAYS
- include-message: ALWAYS
- compression:
- enabled: true
- min-response-size: 1024
- mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
diff --git a/src/main/resources/win32-x86/AlipayChs.dll b/src/main/resources/win32-x86/AlipayChs.dll
new file mode 100644
index 0000000..e69de29