12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package data_manage
- import (
- "eta/eta_task/utils"
- "github.com/beego/beego/v2/client/orm"
- )
- type BaseFromMysteelChemicalIndexItem struct {
- BaseFromMysteelChemicalIndexId int32 `json:"base_from_mysteel_chemical_index_id"`
- BaseFromMysteelChemicalClassifyId int32 `json:"base_from_mysteel_chemical_classify_id"` // 钢联化工指标分类id
- IndexCode string `json:"index_code"` // 指标编码
- IndexName string `json:"index_name"` // 指标名称
- Unit string `json:"unit"` // 单位
- Source string `json:"source"` // 数据来源
- Frequency string `json:"frequency"` // 频度
- StartDate string `json:"start_date"` // 开始日期
- EndDate string `json:"end_date"` // 结束日期
- Describe string `json:"describe"` // 指标描述
- UpdateWeek string `json:"update_week"` // 更新周期
- UpdateTime string `json:"update_time"` // 更新时间,多个时间点用英文,隔开
- UpdateTime2 string `json:"update_time2"` // 更新时间2
- SysUserId int32 `json:"sys_user_id"` // 创建人id
- SysUserRealName string `json:"sys_user_real_name"` // 创建人姓名
- CreateTime string `json:"create_time"` // 创建时间
- ModifyTime string `json:"modify_time"` // 修改时间
- FilePath string `json:"file_path"` // 文件存储路径
- Sort int32 `json:"sort"` // 排序
- MergeFilePath string `json:"merge_file_path"`
- FileIndex int32 `json:"file_index"`
- MergeUpdateWeek string `json:"merge_update_week"` // 合并文件的更新周
- MergeFilePathWeek string `json:"merge_file_path_week"` // 更新文件
- UpdateDate string `json:"update_date"` // 更新日期
- IsRefresh int32 `json:"is_refresh"` // 0:不需要及时刷新,1:需要及时刷新
- IsStop int32 `json:"is_stop"` // 是否停更:1:停更,0:未停更
- TerminalCode string `json:"terminal_code"` // 所属终端编码
- EndValue float64 `json:"end_value"` // 指标的最新值
- EdbInfoId int `json:"edb_info_id"`
- }
- // GetBaseFromMysteelChemicalIndexItemByCode
- // @Description: 根据指标编码获取钢联指标详情
- // @author: Roc
- // @datetime 2024-03-11 16:42:56
- // @param edbCode string
- // @return item *BaseFromMysteelChemicalIndexItem
- // @return err error
- func GetBaseFromMysteelChemicalIndexItemByCode(edbCode string) (item *BaseFromMysteelChemicalIndexItem, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM base_from_mysteel_chemical_index WHERE index_code = ?`
- err = o.Raw(sql, edbCode).QueryRow(&item)
- return
- }
- func GetBaseFromMysteelChemicalIndexItems(frequencyList []string) (items []*BaseFromMysteelChemicalIndexItem, err error) {
- num := len(frequencyList)
- if num == 0 {
- return
- }
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT b.*, e.edb_info_id FROM base_from_mysteel_chemical_index AS b
- LEFT JOIN edb_info AS e
- ON b.index_code = e.edb_code
- WHERE b.source='api' AND b.frequency IN (` + utils.GetOrmInReplace(len(frequencyList)) + `)`
- _, err = o.Raw(sql, frequencyList).QueryRows(&items)
- return
- }
- // GetRefreshBaseFromMysteelChemicalIndexItemByCreateTime 获取正常刷新的钢联化工指标
- func GetRefreshBaseFromMysteelChemicalIndexItemByCreateTime(endDate string, startPage, pageSize int) (items []*BaseFromMysteelChemicalIndexItem, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM base_from_mysteel_chemical_index WHERE is_stop = 0 and create_time < ? Limit ?,?`
- _, err = o.Raw(sql, endDate, startPage, pageSize).QueryRows(&items)
- return
- }
- // GetCountRefreshBaseFromMysteelChemicalIndexItemByCreateTime 获取正常刷新的钢联化工指标
- func GetCountRefreshBaseFromMysteelChemicalIndexItemByCreateTime(endDate string) (total int64, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT count(*) FROM base_from_mysteel_chemical_index WHERE is_stop = 0 and create_time < ?`
- err = o.Raw(sql, endDate).QueryRow(&total)
- return
- }
- func SetStopRefreshMysteelChemicalIndex(ids []int32) (err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` UPDATE base_from_mysteel_chemical_index SET is_stop = 1 WHERE base_from_mysteel_chemical_index_id IN (` + utils.GetOrmInReplace(len(ids)) + `) and is_stop=0`
- _, err = o.Raw(sql, ids).Exec()
- return
- }
|