Commit 5cb0e7aa by lizefeng

刷新在途数据

parent b022d369
...@@ -21,22 +21,18 @@ namespace AutoTurnOver.DB ...@@ -21,22 +21,18 @@ namespace AutoTurnOver.DB
{ {
sql = @" sql = @"
select t1.*,t2.quantity_out_stock, select t1.*,t2.quantity_out_stock,
(t4.quantity_purchase-t4.quantity_inbound) as 'ontheway_quantity', -- 采购在途 (t4.count) as 'ontheway_quantity', -- 采购在途
t3.buyer_name, t3.buyer_name,
t4.estimated_arrival_time, t4.estimated_arrival_time,
t4.purchase_id, t4.purchase_id,
t3.sku_title_cn, t3.sku_title_cn,
(case when (t4.quantity_purchase>t4.quantity_inbound) and now()>t4.estimated_arrival_time then 1 else 0 end) as 'is_overdue', (case when ( ifnull(t4.count)>0) and now()>t4.estimated_arrival_time then 1 else 0 end) as 'is_overdue',
t4.deliver_name t4.deliver_name
from from
dc_auto_forecast_fluctuation as t1 dc_auto_forecast_fluctuation as t1
inner JOIN dc_auto_turnover as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code inner JOIN dc_auto_turnover as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join ( left join dc_auto_purchase_ontheway as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
select t1.*,t2.estimated_arrival_time,t2.warehouse_code from dc_base_purchase_details as t1
left join dc_base_purchase as t2 on t1.bailun_sku = t2.bailun_sku and t1.purchase_id = t2.purchase_id
where t1.`status`!=-1 and t1.quantity_purchase>t1.quantity_inbound
) as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
where 1 = 1 where 1 = 1
"; ";
......
...@@ -750,19 +750,16 @@ left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t ...@@ -750,19 +750,16 @@ left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t
where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') ) and t_db.hq_type!='fba仓' and (case when t_db.hq_type='国内仓' then (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0)) else t1.quantity_out_stock end )>0 where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') ) and t_db.hq_type!='fba仓' and (case when t_db.hq_type='国内仓' then (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0)) else t1.quantity_out_stock end )>0
) "); ) ");
_connection.Execute(@" -- 刷新在途 _connection.Execute(@" -- 刷新在途
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table dc_auto_purchase_ontheway_temp; Truncate table dc_auto_purchase_ontheway_temp;
INSERT into dc_auto_purchase_ontheway_temp(`bailun_sku`,`warehouse_code`,`purchase_id`,`estimated_arrival_time`,`count`) ( INSERT into dc_auto_purchase_ontheway_temp(`bailun_sku`,`warehouse_code`,`purchase_id`,`estimated_arrival_time`,`deliver_name`,`count`) (
SELECT SELECT
tb1.bailun_sku AS bailun_sku, tb1.bailun_sku AS bailun_sku,
tb1.warehouse_code AS warehouse_code, tb1.warehouse_code AS warehouse_code,
tb1.purchase_id AS purchase_id, tb1.purchase_id AS purchase_id,
tb1.estimated_arrival_time AS estimated_arrival_time, tb1.estimated_arrival_time AS estimated_arrival_time,
tb1.deliver_name,
sum( ( tb1.count - IFNULL( tb2.count, 0 ) ) ) AS count sum( ( tb1.count - IFNULL( tb2.count, 0 ) ) ) AS count
FROM FROM
( (
...@@ -773,6 +770,7 @@ FROM ...@@ -773,6 +770,7 @@ FROM
purchase_id, purchase_id,
estimated_arrival_time, estimated_arrival_time,
has_transfer, has_transfer,
supplier_name as 'deliver_name',
sum( count ) AS count sum( count ) AS count
FROM FROM
dc_base_purchase dc_base_purchase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment