12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package data_manage
- import (
- "eta/eta_mobile/utils"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type EdbDataCalculate struct {
- EdbDataId int `orm:"column(edb_data_id);pk"`
- EdbInfoId int
- EdbCode string
- DataTime string
- Value float64
- Status int
- CreateTime time.Time
- ModifyTime time.Time
- DataTimestamp int64
- }
- func AddEdbDataCalculate(items []*EdbDataCalculate) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.InsertMulti(1, items)
- return
- }
- func AddEdbDataCalculateBySql(sqlStr string) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Raw(sqlStr).Exec()
- return
- }
- func ModifyEdbDataCalculate(edbInfoId int64, dataTime string, value float64) (err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` UPDATE edb_data_calculate SET value=?,modify_time=NOW() WHERE edb_info_id=? AND data_time=? `
- _, err = o.Raw(sql, value, edbInfoId, dataTime).Exec()
- return
- }
- func GetEdbDataCalculateByCodeAndDate(edbCode string, startDate string) (count int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT COUNT(1) AS count FROM edb_data_calculate WHERE edb_code=? AND data_time=? `
- err = o.Raw(sql, edbCode, startDate).QueryRow(&count)
- return
- }
- func GetAddSql(edbInfoId, edbCode, dataTime, timestampStr string, value string) (addSql string) {
- nowStr := time.Now().Format(utils.FormatDateTime)
- addSql += "("
- addSql += edbInfoId + "," + "'" + edbCode + "'" + "," + "'" + dataTime + "'" + "," + value + "," + "'" + nowStr + "'" +
- "," + "'" + nowStr + "'" + "," + "1"
- addSql += "," + "'" + timestampStr + "'"
- addSql += "),"
- return
- }
|