lz_data.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type LzClassify struct {
  7. BreedId int `description:"分类id"`
  8. BreedName string `description:"分类名称"`
  9. }
  10. func GetLzSurveyClassify() (items []*LzClassify, err error) {
  11. sql := ` SELECT breed_id,breed_name FROM longzhong_survey_product GROUP BY breed_name ORDER BY breed_name DESC `
  12. o := orm.NewOrmUsingDB("edb")
  13. o.Raw(sql).QueryRows(&items)
  14. return
  15. }
  16. type LzFrequency struct {
  17. Frequency int `description:"频度:1-日度 2-周度 3-月度 4-季度 5-年度 99-无固定频率"`
  18. }
  19. func GetLzFrequencyByClassifyId(breedId int) (items []*LzFrequency, err error) {
  20. sql := ` SELECT frequency FROM longzhong_survey_product WHERE breed_id=? GROUP BY frequency ORDER BY frequency ASC `
  21. o := orm.NewOrmUsingDB("edb")
  22. _, err = o.Raw(sql, breedId).QueryRows(&items)
  23. return
  24. }
  25. type LongzhongSurveyProduct struct {
  26. SurveyProductId int `orm:"column(survey_product_id);pk"`
  27. ProjectQuotaId int64
  28. BreedId string
  29. BreedName string
  30. QuotaId string
  31. QuotaName string
  32. UnitId string
  33. UnitName string
  34. SampleType int64
  35. SampleId string
  36. SampleName string
  37. DeviceId string
  38. Device string
  39. ProductCraftId string
  40. ProductCraft string
  41. ProductLine string
  42. InputMode int64
  43. Frequency int64
  44. InputValue string
  45. TaskShouldFinishTime int
  46. CustomId string
  47. CustomType int64
  48. Custom string
  49. QuotaSampleId int64
  50. StartDate string
  51. EndDate string
  52. ModifyTime time.Time
  53. LzCode string
  54. }
  55. func GetLongzhongSurveyProduct(breedId, frequency int) (items []*LongzhongSurveyProduct, err error) {
  56. sql := ` SELECT * FROM longzhong_survey_product WHERE breed_id=? AND frequency=? ORDER BY survey_product_id ASC `
  57. o := orm.NewOrmUsingDB("edb")
  58. _, err = o.Raw(sql, breedId, frequency).QueryRows(&items)
  59. return
  60. }
  61. type LzProductList struct {
  62. SurveyProductId int `orm:"column(survey_product_id);pk"`
  63. BreedName string `description:"品种名称"`
  64. QuotaName string `description:"指标名称"`
  65. UnitName string `description:"单位"`
  66. SampleType int64 `description:"样本类型 0-空 1-企业 2-港口 3-运距 4-区域/国家 99-不确定"`
  67. SampleName string `description:"样本名称"`
  68. Device string `description:"设备"`
  69. Frequency int64 `description:"频度"`
  70. Custom string `description:"扩展字段"`
  71. StartDate string `description:"开始日期"`
  72. EndDate string `description:"结束日期"`
  73. ModifyTime string `description:"修改时间"`
  74. LzCode string `description:"指标编码"`
  75. DataList []*LzProductData
  76. }
  77. type LzProductData struct {
  78. InputValue string `description:"日期"`
  79. DataTime string `description:"值"`
  80. }
  81. func GetLongzhongSurveyProductData(surveyProductId int) (items []*LzProductData, err error) {
  82. sql := ` SELECT * FROM longzhong_survey_data WHERE survey_product_id=? ORDER BY data_time DESC `
  83. o := orm.NewOrmUsingDB("edb")
  84. _, err = o.Raw(sql, surveyProductId).QueryRows(&items)
  85. return
  86. }
  87. func GetLongzhongSurveyProductByCode(lzCode string) (items *LongzhongSurveyProduct, err error) {
  88. sql := ` SELECT * FROM longzhong_survey_product WHERE lz_code=? `
  89. o := orm.NewOrmUsingDB("edb")
  90. err = o.Raw(sql, lzCode).QueryRow(&items)
  91. return
  92. }