//List集合
List<IllegalConstruction> dataList=violationNoService.getIllegalConstructionByTime(startTime,endTime);
//按照部门名称分组
Map<String, List<IllegalConstruction>> commentList = dataList.stream().collect(Collectors.groupingBy(IllegalConstruction::getDepartment));
//遍历
for(Map.Entry<String, List<IllegalConstruction>> param : commentList.entrySet()){
//键值,我这里是部门名称,String类型
param.getKey();
//value 我这里是List<IllegalConstruction>类型
param.getValue();
}