浏览代码

排序方式 超出下限药品、按3天的预计可用天数、库存量依次升序再按三天用量降序

WANGJIALIANG 2 年之前
父节点
当前提交
7ed17ab277

+ 16 - 6
src/main/java/cn/hnthyy/thmz/mapper/his/yf/YfDrugApplyMapper.java

@@ -16,6 +16,7 @@ public interface YfDrugApplyMapper {
 
     /**
      * 查询药房药品上下限信息
+     * 排序方式 超出下限药品、按3天的预计可用天数、库存量依次升序再按三天用量降序
      * @param searchText
      * @param groupNo
      * @return
@@ -23,11 +24,17 @@ public interface YfDrugApplyMapper {
      */
     @Select("<script>" +
             "SELECT  top ${pageBean.pageSize} * from " +
-            "(SELECT  row_number() over (order by (case when b.mini_stock_amount>=max(isnull(b.stock_amount,0)) then 0 else 1 end)," +
-            "(case when dd.stock_amount>0 then 0 else 1 end),(case when isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 60 then 0 else quantity end),2),0)=0 then 1 else 0 end)," +
-            "isnull( round(max(isnull(b.stock_amount,0)+isnull(bb.stock_amount,0)) /case when (sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end)/(14))<![CDATA[<=]]>0 then 999999999 else (sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end)/(14)) end,1),0)) RowNumber," +
+            "(SELECT  row_number() over (order by (case when b.mini_stock_amount>=max(isnull(b.stock_amount,0)) then 0 else 1 end) asc," +
+            "(case when max(isnull(b.stock_amount,0))=0 " +
+            "       or isnull(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),0)=0" +
+            "       then 0 " +
+            "       else round(max(isnull(b.stock_amount,0))/(isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),2),0)/3),2) end) asc," +
+            "max(isnull(b.stock_amount,0)) asc," +
+            "isnull(round(sum(case" +
+            "                 when datediff(day,confirm_time,getdate()) > 3 then 0" +
+            "                 else quantity end),2),0) desc) RowNumber," +
             "  b.charge_code," +
-            "  dd.stock_amount as stock_amount_yk," +
+            "  isnull(dd.stock_amount,0) as stock_amount_yk," +
             "  a.name," +
             "  b.serial," +
             "  b.group_no," +
@@ -39,11 +46,14 @@ public interface YfDrugApplyMapper {
             "  location=b.location," +
             "  b.max_stock_amount," +
             "  b.mini_stock_amount," +
+            "  three_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),2),0)," +
             "  seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 7 then 0 else quantity end),2),0)," +
             "  fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end),2),0)," +
             "  thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 30 then 0 else quantity end),2),0)," +
-            "  sixty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 60 then 0 else quantity end),2),0)," +
-            "  available_day=isnull( round(max(isnull(b.stock_amount,0)+isnull(bb.stock_amount,0)) /case when (sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end)/(14))<![CDATA[<=]]>0 then 999999999 else (sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end)/(14)) end,1),0)" +
+            "  available_day=" +
+            " case when max(isnull(b.stock_amount,0))=0 or isnull(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),0)=0" +
+            "      then 0 " +
+            "      else round(max(isnull(b.stock_amount,0))/(isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),2),0)/3),2) end" +
             " FROM yp_zd_dict a WITH(NOLOCK) ,yp_base_yf b WITH(NOLOCK),yp_base dd WITH(NOLOCK)," +
             "     (select c.name,a.charge_item_code code,c.serial,a.confirm_time," +
             "        round(sum(case when a.serial <![CDATA[<]]> c.serial then quantity*cy_fy/pack_size else quantity*cy_fy end),2) quantity" +

+ 2 - 0
src/main/java/cn/hnthyy/thmz/vo/YpBaseBoundVo.java

@@ -41,6 +41,8 @@ public class YpBaseBoundVo {
     private Double maxStockAmount;
     //库存下限
     private Double miniStockAmount;
+    //3天用量
+    private Double threeDayDosage;
     //7天用量
     private Double sevenDayDosage;
     //14天用量

+ 10 - 10
src/main/resources/static/js/yf/drug_apply.js

@@ -450,8 +450,8 @@ function initAddDrugTable(drawNo) {
                     return value.toFixed(2);
                 }
             }, {
-                field: 'sevenDayDosage',
-                title: '天用量',
+                field: 'threeDayDosage',
+                title: '3天用量',
                 align: "center",
                 valign: 'middle'
             }, {
@@ -707,32 +707,32 @@ function getYpBaseYfBound() {
                 align: "left",
                 valign: 'middle'
             }, {
-                field: 'sevenDayDosage',
-                title: '7天用量',
+                field: 'threeDayDosage',
+                title: '3天用量',
                 align: "center",
                 valign: 'middle',
                 formatter: function (value, row, index) {
                     return keepTwoDecimal(value);
                 }
             }, {
-                field: 'fourteenDayDosage',
-                title: '14天用量',
+                field: 'sevenDayDosage',
+                title: '7天用量',
                 align: "center",
                 valign: 'middle',
                 formatter: function (value, row, index) {
                     return keepTwoDecimal(value);
                 }
             }, {
-                field: 'thirtyDayDosage',
-                title: '30天用量',
+                field: 'fourteenDayDosage',
+                title: '14天用量',
                 align: "center",
                 valign: 'middle',
                 formatter: function (value, row, index) {
                     return keepTwoDecimal(value);
                 }
             }, {
-                field: 'sixtyDayDosage',
-                title: '60天用量',
+                field: 'thirtyDayDosage',
+                title: '30天用量',
                 align: "center",
                 valign: 'middle',
                 formatter: function (value, row, index) {