<p>优化后的代码如下:</p>
<p>private Collection&lt;List&lt;List<Object>&gt;&gt; getSheetDatassss(final String activityId) {
List<MidLevelDemocracyEvaluationVO> midLevelDemocracyEvaluations = getMidLevelDemocracyEvaluations(activityId);
Map&lt;Integer, List&lt;List<Object>&gt;&gt; collect = midLevelDemocracyEvaluations.stream()
.map(this::createDataObjects)
.collect(Collectors.groupingBy(MidLevelDemocracyEvaluationVO::getOrgSort,
Collectors.mapping(Function.identity(), Collectors.toList())));
return collect.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(Map.Entry::getValue)
.collect(Collectors.toList());
}</p>
<p>private List&lt;List<Object>&gt; createDataObjects(final MidLevelDemocracyEvaluationVO midLevelEvaluation) {
return midLevelEvaluation.getExaminerInfos().stream()
.map(examinerInfo -&gt; Arrays.asList(
midLevelEvaluation.getAppraiseeOrgName(),
midLevelEvaluation.getAppraiseeName(),
midLevelEvaluation.getPositionSign(),
examinerInfo.getExaminerName(),
examinerInfo.getExaminerOrgName(),
examinerInfo.getWeight(),
examinerInfo.getWeightGroup()
))
.collect(Collectors.toList());</p>
java代码优化private CollectionListListObject getSheetDatassssfinal String activityId final ListMidLevelDemocracyEvaluationVO midLevelDemocracyEvaluations = getMidLevelDemocracyEvaluationsactivityI

原文地址: http://www.cveoy.top/t/topic/isjV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录