主要得代码:
-
- public class EventTagsRuleMappingUtil {
-
- /**
- * 1、 主表标签转化为事件标签,
- * 2、 舆情事件入库且分组排序获取最高权重;
- * 3、 判断事件是否四级事件,没有获取四级事件
- * 4、 四级事件入库
- */
- public void mergeEventAndNewsTags(List
tagsList, List eventTags) { - // 事件表主体可能为空,主表主体的标签要分离出来涉及证券+涉及公司
- if (CollectionUtils.isEmpty(tagsList)) {
-
- }
-
- List
otherEventTags = new ArrayList<>(); - List
otherNewsTags = new ArrayList<>(); -
-
- otherNewsTags = tagsList.stream()
- .filter(item -> !eventTags.stream()
- .map(e -> {
- if (Objects.equals(item.getBusinessId(), e.getBusinessId())) {
- return null;
- } else {
- return item.getBusinessId();
- }
- })
- .collect(Collectors.toList())
- .contains(item.getBusinessId()))
- .collect(Collectors.toList());
- otherNewsTags.stream().forEach(System.out::println);
- }
-
-
- public List
createNewsTags() { - List
tagsList = new ArrayList<>(); - TbmNewsTags tbmNewsTags=new TbmNewsTags();
- tbmNewsTags.setNewsId(1L);
- tbmNewsTags.setId(1L);
- tbmNewsTags.setBusinessId("1");
- tagsList.add(tbmNewsTags);
- tbmNewsTags=new TbmNewsTags();
- tbmNewsTags.setNewsId(2L);
- tbmNewsTags.setId(2L);
- tbmNewsTags.setBusinessId("2");
- tagsList.add(tbmNewsTags);
- tbmNewsTags=new TbmNewsTags();
- tbmNewsTags.setNewsId(3L);
- tbmNewsTags.setId(3L);
- tbmNewsTags.setBusinessId("3");
- tagsList.add(tbmNewsTags);
- tbmNewsTags=new TbmNewsTags();
- tbmNewsTags.setNewsId(4L);
- tbmNewsTags.setId(4L);
- tbmNewsTags.setBusinessId("4");
- tagsList.add(tbmNewsTags);
- tbmNewsTags=new TbmNewsTags();
- tbmNewsTags.setNewsId(5L);
- tbmNewsTags.setId(5L);
- tbmNewsTags.setBusinessId("5");
- tagsList.add(tbmNewsTags);
- tbmNewsTags=new TbmNewsTags();
- tbmNewsTags.setNewsId(6L);
- tbmNewsTags.setId(6L);
- tbmNewsTags.setBusinessId("6");
- tagsList.add(tbmNewsTags);
- tbmNewsTags=new TbmNewsTags();
- tbmNewsTags.setNewsId(7L);
- tbmNewsTags.setId(7L);
- tbmNewsTags.setBusinessId("7");
- tagsList.add(tbmNewsTags);
-
- return tagsList;
- }
-
- public List
createEventTags() { - List
eventTags = new ArrayList<>(); - TbmEventTags tbmEventTags=new TbmEventTags();
- tbmEventTags.setId(5L);
- tbmEventTags.setNewsId(5L);
- tbmEventTags.setBusinessId("5");
- eventTags.add(tbmEventTags);
- return eventTags;
- }
-
- /**
- * 输出的结果
- * TbmNewsTags(id=5, newsId=5, registerTagId=null, categoryCode=null, categoryName=null, tagName=null, tagWeight=null, businessId=5, businessCode=null, matchKey=null, frequency=null, nedType=null, main=null, updateTime=null, createTime=null, aiCreate=null, isDelete=null)
- * @param args
- */
- public static void main(String[] args) {
- EventTagsRuleMappingUtil eventTagsRuleMappingUtil = new EventTagsRuleMappingUtil();
- List
tagsList = eventTagsRuleMappingUtil.createNewsTags(); - List
eventTags = eventTagsRuleMappingUtil.createEventTags(); - eventTagsRuleMappingUtil.mergeEventAndNewsTags(tagsList, eventTags);
- }
- //
- }