工序表增加workshop字段

This commit is contained in:
caoqianming 2021-08-31 16:10:47 +08:00
parent 818d3dfe41
commit 5458fef0d4
4 changed files with 36 additions and 3 deletions

View File

@ -2,7 +2,7 @@ from apps.em.serializers import EquipmentSerializer, EquipmentSimpleSerializer
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
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):
@ -29,6 +29,7 @@ class MaterialSimpleSerializer(serializers.ModelSerializer):
class ProcessSerializer(serializers.ModelSerializer):
instruction_ = FileSimpleSerializer(source='instruction', read_only=True)
workshop_ = OrganizationSimpleSerializer(source='workshop', read_only=True)
class Meta:
model = Process
fields = '__all__'

View File

@ -46,10 +46,10 @@ class ProcessViewSet(PageOrNot, CreateUpdateModelAMixin, ModelViewSet):
"""
perms_map = {'get': '*', 'post': 'process_create',
'put': 'process_update', 'delete': 'process_delete'}
queryset = Process.objects.select_related('instruction').all()
queryset = Process.objects.select_related('instruction', 'workshop').all()
serializer_class = ProcessSerializer
search_fields = ['name', 'number']
filterset_fields = ['number']
filterset_fields = ['number', 'workshop']
ordering_fields = ['number']
ordering = ['number']

View File

@ -1,3 +1,4 @@
from typing import Tuple
from apps.system.models import User
from apps.wf.models import CustomField, State, Ticket, Transition, Workflow
from rest_framework.exceptions import APIException
@ -150,4 +151,27 @@ class WfService(object):
destination_participant=destination_participant,
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

View File

@ -149,6 +149,14 @@ class TicketViewSet(OptimizationMixin, CreateUpdateCustomMixin, CreateModelMixin
return Response(TicketSerializer(instance=ticket).data)
def patch(self, request, *args, **kwargs):
"""
处理工单
"""
data = request.data
pass
@action(methods=['get'], detail=True, perms_map={'get':'*'})
def flowsteps(self, request, pk=None):
"""