diff --git a/hb_server/apps/mtm/models.py b/hb_server/apps/mtm/models.py index 6ebe98a..2602113 100644 --- a/hb_server/apps/mtm/models.py +++ b/hb_server/apps/mtm/models.py @@ -177,6 +177,7 @@ class OutputMaterial(CommonAModel): 输出物料 """ material = models.ForeignKey(Material, verbose_name='输出物料', on_delete=models.CASCADE, related_name='outputmaterial') + is_main = models.BooleanField('是否主产出', default=True) # 以该产品完成度计算进度 count = models.FloatField('产出量', default=1) subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE) sort = models.IntegerField('排序号', default=1) diff --git a/hb_server/apps/mtm/serializers.py b/hb_server/apps/mtm/serializers.py index 315e464..46d5f87 100644 --- a/hb_server/apps/mtm/serializers.py +++ b/hb_server/apps/mtm/serializers.py @@ -101,6 +101,8 @@ class OutputMaterialSerializer(serializers.ModelSerializer): fields = ['count', 'sort', 'material', 'subproduction'] def create(self, validated_data): + if OutputMaterial.objects.filter(subproduction=validated_data['subproduction'], is_deleted=False, is_main=True).exists(): + raise ValidationError('主产出只能有1个') if OutputMaterial.objects.filter(material=validated_data['material'], subproduction=validated_data['subproduction'], is_deleted=False).exists(): raise ValidationError('该物料已存在') return super().create(validated_data) diff --git a/hb_server/apps/wpm/models.py b/hb_server/apps/wpm/models.py index ab9aa54..767b0fd 100644 --- a/hb_server/apps/wpm/models.py +++ b/hb_server/apps/wpm/models.py @@ -7,6 +7,16 @@ from utils.model import SoftModel, BaseModel from simple_history.models import HistoricalRecords +class Good(CommonAModel): + """ + 物品 + """ + number = models.CharField('物品编号', primary_key=True, null=True, blank=True, max_length=50) + m_state = models.ForeignKey('所属物料状态', on_delete=models.CASCADE) + p_state = models.ForeignKey('所在步骤', ) + + + class Vendor(CommonAModel): """ 供应商信息 diff --git a/hb_server/server/settings.py b/hb_server/server/settings.py index b2e7755..6fb07a7 100644 --- a/hb_server/server/settings.py +++ b/hb_server/server/settings.py @@ -55,7 +55,8 @@ INSTALLED_APPS = [ 'apps.inm', 'apps.sam', 'apps.qm', - 'apps.pm' + 'apps.pm', + # 'apps.wpm' ] MIDDLEWARE = [