models.py 5.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import datetime, time
  2. from django.db import models
  3. from apps.loon_base_model import BaseModel
  4. from service.common.constant_service import CONSTANT_SERVICE
  5. # Create your models here.
  6. class TicketRecord(BaseModel):
  7. """
  8. 工单记录
  9. """
  10. title = models.CharField(u'标题', max_length=500, blank=True, default='', help_text="工单的标题")
  11. workflow_id = models.IntegerField('关联的流程id', help_text='与workflow.Workflow流程关联')
  12. sn = models.CharField(u'流水号', max_length=25, help_text="工单的流水号")
  13. state_id = models.IntegerField('当前状态', help_text='与workflow.State关联')
  14. parent_ticket_id = models.IntegerField('父工单id', default=0, help_text='与ticket.TicketRecord关联')
  15. parent_ticket_state_id = models.IntegerField('对应父工单状态id', default=0, help_text='与workflow.State关联,子工单是关联到父工单的某个状态下的')
  16. participant_type_id = models.IntegerField('当前处理人类型', default=0, help_text='0.无处理人,1.个人,2.多人,3.部门,4.角色')
  17. participant = models.CharField('当前处理人', max_length=100, default='', blank=True, help_text='可以为空(无处理人的情况,如结束状态)、username\多个username(以,隔开)\部门id\角色id\脚本文件名等')
  18. relation = models.CharField('工单关联人', max_length=1000, default='', blank=True, help_text='工单流转过程中将保存所有相关的人(包括创建人、曾经的待处理人),用于查询')
  19. in_add_node = models.BooleanField('加签状态中', default=False, help_text='是否处于加签状态下')
  20. add_node_man = models.CharField('加签人', max_length=50, default='', blank=True, help_text='加签操作的人,工单当前处理人处理完成后会回到该处理人,当处于加签状态下才有效')
  21. script_run_last_result = models.BooleanField(u'脚本最后一次执行结果', default=True)
  22. is_end = models.BooleanField('已结束', default=False, help_text='工单是否已处于结束状态')
  23. is_rejected = models.BooleanField('被拒绝', default=False, help_text='工单是否处于被拒绝状态')
  24. multi_all_person = models.CharField('全部处理的结果', max_length=1000, default='{}', blank=True, help_text='需要当前状态处理人全部处理时实际的处理结果,json格式')
  25. class Meta:
  26. verbose_name = '工单记录'
  27. verbose_name_plural = '工单记录'
  28. class TicketFlowLog(BaseModel):
  29. """
  30. 工单流转日志
  31. """
  32. ticket_id = models.IntegerField('工单id')
  33. transition_id = models.IntegerField('流转id', help_text='与worklow.Transition关联, 为0时表示认为干预的操作')
  34. suggestion = models.CharField('处理意见', max_length=1000, default='', blank=True)
  35. participant_type_id = models.IntegerField('处理人类型', help_text='见service.constant_service中定义')
  36. participant = models.CharField('处理人', max_length=50, default='', blank=True)
  37. state_id = models.IntegerField('当前状态id', default=0, blank=True)
  38. intervene_type_id = models.IntegerField('干预类型', default=0, help_text='0.非人为干预的流转,1.转交操作 2.加签操作 3.加签处理完成')
  39. ticket_data = models.CharField('工单数据', max_length=10000, default='', blank=True, help_text='可以用于记录当前表单数据,json格式')
  40. class Meta:
  41. verbose_name = '工单流转日志'
  42. verbose_name_plural = '工单流转日志'
  43. class TicketCustomField(BaseModel):
  44. """
  45. 工单自定义字段, 工单自定义字段实际的值。
  46. """
  47. name = models.CharField(u'字段名', max_length=50)
  48. field_key = models.CharField(u'字段标识', max_length=50)
  49. ticket_id = models.IntegerField(u'工单id')
  50. field_type_id = models.IntegerField(u'字段类型', help_text='见service.constant_service中定义')
  51. char_value = models.CharField('字符串值', max_length=1000, default='', blank=True)
  52. int_value = models.IntegerField('整形值', default=0, blank=True)
  53. float_value = models.FloatField('浮点值', default=0.0, blank=True)
  54. bool_value = models.BooleanField('布尔值', default=False, blank=True)
  55. # date_value = models.DateField('日期值', default='0001-01-01', blank=True)
  56. date_value = models.DateField('日期值', default=datetime.datetime.strptime('0001-01-01', "%Y-%m-%d"), blank=True)
  57. # datetime_value = models.DateTimeField('日期时间值', default='0001-01-01 00:00:00', blank=True)
  58. datetime_value = models.DateTimeField('日期时间值', default=datetime.datetime.strptime('0001-01-01 00:00:00', '%Y-%m-%d %H:%M:%S'), blank=True)
  59. # time_value = models.TimeField('时间值', default='00:00:01', blank=True)
  60. time_value = models.TimeField('时间值', default=datetime.datetime.strptime('00:00:01','%H:%M:%S'), blank=True)
  61. radio_value = models.CharField('radio值', default='', max_length=50, blank=True)
  62. checkbox_value = models.CharField('checkbox值', default='', max_length=50, blank=True, help_text='逗号隔开多个选项')
  63. select_value = models.CharField('下拉列表值', default='', max_length=50, blank=True)
  64. multi_select_value = models.CharField('多选下拉列表值', default='', max_length=50, blank=True, help_text='逗号隔开多个选项')
  65. text_value = models.TextField('文本值', default='', blank=True)
  66. username_value = models.CharField('用户名', max_length=50, default='', blank=True)
  67. multi_username_value = models.CharField('多选用户名', max_length=1000, default='', blank=True)
  68. class Meta:
  69. verbose_name = '工单自定义字段'
  70. verbose_name_plural = '工单自定义字段'