edb_data_lz.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  4. )
  5. type lzSurveyData struct {
  6. DataTime string `orm:"column(data_time)" description:"日期"`
  7. InputValue string `orm:"column(input_value)" description:"值"`
  8. }
  9. type LongzhongSurveyData struct {
  10. SurveyDataId int `orm:"column(survey_data_id);pk"`
  11. SurveyProductId int
  12. ProjectQuotaId int64
  13. BreedId string
  14. BreedName string
  15. QuotaId string
  16. QuotaName string
  17. UnitId string
  18. UnitName string
  19. SampleType int64
  20. SampleId string
  21. SampleName string
  22. DeviceId string
  23. Device string
  24. ProductCraftId string
  25. ProductCraft string
  26. ProductLine string
  27. InputMode int64
  28. Frequency int64
  29. InputValue string
  30. TaskShouldFinishTime int64
  31. CustomId string
  32. CustomType int64
  33. Custom string
  34. QuotaSampleId int64
  35. TaskActualFinishTime int64
  36. AreaName string
  37. ProvinceName string
  38. ResearchStartData int64
  39. ResearchStopData int64
  40. DataTime string
  41. }
  42. func GetLzSurveyDataByTradeCode(condition string, pars []interface{}) (item []*lzSurveyData, err error) {
  43. sql := ` SELECT a.* FROM longzhong_survey_data AS a
  44. INNER JOIN longzhong_survey_product AS b ON a.survey_product_id=b.survey_product_id
  45. WHERE 1=1 `
  46. //o := orm.NewOrm()
  47. if condition != "" {
  48. sql += condition
  49. }
  50. sql += ` ORDER BY a.data_time DESC `
  51. //_, err = o.Raw(sql, pars).QueryRows(&item)
  52. err = global.DEFAULT_DmSQL.Raw(sql, pars).Find(&item).Error
  53. return
  54. }
  55. func GetLzSurveyDataExistByTradeCode(surveyProductId int) (items []*LongzhongSurveyData, err error) {
  56. sql := ` SELECT * FROM longzhong_survey_data WHERE 1=1 AND survey_product_id=? `
  57. //o := orm.NewOrm()
  58. //_, err = o.Raw(sql, surveyProductId).QueryRows(&items)
  59. err = global.DEFAULT_DmSQL.Raw(sql, surveyProductId).Find(&items).Error
  60. return
  61. }
  62. func GetEdbDataLzByCodeAndDate(edbCode string, startDate string) (count int, err error) {
  63. //o := orm.NewOrm()
  64. sql := ` SELECT COUNT(1) AS count FROM edb_data_lz WHERE edb_code=? AND data_time=? `
  65. //err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
  66. err = global.DEFAULT_DmSQL.Raw(sql, edbCode, startDate).Scan(&count).Error
  67. return
  68. }
  69. func ModifyEdbDataLz(edbInfoId int64, dataTime, value string) (err error) {
  70. //o := orm.NewOrm()
  71. sql := ` UPDATE edb_data_lz SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
  72. //_, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
  73. err = global.DEFAULT_DmSQL.Exec(sql, value, edbInfoId, dataTime).Error
  74. return
  75. }