123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "hongze/hongze_edb_lib/utils"
- "time"
- )
- type PredictEdbConf struct {
- PredictEdbInfoId int `orm:"column(predict_edb_info_id);pk" description:"预测指标id"`
- SourceEdbInfoId int `description:"来源指标id"`
- RuleType int `description:"预测规则,1:最新,2:固定值"`
- FixedValue float64 `description:"固定值"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"添加时间"`
- }
- func GetPredictEdbConfById(edbInfoId int) (item *PredictEdbConf, err error) {
- o := orm.NewOrm()
- sql := ` SELECT * FROM predict_edb_conf WHERE predict_edb_info_id=? `
- err = o.Raw(sql, edbInfoId).QueryRow(&item)
- return
- }
- func GetPredictEdbConfCount(sourceEdbInfoId int) (count int, err error) {
- o := orm.NewOrm()
- sql := ` SELECT COUNT(1) AS count FROM predict_edb_conf WHERE source_edb_info_id=? `
- err = o.Raw(sql, sourceEdbInfoId).QueryRow(&count)
- return
- }
- func ModifyPredictEdbInfoMaxAndMinInfoBySourceEdbInfoId(sourceEdbInfoId int, item *EdbInfoMaxAndMinInfo) (err error) {
- o := orm.NewOrm()
- var list []*PredictEdbConf
- sql := ` SELECT * FROM predict_edb_conf WHERE source_edb_info_id=? `
- total, err := o.Raw(sql, sourceEdbInfoId).QueryRows(&list)
- if err != nil {
- return
- }
- if total > 0 {
- idList := make([]int, 0)
- for _, v := range list {
- idList = append(idList, v.PredictEdbInfoId)
- }
- sql := ` UPDATE edb_info SET start_date=?,min_value=?,max_value=?,is_update=2,latest_date=?,latest_value=?,modify_time=NOW() WHERE edb_info_id in (` + utils.GetOrmInReplace(int(total)) + `) `
- _, err = o.Raw(sql, item.MinDate, item.MinValue, item.MaxValue, item.MaxDate, item.LatestValue, idList).Exec()
- }
- return
- }
|