Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-08-08 09:59:00 +08:00
commit f0eb0e7740
1 changed files with 15 additions and 48 deletions

View File

@ -459,60 +459,27 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<ResourceDTO> resourceDTOS; List<ResourceDTO> resourceDTOS;
if (orderField.equals("total")) { // 对总体评价特殊处理 if (orderField.equals("total")) { // 对总体评价特殊处理
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
ForkJoinPool customThreadPool = new ForkJoinPool(CPU_NUM * 2);
switch (orderType.toUpperCase()) { switch (orderType.toUpperCase()) {
case "DESC": // total 倒序 case "DESC": // total 倒序
try { ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
ids = (List<Long>) customThreadPool.submit(() -> { Map index = (Map) x;
selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { String string = (index.get("total") == null) ? "0" : index.get("total").toString();
Map index = (Map) x; return Long.valueOf(string);
String string = (index.get("total") == null) ? "0" : index.get("total").toString(); }
return Long.valueOf(string); ).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x ->
} Long.valueOf(x.get("id").toString())
).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> ).limit(pageSize).collect(Collectors.toList());
Long.valueOf(x.get("id").toString())
).limit(pageSize).collect(Collectors.toList());
}).get();
} catch (InterruptedException e) {
logger.error("InterruptedException", e);
} catch (ExecutionException e) {
logger.error("ExecutionException", e);
}
// ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
// Map index = (Map) x;
// String string = (index.get("total") == null) ? "0" : index.get("total").toString();
// return Long.valueOf(string);
// }
// ).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x ->
// Long.valueOf(x.get("id").toString())
// ).limit(pageSize).collect(Collectors.toList());
break; break;
case "ASC": // total 升序 case "ASC": // total 升序
try { ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
ids = (List<Long>) customThreadPool.submit(() -> { String string = (x.get("total") == null) ? "0" : x.get("total").toString();
selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> { return Long.valueOf(string);
String string = (x.get("total") == null) ? "0" : x.get("total").toString(); }
return Long.valueOf(string); )).skip((pageNum - 1) * pageSize).limit(pageSize).map(x ->
} Long.valueOf(x.get("id").toString())
)).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> ).limit(pageSize).collect(Collectors.toList());
Long.valueOf(x.get("id").toString())
).limit(pageSize).collect(Collectors.toList());
}).get();
} catch (InterruptedException e) {
logger.error("InterruptedException", e);
} catch (ExecutionException e) {
logger.error("ExecutionException", e);
}
// ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
// String string = (x.get("total") == null) ? "0" : x.get("total").toString();
// return Long.valueOf(string);
// }
// )).skip((pageNum - 1) * pageSize).limit(pageSize).map(x ->
// Long.valueOf(x.get("id").toString())
// ).limit(pageSize).collect(Collectors.toList());
break; break;
} }
customThreadPool.shutdown();
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids); resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
if ("DESC".equals(orderType)) { if ("DESC".equals(orderType)) {
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> { resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {