ht_report.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package ht
  2. import (
  3. "eta/eta_mini_ht_api/models"
  4. "time"
  5. )
  6. type HTReport struct {
  7. Id int `gorm:"primary_key;auto_increment"`
  8. PlateId int `grom:"plate_id"`
  9. PlateName string `gorm:"column:plate_name"`
  10. PermissionName string `gorm:"column:permission_name"`
  11. PublishUserName string `gorm:"column:publish_user_name"`
  12. ReportName string `gorm:"column:report_name"`
  13. PublishTime int `gorm:"column:publish_time"`
  14. PublishedTime string `gorm:"column:published_time"`
  15. }
  16. func GetHTReports(id int) (reports []HTReport, err error) {
  17. db := models.HT()
  18. sql := "select 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 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"
  19. err = db.Model(&HTReport{}).Raw(sql, id).Scan(&reports).Error
  20. return
  21. }
  22. func GetUpdateHTReports() (reports []HTReport, err error) {
  23. duration := time.Now().Add(-30 * time.Second)
  24. updateTime := duration.UnixMilli()
  25. db := models.HT()
  26. sql := "select 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 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.update_time > ? order by t.id asc"
  27. err = db.Model(&HTReport{}).Raw(sql, updateTime).Scan(&reports).Error
  28. return
  29. }
  30. func GetPDFUrl(id int) (url string, err error) {
  31. db := models.HT()
  32. sql := "select report_file_path from t_iirp_report_info where id=?"
  33. err = db.Model(&HTReport{}).Raw(sql, id).Scan(&url).Error
  34. return
  35. }
  36. type HtQuery struct {
  37. Plate string
  38. Permission string
  39. }
  40. func GetHTReportIdsByPermissionIds(query []HtQuery) (ids []int, err error) {
  41. return
  42. }