|
@@ -6,6 +6,7 @@ import (
|
|
|
"eta/eta_index_lib/services/alarm_msg"
|
|
|
"eta/eta_index_lib/utils"
|
|
|
"fmt"
|
|
|
+ "github.com/shopspring/decimal"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -125,12 +126,25 @@ func HandleSciData(dataMap map[string]map[string]string) {
|
|
|
}
|
|
|
addSciDataList := make([]*models.BaseFromSciData, 0)
|
|
|
|
|
|
+ var tmpStartDate, tmpEndDate time.Time
|
|
|
+ var latestValue string
|
|
|
+
|
|
|
for currDate, currVal := range data {
|
|
|
currDataTime, tmpErr := time.ParseInLocation(utils.FormatDate, currDate, time.Local)
|
|
|
if tmpErr != nil {
|
|
|
errMsgList = append(errMsgList, fmt.Sprint("时间格式化失败,指标编码:", currDate, ";错误原因:", tmpErr.Error()))
|
|
|
continue
|
|
|
}
|
|
|
+ // 如果开始日期为空、或者当前日期早于开始日期,那么给开始日期赋值为当前日期
|
|
|
+ if tmpStartDate.IsZero() || currDataTime.Before(tmpStartDate) {
|
|
|
+ tmpStartDate = currDataTime
|
|
|
+ }
|
|
|
+ // 如果结束日期为空、或者当前日期晚于结束日期,那么给结束日期赋值为当前日期,且赋值最新值
|
|
|
+ if tmpEndDate.IsZero() || currDataTime.After(tmpEndDate) {
|
|
|
+ tmpEndDate = currDataTime
|
|
|
+ latestValue = currVal
|
|
|
+ }
|
|
|
+
|
|
|
timestamp := currDataTime.UnixNano() / 1e6
|
|
|
|
|
|
sciData, ok := indexDataExistMap[currDate]
|
|
@@ -174,8 +188,24 @@ func HandleSciData(dataMap map[string]map[string]string) {
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ updateCols := []string{"ModifyTime"}
|
|
|
indexInfo.ModifyTime = time.Now()
|
|
|
- indexInfo.Update([]string{"ModifyTime"})
|
|
|
+ if !tmpStartDate.IsZero() {
|
|
|
+ indexInfo.StartDate = tmpStartDate
|
|
|
+ updateCols = append(updateCols, "StartDate")
|
|
|
+ }
|
|
|
+ if !tmpEndDate.IsZero() {
|
|
|
+ indexInfo.EndDate = tmpEndDate
|
|
|
+ updateCols = append(updateCols, "EndDate")
|
|
|
+ }
|
|
|
+
|
|
|
+ latestValueDeci, tmpErr := decimal.NewFromString(latestValue)
|
|
|
+ if tmpErr == nil {
|
|
|
+ indexInfo.LatestValue, _ = latestValueDeci.Float64()
|
|
|
+ updateCols = append(updateCols, "LatestValue")
|
|
|
+ }
|
|
|
+ indexInfo.Update(updateCols)
|
|
|
|
|
|
// 同步刷新ETA图库红桃3的指标
|
|
|
{
|