smart_report.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package models
  2. import (
  3. "eta_gn/eta_task/global"
  4. "fmt"
  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. err = global.DmSQL["rddp"].Select(cols).Updates(m).Error
  49. return
  50. }
  51. func (m *SmartReport) GetItemById(id int) (item *SmartReport, err error) {
  52. //o := orm.NewOrmUsingDB("rddp")
  53. //sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  54. //err = o.Raw(sql, id).QueryRow(&item)
  55. sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  56. err = global.DmSQL["rddp"].Raw(sql, id).Find(&item).Error
  57. return
  58. }
  59. // GetPrePublishSmartReports 获取定时发布时间为当前时间的未发布的报告列表
  60. func GetPrePublishSmartReports(startTime, endTime string) (list []*SmartReport, err error) {
  61. //o := orm.NewOrmUsingDB("rddp")
  62. //sql := `SELECT * FROM smart_report WHERE state = 1 AND pre_publish_time >= ? AND pre_publish_time <= ?`
  63. //_, err = o.Raw(sql, startTime, endTime).QueryRows(&list)
  64. sql := `SELECT * FROM smart_report WHERE state = 1 AND pre_publish_time >= ? AND pre_publish_time <= ?`
  65. err = global.DmSQL["rddp"].Raw(sql, startTime, endTime).Find(&list).Error
  66. return
  67. }
  68. // PublishSmartReportById 发布智能报告
  69. func PublishSmartReportById(reportId int, publishTime time.Time) (err error) {
  70. //o := orm.NewOrmUsingDB("rddp")
  71. //sql := `UPDATE smart_report SET state = 2, publish_time = ?, msg_is_send = 1, msg_send_time = NOW(), modify_time = NOW() WHERE smart_report_id = ?`
  72. //_, err = o.Raw(sql, publishTime, reportId).Exec()
  73. sql := `UPDATE smart_report SET state = 2, publish_time = ?, msg_is_send = 1, msg_send_time = NOW(), modify_time = NOW() WHERE smart_report_id = ?`
  74. err = global.DmSQL["rddp"].Exec(sql, publishTime, reportId).Error
  75. return
  76. }
  77. // ElasticSmartReport 智能研报es
  78. type ElasticSmartReport struct {
  79. SmartReportId int `description:"智能研报ID"`
  80. Title string `description:"标题"`
  81. Abstract string `description:"摘要"`
  82. BodyContent string `description:"内容"`
  83. PublishTime string `description:"发布时间"`
  84. PublishState int `description:"发布状态 1-未发布 2-已发布"`
  85. Author string `description:"作者"`
  86. ClassifyIdFirst int `description:"一级分类ID"`
  87. ClassifyNameFirst string `description:"一级分类名称"`
  88. ClassifyIdSecond int `description:"二级分类ID"`
  89. ClassifyNameSecond string `description:"二级分类名称"`
  90. StageStr string `description:"报告期数"`
  91. Frequency string `description:"频度"`
  92. }
  93. // Report2ImgQueueReq 报告详情生成长图队列请求体
  94. type Report2ImgQueueReq struct {
  95. ReportType int `description:"报告类型: 1-研报; 2-智能研报"`
  96. ReportCode string `description:"报告唯一编码"`
  97. }