123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- package data_manage
- import (
- "eta/eta_api/utils"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type LzClassify struct {
- BreedId int `description:"分类id"`
- BreedName string `description:"分类名称"`
- }
- func GetLzSurveyClassify() (items []*LzClassify, err error) {
- sql := ` SELECT breed_id,breed_name FROM longzhong_survey_product GROUP BY breed_name ORDER BY breed_name DESC `
- o := orm.NewOrmUsingDB("edb")
- o.Raw(sql).QueryRows(&items)
- return
- }
- type LzFrequency struct {
- Frequency int `description:"频度:1-日度 2-周度 3-月度 4-季度 5-年度 99-无固定频率"`
- }
- func GetLzFrequencyByClassifyId(breedId int) (items []*LzFrequency, err error) {
- sql := ` SELECT frequency FROM longzhong_survey_product WHERE breed_id=? GROUP BY frequency ORDER BY frequency ASC `
- o := orm.NewOrmUsingDB("edb")
- _, err = o.Raw(sql, breedId).QueryRows(&items)
- return
- }
- // [2025-zsh-时间类型修复-chenhan]
- type LongzhongSurveyProduct struct {
- SurveyProductId int `orm:"column(survey_product_id);pk"`
- ProjectQuotaId int64
- BreedId string
- BreedName string
- QuotaId string
- QuotaName string
- UnitId string
- UnitName string
- SampleType int64
- SampleId string
- SampleName string
- DeviceId string
- Device string
- ProductCraftId string
- ProductCraft string
- ProductLine string
- InputMode int64
- Frequency int64
- InputValue string
- TaskShouldFinishTime int
- CustomId string
- CustomType int64
- Custom string
- QuotaSampleId int64
- StartDate string
- EndDate string
- ModifyTime time.Time
- LzCode string
- }
- type LongzhongSurveyProductOrm struct {
- SurveyProductId int `orm:"column(survey_product_id);pk"`
- ProjectQuotaId int64
- BreedId string
- BreedName string
- QuotaId string
- QuotaName string
- UnitId string
- UnitName string
- SampleType int64
- SampleId string
- SampleName string
- DeviceId string
- Device string
- ProductCraftId string
- ProductCraft string
- ProductLine string
- InputMode int64
- Frequency int64
- InputValue string
- TaskShouldFinishTime int
- CustomId string
- CustomType int64
- Custom string
- QuotaSampleId int64
- StartDate time.Time
- EndDate time.Time
- ModifyTime time.Time
- LzCode string
- }
- func (obj *LongzhongSurveyProductOrm) toView() *LongzhongSurveyProduct {
- return &LongzhongSurveyProduct{
- SurveyProductId: obj.SurveyProductId,
- ProjectQuotaId: obj.ProjectQuotaId,
- BreedId: obj.BreedId,
- BreedName: obj.BreedName,
- QuotaId: obj.QuotaId,
- QuotaName: obj.QuotaName,
- UnitId: obj.UnitId,
- UnitName: obj.UnitName,
- SampleType: obj.SampleType,
- SampleId: obj.SampleId,
- SampleName: obj.SampleName,
- DeviceId: obj.DeviceId,
- Device: obj.Device,
- ProductCraftId: obj.ProductCraftId,
- ProductCraft: obj.ProductCraft,
- ProductLine: obj.ProductLine,
- InputMode: obj.InputMode,
- Frequency: obj.Frequency,
- InputValue: obj.InputValue,
- TaskShouldFinishTime: obj.TaskShouldFinishTime,
- CustomId: obj.CustomId,
- CustomType: obj.CustomType,
- Custom: obj.Custom,
- QuotaSampleId: obj.QuotaSampleId,
- StartDate: obj.StartDate.Format(utils.FormatDate),
- EndDate: obj.EndDate.Format(utils.FormatDate),
- ModifyTime: obj.ModifyTime,
- LzCode: obj.LzCode,
- }
- }
- func ToLongzhongSurveyProductList(items []*LongzhongSurveyProductOrm) (itemsOrm []*LongzhongSurveyProduct) {
- for _, item := range items {
- itemsOrm = append(itemsOrm, item.toView())
- }
- return
- }
- func GetLongzhongSurveyProduct(breedId, frequency int) (items []*LongzhongSurveyProduct, err error) {
- sql := ` SELECT * FROM longzhong_survey_product WHERE breed_id=? AND frequency=? ORDER BY survey_product_id ASC `
- o := orm.NewOrmUsingDB("edb")
- _, err = o.Raw(sql, breedId, frequency).QueryRows(&items)
- return
- }
- type LzProductList struct {
- SurveyProductId int `orm:"column(survey_product_id);pk"`
- BreedName string `description:"品种名称"`
- QuotaName string `description:"指标名称"`
- UnitName string `description:"单位"`
- SampleType int64 `description:"样本类型 0-空 1-企业 2-港口 3-运距 4-区域/国家 99-不确定"`
- SampleName string `description:"样本名称"`
- Device string `description:"设备"`
- Frequency int64 `description:"频度"`
- Custom string `description:"扩展字段"`
- StartDate string `description:"开始日期"`
- EndDate string `description:"结束日期"`
- ModifyTime string `description:"修改时间"`
- LzCode string `description:"指标编码"`
- DataList []*LzProductData
- }
- type LzProductData struct {
- InputValue string `description:"日期"`
- DataTime string `description:"值"`
- }
- func GetLongzhongSurveyProductData(surveyProductId int) (items []*LzProductData, err error) {
- sql := ` SELECT * FROM longzhong_survey_data WHERE survey_product_id=? ORDER BY data_time DESC `
- o := orm.NewOrmUsingDB("edb")
- _, err = o.Raw(sql, surveyProductId).QueryRows(&items)
- return
- }
- func GetLongzhongSurveyProductByCode(lzCode string) (items *LongzhongSurveyProduct, err error) {
- sql := ` SELECT * FROM longzhong_survey_product WHERE lz_code=? `
- o := orm.NewOrmUsingDB("edb")
- err = o.Raw(sql, lzCode).QueryRow(&items)
- return
- }
|