Merge remote-tracking branch 'origin/develop_master' into develop_master
This commit is contained in:
@@ -20,7 +20,7 @@ public class SearchCenter {
|
||||
private Integer countStand;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "执行参数 ALL 存在更新 不存在新增 ,UPD 只 更新存在 es 里的标准 ,ADD 只新增不存在 es 的标准")
|
||||
@ApiModelProperty(value = "执行参数 ALL 存在更新 不存在新增 ,UPD 只 更新存在 es 里的标准 ,ADD 只新增不存在 es 的标准, DEL 只删除不存在标准库的数据")
|
||||
private String execType;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.adc.da.utils.util.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
@@ -91,6 +92,55 @@ public class ResetSearchCenterService {
|
||||
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);
|
||||
SarStandardsInfoEOPage page = new SarStandardsInfoEOPage();
|
||||
page.setSyncParam("sync");
|
||||
ResponseMessage stand = resetStandSearchCenter(page,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);
|
||||
SarLawsStandInfoPage lawsPage = new SarLawsStandInfoPage();
|
||||
page.setSyncParam("sync");
|
||||
ResponseMessage laws = resetLawsSearchCenter(lawsPage,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);
|
||||
SarBussionessStandEOPage bussPage = new SarBussionessStandEOPage();
|
||||
page.setSyncParam("sync");
|
||||
ResponseMessage buss = resetBussStandSearchCenter(bussPage,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
|
||||
public ResponseMessage resetStandSearchCenter(SarStandardsInfoEOPage page,SearchCenter searchCenter) throws Exception{
|
||||
@@ -100,12 +150,15 @@ public class ResetSearchCenterService {
|
||||
|
||||
Boolean getStandIndex = elasticsearchService.isIndexExist("stand");
|
||||
|
||||
List<Map<String, Object>> searchListData = elasticsearchService.searchListData("stand","","","");
|
||||
if(!getStandIndex){
|
||||
logger.info("ES 不存在索引:stand");
|
||||
return Result.error("ES 不存在索引:stand");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> searchListData = elasticsearchService.searchAll("stand");
|
||||
|
||||
List<String> esIdList = searchListData.stream().map(stringObjectMap -> stringObjectMap.get("id").toString()).collect(Collectors.toList());
|
||||
|
||||
logger.info(searchListData.toString());
|
||||
logger.info(esIdList.toString());
|
||||
page.setValidFlag("0");
|
||||
if(searchCenter.getIdList() != null && !searchCenter.getIdList().isEmpty()){
|
||||
String[] result = searchCenter.getIdList().toArray(new String[0]);
|
||||
@@ -170,15 +223,20 @@ public class ResetSearchCenterService {
|
||||
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()+"条数据");
|
||||
logger.info("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+0+"条)删除-共"+delList.size()+"条数据");
|
||||
return Result.success("重置国内外标准:新增-"+ countAddSuccess + "条 更新-"+countUpdateSuccess+"条(国内外标准共:"+0+"条)删除-共"+delList.size()+"条数据");
|
||||
}
|
||||
|
||||
@Async
|
||||
public ResponseMessage resetLawsSearchCenter(SarLawsStandInfoPage sarLawsInfoEOPage,SearchCenter searchCenter) throws Exception{
|
||||
Boolean getLawsIndex = elasticsearchService.isIndexExist("laws");
|
||||
|
||||
List<Map<String, Object>> searchListData = elasticsearchService.searchListData("laws","","","");
|
||||
if(!getLawsIndex){
|
||||
logger.info("ES 不存在索引:laws");
|
||||
return Result.error("ES 不存在索引:laws");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> searchListData = elasticsearchService.searchAll("laws");
|
||||
|
||||
List<String> esIdList = searchListData.stream().map(stringObjectMap -> stringObjectMap.get("id").toString()).collect(Collectors.toList());
|
||||
|
||||
@@ -262,7 +320,12 @@ public class ResetSearchCenterService {
|
||||
public ResponseMessage resetBussStandSearchCenter(SarBussionessStandEOPage sarBussionessStandEOPage,SearchCenter searchCenter) throws Exception{
|
||||
Boolean getbussstandIndex = elasticsearchService.isIndexExist("bussstand");
|
||||
|
||||
List<Map<String, Object>> searchListData = elasticsearchService.searchListData("bussstand","","","");
|
||||
if(!getbussstandIndex){
|
||||
logger.info("ES 不存在索引:bussstand");
|
||||
return Result.error("ES 不存在索引:bussstand");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> searchListData = elasticsearchService.searchAll("bussstand");
|
||||
|
||||
List<String> esIdList = searchListData.stream().map(stringObjectMap -> stringObjectMap.get("id").toString()).collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+7
-6
@@ -9,6 +9,7 @@ import com.adc.da.http.PageInfo;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.person.service.IPersonCollectEOService;
|
||||
import com.adc.da.slrs.regulations.entity.SearchStandByVppsReqDTO;
|
||||
import com.adc.da.slrs.regulations.entity.SearchStandContext;
|
||||
import com.adc.da.slrs.regulations.entity.SearchStandResult;
|
||||
import com.adc.da.slrs.regulations.entity.StandMessageCodeEnum;
|
||||
@@ -71,16 +72,16 @@ public class StandDataController {
|
||||
*/
|
||||
@ApiOperation(value = "|regulations|标准查询列表接口")
|
||||
@PostMapping("/searchStandData")
|
||||
public String searchStandData(@RequestBody SearchStandContext searchStandContext){
|
||||
public String searchStandData(@RequestBody SearchStandByVppsReqDTO searchStandContext){
|
||||
String resultJson = "";
|
||||
if(StringUtils.isEmpty(searchStandContext.getUid())
|
||||
|| StringUtils.isEmpty(searchStandContext.getUsername())
|
||||
|| StringUtils.isEmpty(searchStandContext.getVppsCode())){
|
||||
return StandResult.toJson(StandResult.error(verifyObj(searchStandContext.getUid()),
|
||||
if(StringUtils.isEmpty(searchStandContext.getData().getUid())
|
||||
|| StringUtils.isEmpty(searchStandContext.getData().getUserName())
|
||||
|| StringUtils.isEmpty(searchStandContext.getData().getVppsCode())){
|
||||
return StandResult.toJson(StandResult.error(verifyObj(searchStandContext.getData().getUid()),
|
||||
StandMessageCodeEnum.SOURCE.getCode(), StandMessageCodeEnum.ERROR_PARAM.getCode(),
|
||||
"uid/username/vppsCode 为必填项"));
|
||||
}
|
||||
return iStandDataService.searchStandData(searchStandContext);
|
||||
return iStandDataService.searchStandData(searchStandContext.getData());
|
||||
}
|
||||
|
||||
private String verifyObj(String str){
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.adc.da.slrs.regulations.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SearchStandByVppsReqDTO implements Serializable {
|
||||
|
||||
public SearchStandContext Data;
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class SearchStandContext implements Serializable {
|
||||
private String uid;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private String username;
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "VPPS码")
|
||||
private String vppsCode;
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class StandDataServiceImpl extends ServiceImpl<StandDataDao, StandData> i
|
||||
standDataQuery.stream().peek(standData -> {
|
||||
FileResult fileResult = new FileResult();
|
||||
fileResult.setDocumentName(verifyObj(standData.getStandSort(),standData.getStandNumber(),standData.getStandName()));
|
||||
fileResult.setDocumentUrl(webUrl+"?userName="+encode(searchStandContext.getUsername())+"&dataId="+standData.getStandId()+"&datatype="+standData.getStandType());
|
||||
fileResult.setDocumentUrl(webUrl+"?userName="+encode(searchStandContext.getUserName())+"&dataId="+standData.getStandId()+"&datatype="+standData.getStandType());
|
||||
fileResultList.add(fileResult);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
+3
@@ -279,4 +279,7 @@ public class SarLawsStandInfoPage extends BasePage {
|
||||
@TableField(exist = false)
|
||||
private String exportAllResult;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String syncParam;
|
||||
|
||||
}
|
||||
|
||||
+11
@@ -1,6 +1,7 @@
|
||||
package com.adc.da.slrs.sarStandardsInfo.entity;
|
||||
|
||||
import com.adc.da.sys.common.BasePage;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -173,6 +174,16 @@ public class SarBussionessStandEOPage extends BasePage {
|
||||
private String exportAllAttrInfo;
|
||||
private String exportAllResult;
|
||||
|
||||
private String syncParam;
|
||||
|
||||
public String getSyncParam() {
|
||||
return syncParam;
|
||||
}
|
||||
|
||||
public void setSyncParam(String syncParam) {
|
||||
this.syncParam = syncParam;
|
||||
}
|
||||
|
||||
public String getExportAllResult() {
|
||||
return exportAllResult;
|
||||
}
|
||||
|
||||
+3
@@ -91,6 +91,9 @@ public class SarStandardsInfoEOPage extends BasePage {
|
||||
private String orderBy1 = "SAR_STANDARDS_INFO.issue_time";
|
||||
private String order1 = "";
|
||||
|
||||
// syncParam == sync
|
||||
private String syncParam;
|
||||
|
||||
/**
|
||||
* zhaokaiyao
|
||||
* 文本状态
|
||||
|
||||
Reference in New Issue
Block a user