Commit c8aaee3a authored by 刘林's avatar 刘林

fix(jg):修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据

parent cccc4d3d
...@@ -315,8 +315,8 @@ public class DataHandlerController extends BaseController { ...@@ -315,8 +315,8 @@ public class DataHandlerController extends BaseController {
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据", notes = "修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据") @ApiOperation(httpMethod = "PUT", value = "修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据", notes = "修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据")
@PutMapping(value = "/equip/deleteEquipExistDB") @PutMapping(value = "/equip/modifySupervisionOrgBranchCode")
public ResponseModel<Integer> deleteEquipExistDB2(@RequestParam(value = "isDelete",defaultValue = "false") boolean isDelete) { public ResponseModel<Integer> modifySupervisionOrgBranchCode(@RequestParam(value = "isModify",defaultValue = "false") boolean isModify) {
return ResponseHelper.buildResponse(dataHandlerService.deleteEquipExistDB(isDelete)); return ResponseHelper.buildResponse(dataHandlerService.modifySupervisionOrgBranchCode(isModify));
} }
} }
\ No newline at end of file
...@@ -1864,12 +1864,12 @@ public class DataHandlerServiceImpl { ...@@ -1864,12 +1864,12 @@ public class DataHandlerServiceImpl {
List<String> successDeleteList = Collections.synchronizedList(new ArrayList<>()); List<String> successDeleteList = Collections.synchronizedList(new ArrayList<>());
List<List<String>> allDataList = Lists.partition(records, BATCH_SIZE); List<List<String>> allDataList = Lists.partition(records, BATCH_SIZE);
ExecutorService executor = new ThreadPoolExecutor( ExecutorService executor = new ThreadPoolExecutor(
10, // 核心线程数 10,
20, // 最大线程数 20,
60L, TimeUnit.SECONDS, 60L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(1000), // 队列最多允许1000个任务 new LinkedBlockingQueue<>(1000),
Executors.defaultThreadFactory(), Executors.defaultThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略(可换成其他) new ThreadPoolExecutor.CallerRunsPolicy()
); );
CountDownLatch latch = new CountDownLatch(allDataList.size()); CountDownLatch latch = new CountDownLatch(allDataList.size());
...@@ -1967,10 +1967,10 @@ public class DataHandlerServiceImpl { ...@@ -1967,10 +1967,10 @@ public class DataHandlerServiceImpl {
wrapper.select(IdxBizJgOtherInfo::getRecord) wrapper.select(IdxBizJgOtherInfo::getRecord)
.notIn(IdxBizJgOtherInfo::getClaimStatus, "已认领", ""); .notIn(IdxBizJgOtherInfo::getClaimStatus, "已认领", "");
List<IdxBizJgOtherInfo> jgOtherInfos = otherInfoMapper.selectList(wrapper); List<IdxBizJgOtherInfo> jgOtherInfos = otherInfoMapper.selectList(wrapper);
if (CollectionUtils.isEmpty(jgOtherInfos)) { List<String> records = Optional.ofNullable(jgOtherInfos)
return 0; .orElse(Collections.emptyList())
} .stream()
List<String> records = jgOtherInfos.stream() .filter(Objects::nonNull)
.map(IdxBizJgOtherInfo::getRecord) .map(IdxBizJgOtherInfo::getRecord)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toList()); .collect(Collectors.toList());
...@@ -1979,4 +1979,67 @@ public class DataHandlerServiceImpl { ...@@ -1979,4 +1979,67 @@ public class DataHandlerServiceImpl {
} }
return records.size(); return records.size();
} }
public Integer modifySupervisionOrgBranchCode(boolean isModify) {
// 1. 查询 SuperviseInfo 中 orgBranchCode like "50*X" 的记录
List<SuperviseInfo> supervisionInfos = superviseInfoMapper.selectList(
new LambdaQueryWrapper<SuperviseInfo>()
.select(SuperviseInfo::getRecord)
.like(SuperviseInfo::getOrgBranchCode, "50*X")
);
Set<String> records = supervisionInfos.stream()
.map(SuperviseInfo::getRecord)
.filter(StringUtils::isNotEmpty)
.collect(Collectors.toSet());
if (records.isEmpty()) {
return 0;
}
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery()
.must(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", records));
List<ESEquipmentCategoryDto> esResults;
try {
esResults = registrationManageService.searchResponse(
IDX_BIZ_VIEW_JG_ALL,
boolQuery,
hit -> JSONObject.parseObject(hit.getSourceAsString(), ESEquipmentCategoryDto.class)
);
} catch (Exception ex) {
log.error("ES 查询异常: {}", ex.getMessage(), ex);
throw new RuntimeException("ES 查询失败", ex);
}
List<Map<String, Object>> updateList = esResults.stream()
.filter(dto -> StringUtils.isNotEmpty(dto.getORG_BRANCH_CODE())
&& StringUtils.isNotEmpty(dto.getSEQUENCE_NBR())
)
.map(this::buildUpdateMap)
.collect(Collectors.toList());
if (updateList.isEmpty()) {
return 0;
}
int updateCount = 0;
List<List<Map<String, Object>>> partitions = Lists.partition(updateList, BATCH_SIZE);
for (List<Map<String, Object>> batch : partitions) {
if (isModify) {
int count = superviseInfoMapper.batchUpdateOrgBranch(batch);
updateCount += count;
log.info("更新批次:{}, 成功记录数:{}", batch.size(), count);
}
}
return updateList.size();
}
private Map<String, Object> buildUpdateMap(ESEquipmentCategoryDto dto) {
Map<String, Object> map = new HashMap<>();
map.put("record", dto.getSEQUENCE_NBR());
map.put("orgBranchCode", dto.getORG_BRANCH_CODE());
map.put("orgBranchName", dto.getORG_BRANCH_NAME());
return map;
}
} }
...@@ -20,6 +20,8 @@ public interface SuperviseInfoMapper extends BaseMapper<SuperviseInfo> { ...@@ -20,6 +20,8 @@ public interface SuperviseInfoMapper extends BaseMapper<SuperviseInfo> {
void batchUpdateRecordOrgBranch(@Param("recordList") List<String> recordList); void batchUpdateRecordOrgBranch(@Param("recordList") List<String> recordList);
int batchUpdateOrgBranch(@Param("list") List<Map<String, Object>> list);
List<Map<String,Object>> selectUnitCodeList(@Param("records") List<String> records); List<Map<String,Object>> selectUnitCodeList(@Param("records") List<String> records);
List<String> selectSuperviseCodeList(@Param("records") List<String> records); List<String> selectSuperviseCodeList(@Param("records") List<String> records);
......
...@@ -17,6 +17,25 @@ ...@@ -17,6 +17,25 @@
</foreach> </foreach>
</update> </update>
<update id="batchUpdateOrgBranch">
UPDATE idx_biz_jg_supervision_info
SET
ORG_BRANCH_CODE = CASE RECORD
<foreach collection="list" item="item">
WHEN #{item.record} THEN #{item.orgBranchCode}
</foreach>
END,
ORG_BRANCH_NAME = CASE RECORD
<foreach collection="list" item="item">
WHEN #{item.record} THEN #{item.orgBranchName}
</foreach>
END
WHERE RECORD IN
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item.record}
</foreach>
</update>
<update id="updateEsRecordBatch"> <update id="updateEsRecordBatch">
UPDATE idx_biz_jg_use_info SET "IS_NOT_ES" = 1 WHERE "RECORD" IN UPDATE idx_biz_jg_use_info SET "IS_NOT_ES" = 1 WHERE "RECORD" IN
<foreach collection="recordList" separator="," item="record" open="(" close=")"> <foreach collection="recordList" separator="," item="record" open="(" close=")">
......
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