Browse Source

Merge branch 'master' of https://172.16.32.165/lighter/web-server

xiaochan 3 năm trước cách đây
mục cha
commit
d107ae434b

+ 1 - 0
.gitignore

@@ -4,3 +4,4 @@ target
 web-server.iml
 src/test
 *.zip
+sql

+ 4 - 8
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiManageDao.java

@@ -43,10 +43,8 @@ public interface SiManageDao {
     void updateUploadedFlag2(@Param("table") String table,
                              @Param("code") String codes);
 
-    @Select("select pat_no,times,ledger_sn,medfee_sumamt,acct_pay,fund_pay_sumamt, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996'))" +
-            "from t_si_setlinfo a where insutype=#{insutype} and clr_type=#{clrType} and revoked=0 " +
+    @Select("select pat_no,times,ledger_sn,medfee_sumamt,acct_pay,fund_pay_sumamt,hosp_part_amt " +
+            "from t_si_setlinfo where insutype=#{insutype} and clr_type=#{clrType} and revoked=0 " +
             "and clr_optins=#{clrOptins} and setl_time>=#{start} and setl_time<=#{end} and fund_pay_sumamt!=0 " +
             "and insuplc_admdvs like '43%' ")
     List<InstSetlLdgChkBrf> selectSetlChkBrfsWithInsutype(@Param("clrType") String clrType,
@@ -55,10 +53,8 @@ public interface SiManageDao {
                                                           @Param("start") String start,
                                                           @Param("end") String end);
 
-    @Select("select pat_no,times,ledger_sn,setl_id,mdtrt_id,psn_no,medfee_sumamt,acct_pay,fund_pay_sumamt,psn_cash_pay, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no and b.times=a.times " +
-            "and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996'))" +
-            "from t_si_setlinfo a where clr_type=#{clrType} and revoked=0 and clr_optins=#{clrOptins} and fund_pay_sumamt!=0 " +
+    @Select("select pat_no,times,ledger_sn,setl_id,mdtrt_id,psn_no,medfee_sumamt,acct_pay,fund_pay_sumamt,psn_cash_pay,hosp_part_amt " +
+            "from t_si_setlinfo where clr_type=#{clrType} and revoked=0 and clr_optins=#{clrOptins} and fund_pay_sumamt!=0 " +
             "and setl_time>=#{start} and setl_time<=#{end} and insuplc_admdvs like '43%' ")
     List<InstSetlLdgChkBrf> selectSetlChkBrfs(@Param("clrType") String clrType,
                                               @Param("clrOptins") String clrOptins,

+ 0 - 7
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiMzDao.java

@@ -78,13 +78,6 @@ public interface SiMzDao {
     void deleteAllReceipts(@Param("patNo") String patNo,
                            @Param("times") Integer times);
 
-    @Update("update t_si_pat_info set dise_code=#{code},dise_name=#{name} where pat_no=#{patNo} and times=#{times}")
-    void updatePatDiseinfo(@Param("patNo") String patNo, @Param("times") int times,
-                           @Param("code") String code, @Param("name") String name);
-
-    @Update("delete from t_si_setldetail where pat_no=#{patNo} and times=#{times}")
-    void deleteSetlDetail(@Param("patNo") String patNo, @Param("times") int times);
-
     @Select("select *, " +
             "chargeFee=(select sum(amount) from mz_deposit_file a where a.patient_id=patNo and a.times=temp.times and a.receipt_no=receiptNo), " +
             "status=(select count(1) from t_mt_receipt a where a.patient_id=patNo and a.times=temp.times and a.receipt_no=receiptNo) " +

+ 11 - 45
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiQueryDao.java

@@ -305,22 +305,9 @@ public interface SiQueryDao {
             "   psn_cash_pay, " +
             "   setl_time, " +
             "   a.med_type, " +
-            "   fundPaySumamt= " +
-            "    (SELECT sum(b.fund_payamt) " +
-            "    FROM t_si_setldetail b " +
-            "    WHERE b.pat_no = a.pat_no " +
-            "      AND b.times = a.times " +
-            "      AND b.ledger_sn = a.ledger_sn), a.insutype, hospPay= " +
-            "    (SELECT sum(b.fund_payamt) " +
-            "    FROM t_si_setldetail b " +
-            "    WHERE b.pat_no = a.pat_no " +
-            "      AND b.times = a.times " +
-            "      AND b.ledger_sn = a.ledger_sn " +
-            "      AND (b.fund_pay_type = '999996' " +
-            "      OR b.setl_proc_info = '999996')), maf_pay/*医疗救助*/, admiss_date = begntime, dis_date = endtime, idCard =  " +
-            "    (SELECT top 1 social_no " +
-            "    FROM a_patient_mi " +
-            "    WHERE pat_no = inpatient_no), dis_diag_comment = dis.dis_diag_comment, dis_diag = dis.dis_diag," +
+            "   fundPaySumamt=(a.fund_pay_sumamt-a.hosp_part_amt), a.insutype, " +
+            "  maf_pay, admiss_date = begntime, dis_date = endtime, " +
+            "idCard = a.certno, dis_diag_comment = dis.dis_diag_comment, dis_diag = dis.dis_diag," +
             "    totalMedicalExpenses = medfee_sumamt," +
             "    fulamt_ownpay_amt," +
             "    overlmt_selfpay," +
@@ -349,15 +336,9 @@ public interface SiQueryDao {
                                                                      @Param("setlType") String setlType);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
-            "psn_cash_pay,setl_time,a.med_type, " +
-            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996'))," +
-            "       maf_pay, " +
-            "       admiss_date = begntime, " +
-            "       dis_date = endtime, " +
-            "       idCard = (select top 1 social_no from a_patient_mi where pat_no = inpatient_no), " +
+            "psn_cash_pay,setl_time,a.med_type,maf_pay,endtime as dis_date,begntime as admiss_date, " +
+            "fundPaySumamt=(fund_pay_sumamt-hosp_part_amt),a.insutype, " +
+            "       idCard = a.certno, " +
             "       dis_diag_comment = dis.dis_diag_comment, " +
             "       dis_diag = dis.dis_diag, " +
             "    totalMedicalExpenses = medfee_sumamt," +
@@ -382,10 +363,7 @@ public interface SiQueryDao {
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
             "psn_cash_pay,setl_time,a.med_type, " +
-            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')), " +
+            "fundPaySumamt=(fund_pay_sumamt-hosp_part_amt),a.insutype, " +
             "       maf_pay, " +
             "       admiss_date = begntime, " +
             "       dis_date = endtime, " +
@@ -414,10 +392,7 @@ public interface SiQueryDao {
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
             "psn_cash_pay,setl_time,a.med_type, " +
-            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')), " +
+            "fundPaySumamt=(fund_pay_sumamt-hosp_part_amt),a.insutype, " +
             "       maf_pay, " +
             "       admiss_date = begntime, " +
             "       dis_date = endtime, " +
@@ -446,10 +421,7 @@ public interface SiQueryDao {
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
             "psn_cash_pay,setl_time,a.med_type, " +
-            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')), " +
+            "fundPaySumamt=(fund_pay_sumamt-hosp_part_amt),a.insutype, " +
             "       maf_pay, " +
             "       admiss_date = begntime, " +
             "       dis_date = endtime, " +
@@ -478,10 +450,7 @@ public interface SiQueryDao {
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
             "psn_cash_pay,setl_time,a.med_type, " +
-            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')), " +
+            "fundPaySumamt=(fund_pay_sumamt-hosp_part_amt),a.insutype, " +
             "       maf_pay, " +
             "       admiss_date = begntime, " +
             "       dis_date = endtime, " +
@@ -510,10 +479,7 @@ public interface SiQueryDao {
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
             "psn_cash_pay,setl_time,a.med_type, " +
-            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
-            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')), " +
+            "fundPaySumamt=(fund_pay_sumamt-hosp_part_amt),a.insutype, " +
             "       maf_pay, " +
             "       admiss_date = begntime, " +
             "       dis_date = endtime, " +

+ 2 - 5
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiSetlinfoDao.java

@@ -55,11 +55,8 @@ public interface SiSetlinfoDao extends BaseMapper<SiSetlinfo> {
                                                  @Param("begndate") String begndate,
                                                  @Param("enddate") String enddate);
 
-    @Select("select a.*, " +
-            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no and b.times=a.times " +
-            "and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
-            "from t_si_setlinfo a where a.setl_type=#{setltype} and a.revoked=0 and a.insutype like #{insutype} " +
-            "and a.insuplc_admdvs like #{insuplcAdmdvs} and a.setl_time>=#{begntime} and a.setl_time<=#{endtime}")
+    @Select("select * from t_si_setlinfo where setl_type=#{setltype} and revoked=0 and insutype like #{insutype} " +
+            "and setl_time>=#{begntime} and setl_time<=#{endtime} ${insuplcAdmdvs}")
     List<SiSetlinfo> selectMyList(@Param("setltype") String setltype,
                                   @Param("insutype") String insutype,
                                   @Param("insuplcAdmdvs") String insuplcAdmdvs,

+ 2 - 10
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/UpIdCollectionDao.java

@@ -44,7 +44,7 @@ public interface UpIdCollectionDao {
             "       a.gend, " + //  -- 性别
             "       a.brdy,  " + //-- 出生日期
             "       a.age,  " + // -- 年龄
-            "       a.certno, " + //  -- 证件号码
+            "       a.certno, " + //  -- 证件号码, 医院支付
             "       a.psn_cert_type as patnCertType,  " + // -- 患者证件类别
             "       b.insuplc_admdvs as insuplc,  " + //  -- 参保地
             "       psnSelfpay=cast(a.psn_cash_pay - a.fulamt_ownpay_amt as decimal(16,2)) ,  " + // -- 个人自付 TODO
@@ -56,7 +56,7 @@ public interface UpIdCollectionDao {
             "       (select rytj from batj_ba1 where zyh = #{patNo} and zycs = #{times})  as admWay,  " +  // 入院途径
             "       a.setl_time as  setl_end_date, " +  //结算时间
             "       a.ipt_med_type, a.hi_paymtd, " +
-            "       cast(fund_pay_sumamt as decimal(16,2) ) as  fund_pay_sumamt," + //
+            "       cast((fund_pay_sumamt-hosp_part_amt) as decimal(16,2) ) as  fund_pay_sumamt," + //
             "       cast(maf_pay as decimal(16,2)) as maf_pay," +
             "       psn_idet_type as  sp_psn_type " +
             "from t_si_setlinfo a," +
@@ -177,14 +177,6 @@ public interface UpIdCollectionDao {
             "  and admiss_times = #{times}")
     SetlinfoUpld setlinfo4(@Param("patNo") String patNo, @Param("times") Integer times);
 
-    @Select("select fund_payamt\n" +
-            "from t_si_setldetail\n" +
-            "where fund_pay_type = '999996'\n" +
-            "and pat_no = #{patNo}\n" +
-            "and times = #{times}\n" +
-            "and ledger_sn = #{ledgerSn}")
-    String advancePaidByTheHospital(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn);
-
     @Select("select (select si_code from zd_country_code where code = country)                    as ntly, " +
             "       dis_date                               as setl_end_date, " +
             "       admiss_date                            as setl_begn_date, " +

+ 1 - 1
src/main/java/thyyxxk/webserver/entity/medicalinsurance/manage/InstSetlLdgChkBrf.java

@@ -16,5 +16,5 @@ public class InstSetlLdgChkBrf {
     private BigDecimal acctPay;
     private BigDecimal fundPaySumamt;
     private BigDecimal psnCashPay;
-    private BigDecimal hospPay;
+    private BigDecimal hospPartAmt;
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/entity/medicalinsurance/query/BaseSetlStatistics.java

@@ -43,7 +43,7 @@ public class BaseSetlStatistics {
     /**
      * 医院支付
      */
-    private String hospPay;
+    private String hospPartAmt;
 
     /**
      * 个人账户支出

+ 0 - 2
src/main/java/thyyxxk/webserver/entity/medicalinsurance/setlinfo/SiSetlinfo.java

@@ -382,6 +382,4 @@ public class SiSetlinfo implements Serializable {
 	private String clrOptinsName;
 	@TableField(exist = false)
 	private String insuplcAdmdvsName;
-	@TableField(exist = false)
-	private Double hospPay;
 }

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/setllistupld/SetlinfoUpld.java

@@ -495,4 +495,9 @@ public class SetlinfoUpld implements Serializable {
      */
     private String mafPay;
 
+    /**
+     * 医院支付
+     * */
+    private String hospPartAmt;
+
 }

+ 0 - 6
src/main/java/thyyxxk/webserver/service/medicalinsurance/SetlListUpldService.java

@@ -332,12 +332,6 @@ public class SetlListUpldService {
             bldinfo.setBldCat(item.getBldCat()).setBldAmt(item.getBldAmt().toString()).setBldUnt(item.getBldUnit());
             upldCollection.getBldinfo().add(bldinfo);
         });
-
-        // 医保统筹基金支付	要减去 本院垫付
-        String advancePaidByTheHospital = dao.advancePaidByTheHospital(patNo, times, ledgerSn);
-        if (advancePaidByTheHospital != null) {
-            upldCollection.getSetlinfo().setFundPaySumamt(DecimalUtil.minus(upldCollection.getSetlinfo().getFundPaySumamt(), advancePaidByTheHospital));
-        }
         // 医疗类别为 生育
         List<String> birth = Arrays.asList("51", "52", "2106", "2107");
 

+ 5 - 5
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiManageService.java

@@ -179,8 +179,8 @@ public class SiManageService {
             medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
             acctpaysum = DecimalUtil.add(acctpaysum, brf.getAcctPay());
             fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
-            if (null != brf.getHospPay()) {
-                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay());
+            if (null != brf.getHospPartAmt()) {
+                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPartAmt());
             }
         }
         instStlLdgChk.setMedfeeSumamt(medfeesum);
@@ -245,9 +245,9 @@ public class SiManageService {
             medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
             psnCashPay = DecimalUtil.add(psnCashPay, brf.getPsnCashPay());
             fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
-            if (null != brf.getHospPay()) {
-                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay());
-                brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPay()));
+            if (null != brf.getHospPartAmt()) {
+                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPartAmt());
+                brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPartAmt()));
             }
         }
         insSetlDetlChk.setMedfeeSumamt(medfeesum);

+ 28 - 14
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiQueryService.java

@@ -1625,9 +1625,6 @@ public class SiQueryService {
 
         baseStatistics.forEach(itm -> {
             itm.setInsutypeName(Insutype.getName(itm.getInsutype()));
-            if (null != itm.getHospPay()) {
-                itm.setFundPaySumamt(DecimalUtil.minus(itm.getFundPaySumamt(), itm.getHospPay()));
-            }
             itm.setInsuplcAdmdvsName(redis.getRegionName(itm.getInsuplcAdmdvs()));
             String key;
             if (condition.getAdmdvsType() == 5 || condition.getAdmdvsType() == 6) {
@@ -1747,23 +1744,40 @@ public class SiQueryService {
     public ResultVo<List<SiSetlinfo>> selectSetldetailStatistics(SetlCondition condition) {
         String begntime = condition.getMonth() + "-01 00:00:00.000";
         String endtime = DateUtil.getMonthEndtime(condition.getMonth());
-        String insuplcAdmdvs;
-        if (condition.getAdmdvsType() == 5) {
-            insuplcAdmdvs = "430121";
-        } else if (condition.getAdmdvsType() == 6) {
-            insuplcAdmdvs = "430181";
-        } else {
-            insuplcAdmdvs = condition.getInsuplcAdmdvs().substring(0, 4) + "%";
+        String admdvsCondition;
+
+        switch (condition.getAdmdvsType()) {
+            case 1:
+                admdvsCondition = " and insuplc_admdvs='439900' ";
+                break;
+            case 2:
+                admdvsCondition = " and insuplc_admdvs like '4301%' and  insuplc_admdvs not in ('430121','430181') ";
+                break;
+            case 3:
+                admdvsCondition = " and insuplc_admdvs like '43%' and insuplc_admdvs not like '4301%' ";
+                break;
+            case 4:
+                admdvsCondition = " and insuplc_admdvs not like '43%' ";
+                break;
+            case 5:
+                admdvsCondition = " and insuplc_admdvs='430121' ";
+                break;
+            case 6:
+                admdvsCondition = " and insuplc_admdvs='430181' ";
+                break;
+            default:
+                admdvsCondition = "";
+                break;
         }
+
         String insutype = condition.getInsutype();
         if (StringUtil.isBlank(insutype)) {
             insutype = "%%";
         }
-        List<SiSetlinfo> list = setlinfoDao.selectMyList(condition.getSetlType(), insutype, insuplcAdmdvs, begntime, endtime);
+        List<SiSetlinfo> list = setlinfoDao.selectMyList(condition.getSetlType(), insutype, admdvsCondition, begntime, endtime);
         list.forEach(item -> {
-            if (null != item.getHospPay()) {
-                log.info("hosp: {}", item.getHospPay());
-                item.setFundPaySumamt(DecimalUtil.minusDouble(item.getFundPaySumamt(), item.getHospPay()));
+            if (null != item.getHospPartAmt()) {
+                item.setFundPaySumamt(DecimalUtil.minusDouble(item.getFundPaySumamt(), item.getHospPartAmt()));
             }
             item.setInsuplcAdmdvsName(redis.getRegionName(item.getInsuplcAdmdvs()));
             FilterUtil.filterCodeToName(item);

+ 31 - 24
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiZyService.java

@@ -26,6 +26,7 @@ import thyyxxk.webserver.service.externalhttp.SiZySrvc;
 import thyyxxk.webserver.service.inpatient.DismissService;
 import thyyxxk.webserver.utils.*;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 /**
@@ -456,38 +457,44 @@ public class SiZyService {
         }
         if (infcode == 0) {
             JSONObject setlinfo = result.getJSONObject(OUTPUT).getJSONObject("setlinfo");
-            SiSetlinfo setlEntity = JSONObject.parseObject(setlinfo.toJSONString(), SiSetlinfo.class);
-            setlEntity.setPatNo(p.getInpatientNo());
-            setlEntity.setTimes(p.getAdmissTimes());
-            setlEntity.setLedgerSn(p.getLedgerSn());
-            setlEntity.setStaffId(TokenUtil.getTokenUserId());
-            setlEntity.setRevoked(YesOrNo.NO.getCode());
-            setlEntity.setSetlType(ClrType.INPATIENT.getCode());
-            setlEntity.setInsuplcAdmdvs(preSetlmt.getInsuplcAdmdvs());
-            setlEntity.setBegntime(begntime);
-            setlEntity.setEndtime(p.getDismissDate());
-            setlEntity.setHiPaymtd(calculateHiPaymtd(setlEntity));
-            setlEntity.setMedinsType(MedInsTypeUtil.getMedInsType(setlEntity));
-            setlinfodao.insert(setlEntity);
-            setlinfodao.updateSiZyInfoSetlId(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(),
-                    setlEntity.getSetlId(), setlEntity.getMedinsSetlId(), input.getString("msgid"));
-            setlinfodao.updateApplySettled(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), YesOrNo.YES.getCode());
+            SiSetlinfo setlinfoEntity = JSONObject.parseObject(setlinfo.toJSONString(), SiSetlinfo.class);
+            setlinfoEntity.setPatNo(p.getInpatientNo());
+            setlinfoEntity.setTimes(p.getAdmissTimes());
+            setlinfoEntity.setLedgerSn(p.getLedgerSn());
+            setlinfoEntity.setStaffId(TokenUtil.getTokenUserId());
+            setlinfoEntity.setRevoked(YesOrNo.NO.getCode());
+            setlinfoEntity.setSetlType(ClrType.INPATIENT.getCode());
+            setlinfoEntity.setInsuplcAdmdvs(preSetlmt.getInsuplcAdmdvs());
+            setlinfoEntity.setBegntime(begntime);
+            setlinfoEntity.setEndtime(p.getDismissDate());
+            setlinfoEntity.setHiPaymtd(calculateHiPaymtd(setlinfoEntity));
+            setlinfoEntity.setMedinsType(MedInsTypeUtil.getMedInsType(setlinfoEntity));
             JSONArray setldetail = result.getJSONObject(OUTPUT).getJSONArray("setldetail");
+            BigDecimal hospitalPart = BigDecimal.ZERO;
             for (int i = 0; i < setldetail.size(); i++) {
                 SiSetldetail setldetailEntity = JSONObject.parseObject(setldetail.getJSONObject(i).toJSONString(), SiSetldetail.class);
                 setldetailEntity.setPatNo(p.getInpatientNo());
                 setldetailEntity.setTimes(p.getAdmissTimes());
                 setldetailEntity.setLedgerSn(p.getLedgerSn());
+                if (setldetailEntity.getFundPayType().equals("999996") || setldetailEntity.getSetlProcInfo().equals("999996")) {
+                    hospitalPart = hospitalPart.add(setldetailEntity.getFundPayamt());
+                }
                 setldetldao.insert(setldetailEntity);
             }
+            setlinfoEntity.setHospPartAmt(hospitalPart.doubleValue());
+            setlinfodao.insert(setlinfoEntity);
+            setlinfodao.updateSiZyInfoSetlId(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(),
+                    setlinfoEntity.getSetlId(), setlinfoEntity.getMedinsSetlId(), input.getString("msgid"));
+            setlinfodao.updateApplySettled(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), YesOrNo.YES.getCode());
+
             // 跨省异地数据不参与对账,对总账时无需统计进去。
-            if (setlEntity.getFundPaySumamt() > 0 && setlEntity.getInsuplcAdmdvs().startsWith("43")) {
+            if (setlinfoEntity.getFundPaySumamt() > 0 && setlinfoEntity.getInsuplcAdmdvs().startsWith("43")) {
                 InstStlLdgChk ldgChk = new InstStlLdgChk();
-                ldgChk.setInsutype(setlEntity.getInsutype());
-                ldgChk.setClrType(setlEntity.getClrType());
-                ldgChk.setSetlOptins(setlEntity.getClrOptins());
-                ldgChk.setStmtBegndate(setlEntity.getSetlTime());
-                ldgChk.setStmtEnddate(setlEntity.getSetlTime());
+                ldgChk.setInsutype(setlinfoEntity.getInsutype());
+                ldgChk.setClrType(setlinfoEntity.getClrType());
+                ldgChk.setSetlOptins(setlinfoEntity.getClrOptins());
+                ldgChk.setStmtBegndate(setlinfoEntity.getSetlTime());
+                ldgChk.setStmtEnddate(setlinfoEntity.getSetlTime());
                 ResultVo<String> totalLedgerCheck = manageService.institutionSettlementLedgerCheck(ldgChk);
                 if (totalLedgerCheck.getCode() != ExceptionEnum.SUCCESS.getCode()) {
                     InsSetlDetlChk detlChk = new InsSetlDetlChk();
@@ -502,7 +509,7 @@ public class SiZyService {
                         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, detailLedgerCheck.getMessage());
                     }
                     for (InsSetlDetlChkRslt insSetlDetlChkRslt : detailLedgerCheck.getData()) {
-                        if (Objects.equals(insSetlDetlChkRslt.getSetlId(), setlEntity.getSetlId())) {
+                        if (Objects.equals(insSetlDetlChkRslt.getSetlId(), setlinfoEntity.getSetlId())) {
                             if (!Objects.equals(insSetlDetlChkRslt.getStmtRslt(), "0")) {
                                 revokeSettlement(p);
                                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, insSetlDetlChkRslt.getMemo());
@@ -512,7 +519,7 @@ public class SiZyService {
                     }
                 }
             }
-            queryService.saveCumInfo(setlEntity);
+            queryService.saveCumInfo(setlinfoEntity);
             MedinsSettleFee settleFee = new MedinsSettleFee();
             if (p.getMidSetl()) {
                 settleFee.setZjdzDatetime(p.getZjdzDatetime());

+ 1 - 1
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -108,10 +108,10 @@ public class YiZhuLuRuServer {
         if (StringUtil.notBlank(param.getActOrderNo())) {
             qw.eq("act_order_no", param.getActOrderNo());
         }
-
         if (StringUtil.notBlank(param.getFrequCode())) {
             qw.eq("frequ_code", param.getFrequCode());
         }
+
         List<Integer> zhaungTai = Arrays.asList(1, 2, 5);
 
         if (zhaungTai.contains(param.getZhuangTai())) {