feat: 增加correct_material_batch以矫正mb
This commit is contained in:
parent
3eb7b76095
commit
aaa5545c30
|
@ -0,0 +1,24 @@
|
|||
from .models import MaterialBatch
|
||||
from apps.mtm.models import Material, Mgroup
|
||||
from apps.system.models import Dept
|
||||
from rest_framework.exceptions import ParseError
|
||||
def correct_material_batch():
|
||||
"""矫正物料批次
|
||||
"""
|
||||
mgroups = Mgroup.objects.all()
|
||||
p_dict = {}
|
||||
for mgroup in mgroups:
|
||||
processId = mgroup.process.id
|
||||
dept: Dept = mgroup.belong_dept
|
||||
if processId not in p_dict:
|
||||
p_dict[processId] = dept
|
||||
else:
|
||||
raise ParseError('存在多个同工序的工段:{}'.format(mgroup.name))
|
||||
mbs = MaterialBatch.objects.filter(material__type__in=[Material.MA_TYPE_GOOD, Material.MA_TYPE_HALFGOOD],
|
||||
production_dept=None)
|
||||
for mb in mbs:
|
||||
if mb.material.process:
|
||||
processId = mb.material.process.id
|
||||
mb.production_dept = p_dict[processId]
|
||||
mb.save()
|
||||
|
|
@ -130,7 +130,7 @@ class MIOItem(BaseModel):
|
|||
count_n_qx = models.PositiveIntegerField('气线', default=0)
|
||||
count_n_zz = models.PositiveIntegerField('杂质', default=0)
|
||||
count_n_ysq = models.PositiveIntegerField('颜色青', default=0)
|
||||
count_n_jsqx = models.PositiveIntegerField('结石气线', default=0)
|
||||
count_n_jsqx = models.PositiveIntegerField('结石气线', default=0) # 废弃字段
|
||||
count_n_qt = models.PositiveIntegerField('其他', default=0)
|
||||
|
||||
is_testok = models.BooleanField('检验是否合格', default=True)
|
||||
|
|
Loading…
Reference in New Issue