工序表增加workshop字段
This commit is contained in:
parent
818d3dfe41
commit
5458fef0d4
|
@ -2,7 +2,7 @@ from apps.em.serializers import EquipmentSerializer, EquipmentSimpleSerializer
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
from .models import InputMaterial, Material, OutputMaterial, Process, ProductProcess, Step, UsedStep
|
from .models import InputMaterial, Material, OutputMaterial, Process, ProductProcess, Step, UsedStep
|
||||||
from apps.system.serializers import FileSimpleSerializer
|
from apps.system.serializers import FileSimpleSerializer, OrganizationSimpleSerializer
|
||||||
|
|
||||||
|
|
||||||
class MaterialSerializer(serializers.ModelSerializer):
|
class MaterialSerializer(serializers.ModelSerializer):
|
||||||
|
@ -29,6 +29,7 @@ class MaterialSimpleSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class ProcessSerializer(serializers.ModelSerializer):
|
class ProcessSerializer(serializers.ModelSerializer):
|
||||||
instruction_ = FileSimpleSerializer(source='instruction', read_only=True)
|
instruction_ = FileSimpleSerializer(source='instruction', read_only=True)
|
||||||
|
workshop_ = OrganizationSimpleSerializer(source='workshop', read_only=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Process
|
model = Process
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
|
@ -46,10 +46,10 @@ class ProcessViewSet(PageOrNot, CreateUpdateModelAMixin, ModelViewSet):
|
||||||
"""
|
"""
|
||||||
perms_map = {'get': '*', 'post': 'process_create',
|
perms_map = {'get': '*', 'post': 'process_create',
|
||||||
'put': 'process_update', 'delete': 'process_delete'}
|
'put': 'process_update', 'delete': 'process_delete'}
|
||||||
queryset = Process.objects.select_related('instruction').all()
|
queryset = Process.objects.select_related('instruction', 'workshop').all()
|
||||||
serializer_class = ProcessSerializer
|
serializer_class = ProcessSerializer
|
||||||
search_fields = ['name', 'number']
|
search_fields = ['name', 'number']
|
||||||
filterset_fields = ['number']
|
filterset_fields = ['number', 'workshop']
|
||||||
ordering_fields = ['number']
|
ordering_fields = ['number']
|
||||||
ordering = ['number']
|
ordering = ['number']
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from typing import Tuple
|
||||||
from apps.system.models import User
|
from apps.system.models import User
|
||||||
from apps.wf.models import CustomField, State, Ticket, Transition, Workflow
|
from apps.wf.models import CustomField, State, Ticket, Transition, Workflow
|
||||||
from rest_framework.exceptions import APIException
|
from rest_framework.exceptions import APIException
|
||||||
|
@ -150,4 +151,27 @@ class WfService(object):
|
||||||
destination_participant=destination_participant,
|
destination_participant=destination_participant,
|
||||||
multi_all_person=multi_all_person_dict)
|
multi_all_person=multi_all_person_dict)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def ticket_handle_permission_check(cls, ticket:Ticket, user:User)-> dict:
|
||||||
|
transitions = cls.get_state_transitions(ticket.state)
|
||||||
|
if not transitions:
|
||||||
|
return dict(permission=True, msg="工单当前状态无需操作")
|
||||||
|
current_participant_count = 1
|
||||||
|
participant_type = ticket.participant_type
|
||||||
|
participant = ticket.participant
|
||||||
|
state = ticket.state
|
||||||
|
if participant_type == State.PARTICIPANT_TYPE_PERSONAL:
|
||||||
|
if user.id != participant:
|
||||||
|
return dict(permission=False, need_accept=False, in_add_node=False, msg="非当前处理人")
|
||||||
|
elif participant_type in [State.PARTICIPANT_TYPE_MULTI, State.PARTICIPANT_TYPE_DEPT, State.PARTICIPANT_TYPE_ROLE]:
|
||||||
|
if user.id not in participant:
|
||||||
|
return dict(permission=False, need_accept=False, in_add_node=False, msg="非当前处理人")
|
||||||
|
current_participant_count = len(participant.split(','))
|
||||||
|
need_accept = False
|
||||||
|
if current_participant_count >1 and state.distribute_type == State.STATE_DISTRIBUTE_TYPE_ACTIVE:
|
||||||
|
# 如果是主动接单
|
||||||
|
need_accept = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,14 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
|
||||||
return Response(TicketSerializer(instance=ticket).data)
|
return Response(TicketSerializer(instance=ticket).data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def patch(self, request, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
处理工单
|
||||||
|
"""
|
||||||
|
data = request.data
|
||||||
|
pass
|
||||||
|
|
||||||
@action(methods=['get'], detail=True, perms_map={'get':'*'})
|
@action(methods=['get'], detail=True, perms_map={'get':'*'})
|
||||||
def flowsteps(self, request, pk=None):
|
def flowsteps(self, request, pk=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue