|
@@ -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" +
|