Commit 0a708dd8 by 泽锋 李

切换了头程渠道到采购建议,单独下单

parent acfe36cc
...@@ -172,7 +172,7 @@ INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`source_warehouse_code ...@@ -172,7 +172,7 @@ INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`source_warehouse_code
`product_inner_code`,`goods_quantity_init_advise`,`goods_moq`,`good_sku_codes`,`goods_history_fourteenday_sales`,`history_fourteenday_sales`, `product_inner_code`,`goods_quantity_init_advise`,`goods_moq`,`good_sku_codes`,`goods_history_fourteenday_sales`,`history_fourteenday_sales`,
`quantity_actual`,`main_id`, `quantity_actual`,`main_id`,
`forecast_formula`,`fit_forecast_formula`,`turnover_days`,`supplier_delivery`,`inspection_delivery`,`transfer_delivery`,`sales_upper_limit`,`ispush`,`type` `forecast_formula`,`fit_forecast_formula`,`turnover_days`,`supplier_delivery`,`inspection_delivery`,`transfer_delivery`,`sales_upper_limit`,`ispush`,`type`
,`suppliers_id`,`quantity_out_stock`,`purchase_type_jit`,`auto_replace_logistics_task_id`,`logistics_code`) ,`suppliers_id`,`quantity_out_stock`,`purchase_type_jit`,`auto_replace_logistics_task_id`,`logistics_code`,`task_transport_type`)
( (
select * from ( select * from (
select select
...@@ -221,7 +221,8 @@ select ...@@ -221,7 +221,8 @@ select
end end
) as 'purchase_type_jit', ) as 'purchase_type_jit',
t1.auto_replace_logistics_task_id, t1.auto_replace_logistics_task_id,
tr_task.logistics_code tr_task.logistics_code,
tr_task.transport_type as 'task_transport_type'
from dc_auto_turnover as t1 from dc_auto_turnover as t1
left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.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 left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
...@@ -1267,6 +1268,17 @@ select * from view_purchase_advise_supplier_price as t_price where t_price.main_ ...@@ -1267,6 +1268,17 @@ select * from view_purchase_advise_supplier_price as t_price where t_price.main_
sql += " and t1.purchase_type_jit =@purchase_type_jit "; sql += " and t1.purchase_type_jit =@purchase_type_jit ";
parameters.Add("purchase_type_jit", m.purchase_type_jit); parameters.Add("purchase_type_jit", m.purchase_type_jit);
} }
if (m.is_replace_logistics != null)
{
if (m.is_replace_logistics == 1)
{
sql += " and t1.auto_replace_logistics_task_id >0 ";
}else if(m.is_replace_logistics == 0)
{
sql += " and ( t1.auto_replace_logistics_task_id <=0 or t1.auto_replace_logistics_task_id is null ) ";
}
}
if (m.is_multiple_warehouse) if (m.is_multiple_warehouse)
{ {
......
...@@ -32,6 +32,11 @@ namespace AutoTurnOver.Models.ApiDto ...@@ -32,6 +32,11 @@ namespace AutoTurnOver.Models.ApiDto
public int bp_sendtype { get; set; } public int bp_sendtype { get; set; }
/// <summary> /// <summary>
/// 头程渠道
/// </summary>
public string logistics_code { get; set; }
/// <summary>
/// 采购单类型 /// 采购单类型
/// 1 = 预计缺货 /// 1 = 预计缺货
/// 2 = 实际缺货 /// 2 = 实际缺货
......
...@@ -186,6 +186,11 @@ namespace AutoTurnOver.Models ...@@ -186,6 +186,11 @@ namespace AutoTurnOver.Models
/// </summary> /// </summary>
public string logistics_code { get; set; } public string logistics_code { get; set; }
/// <summary>
/// 推荐发送的运输方式
/// </summary>
public string task_transport_type { get; set; }
} }
...@@ -372,6 +377,7 @@ namespace AutoTurnOver.Models ...@@ -372,6 +377,7 @@ namespace AutoTurnOver.Models
/// 是否是同区多仓的sku /// 是否是同区多仓的sku
/// </summary> /// </summary>
public bool is_multiple_warehouse { get; set; } public bool is_multiple_warehouse { get; set; }
public int? is_replace_logistics { get; set; }
public decimal? quantity_final_advise_price_min { get; set; } public decimal? quantity_final_advise_price_min { get; set; }
......
...@@ -106,24 +106,41 @@ namespace AutoTurnOver.Services ...@@ -106,24 +106,41 @@ namespace AutoTurnOver.Services
private static object _push_lock = new object(); private static object _push_lock = new object();
/// <summary> /// <summary>
/// 把最新一批的采购单推送到采购系统 ///
/// </summary> /// </summary>
/// <param name="type">1= 正常推送 2= 改渠道推送</param>
/// <param name="datas"></param> /// <param name="datas"></param>
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="is_skip_error">是否跳过异常</param> /// <param name="is_skip_error">是否跳过异常</param>
public static void PushBuySys(List<dc_auto_purchase_advise_detailed_dto> original_datas, UserData user,bool is_skip_error,string remarks = "") public static void PushBuySys(int type,List<dc_auto_purchase_advise_detailed_dto> original_datas, UserData user,bool is_skip_error,string remarks = "")
{ {
lock (_push_lock) lock (_push_lock)
{ {
try try
{ {
//查询最近一个采购建议 //查询最近一个采购建议
if (original_datas == null) if (original_datas == null || original_datas.Count <= 0)
{ {
return; return;
} }
var json_datas = original_datas.ToJson().ToObject<List<dc_auto_purchase_advise_detailed_dto>>(); var json_datas = original_datas.ToJson().ToObject<List<dc_auto_purchase_advise_detailed_dto>>();
var datas = json_datas; var datas = new List<dc_auto_purchase_advise_detailed_dto>();
if (type == 1)
{
var new_remarks = ((remarks ?? "") +"系统切换更快的头程渠道:需要审核");
PushBuySys(2, original_datas, user, is_skip_error, new_remarks);
datas = json_datas.Where(s => s.auto_replace_logistics_task_id == null || s.auto_replace_logistics_task_id <= 0).ToList();
}
else if(type==2){
datas = json_datas.Where(s => s.auto_replace_logistics_task_id >0).ToList();
}
if (datas == null || datas.Count<=0)
{
return;
}
List<string> planNos = new List<string>(); List<string> planNos = new List<string>();
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
// 查询未推送成功的采购建议的明细 // 查询未推送成功的采购建议的明细
...@@ -138,33 +155,63 @@ namespace AutoTurnOver.Services ...@@ -138,33 +155,63 @@ namespace AutoTurnOver.Services
bp_sendtoCode = item.Key.warehouse_type != "国内仓" ? item.Key.warehouse_code : null, bp_sendtoCode = item.Key.warehouse_type != "国内仓" ? item.Key.warehouse_code : null,
sys_source = item.Any(s => s.type == 2) ? 2 : item.Any(s => s.type == 1) ? 1 : 3, sys_source = item.Any(s => s.type == 2) ? 2 : item.Any(s => s.type == 1) ? 1 : 3,
bi_buyplandetail = new List<bi_buyplandetail>(), bi_buyplandetail = new List<bi_buyplandetail>(),
bp_remark = $"用户{user.UserName} 在 aims 操作推送-"+ remarks bp_remark = $"用户{user.UserName} 在 aims 操作推送-"+ remarks,
logistics_code = item.Min(v=>v.logistics_code)
}; };
data.bp_sendtype = data.bp_send == 1 ? 4 : -1;
if ("FBA仓".Equals(item.Key.warehouse_type,StringComparison.OrdinalIgnoreCase)) if (type == 1)
{ {
if("美国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase)) // 走旧的运输方式逻辑
data.bp_sendtype = data.bp_send == 1 ? 4 : -1;
if ("FBA仓".Equals(item.Key.warehouse_type, StringComparison.OrdinalIgnoreCase))
{ {
data.bp_sendtype = 2; if ("美国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase))
}else if ("英国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase) {
|| "法国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase) data.bp_sendtype = 2;
|| "德国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase) }
|| "意大利".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase) else if ("英国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase)
|| "西班牙".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase) || "法国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase)
) || "德国".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase)
|| "意大利".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase)
|| "西班牙".Equals(item.Key.area_name, StringComparison.OrdinalIgnoreCase)
)
{
data.bp_sendtype = 4;
}
}
else if ("第三方仓库".Equals(item.Key.warehouse_type, StringComparison.OrdinalIgnoreCase))
{ {
data.bp_sendtype = 4; data.bp_sendtype = 3;
} }
}else if ("第三方仓库".Equals(item.Key.warehouse_type, StringComparison.OrdinalIgnoreCase))
{
data.bp_sendtype = 3;
}
var sendtype = item.Max(s => s.sendtype); var sendtype = item.Max(s => s.sendtype);
if (sendtype > 0) if (sendtype > 0)
{
data.bp_sendtype = sendtype.Value;
}
}
else if (type == 2)
{ {
data.bp_sendtype = sendtype.Value; var task_transport_type = item.Min(v => v.task_transport_type);
if (string.IsNullOrWhiteSpace(task_transport_type))
{
throw new Exception("命中只能切换物流的规则,未查询到运输方式");
}
if (task_transport_type == "海运")
{
data.bp_sendtype = 2;
}else if (task_transport_type == "空运")
{
data.bp_sendtype = 3;
}else if (task_transport_type == "陆运")
{
data.bp_sendtype = 1;
}else if (task_transport_type == "铁路运输")
{
data.bp_sendtype = 4;
}
} }
data.bi_buyplandetail = item.GroupBy(s=>s.bailun_sku).Select(s => new bi_buyplandetail data.bi_buyplandetail = item.GroupBy(s=>s.bailun_sku).Select(s => new bi_buyplandetail
{ {
...@@ -264,15 +311,15 @@ namespace AutoTurnOver.Services ...@@ -264,15 +311,15 @@ namespace AutoTurnOver.Services
if (amazon_datas != null && amazon_datas.Count > 0) if (amazon_datas != null && amazon_datas.Count > 0)
{ {
PushBuySys(amazon_datas, user, is_skip_error, "亚马逊"); PushBuySys(1,amazon_datas, user, is_skip_error, "亚马逊");
} }
if (ali_datas!=null && ali_datas.Count > 0) if (ali_datas!=null && ali_datas.Count > 0)
{ {
PushBuySys(ali_datas, user, is_skip_error,"速卖通"); PushBuySys(1,ali_datas, user, is_skip_error,"速卖通");
} }
if (other_datas != null && other_datas.Count > 0) if (other_datas != null && other_datas.Count > 0)
{ {
PushBuySys(other_datas, user, is_skip_error,"其他"); PushBuySys(1,other_datas, user, is_skip_error,"其他");
} }
} }
...@@ -294,11 +341,11 @@ namespace AutoTurnOver.Services ...@@ -294,11 +341,11 @@ namespace AutoTurnOver.Services
if (alone_datas != null && alone_datas.Count > 0) if (alone_datas != null && alone_datas.Count > 0)
{ {
PushBuySys(alone_datas, user, is_skip_error,"ebay+wish"); PushBuySys(1,alone_datas, user, is_skip_error,"ebay+wish");
} }
if (other_datas != null && other_datas.Count > 0) if (other_datas != null && other_datas.Count > 0)
{ {
PushBuySys(other_datas, user, is_skip_error,"其他"); PushBuySys(1,other_datas, user, is_skip_error,"其他");
} }
} }
...@@ -351,7 +398,7 @@ namespace AutoTurnOver.Services ...@@ -351,7 +398,7 @@ namespace AutoTurnOver.Services
} }
else else
{ {
PurchaseAdviseServices.PushBuySys(datas, new UserData { UserName = "admin" }, true); PurchaseAdviseServices.PushBuySys(1,datas, new UserData { UserName = "admin" }, true);
} }
} }
......
...@@ -62,7 +62,7 @@ namespace AutoTurnOver.Controllers ...@@ -62,7 +62,7 @@ namespace AutoTurnOver.Controllers
[HttpGet] [HttpGet]
public string DetailList(int limit, int offset, int main_id, string sort, string sku, string warehousecode, public string DetailList(int limit, int offset, int main_id, string sort, string sku, string warehousecode,
DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea, string order, DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea, string order,
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool? is_multiple_warehouse = false, bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool? is_multiple_warehouse = false,int? is_replace_logistics = null,
decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null,int? purchase_type_jit = null) decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null,int? purchase_type_jit = null)
{ {
var m = new dc_auto_purchase_advise_detailed_search_dto var m = new dc_auto_purchase_advise_detailed_search_dto
...@@ -80,6 +80,7 @@ namespace AutoTurnOver.Controllers ...@@ -80,6 +80,7 @@ namespace AutoTurnOver.Controllers
purchase_user = purchase_user, purchase_user = purchase_user,
product_inner_code = product_inner_code, product_inner_code = product_inner_code,
is_multiple_warehouse = is_multiple_warehouse.Value, is_multiple_warehouse = is_multiple_warehouse.Value,
is_replace_logistics = is_replace_logistics,
quantity_final_advise_price_max = quantity_final_advise_price_max, quantity_final_advise_price_max = quantity_final_advise_price_max,
quantity_final_advise_price_min = quantity_final_advise_price_min, quantity_final_advise_price_min = quantity_final_advise_price_min,
purchase_type_jit = purchase_type_jit purchase_type_jit = purchase_type_jit
...@@ -109,7 +110,7 @@ namespace AutoTurnOver.Controllers ...@@ -109,7 +110,7 @@ namespace AutoTurnOver.Controllers
[BrowseLog("Bailun_aims", "访问【百伦自动周转系统】->【自动下单管理】->【采购建议列表】->【搜索】页面", 0)] [BrowseLog("Bailun_aims", "访问【百伦自动周转系统】->【自动下单管理】->【采购建议列表】->【搜索】页面", 0)]
public JsonResult DetailListSumFooter(int limit, int offset, int main_id, string sort, string sku, string warehousecode, public JsonResult DetailListSumFooter(int limit, int offset, int main_id, string sort, string sku, string warehousecode,
DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea, DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea,
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool is_multiple_warehouse = false, bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool is_multiple_warehouse = false, int? is_replace_logistics = null,
decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null,int? purchase_type_jit = null decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null,int? purchase_type_jit = null
) )
{ {
...@@ -129,6 +130,7 @@ namespace AutoTurnOver.Controllers ...@@ -129,6 +130,7 @@ namespace AutoTurnOver.Controllers
product_inner_code = product_inner_code, product_inner_code = product_inner_code,
isSum = true, isSum = true,
is_multiple_warehouse = is_multiple_warehouse, is_multiple_warehouse = is_multiple_warehouse,
is_replace_logistics = is_replace_logistics,
quantity_final_advise_price_max = quantity_final_advise_price_max, quantity_final_advise_price_max = quantity_final_advise_price_max,
quantity_final_advise_price_min = quantity_final_advise_price_min, quantity_final_advise_price_min = quantity_final_advise_price_min,
purchase_type_jit = purchase_type_jit purchase_type_jit = purchase_type_jit
...@@ -148,7 +150,7 @@ namespace AutoTurnOver.Controllers ...@@ -148,7 +150,7 @@ namespace AutoTurnOver.Controllers
/// <returns></returns> /// <returns></returns>
public FileResult Export(int limit, int offset, int main_id, string sort, string sku, string warehousecode, public FileResult Export(int limit, int offset, int main_id, string sort, string sku, string warehousecode,
DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea, DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea,
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool is_multiple_warehouse = false, bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool is_multiple_warehouse = false, int? is_replace_logistics = null,
decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null,int? purchase_type_jit = null decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null,int? purchase_type_jit = null
) )
{ {
...@@ -168,6 +170,7 @@ namespace AutoTurnOver.Controllers ...@@ -168,6 +170,7 @@ namespace AutoTurnOver.Controllers
product_inner_code = product_inner_code, product_inner_code = product_inner_code,
isSum = false, isSum = false,
is_multiple_warehouse = is_multiple_warehouse, is_multiple_warehouse = is_multiple_warehouse,
is_replace_logistics = is_replace_logistics,
quantity_final_advise_price_max = quantity_final_advise_price_max, quantity_final_advise_price_max = quantity_final_advise_price_max,
quantity_final_advise_price_min = quantity_final_advise_price_min, quantity_final_advise_price_min = quantity_final_advise_price_min,
purchase_type_jit = purchase_type_jit purchase_type_jit = purchase_type_jit
...@@ -326,7 +329,7 @@ namespace AutoTurnOver.Controllers ...@@ -326,7 +329,7 @@ namespace AutoTurnOver.Controllers
var total = 0; var total = 0;
var list = PurchaseAdviseServices.DetailList(m, 0, int.MaxValue, ref total); var list = PurchaseAdviseServices.DetailList(m, 0, int.MaxValue, ref total);
PurchaseAdviseServices.PushBuySys(list, AutoUtility.GetUser(), false); PurchaseAdviseServices.PushBuySys(1,list, AutoUtility.GetUser(), false);
return new JsonResult(new return new JsonResult(new
......
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