Commit 59b61089 by 泽锋 李

空运切换的时候,也需要重置评价调拨天数

parent 50795701
......@@ -22,7 +22,7 @@ namespace AutoGeneratePurchaseAdvise
try
{
//PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")));
PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")));
//PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 12:00:00")));
//PurchaseAdviseServices.GenerateTemp(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 13:13:00")));
......@@ -45,7 +45,7 @@ namespace AutoGeneratePurchaseAdvise
//PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")));
//PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")));
//PurchaseAdviseServices.AutoPushBuySys(4);
new SkuAutoTurnServices().ResetPurchaseAdvise();
//new SkuAutoTurnServices().ResetPurchaseAdvise();
}
catch (Exception ex)
{
......
......@@ -20,5 +20,6 @@
"api_plat_category": "http://doc.bailuntec.com:6040/profitplatfee/getplatcategory",
"api_lms_order_transfer_sku": "http://lms.bailuntec.com/api/order/transfer/list",
"ApiLogisticsGetFilterLogisticsAssignLine": "http://lms.bailuntec.com/api/Logistics/ApiLogistics/GetFilterLogisticsAssignLine",
"api_lms_order_transfer_sku_avg": "http://lms.bailuntec.com/api/order/transfer/avglist"
"api_lms_order_transfer_sku_avg": "http://lms.bailuntec.com/api/order/transfer/avglist",
"api_lms_avg_order_transfer_list": "http://lms.bailuntec.com/api/order/transfer/avgorderlist"
}
......@@ -20,5 +20,6 @@
"api_plat_category": "http://doc.bailuntec.com:6040/profitplatfee/getplatcategory",
"api_lms_order_transfer_sku": "http://lms.bailuntec.com/api/order/transfer/list",
"ApiLogisticsGetFilterLogisticsAssignLine": "http://lms.bailuntec.com/api/Logistics/ApiLogistics/GetFilterLogisticsAssignLine",
"api_lms_order_transfer_sku_avg": "http://lms.bailuntec.com/api/order/transfer/avglist"
"api_lms_order_transfer_sku_avg": "http://lms.bailuntec.com/api/order/transfer/avglist",
"api_lms_avg_order_transfer_list": "http://lms.bailuntec.com/api/order/transfer/avgorderlist"
}
......@@ -20,5 +20,6 @@
"api_plat_category": "http://doc.bailuntec.com:6040/profitplatfee/getplatcategory",
"api_lms_order_transfer_sku": "http://10.0.8.36/api/order/transfer/list",
"ApiLogisticsGetFilterLogisticsAssignLine": "http://10.0.8.36/api/Logistics/ApiLogistics/GetFilterLogisticsAssignLine",
"api_lms_order_transfer_sku_avg": "http://10.0.8.36/api/order/transfer/avglist"
"api_lms_order_transfer_sku_avg": "http://10.0.8.36/api/order/transfer/avglist",
"api_lms_avg_order_transfer_list": "http://lms.bailuntec.com/api/order/transfer/avgorderlist"
}
\ No newline at end of file
......@@ -42,11 +42,11 @@ namespace AutoTurnOver.DB
/// <summary>
/// 切换物流商
/// </summary>
public static void ReplaceLogistics(DateTime date,string bailun_sku = null,string warehouse_code = null)
public static void ReplaceLogistics(DateTime date, string bailun_sku = null, string warehouse_code = null)
{
Console.WriteLine("查询需要切换的数据");
// 查询需要切换的数据
List<replace_logistics_outofstock_dto> ouDatas = GetOutOfStock(date,bailun_sku, warehouse_code);
List<replace_logistics_outofstock_dto> ouDatas = GetOutOfStock(date, bailun_sku, warehouse_code);
Console.WriteLine($" 查询需要切换的数据 :共:{ouDatas.Count} 条 ");
int count = 1;
// 寻找有没有满足条件的物流方案
......@@ -57,7 +57,8 @@ namespace AutoTurnOver.DB
//Console.WriteLine($"要切换的数据:第{count} 条 {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} ");
count++;
// 查询物流方案
var logisticsDatas = ApiUtility.RealTimeShipLogisticsList(new Models.ApiDto.LmsShipLogisticsRequstDto {
var logisticsDatas = ApiUtility.RealTimeShipLogisticsList(new Models.ApiDto.LmsShipLogisticsRequstDto
{
endCountries = item.country_code,
character_skus = item.bailun_sku,
startPoint = "3"
......@@ -89,6 +90,75 @@ namespace AutoTurnOver.DB
}
remarks += $" \n 默认时效 调拨天数: {item.transfer_delivery} , 入库天数:{item.abroad_inbound_delivery} 预计入库:{DateTime.Now.AddDays(item.payment_before_delivery + item.inspection_delivery + item.supplier_delivery + (int)Math.Round(item.transfer_delivery) + (int)Math.Round(item.abroad_inbound_delivery, 0)).ToString("yyyy-MM-dd")}";
remarks += $" \n 当前推荐物流平均时效 调拨天数: {Math.Round(selectItem.avg_sign_days)} , 入库天数:{Math.Round(selectItem.avg_put_days.Value, 0)} \n 预计入库 :{DateTime.Now.AddDays(item.payment_before_delivery + item.inspection_delivery + item.supplier_delivery + (int)Math.Round(selectItem.avg_sign_days) + (int)Math.Round(selectItem.avg_put_days.Value, 0)).ToString("yyyy-MM-dd")} ";
// 写入调拨历史值
dc_average_warehouse aveData = new dc_average_warehouse
{
warehouse_code = item.warehouse_code,
abroad_inbound_delivery = item.abroad_inbound_delivery,
bailun_sku = item.bailun_sku,
inbound_days = 0,
transfer_bale_delivery = item.transfer_bale_delivery,
transfer_delivery = item.transfer_delivery,
transfer_type_1_days = 0,
transfer_type_2_days = 0,
update_time = DateTime.Now
};
var oldData = _connection.QuerySingleOrDefault<dc_average_warehouse>(" select * from dc_average_warehouse where warehouse_code=@warehouse_code and bailun_sku=@bailun_sku ", new
{
warehouse_code = item.warehouse_code,
bailun_sku = item.bailun_sku
});
if (oldData != null)
{
aveData.inbound_days = oldData.inbound_days;
aveData.ID = oldData.ID;
}
if (aveData.ID > 0)
{
_connection.Update(aveData);
}
else
{
_connection.Insert(aveData);
}
//重新写入取数来源
// 查询该渠道历史单
var lmsAvg = ApiUtility.GetLmsAvgOrderTransferList(new Models.ApiDto.api_lms_order_transfer_sku_requst_dto
{
logistics_code = selectItem.logistics_code,
country = item.country_code
});
// 清空记录,重新记录数据源
_connection.Execute(" delete from dc_base_order_data_source where bailun_sku_warehouse_code=@bailun_sku_warehouse_code and order_type=@order_type ", new
{
bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}",
order_type = "调拨单-平均天数计算"
});
if (lmsAvg != null && lmsAvg.Count >= 1)
{
foreach (var itemLms in lmsAvg)
{
_connection.Insert(new dc_base_order_data_source
{
bailun_sku = item.bailun_sku,
warehouse_code = item.warehouse_code,
logistics_code = itemLms.logistics_code,
bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}",
bale_days = 1,
logistics_name = itemLms.logistics_name,
order_no = itemLms.order_no,
order_type = "调拨单-平均天数计算",
put_days = itemLms.put_days,
sign_days = itemLms.sign_days,
transport_type = itemLms.transport_type
});
}
}
_connection.Insert(new dc_auto_replace_logistics_task
{
bailun_sku = item.bailun_sku,
......@@ -115,15 +185,16 @@ namespace AutoTurnOver.DB
}
catch (Exception ex)
{
Console.WriteLine("查询需要切换的数据 : "+ex.Message );
_connection.Insert(new dc_task_error_log {
date =DateTime.Now,
message = item.ToJson() + " --- "+ex.Message,
stack_trace = ex.StackTrace,
task_name = "空运切换异常"
Console.WriteLine("查询需要切换的数据 : " + ex.Message);
_connection.Insert(new dc_task_error_log
{
date = DateTime.Now,
message = item.ToJson() + " --- " + ex.Message,
stack_trace = ex.StackTrace,
task_name = "空运切换异常"
});
}
}
......@@ -136,7 +207,7 @@ namespace AutoTurnOver.DB
{
// 每秒检查一次
Thread.Sleep(1 * 1000);
var count = _connection.QueryFirstOrDefault<int>(" select count(1) from dc_auto_replace_logistics_task where status=0 ",commandTimeout:0);
var count = _connection.QueryFirstOrDefault<int>(" select count(1) from dc_auto_replace_logistics_task where status=0 ", commandTimeout: 0);
if (count > 0)
{
WaitReplaceLogisticsTask();
......@@ -172,7 +243,7 @@ where t1.type=2 and t2.hq_type in ('第三方仓库','FBA仓') and t1.start_time
and t1.gmt_modified>=@btime
";
DynamicParameters parameters = new DynamicParameters();
parameters.Add("btime",date);
parameters.Add("btime", date);
if (!string.IsNullOrWhiteSpace(bailun_sku))
{
sql += $" and t1.bailun_sku='{bailun_sku}' ";
......@@ -425,7 +496,7 @@ INSERT into dc_aims_goods_moq(`product_inner_code`,`suppliers_id`,`warehouse_cod
dc_base_sku as t2
set t1.adv_uid = CONCAT(t2.product_inner_code,t2.suppliers_id,t1.warehouse_code)
where t1.bailun_sku = t2.bailun_sku and t1.gmt_modified>=@btime ;
",new { btime = date },commandTimeout:0);
", new { btime = date }, commandTimeout: 0);
//RedundancyDeduction("QYBLZZ", "GZBLWH");
//RedundancyDeduction("GZBLWH", "QYBLZZ");
......@@ -619,11 +690,12 @@ set t1.`fixed_unit_price` = t3.unit_price,
{
try
{
item.fixed_stock_up_days = Math.Max((int)(item.fixed_stock_up_days ?? 0M)-1,0);
item.fixed_stock_up_days = Math.Max((int)(item.fixed_stock_up_days ?? 0M) - 1, 0);
item.fixed_turnover_date_sales = (int)item.fixed_sales_explain_details.ToObj<List<decimal>>()[item.turnover_days + 7 - 1];
_connection.Execute("update dc_auto_purchase_advise_detailed set fixed_turnover_date_sales=@fixed_turnover_date_sales,fixed_stock_up_days=@fixed_stock_up_days where id=@id ", new {
id= item.id,
fixed_turnover_date_sales = item.fixed_turnover_date_sales,
_connection.Execute("update dc_auto_purchase_advise_detailed set fixed_turnover_date_sales=@fixed_turnover_date_sales,fixed_stock_up_days=@fixed_stock_up_days where id=@id ", new
{
id = item.id,
fixed_turnover_date_sales = item.fixed_turnover_date_sales,
fixed_stock_up_days = item.fixed_stock_up_days
});
}
......@@ -632,7 +704,7 @@ set t1.`fixed_unit_price` = t3.unit_price,
}
}
}
}
public static void ImportDetailedTemp(int mainID, DateTime date)
......@@ -922,7 +994,7 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
// 采购员为 张莹霞 的商品 按缺货数量下单
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
t1.bailun_sku,
'GZBLWH' as 'warehouse_code',
-1 as 'quantity_init_advise', -- 原始采购建议数量 new
......@@ -1057,7 +1129,7 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
{
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = now, no = purchase_advise.GenerateOrderNo(), type = 1, buy_sys_plan_no = "ImportYiWuShortageDetailed" }) ?? 0;
}
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
t1.bailun_sku,
t1.warehouse_code as 'source_warehouse_code',
t1.warehouse_code as 'warehouse_code',
......@@ -1125,7 +1197,7 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
{
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = now, no = purchase_advise.GenerateOrderNo(), type = 0, buy_sys_plan_no = "ImportDuLiShortageDetailed" }) ?? 0;
}
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
t1.bailun_sku,
t1.warehouse_code as 'source_warehouse_code',
'GZBLWH' as 'warehouse_code',
......@@ -1263,7 +1335,7 @@ update dc_mid_transit set quantity_out_stock =0,quantity_out_stock_aliexpress =
{
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = DateTime.Now, no = purchase_advise.GenerateOrderNo(), type = 1, buy_sys_plan_no = "ImportFuZhuangShortageIncreaseDetailed" }) ?? 0;
}
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
t1.bailun_sku,
t1.warehouse_code as 'warehouse_code',
-1 as 'quantity_init_advise', -- 原始采购建议数量 new
......@@ -1327,7 +1399,7 @@ t8.bailun_order_ids
{
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = DateTime.Now, no = purchase_advise.GenerateOrderNo(), type = 1, buy_sys_plan_no = "ImportFuZhuangShortageIncreaseDetailed" }) ?? 0;
}
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@" select
t1.bailun_sku,
t1.warehouse_code as 'warehouse_code',
-1 as 'quantity_init_advise', -- 原始采购建议数量 new
......@@ -1391,7 +1463,7 @@ t8.bailun_order_ids
{
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = DateTime.Now, no = purchase_advise.GenerateOrderNo(), type = 1, buy_sys_plan_no = "ImportFuZhuangShortageIncreaseDetailed" }) ?? 0;
}
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@"select
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@"select
t1.bailun_sku,
t1.warehouse_code as 'warehouse_code',
-1 as 'quantity_init_advise', -- 原始采购建议数量 new
......@@ -1808,7 +1880,8 @@ select * from view_purchase_advise_supplier_price as t_price where t_price.main_
if (m.is_replace_logistics == 1)
{
sql += " and t1.auto_replace_logistics_task_id >0 ";
}else if(m.is_replace_logistics == 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 ) ";
}
......
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