feat: 光子get_alldata_with_batch优化
This commit is contained in:
parent
cb09cee753
commit
53972fd22a
|
@ -1,4 +1,4 @@
|
|||
from apps.wpm.models import Mlog, BatchSt
|
||||
from apps.wpm.models import Mlog, BatchSt, Handover
|
||||
from apps.mtm.models import Mgroup
|
||||
from apps.system.models import Dept
|
||||
from apps.inm.models import MIOItem
|
||||
|
@ -72,6 +72,7 @@ def get_alldata_with_batch(batch: str):
|
|||
material_start = None
|
||||
if mlogs_blcx_qs.exists():
|
||||
data["产品规格"] = []
|
||||
data["棒料成型_日期"] = []
|
||||
data["棒料成型_出料人"] = []
|
||||
data["棒料成型_切料人"] = []
|
||||
data["棒料成型_备注"] = ""
|
||||
|
@ -85,6 +86,7 @@ def get_alldata_with_batch(batch: str):
|
|||
data["棒料成型_切料人"].append(item.handle_user_2) # 对象
|
||||
if item.note:
|
||||
data["棒料成型_备注"] = ";".join([data["棒料成型_备注"], item.note])
|
||||
data["棒料成型_日期"].append(item.handle_date)
|
||||
for field in mlog_count_fields:
|
||||
if getattr(item, field) > 0 or field in ["count_real", "count_ok"]:
|
||||
if f'棒料成型_{field}' not in data:
|
||||
|
@ -98,6 +100,8 @@ def get_alldata_with_batch(batch: str):
|
|||
data["棒料成型_出料人"] = ";".join([item.name for item in data["棒料成型_出料人"]])
|
||||
data["棒料成型_切料人"] = list(set(data["棒料成型_切料人"]))
|
||||
data["棒料成型_切料人"] = ";".join([item.name for item in data["棒料成型_切料人"]])
|
||||
data["棒料成型_日期"] = list(set(data["棒料成型_日期"]))
|
||||
data["棒料成型_日期"] = [item.strftime("%Y-%m-%d") for item in data["棒料成型_日期"]]
|
||||
try:
|
||||
data["棒料成型_合格率"] = round((data["棒料成型_count_ok"] * 100/ data["棒料成型_count_real"]), 1)
|
||||
except ZeroDivisionError:
|
||||
|
@ -112,12 +116,14 @@ def get_alldata_with_batch(batch: str):
|
|||
if mlogs_glcx_qs.exists():
|
||||
data["产品规格"] = []
|
||||
data["管料成型_备注"] = ""
|
||||
data["管料成型_日期"] = []
|
||||
for item in mlogs_glcx_qs:
|
||||
if material_start is None:
|
||||
material_start = item.material_out
|
||||
data["产品规格"].append(item.material_out) # 对象
|
||||
if item.note:
|
||||
data["管料成型_备注"] = ";".join([data["管料成型_备注"], item.note])
|
||||
data["管料成型_日期"].append(item.handle_date)
|
||||
for field in mlog_count_fields:
|
||||
if getattr(item, field) > 0 or field in ["count_real", "count_ok"]:
|
||||
if f'管料成型_{field}' not in data:
|
||||
|
@ -127,6 +133,8 @@ def get_alldata_with_batch(batch: str):
|
|||
data["产品规格"] = list(set(data["产品规格"]))
|
||||
data["产品规格"] = ";".join([item.specification for item in data["产品规格"]])
|
||||
data["管料成型_合格率"] = round((data["管料成型_count_ok"] * 100 / data["管料成型_count_real"]), 1)
|
||||
data["管料成型_日期"] = list(set(data["管料成型_日期"]))
|
||||
data["管料成型_日期"] = [item.strftime("%Y-%m-%d") for item in data["管料成型_日期"]]
|
||||
|
||||
# 7车间生产入库数据/ 8车间中检数据
|
||||
mioitem_count_fields = MIOItem.count_fields()
|
||||
|
@ -177,9 +185,10 @@ def get_alldata_with_batch(batch: str):
|
|||
if item.test_note:
|
||||
data["十车间入库_检验备注"] = ";".join([data["十车间入库_检验备注"], item.test_note])
|
||||
if item.mio.do_user:
|
||||
data["十车间入库_仓库执行人"].append(item.mio.do_user)
|
||||
data["十车间入库_仓库执行人"].append(item.mio.mio_user)
|
||||
if item.test_user:
|
||||
data["十车间入库_抽检人"].append(item.test_user)
|
||||
data["十车间入库_日期"].append(item.mio.inout_date)
|
||||
for field in mioitem_count_fields:
|
||||
if getattr(item, field) is not None and (getattr(item, field) > 0 or field in ["count", "count_notok", "count_sampling"]):
|
||||
if f'十车间入库_{field}' not in data:
|
||||
|
@ -198,6 +207,28 @@ def get_alldata_with_batch(batch: str):
|
|||
data["十车间入库_合格数"] = data["十车间入库_count"] - data["十车间入库_count_notok"]
|
||||
data["十车间入库_合格率"] = round((data["十车间入库_count"] - data["十车间入库_count_notok"]) * 100/ data["十车间入库_count"], 1)
|
||||
|
||||
# 其他入库数据
|
||||
mioitem_qt_qs = MIOItem.objects.filter(mio__type="other_in", batch=batch, mio__submit_time__isnull=False)
|
||||
if mioitem_qt_qs.exists():
|
||||
data["其他入库_仓库执行人"] = []
|
||||
data["其他入库_日期"] = []
|
||||
for item in mioitem_qt_qs:
|
||||
if material_start is None:
|
||||
material_start = item.material
|
||||
data["其他入库_日期"].append(item.mio.inout_date)
|
||||
if item.mio.do_user:
|
||||
data["其他入库_仓库执行人"].append(item.mio.mio_user)
|
||||
for field in mioitem_count_fields:
|
||||
if getattr(item, field) is not None and (getattr(item, field) > 0 or field in ["count", "count_notok", "count_sampling"]):
|
||||
if f'其他入库_{field}' not in data:
|
||||
data[f'其他入库_{field}'] = getattr(item, field)
|
||||
else:
|
||||
data[f'十车间入库_{field}'] += getattr(item, field)
|
||||
data["其他入库_仓库执行人"] = list(set(data["其他入库_仓库执行人"]))
|
||||
data["其他入库_仓库执行人"] = ";".join([item.name for item in data["其他入库_仓库执行人"]])
|
||||
data["其他入库_日期"] = list(set(data["其他入库_日期"]))
|
||||
data["其他入库_日期"] = ";".join([item.strftime("%Y-%m-%d") for item in data["其他入库_日期"]])
|
||||
|
||||
# 管料退火生产数据
|
||||
mgroup_gltx = Mgroup.objects.get(name="管料退火")
|
||||
mlogs_glth_qs = Mlog.objects.filter(submit_time__isnull=False, mgroup=mgroup_gltx, batch=batch)
|
||||
|
@ -245,9 +276,9 @@ def get_alldata_with_batch(batch: str):
|
|||
material_start = item.material
|
||||
data["六车间领料_日期"].append(item.mio.inout_date)
|
||||
if item.mio.do_user:
|
||||
data["六车间领料_仓库执行人"].append(item.mio.do_user)
|
||||
data["六车间领料_仓库执行人"].append(item.mio.mio_user)
|
||||
if item.mio.mio_user:
|
||||
data["六车间领料_车间执行人"].append(item.mio.mio_user)
|
||||
data["六车间领料_车间执行人"].append(item.mio.do_user)
|
||||
for field in mioitem_count_fields:
|
||||
if getattr(item, field) is not None and getattr(item, field) > 0:
|
||||
if f'六车间领料_{field}' not in data:
|
||||
|
@ -263,7 +294,26 @@ def get_alldata_with_batch(batch: str):
|
|||
data["产品规格"] = list(set(data["产品规格"]))
|
||||
data["产品规格"] = ";".join([item.specification for item in data["产品规格"]])
|
||||
|
||||
# 六车间工段生产数据
|
||||
# 六车间通过交接记录的领料数据
|
||||
handover6_qs = Handover.objects.filter(recive_dept=dept6, submit_time__isnull=False, batch=batch)
|
||||
if handover6_qs.exists():
|
||||
data["六车间交接领料_日期"] = []
|
||||
data["六车间交接领料_送料人"] = []
|
||||
data["六车间交接领料_接料人"] = []
|
||||
data["六车间交接领料_count"] = 0
|
||||
for item in handover6_qs:
|
||||
data["六车间交接领料_count"] += item.count
|
||||
data["六车间交接领料_日期"].append(item.send_date)
|
||||
if item.send_user:
|
||||
data["六车间交接领料_送料人"].append(item.send_user)
|
||||
if item.recive_user:
|
||||
data["六车间交接领料_接料人"].append(item.recive_user)
|
||||
data["六车间交接领料_日期"] = list(set(data["六车间交接领料_日期"]))
|
||||
data["六车间交接领料_日期"] = ";".join([item.strftime("%Y-%m-%d") for item in data["六车间交接领料_日期"]])
|
||||
data["六车间交接领料_送料人"] = list(set(data["六车间交接领料_送料人"]))
|
||||
data["六车间交接领料_送料人"] = ";".join([item.name for item in data["六车间交接领料_送料人"]])
|
||||
data["六车间交接领料_接料人"] = list(set(data["六车间交接领料_接料人"]))
|
||||
data["六车间交接领料_接料人"] = ";".join([item.name for item in data["六车间交接领料_接料人"]])
|
||||
|
||||
# 六车间工段生产数据
|
||||
mgroup_list = ["平头", "粘铁头", "粗中细磨", "平磨", "掏管", "抛光", "开槽", "倒角"]
|
||||
|
@ -348,7 +398,7 @@ def get_alldata_with_batch(batch: str):
|
|||
if item.test_date:
|
||||
data["六车间生产入库_检验日期"].append(item.test_date)
|
||||
for field in mioitem_count_fields:
|
||||
if getattr(item, field) is not None and (getattr(item, field) > 0 or field in ["count", "count_notok"]):
|
||||
if getattr(item, field) is not None and (getattr(item, field) > 0 or field in ["count", "count_notok", "count_sampling"]):
|
||||
if f'六车间生产入库_{field}' not in data:
|
||||
data[f'六车间生产入库_{field}'] = getattr(item, field)
|
||||
else:
|
||||
|
@ -357,6 +407,8 @@ def get_alldata_with_batch(batch: str):
|
|||
data["六车间生产入库_日期"] = ";".join([item.strftime("%Y-%m-%d") for item in data["六车间生产入库_日期"]])
|
||||
data["六车间生产入库_检验日期"] = list(set(data["六车间生产入库_检验日期"]))
|
||||
data["六车间生产入库_检验日期"] = ";".join([item.strftime("%Y-%m-%d") for item in data["六车间生产入库_检验日期"]])
|
||||
data['六车间生产入库_检验人'] = list(set(data['六车间生产入库_检验人']))
|
||||
data['六车间生产入库_检验人'] = ";".join([item.name for item in data['六车间生产入库_检验人']])
|
||||
try:
|
||||
data['六车间生产入库_合格率'] = round((data['六车间生产入库_count'] - data['六车间生产入库_count_notok']) * 100/ data['六车间生产入库_count'], 1)
|
||||
except decimal.InvalidOperation:
|
||||
|
@ -410,7 +462,7 @@ def get_alldata_with_batch(batch: str):
|
|||
if item.mio.inout_date:
|
||||
data["销售发货_日期"].append(item.mio.inout_date)
|
||||
if item.mio.do_user:
|
||||
data['销售发货_仓库执行人'].append(item.mio.do_user)
|
||||
data['销售发货_仓库执行人'].append(item.mio.mio_user)
|
||||
data['销售发货_count']+= item.count
|
||||
if getattr(data, "棒料成型_count_real", 0) > 0:
|
||||
data["七车间_批次发货合格率"] = round(data["销售发货_count"] * 100/ data["棒料成型_count_real"], 1)
|
||||
|
|
Loading…
Reference in New Issue