فهرست منبع

优化费用清单

lighter 5 ماه پیش
والد
کامیت
604d7e5c84

+ 32 - 5
src/main/java/thyyxxk/webserver/dao/his/inpatient/ChargeListDao.java

@@ -40,12 +40,11 @@ public interface ChargeListDao {
 
     @Select("execute zy_receive_drug #{patNo},#{times},#{patNo},'0';" +
             "execute zy_receive_one #{patNo},#{times},#{patNo},'0';")
-    List<ChargeItem> receiveCharges(String patNo, int times);
+    void receiveCharges(String patNo, int times);
 
     @Select("execute dbo.zy_cxtj_mxqd_new #{patNo},#{times}")
     List<ChargeItem> selectChargeList(String patNo, int times);
 
-    
     @Select("<script>" +
             "select " +
             "code=case when isnull(nullif(serial,''),'00')='00' then " +
@@ -68,12 +67,40 @@ public interface ChargeListDao {
             "(select d.bill_item_zy from zd_charge_item d where d.code=charge_code_mx) else " +
             "(select max(d.bill_item_zy) from yp_zd_dict d where d.code=charge_code_mx) end " +
             "from zy_detail_charge a where inpatient_no=#{patNo} and admiss_times=#{times} " +
+            "and trans_flag_yb!=2 and charge_amount!=0 " +
             "<if test=\"ledgerSn != null \">" +
-            "and ledger_sn=#{ledgerSn} and charge_amount!=0 " +
+            "and ledger_sn=#{ledgerSn} " +
             "</if>" +
-            "and trans_flag_yb!=2 " +
             "</script>")
-    List<ChargeItem> getChargeList(PatOverview overview);
+    List<ChargeItem> getChargeListWithChargeDate(PatOverview overview);
+    
+    @Select("select " +
+            "code,name,specification,unit,price,billItemCode,execDept, " +
+            "quantity=sum(quantity),cost=sum(cost) " +
+            "from (select * from ( " +
+            "select code=case when isnull(nullif(a.serial,''),'00')='00' then " +
+            "(select national_code from zd_charge_item d where d.code=charge_code_mx) else " +
+            "(select max(national_code) from yp_zd_dict d where d.code=charge_code_mx) end, " +
+            "name=case when isnull(nullif(a.serial,''),'00')='00' then " +
+            "(select name from zd_charge_item d where d.code=charge_code_mx) else " +
+            "(select max(name) from yp_zd_dict d where d.code=charge_code_mx) end, " +
+            "specification=case when isnull(nullif(a.serial,''),'00')='00' then null else " +
+            "(select max(specification) from yp_zd_dict d where d.code=charge_code_mx) end, " +
+            "unit=case when isnull(nullif(a.serial,''),'00')='00' then " +
+            "(select d.charge_unit from zd_charge_item d where d.code=charge_code_mx) else " +
+            "(select name from yp_zd_unit e where e.code= " +
+            "(select d.pack_unit from yp_zd_dict d where d.code=charge_code_mx and d.serial=a.serial)) end, " +
+            "price=abs(round(charge_fee/case when charge_amount=0 then 1 else charge_amount end,2)), " +
+            "quantity=(a.charge_amount),cost=(charge_fee), " +
+            "execDept=(select d.name from zd_unit_code d where d.code= " +
+            "(case when isnull(exec_unit,'')='' then ward_code else exec_unit end)), " +
+            "billItemCode=case when isnull(nullif(a.serial,''),'00')='00' then " +
+            "(select d.bill_item_zy from zd_charge_item d where d.code=charge_code_mx) else " +
+            "(select max(d.bill_item_zy) from yp_zd_dict d where d.code=charge_code_mx) end " +
+            "from zy_detail_charge a where inpatient_no=#{patNo} and admiss_times=#{times} " +
+            "and trans_flag_yb!=2 and charge_amount!=0) temp) res group by " +
+            "code, name, specification, unit, price, billItemCode, execDept ")
+    List<ChargeItem> getChargeListWithoutChargeDate(PatOverview overview);
 
     @Select("select count(1) from zy_actpatient where inpatient_no=#{patNo} and admiss_times=#{times}")
     Integer isDischargedPatients(PatOverview overview);

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/chargelist/PatOverview.java

@@ -12,6 +12,7 @@ public class PatOverview {
     private String patNo;
     private Integer times;
     private Integer ledgerSn;
+    private Boolean needChargeDate;
     private BigDecimal totalCharge;
     private String name;
     @DateTimeFormat(pattern = "yyyy-MM-dd")
@@ -26,4 +27,8 @@ public class PatOverview {
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date enddate;
+
+    public Boolean needChargeDate() {
+        return null != needChargeDate && needChargeDate;
+    }
 }

+ 6 - 16
src/main/java/thyyxxk/webserver/service/inpatient/ChargeListService.java

@@ -19,12 +19,8 @@ import thyyxxk.webserver.utils.ResultVoUtil;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.time.Instant;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
 import java.time.temporal.ChronoUnit;
-import java.time.temporal.Temporal;
 import java.util.*;
 
 @Slf4j
@@ -78,22 +74,16 @@ public class ChargeListService {
         return (int) (daysBetween + 1);
     }
 
-    public Map<String, Object> selectChargeList(PatOverview overview) {
-//        List<ChargeItem> chargeList;
-//        if (dao.isDischargedPatients(overview.getPatNo(), overview.getTimes()) > 0) {
-//            chargeList = dao.selectChargeList(overview.getPatNo(), overview.getTimes());
-//        } else {
-//            chargeList = dao.selectChargeList2(overview.getPatNo(), overview.getTimes());
-//        }
-
-        if (dao.isDischargedPatients(overview) > 0) {
-            dao.receiveCharges(overview.getPatNo(), overview.getTimes());
+    public Map<String, Object> selectChargeList(PatOverview v) {
+        if (dao.isDischargedPatients(v) > 0) {
+            dao.receiveCharges(v.getPatNo(), v.getTimes());
         }
-        List<ChargeItem> chargeList = dao.getChargeList(overview);
+        List<ChargeItem> chargeList = v.needChargeDate()
+                ? dao.getChargeListWithChargeDate(v)
+                : dao.getChargeListWithoutChargeDate(v);
         for (ChargeItem item : chargeList) {
             item.setBillItemName(redis.getBillItemName(item.getBillItemCode()));
         }
-
         Map<String, List<ChargeItem>> chargeListMap = new HashMap<>();
         Map<String, BigDecimal> sumsTempMap = new HashMap<>();
         sumsTempMap.put("总计", BigDecimal.ZERO);