Commit 2a5620a5 by lizefeng

修改缺货改零的规则

parent 2f3eab4e
...@@ -676,7 +676,12 @@ end ...@@ -676,7 +676,12 @@ end
string sql = @"select string sql = @"select
t1.bailun_sku, t1.bailun_sku,
t1.warehouse_code, t1.warehouse_code,
now() as 'push_time' now() as 'push_time',
(case
when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') then IFNULL(t4.sum_usable_stock, 0) - IFNULL(t5.sum_unshipped_quantity, 0)
else t_stock.usable_stock - ifnull(t3.quantity_unshipped,0)
end
) as 'stocks'
from dc_auto_shortage_push as t1 from dc_auto_shortage_push as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_mid_transit as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code left join dc_mid_transit as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
...@@ -687,7 +692,7 @@ left join dc_base_stock as t_stock on t1.bailun_sku = t_stock.bailun_sku and t1. ...@@ -687,7 +692,7 @@ left join dc_base_stock as t_stock on t1.bailun_sku = t_stock.bailun_sku and t1.
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
where 1=1 where 1=1
and (case and (case
when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') and(ifnull(t4.sum_usable_stock, 0) - ifnull(t5.sum_unshipped_quantity, 0) > 0) then 1 when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') and (ifnull(t4.sum_usable_stock, 0) - ifnull(t5.sum_unshipped_quantity, 0) > 0) then 1
when(t3.quantity_out_stock is null or t3.quantity_out_stock <= 0) and ifnull(t_stock.usable_stock,0)> ifnull(t3.quantity_unshipped, 0) then 1 when(t3.quantity_out_stock is null or t3.quantity_out_stock <= 0) and ifnull(t_stock.usable_stock,0)> ifnull(t3.quantity_unshipped, 0) then 1
else 0 else 0
end end
......
...@@ -9,7 +9,7 @@ namespace AutoTurnOver.Models.ApiDto ...@@ -9,7 +9,7 @@ namespace AutoTurnOver.Models.ApiDto
public List<ShortagePush_Item_RequestDto> amisSkuInfos { get; set;} public List<ShortagePush_Item_RequestDto> amisSkuInfos { get; set;}
/// <summary> /// <summary>
/// sku类型 1.库存为零的sku 2.缺货 /// sku类型 1.库存为零的sku 2.有库存
/// </summary> /// </summary>
public int skuType { get; set; } public int skuType { get; set; }
} }
...@@ -23,7 +23,7 @@ namespace AutoTurnOver.Models.ApiDto ...@@ -23,7 +23,7 @@ namespace AutoTurnOver.Models.ApiDto
/// <summary> /// <summary>
/// 库存 /// 库存
/// </summary> /// </summary>
public decimal stocks { get; set; } public int stocks { get; set; }
} }
public class ShortagePush_ResponseDto public class ShortagePush_ResponseDto
......
...@@ -27,6 +27,6 @@ namespace AutoTurnOver.Models ...@@ -27,6 +27,6 @@ namespace AutoTurnOver.Models
/// </summary> /// </summary>
public int type { get; set; } public int type { get; set; }
public decimal stocks { get; set; } public int stocks { get; set; }
} }
} }
...@@ -13,5 +13,7 @@ namespace AutoTurnOver.Models ...@@ -13,5 +13,7 @@ namespace AutoTurnOver.Models
public string warehouse_code { get; set; } public string warehouse_code { get; set; }
public DateTime push_time { get; set; } public DateTime push_time { get; set; }
public int stocks { get; set; }
} }
} }
...@@ -376,34 +376,31 @@ namespace AutoTurnOver.Services ...@@ -376,34 +376,31 @@ namespace AutoTurnOver.Services
/// <summary> /// <summary>
/// 缺货推送 (分页推送) /// 缺货推送 (分页推送)
/// </summary> /// </summary>
public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> shortage_pushs) public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> datas)
{ {
var err_datas = new List<ShortagePush_Item_RequestDto>(); var err_datas = new List<ShortagePush_Item_RequestDto>();
if (shortage_pushs.Count <= 0) return new List<ShortagePush_Item_RequestDto>(); if (datas.Count <= 0) return new List<ShortagePush_Item_RequestDto>();
foreach (var datas in shortage_pushs.GroupBy(s => s.type)) int page = 1;
int rows = 1000;
int totalPage = (int)Math.Ceiling(datas.Count() * 1.0 / rows);
while (page <= totalPage)
{ {
int page = 1; var result = ShortagePushApi(new ShortagePush_RequestDto
int rows = 1000;
int totalPage = (int)Math.Ceiling(datas.Count() * 1.0 / rows);
while (page <= totalPage)
{ {
var result = ShortagePushApi(new ShortagePush_RequestDto skuType = 1,
{ amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto
skuType = datas.Key == 1 ? 2 : 1,
amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto
{
sku = s.bailun_sku,
warehouseCode = s.warehouse_code,
stocks = s.stocks
}).ToList()
});
if (!result.isSucceeded && result.objData.Count >= 1)
{ {
err_datas.AddRange(result.objData); sku = s.bailun_sku,
} warehouseCode = s.warehouse_code,
page++; stocks = s.stocks
}).ToList()
});
if (!result.isSucceeded && result.objData.Count >= 1)
{
err_datas.AddRange(result.objData);
} }
page++;
} }
...@@ -440,8 +437,10 @@ namespace AutoTurnOver.Services ...@@ -440,8 +437,10 @@ namespace AutoTurnOver.Services
{ {
var result = ReturnGoodsPushApi(new ShortagePush_RequestDto var result = ReturnGoodsPushApi(new ShortagePush_RequestDto
{ {
skuType = 2,
amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto
{ {
stocks = s.stocks,
sku = s.bailun_sku, sku = s.bailun_sku,
warehouseCode = s.warehouse_code warehouseCode = s.warehouse_code
}).ToList() }).ToList()
......
...@@ -28,9 +28,10 @@ namespace ShortagePush ...@@ -28,9 +28,10 @@ namespace ShortagePush
{ {
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")}");
new ReportServices().ShortagePush(); new ReportServices().ShortagePush();
new ReportServices().ReturnGoodsPush();
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")}");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
......
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