fix:优化money股票K线图1H和1D只返回当天数据

This commit is contained in:
xiaoliuhu
2024-04-24 22:11:49 +08:00
parent 11130a9eda
commit 33c83af353

View File

@@ -678,13 +678,13 @@ public class MoneyApiController {
if(StringUtils.equals("H",resolution)){ if(StringUtils.equals("H",resolution)){
to = (long) (System.currentTimeMillis() / 1000); to = (long) (System.currentTimeMillis() / 1000);
from = to - ( 60 * 60 ); from = to - ( 60 * 60 );
countback = 16; countback = 60;
request.setResolution("1"); request.setResolution("1");
}else if(StringUtils.equals("D",resolution)){ }else if(StringUtils.equals("D",resolution)){
to = (long) (System.currentTimeMillis() / 1000); to = (long) (System.currentTimeMillis() / 1000);
from = to - (24 * 60 * 60 ); from = to - (24 * 60 * 60 );
countback = 30; countback = 75;
request.setResolution("1"); request.setResolution("5");
}else if(StringUtils.equals("W",resolution)){ }else if(StringUtils.equals("W",resolution)){
to = (long) (System.currentTimeMillis() / 1000); to = (long) (System.currentTimeMillis() / 1000);
from = to - (10 * 24 * 60 * 60 ); from = to - (10 * 24 * 60 * 60 );
@@ -754,6 +754,11 @@ public class MoneyApiController {
//根据时间过滤,只留当天的数据 //根据时间过滤,只留当天的数据
Date currentTime = new Date(); Date currentTime = new Date();
//判断最后一条是不是当天的数据,如果不是,把最后一条的时间作为当天的时间
long getTime = response.getT().get(response.getT().size() - 1) * 1000L;
if(!DateUtil.isSameDay(currentTime, new Date(getTime))){
currentTime = new Date(getTime);
}
int i = 0; int i = 0;
for (Long time : response.getT()) { for (Long time : response.getT()) {
time = time * 1000; time = time * 1000;