Commit 5a13ce49 authored by 刘林's avatar 刘林

fix(jg):人员查询报错问题处理,监察处置添加单位,综合查询导出优化1

parent b38b8c0c
......@@ -2241,15 +2241,23 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.queryByRoleId(String.join(",", JIAN_CHA_ROLE_ID), null,
true, true, "", buildOrgCodePrefixes(orgCode)).getResult();
if (!ValidationUtil.isEmpty(taskExecutor)) {
String companyCodes = taskExecutor.stream()
Optional<String> companyCodeOpt = taskExecutor.stream()
.map(AgencyUserModel::getCompanys)
.filter(Objects::nonNull)
.filter(list -> !list.isEmpty())
.map(list -> list.get(0).getCompanyCode())
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.joining(","));
dto.setNextExecuteUserCompanyCode(companyCodes);
.filter(list -> list != null && !list.isEmpty())
.flatMap(List::stream)
.filter(c -> "county".equalsIgnoreCase(c.getLevel()))
.map(CompanyModel::getCompanyCode)
.findFirst();
if (!companyCodeOpt.isPresent()) {
companyCodeOpt = taskExecutor.stream()
.map(AgencyUserModel::getCompanys)
.filter(list -> list != null && !list.isEmpty())
.flatMap(List::stream)
.filter(c -> "prefecture-level".equalsIgnoreCase(c.getLevel()))
.map(CompanyModel::getCompanyCode)
.findFirst();
}
companyCodeOpt.ifPresent(dto::setNextExecuteUserCompanyCode);
}
dto.setResultCode("approvalStatus");
map.put("approvalStatus", "9");
......
......@@ -2592,7 +2592,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
.fluentPut("time", new Date().getTime()));
}
public JSONArray exportDataAsyncBatchSearch(JSONObject filter) {
public JSONArray exportDataAsyncBatchSearch1(JSONObject filter) {
JSONArray result = new JSONArray();
int pageSize = 1000;
// 查询首页数据
......@@ -2636,6 +2636,61 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return result;
}
public JSONArray exportDataAsyncBatchSearch(JSONObject filter) {
JSONArray result = new JSONArray();
int batchSize = 5000; // 每页记录数,根据数据量可调大一些
// 查询第一页
filter.fluentPut("size", batchSize).fluentPut("current", 1);
JSONObject firstPage = this.queryForPage(filter);
JSONObject pageData = firstPage.getJSONObject("pageData");
result.addAll(pageData.getJSONArray("records"));
long total = pageData.getLong("total");
int totalPage = (int) Math.ceil((double) total / batchSize);
if (totalPage <= 1) return result; // 只有一页,直接返回
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
// 计算批次,每批处理 N 页,减少线程压力
int batchThreads = Math.min(totalPage - 1, Runtime.getRuntime().availableProcessors());
int pagesPerThread = (int) Math.ceil((double)(totalPage - 1) / batchThreads);
List<CompletableFuture<JSONArray>> futures = new ArrayList<>();
for (int i = 0; i < batchThreads; i++) {
int startPage = 2 + i * pagesPerThread;
int endPage = Math.min(startPage + pagesPerThread - 1, totalPage);
CompletableFuture<JSONArray> future = CompletableFuture.supplyAsync(() -> {
contextWrapper.apply(); // 恢复上下文一次
JSONArray batchResult = new JSONArray();
for (int page = startPage; page <= endPage; page++) {
filter.fluentPut("current", page);
JSONObject pageJson = this.queryForPage(filter);
JSONArray records = pageJson.getJSONObject("pageData").getJSONArray("records");
batchResult.addAll(records);
}
return batchResult;
}, executorService);
futures.add(future);
}
// 等待所有线程完成
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
// 收集结果
for (CompletableFuture<JSONArray> future : futures) {
try {
result.addAll(future.get());
} catch (Exception e) {
log.error("分页查询线程执行失败", e);
}
}
return result;
}
private static MultipartFile getEquipMultipartFile(JSONArray records, String fileName, String sheetName) {
MultipartFile templateExcelFile;
List<EquipInfoVo> exportData = new ArrayList<>();
......@@ -2660,7 +2715,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
.ifPresent(equipInfoVo::setRECORD);
// 技术参数
if (!equip.getJSONArray("techParams").isEmpty()) {
JSONArray techParams = equip.getJSONArray("techParams");
if (techParams != null && !techParams.isEmpty()) {
JSONObject paramsJson = new JSONObject();
equip.getJSONArray("techParams").forEach(techParam -> {
ESEquipmentInfo.TechParam techParamItem = JSONObject.parseObject(JSON.toJSONString(techParam), ESEquipmentInfo.TechParam.class);
......@@ -4628,4 +4684,5 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
// 去重并返回
return esIds.stream().distinct().collect(Collectors.toList());
}
}
\ No newline at end of file
......@@ -343,6 +343,7 @@
<foreach collection="postList" item="item" separator=",">
#{item}
</foreach>
]
</if>
<if test="filter.postCode != null and filter.postCode != ''">
and u.new_post like concat('%',#{filter.postCode}, '%')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment