From 553fbcc82690e7d2cac3e505c3594a1b92e40590 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 24 Feb 2025 10:26:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20labelmat=E5=92=8Cwpr=E9=83=BD=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E8=BF=94=E4=BF=AEEnum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/migrations/0003_alter_lablemat_state.py | 18 ++++++++++++++++++ apps/cm/models.py | 3 ++- apps/wpm/migrations/0088_auto_20250224_0938.py | 2 +- apps/wpm/models.py | 5 +++-- apps/wpmw/migrations/0003_alter_wpr_state.py | 18 ++++++++++++++++++ apps/wpmw/models.py | 3 ++- 6 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 apps/cm/migrations/0003_alter_lablemat_state.py create mode 100644 apps/wpmw/migrations/0003_alter_wpr_state.py diff --git a/apps/cm/migrations/0003_alter_lablemat_state.py b/apps/cm/migrations/0003_alter_lablemat_state.py new file mode 100644 index 00000000..3707d6b3 --- /dev/null +++ b/apps/cm/migrations/0003_alter_lablemat_state.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.12 on 2025-02-24 02:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cm', '0002_lablemat_defect'), + ] + + operations = [ + migrations.AlterField( + model_name='lablemat', + name='state', + field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (34, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'), + ), + ] diff --git a/apps/cm/models.py b/apps/cm/models.py index 9c77ee05..ca86fbbb 100644 --- a/apps/cm/models.py +++ b/apps/cm/models.py @@ -2,10 +2,11 @@ from django.db import models from apps.utils.models import BaseModel from apps.mtm.models import Material from apps.pum.models import Supplier +from apps.wpm.models import WmStateOption # Create your models here. class LableMat(BaseModel): - state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废'))) + state = models.PositiveSmallIntegerField('状态', default=10, choices=WmStateOption.choices) material = models.ForeignKey(Material, on_delete=models.CASCADE) batch = models.CharField('批次号', max_length=100) supplier = models.ForeignKey(Supplier, verbose_name='外协供应商', on_delete=models.SET_NULL, null=True, blank=True) diff --git a/apps/wpm/migrations/0088_auto_20250224_0938.py b/apps/wpm/migrations/0088_auto_20250224_0938.py index 8df074ac..1f47611e 100644 --- a/apps/wpm/migrations/0088_auto_20250224_0938.py +++ b/apps/wpm/migrations/0088_auto_20250224_0938.py @@ -18,6 +18,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='wmaterial', name='state', - field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (32, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'), + field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (34, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'), ), ] diff --git a/apps/wpm/models.py b/apps/wpm/models.py index 4d2de745..5ba603bb 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -96,6 +96,7 @@ class WmStateOption(models.IntegerChoices): OK = 10, _("合格") NOTOK = 20, _("不合格") REPAIR = 30, _("返修") + REPAIRED = 34, _("返修完成") TEST = 40, _("检验") SCRAP = 50, _("报废") @@ -108,7 +109,7 @@ class WMaterial(CommonBDModel): WM_REPAIR = 30 WM_TEST = 40 WM_SCRAP = 50 - state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (32, '返修完成'), (40, '检验'), (50, '报废'))) + state = models.PositiveSmallIntegerField('状态', default=10, choices=WmStateOption.choices) material = models.ForeignKey( 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) @@ -144,7 +145,7 @@ class WMaterial(CommonBDModel): material_out=mtask.material_in ).values_list('batch', flat=True) ), - state__in=[WMaterial.WM_OK] + state__in=[WMaterial.WM_OK, WMaterial.WM_REPAIR] ) class Fmlog(CommonADModel): diff --git a/apps/wpmw/migrations/0003_alter_wpr_state.py b/apps/wpmw/migrations/0003_alter_wpr_state.py new file mode 100644 index 00000000..67ed0e0c --- /dev/null +++ b/apps/wpmw/migrations/0003_alter_wpr_state.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.12 on 2025-02-24 02:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wpmw', '0002_wpr_oinfo'), + ] + + operations = [ + migrations.AlterField( + model_name='wpr', + name='state', + field=models.PositiveSmallIntegerField(choices=[(10, '合格'), (20, '不合格'), (30, '返修'), (34, '返修完成'), (40, '检验'), (50, '报废')], default=10, verbose_name='状态'), + ), + ] diff --git a/apps/wpmw/models.py b/apps/wpmw/models.py index 0d7eeab2..a9f39419 100644 --- a/apps/wpmw/models.py +++ b/apps/wpmw/models.py @@ -4,6 +4,7 @@ from apps.qm.models import FtestDefect, FtestItem from apps.utils.models import BaseModel from apps.mtm.models import Material from rest_framework.exceptions import ParseError +from apps.wpm.models import WmStateOption # Create your models here. class Wpr(BaseModel): @@ -12,7 +13,7 @@ class Wpr(BaseModel): """ number = models.CharField("编号", max_length=50, unique=True, null=True, blank=True) - state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废'))) + state = models.PositiveSmallIntegerField('状态', default=10, choices=WmStateOption.choices) material = models.ForeignKey(Material, verbose_name="当前物料形态", on_delete=models.CASCADE) defects = models.ManyToManyField("qm.defect", through="wpmw.wprdefect", verbose_name="缺陷项")