浏览代码

商品价格曲线bug

xyxie 9 月之前
父节点
当前提交
0b371f1840
共有 1 个文件被更改,包括 13 次插入11 次删除
  1. 13 11
      services/data/future_good/chart_info.go

+ 13 - 11
services/data/future_good/chart_info.go

@@ -405,8 +405,9 @@ func GetChartEdbData(chartInfoId int, startDate, endDate string, baseEdbInfoMapp
 			yDataList[k].Value = v.Value[0 : maxIndex+1]
 		}
 	}
+	baseEdbLen := len(edbInfoMappingList)
+	tmpXDataList, newYDataList, err := handleResultData(regionType, futureGoodEdbType, baseEdbLen, yDataList, futureGoodEdbInfoList, maxIndex)
 
-	tmpXDataList, newYDataList, err := handleResultData(regionType, futureGoodEdbType, yDataList, futureGoodEdbInfoList, maxIndex)
 	if err != nil {
 		return
 	}
@@ -515,6 +516,7 @@ func BarChartData(baseEdbInfoMapping *models.ChartEdbInfoMapping, edbInfoMapping
 					noDataIdList = append(noDataIdList, baseEdbInfoMapping.EdbInfoId)
 					noDataIdMap[baseEdbInfoMapping.EdbInfoId] = baseEdbInfoMapping.EdbInfoId
 				}
+				xEdbInfoIdList = append(xEdbInfoIdList, v.EdbInfoId)
 				continue
 			}
 			tmpRealDateTime, findDataValueTmp, isFindTmp, e := GetNeedDateData(realDateTime, edbDataListMap[v.EdbInfoId], baseEdbDataMap[v.EdbInfoId], futureGoodEdbDataMap)
@@ -661,7 +663,7 @@ func BarChartData(baseEdbInfoMapping *models.ChartEdbInfoMapping, edbInfoMapping
 }
 
 // handleResultData 处理成最终的结果数据
-func handleResultData(regionType string, futureGoodEdbType int, yDataList []models.YData, futureGoodEdbInfoList []*future_good2.FutureGoodEdbInfo, maxIndex int) (xDataList []data_manage.XData, newYDataList []models.YData, err error) {
+func handleResultData(regionType string, futureGoodEdbType, baseEdbLen int, yDataList []models.YData, futureGoodEdbInfoList []*future_good2.FutureGoodEdbInfo, maxIndex int) (xDataList []data_manage.XData, newYDataList []models.YData, err error) {
 	xDataList = make([]data_manage.XData, 0)
 	newYDataList = yDataList
 
@@ -699,11 +701,11 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []mode
 			tmpNList := nList
 
 			//当前的主力合约
-			newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0])
-			newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0])
+			newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0:baseEdbLen]...)
+			newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0:baseEdbLen]...)
 
-			xEdbInfoIdList := yData.XEdbInfoIdList[1:]
-			valIndex := 1
+			xEdbInfoIdList := yData.XEdbInfoIdList[baseEdbLen:]
+			valIndex := baseEdbLen
 			needNum := 0
 			for _, n := range tmpNList {
 				if len(xEdbInfoIdList) > 0 {
@@ -776,7 +778,7 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []mode
 		//v.XEdbInfoIdList
 		for edbInfoIndex, edbInfoId := range v.XEdbInfoIdList {
 			// 第一个不处理
-			if edbInfoIndex == 0 {
+			if edbInfoIndex <= baseEdbLen-1 {
 				continue
 			}
 
@@ -815,12 +817,12 @@ func handleResultData(regionType string, futureGoodEdbType int, yDataList []mode
 		tmpNList := nList
 
 		//当前的主力合约
-		newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0])
-		newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0])
+		newYDataList[yIndex].XEdbInfoIdList = append(newYDataList[yIndex].XEdbInfoIdList, yData.XEdbInfoIdList[0:baseEdbLen]...)
+		newYDataList[yIndex].Value = append(newYDataList[yIndex].Value, yData.Value[0:baseEdbLen]...)
 
-		xEdbInfoIdList := yData.XEdbInfoIdList[1:]
+		xEdbInfoIdList := yData.XEdbInfoIdList[baseEdbLen:]
 		currDataTime := yData.ConfigDate
-		valIndex := 1
+		valIndex := baseEdbLen
 		needNum := 0
 		for _, n := range tmpNList {
 			if len(xEdbInfoIdList) > 0 {