feat: 添加一个log排查逻辑错误

This commit is contained in:
caoqianming 2024-04-30 14:21:09 +08:00
parent dddab37c63
commit 5f20247818
1 changed files with 3 additions and 1 deletions

View File

@ -270,7 +270,7 @@ def cal_mpointstat_manual(mpointId: str, sflogId: str, mgroupId: str, year: int,
ms_year_s.val = sum_dict_year_s["sum"]
ms_year_s.save()
if next_cal: # 二次计算
if next_cal: # 计算工段级数据,手动录入时调用
if hour:
cal_enstat("hour_s", sflogId, mgroupId, year, month, day, hour, year_s, month_s, day_s)
else:
@ -307,6 +307,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
if sflog:
year_s, month_s, day_s = sflog.get_ymd
team = sflog.team
# 如果没有班组,那么month_st无需计算
if team is None and type == "month_st":
return year_s, month_s, day_s
if type == "hour_s":
@ -360,6 +361,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
mps = MpointStat.objects.filter(type="year_s", mgroup=mgroup, year_s=year_s, mpoint__material=material)
if mps.filter(mpoint__is_rep_mgroup=True).exists():
mps = mps.filter(mpoint__is_rep_mgroup=True)
myLogger.info(f'{mgroup.name}-{material.name}-{year_s}-{month_s}-{day_s}-{hour}')
amount_consume = mps.aggregate(sum=Sum("val"))["sum"]
if amount_consume is None:
amount_consume = 0