123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package data_manage
- import (
- "eta/eta_task/utils"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type EdbUpdateLog struct {
- Id int64 `json:"id" orm:"column(id);pk"`
- OpDbName string `json:"op_db_name"` // 库名
- OpTableName string `json:"op_table_name"` // 表名
- OpType string `json:"op_type"` // 变更类型
- OldData string `json:"old_data"` // 历史数据
- NewData string `json:"new_data"` // 新数据
- IsHandle int `json:"is_handle"` // 是否处理,0:未处理,1:已处理;默认:0
- ModifyTime time.Time `json:"modify_time"`
- CreateTime time.Time `json:"create_time"`
- }
- // GetEdbUpdateLogMaxId
- // @Description: 获取最大的数据id
- // @author: Roc
- // @datetime 2024-03-07 18:38:23
- // @param condition string
- // @param pars []interface{}
- // @return maxId int
- // @return err error
- func GetEdbUpdateLogMaxId() (maxId int64, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT id FROM edb_update_log WHERE 1=1 ORDER BY id desc limit 1 `
- err = o.Raw(sql).QueryRow(&maxId)
- return
- }
- // GetEdbUpdateLogMaxHandleId
- // @Description: 获取已经操作了的最大的数据id
- // @author: Roc
- // @datetime 2024-03-08 17:53:29
- // @return maxId int64
- // @return err error
- func GetEdbUpdateLogMaxHandleId() (maxId int64, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT id FROM edb_update_log WHERE 1=1 AND is_handle = 1 ORDER BY id desc limit 1 `
- err = o.Raw(sql).QueryRow(&maxId)
- return
- }
- // GetEdbUpdateLogByCondition
- // @Description: 获取指标更新列表
- // @author: Roc
- // @datetime 2024-03-07 18:36:44
- // @param condition string
- // @param pars []interface{}
- // @return item []*EdbUpdateLog
- // @return err error
- func GetEdbUpdateLogByCondition(condition string, pars []interface{}) (item []*EdbUpdateLog, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM edb_update_log WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- sql += ` ORDER BY id ASC limit 500 `
- _, err = o.Raw(sql, pars).QueryRows(&item)
- return
- }
- // HandleUpdateLogByIds
- // @Description: 批量处理指标更新记录
- // @author: Roc
- // @datetime 2024-03-08 17:30:52
- // @param idList []int
- // @return err error
- func HandleUpdateLogByIds(idList []int64, modifyTime string) (err error) {
- num := len(idList)
- if num <= 0 {
- return
- }
- o := orm.NewOrmUsingDB("data")
- sql := ` UPDATE edb_update_log set is_handle=1 ,modify_time = ? WHERE id in (` + utils.GetOrmInReplace(num) + `) `
- _, err = o.Raw(sql, modifyTime, idList).Exec()
- return
- }
- type EdbInfoItem struct {
- CalculateFormula string `json:"calculate_formula"`
- Calendar string `json:"calendar"`
- ChartImage string `json:"chart_image"`
- ClassifyId int `json:"classify_id"`
- CreateTime string `json:"create_time"`
- DataDateType string `json:"data_date_type"`
- DataUpdateTime string `json:"data_update_time"`
- EdbCode string `json:"edb_code"`
- EdbInfoId int `json:"edb_info_id"`
- EdbInfoType int `json:"edb_info_type"`
- EdbName string `json:"edb_name"`
- EdbNameEn string `json:"edb_name_en"`
- EdbNameSource string `json:"edb_name_source"`
- EdbType int `json:"edb_type"`
- EmptyType int `json:"empty_type"`
- EndDate string `json:"end_date"`
- EndValue float64 `json:"end_value"`
- ErDataUpdateDate string `json:"er_data_update_date"`
- Extra string `json:"extra"`
- Frequency string `json:"frequency"`
- IndicatorCode string `json:"indicator_code"`
- IsUpdate int `json:"is_update"`
- LatestDate string `json:"latest_date"`
- LatestValue float64 `json:"latest_value"`
- ManualSave int `json:"manual_save"`
- MaxEmptyType int `json:"max_empty_type"`
- MaxValue float64 `json:"max_value"`
- MinValue float64 `json:"min_value"`
- ModifyTime string `json:"modify_time"`
- MoveFrequency string `json:"move_frequency"`
- MoveType int `json:"move_type"`
- NoUpdate int `json:"no_update"`
- ServerUrl string `json:"server_url"`
- Sort int `json:"sort"`
- Source int `json:"source"`
- SourceIndexName string `json:"source_index_name"`
- SourceName string `json:"source_name"`
- StartDate string `json:"start_date"`
- StockCode string `json:"stock_code"`
- SubSource int `json:"sub_source"`
- SubSourceName string `json:"sub_source_name"`
- SysUserId int `json:"sys_user_id"`
- SysUserRealName string `json:"sys_user_real_name"`
- TerminalCode string `json:"terminal_code"`
- UniqueCode string `json:"unique_code"`
- Unit string `json:"unit"`
- UnitEn string `json:"unit_en"`
- }
- type EdbData struct {
- EdbDataId int32 `orm:"column(edb_data_id);pk" json:"edb_data_id"`
- EdbInfoId int32 `json:"edb_info_id"` // 指标id
- EdbCode string `json:"edb_code"` // 指标编码
- //DataTime time.Time `json:"data_time"` // 数据日期
- DataTime string `json:"data_time"` // 数据日期
- Value float64 `json:"value"` // 数据值
- //CreateTime time.Time `json:"create_time"` // 创建时间
- //ModifyTime time.Time `json:"modify_time"` // 修改时间
- CreateTime string `json:"create_time"` // 创建时间
- ModifyTime string `json:"modify_time"` // 修改时间
- DataTimestamp int64 `json:"data_timestamp"` // 数据日期时间戳
- }
|