Browse Source

修复费用计算存在的问题。

lighter 3 years ago
parent
commit
be71e8e627

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>10.8.2</version>
+    <version>10.8.4</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 13 - 23
src/main/java/thyyxxk/webserver/dao/his/yibao/DismissDao.java

@@ -331,10 +331,10 @@ public interface DismissDao {
             "and ledger_sn=#{ledgerSn} and isnull(charge_status,'1')!='1' and isnull(infant_flag,'0')!='1' " +
             "and charge_date>=#{begntime} and charge_date<=#{endtime}")
     String selectAdultFee(@Param("patNo") String patNo,
-                           @Param("times") int times,
-                           @Param("ledgerSn") int ledgerSn,
-                           @Param("begntime") Date begntime,
-                           @Param("endtime") Date endtime);
+                          @Param("times") int times,
+                          @Param("ledgerSn") int ledgerSn,
+                          @Param("begntime") Date begntime,
+                          @Param("endtime") Date endtime);
 
 
     @Update("update zy_actpatient set total_charge=#{map.total},charge1=#{map.001},charge2=#{map.002}, " +
@@ -349,29 +349,19 @@ public interface DismissDao {
                          @Param("times") int times,
                          @Param("map") Map<String, String> map);
 
-    @Select("select b.bill_item_zy as bill_code, ledger_fee=sum(a.charge_fee) " +
-            "from zy_detail_charge a, zd_charge_item b " +
-            "where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and " +
-            "a.ledger_sn=#{ledgerSn} and a.charge_status!='1' and isnull(a.infant_flag,'0')!='1' and " +
-            "a.charge_date>=#{begntime} and a.charge_date<=#{endtime} and " +
-            "a.charge_code=b.code group by b.bill_item_zy, a.ledger_sn")
-    List<ReceiptFee> selectAdultReceiptFees(@Param("patNo") String patNo,
-                                            @Param("times") int times,
-                                            @Param("ledgerSn") int ledgerSn,
-                                            @Param("begntime") Date begntime,
-                                            @Param("endtime") Date endtime);
-
-    @Select("select b.bill_item_zy as bill_code, ledger_fee=sum(a.charge_fee) " +
+    @Select("select b.bill_item_zy as bill_code, ledger_fee=sum(a.charge_fee), " +
+            "infant_fee=sum(case when isnull(infant_flag,0)=1 then charge_fee else 0 end), " +
+            "adult_fee=sum(case when isnull(infant_flag,0)!=1 then charge_fee else 0 end) " +
             "from zy_detail_charge a, zd_charge_item b " +
             "where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and " +
-            "a.ledger_sn=#{ledgerSn} and a.charge_status!='1' and isnull(a.infant_flag,'0')='1' and " +
+            "a.ledger_sn=#{ledgerSn} and a.charge_status!='1' and " +
             "a.charge_date>=#{begntime} and a.charge_date<=#{endtime} and " +
             "a.charge_code=b.code group by b.bill_item_zy, a.ledger_sn")
-    List<ReceiptFee> selectInfantReceiptFees(@Param("patNo") String patNo,
-                                            @Param("times") int times,
-                                            @Param("ledgerSn") int ledgerSn,
-                                            @Param("begntime") Date begntime,
-                                            @Param("endtime") Date endtime);
+    List<ReceiptFee> selectLedgerFees(@Param("patNo") String patNo,
+                                      @Param("times") int times,
+                                      @Param("ledgerSn") int ledgerSn,
+                                      @Param("begntime") Date begntime,
+                                      @Param("endtime") Date endtime);
 
     @Select("select code from zy_bill_item")
     List<String> selectBillCodes();

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/yibao/dismiss/ReceiptFee.java

@@ -6,4 +6,6 @@ import lombok.Data;
 public class ReceiptFee {
     private String billCode;
     private String ledgerFee;
+    private String infantFee;
+    private String adultFee;
 }

+ 23 - 19
src/main/java/thyyxxk/webserver/service/yibao/DismissService.java

@@ -16,6 +16,7 @@ import thyyxxk.webserver.entity.yibao.patient.Patient;
 import thyyxxk.webserver.service.externalhttp.SiZySrvc;
 import thyyxxk.webserver.utils.*;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 /**
@@ -286,32 +287,35 @@ public class DismissService {
     }
 
     private ReceiptEntity dismissFeeAnalyse(String patNo, int times, int ledgerSn, Date begntime, Date endtime) {
+        Map<String, String> ledgerMap = initReceiptMap();
+        Map<String, String> infantMap = initReceiptMap();
+        Map<String, String> adultMap = initReceiptMap();
+
+        List<ReceiptFee> ledgerFees = dao.selectLedgerFees(patNo, times, ledgerSn, begntime, endtime);
+        if (null == ledgerFees) {
+            ledgerFees = new ArrayList<>();
+        }
+        for (ReceiptFee fee : ledgerFees) {
+            ledgerMap.replace(fee.getBillCode(), fee.getLedgerFee());
+            ledgerMap.replace("total", DecimalUtil.add(ledgerMap.get("total"), fee.getLedgerFee()));
+
+            infantMap.replace(fee.getBillCode(), fee.getInfantFee());
+            infantMap.replace("total", DecimalUtil.add(infantMap.get("total"), fee.getInfantFee()));
+
+            adultMap.replace(fee.getBillCode(), fee.getAdultFee());
+            adultMap.replace("total", DecimalUtil.add(ledgerMap.get("total"), fee.getAdultFee()));
+
+        }
+        dao.updateZyLedgerFileCharges(patNo, times, ledgerSn, ledgerMap);
+
         ReceiptEntity entity = new ReceiptEntity();
-        String infantfee = dao.selectInfantFee(patNo, times, ledgerSn, begntime, endtime);
-        if (StringUtil.notBlank(infantfee) && DecimalUtil.compare(infantfee, "0") == 1) {
-            Map<String, String> infantMap = initReceiptMap();
-            List<ReceiptFee> infantReceipts = dao.selectInfantReceiptFees(patNo, times, ledgerSn, begntime, endtime);
-            for (ReceiptFee fee : infantReceipts) {
-                infantMap.replace(fee.getBillCode(), fee.getLedgerFee());
-            }
-            infantMap.replace("total", infantfee);
+        if (DecimalUtil.compare(infantMap.get("total"), "0") == 1) {
             String patNo1 = patNo + "$1";
             String patNo6 = patNo + "$6";
             dao.updateInfantfee(patNo1, patNo6, times, infantMap);
             entity.setInfant(infantMap);
         }
 
-        Map<String, String> adultMap = initReceiptMap();
-        String adultfee = dao.selectAdultFee(patNo, times, ledgerSn, begntime, endtime);
-        List<ReceiptFee> adultReceipts = dao.selectAdultReceiptFees(patNo, times, ledgerSn, begntime, endtime);
-        if (null == adultReceipts) {
-            adultReceipts = new ArrayList<>();
-        }
-        for (ReceiptFee fee : adultReceipts) {
-            adultMap.replace(fee.getBillCode(), fee.getLedgerFee());
-        }
-        adultMap.replace("total", adultfee);
-        dao.updateZyLedgerFileCharges(patNo, times, ledgerSn, adultMap);
         String balance = dao.selectBalance(patNo, times, ledgerSn);
         dao.updateZyActpatientCharges(patNo, balance, adultMap);
         entity.setAdult(adultMap);