Commit fa11d014 by 泽锋 李

fix

parent e9cebc87
...@@ -534,7 +534,7 @@ and ( t5.`status`=0 or t5.`status` is null ) and t7.sum_quantity_init_advise>0 ...@@ -534,7 +534,7 @@ and ( t5.`status`=0 or t5.`status` is null ) and t7.sum_quantity_init_advise>0
select id from dc_auto_purchase_advise where buy_sys_plan_no in ('Generate') select id from dc_auto_purchase_advise where buy_sys_plan_no in ('Generate')
) )
and `status`=0 and bailun_sku_warehouse_code not in @bailun_sku_warehouse_codes and `status`=0 and bailun_sku_warehouse_code not in @bailun_sku_warehouse_codes
", new { bailun_sku_warehouse_codes = datas1.Select(s=>$"{s.bailun_sku}{s.warehouse_code}")}); ", new { bailun_sku_warehouse_codes = datas1.Select(s => $"{s.bailun_sku}{s.warehouse_code}") });
} }
if (datas1 != null && datas1.Count >= 1) if (datas1 != null && datas1.Count >= 1)
...@@ -624,17 +624,18 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -624,17 +624,18 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
{ {
List<dc_auto_purchase_advise_detailed> datas = new List<dc_auto_purchase_advise_detailed>(); List<dc_auto_purchase_advise_detailed> datas = new List<dc_auto_purchase_advise_detailed>();
var mother_datas = originalDatas.Where(s=>s.is_mother_map_sku==1).ToList(); var mother_datas = originalDatas.Where(s => s.is_mother_map_sku == 1).ToList();
var not_mother_datas = originalDatas.Where(s=>s.is_mother_map_sku==0).ToList(); var not_mother_datas = originalDatas.Where(s => s.is_mother_map_sku == 0).ToList();
//先清洗一波子母sku //先清洗一波子母sku
if (mother_datas!=null && mother_datas.Count>=1) if (mother_datas != null && mother_datas.Count >= 1)
{ {
// 查询母sku锁包含的子sku全部清除 // 查询母sku锁包含的子sku全部清除
var maps = _connection.Query<dc_base_mother_sku_map>(" select * from dc_base_mother_sku_map where mother_sku_warehouse_code in @mother_sku_warehouse_codes ",new { var maps = _connection.Query<dc_base_mother_sku_map>(" select * from dc_base_mother_sku_map where mother_sku_warehouse_code in @mother_sku_warehouse_codes ", new
mother_sku_warehouse_codes = mother_datas.Select(s=>s.bailun_sku_warehouse_code).ToList() {
mother_sku_warehouse_codes = mother_datas.Select(s => s.bailun_sku_warehouse_code).ToList()
}); });
if (maps != null && maps.Count()>=1) if (maps != null && maps.Count() >= 1)
{ {
foreach (var item in mother_datas) foreach (var item in mother_datas)
{ {
...@@ -645,42 +646,40 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -645,42 +646,40 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
var skuStorageCapacityList = _connection.Query<dc_base_storage_capacity>(" select * from dc_base_storage_capacity where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new var skuStorageCapacityList = _connection.Query<dc_base_storage_capacity>(" select * from dc_base_storage_capacity where bailun_sku_warehouse_code in @bailun_sku_warehouse_codes ", new
{ {
bailun_sku_warehouse_codes = itemMaps.Select(s => s.bailun_sku_warehouse_code).ToList() bailun_sku_warehouse_codes = itemMaps.Select(s => s.bailun_sku_warehouse_code).ToList()
}).Where(s=>s.stock>0).ToList(); }).Where(s => s.stock > 0).ToList();
var new_datas = new List<dc_auto_purchase_advise_detailed>(); var new_datas = new List<dc_auto_purchase_advise_detailed>();
var sum_stock = item.quantity_final_advise; var sum_stock = item.quantity_final_advise;
//根据每个有库容的sku分摊需求 //根据每个有库容的sku分摊需求
foreach (var itemStorageCapacity in skuStorageCapacityList) foreach (var itemMap in itemMaps)
{ {
var itemStorageCapacity = (skuStorageCapacityList.FirstOrDefault(s => s.bailun_sku_warehouse_code == itemMap.bailun_sku_warehouse_code) ?? new dc_base_storage_capacity() { });
if (sum_stock <= 0) break; if (sum_stock <= 0) break;
var usd_quantity = 0; var usd_quantity = 0;
if(itemStorageCapacity.stock>= sum_stock) if (itemStorageCapacity.stock >= sum_stock)
{ {
usd_quantity = sum_stock; usd_quantity = sum_stock;
sum_stock = 0; sum_stock = 0;
} }
else else
{ {
usd_quantity = (int)Math.Ceiling( itemStorageCapacity.stock); usd_quantity = (int)Math.Ceiling(itemStorageCapacity.stock);
sum_stock -= usd_quantity; sum_stock -= usd_quantity;
} }
if (usd_quantity > 0) var new_data = item.ToJson().ToObj<dc_auto_purchase_advise_detailed>();
{ new_data.quantity_init_advise = item.quantity_final_advise;
var new_data = item.ToJson().ToObj<dc_auto_purchase_advise_detailed>(); new_data.quantity_final_advise = usd_quantity;
new_data.quantity_init_advise = item.quantity_final_advise; new_data.mother_sku = item.bailun_sku;
new_data.quantity_final_advise = usd_quantity; new_data.product_inner_code = "";
new_data.mother_sku = item.bailun_sku; new_data.good_sku_codes = "";
new_data.product_inner_code = ""; new_data.is_mother_map_sku = 1;
new_data.good_sku_codes = ""; new_data.mother_sku_quantity = item.quantity_final_advise;
new_data.is_mother_map_sku = 1; new_data.mother_sku_warehouse_code = item.bailun_sku_warehouse_code;
new_data.mother_sku_quantity = item.quantity_final_advise; new_datas.Add(new_data);
new_data.mother_sku_warehouse_code = item.bailun_sku_warehouse_code;
new_datas.Add(new_data);
}
} }
if(new_datas!=null && new_datas.Count >= 1) if (new_datas != null && new_datas.Count >= 1)
{ {
// 写入子sku分摊结果 // 写入子sku分摊结果
var storage_capacity_lack_quantity = item.quantity_final_advise - new_datas.Sum(s => s.quantity_final_advise); var storage_capacity_lack_quantity = item.quantity_final_advise - new_datas.Sum(s => s.quantity_final_advise);
...@@ -701,7 +700,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -701,7 +700,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
bailun_sku_warehouse_codes = not_mother_datas.Select(s => s.bailun_sku_warehouse_code).ToList() bailun_sku_warehouse_codes = not_mother_datas.Select(s => s.bailun_sku_warehouse_code).ToList()
}).ToList(); }).ToList();
if(dc_base_storage_capacity_configs!=null && dc_base_storage_capacity_configs.Count >= 1) if (dc_base_storage_capacity_configs != null && dc_base_storage_capacity_configs.Count >= 1)
{ {
// 查询这些sku的库容 // 查询这些sku的库容
// 查询这些子sku的库容 // 查询这些子sku的库容
...@@ -711,9 +710,9 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -711,9 +710,9 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
}).Where(s => s.stock > 0).ToList(); }).Where(s => s.stock > 0).ToList();
// 把需要监控库容的按库容调整 // 把需要监控库容的按库容调整
foreach (var item in not_mother_datas.Where(s=>dc_base_storage_capacity_configs.Any(v => s.bailun_sku_warehouse_code == v.bailun_sku_warehouse_code))) foreach (var item in not_mother_datas.Where(s => dc_base_storage_capacity_configs.Any(v => s.bailun_sku_warehouse_code == v.bailun_sku_warehouse_code)))
{ {
var storageCapacity = (int)Math.Ceiling( (skuStorageCapacityList.FirstOrDefault(s => s.bailun_sku_warehouse_code == item.bailun_sku_warehouse_code) ?? new dc_base_storage_capacity()).stock); var storageCapacity = (int)Math.Ceiling((skuStorageCapacityList.FirstOrDefault(s => s.bailun_sku_warehouse_code == item.bailun_sku_warehouse_code) ?? new dc_base_storage_capacity()).stock);
var quantity_final_advise = item.quantity_final_advise; var quantity_final_advise = item.quantity_final_advise;
item.quantity_final_advise = Math.Min(quantity_final_advise, storageCapacity); item.quantity_final_advise = Math.Min(quantity_final_advise, storageCapacity);
item.storage_capacity_lack_quantity = Math.Max(0, quantity_final_advise - item.quantity_final_advise); item.storage_capacity_lack_quantity = Math.Max(0, quantity_final_advise - item.quantity_final_advise);
...@@ -721,7 +720,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -721,7 +720,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
} }
// 把不需要监控库容的补回去 // 把不需要监控库容的补回去
datas.AddRange(not_mother_datas.Where(s=>!dc_base_storage_capacity_configs.Any(v=>s.bailun_sku_warehouse_code==v.bailun_sku_warehouse_code))); datas.AddRange(not_mother_datas.Where(s => !dc_base_storage_capacity_configs.Any(v => s.bailun_sku_warehouse_code == v.bailun_sku_warehouse_code)));
} }
else else
{ {
...@@ -992,7 +991,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware ...@@ -992,7 +991,7 @@ and t1.quantity_init_advise>=0 and ( t3.buyer_name in ('张莹霞1') and t1.ware
if (mainID <= 0) if (mainID <= 0)
{ {
mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = time, no = purchase_advise.GenerateOrderNo(), buy_sys_plan_no = "ImportJITShortageDetailed",title =$" jit 缺货 {DateTime.Now.ToString("HH:mm")}" }) ?? 0; mainID = purchase_advise.Add(new dc_auto_purchase_advise { create_time = time, no = purchase_advise.GenerateOrderNo(), buy_sys_plan_no = "ImportJITShortageDetailed", title = $" jit 缺货 {DateTime.Now.ToString("HH:mm")}" }) ?? 0;
} }
var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@"select var datas = _connection.Query<dc_auto_purchase_advise_detailed>(@"select
...@@ -1884,6 +1883,14 @@ where 1=1 "; ...@@ -1884,6 +1883,14 @@ where 1=1 ";
{ {
sql += " and t1.ispush=" + (m.ispush == true ? 1 : 0); sql += " and t1.ispush=" + (m.ispush == true ? 1 : 0);
} }
if (m.is_storage_capacity_lack == 1)
{
sql += " and t1.storage_capacity_lack_quantity>0 ";
}
if (m.is_storage_capacity_lack == 0)
{
sql += " and t1.storage_capacity_lack_quantity<=0 ";
}
if (!string.IsNullOrWhiteSpace(m.warehousetype)) if (!string.IsNullOrWhiteSpace(m.warehousetype))
{ {
sql += " and t2.hq_type=" + $"'{m.warehousetype}'"; sql += " and t2.hq_type=" + $"'{m.warehousetype}'";
...@@ -1911,7 +1918,7 @@ where 1=1 "; ...@@ -1911,7 +1918,7 @@ where 1=1 ";
if (!string.IsNullOrWhiteSpace(m.main_ids)) if (!string.IsNullOrWhiteSpace(m.main_ids))
{ {
sql += $" and t1.main_id in @main_ids "; sql += $" and t1.main_id in @main_ids ";
parameters.Add("main_ids", m.main_ids.Split(',').Select(s=>int.Parse(s)).ToList()); parameters.Add("main_ids", m.main_ids.Split(',').Select(s => int.Parse(s)).ToList());
} }
if (!string.IsNullOrWhiteSpace(m.sku)) if (!string.IsNullOrWhiteSpace(m.sku))
{ {
...@@ -2217,9 +2224,10 @@ where 1=1 "; ...@@ -2217,9 +2224,10 @@ where 1=1 ";
/// <returns></returns> /// <returns></returns>
public static List<dc_auto_purchase_advise> GetToDayDatas() public static List<dc_auto_purchase_advise> GetToDayDatas()
{ {
return _connection.Query<dc_auto_purchase_advise>(" select * from dc_auto_purchase_advise where create_time>=@bdate ",new { return _connection.Query<dc_auto_purchase_advise>(" select * from dc_auto_purchase_advise where create_time>=@bdate ", new
{
bdate = DateTime.Now.ToDayHome() bdate = DateTime.Now.ToDayHome()
}).Where(s=>s.title!=null && (!s.title.Contains("刷新"))).OrderByDescending(s=>s.create_time).ToList(); }).Where(s => s.title != null && (!s.title.Contains("刷新"))).OrderByDescending(s => s.create_time).ToList();
} }
} }
......
...@@ -571,6 +571,9 @@ namespace AutoTurnOver.Models ...@@ -571,6 +571,9 @@ namespace AutoTurnOver.Models
[Description("建议单号")] [Description("建议单号")]
public string order_no { get; set; } public string order_no { get; set; }
[Description("是否缺库容")]
public int? is_storage_capacity_lack { get; set; }
[Description("是否过期")] [Description("是否过期")]
public int is_delete { get; set; } = 0; public int is_delete { get; set; } = 0;
......
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