Commit 04ac134b by 泽锋 李

fix

parent 50be21b1
...@@ -8,6 +8,7 @@ using System.Linq; ...@@ -8,6 +8,7 @@ using System.Linq;
using AutoTurnOver.Models.Base; using AutoTurnOver.Models.Base;
using AutoTurnOver.DB.Base; using AutoTurnOver.DB.Base;
using AutoTurnOver.Models.stock; using AutoTurnOver.Models.stock;
using AutoTurnOver.Utility;
namespace AutoTurnOver.DB namespace AutoTurnOver.DB
{ {
...@@ -1718,10 +1719,28 @@ truncate table dc_base_stock_record_temp; ...@@ -1718,10 +1719,28 @@ truncate table dc_base_stock_record_temp;
", commandTimeout: 0); ", commandTimeout: 0);
//现金流汇总报表,9点之前还在跑数据,不用刷新
if (DateTime.Now.Hour > 9) }
catch (Exception ex)
{
Console.WriteLine(ex.Message);
_connection.Insert<dc_task_error_log>(new dc_task_error_log
{ {
_connection.Execute(@" -- 刷新 现金流汇总表 date = DateTime.Now,
message = ex.Message,
stack_trace = ex.StackTrace,
task_name = "ResetOutofstock"
});
}
}
public static void ResetCashFlowData()
{
//现金流汇总报表,9点之前还在跑数据,不用刷新
if (DateTime.Now.Hour > 9)
{
_connection.Execute(@" -- 刷新 现金流汇总表
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
start transaction; start transaction;
...@@ -1744,24 +1763,61 @@ alter table dc_report_cash_flow_group_day_temp rename dc_report_cash_flow_group_ ...@@ -1744,24 +1763,61 @@ alter table dc_report_cash_flow_group_day_temp rename dc_report_cash_flow_group_
alter table dc_report_cash_flow_group_dayTemp rename dc_report_cash_flow_group_day_temp; alter table dc_report_cash_flow_group_dayTemp rename dc_report_cash_flow_group_day_temp;
truncate table dc_report_cash_flow_group_day_temp; truncate table dc_report_cash_flow_group_day_temp;
", commandTimeout: 0);
var datePar = new {
btime = DateTime.Now.GetMonthFirstDay(),
etime = DateTime.Now.LastDayOfMonth().ToString("yyyy-MM-dd 23:59:59"),
lastBtime = DateTime.Now.AddMonths(-1).GetMonthFirstDay(),
lastEtime = DateTime.Now.AddMonths(-1).LastDayOfMonth().ToString("yyyy-MM-dd 23:59:59")
};
_connection.Execute(@" -- 刷新 现金流汇总表
set session transaction isolation level read uncommitted;
start transaction;
", commandTimeout: 0); -- 清空视图表的数据
} Truncate table dc_report_cash_flow_sku_group_temp;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
_connection.Insert<dc_task_error_log>(new dc_task_error_log
{
date = DateTime.Now,
message = ex.Message,
stack_trace = ex.StackTrace,
task_name = "ResetOutofstock"
});
}
insert dc_report_cash_flow_sku_group_temp(`bailun_sku`,`balance`,`current_date_begin`,`current_date_end`,`last_date_begin`,`last_date_end`,`current_income`,`current_expend`,`last_income`,`last_expend`,`type`)
select
bailun_sku,
sum(val) as 'balance',
@btime as current_date_begin,
@etime as current_date_end,
@lastBtime as last_date_begin,
@lastEtime as last_date_end,
sum(case when occur_time>=@btime and data_type in (2) then val else 0 end) as 'current_income',
sum(case when occur_time>=@btime and data_type not in (2) then val else 0 end ) as 'current_expend',
sum(case when occur_time<@btime and data_type in (2) then val else 0 end ) as 'last_income',
sum(case when occur_time<@btime and data_type not in (2) then val else 0 end ) as 'last_expend',
1 as 'type'
from dc_report_cash_flow_log where occur_time>='2020-06-01 00:00:00' and data_type in (2,3,5,8,9,10)
GROUP BY occur_time_year_month_no;
insert dc_report_cash_flow_sku_group_temp(`bailun_sku`,`balance`,`current_date_begin`,`current_date_end`,`last_date_begin`,`last_date_end`,`current_income`,`current_expend`,`last_income`,`last_expend`,`type`)
select
bailun_sku,
sum(val) as 'balance',
@btime as current_date_begin,
@etime as current_date_end,
@lastBtime as last_date_begin,
@lastEtime as last_date_end,
sum(case when pay_time>=@btime and data_type in (2) then val else 0 end) as 'current_income',
sum(case when pay_time>=@btime and data_type not in (2) then val else 0 end ) as 'current_expend',
sum(case when pay_time<@btime and data_type in (2) then val else 0 end ) as 'last_income',
sum(case when pay_time<@btime and data_type not in (2) then val else 0 end ) as 'last_expend',
2 as 'type'
from dc_report_cash_flow_log where pay_time>=@lastBtime and data_type in (2,3,5,8,9,10)
GROUP BY occur_time_year_month_no;
alter table dc_report_cash_flow_sku_group rename dc_report_cash_flow_sku_groupTemp;
alter table dc_report_cash_flow_sku_group_temp rename dc_report_cash_flow_sku_group;
alter table dc_report_cash_flow_sku_groupTemp rename dc_report_cash_flow_sku_group_temp;
truncate table dc_report_cash_flow_sku_group_temp;
", datePar, commandTimeout: 0);
}
} }
/// <summary> /// <summary>
......
...@@ -75,6 +75,11 @@ namespace AutoTurnOver.Utility ...@@ -75,6 +75,11 @@ namespace AutoTurnOver.Utility
return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1); return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1);
} }
public static DateTime GetMonthFirstDay(this DateTime datetime)
{
return DateTime.Parse(datetime.ToString("yyyy-MM-01 00:00:00"));
}
/// <summary> /// <summary>
/// 得到本周第一天(以星期一为第一天) /// 得到本周第一天(以星期一为第一天)
/// </summary> /// </summary>
......
...@@ -15,6 +15,7 @@ namespace ResetOutofstock ...@@ -15,6 +15,7 @@ namespace ResetOutofstock
Console.WriteLine("刷新缺货数据任务启动..."); Console.WriteLine("刷新缺货数据任务启动...");
var now = DateTime.Now; var now = DateTime.Now;
//report_cash_flow_dao.CalculationOrderCostLogistics(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"))); //report_cash_flow_dao.CalculationOrderCostLogistics(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
report.ResetCashFlowData();
var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{ {
services.AddHostedService<ResetOutofstockBackgrounService>(); services.AddHostedService<ResetOutofstockBackgrounService>();
......
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