feat: handover数据库变动/初步更新批次数据关系链

This commit is contained in:
caoqianming 2025-03-31 16:42:18 +08:00
parent cb28f1d9ef
commit c05c59b004
2 changed files with 27 additions and 7 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.12 on 2025-03-31 08:04
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('wpm', '0106_alter_handover_type'),
]
operations = [
migrations.AlterField(
model_name='handoverb',
name='handover',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='b_handover', to='wpm.handover', verbose_name='关联交接记录'),
),
]

View File

@ -529,7 +529,7 @@ class Handover(CommonADModel):
class Handoverb(BaseModel):
"""TN: 子级交接记录
"""
handover = models.ForeignKey(Handover, verbose_name='关联交接记录', on_delete=models.CASCADE)
handover = models.ForeignKey(Handover, verbose_name='关联交接记录', on_delete=models.CASCADE, related_name="b_handover")
batch = models.TextField("批次号", null=True, blank=True)
wm = models.ForeignKey(WMaterial, verbose_name='关联车间库存', on_delete=models.SET_NULL,
null=True, blank=True, related_name='handoverb_wm')
@ -614,15 +614,16 @@ class BatchSt(BaseModel):
@classmethod
@transaction.atomic
def init_dag(cls, batch:str, force_update=False):
def init_dag(cls, batch:str):
"""
更新批次数据关系链
更新批次数据关系链(初步)
"""
ins:BatchSt = cls.g_create(batch)
ins, _ = cls.g_create(batch)
if ins.mio is None and ins.handover is None and ins.mlog is None:
force_update = True
if force_update:
pass
from apps.inm.models import MIOItem
mioitem = MIOItem.objects.filter(batch=batch, mio__submit_time__isnull=False).order_by('mio__submit_time').first()
handover = Handover.objects.filter(mtype=20, b_handover__batch=batch, submit_time__isnull=False).order_by('submit_time').first() # 拆分
handover2 = Handover.objects.filter(mtype=10, b_handover__batch=batch, submit_time__isnull=False).order_by('submit_time').first() # 合并
return ins
class BatchLog(BaseModel):