代码获取处理人
This commit is contained in:
parent
deb278085d
commit
145bf1d6b7
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.6 on 2021-10-21 08:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mtm', '0024_alter_recordformfield_rule_expression'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='outputmaterial',
|
||||||
|
name='is_main',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='是否主产出'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -232,5 +232,6 @@ class WfScript(CommonAModel):
|
||||||
wait = models.BooleanField('是否等待执行完成', default=True)
|
wait = models.BooleanField('是否等待执行完成', default=True)
|
||||||
name = models.CharField('脚本名称', max_length=100)
|
name = models.CharField('脚本名称', max_length=100)
|
||||||
workflow = models.ForeignKey(Workflow, verbose_name='关联工作流', null=True, blank=True, on_delete=models.SET_NULL)
|
workflow = models.ForeignKey(Workflow, verbose_name='关联工作流', null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
|
func_str = models.CharField('函数名', max_length=50, null=True, blank=True)
|
||||||
content = models.TextField('脚本内容')
|
content = models.TextField('脚本内容')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
from .models import State
|
||||||
|
class GetParticipants:
|
||||||
|
|
||||||
|
all_funcs = [
|
||||||
|
{'func':'get_create_by', 'name':'获取工单创建人'}
|
||||||
|
]
|
||||||
|
|
||||||
|
# def all_funcs(self):
|
||||||
|
# # return list(filter(lambda x: x.startswith('get_') and callable(getattr(self, x)), dir(self)))
|
||||||
|
# return [(func, getattr(self, func).__doc__) for func in dir(self) if callable(getattr(self, func)) and func.startswith('get_')]
|
||||||
|
|
||||||
|
def get_create_by(self, state:dict={}, ticket:dict={}, ticket_data:dict={}, request={}):
|
||||||
|
"""工单创建人"""
|
||||||
|
participant = ticket.create_by.id
|
||||||
|
return participant
|
|
@ -7,6 +7,7 @@ from rest_framework.exceptions import APIException
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import random
|
import random
|
||||||
|
from .scripts import GetParticipants
|
||||||
|
|
||||||
class WfService(object):
|
class WfService(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -147,6 +148,10 @@ class WfService(object):
|
||||||
if destination_participant_type == State.PARTICIPANT_TYPE_FIELD:
|
if destination_participant_type == State.PARTICIPANT_TYPE_FIELD:
|
||||||
destination_participant = ticket_data.get(destination_participant, 0) if destination_participant in ticket_data \
|
destination_participant = ticket_data.get(destination_participant, 0) if destination_participant in ticket_data \
|
||||||
else Ticket.ticket_data.get(destination_participant, 0)
|
else Ticket.ticket_data.get(destination_participant, 0)
|
||||||
|
|
||||||
|
elif destination_participant_type == State.PARTICIPANT_TYPE_FORMCODE:#代码获取
|
||||||
|
destination_participant = getattr(GetParticipants, destination_participant)(state=state, ticket=ticket, ticket_data=ticket_data, request=request)
|
||||||
|
|
||||||
elif destination_participant_type == State.PARTICIPANT_TYPE_DEPT:#部门
|
elif destination_participant_type == State.PARTICIPANT_TYPE_DEPT:#部门
|
||||||
destination_participant = list(User.objects.filter(dept__in=destination_participant).values_list('id', flat=True))
|
destination_participant = list(User.objects.filter(dept__in=destination_participant).values_list('id', flat=True))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.db.models import base
|
from django.db.models import base
|
||||||
from rest_framework import urlpatterns
|
from rest_framework import urlpatterns
|
||||||
from apps.wf.views import CustomFieldViewSet, StateViewSet, TicketFlowViewSet, TicketViewSet, TransitionViewSet, WorkflowViewSet
|
from apps.wf.views import CustomFieldViewSet, FromCodeListView, StateViewSet, TicketFlowViewSet, TicketViewSet, TransitionViewSet, WorkflowViewSet
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ router.register('customfield', CustomFieldViewSet, basename='wf_customfield')
|
||||||
router.register('ticket', TicketViewSet, basename='wf_ticket')
|
router.register('ticket', TicketViewSet, basename='wf_ticket')
|
||||||
router.register('ticketflow', TicketFlowViewSet, basename='wf_ticketflow')
|
router.register('ticketflow', TicketFlowViewSet, basename='wf_ticketflow')
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path('participant_from_code', FromCodeListView.as_view()),
|
||||||
path('', include(router.urls)),
|
path('', include(router.urls)),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.db.models import query
|
from django.db.models import query
|
||||||
|
from rest_framework.views import APIView
|
||||||
from apps.system.models import User
|
from apps.system.models import User
|
||||||
from apps.wf.filters import TicketFilterSet
|
from apps.wf.filters import TicketFilterSet
|
||||||
from django.core.exceptions import AppRegistryNotReady
|
from django.core.exceptions import AppRegistryNotReady
|
||||||
|
@ -15,8 +16,16 @@ from apps.wf.services import WfService
|
||||||
from rest_framework.exceptions import APIException, PermissionDenied
|
from rest_framework.exceptions import APIException, PermissionDenied
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
|
from .scripts import GetParticipants
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
class FromCodeListView(APIView):
|
||||||
|
def get(self, request, format=None):
|
||||||
|
"""
|
||||||
|
获取处理人代码列表
|
||||||
|
"""
|
||||||
|
return Response(GetParticipants.all_funcs)
|
||||||
|
|
||||||
class WorkflowViewSet(CreateUpdateModelAMixin, ModelViewSet):
|
class WorkflowViewSet(CreateUpdateModelAMixin, ModelViewSet):
|
||||||
perms_map = {'get': '*', 'post': 'workflow_create',
|
perms_map = {'get': '*', 'post': 'workflow_create',
|
||||||
'put': 'workflow_update', 'delete': 'workflow_delete'}
|
'put': 'workflow_update', 'delete': 'workflow_delete'}
|
||||||
|
|
|
@ -5,17 +5,29 @@ from django.db.models.query import QuerySet
|
||||||
from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File
|
from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File
|
||||||
from utils.model import SoftModel, BaseModel
|
from utils.model import SoftModel, BaseModel
|
||||||
from simple_history.models import HistoricalRecords
|
from simple_history.models import HistoricalRecords
|
||||||
|
from apps.mtm.models import Material, Step
|
||||||
|
|
||||||
class Good(CommonAModel):
|
class Good(CommonAModel):
|
||||||
"""
|
"""
|
||||||
物品
|
物品
|
||||||
"""
|
"""
|
||||||
|
act_state_choices=(
|
||||||
|
(0, '待执行'),
|
||||||
|
(1, '进行中'),
|
||||||
|
(2, '已完成')
|
||||||
|
)
|
||||||
number = models.CharField('物品编号', primary_key=True, null=True, blank=True, max_length=50)
|
number = models.CharField('物品编号', primary_key=True, null=True, blank=True, max_length=50)
|
||||||
m_state = models.ForeignKey('所属物料状态', on_delete=models.CASCADE)
|
m_state = models.ForeignKey(Material, verbose_name='所属物料状态', on_delete=models.CASCADE)
|
||||||
p_state = models.ForeignKey('所在步骤', )
|
p_state = models.ForeignKey(Step, verbose_name='所在步骤', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
|
act_state = models.IntegerField('进行状态', default=0)
|
||||||
|
|
||||||
|
|
||||||
|
class GoodFlow(BaseModel):
|
||||||
|
"""
|
||||||
|
物品流转日志
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Vendor(CommonAModel):
|
class Vendor(CommonAModel):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -41,6 +41,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'corsheaders',
|
'corsheaders',
|
||||||
'django_celery_beat',
|
'django_celery_beat',
|
||||||
|
'django_celery_results',
|
||||||
'drf_yasg',
|
'drf_yasg',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
"django_filters",
|
"django_filters",
|
||||||
|
@ -203,6 +204,7 @@ CELERY_BROKER_URL = "redis://redis:6379/0" # 任务存储
|
||||||
CELERYD_MAX_TASKS_PER_CHILD = 100 # 每个worker最多执行300个任务就会被销毁,可防止内存泄露
|
CELERYD_MAX_TASKS_PER_CHILD = 100 # 每个worker最多执行300个任务就会被销毁,可防止内存泄露
|
||||||
CELERY_TIMEZONE = 'Asia/Shanghai' # 设置时区
|
CELERY_TIMEZONE = 'Asia/Shanghai' # 设置时区
|
||||||
CELERY_ENABLE_UTC = True # 启动时区设置
|
CELERY_ENABLE_UTC = True # 启动时区设置
|
||||||
|
CELERY_RESULT_BACKEND = 'django-db'
|
||||||
|
|
||||||
# swagger配置
|
# swagger配置
|
||||||
SWAGGER_SETTINGS = {
|
SWAGGER_SETTINGS = {
|
||||||
|
|
Loading…
Reference in New Issue