This commit is contained in:
parent
f6509b5e19
commit
8980f61b1c
|
@ -46,6 +46,7 @@ import io.renren.modules.sys.dao.SysDeptDao;
|
|||
import io.renren.modules.sys.dto.SysUserDTO;
|
||||
import io.renren.modules.sys.service.SysDeptService;
|
||||
import io.renren.modules.sys.service.SysUserService;
|
||||
import lombok.SneakyThrows;
|
||||
import okhttp3.*;
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
|
@ -453,14 +454,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
/**
|
||||
* 从本库内查询
|
||||
*/
|
||||
@SneakyThrows
|
||||
private Page<ResourceDTO> common(Page<ResourceDTO> resultPage, List<Map> selectDTOPageSpecilTotal, ResourceDTO resourceDTO, String orderField, String orderType, Integer pageNum, Integer pageSize) {
|
||||
if (resourceDTO.getInfoList().isEmpty()) {
|
||||
List<ResourceDTO> resourceDTOS;
|
||||
if (orderField.equals("total")) { // 对总体评价特殊处理
|
||||
List<Long> ids = new CopyOnWriteArrayList<>();
|
||||
ForkJoinPool customThreadPool = new ForkJoinPool(CPU_NUM * 3);
|
||||
switch (orderType.toUpperCase()) {
|
||||
case "DESC": // total 倒序
|
||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
||||
ids = customThreadPool.submit(() -> {
|
||||
List<Long> temp = 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);
|
||||
|
@ -468,15 +472,35 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x ->
|
||||
Long.valueOf(x.get("id").toString())
|
||||
).limit(pageSize).collect(Collectors.toList());
|
||||
return temp;
|
||||
}).get();
|
||||
// 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;
|
||||
case "ASC": // total 升序
|
||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
||||
ids = customThreadPool.submit(() -> {
|
||||
List<Long> temp = 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());
|
||||
return temp;
|
||||
}).get();
|
||||
// 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;
|
||||
}
|
||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
|
||||
|
@ -491,6 +515,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
return index.getTotal() == null ? 0L : index.getTotal();
|
||||
})).collect(Collectors.toList()));
|
||||
}
|
||||
customThreadPool.shutdown();
|
||||
} else { // 非总体评价排序时
|
||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType, null);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue