|
@@ -512,7 +512,7 @@ func BarChartData(baseEdbInfoMapping *data_manage.ChartEdbInfoMapping, edbInfoMa
|
|
|
|
|
|
// 先找到基准日期
|
|
|
var realDateTime time.Time
|
|
|
- realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[baseEdbInfoMapping.EdbInfoId], baseEdbDataMap[baseEdbInfoMapping.EdbInfoId])
|
|
|
+ realDateTime, findDataValue, isFind, tmpErr := GetNeedDateData(findDateTime, edbDataListMap[baseEdbInfoMapping.EdbInfoId], baseEdbDataMap[baseEdbInfoMapping.EdbInfoId], edbDataMap)
|
|
|
if tmpErr != nil {
|
|
|
err = tmpErr
|
|
|
return
|
|
@@ -962,7 +962,7 @@ func getFutureGoodEdbInfoList(latestDateTime time.Time, tmpFutureGoodEdbInfoList
|
|
|
}
|
|
|
|
|
|
// GetNeedDateData 获取合约内需要的日期数据
|
|
|
-func GetNeedDateData(needDateTime time.Time, dataList []*data_manage.EdbDataList, edbDataMap map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
|
|
|
+func GetNeedDateData(needDateTime time.Time, dataList []*data_manage.EdbDataList, edbDataMap map[string]float64, allEdbDataMap map[int]map[string]float64) (findDateTime time.Time, findDataValue float64, isFind bool, err error) {
|
|
|
//dataList := edbDataListMap[edbInfoId] //指标的所有数据值
|
|
|
if len(dataList) <= 0 {
|
|
|
// 没有数据的指标id
|
|
@@ -975,18 +975,43 @@ func GetNeedDateData(needDateTime time.Time, dataList []*data_manage.EdbDataList
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 该日期存在数据的期货指标的最小数量,目前是现货和期货各1个,总共2个
|
|
|
+ maxCount := 1
|
|
|
+
|
|
|
for tmpDateTime := needDateTime; tmpDateTime.After(minDateTime) || tmpDateTime.Equal(minDateTime); tmpDateTime = tmpDateTime.AddDate(0, 0, -1) {
|
|
|
tmpDate := tmpDateTime.Format(utils.FormatDate)
|
|
|
- if tmpValue, ok := edbDataMap[tmpDate]; ok { //如果能找到数据,那么就返回
|
|
|
- // 数据为0,也直接返回,做无值处理
|
|
|
- if tmpValue == 0 {
|
|
|
- return
|
|
|
+ tmpValue, ok := edbDataMap[tmpDate]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ // 该日期存在数据的指标数量
|
|
|
+ count := 0
|
|
|
+
|
|
|
+ for _, currEdbDataMap := range allEdbDataMap {
|
|
|
+ _, tmpIsFind := currEdbDataMap[tmpDate]
|
|
|
+ if tmpIsFind {
|
|
|
+ count++
|
|
|
+ if count >= maxCount {
|
|
|
+ continue
|
|
|
+ }
|
|
|
}
|
|
|
- findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
|
|
|
- findDataValue = tmpValue
|
|
|
- isFind = true
|
|
|
+ }
|
|
|
+
|
|
|
+ // 该日期存在数据的期货指标数量小于2个,那么要继续往前找
|
|
|
+ if count < maxCount {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果能找到数据,那么就返回
|
|
|
+ // 数据为0,也直接返回,做无值处理
|
|
|
+ if tmpValue == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ findDateTime, _ = time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
|
|
|
+ findDataValue = tmpValue
|
|
|
+ isFind = true
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
return
|