topN按数目逆序

This commit is contained in:
wangliwen 2022-05-25 08:56:53 +08:00
parent b1e9fd607e
commit 61ec67c9a1
1 changed files with 23 additions and 5 deletions

View File

@ -2,6 +2,8 @@ package io.renren.common.controller;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.renren.common.annotation.LogOperation; import io.renren.common.annotation.LogOperation;
import io.renren.common.utils.Result; import io.renren.common.utils.Result;
import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.processForm.service.TAbilityApplicationService;
@ -208,12 +210,20 @@ public class CensusController {
return task; return task;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join(); CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join();
result.sort(Comparator.comparing(x -> result.sort(Comparator.comparing(x -> {
ObjectUtil.length(x.get("provide")) ObjectMapper mapper = new ObjectMapper();
) try {
Map m = mapper.readValue(mapper.writeValueAsString(x), Map.class);
return ObjectUtil.length(m.get("provide"));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
).reversed()
); );
return new Result<List<Map<String, Object>>>().ok(result); return new Result<List<Map<String, Object>>>().ok(result);
} }
@GetMapping("/capabilityShareCapabilitySet") @GetMapping("/capabilityShareCapabilitySet")
@ApiOperation("资源图谱-能力共享方-能力集") @ApiOperation("资源图谱-能力共享方-能力集")
@LogOperation("资源图谱-能力共享方-能力集") @LogOperation("资源图谱-能力共享方-能力集")
@ -270,11 +280,19 @@ public class CensusController {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join(); CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join();
result.sort(Comparator.comparing(x -> result.sort(Comparator.comparing(x ->
ObjectUtil.length(x.get("provide")) {
) ObjectMapper mapper = new ObjectMapper();
try {
Map m = mapper.readValue(mapper.writeValueAsString(x), Map.class);
return ObjectUtil.length(m.get("provide"));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}).reversed()
); );
return new Result<List<Map<String, Object>>>().ok(result); return new Result<List<Map<String, Object>>>().ok(result);
} }
@GetMapping("/capabilitySharingPartyCapabilityType") @GetMapping("/capabilitySharingPartyCapabilityType")
@ApiOperation("资源图谱-能力共享方-能力类型") @ApiOperation("资源图谱-能力共享方-能力类型")
@LogOperation("资源图谱-能力共享方-能力类型") @LogOperation("资源图谱-能力共享方-能力类型")