全文检索添加动态消息读取上传附件PDF与WORD
This commit is contained in:
+2
@@ -386,7 +386,9 @@ public class JeroElasticsearchTemplate {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
log.info("url:" + url + ":" + data.toJSONString());
|
||||||
String result = this.put(url, data.toJSONString()).getString("result");
|
String result = this.put(url, data.toJSONString()).getString("result");
|
||||||
|
log.info("result:" + result);
|
||||||
return "created".equals(result) || "updated".equals(result);
|
return "created".equals(result) || "updated".equals(result);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage() + "\n-- url: " + url + "\n-- data: " + data.toJSONString());
|
log.error(e.getMessage() + "\n-- url: " + url + "\n-- data: " + data.toJSONString());
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class ReadPdfUtil {
|
|||||||
public static String readPdf(String path) {
|
public static String readPdf(String path) {
|
||||||
if(MinioUtil.doesObjectExist(path)){
|
if(MinioUtil.doesObjectExist(path)){
|
||||||
try (InputStream in = MinioUtil.download(path)) {
|
try (InputStream in = MinioUtil.download(path)) {
|
||||||
if(Objects.isNull(in) || in.available() == 0){
|
if(Objects.isNull(in)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try (PDDocument document = PDDocument.load(in)) {
|
try (PDDocument document = PDDocument.load(in)) {
|
||||||
|
|||||||
+36
-2
@@ -1270,6 +1270,12 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
while (startIndex < listIds.size()) {
|
while (startIndex < listIds.size()) {
|
||||||
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
||||||
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
||||||
|
if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_DELETE)) {
|
||||||
|
for (String s : listIdsSub) {
|
||||||
|
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), s);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
List<LawsDomesticStandard> listLawsDomesticStandard = lawsDomesticStandardService.listByIds(listIdsSub);
|
List<LawsDomesticStandard> listLawsDomesticStandard = lawsDomesticStandardService.listByIds(listIdsSub);
|
||||||
if (CollectionUtils.isEmpty(listLawsDomesticStandard)) {
|
if (CollectionUtils.isEmpty(listLawsDomesticStandard)) {
|
||||||
break;
|
break;
|
||||||
@@ -1402,6 +1408,12 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
while (startIndex < listIds.size()) {
|
while (startIndex < listIds.size()) {
|
||||||
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
||||||
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
||||||
|
if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_DELETE)) {
|
||||||
|
for (String s : listIdsSub) {
|
||||||
|
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), s);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
List<LawsOverseasStandard> listLawsOverseasStandard = lawsOverseasStandardService.listByIds(listIdsSub);
|
List<LawsOverseasStandard> listLawsOverseasStandard = lawsOverseasStandardService.listByIds(listIdsSub);
|
||||||
if (CollectionUtils.isEmpty(listLawsOverseasStandard)) {
|
if (CollectionUtils.isEmpty(listLawsOverseasStandard)) {
|
||||||
break;
|
break;
|
||||||
@@ -1494,6 +1506,12 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
while (startIndex < listIds.size()) {
|
while (startIndex < listIds.size()) {
|
||||||
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
||||||
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
||||||
|
if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_DELETE)) {
|
||||||
|
for (String s : listIdsSub) {
|
||||||
|
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), s);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
List<LawsEnterpriseStandard> listLawsEnterpriseStandard = lawsEnterpriseStandardService.listByIds(listIdsSub);
|
List<LawsEnterpriseStandard> listLawsEnterpriseStandard = lawsEnterpriseStandardService.listByIds(listIdsSub);
|
||||||
if (CollectionUtils.isEmpty(listLawsEnterpriseStandard)) {
|
if (CollectionUtils.isEmpty(listLawsEnterpriseStandard)) {
|
||||||
break;
|
break;
|
||||||
@@ -1570,6 +1588,12 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
// 从第0个下标开始
|
// 从第0个下标开始
|
||||||
List<String> listIds = Arrays.asList(ids.split(","));
|
List<String> listIds = Arrays.asList(ids.split(","));
|
||||||
try {
|
try {
|
||||||
|
if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_DELETE)) {
|
||||||
|
for (String s : listIds) {
|
||||||
|
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), s);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<LawsNewsFeed> listLawsNewsFeed = lawsNewsFeedService.listByIds(listIds);
|
List<LawsNewsFeed> listLawsNewsFeed = lawsNewsFeedService.listByIds(listIds);
|
||||||
if (CollectionUtils.isEmpty(listLawsNewsFeed)) {
|
if (CollectionUtils.isEmpty(listLawsNewsFeed)) {
|
||||||
return;
|
return;
|
||||||
@@ -1586,7 +1610,11 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
obj.setCreateTime(lawsNewsFeed.getCreateTime());
|
obj.setCreateTime(lawsNewsFeed.getCreateTime());
|
||||||
obj.setPushRangeFlag(lawsNewsFeed.getPushRangeFlag());
|
obj.setPushRangeFlag(lawsNewsFeed.getPushRangeFlag());
|
||||||
obj.setReleaseStatus(String.valueOf(lawsNewsFeed.getReleaseStatus()));
|
obj.setReleaseStatus(String.valueOf(lawsNewsFeed.getReleaseStatus()));
|
||||||
updateESLawsNewsFeed(opType, lawsNewsFeed, obj);
|
List<OSSFile> list = new ArrayList<>();
|
||||||
|
if(!StringUtils.isBlank(lawsNewsFeed.getDataText())){
|
||||||
|
list = oSSFileService.listByIds(Arrays.asList(lawsNewsFeed.getDataText().split(",")));
|
||||||
|
}
|
||||||
|
updateESLawsNewsFeed(opType, lawsNewsFeed, obj, list);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(SYNC_ES_ERR, e.getMessage());
|
log.error(SYNC_ES_ERR, e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -1596,13 +1624,19 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateESLawsNewsFeed(String opType, LawsNewsFeed lawsNewsFeed, LawsHomeNormalSearchVO obj) {
|
private void updateESLawsNewsFeed(String opType, LawsNewsFeed lawsNewsFeed, LawsHomeNormalSearchVO obj, List<OSSFile> list) {
|
||||||
if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_ADD) ||
|
if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_ADD) ||
|
||||||
Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_UPDATE)) {
|
Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_UPDATE)) {
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
if (!StringUtils.isBlank(lawsNewsFeed.getDynamicDetails())) {
|
if (!StringUtils.isBlank(lawsNewsFeed.getDynamicDetails())) {
|
||||||
str = new StringBuilder(Jsoup.parse(lawsNewsFeed.getDynamicDetails()).text());
|
str = new StringBuilder(Jsoup.parse(lawsNewsFeed.getDynamicDetails()).text());
|
||||||
}
|
}
|
||||||
|
if(!CollectionUtils.isEmpty(list)){
|
||||||
|
StringBuilder fileTextAll = getStringBuilder(list);
|
||||||
|
if(!StringUtils.isBlank(fileTextAll.toString())){
|
||||||
|
str.append(fileTextAll.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
addES(obj, lawsNewsFeed.getId(), str, null);
|
addES(obj, lawsNewsFeed.getId(), str, null);
|
||||||
} else if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_DELETE)) {
|
} else if (Objects.equals(opType, LawsHomeSearchCommon.LAWS_ES_DELETE)) {
|
||||||
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), lawsNewsFeed.getId());
|
jeroElasticsearchTemplate.delete(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), lawsNewsFeed.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user