Merge branch 'develop_migration' into 'develop_master'
feat: There is no way the, 重置ES 添加 删除 See merge request LiuChao/foton-slrs-system-rest!447
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/${restPath}/search/resetSearchCenter")
|
||||
@Api(description = "搜索中心重置索引及数据+实施预警触发")
|
||||
@Api(tags = "搜索中心重置索引及数据")
|
||||
public class ResetSearchCenterController extends BaseController<Map<String, Object>> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ResetSearchCenterController.class);
|
||||
@@ -41,7 +41,7 @@ public class ResetSearchCenterController extends BaseController<Map<String, Obje
|
||||
|
||||
private ResponseMessage verifySearchCenter(SearchCenter searchCenter) {
|
||||
if(searchCenter.getExecType() == null || "".equals(searchCenter.getExecType())){
|
||||
return Result.error("执行参数 ALL 存在更新 不存在新增 ,UPD 只 更新存在 es 里的标准 ,ADD 只新增不存在 es 的标准");
|
||||
return Result.error("执行参数 ALL 存在更新 不存在新增 ,UPD 只 更新存在 es 里的标准 ,ADD 只新增不存在 es 的标准, DEL 只删除不存在标准库的数据");
|
||||
}
|
||||
|
||||
if(searchCenter.getCountStand() == null || searchCenter.getCountStand() == 0){
|
||||
|
||||
@@ -118,6 +118,8 @@ public class ResetSearchCenterService {
|
||||
List<SarStandardsInfo> rowsStand = iSarStandardsInfoService.getSarStandardsInfoPage(page);
|
||||
List<SarStandardsInfo> insList = new ArrayList<>();
|
||||
List<SarStandardsInfo> updList = new ArrayList<>();
|
||||
List<String> delList = new ArrayList<>();
|
||||
List<String> standIdList = rowsStand.stream().map(SarStandardsInfo::getId).collect(Collectors.toList());
|
||||
if(!esIdList.isEmpty()){
|
||||
|
||||
// 差集 (list1 - list2) 新增
|
||||
@@ -134,12 +136,17 @@ public class ResetSearchCenterService {
|
||||
.collect(Collectors.toList());
|
||||
updList.addAll(intersection);
|
||||
|
||||
// 差集 (list2 - list1) 删除
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
delList.addAll(delDataList);
|
||||
|
||||
}else {
|
||||
// 新增
|
||||
insList.addAll(rowsStand);
|
||||
}
|
||||
|
||||
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType()) || "UPD".equals(searchCenter.getExecType()))){
|
||||
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
for(SarStandardsInfo sarStandardsInfoEO : updList){
|
||||
countUpdateSuccess++;
|
||||
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
|
||||
@@ -149,7 +156,7 @@ public class ResetSearchCenterService {
|
||||
}
|
||||
}
|
||||
|
||||
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType()) || "ADD".equals(searchCenter.getExecType()))){
|
||||
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
for(SarStandardsInfo sarStandardsInfoEO : insList){
|
||||
countAddSuccess++;
|
||||
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
|
||||
@@ -158,8 +165,13 @@ public class ResetSearchCenterService {
|
||||
createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
|
||||
}
|
||||
}
|
||||
logger.info("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+rowsStand.size()+"条)");
|
||||
return Result.success("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+rowsStand.size()+"条)");
|
||||
|
||||
if(!delList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "DEL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
elasticsearchService.deleteBatchId(delList,"stand");
|
||||
elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
}
|
||||
logger.info("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
|
||||
return Result.success("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
|
||||
}
|
||||
|
||||
@Async
|
||||
@@ -181,6 +193,9 @@ public class ResetSearchCenterService {
|
||||
List<SarLawsStandInfo> rowsStand = iSarLawsStandInfoService.getSarStandardsInfoPage(sarLawsInfoEOPage);
|
||||
List<SarLawsStandInfo> insList = new ArrayList<>();
|
||||
List<SarLawsStandInfo> updList = new ArrayList<>();
|
||||
List<String> delList = new ArrayList<>();
|
||||
List<String> standIdList = rowsStand.stream().map(SarLawsStandInfo::getId).collect(Collectors.toList());
|
||||
|
||||
if(!esIdList.isEmpty()){
|
||||
|
||||
// 差集 (list1 - list2) 新增
|
||||
@@ -197,12 +212,17 @@ public class ResetSearchCenterService {
|
||||
.collect(Collectors.toList());
|
||||
updList.addAll(intersection);
|
||||
|
||||
// 差集 (list2 - list1) 删除
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
delList.addAll(delDataList);
|
||||
|
||||
}else {
|
||||
// 新增
|
||||
insList.addAll(rowsStand);
|
||||
}
|
||||
|
||||
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType()) || "UPD".equals(searchCenter.getExecType()))){
|
||||
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
for(SarLawsStandInfo sarLawsInfoEO : updList){
|
||||
countUpdateSuccess++;
|
||||
if (sarLawsInfoEO.getAttrInfoMap() != null) {
|
||||
@@ -212,7 +232,7 @@ public class ResetSearchCenterService {
|
||||
}
|
||||
}
|
||||
|
||||
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType()) || "ADD".equals(searchCenter.getExecType()))){
|
||||
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
for(SarLawsStandInfo sarLawsInfoEO : insList){
|
||||
countAddSuccess++;
|
||||
if (sarLawsInfoEO.getAttrInfoMap() != null) {
|
||||
@@ -221,8 +241,14 @@ public class ResetSearchCenterService {
|
||||
createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
|
||||
}
|
||||
}
|
||||
logger.info("重置国内外政策:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外政策共:"+rowsStand.size()+"条)");
|
||||
return Result.success("重置国内外政策:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外政策共:"+rowsStand.size()+"条)");
|
||||
|
||||
if(!delList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "DEL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
elasticsearchService.deleteBatchId(delList,"laws");
|
||||
elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
}
|
||||
|
||||
logger.info("重置国内外政策:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外政策共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
|
||||
return Result.success("重置国内外政策:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外政策共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
|
||||
}
|
||||
|
||||
private void idListFunc(SarLawsStandInfoPage sarLawsInfoEOPage, SearchCenter searchCenter) {
|
||||
@@ -256,6 +282,9 @@ public class ResetSearchCenterService {
|
||||
List<SarBussionessStand> rowsStand = iSarBussionessStandService.getSarBussionStandPage(sarBussionessStandEOPage);
|
||||
List<SarBussionessStand> insList = new ArrayList<>();
|
||||
List<SarBussionessStand> updList = new ArrayList<>();
|
||||
List<String> delList = new ArrayList<>();
|
||||
List<String> standIdList = rowsStand.stream().map(SarBussionessStand::getId).collect(Collectors.toList());
|
||||
|
||||
if(!esIdList.isEmpty()){
|
||||
|
||||
// 差集 (list1 - list2) 新增
|
||||
@@ -272,12 +301,17 @@ public class ResetSearchCenterService {
|
||||
.collect(Collectors.toList());
|
||||
updList.addAll(intersection);
|
||||
|
||||
// 差集 (list2 - list1) 删除
|
||||
List<String> delDataList = esIdList.stream().filter(num -> !standIdList.contains(num))
|
||||
.collect(Collectors.toList());
|
||||
delList.addAll(delDataList);
|
||||
|
||||
}else {
|
||||
// 新增
|
||||
insList.addAll(rowsStand);
|
||||
}
|
||||
|
||||
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType()) || "UPD".equals(searchCenter.getExecType()))){
|
||||
if(!updList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "UPD".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
for(SarBussionessStand sarBussionessStandEO : updList){
|
||||
countUpdateSuccess++;
|
||||
if (sarBussionessStandEO.getAttrInfoMap() != null) {
|
||||
@@ -287,7 +321,7 @@ public class ResetSearchCenterService {
|
||||
}
|
||||
}
|
||||
|
||||
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType()) || "ADD".equals(searchCenter.getExecType()))){
|
||||
if(!insList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "ADD".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
for(SarBussionessStand sarBussionessStandEO : insList){
|
||||
countAddSuccess++;
|
||||
if (sarBussionessStandEO.getAttrInfoMap() != null) {
|
||||
@@ -296,8 +330,13 @@ public class ResetSearchCenterService {
|
||||
createStandMQService.sendBussStandMQ(sarBussionessStandEO,"add");
|
||||
}
|
||||
}
|
||||
logger.info("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)");
|
||||
return Result.success("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)");
|
||||
|
||||
if(!delList.isEmpty() && ("ALL".equals(searchCenter.getExecType().toUpperCase()) || "DEL".equals(searchCenter.getExecType().toUpperCase()))){
|
||||
elasticsearchService.deleteBatchId(delList,"bussstand");
|
||||
elasticsearchService.deleteBatchId(delList,"fulltextserch");
|
||||
}
|
||||
logger.info("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
|
||||
return Result.success("重置企标:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(企标共:"+rowsStand.size()+"条)删除-共"+delList.size()+"条数据");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user