From 50970874dd6347ede77c6453926d20826583b3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Tue, 21 Jun 2022 18:06:33 +0800 Subject: [PATCH 01/15] is_midtesting bug --- hb_server/apps/wpm/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 99d619c..e69dd92 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -4,7 +4,7 @@ from rest_framework.mixins import CreateModelMixin, DestroyModelMixin, \ from rest_framework.viewsets import GenericViewSet from apps.inm.models import FIFO, FIFOItem, FIFOItemProduct from apps.inm.services import InmService -from apps.mtm.models import Material, RecordForm, RecordFormField, Step, SubprodctionMaterial, TechDoc +from apps.mtm.models import Material, RecordForm, RecordFormField, Step, SubprodctionMaterial, TechDoc, UsedStep from apps.mtm.serializers import RecordFormDetailSerializer, SubprodctionMaterialListSerializer, TechDocListSerializer from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress from apps.pm.serializers import SubProductionPlanListSerializer, SubProductionProgressSerializer @@ -212,9 +212,9 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): savedict['type'] = TestRecord.TEST_FINAL elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB - elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST and\ - wproduct.step != wproduct.pre_step: # 如果是工序内检验 - savedict['is_midtesting'] = True + elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: + if UsedStep.objects.filter(subproduction=wproduct.subroduction_plan.suproduction).first().need_test: + savedict['is_midtesting'] = True tr = TestRecord.objects.create(**savedict) # 更新wproduct wproduct.test = tr From af3f487af1e7dc45afa790c47b7cbf5029af3cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 22 Jun 2022 14:31:38 +0800 Subject: [PATCH 02/15] bug --- 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 e69dd92..ad82634 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -213,7 +213,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: - if UsedStep.objects.filter(subproduction=wproduct.subroduction_plan.suproduction).first().need_test: + if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.suproduction).first().need_test: savedict['is_midtesting'] = True tr = TestRecord.objects.create(**savedict) # 更新wproduct From 38096a9efe6d26ef4c6217b797dfb036d69af016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 22 Jun 2022 14:35:42 +0800 Subject: [PATCH 03/15] bug --- 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 ad82634..1a15fa7 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -213,7 +213,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: - if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.suproduction).first().need_test: + if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.subproduction).first().need_test: savedict['is_midtesting'] = True tr = TestRecord.objects.create(**savedict) # 更新wproduct From 091d0b1257efd079574753512901c222100f27bd Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 24 Jun 2022 08:34:56 +0800 Subject: [PATCH 04/15] tianjiadanweim --- hb_client/src/views/mtm/material.vue | 3 +++ hb_client/src/views/mtm/productList.vue | 3 +++ hb_client/src/views/mtm/wproductList.vue | 3 +++ 3 files changed, 9 insertions(+) diff --git a/hb_client/src/views/mtm/material.vue b/hb_client/src/views/mtm/material.vue index ae26994..651bdf6 100644 --- a/hb_client/src/views/mtm/material.vue +++ b/hb_client/src/views/mtm/material.vue @@ -287,6 +287,9 @@ }, { value: '袋', label: '袋' + }, { + value: '米', + label: '米' }, ], listQuery: { diff --git a/hb_client/src/views/mtm/productList.vue b/hb_client/src/views/mtm/productList.vue index db2480a..d208cbd 100644 --- a/hb_client/src/views/mtm/productList.vue +++ b/hb_client/src/views/mtm/productList.vue @@ -243,6 +243,9 @@ }, { value: '袋', label: '袋' + },{ + value: '米', + label: '米' }, ], listQuery: { diff --git a/hb_client/src/views/mtm/wproductList.vue b/hb_client/src/views/mtm/wproductList.vue index 80e649b..a6aab9b 100644 --- a/hb_client/src/views/mtm/wproductList.vue +++ b/hb_client/src/views/mtm/wproductList.vue @@ -217,6 +217,9 @@ }, { value: '袋', label: '袋' + },{ + value: '米', + label: '米' }, ], listQuery: { From 276b8fc9fc6ae7595609b2800bad70333e113616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Mon, 27 Jun 2022 13:05:16 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=A4=8D=E7=94=A8=E4=B8=8A=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_client/src/views/mtm/productprocess.vue | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/hb_client/src/views/mtm/productprocess.vue b/hb_client/src/views/mtm/productprocess.vue index ef23993..073a693 100644 --- a/hb_client/src/views/mtm/productprocess.vue +++ b/hb_client/src/views/mtm/productprocess.vue @@ -458,6 +458,12 @@ 不检验 + + + @@ -500,12 +506,6 @@ label-width="100px" label-position="right" > - - - 检验 - 不检验 - - + + + 检验 + 不检验 + + + + + + + + From 1784a066d0a49aedb03be63e248156d0bd30f114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Mon, 27 Jun 2022 13:06:09 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E5=AD=90=E5=B7=A5=E5=BA=8F=E5=8F=AF?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E4=B8=8A=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/hrm/views.py | 10 +++--- hb_server/apps/mtm/models.py | 1 + hb_server/apps/mtm/serializers.py | 4 +-- hb_server/apps/wpm/services.py | 7 ++-- hb_server/apps/wpm/views.py | 57 +++++++++++++++++++++---------- 5 files changed, 51 insertions(+), 28 deletions(-) diff --git a/hb_server/apps/hrm/views.py b/hb_server/apps/hrm/views.py index c167784..303e25d 100644 --- a/hb_server/apps/hrm/views.py +++ b/hb_server/apps/hrm/views.py @@ -106,12 +106,12 @@ class ClockRecordViewSet(CreateModelMixin, ListModelMixin, GenericViewSet): def create(self, request, *args, **kwargs): now = timezone.now() now_local = timezone.localtime() - if 8<=now_local.hour<=17: + if 6<=now_local.hour<=17: base64_data = base64.urlsafe_b64decode(tran64( request.data.get('base64').replace(' ', '+'))) user, msg = HRMService.face_compare_from_base64(base64_data, request.data.get('tolerance', 0.36)) if user: - ins, created = ClockRecord.objects.get_or_create( + ClockRecord.objects.get_or_create( create_by = user, create_time__hour__range = [8,18], create_time__year=now_local.year, create_time__month=now_local.month, create_time__day=now_local.day, @@ -120,9 +120,9 @@ class ClockRecordViewSet(CreateModelMixin, ListModelMixin, GenericViewSet): 'create_by':user, 'create_time':now }) - if not created: - ins.update_time = now - ins.save() + # if not created: + # ins.update_time = now + # ins.save() # 设为在岗 Employee.objects.filter(user=user).update(is_atwork=True, last_check_time=now) return Response(UserSimpleSerializer(instance=user).data) diff --git a/hb_server/apps/mtm/models.py b/hb_server/apps/mtm/models.py index 4603bd5..80ab3b3 100644 --- a/hb_server/apps/mtm/models.py +++ b/hb_server/apps/mtm/models.py @@ -266,6 +266,7 @@ class UsedStep(CommonADModel): """ step = models.ForeignKey(Step, verbose_name='子工序', on_delete=models.CASCADE, related_name='usedstep') need_test = models.BooleanField('工序内检验', default=False) + reuse_form = models.BooleanField('复用上表', default=True) remark = models.TextField('生产备注', null=True, blank=True) subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE, related_name='usedstep_subproduction') diff --git a/hb_server/apps/mtm/serializers.py b/hb_server/apps/mtm/serializers.py index 43681b1..ec43e99 100644 --- a/hb_server/apps/mtm/serializers.py +++ b/hb_server/apps/mtm/serializers.py @@ -163,7 +163,7 @@ class UsedStepCreateSerializer(serializers.ModelSerializer): """ class Meta: model = UsedStep - fields = ['step', 'subproduction', 'remark', 'need_test'] + fields = ['step', 'subproduction', 'remark', 'need_test', 'reuse_form'] class UsedStepUpdateSerializer(serializers.ModelSerializer): """ @@ -171,7 +171,7 @@ class UsedStepUpdateSerializer(serializers.ModelSerializer): """ class Meta: model = UsedStep - fields = ['remark', 'need_test'] + fields = ['remark', 'need_test', 'reuse_form'] class UsedStepListSerializer(serializers.ModelSerializer): """ diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 384f036..821d2de 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -15,16 +15,17 @@ class WpmService(object): @classmethod def get_next_step(cls, subproduction_plan:SubProductionPlan, nowstep:Step): """ - 获取下一步骤 + 获取下一步骤的信息 """ steps_list = subproduction_plan.steps stepIds = [i['id'] for i in steps_list] pindex = stepIds.index(nowstep.id) need_test = steps_list[pindex].get('need_test', False) + reuse_form = steps_list[pindex].get('reuse_form', True) if pindex + 1 < len(stepIds): - return Step.objects.get(pk=stepIds[pindex+1]), need_test + return Step.objects.get(pk=stepIds[pindex+1]), need_test, reuse_form else: - return nowstep, need_test + return nowstep, need_test, reuse_form @classmethod def get_subplans_queryset_from_wproducts(cls, wproducts:List): diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 1a15fa7..4f7d492 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -185,14 +185,14 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): vdata = serializer.validated_data wproduct = vdata['wproduct'] form = vdata['form'] - if wproduct.test: - raise exceptions.APIException('存在进行中检验') - # 根据情况创建一条检验记录 if wproduct.act_state not in [WProduct.WPR_ACT_STATE_TOTEST, WProduct.WPR_ACT_STATE_TORETEST, WProduct.WPR_ACT_STATE_TOFINALTEST, WProduct.WPR_ACT_STATE_TOCOMBTEST]: raise exceptions.APIException('该产品当前状态不可检验') + if wproduct.test: + raise exceptions.APIException('存在进行中检验') + savedict = dict( create_by=request.user, wproduct=wproduct, @@ -213,8 +213,10 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: - if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.subproduction).first().need_test: + _, need_test, _ = WpmService.get_next_step(wproduct.subproduction_plan, wproduct.step) + if need_test: savedict['is_midtesting'] = True + # if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.subproduction).first().need_test: tr = TestRecord.objects.create(**savedict) # 更新wproduct wproduct.test = tr @@ -698,7 +700,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wsp = i.subproduction_plan # 获取下一步子工序 - newstep, needTest = WpmService.get_next_step(wsp, step) + newstep, needTest, reuseForm = WpmService.get_next_step(wsp, step) wp.step = newstep wp.pre_step = step wp.material = wsp.product @@ -706,16 +708,24 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if step == newstep: wp.act_state = WProduct.WPR_ACT_STATE_TOTEST if wp.test:# 如果有正在进行的工序中检验 - wp.test.is_midtesting = False - wp.test.is_submited = False - wp.test.save() - else: - wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT - if needTest: - wp.act_state = WProduct.WPR_ACT_STATE_TOTEST - if wp.test:# 如果有正在进行的工序中检验 + if reuseForm: + wp.test.is_midtesting = False wp.test.is_submited = False wp.test.save() + else: + wp.test = None + wp.save() + else: + wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT + if needTest: #子工序若需要检验 + wp.act_state = WProduct.WPR_ACT_STATE_TOTEST + if wp.test:# 如果有正在进行的工序中检验 + if reuseForm: + wp.test.is_submited = False + wp.test.save() + else: + wp.test = None + wp.save() wp.operation = None wp.update_by = request.user @@ -732,7 +742,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd raise exceptions.APIException('请选择物料产出') for i in omos: if i.subproduction_progress.is_main: - newstep, _ = WpmService.get_next_step( + newstep, _, _ = WpmService.get_next_step( i.subproduction_plan, step) wpr = dict(material=i.material, step=newstep, act_state=WProduct.WPR_ACT_STATE_DOWAIT, remark='', @@ -753,7 +763,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if oms_w.count!=1: raise exceptions.APIException('产出数量应为1') # 校验单片数量是否正确, 暂时未写 - newstep, needTest = WpmService.get_next_step( + newstep, needTest, reuseForm = WpmService.get_next_step( oms_w.subproduction_plan, step) wproduct = WProduct() wproduct.material = oms_w.material @@ -762,13 +772,24 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if step == newstep: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST if wproduct.test:# 如果有正在进行的工序中检验 - wproduct.test.is_midtesting = False - wproduct.test.is_submited = False - wproduct.test.save() + if reuseForm: + wproduct.test.is_midtesting = False + wproduct.test.is_submited = False + wproduct.test.save() + else: + wproduct.test = None + wproduct.save() else: wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST + if wproduct.test:# 如果有正在进行的工序中检验 + if reuseForm: + wproduct.test.is_submited = False + wproduct.test.save() + else: + wproduct.test = None + wproduct.save() # 更新子计划进度 WpmService.update_subproduction_progress_main( From 0b0fab4b0abee95d9af6349ee2df1c794076cae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Tue, 28 Jun 2022 13:47:45 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E5=AD=90=E5=B7=A5=E5=BA=8F=E6=A3=80?= =?UTF-8?q?=E9=AA=8C=E5=8F=AF=E4=B8=8D=E5=A4=8D=E7=94=A8=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mtm/migrations/0054_usedstep_reuse_form.py | 18 ++++++++++++++++++ hb_server/apps/wpm/services.py | 4 +--- hb_server/apps/wpm/views.py | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 hb_server/apps/mtm/migrations/0054_usedstep_reuse_form.py diff --git a/hb_server/apps/mtm/migrations/0054_usedstep_reuse_form.py b/hb_server/apps/mtm/migrations/0054_usedstep_reuse_form.py new file mode 100644 index 0000000..1b803dc --- /dev/null +++ b/hb_server/apps/mtm/migrations/0054_usedstep_reuse_form.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.9 on 2022-06-27 05:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mtm', '0053_alter_material_unit'), + ] + + operations = [ + migrations.AddField( + model_name='usedstep', + name='reuse_form', + field=models.BooleanField(default=True, verbose_name='复用上表'), + ), + ] diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 821d2de..42de513 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -51,7 +51,6 @@ class WpmService(object): """ is_testok = test.is_testok wproduct = test.wproduct - test_i = None if is_testok: if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: # 复检 wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT @@ -63,7 +62,6 @@ class WpmService(object): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST and \ test.is_midtesting is True: wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT - test_i = test 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 @@ -113,7 +111,7 @@ class WpmService(object): wproduct.update_by = user wproduct.update_time = timezone.now() - wproduct.test = test_i + wproduct.test = None wproduct.last_test_result = is_testok wproduct.save() # 添加日志 diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 4f7d492..80fee33 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -771,7 +771,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.subproduction_plan = oms_w.subproduction_plan if step == newstep: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - if wproduct.test:# 如果有正在进行的工序中检验 + if wproduct.test: # 如果有正在进行的工序中检验 if reuseForm: wproduct.test.is_midtesting = False wproduct.test.is_submited = False From f2af3e4a8d0b872845e3606ee74fc393806ab0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Tue, 28 Jun 2022 16:58:38 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E5=AD=90=E5=B7=A5=E5=BA=8F=E6=A3=80?= =?UTF-8?q?=E6=9F=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/models.py | 7 ++++ hb_server/apps/wpm/services.py | 43 +++++++++++++++------ hb_server/apps/wpm/views.py | 70 +++++++++++++++++----------------- 3 files changed, 72 insertions(+), 48 deletions(-) diff --git a/hb_server/apps/wpm/models.py b/hb_server/apps/wpm/models.py index 085a20d..a78c6ee 100644 --- a/hb_server/apps/wpm/models.py +++ b/hb_server/apps/wpm/models.py @@ -136,6 +136,13 @@ class WProduct(CommonAModel): """ return self.test_wproduct.filter(type=TestRecord.TEST_PROCESS, is_submited=True).order_by('-id').first() + @property + def last_wp_test(self): + """ + 最后提交的本产品自检 + """ + return self.test_wproduct.filter(is_submited=True).order_by('-id').first() + class WprouctTicket(CommonAModel): """ diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 42de513..081553e 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -3,7 +3,7 @@ from typing import List from django.db.models.expressions import F from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress -from apps.mtm.models import Material, Step, SubprodctionMaterial +from apps.mtm.models import Material, Step, SubprodctionMaterial, UsedStep from apps.qm.models import TestRecord from apps.system.models import User from apps.wf.models import State, TicketFlow, Transition @@ -13,19 +13,38 @@ from rest_framework.exceptions import ParseError class WpmService(object): @classmethod - def get_next_step(cls, subproduction_plan:SubProductionPlan, nowstep:Step): + def get_step_info(cls, subproduction_plan:SubProductionPlan, nowstep:Step, get_next=True): """ - 获取下一步骤的信息 + 获取本步骤或下一步骤的信息 """ - steps_list = subproduction_plan.steps - stepIds = [i['id'] for i in steps_list] - pindex = stepIds.index(nowstep.id) - need_test = steps_list[pindex].get('need_test', False) - reuse_form = steps_list[pindex].get('reuse_form', True) - if pindex + 1 < len(stepIds): - return Step.objects.get(pk=stepIds[pindex+1]), need_test, reuse_form - else: - return nowstep, need_test, reuse_form + used_steps = UsedStep.objects.filter(subproduction=subproduction_plan.subproduction).order_by('step__number') + for index, i in enumerate(used_steps): + if i.step == nowstep and get_next: + try: + used_step = used_steps[index+1] + return used_step, used_step.need_test, used_step.reuse_form + except: + return nowstep, i.need_test, i.reuse_form + elif i.step == nowstep and get_next == False: + return nowstep, i.need_test, i.reuse_form + + # steps_list = subproduction_plan.steps + # stepIds = [i['id'] for i in steps_list] + # pindex = stepIds.index(nowstep.id) + # if get_next: + # if pindex + 1 < len(stepIds): + # pindex = pindex + 1 + # need_test = steps_list[pindex].get('need_test', False) + # reuse_form = steps_list[pindex].get('reuse_form', True) + # return Step.objects.get(pk=stepIds[pindex]), need_test, reuse_form + # else: + # need_test = steps_list[pindex].get('need_test', False) + # reuse_form = steps_list[pindex].get('reuse_form', True) + # return nowstep, need_test, reuse_form + # else: + # need_test = steps_list[pindex].get('need_test', False) + # reuse_form = steps_list[pindex].get('reuse_form', True) + # return @classmethod def get_subplans_queryset_from_wproducts(cls, wproducts:List): diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 80fee33..d448544 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -213,8 +213,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: - _, need_test, _ = WpmService.get_next_step(wproduct.subproduction_plan, wproduct.step) - if need_test: + step, need_test, _ = WpmService.get_step_info(wproduct.subproduction_plan, wproduct.step, get_next=False) + if need_test and wproduct.step != step: savedict['is_midtesting'] = True # if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.subproduction).first().need_test: tr = TestRecord.objects.create(**savedict) @@ -700,32 +700,31 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wsp = i.subproduction_plan # 获取下一步子工序 - newstep, needTest, reuseForm = WpmService.get_next_step(wsp, step) + newstep, needTest, reuseForm = WpmService.get_step_info(wsp, step) wp.step = newstep wp.pre_step = step wp.material = wsp.product if step == newstep: wp.act_state = WProduct.WPR_ACT_STATE_TOTEST - if wp.test:# 如果有正在进行的工序中检验 - if reuseForm: - wp.test.is_midtesting = False - wp.test.is_submited = False - wp.test.save() - else: - wp.test = None - wp.save() + last_test = wp.last_wp_test + if last_test and reuseForm: + last_test.is_midtesting = False + last_test.is_submited = False + last_test.save() + wp.test = last_test + wp.save() else: wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT - if needTest: #子工序若需要检验 + if needTest: #子工序若需要检验 wp.act_state = WProduct.WPR_ACT_STATE_TOTEST - if wp.test:# 如果有正在进行的工序中检验 - if reuseForm: - wp.test.is_submited = False - wp.test.save() - else: - wp.test = None - wp.save() + last_test = wp.last_wp_test + if last_test and reuseForm: + last_test.is_midtesting = True + last_test.is_submited = False + last_test.save() + wp.test = last_test + wp.save() wp.operation = None wp.update_by = request.user @@ -742,7 +741,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd raise exceptions.APIException('请选择物料产出') for i in omos: if i.subproduction_progress.is_main: - newstep, _, _ = WpmService.get_next_step( + newstep, _, _ = WpmService.get_step_info( i.subproduction_plan, step) wpr = dict(material=i.material, step=newstep, act_state=WProduct.WPR_ACT_STATE_DOWAIT, remark='', @@ -763,7 +762,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if oms_w.count!=1: raise exceptions.APIException('产出数量应为1') # 校验单片数量是否正确, 暂时未写 - newstep, needTest, reuseForm = WpmService.get_next_step( + newstep, needTest, reuseForm = WpmService.get_step_info( oms_w.subproduction_plan, step) wproduct = WProduct() wproduct.material = oms_w.material @@ -771,25 +770,24 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.subproduction_plan = oms_w.subproduction_plan if step == newstep: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - if wproduct.test: # 如果有正在进行的工序中检验 - if reuseForm: - wproduct.test.is_midtesting = False - wproduct.test.is_submited = False - wproduct.test.save() - else: - wproduct.test = None - wproduct.save() + last_test = wproduct.last_wp_test + if last_test and reuseForm: + last_test.is_midtesting = False + last_test.is_submited = False + last_test.save() + wproduct.test = last_test + wproduct.save() else: wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - if wproduct.test:# 如果有正在进行的工序中检验 - if reuseForm: - wproduct.test.is_submited = False - wproduct.test.save() - else: - wproduct.test = None - wproduct.save() + last_test = wproduct.last_wp_test + if last_test and reuseForm: + last_test.is_midtesting = True + last_test.is_submited = False + last_test.save() + wproduct.test = last_test + wproduct.save() # 更新子计划进度 WpmService.update_subproduction_progress_main( From de1a17f166381f25f5467620af861619c963db00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 09:54:13 +0800 Subject: [PATCH 09/15] =?UTF-8?q?get=5Fstep=5Finfo=20=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 081553e..fddb01a 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -22,7 +22,7 @@ class WpmService(object): if i.step == nowstep and get_next: try: used_step = used_steps[index+1] - return used_step, used_step.need_test, used_step.reuse_form + return used_step.step, used_step.need_test, used_step.reuse_form except: return nowstep, i.need_test, i.reuse_form elif i.step == nowstep and get_next == False: From 0fb897d75b7cabd0cffd9c65c1546f7ccb3fdf62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 10:56:53 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E6=AD=A5=E5=AD=90=E5=B7=A5=E5=BA=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/models.py | 2 +- hb_server/apps/wpm/views.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hb_server/apps/wpm/models.py b/hb_server/apps/wpm/models.py index a78c6ee..78e3a3f 100644 --- a/hb_server/apps/wpm/models.py +++ b/hb_server/apps/wpm/models.py @@ -139,7 +139,7 @@ class WProduct(CommonAModel): @property def last_wp_test(self): """ - 最后提交的本产品自检 + 最后提交的本产品工序自检 """ return self.test_wproduct.filter(is_submited=True).order_by('-id').first() diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index d448544..c20918c 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -707,7 +707,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if step == newstep: wp.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wp.last_wp_test + last_test = wp.last_process_test if last_test and reuseForm: last_test.is_midtesting = False last_test.is_submited = False @@ -718,7 +718,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: #子工序若需要检验 wp.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wp.last_wp_test + last_test = wp.last_process_test if last_test and reuseForm: last_test.is_midtesting = True last_test.is_submited = False @@ -770,7 +770,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.subproduction_plan = oms_w.subproduction_plan if step == newstep: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wproduct.last_wp_test + last_test = wproduct.last_process_test if last_test and reuseForm: last_test.is_midtesting = False last_test.is_submited = False @@ -781,7 +781,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wproduct.last_wp_test + last_test = wproduct.last_process_test if last_test and reuseForm: last_test.is_midtesting = True last_test.is_submited = False From 4024fee8657adbc4cd37a782ab42462fe2369e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 11:33:09 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E6=9C=80=E5=90=8E=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E7=9A=84=E6=9C=AC=E4=BA=A7=E5=93=81=E6=9C=AC=E5=B7=A5=E5=BA=8F?= =?UTF-8?q?=E8=87=AA=E6=A3=80=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/models.py | 4 ++-- hb_server/apps/wpm/views.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hb_server/apps/wpm/models.py b/hb_server/apps/wpm/models.py index 78e3a3f..45c5fcb 100644 --- a/hb_server/apps/wpm/models.py +++ b/hb_server/apps/wpm/models.py @@ -139,9 +139,9 @@ class WProduct(CommonAModel): @property def last_wp_test(self): """ - 最后提交的本产品工序自检 + 最后提交的本产品本工序自检 """ - return self.test_wproduct.filter(is_submited=True).order_by('-id').first() + return self.test_wproduct.filter(is_submited=True, type=TestRecord.TEST_PROCESS, subproduction_plan=self.subproduction_plan).order_by('-id').first() class WprouctTicket(CommonAModel): diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index c20918c..012b103 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -203,7 +203,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): form=form) if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: # 查找最近一条检验记录 - trs = wproduct.last_process_test + trs = wproduct.last_wp_test savedict['origin_test'] = trs if not trs: raise exceptions.APIException('原工序检验记录不存在') @@ -707,7 +707,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if step == newstep: wp.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wp.last_process_test + last_test = wp.last_wp_test if last_test and reuseForm: last_test.is_midtesting = False last_test.is_submited = False @@ -718,7 +718,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: #子工序若需要检验 wp.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wp.last_process_test + last_test = wp.last_wp_test if last_test and reuseForm: last_test.is_midtesting = True last_test.is_submited = False @@ -770,7 +770,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.subproduction_plan = oms_w.subproduction_plan if step == newstep: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wproduct.last_process_test + last_test = wproduct.last_wp_test if last_test and reuseForm: last_test.is_midtesting = False last_test.is_submited = False @@ -781,7 +781,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wproduct.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: wproduct.act_state = WProduct.WPR_ACT_STATE_TOTEST - last_test = wproduct.last_process_test + last_test = wproduct.last_wp_test if last_test and reuseForm: last_test.is_midtesting = True last_test.is_submited = False From 7e43f76112e0c9dc602bcd5978e3216445ad5b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 13:16:50 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E6=9F=A5=E6=89=BE=E6=9C=80=E8=BF=91?= =?UTF-8?q?=E4=B8=80=E6=9D=A1=E5=B7=A5=E5=BA=8F=E6=A3=80=E9=AA=8C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/wpm/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 012b103..9f8c6f7 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -202,8 +202,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): step=wproduct.step, form=form) if wproduct.act_state == WProduct.WPR_ACT_STATE_TORETEST: - # 查找最近一条检验记录 - trs = wproduct.last_wp_test + # 查找最近一条工序检验记录 + trs = wproduct.last_process_test savedict['origin_test'] = trs if not trs: raise exceptions.APIException('原工序检验记录不存在') From 464f1930fc7ab44be8e3e00f005d97cd6222127a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 14:12:37 +0800 Subject: [PATCH 13/15] test init bug --- 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 9f8c6f7..e5a4d0c 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -213,7 +213,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: - step, need_test, _ = WpmService.get_step_info(wproduct.subproduction_plan, wproduct.step, get_next=False) + step, need_test, _ = WpmService.get_step_info(wproduct.subproduction_plan, wproduct.pre_step, get_next=False) if need_test and wproduct.step != step: savedict['is_midtesting'] = True # if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.subproduction).first().need_test: From 4dc8918f809644c7eb177cf32814c37481349dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 14:53:25 +0800 Subject: [PATCH 14/15] get_step info bug --- hb_server/apps/wpm/services.py | 13 ++++++------- hb_server/apps/wpm/views.py | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index fddb01a..55ad079 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -13,20 +13,19 @@ from rest_framework.exceptions import ParseError class WpmService(object): @classmethod - def get_step_info(cls, subproduction_plan:SubProductionPlan, nowstep:Step, get_next=True): + def get_step_info(cls, subproduction_plan:SubProductionPlan, nowstep:Step): """ - 获取本步骤或下一步骤的信息 + 返回下一步骤, 当前步骤是否需要检验, 当前步骤是否需要复用表 """ used_steps = UsedStep.objects.filter(subproduction=subproduction_plan.subproduction).order_by('step__number') for index, i in enumerate(used_steps): - if i.step == nowstep and get_next: + if i.step == nowstep: try: used_step = used_steps[index+1] - return used_step.step, used_step.need_test, used_step.reuse_form + return used_step.step, i.need_test, i.reuise_form except: - return nowstep, i.need_test, i.reuse_form - elif i.step == nowstep and get_next == False: - return nowstep, i.need_test, i.reuse_form + return nowstep, False, True + raise ParseError('获取步骤信息失败') # steps_list = subproduction_plan.steps # stepIds = [i['id'] for i in steps_list] diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index e5a4d0c..a532c26 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -213,8 +213,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST: savedict['type'] = TestRecord.TEST_COMB elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOTEST: - step, need_test, _ = WpmService.get_step_info(wproduct.subproduction_plan, wproduct.pre_step, get_next=False) - if need_test and wproduct.step != step: + _, need_test, _ = WpmService.get_step_info(wproduct.subproduction_plan, wproduct.pre_step) + if need_test and wproduct.step != wproduct.pre_step: savedict['is_midtesting'] = True # if UsedStep.objects.filter(subproduction=wproduct.subproduction_plan.subproduction).first().need_test: tr = TestRecord.objects.create(**savedict) From 3a31196f152ed4915118abdb6fb0cc33a03d3de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=89=8D=E6=98=8E?= <909355014@qq.com> Date: Wed, 29 Jun 2022 18:07:19 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E6=A3=80=E9=AA=8C=E6=B5=81=E8=BD=ACbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/mtm/views.py | 2 +- hb_server/apps/wpm/services.py | 10 ++++++++-- hb_server/apps/wpm/views.py | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hb_server/apps/mtm/views.py b/hb_server/apps/mtm/views.py index c5932e5..7ab01d0 100644 --- a/hb_server/apps/mtm/views.py +++ b/hb_server/apps/mtm/views.py @@ -166,7 +166,7 @@ class UsedStepViewSet(OptimizationMixin, CreateModelMixin, DestroyModelMixin, Li 'put':'subproduction_update', 'delete':'subproduction_update'} queryset = UsedStep.objects.all() filterset_fields = ['subproduction', 'step'] - ordering = ['step__sort', '-step__create_time'] + ordering = ['step__number', 'step__create_time'] def get_serializer_class(self): if self.action =='create': diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index 55ad079..1587c55 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -2,6 +2,7 @@ from django.utils import timezone from typing import List from django.db.models.expressions import F +from apps.mtm.serializers import UsedStepListSerializer from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress from apps.mtm.models import Material, Step, SubprodctionMaterial, UsedStep from apps.qm.models import TestRecord @@ -18,13 +19,18 @@ class WpmService(object): 返回下一步骤, 当前步骤是否需要检验, 当前步骤是否需要复用表 """ used_steps = UsedStep.objects.filter(subproduction=subproduction_plan.subproduction).order_by('step__number') + if nowstep is None: + try: + nowstep = used_steps[0].step + except: + pass for index, i in enumerate(used_steps): if i.step == nowstep: try: used_step = used_steps[index+1] - return used_step.step, i.need_test, i.reuise_form + return used_step.step, i.need_test, i.reuse_form except: - return nowstep, False, True + return nowstep, i.need_test, i.reuse_form raise ParseError('获取步骤信息失败') # steps_list = subproduction_plan.steps diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index a532c26..a72ae13 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -36,7 +36,7 @@ from apps.wpm.services import WpmService from django.utils import timezone from rest_framework import status from django.db.models import Count, Q - +from rest_framework.exceptions import ParseError from utils.tools import ranstr @@ -717,6 +717,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd else: wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: #子工序若需要检验 + print(needTest, reuseForm) wp.act_state = WProduct.WPR_ACT_STATE_TOTEST last_test = wp.last_wp_test if last_test and reuseForm: