package data_manage import ( "eta_gn/eta_task/global" "time" ) type BaseFromTradeDalianIndex struct { BaseFromTradeDalianIndexId int `orm:"column(base_from_trade_dalian_index_id);pk"` Rank string `description:"排名"` DealShortName string `description:"成交量公司简称"` DealName string `description:"成交量指标名称"` DealCode string `description:"成交量指标编码"` DealValue string `description:"成交量"` DealChange string `description:"成交变化量"` BuyShortName string `description:"成交量公司简称"` BuyName string `description:"持买单量指标名称"` BuyCode string `description:"持买单量指标编码"` BuyValue string `description:"持买单量"` BuyChange string `description:"持买单量变化量"` SoldShortName string `description:"成交量公司简称"` SoldName string `description:"持买单量指标名称"` SoldCode string `description:"持买单量指标编码"` SoldValue string `description:"持买单量"` SoldChange string `description:"持买单量变化量"` Frequency string `description:"频度"` ClassifyName string `description:"分类名称"` ClassifyType string `description:"分类名称下的类型"` CreateTime string `description:"插入时间"` ModifyTime string `description:"修改时间"` DataTime string `description:"数据日期"` } func AddBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex) (lastId int64, err error) { //o := orm.NewOrm() //lastId, err = o.Insert(item) err = global.DEFAULT_DmSQL.Create(item).Error if err != nil { return } lastId = int64(item.BaseFromTradeDalianIndexId) return } type BaseFromTradeDalianData struct { BaseFromTradeDalianDataId int `orm:"column(base_from_trade_dalian_data_id);pk"` BaseFromTradeDalianIndexId int IndexCode string DataTime time.Time Value string AddCutValue string CreateTime time.Time ModifyTime time.Time DataTimestamp string } // 刷新大连指标数据 func RefreshEdbDataByDaLian(addSql string) (err error) { //o := orm.NewOrm() //_, err = o.Raw(addSql).Exec() //if err != nil { // return err //} //err = global.DEFAULT_DmSQL.Exec(addSql).Error return } // 获取当天数据信息列表 func GetBaseFromTradeDalianDataList(dateTime string) (items []*BaseFromTradeDalianIndex, err error) { //o := orm.NewOrm() sql := `SELECT * FROM base_from_trade_dalian_index WHERE data_time>=?` //_, err = o.Raw(sql, dateTime).QueryRows(&items) err = global.DEFAULT_DmSQL.Raw(sql, dateTime).Find(&items).Error return } func UpdateBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex, dataId int) (err error) { //o := orm.NewOrm() sql := "UPDATE base_from_trade_dalian_index SET `rank`=?,deal_short_name=?,deal_name=?,deal_code=?,deal_value=?,buy_short_name=?,deal_change=?,buy_name=?,buy_code=?,buy_value=?,buy_change=?,sold_short_name=?,sold_name=?,sold_code=?,sold_value=?,sold_change=?,frequency=?,classify_name=?,classify_type=?,modify_time=?,data_time=? WHERE base_from_trade_dalian_index_id=? " //_, err = o.Raw(sql, item.Rank, item.DealShortName, item.DealName, item.DealCode, item.DealValue, item.BuyShortName, item.DealChange, item.BuyName, item.BuyCode, item.BuyValue, item.BuyChange, item.SoldShortName, item.SoldName, item.SoldCode, item.SoldValue, item.SoldChange, item.Frequency, item.ClassifyName, item.ClassifyType, item.ModifyTime, item.DataTime, dataId).Exec() err = global.DEFAULT_DmSQL.Exec(sql, item.Rank, item.DealShortName, item.DealName, item.DealCode, item.DealValue, item.BuyShortName, item.DealChange, item.BuyName, item.BuyCode, item.BuyValue, item.BuyChange, item.SoldShortName, item.SoldName, item.SoldCode, item.SoldValue, item.SoldChange, item.Frequency, item.ClassifyName, item.ClassifyType, item.ModifyTime, item.DataTime, dataId).Error return } type DalianIndexResp struct { Ret int Msg string ErrMsg string ErrCode string Data []*BaseFromTradeDalianIndex } func GetBaseFromTradeDalianIndexMaxDate() (max_date time.Time, err error) { //o := orm.NewOrm() sql := ` SELECT max(a.data_time)as max_date FROM base_from_trade_dalian_index as a ` //err = o.Raw(sql).QueryRow(&max_date) err = global.DEFAULT_DmSQL.Raw(sql).Scan(&max_date).Error return }