diff --git a/hb_server/apps/pm/views.py b/hb_server/apps/pm/views.py index cb02d67..4257e9f 100644 --- a/hb_server/apps/pm/views.py +++ b/hb_server/apps/pm/views.py @@ -98,7 +98,7 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel for index, i in enumerate(subps): steps = Step.objects.filter(usedstep__subproduction=i, usedstep__subproduction__is_deleted=False, usedstep__is_deleted=False, is_deleted=False - ).values('id', 'number', 'name', 'usedstep__remark', need_test=F('usedstep__need_test')) + ).order_by('number').values('id', 'number', 'name', 'usedstep__remark', need_test=F('usedstep__need_test')) instance = SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i, start_date=production_plan.start_date, end_date=production_plan.end_date, workshop=i.process.workshop, process=i.process, create_by=request.user, diff --git a/hb_server/apps/system/views.py b/hb_server/apps/system/views.py index 3664054..3677e66 100644 --- a/hb_server/apps/system/views.py +++ b/hb_server/apps/system/views.py @@ -200,9 +200,9 @@ class PermissionViewSet(ModelViewSet): queryset = Permission.objects.all() serializer_class = PermissionSerializer pagination_class = None - search_fields = ['name'] - ordering_fields = ['sort'] - ordering = ['pk'] + search_fields = ['name', 'method'] + ordering_fields = ['sort', 'id', 'method'] + ordering = ['sort'] class OrganizationViewSet(ModelViewSet): diff --git a/hb_server/apps/wpm/serializers.py b/hb_server/apps/wpm/serializers.py index b5c702f..61ae4b5 100644 --- a/hb_server/apps/wpm/serializers.py +++ b/hb_server/apps/wpm/serializers.py @@ -64,6 +64,8 @@ class PickSerializer(serializers.Serializer): fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_OUT, inout_date=timezone.now(), create_by=self.context['request'].user, number = 'CK' + ranstr(7)) + if len(picks)<=0: + raise exceptions.APIException('没有领料项目') for i in picks: isLowLevel = False # 更新出库详情 @@ -116,8 +118,9 @@ class PickSerializer(serializers.Serializer): subproduction_plan=sp) sp.is_picked=True sp.state = SubProductionPlan.SUBPLAN_STATE_WORKING #生产中 - sp.state_date_real = timezone.now() #实际开工日期 - sp.save() + if sp.start_date_real is None: + sp.start_date_real = timezone.now()#实际开工日期 + sp.save() # 创建领料记录 pick = Pick() pick.subproduction_plan = sp diff --git a/hb_server/apps/wpm/services.py b/hb_server/apps/wpm/services.py index acf5cf0..f836273 100644 --- a/hb_server/apps/wpm/services.py +++ b/hb_server/apps/wpm/services.py @@ -76,8 +76,9 @@ class WpmService(object): if wt.step.process == test.step.process: wproduct.ng_sign = None ticket = wt.ticket - ticket_data = wt.ticket_data + ticket_data = ticket.ticket_data ticket_data['retest_result'] = 1 + ticket.ticket_data = ticket_data ticket.update_by = user ticket.save() # 创建处理日志 diff --git a/hb_server/apps/wpm/signals.py b/hb_server/apps/wpm/signals.py index 67ba2d2..874859a 100644 --- a/hb_server/apps/wpm/signals.py +++ b/hb_server/apps/wpm/signals.py @@ -71,7 +71,9 @@ def handleTicket(sender, instance, created, **kwargs): elif decision in [WProduct.NG_ACCEPT, WProduct.NG_PERMIT]: wp.act_state = WProduct.WPR_ACT_STATE_OK - if wp.test_wproduct.filter(is_submited=True).order_by('-id').last().type == TestRecord.TEST_PROCESS_RE: + # 获取最后一次检验 + test= wp.test_wproduct.filter(is_submited=True).order_by('-id').last() + if test.type == TestRecord.TEST_PROCESS_RE or test.is_midtesting: wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT wp.ng_sign = decision wt.save() diff --git a/hb_server/apps/wpm/views.py b/hb_server/apps/wpm/views.py index 9e53ef9..59a4086 100644 --- a/hb_server/apps/wpm/views.py +++ b/hb_server/apps/wpm/views.py @@ -163,7 +163,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): 'to_order').prefetch_related('wp_child') serializer_class = WProductListSerializer filterset_class = WProductFilterSet - search_fields = ['number'] + search_fields = ['number', 'material__name', 'subproduction_plan__number'] ordering_fields = ['id'] ordering = ['id'] @@ -315,7 +315,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): remark = vdata.get('remark', '') fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_IN, is_audited=True, auditor=request.user, inout_date=timezone.now(), - create_by=request.user, remark=remark) + create_by=request.user, remark=remark, number='RK'+ranstr(7)) # 创建入库明细 fifoitem = FIFOItem() fifoitem.warehouse = warehouse @@ -660,8 +660,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd if set(list(sps_omi_l)) != set(list(sps_omo_l)): raise exceptions.APIException('消耗与产出不一致') else: - if omis.exists() and processId !=1: # 不是冷加工 - raise exceptions.APIException('请选择消耗物料') + pass + # if omis.exists() and processId !=1: # 不是冷加工 + # raise exceptions.APIException('请选择消耗物料') # 检查自定义表单填写 if OperationRecord.objects.filter(operation=op, is_filled=False).exists(): @@ -712,6 +713,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT if needTest: wp.act_state = WProduct.WPR_ACT_STATE_TOTEST + if wp.test:# 如果有正在进行的工序中检验 + wp.test.is_submited = False + wp.test.save() wp.operation = None wp.update_by = request.user