feat: 批号追加工段标识

This commit is contained in:
caoqianming 2025-04-21 11:32:57 +08:00
parent 9e4e5a28c6
commit 786d178edc
3 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2025-04-21 02:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mtm', '0055_auto_20250327_1239'),
]
operations = [
migrations.AddField(
model_name='mgroup',
name='batch_append_code',
field=models.BooleanField(default=False, verbose_name='批号追加工段标识'),
),
]

View File

@ -154,6 +154,7 @@ class Mgroup(CommonBModel):
'直接材料', default=list, blank=True, help_text='material的ID列表')
test_materials = models.JSONField(
'检测材料', default=list, blank=True, help_text='material的ID列表')
batch_append_code = models.BooleanField('批号追加工段标识', default=False)
sort = models.PositiveSmallIntegerField('排序', default=1)
need_enm = models.BooleanField('是否进行能源监测', default=True)
is_running = models.BooleanField('是否正常运行', default=False)

View File

@ -29,7 +29,8 @@ myLogger = logging.getLogger('log')
def generate_new_batch(old_batch: str, mlog: Mlog):
new_batch = old_batch
supplier = mlog.supplier
process = mlog.mgroup.process
mgroup = mlog.mgroup
process = mgroup.process
if mlog.mtype == Mlog.MTYPE_OUT:
supplier_number = supplier.number if supplier else ''
if supplier_number:
@ -40,6 +41,9 @@ def generate_new_batch(old_batch: str, mlog: Mlog):
new_batch = f'{new_batch}>{number}'
if mlog.index:
new_batch = f'{new_batch}>{mlog.index}'
if mgroup.batch_append_code:
if mgroup.code:
new_batch = f'{new_batch}>{mgroup.code}'
return new_batch
def find_material_can_change(material: Material, mgroup_to: Mgroup):