ORM本地分析详细过程

本地分析入口:AnalysisCallController

路由:/startAnalysis/{date}

执行方法:ormStart.startAnalysis(date);

分析方式和数据来源:

1:开启100个线程

ExecutorServicethreadMain= Executors.newFixedThreadPool(100); //使用多线程分析

2:获取线上库(wi_user_center)状态为1、未删除的项目

List<OutProjectBaseInfoDto> proList= httpProject.getProject();// 获取线上项目信息

3:循环每个项目添加到线程中执行分析

for(OutProjectBaseInfoDto projectBase: proList){

log.info("当时项目id"+ projectBase.getProjectId());

threadMain.execute(this.newStartAnnlyze(projectBase, threadSignal,date));

}

每个项目分析逻辑:

(1)分析所需数据

1:根据项目id获取线下爬虫库wi_orm_crawler

中wi_include_orm表所有软文(没用到)

2:根据项目id获取线下爬虫库wi_orm_crawler中wi_rngative_orm表所有负面(没用到)

3:根据项目id获取项目的所有有效关键词(包含竞品中的关键词)

4:获取项目的所有渠道(11种引擎类型固定的值)

5:根据关键词名称和爬取日期获取所有详单数据。线下爬虫库wi_orm_crawler中wi_artice_orm表的中数据

6:根据关键词名称和爬取日期获取所有的子链接。线下爬虫库wi_orm_crawler中wi_artice_orm表和wi_duplicate_orm表的中数据

7:根据关键词名称和爬取日期获取关键词每个搜索引擎的总条数。线下爬虫库wi_orm_crawler表中数据

(2)分析过程

遍历根据项目id获取的关键词集合keywordList,通过关键词名称和爬取日期查询所有详单数据、所有的子链接数据、关键词每个搜索引擎的总条数数据。遍历各集合数据组装生成10张表的数据。

to_b_total_search_his 爬取关键词历史总数记录表

tm_b_sentiment_duplicate 舆情详单数据历史表--用于保存同一排名多条记录的情况

tm_b_sentiment_detail 存储最为详细的舆情数据

tm_b_search_result_detail 存储在搜索渠道中所有的结果详情

tm_b_sentiment_detail_noise 存储最为详细的舆情数据表tm_b_search_result_detail_noise 存储在搜索渠道中所有的结果详情

tm_b_pro_detail_relation_noise 项目和详单数据关系表

tm_b_pro_detail_relation 项目和详单数据关系表

tm_b_softPaper 软文临时表

tm_b_sentiment_detail_origin 负面历史临时表

1:爬取关键词历史总数记录表-to_b_total_search_his数据集合totalSearchList的生成。

(1.1)Map<Long, List<SentimentDetail>> sentimentDetailChanneMap= Maps.newConcurrentMap();集合的生成。

遍历根据关键词名称和爬取日期查询的取所有详单数据集合artices

生成以渠道ChannelId为key,list<详单>为value的map。

(1.2)遍历sentimentDetailChanneMap中和每个key如何在channelIdList中不存在则从sentimentDetailChanneMap中删除,如果存在则生成搜索总数记录保存到totalSearchList中。

2:舆情详单数据历史表-tm_b_sentiment_duplicate数据集合senDupList的生成。

(2.1)Map<Long, List<String>> prowordMap= projectStringto(project, keyword.getKeywordName());项目飘红规则数据集合的生成。

获取项目中alias和竞品中的alias生成以项目id为key,List<String>为value的map,List<String>中包含alias、项目名称、关键词名称的值。

NoiseDto noise= httpProject.getNoise(project.getProjectId());项目噪声规则数据集合的生成

获取项目噪声集合生成以项目id为key,List<String>为value的map,List<String>中包含项目和竞品的噪声规则noisewordMap。

(2.2)List<DetailRelation> detailRelationList= newArrayList<>()和List<DetailRelation> noisedetailRelationList= newArrayList<>();数据集合的生成。

遍历prowordMap的value集合和sentimentDetailChanneMap的value集合,如果遍历sentimentDetailChanneMap的对象中Title、Desc、Text字段值其中有一个包含prowordMap遍历中对象的值也就是存在飘红则遍历项目噪声数据noisewordMap。如果遍历sentimentDetailChanneMap的对象中Title、Desc、Text字段值其中有一个包含noisewordMap遍历中对象的值则生成

noiseSentimentDetailRelationMap噪声详单数据,如果noisewordMap遍历中对象的值都不包含在sentimentDetailChanneMap的对象中Title、Desc、Text字段值中则生成SentimentDetailRelationMap飘红数据。

(2.3)遍历生成sentimentMap

相关代码:

sentimentDetailChanneMap= reckonranking(sentimentDetailChanneMap);

for(Long projectId: sentimentDetailChanneMap.keySet()) {

for(SentimentDetail sentimentDetail: sentimentDetailChanneMap.get(projectId)) {

sentimentMap.put(sentimentDetail.getDetailId(), sentimentDetail);

}

}

(2.4)遍历SentimentDetailRelationMap生成SentimentDetailRelationList和SentimentDetailList集合。从sentimentMap中获取SentimentDetail设置SentimentDetailRelationMap的Desc和Title。MediaId值的根据sentimentDetail.getChannelId()和sentimentDetail.getUrl()判断设置。

相关代码:

if(1 != sentimentDetail.getChannelId().intValue()) {

subDomian= GetStUtil.getSubDomain(sentimentDetail.getUrl());

} else{

subDomian= GetStUtil.getSubDomain(sentimentDetail.getBaiduurl());

}

Map<String, Long> mediaMap= annlyzeInit.getMedia();

if(mediaMap.containsKey(subDomian)) {

sentimentDetail.setMediaId(mediaMap.get(subDomian));

} else{

sentimentDetail.setMediaId(0l);

}...

(2.5)Map<Long,List<Duplicate>> dupMap= newHashMap<>()数据生成

遍历子链接数据dupLIst生成dupMap,以acticleId为key,List<Duplicate>为value的map。

(2.6)遍历SentimentDetailList,根据detailId从dupMap中取出List<Duplicate> dupList,遍历dupList,生成senDupList数据集合。

3:存储最为详细的舆情数据表-tm_b_sentiment_detail数据集合SentimentDetailList的生成。

在(2.4)中已有生成逻辑。

4:储在搜索渠道中所有的结果详情表-tm_b_search_result_detail数据集合SentimentDetailList的生成。

在(2.4)中已有生成逻辑。

5:存储最为详细的舆情数据表-tm_b_sentiment_detail_noise数据集合noiseSentimentDetailList的生成。

遍历在(2.2)中生成的noiseSentimentDetailRelationMap通过detailRelation.getDetailId()从sentimentMap中获取noiseSentimentDetailList。

6:存储在搜索渠道中所有的结果详情表-tm_b_search_result_detail_noise数据集合noiseSentimentDetailList的生成。

遍历在(2.2)中生成的noiseSentimentDetailRelationMap通过detailRelation.getDetailId()从sentimentMap中获取noiseSentimentDetailList。

7:项目和详单数据关系表-tm_b_pro_detail_relation_noise数据集合noiseSentimentDetailRelationList的生成。

遍历在(2.2)中生成的noiseSentimentDetailRelationMap生成noiseSentimentDetailRelationList。

8:项目和详单数据关系表-tm_b_pro_detail_relation数据集合SentimentDetailRelationList的生成。

在(2.4)中已有生成逻辑

9:软文临时表-tm_b_softPaper 数据集合includeList的生成。(没有用到)

10:负面历史临时表 tm_b_sentiment_detail_origin

数据集合rngativeExitList的生成。(没有用到)

所有项目分析完成后调用线下调度将文件压缩上传到线上分析。


【识别上图二维码,关注NC官方公众号和官方微博,每周行业资讯看不停】