feat: 所有batch设为textfield并添加索引

This commit is contained in:
caoqianming 2025-05-23 09:24:34 +08:00
parent 359dd8f898
commit 62f261fd75
8 changed files with 124 additions and 12 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2025-05-23 01:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cm', '0005_labeltemplate_process_json'),
]
operations = [
migrations.AlterField(
model_name='lablemat',
name='batch',
field=models.TextField(db_index=True, verbose_name='批次号'),
),
]

View File

@ -10,7 +10,7 @@ class LableMat(BaseModel):
"""TN: 标签物料"""
state = models.PositiveSmallIntegerField('状态', default=10, choices=WmStateOption.choices)
material = models.ForeignKey(Material, on_delete=models.CASCADE)
batch = models.CharField('批次号', max_length=100)
batch = models.TextField('批次号', db_index=True)
supplier = models.ForeignKey(Supplier, verbose_name='外协供应商', on_delete=models.SET_NULL, null=True, blank=True)
notok_sign = models.CharField('不合格标记', max_length=10, null=True, blank=True)
defect = models.ForeignKey("qm.defect", verbose_name='缺陷', on_delete=models.SET_NULL, null=True, blank=True)

View File

@ -0,0 +1,33 @@
# Generated by Django 3.2.12 on 2025-05-23 01:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inm', '0029_alter_mioitem_batch'),
]
operations = [
migrations.AlterField(
model_name='materialbatch',
name='batch',
field=models.TextField(db_index=True, verbose_name='批次号'),
),
migrations.AlterField(
model_name='materialbatcha',
name='batch',
field=models.TextField(db_index=True, verbose_name='批次号'),
),
migrations.AlterField(
model_name='mioitem',
name='batch',
field=models.TextField(db_index=True, verbose_name='批次号'),
),
migrations.AlterField(
model_name='mioitema',
name='batch',
field=models.TextField(db_index=True, verbose_name='批次号'),
),
]

View File

@ -22,7 +22,7 @@ class MaterialBatch(BaseModel):
"""
TN:物料批次
"""
batch = models.TextField('批次号')
batch = models.TextField('批次号', db_index=True)
state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废')))
material = models.ForeignKey(
Material, on_delete=models.CASCADE, verbose_name='物料')
@ -43,7 +43,7 @@ class MaterialBatchA(BaseModel):
"""
TN:组合件物料批次
"""
batch = models.CharField('批次号', max_length=100)
batch = models.TextField('批次号', db_index=True)
material = models.ForeignKey(
Material, on_delete=models.CASCADE, verbose_name='物料')
rate = models.PositiveIntegerField('比例', default=1)
@ -138,7 +138,7 @@ class MIOItem(BaseModel):
WareHouse, on_delete=models.CASCADE, verbose_name='仓库')
material = models.ForeignKey(
Material, verbose_name='物料', on_delete=models.CASCADE)
batch = models.TextField('批次号')
batch = models.TextField('批次号', db_index=True)
count = models.DecimalField('出入数量', max_digits=12, decimal_places=3)
count_tested = models.PositiveIntegerField('已检数', null=True, blank=True)
test_date = models.DateField('检验日期', null=True, blank=True)
@ -186,7 +186,7 @@ class MIOItemA(BaseModel):
"""
material = models.ForeignKey(
Material, verbose_name='物料', on_delete=models.CASCADE)
batch = models.CharField('批次号', max_length=50)
batch = models.TextField('批次号', db_index=True)
rate = models.PositiveIntegerField('比例', default=1)
mioitem = models.ForeignKey(
MIOItem, verbose_name='关联出入库明细', on_delete=models.CASCADE, related_name='a_mioitem')

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2025-05-23 01:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('qm', '0050_alter_defect_cate'),
]
operations = [
migrations.AlterField(
model_name='ftestwork',
name='batch',
field=models.TextField(db_index=True, verbose_name='生产批次'),
),
]

View File

@ -258,7 +258,7 @@ class FtestWork(CommonBDModel):
test_date = models.DateField('检验日期')
material = models.ForeignKey(
Material, verbose_name='产品', on_delete=models.CASCADE)
batch = models.CharField('生产批次', max_length=50)
batch = models.TextField('生产批次', db_index=True)
count = models.PositiveIntegerField('检验数量')
count_sampling = models.PositiveIntegerField('抽检数量', default=0)
count_sampling_ok = models.PositiveIntegerField('抽检合格数量', default=0)

View File

@ -0,0 +1,43 @@
# Generated by Django 3.2.12 on 2025-05-23 01:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wpm', '0115_batchst_first_time'),
]
operations = [
migrations.AlterField(
model_name='handover',
name='batch',
field=models.TextField(blank=True, db_index=True, null=True, verbose_name='批次号'),
),
migrations.AlterField(
model_name='handover',
name='new_batch',
field=models.TextField(blank=True, db_index=True, null=True, verbose_name='新批次号'),
),
migrations.AlterField(
model_name='handoverb',
name='batch',
field=models.TextField(blank=True, db_index=True, null=True, verbose_name='批次号'),
),
migrations.AlterField(
model_name='mlog',
name='batch',
field=models.TextField(blank=True, db_index=True, null=True, verbose_name='批次号'),
),
migrations.AlterField(
model_name='mlogb',
name='batch',
field=models.TextField(blank=True, db_index=True, null=True, verbose_name='批次号'),
),
migrations.AlterField(
model_name='wmaterial',
name='batch',
field=models.TextField(db_index=True, verbose_name='批次号'),
),
]

View File

@ -109,7 +109,7 @@ class WMaterial(CommonBDModel):
Material, verbose_name='物料', on_delete=models.CASCADE, related_name='wm_m')
supplier = models.ForeignKey(Supplier, verbose_name='外协供应商', on_delete=models.SET_NULL, null=True, blank=True)
mgroup = models.ForeignKey(Mgroup, verbose_name='所在工段', on_delete=models.CASCADE, null=True, blank=True)
batch = models.TextField('批次号')
batch = models.TextField('批次号', db_index=True)
count = models.DecimalField('当前数量', default=0, max_digits=11, decimal_places=1)
count_eweight = models.FloatField('单数重量', default=0)
defect = models.ForeignKey('qm.defect', verbose_name='缺陷', on_delete=models.SET_NULL, null=True, blank=True)
@ -199,7 +199,7 @@ class Mlog(CommonADModel):
shift = models.ForeignKey(
Shift, verbose_name='关联班次', on_delete=models.SET_NULL, null=True, blank=True)
batch = models.TextField('批次号', null=True, blank=True)
batch = models.TextField('批次号', null=True, blank=True, db_index=True)
count_use = models.DecimalField('领用数', default=0, max_digits=11, decimal_places=1)
count_real = models.DecimalField('实际生产数', default=0, max_digits=11, decimal_places=1)
count_real_eweight = models.FloatField('单数重量', default=0)
@ -326,7 +326,7 @@ class Mlogb(BaseModel):
mlog = models.ForeignKey(Mlog, verbose_name='关联日志',
on_delete=models.CASCADE, related_name='b_mlog')
note = models.TextField('备注', default='', blank=True)
batch = models.TextField('批次号', null=True, blank=True)
batch = models.TextField('批次号', null=True, blank=True, db_index=True)
mtask = models.ForeignKey(Mtask, verbose_name='关联任务',
on_delete=models.CASCADE, related_name='mlogb_mtask', null=True, blank=True)
@ -504,7 +504,7 @@ class Handover(CommonADModel):
H_MERGE = 30
H_DIV = 20
new_batch = models.TextField('新批次号', null=True, blank=True)
new_batch = models.TextField('新批次号', null=True, blank=True, db_index=True)
new_wm = models.ForeignKey(WMaterial, on_delete=models.SET_NULL, null=True, blank=True)
mtype = models.PositiveSmallIntegerField("合并类型", default=H_NORMAL, choices=
[(H_NORMAL, '正常'), (H_DIV, '分批'), (H_MERGE, '合批')])
@ -518,7 +518,7 @@ class Handover(CommonADModel):
Mgroup, verbose_name='送料工段', on_delete=models.CASCADE, null=True, blank=True)
send_dept = models.ForeignKey(
Dept, verbose_name='送料部门', on_delete=models.CASCADE, related_name='handover_send_dept')
batch = models.TextField('批次号', null=True, blank=True)
batch = models.TextField('批次号', null=True, blank=True, db_index=True)
material = models.ForeignKey(
Material, verbose_name='物料', on_delete=models.CASCADE, related_name='h_ma')
material_changed = models.ForeignKey(Material, verbose_name='变更后物料', on_delete=models.CASCADE, null=True, blank=True, related_name='h_ma_c')
@ -549,7 +549,7 @@ class Handoverb(BaseModel):
"""TN: 子级交接记录
"""
handover = models.ForeignKey(Handover, verbose_name='关联交接记录', on_delete=models.CASCADE, related_name="b_handover")
batch = models.TextField("批次号", null=True, blank=True)
batch = models.TextField("批次号", null=True, blank=True, db_index=True)
wm = models.ForeignKey(WMaterial, verbose_name='关联车间库存', on_delete=models.SET_NULL,
null=True, blank=True, related_name='handoverb_wm')
wm_to = models.ForeignKey(WMaterial, verbose_name='所到车间库存', on_delete=models.SET_NULL,