|
@@ -1,6 +1,9 @@
|
|
|
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;
|
|
@@ -19,12 +22,11 @@ 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.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>
|
|
@@ -42,6 +44,7 @@ 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;
|
|
@@ -180,21 +183,48 @@ public class TransferInOfExpensesService {
|
|
|
return R.fail(ExceptionEnum.LOGICAL_ERROR, resultVo.getMessage());
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> getDzfpQrcodeBySerialNo(Integer serialNo) {
|
|
|
+ /**
|
|
|
+ * 获取发票的二维码
|
|
|
+ *
|
|
|
+ * @param serialNo 机制号
|
|
|
+ * @return 数据
|
|
|
+ */
|
|
|
+ public ResultVo<CorrectInvoice.DzcfVo> getDzfpQrcodeBySerialNo(Integer serialNo) {
|
|
|
CorrectInvoice correctInvoice = dao.getSerialNoByInvoiceNo(serialNo);
|
|
|
- return getDzfpQrcodeByCorrectInvoice(correctInvoice);
|
|
|
+ return getDzfpQrcodeByCorrectInvoice(correctInvoice, serialNo);
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> getDzfpQrcodeByCorrectInvoice(CorrectInvoice correctInvoice) {
|
|
|
+ public ResultVo<CorrectInvoice.DzcfVo> getDzfpQrcodeByCorrectInvoice(CorrectInvoice correctInvoice, Integer serialNo) {
|
|
|
if (correctInvoice == null) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到该发票号");
|
|
|
}
|
|
|
// 查询是否已经冲正了,如果冲正了就直接用冲正的东西
|
|
|
- CorrectInvoice.DzcfVo mzDzcfUpload = dao.getMzDzcfUpload(correctInvoice);
|
|
|
- if (mzDzcfUpload != null) {
|
|
|
- return R.ok(mzDzcfUpload.getQrCode());
|
|
|
+ CorrectInvoice.DzcfVo uploadData = dao.getMzDzcfUpload(correctInvoice);
|
|
|
+
|
|
|
+ if (uploadData == null) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到电子发票");
|
|
|
}
|
|
|
- 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);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|