feat: There is no way the, 重置ES
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.adc.da.search;
|
||||
|
||||
import com.adc.da.base.web.BaseController;
|
||||
import com.adc.da.search.server.ResetSearchCenterService;
|
||||
import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage;
|
||||
import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfoPage;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/${restPath}/search/resetSearchCenter")
|
||||
@Api(description = "搜索中心重置索引及数据+实施预警触发")
|
||||
public class ResetSearchCenterController extends BaseController<Map<String, Object>> {
|
||||
|
||||
@Autowired
|
||||
private ResetSearchCenterService resetSearchCenterService;
|
||||
|
||||
@ApiOperation(value = "|SearchCenter|重新创建国内外标准数据索引")
|
||||
@PostMapping(value="/resetAStandSearchCenter")
|
||||
public ResponseMessage resetStandSearchCenter() throws Exception{
|
||||
SarStandardsInfoEOPage sarStandardsInfoEOPage = new SarStandardsInfoEOPage();
|
||||
return resetSearchCenterService.resetStandSearchCenter(sarStandardsInfoEOPage);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|SearchCenter|重新创建国内外政策数据索引")
|
||||
@PostMapping(value="/resetBLawsSearchCenter")
|
||||
public ResponseMessage resetLawsSearchCenter() throws Exception{
|
||||
SarLawsStandInfoPage sarLawsInfoEOPage = new SarLawsStandInfoPage();
|
||||
return resetSearchCenterService.resetLawsSearchCenter(sarLawsInfoEOPage);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|SearchCenter|重新创建企业标准数据索引")
|
||||
@PostMapping(value="/resetCBussStandSearchCenter")
|
||||
public ResponseMessage resetBussStandSearchCenter() throws Exception{
|
||||
SarBussionessStandEOPage sarBussionessStandEOPage = new SarBussionessStandEOPage();
|
||||
return resetSearchCenterService.resetBussStandSearchCenter(sarBussionessStandEOPage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.adc.da.search.server;
|
||||
|
||||
import com.adc.da.mq.CreateStandMQService;
|
||||
import com.adc.da.search.service.ElasticsearchService;
|
||||
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||
import com.adc.da.slrs.sarBussionessStand.service.ISarBussionessStandService;
|
||||
import com.adc.da.slrs.sarLawsInfo.entity.SarLawsInfo;
|
||||
import com.adc.da.slrs.sarLawsInfo.page.SarLawsInfoEOPage;
|
||||
import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfo;
|
||||
import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfoPage;
|
||||
import com.adc.da.slrs.sarLawsStandInfo.service.ISarLawsStandInfoService;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
|
||||
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfoEOPage;
|
||||
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.elasticsearch.client.transport.TransportClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("resetSearchCenterService")
|
||||
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
||||
public class ResetSearchCenterService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ResetSearchCenterService.class);
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchService elasticsearchService;
|
||||
|
||||
@Autowired
|
||||
private TransportClient transportClient;
|
||||
|
||||
@Autowired
|
||||
private TransportClient client;
|
||||
|
||||
@Autowired
|
||||
private ISarStandardsInfoService iSarStandardsInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISarLawsStandInfoService iSarLawsStandInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISarBussionessStandService iSarBussionessStandService;
|
||||
|
||||
@Autowired
|
||||
private CreateStandMQService createStandMQService;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
client = this.transportClient;
|
||||
}
|
||||
|
||||
//重建国内外标准
|
||||
public ResponseMessage resetStandSearchCenter(SarStandardsInfoEOPage page) throws Exception{
|
||||
Boolean getStandIndex = elasticsearchService.isIndexExist("stand");
|
||||
if(getStandIndex){
|
||||
Boolean deleteStandIndex = elasticsearchService.deleteIndex("stand");
|
||||
}
|
||||
page.setValidFlag("0");
|
||||
// int countStand = sarStandardsInfoEODao.getSarStandardsInfoCount(page);
|
||||
int countStand = 10000;
|
||||
int countSuccess = 0;
|
||||
if(countStand>0){
|
||||
page.setPageSize(countStand);
|
||||
page.setMenuId("nomenu");
|
||||
page.setStandType("ALL");
|
||||
List<SarStandardsInfo> rowsStand = iSarStandardsInfoService.getSarStandardsInfoPage(page);
|
||||
for(SarStandardsInfo sarStandardsInfoEO : rowsStand){
|
||||
countSuccess++;
|
||||
if (sarStandardsInfoEO.getAttrInfoMap() != null) {
|
||||
sarStandardsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarStandardsInfoEO.getAttrInfoMap()));
|
||||
}
|
||||
createStandMQService.sendStandMQ(sarStandardsInfoEO,"add");
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success("重置:"+ countSuccess + "条");
|
||||
}
|
||||
|
||||
public ResponseMessage resetLawsSearchCenter(SarLawsStandInfoPage sarLawsInfoEOPage) throws Exception{
|
||||
Boolean getLawsIndex = elasticsearchService.isIndexExist("laws");
|
||||
if(getLawsIndex){
|
||||
Boolean deleteLawsIndex = elasticsearchService.deleteIndex("laws");
|
||||
}
|
||||
sarLawsInfoEOPage.setLawsType("FOREIGN");
|
||||
// sarLawsInfoEOPage.setMenuId("6bc1632eb6354d4fb725");
|
||||
// int countLaws = sarLawsInfoEODao.queryByCount(sarLawsInfoEOPage);
|
||||
int countLaws = 10000;
|
||||
int countSuccess = 0;
|
||||
if (countLaws>0) {
|
||||
sarLawsInfoEOPage.setPageSize(countLaws);
|
||||
List<SarLawsStandInfo> rowsLaws = iSarLawsStandInfoService.getSarStandardsInfoPage(sarLawsInfoEOPage);
|
||||
for(SarLawsStandInfo sarLawsInfoEO : rowsLaws){
|
||||
countSuccess++;
|
||||
if (sarLawsInfoEO.getAttrInfoMap() != null) {
|
||||
sarLawsInfoEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarLawsInfoEO.getAttrInfoMap()));
|
||||
}
|
||||
createStandMQService.sendLawsMQ(sarLawsInfoEO,"add");
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success("重置:"+ countSuccess + "条");
|
||||
}
|
||||
|
||||
public ResponseMessage resetBussStandSearchCenter(SarBussionessStandEOPage sarBussionessStandEOPage) throws Exception{
|
||||
Boolean getbussstandIndex = elasticsearchService.isIndexExist("bussstand");
|
||||
int number = 0;
|
||||
if(getbussstandIndex){
|
||||
Boolean deletebussstandIndex = elasticsearchService.deleteIndex("bussstand");
|
||||
}
|
||||
List<SarBussionessStand> getAllList = new ArrayList<>();
|
||||
sarBussionessStandEOPage.setValidFlag("0");
|
||||
sarBussionessStandEOPage.setOrderBy("SAR_BUSSIONESS_STAND.issue_time is null,SAR_BUSSIONESS_STAND.issue_time desc,SAR_BUSSIONESS_STAND.id");
|
||||
sarBussionessStandEOPage.setMenuRoleList(null);
|
||||
sarBussionessStandEOPage.setMenuId("nomenu");
|
||||
int countBuss = 10000;
|
||||
int countSuccess = 0;
|
||||
if(countBuss>0){
|
||||
sarBussionessStandEOPage.setMenuId("0");
|
||||
sarBussionessStandEOPage.setPageSize(countBuss);
|
||||
getAllList = iSarBussionessStandService.getSarBussionStandPage(sarBussionessStandEOPage);
|
||||
number = getAllList.size();
|
||||
}
|
||||
if (getAllList != null && !getAllList.isEmpty()) {
|
||||
sendESForBussStand(getAllList,countSuccess);
|
||||
}
|
||||
return Result.success("重置:"+ number + "条");
|
||||
}
|
||||
|
||||
public void sendESForBussStand(List<SarBussionessStand> getAllList,int countSuccess) throws Exception {
|
||||
for(SarBussionessStand sarBussionessStandEO : getAllList){
|
||||
countSuccess++;
|
||||
Map<String,Object> attrInfoMap = sarBussionessStandEO.getAttrInfoMap();
|
||||
if (null != attrInfoMap && attrInfoMap.containsKey("QBMJ") && null != attrInfoMap.get("QBMJ") && String.valueOf(attrInfoMap.get("QBMJ")).contains("ACF675Z88W")){
|
||||
countSuccess--;
|
||||
}
|
||||
if (sarBussionessStandEO.getAttrInfoMap() != null) {
|
||||
sarBussionessStandEO.setSarStandAttrEOStr(JSONObject.toJSONString(sarBussionessStandEO.getAttrInfoMap()));
|
||||
}
|
||||
createStandMQService.sendBussStandMQ(sarBussionessStandEO,"add");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user