Pārlūkot izejas kodu

住院电子发票优化

lihong 1 mēnesi atpakaļ
vecāks
revīzija
055edf423e

+ 2 - 2
src/main/java/thyyxxk/webserver/dao/his/inpatient/charge/CashierProcessDao.java

@@ -622,8 +622,8 @@ public interface CashierProcessDao {
     ZyActpatient selectZyActpatientFeeDetail(PatientParam param);
     @Select(" select max ( ledger_sn ) maxLedgerSn , min ( ledger_sn ) minLedgerSn  from zy_ledger_file where inpatient_no =#{inpatientNo} and admiss_times =#{admissTimes}  ")
     Map<String,Object> selectMaxAndMinLedgerSn(PatientParam param);
-    @Select(" select fp_no from mz_dzfp_upload where del_flag = 0 and  type_flag = #{typeFlag} and patient_id = #{inpatientNo} and times = #{admissTimes} and receipt_no = #{ledgerSn} ")
-    String selectDzfpNo(PatientParam param);
+    @Select(" select fp_no,qrcode from mz_dzfp_upload where del_flag = 0 and  type_flag = #{typeFlag} and patient_id = #{inpatientNo} and times = #{admissTimes} and receipt_no = #{ledgerSn} ")
+    Map<String,Object> selectDzfpNo(PatientParam param);
     @Update("update zy_receipt set dzfp_receipt_no =null  where inpatient_no =#{inpatientNo} and admiss_times =#{admissTimes} and ledger_sn =#{ledgerSn} and ( case when 1 > 0 then receipt_sn else 1 end ) =1 ")
     void clearZyReceiptDzfpNo(PatientParam param);
 }

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/charge/PatientParam.java

@@ -21,6 +21,8 @@ public class PatientParam extends BasePage {
     //发票类型 1 门诊蓝字发票  2 门诊红字发票 3住院蓝字发票 4住院红字发票 */
     private Integer typeFlag;
     private String wardCode;
+    // 0 下载pdf  1 下载二维码
+    private String type;
     //打印标识 0 不新增  1 新增
     private String printFlag;
     //发票号

+ 21 - 10
src/main/java/thyyxxk/webserver/service/inpatient/DismissService.java

@@ -16,8 +16,14 @@ import thyyxxk.webserver.constants.sidicts.MedType;
 import thyyxxk.webserver.constants.sidicts.PsnCertType;
 import thyyxxk.webserver.dao.his.inpatient.DismissDao;
 import thyyxxk.webserver.entity.ResultVo;
-import thyyxxk.webserver.entity.inpatient.charge.PatientParam;
-import thyyxxk.webserver.entity.inpatient.dismiss.*;
+import thyyxxk.webserver.entity.inpatient.dismiss.ActOrderDetail;
+import thyyxxk.webserver.entity.inpatient.dismiss.ActOrderGroup;
+import thyyxxk.webserver.entity.inpatient.dismiss.BriefMdtrtInfo;
+import thyyxxk.webserver.entity.inpatient.dismiss.DepositFile;
+import thyyxxk.webserver.entity.inpatient.dismiss.IllegalFee;
+import thyyxxk.webserver.entity.inpatient.dismiss.MedinsSettleFee;
+import thyyxxk.webserver.entity.inpatient.dismiss.ReceiptEntity;
+import thyyxxk.webserver.entity.inpatient.dismiss.ReceiptFee;
 import thyyxxk.webserver.entity.inpatient.patient.Overview;
 import thyyxxk.webserver.entity.inpatient.patient.Patient;
 import thyyxxk.webserver.entity.medicalinsurance.injury.InjuryCareQualification;
@@ -25,10 +31,21 @@ import thyyxxk.webserver.http.drg.DrgWebApi;
 import thyyxxk.webserver.service.externalhttp.SiInjuryFeeUpld;
 import thyyxxk.webserver.service.externalhttp.SiZySrvc;
 import thyyxxk.webserver.service.inpatient.charge.CashierProcessService;
-import thyyxxk.webserver.utils.*;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.DecimalUtil;
+import thyyxxk.webserver.utils.IdCardUtil;
+import thyyxxk.webserver.utils.ListUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+import thyyxxk.webserver.utils.TokenUtil;
 
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * @author dj
@@ -342,12 +359,6 @@ public class DismissService {
         if (code < 1) {
             throw new BizException(ExceptionEnum.LOGICAL_ERROR, "更新住院状态失败。" + code);
         }
-        PatientParam param = new PatientParam();
-        param.setInpatientNo(settleFee.getInpatientNo());
-        param.setAdmissTimes(settleFee.getAdmissTimes());
-        param.setLedgerSn(settleFee.getLedgerSn());
-        param.setTypeFlag(3);
-        cashierService.uploadDzInvoice(param);
         new DestructionUser(settleFee.getInpatientNo(), settleFee.getAdmissTimes()).start();
         return "OK";
     }

+ 47 - 24
src/main/java/thyyxxk/webserver/service/inpatient/charge/CashierProcessService.java

@@ -516,38 +516,61 @@ public class CashierProcessService {
         }
         ZyReceipt zyReceipt = dao.selectPrintZyFpData(param);
         AssertUtil.isnotBlank(zyReceipt, "没有发票信息");
+        ZyLedgerFile zyLedgerFile = dao.selectSettData(param);
+        AssertUtil.isnotBlank(zyReceipt, "没有账页信息");
+        zyReceipt.setYsHjJe(Convert.toBigDecimal(zyLedgerFile.getDeposit(),BigDecimal.ZERO));
+        if(Convert.toBigDecimal(zyLedgerFile.getSettle(), BigDecimal.ZERO).compareTo(BigDecimal.ZERO) >= 0){
+            zyReceipt.setTkHjJe(Convert.toBigDecimal(zyLedgerFile.getSettle(),BigDecimal.ZERO));
+            zyReceipt.setBsHjJe(BigDecimal.ZERO);
+        }else {
+            zyReceipt.setTkHjJe(BigDecimal.ZERO);
+            zyReceipt.setBsHjJe(zyLedgerFile.getSettle().abs());
+        }
         ZyActpatient zyActpatient = dao.selectApatienInfo(param.getInpatientNo());
         zyReceipt.setName(Convert.toInt(NumberEnum.FOUR.getCode()).equals(Convert.toInt(param.getReceiptSn(),1)) ? zyActpatient.getName()+"(婴儿)":zyActpatient.getName());
         if(Convert.toInt(NumberEnum.FOUR.getCode()).equals(param.getReceiptSn())){
             param.setInpatientNo(param.getInpatientNo()+"$1");
         }
-        Map<String, Object> paramMap = dealInvoiceParam(param);
-        ResultVo response = template.postForObject(thmzApiUrl +"/queryInvoiceFile", paramMap, ResultVo.class);
-        if(response == null ){
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, "下载电子发票错误");
-        }
-        if(response.getCode() == -1 ){
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, response.getMessage());
-        }
-        if(Convert.toInt(NumberEnum.ThREE.getCode()).equals(param.getTypeFlag())){
-           String dzfpNo =  dao.selectDzfpNo(param);
-           if(StrUtil.isNotBlank(dzfpNo)){
-               param.setReceiptNo(dzfpNo);
-               dao.updateZyLedgerFileReceiptNo(param);
-               dao.updateZyDepositFileReceiptNo(param);
-               dao.updatezyReceiptDzfpNo(param);
-           }else {
-           //    查询是否有冲红的发票
-               param.setTypeFlag(4);
-               String zfDzfpNo =  dao.selectDzfpNo(param);
-               if(StrUtil.isNotBlank(zfDzfpNo)){
-                   dao.clearZyReceiptDzfpNo(param);
-               }
-           }
+        //    下载二维码 直接查数据库
+        Map<String, Object> fpInfo = new HashMap<>();
+        if(NumberEnum.ONE.getCode().equals(param.getType())){
+            Map<String,Object> dzfpMap =  dao.selectDzfpNo(param);
+            AssertUtil.isnotBlank(dzfpMap,"没有查询到电子发票");
+            AssertUtil.isnotBlank(dzfpMap.get("qrcode"),"没有查询到电子发票");
+            fpInfo.put("qrcode", dzfpMap.get("qrcode"));
+            fpInfo.put("pdfFileStr", "");
+        }else {
+            Map<String, Object> paramMap = dealInvoiceParam(param);
+            ResultVo response = template.postForObject(thmzApiUrl +"/queryInvoiceFile", paramMap, ResultVo.class);
+            if(response == null ){
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, "下载电子发票错误");
+            }
+            if(response.getCode() == -1 ){
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, response.getMessage());
+            }
+            fpInfo = (Map)response.getData();
+            if(Convert.toInt(NumberEnum.ThREE.getCode()).equals(param.getTypeFlag())){
+                Map<String,Object> dzfpNoMap =  dao.selectDzfpNo(param);
+                String dzfpNo = dzfpNoMap != null && dzfpNoMap.get("fp_no") != null? Convert.toStr(dzfpNoMap.get("fp_no")) : null;
+                if(StrUtil.isNotBlank(dzfpNo)){
+                    param.setReceiptNo(dzfpNo);
+                    dao.updateZyLedgerFileReceiptNo(param);
+                    dao.updateZyDepositFileReceiptNo(param);
+                    dao.updatezyReceiptDzfpNo(param);
+                }else {
+                    //    查询是否有冲红的发票
+                    param.setTypeFlag(4);
+                    Map<String,Object> zfDzfpNoMap =  dao.selectDzfpNo(param);
+                    String zfDzfpNo = zfDzfpNoMap != null && zfDzfpNoMap.get("fp_no") != null? Convert.toStr(zfDzfpNoMap.get("fp_no")) : null;
+                    if(StrUtil.isNotBlank(zfDzfpNo)){
+                        dao.clearZyReceiptDzfpNo(param);
+                    }
+                }
+            }
         }
         Map<String, Object> res = new HashMap<>();
         res.put("zyReceipt", zyReceipt);
-        res.put("fpInfo", response.getData());
+        res.put("fpInfo", fpInfo);
         return ResultVoUtil.success(ExceptionEnum.SUCCESS,res);
     }
 

+ 0 - 7
src/main/java/thyyxxk/webserver/service/inpatient/charge/ForceInAndOutService.java

@@ -11,7 +11,6 @@ import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.sidicts.MedType;
 import thyyxxk.webserver.dao.his.inpatient.charge.ForceInAndOutDao;
 import thyyxxk.webserver.entity.ResultVo;
-import thyyxxk.webserver.entity.inpatient.charge.PatientParam;
 import thyyxxk.webserver.entity.inpatient.charge.forceinout.PatInquiry;
 import thyyxxk.webserver.entity.inpatient.charge.forceinout.SimplePatient;
 import thyyxxk.webserver.entity.login.UserInfo;
@@ -197,12 +196,6 @@ public class ForceInAndOutService {
     }
 
     private String revokeHisSettle(SimplePatient patient) {
-        PatientParam param = new PatientParam();
-        param.setInpatientNo(patient.getPatNo());
-        param.setAdmissTimes(patient.getTimes());
-        param.setLedgerSn(patient.getLedgerSn());
-        param.setTypeFlag(4);
-        cashierService.uploadDzInvoice(param);
         dao.clearZyLedgerFile(patient);
         dao.updateZyDetailCharge(patient);
         dao.deleteZyReceipt(patient);

+ 26 - 1
src/main/java/thyyxxk/webserver/service/medicalinsurance/SetlListUpldService.java

@@ -49,6 +49,7 @@ import thyyxxk.webserver.entity.drg.BaseInfo;
 import thyyxxk.webserver.entity.drg.DiseInfoList;
 import thyyxxk.webserver.entity.drg.OprtInfoList;
 import thyyxxk.webserver.entity.inpatient.ZyActpatient;
+import thyyxxk.webserver.entity.inpatient.charge.PatientParam;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.BatjBa4;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.YbZyDisDiag;
@@ -80,9 +81,14 @@ import thyyxxk.webserver.http.drg.DrgWebApi;
 import thyyxxk.webserver.http.websocket.SocketV2;
 import thyyxxk.webserver.http.websocket.dto.WebSocketByUserCode;
 import thyyxxk.webserver.service.PublicServer;
-import thyyxxk.webserver.service.hutoolcache.*;
+import thyyxxk.webserver.service.hutoolcache.DeptCache;
+import thyyxxk.webserver.service.hutoolcache.NationCache;
+import thyyxxk.webserver.service.hutoolcache.RegionCache;
+import thyyxxk.webserver.service.hutoolcache.RelativeCache;
+import thyyxxk.webserver.service.hutoolcache.UserCache;
 import thyyxxk.webserver.service.inpatient.casefrontsheet.CaseFrontSheetMainService;
 import thyyxxk.webserver.service.inpatient.casefrontsheet.VerifyCaseFrontSheet;
+import thyyxxk.webserver.service.inpatient.charge.CashierProcessService;
 import thyyxxk.webserver.service.outpatient.wxapi.SendWxInfoService;
 import thyyxxk.webserver.utils.*;
 
@@ -126,6 +132,7 @@ public class SetlListUpldService {
     private final RegionCache regionCache;
     private final RelativeCache relativeCache;
     private final DrgWebApi drgWebApi;
+    private final CashierProcessService cashierProcessService;
 
     /**
      * 上传到医保的结算单上传
@@ -2356,6 +2363,7 @@ public class SetlListUpldService {
         // 因为我们是三级医院 所以就是三
         setlinfoUpld.setHiSetlLv("3");
         // 票据代码
+        dealDzfp(patNo, times, ledgerSn);
         String billNo = dao.billNo(patNo, times, ledgerSn);
         if("00000000".equals(billNo)){
             billNo = "";
@@ -2446,6 +2454,23 @@ public class SetlListUpldService {
         return setlinfoUpld;
     }
 
+    private void dealDzfp(String patNo, Integer times, Integer ledgerSn) {
+        try {
+            PatientParam param = new PatientParam();
+            param.setInpatientNo(patNo);
+            param.setAdmissTimes(times);
+            param.setLedgerSn(ledgerSn);
+            param.setReceiptSn(1);
+            param.setType("0");
+            log.info("[dealDzfp]查询电子发票传参住院号={},次数={},账页号={}",patNo,times,ledgerSn);
+            ResultVo<Map<String, Object>> mapResultVo = cashierProcessService.downDzInvoice(param);
+            log.info("[dealDzfp]查询电子发票返回消息,{}",mapResultVo.getMessage());
+        }catch (Exception e){
+            log.error("[dealDzfp]结算单上传查询电子发票失败:",e);
+        }
+
+    }
+
     private SetlinfoUpld getSetlinfoUpld2(String patNo, Integer times) {
         if (dao.countZy(patNo, times) == null) {
             return dao.setlinfo2(patNo, times, ZyActpatient.ZY_INACTPATIENT);