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: # 复用去年的数据创建