List<LivelihoodLawCounty> livelihoodLawCounties = livelihoodLawCountyMapper.selectByExample(criteria.example());
//新特性根据某个值进行排序
List<LivelihoodLawCounty> collect = livelihoodLawCounties.stream().sorted(Comparator.comparing(LivelihoodLawCounty::getStatisticsDate)).collect(Collectors.toList());
public Map<String, IntSummaryStatistics> selectLawCounty(String statisticsDate, String regionCode, String statisticsType){
LivelihoodLawCountyExample livelihoodLawCountyExample=new LivelihoodLawCountyExample();
LivelihoodLawCountyExample.Criteria criteria = livelihoodLawCountyExample.createCriteria();
criteria.andParentCodeEqualTo(regionCode);
criteria.andStatisticsTypeEqualTo(statisticsType);
int indexDe = statisticsDate.indexOf("_");
String str = statisticsDate.substring(0, indexDe);
String yearMonth = statisticsDate.substring(indexDe + 1);
String year = yearMonth.substring(0);
int indexDeFu = yearMonth.indexOf("-");
String month = yearMonth.substring(indexDeFu + 1);
if(str.equals("year")){
criteria.andStatisticsDateLike(year+"%");
}
if(str.equals("month")){
criteria.andStatisticsDateLike(yearMonth+"%");
}
if(str.equals("quarter")){
Map<String, String> quarterStartEndTime = DateStringUtils.getQuarterStartEndTime(month);
String startTime = quarterStartEndTime.get("startTime");
String endTime = quarterStartEndTime.get("endTime");
criteria.andStatisticsDateBetween(startTime,endTime);
}
List<LivelihoodLawCounty> livelihoodLawCounties = livelihoodLawCountyMapper.selectByExample(criteria.example());
//新特性根据某个值进行排序
List<LivelihoodLawCounty> collect = livelihoodLawCounties.stream().sorted(Comparator.comparing(LivelihoodLawCounty::getStatisticsDate)).collect(Collectors.toList());
Map<String, IntSummaryStatistics> collect1 = collect.stream().collect(Collectors.groupingBy(LivelihoodLawCounty::getRegionCode, Collectors.summarizingInt(LivelihoodLawCounty::getStatisticsSum)));
return collect1;
}
list排序
最新推荐文章于 2024-08-09 09:30:00 发布