From 18f39bff9cec76e0ae798025ee97186d94b9a0c0 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 10 Jan 2025 14:41:56 +0800 Subject: [PATCH] feat: get_alldata_with_batch_and_store --- apps/wpm/services_2.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/wpm/services_2.py b/apps/wpm/services_2.py index 203339b1..52330805 100644 --- a/apps/wpm/services_2.py +++ b/apps/wpm/services_2.py @@ -11,8 +11,15 @@ def get_alldata_with_batch_and_store(batch: str): """ 获取某个批次的整体生产数据并保存 """ + need_update = False if BASE_PROJECT_CODE == "gzerp": + need_update = True last_time, data = get_alldata_with_batch(batch) + elif BASE_PROJECT_CODE == "gxerp": + need_update = True + last_time, data = get_alldata_with_batch_gx(batch) + + if need_update and last_time and data: bobj, _ = BatchSt.objects.get_or_create(batch=batch, defaults={ "last_time": last_time }) @@ -20,6 +27,12 @@ def get_alldata_with_batch_and_store(batch: str): bobj.data = data bobj.save() +def get_alldata_with_batch_gx(batch: str): + """ + 光芯获取batch的统计数据 + """ + pass + def get_alldata_with_batch(batch: str): """ 获取某个批次的整体生产数据 @@ -56,7 +69,7 @@ def get_alldata_with_batch(batch: str): data[f'棒料成型_{field}'] += getattr(item, field) # 整理棒料成型数据 data["产品规格"] = list(set(data["产品规格"])) - data["产品规格"] = ";".join([item.specification for item in data["产品规格"]]) + data["产品规格"] = ";".join([item.specification if item.specification else "" for item in data["产品规格"]]) data["棒料成型_出料人"] = list(set(data["棒料成型_出料人"])) data["棒料成型_出料人"] = ";".join([item.name for item in data["棒料成型_出料人"]]) data["棒料成型_切料人"] = list(set(data["棒料成型_切料人"]))