提交 5a471022 作者: yanxin

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

...@@ -162,8 +162,8 @@ public class EventManageController { ...@@ -162,8 +162,8 @@ public class EventManageController {
log.info("新增事件,通知采集,事件id:{}", event.getId()); log.info("新增事件,通知采集,事件id:{}", event.getId());
configurationMessageService.bindKeyWordsEventSend(event.getId()); configurationMessageService.bindKeyWordsEventSend(event.getId());
//事件分析 //事件分析
log.info("新增事件,事件分析,事件id:{}", event.getId()); // log.info("新增事件,事件分析,事件id:{}", event.getId());
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode()); // kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}); });
return Result.OK(); return Result.OK();
} else { } else {
......
...@@ -263,6 +263,7 @@ public class EventDataController { ...@@ -263,6 +263,7 @@ public class EventDataController {
AddEventParam eventParam = new AddEventParam(); AddEventParam eventParam = new AddEventParam();
BeanUtils.copyProperties(addEventVO, eventParam); BeanUtils.copyProperties(addEventVO, eventParam);
eventParam.setCreateBy(currentUser.getUsername()); eventParam.setCreateBy(currentUser.getUsername());
eventParam.setOpen(true);
Event event = eventService.saveMain(eventParam); Event event = eventService.saveMain(eventParam);
//新增关键词 //新增关键词
keyWordsService.saveBaseAndMap(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord()); keyWordsService.saveBaseAndMap(event, keywordsVO.getKeyword(), keywordsVO.getExclusionWord());
......
...@@ -344,8 +344,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements ...@@ -344,8 +344,11 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
public Event saveMain(AddEventParam addEventParam) { public Event saveMain(AddEventParam addEventParam) {
Event event = new Event(); Event event = new Event();
BeanUtils.copyProperties(addEventParam, event); BeanUtils.copyProperties(addEventParam, event);
event.setStatus(1); if (ObjectUtil.isNotEmpty(addEventParam.isOpen()) && addEventParam.isOpen()) {
event.setFirstOpenTime(new Date()); //立即开启
event.setStatus(1);
event.setFirstOpenTime(new Date());
}
Date endTime = event.getEndTime(); Date endTime = event.getEndTime();
if (endTime == null) { if (endTime == null) {
endTime = DateUtil.addDate(new Date(), 15); endTime = DateUtil.addDate(new Date(), 15);
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.bean.copier.CopyOptions; ...@@ -5,6 +5,7 @@ import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -37,6 +38,7 @@ import org.elasticsearch.index.query.TermsQueryBuilder; ...@@ -37,6 +38,7 @@ import org.elasticsearch.index.query.TermsQueryBuilder;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -98,6 +100,9 @@ public class InformationServiceImpl implements InformationService { ...@@ -98,6 +100,9 @@ public class InformationServiceImpl implements InformationService {
private ImageUtil imageUtil; private ImageUtil imageUtil;
private String subjectId = "1898653164373065730";//中外智库专栏对应专题id private String subjectId = "1898653164373065730";//中外智库专栏对应专题id
@Value("${ai-article.thematicColumnConfig-url:}")
private String thematicColumnConfig;
@Override @Override
public IPage<EventDataVO> collectPageList(InfoDataSearchCondition eventDataCondition) { public IPage<EventDataVO> collectPageList(InfoDataSearchCondition eventDataCondition) {
return esService.collectPageList(eventDataCondition); return esService.collectPageList(eventDataCondition);
...@@ -160,7 +165,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -160,7 +165,7 @@ public class InformationServiceImpl implements InformationService {
publishDate = EsDateUtil.esFieldDateMapping(info.getPublishDate()); publishDate = EsDateUtil.esFieldDateMapping(info.getPublishDate());
String dateFormat = searchCondition.getDateFormat(); String dateFormat = searchCondition.getDateFormat();
if (!dateFormat.equals("yyyy-MM-dd HH:mm:ss")) { if (!dateFormat.equals("yyyy-MM-dd HH:mm:ss")) {
info.setPublishDate(DateUtil.formatStr(publishDate,"yyyy-MM-dd HH:mm:ss", dateFormat)); info.setPublishDate(DateUtil.formatStr(publishDate, "yyyy-MM-dd HH:mm:ss", dateFormat));
} }
} }
//标签处理 //标签处理
...@@ -287,6 +292,10 @@ public class InformationServiceImpl implements InformationService { ...@@ -287,6 +292,10 @@ public class InformationServiceImpl implements InformationService {
map.put("infoList", listN); map.put("infoList", listN);
list.add(map); list.add(map);
}); });
List<String> columnConfigList = thematicColumnConfig(searchCondition.getSubjectId());
if (CollectionUtils.isNotEmpty(columnConfigList)) {
sortByAnotherList(list, columnConfigList);
}
} else { } else {
//不加标签获取列表数据 //不加标签获取列表数据
searchCondition.setLabelMark(null); searchCondition.setLabelMark(null);
...@@ -372,6 +381,44 @@ public class InformationServiceImpl implements InformationService { ...@@ -372,6 +381,44 @@ public class InformationServiceImpl implements InformationService {
return groupedByLabelMark; return groupedByLabelMark;
} }
private List<String> thematicColumnConfig(String subjectId) {
List<String> list = new ArrayList<>();
try {
Map<String, String> variables = new HashMap<>();
variables.put("id", subjectId);
String response = HttpUtil.doGet(thematicColumnConfig, variables, null, "utf-8");
JSONObject jsonObject = JSONObject.parseObject(response);
if (jsonObject == null) {
return list;
}
JSONArray data = jsonObject.getJSONArray("data");
if (data != null && data.size() > 0) {
for (Object datum : data) {
JSONObject item = (JSONObject) datum;
list.add(item.getString("themeName"));
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
//目标集合按照另一个集合的顺序排序
private void sortByAnotherList(List<HashMap> list, List<String> anotherList) {
list.sort((o1, o2) -> {
int index1 = anotherList.indexOf(o1.get("relationName").toString());
int index2 = anotherList.indexOf(o2.get("relationName").toString());
if (index1 != -1) {
index1 = list.size() - index1;
}
if (index2 != -1) {
index2 = list.size() - index2;
}
return index2 - index1;
});
}
@Override @Override
public DisplayInfo queryInfo(Integer type, String index, String id) { public DisplayInfo queryInfo(Integer type, String index, String id) {
DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(index, id, DisplayInfo.class); DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(index, id, DisplayInfo.class);
...@@ -1103,7 +1150,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -1103,7 +1150,7 @@ public class InformationServiceImpl implements InformationService {
dataList.add(specialInformation); dataList.add(specialInformation);
} }
esOpUtil.docSaveBulk(index, dataList); esOpUtil.docSaveBulk(index, dataList);
log.info("专题-{},批量插入-{}-条数据完成",subjectId, lists.size()); log.info("专题-{},批量插入-{}-条数据完成", subjectId, lists.size());
} }
} }
...@@ -1228,7 +1275,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -1228,7 +1275,7 @@ public class InformationServiceImpl implements InformationService {
deleteParams.put("fieldType", word); deleteParams.put("fieldType", word);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchNestedDeleteScript(indexArr, buildQuery, deleteParams, "sortField"); esOpUtil.batchNestedDeleteScript(indexArr, buildQuery, deleteParams, "sortField");
log.info("删除关键词-{},耗时:{}",word, System.currentTimeMillis()-start); log.info("删除关键词-{},耗时:{}", word, System.currentTimeMillis() - start);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -1252,11 +1299,11 @@ public class InformationServiceImpl implements InformationService { ...@@ -1252,11 +1299,11 @@ public class InformationServiceImpl implements InformationService {
} }
Map<String, Object> modifyParams = new HashMap<>(); Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus", 1); modifyParams.put("checkStatus", 1);
modifyParams.put("deleteFlag",0); modifyParams.put("deleteFlag", 0);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams); esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("添加到精选,耗时:{}", System.currentTimeMillis()-start); log.info("添加到精选,耗时:{}", System.currentTimeMillis() - start);
} }
@Override @Override
...@@ -1273,12 +1320,12 @@ public class InformationServiceImpl implements InformationService { ...@@ -1273,12 +1320,12 @@ public class InformationServiceImpl implements InformationService {
buildQuery = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery("id", ids)); buildQuery = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery("id", ids));
} }
Map<String, Object> modifyParams = new HashMap<>(); Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus",3); modifyParams.put("checkStatus", 3);
modifyParams.put("deleteFlag",0); modifyParams.put("deleteFlag", 0);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams); esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("添加到待定,耗时:{}", System.currentTimeMillis()-start); log.info("添加到待定,耗时:{}", System.currentTimeMillis() - start);
} }
@Override @Override
...@@ -1295,11 +1342,11 @@ public class InformationServiceImpl implements InformationService { ...@@ -1295,11 +1342,11 @@ public class InformationServiceImpl implements InformationService {
buildQuery = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery("id", ids)); buildQuery = QueryBuilders.boolQuery().must(QueryBuilders.termsQuery("id", ids));
} }
Map<String, Object> modifyParams = new HashMap<>(); Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("deleteFlag",1); modifyParams.put("deleteFlag", 1);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams); esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("添加到删除,耗时:{}", System.currentTimeMillis()-start); log.info("添加到删除,耗时:{}", System.currentTimeMillis() - start);
} }
@Override @Override
...@@ -1310,12 +1357,12 @@ public class InformationServiceImpl implements InformationService { ...@@ -1310,12 +1357,12 @@ public class InformationServiceImpl implements InformationService {
String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime); String[] indexArr = EsIndexUtil.getIndexIntervalYearStr(Constants.SUBJECT_INDEX, minCreateTime);
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList); BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
Map<String, Object> modifyParams = new HashMap<>(); Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("checkStatus",0); modifyParams.put("checkStatus", 0);
modifyParams.put("deleteFlag",0); modifyParams.put("deleteFlag", 0);
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams); esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
log.info("初始化数据,耗时:{}", System.currentTimeMillis()-start); log.info("初始化数据,耗时:{}", System.currentTimeMillis() - start);
} }
@Override @Override
...@@ -1329,7 +1376,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -1329,7 +1376,7 @@ public class InformationServiceImpl implements InformationService {
Integer searchScope = searchWordVO.getSearchScope(); Integer searchScope = searchWordVO.getSearchScope();
String oldWord = searchWordVO.getSearchInfo(); String oldWord = searchWordVO.getSearchInfo();
String newWord = searchCondition.getReplaceWord(); String newWord = searchCondition.getReplaceWord();
if(StringUtils.isEmpty(newWord)) { if (StringUtils.isEmpty(newWord)) {
newWord = ""; newWord = "";
} }
List<String> modifyFields = new ArrayList<>(); List<String> modifyFields = new ArrayList<>();
...@@ -1352,14 +1399,14 @@ public class InformationServiceImpl implements InformationService { ...@@ -1352,14 +1399,14 @@ public class InformationServiceImpl implements InformationService {
BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList); BoolQueryBuilder buildQuery = esService.buildQuery(searchCondition, subjectIdList);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchReplaceScript(indexArr, buildQuery, modifyFields, oldWord, newWord); esOpUtil.batchReplaceScript(indexArr, buildQuery, modifyFields, oldWord, newWord);
log.info("字符串替换-{},耗时:{}", oldWord,System.currentTimeMillis()-start); log.info("字符串替换-{},耗时:{}", oldWord, System.currentTimeMillis() - start);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
Map<String, Object> modifyParams = new HashMap<>(); Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams); esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
} }
...@@ -1379,17 +1426,17 @@ public class InformationServiceImpl implements InformationService { ...@@ -1379,17 +1426,17 @@ public class InformationServiceImpl implements InformationService {
Map<String, Object> addParams = new HashMap<>(); Map<String, Object> addParams = new HashMap<>();
for (Label markTag : searchCondition.getMarkTags()) { for (Label markTag : searchCondition.getMarkTags()) {
Map<String, String> addTag = ObjectUtil.objectToMap(markTag); Map<String, String> addTag = ObjectUtil.objectToMap(markTag);
addParams.put("labels",addTag); addParams.put("labels", addTag);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchNestedAddScript(indexArr, buildQuery, addParams,"labels","relationId"); esOpUtil.batchNestedAddScript(indexArr, buildQuery, addParams, "labels", "relationId");
log.info("打标-{},耗时:{}", markTag.getRelationName(),System.currentTimeMillis()-start); log.info("打标-{},耗时:{}", markTag.getRelationName(), System.currentTimeMillis() - start);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
Map<String, Object> modifyParams = new HashMap<>(); Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams); esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
...@@ -1422,14 +1469,14 @@ public class InformationServiceImpl implements InformationService { ...@@ -1422,14 +1469,14 @@ public class InformationServiceImpl implements InformationService {
deleteParams.put("relationId", markTag.getRelationId()); deleteParams.put("relationId", markTag.getRelationId());
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
esOpUtil.batchNestedDeleteScript(indexArr, buildQuery, deleteParams, "labels"); esOpUtil.batchNestedDeleteScript(indexArr, buildQuery, deleteParams, "labels");
log.info("删除标签-{},耗时:{}", markTag.getRelationName(),System.currentTimeMillis()-start); log.info("删除标签-{},耗时:{}", markTag.getRelationName(), System.currentTimeMillis() - start);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
Map<String, Object> modifyParams = new HashMap<>(); Map<String, Object> modifyParams = new HashMap<>();
modifyParams.put("updateDate",EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime())); modifyParams.put("updateDate", EsDateUtil.esFieldDateFormat(DateUtils.formatDateTime()));
esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams); esOpUtil.batchUpdateScript(indexArr, buildQuery, modifyParams);
try { try {
Thread.sleep(1000); Thread.sleep(1000);
......
...@@ -351,7 +351,8 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i ...@@ -351,7 +351,8 @@ public class KeyWordsServiceImpl extends ServiceImpl<KeyWordsMapper, KeyWords> i
//排除词 //排除词
LambdaQueryWrapper<SubjectKeywordsMap> query = Wrappers.lambdaQuery(); LambdaQueryWrapper<SubjectKeywordsMap> query = Wrappers.lambdaQuery();
query.eq(SubjectKeywordsMap::getSubjectId, event.getId()).eq(SubjectKeywordsMap::getBindingType, 3); query.eq(SubjectKeywordsMap::getSubjectId, event.getId()).eq(SubjectKeywordsMap::getBindingType, 3);
SubjectKeywordsMap excludeOne = subjectKeywordsMapService.getOne(queryWrapper); SubjectKeywordsMap excludeOne = subjectKeywordsMapService.getOne(query);
if (StringUtils.isNotEmpty(exclusionWord)) { if (StringUtils.isNotEmpty(exclusionWord)) {
if (excludeOne == null) { if (excludeOne == null) {
addMapMain(event, exclusionWord,2); addMapMain(event, exclusionWord,2);
......
...@@ -18,4 +18,6 @@ public class AddEventParam extends Event { ...@@ -18,4 +18,6 @@ public class AddEventParam extends Event {
/**伪事件id*/ /**伪事件id*/
private String fakeEventId; private String fakeEventId;
/**是否立即开启*/
private boolean isOpen;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论