Commit 03dfa6bd by 泽锋 李

仓库汇总报表,新增库存数

parent 7d4a1e3e
...@@ -2610,6 +2610,13 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2610,6 +2610,13 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
public static List<bailun_sku_warehouse_code_dto> GetSkuWarehouseSales(bailun_sku_website_sales_search_dto search_data) public static List<bailun_sku_warehouse_code_dto> GetSkuWarehouseSales(bailun_sku_website_sales_search_dto search_data)
{ {
var b_time = DateTime.Now.AddDays(-1);
var e_time = b_time.AddDays(-7);
if (search_data.btime != null && search_data.etime != null)
{
e_time = search_data.btime.Value;
b_time = search_data.etime.Value;
}
var tableName = "dc_base_oms_sku_7"; var tableName = "dc_base_oms_sku_7";
if (search_data.btime != null || search_data.etime != null) if (search_data.btime != null || search_data.etime != null)
{ {
...@@ -2624,15 +2631,23 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2624,15 +2631,23 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
-- and t1.has_buyer_remark = 0 -- and t1.has_buyer_remark = 0
-- and t1.has_platsku_remark = 0 -- and t1.has_platsku_remark = 0
and t1.has_innersale = 0 "; and t1.has_innersale = 0 ";
var stock_sql = @" select * from dc_daily_stock_warehouse as t1 where 1=1 ";
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
if (search_data != null) DynamicParameters parameters_sql = new DynamicParameters();
if (b_time != null && e_time != null)
{ {
if (search_data.btime != null && search_data.etime != null) sql += " and t1.paid_time<=@btime and t1.paid_time>=@etime ";
{ parameters.Add("btime", b_time.ToString("yyyy-MM-dd 23:59:59"));
sql += " and t1.paid_time>=@btime and t1.paid_time<=@etime "; parameters.Add("etime", e_time.ToString("yyyy-MM-dd 00:00:00"));
parameters.Add("btime", search_data.btime.Value.ToString("yyyy-MM-dd 00:00:00"));
parameters.Add("etime", search_data.etime.Value.ToString("yyyy-MM-dd 23:59:59")); stock_sql += " and t1.record_time<=@btime and t1.record_time>=@etime ";
parameters_sql.Add("btime", b_time.ToString("yyyy-MM-dd 23:59:59"));
parameters_sql.Add("etime", e_time.ToString("yyyy-MM-dd 00:00:00"));
} }
if (search_data != null)
{
if (!string.IsNullOrWhiteSpace(search_data.platform_type)) if (!string.IsNullOrWhiteSpace(search_data.platform_type))
{ {
if ("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase)) if ("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase))
...@@ -2664,6 +2679,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2664,6 +2679,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
} }
var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters); var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters);
var stock_list = _connection.Query<dc_daily_stock_warehouse>(stock_sql, parameters_sql,commandTimeout:0);
List<bailun_sku_warehouse_code_dto> datas = new List<bailun_sku_warehouse_code_dto>(); List<bailun_sku_warehouse_code_dto> datas = new List<bailun_sku_warehouse_code_dto>();
...@@ -2719,13 +2735,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2719,13 +2735,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
var b_time = DateTime.Now.AddDays(-1);
var e_time = b_time.AddDays(-7);
if (search_data.btime != null && search_data.etime != null)
{
e_time = search_data.btime.Value;
b_time = search_data.etime.Value;
}
var this_time = b_time; var this_time = b_time;
while (this_time >= e_time) while (this_time >= e_time)
{ {
...@@ -2743,8 +2753,9 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2743,8 +2753,9 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
month = this_time.Month, month = this_time.Month,
day = this_time.Day, day = this_time.Day,
count = temp_datas.Sum(s => s.bailun_sku_quantity_ordered), count = temp_datas.Sum(s => s.bailun_sku_quantity_ordered),
sum = temp_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate) sum = temp_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate),
}); stock = stock_list.Where(v=>v.warehouse_code== item.warehouse_code && v.record_time.Year == this_time.Year && v.record_time.Month == this_time.Month && v.record_time.Day == this_time.Day).Sum(v=>v.stock)
}) ;
} }
this_time = this_time.AddDays(-1); this_time = this_time.AddDays(-1);
...@@ -3672,5 +3683,20 @@ GROUP BY t_p.bailun_sku ,t_p.warehouse_into_code ...@@ -3672,5 +3683,20 @@ GROUP BY t_p.bailun_sku ,t_p.warehouse_into_code
); );
", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0); ", new { btime, etime, week_tag, eonthFirstDate }, commandTimeout: 0);
} }
/// <summary>
/// 刷新每日库存汇总
/// </summary>
public static void ResetDailyStockWarehouse()
{
_connection.Execute(@"
insert into dc_daily_stock_warehouse (warehouse_code,stock,record_time)
(
select warehouse_code,sum(usable_stock) as 'stock', @record_time as 'record_time'
from dc_base_stock as t1
where t1.usable_stock>0
group by warehouse_code
)",new { record_time = DateTime.Now.AddDays(-1)});
}
} }
} }
......
...@@ -78,6 +78,7 @@ namespace AutoTurnOver.Models.Report ...@@ -78,6 +78,7 @@ namespace AutoTurnOver.Models.Report
public decimal count { get; set; } public decimal count { get; set; }
public decimal sum { get; set; } public decimal sum { get; set; }
public decimal stock { get; set; }
} }
} }
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class dc_daily_stock_warehouse
{
public int id { get; set; }
public string warehouse_code { get; set; }
public decimal stock { get; set; }
public DateTime record_time { get; set; }
}
}
...@@ -694,6 +694,8 @@ namespace AutoTurnOver.Services ...@@ -694,6 +694,8 @@ namespace AutoTurnOver.Services
dic["v_count_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.count, 2); dic["v_count_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.count, 2);
dic["sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2); dic["sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2);
dic["v_sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2); dic["v_sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2);
dic["stock_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.stock, 2);
dic["v_stock_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.stock, 2);
} }
datas.Add(o); datas.Add(o);
......
...@@ -865,6 +865,7 @@ namespace AutoTurnOver.Controllers ...@@ -865,6 +865,7 @@ namespace AutoTurnOver.Controllers
{ {
table.Columns.Add($"{col_this_date.ToString("MM-dd")}-销量"); table.Columns.Add($"{col_this_date.ToString("MM-dd")}-销量");
table.Columns.Add($"{col_this_date.ToString("MM-dd")}-销售额"); table.Columns.Add($"{col_this_date.ToString("MM-dd")}-销售额");
table.Columns.Add($"{col_this_date.ToString("MM-dd")}-库存");
col_this_date = col_this_date.AddDays(-1); col_this_date = col_this_date.AddDays(-1);
} }
...@@ -881,6 +882,7 @@ namespace AutoTurnOver.Controllers ...@@ -881,6 +882,7 @@ namespace AutoTurnOver.Controllers
{ {
row[$"{row_this_date.ToString("MM-dd")}-销量"] = itemData["v_count_" + $"{row_this_date.Month}-{row_this_date.Day}"]; row[$"{row_this_date.ToString("MM-dd")}-销量"] = itemData["v_count_" + $"{row_this_date.Month}-{row_this_date.Day}"];
row[$"{row_this_date.ToString("MM-dd")}-销售额"] = itemData["v_sum_" + $"{row_this_date.Month}-{row_this_date.Day}"]; row[$"{row_this_date.ToString("MM-dd")}-销售额"] = itemData["v_sum_" + $"{row_this_date.Month}-{row_this_date.Day}"];
row[$"{row_this_date.ToString("MM-dd")}-库存"] = itemData["v_stock_" + $"{row_this_date.Month}-{row_this_date.Day}"];
row_this_date = row_this_date.AddDays(-1); row_this_date = row_this_date.AddDays(-1);
} }
......
...@@ -22,6 +22,12 @@ namespace ResetOutofstock ...@@ -22,6 +22,12 @@ namespace ResetOutofstock
{ {
var now = DateTime.Now; var now = DateTime.Now;
if (now.Hour == 0 && now.Minute == 01)
{
Console.WriteLine($"开始 备份库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.ResetDailyStockWarehouse();
Console.WriteLine($"结束 备份库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
if (now.DayOfWeek == DayOfWeek.Monday) if (now.DayOfWeek == DayOfWeek.Monday)
{ {
if (now.Hour == 0 && now.Minute == 10) if (now.Hour == 0 && now.Minute == 10)
......
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