feat: 增加get_day_s方法

This commit is contained in:
caoqianming 2023-08-23 13:50:43 +08:00
parent e907b152f3
commit c424254670
1 changed files with 12 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import re
import traceback
from apps.mtm.services import get_mgroup_goals
from django.db.models import Q
import datetime
def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour: int):
@ -19,6 +20,17 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour:
return rval
def get_day_s(year: int, month: int, day: int, hour: int, hour_split: int = 21):
"""
根据给定的小时数, 计算出班天
"""
if hour <= hour_split:
return year, month, day
else:
now = datetime.datetime(year, month, day, hour)
now2 = now + datetime.timedelta(days=1)
return now2.year, now2.month, now2.day
# cal_rule = {
# "电石渣": {
# "total_production": 0.4,