Commit 00b8b24d by 泽锋 李

测试读写分离优化

parent e7cc8609
......@@ -48,18 +48,30 @@ namespace AutoTurnOver.DB
{
_connection.Dispose();
}
public static MySqlConnection __connection;
public static MySqlConnection _connection
{
get
{
return new MySqlConnection(ConfigHelper.ConnectionString("Default"));
if (__connection == null)
{
__connection = new MySqlConnection(ConfigHelper.ConnectionString("Default"));
}
return __connection;
}
}
public static MySqlConnection __connection_read_only;
public static MySqlConnection _connection_read_only
{
get
{
return new MySqlConnection(ConfigHelper.ConnectionString("ReadOnly"));
if (__connection_read_only == null)
{
__connection_read_only = new MySqlConnection(ConfigHelper.ConnectionString("ReadOnly"));
}
return __connection_read_only;
}
}
......
......@@ -2966,7 +2966,10 @@ where 1=1
delete from dc_report_stock_week where week_tag=@week_tag;
insert into dc_report_stock_week(`stock`,`week_tag`,`warehouse_code`,`bailun_sku`,`first_day_date`,`web_site`,`sku_tag`,`stock_amount`,`is_order`)
(
select
select
t1.stock,
t1.week_tag,
t1.warehouse_code,
......@@ -2990,7 +2993,20 @@ from dc_base_oms_sku as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_stock t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
left join dc_base_sku as t4 on t1.bailun_sku = t4.bailun_sku
where t1.paid_time>=@btime and t1.paid_time<=@etime group by t1.warehouse_code,t1.bailun_sku ) as t1
where t1.paid_time>=@btime and t1.paid_time<=@etime
and t1.bailun_order_status = 'Handling'
and t1.bailun_interception_status in ('None', 'Failed')
and t1.warehouse_code != ''
and t1.platform_type != 'FBA'
and t1.company_id = 1
and t1.has_delete = 0
and t1.has_scalp = 0
and t1.has_buyer_remark = 0
and t1.has_platsku_remark = 0
and t1.has_fba_s = 0
and t1.has_innersale = 0
and t1.paid_time >= '2019-03-01 12:00:00'
group by t1.warehouse_code,t1.bailun_sku ) as t1
where t1.hq_type='第三方仓库'
);
insert ignore into dc_report_stock_week(`stock`,`week_tag`,`warehouse_code`,`bailun_sku`,`first_day_date`,`web_site`,`sku_tag`,`stock_amount`,`is_order`)
......@@ -3178,5 +3194,78 @@ where t1.bailun_sku = t2.bailun_sku and t1.week_tag=@week_tag;
return weeks;
}
/// <summary>
/// 库存-采购每周备份
/// </summary>
public static void PurchaseWeekBackUp()
{
var btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome();
var etime = btime.GetWeekLastDaySun().ToDayEnd();
var eonthFirstDate = DateTime.Now.GetMonthFirstDay();
var week_tag = $"{btime.ToString("MM-dd")} ~ {etime.ToString("MM-dd")}";
_connection.Execute(@"
delete from dc_report_purchase_week where week_tag=@week_tag;
insert into dc_report_purchase_week(`week_tag`,`type`,`warehouse_code`,`bailun_sku`,`stock`,`unit_price`,`is_new`,`quantity_purchase`,`amount_paid`,`web_stie`,`first_day_date`)
(
select
@week_tag as 'week_tag',
2 as 'type',
t_p.targetwareno as 'warehouse_code',
t_ps.sku as 'bailun_sku',
t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t1.usable_stock<=0 and t3.develop_time >=@eonthFirstDate then 1
else 0
end
) as 'is_new',
sum(t_ps.deliverycount) as 'quantity_purchase',
sum(t_ps.deliverycount * t3.unit_price) as 'amount_paid',
t2.area_name as 'web_stie',
@btime as 'first_day_date'
from dc_base_transfer_info as t_p
left join dc_base_transfer_info_skus as t_ps on t_p.`dataid` = t_ps.dataid
left join dc_base_stock as t1 on t1.bailun_sku =t_ps.sku and t1.warehouse_code = t_p.targetwareno
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku =t3.bailun_sku
where t2.hq_type='第三方仓库' and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋1')
and t_p.`isdeleted`=0 and t_p.creationtime>=@btime and t_p.creationtime<=@etime
GROUP BY t_ps.sku ,t_p.targetwareno
);
insert into dc_report_purchase_week(`week_tag`,`type`,`warehouse_code`,`bailun_sku`,`stock`,`unit_price`,`is_new`,`quantity_purchase`,`amount_paid`,`web_stie`,`first_day_date`)
(
select
@week_tag as 'week_tag',
1 as 'type',
t_p.warehouse_into_code as 'warehouse_code',
t_p.bailun_sku,
t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t1.usable_stock<=0 and t3.develop_time >=@eonthFirstDate then 1
else 0
end
) as 'is_new',
sum(t_p.quantity_purchase) as 'quantity_purchase',
sum(t_p.amount_paid) as 'amount_paid',
t2.area_name as 'web_stie',
@btime as 'first_day_date'
from dc_base_purchase_details as t_p
left join dc_base_stock as t1 on t1.bailun_sku =t_p.bailun_sku and t1.warehouse_code = t_p.warehouse_into_code
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku =t3.bailun_sku
where t2.hq_type='第三方仓库'
and t_p.`status`!=-1 and t_p.create_time>=@btime and t_p.create_time<=@etime
GROUP BY t_p.bailun_sku ,t_p.warehouse_into_code
);
", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0);
}
}
}
......
......@@ -16,7 +16,8 @@ namespace ResetOutofstock
try
{
var now = DateTime.Now;
//report.StockWeekBackUp();
//report.StockWeekBackUp();
//report.PurchaseWeekBackUp();
//report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//report_cash_flow_dao.SynchroTransferCost();
}
......
......@@ -16,11 +16,11 @@ namespace ResetOutofstock
{
Task.Factory.StartNew(() =>
{
//Console.WriteLine("开始刷新调拨订单数据");
//var now = DateTime.Now;
//report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
Console.WriteLine("开始刷新调拨订单数据");
var now = DateTime.Now;
report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//report.ResetCashFlowData();
//Console.WriteLine("结束调拨订单数据");
Console.WriteLine("结束调拨订单数据");
});
......
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