Commit ea8c49c3 by lizefeng

实时缺货明细,新增账号可筛选,汇总订单数量

parent bc0c496c
......@@ -18,5 +18,5 @@
<ProjectReference Include="..\AutoTurnOver.Utility\AutoTurnOver.Utility.csproj" />
</ItemGroup>
</Project>
......@@ -42,9 +42,6 @@ namespace AutoTurnOver.DB
var configuration = configurationBuilder.Build();
_connStr = configuration.GetConnectionString("Default");
//var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
//var configurationRoot = builder.Build();
//_connStr = ConfigHelper.GetValue("cnstr");
return _connStr;
}
}
......
......@@ -25,6 +25,7 @@ select t1.*,t2.quantity_out_stock,
t3.buyer_name,
t4.estimated_arrival_time,
t4.purchase_id,
t3.sku_title_cn,
(case when (t4.quantity_purchase>t4.quantity_inbound) and now()>t4.estimated_arrival_time then 1 else 0 end) as 'is_overdue',
t4.deliver_name
from
......@@ -43,8 +44,9 @@ where 1 = 1
else
{
sql = @"
select t1.* from dc_auto_forecast_fluctuation as t1
select t1.*,t3.sku_title_cn from dc_auto_forecast_fluctuation as t1
inner JOIN dc_auto_turnover as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
where 1 = 1
";
......
......@@ -187,7 +187,7 @@ where 1=1 ";
total = _connection.ExecuteScalar<int>(sqlCount);
//设置默认排序字段
if (string.IsNullOrWhiteSpace(sort)) sort = "quantity_init_advise";
if (string.IsNullOrWhiteSpace(sort)) sort = "dat.id";
if (!string.IsNullOrEmpty(sort))
{
sql += " order by " + sort;
......
......@@ -146,7 +146,22 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where 1=1
";
sql = @"
if (m.isSum)
{
sql = @"
select
count(DISTINCT t1.origin_order_id) as 'sum_order_count',
count(DISTINCT case when t2.quantity_out_stock>0 then t1.bailun_sku else null end) as 'sum_sku_count'
from dc_base_oms_sku_outofstock as t1
left join dc_mid_transit as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where 1=1
";
}
else
{
sql = @"
select
t2.gmt_out_stock_modified,
t1.origin_order_id,
......@@ -188,6 +203,14 @@ left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku an
left join view_buy_ontheway_detail as t8 on t1.bailun_sku = t8.bailun_sku and t1.warehouse_code = t8.warehouse_code
where 1=1
";
}
if (m.bailun_account_id != null)
{
sql += " and t1.bailun_account_id=@bailun_account_id ";
countSql += " and t1.bailun_account_id=@bailun_account_id ";
parameters.Add("bailun_account_id", m.bailun_account_id);
}
if (!string.IsNullOrWhiteSpace(m.product_inner_code))
{
sql += " and t6.product_inner_code=@product_inner_code ";
......@@ -223,7 +246,7 @@ where 1=1
parameters.Add("buyer_name", m.purchase_user);
}
if (limit > 10000)
if (limit > 10000 || m.isSum)
{
total = 0;
}
......@@ -346,5 +369,10 @@ truncate table china_warehouse_unshipped_temp; ", commandTimeout: 0);
}
}
public static void AddError(dc_task_error_log data)
{
_connection.Insert(data);
}
}
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
/// <summary>
/// 账号数据
/// </summary>
public class AccountDto
{
public int Id { get; set; }
public string Account { get; set; }
public string OmsAccount { get; set; }
public string EmailAccount { get; set; }
public string PlatformEn { get; set; }
public string SiteEn { get; set; }
}
public class AccountResultDto
{
public bool Success { get; set; }
public string Message { get; set; }
public List<AccountDto> Data { get; set; }
}
}
......@@ -184,7 +184,10 @@ namespace AutoTurnOver.Models.Report
no = buy_array[0].Trim(),
count = int.Parse(buy_array[1].Trim()),
inbound = int.Parse(buy_array[2].Trim()),
arrival_date = DateTime.Parse(buy_array[3].Trim())
arrival_date = DateTime.Parse(buy_array[3].Trim()),
supplier_name = buy_array[4].Trim(),
alibaba_order_id = buy_array[5].Trim(),
logistics_order_id = buy_array[6].Trim(),
});
}
......@@ -192,6 +195,9 @@ namespace AutoTurnOver.Models.Report
}
}
}
public int sum_order_count { get; set; }
public int sum_sku_count { get; set; }
}
public class quantity_out_stock_detail_search_dto
......@@ -207,6 +213,8 @@ namespace AutoTurnOver.Models.Report
public string product_inner_code { get; set; }
public string purchase_user { get; set; }
public int? bailun_account_id { get; set;}
public bool isSum { get; set; }
}
......@@ -216,5 +224,11 @@ namespace AutoTurnOver.Models.Report
public int count { get; set; }
public int inbound { get; set; }
public DateTime arrival_date { get; set; }
public string supplier_name { get; set; }
public string alibaba_order_id { get; set; }
public string logistics_order_id { get; set; }
}
}
......@@ -85,6 +85,8 @@ namespace AutoTurnOver.Models
/// </summary>
public int purchase_advise_count { get; set; }
public string sku_title_cn { get; set; }
/// <summary>
/// 采购在途
/// </summary>
......
......@@ -261,6 +261,10 @@ namespace AutoTurnOver.Models
}
}
public decimal history_sevenday_sales_ebay { get; set; }
public decimal history_fourteenday_sales_ebay { get; set; }
public decimal history_thirtyday_sales_ebay { get; set; }
}
public class Condition_AutoTurnOver
......
......@@ -6,6 +6,8 @@ using System.Configuration;
using System.Net;
using System.Text;
using System.Linq;
using AutoTurnOver.Models;
using AutoTurnOver.DB;
namespace AutoTurnOver.Services
{
......@@ -143,5 +145,60 @@ namespace AutoTurnOver.Services
}
return result;
}
/// <summary>
/// 推送采购计划
/// </summary>
public static List<AccountDto> AccountList()
{
//查询采购建议明细
return RedisHelper.Get(RedisConsts.Pams_GetAccountToken, () =>
{
string url = ConfigHelper.GetValue("Pams_GetAccountToken");
string resultStr = HttpHelper.Request(url, RequestType.GET, "", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<AccountResultDto>();
if (result == null)
{
throw new Exception("账号系统异常: 未获取到数据");
}
if (!result.Success)
{
throw new Exception("账号系统异常: " + result.Message);
}
return result.Data;
});
}
public static List<AccountDto> AccountList(string name)
{
try
{
if (string.IsNullOrWhiteSpace(name)) return AccountList();
return AccountList().Where(s =>
(s.OmsAccount ?? "").Contains(name, StringComparison.OrdinalIgnoreCase)
||
(s.EmailAccount ?? "").Contains(name, StringComparison.OrdinalIgnoreCase)
||
(s.Account ?? "").Contains(name, StringComparison.OrdinalIgnoreCase)
).ToList();
}
catch (Exception ex)
{
report.AddError(new dc_task_error_log
{
date = DateTime.Now,
message = ex.Message,
stack_trace = ex.StackTrace,
task_name = "account_api"
});
throw;
}
}
}
}
......@@ -6,9 +6,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bailun.ServiceFabric.Redis" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Utility
{
public class RedisConsts
{
public static string Pams_GetAccountToken = "Pams_GetAccountToken";
}
}
using Bailun.ServiceFabric.Extension;
using Bailun.ServiceFabric.Redis;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace AutoTurnOver.Utility
{
public class RedisHelper
{
public static T Get<T>(string name, Func<T> getData, int ticks = 0) where T : class
{
var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{environmentName}.json", true, reloadOnChange: true);
var configuration = configurationBuilder.Build();
ConfigManagerConf.SetConfiguration(configuration);
var _cache = CacheManagerFactory.GetCacheManager();
object cache = _cache.Get<T>(name);
if (cache == null)
{
cache = getData();
if (!string.IsNullOrEmpty(cache.ToString()))
{
_cache.Add(name, cache);
if (ticks <= 0)
{
_cache.SetExpire(name, new TimeSpan(1, 0, 0, 0)); //设置一天缓存
}
else
_cache.SetExpire(name, new TimeSpan(ticks));
}
else
return default(T);
}
return (T)cache;
}
}
}
......@@ -8,6 +8,7 @@ using AutoTurnOver.Services;
using Microsoft.AspNetCore.Cors;
using System.Net;
using AutoTurnOver.Common;
using AutoTurnOver.DB;
namespace AutoTurnOver.Controllers
{
......@@ -87,10 +88,30 @@ namespace AutoTurnOver.Controllers
}));
}
public JsonResult AccountList(string name)
{
try
{
var list = ApiServices.AccountList(name);
return new JsonResult(list.Select(p => new
{
id = p.Id,
text = p.PlatformEn + " - " + p.Account
}));
}
catch (Exception ex)
{
throw;
}
}
/// <summary>
/// 获取一二级的百伦数据
/// </summary>
......
......@@ -62,7 +62,7 @@ namespace AutoTurnOver.Controllers
var list = service.List(m, 0, int.MaxValue, ref total, order, sort);
DataTable table = new DataTable();
string[] cols = new string[] { "Sku","仓库编码","仓库名称","最近3日日均","异常类型","开始时间",
string[] cols = new string[] { "Sku","中文名称","仓库编码","仓库名称","最近3日日均","异常类型","开始时间",
"总缺货数","在途数量","采购员","预计到货","bi 采购单号","供应商","逾期状态",
"结束时间","是否确认","确认人","预计解决时间",
"处理方案","是否解决"
......@@ -77,6 +77,7 @@ namespace AutoTurnOver.Controllers
DataRow row = table.NewRow();
row["Sku"] = itemData.bailun_sku;
row["中文名称"] = itemData.sku_title_cn;
row["仓库编码"] = itemData.warehouse_code;
row["仓库名称"] = itemData.warehouse_name;
row["最近3日日均"] = itemData.avg_sales_three;
......
......@@ -226,7 +226,7 @@ namespace AutoTurnOver.Controllers
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <returns></returns>
public JsonResult QuantityOutStockDetailList(string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
public JsonResult QuantityOutStockDetailList(int? bailun_account_id, string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
{
var m = new quantity_out_stock_detail_search_dto
{
......@@ -235,7 +235,8 @@ namespace AutoTurnOver.Controllers
purchase_user = purchase_user,
warehousearea = warehousearea,
warehousetype = warehousetype,
warehouse_code = warehousecode
warehouse_code = warehousecode,
bailun_account_id = bailun_account_id
};
var services = new ReportServices();
var total = 0;
......@@ -249,13 +250,33 @@ namespace AutoTurnOver.Controllers
}
public JsonResult QuantityOutStockDetailFooter(int? bailun_account_id, string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
{
var m = new quantity_out_stock_detail_search_dto
{
bailun_sku = bailun_sku,
product_inner_code = product_inner_code,
purchase_user = purchase_user,
warehousearea = warehousearea,
isSum = true,
warehousetype = warehousetype,
warehouse_code = warehousecode,
bailun_account_id = bailun_account_id
};
var services = new ReportServices();
var total = 0;
var list = services.QuantityOutStockDetailList(m, offset, limit, ref total, order: order, sort: sort);
return new JsonResult(list == null || list.Count <= 0 ? new quantity_out_stock_detail_dto() : list[0]);
}
/// <summary>
/// 导出实时缺货
/// </summary>
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public FileResult QuantityOutStockDetailExport(string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
public FileResult QuantityOutStockDetailExport(int? bailun_account_id, string bailun_sku, string warehousecode, string product_inner_code, string purchase_user, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
{
var m = new quantity_out_stock_detail_search_dto
{
......@@ -264,7 +285,8 @@ namespace AutoTurnOver.Controllers
purchase_user = purchase_user,
warehousearea = warehousearea,
warehousetype = warehousetype,
warehouse_code = warehousecode
warehouse_code = warehousecode,
bailun_account_id = bailun_account_id
};
var services = new ReportServices();
var total = 0;
......@@ -273,7 +295,7 @@ namespace AutoTurnOver.Controllers
DataTable table = new DataTable();
string[] cols = new string[] { "缺货统计时间", "平台订单号", "平台类型", "百伦订单号", "付款交易号", "站点", "付款时间", "销售账号","国家","sku",
"产品名称", "订单sku销量", "发货仓库编码","发货仓库", "是否缺货", "仓库总缺货", "国内仓总缺货", "其他有库存仓库", "其他仓库库存数","国内仓是否缺货","采购员",
"平台物流方式", "发货物流方式", "sku监控状态", "销售状态", "总在途库存数", "最先到货采购单","最快到货时间"
"平台物流方式", "发货物流方式", "sku监控状态", "销售状态", "总在途库存数", "最先到货采购单","最快到货时间","采购单供应商","采购单阿里巴巴单号","采购单物流单号"
};
foreach (var item in cols)
{
......@@ -312,6 +334,9 @@ namespace AutoTurnOver.Controllers
row["总在途库存数"] = itemData.quantity_ontheway;
row["最先到货采购单"] = itemData.min_buy.no;
row["最快到货时间"] = itemData.min_buy.arrival_date;
row["采购单供应商"] = itemData.min_buy.supplier_name;
row["采购单阿里巴巴单号"] = itemData.min_buy.alibaba_order_id;
row["采购单物流单号"] = itemData.min_buy.logistics_order_id;
table.Rows.Add(row);
}
......
......@@ -73,6 +73,7 @@ namespace AutoTurnOver.Controllers
p.quantity_transfer,
p.forecast_fourteenday_sales,
p.forecast_sevenday_sales,
p.history_thirtyday_sales,
p.oneday_sales,
p.forecast_oneday_sales2,
p.product_inner_code,
......@@ -81,7 +82,11 @@ namespace AutoTurnOver.Controllers
p.history_fourteenday_sales,
p.history_sevenday_sales,
p.monitor_status,
p.suppliers_name
p.suppliers_name,
p.history_sevenday_sales_ebay,
p.history_fourteenday_sales_ebay,
p.history_thirtyday_sales_ebay
});
return new JsonResult(new
......@@ -181,14 +186,17 @@ namespace AutoTurnOver.Controllers
p.unit_price,
p.weight,
p.usable_stock,
p.suppliers_name
p.suppliers_name,
p.history_sevenday_sales_ebay,
p.history_fourteenday_sales_ebay,
p.history_thirtyday_sales_ebay
});
DataTable table = new DataTable();
string[] cols = new string[] { "Sku","商品编码", "内部编码", "sku标题", "仓库编码", "仓库名称", "MOQ",
"采购在途", "调拨在途", "昨日销量", "明日销量", "未来7天日均", "未来14天日均", "建议采购数", "活动促销数量",
"实际库存", "安全库存", "周转天数", "供应商交期", "质检入库天数", "调拨头程天数", "预测是否断货", "缺货数量","监控状态","供应商","采购员","交期异常",
"过去7天日均","过去14天日均","过去30天日均","重量","单价","实时库存"
"过去7天日均","过去14天日均","过去30天日均","重量","单价","实时库存","ebay最近7天日均销量","ebay最近14天日均销量","ebay最近30天日均销量"
};
foreach (var item in cols)
{
......@@ -232,6 +240,9 @@ namespace AutoTurnOver.Controllers
row["重量"] = itemData.weight;
row["单价"] = itemData.unit_price;
row["实时库存"] = itemData.usable_stock;
row["ebay最近7天日均销量"] = itemData.history_sevenday_sales_ebay;
row["ebay最近14天日均销量"] = itemData.history_fourteenday_sales_ebay;
row["ebay最近30天日均销量"] = itemData.history_thirtyday_sales_ebay;
table.Rows.Add(row);
}
......
......@@ -5,5 +5,11 @@
"System": "Information",
"Microsoft": "Information"
}
},
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": 1
}
}
......@@ -10,5 +10,11 @@
"AllowedHosts": "*",
"PushBuyPlan": "http://purchase.bailuntec.com/api/CreatePlanToPurchase",
"WebHost_GetUser": "http://www.bailuntec.com/Login/GetUserByBLUserAcct?webcode=aims",
"WebHost_LoginOut": "http://www.bailuntec.com/Login/LoginOut"
"WebHost_LoginOut": "http://www.bailuntec.com/Login/LoginOut",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": 0
}
}
......@@ -10,5 +10,12 @@
"AllowedHosts": "*",
"PushBuyPlan": "http://purchase.bailuntec.com/api/CreatePlanToPurchase",
"WebHost_GetUser": "http://www.bailuntec.com/Login/GetUserByBLUserAcct?webcode=aims",
"WebHost_LoginOut": "http://www.bailuntec.com/Login/LoginOut"
"WebHost_LoginOut": "http://www.bailuntec.com/Login/LoginOut",
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": 0
}
}
......@@ -10,5 +10,11 @@
"AllowedHosts": "*",
"PushBuyPlan": "http://purchase.bailuntec.com/api/CreatePlanToPurchase",
"WebHost_GetUser": "http://www.bailuntec.com/Login/GetUserByBLUserAcct?webcode=aims",
"WebHost_LoginOut": "http://www.bailuntec.com/Login/LoginOut"
"WebHost_LoginOut": "http://www.bailuntec.com/Login/LoginOut",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": 0
}
}
using AutoTurnOver.DB;
using AutoTurnOver.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
......@@ -11,7 +12,7 @@ namespace ResetOutofstock
static async Task Main(string[] args)
{
Console.WriteLine("刷新缺货数据任务启动...");
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
......
......@@ -14,6 +14,7 @@
<ItemGroup>
<ProjectReference Include="..\AutoTurnOver.DB\AutoTurnOver.DB.csproj" />
<ProjectReference Include="..\AutoTurnOver.Services\AutoTurnOver.Services.csproj" />
</ItemGroup>
<ItemGroup>
......@@ -28,4 +29,6 @@
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project>
{
"ConnectionStrings": {
"Default": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": "0"
}
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "",
"Defaultdatabase": "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