fix: get_mgroup_goals 可复用去年数据3
This commit is contained in:
parent
9b44d2c398
commit
9c2e940994
|
@ -9,6 +9,7 @@ from apps.wf.models import Ticket
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from typing import List
|
from typing import List
|
||||||
from apps.utils.snowflake import idWorker
|
from apps.utils.snowflake import idWorker
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
def cal_material_count(materialId_list: List[str]=None):
|
def cal_material_count(materialId_list: List[str]=None):
|
||||||
"""
|
"""
|
||||||
|
@ -47,14 +48,16 @@ def get_mgroup_goals(mgroupId, year, reload=False):
|
||||||
mgroup_goals = {}
|
mgroup_goals = {}
|
||||||
if not goals.exists():
|
if not goals.exists():
|
||||||
# 尝试寻找去年的
|
# 尝试寻找去年的
|
||||||
goals_last_year = Goal.objects.filter(mgroup__id=mgroupId, year=year)
|
goals_last_year = Goal.objects.filter(mgroup__id=mgroupId, year=year-1)
|
||||||
if goals_last_year.exists():
|
if goals_last_year.exists():
|
||||||
for goal in goals_last_year:
|
for goal in goals_last_year:
|
||||||
# 复用去年的数据创建
|
# 复用去年的数据创建
|
||||||
goal.id = idWorker.get_id()
|
goal.id = idWorker.get_id()
|
||||||
goal.year = year + 1
|
goal.create_time = timezone.now()
|
||||||
|
goal.update_time = goal.create_time
|
||||||
|
goal.year = year
|
||||||
goal.save()
|
goal.save()
|
||||||
goals = Goal.objects.get(mgroup__id=mgroupId, year=year)
|
goals = Goal.objects.filter(mgroup__id=mgroupId, year=year)
|
||||||
for goal in goals:
|
for goal in goals:
|
||||||
mgroup_goals[f'{goal.goal_cate.code}_year'] = goal.goal_val
|
mgroup_goals[f'{goal.goal_cate.code}_year'] = goal.goal_val
|
||||||
for i in range(12):
|
for i in range(12):
|
||||||
|
|
Loading…
Reference in New Issue