Commit 8cc8a506 by 泽锋 李

优化缺货明细的刷新任务

parent fb550145
...@@ -9,6 +9,7 @@ using AutoTurnOver.Models.Base; ...@@ -9,6 +9,7 @@ using AutoTurnOver.Models.Base;
using AutoTurnOver.DB.Base; using AutoTurnOver.DB.Base;
using AutoTurnOver.Models.stock; using AutoTurnOver.Models.stock;
using AutoTurnOver.Utility; using AutoTurnOver.Utility;
using AutoTurnOver.Models.auto;
namespace AutoTurnOver.DB namespace AutoTurnOver.DB
{ {
...@@ -1325,139 +1326,6 @@ set session transaction isolation level read uncommitted; ...@@ -1325,139 +1326,6 @@ set session transaction isolation level read uncommitted;
start transaction; start transaction;
-- 清空视图表的数据 -- 清空视图表的数据
Truncate table dc_base_oms_sku_outofstock_temp;
INSERT into dc_base_oms_sku_outofstock_temp (
select
t1.`id`,
t1.`origin_order_id`,
t1.`platform_type`,
t1.`transaction_id`,
t1.`pay_time`,
t1.`pay_method`,
t1.`pay_account`,
t1.`pay_status`,
t1.`collection_account`,
t1.`platform_order_type`,
t1.`website`,
t1.`create_time`,
t1.`paid_time`,
t1.`refund_time`,
t1.`seller_id`,
t1.`bailun_account_id`,
t1.`hq_account`,
t1.`seller_account`,
t1.`seller_order_id`,
t1.`seller_email`,
t1.`order_update_time`,
t1.`seller_order_exchange_rate`,
t1.`seller_other_exchange_rate`,
t1.`finance_order_exchange_rate`,
t1.`finance_other_exchange_rate`,
t1.`cny_to_usd_exchange_rate`,
t1.`order_to_usd_exchange_rate`,
t1.`other_to_usd_exchange_rate` ,
t1.`order_currency`,
t1.`other_currency`,
t1.`seller_name`,
t1.`bailun_order_id`,
t1.`platform_order_status`,
t1.`bailun_order_status`,
t1.`bailun_payment_status`,
t1.`bailun_interception_status`,
t1.`shipping_status`,
t1.`bailun_sku`,
t1.`bailun_sku_title_en`,
t1.`bailun_sku_title_cn`,
t1.`bailun_sku_quantity_ordered`,
t1.`bailun_sku_quantity_shipped`,
t1.`bailun_sku_quantity_refund`,
t1.`bailun_sku_quantity_picked`,
t1.`warehouse_name`,
t1.`warehouse_code_fba`,
t1.`warehouse_code`,
t1.`bailun_sku_unit_price`,
t1.`bailun_sku_weight`,
t1.`bailun_sku_size`,
t1.`amount_sales`,
t1.`amount_total`,
t1.`amount_shipping`,
t1.`amount_product`,
t1.`amount_tax`,
t1.`amount_adjustment`,
t1.`amount_gift_wrap`,
t1.`amount_refund`,
t1.`amount_prepaid`,
t1.`cost_total`,
t1.`cost_promotion`,
t1.`cost_platform_fee`,
t1.`cost_product`,
t1.`cost_shipping`,
t1.`cost_package`,
t1.`cost_fba_fee`,
t1.`cost_paypal_fee`,
t1.`cost_refund_commisson`,
t1.`cost_handle_bailun`,
t1.`cost_handle_platform`,
t1.`cost_tail`,
t1.`cost_first`,
t1.`cost_logistics`,
t1.`profit_total`,
t1.`profit_rate`,
t1.`receipt_country`,
t1.`receipt_city`,
t1.`receipt_area`,
t1.`receipt_address`,
t1.`receipt_address_2`,
t1.`receipt_postal_code`,
t1.`receiver`,
t1.`receiver_phone`,
t1.`buyer_id`,
t1.`buyer_name`,
t1.`buyer_email`,
t1.`has_fba_exception`,
t1.`has_platform_exception`,
t1.`has_cancle`,
t1.`area_id`,
t1.`bailun_category_id`,
t1.`bailun_category_name`,
t1.`gmt_create`,
t1.`gmt_modified`,
t1.`ratio_weight`,
t1.`ratio_price`,
t1.`bailun_picking_status`,
t1.`bailun_require_logistics`,
t1.`has_delete`,
t1.`has_scalp`,
t1.`logistics_method_code`,
t1.`logistics_method_name`,
t1.`has_innersale`,
t1.`company_id`,
t1.`bailun_refund_status`,
t1.`refund_obj`,
t1.`refund_type`,
t1.`refund_reference_id`,
t1.`has_fba_s`,
t1.`bailun_sku_quantity_pushed`,
( CASE WHEN ( `t1`.`warehouse_code` IN ( 'QYBLZZ', 'GZBLWH' ) ) THEN 'QYBLZZ-GZBLWH' ELSE `t1`.`warehouse_code` END ) as 'warehouse_code_extend',
t1.`shipping_deadline_real`
from dc_base_oms_sku as t1
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where t1.company_id=1 and t1.has_innersale=0 and t1.create_time>'2019-03-01 12:00:00' and t1.bailun_picking_status!='TotalPicked' and t1.bailun_order_status = 'Handling' and t1.has_delete=0 and t1.has_scalp=0 and t1.has_buyer_remark = 0
and t1.has_platsku_remark = 0 and t1.bailun_interception_status not in ('Success','Part') and t1.platform_type!='FBA'
);
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_outofstockTemp rename dc_base_oms_sku_outofstock_temp;
truncate table dc_base_oms_sku_outofstock_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新缺货明细表
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table china_warehouse_stock_temp; Truncate table china_warehouse_stock_temp;
INSERT into china_warehouse_stock_temp(`bailun_sku`,`sum_usable_stock`,`warehouse_codes`) ( INSERT into china_warehouse_stock_temp(`bailun_sku`,`sum_usable_stock`,`warehouse_codes`) (
...@@ -1765,6 +1633,147 @@ where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code; ...@@ -1765,6 +1633,147 @@ where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code;
} }
/// <summary> /// <summary>
/// 刷新oms的缺货数据
/// </summary>
public static void ResetOmsOutofstock()
{
var datas = _connection.Query<dc_base_oms_sku_outofstock_temp>(@"select
t1.`id`,
t1.`origin_order_id`,
t1.`platform_type`,
t1.`transaction_id`,
t1.`pay_time`,
t1.`pay_method`,
t1.`pay_account`,
t1.`pay_status`,
t1.`collection_account`,
t1.`platform_order_type`,
t1.`website`,
t1.`create_time`,
t1.`paid_time`,
t1.`refund_time`,
t1.`seller_id`,
t1.`bailun_account_id`,
t1.`hq_account`,
t1.`seller_account`,
t1.`seller_order_id`,
t1.`seller_email`,
t1.`order_update_time`,
t1.`seller_order_exchange_rate`,
t1.`seller_other_exchange_rate`,
t1.`finance_order_exchange_rate`,
t1.`finance_other_exchange_rate`,
t1.`cny_to_usd_exchange_rate`,
t1.`order_to_usd_exchange_rate`,
t1.`other_to_usd_exchange_rate` ,
t1.`order_currency`,
t1.`other_currency`,
t1.`seller_name`,
t1.`bailun_order_id`,
t1.`platform_order_status`,
t1.`bailun_order_status`,
t1.`bailun_payment_status`,
t1.`bailun_interception_status`,
t1.`shipping_status`,
t1.`bailun_sku`,
t1.`bailun_sku_title_en`,
t1.`bailun_sku_title_cn`,
t1.`bailun_sku_quantity_ordered`,
t1.`bailun_sku_quantity_shipped`,
t1.`bailun_sku_quantity_refund`,
t1.`bailun_sku_quantity_picked`,
t1.`warehouse_name`,
t1.`warehouse_code_fba`,
t1.`warehouse_code`,
t1.`bailun_sku_unit_price`,
t1.`bailun_sku_weight`,
t1.`bailun_sku_size`,
t1.`amount_sales`,
t1.`amount_total`,
t1.`amount_shipping`,
t1.`amount_product`,
t1.`amount_tax`,
t1.`amount_adjustment`,
t1.`amount_gift_wrap`,
t1.`amount_refund`,
t1.`amount_prepaid`,
t1.`cost_total`,
t1.`cost_promotion`,
t1.`cost_platform_fee`,
t1.`cost_product`,
t1.`cost_shipping`,
t1.`cost_package`,
t1.`cost_fba_fee`,
t1.`cost_paypal_fee`,
t1.`cost_refund_commisson`,
t1.`cost_handle_bailun`,
t1.`cost_handle_platform`,
t1.`cost_tail`,
t1.`cost_first`,
t1.`cost_logistics`,
t1.`profit_total`,
t1.`profit_rate`,
t1.`receipt_country`,
t1.`receipt_city`,
t1.`receipt_area`,
t1.`receipt_address`,
t1.`receipt_address_2`,
t1.`receipt_postal_code`,
t1.`receiver`,
t1.`receiver_phone`,
t1.`buyer_id`,
t1.`buyer_name`,
t1.`buyer_email`,
t1.`has_fba_exception`,
t1.`has_platform_exception`,
t1.`has_cancle`,
t1.`area_id`,
t1.`bailun_category_id`,
t1.`bailun_category_name`,
t1.`gmt_create`,
t1.`gmt_modified`,
t1.`ratio_weight`,
t1.`ratio_price`,
t1.`bailun_picking_status`,
t1.`bailun_require_logistics`,
t1.`has_delete`,
t1.`has_scalp`,
t1.`logistics_method_code`,
t1.`logistics_method_name`,
t1.`has_innersale`,
t1.`company_id`,
t1.`bailun_refund_status`,
t1.`refund_obj`,
t1.`refund_type`,
t1.`refund_reference_id`,
t1.`has_fba_s`,
t1.`bailun_sku_quantity_pushed`,
( CASE WHEN ( `t1`.`warehouse_code` IN ( 'QYBLZZ', 'GZBLWH' ) ) THEN 'QYBLZZ-GZBLWH' ELSE `t1`.`warehouse_code` END ) as 'warehouse_code_extend',
t1.`shipping_deadline_real`
from dc_base_oms_sku as t1
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where t1.company_id=1 and t1.has_innersale=0 and t1.create_time>'2019-03-01 12:00:00' and t1.bailun_picking_status!='TotalPicked' and t1.bailun_order_status = 'Handling' and t1.has_delete=0 and t1.has_scalp=0 and t1.has_buyer_remark = 0
and t1.has_platsku_remark = 0 and t1.bailun_interception_status not in ('Success','Part') and t1.platform_type!='FBA'",commandTimeout:0).ToList();
_connection.Execute(@"
-- 清空视图表的数据
Truncate table dc_base_oms_sku_outofstock_temp;
", commandTimeout: 0);
foreach (var item in datas)
{
_connection.Insert(item);
}
_connection.Execute(@"
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_outofstockTemp rename dc_base_oms_sku_outofstock_temp;
truncate table dc_base_oms_sku_outofstock_temp; ", commandTimeout: 0);
}
/// <summary>
/// 全量刷新入库记录 /// 全量刷新入库记录
/// </summary> /// </summary>
public static void ResetStockRecord() public static void ResetStockRecord()
...@@ -2044,6 +2053,8 @@ alter table dc_base_oms_sku_7Temp rename dc_base_oms_sku_7_temp; ...@@ -2044,6 +2053,8 @@ alter table dc_base_oms_sku_7Temp rename dc_base_oms_sku_7_temp;
truncate table dc_base_oms_sku_7_temp; ", new { time = DateTime.Now.AddDays(-8).ToString("yyyy-MM-dd 00:00:00") }, commandTimeout: 0); truncate table dc_base_oms_sku_7_temp; ", new { time = DateTime.Now.AddDays(-8).ToString("yyyy-MM-dd 00:00:00") }, commandTimeout: 0);
} }
/// <summary> /// <summary>
/// 刷新安全库存 /// 刷新安全库存
/// </summary> /// </summary>
......
...@@ -20,6 +20,7 @@ namespace ResetOutofstock ...@@ -20,6 +20,7 @@ namespace ResetOutofstock
//dc_base_supplier_dao.SynchroBailunSupplier(); //dc_base_supplier_dao.SynchroBailunSupplier();
//dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-3), DateTime.Now); //dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-3), DateTime.Now);
//report.PurchaseWeekBackUp(); //report.PurchaseWeekBackUp();
//report.ResetOmsOutofstock();
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -100,8 +100,37 @@ namespace ResetOutofstock ...@@ -100,8 +100,37 @@ namespace ResetOutofstock
} }
else else
{ {
Console.WriteLine($"开始刷新缺货明细数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"开始刷新数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.ResetOutofstock(); report.ResetOutofstock();
Console.WriteLine($"结束刷新数据任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Thread.Sleep(4 * 60 * 60 * 1000);
}
});
Task.Factory.StartNew(() =>
{
while (true)
{
try
{
var now = DateTime.Now;
if (now.Hour>2 && now.Hour<=8)
{
Console.WriteLine(" 刷新缺货明细数据 * (数据库忙时,暂停)");
}
else
{
Console.WriteLine($"开始刷新缺货明细数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.ResetOmsOutofstock();
Console.WriteLine($"结束刷新缺货明细数据任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"结束刷新缺货明细数据任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
......
...@@ -66,7 +66,7 @@ namespace ResetOutofstock ...@@ -66,7 +66,7 @@ namespace ResetOutofstock
report.ResetInventory(); report.ResetInventory();
Console.WriteLine($"结束 刷新jit安全库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"结束 刷新jit安全库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
if (now.Hour == 9 && now.Minute == 20) if (now.Hour == 12 && now.Minute == 00)
{ {
Console.WriteLine($"开始 刷新最近7天的oms数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); Console.WriteLine($"开始 刷新最近7天的oms数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.ResetOms7(); report.ResetOms7();
......
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