|
@@ -13,12 +13,12 @@ import (
|
|
|
type BaseFromBaiinfoData struct {
|
|
|
BaiinfoDataId int `orm:"column(baiinfo_data_id);pk"`
|
|
|
BaseFromBaiinfoIndexId int
|
|
|
- IndexCode string
|
|
|
- DataTime string
|
|
|
- Value string
|
|
|
- CreateTime time.Time
|
|
|
- ModifyTime time.Time
|
|
|
- DataTimestamp int64
|
|
|
+ IndexCode string
|
|
|
+ DataTime string
|
|
|
+ Value string
|
|
|
+ CreateTime time.Time
|
|
|
+ ModifyTime time.Time
|
|
|
+ DataTimestamp int64
|
|
|
}
|
|
|
|
|
|
func GetBaseFromBaiinfoDataByCondition(condition string, pars []interface{}) (list []*BaseFromBaiinfoData, err error) {
|
|
@@ -31,7 +31,7 @@ func GetBaseFromBaiinfoDataByCondition(condition string, pars []interface{}) (li
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
func AddEdbDataFromBaiinfo(edbCode string) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
|
|
@@ -73,7 +73,7 @@ func AddEdbDataFromBaiinfo(edbCode string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
func RefreshEdbDataFromBaiinfo(edbInfoId int, edbCode, startDate string) (err error) {
|
|
|
source := utils.DATA_SOURCE_BAIINFO
|
|
|
o := orm.NewOrm()
|
|
@@ -96,6 +96,23 @@ func RefreshEdbDataFromBaiinfo(edbInfoId int, edbCode, startDate string) (err er
|
|
|
}
|
|
|
|
|
|
baiinfoDataList, err := GetBaseFromBaiinfoDataByCondition(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var realDataMaxDate, edbDataInsertConfigDate time.Time
|
|
|
+ var edbDataInsertConfig *EdbDataInsertConfig
|
|
|
+ var isFindConfigDateRealData bool
|
|
|
+ {
|
|
|
+ edbDataInsertConfig, err = GetEdbDataInsertConfigByEdbId(edbInfoId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if edbDataInsertConfig != nil {
|
|
|
+ edbDataInsertConfigDate = edbDataInsertConfig.Date
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
var existCondition string
|
|
|
var existPars []interface{}
|
|
@@ -119,14 +136,14 @@ func RefreshEdbDataFromBaiinfo(edbInfoId int, edbCode, startDate string) (err er
|
|
|
var isAdd bool
|
|
|
for _, v := range baiinfoDataList {
|
|
|
item := v
|
|
|
+ eDate := item.DataTime
|
|
|
+ dataTime, err := time.ParseInLocation(utils.FormatDate, eDate, time.Local)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
if findItem, ok := existMap[v.DataTime]; !ok {
|
|
|
- eDate := item.DataTime
|
|
|
sValue := item.Value
|
|
|
|
|
|
- dataTime, err := time.Parse(utils.FormatDate, eDate)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
timestamp := dataTime.UnixNano() / 1e6
|
|
|
timeStr := fmt.Sprintf("%d", timestamp)
|
|
|
|
|
@@ -140,8 +157,21 @@ func RefreshEdbDataFromBaiinfo(edbInfoId int, edbCode, startDate string) (err er
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ {
|
|
|
+ if realDataMaxDate.IsZero() || dataTime.After(realDataMaxDate) {
|
|
|
+ realDataMaxDate = dataTime
|
|
|
+ }
|
|
|
+ if edbDataInsertConfigDate.IsZero() || dataTime.Equal(edbDataInsertConfigDate) {
|
|
|
+ isFindConfigDateRealData = true
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ HandleConfigInsertEdbData(realDataMaxDate, edbDataInsertConfig, edbInfoId, source, existMap, isFindConfigDateRealData)
|
|
|
+
|
|
|
if isAdd {
|
|
|
addSql = strings.TrimRight(addSql, ",")
|
|
|
_, err = o.Raw(addSql).Exec()
|