From a7f10b2767318161d60fb594052c27b3d719166d Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 2 Dec 2021 16:32:32 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=9B=B4=E6=94=B9wproduct=20act=5Fstate?= =?UTF-8?q?=E5=AD=97=E6=AE=B5;=E5=A4=8D=E6=A3=80=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qm/migrations/0013_auto_20211202_1620.py | 30 +++++ hb_server/apps/qm/models.py | 13 ++ .../wpm/migrations/0028_auto_20211202_1620.py | 23 ++++ .../wpm/migrations/0029_auto_20211202_1630.py | 23 ++++ hb_server/apps/wpm/models.py | 7 +- hb_server/apps/wpm/serializers.py | 14 +- hb_server/apps/wpm/views.py | 120 +++++++++--------- 7 files changed, 163 insertions(+), 67 deletions(-) create mode 100644 hb_server/apps/qm/migrations/0013_auto_20211202_1620.py create mode 100644 hb_server/apps/wpm/migrations/0028_auto_20211202_1620.py create mode 100644 hb_server/apps/wpm/migrations/0029_auto_20211202_1630.py diff --git a/hb_server/apps/qm/migrations/0013_auto_20211202_1620.py b/hb_server/apps/qm/migrations/0013_auto_20211202_1620.py new file mode 100644 index 0000000..2909dc9 --- /dev/null +++ b/hb_server/apps/qm/migrations/0013_auto_20211202_1620.py @@ -0,0 +1,30 @@ +# Generated by Django 3.2.9 on 2021-12-02 08:20 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('mtm', '0040_material_piece_count'), + ('qm', '0012_alter_testrecorditem_field_type'), + ] + + operations = [ + migrations.AddField( + model_name='testrecord', + name='step', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='mtm.step', verbose_name='关联的工序步骤'), + ), + migrations.AddField( + model_name='testrecord', + name='test_record', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='qm.testrecord', verbose_name='关联检验记录'), + ), + migrations.AddField( + model_name='testrecord', + name='type', + field=models.PositiveSmallIntegerField(choices=[(10, '子工序检验'), (20, '工序检验'), (30, '工序复检'), (40, '成品检验')], default=20), + ), + ] diff --git a/hb_server/apps/qm/models.py b/hb_server/apps/qm/models.py index c2dea88..eca8ed5 100644 --- a/hb_server/apps/qm/models.py +++ b/hb_server/apps/qm/models.py @@ -47,14 +47,27 @@ class TestRecord(CommonAModel): """ 检验记录 """ + TEST_STEP = 10 + TEST_PROCESS = 20 + TEST_PROCESS_RE = 30 + TEST_FINAL = 40 + type_choice = ( + (TEST_STEP, '子工序检验'), + (TEST_PROCESS, '工序检验'), + (TEST_PROCESS_RE, '工序复检'), + (TEST_FINAL, '成品检验') + ) form = models.ForeignKey('mtm.recordform', verbose_name='所用表格', on_delete=models.CASCADE) + type = models.PositiveSmallIntegerField(choices=type_choice, default=TEST_PROCESS) is_testok = models.BooleanField('是否合格', default=True) is_testok_robot = models.BooleanField('自动判定的是否合格', default=True) number = models.CharField('产品编号', null=True, blank=True, max_length=50) wproduct = models.ForeignKey('wpm.wproduct', verbose_name='关联的动态产品', on_delete=models.CASCADE, null=True, blank=True) material = models.ForeignKey('mtm.material', verbose_name='关联的物料状态', on_delete=models.CASCADE, null=True, blank=True) + step = models.ForeignKey('mtm.step', verbose_name='关联的工序步骤', on_delete=models.CASCADE, null=True, blank=True) subproduction_plan = models.ForeignKey('pm.subproductionplan', verbose_name='关联的生产子计划', on_delete=models.CASCADE, null=True, blank=True) fifo_item = models.ForeignKey('inm.fifoitem', verbose_name='关联的出入库批次', on_delete=models.CASCADE, null=True, blank=True) + test_record = models.ForeignKey('self', verbose_name='关联检验记录', on_delete=models.CASCADE, null=True, blank=True) remark = models.TextField('备注', default='') diff --git a/hb_server/apps/wpm/migrations/0028_auto_20211202_1620.py b/hb_server/apps/wpm/migrations/0028_auto_20211202_1620.py new file mode 100644 index 0000000..9772c46 --- /dev/null +++ b/hb_server/apps/wpm/migrations/0028_auto_20211202_1620.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.9 on 2021-12-02 08:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wpm', '0027_pick_pickwproduct'), + ] + + operations = [ + migrations.AlterField( + model_name='wproduct', + name='act_state', + field=models.IntegerField(choices=[(6, '待复检'), (8, '操作准备中'), (10, '操作进行中'), (20, '待检验'), (30, '已合格'), (40, '库存中'), (50, '不合格'), (60, '待成品检验')], default=0, verbose_name='进行状态'), + ), + migrations.AlterField( + model_name='wproduct', + name='is_executed', + field=models.BooleanField(default=False, verbose_name='是否执行'), + ), + ] diff --git a/hb_server/apps/wpm/migrations/0029_auto_20211202_1630.py b/hb_server/apps/wpm/migrations/0029_auto_20211202_1630.py new file mode 100644 index 0000000..d6b195c --- /dev/null +++ b/hb_server/apps/wpm/migrations/0029_auto_20211202_1630.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.9 on 2021-12-02 08:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wpm', '0028_auto_20211202_1620'), + ] + + operations = [ + migrations.RemoveField( + model_name='wproduct', + name='is_executed', + ), + migrations.AlterField( + model_name='wproduct', + name='operation', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='wp_operation', to='wpm.operation', verbose_name='关联操作'), + ), + ] diff --git a/hb_server/apps/wpm/models.py b/hb_server/apps/wpm/models.py index b1af088..b21c765 100644 --- a/hb_server/apps/wpm/models.py +++ b/hb_server/apps/wpm/models.py @@ -25,6 +25,7 @@ class WProduct(CommonAModel): 动态半成品/成品表 """ WPR_ACT_STATE_TORETEST = 6 + WPR_ACT_STATE_DOWAIT = 8 WPR_ACT_STATE_DOING = 10 WPR_ACT_STATE_TOTEST = 20 WPR_ACT_STATE_OK = 30 @@ -33,7 +34,8 @@ class WProduct(CommonAModel): WPR_ACT_STATE_TOFINALTEST = 60 act_state_choices=( (WPR_ACT_STATE_TORETEST, '待复检'), - (WPR_ACT_STATE_DOING, '生产中'), + (WPR_ACT_STATE_DOWAIT, '操作准备中'), + (WPR_ACT_STATE_DOING, '操作进行中'), (WPR_ACT_STATE_TOTEST, '待检验'), (WPR_ACT_STATE_OK, '已合格'), (WPR_ACT_STATE_INM, '库存中'), @@ -45,14 +47,13 @@ class WProduct(CommonAModel): pre_step = models.ForeignKey(Step, verbose_name='已执行到', help_text='已执行完的步骤', null=True, blank=True, on_delete=models.CASCADE, related_name='w_pre_step') step = models.ForeignKey(Step, verbose_name='所在步骤', on_delete=models.CASCADE, null=True, blank=True, related_name='w_step') act_state = models.IntegerField('进行状态', default=0, choices=act_state_choices) - is_executed = models.BooleanField('子工序是否已执行', default=False) is_hidden = models.BooleanField('是否隐藏', default=False) child = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE) remark = models.CharField('备注', max_length=200, null=True, blank=True) subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE, related_name='wproduct_subplan') warehouse = models.ForeignKey(WareHouse, verbose_name='所在仓库', on_delete=models.SET_NULL, null=True, blank=True) operation = models.ForeignKey('wpm.operation', verbose_name='关联操作', - on_delete=models.SET_NULL, null=True, blank=True, related_name='current_operation') + on_delete=models.SET_NULL, null=True, blank=True, related_name='wp_operation') class Pick(CommonADModel): diff --git a/hb_server/apps/wpm/serializers.py b/hb_server/apps/wpm/serializers.py index 7bca29e..f7591de 100644 --- a/hb_server/apps/wpm/serializers.py +++ b/hb_server/apps/wpm/serializers.py @@ -100,7 +100,7 @@ class PickSerializer(serializers.Serializer): wids = IProduct.objects.filter(pk__in=[x.id for x in iproducts]).values_list('wproduct', flat=True) wproducts = WProduct.objects.filter(pk__in=wids) first_step = Step.objects.get(pk=sp.steps[0]['id']) - wproducts.update(step=first_step, is_executed=False, + wproducts.update(step=first_step, act_state=WProduct.WPR_ACT_STATE_TORETEST, is_hidden=False, warehouse=None, subproduction_plan=sp) sp.is_picked=True @@ -187,10 +187,10 @@ class OperationCreateSerializer(serializers.Serializer): if step.type == Step.STEP_TYPE_DIV: raise exceptions.APIException(_('不可进行此操作')) for i in data['wproducts']: - if i.act_state != WProduct.WPR_ACT_STATE_DOING: - raise exceptions.APIException('半成品不在生产状态') - if i.is_executed: - raise exceptions.APIException('不可进行操作') + if i.act_state != WProduct.WPR_ACT_STATE_DOWAIT: + raise exceptions.APIException('半成品不在待操作状态') + # if i.is_executed: + # raise exceptions.APIException('不可进行操作') # if i.subproduction_plan != subproduction_plan: # raise exceptions.APIException('半成品所属子计划不一致') if i.step != step: @@ -224,8 +224,8 @@ class OperationInitSerializer(serializers.Serializer): if step.type == Step.STEP_TYPE_DIV: raise exceptions.APIException(_('不可进行此操作')) for i in data['wproducts']: - if i.is_executed: - raise exceptions.APIException('不可进行操作') + if i.act_state != WProduct.WPR_ACT_STATE_DOWAIT: + raise exceptions.APIException('半成品不在待操作状态') # if i.subproduction_plan != subproduction_plan: # raise exceptions.APIException('半成品所属子计划不一致') if i.step != step: diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 5fc6d27..5687616 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -11,7 +11,7 @@ from apps.mtm.models import Material, RecordForm, RecordFormField, Step, Subprod from apps.mtm.serializers import RecordFormDetailSerializer, SubprodctionMaterialListSerializer, TechDocListSerializer from apps.pm.models import SubProductionPlan, SubProductionProgress from apps.pm.serializers import SubProductionPlanListSerializer, SubProductionPlanUpdateSerializer, SubProductionProgressSerializer -from apps.qm.models import TestRecordItem +from apps.qm.models import TestRecord, TestRecordItem from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin from rest_framework.decorators import action @@ -73,7 +73,7 @@ class WPlanViewSet(ListModelMixin, GenericViewSet): # raise exceptions.APIException('超过计划数') spp.save() wps = WProduct.objects.filter(pk__in=[x for x in i['wproducts']], act_state=WProduct.WPR_ACT_STATE_OK) - wps.update(step=first_step, is_executed=False, + wps.update(step=first_step, act_state=WProduct.WPR_ACT_STATE_TORETEST, is_hidden=False, warehouse=None, subproduction_plan=sp, update_by=request.user, update_time=timezone.now()) for i in wps: @@ -195,13 +195,19 @@ class WProductViewSet(ListModelMixin, GenericViewSet): vdata = serializer.validated_data record_data = vdata.pop('record_data') wproduct = vdata['wproduct'] - if wproduct.act_state not in [WProduct.WPR_ACT_STATE_TOTEST, WProduct.WPR_ACT_STATE_TORETEST]: + if wproduct.act_state not in [WProduct.WPR_ACT_STATE_TOTEST, + WProduct.WPR_ACT_STATE_TORETEST, WProduct.WPR_ACT_STATE_TOFINALTEST]: raise exceptions.APIException('该产品当前状态不可检验') if 'is_testok' not in vdata: raise exceptions.APIException('未填写检测结论') - - obj = serializer.save(create_by = self.request.user, - material=wproduct.material, number=wproduct.number, subproduction_plan=wproduct.subproduction_plan) + + savedict = dict(create_by = self.request.user, + material=wproduct.material, number=wproduct.number, subproduction_plan=wproduct.subproduction_plan, step=wproduct.step) + if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: + savedict['type'] = TestRecord.TEST_PROCESS_RE + elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOFINALTEST: + savedict['type'] = TestRecord.TEST_FINAL + obj = serializer.save(**savedict) tris = [] for m in record_data: # 保存记录详情 form_field = m['form_field'] @@ -220,6 +226,10 @@ class WProductViewSet(ListModelMixin, GenericViewSet): if obj.is_testok: wproduct.act_state = WProduct.WPR_ACT_STATE_OK + if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: + wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT + elif wproduct.material == Material.MA_TYPE_GOOD: + wproduct.act_state = WProduct.WPR_ACT_STATE_TOFINALTEST if wproduct.number is None: # 产生半成品编号 wproduct.number = 'WP'+ranstr(7) wproduct.save() @@ -235,47 +245,47 @@ class WProductViewSet(ListModelMixin, GenericViewSet): return Response() - @action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=WpmTestRecordCreateSerializer) - @transaction.atomic - def retest(self, request, pk=None): - """ - 复检 - """ - serializer = WpmTestRecordCreateSerializer(data=request.data) - serializer.is_valid(raise_exception=True) - vdata = serializer.validated_data - record_data = vdata.pop('record_data') - wproduct = vdata['wproduct'] - if wproduct.act_state != WProduct.WPR_ACT_STATE_TORETEST: - raise exceptions.APIException('该产品当前状态不可检验') - if 'is_testok' not in vdata: - raise exceptions.APIException('未填写检测结论') + # @action(methods=['post'], detail=False, perms_map={'post':'*'}, serializer_class=WpmTestRecordCreateSerializer) + # @transaction.atomic + # def retest(self, request, pk=None): + # """ + # 复检 + # """ + # serializer = WpmTestRecordCreateSerializer(data=request.data) + # serializer.is_valid(raise_exception=True) + # vdata = serializer.validated_data + # record_data = vdata.pop('record_data') + # wproduct = vdata['wproduct'] + # if wproduct.act_state != WProduct.WPR_ACT_STATE_TORETEST: + # raise exceptions.APIException('该产品当前状态不可检验') + # if 'is_testok' not in vdata: + # raise exceptions.APIException('未填写检测结论') - obj = serializer.save(create_by = self.request.user, - material=wproduct.material, number=wproduct.number, subproduction_plan=wproduct.subproduction_plan) - tris = [] - for m in record_data: # 保存记录详情 - form_field = m['form_field'] - m['field_name'] = form_field.field_name - m['field_key'] = form_field.field_key - m['field_type'] = form_field.field_type - m['field_value'] = m['field_value'] - m['sort'] = form_field.sort - m['need_judge'] = form_field.need_judge - m['is_testok'] = m['is_testok'] if 'is_testok' in m else None - m['test_record'] = obj - tris.append(TestRecordItem(**m)) - TestRecordItem.objects.bulk_create(tris) + # obj = serializer.save(create_by = self.request.user, + # material=wproduct.material, number=wproduct.number, subproduction_plan=wproduct.subproduction_plan) + # tris = [] + # for m in record_data: # 保存记录详情 + # form_field = m['form_field'] + # m['field_name'] = form_field.field_name + # m['field_key'] = form_field.field_key + # m['field_type'] = form_field.field_type + # m['field_value'] = m['field_value'] + # m['sort'] = form_field.sort + # m['need_judge'] = form_field.need_judge + # m['is_testok'] = m['is_testok'] if 'is_testok' in m else None + # m['test_record'] = obj + # tris.append(TestRecordItem(**m)) + # TestRecordItem.objects.bulk_create(tris) - # 如果检测合格, 变更动态产品进行状态 + # # 如果检测合格, 变更动态产品进行状态 - if obj.is_testok: - wproduct.act_state = WProduct.WPR_ACT_STATE_DOING - wproduct.save() - else:# 如果不合格 - wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK - wproduct.save() - return Response() + # if obj.is_testok: + # wproduct.act_state = WProduct.WProduct.WPR_ACT_STATE_DOWAIT + # wproduct.save() + # else:# 如果不合格 + # wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK + # wproduct.save() + # return Response() @action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=WproductPutInSerializer) @transaction.atomic @@ -358,6 +368,8 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if instance.is_submited: raise exceptions.APIException('该操作已提交') self.perform_destroy(instance) + # 恢复半成品可操作 + instance.wp_operation.all().update(act_state=WProduct.WPR_ACT_STATE_DOWAIT) return Response(status=status.HTTP_204_NO_CONTENT) @transaction.atomic @@ -376,7 +388,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd # 创建操作所用半成品关联记录 if 'wproducts' in vdata: owps = [] - WProduct.objects.filter(pk__in=[x.id for x in vdata['wproducts']]).update(operation=op) + WProduct.objects.filter(pk__in=[x.id for x in vdata['wproducts']]).update(operation=op, act_state=WProduct.WPR_ACT_STATE_DOING) splans = WpmServies.get_subplans_queryset_from_wproducts(vdata['wproducts']) for wpd in vdata['wproducts']: owp = {} @@ -456,9 +468,8 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wp.step = newstep wp.pre_step = step if hasNext: - wp.is_executed= False + wp.act_state= WProduct.WPR_ACT_STATE_DOWAIT else: - wp.is_executed = True wp.act_state = WProduct.WPR_ACT_STATE_TOTEST wp.material = wsp.main_product # 更新子计划进度 @@ -474,7 +485,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if i.subproduction_progress.is_main: newstep, _ = WpmServies.get_next_step(i.subproduction_plan, step) wpr = dict(material=i.material, step=newstep, - act_state=WProduct.WPR_ACT_STATE_DOING, is_executed=False, remark='', + act_state=WProduct.WPR_ACT_STATE_DOWAIT, remark='', subproduction_plan=i.subproduction_plan) for x in range(i.count): WProduct.objects.create(**wpr) @@ -486,11 +497,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.step = newstep wproduct.subproduction_plan = i.subproduction_plan if hasNext: - wproduct.act_state = WProduct.WPR_ACT_STATE_DOING - wproduct.is_executed = False + wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT else: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - wproduct.is_executed = True # 更新子计划进度 instance = SubProductionProgress.objects.get(subproduction_plan=i.subproduction_plan, is_main=True, type=SubprodctionMaterial.SUB_MA_TYPE_OUT) @@ -799,7 +808,7 @@ class DoFormSubmit(CreateAPIView, GenericAPIView): if vdata['step'].type == Step.STEP_TYPE_DIV: newstep, _ = WpmServies.get_next_step(i['subproduction_plan'], vdata['step']) wpr = dict(material=ma, step=newstep, - act_state=WProduct.WPR_ACT_STATE_DOING, is_executed=False, remark='', + act_state=WProduct.WPR_ACT_STATE_DOWAIT, remark='', subproduction_plan=i['subproduction_plan']) for x in range(i['count_output']): WProduct.objects.create(**wpr) @@ -831,11 +840,9 @@ class DoFormSubmit(CreateAPIView, GenericAPIView): wproduct.subproduction_plan=vdata['subproduction_plan'] wproduct.parent = data['wproducts'] if hasNext: - wproduct.act_state=WProduct.WPR_ACT_STATE_DOING - wproduct.is_executed=False + wproduct.act_state=WProduct.WPR_ACT_STATE_DOWAIT else: wproduct.act_state=WProduct.WPR_ACT_STATE_TOTEST - wproduct.is_executed=True wproduct.save() else: raise exceptions.APIException('请指定子计划') @@ -846,9 +853,8 @@ class DoFormSubmit(CreateAPIView, GenericAPIView): wproduct.step = newstep wproduct.pre_step=vdata['step'] if hasNext: - wproduct.is_executed= False + wproduct.act_state=WProduct.WPR_ACT_STATE_DOWAIT else: - wproduct.is_executed= True wproduct.act_state=WProduct.WPR_ACT_STATE_TOTEST wproduct.material=wproduct.subproduction_plan.main_product wproduct.save() From 87ac88a62f7a81b0a9086c45503cae4d4d437e1b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 2 Dec 2021 16:37:07 +0800 Subject: [PATCH 2/8] =?UTF-8?q?wproduct=20list=20=E5=8E=BB=E9=99=A4operati?= =?UTF-8?q?on=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 5687616..ebc5b98 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -177,7 +177,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet): 半成品 """ perms_map={'*':'*'} - queryset = WProduct.objects.select_related('step', 'material').filter(is_hidden=False, operation=None) + queryset = WProduct.objects.select_related('step', 'material').filter(is_hidden=False) serializer_class = WProductListSerializer filterset_fields = ['step', 'subproduction_plan', 'material', 'step__process', 'act_state'] search_fields = ['number'] From 69a54f7f4b8bc86df747a49e798b39b5abe1fdf7 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 2 Dec 2021 16:56:05 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index ebc5b98..3205fdf 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -225,11 +225,12 @@ class WProductViewSet(ListModelMixin, GenericViewSet): # 如果检测合格, 变更动态产品进行状态 if obj.is_testok: - wproduct.act_state = WProduct.WPR_ACT_STATE_OK if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: - wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT + wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT # 复检 elif wproduct.material == Material.MA_TYPE_GOOD: - wproduct.act_state = WProduct.WPR_ACT_STATE_TOFINALTEST + wproduct.act_state = WProduct.WPR_ACT_STATE_TOFINALTEST # 成品检验 + else: + wproduct.act_state = WProduct.WPR_ACT_STATE_OK if wproduct.number is None: # 产生半成品编号 wproduct.number = 'WP'+ranstr(7) wproduct.save() From 1c0f184a37c1a46b6ce806dff0e0a0f296896cdb Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 3 Dec 2021 08:52:28 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 3205fdf..b4fda0b 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -368,9 +368,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd instance = self.get_object() if instance.is_submited: raise exceptions.APIException('该操作已提交') - self.perform_destroy(instance) # 恢复半成品可操作 instance.wp_operation.all().update(act_state=WProduct.WPR_ACT_STATE_DOWAIT) + self.perform_destroy(instance) return Response(status=status.HTTP_204_NO_CONTENT) @transaction.atomic From fa91eb88f20f98d73c5a0c8ffffa41463cc68cca Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 3 Dec 2021 09:02:18 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=BE=85=E6=88=90=E5=93=81=E6=A3=80?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index b4fda0b..ae57705 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -227,7 +227,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet): if obj.is_testok: if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT # 复检 - elif wproduct.material == Material.MA_TYPE_GOOD: + elif wproduct.material.type == Material.MA_TYPE_GOOD: wproduct.act_state = WProduct.WPR_ACT_STATE_TOFINALTEST # 成品检验 else: wproduct.act_state = WProduct.WPR_ACT_STATE_OK From cc6713da25c34110057e8d5cd32313e16c432f3e Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 3 Dec 2021 09:11:19 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=88=90=E5=93=81=E6=A3=80=E9=AA=8Cbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mtm/migrations/0041_alter_material_type.py | 18 ++++++++++++++++++ hb_server/apps/mtm/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 hb_server/apps/mtm/migrations/0041_alter_material_type.py diff --git a/hb_server/apps/mtm/migrations/0041_alter_material_type.py b/hb_server/apps/mtm/migrations/0041_alter_material_type.py new file mode 100644 index 0000000..54bada2 --- /dev/null +++ b/hb_server/apps/mtm/migrations/0041_alter_material_type.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.9 on 2021-12-03 01:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mtm', '0040_material_piece_count'), + ] + + operations = [ + migrations.AlterField( + model_name='material', + name='type', + field=models.PositiveSmallIntegerField(choices=[(1, '成品'), (2, '半成品'), (3, '主要原料'), (4, '辅助材料'), (5, '加工工具'), (6, '辅助工装')], default=1, verbose_name='物料类型'), + ), + ] diff --git a/hb_server/apps/mtm/models.py b/hb_server/apps/mtm/models.py index a131e3d..5d39027 100644 --- a/hb_server/apps/mtm/models.py +++ b/hb_server/apps/mtm/models.py @@ -36,7 +36,7 @@ class Material(CommonAModel): name = models.CharField('物料名称', max_length=100) number = models.CharField('编号', max_length=100, unique=True) specification = models.CharField('型号', max_length=100, null=True, blank=True) - type = models.CharField('物料类型', choices= type_choices, max_length=20, default=1) + type = models.PositiveSmallIntegerField('物料类型', choices= type_choices, default=1) sort_str = models.CharField('排序字符', max_length=100, null=True, blank=True) unit = models.CharField('基准计量单位', choices=unit_choices, default='块', max_length=10) count = models.IntegerField('物料总数', default=0) From 4c5bbc00b339058edefe32845439dae17dac75e7 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 3 Dec 2021 09:15:01 +0800 Subject: [PATCH 7/8] =?UTF-8?q?wproduct=E5=A2=9E=E5=8A=A0material=5Ftype?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index ae57705..fc3653d 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -179,7 +179,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet): perms_map={'*':'*'} queryset = WProduct.objects.select_related('step', 'material').filter(is_hidden=False) serializer_class = WProductListSerializer - filterset_fields = ['step', 'subproduction_plan', 'material', 'step__process', 'act_state'] + filterset_fields = ['step', 'subproduction_plan', 'material', 'step__process', 'act_state', 'material__type'] search_fields = ['number'] ordering_fields = ['id'] ordering = ['id'] From 015491f4697b9a57232e3ffe851e0eee2086309b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 3 Dec 2021 09:33:32 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=88=90=E5=93=81=E6=A3=80=E9=AA=8Cbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index fc3653d..39a7b08 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -227,7 +227,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet): if obj.is_testok: if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT # 复检 - elif wproduct.material.type == Material.MA_TYPE_GOOD: + elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST and wproduct.material.type == Material.MA_TYPE_GOOD: wproduct.act_state = WProduct.WPR_ACT_STATE_TOFINALTEST # 成品检验 else: wproduct.act_state = WProduct.WPR_ACT_STATE_OK