300行代码手撸SpringBoot核心原理:自动装配与内嵌Tomcat
2026/9/16 15:03:47
// map xx+yy形式Map<String,VehicleRecordNumVO>vehicleRecordNumVOMap=vehicleRecordNumVOList.stream().collect(Collectors.toMap(v->v.getAppletUserId()+"-"+v.getVehiclePlate(),vehicleRecordNumVO->vehicleRecordNumVO));// map xx形式Map<String,MyVehicle>myVehicleMap=myVehicleList.stream().collect(Collectors.toMap(MyVehicle::getPlateNum,myVehicle->myVehicle));Map<String,List<MyVehicle>>myVehicleMap=myVehicleList.stream().collect(Collectors.groupingBy(MyVehicle::getAppletUserId));// list过滤List<EnterpriseCarInfo>uniqueMyVehicleList=uniqueList.stream().collect(Collectors.toMap(v->v.getPlateNum()+"_"+v.getVehicleColor(),// 作为唯一 keyv->v,(existing,replacement)->existing// 如果重复,保留第一个)).values().stream().collect(Collectors.toList());Map<String,Refund>refundMap=refundList.stream().collect(Collectors.toMap(Refund::getOutTradeNo,refund->refund,(existing,replacement)->replacement// 遇到重复key时,保留新值(覆盖旧值)));importjava.text.Collator;importjava.util.Locale;// 查询后手动排序List<PersonalPerformance>result=repository.findBySectionDeptIdAndMonthAndUserIdInAndDelFlag(sectionDeptId,month,userIds,delFlag);// 使用中文拼音排序Collatorcollator=Collator.getInstance(Locale.CHINA);result.sort((a,b)->{intscoreCompare=Integer.compare(b.getScore(),a.getScore());// descif(scoreCompare!=0)returnscoreCompare;returncollator.compare(a.getUserName(),b.getUserName());// 拼音升序});