lz_data.go 4.3 KB

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