lz_data.go 3.4 KB

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