删除索引信息

This commit is contained in:
zhangjun
2022-10-12 12:09:05 +08:00
parent 5f6fa80e16
commit 8f74bbfbd9
@@ -45,6 +45,8 @@ import org.elasticsearch.client.transport.TransportClient;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -571,6 +573,16 @@ public class ResetSearchCenterService {
page.setMenuId("nomenu");
page.setStandType("ALL");
List<SarStandardsInfo> rowsStand = iSarStandardsInfoService.getSarStandardsInfoPage(page);
//如果时自动触发,删除需要根据全部的结果进行数据处理
SarStandardsInfoEOPage infoEOPage = new SarStandardsInfoEOPage();
List<SarStandardsInfo> allStand = null;
if (StringUtils.isNotBlank(page.getSyncParam())) {
BeanUtils.copyProperties(page, infoEOPage);
infoEOPage.setSyncParam(null);
allStand = iSarStandardsInfoService.getSarStandardsInfoPage(infoEOPage);
}
String isAll = null == allStand ? "" : "";
logger.info("是否查询了全部数据信息:" + isAll);
List<SarStandardsInfo> insList = new ArrayList<>();
List<SarStandardsInfo> updList = new ArrayList<>();
List<String> delList = new ArrayList<>();
@@ -603,8 +615,15 @@ public class ResetSearchCenterService {
updList.addAll(intersection);
}
List<String> finalStandIdList = null;
// 差集 (list2 - list1) 删除
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
if (allStand != null && !allStand.isEmpty()) {
finalStandIdList = allStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
}else{
finalStandIdList = rowsStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
}
List<String> finalStandIdList1 = finalStandIdList;
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
.collect(Collectors.toList());
// 可以更新IDLIST 删除 ES
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
@@ -622,7 +641,7 @@ public class ResetSearchCenterService {
for(SarStandardsInfo sarStandardsInfoEO : updList){
countUpdateSuccess++;
standFunc(sarStandardsInfoEO);
createStandMQService.sendStandMQ(sarStandardsInfoEO,"update");
// createStandMQService.sendStandMQ(sarStandardsInfoEO,"update");
}
}
@@ -633,13 +652,15 @@ public class ResetSearchCenterService {
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap()));
}
createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
// createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
}
}
if(!delList.isEmpty() && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
elasticsearchService.deleteBatchId(delList,"stand");
elasticsearchService.deleteBatchId(delList,"fulltextserch");
if(!delList.isEmpty() && !"sync".equals(page.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
// elasticsearchService.deleteBatchId(delList,"stand");
// elasticsearchService.deleteBatchId(delList,"fulltextserch");
logger.info("重置国内外标准:删除-共"+delList.size()+"条数据");
}else{
logger.info("重置国内外标准:没有删除数据,但应该删除"+delList.size()+"条数据");
}
logger.info("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+0+"条)删除-共"+delList.size()+"条数据");
return Result.success("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+0+"条)删除-共"+delList.size()+"条数据");
@@ -1091,6 +1112,16 @@ public class ResetSearchCenterService {
if(count2 > 0){
sarLawsInfoEOPage.setPageSize(count2);
List<SarLawsStandInfo> rowsStand = iSarLawsStandInfoService.getSarStandardsInfoPage(sarLawsInfoEOPage);
//如果时自动触发,删除需要根据全部的结果进行数据处理
SarLawsStandInfoPage infoEOPage = new SarLawsStandInfoPage();
List<SarLawsStandInfo> allStand = null;
if (StringUtils.isNotBlank(sarLawsInfoEOPage.getSyncParam())) {
BeanUtils.copyProperties(sarLawsInfoEOPage, infoEOPage);
infoEOPage.setSyncParam(null);
allStand = iSarLawsStandInfoService.getSarStandardsInfoPage(infoEOPage);
}
String isAll = null == allStand ? "" : "";
logger.info("是否查询了全部数据信息:" + isAll);
List<SarLawsStandInfo> insList = new ArrayList<>();
List<SarLawsStandInfo> updList = new ArrayList<>();
List<String> delList = new ArrayList<>();
@@ -1124,7 +1155,15 @@ public class ResetSearchCenterService {
}
// 差集 (list2 - list1) 删除
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
List<String> finalStandIdList = null;
// 差集 (list2 - list1) 删除
if (allStand != null && !allStand.isEmpty()) {
finalStandIdList = allStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
}else{
finalStandIdList = rowsStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
}
List<String> finalStandIdList1 = finalStandIdList;
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
.collect(Collectors.toList());
// 可以更新IDLIST 删除 ES
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
@@ -1161,7 +1200,7 @@ public class ResetSearchCenterService {
if (sarLawsInfoEO.getAttrInfoMap() != null) {
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
}
createStandMQService.sendLawsMQ(sarLawsInfoEO,"update");
// createStandMQService.sendLawsMQ(sarLawsInfoEO,"update");
}
}
@@ -1191,14 +1230,16 @@ public class ResetSearchCenterService {
if (sarLawsInfoEO.getAttrInfoMap() != null) {
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
}
createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
// createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
}
}
if(!delList.isEmpty() && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
elasticsearchService.deleteBatchId(delList,"laws");
elasticsearchService.deleteBatchId(delList,"fulltextserch");
if(!delList.isEmpty() && !"sync".equals(sarLawsInfoEOPage.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
// elasticsearchService.deleteBatchId(delList,"laws");
// elasticsearchService.deleteBatchId(delList,"fulltextserch");
logger.info("重置国内外政策:删除-共"+delList.size()+"条数据");
}else{
logger.info("重置国内外政策:没有删除数据,但应该删除"+delList.size()+"条数据");
}
logger.info("重置国内外政策:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外政策共:"+rowsStand.size()+"条)数据");
@@ -1673,6 +1714,16 @@ public class ResetSearchCenterService {
sarBussionessStandEOPage.setPageSize(count3);
List<SarBussionessStand> rowsStand = iSarBussionessStandService.getSarBussionStandPage(sarBussionessStandEOPage);
//如果时自动触发,删除需要根据全部的结果进行数据处理
SarBussionessStandEOPage infoEOPage = new SarBussionessStandEOPage();
List<SarBussionessStand> allStand = null;
if (StringUtils.isNotBlank(sarBussionessStandEOPage.getSyncParam())) {
BeanUtils.copyProperties(sarBussionessStandEOPage, infoEOPage);
infoEOPage.setSyncParam(null);
allStand = iSarBussionessStandService.getSarBussionStandPage(infoEOPage);
}
String isAll = null == allStand ? "" : "";
logger.info("是否查询了全部数据信息:" + isAll);
List<SarBussionessStand> insList = new ArrayList<>();
List<SarBussionessStand> updList = new ArrayList<>();
List<String> delList = new ArrayList<>();
@@ -1706,8 +1757,15 @@ public class ResetSearchCenterService {
updList.addAll(intersection);
}
List<String> finalStandIdList = null;
// 差集 (list2 - list1) 删除
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
if (allStand != null && !allStand.isEmpty()) {
finalStandIdList = allStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
}else{
finalStandIdList = rowsStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
}
List<String> finalStandIdList1 = finalStandIdList;
List<String> delDataList = esIdList.stream().filter(num -> !finalStandIdList1.contains(num))
.collect(Collectors.toList());
// 可以更新IDLIST 删除 ES
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty() && "DEL".equals(searchCenter.getExecType().toUpperCase())){
@@ -1742,10 +1800,12 @@ public class ResetSearchCenterService {
}
}
if(!delList.isEmpty() && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
if(!delList.isEmpty() && !"sync".equals(sarBussionessStandEOPage.getSyncParam()) && ("DEL".equals(searchCenter.getExecType().toUpperCase()) || "ALL".equals(searchCenter.getExecType().toUpperCase()))){
elasticsearchService.deleteBatchId(delList,"bussstand");
elasticsearchService.deleteBatchId(delList,"fulltextserch");
logger.info("重置企标:删除-共"+delList.size()+"条数据");
}else{
logger.info("重置企标:没有删除数据,但应该删除"+delList.size()+"条数据");
}
logger.info("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)数据");
return Result.success("");