提交 668f9f66 作者: 布红亮

修复事件分析bug 当事件为0时资讯数增量数应为0,,

上级 59ad9772
...@@ -9,6 +9,7 @@ import com.zzsn.event.util.user.UserVo; ...@@ -9,6 +9,7 @@ import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.EventExcelVO; import com.zzsn.event.vo.EventExcelVO;
import com.zzsn.event.vo.EventRegionVO; import com.zzsn.event.vo.EventRegionVO;
import com.zzsn.event.vo.EventTopVO; import com.zzsn.event.vo.EventTopVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -57,14 +58,19 @@ public class EventHomeController { ...@@ -57,14 +58,19 @@ public class EventHomeController {
Map<String, Integer> map = new HashMap<>(); Map<String, Integer> map = new HashMap<>();
List<EventExcelVO> eventList = eventService.frontAllList(projectId, username, null, null,null,null,null,null, tenant); List<EventExcelVO> eventList = eventService.frontAllList(projectId, username, null, null,null,null,null,null, tenant);
map.put("eventCount", eventList.size()); map.put("eventCount", eventList.size());
List<String> eventIdList = eventList.stream().map(EventExcelVO::getId).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(eventList)) {
long total = esStatisticsService.totalCount(eventIdList, null, null); List<String> eventIdList = eventList.stream().map(EventExcelVO::getId).collect(Collectors.toList());
map.put("total", (int) total); long total = esStatisticsService.totalCount(eventIdList, null, null);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); map.put("total", (int) total);
LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime previousHour = now.minus(1, ChronoUnit.DAYS); LocalDateTime now = LocalDateTime.now();
long totalAdd = esStatisticsService.totalCount(eventIdList, previousHour.format(formatter), now.format(formatter)); LocalDateTime previousHour = now.minus(1, ChronoUnit.DAYS);
map.put("totalAdd", (int) totalAdd); long totalAdd = esStatisticsService.totalCount(eventIdList, previousHour.format(formatter), now.format(formatter));
map.put("totalAdd", (int) totalAdd);
} else {
map.put("total", 0);
map.put("totalAdd", 0);
}
return Result.OK(map); return Result.OK(map);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论