diff --git a/app/apps/main/services/worktime/service.py b/app/apps/main/services/worktime/service.py index ceb6edc..56d2cf3 100644 --- a/app/apps/main/services/worktime/service.py +++ b/app/apps/main/services/worktime/service.py @@ -11,9 +11,12 @@ class FabricWorkTimeService(DashboardBaseService): @classmethod def calculate_work_time(cls, qs: list, return_duration: bool = False) -> dict: status_durations = {"WO": timedelta(0), "WA": timedelta(0), "NW": timedelta(0)} - + time_now = cls.get_current_time() if not qs: - return {"WO": 0, "WA": 0, "NW": 0} + return {"WO": 0, "WA": 0, "NW": 0} if not return_duration else {"WO": "P0DT00H00M00S", + "WA": "P0DT00H00M00S", + "NW": time_now - cls.get_shift_start( + time_now)} previous_time = qs[0]["time"] previous_status = qs[0]["status"] @@ -54,11 +57,7 @@ class FabricWorkTimeService(DashboardBaseService): now_date = self.get_current_time() start_month = now_date - relativedelta(hours=730) start_week = now_date - relativedelta(hours=168) - start_shift = now_date.replace(hour=8, minute=0, second=0, microsecond=0) - if now_date.hour < 8: - start_shift = now_date.replace(hour=20, minute=0, second=0, microsecond=0) - relativedelta(days=1) - elif now_date.hour > 20: - start_shift = now_date.replace(hour=20, minute=0, second=0, microsecond=0) + start_shift = self.get_shift_start(now_date) monthly_qs = self.get_qs_by_range(start_month, now_date) monthly = self.calculate_work_time(list(monthly_qs), return_durations) diff --git a/app/repcofkk/app_settings.py b/app/repcofkk/app_settings.py index 73e4043..64f7f6c 100644 --- a/app/repcofkk/app_settings.py +++ b/app/repcofkk/app_settings.py @@ -16,7 +16,7 @@ INSTALLED_APPS = [ """Информация о приложении """ SITE_TITLE = "Система отчетов" SITE_TITLE_S = "СиО" -APP_VERSION = "0.5.1" +APP_VERSION = "0.5.2" APP_VEK = "2024 г" APP_COPPIRIGHT = "Система отчетов" diff --git a/app/static/js/charts/worktime.js b/app/static/js/charts/worktime.js index 443582a..e276e16 100644 --- a/app/static/js/charts/worktime.js +++ b/app/static/js/charts/worktime.js @@ -112,6 +112,9 @@ const spanSum = document.querySelector(`#${item}SUM`) spanSum.textContent = sumTimeString + if (workedWO.days !== 0) workedWO.hours += workedWO.days * 24 + if (workedWA.days !== 0) workedWA.hours += workedWA.days * 24 + if (workedNW.days !== 0) workedNW.hours += workedNW.days * 24 switch (item) { case 'daily': dailyWorkChart.updateSeries([workedWO.hours, workedWA.hours, workedNW.hours])