123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package thyyxxk.webserver.service.zhuyuanyiji;
- import com.alibaba.fastjson.JSON;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import thyyxxk.webserver.config.exception.ExceptionEnum;
- import thyyxxk.webserver.constants.GetDateFormat;
- import thyyxxk.webserver.dao.his.yibao.XiangMuLuRuDao;
- import thyyxxk.webserver.dao.his.zhuyuanyiji.QueRenYiZhuShouFeiDao;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.datamodify.FeiYongLeiXin;
- import thyyxxk.webserver.entity.datamodify.YzActOrder;
- import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
- import thyyxxk.webserver.service.PublicServer;
- import thyyxxk.webserver.utils.*;
- import java.math.BigDecimal;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * <p>
- * 描述: 确认医嘱收费
- * </p>
- *
- * @author xc
- * @date 2021-09-27 11:50
- */
- @Service
- @Slf4j
- public class QueRenYiZhuShouFeiServer {
- private final QueRenYiZhuShouFeiDao dao;
- private final XiangMuLuRuDao xiangMuLuRuDao;
- private final PublicServer publicServer;
- public QueRenYiZhuShouFeiServer(QueRenYiZhuShouFeiDao dao, XiangMuLuRuDao xiangMuLuRuDao, PublicServer server) {
- this.dao = dao;
- this.xiangMuLuRuDao = xiangMuLuRuDao;
- this.publicServer = server;
- }
- /**
- * @param yzActOrder 查询条件 住院号,住院次数,执行科室, 分页
- * @return 返回分页数据
- */
- public ResultVo<IPage<YzActOrder>> getXuQueFeiYiZhu(YzActOrder yzActOrder) {
- IPage<YzActOrder> page = new Page<>(yzActOrder.getCurrentPage(), yzActOrder.getPageSize(), false);
- if (StringUtil.isBlank(yzActOrder.getExecUnit())) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "科室信息为空 [・_・?]");
- }
- log.info("查询需确费医嘱:数据:{}", JSON.toJSONString(yzActOrder));
- page.setTotal(dao.getXuQueFeiYiZhuTotal(yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), publicServer.getKeShiLieBiaoList(yzActOrder.getExecUnit())));
- dao.getXuQueFeiYiZhu(page, yzActOrder.getInpatientNo(), yzActOrder.getWardCode(), publicServer.getKeShiLieBiaoList(yzActOrder.getExecUnit()));
- if (page.getRecords().isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
- }
- return ResultVoUtil.success(page);
- }
- /**
- * 这里是查询 患者的具体医嘱确认信息
- *
- * @param inpatientNo 住院号
- * @param admissTimes 住院次数
- * @param execUnit 执行科室
- * @return 返回
- */
- public ResultVo<YzActOrder> getXuQueFeiXiangXiXinXi(String inpatientNo, Integer admissTimes, String execUnit) {
- YzActOrder yzActOrder = dao.huoQuGeRenXinXi(inpatientNo, admissTimes);
- log.info("查询确认医嘱费用明细 ==> 住院号:{},住院次数:{},执行科室:{}", inpatientNo, admissTimes, execUnit);
- yzActOrder.setList(dao.getXuQueFeiXiangXiXinXi(inpatientNo, admissTimes, execUnit, publicServer.getKeShiLieBiaoList(execUnit)));
- if (yzActOrder.getList() == null || yzActOrder.getList().isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有数据 ヽ(゜Q。)ノ?");
- }
- return ResultVoUtil.success(yzActOrder);
- }
- @Transactional(rollbackFor = Exception.class)
- public ResultVo<String> baoCunYiZhuQueFeiShuJu(YzActOrder param) {
- List<ZyDetailCharge> zyDetailCharges = new ArrayList<>();
- List<YzActOrder> shangChuanList = new ArrayList<>();
- BigDecimal sum = new BigDecimal(0);
- if (ListUtil.isBlank(param.getList())) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者没有需要确认的医嘱费用 ∑(っ°Д°;)っ。");
- }
- for (YzActOrder yzActOrder : param.getList()) {
- if (StringUtil.isBlank(yzActOrder.getChargeStatus())) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER);
- }
- if (yzActOrder.getChargeStatus().equals("1")) {
- ZyDetailCharge zy = new ZyDetailCharge();
- zy.setChargeAmount(yzActOrder.getOrderCount());
- zy.setChargeFee(yzActOrder.getChargeFee());
- zy.setBillItemCode(yzActOrder.getBillItemCode());
- zyDetailCharges.add(zy);
- sum = sum.add(zy.getChargeAmount().multiply(zy.getChargeFee()));
- shangChuanList.add(yzActOrder);
- } else if (yzActOrder.getChargeStatus().equals("2")) {
- yzActOrder.setOccTimeString(DateUtil.formatDatetime(yzActOrder.getOccTime()));
- shangChuanList.add(yzActOrder);
- }
- }
- if (shangChuanList.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有选择任何操作 !!!∑(゚Д゚ノ)ノ");
- } else {
- dao.baoCunYiZhuQueFei(param.getInpatientNo(), param.getAdmissTimes(), shangChuanList, TokenUtil.getTokenUserId());
- }
- if (!zyDetailCharges.isEmpty()) {
- FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(zyDetailCharges, true);
- fy.setTotalCharge(sum);
- xiangMuLuRuDao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_ledger_file");
- xiangMuLuRuDao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
- }
- log.info("医嘱确费保存==》操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(param.getList(), GetDateFormat.DATE_TIME));
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "操作成功 (๑*◡*๑)");
- }
- }
|