Commit 23a37150 by lizefeng

jit 广州01 仓每天自动推送缺货数据

parent 22994743
...@@ -29,6 +29,10 @@ namespace AutoGeneratePurchaseAdvise ...@@ -29,6 +29,10 @@ namespace AutoGeneratePurchaseAdvise
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")}");
PurchaseAdviseServices.Generate(); PurchaseAdviseServices.Generate();
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")}");
Console.WriteLine($"开始采购平均值统计任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
PurchaseAdviseServices.AutoPushBuySys();
Console.WriteLine($"结束采购平均值统计任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -13,7 +13,7 @@ namespace AutoGeneratePurchaseAdvise ...@@ -13,7 +13,7 @@ namespace AutoGeneratePurchaseAdvise
{ {
Console.WriteLine("采购建议计算任务启动..."); Console.WriteLine("采购建议计算任务启动...");
// 创建采购计划 // 创建采购计划
//purchase_advise.ImportJITShortageDetailed(141); //PurchaseAdviseServices.AutoPushBuySys();
var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{ {
services.AddHostedService<GeneratePurchaseAdviseBackgroundService>(); services.AddHostedService<GeneratePurchaseAdviseBackgroundService>();
......
...@@ -30,12 +30,14 @@ t3.sku_title_cn, ...@@ -30,12 +30,14 @@ t3.sku_title_cn,
t4.deliver_name, t4.deliver_name,
t2.history_sevenday_sales, t2.history_sevenday_sales,
t2.history_fourteenday_sales, t2.history_fourteenday_sales,
t2.history_thirtyday_sales t2.history_thirtyday_sales,
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status'
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 dc_auto_purchase_ontheway as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code left join dc_auto_purchase_ontheway as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where 1 = 1 where 1 = 1
"; ";
...@@ -46,10 +48,11 @@ where 1 = 1 ...@@ -46,10 +48,11 @@ where 1 = 1
select t1.*,t3.sku_title_cn, select t1.*,t3.sku_title_cn,
t2.history_sevenday_sales, t2.history_sevenday_sales,
t2.history_fourteenday_sales, t2.history_fourteenday_sales,
t2.history_thirtyday_sales from dc_auto_forecast_fluctuation as t1 t2.history_thirtyday_sales, ( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status' from 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_sku as t3 on t1.bailun_sku = t3.bailun_sku 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_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where 1 = 1 where 1 = 1
"; ";
} }
......
...@@ -470,7 +470,7 @@ t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZB ...@@ -470,7 +470,7 @@ t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZB
and ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') ) and ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') )
and t_db.hq_type!='fba仓' and t_db.hq_type!='fba仓'
and (case when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') then (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0)) else t1.quantity_out_stock end )>0 and (case when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') then (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0)) else t1.quantity_out_stock end )>0
and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku )"; and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=1 )";
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,commandTimeout: 0));
// 0库存推送 // 0库存推送
...@@ -482,6 +482,7 @@ now() as 'push_date', ...@@ -482,6 +482,7 @@ now() as 'push_date',
left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
where t1.usable_stock<=0 and t1.bailun_sku!='' where t1.usable_stock<=0 and t1.bailun_sku!=''
and ( t_db.warehouse_code!='QYBLZZ' or t2.buyer_name not in ('张莹霞','张莹霞1','黄镜洁','赵美聪') )
and t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL') and t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL')
and ( and (
case case
...@@ -489,8 +490,20 @@ and ( ...@@ -489,8 +490,20 @@ and (
else t2.quantity_transfer else t2.quantity_transfer
end end
)<=0 )<=0
and not EXISTS ( select * from dc_base_stock as t_stock where t_stock.bailun_sku= t1.bailun_sku and t1.usable_stock>0 ) and not EXISTS (
and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku )"; select * from dc_base_stock as t_stock
left join dc_base_warehouse as t_stock_w on t_stock.warehouse_code = t_stock_w.warehouse_code
left join dc_mid_transit as t_stock_t on t_stock.warehouse_code =t_stock_t.warehouse_code and t_stock.bailun_sku =t_stock_t.bailun_sku
where ( ( t_stock_w.hq_type='国内仓' and t_db.hq_type='国内仓' ) or ( t_db.hq_type!='国内仓' and t_stock_w.hq_type!='国内仓' and t_db.area_id=t_stock_w.area_id ) ) and t_stock.bailun_sku= t1.bailun_sku and ( t_stock.usable_stock>0 or
(
case
when t_stock_w.hq_type='国内仓' then t_stock_t.quantity_purchase
else t_stock_t.quantity_transfer
end
)>0
)
) -- 同属性仓库 (是否国内) 有库存,就不算 0库存
and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=2 )";
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql, commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql, commandTimeout: 0));
return shortage_list; return shortage_list;
......
...@@ -133,6 +133,11 @@ namespace AutoTurnOver.Models ...@@ -133,6 +133,11 @@ namespace AutoTurnOver.Models
/// 最近30日日均 /// 最近30日日均
/// </summary> /// </summary>
public decimal history_thirtyday_sales { get; set; } public decimal history_thirtyday_sales { get; set; }
/// <summary>
/// 是否停止监控
/// </summary>
public int monitor_status { get; set; }
} }
public class dc_auto_forecast_fluctuation_search_dto public class dc_auto_forecast_fluctuation_search_dto
......
...@@ -381,7 +381,7 @@ namespace AutoTurnOver.Services ...@@ -381,7 +381,7 @@ namespace AutoTurnOver.Services
var err_datas = new List<ShortagePush_Item_RequestDto>(); var err_datas = new List<ShortagePush_Item_RequestDto>();
if (datas.Count <= 0) return new List<ShortagePush_Item_RequestDto>(); if (datas.Count <= 0) return new List<ShortagePush_Item_RequestDto>();
int page = 1; int page = 1;
int rows = 1000; int rows = 1000;
int totalPage = (int)Math.Ceiling(datas.Count() * 1.0 / rows); int totalPage = (int)Math.Ceiling(datas.Count() * 1.0 / rows);
while (page <= totalPage) while (page <= totalPage)
......
...@@ -190,5 +190,27 @@ namespace AutoTurnOver.Services ...@@ -190,5 +190,27 @@ namespace AutoTurnOver.Services
} }
/// <summary>
/// 自动推送采购单
/// </summary>
public static void AutoPushBuySys()
{
try
{
List<dc_auto_purchase_advise_detailed_dto> datas = new List<dc_auto_purchase_advise_detailed_dto>();
// 推送 张莹霞 广州01 仓的数据
var total = 0;
datas.AddRange(PurchaseAdviseServices.DetailList(new dc_auto_purchase_advise_detailed_search_dto { end_date = DateTime.Now,start_date = DateTime.Now, ispush = false,purchase_user="张莹霞",warehouse_code= "GZBLWH" }, 0, int.MaxValue, ref total));
datas.AddRange(PurchaseAdviseServices.DetailList(new dc_auto_purchase_advise_detailed_search_dto { end_date = DateTime.Now, start_date = DateTime.Now, ispush = false, purchase_user = "张莹霞1", warehouse_code = "GZBLWH" }, 0, int.MaxValue, ref total));
PurchaseAdviseServices.PushBuySys(datas, new UserData { UserName = "admin" });
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
} }
} }
...@@ -65,7 +65,7 @@ namespace AutoTurnOver.Controllers ...@@ -65,7 +65,7 @@ namespace AutoTurnOver.Controllers
string[] cols = new string[] { "Sku","中文名称","仓库编码","仓库名称","最近3日日均","最近7日日均","最近14日日均","最近30日日均","异常类型","开始时间", string[] cols = new string[] { "Sku","中文名称","仓库编码","仓库名称","最近3日日均","最近7日日均","最近14日日均","最近30日日均","异常类型","开始时间",
"总缺货数","在途数量","采购员","预计到货","bi 采购单号","供应商","逾期状态", "总缺货数","在途数量","采购员","预计到货","bi 采购单号","供应商","逾期状态",
"结束时间","是否确认","确认人","预计解决时间", "结束时间","是否确认","确认人","预计解决时间",
"处理方案","是否解决" "处理方案","是否解决","监控状态"
}; };
foreach (var item in cols) foreach (var item in cols)
{ {
...@@ -102,6 +102,7 @@ namespace AutoTurnOver.Controllers ...@@ -102,6 +102,7 @@ namespace AutoTurnOver.Controllers
row["预计解决时间"] = itemData.forecast_solve_time; row["预计解决时间"] = itemData.forecast_solve_time;
row["处理方案"] = itemData.remark; row["处理方案"] = itemData.remark;
row["是否解决"] = itemData.has_solve == 1 ? "是" : "否"; row["是否解决"] = itemData.has_solve == 1 ? "是" : "否";
row["监控状态"] = itemData.monitor_status==1?"停止监控":"正常监控";
table.Rows.Add(row); table.Rows.Add(row);
} }
......
...@@ -382,6 +382,7 @@ namespace AutoTurnOver.Controllers ...@@ -382,6 +382,7 @@ namespace AutoTurnOver.Controllers
} }
} }
} }
} }
\ No newline at end of file
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