package data_manage import ( "eta/eta_hub/utils" "github.com/beego/beego/v2/client/orm" "time" ) // BaseFromMysteelChemicalIndex 钢联化工指标表 type BaseFromMysteelChemicalIndex struct { BaseFromMysteelChemicalIndexId int `orm:"column(base_from_mysteel_chemical_index_id);pk"` BaseFromMysteelChemicalClassifyId int `orm:"column(base_from_mysteel_chemical_classify_id)" description:"钢联化工指标分类id"` IndexCode string `description:"指标编码"` IndexName string `description:"指标名称"` Unit string `description:"单位"` Source string `description:"数据来源"` Frequency string `description:"频度"` StartDate string `description:"开始日期"` EndDate string `description:"结束日期"` Describe string `description:"指标描述"` UpdateWeek string `description:"更新周期"` UpdateTime string `description:"更新时间1"` UpdateTime2 string `description:"更新时间2"` SysUserId int `description:"创建人id"` SysUserRealName string `description:"创建人姓名"` ModifyTime time.Time `description:"修改时间"` CreateTime time.Time `description:"创建时间"` Sort int `description:"排序字段"` MergeFilePath string `description:"合并文件"` TerminalCode string `description:"终端编码"` IsStop int `description:"是否停更:1:停更,0:未停更"` EndValue float64 `description:"指标的最新值"` IsSupplierStop int `description:"是否供应商停更:1:停更,0:未停更"` } // GetNotIsSupplierStopIndexByCodeList // @Description: 获取未被供应商停更的指标 // @author: Roc // @datetime 2024-08-28 18:15:03 // @param codeList []string // @param isStop int // @return items []*BaseFromMysteelChemicalIndex // @return err error func GetNotIsSupplierStopIndexByCodeList(codeList []string, isStop int) (items []*BaseFromMysteelChemicalIndex, err error) { num := len(codeList) if num <= 0 { return } o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_mysteel_chemical_index WHERE is_supplier_stop = ? AND index_code in (` + utils.GetOrmInReplace(num) + `) ` _, err = o.Raw(sql, isStop, codeList).QueryRows(&items) return } func ModifyMysteelChemicalUpdateStatusByEdbInfoIds(edbInfoIds []int, isStop int, edbCodes []string, calculateEdbInfoIds []int) (err error) { o, err := orm.NewOrmUsingDB("data").Begin() if err != nil { return } defer func() { if err != nil { _ = o.Rollback() return } _ = o.Commit() }() // 更改数据源的更新状态 sql := ` UPDATE base_from_mysteel_chemical_index SET is_stop = ? WHERE index_code IN (` + utils.GetOrmInReplace(len(edbCodes)) + `) ` _, err = o.Raw(sql, isStop, edbCodes).Exec() if err != nil { return } // 更改指标的更新状态 sql = ` UPDATE edb_info SET no_update = ? WHERE source = ? AND edb_info_id IN (` + utils.GetOrmInReplace(len(edbInfoIds)) + `) ` _, err = o.Raw(sql, isStop, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, edbInfoIds).Exec() if err != nil { return } if len(calculateEdbInfoIds) > 0 { // 批量更新相关联的指标ID sql = ` UPDATE edb_info SET no_update = ? WHERE edb_info_id IN (` + utils.GetOrmInReplace(len(calculateEdbInfoIds)) + `) ` _, err = o.Raw(sql, isStop, calculateEdbInfoIds).Exec() if err != nil { return } } return }