Przeglądaj źródła

住院日结报表优化

lihong 1 miesiąc temu
rodzic
commit
fec1f1237b

+ 8 - 1
src/main/java/thyyxxk/webserver/dao/his/zygl/ZyDailySettlementDao.java

@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.executeItem.ZyLedgerFile;
 import thyyxxk.webserver.entity.zygl.ZyDayclosingRecord;
 
 import java.util.Date;
@@ -40,6 +41,8 @@ public interface ZyDailySettlementDao {
             "where  cash_date > #{beginTime}  and cash_date <= #{endTime} and  cash_id = #{opId} ")
     Map<String, Object> selectTotalChargeFromLegerFile(@Param("opId") String opId, @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);
 
+    @Select("select rtrim(inpatient_no) inpatient_no ,admiss_times,ledger_sn from zy_ledger_file  where  cash_date > #{beginTime}  and cash_date <= #{endTime} and  cash_id = #{opId}")
+    List<ZyLedgerFile> selectCashPatientByOpId(@Param("opId") String opId, @Param("beginTime") Date beginTime, @Param("endTime") Date endTime);
 
     /**
      * 查询预交金信息
@@ -329,7 +332,7 @@ public interface ZyDailySettlementDao {
             "        charge_bk   =isnull(max(d.charge_bk),0) ," +
             "        charge_tk   =isnull(max(d.charge_tk),0) ," +
             "        deposit     =case when a.ledger_sn<0 then 0 - abs(max(a.deposit)) else max(a.deposit) end  ," +
-            "        receipt_no  =max(c.receipt_no)," +
+            "        receipt_no  =case when max(isnull(c.dzfp_receipt_no,'')) !='' then max(c.dzfp_receipt_no) else max(c.receipt_no) end ," +
             " ledger_sn=a.ledger_sn " +
             "          from zy_ledger_file a join zy_receipt c on a.inpatient_no=c.inpatient_no and a.admiss_times=c.admiss_times and a.ledger_sn = c.ledger_sn " +
             "    left join    (select inpatient_no,admiss_times,ledger_sn," +
@@ -406,4 +409,8 @@ public interface ZyDailySettlementDao {
             "         join dj_dict_role b on a.role_id = b.id  " +
             "         where a.user_code=#{userCode} ")
     List<String> selectRoleNamesByUserCode(String userCode);
+    @Select(" select dzfp_receipt_no from zy_receipt where inpatient_no=#{inpatientNo} and admiss_times= #{admissTimes} and ledger_sn = #{ledgerSn} and receipt_sn = 1")
+    String selectzyReceiptDzfp(ZyLedgerFile zyLedgerFile);
+    @Select(" select count(*) from zy_receipt where  inpatient_no=#{inpatientNo} and admiss_times= #{admissTimes} and ledger_sn = #{ledgerSn} and receipt_sn = 4")
+    Integer selectCountZyReceiptDzfpBaby(ZyLedgerFile zyLedgerFile);
 }

+ 32 - 0
src/main/java/thyyxxk/webserver/service/zygl/ZyDailySettlementService.java

@@ -15,11 +15,14 @@ import thyyxxk.webserver.dao.his.zygl.ZyActpatientDao;
 import thyyxxk.webserver.dao.his.zygl.ZyDailySettlementDao;
 import thyyxxk.webserver.entity.dictionary.ZdUnitCode;
 import thyyxxk.webserver.entity.executeItem.NumberEnum;
+import thyyxxk.webserver.entity.executeItem.ZyLedgerFile;
 import thyyxxk.webserver.entity.inpatient.ZyActpatient;
+import thyyxxk.webserver.entity.inpatient.charge.PatientParam;
 import thyyxxk.webserver.entity.zygl.CodeNameEntity;
 import thyyxxk.webserver.entity.zygl.ZyDailySettlementVo;
 import thyyxxk.webserver.entity.zygl.ZyDayclosingRecord;
 import thyyxxk.webserver.service.hutoolcache.UserCache;
+import thyyxxk.webserver.service.inpatient.charge.CashierProcessService;
 import thyyxxk.webserver.utils.AssertUtil;
 import thyyxxk.webserver.utils.TokenUtil;
 
@@ -45,6 +48,8 @@ public class ZyDailySettlementService  {
     private ZdUnitCodeDao zdUnitCodeDao;
     @Resource
     private DictDataDao dictDataDao;
+    @Resource
+    private CashierProcessService cashierProcessService;
     /**
      * @description: 住院日结操作
      * @author: lihong
@@ -88,6 +93,7 @@ public class ZyDailySettlementService  {
         zyDailySettlementVo.setOpCodeRs(userCache.get(opId).getCodeRs());
         zyDailySettlementVo.setLastDailyDate(DateUtil.format(lastDailyDate, "yyyy-MM-dd HH:mm:ss"));
         zyDailySettlementVo.setCurrentDate(DateUtil.format(now, "yyyy-MM-dd HH:mm:ss"));
+        dealDzfp(opId, lastDailyDate, now);
         Map<String, Object> map = zyDailySettlementMapper.selectTotalChargeFromLegerFile(opId, lastDailyDate, now);
         setAttribute(zyDailySettlementVo, map);
         map = zyDailySettlementMapper.selectYjjFromDepositFile(opId, lastDailyDate, now);
@@ -108,6 +114,32 @@ public class ZyDailySettlementService  {
         return zyDailySettlementVo;
     }
 
+    private void dealDzfp(String opId, Date lastDailyDate, Date now) {
+        List<ZyLedgerFile> zyLedgerFiles = zyDailySettlementMapper.selectCashPatientByOpId(opId, lastDailyDate, now);
+        for(ZyLedgerFile zyLedgerFile : zyLedgerFiles){
+            try {
+                PatientParam param = new PatientParam();
+                param.setInpatientNo(zyLedgerFile.getInpatientNo());
+                param.setAdmissTimes(zyLedgerFile.getAdmissTimes());
+                param.setLedgerSn(zyLedgerFile.getLedgerSn());
+                param.setReceiptSn(1);
+                param.setTypeFlag(3);
+                param.setType("0");
+                String dzfp = zyDailySettlementMapper.selectzyReceiptDzfp(zyLedgerFile);
+                if(StrUtil.isBlank(dzfp)){
+                    cashierProcessService.downDzInvoice(param);
+                    Integer babyCount = zyDailySettlementMapper.selectCountZyReceiptDzfpBaby(zyLedgerFile);
+                    if(babyCount > 0){
+                        param.setReceiptSn(4);
+                        cashierProcessService.downDzInvoice(param);
+                    }
+                }
+            }catch (Exception e){
+                log.error("住院日结报表同步电子发票报错",e);
+            }
+        }
+    }
+
     /**
      * 结算费用登记报表
      *