Browse Source

拆分获取收费明细的存储过程并在后台分页。

lighter 4 năm trước cách đây
mục cha
commit
42e7e30f33

+ 0 - 5
src/main/java/thyyxxk/webserver/dao/his/yibao/PatientDao.java

@@ -366,9 +366,4 @@ public interface PatientDao {
             "</foreach>" +
             "</script>")
     void insertDisDiags(@Param("staffId") String staffId, @Param("list") List<ZyInYbDiag> list);
-
-    @Update("update zy_detail_charge set trans_flag_yb=0 where inpatient_no=#{inpatientNo} " +
-            "and admiss_times=#{admissTimes} and trans_flag_yb=3")
-    void fixWrongTransFlag(@Param("inpatientNo") String inpatientNo,
-                           @Param("admissTimes") Integer admissTimes);
 }

+ 208 - 13
src/main/java/thyyxxk/webserver/dao/his/yibao/Routines.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.dao.his.yibao;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -7,7 +8,6 @@ import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.pojo.yibao.patient.FeePojo;
 
 import java.util.Date;
-import java.util.List;
 
 @Mapper
 public interface Routines {
@@ -19,23 +19,218 @@ public interface Routines {
     @Update("EXEC zy_calc_balance #{zyh}, #{times}, #{ledgerSn}")
     void hisRecount(@Param("zyh") String zyh, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn);
 
-    @Select("exec p_syb_xmlist #{inpatientNo}, #{admissTimes}")
-    List<FeePojo> getSybProjectFee(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+    @Select("select * from (" +
+            "select a.detail_sn,a.charge_date,a.charge_code_mx as his_item_code, " +
+            "d.hnsyb_item_code as yb_code,a.charge_fee,price=b.charge_amount,a.charge_amount, " +
+            "b.name as his_item_name,c.hnsyb_stat_type, " +
+            "yb_self_flag=isnull(a.yb_self_flag,0) " +
+            "from zd_charge_item b,zy_bill_item c,zy_detail_charge a with (nolock) " +
+            "left join (select distinct * from zd_charge_item_hnsyb) d on a.charge_code_mx=d.hosp_code " +
+            "where a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and a.ledger_sn=#{ledgerSn} and " +
+            "a.charge_code_mx=b.code and a.charge_status>1 and a.infant_flag=0 and b.bill_item_zy=c.code and " +
+            "(a.charge_code<>'BILL01' and a.charge_code<>'BILL05') and isnull(a.trans_flag_yb,'0')='0' " +
+            "union " +
+            "select a.detail_sn,a.charge_date,a.charge_code_mx as his_item_code, " +
+            "d.hnsyb_item_code as yb_code,a.charge_fee,price=b.charge_amount,a.charge_amount, " +
+            "b.name as his_item_name,c.hnsyb_stat_type, " +
+            "yb_self_flag=isnull(a.yb_self_flag,0) " +
+            "from zd_charge_item b,zy_bill_item c,zy_detail_charge a with (nolock) " +
+            "left join (select distinct * from zd_charge_item_hnsyb) d on a.charge_code_mx=d.hosp_code " +
+            "where a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and a.ledger_sn=#{ledgerSn} and " +
+            "a.charge_code_mx=b.code and a.charge_status>1 and a.infant_flag=0 and isnull(a.serial,'00')='00' and " +
+            "b.bill_item_zy=c.code and (a.charge_code='BILL01' or a.charge_code='BILL05') and a.order_no<5 and " +
+            "isnull(a.trans_flag_yb,'0')='0'" +
+            ") temp")
+    IPage<FeePojo> selectHnsybGsProjectFee(IPage<FeePojo> iPage,
+                                           @Param("inpatientNo") String inpatientNo,
+                                           @Param("admissTimes") Integer admissTimes,
+                                           @Param("ledgerSn") Integer ledgerSn);
 
-    @Select("exec p_hnsyb_xmlist #{inpatientNo}, #{admissTimes}")
-    List<FeePojo> getHnsybProjectFee(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+    @Select("select * from (" +
+            "select a.detail_sn,a.charge_date,a.charge_code_mx as his_item_code, " +
+            "d.hnsyb_item_code as yb_code,a.charge_fee,price=b.charge_amount,a.charge_amount, " +
+            "b.name as his_item_name,c.hnsyb_stat_type,yb_self_flag=isnull(a.yb_self_flag,0) " +
+            "from zy_detail_charge a with (nolock),zd_charge_item b,zy_bill_item c,(select distinct * from zd_charge_item_hnsyb) d " +
+            "where a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and a.ledger_sn=#{ledgerSn} and " +
+            "a.charge_code_mx=b.code and a.charge_status>1 and a.infant_flag=0 and b.bill_item_zy=c.code and " +
+            "a.charge_code_mx*=d.hosp_code and (a.charge_code<>'BILL01' and a.charge_code<>'BILL05') and " +
+            "isnull(a.trans_flag_yb,'0')='0' " +
+            "union " +
+            "select a.detail_sn,a.charge_date,a.charge_code_mx as his_item_code, " +
+            "d.hnsyb_item_code as yb_code,a.charge_fee,price=b.charge_amount,a.charge_amount, " +
+            "b.name as his_item_name,c.hnsyb_stat_type,yb_self_flag=isnull(a.yb_self_flag,0) " +
+            "from zy_detail_charge a with (nolock),zd_charge_item b,zy_bill_item c,(select distinct * from zd_charge_item_hnsyb) d " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and a.ledger_sn=#{ledgerSn} and " +
+            "a.charge_code_mx=b.code and a.charge_status>1 and a.infant_flag=0 and isnull(a.serial,'00')='00' and " +
+            "b.bill_item_zy=c.code and a.charge_code_mx*=d.hosp_code and " +
+            "(a.charge_code='BILL01' or a.charge_code='BILL05') and a.order_no<5 and " +
+            "isnull(a.trans_flag_yb,'0')='0'" +
+            ") temp")
+    IPage<FeePojo> selectHnsybProjectFee(IPage<FeePojo> iPage,
+                                           @Param("inpatientNo") String inpatientNo,
+                                           @Param("admissTimes") Integer admissTimes,
+                                           @Param("ledgerSn") Integer ledgerSn);
 
-    @Select("exec p_xnh_xmlist #{inpatientNo}, #{admissTimes}")
-    List<FeePojo> getXnhProjectFee(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+    @Select("select a.detail_sn,a.charge_date,a.charge_code_mx as his_item_code, " +
+            "g.hnsyb_item_code as yb_code, " +
+            "medi_item_type=(select yp_type from yp_zd_drug_kind where code=b.drug_kind), " +
+            "b.name as his_item_name,b.retprice as price, " +
+            "a.charge_amount,a.charge_fee,f.hnsyb_stat_type, " +
+            "yb_self_flag=isnull(a.yb_self_flag,0) " +
+            "from yp_zd_dict b left join yp_zd_dosage c on b.dosage=c.code " +
+            "left join yp_zd_manufactory d on b.manu_code=d.code, " +
+            "zy_bill_item f,zy_detail_charge a with (nolock) " +
+            "left join (select distinct * from zd_charge_item_hnsyb) g " +
+            "on a.charge_code_mx=g.hosp_code " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and " +
+            "a.ledger_sn=#{ledgerSn} and a.charge_status>1 and " +
+            "isnull(a.serial,'00')<>'00' and a.charge_code_mx=b.code and " +
+            "a.serial=b.serial and a.infant_flag=0 and " +
+            "b.bill_item_zy=f.code and isnull(a.trans_flag_yb,'0')='0'")
+    IPage<FeePojo> selectHnsybGsMedicineFee(IPage<FeePojo> iPage,
+                                         @Param("inpatientNo") String inpatientNo,
+                                         @Param("admissTimes") Integer admissTimes,
+                                         @Param("ledgerSn") Integer ledgerSn);
 
-    @Select("exec p_syb_yplist #{inpatientNo}, #{admissTimes}")
-    List<FeePojo> getSybMedicineFee(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+    @Select("select a.detail_sn,a.charge_date,a.charge_code_mx as his_item_code, " +
+            "g.hnsyb_item_code as yb_code, " +
+            "medi_item_type=(select yp_type from yp_zd_drug_kind where code=b.drug_kind), " +
+            "b.name as his_item_name,b.retprice as price, " +
+            "a.charge_amount,a.charge_fee,f.hnsyb_stat_type,yb_self_flag=isnull(a.yb_self_flag,0) " +
+            "from yp_zd_dict b left join yp_zd_dosage c on b.dosage=c.code " +
+            "left join yp_zd_manufactory d on b.manu_code=d.code, " +
+            "zy_bill_item f,zy_detail_charge a with (nolock) " +
+            "left join (select distinct * from zd_charge_item_hnsyb) g on a.charge_code_mx=g.hosp_code " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and a.ledger_sn=#{ledgerSn} and " +
+            "a.charge_status>1 and isnull(a.serial,'00')<>'00' and a.charge_code_mx=b.code and " +
+            "a.serial=b.serial and a.infant_flag=0 and b.bill_item_zy=f.code and " +
+            "isnull(a.trans_flag_yb,'0')='0'")
+    IPage<FeePojo> selectHnsybMedicineFee(IPage<FeePojo> iPage,
+                                            @Param("inpatientNo") String inpatientNo,
+                                            @Param("admissTimes") Integer admissTimes,
+                                            @Param("ledgerSn") Integer ledgerSn);
 
-    @Select("exec p_hnsyb_yplist #{inpatientNo}, #{admissTimes}")
-    List<FeePojo> getHnsybMedicineFee(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+    @Select("select * from (" +
+            "select a.detail_sn,charge_date,his_item_code=b.code,charge_fee=sum(a.charge_fee), " +
+            "his_item_name=max(c.his_name),price=max(b.charge_amount), " +
+            "yb_bill_code=isnull(max(c.yb_bill_code),''),yb_code=isnull(max(c.yb_code),''), " +
+            "yb_self_flag=isnull(a.yb_self_flag,0),yb_class=isnull(max(c.yb_class),''), " +
+            "charge_amount=cast(sum(isnull(a.charge_amount,1)) as real ) " +
+            "from zy_detail_charge a,zd_charge_item b, " +
+            "(select charge_code=his_code,max(his_name) his_name, " +
+            "yb_code=max(yb_code),yb_bill_code=max(charge_type),yb_class=max(charge_category),max(audit_date) sh_date " +
+            "from zd_cssyb_xmdz group by his_code) c " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and a.ledger_sn=#{ledgerSn} and " +
+            "a.charge_code=b.code and a.charge_status>1 and " +
+            "(case when isnull(a.serial,'')='' or isnull(a.serial,'')='00' then '00' else a.serial end)='00' and " +
+            "b.code*=c.charge_code and isnull(a.trans_flag_yb,'0')='0' and isnull(a.infant_flag,'0')='0' and " +
+            "charge_date<'2018-09-01' " +
+            "group by a.inpatient_no,a.admiss_times,a.ledger_sn,detail_sn,a.charge_date, " +
+            "b.code,isnull(trans_flag_yb,''),yb_self_flag " +
+            "union all " +
+            "select detail_sn=a.detail_sn,charge_date,his_item_code=b.code,charge_fee=sum(a.charge_fee), " +
+            "his_item_name=max(c.his_name),price=max(b.charge_amount), " +
+            "yb_bill_code=isnull(max(c.yb_bill_code),''),yb_code=isnull(max(c.yb_code),''), " +
+            "yb_self_flag=isnull(a.yb_self_flag,0),yb_class=isnull(max(c.yb_class),''), " +
+            "charge_amount=cast(sum(isnull(a.charge_amount,1)) as real ) " +
+            "from zy_detail_charge a,zd_charge_item b, " +
+            "(select charge_code=his_code,max(his_name) his_name, " +
+            "yb_code=max(yb_code),yb_bill_code=max(charge_type),yb_class=max(charge_category),max(audit_date) sh_date " +
+            "from zd_cssyb_xmdz group by his_code) c " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and a.ledger_sn=#{ledgerSn} and " +
+            "a.charge_code=b.code and a.charge_status>1 and " +
+            "(case when isnull(a.serial,'')='' or isnull(a.serial,'')='00' then '00' else a.serial end)='00' and " +
+            "b.code*=c.charge_code and isnull(a.trans_flag_yb,'0')='0' and isnull(a.infant_flag,'0')='0' and " +
+            "charge_date>='2018-09-01' " +
+            "group by a.inpatient_no,a.admiss_times,a.ledger_sn,detail_sn,a.charge_date, " +
+            "b.code,isnull(trans_flag_yb,''),yb_self_flag" +
+            ") temp")
+    IPage<FeePojo> selectCssybProjectFee(IPage<FeePojo> iPage,
+                                          @Param("inpatientNo") String inpatientNo,
+                                          @Param("admissTimes") Integer admissTimes,
+                                          @Param("ledgerSn") Integer ledgerSn);
 
-    @Select("exec p_xnh_yplist #{inpatientNo}, #{admissTimes}")
-    List<FeePojo> getXnhMedicineFee(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+    @Select("select * from (" +
+            "select detail_sn=a.detail_sn,charge_date, " +
+            "his_item_code=case b.code  when '00983' then '30033' else b.code end, " +
+            "price=max(b.pack_retprice),charge_fee=sum(a.charge_fee), " +
+            "charge_amount=cast (sum(a.charge_amount) as real),his_item_name=max(b.name )    , " +
+            "yb_bill_code=isnull(max(c.yb_bill_code),''),yb_code=isnull(max(c.yb_code),''), " +
+            "yb_self_flag=isnull(a.yb_self_flag,0),yb_class=isnull(max(c.yb_class),'') " +
+            "from   zy_detail_charge a,yp_zd_dict b, " +
+            "(select charge_code=his_code,yb_name=max(his_name), " +
+            "yb_code=max(yb_code),yb_bill_code=max(charge_type), " +
+            "yb_class=max(charge_category),max(audit_date) sh_date " +
+            "from zd_cssyb_xmdz group by his_code) c " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and " +
+            "a.ledger_sn=#{ledgerSn} and a.charge_status>'1' and " +
+            "a.charge_code_mx=b.code and a.serial=b.serial and " +
+            "a.charge_code_mx *=c.charge_code and isnull(a.serial,'')<>'00' and " +
+            "isnull(a.trans_flag_yb,'0')='0' and isnull(c.yb_code,'')<>'' " +
+            "and isnull(a.infant_flag,'0')='0' and charge_date<'2018-09-01' " +
+            "group by a.inpatient_no,a.admiss_times,a.ledger_sn,detail_sn,charge_date, " +
+            "b.code,b.specification,trans_flag_yb,yb_self_flag " +
+            "union all " +
+            "select detail_sn=a.detail_sn,charge_date, " +
+            "his_item_code=case b.code  when '00983' then '30033' else b.code end, " +
+            "price=max(b.pack_retprice),charge_fee=sum(a.charge_fee), " +
+            "charge_amount=cast (sum(a.charge_amount) as real),his_item_name=max(b.name )    , " +
+            "yb_bill_code=isnull(max(c.yb_bill_code),''),yb_code=isnull(max(c.yb_code),''), " +
+            "yb_self_flag=isnull(a.yb_self_flag,0),yb_class=isnull(max(c.yb_class),'') " +
+            "from   zy_detail_charge a,yp_zd_dict b, " +
+            "(select charge_code=his_code,max(his_name) yb_name, " +
+            "yb_code=max(yb_code),yb_bill_code=max(charge_type),yb_class=max(charge_category),max(audit_date) sh_date " +
+            "from zd_cssyb_xmdz group by his_code) c " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and " +
+            "a.ledger_sn=#{ledgerSn} and a.charge_status>'1' and " +
+            "a.charge_code_mx=b.code and a.serial=b.serial and " +
+            "a.charge_code_mx *=c.charge_code and isnull(a.serial,'')<>'00' and " +
+            "isnull(a.trans_flag_yb,'0')='0' and isnull(c.yb_code,'')<>'' " +
+            "and isnull(a.infant_flag,'0')='0' and charge_date>='2018-09-01' " +
+            "group by a.inpatient_no,a.admiss_times,a.ledger_sn,detail_sn,charge_date, " +
+            "b.code,b.specification,trans_flag_yb,yb_self_flag" +
+            ") temp")
+    IPage<FeePojo> selectCssybMedicineFee(IPage<FeePojo> iPage,
+                                          @Param("inpatientNo") String inpatientNo,
+                                          @Param("admissTimes") Integer admissTimes,
+                                          @Param("ledgerSn") Integer ledgerSn);
+
+    @Select("select a.detail_sn,charge_date,his_item_code=b.code, " +
+            "charge_fee=sum(a.charge_fee),his_item_name=max(b.name), " +
+            "yb_name=isnull(max(c.hnsyb_item_name ),b.xnh_name), " +
+            "price=max(b.charge_amount), " +
+            "yb_code=isnull(max(c.hnsyb_item_code),b.xnh_code), " +
+            "charge_amount=sum(isnull(a.charge_amount,1)) " +
+            "from zy_detail_charge a left join zd_charge_item_hnsyb c on a.charge_code=c.hosp_code,zd_charge_item b " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and " +
+            "a.ledger_sn=#{ledgerSn} and a.charge_code=b.code and " +
+            "a.charge_status>1 and " +
+            "(case when isnull(a.serial,'')='' then '00' else a.serial end)='00' and " +
+            "isnull(a.trans_flag_yb,'0')='0' " +
+            "group by a.inpatient_no,a.admiss_times,a.ledger_sn,detail_sn,charge_date,b.code, " +
+            "isnull(trans_flag_yb,''),c.hnsyb_item_name,c.hosp_code,b.xnh_name,b.xnh_code")
+    IPage<FeePojo> selectXnhybProjectFee(IPage<FeePojo> iPage,
+                                         @Param("inpatientNo") String inpatientNo,
+                                         @Param("admissTimes") Integer admissTimes,
+                                         @Param("ledgerSn") Integer ledgerSn);
+
+    @Select("select a.detail_sn,charge_date,his_item_code=b.code, " +
+            "charge_fee=sum(a.charge_fee),his_item_name=max(b.name ), " +
+            "yb_name=isnull(max(c.hnsyb_item_name ),b.xnh_name), " +
+            "price=max(b.pack_retprice), " +
+            "yb_code=isnull(max(c.hnsyb_item_code),b.xnh_code), " +
+            "charge_amount=sum(a.charge_amount) " +
+            "from   zy_detail_charge a left join zd_charge_item_hnsyb c on a.charge_code_mx=c.hosp_code,yp_zd_dict b " +
+            "where  a.inpatient_no=#{inpatientNo} and a.admiss_times=#{admissTimes} and " +
+            "a.ledger_sn=#{ledgerSn} and a.charge_status>'1' and " +
+            "a.charge_code_mx=b.code and a.serial=b.serial and " +
+            "isnull(a.trans_flag_yb,'0')='0' " +
+            "group by a.inpatient_no,a.admiss_times,a.ledger_sn,detail_sn,charge_date,b.code, " +
+            "b.specification,trans_flag_yb,c.hnsyb_item_code,c.hnsyb_item_name,b.xnh_name,b.xnh_code")
+    IPage<FeePojo> selectXnhybMedicineFee(IPage<FeePojo> iPage,
+                                          @Param("inpatientNo") String inpatientNo,
+                                          @Param("admissTimes") Integer admissTimes,
+                                          @Param("ledgerSn") Integer ledgerSn);
 
     @Update("update zy_actpatient set yb_register_date=#{date} where inpatient_no=#{inpatientNo}")
     void updateYbRegisterDate(@Param("inpatientNo") String inpatientNo, @Param("date") Date date);

+ 11 - 35
src/main/java/thyyxxk/webserver/pojo/yibao/patient/FeePojo.java

@@ -1,49 +1,25 @@
 package thyyxxk.webserver.pojo.yibao.patient;
 
 import lombok.Data;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.util.Date;
 
 @Data
 public class FeePojo {
     private Integer detailSn;
-    private String chargeDate;
-    private String chargeCode;
-    private String hnsybItemCode;
+    private Date chargeDate;
+    private String hisItemCode;
     private String ybCode;
     private String chargeFee;
     private String price;
-    private String amount;
-    private String name;
-    private String statusFlag;
-    private String chargeCodeMx;
-    private String retprice;
     private String chargeAmount;
+    private String hisItemName;
+    private String hnsybStatType;
+    private String ybSelfFlag;
 
-    public String getChargeDate() {
-        return isNull(chargeDate) ? "" : chargeDate.split("\\.")[0];
-    }
-
-    public String getChargeCode() {
-        return isNull(chargeCode) ? chargeCodeMx : chargeCode;
-    }
-
-    public String getYbCode() {
-        return isNull(ybCode) ? hnsybItemCode : ybCode;
-    }
-
-    public String getAmount() {
-        return isNull(amount) ? chargeAmount : amount;
-    }
-
-    public String getPrice() {
-        return isNull(price) ? retprice : price;
-    }
-
-    public String getStatusFlag() {
-        if (isNull(statusFlag)) return "是";
-        return statusFlag.trim().equals("0") ? "是" : "否";
-    }
-
-    private boolean isNull(String val) {
-        return null == val || val.trim().equals("");
+    public String getYbSelfFlag() {
+        if (StringUtil.isBlank(ybSelfFlag)) return "是";
+        return ybSelfFlag.trim().equals("0") ? "是" : "否";
     }
 }

+ 14 - 0
src/main/java/thyyxxk/webserver/pojo/yibao/patient/GetFeesParam.java

@@ -0,0 +1,14 @@
+package thyyxxk.webserver.pojo.yibao.patient;
+
+import lombok.Data;
+
+@Data
+public class GetFeesParam {
+    private String inpatientNo;
+    private Integer admissTimes;
+    private String responceType;
+    private String ybType;
+    private Integer ledgerSn;
+    private Integer currentPage;
+    private Integer pageSize;
+}