From 9b44d2c398e61fa376df07ac173fef8069d27cb2 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sat, 28 Dec 2024 23:32:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20get=5Fmgroup=5Fgoals=20=E5=8F=AF?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E5=8E=BB=E5=B9=B4=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/mtm/services.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/mtm/services.py b/apps/mtm/services.py index f2aaa53e..47f7ab60 100644 --- a/apps/mtm/services.py +++ b/apps/mtm/services.py @@ -38,7 +38,7 @@ def get_mgroup_goals(mgroupId, year, reload=False): """ 获取工段某年的全部目标值, 以字典形式返回, 带缓存 """ - goals = Goal.objects.get(mgroup__id=mgroupId, year=year) + goals = Goal.objects.filter(mgroup__id=mgroupId, year=year) key = f'mgroup_{mgroupId}_goals_{year}' if reload is False: mgroup_goals = cache.get(key, None) @@ -47,8 +47,7 @@ def get_mgroup_goals(mgroupId, year, reload=False): mgroup_goals = {} if not goals.exists(): # 尝试寻找去年的 - goals_last_year = Goal.objects.filter( - Q(mgroup__id=mgroupId) | Q(mgroup__name=mgroupId), year=year-1) + goals_last_year = Goal.objects.filter(mgroup__id=mgroupId, year=year) if goals_last_year.exists(): for goal in goals_last_year: # 复用去年的数据创建