Commit d03d4726 by guanzhenshan

逻辑仓库服务增加可用天数的数据更新

parent 5a653f91
...@@ -38,6 +38,8 @@ namespace Bailun.DC.LogicWareHouse ...@@ -38,6 +38,8 @@ namespace Bailun.DC.LogicWareHouse
// //new Services().UpdateLogicWareHouseSemiSale(); // //new Services().UpdateLogicWareHouseSemiSale();
// //new Services().SaleWHDailySnaps(); // //new Services().SaleWHDailySnaps();
// new Services().UpdateAvailableDays();
//} //}
} }
} }
...@@ -120,6 +120,9 @@ namespace Bailun.DC.LogicWareHouse ...@@ -120,6 +120,9 @@ namespace Bailun.DC.LogicWareHouse
//更新30天现金流 //更新30天现金流
UpdateCash30Days(); UpdateCash30Days();
//更新逻辑仓的可用天数
UpdateAvailableDays();
//保存每日数据快照 //保存每日数据快照
SaleWHDailySnaps(); SaleWHDailySnaps();
...@@ -411,6 +414,56 @@ namespace Bailun.DC.LogicWareHouse ...@@ -411,6 +414,56 @@ namespace Bailun.DC.LogicWareHouse
} }
/// <summary> /// <summary>
/// 更新逻辑仓库表的可用天数
/// </summary>
public void UpdateAvailableDays()
{
Console.WriteLine("【启动】更新逻辑仓库表的可用天数服务 "+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
try
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var sql = "TRUNCATE dc_mid_logicwh_availabledays;";
cn.Execute(sql);
//半成品的可用天数
sql = @"insert into dc_mid_logicwh_availabledays (bailun_sku,warehouse_code,hq_type,available_days)
select sku as bailun_sku,warehouse_id as warehouse_code,'半成品仓' as hq_type,available_days from dc_semi_stock_sales_shipping where available_days>0;";
cn.Execute(sql,null,null,6*60);
//成品的可用天数
sql = @"insert into dc_mid_logicwh_availabledays (bailun_sku,warehouse_code,hq_type,available_days)
select bailun_sku,t1.warehouse_code,t2.hq_type,available_days from dc_base_stock t1
left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code
where available_days>0;";
cn.Execute(sql, null, null, 6 * 60);
//更新逻辑仓的可用天数
sql = @"update dc_skuwarehouse_stock_sales t1
join dc_mid_logicwh_availabledays t2 on t1.bailun_sku=t2.bailun_sku and t1.warehouse_code=t2.warehouse_code
set t1.available_days=t2.available_days";
cn.Execute(sql, null, null, 6 * 60);
}
}
catch (Exception ex)
{
Console.WriteLine("更新逻辑仓库表的可用天数服务失败,异常信息:" + ex.Message);
UpdateAvailableDays();
}
Console.WriteLine("【完成】更新逻辑仓库表的可用天数服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
/// <summary>
/// 保存每日数据快照 /// 保存每日数据快照
/// </summary> /// </summary>
public void SaleWHDailySnaps() public void SaleWHDailySnaps()
...@@ -451,5 +504,7 @@ select DATE_SUB(curdate(),INTERVAL 1 DAY) as day,t1.* from (select t1.hq_type,t1 ...@@ -451,5 +504,7 @@ select DATE_SUB(curdate(),INTERVAL 1 DAY) as day,t1.* from (select t1.hq_type,t1
} }
} }
} }
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