def WorkOrderFlow_revoke(request): # temp_name = "skworkorders/skworkorders-header.html" login_user = request.user WorkOrderFlow_id = request.GET.get('id', '') t01 = WorkOrdkerFlowTask(WorkOrderFlow_id, login_user, request) if WorkOrderFlow_id: if t01.obj.celery_task_id: t01.celery_task_revoke() else: t01.manual_task_revoke() return HttpResponse('successful') else: return HttpResponse('the WorkOrderFlow_id didnot exist')
def WorkOrderFlow_permit(request): if request.method == "POST": tpl_Comment_form = Comment_form(request.POST) if tpl_Comment_form.is_valid(): comment_content = request.POST["comment_content"] WorkOrderFlow_id = request.POST["id"] login_user = request.user login_user = str(login_user) obj_user = UserInfo.objects.get(username=request.user) obj_group = obj_user.usergroup_set.all() obj_WorkOrderFlow = WorkOrderFlow.objects.get(id=WorkOrderFlow_id) obj_WorkOrder = WorkOrder.objects.get( id=obj_WorkOrderFlow.workorder_id) obj_AuditFlow = AuditFlow.objects.get( name=obj_WorkOrder.audit_flow) obj_level = obj_AuditFlow.level obj_status = obj_WorkOrderFlow.status t01 = WorkOrdkerFlowTask(WorkOrderFlow_id, login_user, request) time_now = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') if obj_level == "1": obj_l1 = UserGroup.objects.get(name=obj_AuditFlow.l1) if obj_l1 in obj_group: WorkOrderFlow.objects.filter(id=WorkOrderFlow_id).update( status="1", user_l1=login_user, comment_l1=comment_content, updated_at_l1=time_now) if t01.obj.celery_schedule_time: t01.celery_task_add() elif t01.obj.auto_exe_enable: t01.celery_task_add() elif obj_level == "2": obj_l1 = UserGroup.objects.get(name=obj_AuditFlow.l1) obj_l2 = UserGroup.objects.get(name=obj_AuditFlow.l2) if obj_l1 in obj_group and (obj_status == "0" or obj_status == "2"): WorkOrderFlow.objects.filter(id=WorkOrderFlow_id).update( status="1", user_l1=login_user, comment_l1=comment_content, updated_at_l1=time_now) if obj_l2 in obj_group: WorkOrderFlow.objects.filter(id=WorkOrderFlow_id).update( status="5", user_l2=login_user, comment_l2=comment_content, updated_at_l2=time_now) if t01.obj.celery_schedule_time: t01.celery_task_add() elif t01.obj.auto_exe_enable: t01.celery_task_add() elif obj_level == "3": obj_l1 = UserGroup.objects.get(name=obj_AuditFlow.l1) obj_l2 = UserGroup.objects.get(name=obj_AuditFlow.l2) obj_l3 = UserGroup.objects.get(name=obj_AuditFlow.l3) if obj_l1 in obj_group and (obj_status == "0" or obj_status == "2"): WorkOrderFlow.objects.filter(id=WorkOrderFlow_id).update( status="1", comment_l1=comment_content, user_l1=login_user, updated_at_l1=time_now) if obj_l2 in obj_group and (obj_status == "0" or obj_status == "2" or obj_status == "1" or obj_status == "6"): WorkOrderFlow.objects.filter(id=WorkOrderFlow_id).update( status="5", user_l2=login_user, comment_l2=comment_content, updated_at_l2=time_now) if obj_l3 in obj_group: WorkOrderFlow.objects.filter(id=WorkOrderFlow_id).update( status="7", user_l3=login_user, comment_l3=comment_content, updated_at_l3=time_now) if t01.obj.celery_schedule_time: t01.celery_task_add() elif t01.obj.auto_exe_enable: t01.celery_task_add() status = 1 else: status = 2 else: tpl_Comment_form = Comment_form() tpl_id = request.GET.get('id', '') return render(request, 'skworkorders/WorkOrderFlow_permit.html', locals()) return HttpResponse('ok')
def WorkOrderFlow_release_run(request): temp_name = "skworkorders/skworkorders-header.html" if not request.is_websocket(): #判断是不是websocket连接 try: #如果是普通的http方法 message = request.GET['message'] return HttpResponse(message) except: return render(request, 'skworkorders/websocket.html', locals()) else: for message in request.websocket: WorkOrderFlow_id = int(message) user = request.user t01 = WorkOrdkerFlowTask(WorkOrderFlow_id, user, request) content_str = "execute starting" t01.log("info", content_str) if t01.permission_audit_pass(): if t01.permission_submit_pass(): if t01.obj.celery_task_id: t01.celery_task_changeto_manual_task() t01.all_task_do() else: t01.permission_submit_deny() else: t01.permission_audit_deny()