|
@@ -1,10 +1,14 @@
|
|
|
package thyyxxk.webserver.service.inpatient;
|
|
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
@@ -16,15 +20,13 @@ import thyyxxk.webserver.entity.datamodify.MzChargeDetail;
|
|
|
import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
|
|
|
import thyyxxk.webserver.entity.inpatient.ZyActpatient;
|
|
|
import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyPatientInfo;
|
|
|
+import thyyxxk.webserver.entity.transferInOfExpenses.data.CorrectInvoice;
|
|
|
import thyyxxk.webserver.service.PublicServer;
|
|
|
-import thyyxxk.webserver.utils.DateUtil;
|
|
|
-import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
-import thyyxxk.webserver.utils.TokenUtil;
|
|
|
+import thyyxxk.webserver.service.hutoolcache.UserCache;
|
|
|
+import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -36,16 +38,17 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
public class TransferInOfExpensesService {
|
|
|
|
|
|
private final TransferInOfExpensesDao dao;
|
|
|
private final PublicServer publicServer;
|
|
|
+ private final RestTemplateUtils template;
|
|
|
+ private final UserCache userCache;
|
|
|
+
|
|
|
+ @Value("${thmz-api-url}")
|
|
|
+ private String thmzApiUrl;
|
|
|
|
|
|
- @Autowired
|
|
|
- public TransferInOfExpensesService(TransferInOfExpensesDao dao, PublicServer publicServer) {
|
|
|
- this.dao = dao;
|
|
|
- this.publicServer = publicServer;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 查询再远患者信息
|
|
@@ -65,18 +68,12 @@ public class TransferInOfExpensesService {
|
|
|
/**
|
|
|
* 通过机制号来查找信息
|
|
|
*
|
|
|
- * @param serialNo 机制号
|
|
|
- * @param liShiFlag 是否查看历史 0:不查看 1:查看
|
|
|
+ * @param serialNo 机制号
|
|
|
* @return 返回信息
|
|
|
*/
|
|
|
- public ResultVo<List<MzChargeDetail>> getSerialNo(Integer serialNo, Integer liShiFlag) {
|
|
|
- List<MzChargeDetail> list;
|
|
|
- if (liShiFlag == 0) {
|
|
|
- list = dao.getSerialNo("mz_charge_detail", "mz_receipt_serial", serialNo);
|
|
|
- } else {
|
|
|
- list = dao.getSerialNo("mz_charge_detail_b", "mz_receipt_serial_b", serialNo);
|
|
|
- }
|
|
|
- if (list.size() > 0) {
|
|
|
+ public ResultVo<List<MzChargeDetail>> getSerialNo(Integer serialNo) {
|
|
|
+ List<MzChargeDetail> list = dao.getSerialNo("mz_charge_detail", "mz_receipt_serial", serialNo);
|
|
|
+ if (!list.isEmpty()) {
|
|
|
return ResultVoUtil.success(list);
|
|
|
} else {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
|
|
@@ -98,7 +95,7 @@ public class TransferInOfExpensesService {
|
|
|
List<ZyDetailCharge> list = dao.getZyJiMenZhenZhuangRuFeiYong(page, inpatientNo, chargeCodeMX, admissTimes, ledgerSn);
|
|
|
List<ZyDetailCharge> sumList = dao.sumZyFee(inpatientNo, chargeCodeMX, admissTimes, ledgerSn);
|
|
|
Map<String, Object> map = new HashMap<>(Capacity.TWO);
|
|
|
- if (page.getTotal() > 0 || list.size() > 0) {
|
|
|
+ if (page.getTotal() > 0 || !list.isEmpty()) {
|
|
|
BigDecimal sum = new BigDecimal(0);
|
|
|
for (ZyDetailCharge zyDetailCharge : sumList) {
|
|
|
sum = sum.add(zyDetailCharge.getChargeFee().multiply(zyDetailCharge.getChargeAmount()));
|
|
@@ -130,6 +127,9 @@ public class TransferInOfExpensesService {
|
|
|
* @return 返回通知
|
|
|
*/
|
|
|
public ResultVo<String> baoCunHuanZheZhuYuanFeiYong(ZyActpatient param) {
|
|
|
+ if (param.getSerialNo() == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "刷新页面机制号为空");
|
|
|
+ }
|
|
|
param.setStaffId(TokenUtil.getInstance().getTokenUserId());
|
|
|
List<MzChargeDetail> list = param.getList();
|
|
|
//查询流水号
|
|
@@ -147,7 +147,6 @@ public class TransferInOfExpensesService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "费用发生时间不能大于出院时间,患者出院时间为:" + DateUtil.formatDatetime(param.getDisDate()));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 流水号取出这个患者流水值的最大值 在加 1
|
|
|
// 同时计算 出患者的总金额 以及 费用的类型
|
|
|
list.removeIf(item -> "BILL99".equals(item.getChargeCodeMx()));
|
|
@@ -162,6 +161,73 @@ public class TransferInOfExpensesService {
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "操作成功。");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public ResultVo<String> correctInvoice(CorrectInvoice.CorrectInvoiceReq param) {
|
|
|
+ CorrectInvoice correctInvoice = dao.getSerialNoByInvoiceNo(param.getSerialNo());
|
|
|
+ if (correctInvoice == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到该发票号");
|
|
|
+ }
|
|
|
+
|
|
|
+ String url = thmzApiUrl + "/uploadPartMzInvoice";
|
|
|
+ correctInvoice.setOpId(TokenUtil.getInstance().getTokenUserId());
|
|
|
+ param.getCodes().replaceAll(String::trim);
|
|
|
+ correctInvoice.setChargeItemCodes(param.getCodes());
|
|
|
+
|
|
|
+ ResultVo<String> resultVo = template.post(url, correctInvoice, String.class, "门诊部分开票");
|
|
|
+ if (resultVo == null) {
|
|
|
+ return R.fail(ExceptionEnum.LOGICAL_ERROR, "调用接口错误,请联系管理员。");
|
|
|
+ }
|
|
|
+ if (resultVo.getCode().equals(0)) {
|
|
|
+ return R.ok(resultVo.getData());
|
|
|
+ }
|
|
|
+ return R.fail(ExceptionEnum.LOGICAL_ERROR, resultVo.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取发票的二维码
|
|
|
+ *
|
|
|
+ * @param serialNo 机制号
|
|
|
+ * @return 数据
|
|
|
+ */
|
|
|
+ public ResultVo<CorrectInvoice.DzcfVo> getDzfpQrcodeBySerialNo(Integer serialNo) {
|
|
|
+ CorrectInvoice correctInvoice = dao.getSerialNoByInvoiceNo(serialNo);
|
|
|
+ return getDzfpQrcodeByCorrectInvoice(correctInvoice, serialNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<CorrectInvoice.DzcfVo> getDzfpQrcodeByCorrectInvoice(CorrectInvoice correctInvoice, Integer serialNo) {
|
|
|
+ if (correctInvoice == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到该发票号");
|
|
|
+ }
|
|
|
+ // 查询是否已经冲正了,如果冲正了就直接用冲正的东西
|
|
|
+ CorrectInvoice.DzcfVo uploadData = dao.getMzDzcfUpload(correctInvoice);
|
|
|
+
|
|
|
+ if (uploadData == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到电子发票");
|
|
|
+ }
|
|
|
+ List<String> changeCodes = StrUtil.isNotBlank(uploadData.getChargeCode()) ? Arrays.asList(uploadData.getChargeCode().split(",")) : null;
|
|
|
+
|
|
|
+ QueryWrapper<?> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("patient_id", correctInvoice.getPatientId())
|
|
|
+ .eq("times", correctInvoice.getTimes())
|
|
|
+ .eq("receipt_no", correctInvoice.getReceiptNo())
|
|
|
+ .eq("serial_no", serialNo)
|
|
|
+ .in("charge_item_code", changeCodes);
|
|
|
+
|
|
|
+ BigDecimal dzfpChangeTotal = dao.getDzfpChangeTotal(qw);
|
|
|
+ uploadData.setPatientId(correctInvoice.getPatientId());
|
|
|
+
|
|
|
+ if (dzfpChangeTotal != null) {
|
|
|
+ uploadData.setTotal(dzfpChangeTotal.toPlainString());
|
|
|
+ } else {
|
|
|
+ uploadData.setTotal("0");
|
|
|
+ }
|
|
|
+ uploadData.setOpName(userCache.getEmployeeName(correctInvoice.getOpId()));
|
|
|
+ uploadData.setPrintDate(DateUtil.format(new Date(), DatePattern.CHINESE_DATE_FORMAT));
|
|
|
+ return R.ok(uploadData);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 远程搜索 项目名称
|
|
|
*
|
|
@@ -171,4 +237,5 @@ public class TransferInOfExpensesService {
|
|
|
public ResultVo<List<GetDropdownBox>> queryEntryName(String pyCode) {
|
|
|
return ResultVoUtil.success(dao.queryEntryName("%" + pyCode.toUpperCase() + "%"));
|
|
|
}
|
|
|
+
|
|
|
}
|