Merge remote-tracking branch 'origin/develop_master' into develop_master

This commit is contained in:
yuezhihang
2022-04-29 15:33:41 +08:00
21 changed files with 332 additions and 40 deletions
@@ -11,7 +11,7 @@ spring.datasource.password = Fting&8g35g#geg2
#==============================================
# 应用设置
spring.application.name=FotonLAWSSystem
spring.application.name=FotonLAWSSystem-REST-SEARCH
application.code=20200101
application.center=1
#==============================================
@@ -9,7 +9,7 @@ spring.profiles.active=dev
server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/plain,text/css,application/x-javascript
# 端口号设置
server.port=4202
server.port=10086
#主服务session超时
server.servlet.session.timeout =600
@@ -8,7 +8,7 @@
<!-- 项目名称 -->
<property name="PROJECT_NAME" value="adc-da" />
<!-- 定义日志文件的存储地址,勿在 LogBack的配置中使用相对路径 -->
<property name="LOG_HOME" value="/tmp/applog/pcms-rest-system" />
<property name="LOG_HOME" value="/data/slrs/rest-system-search/logs" />
<!-- <property name="LOG_HOME" value="../logs/pcms-rest" />-->
<!-- 定义系统日志文件的存储地址,勿在 LogBack的配置中使用相对路径 -->
<property name="LOG_HOME_SYSTEM" value="system" />
@@ -118,6 +118,11 @@ public interface ElasticsearchService {
*/
Map<String, Object> searchDataById(String index, String type, String id, String fields);
/**
* 使用索引查询所有
*/
List<Map<String,Object>> searchAll(String index);
/**
* 使用分词查询
@@ -8,6 +8,7 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequestBuilder;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
@@ -24,11 +25,16 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.Scroll;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.BucketOrder;
import org.elasticsearch.search.aggregations.bucket.range.Range;
@@ -36,6 +42,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
import org.elasticsearch.search.aggregations.metrics.Avg;
import org.elasticsearch.search.aggregations.metrics.Max;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -273,6 +280,54 @@ public class ElasticsearchServiceImpl implements ElasticsearchService {
return getResponse.getSource();
}
/**
* 使用索引查询所有
*/
@Override
public List<Map<String, Object>> searchAll(String index) {
List<Map<String, Object>> sourceList = new ArrayList<Map<String, Object>>();
//1、指定es集群 cluster.name 是固定的key值,my-application是ES集群的名称
// Settings settings = Settings.builder().put("cluster.name", "my-application").build();
QueryBuilder qBuilder = QueryBuilders.matchAllQuery();
SearchResponse sResponse = client.prepareSearch(index)
.setQuery(qBuilder).setTrackTotalHits(true)
.get();
SearchHits hits = sResponse.getHits();
if(hits.getTotalHits().value > 0){
SearchResponse scrollResp = search(index,qBuilder, 1,(int) hits.getTotalHits().value);
for (SearchHit hit : scrollResp.getHits().getHits()) {
sourceList.add(hit.getSourceAsMap());
}
}
return sourceList;
}
public SearchResponse search(String index, QueryBuilder query,int page, int size) {
updateIndex(index, page,size);
SearchResponse searchResponse = client.prepareSearch(index)
.setScroll(new TimeValue(360000))
.setQuery(query).setTrackTotalHits(true).setSize(size)
.get();
return searchResponse;
}
//更新索引的max_result_window参数
private boolean updateIndex(String indices, int from,int size) {
int records = from * size + size;
if (records <= 10000) return true;
AcknowledgedResponse indexResponse = client.admin().indices()
.prepareUpdateSettings(indices)
.setSettings(Settings.builder()
.put("index.max_result_window", records)
.build()
).get();
return indexResponse.isAcknowledged();
}
/**
* 使用分词查询
@@ -4,6 +4,8 @@ import com.adc.da.search.entity.*;
import com.adc.da.search.service.SearchCenterService;
import com.adc.da.search.util.DateUtil;
import com.adc.da.search.util.InitStandAttrSearchUtil;
import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.sys.entity.DicTypeEO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -56,6 +58,9 @@ public class SearchCenterServiceImpl implements SearchCenterService {
private TransportClient client;
@Autowired
private DicTypeEODao dicTypeEODao;
@PostConstruct
public void init() {
client = this.transportClient;
@@ -1292,12 +1297,22 @@ public class SearchCenterServiceImpl implements SearchCenterService {
String real = searchInfoEO.getSelectValue();
boolean isReal = false;
int num = searchInfoEO.getSelectValue().indexOf(" ");
//查询字典表,形成Hash映射提升速度
List<DicTypeEO> dicInfo = dicTypeEODao.getDicInfo("dic_id","dic_type_code", "dic_type_name");
Map<String, String> dicMap = dicInfo.stream()
.filter(item-> ("JKSADFH564S".equals(item.getDicId()) || "NGETEMDJDI".equals(item.getDicId()) || "sg9gb7liywkrnv3pa5uh".equals(item.getDicId())) && !item.getDicTypeCode().isEmpty())
.collect(Collectors.toMap(DicTypeEO::getDicTypeCode,DicTypeEO::getDicTypeName,(value1, value2 )->value2));
String value = "";
String select = "";
if (-1 != num) {
value = searchInfoEO.getSelectValue().substring(0, num).trim();
select = searchInfoEO.getSelectValue().substring(num + 1).trim();
real = value + " " + select;
value = searchInfoEO.getSelectValue().substring(0, num).trim().toUpperCase();
if (dicMap.containsKey(value) && dicMap.get(value) != null && !"".equals(dicMap.get(value))){
select = searchInfoEO.getSelectValue().substring(num + 1).trim();
real = value + " " + select;
}else {
select = null;
value = real;
}
}else{
String reg = ".*[0-9].*";
if("-".contains(real)){
@@ -1306,12 +1321,27 @@ public class SearchCenterServiceImpl implements SearchCenterService {
String[] valArr = value.split("\\/");
if (valArr.length > 2) {
value = valArr[0] + "/" + valArr[1];
select = content.replaceAll("[^(0-9a-zA-Z\\.\\(\\\\\\)\\s\\/\\-\\:)]", "").replaceAll(value,"");
select = content.replaceAll("[^(0-9a-zA-Z\\.\\(\\\\\\)\\s\\/\\-\\:)]", "").replace(value,"");
// 如果类别小写 转 大写
Pattern pattern = Pattern.compile("^[a-zA-Z\\/]+$");
if (pattern.matcher(value).matches()) {
value = value.toUpperCase();
}
}else{
value = valArr[0];
select = real.replaceAll("[^(0-9a-zA-Z\\.\\(\\\\\\)\\s\\/\\-\\:)]", "").replaceAll(value,"");
select = real.replaceAll("[^(0-9a-zA-Z\\.\\(\\\\\\)\\s\\/\\-\\:)]", "").replace(value,"");
// 如果类别小写 转 大写
Pattern pattern = Pattern.compile("^[a-zA-Z\\/]+$");
if (pattern.matcher(value).matches()) {
value = value.toUpperCase();
}
}
if (dicMap.containsKey(value) && dicMap.get(value) != null && !"".equals(dicMap.get(value))){
real = value + " " + select;
}else {
select = null;
value = real;
}
real = value + " " + select;
}else if(real.matches(reg)){
value = real.replaceAll("[^(A-Za-z\\/)]", "");
String[] valArr = value.split("\\/");
@@ -1326,13 +1356,28 @@ public class SearchCenterServiceImpl implements SearchCenterService {
select = sel;
}
}else{
value = valArr[0];
select = real.replaceAll("[^(0-9a-zA-Z\\.\\(\\\\\\)\\s\\/\\-\\:)]", "").replaceAll(value,"");
select = real.replaceAll("[^(0-9a-zA-Z\\.\\(\\\\\\)\\s\\/\\-\\:)]", "").replace(value,"");
// 如果类别小写 转 大写
Pattern pattern = Pattern.compile("^[a-zA-Z\\/]+$");
if (pattern.matcher(value).matches()) {
value = value.toUpperCase();
}
}
if (dicMap.containsKey(value) && dicMap.get(value) != null && !"".equals(dicMap.get(value))){
real = value + " " + select;
}else {
select = null;
value = real;
}
real = value + " " + select;
}else {
value = real;
select = "";
// 如果类别小写 转 大写
Pattern pattern = Pattern.compile("^[a-zA-Z\\/]+$");
if (pattern.matcher(value).matches()) {
value = value.toUpperCase();
}
}
}
searchInfoEO.setSelectValue(select);
@@ -1378,16 +1423,10 @@ public class SearchCenterServiceImpl implements SearchCenterService {
if(null != value || null != selects){
if (null != value && selects == null) {
boolSelectValue.should(QueryBuilders.multiMatchQuery(value,
"title"
).minimumShouldMatch("100%").field("title",1000f));
boolSelectValue.should(QueryBuilders.multiMatchQuery(value,
"textContent"
).minimumShouldMatch("100%").field("title",1000f));
boolSelectValue.should(QueryBuilders.multiMatchQuery(value,
"textItems"
).minimumShouldMatch("100%").field("title",1000f));
boolSelectValue.should(QueryBuilders.wildcardQuery("title.keyword","*"+value+"*"));
boolSelectValue
.should(QueryBuilders.wildcardQuery("title.keyword", "*" + value + "*").boost(1000f))
.should(QueryBuilders.wildcardQuery("textContent.keyword", "*" + value + "*").boost(0.0000000000000000000000000000000001f))
.should(QueryBuilders.wildcardQuery("issue_time", "*" + value + "*"));
// multiQueryBuilder = QueryBuilders.multiMatchQuery("*"+value+"*",
// "title.keyword", "textContent", "issue_time").minimumShouldMatch("100%").field("title.keyword", 1000f).field("textContent.keyword", 0.0000000000000000000000000000000001f);
//// boolQueryMust.must(multiQueryBuilder);
@@ -1486,6 +1525,14 @@ public class SearchCenterServiceImpl implements SearchCenterService {
result.add(sourceAsMap);
}
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits().value);
//给aqi升序排,null放到最后
// result.sort((o1, o2) -> {
// if (o1.get("issue_time") != null && o2.get("issue_time") != null) {
// return o2.get("issue_time").toString().compareTo(o1.get("issue_time").toString());
// } else {
// return o1.get("issue_time") == null ? 1 : -1;
// }
// });
return result;
}
@@ -225,6 +225,7 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
contentBuilder.append("标准文本: ").append(attrInfoMap.get("content")).append(" ");
StringBuilder textContent = replaceAll(contentBuilder, "null", "--");
fullTextSearchEO.put("textContent",textContent.toString());
fullTextSearchEO.put("yearOrder", String.valueOf(attrInfoMap.get("standYear")));
// 全文检索 加入 发布稿 分解单条款内容逻辑
StringBuilder itemBuilder = new StringBuilder();
@@ -237,8 +238,10 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
if (null != attrInfoMap.get("issueTime") && !"".equals(attrInfoMap.get("issueTime")) && !"null".equals(attrInfoMap.get("issueTime"))) {
fullTextSearchEO.put("issue_time", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))));
fullTextSearchEO.put("issue_time_order", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))).replace("-",""));
}else {
fullTextSearchEO.put("issue_time", "--");
fullTextSearchEO.put("issue_time_order", "--");
}
} else if("laws".equals(attrInfoMap.get("type"))){
// 政策全文
@@ -247,7 +250,7 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
attrInfoMap.put(key, "null");
}
}
fullTextSearchEO.put("title",attrInfoMap.get("lawsNumber")+" "+attrInfoMap.get("lawsNumber"));
fullTextSearchEO.put("title",attrInfoMap.get("lawsTypeName")+" "+attrInfoMap.get("lawsNumber")+" "+attrInfoMap.get("lawsName"));
StringBuilder contentBuilder = new StringBuilder();
contentBuilder.append("政策分类: ").append(attrInfoMap.get("lawsTypeName")).append(" ");
contentBuilder.append("政策编号: ").append(attrInfoMap.get("lawsNumber")).append(" ");
@@ -296,11 +299,14 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
contentBuilder.append("标准文本: ").append(attrInfoMap.get("content")).append(" ");
StringBuilder textContent = replaceAll(contentBuilder, "null", "--");
fullTextSearchEO.put("textContent",textContent.toString());
fullTextSearchEO.put("yearOrder", String.valueOf(attrInfoMap.get("lawsYearName")));
if (null != attrInfoMap.get("issueTime") && !"".equals(attrInfoMap.get("issueTime")) && !"null".equals(attrInfoMap.get("issueTime"))) {
fullTextSearchEO.put("issue_time", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))));
fullTextSearchEO.put("issue_time_order", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))).replace("-",""));
}else {
fullTextSearchEO.put("issue_time", "--");
fullTextSearchEO.put("issue_time_order", "--");
}
}else if ("bussstand".equals(attrInfoMap.get("type"))){
@@ -309,7 +315,7 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
attrInfoMap.put(key, "null");
}
}
fullTextSearchEO.put("title",attrInfoMap.get("stand_code"));
fullTextSearchEO.put("title",attrInfoMap.get("stand_code")+" "+attrInfoMap.get("stand_name"));
StringBuilder contentBuilder = new StringBuilder();
contentBuilder.append("企标类别:").append(attrInfoMap.get("standSort")).append(" ");
contentBuilder.append("标准年份:").append(attrInfoMap.get("standYear")).append(" ");
@@ -348,10 +354,13 @@ public class StandLawsSearchServiceImpl implements StandLawsSearchService {
StringBuilder textContent = replaceAll(contentBuilder, "null", "--");
fullTextSearchEO.put("textContent",textContent.toString());
fullTextSearchEO.put("yearOrder", String.valueOf(attrInfoMap.get("standYear")));
if (null != attrInfoMap.get("issueTime") && !"".equals(attrInfoMap.get("issueTime")) && !"null".equals(attrInfoMap.get("issueTime"))) {
fullTextSearchEO.put("issue_time", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))));
fullTextSearchEO.put("issue_time_order", dateFormatToStr(String.valueOf(attrInfoMap.get("issueTime"))).replace("-",""));
}else {
fullTextSearchEO.put("issue_time", "--");
fullTextSearchEO.put("issue_time_order", "--");
}
}
return fullTextSearchEO;
@@ -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());
}
}
}
}
@@ -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){
@@ -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;
}
@@ -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;
@@ -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());
}
@@ -279,4 +279,7 @@ public class SarLawsStandInfoPage extends BasePage {
@TableField(exist = false)
private String exportAllResult;
@TableField(exist = false)
private String syncParam;
}
@@ -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;
}
@@ -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
* 文本状态
@@ -489,6 +489,10 @@
and text_status_buss=#{textStatusBuss}
</if>
<if test='syncParam != null and syncParam == "sync"'>
and SAR_BUSSIONESS_STAND.MODIFY_TIME between DATE_SUB(NOW(),INTERVAL 7 day) and DATE_SUB(NOW(),INTERVAL -1 day)
</if>
<if test="standCode != null" >
<!-- and (
(concat(dicstandSort.DIC_TYPE_NAME, ' ', SAR_BUSSIONESS_STAND.STAND_CODE, '-', SAR_BUSSIONESS_STAND.STAND_YEAR)
@@ -88,6 +88,9 @@
where 1=1 and SAR_LAWS_STAND_INFO.valid_flag=0
<trim suffixOverrides=",">
<!-- 基本搜索项 -->
<if test='syncParam != null and syncParam == "sync"'>
and SAR_LAWS_STAND_INFO.MODIFY_TIME between DATE_SUB(NOW(),INTERVAL 7 day) and DATE_SUB(NOW(),INTERVAL -1 day)
</if>
<if test="lawsType != null and lawsType != ''">
and SAR_LAWS_STAND_INFO.LAWS_TYPE like concat(concat('%',#{lawsType}),'%')
</if>
@@ -979,6 +979,9 @@
<if test='page.standType != null and page.standType != "ALL"'>
and stand_type = #{page.standType}
</if>
<if test='page.syncParam != null and page.syncParam != ""'>
and SAR_STANDARDS_INFO.MODIFY_TIME between DATE_SUB(NOW(),INTERVAL 7 day) and DATE_SUB(NOW(),INTERVAL -1 day)
</if>
<!-- 基本搜索项 -->
<!-- 国家、地区 -->
<if test="page.country != null and page.country != ''">
@@ -609,6 +609,7 @@
<foreach collection="filed" index="index" item="item" separator=" and " >
${item} is not NULL
</foreach>
and TS_DICTYPE.VALID_FLAG= '0'
</where>
</select>