run_process.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // ============================================================================
  2. // This is auto-generated by gf cli tool only once. Fill this file as you wish.
  3. // ============================================================================
  4. package wf_run_process
  5. import (
  6. "github.com/gogf/gf/database/gdb"
  7. "github.com/gogf/gf/errors/gerror"
  8. "github.com/gogf/gf/frame/g"
  9. "github.com/gogf/gf/util/gconv"
  10. )
  11. type SearchRunProcess struct {
  12. RunId uint `json:"run_id"`
  13. RunFlow uint `json:"run_flow"`
  14. RunFlowProcess string `json:"run_flow_process"`
  15. Status string `json:"status"`
  16. }
  17. type SaveRunProcessData struct {
  18. Uid uint `p:"uid" json:"uid"` //
  19. RunId uint `p:"run_id" json:"run_id"` // 当前流转id
  20. RunFlow uint `p:"run_flow" json:"run_flow"` // 属于那个流程的id
  21. RunFlowProcess uint `p:"run_flow_process" json:"run_flow_process"` // 当前步骤编号
  22. ParentFlow uint `p:"parent_flow" json:"parent_flow"` // 上一步流程
  23. ParentFlowProcess uint `p:"parent_flow_process" json:"parent_flow_process"` // 上一步骤号
  24. RunChild uint `p:"run_child" json:"run_child"` // 开始转入子流程run_id 如果转入子流程,则在这里也记录
  25. Remark string `p:"remark" json:"remark"` // 备注
  26. IsSponsor uint `p:"is_sponsor" json:"is_sponsor"` // 是否步骤主办人 0否(默认) 1是
  27. Status uint `p:"status" json:"status"` // 状态 0为未接收(默认),1为办理中 ,2为已转交,3为已结束4为已打回
  28. SponsorIds string `p:"sponsor_ids" json:"sponsor_ids"` //
  29. SponsorText string `p:"sponsor_text" json:"sponsor_text"` //
  30. AutoPerson int `p:"auto_person" json:"auto_person"` //
  31. JsTime uint `p:"js_time" json:"js_time"` // 接收时间
  32. Dateline uint `p:"dateline" json:"dateline"` //
  33. WfMode int `p:"wf_mode" json:"wf_mode"` //
  34. WfAction string `p:"wf_action" json:"wf_action"` //
  35. }
  36. //获取流程运行步骤信息列表
  37. func GetProcessList(where *SearchRunProcess) (list []*Entity, err error) {
  38. model := Model.Where(Columns.RunId, where.RunId).
  39. And(Columns.RunFlowProcess+" in (?) OR FIND_IN_SET("+Columns.RunFlowProcess+",?)", where.RunFlowProcess, where.RunFlowProcess)
  40. if where.RunFlow != 0 {
  41. model = model.And(Columns.RunFlow, where.RunFlow)
  42. }
  43. if where.Status != "" {
  44. model = model.And(Columns.Status, gconv.Int(where.Status))
  45. }
  46. list, err = model.FindAll()
  47. if err != nil {
  48. g.Log().Error(err)
  49. err = gerror.New("获取流程运行步骤列表信息失败")
  50. return
  51. }
  52. return
  53. }
  54. //获取流程运行步骤信息
  55. func GetProcess(where *SearchRunProcess) (info *Entity, err error) {
  56. model := Model.Where(Columns.RunId, where.RunId).
  57. And(Columns.RunFlowProcess+" in (?) OR FIND_IN_SET("+Columns.RunFlowProcess+",?)", where.RunFlowProcess, where.RunFlowProcess)
  58. if where.RunFlow != 0 {
  59. model = model.And(Columns.RunFlow, where.RunFlow)
  60. }
  61. if where.Status != "" {
  62. model = model.And(Columns.Status, gconv.Int(where.Status))
  63. }
  64. info, err = model.FindOne()
  65. if err != nil {
  66. g.Log().Error(err)
  67. err = gerror.New("获取流程运行步骤信息失败")
  68. return
  69. }
  70. return
  71. }
  72. func GetProcessByMap(where g.Map) (list []*Entity, err error) {
  73. list, err = Model.FindAll(where)
  74. if err != nil {
  75. g.Log().Error(err)
  76. err = gerror.New("获取流程运行步骤失败")
  77. }
  78. return
  79. }
  80. //通过id获取步骤运行信息
  81. func GetProcessById(id uint) (info *Entity, err error) {
  82. info, err = Model.FindOne(id)
  83. if err != nil {
  84. g.Log().Error(err)
  85. err = gerror.New("获取流程运转信息失败")
  86. }
  87. return
  88. }
  89. //获取本流程中小于ID的步骤信息
  90. func GetProcessLtId(where *Entity) (list []*Entity, err error) {
  91. list, err = Model.Where("id < ?", where.Id).Where("run_flow", where.RunFlow).
  92. Where("run_id", where.RunId).FindAll()
  93. if err != nil {
  94. g.Log().Error(err)
  95. err = gerror.New("获取小于指定步骤流程运转信息失败")
  96. }
  97. return
  98. }
  99. func Add(data *SaveRunProcessData, tx *gdb.TX) error {
  100. _, err := Model.TX(tx).Save(data)
  101. if err != nil {
  102. g.Log().Error(err)
  103. return gerror.New("保存流程步骤日志失败")
  104. }
  105. return nil
  106. }