[BGService]修正月歸檔少算一天的邏輯

This commit is contained in:
張家睿 2024-09-10 15:50:27 +08:00
parent 7fb85c72d7
commit d0c5d8a1b9

View File

@ -1127,9 +1127,9 @@ namespace BackendWorkerService.Quartz.Jobs
var endDay = System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); var endDay = System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
foreach (DateTime day in EachMonth(startDay, endDay)) foreach (DateTime month in EachMonth(startDay, endDay))
{ {
if (day.ToString("yyyy-MM") == System.DateTime.Now.AddDays(-1).ToString("yyyy-MM")) if (month.ToString("yyyy-MM") == System.DateTime.Now.AddDays(-1).ToString("yyyy-MM"))
{ {
var preDay = now.AddDays(-1); //取得前一天 var preDay = now.AddDays(-1); //取得前一天
@ -1154,9 +1154,9 @@ namespace BackendWorkerService.Quartz.Jobs
} }
else else
{ {
var dayInMonth = DateTime.DaysInMonth(day.Year, day.Month); var dayInMonth = DateTime.DaysInMonth(month.Year, month.Month);
var FirstDay = new DateTime(day.Year, day.Month, 1); var FirstDay = new DateTime(month.Year, month.Month, 1);
var LastDay = new DateTime(day.Year, day.Month, dayInMonth); var LastDay = new DateTime(month.Year, month.Month, dayInMonth);
startTimestamp = string.Format("{0}T00:00:00.000+08:00", FirstDay.ToString("yyyy-MM-dd")); startTimestamp = string.Format("{0}T00:00:00.000+08:00", FirstDay.ToString("yyyy-MM-dd"));
@ -1270,7 +1270,7 @@ namespace BackendWorkerService.Quartz.Jobs
{ {
var dayInMonth = DateTime.DaysInMonth(day.Year, day.Month); var dayInMonth = DateTime.DaysInMonth(day.Year, day.Month);
var FirstDay = new DateTime(day.Year, day.Month, 1); var FirstDay = new DateTime(day.Year, day.Month, 1);
var LastDay = new DateTime(day.Year, day.Month, dayInMonth); var LastDay = new DateTime(day.Year, day.Month, dayInMonth).AddDays(1);
startTimestamp = string.Format("{0}T00:00:00.000+08:00", FirstDay.ToString("yyyy-MM-dd")); startTimestamp = string.Format("{0}T00:00:00.000+08:00", FirstDay.ToString("yyyy-MM-dd"));
@ -1746,9 +1746,11 @@ namespace BackendWorkerService.Quartz.Jobs
{ {
var strtday = DateTime.Parse(from); var strtday = DateTime.Parse(from);
var endday = DateTime.Parse(thru); var endday = DateTime.Parse(thru);
for (var _month = strtday.Date; _month.Month <= endday.Month; _month = _month.AddMonths(1))
yield return _month;
for (var _month = strtday.Date; _month <= endday; _month = _month.AddMonths(1))
{
yield return _month;
}
} }
private List<Dictionary<string, object>> ArrangeRawData(DeviceNumberPoint deviceNumberPoint, JObject jsonResult) private List<Dictionary<string, object>> ArrangeRawData(DeviceNumberPoint deviceNumberPoint, JObject jsonResult)
{ {