Browse Source

导出数据源时间格式bug

xyxie 3 weeks ago
parent
commit
00a75ff1cc

+ 1 - 1
models/ai_predict_model/ai_predict_model_data.go

@@ -180,7 +180,7 @@ type AiPredictModelDataItem struct {
 	PredictValue  *float64 `description:"预测值"`
 	Direction     string   `description:"方向"`
 	DeviationRate string   `description:"偏差率"`
-	DataTimestamp int64    `description:"数据日期时间戳"`
+	DataTimestamp int64    `description:"数据日期时间戳" gorm:"column:data_timestamp"`
 }
 
 func (m *AiPredictModelData) Format2Item() (item *AiPredictModelDataItem) {

+ 9 - 1
models/data_manage/base_from_ccf.go

@@ -263,7 +263,15 @@ func GetCCFDataDataTimeByIndexId(indexIdList []int) (items []string, err error)
 		return
 	}
 	sql := ` SELECT DISTINCT data_time FROM base_from_ccf_data WHERE base_from_ccf_index_id IN (` + utils.GetOrmInReplace(len(indexIdList)) + `) ORDER BY data_time DESC`
-	err = global.DbMap[utils.DbNameIndex].Raw(sql, indexIdList).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, indexIdList).Scan(&items).Error
+	if err != nil {
+		return
+	}
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		for i := range items {
+			items[i] = utils.GormDateStrToDateStr(items[i])
+		}
+	}
 	return
 }
 

+ 8 - 1
models/data_manage/base_from_fenwei.go

@@ -261,7 +261,14 @@ func GetBaseFromFenWeiDataByIndexCode(indexCode string) (items []*BaseFromFenwei
 func GetFenWeiDataListByIndexCodes(IndexCodes string) (items []string, err error) {
 	sql := ` SELECT DISTINCT data_time FROM base_from_fenwei_data WHERE index_code IN(` + IndexCodes + `)  ORDER BY data_time DESC `
 	err = global.DbMap[utils.DbNameIndex].Raw(sql).Find(&items).Error
-	return
+	if err != nil {
+		return
+	}
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		for i := range items {
+			items[i] = utils.GormDateStrToDateStr(items[i])
+		}
+	}
 }
 
 // GetFenWeiIndexInfoPage 分页查询指标信息

+ 8 - 0
models/data_manage/base_from_ly_data.go

@@ -61,6 +61,14 @@ func GetLyDataListByIndexCodes(IndexCodes string) (items []string, err error) {
 	sql := ` SELECT DISTINCT data_time FROM base_from_ly_data WHERE index_code IN(` + IndexCodes + `)  ORDER BY data_time DESC `
 	o := global.DbMap[utils.DbNameIndex]
 	err = o.Raw(sql).Find(&items).Error
+	if err != nil {
+		return
+	}
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		for i := range items {
+			items[i] = utils.GormDateStrToDateStr(items[i])
+		}
+	}
 	return
 }
 

+ 8 - 0
models/data_manage/base_from_sci_hq_data.go

@@ -33,6 +33,14 @@ func GetSciHqDataDataTimeByIndexId(indexIdList []int) (items []string, err error
 	o := global.DbMap[utils.DbNameIndex]
 	sql := ` SELECT DISTINCT data_time FROM base_from_sci_hq_data WHERE base_from_sci_hq_index_id IN (` + utils.GetOrmInReplace(len(indexIdList)) + `) ORDER BY data_time DESC`
 	err = o.Raw(sql, indexIdList).Find(&items).Error
+	if err != nil {
+		return
+	}
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		for i := range items {
+			items[i] = utils.GormDateStrToDateStr(items[i])
+		}
+	}
 	return
 }
 

+ 8 - 0
models/data_manage/base_from_usda_fas.go

@@ -179,6 +179,14 @@ func GetUsdaFasDataDataTimeByIndexId(indexIdList []int) (items []string, err err
 	o := global.DbMap[utils.DbNameIndex]
 	sql := ` SELECT DISTINCT data_time FROM base_from_usda_fas_data WHERE base_from_usda_fas_index_id IN (` + utils.GetOrmInReplace(len(indexIdList)) + `) ORDER BY data_time DESC`
 	err = o.Raw(sql, indexIdList).Find(&items).Error
+	if err != nil {
+		return
+	}
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		for i := range items {
+			items[i] = utils.GormDateStrToDateStr(items[i])
+		}
+	}
 	return
 }
 

+ 3 - 3
models/data_manage/base_from_yongyi.go

@@ -138,18 +138,18 @@ func GetYongyiDataDataTimeByIndexId(indexIdList []int) (items []string, err erro
 }
 
 type BaseFromYongyiData struct {
-	YongyiDataId  int `orm:"column(yongyi_data_id);pk"`
+	YongyiDataId  int    `orm:"column(yongyi_data_id);pk" gorm:"primaryKey"`
 	YongyiIndexId int
 	IndexCode     string
 	DataTime      string
 	Value         string
 	CreateTime    string
 	ModifyTime    string
-	DataTimestamp int64
+	DataTimestamp int64  `gorm:"column:data_timestamp"`
 }
 
 type BaseFromYongyiIndexSearchItem struct {
-	YongyiIndexId    int `orm:"column(yongyi_index_id);pk"`
+	YongyiIndexId    int `orm:"column(yongyi_index_id);pk" gorm:"primaryKey"`
 	ClassifyId       int
 	ParentClassifyId int
 	IndexCode        string

+ 1 - 1
models/data_manage/chart_theme/chart_theme_default_data.go

@@ -15,7 +15,7 @@ type ChartThemeDefaultData struct {
 	EdbInfoId     int       `description:"指标ID"`
 	EdbCode       string    `description:"指标编码"`
 	DataTime      string    //`json:"-" description:"数据日期"`
-	DataTimestamp int64     `description:"数据日期"`
+	DataTimestamp int64     `description:"数据日期" gorm:"column:data_timestamp"`
 	Value         float64   `description:"数据值"`
 	ModifyTime    time.Time `description:"修改时间"`
 	CreateTime    time.Time `description:"创建时间"`

+ 1 - 1
models/data_manage/edb_data_pb.go

@@ -18,7 +18,7 @@ type EdbDataPb struct {
 	ModifyTime    time.Time
 	Ticker        string
 	Field         string
-	DataTimestamp int64
+	DataTimestamp int64  `gorm:"column:data_timestamp"`
 }
 
 func GetEdbDataPbMaxOrMinDate(edbCode string) (min_date, max_date string, err error) {

+ 1 - 1
models/data_manage/edb_data_ths.go

@@ -16,7 +16,7 @@ type EdbDataThs struct {
 	Status        int
 	CreateTime    time.Time
 	ModifyTime    time.Time
-	DataTimestamp int64
+	DataTimestamp int64  `gorm:"column:data_timestamp"`
 }
 
 func GetEdbDataThsMaxOrMinDate(edbCode string) (min_date, max_date string, err error) {

+ 2 - 2
models/data_manage/edb_data_wind.go

@@ -15,8 +15,8 @@ type EdbDataWind struct {
 	Value         float64
 	Status        int
 	CreateTime    time.Time
-	ModifyTime    time.Time
-	DataTimestamp int64
+	ModifyTime    time.Time 
+	DataTimestamp int64  `gorm:"column:data_timestamp"`
 }
 
 func AddEdbDataWindBySql(sqlStr string) (err error) {

+ 8 - 0
models/data_manage/mysteel_chemical_index.go

@@ -324,6 +324,14 @@ func GetBaseFromMysteelChemicalDataTimeByIndexId(indexIdList []int) (items []str
 	o := global.DbMap[utils.DbNameIndex]
 	sql := ` SELECT DISTINCT data_time FROM base_from_mysteel_chemical_data WHERE base_from_mysteel_chemical_index_id IN (` + utils.GetOrmInReplace(len(indexIdList)) + `) ORDER BY data_time DESC`
 	err = o.Raw(sql, indexIdList).Find(&items).Error
+	if err != nil {
+		return
+	}
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		for i := range items {
+			items[i] = utils.GormDateStrToDateStr(items[i])
+		}
+	}
 	return
 }
 

+ 2 - 2
models/data_manage/stl/edb_data_calculate_stl.go

@@ -9,14 +9,14 @@ import (
 )
 
 type EdbDataCalculateStl struct {
-	EdbDataId     int       `orm:"pk"`
+	EdbDataId     int       `orm:"pk" gorm:"primaryKey"`
 	EdbInfoId     int       `description:"指标id"`
 	EdbCode       string    `description:"指标编码"`
 	DataTime      time.Time `description:"数据时间"`
 	Value         float64   `description:"数据值"`
 	CreateTime    time.Time `description:"创建时间"`
 	ModifyTime    time.Time `description:"修改时间"`
-	DataTimestamp int64     `description:"数据时间戳"`
+	DataTimestamp int64     `description:"数据时间戳" gorm:"column:data_timestamp"`
 }
 
 func GetEdbDataCalculateStlByEdbCode(edbCode string) (items []*EdbDataCalculateStl, err error) {

+ 14 - 0
models/data_manage/supply_analysis/variety_edb_info.go

@@ -5,6 +5,8 @@ import (
 	"eta/eta_api/global"
 	"eta/eta_api/utils"
 	"time"
+
+	"gorm.io/gorm"
 )
 
 // VarietyEdbInfo variety_edb_info 品种指标表
@@ -85,6 +87,18 @@ type VarietyEdbInfoItem struct {
 	Button       VarietyEdbInfoButton `description:"操作按钮权限"gorm:"-"`
 }
 
+func (v *VarietyEdbInfoItem) AfterFind(tx *gorm.DB) (err error) {
+	if utils.NeedDateOrTimeFormat(utils.DbDriverName) {
+		if v.CreateTime != "" {
+			v.CreateTime = utils.GormDateStrToDateTimeStr(v.CreateTime)
+		}
+		if v.ModifyTime != "" {
+			v.ModifyTime = utils.GormDateStrToDateTimeStr(v.ModifyTime)
+		}
+	}
+	return
+}
+
 type VarietyEdbInfoButton struct {
 	Copy bool `description:"复制数据权限"`
 	Show bool `description:"查看数据权限"`

+ 1 - 1
models/residual_analysis_model/edb_data_residual_analysis.go

@@ -15,7 +15,7 @@ type edbDataResidualAnalysis struct {
 	Value         float64   `orm:"column(value)" description:"数据值"`
 	CreateTime    time.Time `orm:"column(create_time)" description:"创建时间"`
 	ModifyTime    time.Time `orm:"column(modify_time)" description:"修改时间"`
-	DataTimeStamp int64     `orm:"column(data_timestamp)"`
+	DataTimeStamp int64     `orm:"column(data_timestamp)" gorm:"column:data_timestamp"`
 }
 
 func init() {