Przeglądaj źródła

修改分时图数据接口BUG

zhou.xiaoning 4 lat temu
rodzic
commit
98fedd03dc
1 zmienionych plików z 7 dodań i 5 usunięć
  1. 7 5
      controllers/quote/history.go

+ 7 - 5
controllers/quote/history.go

@@ -469,12 +469,13 @@ func QueryTSData(c *gin.Context) {
 			for i := 1; i <= minute; i++ {
 				st := cycleDatas[0].ST - i*60
 				stt := time.Unix(int64(st), 0).Format("2006-01-02 15:04:05")
+				// 前面的数据使用昨结来补
 				cycleDatas = append(cycleDatas, models.CycleData{
 					GC:    cycleDatas[0].GC,
-					Open:  cycleDatas[0].Close,
-					High:  cycleDatas[0].Close,
-					Low:   cycleDatas[0].Close,
-					Close: cycleDatas[0].Close,
+					Open:  preSettleInt,
+					High:  preSettleInt,
+					Low:   preSettleInt,
+					Close: preSettleInt,
 					TV:    0,
 					TT:    0,
 					HV:    0,
@@ -547,7 +548,8 @@ func QueryTSData(c *gin.Context) {
 				minute := int(diff.Minutes())
 				// 判断是否需要补数据,与上一条数据的间距不是一分钟
 				if minute > 1 {
-					for j := 1; j <= minute; j++ {
+					// 注意补中间数据时,是不用补最后一条数据的,所以是 < minute
+					for j := 1; j < minute; j++ {
 						st := cycleDatas[i-1].ST + j*60
 						stt := time.Unix(int64(st), 0).Format("2006-01-02 15:04:05")
 						fillDatas = append(fillDatas, models.CycleData{