ht_report.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package ht
  2. import (
  3. "eta/eta_mini_ht_api/models"
  4. "time"
  5. )
  6. const (
  7. Publish = 3
  8. limit = 50
  9. )
  10. type HTReport struct {
  11. Id int `gorm:"primary_key;auto_increment"`
  12. PlateId int `grom:"plate_id"`
  13. PlateName string `gorm:"column:plate_name"`
  14. PermissionName string `gorm:"column:permission_name"`
  15. PublishUserName string `gorm:"column:publish_user_name"`
  16. ReportName string `gorm:"column:report_name"`
  17. PublishTime int `gorm:"column:publish_time"`
  18. PublishedTime string `gorm:"column:published_time"`
  19. IsDelete int `gorm:"column:is_delete"`
  20. Status int `gorm:"column:status"`
  21. }
  22. func GetHTReports(id int) (reports []HTReport, err error) {
  23. db := models.HT()
  24. sql := "select distinct t.id as id,tirtp.plate_id as plate_id, tip.plate_name as plate_name, t.id as id ,t.report_name as report_name,t.publish_user_name as publish_user_name,t.publish_time as publish_time,t.is_delete as is_delete,t.status as status from t_iirp_report_to_plate tirtp left join t_iirp_report_info t on t.id=tirtp.report_id left JOIN t_iirp_plate tip on tip.id=tirtp.plate_id where t.is_delete =0 and t.`status` =3 and t.report_file_path<>'' and t.id > ? order by t.id asc limit 0,?"
  25. err = db.Model(&HTReport{}).Raw(sql, id, limit).Scan(&reports).Error
  26. return
  27. }
  28. func GetUpdateHTReports() (reports []HTReport, err error) {
  29. duration := time.Now().Add(-30 * time.Second)
  30. updateTime := duration.UnixMilli()
  31. db := models.HT()
  32. sql := "select distinct t.id as id, tirtp.plate_id as plate_id, tip.plate_name as plate_name, t.id as id ,t.report_name as report_name,t.publish_user_name as publish_user_name,t.publish_time as publish_time,t.is_delete as is_delete,t.status as status from t_iirp_report_to_plate tirtp left join t_iirp_report_info t on t.id=tirtp.report_id left JOIN t_iirp_plate tip on tip.id=tirtp.plate_id where t.report_file_path<>'' and t.update_time > ? order by t.id asc"
  33. err = db.Model(&HTReport{}).Raw(sql, updateTime).Scan(&reports).Error
  34. return
  35. }
  36. func GetPDFUrl(id int) (url string, err error) {
  37. db := models.HT()
  38. sql := "select report_file_path from t_iirp_report_info where id=?"
  39. err = db.Model(&HTReport{}).Raw(sql, id).Scan(&url).Error
  40. return
  41. }
  42. type HtQuery struct {
  43. Plate string
  44. Permission string
  45. }
  46. func GetHTReportIdsByPermissionIds(query []HtQuery) (ids []int, err error) {
  47. return
  48. }