From 77bca898394e4fa8456f9cb8e38a938f140916af Mon Sep 17 00:00:00 2001 From: zakhy Date: Tue, 13 Aug 2024 08:49:38 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=87=D0=B5=D0=B3=D0=BE=20=D0=B2=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/apps/main/services/worktime/service.py | 4 +++- app/repcofkk/app_settings.py | 2 +- app/static/js/charts/worktime.js | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/apps/main/services/worktime/service.py b/app/apps/main/services/worktime/service.py index ceb6edc..f10a89d 100644 --- a/app/apps/main/services/worktime/service.py +++ b/app/apps/main/services/worktime/service.py @@ -13,7 +13,9 @@ class FabricWorkTimeService(DashboardBaseService): status_durations = {"WO": timedelta(0), "WA": timedelta(0), "NW": timedelta(0)} 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": "P0DT00H00M00S"} previous_time = qs[0]["time"] previous_status = qs[0]["status"] 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]) From a8240902da4ea287c867d5828242a9326bf90cf2 Mon Sep 17 00:00:00 2001 From: zakhy Date: Tue, 13 Aug 2024 08:49:38 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=87=D0=B5=D0=B3=D0=BE=20=D0=B2=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Если нет данных с начала смены. то считается что фабрика не работает --- app/apps/main/services/worktime/service.py | 13 ++++++------- app/repcofkk/app_settings.py | 2 +- app/static/js/charts/worktime.js | 3 +++ 3 files changed, 10 insertions(+), 8 deletions(-) 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])