smart_report.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package models
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. // SmartReport 智能研报
  8. type SmartReport struct {
  9. SmartReportId int `orm:"column(smart_report_id)" description:"智能研报ID"`
  10. ReportCode string `description:"报告唯一编码"`
  11. ClassifyIdFirst int `description:"一级分类ID"`
  12. ClassifyNameFirst string `description:"一级分类名称"`
  13. ClassifyIdSecond int `description:"二级分类ID"`
  14. ClassifyNameSecond string `description:"二级分类名称"`
  15. AddType int `description:"新增方式:1-新增报告;2-继承报告"`
  16. Title string `description:"标题"`
  17. Abstract string `description:"摘要"`
  18. Author string `description:"作者"`
  19. Frequency string `description:"频度"`
  20. Stage int `description:"期数"`
  21. Content string `description:"内容"`
  22. ContentSub string `description:"内容前两个章节"`
  23. ContentStruct string `description:"内容组件"`
  24. VideoUrl string `description:"音频文件URL"`
  25. VideoName string `description:"音频文件名称"`
  26. VideoPlaySeconds string `description:"音频播放时长"`
  27. VideoSize string `description:"音频文件大小,单位M"`
  28. AdminId int `description:"创建者ID"`
  29. AdminRealName string `description:"创建者姓名"`
  30. State int `description:"发布状态:1-待发布;2-已发布"`
  31. PublishTime time.Time `description:"发布时间"`
  32. PrePublishTime time.Time `description:"预发布时间"`
  33. PreMsgSend int `description:"定时发布后是否推送模版消息:0-否;1-是"`
  34. MsgIsSend int `description:"消息是否已发送:0-否;1-是"`
  35. MsgSendTime time.Time `description:"模版消息发送时间"`
  36. CreateTime time.Time `description:"创建时间"`
  37. ModifyTime time.Time `description:"修改时间"`
  38. }
  39. func (m *SmartReport) TableName() string {
  40. return "smart_report"
  41. }
  42. func (m *SmartReport) PrimaryId() string {
  43. return "smart_report_id"
  44. }
  45. func (m *SmartReport) Update(cols []string) (err error) {
  46. o := orm.NewOrmUsingDB("rddp")
  47. _, err = o.Update(m, cols...)
  48. return
  49. }
  50. func (m *SmartReport) GetItemById(id int) (item *SmartReport, err error) {
  51. o := orm.NewOrmUsingDB("rddp")
  52. sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  53. err = o.Raw(sql, id).QueryRow(&item)
  54. return
  55. }
  56. // GetPrePublishSmartReports 获取定时发布时间为当前时间的未发布的报告列表
  57. func GetPrePublishSmartReports(startTime, endTime string) (list []*SmartReport, err error) {
  58. o := orm.NewOrmUsingDB("rddp")
  59. sql := `SELECT * FROM smart_report WHERE state = 1 AND pre_publish_time >= ? AND pre_publish_time <= ?`
  60. _, err = o.Raw(sql, startTime, endTime).QueryRows(&list)
  61. return
  62. }
  63. // PublishSmartReportById 发布智能报告
  64. func PublishSmartReportById(reportId int, publishTime time.Time) (err error) {
  65. o := orm.NewOrmUsingDB("rddp")
  66. sql := `UPDATE smart_report SET state = 2, publish_time = ?, msg_is_send = 1, msg_send_time = NOW(), modify_time = NOW() WHERE smart_report_id = ?`
  67. _, err = o.Raw(sql, publishTime, reportId).Exec()
  68. return
  69. }
  70. // ElasticSmartReport 智能研报es
  71. type ElasticSmartReport struct {
  72. SmartReportId int `description:"智能研报ID"`
  73. Title string `description:"标题"`
  74. Abstract string `description:"摘要"`
  75. BodyContent string `description:"内容"`
  76. PublishTime string `description:"发布时间"`
  77. PublishState int `description:"发布状态 1-未发布 2-已发布"`
  78. Author string `description:"作者"`
  79. ClassifyIdFirst int `description:"一级分类ID"`
  80. ClassifyNameFirst string `description:"一级分类名称"`
  81. ClassifyIdSecond int `description:"二级分类ID"`
  82. ClassifyNameSecond string `description:"二级分类名称"`
  83. StageStr string `description:"报告期数"`
  84. Frequency string `description:"频度"`
  85. }
  86. // Report2ImgQueueReq 报告详情生成长图队列请求体
  87. type Report2ImgQueueReq struct {
  88. ReportType int `description:"报告类型: 1-研报; 2-智能研报"`
  89. ReportCode string `description:"报告唯一编码"`
  90. }