fix: batch_gxerp 优化
This commit is contained in:
parent
74e176ce97
commit
eefd3691e6
|
@ -4,6 +4,7 @@ from apps.qm.models import Defect
|
|||
from apps.wpm.models import Mlogb, MlogbDefect
|
||||
import decimal
|
||||
from django.db.models import Sum
|
||||
from datetime import datetime
|
||||
|
||||
myLogger = logging.getLogger("log")
|
||||
|
||||
|
@ -16,6 +17,9 @@ def main(batch: str):
|
|||
|
||||
data = {"批次号": batch}
|
||||
|
||||
from zoneinfo import ZoneInfo
|
||||
tz_shanghai = ZoneInfo("Asia/Shanghai")
|
||||
|
||||
mgroup_names = ["尺寸检验", "外观检验"]
|
||||
for mgroup_name in mgroup_names:
|
||||
mlogb1_qs = Mlogb.objects.filter(mlog__submit_time__isnull=False, material_out__isnull=False, mlog__mgroup__name=mgroup_name, batch=batch)
|
||||
|
@ -105,7 +109,24 @@ def main(batch: str):
|
|||
except decimal.InvalidOperation:
|
||||
data["外观检验_完全直通合格率"] = 0
|
||||
|
||||
return data, {}
|
||||
first_time = None
|
||||
last_time = None
|
||||
for k, v in data.items():
|
||||
if k.endswith("_日期"):
|
||||
if v:
|
||||
v = v.split(";")
|
||||
if first_time is None:
|
||||
first_time = min(v)
|
||||
else:
|
||||
first_time = min(first_time, min(v))
|
||||
if last_time is None:
|
||||
last_time = max(v)
|
||||
else:
|
||||
last_time = max(last_time, max(v))
|
||||
|
||||
|
||||
return data, {"first_time": datetime.strptime(f"{first_time} 00:00:00", "%Y-%m-%d %H:%M:%S").replace(tzinfo=tz_shanghai) if first_time else None,
|
||||
"last_time": datetime.strptime(f"{last_time} 23:59:59", "%Y-%m-%d %H:%M:%S").replace(tzinfo=tz_shanghai) if last_time else None}
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
Loading…
Reference in New Issue