Commit 8fd33c8c by 泽锋 李

晚上财报的数据计算

parent 3ef6386a
......@@ -389,5 +389,188 @@ GROUP BY t2.product_type,t2.product_type_desc ", new
thisTime = thisTime.AddDays(-1);
}
}
/// <summary>
/// 计算筹资
/// </summary>
public static void CalculationRaise(DateTime bTime)
{
var etime = DateTime.Now;
var thisTime = etime;
while (thisTime >= bTime)
{
var b_this_time = DateTime.Parse( thisTime.ToString("yyyy-MM-01 00:00:00"));
var e_this_time = thisTime.LastDayOfMonth().ToDayEnd();
var datas = new List<dc_report_finance>();
//当月-上月的金额
var val = (_connection.QueryFirstOrDefault<decimal?>(@" select short_term_borrow from dc_balance_sheet
where `statistical_time`=@b_this_time ", new {
b_this_time = b_this_time.LastDayOfMonth().ToString("yyyy-MM-dd")
}) ?? 0M)
-
(_connection.QueryFirstOrDefault<decimal?>(@" select short_term_borrow from dc_balance_sheet
where `statistical_time`>=@b_this_time ", new
{
b_this_time = b_this_time.AddMonths(-1).LastDayOfMonth().ToString("yyyy-MM-dd")
}) ?? 0M)
;
datas.Add( new dc_report_finance()
{
data_type = "筹资现金流入",
item_name = "筹资现金流入",
item_id = "筹资现金流入",
date = b_this_time,
val = val>0? val:0,
update_date = DateTime.Now
});
datas.Add(new dc_report_finance()
{
data_type = "还款现金流出",
item_name = "还款现金流出",
item_id = "还款现金流出",
date = b_this_time,
val = val<0? val:0,
update_date = DateTime.Now
});
foreach (var data in datas)
{
data.id = _connection.QueryFirstOrDefault<int>(" select id from dc_report_finance where data_type=@data_type and item_name=@item_name and date=@date ", new
{
data_type = data.data_type,
item_name = data.item_name,
date = data.date
});
if (data.id > 0)
{
_connection.Update(data);
}
else
{
_connection.Insert(data);
}
}
thisTime = thisTime.AddMonths(-1);
}
}
/// <summary>
/// 计算其他收入
/// </summary>
public static void CalculationOtherIncome(DateTime bTime)
{
var etime = DateTime.Now;
var thisTime = etime;
while (thisTime >= bTime)
{
var b_this_time = thisTime.ToDayHome();
var e_this_time = thisTime.ToDayEnd();
dc_report_finance data = new dc_report_finance()
{
data_type = "其他收入",
item_name = "其他收入",
item_id = "其他收入",
date = b_this_time,
val = 0,
update_date = DateTime.Now
};
data.val = _connection.QueryFirstOrDefault<decimal?>("select other_incoming from dc_month_sale_profit where `month`=@month ", new
{
month = b_this_time.ToString("yyyy-MM")
}) ?? 0M;
data.id = _connection.QueryFirstOrDefault<int>(" select id from dc_report_finance where data_type=@data_type and item_name=@item_name and date=@date ", new
{
data_type = data.data_type,
item_name = data.item_name,
date = data.date
});
if (data.id > 0)
{
_connection.Update(data);
}
else
{
_connection.Insert(data);
}
thisTime = thisTime.AddMonths(-1);
}
}
/// <summary>
/// 计算应收应付账款
/// </summary>
public static void CalculationAccounts(DateTime bTime)
{
var etime = DateTime.Now;
var thisTime = etime;
while (thisTime >= bTime)
{
var b_this_time = DateTime.Parse(thisTime.ToString("yyyy-MM-01 00:00:00"));
var e_this_time = thisTime.LastDayOfMonth().ToDayEnd();
var datas = new List<dc_report_finance>();
datas.Add(new dc_report_finance()
{
data_type = "应收账款余额",
item_name = "应收账款余额",
item_id = "应收账款余额",
date = b_this_time,
val = (_connection.QueryFirstOrDefault<decimal?>(@" select accounts_receivable from dc_balance_sheet
where `statistical_time`>=@b_this_time ", new
{
b_this_time = b_this_time.LastDayOfMonth().ToString("yyyy-MM-dd")
}) ?? 0M),
update_date = DateTime.Now
});
datas.Add(new dc_report_finance()
{
data_type = "应付账款余额",
item_name = "应付账款余额",
item_id = "应付账款余额",
date = b_this_time,
val = (_connection.QueryFirstOrDefault<decimal?>(@" select accounts_payable from dc_balance_sheet
where `statistical_time`>=@b_this_time ", new
{
b_this_time = b_this_time.LastDayOfMonth().ToString("yyyy-MM-dd")
}) ?? 0M),
update_date = DateTime.Now
});
foreach (var data in datas)
{
data.id = _connection.QueryFirstOrDefault<int>(" select id from dc_report_finance where data_type=@data_type and item_name=@item_name and date=@date ", new
{
data_type = data.data_type,
item_name = data.item_name,
date = data.date
});
if (data.id > 0)
{
_connection.Update(data);
}
else
{
_connection.Insert(data);
}
}
thisTime = thisTime.AddMonths(-1);
}
}
}
}
......@@ -30,6 +30,8 @@ namespace ResetOutofstock
//dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-3), DateTime.Now);
//dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-1), DateTime.Now);
//dc_report_finance_dao.CalculationRefund(DateTime.Now.AddYears(-1));
//dc_report_finance_dao.CalculationRaise(DateTime.Now.AddYears(-1));
//dc_report_finance_dao.CalculationAccounts(DateTime.Now.AddYears(-1));
}
catch (Exception ex)
{
......
......@@ -52,6 +52,24 @@ namespace ResetOutofstock
dc_report_finance_dao.CalculationRefund(DateTime.Now.AddDays(-90));
Console.WriteLine($"结束 财报退款数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
if (now.Hour == 0 && now.Minute == 06)
{
Console.WriteLine($"开始 财报其他收入 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
dc_report_finance_dao.CalculationOtherIncome(DateTime.Now.AddDays(-90));
Console.WriteLine($"结束 财报其他收入,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
if (now.Hour == 0 && now.Minute == 06)
{
Console.WriteLine($"开始 财报筹资流入出 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
dc_report_finance_dao.CalculationRaise(DateTime.Now.AddDays(-90));
Console.WriteLine($"结束 财报筹资流入出,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
if (now.Hour == 0 && now.Minute == 06)
{
Console.WriteLine($"开始 财报应首付账款 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
dc_report_finance_dao.CalculationAccounts(DateTime.Now.AddDays(-90));
Console.WriteLine($"结束 财报应首付账款,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
......
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