From d0c5d8a1b9339c19172a1a5097c905ef37d1b441 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 10 Sep 2024 15:50:27 +0800 Subject: [PATCH] =?UTF-8?q?[BGService]=E4=BF=AE=E6=AD=A3=E6=9C=88=E6=AD=B8?= =?UTF-8?q?=E6=AA=94=E5=B0=91=E7=AE=97=E4=B8=80=E5=A4=A9=E7=9A=84=E9=82=8F?= =?UTF-8?q?=E8=BC=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Quartz/Jobs/ArchiveElectricMeterDayJob.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs b/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs index 220b566..d8b4ea6 100644 --- a/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs +++ b/BackendWorkerService/Quartz/Jobs/ArchiveElectricMeterDayJob.cs @@ -1127,9 +1127,9 @@ namespace BackendWorkerService.Quartz.Jobs 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); //取得前一天 @@ -1154,9 +1154,9 @@ namespace BackendWorkerService.Quartz.Jobs } else { - var dayInMonth = DateTime.DaysInMonth(day.Year, day.Month); - var FirstDay = new DateTime(day.Year, day.Month, 1); - var LastDay = new DateTime(day.Year, day.Month, dayInMonth); + var dayInMonth = DateTime.DaysInMonth(month.Year, month.Month); + var FirstDay = new DateTime(month.Year, month.Month, 1); + var LastDay = new DateTime(month.Year, month.Month, dayInMonth); 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 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")); @@ -1746,9 +1746,11 @@ namespace BackendWorkerService.Quartz.Jobs { var strtday = DateTime.Parse(from); 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> ArrangeRawData(DeviceNumberPoint deviceNumberPoint, JObject jsonResult) {