feat: 完善光子批次统计数据
This commit is contained in:
parent
f35d2d7d9e
commit
dd6dcad74a
|
@ -317,13 +317,12 @@ def get_alldata_with_batch(batch: str):
|
|||
data["六车间生产入库_日期"] = []
|
||||
data["六车间生产入库_检验日期"] = []
|
||||
data["六车间生产入库_检验人"] = []
|
||||
for item in mioitem6_qs:
|
||||
for item in mioitem6_qs2:
|
||||
data["六车间生产入库_日期"].append(item.mio.inout_date)
|
||||
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:
|
||||
if getattr(item, field) is not None and (getattr(item, field) > 0 or field in ["count", "count_notok"]):
|
||||
if f'六车间生产入库_{field}' not in data:
|
||||
data[f'六车间生产入库_{field}'] = getattr(item, field)
|
||||
else:
|
||||
|
@ -333,7 +332,7 @@ def get_alldata_with_batch(batch: str):
|
|||
data["六车间生产入库_检验日期"] = list(set(data["六车间生产入库_检验日期"]))
|
||||
data["六车间生产入库_检验日期"] = ";".join([item.strftime("%Y-%m-%d") for item in data["六车间生产入库_检验日期"]])
|
||||
try:
|
||||
data['六车间生产入库_合格率'] = round((data['六车间生产入库_count']-data['六车间生产入库_count_notok ']) * 100/ data['六车间生产入库_count'], 1)
|
||||
data['六车间生产入库_合格率'] = round((data['六车间生产入库_count'] - data['六车间生产入库_count_notok']) * 100/ data['六车间生产入库_count'], 1)
|
||||
except decimal.InvalidOperation:
|
||||
myLogger.error("六车间生产入库_合格率decimal.InvalidOperation-{data}")
|
||||
data['六车间生产入库_合格率'] = 0
|
||||
|
@ -367,27 +366,29 @@ def get_alldata_with_batch(batch: str):
|
|||
data['成品检验_检验人'] = list(set(data['成品检验_检验人']))
|
||||
data['成品检验_检验人'] = ";".join([item.name for item in data['成品检验_检验人']])
|
||||
data['成品检验_合格率'] = round(data['成品检验_count_ok'] * 100/ data['成品检验_count'], 1)
|
||||
if data["六车间领料_count"]:
|
||||
if getattr(data, "六车间领料_count", 0) > 0:
|
||||
data["六车间_批次生产合格率"] = round(data["成品检验_count_ok"] * 100/ data["六车间领料_count"], 1)
|
||||
if data["棒料成型_count_real"]:
|
||||
if getattr(data, "棒料成型_count_real", 0) > 0:
|
||||
data["七车间_批次应出合格率"] = round(data["成品检验_count_ok"] * 100/ data["棒料成型_count_real"], 1)
|
||||
|
||||
# 销售发货数据
|
||||
mioitem_qs = MIOItem.objects.filter(batch=batch, mio__type="sale_out", mio__submit_time__isnull=False)
|
||||
if mioitem_qs.exists():
|
||||
data["销售发货_日期"] = []
|
||||
data['销售发货_执行人'] = []
|
||||
data['销售发货_仓库执行人'] = []
|
||||
data['销售发货_count'] = 0
|
||||
for item in mioitem_qs:
|
||||
last_time = item.mio.update_time if item.mio.update_time > last_time else last_time
|
||||
if item.mio.inout_date:
|
||||
data["销售发货_日期"].append(item.mio.inout_date)
|
||||
data['销售发货_执行人'].append(item.mio.user)
|
||||
if item.mio.do_user:
|
||||
data['销售发货_仓库执行人'].append(item.mio.do_user)
|
||||
data['销售发货_count']+= item.count
|
||||
if data["棒料成型_count_real"]:
|
||||
data["七车间_批次发货合格率"] = round(data["销售发货_count"] * 100/ data["棒料成型_count_real"], 1)
|
||||
if data["六车间领料_count"]:
|
||||
if getattr(data, "棒料成型_count_real", 0) > 0:
|
||||
data["七车间_批次发货合格率"] = round(data["销售发货_count"] * 100/ data["棒料成型_count_real"], 1)
|
||||
if getattr(data, "六车间领料_count", 0) > 0:
|
||||
data["六车间_批次发货合格率"] = round(data["销售发货_count"] * 100/ data["六车间领料_count"], 1)
|
||||
data['销售发货_仓库执行人'] = ";".join([item.name for item in data['销售发货_仓库执行人']])
|
||||
|
||||
return last_time, data
|
||||
|
Loading…
Reference in New Issue