From 458385c0f693c1a87aaaee2e98ef28ca4ff579c0 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 28 May 2024 14:29:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20material=E5=A2=9E=E5=8A=A0count=5Fmb?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/inm/services.py | 11 +++++---- .../mtm/migrations/0029_auto_20240528_1428.py | 23 +++++++++++++++++++ apps/mtm/models.py | 3 ++- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 apps/mtm/migrations/0029_auto_20240528_1428.py diff --git a/apps/inm/services.py b/apps/inm/services.py index 35b57afb..4cab2327 100644 --- a/apps/inm/services.py +++ b/apps/inm/services.py @@ -45,15 +45,16 @@ class InmService: @classmethod def cal_mat_count(cls, material: Material): - material_count = MaterialBatch.objects.filter(material=material).aggregate(total=Sum("count"))["total"] + mb_count = MaterialBatch.objects.filter(material=material).aggregate(total=Sum("count"))["total"] from apps.wpm.models import WMaterial - wm_count = WMaterial.objects.filter(material=material).aggregate(total=Sum("count"))["total"] - if material_count is None: - material_count = 0 + if mb_count is None: + mb_count = 0 if wm_count is None: wm_count = 0 - Material.objects.filter(id=material.id).update(count=material_count + wm_count) + Material.objects.filter(id=material.id).update( + count_mb=mb_count, + count=mb_count + wm_count) @classmethod def update_mb(cls, instance: MIO, in_or_out: int = 1): diff --git a/apps/mtm/migrations/0029_auto_20240528_1428.py b/apps/mtm/migrations/0029_auto_20240528_1428.py new file mode 100644 index 00000000..4801ae59 --- /dev/null +++ b/apps/mtm/migrations/0029_auto_20240528_1428.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.12 on 2024-05-28 06:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mtm', '0028_shift_sort'), + ] + + operations = [ + migrations.AddField( + model_name='material', + name='count_mb', + field=models.PositiveIntegerField(default=0, verbose_name='仓库总数'), + ), + migrations.AlterField( + model_name='material', + name='count', + field=models.PositiveIntegerField(default=0, verbose_name='总库存'), + ), + ] diff --git a/apps/mtm/models.py b/apps/mtm/models.py index e5c0f2fd..1f7c9065 100644 --- a/apps/mtm/models.py +++ b/apps/mtm/models.py @@ -55,7 +55,8 @@ class Material(CommonAModel): testitems = models.JSONField('检测项目', default=list, blank=True) sort = models.PositiveSmallIntegerField('排序', default=1) unit = models.CharField('基准计量单位', default='个', max_length=10) - count = models.PositiveIntegerField('物料库存总数', default=0) + count = models.PositiveIntegerField('总库存', default=0) + count_mb = models.PositiveIntegerField('仓库总数', default=0) count_safe = models.PositiveIntegerField('安全库存总数', null=True, blank=True) week_esitimate_consume = models.PositiveIntegerField( '周消耗预估', null=True, blank=True)