QueRenYiZhuShouFeiServer.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package thyyxxk.webserver.service.zhuyuanyiji;
  2. import com.alibaba.fastjson.JSON;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import lombok.extern.slf4j.Slf4j;
  6. import org.springframework.stereotype.Service;
  7. import org.springframework.transaction.annotation.Transactional;
  8. import thyyxxk.webserver.config.exception.ExceptionEnum;
  9. import thyyxxk.webserver.constants.GetDateFormat;
  10. import thyyxxk.webserver.dao.his.yibao.XiangMuLuRuDao;
  11. import thyyxxk.webserver.dao.his.zhuyuanyiji.QueRenYiZhuShouFeiDao;
  12. import thyyxxk.webserver.entity.ResultVo;
  13. import thyyxxk.webserver.entity.datamodify.FeiYongLeiXin;
  14. import thyyxxk.webserver.entity.datamodify.YzActOrder;
  15. import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
  16. import thyyxxk.webserver.service.PublicServer;
  17. import thyyxxk.webserver.utils.*;
  18. import java.math.BigDecimal;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. /**
  22. * <p>
  23. * 描述: 确认医嘱收费
  24. * </p>
  25. *
  26. * @author xc
  27. * @date 2021-09-27 11:50
  28. */
  29. @Service
  30. @Slf4j
  31. public class QueRenYiZhuShouFeiServer {
  32. private final QueRenYiZhuShouFeiDao dao;
  33. private final XiangMuLuRuDao xiangMuLuRuDao;
  34. private final PublicServer publicServer;
  35. public QueRenYiZhuShouFeiServer(QueRenYiZhuShouFeiDao dao, XiangMuLuRuDao xiangMuLuRuDao, PublicServer server) {
  36. this.dao = dao;
  37. this.xiangMuLuRuDao = xiangMuLuRuDao;
  38. this.publicServer = server;
  39. }
  40. /**
  41. * @param yzActOrder 查询条件 住院号,住院次数,执行科室, 分页
  42. * @return 返回分页数据
  43. */
  44. public ResultVo<IPage<YzActOrder>> getXuQueFeiYiZhu(YzActOrder yzActOrder) {
  45. IPage<YzActOrder> page = new Page<>(yzActOrder.getCurrentPage(), yzActOrder.getPageSize(), false);
  46. if (StringUtil.isBlank(yzActOrder.getExecUnit())) {
  47. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "科室信息为空 [・_・?]");
  48. }
  49. log.info("查询需确费医嘱:数据:{}", JSON.toJSONString(yzActOrder));
  50. page.setTotal(dao.getXuQueFeiYiZhuTotal(yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), publicServer.getKeShiLieBiaoList(yzActOrder.getExecUnit())));
  51. dao.getXuQueFeiYiZhu(page, yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), publicServer.getKeShiLieBiaoList(yzActOrder.getExecUnit()));
  52. if (page.getRecords().isEmpty()) {
  53. return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
  54. }
  55. return ResultVoUtil.success(page);
  56. }
  57. /**
  58. * 这里是查询 患者的具体医嘱确认信息
  59. *
  60. * @param inpatientNo 住院号
  61. * @param admissTimes 住院次数
  62. * @param execUnit 执行科室
  63. * @return 返回
  64. */
  65. public ResultVo<YzActOrder> getXuQueFeiXiangXiXinXi(String inpatientNo, Integer admissTimes, String execUnit) {
  66. YzActOrder yzActOrder = dao.huoQuGeRenXinXi(inpatientNo, admissTimes);
  67. log.info("查询确认医嘱费用明细 ==> 住院号:{},住院次数:{},执行科室:{}", inpatientNo, admissTimes, execUnit);
  68. yzActOrder.setList(dao.getXuQueFeiXiangXiXinXi(inpatientNo, admissTimes, execUnit, publicServer.getKeShiLieBiaoList(execUnit)));
  69. if (yzActOrder.getList() == null || yzActOrder.getList().isEmpty()) {
  70. return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有数据 ヽ(゜Q。)ノ?");
  71. }
  72. return ResultVoUtil.success(yzActOrder);
  73. }
  74. @Transactional(rollbackFor = Exception.class)
  75. public ResultVo<String> baoCunYiZhuQueFeiShuJu(YzActOrder param) {
  76. List<ZyDetailCharge> zyDetailCharges = new ArrayList<>();
  77. List<YzActOrder> shangChuanList = new ArrayList<>();
  78. BigDecimal sum = new BigDecimal(0);
  79. if (ListUtil.isBlank(param.getList())) {
  80. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者没有需要确认的医嘱费用 ∑(っ°Д°;)っ。");
  81. }
  82. for (YzActOrder yzActOrder : param.getList()) {
  83. if (StringUtil.isBlank(yzActOrder.getChargeStatus())) {
  84. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER);
  85. }
  86. if (yzActOrder.getChargeStatus().equals("1")) {
  87. ZyDetailCharge zy = new ZyDetailCharge();
  88. zy.setChargeAmount(yzActOrder.getOrderCount());
  89. zy.setChargeFee(yzActOrder.getChargeFee());
  90. zy.setBillItemCode(yzActOrder.getBillItemCode());
  91. zyDetailCharges.add(zy);
  92. sum = sum.add(zy.getChargeAmount().multiply(zy.getChargeFee()));
  93. shangChuanList.add(yzActOrder);
  94. } else if (yzActOrder.getChargeStatus().equals("2")) {
  95. yzActOrder.setOccTimeString(DateUtil.formatDatetime(yzActOrder.getOccTime()));
  96. shangChuanList.add(yzActOrder);
  97. }
  98. }
  99. if (shangChuanList.isEmpty()) {
  100. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有选择任何操作 !!!∑(゚Д゚ノ)ノ");
  101. } else {
  102. dao.baoCunYiZhuQueFei(param.getInpatientNo(), param.getAdmissTimes(), shangChuanList, TokenUtil.getTokenUserId());
  103. }
  104. if (!zyDetailCharges.isEmpty()) {
  105. FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(zyDetailCharges, true);
  106. fy.setTotalCharge(sum);
  107. xiangMuLuRuDao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_ledger_file");
  108. xiangMuLuRuDao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
  109. }
  110. log.info("医嘱确费保存==》操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(param.getList(), GetDateFormat.DATE_TIME));
  111. return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "操作成功 (๑*◡*๑)");
  112. }
  113. }