Commit 048d154b by 泽锋 李

采购计划生产时,如果之前有采购建议未更新

parent c19aff4b
...@@ -579,7 +579,7 @@ and ( t5.`status`=0 or t5.`status` is null ) and t7.sum_quantity_init_advise>0 ...@@ -579,7 +579,7 @@ and ( t5.`status`=0 or t5.`status` is null ) and t7.sum_quantity_init_advise>0
", new { main_id = mainID, btime = date }, commandTimeout: 0).ToList(); ", new { main_id = mainID, btime = date }, commandTimeout: 0).ToList();
Console.WriteLine("开始出建议 完"); Console.WriteLine("开始出建议 完");
if(datas1!=null && datas1.Count >= 1) if (datas1 != null && datas1.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new _connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new
{ {
...@@ -974,20 +974,45 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse ...@@ -974,20 +974,45 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end )) + sum(t7.quantity_transfer) + sum(t7.quantity_purchase) < sum(t7.quantity_out_stock) ) HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end )) + sum(t7.quantity_transfer) + sum(t7.quantity_purchase) < sum(t7.quantity_out_stock) )
", new { main_id = mainID }, commandTimeout: 0).ToList(); ", new { main_id = mainID }, commandTimeout: 0).ToList();
if (datas != null && datas.Count>=1)
if (datas != null && datas.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new WritePurchaseAdvise(datas);
}
return mainID;
}
/// <summary>
/// 写入采购建议
/// </summary>
public static void WritePurchaseAdvise(List<dc_auto_purchase_advise_detailed> datas)
{
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
item.create_time = DateTime.Now;
// 查询是否有未过期 未推送的数据
var oldCreateDate = _connection.QuerySingleOrDefault<DateTime?>(" select create_time from dc_auto_purchase_advise_detailed where bailun_sku_warehouse_code = @bailun_sku_warehouse_code and status=0 and ispush=0 limit 1 ", new
{ {
bailun_sku_warehouse_codes = datas.Select(s=>$"{s.bailun_sku}{s.warehouse_code}").ToList() bailun_sku_warehouse_code = item.bailun_sku_warehouse_code
}, commandTimeout: 0); }, commandTimeout: 0);
if (oldCreateDate != null)
foreach (var item in datas)
{ {
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}"; item.create_time = oldCreateDate;
_connection.Insert(item);
} }
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code = @bailun_sku_warehouse_code ", new
{
bailun_sku_warehouse_code = item.bailun_sku_warehouse_code
}, commandTimeout: 0);
_connection.Insert(item);
} }
return mainID; }
public class old_purchase_advise_detailed
{
public int id { get; set; }
public int main_id { get; set; }
} }
/// <summary> /// <summary>
...@@ -1049,17 +1074,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse ...@@ -1049,17 +1074,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end )) < sum(t7.quantity_out_stock) ) ", new { main_id = mainID }, commandTimeout: 0).ToList(); HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end )) < sum(t7.quantity_out_stock) ) ", new { main_id = mainID }, commandTimeout: 0).ToList();
if (datas != null && datas.Count>=1) if (datas != null && datas.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new WritePurchaseAdvise(datas);
{
bailun_sku_warehouse_codes = datas.Select(s => $"{s.bailun_sku}{s.warehouse_code}").ToList()
}, commandTimeout: 0);
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
_connection.Insert(item);
}
} }
return mainID; return mainID;
} }
...@@ -1120,17 +1137,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse ...@@ -1120,17 +1137,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
and ( t5.`status`=0 or t5.`status` is null ) and ( t5.`status`=0 or t5.`status` is null )
and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock) ", new { main_id = mainID }, commandTimeout: 0).ToList(); and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock) ", new { main_id = mainID }, commandTimeout: 0).ToList();
if (datas != null && datas.Count>=1) if (datas != null && datas.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new WritePurchaseAdvise(datas);
{
bailun_sku_warehouse_codes = datas.Select(s => $"{s.bailun_sku}{s.warehouse_code}").ToList()
}, commandTimeout: 0);
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
_connection.Insert(item);
}
} }
return mainID; return mainID;
} }
...@@ -1191,17 +1200,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse ...@@ -1191,17 +1200,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
and ( t5.`status`=0 or t5.`status` is null ) and ( t5.`status`=0 or t5.`status` is null )
and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock)", new { main_id = mainID }, commandTimeout: 0).ToList(); and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock)", new { main_id = mainID }, commandTimeout: 0).ToList();
if (datas != null && datas.Count>=1) if (datas != null && datas.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new WritePurchaseAdvise(datas);
{
bailun_sku_warehouse_codes = datas.Select(s => $"{s.bailun_sku}{s.warehouse_code}").ToList()
}, commandTimeout: 0);
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
_connection.Insert(item);
}
} }
return mainID; return mainID;
} }
...@@ -1263,17 +1264,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse ...@@ -1263,17 +1264,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
and ( t5.`status`=0 or t5.`status` is null ) and ( t5.`status`=0 or t5.`status` is null )
and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock)", new { main_id = mainID }, commandTimeout: 0).ToList(); and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock)", new { main_id = mainID }, commandTimeout: 0).ToList();
if (datas != null && datas.Count>=1) if (datas != null && datas.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new WritePurchaseAdvise(datas);
{
bailun_sku_warehouse_codes = datas.Select(s => $"{s.bailun_sku}{s.warehouse_code}").ToList()
}, commandTimeout: 0);
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
_connection.Insert(item);
}
} }
return mainID; return mainID;
} }
...@@ -1535,17 +1528,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse ...@@ -1535,17 +1528,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
and ( t5.`status`=0 or t5.`status` is null ) and t8.quantity>0 and ( t5.`status`=0 or t5.`status` is null ) and t8.quantity>0
", new { main_id = mainID, time = last_date }, commandTimeout: 0).ToList(); ", new { main_id = mainID, time = last_date }, commandTimeout: 0).ToList();
if (datas != null && datas.Count>=1) if (datas != null && datas.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new WritePurchaseAdvise(datas);
{
bailun_sku_warehouse_codes = datas.Select(s => $"{s.bailun_sku}{s.warehouse_code}").ToList()
}, commandTimeout: 0);
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
_connection.Insert(item);
}
} }
return mainID; return mainID;
} }
...@@ -1602,17 +1587,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse ...@@ -1602,17 +1587,9 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
where t6.`status`=2 and ( t6.buyer_name in ('陈嘉雯1','黎艳漫') and t1.warehouse_code in ('BLGZ03') ) where t6.`status`=2 and ( t6.buyer_name in ('陈嘉雯1','黎艳漫') and t1.warehouse_code in ('BLGZ03') )
and ( t5.`status`=0 or t5.`status` is null ) and ( t5.`status`=0 or t5.`status` is null )
and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock)", new { main_id = mainID }, commandTimeout: 0).ToList(); and ((case when t7.quantity_out_stock>0 then 0 else (t1.usable_stock+t1.occupy_order) end ) + t7.quantity_transfer + t7.quantity_purchase < t7.quantity_out_stock)", new { main_id = mainID }, commandTimeout: 0).ToList();
if (datas != null && datas.Count>=1) if (datas != null && datas.Count >= 1)
{ {
_connection.Execute(" update dc_auto_purchase_advise_detailed set status=-1 where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new WritePurchaseAdvise(datas);
{
bailun_sku_warehouse_codes = datas.Select(s => $"{s.bailun_sku}{s.warehouse_code}").ToList()
}, commandTimeout: 0);
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
_connection.Insert(item);
}
} }
return mainID; return mainID;
} }
...@@ -1793,7 +1770,7 @@ where t1.status=0 "; ...@@ -1793,7 +1770,7 @@ where t1.status=0 ";
{ {
sql = @" sql = @"
select select
t1.*,(case when t2.hq_type='fba仓' then t2.bailun_account else t2.warehouse_name end) as 'warehouse_name',t3.sku_title_cn as 'sku_name',t4.create_time,t3.buyer_name, t1.*,(case when t2.hq_type='fba仓' then t2.bailun_account else t2.warehouse_name end) as 'warehouse_name',t3.sku_title_cn as 'sku_name',t3.buyer_name,
(t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 安全库存 (t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 安全库存
(t5.daily_weighted_sales) as 'daily_weighted_sales', -- 日均加权 (t5.daily_weighted_sales) as 'daily_weighted_sales', -- 日均加权
(t7.quantity_out_stock) as 'realtime_quantity_out_stock', -- 实时缺货 (t7.quantity_out_stock) as 'realtime_quantity_out_stock', -- 实时缺货
...@@ -1884,7 +1861,7 @@ where 1=1 "; ...@@ -1884,7 +1861,7 @@ where 1=1 ";
sql += " and t4.`no` =@order_no "; sql += " and t4.`no` =@order_no ";
parameters.Add("order_no", m.order_no); parameters.Add("order_no", m.order_no);
} }
if (m.is_delete>-2) if (m.is_delete > -2)
{ {
sql += " and t1.`status` =@is_delete "; sql += " and t1.`status` =@is_delete ";
parameters.Add("is_delete", m.is_delete); parameters.Add("is_delete", m.is_delete);
......
...@@ -52,6 +52,7 @@ namespace AutoTurnOver.Models ...@@ -52,6 +52,7 @@ namespace AutoTurnOver.Models
/// sku /// sku
/// </summary> /// </summary>
public string bailun_sku { get; set; } public string bailun_sku { get; set; }
public DateTime? create_time { get; set; }
public string bailun_sku_warehouse_code { get; set; } public string bailun_sku_warehouse_code { get; set; }
/// <summary> /// <summary>
...@@ -362,7 +363,14 @@ namespace AutoTurnOver.Models ...@@ -362,7 +363,14 @@ namespace AutoTurnOver.Models
/// 工作日 /// 工作日
/// </summary> /// </summary>
public int working_days { get { public int working_days { get {
return WorkingDays(create_time,DateTime.Now); if (create_time != null)
{
return WorkingDays(create_time.Value, DateTime.Now);
}
else
{
return 0;
}
} } } }
public bool has_overdue { get public bool has_overdue { get
...@@ -431,9 +439,8 @@ namespace AutoTurnOver.Models ...@@ -431,9 +439,8 @@ namespace AutoTurnOver.Models
public string sku_name { get; set; } public string sku_name { get; set; }
public DateTime create_time { get; set; }
public string create_time_str { get { return create_time.ToString("yyyy-MM-dd HH:mm"); } } public string create_time_str { get { if (create_time == null) return ""; return create_time.Value.ToString("yyyy-MM-dd HH:mm"); } }
/// <summary> /// <summary>
/// 日均加权销量 /// 日均加权销量
......
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