data_entry.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package models
  2. import "github.com/beego/beego/v2/client/orm"
  3. //数据录入
  4. type EdbInfo struct {
  5. UserId int
  6. SecName string `orm:"column(SEC_NAME);" description:"指标名称"`
  7. NoticeTime string
  8. Frequency string
  9. TradeCode string `orm:"column(TRADE_CODE);" description:"指标编码"`
  10. }
  11. //获取日度指标
  12. func GetEdbInfoByFrequency(frequency string) (items []*EdbInfo, err error) {
  13. sql := `SELECT * FROM edbinfo WHERE frequency=? AND notice_time<>'' `
  14. o := orm.NewOrmUsingDB("edb")
  15. _, err = o.Raw(sql, frequency).QueryRows(&items)
  16. return
  17. }
  18. //获取日度指标
  19. func GetEdbInfoByFrequencyWeek(frequency, weekDay string) (items []*EdbInfo, err error) {
  20. sql := `SELECT * FROM edbinfo WHERE frequency=? AND notice_time<>'' AND left(notice_time,2)=? `
  21. o := orm.NewOrmUsingDB("edb")
  22. _, err = o.Raw(sql, frequency, weekDay).QueryRows(&items)
  23. return
  24. }
  25. func GetEdbdataCount(tradeCode, nowDate string) (count int, err error) {
  26. sql := `SELECT COUNT(1) AS count FROM edbdata WHERE TRADE_CODE=? AND DT=? `
  27. o := orm.NewOrmUsingDB("edb")
  28. err = o.Raw(sql, tradeCode, nowDate).QueryRow(&count)
  29. return
  30. }
  31. // GetEdbInfoByFrequencyNotDay 获取频度非日度 且 提醒时间不为空 的指标数据
  32. func GetEdbInfoByFrequencyNotDay() (items []*EdbInfo, err error) {
  33. sql := `SELECT * FROM edbinfo WHERE frequency!="日度" AND notice_time<>'' and user_id>0 `
  34. o := orm.NewOrmUsingDB("edb")
  35. _, err = o.Raw(sql).QueryRows(&items)
  36. return
  37. }