42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
| 
 | |
| from apps.wf.models import Ticket
 | |
| # TicketFlow, Transition, Workflow, CustomField, State, 
 | |
| from apps.ofm.models import LendingSeal, Vehicle
 | |
| from rest_framework.exceptions import ParseError
 | |
| 
 | |
| 
 | |
| def seal_submit_validate(ins: LendingSeal):
 | |
|     if ins.submit_time:
 | |
|         raise ParseError('该日志已提交!')
 | |
|     if ins.mtask and ins.mtask.state == LendingSeal.MTASK_STOP:
 | |
|         raise ParseError('该任务已停止!')
 | |
|             
 | |
| def bind_lendingseal(ticket: Ticket, transition, new_ticket_data: dict):
 | |
|     ins = LendingSeal.objects.get(id=new_ticket_data['t_id'])
 | |
|     ticket_data = ticket.ticket_data
 | |
|     ticket_data.update({
 | |
|         't_model': 'LendingSeal',
 | |
|         't_id': ins.id,
 | |
|     })
 | |
|     ticket.ticket_data = ticket_data
 | |
|     ticket.create_by = ins.create_by
 | |
|     ticket.save()
 | |
|     if ins.ticket is None:
 | |
|         ins.ticket = ticket
 | |
|         ins.save()
 | |
| 
 | |
| def bind_vehicle(ticket: Ticket, transition, new_ticket_data: dict):
 | |
|     ins = Vehicle.objects.get(id=new_ticket_data['t_id'])
 | |
|     ticket_data = ticket.ticket_data
 | |
|     ticket_data.update({
 | |
|         't_model': 'Vehicle',
 | |
|         't_id': ins.id,
 | |
|     })
 | |
|     ticket.ticket_data = ticket_data
 | |
|     ticket.create_by = ins.create_by
 | |
|     ticket.save()
 | |
|     if ins.ticket is None:
 | |
|         ins.ticket = ticket
 | |
|         ins.save()
 | |
| 
 |