feat: There is no way the, rest es conf
This commit is contained in:
@@ -18,6 +18,7 @@ import com.adc.da.util.http.ResponseMessage;
|
|||||||
import com.adc.da.util.http.Result;
|
import com.adc.da.util.http.Result;
|
||||||
import com.adc.da.utils.util.DateUtil;
|
import com.adc.da.utils.util.DateUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
@@ -91,6 +92,49 @@ public class ResetSearchCenterService {
|
|||||||
return Result.success(res);
|
return Result.success(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public ResponseMessage syncResetALLSearchCenter(SearchCenter searchCenter) throws Exception{
|
||||||
|
Boolean getFulltextserchIndex = elasticsearchService.isIndexExist("fulltextserch");
|
||||||
|
SearchCenter standSearch = new SearchCenter();
|
||||||
|
QueryWrapper qw = new QueryWrapper();
|
||||||
|
qw.eq("VALID_FLAG","0");
|
||||||
|
int count = iSarStandardsInfoService.count(qw);
|
||||||
|
standSearch.setExecType(searchCenter.getExecType());
|
||||||
|
standSearch.setCountStand(count);
|
||||||
|
ResponseMessage stand = resetStandSearchCenter(new SarStandardsInfoEOPage(),standSearch);
|
||||||
|
List<String> r = new ArrayList<>();
|
||||||
|
if(stand.isOk() && StringUtils.isNotBlank(stand.getData().toString())){
|
||||||
|
r.add(stand.getData().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchCenter lawsSearch = new SearchCenter();
|
||||||
|
QueryWrapper qw2 = new QueryWrapper();
|
||||||
|
qw2.eq("VALID_FLAG","0");
|
||||||
|
int count2 = iSarLawsStandInfoService.count(qw2);
|
||||||
|
lawsSearch.setExecType(searchCenter.getExecType());
|
||||||
|
lawsSearch.setCountStand(count2);
|
||||||
|
ResponseMessage laws = resetLawsSearchCenter(new SarLawsStandInfoPage(),lawsSearch);
|
||||||
|
if(laws.isOk() && StringUtils.isNotBlank(laws.getData().toString())){
|
||||||
|
r.add(laws.getData().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchCenter bussSearch = new SearchCenter();
|
||||||
|
QueryWrapper qw3 = new QueryWrapper();
|
||||||
|
qw3.eq("VALID_FLAG","0");
|
||||||
|
int count3 = iSarBussionessStandService.count(qw3);
|
||||||
|
bussSearch.setExecType(searchCenter.getExecType());
|
||||||
|
bussSearch.setCountStand(count3);
|
||||||
|
ResponseMessage buss = resetBussStandSearchCenter(new SarBussionessStandEOPage(),bussSearch);
|
||||||
|
if(buss.isOk() && StringUtils.isNotBlank(buss.getData().toString())){
|
||||||
|
r.add(buss.getData().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
String res = String.join(", ", r);
|
||||||
|
logger.info(res);
|
||||||
|
|
||||||
|
return Result.success(res);
|
||||||
|
}
|
||||||
|
|
||||||
//重建国内外标准
|
//重建国内外标准
|
||||||
@Async
|
@Async
|
||||||
public ResponseMessage resetStandSearchCenter(SarStandardsInfoEOPage page,SearchCenter searchCenter) throws Exception{
|
public ResponseMessage resetStandSearchCenter(SarStandardsInfoEOPage page,SearchCenter searchCenter) throws Exception{
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.adc.da.search.sync;
|
||||||
|
|
||||||
|
import com.adc.da.search.bean.SearchCenter;
|
||||||
|
import com.adc.da.search.server.ResetSearchCenterService;
|
||||||
|
import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao;
|
||||||
|
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||||
|
import com.adc.da.slrs.sarBussionessStandState.entity.SarBussionessStandState;
|
||||||
|
import com.adc.da.slrs.sarBussionessStandState.service.ISarBussionessStandStateService;
|
||||||
|
import com.adc.da.utils.util.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: TODO
|
||||||
|
* @author: super_liu
|
||||||
|
* @date: 2022年01月25日 3:34
|
||||||
|
*/
|
||||||
|
@EnableScheduling
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class restSearchSync {
|
||||||
|
Logger logger = LoggerFactory.getLogger(restSearchSync.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResetSearchCenterService resetSearchCenterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置文件设置是否开启定时器
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Value("${isNotScheduled}")
|
||||||
|
private boolean isNotScheduled; //是否开启定时器
|
||||||
|
|
||||||
|
|
||||||
|
// 每天0点1分执行 重置ES 自动更新、新增、删除
|
||||||
|
// @Scheduled(cron="0 0 1 1 * ?")
|
||||||
|
@Scheduled(cron = "0 1 0 * * ?")
|
||||||
|
@Async
|
||||||
|
public void StandScheduledJobMonthBegin(){
|
||||||
|
if(isNotScheduled){
|
||||||
|
try{
|
||||||
|
Thread.sleep(2000);
|
||||||
|
logger.info("每天0点1分执行 重置ES 自动更新、新增、删除:"+Thread.currentThread().getName() + " cron=0 1 0 * * ? --- " + new Date()+"---START-01");
|
||||||
|
|
||||||
|
SearchCenter searchCenter = new SearchCenter();
|
||||||
|
// ALL 执行全部
|
||||||
|
searchCenter.setExecType("ALL");
|
||||||
|
resetSearchCenterService.syncResetALLSearchCenter(searchCenter);
|
||||||
|
|
||||||
|
logger.info("每天0点1分执行 重置ES 自动更新、新增、删除:"+Thread.currentThread().getName() + " cron=0 1 0 * * ? --- " + new Date()+"---End-01");
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.info(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user