package com.douyin.w3.core.vo.rt;
import com.douyin.w3.core.service.RtService;
import com.douyin.w3.module.view.module.seri.vo.VisualizationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class ResTimeService {
@Autowired
RtService rtService;
public List doListRt(String start, String end, String app) {
//1:处理入参
List result = new ArrayList();
long startTime = Long.parseLong(start);
long endTime = Long.parseLong(end);
//2:根据参数,调用远程接口,获取数据结果
Map<String, List> data = rtService.getRtLines(app, startTime, endTime);
//3:通过for循环,将远程结果,转化成自己的 POJO数据对象
for (String name : data.keySet()) {
List vos = data.get(name);
ResTime resTime1 = transform(name, vos);
result.add(resTime1);
}
return result;
}
private ResTime transform(String name, List vos) {
List points = transform(vos);
ResTime resTime1 = new ResTime(name, points);
return resTime1;
}
private List transform(List vos) {
List points = new ArrayList();
for (VisualizationVo vo : vos) {
Point point1 = new Point(vo.getDate() ,
double2Int(vo.getValue()),
double2Int(vo.getLastDayValue()),
double2Int(vo.getLastWeekValue())
);
points.add(point1);
}
return points;
}
private int double2Int(double value) {
return new Double(value).intValue();
}
}