lz_data.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package data_manage
  2. import (
  3. "time"
  4. "eta/eta_api/global"
  5. "eta/eta_api/utils"
  6. )
  7. type LzClassify struct {
  8. BreedId int `gorm:"column:breed_id" description:"分类id"`
  9. BreedName string `gorm:"column:breed_name" description:"分类名称"`
  10. }
  11. func GetLzSurveyClassify() (items []*LzClassify, err error) {
  12. sql := `SELECT breed_id,breed_name FROM longzhong_survey_product GROUP BY breed_name ORDER BY breed_name DESC`
  13. o := global.DbMap[utils.DbNameManualIndex]
  14. err = o.Raw(sql).Find(&items).Error
  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 := global.DbMap[utils.DbNameManualIndex]
  23. err = o.Raw(sql, breedId).Find(&items).Error
  24. return
  25. }
  26. type LongzhongSurveyProduct struct {
  27. SurveyProductId int `gorm:"column:survey_product_id;primaryKey"`
  28. ProjectQuotaId int64 `gorm:"column:project_quota_id"`
  29. BreedId string `gorm:"column:breed_id"`
  30. BreedName string `gorm:"column:breed_name"`
  31. QuotaId string `gorm:"column:quota_id"`
  32. QuotaName string `gorm:"column:quota_name"`
  33. UnitId string `gorm:"column:unit_id"`
  34. UnitName string `gorm:"column:unit_name"`
  35. SampleType int64 `gorm:"column:sample_type"`
  36. SampleId string `gorm:"column:sample_id"`
  37. SampleName string `gorm:"column:sample_name"`
  38. DeviceId string `gorm:"column:device_id"`
  39. Device string `gorm:"column:device"`
  40. ProductCraftId string `gorm:"column:product_craft_id"`
  41. ProductCraft string `gorm:"column:product_craft"`
  42. ProductLine string `gorm:"column:product_line"`
  43. InputMode int64 `gorm:"column:input_mode"`
  44. Frequency int64 `gorm:"column:frequency"`
  45. InputValue string `gorm:"column:input_value"`
  46. TaskShouldFinishTime int `gorm:"column:task_should_finish_time"`
  47. CustomId string `gorm:"column:custom_id"`
  48. CustomType int64 `gorm:"column:custom_type"`
  49. Custom string `gorm:"column:custom"`
  50. QuotaSampleId int64 `gorm:"column:quota_sample_id"`
  51. StartDate string `gorm:"column:start_date"`
  52. EndDate string `gorm:"column:end_date"`
  53. ModifyTime time.Time `gorm:"column:modify_time"`
  54. LzCode string `gorm:"column:lz_code"`
  55. }
  56. func GetLongzhongSurveyProduct(breedId, frequency int) (items []*LongzhongSurveyProduct, err error) {
  57. sql := `SELECT * FROM longzhong_survey_product WHERE breed_id=? AND frequency=? ORDER BY survey_product_id ASC`
  58. o := global.DbMap[utils.DbNameManualIndex]
  59. err = o.Raw(sql, breedId, frequency).Find(&items).Error
  60. return
  61. }
  62. type LzProductList struct {
  63. SurveyProductId int `gorm:"column:survey_product_id;primaryKey"`
  64. BreedName string `gorm:"column:breed_name" description:"品种名称"`
  65. QuotaName string `gorm:"column:quota_name" description:"指标名称"`
  66. UnitName string `gorm:"column:unit_name" description:"单位"`
  67. SampleType int64 `gorm:"column:sample_type" description:"样本类型 0-空 1-企业 2-港口 3-运距 4-区域/国家 99-不确定"`
  68. SampleName string `gorm:"column:sample_name" description:"样本名称"`
  69. Device string `gorm:"column:device" description:"设备"`
  70. Frequency int64 `gorm:"column:frequency" description:"频度"`
  71. Custom string `gorm:"column:custom" description:"扩展字段"`
  72. StartDate string `gorm:"column:start_date" description:"开始日期"`
  73. EndDate string `gorm:"column:end_date" description:"结束日期"`
  74. ModifyTime string `gorm:"column:modify_time" description:"修改时间"`
  75. LzCode string `gorm:"column:lz_code" description:"指标编码"`
  76. DataList []*LzProductData `gorm:"-"`
  77. }
  78. type LzProductData struct {
  79. InputValue string `description:"日期"`
  80. DataTime string `description:"值"`
  81. }
  82. func GetLongzhongSurveyProductData(surveyProductId int) (items []*LzProductData, err error) {
  83. sql := `SELECT * FROM longzhong_survey_data WHERE survey_product_id=? ORDER BY data_time DESC`
  84. o := global.DbMap[utils.DbNameManualIndex]
  85. err = o.Raw(sql, surveyProductId).Find(&items).Error
  86. return
  87. }
  88. func GetLongzhongSurveyProductByCode(lzCode string) (items *LongzhongSurveyProduct, err error) {
  89. sql := `SELECT * FROM longzhong_survey_product WHERE lz_code=?`
  90. o := global.DbMap[utils.DbNameManualIndex]
  91. err = o.Raw(sql, lzCode).First(&items).Error
  92. return
  93. }