|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.ListUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -19,10 +20,7 @@ import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -98,6 +96,7 @@ public class XiangMuLuRuService {
|
|
|
* @return 返回项目信息
|
|
|
*/
|
|
|
public ResultVo<List<GetDropdownBox>> getChargeCode(String pyCode) {
|
|
|
+ log.info("获取编码:{}", pyCode);
|
|
|
return ResultVoUtil.success(dao.getChargeCode(StringUtil.isContainChinese(pyCode)));
|
|
|
}
|
|
|
|
|
@@ -125,19 +124,15 @@ public class XiangMuLuRuService {
|
|
|
for (ZyDetailCharge charge : chaKanSFtuiFei) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为:【%s】已退费,请勿重复退费 <br/>···(。•́︿•̀。) ", charge.getOriDetailSn()));
|
|
|
}
|
|
|
+ int infantFlag = 0;
|
|
|
// 判断是否为婴儿
|
|
|
if (param.getInpatientNo().contains("$")) {
|
|
|
param.setInpatientNo(param.getInpatientNo().split("\\$")[0]);
|
|
|
+ infantFlag = 1;
|
|
|
}
|
|
|
if (dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes()) == null || dao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes()) != 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者已经结算了");
|
|
|
}
|
|
|
- // 获取到用户角色
|
|
|
- List<Integer> yongHuJueSe = dao.huoQuJueSe(TokenUtil.getTokenUserId());
|
|
|
-
|
|
|
- //获取到这个人是否属于这个科室
|
|
|
- List<String> zhiXinKeShi = dao.chaXunZhiZXinKeShi(param.getDeptCode());
|
|
|
-
|
|
|
// 获取原来的数据
|
|
|
List<ZyDetailCharge> yuanTuiFeiList = dao.huoQuJuTiFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getList());
|
|
|
// 获取患者的总费用
|
|
@@ -146,6 +141,8 @@ public class XiangMuLuRuService {
|
|
|
// 获取最大值
|
|
|
Integer maxDetailSn = publicServer.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
|
|
|
+ List<ZyDetailCharge> yaoPingDan = new ArrayList<>();
|
|
|
+
|
|
|
List<Integer> genXingZhenShuTuiFeiLiuShui = new ArrayList<>();
|
|
|
List<ZyDetailCharge> tuiFeiList = new ArrayList<>();
|
|
|
for (ZyDetailCharge pojo : yuanTuiFeiList) {
|
|
@@ -153,21 +150,12 @@ public class XiangMuLuRuService {
|
|
|
if (pojo.getChargeFee().signum() == -1 || pojo.getChargeAmount().signum() == -1) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("患者费用存在负数,流水号:【%s】,该数据为退费数据。<br/>( ´Д`)y━・~~", pojo.getDetailSn()));
|
|
|
}
|
|
|
- // 管理员角色可以无视
|
|
|
- if (!yongHuJueSe.contains(1)) {
|
|
|
- // 科室开头 是 8 就不是医技科室 只有医技科室可以退药品
|
|
|
- if (param.getDeptCode().startsWith("8")) {
|
|
|
- if (!zhiXinKeShi.contains(pojo.getExecUnit())) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。<br/>( ´Д`)y━・~~", pojo.getDetailSn()));
|
|
|
- }
|
|
|
- // 护士是不可以退药品的
|
|
|
- if (pojo.getChargeCode().startsWith("BILL")) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,包含药品费用,无法退费。<br/>( ´Д`)y━・~~", pojo.getDetailSn()));
|
|
|
- }
|
|
|
- } else if (!param.getDeptCode().equals(pojo.getExecUnit())) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。<br/>( ´Д`)y━・~~", pojo.getDetailSn()));
|
|
|
- }
|
|
|
+ if (pojo.getChargeCode().startsWith("BILL")) {
|
|
|
+ yaoPingDan.add(pojo);
|
|
|
}
|
|
|
+ // 在这里判断执行科室
|
|
|
+ ResultVo<String> LOGICAL_ERROR = getStringResultVo(param, pojo);
|
|
|
+ if (LOGICAL_ERROR != null) return LOGICAL_ERROR;
|
|
|
// 数据库有个 触发器 如果带了医嘱号且有篆刻那么这里就需要改成 0
|
|
|
if (BigUtils.bigDaYu(pojo.getOrderNo(), 10)) {
|
|
|
pojo.setOrderNo(new BigDecimal(0));
|
|
@@ -191,18 +179,43 @@ public class XiangMuLuRuService {
|
|
|
if (tuiFeiList.isEmpty()) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "查询不到患者原数据,请联系管理员。( ´Д`)y━・~~");
|
|
|
} else {
|
|
|
+ log.info("操作项目退费 ==》 操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(tuiFeiList));
|
|
|
List<List<ZyDetailCharge>> fenGe = ListUtils.partition(tuiFeiList, 20);
|
|
|
+ if (ListUtil.notBlank(yaoPingDan)) {
|
|
|
+ dao.shenQingYaoPing(param, yaoPingDan, infantFlag, publicServer.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes()), TokenUtil.getTokenUserId());
|
|
|
+ }
|
|
|
fenGe.forEach(dao::xiangMuTuiFei);
|
|
|
dao.genXinZhenShuTuiFeiLiuShui(param.getInpatientNo(), param.getAdmissTimes(),
|
|
|
publicServer.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes()), genXingZhenShuTuiFeiLiuShui);
|
|
|
dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_ledger_file");
|
|
|
dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
|
|
|
- log.info("更新正数水流:{}", JSON.toJSONString(genXingZhenShuTuiFeiLiuShui));
|
|
|
- log.info("操作项目退费 ==》 操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(tuiFeiList));
|
|
|
+
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "项目退费操作成功。乁( ˙ ω˙乁)");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private ResultVo<String> getStringResultVo(ZyDetailCharge xuYaoTuiDeShuJu, ZyDetailCharge piPeiDeShuJu) {
|
|
|
+ // 获取到用户角色 管理员角色可以无视
|
|
|
+ List<Integer> yongHuJueSe = dao.huoQuJueSe(TokenUtil.getTokenUserId());
|
|
|
+ if (!yongHuJueSe.contains(1)) {
|
|
|
+ // 科室开头 是 8 就不是医技科室 只有医技科室可以退药品
|
|
|
+ if (xuYaoTuiDeShuJu.getDeptCode().startsWith("8")) {
|
|
|
+ //获取到这个人是否属于这个科室
|
|
|
+ List<String> zhiXinKeShi = dao.chaXunZhiZXinKeShi(xuYaoTuiDeShuJu.getDeptCode());
|
|
|
+ if (!zhiXinKeShi.contains(piPeiDeShuJu.getExecUnit())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。<br/>( ´Д`)y━・~~", piPeiDeShuJu.getDetailSn()));
|
|
|
+ }
|
|
|
+ // 护士是不可以退药品的
|
|
|
+ if (piPeiDeShuJu.getChargeCode().startsWith("BILL")) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,包含药品费用,无法退费。<br/>( ´Д`)y━・~~", piPeiDeShuJu.getDetailSn()));
|
|
|
+ }
|
|
|
+ } else if (!xuYaoTuiDeShuJu.getDeptCode().equals(piPeiDeShuJu.getExecUnit())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。<br/>( ´Д`)y━・~~", piPeiDeShuJu.getDetailSn()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取模板
|
|
|
*
|
|
@@ -264,32 +277,33 @@ public class XiangMuLuRuService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> xiangMuFeiYongShangChuan(ZyDetailCharge param) {
|
|
|
+
|
|
|
+ log.info("param:{}", JSON.toJSONStringWithDateFormat(param, DateUtil.DEFAULT_PATTERN));
|
|
|
if (param.getList().size() > 50) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "一次性项目录入大于50条,๑乛◡乛๑");
|
|
|
}
|
|
|
StringBuilder errorStr = new StringBuilder();
|
|
|
if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null) {
|
|
|
- errorStr.append("1、住院号和住院次数为空<br />");
|
|
|
+ errorStr.append("住院号和住院次数为空<br />");
|
|
|
}
|
|
|
if (param.getList().size() == 0) {
|
|
|
- errorStr.append("2、没有要录入的项目 <br />");
|
|
|
+ errorStr.append("没有要录入的项目 <br />");
|
|
|
}
|
|
|
if (StringUtil.isBlank(param.getWard())) {
|
|
|
- errorStr.append("3、病区为空 <br />");
|
|
|
+ errorStr.append("病区为空 <br />");
|
|
|
}
|
|
|
if (StringUtil.isBlank(param.getDept())) {
|
|
|
- errorStr.append("4、申请科室为空 <br />");
|
|
|
+ errorStr.append("申请科室为空 <br />");
|
|
|
}
|
|
|
if (StringUtil.isBlank(param.getZySerialNo())) {
|
|
|
- errorStr.append("5、住院流水号为空 <br />");
|
|
|
+ errorStr.append("住院流水号为空 <br />");
|
|
|
}
|
|
|
if (dao.getHuanZheSFZaiYuan(param.getInpatientNo(), param.getAdmissTimes()) == 0) {
|
|
|
- errorStr.append("6、没有患者的在院信息 <br />");
|
|
|
+ errorStr.append("没有患者的在院信息 <br />");
|
|
|
}
|
|
|
if (errorStr.length() > 3) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, errorStr.toString());
|
|
|
}
|
|
|
-
|
|
|
// 婴儿 要特殊处理
|
|
|
// 如果带有这个 $ 说明是婴儿
|
|
|
int infantFlag = publicServer.getInfantFlag(param.getInpatientNo());
|
|
@@ -300,7 +314,7 @@ public class XiangMuLuRuService {
|
|
|
BigDecimal sum = new BigDecimal(0);
|
|
|
// 录入人的id
|
|
|
param.setOpIdCode(TokenUtil.getTokenUserId());
|
|
|
- int shiFuoCunZaiYaoPing = 0;
|
|
|
+ List<ZyDetailCharge> yaoPingShenQingDan = new ArrayList<>();
|
|
|
// 药品
|
|
|
for (ZyDetailCharge zyDetailCharge : param.getList()) {
|
|
|
switch (zyDetailCharge.getBillItemCode()) {
|
|
@@ -356,7 +370,11 @@ public class XiangMuLuRuService {
|
|
|
zyDetailCharge.setChargeAmount(zyDetailCharge.getChargeAmount().multiply(zyDetailCharge.getAmount()));
|
|
|
zyDetailCharge.setDetailSn(maxDetailSn += 1);
|
|
|
if (zyDetailCharge.getSerial().equals("01")) {
|
|
|
- shiFuoCunZaiYaoPing += 1;
|
|
|
+ ZyDetailCharge shenQing = new ZyDetailCharge();
|
|
|
+ BeanUtils.copyProperties(zyDetailCharge, shenQing);
|
|
|
+ shenQing.setChargeFee(zyDetailCharge.getChargeAmount());
|
|
|
+ shenQing.setChargeAmount((zyDetailCharge.getAmount()));
|
|
|
+ yaoPingShenQingDan.add(shenQing);
|
|
|
}
|
|
|
}
|
|
|
FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(param.getList(), true);
|
|
@@ -367,8 +385,9 @@ public class XiangMuLuRuService {
|
|
|
dao.chaRuFeiYong(param, param.getList(), infantFlag, ledgerSn);
|
|
|
dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_ledger_file");
|
|
|
dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
|
|
|
- if (shiFuoCunZaiYaoPing > 0) {
|
|
|
- dao.shenQingYaoPing(param, param.getList(), infantFlag, ledgerSn);
|
|
|
+ if (ListUtil.notBlank(yaoPingShenQingDan)) {
|
|
|
+ log.info("shenqingdan:{}", JSON.toJSONStringWithDateFormat(yaoPingShenQingDan, DateUtil.DEFAULT_PATTERN));
|
|
|
+ dao.shenQingYaoPing(param, yaoPingShenQingDan, infantFlag, ledgerSn, TokenUtil.getTokenUserId());
|
|
|
}
|
|
|
log.info("项目录入费用上传 ==》 操作人:{},数据:{}", param.getOpIdCode(), JSON.toJSONString(param));
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用上传成功。<( ̄︶ ̄)>");
|
|
@@ -416,93 +435,95 @@ public class XiangMuLuRuService {
|
|
|
* @param admissTimes 住院次数
|
|
|
* @return 返回是否匹配成功
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> yiZhuTuiFeiPiPei(String inpatientNo, Integer admissTimes) {
|
|
|
- inpatientNo = publicServer.getInpatientNo(inpatientNo);
|
|
|
int infantFlag = publicServer.getInfantFlag(inpatientNo);
|
|
|
+ inpatientNo = publicServer.getInpatientNo(inpatientNo);
|
|
|
Integer ledgerSn = publicServer.getLedgerSn(inpatientNo, admissTimes);
|
|
|
|
|
|
- // 获取正的医嘱费用
|
|
|
- List<ZyDetailCharge> getYiZhuFeiYongZhenShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, ">", infantFlag);
|
|
|
- // 获取负的医嘱费用
|
|
|
- List<ZyDetailCharge> getYiZhuFeiYongFuShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, "<", infantFlag);
|
|
|
- // 获取负数的退费数据 主要是用来判断 这一条正的是否退费了。
|
|
|
- List<ZyDetailCharge> tuiFeiList = dao.tuiFeiList(inpatientNo, admissTimes, infantFlag);
|
|
|
- if (!tuiFeiList.isEmpty()) {
|
|
|
- Map<Integer, Integer> map = new HashMap<>();
|
|
|
- for (ZyDetailCharge zyDetailCharge : tuiFeiList) {
|
|
|
- map.put(zyDetailCharge.getOriDetailSn(), zyDetailCharge.getDetailSn());
|
|
|
- }
|
|
|
- getYiZhuFeiYongZhenShu.forEach(item -> {
|
|
|
- if (map.containsKey(item.getDetailSn())) {
|
|
|
- item.setTuiFeiFlag(1);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 需要保存需要匹配的一些流水数据
|
|
|
- List<ZyDetailCharge> piPei = new ArrayList<>();
|
|
|
- // 此处是需要二次匹配的 list
|
|
|
- List<ZyDetailCharge> erCiPiPei = new ArrayList<>();
|
|
|
- // 用map 来保存正数的信息,但是有可能匹配的条件中map 的 key会一致 所以在这里使用 java8 的新特性 stream 流来进行分组 这样就不会因为key 一样导致数据被覆盖了
|
|
|
- // 第一次 匹配 根据 医嘱号 收费时间 项目编码 数量 账页号
|
|
|
- Map<String, List<ZyDetailCharge>> zhenShuMap = getYiZhuFeiYongZhenShu.stream().collect(
|
|
|
- Collectors.groupingBy(item -> item.getOrderNo() + DateUtil.formatDatetime(item.getChargeDate()) + item.getChargeCodeMx() + item.getChargeAmount() + item.getChargeFee() + item.getLedgerSn())
|
|
|
- );
|
|
|
- // 用负数拼接的 key 去查找
|
|
|
- for (ZyDetailCharge fuShu : getYiZhuFeiYongFuShu) {
|
|
|
- String key = fuShu.getOrderNo() + DateUtil.formatDatetime(fuShu.getChargeDate()) + fuShu.getChargeCodeMx() + fuShu.getChargeAmount().negate()
|
|
|
- + fuShu.getChargeFee().negate() + fuShu.getLedgerSn();
|
|
|
- if (zhenShuMap.containsKey(key)) {
|
|
|
- for (ZyDetailCharge zyDetailCharge : zhenShuMap.get(key)) {
|
|
|
- if (zyDetailCharge.getTuiFeiFlag() == null && zyDetailCharge.getOriDetailSn() == null) {
|
|
|
- fuShu.setOriDetailSn(zyDetailCharge.getDetailSn());
|
|
|
- zyDetailCharge.setTuiFeiFlag(1);
|
|
|
- piPei.add(fuShu);
|
|
|
- log.info("第一次匹配==》流水:{},匹配流水:{},", fuShu.getDetailSn(), fuShu.getOriDetailSn());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 这个是需要进行二次匹配的
|
|
|
- erCiPiPei.add(fuShu);
|
|
|
- }
|
|
|
- }
|
|
|
- // 下面是二次匹配
|
|
|
- if (erCiPiPei.size() > 0) {
|
|
|
- // 二次匹配 条件为 执行科室 项目编码 数量 账页号
|
|
|
- Map<String, List<ZyDetailCharge>> erCiPiPeiZhenShu = getYiZhuFeiYongZhenShu.stream().collect(
|
|
|
- Collectors.groupingBy(item -> item.getExecUnit() + item.getChargeCodeMx() + item.getChargeAmount() + item.getChargeFee() + item.getLedgerSn())
|
|
|
- );
|
|
|
- // 开始二次匹配
|
|
|
- for (ZyDetailCharge zyDetailCharge : erCiPiPei) {
|
|
|
- String key = zyDetailCharge.getExecUnit() + zyDetailCharge.getChargeCodeMx() + zyDetailCharge.getChargeAmount().negate()
|
|
|
- + zyDetailCharge.getChargeFee().negate() + zyDetailCharge.getLedgerSn();
|
|
|
- if (erCiPiPeiZhenShu.containsKey(key)) {
|
|
|
- for (ZyDetailCharge detailCharge : erCiPiPeiZhenShu.get(key)) {
|
|
|
- if (detailCharge.getTuiFeiFlag() == null && detailCharge.getOriDetailSn() == null) {
|
|
|
- zyDetailCharge.setOriDetailSn(detailCharge.getDetailSn());
|
|
|
- detailCharge.setTuiFeiFlag(1);
|
|
|
- piPei.add(zyDetailCharge);
|
|
|
- log.info("第二次匹配==》流水:{},匹配流水:{}", zyDetailCharge.getDetailSn(), zyDetailCharge.getOriDetailSn());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 开始匹配
|
|
|
- if (piPei.size() > 0) {
|
|
|
- // 100 条的更新 ListUtils.partition 用来拆分 list size 是拆分的条数
|
|
|
- List<List<ZyDetailCharge>> fenDuan = ListUtils.partition(piPei, 100);
|
|
|
- for (List<ZyDetailCharge> list : fenDuan) {
|
|
|
- dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, list, infantFlag);
|
|
|
- }
|
|
|
- publicServer.genXingYuanLiuShuiBiaoZhi(inpatientNo, admissTimes, ledgerSn);
|
|
|
- log.info("医嘱退费匹配 ==》 操作人:{},住院号:{},住院次数:{}", TokenUtil.getTokenUserId(), inpatientNo, admissTimes);
|
|
|
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION,
|
|
|
- String.format("匹配成功共:{%d}条,匹配成功:{%s}条", getYiZhuFeiYongFuShu.size(), piPei.size()));
|
|
|
- }
|
|
|
+// // 获取正的医嘱费用
|
|
|
+// List<ZyDetailCharge> getYiZhuFeiYongZhenShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, ">", infantFlag);
|
|
|
+// // 获取负的医嘱费用
|
|
|
+// List<ZyDetailCharge> getYiZhuFeiYongFuShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ledgerSn, "<", infantFlag);
|
|
|
+// // 获取负数的退费数据 主要是用来判断 这一条正的是否退费了。
|
|
|
+// List<ZyDetailCharge> tuiFeiList = dao.tuiFeiList(inpatientNo, admissTimes, infantFlag);
|
|
|
+// if (!tuiFeiList.isEmpty()) {
|
|
|
+// Map<Integer, Integer> map = new HashMap<>();
|
|
|
+// for (ZyDetailCharge zyDetailCharge : tuiFeiList) {
|
|
|
+// map.put(zyDetailCharge.getOriDetailSn(), zyDetailCharge.getDetailSn());
|
|
|
+// }
|
|
|
+// getYiZhuFeiYongZhenShu.forEach(item -> {
|
|
|
+// if (map.containsKey(item.getDetailSn())) {
|
|
|
+// item.setTuiFeiFlag(1);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// // 需要保存需要匹配的一些流水数据
|
|
|
+// List<ZyDetailCharge> piPei = new ArrayList<>();
|
|
|
+// // 此处是需要二次匹配的 list
|
|
|
+// List<ZyDetailCharge> erCiPiPei = new ArrayList<>();
|
|
|
+// // 用map 来保存正数的信息,但是有可能匹配的条件中map 的 key会一致 所以在这里使用 java8 的新特性 stream 流来进行分组 这样就不会因为key 一样导致数据被覆盖了
|
|
|
+// // 第一次 匹配 根据 医嘱号 收费时间 项目编码 数量 账页号
|
|
|
+// Map<String, List<ZyDetailCharge>> zhenShuMap = getYiZhuFeiYongZhenShu.stream().collect(
|
|
|
+// Collectors.groupingBy(item -> item.getOrderNo() + DateUtil.formatDatetime(item.getChargeDate()) + item.getChargeCodeMx() + item.getChargeAmount() + item.getChargeFee() + item.getLedgerSn())
|
|
|
+// );
|
|
|
+// // 用负数拼接的 key 去查找
|
|
|
+// for (ZyDetailCharge fuShu : getYiZhuFeiYongFuShu) {
|
|
|
+// String key = fuShu.getOrderNo() + DateUtil.formatDatetime(fuShu.getChargeDate()) + fuShu.getChargeCodeMx() + fuShu.getChargeAmount().negate()
|
|
|
+// + fuShu.getChargeFee().negate() + fuShu.getLedgerSn();
|
|
|
+// if (zhenShuMap.containsKey(key)) {
|
|
|
+// for (ZyDetailCharge zyDetailCharge : zhenShuMap.get(key)) {
|
|
|
+// if (zyDetailCharge.getTuiFeiFlag() == null && zyDetailCharge.getOriDetailSn() == null) {
|
|
|
+// fuShu.setOriDetailSn(zyDetailCharge.getDetailSn());
|
|
|
+// zyDetailCharge.setTuiFeiFlag(1);
|
|
|
+// piPei.add(fuShu);
|
|
|
+// log.info("第一次匹配==》流水:{},匹配流水:{},", fuShu.getDetailSn(), fuShu.getOriDetailSn());
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// // 这个是需要进行二次匹配的
|
|
|
+// erCiPiPei.add(fuShu);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // 下面是二次匹配
|
|
|
+// if (erCiPiPei.size() > 0) {
|
|
|
+// // 二次匹配 条件为 执行科室 项目编码 数量 账页号
|
|
|
+// Map<String, List<ZyDetailCharge>> erCiPiPeiZhenShu = getYiZhuFeiYongZhenShu.stream().collect(
|
|
|
+// Collectors.groupingBy(item -> item.getExecUnit() + item.getChargeCodeMx() + item.getChargeAmount() + item.getChargeFee() + item.getLedgerSn())
|
|
|
+// );
|
|
|
+// // 开始二次匹配
|
|
|
+// for (ZyDetailCharge zyDetailCharge : erCiPiPei) {
|
|
|
+// String key = zyDetailCharge.getExecUnit() + zyDetailCharge.getChargeCodeMx() + zyDetailCharge.getChargeAmount().negate()
|
|
|
+// + zyDetailCharge.getChargeFee().negate() + zyDetailCharge.getLedgerSn();
|
|
|
+// if (erCiPiPeiZhenShu.containsKey(key)) {
|
|
|
+// for (ZyDetailCharge detailCharge : erCiPiPeiZhenShu.get(key)) {
|
|
|
+// if (detailCharge.getTuiFeiFlag() == null && detailCharge.getOriDetailSn() == null) {
|
|
|
+// zyDetailCharge.setOriDetailSn(detailCharge.getDetailSn());
|
|
|
+// detailCharge.setTuiFeiFlag(1);
|
|
|
+// piPei.add(zyDetailCharge);
|
|
|
+// log.info("第二次匹配==》流水:{},匹配流水:{}", zyDetailCharge.getDetailSn(), zyDetailCharge.getOriDetailSn());
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // 开始匹配
|
|
|
+// if (piPei.size() > 0) {
|
|
|
+// // 100 条的更新 ListUtils.partition 用来拆分 list size 是拆分的条数
|
|
|
+// List<List<ZyDetailCharge>> fenDuan = ListUtils.partition(piPei, 100);
|
|
|
+// for (List<ZyDetailCharge> list : fenDuan) {
|
|
|
+// dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, list, infantFlag);
|
|
|
+// }
|
|
|
+// publicServer.genXingYuanLiuShuiBiaoZhi(inpatientNo, admissTimes, ledgerSn);
|
|
|
+// log.info("医嘱退费匹配 ==》 操作人:{},住院号:{},住院次数:{}", TokenUtil.getTokenUserId(), inpatientNo, admissTimes);
|
|
|
+// return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION,
|
|
|
+// String.format("匹配成功共:{%d}条,匹配成功:{%s}条", getYiZhuFeiYongFuShu.size(), piPei.size()));
|
|
|
+// }
|
|
|
publicServer.genXingYuanLiuShuiBiaoZhi(inpatientNo, admissTimes, ledgerSn);
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, String.format("该患者有【%d】条,未能匹配 |д・)っ", getYiZhuFeiYongFuShu.size()));
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ //return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, String.format("该患者有【%d】条,未能匹配 |д・)っ", getYiZhuFeiYongFuShu.size()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -541,10 +562,12 @@ public class XiangMuLuRuService {
|
|
|
return ResultVoUtil.success(dao.getBingQuDuiYingKeShi(ward));
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> cheXiaoTuiFei(String inpatientNo, Integer admissTimes, Integer ledger, Integer detailSn) {
|
|
|
if (StringUtil.isBlank(inpatientNo) || admissTimes == null || ledger == null || detailSn == null) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者信息不全。");
|
|
|
}
|
|
|
+ inpatientNo = publicServer.getInpatientNo(inpatientNo);
|
|
|
ZyDetailCharge zyDetailCharge = dao.beiTuiFeiYongXinXi(inpatientNo, admissTimes, ledger, detailSn);
|
|
|
if (zyDetailCharge == null) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "未查询到对应信息,可能该费用可能已经被撤销了或被正负相抵了。");
|
|
@@ -561,24 +584,79 @@ public class XiangMuLuRuService {
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "撤销成功,请刷新数据。");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public ResultVo<WeiGuiFeiYongFenXi> weiGuiFeiYongFenXi(String inpatientNo, Integer admissTimes) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public ResultVo<WeiGuiFeiYongFenXi> weiGuiFeiYongFenXi(String inpatientNo, Integer admissTimes, String execUnit) {
|
|
|
inpatientNo = publicServer.getInpatientNo(inpatientNo);
|
|
|
int infantFlag = publicServer.getInfantFlag(inpatientNo);
|
|
|
Integer ledger = publicServer.getLedgerSn(inpatientNo, admissTimes);
|
|
|
|
|
|
- List<Integer> chongFuTuiFei = dao.chongFuTuiFei(inpatientNo, admissTimes, ledger, infantFlag);
|
|
|
-
|
|
|
- if (ListUtil.notBlank(chongFuTuiFei)) {
|
|
|
- dao.chongZhiWeiGuiYuanLiuShui(inpatientNo, admissTimes, ledger, infantFlag, chongFuTuiFei);
|
|
|
- }
|
|
|
WeiGuiFeiYongFenXi weiGuiFeiYongFenXi = new WeiGuiFeiYongFenXi();
|
|
|
weiGuiFeiYongFenXi.setWeiPiPei(new ArrayList<>());
|
|
|
weiGuiFeiYongFenXi.setWeiXieDaiYuanLiuShui(new ArrayList<>());
|
|
|
+
|
|
|
+ List<Integer> yaoPingBianMaTongBu = dao.weiGuiYaoPinInt(inpatientNo, admissTimes, ledger, infantFlag);
|
|
|
+
|
|
|
+ if (yaoPingBianMaTongBu.size() > 0) {
|
|
|
+ dao.genXinYaoPingPiPeiXinXi(yaoPingBianMaTongBu);
|
|
|
+ }
|
|
|
weiGuiFeiYongFenXi.getWeiPiPei().addAll(dao.weiGuiYaoPin(inpatientNo, admissTimes, ledger, infantFlag));
|
|
|
weiGuiFeiYongFenXi.getWeiPiPei().addAll(dao.weiGuiXiangMu(inpatientNo, admissTimes, ledger, infantFlag));
|
|
|
- weiGuiFeiYongFenXi.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShui(inpatientNo, admissTimes, ledger, infantFlag));
|
|
|
+ weiGuiFeiYongFenXi.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiXiangMu(inpatientNo, admissTimes, ledger, infantFlag, execUnit));
|
|
|
+ weiGuiFeiYongFenXi.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiYaoPing(inpatientNo, admissTimes, ledger, infantFlag, execUnit));
|
|
|
return ResultVoUtil.success(weiGuiFeiYongFenXi);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public ResultVo<List<ZyDetailCharge>> huoQuZhenShuKePiPei(String inpatientNo, Integer admissTimes, Integer ledgerSn, String chargeCodeMx, String execUnit, String startTime, String endTime, String riQiPaiXu) {
|
|
|
+ log.info("获取可以匹配的费用==》 住院号:{},次数:{},账页号:{},项目编码:{},执行科室:{}", inpatientNo, admissTimes, ledgerSn, chargeCodeMx, execUnit);
|
|
|
+ return ResultVoUtil.success(dao.weiGuiZhenShuPiPei(publicServer.getInpatientNo(inpatientNo), admissTimes, ledgerSn, chargeCodeMx, execUnit, startTime, endTime, riQiPaiXu));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public ResultVo<String> caiFenPiPei(ZyDetailCharge zyDetailCharge) {
|
|
|
+ String inpatientNo = publicServer.getInpatientNo(zyDetailCharge.getInpatientNo());
|
|
|
+ Integer infantFlag = publicServer.getInfantFlag(zyDetailCharge.getInpatientNo());
|
|
|
+ if (ListUtil.isBlank(zyDetailCharge.getList())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择数据。");
|
|
|
+ }
|
|
|
+ int[] detailSnList = new int[zyDetailCharge.getList().size()];
|
|
|
+ for (int i = 0; i < zyDetailCharge.getList().size(); i++) {
|
|
|
+ detailSnList[i] = zyDetailCharge.getList().get(i).getDetailSn();
|
|
|
+ }
|
|
|
+ ZyDetailCharge zy = dao.piPeiXinXiFuShu(inpatientNo, zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn(), infantFlag, zyDetailCharge.getDetailSn());
|
|
|
+ if (zy == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "未找到负数费用信息,可能已经被删除了,请刷新页面重试。");
|
|
|
+ } else if (zy.getTransFlagYb().equals("2") || zy.getOriDetailSn() != null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该负数费用已被正负相抵。");
|
|
|
+ }
|
|
|
+ List<ZyDetailCharge> shuJuXinXi = dao.piPeiXinXi(inpatientNo, zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn(), infantFlag, detailSnList);
|
|
|
+ BigDecimal chargeFeeSum = new BigDecimal(0);
|
|
|
+ BigDecimal chargeAmountSum = new BigDecimal(0);
|
|
|
+ for (ZyDetailCharge detailCharge : shuJuXinXi) {
|
|
|
+ ResultVo<String> LOGICAL_ERROR = getStringResultVo(zyDetailCharge, detailCharge);
|
|
|
+ if (LOGICAL_ERROR != null) return LOGICAL_ERROR;
|
|
|
+ if (detailCharge.getOriDetailSn() != null || detailCharge.getTransFlagYb().equals("2")) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为:{%d},已被退费请重新选择。", detailCharge.getDetailSn()));
|
|
|
+ }
|
|
|
+ chargeFeeSum = chargeFeeSum.add(detailCharge.getChargeFee());
|
|
|
+ chargeAmountSum = chargeAmountSum.add(detailCharge.getChargeAmount());
|
|
|
+ }
|
|
|
+ if (BigUtils.dengYu(chargeFeeSum, zy.getChargeFee().negate()) && BigUtils.dengYu(chargeAmountSum, zy.getChargeAmount().negate())) {
|
|
|
+ if (shuJuXinXi.size() == 1) {
|
|
|
+ dao.zhiYouYiGeJiuGenXingFuShuLiuShui(zyDetailCharge.getInpatientNo(), zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn(), zyDetailCharge.getDetailSn(), shuJuXinXi.get(0).getDetailSn());
|
|
|
+ publicServer.genXingYuanLiuShuiBiaoZhi(inpatientNo, zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn());
|
|
|
+ } else {
|
|
|
+ ResultVo<String> tuiFei = xiangMuTuiFei(zyDetailCharge);
|
|
|
+ if (tuiFei.getCode() != 201) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, tuiFei.getMessage());
|
|
|
+ }
|
|
|
+ dao.cheXiaoFeiYong(inpatientNo, zyDetailCharge.getAdmissTimes(), zyDetailCharge.getLedgerSn(), zyDetailCharge.getDetailSn());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
|
|
|
+ String.format("负数费用:{%.2f},匹配费用:{%.2f} <br> 负数数量:{%.2f},匹配数量:{%.2f}", zy.getChargeFee().negate(), chargeFeeSum, zy.getChargeAmount().negate(), chargeAmountSum));
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用拆分成功。");
|
|
|
+ }
|
|
|
}
|
|
|
|