This commit is contained in:
zty 2025-09-08 16:31:24 +08:00
commit 0183234497
6 changed files with 70 additions and 6 deletions

View File

@ -186,6 +186,7 @@ class MlogbFilter(filters.FilterSet):
"wm_in__state": ["exact"], "wm_in__state": ["exact"],
"material_in": ["exact", "isnull"], "material_in": ["exact", "isnull"],
"material_out": ["exact", "isnull"], "material_out": ["exact", "isnull"],
"parent": ["exact", "isnull"],
} }
def filter_type(self, queryset, name, value): def filter_type(self, queryset, name, value):

View File

@ -69,6 +69,7 @@ def main(batch: str, mgroup_obj:Mgroup=None):
data[f"{mgroup_name}_合格率"] = 0 data[f"{mgroup_name}_合格率"] = 0
mlogbd1_qs = MlogbDefect.objects.filter(mlogb__in=mlogb1_qs, count__gt=0).values("defect__name").annotate(total=Sum("count")) mlogbd1_qs = MlogbDefect.objects.filter(mlogb__in=mlogb1_qs, count__gt=0).values("defect__name").annotate(total=Sum("count"))
mlogbd1_qs_x = MlogbDefect.objects.filter(mlogb__in=mlogb1_qs, count_has__gt=0).values("defect__name").annotate(total=Sum("count_has"))
mlogbd1_q_qs = MlogbDefect.objects.filter(mlogb__id__in=mlogb_q_ids, count__gt=0).values("defect__name").annotate(total=Sum("count")) mlogbd1_q_qs = MlogbDefect.objects.filter(mlogb__id__in=mlogb_q_ids, count__gt=0).values("defect__name").annotate(total=Sum("count"))
for item in mlogbd1_q_qs: for item in mlogbd1_q_qs:
@ -79,6 +80,10 @@ def main(batch: str, mgroup_obj:Mgroup=None):
data[f"{mgroup_name}_缺陷_{item['defect__name']}"] = item["total"] data[f"{mgroup_name}_缺陷_{item['defect__name']}"] = item["total"]
data[f"{mgroup_name}_缺陷_{item['defect__name']}_比例"] = round((item["total"] / data[f"{mgroup_name}_count_real"])*100, 2) data[f"{mgroup_name}_缺陷_{item['defect__name']}_比例"] = round((item["total"] / data[f"{mgroup_name}_count_real"])*100, 2)
for item in mlogbd1_qs_x:
data[f"{mgroup_name}_含缺陷_{item['defect__name']}"] = item["total"]
data[f"{mgroup_name}_含缺陷_{item['defect__name']}_比例"] = round((item["total"] / data[f"{mgroup_name}_count_real"])*100, 2)
data[f"{mgroup_name}_日期"] = list(set(data[f"{mgroup_name}_日期"])) data[f"{mgroup_name}_日期"] = list(set(data[f"{mgroup_name}_日期"]))
data[f"{mgroup_name}_小日期"] = max(data[f"{mgroup_name}_日期"]).strftime("%Y-%m-%d") data[f"{mgroup_name}_小日期"] = max(data[f"{mgroup_name}_日期"]).strftime("%Y-%m-%d")
data[f"{mgroup_name}_大日期"] = min(data[f"{mgroup_name}_日期"]).strftime("%Y-%m-%d") data[f"{mgroup_name}_大日期"] = min(data[f"{mgroup_name}_日期"]).strftime("%Y-%m-%d")

View File

@ -10,7 +10,7 @@ from django.db.models import Sum
from django.utils import timezone from django.utils import timezone
from apps.system.models import User from apps.system.models import User
from apps.mtm.models import Material, Process, Route, Mgroup, RoutePack from apps.mtm.models import Material, Process, Route, Mgroup, RoutePack, RouteMat
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
from apps.utils.mixins import CustomListModelMixin, BulkCreateModelMixin, ComplexQueryMixin from apps.utils.mixins import CustomListModelMixin, BulkCreateModelMixin, ComplexQueryMixin
@ -199,6 +199,7 @@ class MlogViewSet(CustomModelViewSet):
search_fields = ['material_in__name', search_fields = ['material_in__name',
'material_in__number', 'material_in__specification', 'batch', 'material_in__model', 'material_in__number', 'material_in__specification', 'batch', 'material_in__model',
'material_out__name', 'material_out__number', 'material_out__specification', 'material_out__model', "b_mlog__batch"] 'material_out__name', 'material_out__number', 'material_out__specification', 'material_out__model', "b_mlog__batch"]
ordering_fields = ["create_time", "update_time"]
def add_info_for_item(self, data): def add_info_for_item(self, data):
if data.get("oinfo_json", {}): if data.get("oinfo_json", {}):
@ -686,6 +687,7 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
@classmethod @classmethod
def p_create_after(cls, mlogbin:Mlogb): def p_create_after(cls, mlogbin:Mlogb):
mlogbin_parent:Mlogb = mlogbin.parent
mlog:Mlog = mlogbin.mlog mlog:Mlog = mlogbin.mlog
mgroup:Mgroup = mlog.mgroup mgroup:Mgroup = mlog.mgroup
route:Route = mlogbin.route route:Route = mlogbin.route
@ -701,9 +703,15 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
material_out:Material = material_in if is_fix else route.material_out material_out:Material = material_in if is_fix else route.material_out
if material_out is None: if material_out is None:
raise ParseError('产物不可为空') raise ParseError('产物不可为空')
if route and route.material_in != material_in:
raise ParseError('工艺步骤输入与实际输入不符')
# 如果是主要输入物料且是主批次,才需生成输出 # 如果是主要输入物料且是主批次,才需生成输出
if is_fix is False and route and route.material_in != material_in or mlogbin.parent is not None: if mlogbin_parent is not None:
return if mtype and mtype == Process.PRO_MERGE:
pass
else:
return
wm_in: WMaterial = mlogbin.wm_in wm_in: WMaterial = mlogbin.wm_in
@ -790,7 +798,21 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
mlogbout.save(update_fields=["count_json_from"]) mlogbout.save(update_fields=["count_json_from"])
elif mtype == Process.PRO_MERGE: # 支持批到批,批到个 elif mtype == Process.PRO_MERGE: # 支持批到批,批到个
div_number = route.div_number div_number = route.div_number
xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / div_number) if mlogbin_parent is not None:
# 说明是次批
if mlogbin.material_in == mlogbin_parent.material_in:
# 如果主次物料一致,则进行处理
count_use_sum = Mlogb.objects.filter(Q(id=mlogbin_parent.id)|Q(parent=mlogbin_parent), material_in=mlogbin.material_in).aggregate(Sum('count_use'))['count_use__sum'] or 0
count_pn_jgqbl_sum = Mlogb.objects.filter(Q(id=mlogbin_parent.id)|Q(parent=mlogbin_parent), material_in=mlogbin.material_in).aggregate(Sum('count_pn_jgqbl'))['count_pn_jgqbl__sum'] or 0
xcount = math.floor( (count_use_sum-count_pn_jgqbl_sum) / div_number)
else:
# 获取可用的辅料
if not RouteMat.objects.filter(material=mlogbin.material_in, route=route).exists():
raise ParseError("工艺步骤中不存在该辅料")
# 使用主批作为后续引用
mlogbin = mlogbin_parent
else:
xcount = math.floor( (mlogbin.count_use-mlogbin.count_pn_jgqbl) / div_number)
d_count_real = xcount d_count_real = xcount
d_count_ok = xcount d_count_ok = xcount
number_to_batch = process.number_to_batch number_to_batch = process.number_to_batch

View File

@ -1,3 +1,39 @@
## 2.8.2025090815
- feat: 新增功能
- batch bxerp含缺陷统计 [caoqianming]
- mlog list 添加update_time筛选 [caoqianming]
- 工艺步骤中辅料使用的校验 [caoqianming]
- mlogb添加parent isnull查询 [caoqianming]
- 次批触发输出产生 [caoqianming]
- 修改印章的model 和 serializer [zty]
- 修改 ofm sevice 印章模块 [zty]
- base 优化safe_get_or_create [caoqianming]
- 修改ofm seal 过滤查询功能 [zty]
- 行政管理 -印章管理 [zty]
- ftest默认为合格 [caoqianming]
- mlogbdefect添加count_has 字段及处理 [caoqianming]
- update_mb_item defect处理更严谨 [caoqianming]
- 取消最后一步产出与工艺包不一致 的校验 [caoqianming]
- 出入库记录添加乐观锁 [caoqianming]
- batch_bxerp考虑mlogbw_from [caoqianming]
- mlog_submit mlogbdefect增加筛选条件 [caoqianming]
- 导入物料明细时可默认批次号为无 [caoqianming]
- 光芯批次统计增加班次返回 [caoqianming]
- mlog_submit 进行操作时间校验 [caoqianming]
- route update 时from_route存在则不可修改关键信息 [caoqianming]
- mlogchange支持work_start_time [caoqianming]
- route采用引用方式允许重复创建 [caoqianming]
- MlogSerializer 处理 work_start_time 的 bug [caoqianming]
- 修改能管采集的点位 [zty]
- mlog work_start_time必填 [caoqianming]
- ftestwork submit支持mb [zty]
- toggle_state 使用 routepack.update权限 [caoqianming]
- ftestwork支持对materialbatch检查 [caoqianming]
- batchst返回material_start相关信息 [caoqianming]
- fix: 问题修复
- ftestwork submit 校验wm和mb bug [caoqianming]
- MlogbInUpdateSerializer 联动count_use 和 count_real [caoqianming]
- batchlog batches_to 优化 [caoqianming]
## 2.7.2025082816 ## 2.7.2025082816
- feat: 新增功能 - feat: 新增功能
- 添加定时任务以标记mtask为已完成 [caoqianming] - 添加定时任务以标记mtask为已完成 [caoqianming]

View File

@ -35,7 +35,7 @@ sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
SYS_NAME = '星途工厂综合管理系统' SYS_NAME = '星途工厂综合管理系统'
SYS_VERSION = '2.7.2025082816' SYS_VERSION = '2.8.2025090815'
X_FRAME_OPTIONS = 'SAMEORIGIN' X_FRAME_OPTIONS = 'SAMEORIGIN'
# Application definition # Application definition

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# 设置默认版本号 (格式: 2.7.YYYYMMDDHH) # 设置默认版本号 (格式: 2.7.YYYYMMDDHH)
DEFAULT_VERSION="2.7.$(date '+%Y%m%d%H')" DEFAULT_VERSION="2.8.$(date '+%Y%m%d%H')"
# 获取参数 (起始tag) # 获取参数 (起始tag)
TARGET_TAG="$1" TARGET_TAG="$1"