From fbb18ae990f69de9b7408f39a2ac656feb1947c3 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sun, 9 Mar 2025 11:36:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=83=A8=E5=88=86bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/inm/models.py | 2 ++ apps/mtm/serializers.py | 20 ++++++++++--------- apps/wpm/filters.py | 4 ++-- .../wpm/migrations/0091_auto_20250303_1708.py | 5 ----- apps/wpm/models.py | 1 - apps/wpm/serializers.py | 2 +- apps/wpm/services.py | 2 +- apps/wpm/views.py | 8 +++++++- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/apps/inm/models.py b/apps/inm/models.py index 78032f08..8c729227 100644 --- a/apps/inm/models.py +++ b/apps/inm/models.py @@ -101,6 +101,8 @@ class MIO(CommonBDModel): materials = models.ManyToManyField( Material, verbose_name='物料明细', through='inm.mioitem', blank=True) + def get_a_number(self, type): + pass class MIOItem(BaseModel): """ diff --git a/apps/mtm/serializers.py b/apps/mtm/serializers.py index e65a4943..5f70c52b 100644 --- a/apps/mtm/serializers.py +++ b/apps/mtm/serializers.py @@ -231,12 +231,14 @@ class RouteSerializer(CustomModelSerializer): process = validated_data['process'] routepack = validated_data.get('routepack', None) if routepack: - if Route.objects.filter(routepack=routepack, process=process).exists(): - raise ValidationError('已选择该工序!') + pass + # if Route.objects.filter(routepack=routepack, process=process).exists(): + # raise ValidationError('已选择该工序!') else: - material = validated_data.get('material', None) - if material and process and Route.objects.filter(material=material, process=process).exists(): - raise ValidationError('已选择该工序!!') + pass + # material = validated_data.get('material', None) + # if material and process and Route.objects.filter(material=material, process=process).exists(): + # raise ValidationError('已选择该工序!!') with transaction.atomic(): instance = super().create(validated_data) material_out = instance.material_out @@ -246,8 +248,8 @@ class RouteSerializer(CustomModelSerializer): if instance.material: material_out.parent = instance.material material_out.save() - elif material_out.process != process: - raise ParseError('物料工序错误!请重新选择') + # elif material_out.process != process: + # raise ParseError('物料工序错误!请重新选择') else: if instance.material: self.gen_material_out(instance, validated_data.get("material_out_tracking", Material.MA_TRACKING_BATCH)) @@ -265,8 +267,8 @@ class RouteSerializer(CustomModelSerializer): if instance.material: material_out.parent = instance.material material_out.save() - elif material_out.process != process: - raise ParseError('物料工序错误!请重新选择') + # elif material_out.process != process: + # raise ParseError('物料工序错误!请重新选择') else: if instance.material: self.gen_material_out(instance, validated_data.get("material_out_tracking", Material.MA_TRACKING_BATCH)) diff --git a/apps/wpm/filters.py b/apps/wpm/filters.py index 4a5bb893..2a6b458d 100644 --- a/apps/wpm/filters.py +++ b/apps/wpm/filters.py @@ -49,10 +49,10 @@ class WMaterialFilter(filters.FilterSet): if mgroup: process = Mgroup.objects.get(id=mgroup).process if value == "todo": - qs = queryset.filter(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIR) + qs = queryset.exclude(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIR) return qs elif value == "done": - qs = queryset.exclude(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIRED) + qs = queryset.filter(material__process=process)|queryset.filter(state=WMaterial.WM_REPAIRED) return qs else: raise ParseError("请提供工段查询条件") diff --git a/apps/wpm/migrations/0091_auto_20250303_1708.py b/apps/wpm/migrations/0091_auto_20250303_1708.py index d2d49439..9d0365a2 100644 --- a/apps/wpm/migrations/0091_auto_20250303_1708.py +++ b/apps/wpm/migrations/0091_auto_20250303_1708.py @@ -17,9 +17,4 @@ class Migration(migrations.Migration): name='qct', field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='qm.qct', verbose_name='所用质检表'), ), - migrations.AddField( - model_name='mlogbdefect', - name='count_test', - field=models.IntegerField(blank=True, null=True, verbose_name='抽检数'), - ), ] diff --git a/apps/wpm/models.py b/apps/wpm/models.py index 8b5b41b3..f58e01b5 100644 --- a/apps/wpm/models.py +++ b/apps/wpm/models.py @@ -410,7 +410,6 @@ class Mlogb(BaseModel): class MlogbDefect(BaseModel): mlogb = models.ForeignKey(Mlogb, verbose_name='生产记录', on_delete=models.CASCADE) defect = models.ForeignKey("qm.Defect", verbose_name='缺陷', on_delete=models.CASCADE, null=True, blank=True) - count_test = models.IntegerField("抽检数", null=True, blank=True) floor = models.IntegerField("层数", null=True, blank=True) count = models.PositiveIntegerField('数量', default=0) diff --git a/apps/wpm/serializers.py b/apps/wpm/serializers.py index 697b9fe0..9bc864f0 100644 --- a/apps/wpm/serializers.py +++ b/apps/wpm/serializers.py @@ -208,7 +208,7 @@ class MlogbDefectSerializer(CustomModelSerializer): defect_okcate = serializers.CharField(source="defect.okcate", read_only=True) class Meta: model = MlogbDefect - fields = ["id", "defect_name", "count", "mlogb", "defect", "floor", "count_test", "defect_okcate"] + fields = ["id", "defect_name", "count", "mlogb", "defect", "floor", "defect_okcate"] read_only_fields = EXCLUDE_FIELDS_BASE + ["mlogb"] class MlogbSerializer(CustomModelSerializer): diff --git a/apps/wpm/services.py b/apps/wpm/services.py index a5204a7d..7e17bbd4 100644 --- a/apps/wpm/services.py +++ b/apps/wpm/services.py @@ -507,7 +507,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]): for item in m_ins_bl_list: material, batch, count, defect, mi_ = item if count> 0: - lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'defect': 'jgqbl', 'state': WMaterial.WM_NOTOK} + lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'defect': defect, 'state': WMaterial.WM_NOTOK} wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept}) wm.count = wm.count - count if wm.count < 0: diff --git a/apps/wpm/views.py b/apps/wpm/views.py index d7583ba0..a0aa5059 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -657,7 +657,13 @@ class FmlogViewSet(CustomModelViewSet): raise ParseError('因存在二级日志不可删除') return super().destroy(request, *args, **kwargs) - + @action(methods=['post'], detail=True, perms_map={'post': '*'}, serializer_class=Serializer) + def toggle_enabled(self, request, *args, **kwargs): + ins:Fmlog = self.get_object() + ins.enabled = False if ins.enabled else True + ins.save() + return Response() + class BatchStViewSet(ListModelMixin, CustomGenericViewSet): """ list: 批次统计数据