Commit 78cfae17 by lizefeng

修改缺货改零推送接口字段

parent 4961287d
using AutoTurnOver.Services;
using AutoTurnOver.DB;
using AutoTurnOver.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
......@@ -12,7 +13,7 @@ namespace AutoGeneratePurchaseAdvise
{
Console.WriteLine("采购建议计算任务启动...");
// 创建采购计划
//PurchaseAdviseServices.Generate();
//purchase_advise.ImportJITShortageDetailed(141);
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<GeneratePurchaseAdviseBackgroundService>();
......
......@@ -160,6 +160,17 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
}
ImportJITShortageDetailed(mainID);
ImportFuZhuangShortageDetailed(mainID);
}
/// <summary>
/// 导入缺货明细
/// </summary>
/// <param name="mainID"></param>
public static void ImportJITShortageDetailed(int mainID)
{
// 采购员为 赵美聪 的商品 按缺货数量下单
_connection.Execute(@" INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quantity_init_advise`,`quantity_final_advise`,
`product_inner_code`,`goods_quantity_init_advise`,`goods_moq`,`good_sku_codes`,`goods_history_fourteenday_sales`,`history_fourteenday_sales`,
......@@ -195,13 +206,60 @@ where t2.`status`=2 and t1.bailun_sku = t2.bailun_sku and quantity_final_advise=
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_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_mid_transit as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
where t6.`status`=2 and ( ( t6.buyer_name in ('赵美聪','张莹霞','张莹霞1') and t1.warehouse_code in ('GZBLWH','GZBLYS') ) or t1.warehouse_code='BLGZ03' )
where t6.`status`=2 and ( ( t6.buyer_name in ('张莹霞','张莹霞1') and t1.warehouse_code in ('GZBLWH','GZBLYS') ) or t1.warehouse_code='BLGZ03' )
and ( t5.`status`=0 or t5.`status` is null )
GROUP BY t1.bailun_sku
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t7.quantity_out_stock) )
) ", new { main_id = mainID }, commandTimeout: 0);
}
/// <summary>
/// 导入缺货明细 (服装)
/// </summary>
/// <param name="mainID"></param>
public static void ImportFuZhuangShortageDetailed(int mainID)
{
_connection.Execute(@" INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quantity_init_advise`,`quantity_final_advise`,
`product_inner_code`,`goods_quantity_init_advise`,`goods_moq`,`good_sku_codes`,`goods_history_fourteenday_sales`,`history_fourteenday_sales`,
`quantity_actual`,`main_id`,
`forecast_formula`,`fit_forecast_formula`,`turnover_days`,`supplier_delivery`,`inspection_delivery`,`transfer_delivery`,`sales_upper_limit`,`ispush`,`type`,`suppliers_id`,`quantity_out_stock`)
(
select
t1.bailun_sku,
'GZBLWH' as 'warehouse_code',
sum(t1.quantity_init_advise) as 'quantity_init_advise', -- 原始采购建议数量 new
( sum(t7.quantity_out_stock) - ( sum((case when t7.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) ) ) as 'quantity_final_advise', -- 计算moq之后的数量 new
t6.product_inner_code as 'product_inner_code', -- 内部商品编码 new
0 as 'goods_quantity_init_advise', -- 商品本次的建议下单数量 new
0 as 'goods_moq', -- 商品的moq new
0 as 'good_sku_codes', -- 商品涉及的下单所有sku new
0 as 'goods_history_fourteenday_sales', -- 商品的最近14日总日均销量
t1.history_fourteenday_sales as 'history_fourteenday_sales', -- sku的最近14日日均
0 as 'quantity_actual', -- 真实下单数量
@main_id as 'main_id',
t2.forecast_formula as 'forecast_formula',
t2.fit_forecast_formula as 'fit_forecast_formula',
t1.turnover_days,
t1.supplier_delivery,
t1.inspection_delivery,
t1.transfer_delivery,
t1.sales_upper_limit,
0 as 'ispush',
2 as 'type',
t6.suppliers_id,
t7.quantity_out_stock
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_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_mid_transit as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
where t6.`status`=2 and ( ( t6.buyer_name in ('赵美聪') and t1.warehouse_code in ('GZBLWH','GZBLYS') ) or t1.warehouse_code='BLGZ03' )
and ( t5.`status`=0 or t5.`status` is null )
GROUP BY t1.bailun_sku
HAVING ( sum((case when t7.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t7.quantity_out_stock) )
) ", new { main_id = mainID }, commandTimeout: 0);
}
......
......@@ -458,12 +458,13 @@ where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹
t1.bailun_sku,
t1.warehouse_code,
now() as 'push_date',
1 as 'type'
1 as 'type',
(case when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') then t5.usable_stock else ifnull(t3.sum_usable_stock,0) end ) as 'stocks'
from dc_mid_transit as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where
t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL')
and ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') )
......@@ -476,6 +477,7 @@ and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push
string no_library_sql = @"select t1.bailun_sku,
t1.warehouse_code,
now() as 'push_date',
0 as 'stocks',
2 as 'type' from dc_base_stock as t1
left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
......
......@@ -7,6 +7,11 @@ namespace AutoTurnOver.Models.ApiDto
public class ShortagePush_RequestDto
{
public List<ShortagePush_Item_RequestDto> amisSkuInfos { get; set;}
/// <summary>
/// sku类型 1.库存为零的sku 2.缺货
/// </summary>
public int skuType { get; set; }
}
public class ShortagePush_Item_RequestDto
......@@ -14,6 +19,11 @@ namespace AutoTurnOver.Models.ApiDto
public string sku { get; set; }
public string warehouseCode { get; set; }
/// <summary>
/// 库存
/// </summary>
public int stocks { get; set; }
}
public class ShortagePush_ResponseDto
......
......@@ -26,5 +26,7 @@ namespace AutoTurnOver.Models
///2 = 0 库存
/// </summary>
public int type { get; set; }
public decimal stocks { get; set; }
}
}
......@@ -376,26 +376,36 @@ namespace AutoTurnOver.Services
/// <summary>
/// 缺货推送 (分页推送)
/// </summary>
public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> datas)
public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> shortage_pushs)
{
var err_datas = new List<ShortagePush_Item_RequestDto>();
if (datas.Count <= 0) return new List<ShortagePush_Item_RequestDto>() ;
if (shortage_pushs.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);
int totalPage = (int)Math.Ceiling(datas.Count() * 1.0 / rows);
while (page <= totalPage)
{
var result = ShortagePushApi(new ShortagePush_RequestDto { amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s=>new ShortagePush_Item_RequestDto {
var result = ShortagePushApi(new ShortagePush_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
}).ToList()} );
if(!result.isSucceeded && result.objData.Count >= 1)
warehouseCode = s.warehouse_code,
stocks = s.stocks
}).ToList()
});
if (!result.isSucceeded && result.objData.Count >= 1)
{
err_datas.AddRange(result.objData);
}
page++;
}
}
return err_datas;
}
......
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