1.根据开始时间和结束时间,通过折线进行展示。
if(startTime === null || startTime === ""){
startTime = DataUtil.getlastWeekTime();
}
if(endTime === null || endTime === ""){
endTime = DataUtil.getCurrentTime();
}
// ---- 1.获取最近几天每天的告警数量----
var warningCountList = ds.query("SELECT new map(DATE_FORMAT(s.createTime,'%Y-%m-%d') as day,COUNT(id) as count)FROM WarningEntity s
WHERE s.createTime >= \'" + startTime + "\' AND s.createTime <= \'" + endTime + "\'
GROUP BY DATE_FORMAT(s.createTime,'%Y-%m-%d')
ORDER BY s.createTime
");
var daysList = DataUtil.getDayBetweenDate(startTime,endTime);
// 定义报警数数组
var countList = new ArrayList();
for(everyDay:daysList){
var bool = true;
var boo = true;
for(warningCount:warningCountList){
if(bool){
var warningCountMap = warningCount as HashMap;
var day = warningCountMap.get("day");
var count = warningCountMap.get("count");
if(everyDay == day){
countList.add(count);
bool =false;
boo = false;
}
}
}
if(boo){
countList.add(0);
}
}
var jsonObj = new JSONObject();
jsonObj.put("dayList",daysList);
jsonObj.put("countList",countList);
实现效果图如下: