当前位置: 首页 > wzjs >正文

陕西建设官方网站免费推广网站2023mmm

陕西建设官方网站,免费推广网站2023mmm,政府门户网站建设对策建议,精品网络小说推荐写在前面的话&#xff1a;减少strean流操作&#xff0c;减少多层嵌套for循环。使用普通for循环和map的方式进行转换&#xff0c; 第一步查询数据 List<Student> findList studentDao.findList(findMap); 第二步准备遍历和赋值 if(CollectionUtil.isNotEmpty(findLis…

写在前面的话:减少strean流操作,减少多层嵌套for循环。使用普通for循环和map的方式进行转换,

第一步查询数据

List<Student> findList = studentDao.findList(findMap);

第二步准备遍历和赋值

if(CollectionUtil.isNotEmpty(findList)){// 第一次遍历,取出所有待翻译的字段,避免重复使用steam流取值Set<String> courseSet = new HashSet<>(16);Set<String> schooldSet = new HashSet<>(16);Set<String> nativePlaceSet = new HashSet<>(16);for (Student student : findList) {// 课程idString courseId = student.getSourceId();if(StringUtil.isNotEmpty(courseId)){courseSet.add(courseId);}// 学校idString schooldId = student.getSchoold();if(StringUtil.isNotEmpty(schooldId)){schooldSet.add(schooldId);}// 籍贯idString nativePlaceId = student.getNativePlace();if(StringUtil.isNotEmpty(nativePlaceId)){nativePlaceSet.add(nativePlaceId);}}// 查询课程信息、学校信息、籍贯信息,并转换成mapMap<String,Object> findMap = new HashMap<>(16);findMap.put("courseSet",courseSet);findMap.put("schooldSet",schooldSet);findMap.put("nativePlaceSet",nativePlaceSet);List<Course> courseList = courseDao.findList(findMap);List<Schoold> schooldList = schooldDao.findList(findMap);List<NativePlace> nativePlaceList = nativePlaceDao.findList(findMap);// 转换成mapMap<String,Course> courseMap = CollectionUtil.isEmpty(courseList) ? new HashMap<>(0) :courseList.stream().collect(Collectors.toMap(Course::getId, course -> course));Map<String,Schoold> schooldMap = CollectionUtil.isEmpty(schooldList) ? new HashMap<>(0) :courseList.stream().collect(Collectors.toMap(Schoold::getId, schoold -> schoold));Map<String,NativePlace> nativePlaceMap = CollectionUtil.isEmpty(nativePlaceList) ? new HashMap<>(0) :courseList.stream().collect(Collectors.toMap(NativePlace::getId, nativePlace -> nativePlace));// 第二次遍历,填充翻译后的值for (Student student : findList) {// 课程id-->课程名称String courseId = student.getSourceId();if(StringUtil.isNotEmpty(courseId)){student.setSourceName(courseMap.get(courseId).getName());}// 学校id-->学校名称String schooldId = student.getSchoold();if(StringUtil.isNotEmpty(schooldId)){student.setSchooldName(schooldMap.get(schooldId).getName());}// 籍贯id-->籍贯名称String nativePlaceId = student.getNativePlace();if(StringUtil.isNotEmpty(nativePlaceId)){student.setNativePlaceName(nativePlaceMap.get(nativePlaceId).getName());}}}

结语:仅遍历2次,减少了stream流取值。用转map的方式减少了多层for循环。

http://www.dtcms.com/wzjs/296879.html

相关文章:

  • 网站域名更换相应内容seo网站推广主要目的不包括
  • 360怎么做网站搜索群推广
  • 成都网站外包优化公司电商怎么注册开店
  • 做网推的网站免费推广网站
  • 定制建站网站建设域名服务器ip地址查询
  • wordpress aike主题淘宝seo排名优化软件
  • 威县做网站哪家便宜教育培训机构报名
  • 网站建设的公司哪家靠谱网站关键词优化价格
  • 网站白名单查询产品营销网站建设
  • 公司网站需要备案吗友情链接代码
  • 企业网站建设方案包含百度搜索数据
  • 网站反链一般怎么做高端网站建设定制
  • 做JSP网站买什么书营销推广的工具有哪些
  • 河南郑州广告公司网站建设适合网络营销的产品
  • 江苏经营性网站备案深圳seo外包公司
  • 服装企业网站建设策划书自己做网站难吗
  • 商洛网站开发北京seo关键词排名优化
  • 大连开发区盛京医院电话海口seo计费
  • html5 图片网站能搜任何网站的浏览器
  • 云南省建设考试中心网站微信卖货小程序怎么做
  • 网站安排磁力搜索引擎不死鸟
  • 网站创建桌面快捷方式头条号权重查询
  • 微信网站技术方案如何找客户资源
  • 网站html模板免费下载seo快速优化报价
  • 大型网站建设费用国内产女装一线二线品牌知乎
  • 制作精美网站建设售后完善昆山seo网站优化软件
  • 优秀设计师网站站长网站seo查询
  • 泰州高端网站建设丁的老头seo博客
  • 建站快车代理商营销手段有哪些方式
  • 企业邮箱怎么开通注册免费seo排名哪家有名