feat: There is no way the, 重置ES

This commit is contained in:
super_liu
2022-03-07 17:33:25 +08:00
parent 291ade6b35
commit 69c2d4c6e2
4 changed files with 45 additions and 4 deletions
@@ -110,6 +110,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
addInterceptor.excludePathPatterns("/api/lawss/activiti/loginMobile");
// 重置ES
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetALLSearchCenter");
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetAStandSearchCenter");
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetBLawsSearchCenter");
addInterceptor.excludePathPatterns("/api/search/resetSearchCenter/resetCBussStandSearchCenter");
@@ -23,6 +23,11 @@ public class ResetSearchCenterController extends BaseController<Map<String, Obje
@Autowired
private ResetSearchCenterService resetSearchCenterService;
@ApiOperation(value = "|SearchCenter|重新创建ALL标准数据索引")
@PostMapping(value="/resetALLSearchCenter")
public ResponseMessage resetALLSearchCenter() throws Exception{
return resetSearchCenterService.resetALLSearchCenter();
}
@ApiOperation(value = "|SearchCenter|重新创建国内外标准数据索引")
@PostMapping(value="/resetAStandSearchCenter")
@@ -16,10 +16,12 @@ import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.transport.TransportClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -28,6 +30,7 @@ import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("resetSearchCenterService")
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
@@ -61,7 +64,31 @@ public class ResetSearchCenterService {
client = this.transportClient;
}
@Async
public ResponseMessage resetALLSearchCenter() throws Exception{
ResponseMessage stand = resetStandSearchCenter(new SarStandardsInfoEOPage());
List<String> r = new ArrayList<>();
if(stand.isOk() && StringUtils.isNotBlank(stand.getData().toString())){
r.add(stand.getData().toString());
}
ResponseMessage laws = resetLawsSearchCenter(new SarLawsStandInfoPage());
if(laws.isOk() && StringUtils.isNotBlank(laws.getData().toString())){
r.add(laws.getData().toString());
}
ResponseMessage buss = resetBussStandSearchCenter(new SarBussionessStandEOPage());
if(buss.isOk() && StringUtils.isNotBlank(buss.getData().toString())){
r.add(buss.getData().toString());
}
String res = String.join(", ", r);
return Result.success(res);
}
//重建国内外标准
@Async
public ResponseMessage resetStandSearchCenter(SarStandardsInfoEOPage page) throws Exception{
Boolean getStandIndex = elasticsearchService.isIndexExist("stand");
if(getStandIndex){
@@ -85,9 +112,10 @@ public class ResetSearchCenterService {
}
}
return Result.success("重置:"+ countSuccess + "");
return Result.success("重置国内外"+ countSuccess + "");
}
@Async
public ResponseMessage resetLawsSearchCenter(SarLawsStandInfoPage sarLawsInfoEOPage) throws Exception{
Boolean getLawsIndex = elasticsearchService.isIndexExist("laws");
if(getLawsIndex){
@@ -110,9 +138,10 @@ public class ResetSearchCenterService {
}
}
return Result.success("重置:"+ countSuccess + "");
return Result.success("重置国内外政策"+ countSuccess + "");
}
@Async
public ResponseMessage resetBussStandSearchCenter(SarBussionessStandEOPage sarBussionessStandEOPage) throws Exception{
Boolean getbussstandIndex = elasticsearchService.isIndexExist("bussstand");
int number = 0;
@@ -135,9 +164,10 @@ public class ResetSearchCenterService {
if (getAllList != null && !getAllList.isEmpty()) {
sendESForBussStand(getAllList,countSuccess);
}
return Result.success("重置:"+ number + "");
return Result.success("重置企标"+ number + "");
}
@Async
public void sendESForBussStand(List<SarBussionessStand> getAllList,int countSuccess) throws Exception {
for(SarBussionessStand sarBussionessStandEO : getAllList){
countSuccess++;
@@ -98,7 +98,12 @@ public class SysInfoEOService {
String names = "";
if (StringUtils.isNotBlank(codes)) {
String[] idArr = codes.split(",");
names = dicTypeEODao.getDicNamesByCodes(Arrays.asList(idArr));
String names1 = dicTypeEODao.getDicNamesByCodes(Arrays.asList(idArr));
if(StringUtils.isNotBlank(names1) && names1.contains(",")){
List<String> list1 = Arrays.asList(names1.split(","));
List<String> list = list1.stream().distinct().collect(Collectors.toList());
names = String.join(",",list);
}
}
return names;
}