Commit 01686b99 by lizefeng

把所有涉及仓库列表的地方,只要是FBA的仓库,均显示销售账号名

周转表页面新增SKU分类的字段,支持根据SKU分类(百伦分类)筛选
找静雯沟通,补齐所有仓库的头程费
平均调拨天数计算
parent 608d31e4
......@@ -143,6 +143,25 @@ ORDER BY t1.update_time desc LIMIT @seed_count
}
/// <summary>
/// / 获取指定SKU的最近调拨数据
/// </summary>
/// <param name="bailun_sku"></param>
/// <param name="warehouse_code"></param>
/// <param name="type">调拨类型</param>
/// <param name="seed_count"></param>
/// <returns></returns>
public static IEnumerable<dc_base_transfer_transport> GetTransportList(string bailun_sku,string warehouse_code, string type, int seed_count)
{
DynamicParameters parameters = new DynamicParameters();
parameters.Add("bailun_sku", bailun_sku);
parameters.Add("transport_type", type);
parameters.Add("seed_count", seed_count);
parameters.Add("warehouse_code", warehouse_code);
return _connection.Query<dc_base_transfer_transport>(@" SELECT * FROM `dc_base_transfer_transport` where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code and transport_type=@transport_type and arrival_time>='1990-01-01' LIMIT @seed_count
", parameters);
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="data"></param>
......
......@@ -16,7 +16,7 @@ namespace AutoTurnOver.DB
/// <returns></returns>
public static List<dc_base_warehouse> ListWareHouse(string type,int? areaId)
{
var sql = "select * from dc_base_warehouse where 1=1";
var sql = " select * from dc_base_warehouse where 1=1 ";
if (areaId.HasValue)
{
......
......@@ -34,7 +34,7 @@ namespace AutoTurnOver.DB
{
sql = @"select
sum(dat.quantity_inventory) as 'quantity_inventory',
sum(dat.quantity_inventory) as 'quantity_out_stock',
sum(dat.quantity_out_stock) as 'quantity_out_stock',
sum(dat.quantity_purchase) as 'quantity_purchase',
sum(dat.quantity_transfer) as 'quantity_transfer',
sum(t2.oneday_sales) as 'oneday_sales',
......@@ -50,14 +50,25 @@ where 1=1 ";
else
{
sql = @"select dat.*,t2.oneday_sales,t2.forecast_oneday_sales as 'forecast_oneday_sales2',
t4.product_inner_code,t4.product_code from dc_auto_turnover as dat
t4.product_inner_code,t4.product_code,t4.bailun_category_name from dc_auto_turnover as dat
left join dc_auto_sales as t2 on t2.bailun_sku=dat.bailun_sku and dat.warehouse_code = t2.warehouse_code
left join dc_base_warehouse as t3 on dat.warehouse_code = t3.warehouse_code
left join dc_base_sku as t4 on dat.bailun_sku = t4.bailun_sku
where 1=1 ";
}
if (m.categoryModels!=null)
{
sql += " and t4.bailun_category_id in ( "+ string.Join(",", m.categoryModels.Select(s=>s.C_ID).Distinct()) +")" ;
}
if (m.hasAadvise == true)
{
sql = " and dat.quantity_final_advise>0 ";
}
if (m.hasAadvise == false)
{
sql = " and dat.quantity_final_advise<=0 ";
}
if (!string.IsNullOrWhiteSpace(m.product_code))
{
sql += " and t4.product_code like" + $"'%{m.product_code}%'";
......
using System;
using AutoTurnOver.Models.ApiDto;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -197,6 +198,16 @@ namespace AutoTurnOver.Models
/// </summary>
public decimal turnover_inbound { get; set; }
/// <summary>
/// 过去7日销量(日均)
/// </summary>
public decimal history_sevenday_sales { get; set; }
/// <summary>
/// 过去14日日均销量
/// </summary>
public decimal history_fourteenday_sales { get; set; }
}
public class Condition_AutoTurnOver
......@@ -245,6 +256,18 @@ namespace AutoTurnOver.Models
/// 商品编码
/// </summary>
public string product_code { get; set; }
/// <summary>
/// 是否建议下单
/// </summary>
public bool? hasAadvise { get; set; }
/// <summary>
///百伦分类
/// </summary>
public string categoryIds { get; set; }
public List<CategoryDto> categoryModels { get;set; }
}
public class dc_auto_turnover_Extend : dc_auto_turnover
......@@ -264,5 +287,17 @@ namespace AutoTurnOver.Models
/// </summary>
public string product_inner_code { get; set; }
/// <summary>
/// 商品编码
/// </summary>
public string product_code { get; set; }
/// <summary>
/// 百伦分类
/// </summary>
public string bailun_category_name { get; set; }
}
}
......@@ -24,5 +24,15 @@ namespace AutoTurnOver.Models
/// 更新时间
/// </summary>
public DateTime update_time { get; set; }
/// <summary>
/// 海运平均调拨天数
/// </summary>
public decimal transfer_type_1_days { get; set; }
/// <summary>
/// 空运平均调拨天数
/// </summary>
public decimal transfer_type_2_days { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
/// <summary>
/// 调拨数据
/// </summary>
public class dc_base_transfer_transport
{
public int id { get; set; }
public DateTime gmt_create { get; set; }
public DateTime gmt_modified { get; set; }
public string bailun_sku { get; set; }
/// <summary>
/// 调拨单号
/// </summary>
public string transfer_order_id { get; set; }
/// <summary>
/// 调拨箱号
/// </summary>
public string transfer_box_id { get; set; }
public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
public int count { get; set; }
/// <summary>
/// 调拨类型
/// </summary>
public string transport_type { get; set; }
/// <summary>
/// 发货时间
/// </summary>
public DateTime delivery_time { get; set; }
/// <summary>
/// 到货时间
/// </summary>
public DateTime arrival_time { get; set; }
}
}
......@@ -14,7 +14,22 @@ namespace AutoTurnOver.Models
public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
private string _warehouse_name;
public string warehouse_name
{
get
{
if ("fba仓".Equals(hq_type, StringComparison.OrdinalIgnoreCase))
{
return bailun_account;
}
else
{
return _warehouse_name;
}
}
set { _warehouse_name = value; }
}
public string warehouse_extend_name { get; set; }
......@@ -24,7 +39,7 @@ namespace AutoTurnOver.Models
public string system_flag { get; set; }
public int bailun_account_id { get; set; }
public int bailun_account_id { get; set; }
public string bailun_account { get; set; }
......
......@@ -11,8 +11,39 @@ namespace AutoTurnOver.Services
{
public class ApiServices
{
public static List<CategoryDto> GetCategoryList()
/// <summary>
/// 获取一二级的百伦分类数据
/// </summary>
/// <returns></returns>
public static List<CategoryDto> GetCategoryAll()
{
List<CategoryDto> clsit = new List<CategoryDto>();
clsit.AddRange(GetCategoryList(1));
clsit.AddRange(GetCategoryList(2));
return clsit;
}
public static List<CategoryDto> GetCategoryList(int level = 1)
{
if (level == 0)
{
List<CategoryDto> datas = new List<CategoryDto>();
var tempLevel = 1;
while (true)
{
var tempDatas = GetCategoryList(tempLevel);
if (tempDatas != null && tempDatas.Count >= 1 && level <= 4)
{
datas.AddRange(tempDatas);
}
else
{
return datas;
}
tempLevel++;
}
}
string appId = "SystemDC";
string appKey = "YmFpbHVuREM=";
string url = "http://api.sku.bailuntec.com/api/BailunCateData/GetAllCategoryList";
......@@ -21,23 +52,75 @@ namespace AutoTurnOver.Services
ApiEntrance model = new ApiEntrance();
model.code = appId;
model.data = "1";
model.data = level.ToString();
string sign = Security.md5Encrypt(appKey + model.code + Security.md5Encrypt(model.key + model.data));
string resultStr = HttpHelper.Request(url+$"?sign={sign}&appId={appId}&level=1",RequestType.GET);
string resultStr = HttpHelper.Request(url + $"?sign={sign}&appId={appId}&level={level}", RequestType.GET);
ApiResult apiResult = resultStr.ToObj<ApiResult>();
if (apiResult.result_code == 1)
{
result = WebUtility.UrlDecode(apiResult.data).ToObj<List<CategoryDto>>();
result = WebUtility.UrlDecode(apiResult.data).ToObj<List<CategoryDto>>().Where(s => s.C_LEVEL == level).ToList();
}
return result;
}
/// <summary>
/// 根据ID查询分类
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static CategoryDto GetCategoryById(int id)
{
var all = GetCategoryList();
return all.SingleOrDefault(s=>s.C_ID==id);
var all = GetCategoryAll();
return all.SingleOrDefault(s => s.C_ID == id);
}
/// <summary>
/// 查询相关的子节点
/// </summary>
/// <param name="all"></param>
/// <param name="id"></param>
/// <returns></returns>
public static List<CategoryDto> GetClientNodesByIds(List<int> ids)
{
if (ids == null || ids.Count <= 0)
{
return new List<CategoryDto>();
}
List<CategoryDto> datas = new List<CategoryDto>();
var all = GetCategoryList(0);
foreach (var item in ids)
{
datas.AddRange(GetClientNodesById(all, item));
}
return datas;
}
/// <summary>
/// 查询相关的子节点
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public static List<CategoryDto> GetClientNodesById(List<CategoryDto> all, int id)
{
// 查询所有数据
if (all == null)
{
all = GetCategoryList(0);
}
List<CategoryDto> clients = all.Where(s => s.C_ID == id).ToList();
var cNodes = all.Where(s => s.C_PARENTID == id).ToList();
if (cNodes != null || cNodes.Count >= 1)
{
foreach (var item in cNodes)
{
clients.AddRange(GetClientNodesById(all, item.C_ID));
}
}
return clients;
}
......@@ -48,7 +131,7 @@ namespace AutoTurnOver.Services
{
//查询采购建议明细
string url = ConfigHelper.GetValue("PushBuyPlan");
string resultStr = HttpHelper.Request(url, RequestType.POST, "obj="+WebUtility.UrlDecode(data.ToJson()));
string resultStr = HttpHelper.Request(url, RequestType.POST, "obj=" + WebUtility.UrlDecode(data.ToJson()));
var result = resultStr.ToObj<BuyOutputResult>();
if (result == null)
{
......
......@@ -120,6 +120,23 @@ namespace AutoTurnOver.Services
// 平均入库天数
dataWarehouse.inbound_days = inbound_days / purchaseWList.Count;
// 计算平均海运调拨天数
// 查询最近5次海运(已完成)记录
var transport1List = AveragePurchase.GetTransportList(skuItem.bailun_sku, skuItem.warehouse_code,"海运", _seed_count);
if(transport1List!=null && transport1List.Count() >= 1)
{
dataWarehouse.transfer_type_1_days = (decimal)transport1List.Sum(s => (s.arrival_time - s.delivery_time).TotalDays) / transport1List.Count();
}
// 计算平均空运调拨天数
// 查询最近5次空运(已完成)记录
var transport2List = AveragePurchase.GetTransportList(skuItem.bailun_sku, skuItem.warehouse_code, "空运", _seed_count);
if (transport2List != null && transport2List.Count() >= 1)
{
dataWarehouse.transfer_type_2_days = (decimal)transport2List.Sum(s => (s.arrival_time - s.delivery_time).TotalDays) / transport2List.Count();
}
AveragePurchase.Save(dataWarehouse, conn);
}
......
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using AutoTurnOver.Models;
using System.Linq;
namespace AutoTurnOver.Services
{
......@@ -21,6 +22,10 @@ namespace AutoTurnOver.Services
/// <returns></returns>
public List<dc_auto_turnover_Extend> List(Condition_AutoTurnOver m,int offset, int limit, ref int total,string order="",string sort="",bool isSum = false)
{
if (!string.IsNullOrWhiteSpace(m.categoryIds))
{
m.categoryModels = ApiServices.GetClientNodesByIds(m.categoryIds.Split(',').Select(s=>int.Parse(s)).ToList());
}
return DB.dc_auto_turnover.List(m,offset, limit, ref total,order,sort, isSum);
}
......
......@@ -52,5 +52,37 @@ namespace AutoTurnOver.Controllers
return new JsonResult(datas);
}
/// <summary>
/// 获取一二级的百伦数据
/// </summary>
/// <returns></returns>
public JsonResult GetCategoryAll()
{
try
{
var datas = ApiServices.GetCategoryAll().Select(s=> new {
id = s.C_ID,
pId = s.C_PARENTID,
name = s.C_CNAME,
open = false
});
return new JsonResult(new
{
data = datas,
success = true
});
}
catch (Exception ex)
{
return new JsonResult(new
{
message = ex.Message,
success = false
});
}
}
}
}
\ No newline at end of file
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