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.dto.SysUserDTO;
|
||||||
import io.renren.modules.sys.service.SysDeptService;
|
import io.renren.modules.sys.service.SysDeptService;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import org.activiti.engine.HistoryService;
|
import org.activiti.engine.HistoryService;
|
||||||
import org.activiti.engine.history.HistoricProcessInstance;
|
import org.activiti.engine.history.HistoricProcessInstance;
|
||||||
|
@ -408,7 +409,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
String body = response.body().string();
|
String body = response.body().string();
|
||||||
JSONObject jsonObject_ = JSON.parseObject(body);
|
JSONObject jsonObject_ = JSON.parseObject(body);
|
||||||
logger.info("西海岸接口{}返回:{}" , url, body);
|
logger.info("西海岸接口{}返回:{}", url, body);
|
||||||
if (jsonObject_.containsKey("data")) {
|
if (jsonObject_.containsKey("data")) {
|
||||||
if (jsonObject_.getJSONObject("data").containsKey("list")) {
|
if (jsonObject_.getJSONObject("data").containsKey("list")) {
|
||||||
resultPage.setTotal(jsonObject_.getJSONObject("data").getLongValue("total"));
|
resultPage.setTotal(jsonObject_.getJSONObject("data").getLongValue("total"));
|
||||||
|
@ -453,30 +454,53 @@ 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) {
|
private Page<ResourceDTO> common(Page<ResourceDTO> resultPage, List<Map> selectDTOPageSpecilTotal, ResourceDTO resourceDTO, String orderField, String orderType, Integer pageNum, Integer pageSize) {
|
||||||
if (resourceDTO.getInfoList().isEmpty()) {
|
if (resourceDTO.getInfoList().isEmpty()) {
|
||||||
List<ResourceDTO> resourceDTOS;
|
List<ResourceDTO> resourceDTOS;
|
||||||
if (orderField.equals("total")) { // 对总体评价特殊处理
|
if (orderField.equals("total")) { // 对总体评价特殊处理
|
||||||
List<Long> ids = new CopyOnWriteArrayList<>();
|
List<Long> ids = new CopyOnWriteArrayList<>();
|
||||||
|
ForkJoinPool customThreadPool = new ForkJoinPool(CPU_NUM * 3);
|
||||||
switch (orderType.toUpperCase()) {
|
switch (orderType.toUpperCase()) {
|
||||||
case "DESC": // total 倒序
|
case "DESC": // total 倒序
|
||||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
ids = customThreadPool.submit(() -> {
|
||||||
Map index = (Map) x;
|
List<Long> temp = 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());
|
||||||
|
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;
|
break;
|
||||||
case "ASC": // total 升序
|
case "ASC": // total 升序
|
||||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
ids = customThreadPool.submit(() -> {
|
||||||
String string = (x.get("total") == null) ? "0" : x.get("total").toString();
|
List<Long> temp = 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());
|
||||||
|
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;
|
break;
|
||||||
}
|
}
|
||||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
|
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();
|
return index.getTotal() == null ? 0L : index.getTotal();
|
||||||
})).collect(Collectors.toList()));
|
})).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
customThreadPool.shutdown();
|
||||||
} else { // 非总体评价排序时
|
} else { // 非总体评价排序时
|
||||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType, null);
|
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType, null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue