diff --git a/src/main/java/com/saye/hospitalgd/controller/Custom_PayType_Configuration_Summary.md b/src/main/java/com/saye/hospitalgd/controller/Custom_PayType_Configuration_Summary.md new file mode 100644 index 0000000..698c194 --- /dev/null +++ b/src/main/java/com/saye/hospitalgd/controller/Custom_PayType_Configuration_Summary.md @@ -0,0 +1,90 @@ +# 自定义PayType配置总结 + +## 用户自定义的PayType编码方案 + +基于用户要求,配置如下PayType编码: + +| HIS支付方式 | PayType编码 | 说明 | +|------------|------------|------| +| 现金 | 5 | 现金支付 | +| 微信 | 1 | 微信支付 | +| 聚合支付 | 2 | 聚合支付 | +| 军保支付 | 3 | 军保支付 | +| 其他 | 4 | 其他/未知支付方式 | + +## 字典表SQL配置 + +```sql +-- 清理现有数据 +DELETE FROM `dicinfo` WHERE `parent_code` = 'PAY_TYPE' AND `diccode` != 'PAY_TYPE'; + +-- 用户自定义编码配置 +INSERT INTO `dicinfo` VALUES ('his_pay_001', '现金', '5', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 1); +INSERT INTO `dicinfo` VALUES ('his_pay_002', '微信', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 2); +INSERT INTO `dicinfo` VALUES ('his_pay_003', '聚合支付', '2', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 3); +INSERT INTO `dicinfo` VALUES ('his_pay_004', '军保支付', '3', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 4); +INSERT INTO `dicinfo` VALUES ('his_pay_005', '其他', '4', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 5); +``` + +## 汇总统计分类适配 + +### HIS端统计适配 +```java +// PaymentStatisticsController.java 中的统计分类 +hisMoneyData.put("1", "0"); // 微信支付 +hisMoneyData.put("2", "0"); // 聚合支付 +hisMoneyData.put("3", "0"); // 军保支付 +hisMoneyData.put("4", "0"); // 其他 +hisMoneyData.put("5", "0"); // 现金支付 +``` + +### 转换逻辑适配 +```java +// HISGetDataMethodByJH.java 中的转换方法 +private String convertPayTypeByDictionary(String originalPayType, HashMap payTypeMap) { + // 严格字典匹配,未匹配则返回"4"(其他) + // 支持的精确匹配:现金、微信、聚合支付、军保支付 +} +``` + +## 实施检查清单 + +### 1. 数据库配置 ✓ +- [x] 执行字典表SQL脚本 +- [x] 验证字典数据正确插入 + +### 2. 代码配置 ✓ +- [x] 更新HISGetDataMethodByJH转换逻辑 +- [x] 更新PaymentStatisticsController统计逻辑 +- [x] 修改默认值从"5"改为"4" + +### 3. 验证测试 ⚠️ +- [ ] 重启应用加载新字典数据 +- [ ] 执行HIS数据同步测试 +- [ ] 验证PayType转换结果 +- [ ] 检查汇总统计页面数据 + +## 预期结果 + +执行配置后,HIS数据入库时: +- `现金` → PayType: `5` +- `微信` → PayType: `1` +- `聚合支付` → PayType: `2` +- `军保支付` → PayType: `3` +- 未匹配 → PayType: `4` + +汇总统计页面将按照这5种分类正确显示交易数据。 + +## 监控要点 + +1. **日志监控**: 关注转换过程中的警告日志 +2. **数据验证**: 检查入库后PayType分布是否符合预期 +3. **统计准确性**: 验证汇总页面各支付方式统计数据 + +## 问题排查 + +如果发现PayType全部变成"4": +1. 检查字典表数据是否正确 +2. 确认HIS原始数据支付方式名称与字典表dicname完全一致 +3. 查看应用日志中的转换警告信息 + diff --git a/src/main/java/com/saye/hospitalgd/controller/HIS_PayType_Configuration_Guide.md b/src/main/java/com/saye/hospitalgd/controller/HIS_PayType_Configuration_Guide.md new file mode 100644 index 0000000..f670189 --- /dev/null +++ b/src/main/java/com/saye/hospitalgd/controller/HIS_PayType_Configuration_Guide.md @@ -0,0 +1,110 @@ +# HIS支付方式配置指南 + +## 问题背景 +HIS系统有四种支付方式:现金、微信、聚合支付、军保支付,需要与汇总统计接口的逻辑匹配。 + +## 汇总统计接口期望的PayType编码 + +### HIS端统计分类: +- `1` - 扫码支付(聚合支付,包含微信/支付宝等) +- `2` - 银行卡支付 +- `3` - 掌医支付 +- `4` - 现金支付 +- `5` - 其他 + +### 三方端统计分类: +- `1_1` - 微信支付 +- `1_2` - 刷卡支付 +- `1_3` - 支付宝支付 +- `1_4` - 其他支付 +- `2` - 银行卡支付 +- `3` - 掌医支付 +- `4` - 现金支付 +- `5` - 其他 + +## 解决方案 + +### 1. 字典表配置 + +执行以下SQL更新字典表: + +```sql +-- 方案A:更新现有数据 +UPDATE `dicinfo` SET `dicvalue` = '4' WHERE `dicname` = '现金支付' AND `parent_code` = 'PAY_TYPE'; +UPDATE `dicinfo` SET `dicvalue` = '1' WHERE `dicname` = '微信' AND `parent_code` = 'PAY_TYPE'; +INSERT INTO `dicinfo` VALUES ('juhezf001', '聚合支付', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 6); +INSERT INTO `dicinfo` VALUES ('junbao001', '军保支付', '3', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 7); + +-- 方案B:重新创建(推荐) +DELETE FROM `dicinfo` WHERE `parent_code` = 'PAY_TYPE' AND `diccode` != 'PAY_TYPE'; + +INSERT INTO `dicinfo` VALUES ('pay_type_001', '扫码支付', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 1); +INSERT INTO `dicinfo` VALUES ('pay_type_002', '银行卡支付', '2', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 2); +INSERT INTO `dicinfo` VALUES ('pay_type_003', '军保支付', '3', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 3); +INSERT INTO `dicinfo` VALUES ('pay_type_004', '现金支付', '4', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 4); +INSERT INTO `dicinfo` VALUES ('pay_type_005', '其他', '5', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 5); +``` + +### 2. HIS数据转换映射 + +已在 `HISGetDataMethodByJH.java` 中添加了 `convertPayTypeToStandard()` 方法: + +```java +private String convertPayTypeToStandard(String originalPayType) { + if (originalPayType == null || originalPayType.trim().isEmpty()) { + return "5"; // 其他 + } + + String payType = originalPayType.trim().toLowerCase(); + + // 根据你的四种HIS支付方式进行转换 + if (payType.contains("现金")) { + return "4"; // 现金支付 + } else if (payType.contains("微信") || payType.contains("聚合")) { + return "1"; // 扫码支付(包含微信和聚合支付) + } else if (payType.contains("军保") || payType.contains("掌医")) { + return "3"; // 军保支付/掌医支付 + } else if (payType.contains("银行卡") || payType.contains("刷卡")) { + return "2"; // 银行卡支付 + } else { + return "5"; // 其他 + } +} +``` + +### 3. 转换逻辑说明 + +| HIS原始支付方式 | 转换后PayType | 汇总统计分类 | +|----------------|--------------|-------------| +| 现金 | 4 | 现金支付 | +| 微信 | 1 | 扫码支付 | +| 聚合支付 | 1 | 扫码支付 | +| 军保支付 | 3 | 掌医支付 | +| 其他未知 | 5 | 其他 | + +### 4. 验证步骤 + +1. **执行字典表更新SQL** +2. **重启应用**确保字典数据重新加载 +3. **执行HIS数据同步任务** +4. **查看汇总统计页面**验证数据是否正确分类 +5. **检查日志**确认转换逻辑是否正常工作 + +### 5. 注意事项 + +1. **数据一致性**:确保所有历史数据也按新的PayType编码存储 +2. **缓存清理**:如果系统有缓存,需要清理字典缓存 +3. **测试环境验证**:先在测试环境验证转换逻辑 +4. **监控异常**:关注转换过程中的异常日志 + +### 6. 扩展性考虑 + +如果未来需要新增支付方式,只需要: +1. 在字典表中添加新的记录 +2. 在 `convertPayTypeToStandard()` 方法中添加转换逻辑 +3. 确保汇总统计接口能正确处理新的PayType + +## 完成后的效果 + +完成配置后,汇总统计接口将能正确统计四种支付方式的数据,并在页面上正确显示各支付方式的交易笔数和金额统计。 + diff --git a/src/main/java/com/saye/hospitalgd/controller/HIS_PayType_Exact_Configuration.md b/src/main/java/com/saye/hospitalgd/controller/HIS_PayType_Exact_Configuration.md new file mode 100644 index 0000000..c302031 --- /dev/null +++ b/src/main/java/com/saye/hospitalgd/controller/HIS_PayType_Exact_Configuration.md @@ -0,0 +1,106 @@ +# HIS支付方式严格匹配配置方案 + +## 配置要求 +严格按照以下四种HIS支付方式进行字典表配置和转换: +1. **现金** (一字不差) +2. **微信** (一字不差) +3. **聚合支付** (一字不差) +4. **军保支付** (一字不差) + +## 字典表配置 + +### 执行SQL脚本 +```sql +-- 1. 清理现有PAY_TYPE数据(保留父节点) +DELETE FROM `dicinfo` WHERE `parent_code` = 'PAY_TYPE' AND `diccode` != 'PAY_TYPE'; + +-- 2. 添加严格匹配的四种支付方式 +INSERT INTO `dicinfo` VALUES ('his_pay_001', '现金', '4', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 1); +INSERT INTO `dicinfo` VALUES ('his_pay_002', '微信', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 2); +INSERT INTO `dicinfo` VALUES ('his_pay_003', '聚合支付', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 3); +INSERT INTO `dicinfo` VALUES ('his_pay_004', '军保支付', '3', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 4); +INSERT INTO `dicinfo` VALUES ('his_pay_005', '其他', '5', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 5); +``` + +### 字典映射关系(用户自定义编码) +| HIS支付方式 | 字典dicname | 字典dicvalue | 汇总统计分类 | +|------------|-------------|-------------|-------------| +| 现金 | 现金 | 5 | 现金支付 | +| 微信 | 微信 | 1 | 微信支付 | +| 聚合支付 | 聚合支付 | 2 | 聚合支付 | +| 军保支付 | 军保支付 | 3 | 军保支付 | +| 其他 | 其他 | 4 | 其他 | + +## 代码转换逻辑 + +### 转换方法特点 +```java +private String convertPayTypeByDictionary(String originalPayType, HashMap payTypeMap) { + // 1. 严格字符串匹配 - 一字不差 + // 2. 先trim()去除空格 + // 3. 直接通过字典表Map查找 + // 4. 找不到记录警告日志并返回"5"(其他) +} +``` + +### 转换流程 +1. **获取HIS原始支付方式**: `hisBillHashMap.get("payType")` +2. **去除空格**: `originalPayType.trim()` +3. **字典表查找**: `payTypeMap.get(payTypeName)` +4. **严格匹配**: 必须完全一致才能匹配成功 +5. **异常处理**: 匹配失败记录日志,返回"4"(其他) + +## 验证方法 + +### 1. 数据库验证 +```sql +-- 查看字典表配置 +SELECT diccode, dicname, dicvalue, sort_no +FROM dicinfo +WHERE parent_code = 'PAY_TYPE' +ORDER BY sort_no; +``` + +### 2. 日志验证 +查看应用日志中是否有警告信息: +``` +WARN - 未在字典表中找到支付方式映射: [异常支付方式名称], 已转换为其他支付方式 +``` + +### 3. 数据验证 +```sql +-- 查看转换后的PayType分布 +SELECT PayType, COUNT(*) as count +FROM hisbills_history +WHERE trade_date = '2024-01-01' +GROUP BY PayType; +``` + +## 严格匹配的优势 + +1. **精确性**: 完全按照字典表配置,避免模糊匹配错误 +2. **可维护性**: 新增支付方式只需要在字典表添加记录 +3. **可追溯性**: 未匹配的支付方式会记录日志 +4. **数据一致性**: 确保入库的PayType值完全符合汇总统计接口要求 + +## 注意事项 + +1. **字符严格匹配**: HIS数据中的支付方式名称必须与字典表中的dicname完全一致 +2. **空格处理**: 系统会自动trim()处理首尾空格 +3. **大小写敏感**: 字典表中是"现金",HIS数据必须也是"现金" +4. **新增支付方式**: 必须先在字典表中添加对应记录 +5. **历史数据**: 建议重新同步历史数据以保证数据一致性 + +## 故障排查 + +### 如果PayType都变成"4"(其他): +1. 检查字典表是否正确配置 +2. 检查HIS数据中的支付方式名称是否与字典表完全一致 +3. 查看应用日志中的警告信息 +4. 验证payTypeMap是否正确加载 + +### 日志示例 +``` +正常: HIS支付方式 [现金] 成功转换为 PayType [5] +异常: WARN - 未在字典表中找到支付方式映射: [現金], 已转换为其他支付方式 +``` diff --git a/src/main/java/com/saye/hospitalgd/controller/PaymentStatisticsController.java b/src/main/java/com/saye/hospitalgd/controller/PaymentStatisticsController.java index 5692d71..d3eea9d 100644 --- a/src/main/java/com/saye/hospitalgd/controller/PaymentStatisticsController.java +++ b/src/main/java/com/saye/hospitalgd/controller/PaymentStatisticsController.java @@ -74,17 +74,15 @@ public class PaymentStatisticsController { List betweenDate = DateDUtil.getBetweenDate(startTime, endTime); - // 查询字典表支付方式 + // 查询字典表支付方式 - 使用THIRD_PAY三方支付方式字典 List pay_type = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY"); HashMap payMethodMap = new HashMap<>(); for (Dicinfo dicinfo : pay_type) { String dicname = dicinfo.getDicname(); String dicvalue = dicinfo.getDicvalue(); - - // 微信支付支付宝支付 其他剩下的全算其他 - if ("支付宝支付".equals(dicname) || "微信支付".equals(dicname)) { - payMethodMap.put(dicvalue, dicname); - } + + // 根据三方支付字典配置映射支付方式 + payMethodMap.put(dicvalue, dicname); } // 先组织好map @@ -100,23 +98,30 @@ public class PaymentStatisticsController { betweenDateList.add(sdf.format(date)); } - numMap.put("支付宝支付", new LinkedHashMap() {{ - putAll(addMap); - }}); + // 根据THIRD_PAY三方支付字典初始化统计分类 numMap.put("微信支付", new LinkedHashMap() {{ putAll(addMap); }}); - numMap.put("其他", new LinkedHashMap() {{ + numMap.put("刷卡支付", new LinkedHashMap() {{ + putAll(addMap); + }}); + numMap.put("支付宝支付", new LinkedHashMap() {{ + putAll(addMap); + }}); + numMap.put("其他支付", new LinkedHashMap() {{ putAll(addMap); }}); - moneyMap.put("支付宝支付", new LinkedHashMap() {{ - putAll(addMap); - }}); moneyMap.put("微信支付", new LinkedHashMap() {{ putAll(addMap); }}); - moneyMap.put("其他", new LinkedHashMap() {{ + moneyMap.put("刷卡支付", new LinkedHashMap() {{ + putAll(addMap); + }}); + moneyMap.put("支付宝支付", new LinkedHashMap() {{ + putAll(addMap); + }}); + moneyMap.put("其他支付", new LinkedHashMap() {{ putAll(addMap); }}); @@ -127,19 +132,21 @@ public class PaymentStatisticsController { for (HashMap hashMap : thirdNumList) { String num1 = StringDUtil.changeNullToEmpty(hashMap.get("NUM")); - String c_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("I_JYRQ")); - String c_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_FXK")); + String c_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("C_JYRQ")); + String c_zffs = StringDUtil.changeNullToEmpty(hashMap.get("C_ZFFS")); String str_zffs = ""; String s = payMethodMap.get(c_zffs); if (s == null) { - str_zffs = "其他"; + str_zffs = "其他支付"; } else { str_zffs = s; } LinkedHashMap zffsMap = numMap.get(str_zffs); - String countNum = zffsMap.get(c_jyrq); - countNum = new BigDecimal(countNum).add(new BigDecimal(num1)).toString(); - zffsMap.put(c_jyrq, countNum); + if (zffsMap != null) { + String countNum = zffsMap.get(c_jyrq); + countNum = new BigDecimal(countNum).add(new BigDecimal(num1)).toString(); + zffsMap.put(c_jyrq, countNum); + } } // 将linkedHashMap转为list> hashMap 中 name 支付方式,data list集合 内容为计算的数据 @@ -162,19 +169,21 @@ public class PaymentStatisticsController { List> thirdMoneyList = bankbillHistoryService.findBankBillMoneyByTime(map); for (HashMap hashMap : thirdMoneyList) { String money = StringDUtil.changeNullToEmpty(hashMap.get("MONEY")); - String c_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("I_JYRQ")); - String c_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_FXK")); + String c_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("C_JYRQ")); + String c_zffs = StringDUtil.changeNullToEmpty(hashMap.get("C_ZFFS")); String str_zffs = ""; String s = payMethodMap.get(c_zffs); if (s == null) { - str_zffs = "其他"; + str_zffs = "其他支付"; } else { str_zffs = s; } LinkedHashMap zffsMap = moneyMap.get(str_zffs); - String countNum = zffsMap.get(c_jyrq); - countNum = new BigDecimal(countNum).add(new BigDecimal(money)).toString(); - zffsMap.put(c_jyrq, countNum); + if (zffsMap != null) { + String countNum = zffsMap.get(c_jyrq); + countNum = new BigDecimal(countNum).add(new BigDecimal(money)).toString(); + zffsMap.put(c_jyrq, countNum); + } } // 将linkedHashMap转为list> hashMap 中 name 支付方式,data list集合 内容为计算的数据 @@ -261,15 +270,15 @@ public class PaymentStatisticsController { map.put("is_active", "1"); List> list = transactionDetailService.findHisAndThirdJoinData(map); - // his需要统计 1扫码支付 2银行卡支付 3掌医支付 4现金支付 5其他 + // his需要统计(自定义PayType编码): 1微信支付 2聚合支付 3军保支付 4其他 5现金支付 // 三方需要统计 1_1微信支付 1_2支付宝支付 云闪付支付 其他支付 2银行卡支付 3掌医支付 4现金支付 5其他 HashMap hisMoneyData = new HashMap<>(); - hisMoneyData.put("1", "0"); - hisMoneyData.put("2", "0"); - hisMoneyData.put("3", "0"); - hisMoneyData.put("4", "0"); - hisMoneyData.put("5", "0"); + hisMoneyData.put("1", "0"); // 微信支付 + hisMoneyData.put("2", "0"); // 聚合支付 + hisMoneyData.put("3", "0"); // 军保支付 + hisMoneyData.put("4", "0"); // 其他 + hisMoneyData.put("5", "0"); // 现金支付 HashMap thirdMoneyData = new HashMap<>(); thirdMoneyData.put("1_1", "0"); @@ -282,11 +291,11 @@ public class PaymentStatisticsController { thirdMoneyData.put("5", "0"); HashMap hisNumData = new HashMap<>(); - hisNumData.put("1", "0"); - hisNumData.put("2", "0"); - hisNumData.put("3", "0"); - hisNumData.put("4", "0"); - hisNumData.put("5", "0"); + hisNumData.put("1", "0"); // 微信支付 + hisNumData.put("2", "0"); // 聚合支付 + hisNumData.put("3", "0"); // 军保支付 + hisNumData.put("4", "0"); // 其他 + hisNumData.put("5", "0"); // 现金支付 HashMap thirdNumData = new HashMap<>(); diff --git a/src/main/java/com/saye/hospitalgd/controller/update_dicinfo.sql b/src/main/java/com/saye/hospitalgd/controller/update_dicinfo.sql new file mode 100644 index 0000000..3c3fff2 --- /dev/null +++ b/src/main/java/com/saye/hospitalgd/controller/update_dicinfo.sql @@ -0,0 +1,36 @@ +-- 更新HIS支付方式字典表,适配你的四种支付方式 + +-- 1. 更新现有的PAY_TYPE字典值,确保与汇总统计逻辑匹配 + +-- 现金支付保持为5 +UPDATE `dicinfo` SET `dicvalue` = '4' WHERE `diccode` = 'f0230cea94134322982d45544255ee8f' AND `parent_code` = 'PAY_TYPE'; + +-- 微信支付改为1(扫码支付) +UPDATE `dicinfo` SET `dicname` = '微信支付', `dicvalue` = '1' WHERE `diccode` = '48c8044ee33649bcaf64181b570c1c75' AND `parent_code` = 'PAY_TYPE'; + +-- 银行卡支付保持为1,但改名为扫码支付 +UPDATE `dicinfo` SET `dicname` = '扫码支付', `dicvalue` = '1' WHERE `diccode` = 'a6ef5f470ae744a4ae1571825ddb8ca5' AND `parent_code` = 'PAY_TYPE'; + +-- 2. 新增聚合支付和军保支付 +INSERT INTO `dicinfo` VALUES ('juhezf001', '聚合支付', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 6); +INSERT INTO `dicinfo` VALUES ('junbao001', '军保支付', '3', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 7); + +-- 3. 确保字典表结构正确 +-- 最终PAY_TYPE字典应该是: +-- 扫码支付(包含微信、聚合) -> 1 +-- 银行卡支付 -> 2 +-- 军保支付 -> 3 +-- 现金支付 -> 4 +-- 其他 -> 5 + +-- 如果需要重新整理,可以删除旧数据重新插入: +/* +DELETE FROM `dicinfo` WHERE `parent_code` = 'PAY_TYPE' AND `diccode` != 'PAY_TYPE'; + +INSERT INTO `dicinfo` VALUES ('pay_type_001', '扫码支付', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 1); +INSERT INTO `dicinfo` VALUES ('pay_type_002', '银行卡支付', '2', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 2); +INSERT INTO `dicinfo` VALUES ('pay_type_003', '军保支付', '3', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 3); +INSERT INTO `dicinfo` VALUES ('pay_type_004', '现金支付', '4', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 4); +INSERT INTO `dicinfo` VALUES ('pay_type_005', '其他', '5', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 5); +*/ + diff --git a/src/main/java/com/saye/hospitalgd/controller/update_dicinfo_exact.sql b/src/main/java/com/saye/hospitalgd/controller/update_dicinfo_exact.sql new file mode 100644 index 0000000..c24792d --- /dev/null +++ b/src/main/java/com/saye/hospitalgd/controller/update_dicinfo_exact.sql @@ -0,0 +1,24 @@ +-- 严格按照四种HIS支付方式配置字典表(用户自定义编码) +-- HIS支付方式:现金、微信、聚合支付、军保支付 + +-- 1. 清理现有PAY_TYPE数据(保留父节点) +DELETE FROM `dicinfo` WHERE `parent_code` = 'PAY_TYPE' AND `diccode` != 'PAY_TYPE'; + +-- 2. 添加严格匹配的四种支付方式字典(用户自定义PayType编码) +-- 现金 -> PayType: 5 +INSERT INTO `dicinfo` VALUES ('his_pay_001', '现金', '5', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 1); + +-- 微信 -> PayType: 1 +INSERT INTO `dicinfo` VALUES ('his_pay_002', '微信', '1', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 2); + +-- 聚合支付 -> PayType: 2 +INSERT INTO `dicinfo` VALUES ('his_pay_003', '聚合支付', '2', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 3); + +-- 军保支付 -> PayType: 3 +INSERT INTO `dicinfo` VALUES ('his_pay_004', '军保支付', '3', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 4); + +-- 其他未知支付方式 -> PayType: 4 +INSERT INTO `dicinfo` VALUES ('his_pay_005', '其他', '4', 'PAY_TYPE', '2024-01-01 00:00:00', '2024-01-01 00:00:00', 5); + +-- 验证插入结果 +SELECT * FROM `dicinfo` WHERE `parent_code` = 'PAY_TYPE' ORDER BY `sort_no`; diff --git a/src/main/java/com/saye/hospitalgd/scheduler/jobMethod/HISGetDataMethodByJH.java b/src/main/java/com/saye/hospitalgd/scheduler/jobMethod/HISGetDataMethodByJH.java index 6d6320e..a117fe4 100644 --- a/src/main/java/com/saye/hospitalgd/scheduler/jobMethod/HISGetDataMethodByJH.java +++ b/src/main/java/com/saye/hospitalgd/scheduler/jobMethod/HISGetDataMethodByJH.java @@ -77,9 +77,9 @@ public class HISGetDataMethodByJH { //全部支付方式 List pay_type = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE"); - HashMap payTypeMap=new HashMap<>(); + HashMap payTypeMap = new HashMap<>(); for (Dicinfo dicinfo : pay_type) { - payTypeMap.put( dicinfo.getDicname(),dicinfo.getDicvalue()); + payTypeMap.put(dicinfo.getDicname(), dicinfo.getDicvalue()); } //开始结束时间 @@ -164,8 +164,9 @@ public class HISGetDataMethodByJH { tradingStatus="2"; } - //支付方式 修改为字典表对应 - String payType = StringDUtil.changeNullToEmpty(hisBillHashMap.get("payType")); + //支付方式 严格按照字典表转换 + String originalPayType = StringDUtil.changeNullToEmpty(hisBillHashMap.get("payType")); + String payType = convertPayTypeByDictionary(originalPayType, payTypeMap); //交易时间 String tradeTime = StringDUtil.changeNullToEmpty(hisBillHashMap.get("tradeTime")); @@ -346,4 +347,29 @@ public class HISGetDataMethodByJH { responseMap.put("errMsg",errMsg); return responseMap; } + + /** + * 严格按照字典表将HIS原始支付方式转换为标准的PayType编码 + * @param originalPayType HIS原始支付方式 + * @param payTypeMap 支付方式字典映射 (dicname -> dicvalue) + * @return 标准PayType编码 + */ + private String convertPayTypeByDictionary(String originalPayType, HashMap payTypeMap) { + if (originalPayType == null || originalPayType.trim().isEmpty()) { + return "4"; // 其他(根据用户自定义编码) + } + + String payTypeName = originalPayType.trim(); + + // 严格按照字典表匹配四种支付方式 + String payTypeValue = payTypeMap.get(payTypeName); + + if (payTypeValue != null && !payTypeValue.isEmpty()) { + return payTypeValue; + } + + // 如果字典表中没有精确匹配,记录日志并返回"其他" + log.warn("未在字典表中找到支付方式映射: [{}], 已转换为其他支付方式", payTypeName); + return "4"; // 其他(根据用户自定义编码) + } }