LIJU 2 周之前
父節點
當前提交
81728d0592

+ 4 - 1
src/main/java/thyyxxk/sizyfeeoprnsystm/service/ExecService.java

@@ -201,7 +201,10 @@ public class ExecService {
     /**
      * 工伤接口URL
      */
-    private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
+    // 模拟接口地址(注释掉,需要时手动切换)
+    // private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
+    // 真实接口地址(当前使用)
+    private static final String WORK_INJURY_API_URL = "http://localhost:8321/api/entry/workinjury";
     
     /**
      * 执行工伤接口调用(工伤接口使用不同的请求头格式)

+ 149 - 12
src/main/java/thyyxxk/sizyfeeoprnsystm/service/SiZyFeeService.java

@@ -656,17 +656,21 @@ public class SiZyFeeService {
             log.info("【操作员:{}】撤销工伤已上传的费用明细{}:\n参数:{},\n结果:{}", 
                     p.getStaffId(), detailSn, input, result);
             
-            if (null == result || null == result.getInteger(RESULT_CODE)) {
+            // 工伤接口返回结果处理(支持模拟接口和真实接口切换)
+            Integer infcode = extractWorkInjuryResultCode(result);
+            
+            if (null == result || null == infcode) {
                 log.error("工伤撤销接口调用失败,明细:{}", detailSn);
                 failedDetailSns.add(detailSn);
                 continue; // 继续撤销下一个,不中断整个流程
             }
             
-            if (result.getIntValue(RESULT_CODE) == 0) {
+            if (infcode == 0) {
                 log.info("工伤撤销成功,明细:{}", detailSn);
                 successDetailSns.add(detailSn);
             } else {
-                log.error("工伤撤销失败,明细:{},错误:{}", detailSn, result.getString(ERROR_MESSAGE));
+                String errorMsg = extractWorkInjuryErrorMessage(result);
+                log.error("工伤撤销失败,明细:{},错误:{}", detailSn, errorMsg);
                 failedDetailSns.add(detailSn);
             }
         }
@@ -817,13 +821,17 @@ public class SiZyFeeService {
         
         // 调用工伤费用上传接口
         JSONObject result = exec.executeWorkInjuryTrade(input);
-        int infcode = result.getIntValue(RESULT_CODE);
-        String logMsg = infcode + "," + result.getString("inf_refmsgid");
+        
+        // 工伤接口返回结果处理(支持模拟接口和真实接口切换)
+        Integer infcode = extractWorkInjuryResultCode(result);
+        String logMsg = (infcode != null ? infcode.toString() : "null") + "," + 
+                       (result != null ? result.getString("inf_refmsgid") : "null");
         log.info("【操作员:{}】,工伤费用上传:\n患者:{},\n结果:{}", p.getStaffId(),
                 p.getPsnInfo(), logMsg);
         
         if (infcode == 0) {
-            JSONArray array = result.getJSONObject(OUTPUT).getJSONArray("result");
+            // 工伤接口返回结果提取(支持模拟接口和真实接口切换)
+            JSONArray array = extractWorkInjuryUploadResult(result);
             List<SiChargeTemp> tempList = new ArrayList<>();
             for (int i = 0; i < array.size(); i++) {
                 JSONObject upldretrn = array.getJSONObject(i);
@@ -837,7 +845,7 @@ public class SiZyFeeService {
             zyDao.insertSiChargeTempFeeBatch(tempList);
             return new int[]{tempList.size(), fees.size() - tempList.size()};
         } else {
-            String message = result.getString(ERROR_MESSAGE);
+            String message = extractWorkInjuryErrorMessage(result);
             sendUploadResponse(p, message);
             return new int[]{fees.size(), 0};
         }
@@ -908,16 +916,19 @@ public class SiZyFeeService {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
         
-        Integer infcode = result.getInteger(RESULT_CODE);
+        // 工伤接口返回结果处理(支持模拟接口和真实接口切换)
+        Integer infcode = extractWorkInjuryResultCode(result);
         logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, zyPreSetlmt.getPsnNo()));
         
         if (null == infcode) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "工伤中心报错:" + result.getString("message"));
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "工伤中心报错:" + 
+                (result != null ? result.getString("message") : "未知错误"));
         }
         
         if (infcode == 0) {
-            JSONObject setlinfo = result.getJSONObject(OUTPUT).getJSONObject("setlinfo");
-            String fundPay = setlinfo.getString("fund_pay_sumamt");
+            // 工伤接口返回结果提取(支持模拟接口和真实接口切换)
+            JSONObject setlinfo = extractWorkInjuryPreSettlementResult(result);
+            String fundPay = setlinfo != null ? setlinfo.getString("hifp_pay") : "0";  // 工伤使用 hifp_pay 字段
             
             // 更新工伤报销金额(使用相同的表)
             zyDao.updateFundPay(fundPay, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
@@ -934,7 +945,133 @@ public class SiZyFeeService {
             return ResultVoUtil.success(message);
         }
         
-        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, extractWorkInjuryErrorMessage(result));
+    }
+
+    /**
+     * 工伤接口返回结果代码提取(支持模拟接口和真实接口切换)
+     */
+    private Integer extractWorkInjuryResultCode(JSONObject result) {
+        if (result == null) {
+            return null;
+        }
+        
+        // 模拟接口返回结构:result.getJSONObject("data").getJSONObject("data").getString("infcode")
+        // 真实接口返回结构:result.getJSONObject("data").getString("infcode")
+        
+        // 模拟接口处理(注释掉,需要时手动切换)
+        if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+            JSONObject innerData = result.getJSONObject("data").getJSONObject("data");
+            return innerData != null ? innerData.getInteger(RESULT_CODE) : null;
+        }
+        // 真实接口处理(当前使用)
+        else if (result.containsKey("data")) {
+            JSONObject data = result.getJSONObject("data");
+            return data != null ? data.getInteger(RESULT_CODE) : null;
+        }
+        
+        return null;
+    }
+
+    /**
+     * 工伤费用上传返回结果提取(支持模拟接口和真实接口切换)
+     */
+    private JSONArray extractWorkInjuryUploadResult(JSONObject result) {
+        if (result == null) {
+            return new JSONArray();
+        }
+        
+        // 模拟接口返回结构:result.getJSONObject("data").getJSONObject("data").getJSONObject("output")
+        // 真实接口返回结构:result.getJSONObject("data").getJSONObject("output")
+        
+        // 模拟接口处理(注释掉,需要时手动切换)
+        if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+            JSONObject innerData = result.getJSONObject("data").getJSONObject("data");
+            if (innerData != null && innerData.containsKey(OUTPUT)) {
+                Object output = innerData.get(OUTPUT);
+                if (output instanceof JSONArray) {
+                    return (JSONArray) output;
+                }
+            }
+        }
+        // 真实接口处理(当前使用)
+        else if (result.containsKey("data")) {
+            JSONObject data = result.getJSONObject("data");
+            if (data != null && data.containsKey(OUTPUT)) {
+                Object output = data.get(OUTPUT);
+                if (output instanceof JSONArray) {
+                    return (JSONArray) output;
+                }
+            }
+        }
+        
+        return new JSONArray();
+    }
+
+    /**
+     * 工伤预结算返回结果提取(支持模拟接口和真实接口切换)
+     */
+    private JSONObject extractWorkInjuryPreSettlementResult(JSONObject result) {
+        if (result == null) {
+            return new JSONObject();
+        }
+        
+        // 模拟接口返回结构:result.getJSONObject("data").getJSONObject("data").getJSONObject("output")
+        // 真实接口返回结构:result.getJSONObject("data").getJSONObject("output")
+        
+        // 模拟接口处理(注释掉,需要时手动切换)
+        if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+            JSONObject innerData = result.getJSONObject("data").getJSONObject("data");
+            if (innerData != null && innerData.containsKey(OUTPUT)) {
+                Object output = innerData.get(OUTPUT);
+                if (output instanceof JSONObject) {
+                    return (JSONObject) output;
+                }
+            }
+        }
+        // 真实接口处理(当前使用)
+        else if (result.containsKey("data")) {
+            JSONObject data = result.getJSONObject("data");
+            if (data != null && data.containsKey(OUTPUT)) {
+                Object output = data.get(OUTPUT);
+                if (output instanceof JSONObject) {
+                    return (JSONObject) output;
+                }
+            }
+        }
+        
+        return new JSONObject();
+    }
+
+    /**
+     * 工伤接口错误信息提取(支持模拟接口和真实接口切换)
+     */
+    private String extractWorkInjuryErrorMessage(JSONObject result) {
+        if (result == null) {
+            return "未知错误";
+        }
+        
+        // 模拟接口返回结构:result.getJSONObject("data").getJSONObject("data").getString("err_msg")
+        // 真实接口返回结构:result.getJSONObject("data").getString("err_msg")
+        
+        // 模拟接口处理(注释掉,需要时手动切换)
+        if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+            JSONObject innerData = result.getJSONObject("data").getJSONObject("data");
+            if (innerData != null) {
+                String errorMsg = innerData.getString(ERROR_MESSAGE);
+                return StringUtil.isBlank(errorMsg) ? "未知错误" : errorMsg;
+            }
+        }
+        // 真实接口处理(当前使用)
+        else if (result.containsKey("data")) {
+            JSONObject data = result.getJSONObject("data");
+            if (data != null) {
+                String errorMsg = data.getString(ERROR_MESSAGE);
+                return StringUtil.isBlank(errorMsg) ? "未知错误" : errorMsg;
+            }
+        }
+        
+        return "未知错误";
     }
 
         /**

+ 172 - 0
工伤接口切换说明.md

@@ -0,0 +1,172 @@
+# 工伤接口切换说明
+
+## 概述
+
+工伤接口支持在模拟接口和真实接口之间进行切换,通过注释代码的方式实现手动切换。
+
+## 切换位置
+
+### 1. 接口URL切换
+
+**文件位置**: `src/main/java/thyyxxk/sizyfeeoprnsystm/service/ExecService.java`
+
+**切换方法**:
+```java
+// 模拟接口地址(注释掉,需要时手动切换)
+// private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
+// 真实接口地址(当前使用)
+private static final String WORK_INJURY_API_URL = "http://localhost:8321/api/entry/workinjury";
+```
+
+**切换步骤**:
+1. 注释掉当前使用的URL
+2. 取消注释要使用的URL
+
+### 2. 返回结果处理切换
+
+**文件位置**: `src/main/java/thyyxxk/sizyfeeoprnsystm/service/SiZyFeeService.java`
+
+**切换方法**:
+在以下方法中,通过注释切换不同的处理逻辑:
+
+#### 2.1 工伤接口返回结果代码提取
+```java
+private Integer extractWorkInjuryResultCode(JSONObject result) {
+    // 模拟接口处理(注释掉,需要时手动切换)
+    if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+        return result.getJSONObject("data").getJSONObject("data").getInteger(RESULT_CODE);
+    }
+    // 真实接口处理(当前使用)
+    else if (result.containsKey("data")) {
+        return result.getJSONObject("data").getInteger(RESULT_CODE);
+    }
+    return null;
+}
+```
+
+#### 2.2 工伤费用上传返回结果提取
+```java
+private JSONArray extractWorkInjuryUploadResult(JSONObject result) {
+    // 模拟接口处理(注释掉,需要时手动切换)
+    if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+        return result.getJSONObject("data").getJSONObject("data").getJSONArray(OUTPUT);
+    }
+    // 真实接口处理(当前使用)
+    else if (result.containsKey("data")) {
+        return result.getJSONObject("data").getJSONArray(OUTPUT);
+    }
+    return new JSONArray();
+}
+```
+
+#### 2.3 工伤预结算返回结果提取
+```java
+private JSONObject extractWorkInjuryPreSettlementResult(JSONObject result) {
+    // 模拟接口处理(注释掉,需要时手动切换)
+    if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+        return result.getJSONObject("data").getJSONObject("data").getJSONObject(OUTPUT);
+    }
+    // 真实接口处理(当前使用)
+    else if (result.containsKey("data")) {
+        return result.getJSONObject("data").getJSONObject(OUTPUT);
+    }
+    return new JSONObject();
+}
+```
+
+#### 2.4 工伤接口错误信息提取
+```java
+private String extractWorkInjuryErrorMessage(JSONObject result) {
+    // 模拟接口处理(注释掉,需要时手动切换)
+    if (result.containsKey("data") && result.getJSONObject("data").containsKey("data")) {
+        return result.getJSONObject("data").getJSONObject("data").getString(ERROR_MESSAGE);
+    }
+    // 真实接口处理(当前使用)
+    else if (result.containsKey("data")) {
+        return result.getJSONObject("data").getString(ERROR_MESSAGE);
+    }
+    return "未知错误";
+}
+```
+
+## 接口返回结构对比
+
+### 模拟接口返回结构
+```json
+{
+  "code": 1,
+  "data": {
+    "success": true,
+    "code": 200,
+    "message": "交易成功",
+    "device": "江苏工伤联网接口(模拟)",
+    "transactionCode": "2204",
+    "data": {
+      "infcode": "0",
+      "inf_refmsgid": "xxx",
+      "err_msg": "",
+      "output": {}
+    }
+  }
+}
+```
+
+### 真实接口返回结构
+```json
+{
+  "success": true,
+  "code": 200,
+  "message": "交易成功",
+  "device": "江苏工伤联网接口",
+  "transactionCode": "2204",
+  "data": {
+    "infcode": "0",
+    "inf_refmsgid": "xxx",
+    "err_msg": "",
+    "output": {}
+  }
+}
+```
+
+## 切换步骤
+
+### 从真实接口切换到模拟接口
+
+1. **修改URL**:
+   ```java
+   // 注释掉真实接口URL
+   // private static final String WORK_INJURY_API_URL = "http://localhost:8321/api/entry/workinjury";
+   // 取消注释模拟接口URL
+   private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
+   ```
+
+2. **修改返回结果处理**:
+   在每个提取方法中,注释掉真实接口处理逻辑,取消注释模拟接口处理逻辑。
+
+### 从模拟接口切换到真实接口
+
+1. **修改URL**:
+   ```java
+   // 注释掉模拟接口URL
+   // private static final String WORK_INJURY_API_URL = "http://130.150.161.72:9206/thyy/api/public/injury/workinjury";
+   // 取消注释真实接口URL
+   private static final String WORK_INJURY_API_URL = "http://localhost:8321/api/entry/workinjury";
+   ```
+
+2. **修改返回结果处理**:
+   在每个提取方法中,注释掉模拟接口处理逻辑,取消注释真实接口处理逻辑。
+
+## 注意事项
+
+1. **切换时需要同时修改URL和返回结果处理逻辑**
+2. **切换后需要重新编译和部署**
+3. **建议在测试环境先验证切换是否正确**
+4. **切换前请备份当前配置**
+
+## 支持的接口
+
+- **2204**: 工伤费用上传
+- **2205**: 工伤费用撤销
+- **2206**: 工伤预结算
+
+所有接口都支持模拟接口和真实接口的切换。 

+ 137 - 0
工伤流程图精简版.md

@@ -0,0 +1,137 @@
+工伤费用上传精简流程:
+┌─────────────────┐
+│ 前端调用工伤接口 │
+│ /uploadWorkInjuryFees │
+│ 📝 接收前端批量上传请求,包含患者信息 │
+│ 📝 创建Socket任务用于进度反馈 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ uploadWorkInjury│
+│ FeeDetail       │
+│ 📝 处理单个工伤患者的费用上传 │
+│ 📝 验证患者工伤在院信息有效性 │
+│ 📝 设置账本号、中间结算标志 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ beforeWorkInjury│
+│ Upload          │ ← 工伤预处理
+│ - 修改费用时间  │
+│ - 正负相抵逻辑  │
+│ 📝 将超出出院时间的费用时间修改为出院时间 │
+│ 📝 处理正负费用相抵,避免重复计算 │
+│ 📝 更新费用明细的抵消状态 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ getAllFeesNot   │
+│ Uploaded        │ ← 获取未上传费用
+│ - 正费用查询    │
+│ - 负费用查询    │
+│ 📝 从t_fee_dtle表查询未上传的正费用 │
+│ 📝 从t_fee_dtle表查询未上传的负费用 │
+│ 📝 按费用发生时间排序,分批处理 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ prepareWorkInjury│
+│ UploadFees      │
+│ 📝 构建工伤费用上传请求头 │
+│ 📝 设置医生编码、科室编码等必要信息 │
+│ 📝 将费用明细转换为工伤中心格式 │
+│ 📝 批量处理,每次最多100条明细 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ executeWorkInjury│
+│ UploadFees      │
+│ 📝 执行工伤费用上传核心逻辑 │
+│ 📝 构建符合工伤接口文档的请求参数 │
+│ 📝 调用工伤中心2204接口 │
+│ 📝 处理上传结果,记录成功/失败明细 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 调用工伤接口    │
+│ (2204)          │
+│ 📝 调用工伤费用上传接口 │
+│ 📝 URL: http://130.150.161.72:9206/thyy/api/public/injury/workinjury │
+│ 📝 传递费用明细数组,包含单价、数量、金额等信息 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 处理上传结果    │
+│ - 解析返回数据  │
+│ - 记录成功/失败 │
+│ 📝 解析工伤中心返回的JSON结果 │
+│ 📝 提取成功上传的明细流水号 │
+│ 📝 记录失败明细及错误信息 │
+│ 📝 更新本地数据库的上传状态 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 更新数据库      │
+│ - t_si_charge_temp │
+│ - 更新trans_flag │
+│ 📝 将成功上传的明细插入t_si_charge_temp表 │
+│ 📝 更新t_fee_dtle表的trans_flag为已上传 │
+│ 📝 记录上传日志到t_si_log表 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 工伤预结算      │
+│ (2206)          │
+│ 📝 调用工伤费用预结算接口 │
+│ 📝 获取工伤报销金额和自费金额 │
+│ 📝 更新预结算信息到数据库 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ workInjuryPreSettlement │
+│ 📝 构建工伤预结算请求参数 │
+│ 📝 包含患者信息、费用总额等 │
+│ 📝 调用工伤中心2206预结算接口 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 调用工伤预结算接口│
+│ exec.executeWorkInjuryTrade │
+│ 📝 发送预结算请求到工伤中心 │
+│ 📝 传递患者就医ID、费用信息等 │
+│ 📝 接收预结算结果 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 处理预结算结果  │
+│ - 获取报销金额  │
+│ - 更新数据库    │
+│ 📝 解析预结算返回的报销金额 │
+│ 📝 更新t_zy_pre_setlmt表的预结算信息 │
+│ 📝 记录预结算日志 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 返回成功消息    │
+│ "工伤费用预结算成功" │
+│ 📝 向前端返回处理结果 │
+│ 📝 包含上传成功数量和预结算金额 │
+│ 📝 发送Socket消息通知前端更新 │
+└─────────────────┘
+
+## 工伤接口调用
+
+### 主要接口:
+
+1. **2204 - 工伤费用上传**
+   - **URL**: `http://130.150.161.72:9206/thyy/api/public/injury/workinjury`
+   - **功能**: 上传工伤费用明细
+
+2. **2206 - 工伤预结算**
+   - **URL**: `http://130.150.161.72:9206/thyy/api/public/injury/workinjury`
+   - **功能**: 工伤费用预结算
+
+### 数据库操作:
+- **查询**: `t_si_pat_info`, `t_fee_dtle`, `t_zy_patient_info`
+- **更新**: `t_fee_dtle`, `t_si_charge_temp`
+- **插入**: `t_si_charge_temp`