Commit 86b2819c by 泽锋 李

修改缺货计算

parent b814fa86
...@@ -1328,120 +1328,7 @@ alter table dc_base_oms_bailun_no_map_items_temp rename dc_base_oms_bailun_no_ma ...@@ -1328,120 +1328,7 @@ alter table dc_base_oms_bailun_no_map_items_temp rename dc_base_oms_bailun_no_ma
alter table dc_base_oms_bailun_no_map_itemsTemp rename dc_base_oms_bailun_no_map_items_temp; alter table dc_base_oms_bailun_no_map_itemsTemp rename dc_base_oms_bailun_no_map_items_temp;
truncate table dc_base_oms_bailun_no_map_items_temp; ", commandTimeout: 0); truncate table dc_base_oms_bailun_no_map_items_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新缺货明细表
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table china_warehouse_stock_temp;
INSERT into china_warehouse_stock_temp(`bailun_sku`,`sum_usable_stock`,`warehouse_codes`) (
SELECT
`t1`.`bailun_sku` AS `bailun_sku`,
sum( `t1`.`usable_stock` + t1.occupy_stock ) AS `sum_usable_stock`,
group_concat( ( CASE WHEN ( `t1`.`usable_stock` + t1.occupy_stock > 0 ) THEN `t1`.`warehouse_code` ELSE '' END ) SEPARATOR ' | ' ) AS `warehouse_codes`
FROM
( `dc_base_stock` `t1` LEFT JOIN `dc_base_warehouse` `t2` ON ( ( `t1`.`warehouse_code` = `t2`.`warehouse_code` ) ) )
WHERE
( ( `t2`.`hq_type` = '国内仓' ) AND ( `t1`.`warehouse_code` IN ( 'GZBLWH', 'QYBLZZ' ,'BLGZ03' ) ) )
GROUP BY
`t1`.`bailun_sku`
);
alter table china_warehouse_stock rename china_warehouse_stockTemp;
alter table china_warehouse_stock_temp rename china_warehouse_stock;
alter table china_warehouse_stockTemp rename china_warehouse_stock_temp;
truncate table china_warehouse_stock_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新国内仓未发货
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table china_warehouse_unshipped_temp;
INSERT into china_warehouse_unshipped_temp(`bailun_sku`,`sum_unshipped_quantity`) (
SELECT
`t1`.`bailun_sku` AS `bailun_sku`,
sum(case when t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 then ( `t1`.`bailun_sku_quantity_ordered` - `t1`.`bailun_sku_quantity_picked` ) else 0 end ) AS `sum_unshipped_quantity`
FROM
( `dc_base_oms_sku_outofstock` `t1` LEFT JOIN `dc_base_warehouse` `t2` ON ( ( `t1`.`warehouse_code` = `t2`.`warehouse_code` ) ) )
WHERE
t1.has_innersale=0
and `t2`.`hq_type` = '国内仓' and t1.warehouse_code IN ( 'GZBLWH', 'QYBLZZ' ,'BLGZ03' )
GROUP BY
`t1`.`bailun_sku`
);
alter table china_warehouse_unshipped rename china_warehouse_unshippedTemp;
alter table china_warehouse_unshipped_temp rename china_warehouse_unshipped;
alter table china_warehouse_unshippedTemp rename china_warehouse_unshipped_temp;
truncate table china_warehouse_unshipped_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新缺货明细表
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table buy_ontheway_detail_temp;
INSERT into buy_ontheway_detail_temp(`bailun_sku`,`warehouse_code`,`buy_ontheway_detail`) (
select
t1.*
from view_buy_ontheway_detail as t1
);
alter table buy_ontheway_detail rename buy_ontheway_detailTemp;
alter table buy_ontheway_detail_temp rename buy_ontheway_detail;
alter table buy_ontheway_detailTemp rename buy_ontheway_detail_temp;
truncate table buy_ontheway_detail_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新在途
set session transaction isolation level read uncommitted;
start transaction;
Truncate table dc_auto_purchase_ontheway_temp;
INSERT into dc_auto_purchase_ontheway_temp(`bailun_sku`,`warehouse_code`,`purchase_id`,`estimated_arrival_time`,`deliver_name`,`count`) (
SELECT
tb1.bailun_sku AS bailun_sku,
tb1.warehouse_code AS warehouse_code,
tb1.purchase_id AS purchase_id,
tb1.estimated_arrival_time AS estimated_arrival_time,
tb1.deliver_name,
sum( ( tb1.count - IFNULL( tb2.count, 0 ) ) ) AS count
FROM
(
SELECT
bailun_sku,
warehouse_code,
parent_id,
purchase_id,
estimated_arrival_time,
has_transfer,
supplier_name as 'deliver_name',
sum( count ) AS count
FROM
dc_base_purchase
WHERE
buy_status IN ( 0, 1, 2, 3 )
AND has_delete = 0
GROUP BY
bailun_sku,
parent_id
) tb1
LEFT JOIN ( SELECT bailun_sku, warehouse_code, parent_id, sum( count ) AS count FROM dc_base_purchase_inbound GROUP BY bailun_sku, parent_id ) tb2 ON tb1.bailun_sku = tb2.bailun_sku
AND tb1.parent_id = tb2.parent_id
GROUP BY
tb1.bailun_sku,
tb1.warehouse_code,
tb1.purchase_id
);
alter table dc_auto_purchase_ontheway rename dc_auto_purchase_onthewayTemp;
alter table dc_auto_purchase_ontheway_temp rename dc_auto_purchase_ontheway;
alter table dc_auto_purchase_onthewayTemp rename dc_auto_purchase_ontheway_temp;
truncate table dc_auto_purchase_ontheway_temp; ", commandTimeout: 0);
_connection.Execute(@"-- 刷新 订单sku 标签表 _connection.Execute(@"-- 刷新 订单sku 标签表
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
...@@ -1548,10 +1435,6 @@ alter table dc_view_stock_monitor_sku_temp rename dc_view_stock_monitor_sku; ...@@ -1548,10 +1435,6 @@ alter table dc_view_stock_monitor_sku_temp rename dc_view_stock_monitor_sku;
alter table dc_view_stock_monitor_skuTemp rename dc_view_stock_monitor_sku_temp; alter table dc_view_stock_monitor_skuTemp rename dc_view_stock_monitor_sku_temp;
truncate table dc_view_stock_monitor_sku_temp; ", commandTimeout: 0); truncate table dc_view_stock_monitor_sku_temp; ", commandTimeout: 0);
// _connection.Execute(@" -- 刷新sku汇总 // _connection.Execute(@" -- 刷新sku汇总
//set session transaction isolation level read uncommitted; //set session transaction isolation level read uncommitted;
//start transaction; //start transaction;
...@@ -1646,6 +1529,32 @@ where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code; ...@@ -1646,6 +1529,32 @@ where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code;
{ {
try try
{ {
// 刷新国内仓可用库存
_connection.Execute(@" -- 刷新缺货明细表
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table china_warehouse_stock_temp;
INSERT into china_warehouse_stock_temp(`bailun_sku`,`sum_usable_stock`,`warehouse_codes`) (
SELECT
`t1`.`bailun_sku` AS `bailun_sku`,
sum( `t1`.`usable_stock` + t1.occupy_stock ) AS `sum_usable_stock`,
group_concat( ( CASE WHEN ( `t1`.`usable_stock` + t1.occupy_stock > 0 ) THEN `t1`.`warehouse_code` ELSE '' END ) SEPARATOR ' | ' ) AS `warehouse_codes`
FROM
( `dc_base_stock` `t1` LEFT JOIN `dc_base_warehouse` `t2` ON ( ( `t1`.`warehouse_code` = `t2`.`warehouse_code` ) ) )
WHERE
( ( `t2`.`hq_type` = '国内仓' ) AND ( `t1`.`warehouse_code` IN ( 'GZBLWH', 'QYBLZZ' ,'BLGZ03' ) ) )
GROUP BY
`t1`.`bailun_sku`
);
alter table china_warehouse_stock rename china_warehouse_stockTemp;
alter table china_warehouse_stock_temp rename china_warehouse_stock;
alter table china_warehouse_stockTemp rename china_warehouse_stock_temp;
truncate table china_warehouse_stock_temp; ", commandTimeout: 0);
var datas = _connection.Query<dc_base_oms_sku_outofstock_temp>(@"select var datas = _connection.Query<dc_base_oms_sku_outofstock_temp>(@"select
t1.`id`, t1.`id`,
t1.`origin_order_id`, t1.`origin_order_id`,
...@@ -1770,6 +1679,31 @@ where t1.company_id=1 and t1.has_innersale=0 and t1.create_time>'2019-03-01 12: ...@@ -1770,6 +1679,31 @@ where t1.company_id=1 and t1.has_innersale=0 and t1.create_time>'2019-03-01 12:
Truncate table dc_base_oms_sku_outofstock_temp; Truncate table dc_base_oms_sku_outofstock_temp;
", commandTimeout: 0); ", commandTimeout: 0);
// 刷新国内仓未发货
_connection.Execute(@" -- 刷新国内仓未发货
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table china_warehouse_unshipped_temp;
INSERT into china_warehouse_unshipped_temp(`bailun_sku`,`sum_unshipped_quantity`) (
SELECT
`t1`.`bailun_sku` AS `bailun_sku`,
sum(case when t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 then ( `t1`.`bailun_sku_quantity_ordered` - `t1`.`bailun_sku_quantity_picked` ) else 0 end ) AS `sum_unshipped_quantity`
FROM
( `dc_base_oms_sku_outofstock` `t1` LEFT JOIN `dc_base_warehouse` `t2` ON ( ( `t1`.`warehouse_code` = `t2`.`warehouse_code` ) ) )
WHERE
t1.has_innersale=0
and `t2`.`hq_type` = '国内仓' and t1.warehouse_code IN ( 'GZBLWH', 'QYBLZZ' ,'BLGZ03' )
GROUP BY
`t1`.`bailun_sku`
);
alter table china_warehouse_unshipped rename china_warehouse_unshippedTemp;
alter table china_warehouse_unshipped_temp rename china_warehouse_unshipped;
alter table china_warehouse_unshippedTemp rename china_warehouse_unshipped_temp;
truncate table china_warehouse_unshipped_temp; ", commandTimeout: 0);
foreach (var item in datas) foreach (var item in datas)
{ {
_connection.Insert(item); _connection.Insert(item);
...@@ -1780,6 +1714,72 @@ alter table dc_base_oms_sku_outofstock rename dc_base_oms_sku_outofstockTemp; ...@@ -1780,6 +1714,72 @@ alter table dc_base_oms_sku_outofstock rename dc_base_oms_sku_outofstockTemp;
alter table dc_base_oms_sku_outofstock_temp rename dc_base_oms_sku_outofstock; alter table dc_base_oms_sku_outofstock_temp rename dc_base_oms_sku_outofstock;
alter table dc_base_oms_sku_outofstockTemp rename dc_base_oms_sku_outofstock_temp; alter table dc_base_oms_sku_outofstockTemp rename dc_base_oms_sku_outofstock_temp;
truncate table dc_base_oms_sku_outofstock_temp; ", commandTimeout: 0); truncate table dc_base_oms_sku_outofstock_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新缺货明细表
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table buy_ontheway_detail_temp;
INSERT into buy_ontheway_detail_temp(`bailun_sku`,`warehouse_code`,`buy_ontheway_detail`) (
select
t1.*
from view_buy_ontheway_detail as t1
);
alter table buy_ontheway_detail rename buy_ontheway_detailTemp;
alter table buy_ontheway_detail_temp rename buy_ontheway_detail;
alter table buy_ontheway_detailTemp rename buy_ontheway_detail_temp;
truncate table buy_ontheway_detail_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新在途
set session transaction isolation level read uncommitted;
start transaction;
Truncate table dc_auto_purchase_ontheway_temp;
INSERT into dc_auto_purchase_ontheway_temp(`bailun_sku`,`warehouse_code`,`purchase_id`,`estimated_arrival_time`,`deliver_name`,`count`) (
SELECT
tb1.bailun_sku AS bailun_sku,
tb1.warehouse_code AS warehouse_code,
tb1.purchase_id AS purchase_id,
tb1.estimated_arrival_time AS estimated_arrival_time,
tb1.deliver_name,
sum( ( tb1.count - IFNULL( tb2.count, 0 ) ) ) AS count
FROM
(
SELECT
bailun_sku,
warehouse_code,
parent_id,
purchase_id,
estimated_arrival_time,
has_transfer,
supplier_name as 'deliver_name',
sum( count ) AS count
FROM
dc_base_purchase
WHERE
buy_status IN ( 0, 1, 2, 3 )
AND has_delete = 0
GROUP BY
bailun_sku,
parent_id
) tb1
LEFT JOIN ( SELECT bailun_sku, warehouse_code, parent_id, sum( count ) AS count FROM dc_base_purchase_inbound GROUP BY bailun_sku, parent_id ) tb2 ON tb1.bailun_sku = tb2.bailun_sku
AND tb1.parent_id = tb2.parent_id
GROUP BY
tb1.bailun_sku,
tb1.warehouse_code,
tb1.purchase_id
);
alter table dc_auto_purchase_ontheway rename dc_auto_purchase_onthewayTemp;
alter table dc_auto_purchase_ontheway_temp rename dc_auto_purchase_ontheway;
alter table dc_auto_purchase_onthewayTemp rename dc_auto_purchase_ontheway_temp;
truncate table dc_auto_purchase_ontheway_temp; ", commandTimeout: 0);
} }
catch (Exception ex) catch (Exception ex)
{ {
......
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