lz_data.go 3.5 KB

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