|
@@ -239,25 +239,26 @@ public class XiangMuLuRuService {
|
|
|
List<ZyDetailCharge> getYiZhuFeiYongZhenShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ">");
|
|
|
// 获取负的费用
|
|
|
List<ZyDetailCharge> getYiZhuFeiYongFuShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, "<");
|
|
|
- // 需要匹配的一些流水
|
|
|
+ // 需要匹配的一些流水数据
|
|
|
List<ZyDetailCharge> piPei = new ArrayList<>();
|
|
|
+
|
|
|
+ // 保存正数的 map 用来匹配
|
|
|
+ Map<String, ZyDetailCharge> zhenShuMap = new HashMap<>();
|
|
|
+ for (ZyDetailCharge zhenShu : getYiZhuFeiYongZhenShu) {
|
|
|
+ String key = zhenShu.getOrderNo() + DateUtil.formatDatetime(zhenShu.getChargeDate()) + zhenShu.getChargeCodeMx() + zhenShu.getChargeAmount();
|
|
|
+ zhenShuMap.put(key, zhenShu);
|
|
|
+ }
|
|
|
+ // 用负数拼接的 key 去查找
|
|
|
for (ZyDetailCharge fuShu : getYiZhuFeiYongFuShu) {
|
|
|
- for (ZyDetailCharge zhenShu : getYiZhuFeiYongZhenShu) {
|
|
|
- // 判断退费的数据匹配一条正数 通过医嘱号,收费日期,项目编码,数量
|
|
|
- if (fuShu.getOrderNo().equals(zhenShu.getOrderNo())
|
|
|
- && DateUtil.formatDatetime(fuShu.getChargeDate()).equals(DateUtil.formatDatetime(zhenShu.getChargeDate()))
|
|
|
- && fuShu.getChargeCodeMx().equals(zhenShu.getChargeCodeMx())
|
|
|
- && fuShu.getChargeAmount().negate().equals(zhenShu.getChargeAmount())) {
|
|
|
- // 把匹配到的 流水号 添加进来
|
|
|
- fuShu.setOriDetailSn(zhenShu.getDetailSn());
|
|
|
- // 在保存到list中
|
|
|
- piPei.add(fuShu);
|
|
|
- }
|
|
|
+ String key = fuShu.getOrderNo() + DateUtil.formatDatetime(fuShu.getChargeDate()) + fuShu.getChargeCodeMx() + fuShu.getChargeAmount().negate();
|
|
|
+ if (zhenShuMap.containsKey(key)) {
|
|
|
+ fuShu.setOriDetailSn(zhenShuMap.get(key).getDetailSn());
|
|
|
+ piPei.add(fuShu);
|
|
|
}
|
|
|
}
|
|
|
+ // 开始匹配
|
|
|
if (piPei.size() > 0) {
|
|
|
// 100 条的更新
|
|
|
- log.info("医嘱退费匹配 ==》 操作人:{} :住院号:{},住院次数:{}", TokenUtil.getTokenUserId(), inpatientNo, admissTimes);
|
|
|
List<ZyDetailCharge> fenDuanPiPei = new ArrayList<>();
|
|
|
for (ZyDetailCharge zyDetailCharge : piPei) {
|
|
|
fenDuanPiPei.add(zyDetailCharge);
|
|
@@ -266,6 +267,10 @@ public class XiangMuLuRuService {
|
|
|
fenDuanPiPei.clear();
|
|
|
}
|
|
|
}
|
|
|
+ if (fenDuanPiPei.size() > 0) {
|
|
|
+ dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, fenDuanPiPei);
|
|
|
+ }
|
|
|
+ log.info("医嘱退费匹配 ==》 操作人:{} :住院号:{},住院次数:{}", TokenUtil.getTokenUserId(), inpatientNo, admissTimes);
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, String.format("医嘱退费匹配成功共匹配%d条", piPei.size()));
|
|
|
} else {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者没有可以匹配的医嘱退费");
|