|
|
@@ -2,6 +2,7 @@ package thyyxxk.webserver.service.yibao;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.ListUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -80,9 +81,9 @@ public class XiangMuLuRuService {
|
|
|
* @param param 需要生成退费 的数据
|
|
|
* @return 返回
|
|
|
*/
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> xiangMuTuiFei(ZyDetailCharge param) {
|
|
|
- if (param.getList().size() >= 100) {
|
|
|
+ if (param.getList().size() > 100) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "项目退费一次性大于100条数据");
|
|
|
}
|
|
|
if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null || param.getLedgerSn() == null || param.getList().size() == 0) {
|
|
|
@@ -97,10 +98,8 @@ public class XiangMuLuRuService {
|
|
|
Integer maxDetailSn = transferInOfExpensesDao.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
|
|
|
// 获取原来的数据
|
|
|
List<ZyDetailCharge> yuanTuiFeiList = dao.huoQuJuTiFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(), param.getList());
|
|
|
-
|
|
|
// 获取患者的总费用
|
|
|
BigDecimal sum = new BigDecimal(0);
|
|
|
-
|
|
|
List<ZyDetailCharge> tuiFeiList = new ArrayList<>();
|
|
|
for (ZyDetailCharge pojo : yuanTuiFeiList) {
|
|
|
// 判断患者的费用是否存在负数
|
|
|
@@ -122,16 +121,11 @@ public class XiangMuLuRuService {
|
|
|
}
|
|
|
FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(yuanTuiFeiList, false);
|
|
|
fy.setTotalCharge(sum.negate());
|
|
|
-
|
|
|
- try {
|
|
|
- // 执行退费的操作
|
|
|
- dao.xiangMuTuiFei(tuiFeiList);
|
|
|
- dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
|
|
|
- log.info("操作项目退费 ==》 操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(tuiFeiList));
|
|
|
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "项目退费操作成功。");
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException("退费失败,可能导致原因同一时间操作该患者的费用,请确认是否还有其他操作员在操作该患者费用,在重新操作退费。");
|
|
|
- }
|
|
|
+ // 执行退费的操作
|
|
|
+ dao.xiangMuTuiFei(tuiFeiList);
|
|
|
+ dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
|
|
|
+ log.info("操作项目退费 ==》 操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(tuiFeiList));
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "项目退费操作成功。");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -165,10 +159,9 @@ public class XiangMuLuRuService {
|
|
|
return ResultVoUtil.success(dao.queryXiangMu(pyCode.toUpperCase() + "%"));
|
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> xiangMuFeiYongShangChuan(ZyDetailCharge param) {
|
|
|
-
|
|
|
- if (param.getList().size() >= 100) {
|
|
|
+ if (param.getList().size() > 100) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "一次性项目录入大于100条");
|
|
|
}
|
|
|
if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null || param.getLedgerSn() == null || param.getList().size() == 0
|
|
|
@@ -198,15 +191,11 @@ public class XiangMuLuRuService {
|
|
|
}
|
|
|
FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(param.getList(), true);
|
|
|
fy.setTotalCharge(sum);
|
|
|
- try {
|
|
|
- // 在此处 插入费用
|
|
|
- dao.chaRuFeiYong(param, param.getList());
|
|
|
- dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
|
|
|
- log.info("项目录入费用上传 ==》 操作人:{},数据:{}", param.getOpIdCode(), JSON.toJSONString(param));
|
|
|
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用上传成功。");
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException("项目录入失败,可能导致原因同一时间操作该患者的费用,请确认是否还有其他操作员在操作该患者费用,在重新操作退费。");
|
|
|
- }
|
|
|
+ // 在此处 插入费用
|
|
|
+ dao.chaRuFeiYong(param, param.getList());
|
|
|
+ dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
|
|
|
+ log.info("项目录入费用上传 ==》 操作人:{},数据:{}", param.getOpIdCode(), JSON.toJSONString(param));
|
|
|
+ return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用上传成功。");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -258,17 +247,10 @@ public class XiangMuLuRuService {
|
|
|
}
|
|
|
// 开始匹配
|
|
|
if (piPei.size() > 0) {
|
|
|
- // 100 条的更新
|
|
|
- List<ZyDetailCharge> fenDuanPiPei = new ArrayList<>();
|
|
|
- for (ZyDetailCharge zyDetailCharge : piPei) {
|
|
|
- fenDuanPiPei.add(zyDetailCharge);
|
|
|
- if (fenDuanPiPei.size() == 100) {
|
|
|
- dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, fenDuanPiPei);
|
|
|
- fenDuanPiPei.clear();
|
|
|
- }
|
|
|
- }
|
|
|
- if (fenDuanPiPei.size() > 0) {
|
|
|
- dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, fenDuanPiPei);
|
|
|
+ // 100 条的更新 ListUtils.partition 用来拆分 list size 是拆分的条数
|
|
|
+ List<List<ZyDetailCharge>> fenDuan = ListUtils.partition(piPei, 100);
|
|
|
+ for (List<ZyDetailCharge> list : fenDuan) {
|
|
|
+ dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, list);
|
|
|
}
|
|
|
log.info("医嘱退费匹配 ==》 操作人:{} :住院号:{},住院次数:{}", TokenUtil.getTokenUserId(), inpatientNo, admissTimes);
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, String.format("医嘱退费匹配成功共匹配%d条", piPei.size()));
|