feat: 添加料耗系数

This commit is contained in:
caoqianming 2024-04-26 15:24:42 +08:00
parent 7642f23423
commit 9805b471d4
1 changed files with 9 additions and 1 deletions

View File

@ -14,6 +14,7 @@ from apps.fim.services import get_cost_unit, get_price_unit
from apps.fim.models import Fee
from apps.enm.services import translate_eval_formula
import logging
from server.settings import get_sysconfig
from django.db.models import F
from apps.wpm.services import get_pcoal_heat
from django.utils import timezone
@ -83,8 +84,11 @@ def cal_mpointstats_duration(start_time: str, end_time: str):
"""
重跑某一段时间的任务
"""
mytz = tz.gettz(settings.TIME_ZONE)
start_time = datetime.datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S")
start_time.replace(tzinfo=mytz)
end_time = datetime.datetime.strptime(end_time, "%Y-%m-%d %H:%M:%S")
start_time.replace(tzinfo=mytz)
current_time = start_time
while current_time <= end_time:
year, month, day, hour = current_time.year, current_time.month, current_time.day, current_time.hour
@ -353,6 +357,9 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
if amount_consume is None:
amount_consume = 0
if ind == 0 and has_product: # 如果是产量
# 料耗系数
if mgroup.name == '回转窑':
amount_consume = amount_consume / get_sysconfig('enm.enm_lhxs')
enstat.total_production = amount_consume
else:
if material.code in ["pcoal", "cair", "steam"]:
@ -443,7 +450,8 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s,
pre_enstat = EnStat.objects.filter(type=enstat.type, year_s=enstat.year_s, month_s=enstat.month_s, day_s=enstat.day_s, hour=enstat.hour, mgroup__name="原料磨").first()
if pre_enstat:
try:
enstat.celec_consume_unit = enstat.elec_consume_unit + 1.45 * pre_enstat.elec_consume_unit
# 料耗系数
enstat.celec_consume_unit = enstat.elec_consume_unit + get_sysconfig('enm.enm_lhxs') * pre_enstat.elec_consume_unit
enstat.save()
except Exception as e:
pass