Commit 6fe16ea2 by shenjunjie

Merge branch 'feature' into 'dev'

Feature

See merge request !488
parents c60988a4 65dc384b
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<qbjc.bean.version>1.1.7.1-SNAPSHOT</qbjc.bean.version> <qbjc.bean.version>1.1.7.1-SNAPSHOT</qbjc.bean.version>
<springfox.version>2.9.2</springfox.version> <springfox.version>2.9.2</springfox.version>
<fastjson.version>1.2.47</fastjson.version> <fastjson.version>1.2.47</fastjson.version>
<easyexcel.version>3.0.5</easyexcel.version> <easyexcel.version>3.3.4</easyexcel.version>
<marker.client.version>1.1.9-SNAPSHOT</marker.client.version> <marker.client.version>1.1.9-SNAPSHOT</marker.client.version>
<base-objects.version>2.1.6.1-SNAPSHOT</base-objects.version> <base-objects.version>2.1.6.1-SNAPSHOT</base-objects.version>
<es.version>7.9.2</es.version> <es.version>7.9.2</es.version>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<dubbo.version>2.7.4.1</dubbo.version> <dubbo.version>2.7.4.1</dubbo.version>
<curator.version>2.12.0</curator.version> <curator.version>2.12.0</curator.version>
<push.log.version>2.17.0-SNAPSHOT</push.log.version> <push.log.version>2.17.0-SNAPSHOT</push.log.version>
<event-client.version>1.0.9.8-SNAPSHOT</event-client.version> <event-client.version>1.0.9.9-SNAPSHOT</event-client.version>
<cleaner-unified-filter.version>1.1.5-SNAPSHOT</cleaner-unified-filter.version> <cleaner-unified-filter.version>1.1.5-SNAPSHOT</cleaner-unified-filter.version>
</properties> </properties>
...@@ -187,6 +187,17 @@ ...@@ -187,6 +187,17 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version> <version>${easyexcel.version}</version>
<exclusions>
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.7.1</version>
</dependency> </dependency>
<!-- lombok --> <!-- lombok -->
<dependency> <dependency>
......
...@@ -2,10 +2,7 @@ package com.zhiwei.brandkbs2.common; ...@@ -2,10 +2,7 @@ package com.zhiwei.brandkbs2.common;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.ChannelTag; import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.pojo.HighlightWord;
import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.SensitiveChannel;
import com.zhiwei.brandkbs2.service.ChannelService; import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.service.SystemInfoService; import com.zhiwei.brandkbs2.service.SystemInfoService;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
...@@ -103,6 +100,11 @@ public class GlobalPojo { ...@@ -103,6 +100,11 @@ public class GlobalPojo {
*/ */
public static Map<String, SensitiveChannel> COMMON_SENSITIVE_CHANNEL = new HashMap<>(); public static Map<String, SensitiveChannel> COMMON_SENSITIVE_CHANNEL = new HashMap<>();
/**
* 字节定制指定渠道影响力信息
*/
public static Map<String, BytedanceCustomChannelInfluence> BYTEDANCE_CHANNEL_INFLUENCE = new HashMap<>();
@PostConstruct @PostConstruct
public void start() { public void start() {
try { try {
...@@ -139,9 +141,10 @@ public class GlobalPojo { ...@@ -139,9 +141,10 @@ public class GlobalPojo {
PROJECT_EMOTION_CHANNEL_DATA = channelService.getProjectEmotionChannelListData(); PROJECT_EMOTION_CHANNEL_DATA = channelService.getProjectEmotionChannelListData();
PROJECT_SENSITIVE_CHANNEL = systemInfoService.getProjectSensitiveChannel(); PROJECT_SENSITIVE_CHANNEL = systemInfoService.getProjectSensitiveChannel();
COMMON_SENSITIVE_CHANNEL = systemInfoService.getCommonSensitiveChannel(); COMMON_SENSITIVE_CHANNEL = systemInfoService.getCommonSensitiveChannel();
BYTEDANCE_CHANNEL_INFLUENCE = systemInfoService.getByteDanceChannelInfluence();
updateHighlightGraphs(); updateHighlightGraphs();
log.info("{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{},PROJECT_EMOTION_CHANNEL_DATA-size:{},PROJECT_SENSITIVE_CHANNEL-size:{}, COMMON_SENSITIVE_CHANNEL-size:{}", logMsg, PLATFORMS.size(), TAGS.size(), log.info("{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{},PROJECT_EMOTION_CHANNEL_DATA-size:{},PROJECT_SENSITIVE_CHANNEL-size:{}, COMMON_SENSITIVE_CHANNEL-size:{},BYTEDANCE_CHANNEL_INFLUENCE-size:{}", logMsg, PLATFORMS.size(), TAGS.size(),
LINKED_GROUP_ID_TAGS.size(), CHANNEL_TAGS.size(), MEDIA_TYPE.size(), PROJECT_MAP.size(), YU_QING_PROJECTS.size(), PROJECT_EMOTION_CHANNEL_DATA.size(), PROJECT_SENSITIVE_CHANNEL.size(), COMMON_SENSITIVE_CHANNEL.size()); LINKED_GROUP_ID_TAGS.size(), CHANNEL_TAGS.size(), MEDIA_TYPE.size(), PROJECT_MAP.size(), YU_QING_PROJECTS.size(), PROJECT_EMOTION_CHANNEL_DATA.size(), PROJECT_SENSITIVE_CHANNEL.size(), COMMON_SENSITIVE_CHANNEL.size(), BYTEDANCE_CHANNEL_INFLUENCE.size());
} catch (Exception e) { } catch (Exception e) {
log.info("{}-获取缓存值异常", logMsg, e); log.info("{}-获取缓存值异常", logMsg, e);
} }
......
...@@ -27,6 +27,7 @@ public class RedisKeyPrefix { ...@@ -27,6 +27,7 @@ public class RedisKeyPrefix {
public static final String INDEX_PLATFORM = "BRANDKBS:INDEX:PLATFORM:"; public static final String INDEX_PLATFORM = "BRANDKBS:INDEX:PLATFORM:";
public static final String INDEX_SPREAD = "BRANDKBS:INDEX:SPREAD:"; public static final String INDEX_SPREAD = "BRANDKBS:INDEX:SPREAD:";
public static final String INDEX_COMPARE_SUMMARY_MOBILE = "BRANDKBS:INDEX:COMPARE_SUMMARY:MOBILE:"; public static final String INDEX_COMPARE_SUMMARY_MOBILE = "BRANDKBS:INDEX:COMPARE_SUMMARY:MOBILE:";
public static final String INDEX_EMOTION = "BRANDKBS:INDEX:EMOTION:";
/** /**
* 渠道榜单缓存 * 渠道榜单缓存
*/ */
......
...@@ -55,17 +55,8 @@ public class InterfaceController { ...@@ -55,17 +55,8 @@ public class InterfaceController {
@ApiOperation("获取舆情动态-预警结果") @ApiOperation("获取舆情动态-预警结果")
@PostMapping("/warn/yuqing") @PostMapping("/warn/yuqing")
@Deprecated
public ResponseResult getYuqingWaring(@RequestBody JSONObject json) { public ResponseResult getYuqingWaring(@RequestBody JSONObject json) {
String projectId = json.getString("projectId"); String projectId = json.getString("projectId");
BrandkbsYuQingConfig config = json.getObject("config", BrandkbsYuQingConfig.class);
return projectWarnService.getYuqingWaring(projectId, config);
}
@ApiOperation("获取舆情动态-预警结果")
@PostMapping("/warn/yuqingNew")
public ResponseResult getYuqingWaringNew(@RequestBody JSONObject json) {
String projectId = json.getString("projectId");
BrandkbsYuQingConfigNew config = json.getObject("config", BrandkbsYuQingConfigNew.class); BrandkbsYuQingConfigNew config = json.getObject("config", BrandkbsYuQingConfigNew.class);
return projectWarnService.getYuqingWaringNew(projectId, config); return projectWarnService.getYuqingWaringNew(projectId, config);
} }
......
...@@ -168,6 +168,7 @@ public class AppArticleController extends BaseController { ...@@ -168,6 +168,7 @@ public class AppArticleController extends BaseController {
@ApiOperation("舆情分析-舆情概览") @ApiOperation("舆情分析-舆情概览")
@ApiImplicitParams({@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "long")}) @ApiImplicitParams({@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "long"), @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "long")})
@GetMapping("/analyze/summary") @GetMapping("/analyze/summary")
@Deprecated
public ResponseResult getAnalyzeSummary(@RequestParam(value = "startTime", required = false) Long startTime, @RequestParam(value = "endTime", required = false) Long endTime) { public ResponseResult getAnalyzeSummary(@RequestParam(value = "startTime", required = false) Long startTime, @RequestParam(value = "endTime", required = false) Long endTime) {
return ResponseResult.success(markDataService.getAnalyzeSummary(startTime, endTime, true)); return ResponseResult.success(markDataService.getAnalyzeSummary(startTime, endTime, true));
} }
...@@ -447,77 +448,58 @@ public class AppArticleController extends BaseController { ...@@ -447,77 +448,58 @@ public class AppArticleController extends BaseController {
} }
@ApiOperation("新-舆情分析-舆情总量") @ApiOperation("新-舆情分析-舆情总量")
@GetMapping("/analyze/amount") @PostMapping("/analyze/amount")
@LogRecord(description = "舆情库-舆情分析") @LogRecord(description = "舆情库-舆情分析")
public ResponseResult getYuqingAmount(@RequestParam(value = "startTime") Long startTime, public ResponseResult getYuqingAmount(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getYuqingAmount(markSearchDTO));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getYuqingAmount(startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-情感分布") @ApiOperation("新-舆情分析-情感分布")
@GetMapping("/analyze/emotion") @PostMapping("/analyze/emotion")
public ResponseResult getYuqingEmotionDistribution(@RequestParam(value = "startTime") Long startTime, public ResponseResult getYuqingEmotionDistribution(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getYuqingEmotionDistribution(markSearchDTO));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getYuqingEmotionDistribution(startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-重点平台") @ApiOperation("新-舆情分析-重点平台")
@GetMapping("/analyze/important-platform") @PostMapping("/analyze/important-platform")
public ResponseResult getImportantPlatformPercentage(@RequestParam(value = "startTime") Long startTime, public ResponseResult getImportantPlatformPercentage(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getImportantPlatformPercentage(markSearchDTO));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getImportantPlatformPercentage(startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-平台占比") @ApiOperation("新-舆情分析-平台占比")
@GetMapping("/analyze/platform-percent") @PostMapping("/analyze/platform-percent")
public ResponseResult getPlatformPercentage(@RequestParam(value = "startTime") Long startTime, public ResponseResult getPlatformPercentage(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.geAnalyzePlatformPercentage(markSearchDTO));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getPlatformPercentage(startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-舆情走势图") @ApiOperation("新-舆情分析-舆情走势图")
@GetMapping("/analyze/tendency") @PostMapping("/analyze/tendency")
public ResponseResult getSpreadTendency(@RequestParam(value = "startTime") Long startTime, public ResponseResult getSpreadTendency(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getSpreadTendency(markSearchDTO));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getSpreadTendency(startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-活跃渠道") @ApiOperation("新-舆情分析-活跃渠道")
@GetMapping("/analyze/active-channel") @PostMapping("/analyze/active-channel")
public ResponseResult getActiveChannels(@RequestParam(value = "startTime") Long startTime, public ResponseResult getActiveChannels(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getActiveChannels(markSearchDTO));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getActiveChannels(startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-ip分布") @ApiOperation("新-舆情分析-ip分布")
@GetMapping("/analyze/ip-located") @PostMapping("/analyze/ip-located")
public ResponseResult getArticleIpLocated(@RequestParam(value = "startTime") Long startTime, public ResponseResult getArticleIpLocated(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getArticleIpLocated(markSearchDTO));
@RequestParam(value = "planId", required = false) String planId,
@RequestParam(value = "size") int size) {
return ResponseResult.success(markDataService.getArticleIpLocated(startTime, endTime, planId, size));
} }
@ApiOperation("新-舆情分析-词云") @ApiOperation("新-舆情分析-词云")
@GetMapping("/analyze/high-word") @PostMapping("/analyze/high-word")
public ResponseResult getHighWord(@RequestParam(value = "startTime") Long startTime, public ResponseResult getHighWord(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getAnalyzeHighWord(markSearchDTO, true));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getHighWord(startTime, endTime, planId, true));
} }
@ApiOperation("新-舆情分析-高频标题") @ApiOperation("新-舆情分析-高频标题")
@GetMapping("/analyze/frequent-title") @PostMapping("/analyze/frequent-title")
public ResponseResult getLastNews(@RequestParam(value = "startTime") Long startTime, public ResponseResult getLastNews(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getLastNews(markSearchDTO, 5));
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getLastNews(startTime, endTime, planId, 5, true));
} }
@ApiOperation("新-舆情分析-活跃渠道、ip分布、词云详情页面,社媒平台发文") @ApiOperation("新-舆情分析-活跃渠道、ip分布、词云详情页面,社媒平台发文")
...@@ -527,42 +509,33 @@ public class AppArticleController extends BaseController { ...@@ -527,42 +509,33 @@ public class AppArticleController extends BaseController {
} }
@ApiOperation("新-舆情分析-高频标题-基础信息") @ApiOperation("新-舆情分析-高频标题-基础信息")
@GetMapping("/analyze/frequent-title/info") @PostMapping("/analyze/frequent-title/info")
public ResponseResult getAggTitleBaseInfo(@RequestParam(value = "startTime") Long startTime, public ResponseResult getAggTitleBaseInfo(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getAggTitleBaseInfo(markSearchDTO));
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getAggTitleBaseInfo(aggTitle, startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-高频标题-发布节点") @ApiOperation("新-舆情分析-高频标题-发布节点")
@GetMapping("/analyze/frequent-title/article-point") @PostMapping("/analyze/frequent-title/article-point")
public ResponseResult getArticlePoints(@RequestParam(value = "startTime") Long startTime, public ResponseResult getArticlePoints(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getAggTitleArticlePoints(markSearchDTO));
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getAggTitleArticlePoints(aggTitle, startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-高频标题-平台分布") @ApiOperation("新-舆情分析-高频标题-平台分布")
@GetMapping("/analyze/frequent-title/platform-percent") @PostMapping("/analyze/frequent-title/platform-percent")
public ResponseResult getAggTitlePlatformPercentage(@RequestParam(value = "startTime") Long startTime, public ResponseResult getAggTitlePlatformPercentage(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getAggTitlePlatformPercentage(markSearchDTO));
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getAggTitlePlatformPercentage(aggTitle, startTime, endTime, planId));
} }
@ApiOperation("新-舆情分析-高频标题-发文列表") @ApiOperation("新-舆情分析-高频标题-发文列表")
@GetMapping("/analyze/frequent-title/articles") @PostMapping("/analyze/frequent-title/articles")
public ResponseResult getArticleList(@RequestParam(value = "startTime") Long startTime, public ResponseResult getArticleList(@RequestBody MarkSearchDTO markSearchDTO) {
@RequestParam(value = "endTime") Long endTime, return ResponseResult.success(markDataService.getArticleList(markSearchDTO));
@RequestParam(value = "aggTitle") String aggTitle, }
@RequestParam(value = "platform") String platform,
@RequestParam(value = "planId", required = false) String planId, @ApiOperation("新-(查舆情)舆情分析-词云")
@RequestParam(value = "page", defaultValue = "1") Integer page, @PostMapping("/analyze/search/high-word")
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { public ResponseResult generateSearchAnalyzeHighWord(@RequestBody MarkSearchDTO markSearchDTO) {
return ResponseResult.success(markDataService.getArticleList(aggTitle, startTime, endTime, planId, platform, page, pageSize)); return ResponseResult.success(markDataService.getSearchAnalyzeHighWord(markSearchDTO));
} }
private boolean checkMTagIllegal(StringBuilder mtag) { private boolean checkMTagIllegal(StringBuilder mtag) {
......
...@@ -519,15 +519,22 @@ public class AppDownloadController extends BaseController { ...@@ -519,15 +519,22 @@ public class AppDownloadController extends BaseController {
@DownloadTask(taskName = "事件影响力更新模板下载", description = "事件影响力更新模板") @DownloadTask(taskName = "事件影响力更新模板下载", description = "事件影响力更新模板")
public ResponseResult downloadEventUpdateTemplate(){ public ResponseResult downloadEventUpdateTemplate(){
List<List<String>> head = new ArrayList<>(); List<List<String>> head = new ArrayList<>();
head.add(Collections.singletonList("序号"));
head.add(Collections.singletonList("平台类型")); head.add(Collections.singletonList("平台类型"));
head.add(Collections.singletonList("渠道名称")); head.add(Collections.singletonList("发布平台"));
head.add(Collections.singletonList("链接")); head.add(Collections.singletonList("渠道"));
head.add(Collections.singletonList("事件名")); head.add(Collections.singletonList("时间"));
head.add(Collections.singletonList("微博转发")); head.add(Collections.singletonList("标题"));
head.add(Collections.singletonList("微博评论")); head.add(Collections.singletonList("文本"));
head.add(Collections.singletonList("微博点赞")); head.add(Collections.singletonList("地址"));
head.add(Collections.singletonList("微信阅读")); head.add(Collections.singletonList("命中词"));
head.add(Collections.singletonList("微信在看")); head.add(Collections.singletonList("情感倾向"));
head.add(Collections.singletonList("事件标签"));
head.add(Collections.singletonList("在看"));
head.add(Collections.singletonList("阅读"));
head.add(Collections.singletonList("点赞"));
head.add(Collections.singletonList("评论"));
head.add(Collections.singletonList("转发"));
// excel写入至指定路径 // excel写入至指定路径
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName(); String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "事件更新模板"); String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "事件更新模板");
......
...@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum; ...@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO; import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
import com.zhiwei.brandkbs2.service.EventService; import com.zhiwei.brandkbs2.service.EventService;
import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO; import com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO;
import com.zhiwei.middleware.event.pojo.dto.EventDTO; import com.zhiwei.middleware.event.pojo.dto.EventDTO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -20,6 +21,7 @@ import org.springframework.http.ResponseEntity; ...@@ -20,6 +21,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
/** /**
...@@ -64,6 +66,9 @@ public class AppEventController extends BaseController { ...@@ -64,6 +66,9 @@ public class AppEventController extends BaseController {
private final EventService eventService; private final EventService eventService;
@Resource(name = "markDataServiceImpl")
MarkDataService markDataService;
public AppEventController(EventService eventService) { public AppEventController(EventService eventService) {
this.eventService = eventService; this.eventService = eventService;
} }
...@@ -355,4 +360,43 @@ public class AppEventController extends BaseController { ...@@ -355,4 +360,43 @@ public class AppEventController extends BaseController {
public ResponseResult aggTitleAnalyze(@RequestBody EventDTO dto){ public ResponseResult aggTitleAnalyze(@RequestBody EventDTO dto){
return eventService.aggTitleAnalyze(dto); return eventService.aggTitleAnalyze(dto);
} }
@ApiOperation("新-舆情分析-高频标题-基础信息")
@GetMapping("/analyze/frequent-title/info")
public ResponseResult getAggTitleBaseInfo(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getAggTitleBaseInfo(aggTitle, startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-高频标题-发布节点")
@GetMapping("/analyze/frequent-title/article-point")
public ResponseResult getArticlePoints(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getAggTitleArticlePoints(aggTitle, startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-高频标题-平台分布")
@GetMapping("/analyze/frequent-title/platform-percent")
public ResponseResult getAggTitlePlatformPercentage(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getAggTitlePlatformPercentage(aggTitle, startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-高频标题-发文列表")
@GetMapping("/analyze/frequent-title/articles")
public ResponseResult getArticleList(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "platform") String platform,
@RequestParam(value = "planId", required = false) String planId,
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return ResponseResult.success(markDataService.getArticleList(aggTitle, startTime, endTime, planId, platform, page, pageSize));
}
} }
...@@ -90,5 +90,15 @@ public class AppIndexController extends BaseController { ...@@ -90,5 +90,15 @@ public class AppIndexController extends BaseController {
return ResponseResult.success(indexService.getSpreadingTend(startTime, endTime, true)); return ResponseResult.success(indexService.getSpreadingTend(startTime, endTime, true));
} }
@ApiOperation("首页-净情感度")
@ApiImplicitParams({
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "long")
})
@GetMapping("/emotion-percent")
public ResponseResult getEmotionPercent(@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime) {
return ResponseResult.success(indexService.getEmotionPercent(startTime, endTime, true));
}
} }
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelLevelInfo;
/**
* @ClassName: BytedanceCustomChannelDao
* @Description BytedanceCustomChannelDao
* @author: cjz
* @date: 2023-10-13 15:43
*/
public interface BytedanceCustomChannelLevelInfoDao extends BaseMongoDao<BytedanceCustomChannelLevelInfo>{
}
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.MarkSearchAnalyzeTask;
public interface MarkSearchAnalyzeTaskDao extends BaseMongoDao<MarkSearchAnalyzeTask>{
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.BytedanceCustomChannelLevelInfoDao;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelLevelInfo;
import org.springframework.stereotype.Component;
@Component("bytedanceCustomChannelLevelInfoDao")
public class BytedanceCustomChannelLevelInfoDaoImpl extends BaseMongoDaoImpl<BytedanceCustomChannelLevelInfo> implements BytedanceCustomChannelLevelInfoDao {
private static final String COLLECTION_NAME = "brandkbs_bytedance_custom_channel_level_info";
public BytedanceCustomChannelLevelInfoDaoImpl() {
super(COLLECTION_NAME);
}
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.MarkSearchAnalyzeTaskDao;
import com.zhiwei.brandkbs2.pojo.MarkSearchAnalyzeTask;
import org.springframework.stereotype.Component;
@Component("markSearchAnalyzeTaskDao")
public class MarkSearchAnalyzeTaskDaoImpl extends BaseMongoDaoImpl<MarkSearchAnalyzeTask> implements MarkSearchAnalyzeTaskDao {
private static final String COLLECTION_NAME = "brandkbs_search_analyze_task";
public MarkSearchAnalyzeTaskDaoImpl() {
super(COLLECTION_NAME);
}
}
...@@ -16,13 +16,15 @@ public class ExportBytedanceEventComputeResultDTO { ...@@ -16,13 +16,15 @@ public class ExportBytedanceEventComputeResultDTO {
@ExcelProperty("事件名") @ExcelProperty("事件名")
private String name; private String name;
@ExcelProperty("影响力指数") @ExcelProperty("渠道指标")
private Double inf; private Double inf;
@ExcelProperty("实时传播力") @ExcelProperty("流量指标")
private Double RMI; private Double RMI;
@ExcelProperty("传播影响力") @ExcelProperty("综合影响力")
private Double finalInf; private Double finalInf;
@ExcelProperty("传播量")
private Integer dataCount;
} }
...@@ -11,31 +11,51 @@ import lombok.Data; ...@@ -11,31 +11,51 @@ import lombok.Data;
*/ */
@Data @Data
public class UploadBytedanceEventDTO { public class UploadBytedanceEventDTO {
@ExcelProperty("序号")
private String number;
@ExcelProperty("平台类型") @ExcelProperty("平台类型")
private String platformType;
@ExcelProperty("发布平台")
private String platform; private String platform;
@ExcelProperty("渠道名称") @ExcelProperty("渠道")
private String channel; private String channel;
@ExcelProperty("链接") @ExcelProperty("时间")
private String time;
@ExcelProperty("标题")
private String title;
@ExcelProperty("文本")
private String content;
@ExcelProperty("地址")
private String url; private String url;
@ExcelProperty("事件名") @ExcelProperty("命中词")
private String hitWord;
@ExcelProperty("情感倾向")
private String emotion;
@ExcelProperty("事件标签")
private String eventName; private String eventName;
@ExcelProperty("微博转发") @ExcelProperty("在看")
private Integer weiboForward; private String reading;
@ExcelProperty("微博评论") @ExcelProperty("阅读")
private Integer weiboComment; private String read;
@ExcelProperty("微博点赞") @ExcelProperty("点赞")
private Integer weiboLike; private String like;
@ExcelProperty("微信阅读") @ExcelProperty("评论")
private Integer wechatRead; private String comment;
@ExcelProperty("微信在看") @ExcelProperty("转发")
private Integer wechatReading; private String forward;
} }
...@@ -4,11 +4,8 @@ import com.alibaba.excel.context.AnalysisContext; ...@@ -4,11 +4,8 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.event.AnalysisEventListener;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO; import com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTaskData; import com.zhiwei.brandkbs2.pojo.BytedanceCustomEventUpdateTaskData;
import com.zhiwei.brandkbs2.util.Tools;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -33,20 +30,20 @@ public class BytedanceEventListener extends AnalysisEventListener<UploadBytedanc ...@@ -33,20 +30,20 @@ public class BytedanceEventListener extends AnalysisEventListener<UploadBytedanc
public void invoke(UploadBytedanceEventDTO dto, AnalysisContext context) { public void invoke(UploadBytedanceEventDTO dto, AnalysisContext context) {
BytedanceCustomEventUpdateTaskData taskData = new BytedanceCustomEventUpdateTaskData(); BytedanceCustomEventUpdateTaskData taskData = new BytedanceCustomEventUpdateTaskData();
taskData.setTaskId(taskId); taskData.setTaskId(taskId);
taskData.setEventName(dto.getEventName()); taskData.setPlatformType(dto.getPlatformType());
taskData.setChannel(dto.getChannel());
taskData.setPlatform(dto.getPlatform()); taskData.setPlatform(dto.getPlatform());
taskData.setUrl(dto.getUrl()); taskData.setChannel(dto.getChannel());
taskData.setWeiboComment(dto.getWeiboComment()); taskData.setEventName(dto.getEventName());
taskData.setWeiboForward(dto.getWeiboForward()); // 填 "/" 当作0处理
taskData.setWeiboLike(dto.getWeiboLike()); taskData.setReading(Objects.isNull(dto.getReading()) || Objects.equals("/", dto.getReading()) ? 0 : Integer.parseInt(dto.getReading()));
taskData.setWechatRead(dto.getWechatRead()); taskData.setRead(Objects.isNull(dto.getRead()) || Objects.equals("/", dto.getRead()) ? 0 : Integer.parseInt(dto.getRead()));
taskData.setWechatReading(dto.getWechatReading()); taskData.setLike(Objects.isNull(dto.getLike()) || Objects.equals("/", dto.getLike()) ? 0 : Integer.parseInt(dto.getLike()));
taskData.setComment(Objects.isNull(dto.getComment()) || Objects.equals("/", dto.getComment()) ? 0 : Integer.parseInt(dto.getComment()));
taskData.setForward(Objects.isNull(dto.getForward()) || Objects.equals("/", dto.getForward()) ? 0 : Integer.parseInt(dto.getForward()));
data.add(taskData); data.add(taskData);
} }
@Override @Override
public void doAfterAllAnalysed(AnalysisContext context) { public void doAfterAllAnalysed(AnalysisContext context) {
} }
} }
...@@ -417,18 +417,18 @@ public class EsQueryTools { ...@@ -417,18 +417,18 @@ public class EsQueryTools {
public static void addSensitiveChannel(BrandkbsYuQingConfigNew config, BoolQueryBuilder boolQueryBuilder) { public static void addSensitiveChannel(BrandkbsYuQingConfigNew config, BoolQueryBuilder boolQueryBuilder) {
BoolQueryBuilder hitBoolQuery = QueryBuilders.boolQuery(); BoolQueryBuilder hitBoolQuery = QueryBuilders.boolQuery();
if (!Tools.isEmpty(config.getPoliticsLevels())) { if (!Tools.isEmpty(config.getPoliticsLevels()) && !config.getPoliticsLevels().contains("全部")) {
List<String> hitList = config.getPoliticsLevels(); List<String> hitList = config.getPoliticsLevels();
if (config.getPoliticsLevels().contains("全部")) { // if (config.getPoliticsLevels().contains("全部")) {
hitList = ChannelType.POLITICS_LEVELS; // hitList = ChannelType.POLITICS_LEVELS;
} // }
hitList.forEach(politicsLevel -> hitBoolQuery.should(QueryBuilders.termQuery(GenericAttribute.ES_SENSITIVE_CHANNEL + "." + GenericAttribute.ES_POLITICS_LEVEL + ".keyword", politicsLevel))); hitList.forEach(politicsLevel -> hitBoolQuery.should(QueryBuilders.termQuery(GenericAttribute.ES_SENSITIVE_CHANNEL + "." + GenericAttribute.ES_POLITICS_LEVEL + ".keyword", politicsLevel)));
} }
if (!Tools.isEmpty(config.getFields())) { if (!Tools.isEmpty(config.getFields()) && !config.getFields().contains("全部")) {
List<String> hitList = config.getFields(); List<String> hitList = config.getFields();
if (config.getFields().contains("全部")) { // if (config.getFields().contains("全部")) {
hitList = ChannelType.COMMON_FIELDS; // hitList = ChannelType.COMMON_FIELDS;
} // }
hitList.forEach(field -> hitBoolQuery.should(QueryBuilders.termQuery(GenericAttribute.ES_SENSITIVE_CHANNEL + "." + GenericAttribute.ES_FIELD + ".keyword", field))); hitList.forEach(field -> hitBoolQuery.should(QueryBuilders.termQuery(GenericAttribute.ES_SENSITIVE_CHANNEL + "." + GenericAttribute.ES_FIELD + ".keyword", field)));
} }
boolQueryBuilder.must(hitBoolQuery); boolQueryBuilder.must(hitBoolQuery);
......
...@@ -50,7 +50,7 @@ public class ExceptionCatch { ...@@ -50,7 +50,7 @@ public class ExceptionCatch {
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public ResponseResult exception(Exception exception) { public ResponseResult exception(Exception exception) {
//记录日志 //记录日志
log.info("catch exception:", exception); log.error("catch exception:", exception);
//返回400操作失败 //返回400操作失败
return new ResponseResult(CommonCodeEnum.FAIL, Collections.EMPTY_LIST); return new ResponseResult(CommonCodeEnum.FAIL, Collections.EMPTY_LIST);
} }
......
...@@ -11,6 +11,7 @@ import lombok.Setter; ...@@ -11,6 +11,7 @@ import lombok.Setter;
*/ */
@Getter @Getter
@Setter @Setter
@Deprecated // 2024.3.22 计算公式调整 弃用
public class BytedanceCustomChannel extends AbstractBaseMongo{ public class BytedanceCustomChannel extends AbstractBaseMongo{
/** /**
......
...@@ -27,4 +27,9 @@ public class BytedanceCustomChannelInfluence extends AbstractBaseMongo{ ...@@ -27,4 +27,9 @@ public class BytedanceCustomChannelInfluence extends AbstractBaseMongo{
* 影响力 * 影响力
*/ */
private double influence; private double influence;
/**
* 渠道等级
*/
private String level;
} }
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.Setter;
/**
* @ClassName: BytedanceCustomChannelLevelInfo
* @Description 字节定制渠道等级、拐点、极值、权重对照表
* @author: cjz
* @date: 2024-3-20 14:09
*/
@Getter
@Setter
public class BytedanceCustomChannelLevelInfo extends AbstractBaseMongo{
/**
* 等级
*/
private String level;
/**
* HMax
*/
private double HMax;
/**
* 权重
*/
private double weight;
/**
* 临界
*/
private double threshold;
/**
* 系数
*/
private double coefficient;
}
package com.zhiwei.brandkbs2.pojo; package com.zhiwei.brandkbs2.pojo;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadBytedanceEventDTO;
import lombok.*; import lombok.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @ClassName: BytedanceCustomEventInfluenceTask * @ClassName: BytedanceCustomEventInfluenceTask
...@@ -40,14 +38,6 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -40,14 +38,6 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
*/ */
private List<EventInfo> eventInfo; private List<EventInfo> eventInfo;
/** /**
* 事件数据
*/
// private Map<String, List<UploadBytedanceEventDTO>> eventData;
/**
* 报错数据
*/
private List<BytedanceCustomEventUpdateTaskData> errorData;
/**
* 竞品影响力指数 * 竞品影响力指数
*/ */
private Double contendInfluence; private Double contendInfluence;
...@@ -88,6 +78,10 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -88,6 +78,10 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
*/ */
private String name; private String name;
/** /**
* 传播量(该事件的数据量)
*/
private Integer dataCount;
/**
* 影响力指数 * 影响力指数
*/ */
private Double influence; private Double influence;
...@@ -145,7 +139,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -145,7 +139,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
task.setProcessStatus(ProcessStatus.CHANNEL_MATCH.getStatus()); task.setProcessStatus(ProcessStatus.CHANNEL_MATCH.getStatus());
task.setExtraCompute(extraCompute); task.setExtraCompute(extraCompute);
task.setEventInfo(new ArrayList<>()); task.setEventInfo(new ArrayList<>());
task.setErrorData(new ArrayList<>()); // task.setErrorData(new ArrayList<>());
task.setCancel(false); task.setCancel(false);
task.setSchedule(0); task.setSchedule(0);
task.setTotalSchedule(0); task.setTotalSchedule(0);
...@@ -165,7 +159,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{ ...@@ -165,7 +159,7 @@ public class BytedanceCustomEventUpdateTask extends AbstractBaseMongo{
task.setProcessStatus(ProcessStatus.QUERY_YUQING.getStatus()); task.setProcessStatus(ProcessStatus.QUERY_YUQING.getStatus());
task.setExtraCompute(false); task.setExtraCompute(false);
task.setEventInfo(null); task.setEventInfo(null);
task.setErrorData(null); // task.setErrorData(null);
task.setCancel(false); task.setCancel(false);
task.setSchedule(0); task.setSchedule(0);
task.setTotalSchedule(0); task.setTotalSchedule(0);
......
...@@ -6,7 +6,7 @@ import lombok.Setter; ...@@ -6,7 +6,7 @@ import lombok.Setter;
/** /**
* @ClassName: BytedanceCustomEventInfluenceTask * @ClassName: BytedanceCustomEventInfluenceTask
* @Description 字节定制事件影响力计算rw * @Description 字节定制事件影响力计算
* @author: cjz * @author: cjz
* @date: 2023-10-16 15:12 * @date: 2023-10-16 15:12
*/ */
...@@ -16,21 +16,21 @@ import lombok.Setter; ...@@ -16,21 +16,21 @@ import lombok.Setter;
public class BytedanceCustomEventUpdateTaskData extends AbstractBaseMongo { public class BytedanceCustomEventUpdateTaskData extends AbstractBaseMongo {
private String taskId; private String taskId;
private String platformType;
private String platform; private String platform;
private String channel; private String channel;
private String url;
private String eventName; private String eventName;
private Integer weiboForward; private Integer reading;
private Integer weiboComment; private Integer read;
private Integer weiboLike; private Integer like;
private Integer wechatRead; private Integer comment;
private Integer wechatReading; private Integer forward;
} }
package com.zhiwei.brandkbs2.pojo;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @ClassName: YuqingSearchAnalyzeTask
* @Description 查舆情数据分析任务
* @author: cjz
* @date: 2024-04-16 14:21
*/
@Getter
@Setter
@AllArgsConstructor
public class MarkSearchAnalyzeTask extends AbstractBaseMongo {
/**
* 查舆情搜索条件
*/
private MarkSearchDTO markSearchDTO;
/**
* 数据分析结果-词云
*/
List<JSONObject> highWord;
/**
* 词云计算是否已完成
*/
private Boolean finish;
/**
* 创建时间
*/
private Long cTime;
}
...@@ -195,4 +195,9 @@ public class MarkSearchDTO { ...@@ -195,4 +195,9 @@ public class MarkSearchDTO {
*/ */
@ApiModelProperty(value = "gid限制") @ApiModelProperty(value = "gid限制")
private Long pageGid; private Long pageGid;
/**
* 聚合标题
*/
@ApiModelProperty(value = "聚合标题")
private String aggTitle;
} }
...@@ -19,6 +19,16 @@ public class BrandkbsYuQingConfigNew { ...@@ -19,6 +19,16 @@ public class BrandkbsYuQingConfigNew {
private String channel; private String channel;
/** /**
* 屏蔽关键字命中
*/
private String noiseKeyword;
/**
* 屏蔽自定义渠道
*/
private String noiseChannel;
/**
* 行政级别 * 行政级别
*/ */
private List<String> politicsLevels; private List<String> politicsLevels;
......
...@@ -81,4 +81,12 @@ public interface IndexService { ...@@ -81,4 +81,12 @@ public interface IndexService {
*/ */
JSONObject getMobileWholeCriteria(Long startTime, Long endTime); JSONObject getMobileWholeCriteria(Long startTime, Long endTime);
/**
* 获取主品牌净情感度
* @param startTime 开始时间
* @param endTime 结束时间
* @param cache 是否优先读取缓存
* @return
*/
JSONObject getEmotionPercent(Long startTime, Long endTime, boolean cache);
} }
...@@ -5,11 +5,7 @@ import com.zhiwei.brandkbs2.model.ResponseResult; ...@@ -5,11 +5,7 @@ import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.BaseMap; import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.MarkFlowEntity; import com.zhiwei.brandkbs2.pojo.MarkFlowEntity;
import com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO; import com.zhiwei.brandkbs2.pojo.dto.*;
import com.zhiwei.brandkbs2.pojo.dto.ExportSearchWholeDTO;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO;
import com.zhiwei.brandkbs2.pojo.dto.NonManualProjectPlanDTO;
import com.zhiwei.brandkbs2.pojo.vo.LineVO; import com.zhiwei.brandkbs2.pojo.vo.LineVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO; import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
...@@ -545,95 +541,88 @@ public interface MarkDataService { ...@@ -545,95 +541,88 @@ public interface MarkDataService {
/** /**
* 新-舆情分析-舆情总量 * 新-舆情分析-舆情总量
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
* @throws IOException * @throws IOException
*/ */
JSONObject getYuqingAmount(Long startTime, Long endTime, String planId); JSONObject getYuqingAmount(MarkSearchDTO dto);
/** /**
* 新-舆情分析-情感分布 * 新-舆情分析-情感分布
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
* @throws IOException * @throws IOException
*/ */
JSONObject getYuqingEmotionDistribution(Long startTime, Long endTime, String planId); JSONObject getYuqingEmotionDistribution(MarkSearchDTO dto);
/** /**
* 新-舆情分析-重点平台 * 新-舆情分析-重点平台
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
*/ */
JSONObject getImportantPlatformPercentage(Long startTime, Long endTime, String planId); JSONObject getImportantPlatformPercentage(MarkSearchDTO dto);
/** /**
* 新-舆情分析-平台占比 * 新-舆情分析-平台占比
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
*/ */
List<JSONObject> getPlatformPercentage(Long startTime, Long endTime, String planId); List<JSONObject> geAnalyzePlatformPercentage(MarkSearchDTO dto);
/** /**
* 新-舆情分析-舆情走势图 * 新-舆情分析-舆情走势图
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
*/ */
JSONObject getSpreadTendency(Long startTime, Long endTime, String planId); JSONObject getSpreadTendency(MarkSearchDTO dto);
/** /**
* 新-舆情分析-活跃渠道 * 新-舆情分析-活跃渠道
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
*/ */
List<JSONObject> getActiveChannels(Long startTime, Long endTime, String planId); List<JSONObject> getActiveChannels(MarkSearchDTO dto);
/** /**
* 新-舆情分析-ip分布 * 新-舆情分析-ip分布
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
*/ */
List<JSONObject> getArticleIpLocated(Long startTime, Long endTime, String planId, int size); List<JSONObject> getArticleIpLocated(MarkSearchDTO dto);
/** /**
* 新-舆情分析-活跃渠道、ip分布、词云详情页面 * 新-舆情分析-活跃渠道、ip分布、词云详情页面
* @param dto * @param dto 标注数据搜索传输类
* @return * @return
*/ */
PageVO<MarkFlowEntity> getYuqingAnalyzeDetail(MarkSearchDTO dto); PageVO<MarkFlowEntity> getYuqingAnalyzeDetail(MarkSearchDTO dto);
void cacheHighWord(Long startTime, Long endTime, String planId, boolean cache);
/** /**
* 新-舆情分析-词云 * 新-舆情分析-词云
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @return * @return
*/ */
List<JSONObject> getHighWord(Long startTime, Long endTime, String planId, boolean cache); List<JSONObject> getAnalyzeHighWord(MarkSearchDTO dto, boolean cache);
/**
* 查舆情-数据分析-生成词云
* @param dto
* @return
*/
List<JSONObject> getSearchAnalyzeHighWord(MarkSearchDTO dto);
/** /**
* 新-舆情分析-高频标题 * 新-舆情分析-高频标题
* @param startTime * @param startTime
* @param endTime * @param endTime
* @param planId
* @param size * @param size
* @param include
* @return * @return
*/ */
List<JSONObject> getLastNews(Long startTime, Long endTime, String planId, int size, boolean include); List<JSONObject> getLastNews(Long startTime, Long endTime, int size);
List<JSONObject> getLastNews(MarkSearchDTO dto, int size);
/** /**
* 舆情分析-高频标题详情页-基础信息 * 舆情分析-高频标题详情页-基础信息
...@@ -645,6 +634,8 @@ public interface MarkDataService { ...@@ -645,6 +634,8 @@ public interface MarkDataService {
*/ */
JSONObject getAggTitleBaseInfo(String aggTitle, Long startTime, Long endTime, String planId); JSONObject getAggTitleBaseInfo(String aggTitle, Long startTime, Long endTime, String planId);
JSONObject getAggTitleBaseInfo(MarkSearchDTO dto);
/** /**
* 舆情分析-高频标题详情页-发布节点 * 舆情分析-高频标题详情页-发布节点
* @param aggTitle * @param aggTitle
...@@ -655,6 +646,8 @@ public interface MarkDataService { ...@@ -655,6 +646,8 @@ public interface MarkDataService {
*/ */
List<JSONObject> getAggTitleArticlePoints(String aggTitle, Long startTime, Long endTime, String planId); List<JSONObject> getAggTitleArticlePoints(String aggTitle, Long startTime, Long endTime, String planId);
List<JSONObject> getAggTitleArticlePoints(MarkSearchDTO dto);
/** /**
* 舆情分析-高频标题详情页-平台分布 * 舆情分析-高频标题详情页-平台分布
* @param aggTitle * @param aggTitle
...@@ -665,6 +658,8 @@ public interface MarkDataService { ...@@ -665,6 +658,8 @@ public interface MarkDataService {
*/ */
List<JSONObject> getAggTitlePlatformPercentage(String aggTitle, Long startTime, Long endTime, String planId); List<JSONObject> getAggTitlePlatformPercentage(String aggTitle, Long startTime, Long endTime, String planId);
List<JSONObject> getAggTitlePlatformPercentage(MarkSearchDTO dto);
/** /**
* 舆情分析-高频标题详情页-发文列表 * 舆情分析-高频标题详情页-发文列表
* @param aggTitle * @param aggTitle
...@@ -676,4 +671,6 @@ public interface MarkDataService { ...@@ -676,4 +671,6 @@ public interface MarkDataService {
* @return * @return
*/ */
PageVO<JSONObject> getArticleList(String aggTitle, Long startTime, Long endTime, String planId, String platform, int page, int pageSize); PageVO<JSONObject> getArticleList(String aggTitle, Long startTime, Long endTime, String planId, String platform, int page, int pageSize);
PageVO<JSONObject> getArticleList(MarkSearchDTO dto);
} }
...@@ -23,14 +23,6 @@ public interface ProjectWarnService { ...@@ -23,14 +23,6 @@ public interface ProjectWarnService {
ResponseResult getProjectWarnCriteriaDefault(String projectId, String type); ResponseResult getProjectWarnCriteriaDefault(String projectId, String type);
/** /**
* 获取舆情动态预警
* @param projectId
* @param brandkbsYuQingConfig
* @return
*/
ResponseResult getYuqingWaring(String projectId, BrandkbsYuQingConfig brandkbsYuQingConfig);
/**
* 获取舆情动态预警-新 * 获取舆情动态预警-新
* @param projectId * @param projectId
* @param brandkbsYuQingConfigNew * @param brandkbsYuQingConfigNew
......
package com.zhiwei.brandkbs2.service; package com.zhiwei.brandkbs2.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.BytedanceCustomChannelInfluence;
import com.zhiwei.brandkbs2.pojo.ChannelTag; import com.zhiwei.brandkbs2.pojo.ChannelTag;
import com.zhiwei.brandkbs2.pojo.Project; import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.SensitiveChannel; import com.zhiwei.brandkbs2.pojo.SensitiveChannel;
...@@ -70,4 +71,10 @@ public interface SystemInfoService { ...@@ -70,4 +71,10 @@ public interface SystemInfoService {
* @return * @return
*/ */
Map<String, SensitiveChannel> getCommonSensitiveChannel(); Map<String, SensitiveChannel> getCommonSensitiveChannel();
/**
* 获取字节定制指定渠道影响力信息
* @return
*/
Map<String, BytedanceCustomChannelInfluence> getByteDanceChannelInfluence();
} }
...@@ -994,69 +994,70 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -994,69 +994,70 @@ public class ChannelServiceImpl implements ChannelService {
@Override @Override
public Channel calculateChannelEmotionIndex(Channel channel) { public Channel calculateChannelEmotionIndex(Channel channel) {
try { // 渠道倾向及渠道影响力指数计算关闭
Project project = projectService.getProjectById(channel.getProjectId()); // try {
// 数据格式变化未含有contendId部分 // Project project = projectService.getProjectById(channel.getProjectId());
if (null == channel.getContendId()) { // // 数据格式变化未含有contendId部分
channel.setContendId("0"); // if (null == channel.getContendId()) {
} // channel.setContendId("0");
// 不做统计 // }
if (!hasEmotion(channel)) { // // 不做统计
return channel; // if (!hasEmotion(channel)) {
} // return channel;
// 该渠道发布正面稿件 // }
Long positiveCount = markCountByEmotion(channel, EmotionEnum.POSITIVE.getName()); // // 该渠道发布正面稿件
// 该渠道发布中性稿件 // Long positiveCount = markCountByEmotion(channel, EmotionEnum.POSITIVE.getName());
Long neutralCount = markCountByEmotion(channel, EmotionEnum.NEUTRAL.getName()); // // 该渠道发布中性稿件
// 该渠道发布负面稿件 // Long neutralCount = markCountByEmotion(channel, EmotionEnum.NEUTRAL.getName());
Long negativeCount = markCountByEmotion(channel, EmotionEnum.NEGATIVE.getName()); // // 该渠道发布负面稿件
// 是否友好渠道 // Long negativeCount = markCountByEmotion(channel, EmotionEnum.NEGATIVE.getName());
boolean isPositive = false; // // 是否友好渠道
boolean isNegative = false; // boolean isPositive = false;
long specNegativeCount = eventMiddlewareDao.getEventCount(new ChannelIndex(channel).getFid(), // boolean isNegative = false;
Arrays.asList(EmotionEnum.POSITIVE.getName(), EmotionEnum.NEUTRAL.getName()), // long specNegativeCount = eventMiddlewareDao.getEventCount(new ChannelIndex(channel).getFid(),
EmotionEnum.NEGATIVE.getName()); // Arrays.asList(EmotionEnum.POSITIVE.getName(), EmotionEnum.NEUTRAL.getName()),
long specPositiveCount = eventMiddlewareDao.getEventCount(new ChannelIndex(channel).getFid(), // EmotionEnum.NEGATIVE.getName());
Collections.singletonList(EmotionEnum.NEGATIVE.getName()), EmotionEnum.POSITIVE.getName()); // long specPositiveCount = eventMiddlewareDao.getEventCount(new ChannelIndex(channel).getFid(),
// 特殊情况:若皆有发布过反常稿件 // Collections.singletonList(EmotionEnum.NEGATIVE.getName()), EmotionEnum.POSITIVE.getName());
if (specNegativeCount > 0 && specPositiveCount > 0) { // // 特殊情况:若皆有发布过反常稿件
// 正面稿件数>负面稿件数,为正面 // if (specNegativeCount > 0 && specPositiveCount > 0) {
if (positiveCount > negativeCount) { // // 正面稿件数>负面稿件数,为正面
isPositive = true; // if (positiveCount > negativeCount) {
// 正面稿件数<负面稿件数,为负面 // isPositive = true;
} else if (positiveCount < negativeCount) { // // 正面稿件数<负面稿件数,为负面
isNegative = true; // } else if (positiveCount < negativeCount) {
} // isNegative = true;
} else { // }
// 在正/中性事件中发布负面稿件||负面报道数>正面报道数(满足任一条件) // } else {
if (negativeCount > positiveCount) { // // 在正/中性事件中发布负面稿件||负面报道数>正面报道数(满足任一条件)
isNegative = true; // if (negativeCount > positiveCount) {
// 如果有在正面事件中发布负面稿件 // isNegative = true;
} else if (specNegativeCount > 0) { // // 如果有在正面事件中发布负面稿件
// 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64 // } else if (specNegativeCount > 0) {
if (positiveCount > negativeCount && positiveCount >= neutralCount // // 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64
&& (this.inEventCountMonthAverage(channel, EmotionEnum.POSITIVE.getName()) >= 4.64)) { // if (positiveCount > negativeCount && positiveCount >= neutralCount
isPositive = true; // && (this.inEventCountMonthAverage(channel, EmotionEnum.POSITIVE.getName()) >= 4.64)) {
} else { // isPositive = true;
isNegative = true; // } else {
} // isNegative = true;
} else { // }
// 在负面事件中发布过正面稿件即满足 // } else {
if (specPositiveCount > 0) { // // 在负面事件中发布过正面稿件即满足
isPositive = true; // if (specPositiveCount > 0) {
// 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64 // isPositive = true;
} else if (positiveCount > negativeCount && positiveCount >= neutralCount // // 或满足三者复合条件:发布正面稿件>负面稿件&&正面稿件>=中性稿件&&月均参与正面事件数≥4.64
&& (this.inEventCountMonthAverage(channel, EmotionEnum.POSITIVE.getName()) >= 4.64)) { // } else if (positiveCount > negativeCount && positiveCount >= neutralCount
isPositive = true; // && (this.inEventCountMonthAverage(channel, EmotionEnum.POSITIVE.getName()) >= 4.64)) {
} // isPositive = true;
} // }
} // }
// 更新渠道指数,渠道等级,情感倾向并记录变化 // }
this.updateChannel(channel, project, positiveCount, neutralCount, negativeCount, isPositive, isNegative, // // 更新渠道指数,渠道等级,情感倾向并记录变化
specPositiveCount, specNegativeCount); // this.updateChannel(channel, project, positiveCount, neutralCount, negativeCount, isPositive, isNegative,
} catch (Exception e) { // specPositiveCount, specNegativeCount);
log.error("calculateChannelEmotionIndex-", e); // } catch (Exception e) {
} // log.error("calculateChannelEmotionIndex-", e);
// }
return channel; return channel;
} }
......
...@@ -903,7 +903,7 @@ public class EventServiceImpl implements EventService { ...@@ -903,7 +903,7 @@ public class EventServiceImpl implements EventService {
if (cache && StringUtils.isNotEmpty(resultStr)) { if (cache && StringUtils.isNotEmpty(resultStr)) {
return JSON.parseArray(resultStr, JSONObject.class); return JSON.parseArray(resultStr, JSONObject.class);
} }
List<JSONObject> resultList = markDataService.getLastNews(startTime, endTime, null, 50, true); List<JSONObject> resultList = markDataService.getLastNews(startTime, endTime, 50);
redisUtil.setExpire(redisKey, JSON.toJSONString(resultList)); redisUtil.setExpire(redisKey, JSON.toJSONString(resultList));
return resultList; return resultList;
} }
......
...@@ -334,6 +334,58 @@ public class IndexServiceImpl implements IndexService { ...@@ -334,6 +334,58 @@ public class IndexServiceImpl implements IndexService {
return result; return result;
} }
@Override
public JSONObject getEmotionPercent(Long startTime, Long endTime, boolean cache) {
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
Long[] timeRangeMonth = commonService.getTimeRangeMonth();
startTime = timeRangeMonth[0];
endTime = timeRangeMonth[1];
}
String projectId = UserThreadLocal.getProjectId();
String redisKey = RedisUtil.getIndexEmotionKey(projectId, startTime, endTime);
String resultStr;
// 返回缓存
if (cache && StringUtils.isNotEmpty(resultStr = redisUtil.get(redisKey))) {
return JSON.parseObject(resultStr);
}
JSONObject jsonObject = new JSONObject();
try {
// 关于NSR计算:NSR净情感度=(正面-负面)/(正面+负面)*100%
// 项目总正面稿件数
long totalPositiveCount = markDataService.getYuqingMarkCount(null, null, EmotionEnum.POSITIVE.getName(), projectId, Constant.PRIMARY_CONTEND_ID);
// 项目总负面稿件数
long totalNegativeCount = markDataService.getYuqingMarkCount(null, null, EmotionEnum.NEGATIVE.getName(), projectId, Constant.PRIMARY_CONTEND_ID);
// 项目均值NSR
double avg = 0 == totalPositiveCount + totalNegativeCount ? 0 :(totalPositiveCount - totalNegativeCount) / (double) (totalPositiveCount + totalNegativeCount);
jsonObject.put("avgNSR", avg);
// 正面稿件数
long positiveCount = markDataService.getYuqingMarkCount(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, Constant.PRIMARY_CONTEND_ID);
jsonObject.put("positiveCount", positiveCount);
// 负面稿件数
long negativeCount = markDataService.getYuqingMarkCount(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, Constant.PRIMARY_CONTEND_ID);
jsonObject.put("negativeCount", negativeCount);
// 本次NSR
double NSR = 0 == positiveCount + negativeCount ? 0 :(positiveCount - negativeCount) / (double) (positiveCount + negativeCount);
jsonObject.put("NSR", NSR);
// 上一周期开始时间
long previousStartTime = startTime - (endTime - startTime);
// 上一周期正面稿件数
long previousPositiveCount = markDataService.getYuqingMarkCount(previousStartTime, startTime, EmotionEnum.POSITIVE.getName(), projectId, Constant.PRIMARY_CONTEND_ID);
// 上一周期负面稿件数
long previousNegativeCount = markDataService.getYuqingMarkCount(previousStartTime, startTime, EmotionEnum.NEGATIVE.getName(), projectId, Constant.PRIMARY_CONTEND_ID);
// 上一周期NSR
double previousNSR = 0 == previousPositiveCount + previousNegativeCount ? 0 :(previousPositiveCount - previousNegativeCount) / (double) (previousPositiveCount + previousNegativeCount);
// 环比
jsonObject.put("compare", NSR - previousNSR);
redisUtil.setExpire(redisKey, JSON.toJSONString(jsonObject));
} catch (Exception e) {
ExceptionCast.cast(CommonCodeEnum.FAIL, "getEmotionPercent异常", e);
}
return jsonObject;
}
public List<JSONObject> getPlatformProportionWithPlatform(Long startTime, Long endTime, String emotion, String projectId, String contendId, long normalCount) { public List<JSONObject> getPlatformProportionWithPlatform(Long startTime, Long endTime, String emotion, String projectId, String contendId, long normalCount) {
List<String> platformIds = GlobalPojo.PLATFORMS.stream().map(MessagePlatform::getId).collect(Collectors.toList()); List<String> platformIds = GlobalPojo.PLATFORMS.stream().map(MessagePlatform::getId).collect(Collectors.toList());
List<JSONObject> resultList = new ArrayList<>(platformIds.size()); List<JSONObject> resultList = new ArrayList<>(platformIds.size());
......
...@@ -13,10 +13,7 @@ import com.zhiwei.brandkbs2.common.GenericAttribute; ...@@ -13,10 +13,7 @@ import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.common.GlobalPojo; import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.common.RedisKeyPrefix; import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import com.zhiwei.brandkbs2.config.Constant; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.dao.AggreeResultDao; import com.zhiwei.brandkbs2.dao.*;
import com.zhiwei.brandkbs2.dao.ChannelDao;
import com.zhiwei.brandkbs2.dao.HighlightWordDao;
import com.zhiwei.brandkbs2.dao.NonManualProjectPlanDao;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil; import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportYuqingInteractionUpdateDTO; import com.zhiwei.brandkbs2.easyexcel.dto.ExportYuqingInteractionUpdateDTO;
import com.zhiwei.brandkbs2.enmus.ChannelEmotion; import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
...@@ -73,6 +70,7 @@ import org.joda.time.PeriodType; ...@@ -73,6 +70,7 @@ import org.joda.time.PeriodType;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -173,6 +171,9 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -173,6 +171,9 @@ public class MarkDataServiceImpl implements MarkDataService {
@Resource(name = "nonManualProjectPlanDao") @Resource(name = "nonManualProjectPlanDao")
NonManualProjectPlanDao nonManualProjectPlanDao; NonManualProjectPlanDao nonManualProjectPlanDao;
@Resource(name = "markSearchAnalyzeTaskDao")
MarkSearchAnalyzeTaskDao markSearchAnalyzeTaskDao;
@Resource(name = "toolsetServiceImpl") @Resource(name = "toolsetServiceImpl")
private ToolsetService toolsetService; private ToolsetService toolsetService;
...@@ -828,7 +829,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -828,7 +829,7 @@ public class MarkDataServiceImpl implements MarkDataService {
public List<Map.Entry<String, Integer>> getMarkTopTitle(Long startTime, Long endTime, String emotion, String projectId, String contendId, int size, boolean include) throws IOException { public List<Map.Entry<String, Integer>> getMarkTopTitle(Long startTime, Long endTime, String emotion, String projectId, String contendId, int size, boolean include) throws IOException {
// 索引 // 索引
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("titles").field("agg_title.keyword").size(size + 1); TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("titles").field("agg_title.keyword").size(size + Tools.FILTER_TITLE.size());
// query // query
BoolQueryBuilder query; BoolQueryBuilder query;
if (include) { if (include) {
...@@ -848,8 +849,8 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -848,8 +849,8 @@ public class MarkDataServiceImpl implements MarkDataService {
ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("titles"); ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("titles");
for (Terms.Bucket bucket : teamAgg.getBuckets()) { for (Terms.Bucket bucket : teamAgg.getBuckets()) {
String title = bucket.getKeyAsString(); String title = bucket.getKeyAsString();
// 过滤 “分享一篇文章” 的标题 // 过滤 “分享一篇文章”,”暂无标题“,”Notitle“ 的标题
if ("分享一篇文章".equals(title)) { if (Tools.filterUselessTitle(title)) {
continue; continue;
} }
int num = (int) bucket.getDocCount(); int num = (int) bucket.getDocCount();
...@@ -858,31 +859,22 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -858,31 +859,22 @@ public class MarkDataServiceImpl implements MarkDataService {
return result.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).limit(size).collect(Collectors.toList()); return result.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).limit(size).collect(Collectors.toList());
} }
private List<JSONObject> getMarkTopTitle(Long startTime, Long endTime, String emotion, String projectId, String contendId, String planId, int size) throws IOException { private List<JSONObject> getMarkTopTitle(MarkSearchDTO dto, int size) throws IOException {
// 索引 // 索引
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("titles").field("agg_title.keyword").size(size + 1); TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("titles").field("agg_title.keyword").size(size + Tools.FILTER_TITLE.size());
TermsAggregationBuilder sourceAggregationBuilder = AggregationBuilders.terms("source").field("source").size(10000); TermsAggregationBuilder sourceAggregationBuilder = AggregationBuilders.terms("source").field("source").size(10000);
// query // query
BoolQueryBuilder query; BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
if (Objects.isNull(planId)) {
query = projectContendIdQuery(projectId, contendId);
}else {
query = EsQueryTools.assembleCacheMapsPlanQuery(projectId, planId);
}
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime))
// 过滤微博 // 过滤微博
.mustNot(QueryBuilders.termQuery("platform_id", "5d02236e6395002a7c380b79")); query.mustNot(QueryBuilders.termQuery("platform_id", "5d02236e6395002a7c380b79"));
if (null != emotion && !Objects.equals(emotion, EmotionEnum.ALL.getName())) {
query.must(QueryBuilders.termQuery("brandkbs_mark_cache_maps.name.keyword", emotion));
}
SearchResponse searchResponse; SearchResponse searchResponse;
// 单独处理buckets超过上限异常,出错时按时间分段查询 // 单独处理buckets超过上限异常,出错时按时间分段查询
try { try {
searchResponse = esClientDao.searchResponse(indexes, null, query, searchResponse = esClientDao.searchResponse(indexes, null, query,
aggregationBuilder.subAggregation(sourceAggregationBuilder), null, null, 0, 0, null); aggregationBuilder.subAggregation(sourceAggregationBuilder), null, null, 0, 0, null);
}catch (ElasticsearchStatusException e){ }catch (ElasticsearchStatusException e){
return getMarkTopTitleDivided(query, indexes, aggregationBuilder, startTime, endTime, size); return getMarkTopTitleDivided(query, indexes, aggregationBuilder, dto.getStartTime(), dto.getEndTime(), size);
} }
List<JSONObject> res = new ArrayList<>(); List<JSONObject> res = new ArrayList<>();
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap(); Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
...@@ -890,8 +882,8 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -890,8 +882,8 @@ public class MarkDataServiceImpl implements MarkDataService {
for (Terms.Bucket bucket : teamAgg.getBuckets()) { for (Terms.Bucket bucket : teamAgg.getBuckets()) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
String title = bucket.getKeyAsString(); String title = bucket.getKeyAsString();
// 过滤 “分享一篇文章” 的标题 // 过滤 “分享一篇文章”,”暂无标题“,”Notitle“ 的标题
if ("分享一篇文章".equals(title)) { if (Tools.filterUselessTitle(title)) {
continue; continue;
} }
jsonObject.put("title", title); jsonObject.put("title", title);
...@@ -976,10 +968,6 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -976,10 +968,6 @@ public class MarkDataServiceImpl implements MarkDataService {
return getArticleSort(startTime, endTime, aggTitle, projectId, contendId, planId, include, "{\"time\" : \"asc\"}"); return getArticleSort(startTime, endTime, aggTitle, projectId, contendId, planId, include, "{\"time\" : \"asc\"}");
} }
private BaseMap getLastArticle(Long startTime, Long endTime, String aggTitle, String projectId, String contendId, String planId, boolean include) throws IOException {
return getArticleSort(startTime, endTime, aggTitle, projectId, contendId, planId, include, "{\"time\" : \"desc\"}");
}
private BaseMap getArticleSort(Long startTime, Long endTime, String aggTitle, String projectId, String contendId, String planId, boolean include, String sorter) throws IOException { private BaseMap getArticleSort(Long startTime, Long endTime, String aggTitle, String projectId, String contendId, String planId, boolean include, String sorter) throws IOException {
// 索引 // 索引
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
...@@ -1014,6 +1002,36 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -1014,6 +1002,36 @@ public class MarkDataServiceImpl implements MarkDataService {
return Tools.getBaseFromEsMap(hits.getAt(0).getSourceAsMap()); return Tools.getBaseFromEsMap(hits.getAt(0).getSourceAsMap());
} }
private BaseMap getAnalyzeFirstArticle(MarkSearchDTO dto) throws IOException{
return getArticleSort(dto, "{\"time\" : \"asc\"}");
}
private BaseMap getAnalyzeLastArticle(MarkSearchDTO dto) throws IOException {
return getArticleSort(dto, "{\"time\" : \"desc\"}");
}
private BaseMap getArticleSort(MarkSearchDTO dto, String sorter) throws IOException {
// 索引
String[] indexes = esClientDao.getIndexes();
BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
//sort
FieldSortBuilder sort = new FieldSortBuilder("time").order(SortOrder.ASC);
JSONObject sortJson = JSONObject.parseObject(sorter);
for (Map.Entry<String, Object> entry : sortJson.entrySet()) {
if (entry.getValue().toString().contains("desc")) {
sort = SortBuilders.fieldSort(entry.getKey()).order(SortOrder.DESC);
} else {
sort = SortBuilders.fieldSort(entry.getKey()).order(SortOrder.ASC);
}
}
//hits
SearchHits hits = esClientDao.searchHits(indexes, query, null, null, sort, 0, 1, null);
if (0 == hits.getTotalHits().value) {
return new BaseMap();
}
return Tools.getBaseFromEsMap(hits.getAt(0).getSourceAsMap());
}
@Override @Override
public List<JSONObject> searchMarkDataByEvent(Event event) { public List<JSONObject> searchMarkDataByEvent(Event event) {
Long endTime = null; Long endTime = null;
...@@ -1720,7 +1738,9 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -1720,7 +1738,9 @@ public class MarkDataServiceImpl implements MarkDataService {
result.put("source", channel.getSource()); result.put("source", channel.getSource());
result.put("platform", channel.getPlatform()); result.put("platform", channel.getPlatform());
result.put("num", bucket.getDocCount()); result.put("num", bucket.getDocCount());
channelResultList.add(result); if (!Tools.filterUselessSource(channel.getSource())){
channelResultList.add(result);
}
} }
} }
}); });
...@@ -2410,19 +2430,21 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2410,19 +2430,21 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
@Override @Override
public JSONObject getYuqingAmount(Long startTime, Long endTime, String planId) { public JSONObject getYuqingAmount(MarkSearchDTO dto) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
try { try {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
String planId = dto.getPlanId();
dto.setProjectId(projectId);
// 舆情总量 // 舆情总量
long total = getYuqingAnalyzeCount(startTime, endTime, planId, EmotionEnum.ALL.getName()); long total = getYuqingAnalyzeCount(dto);
jsonObject.put("total", total); jsonObject.put("total", total);
// 项目日均 // 项目日均
String projectYuqingCountAvgKey = RedisUtil.getYuqingAnalyzeProjectAvgCountKey(projectId, Constant.PRIMARY_CONTEND_ID, planId); String projectYuqingCountAvgKey = RedisUtil.getYuqingAnalyzeProjectAvgCountKey(projectId, Constant.PRIMARY_CONTEND_ID, planId);
double projectYuqingAvgCount = Objects.isNull(redisUtil.get(projectYuqingCountAvgKey)) ? 0d : Double.parseDouble(redisUtil.get(projectYuqingCountAvgKey)); double projectYuqingAvgCount = Objects.isNull(redisUtil.get(projectYuqingCountAvgKey)) ? 0d : Double.parseDouble(redisUtil.get(projectYuqingCountAvgKey));
jsonObject.put("projectAvg", projectYuqingAvgCount); jsonObject.put("projectAvg", projectYuqingAvgCount);
// 本次日均 // 本次日均
int days = new Period(startTime, endTime, PeriodType.days()).getDays(); int days = new Period(dto.getStartTime(), dto.getEndTime(), PeriodType.days()).getDays();
days = 0 == days ? 1 : days; days = 0 == days ? 1 : days;
double yuqingAvgCount = total == 0 ? 0d : total / (double) days; double yuqingAvgCount = total == 0 ? 0d : total / (double) days;
jsonObject.put("compare", compare(yuqingAvgCount, projectYuqingAvgCount)); jsonObject.put("compare", compare(yuqingAvgCount, projectYuqingAvgCount));
...@@ -2433,18 +2455,20 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2433,18 +2455,20 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
@Override @Override
public JSONObject getYuqingEmotionDistribution(Long startTime, Long endTime, String planId) { public JSONObject getYuqingEmotionDistribution(MarkSearchDTO dto) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
try { try {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
String planId = dto.getPlanId();
dto.setProjectId(projectId);
// 舆情总量 // 舆情总量
long total = getYuqingAnalyzeCount(startTime, endTime, planId, EmotionEnum.ALL.getName()); long total = getYuqingAnalyzeCount(dto);
// 正面舆情 // 正面舆情
long positiveCount = getYuqingAnalyzeCount(startTime, endTime, planId, EmotionEnum.POSITIVE.getName()); long positiveCount = getYuqingAnalyzeCount(dto, EmotionEnum.POSITIVE.getName());
// 中性舆情 // 中性舆情
long neutralCount = getYuqingAnalyzeCount(startTime, endTime, planId, EmotionEnum.NEUTRAL.getName()); long neutralCount = getYuqingAnalyzeCount(dto, EmotionEnum.NEUTRAL.getName());
// 负面舆情 // 负面舆情
long negativeCount = getYuqingAnalyzeCount(startTime, endTime, planId, EmotionEnum.NEGATIVE.getName()); long negativeCount = getYuqingAnalyzeCount(dto, EmotionEnum.NEGATIVE.getName());
// 各情感倾向占比 // 各情感倾向占比
double positivePercentage = total == 0 ? 0d : positiveCount / (double) total; double positivePercentage = total == 0 ? 0d : positiveCount / (double) total;
double neutralPercentage = total == 0 ? 0d : neutralCount / (double) total; double neutralPercentage = total == 0 ? 0d : neutralCount / (double) total;
...@@ -2478,15 +2502,20 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2478,15 +2502,20 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
@Override @Override
public JSONObject getImportantPlatformPercentage(Long startTime, Long endTime, String planId) { public JSONObject getImportantPlatformPercentage(MarkSearchDTO dto) {
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
try { try {
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
List<String> importantPlatforms = Arrays.asList("微博", "微信", "抖音", "小红书", "今日头条", "网媒"); List<String> importantPlatforms = new ArrayList<>();
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
Long total = getYuqingAnalyzeCount(startTime, endTime, planId, importantPlatforms); dto.setProjectId(projectId);
for (String platformNames : Arrays.asList("微博", "微信", "抖音", "小红书", "今日头条", "网媒")) {
importantPlatforms.add(GlobalPojo.getPlatformIdByName(platformNames));
}
dto.setPlatforms(importantPlatforms);
Long total = getYuqingAnalyzeCount(dto);
// 平台聚合 // 平台聚合
SearchResponse searchResponse = platformAggSearchResponse(startTime, endTime, planId, importantPlatforms, null); SearchResponse searchResponse = platformAggSearchResponse(dto);
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap(); Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("platform_count"); ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("platform_count");
List<? extends Terms.Bucket> buckets = teamAgg.getBuckets(); List<? extends Terms.Bucket> buckets = teamAgg.getBuckets();
...@@ -2501,12 +2530,12 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2501,12 +2530,12 @@ public class MarkDataServiceImpl implements MarkDataService {
// 总量 // 总量
overview.put("total", total); overview.put("total", total);
// 日均 // 日均
int days = new Period(startTime, endTime, PeriodType.days()).getDays(); int days = new Period(dto.getStartTime(), dto.getEndTime(), PeriodType.days()).getDays();
days = 0 == days ? 1 : days; days = 0 == days ? 1 : days;
double avg = total == 0 ? 0d : total / (double) days; double avg = total == 0 ? 0d : total / (double) days;
overview.put("avg", avg); overview.put("avg", avg);
// 项目均值 // 项目均值
String key = RedisUtil.getYuqingAnalyzePlatformAvgCountKey(projectId, Constant.PRIMARY_CONTEND_ID, planId); String key = RedisUtil.getYuqingAnalyzePlatformAvgCountKey(projectId, Constant.PRIMARY_CONTEND_ID, dto.getPlanId());
double projectAvg = Objects.isNull(redisUtil.get(key)) ? 0d : Double.parseDouble(redisUtil.get(key)); double projectAvg = Objects.isNull(redisUtil.get(key)) ? 0d : Double.parseDouble(redisUtil.get(key));
overview.put("compare", compare(avg, projectAvg)); overview.put("compare", compare(avg, projectAvg));
res.put("overview", overview); res.put("overview", overview);
...@@ -2532,9 +2561,9 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2532,9 +2561,9 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
@Override @Override
public List<JSONObject> getPlatformPercentage(Long startTime, Long endTime, String planId) { public List<JSONObject> geAnalyzePlatformPercentage(MarkSearchDTO dto) {
try { try {
return getPlatformPercentage(null, startTime, endTime, planId); return getPlatformPercentage(dto);
}catch (Exception e){ }catch (Exception e){
ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getPlatformPercentage异常-", e); ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getPlatformPercentage异常-", e);
} }
...@@ -2543,22 +2572,19 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2543,22 +2572,19 @@ public class MarkDataServiceImpl implements MarkDataService {
/** /**
* 获取舆情分析平台分布 * 获取舆情分析平台分布
* @param aggTitle * @param dto 标注数据搜索传输类
* @param startTime
* @param endTime
* @param planId
* @return * @return
* @throws IOException * @throws IOException
*/ */
private List<JSONObject> getPlatformPercentage(String aggTitle, Long startTime, Long endTime, String planId) throws IOException { private List<JSONObject> getPlatformPercentage(MarkSearchDTO dto) throws IOException {
List<String> platforms = commonService.getQbjcPlatformNames(); List<String> platforms = commonService.getQbjcPlatform().stream().map(jsonObject -> jsonObject.getString("id")).collect(Collectors.toList());
dto.setPlatforms(platforms);
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
// query
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, null, planId, null, null, aggTitle);
// total // total
Long total = esClientDao.count(query); dto.setProjectId(UserThreadLocal.getProjectId());
Long total = getYuqingAnalyzeCount(dto);
// 平台聚合 // 平台聚合
SearchResponse searchResponse = platformAggSearchResponse(startTime, endTime, planId, platforms, aggTitle); SearchResponse searchResponse = platformAggSearchResponse(dto);
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap(); Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("platform_count"); ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("platform_count");
List<? extends Terms.Bucket> buckets = teamAgg.getBuckets(); List<? extends Terms.Bucket> buckets = teamAgg.getBuckets();
...@@ -2582,67 +2608,66 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2582,67 +2608,66 @@ public class MarkDataServiceImpl implements MarkDataService {
/** /**
* 平台聚合查询 * 平台聚合查询
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @param platforms
* @return * @return
* @throws IOException * @throws IOException
*/ */
private SearchResponse platformAggSearchResponse(Long startTime, Long endTime, String planId, List<String> platforms, String aggTitle) throws IOException { private SearchResponse platformAggSearchResponse(MarkSearchDTO dto) throws IOException {
// 索引 // 索引
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
// 聚合请求 // 聚合请求
TermsAggregationBuilder platformAggregationBuilder = AggregationBuilders.terms("platform_count").field("platform_id").order(BucketOrder.count(false)); TermsAggregationBuilder platformAggregationBuilder = AggregationBuilders.terms("platform_count").field("platform_id").order(BucketOrder.count(false));
// query // query
BoolQueryBuilder query; BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
if (Objects.isNull(aggTitle)){
query = yuqingAnalyzeQuery(startTime, endTime, planId, null, platforms);
}else {
query = yuqingAnalyzeQuery(startTime, endTime, null, planId, null, null, aggTitle);
}
return esClientDao.searchResponse(indexes, null, query, platformAggregationBuilder, null, null, 0, 0, null); return esClientDao.searchResponse(indexes, null, query, platformAggregationBuilder, null, null, 0, 0, null);
} }
@Override @Override
public JSONObject getSpreadTendency(Long startTime, Long endTime, String planId) { public JSONObject getSpreadTendency(MarkSearchDTO dto) {
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
try { try {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
Long endTime = dto.getEndTime();
String planId = dto.getPlanId();
dto.setProjectId(projectId);
// 各平台趋势图 // 各平台趋势图
Map<String, List<LineVO>> platformSpreadTendency = getPlatformSpreadTendency(startTime, endTime, planId); Map<String, List<LineVO>> platformSpreadTendency = getPlatformSpreadTendency(dto);
// 总趋势图 // 总趋势图
Pair<String, List<LineVO>> spreadTendency = getSpreadTendency(startTime, endTime, planId, null); Pair<String, List<LineVO>> spreadTendency = getEmotionSpreadTendency(dto, null);
// 负面趋势图 // 负面趋势图
Pair<String, List<LineVO>> negativeSpreadTendency = getSpreadTendency(startTime, endTime, planId, EmotionEnum.NEGATIVE.getName()); Pair<String, List<LineVO>> negativeSpreadTendency = getEmotionSpreadTendency(dto, EmotionEnum.NEGATIVE.getName());
Map<String, BaseMap> baseMaps = new HashMap<>(2); Map<String, BaseMap> baseMaps = new HashMap<>(2);
BaseMap totalBaseMaps = null; BaseMap totalBaseMaps = null;
BaseMap negativeBaseMaps = null; BaseMap negativeBaseMaps = null;
if (Objects.nonNull(negativeSpreadTendency.getLeft()) && Objects.nonNull(spreadTendency.getLeft())) { if (Objects.nonNull(negativeSpreadTendency.getLeft()) || Objects.nonNull(spreadTendency.getLeft())) {
CompletableFuture.allOf(Stream.of(spreadTendency.getLeft(), negativeSpreadTendency.getLeft()).map(aggTitle -> CompletableFuture.runAsync(() -> { CompletableFuture.allOf(Stream.of(spreadTendency.getLeft(), negativeSpreadTendency.getLeft()).filter(Objects::nonNull).map(aggTitle ->
CompletableFuture.runAsync(() -> {
try { try {
baseMaps.put(aggTitle, getFirstArticle(startTime, endTime, aggTitle, projectId, Constant.PRIMARY_CONTEND_ID, planId, true)); dto.setAggTitle(aggTitle);
baseMaps.put(aggTitle, getAnalyzeFirstArticle(dto));
} catch (IOException ignored) { } catch (IOException ignored) {
} }
}, executor)).toArray(CompletableFuture[]::new)).join(); }, executor)).toArray(CompletableFuture[]::new)).join();
} }
// 趋势图标题为空,此时说明最高点的时间段发文平台全为微博,此时取最高点时间段内时间最早的微博发文 // 标题为空,但趋势图不为空,此时说明最高点的时间段发文平台全为微博,此时取最高点时间段内时间最早的微博发文
if (Objects.isNull(spreadTendency.getLeft()) || Objects.isNull(negativeSpreadTendency.getLeft())){ if (Objects.isNull(spreadTendency.getLeft()) && CollectionUtils.isNotEmpty(spreadTendency.getRight())){
totalBaseMaps = getWeiboFirstArticle(endTime, spreadTendency.getRight(), planId, projectId, null); totalBaseMaps = getWeiboFirstArticle(endTime, spreadTendency.getRight(), planId, projectId, null);
}
if (Objects.isNull(negativeSpreadTendency.getLeft()) && CollectionUtils.isNotEmpty(negativeSpreadTendency.getRight())){
negativeBaseMaps = getWeiboFirstArticle(endTime, spreadTendency.getRight(), planId, projectId, EmotionEnum.NEGATIVE.getName()); negativeBaseMaps = getWeiboFirstArticle(endTime, spreadTendency.getRight(), planId, projectId, EmotionEnum.NEGATIVE.getName());
} }
// 最高点 // 最高点
BaseMap baseMap = Objects.isNull(baseMaps.get(spreadTendency.getLeft())) ? totalBaseMaps : baseMaps.get(spreadTendency.getLeft()); BaseMap baseMap = Objects.isNull(baseMaps.get(spreadTendency.getLeft())) ? totalBaseMaps : baseMaps.get(spreadTendency.getLeft());
JSONObject highestJson = new JSONObject(); JSONObject highestJson = new JSONObject();
if (Objects.nonNull(baseMap)) { if (Objects.nonNull(baseMap)) {
highestJson.put("title", baseMap.getTitle()); highestJson.put("title", Tools.filterUselessTitle(baseMap.getTitle()) ? StringUtils.substring(baseMap.getContent(), 0, 15) : baseMap.getTitle());
highestJson.put("url", baseMap.getUrl()); highestJson.put("url", baseMap.getUrl());
} }
// 负面最高点 // 负面最高点
BaseMap negativeBaseMap = Objects.isNull(baseMaps.get(negativeSpreadTendency.getLeft())) ? negativeBaseMaps : baseMaps.get(negativeSpreadTendency.getLeft()); BaseMap negativeBaseMap = Objects.isNull(baseMaps.get(negativeSpreadTendency.getLeft())) ? negativeBaseMaps : baseMaps.get(negativeSpreadTendency.getLeft());
JSONObject negativeHighestJson = new JSONObject(); JSONObject negativeHighestJson = new JSONObject();
if (Objects.nonNull(negativeBaseMap)) { if (Objects.nonNull(negativeBaseMap)) {
negativeHighestJson.put("title", negativeBaseMap.getTitle()); negativeHighestJson.put("title", Tools.filterUselessTitle(negativeBaseMap.getTitle()) ? StringUtils.substring(negativeBaseMap.getContent(), 0, 15) : negativeBaseMap.getTitle());
negativeHighestJson.put("url", negativeBaseMap.getUrl()); negativeHighestJson.put("url", negativeBaseMap.getUrl());
} }
res.putAll(platformSpreadTendency); res.putAll(platformSpreadTendency);
...@@ -2705,15 +2730,16 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2705,15 +2730,16 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
@Override @Override
public List<JSONObject> getActiveChannels(Long startTime, Long endTime, String planId) { public List<JSONObject> getActiveChannels(MarkSearchDTO dto) {
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
try { try {
dto.setProjectId(UserThreadLocal.getProjectId());
// 索引 // 索引
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
// query // query
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, planId, null, null); BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
// 渠道聚合,取前20 // 渠道聚合,取前20
TermsAggregationBuilder sourceAggregationBuilder = AggregationBuilders.terms("source_count").field("source").order(BucketOrder.count(false)).size(20); TermsAggregationBuilder sourceAggregationBuilder = AggregationBuilders.terms("source_count").field("source").order(BucketOrder.count(false)).size(20 + Tools.FILTER_SOURCE.size());
// 情感倾向子聚合 // 情感倾向子聚合
TermsAggregationBuilder emotionAggregationBuilder = AggregationBuilders.terms("emotion_count").field("brandkbs_mark_cache_maps.name.keyword"); TermsAggregationBuilder emotionAggregationBuilder = AggregationBuilders.terms("emotion_count").field("brandkbs_mark_cache_maps.name.keyword");
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query, SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query,
...@@ -2721,15 +2747,20 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2721,15 +2747,20 @@ public class MarkDataServiceImpl implements MarkDataService {
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap(); Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
ParsedStringTerms sourceCountTeam = (ParsedStringTerms) aggMap.get("source_count"); ParsedStringTerms sourceCountTeam = (ParsedStringTerms) aggMap.get("source_count");
List<? extends Terms.Bucket> buckets = sourceCountTeam.getBuckets(); List<? extends Terms.Bucket> buckets = sourceCountTeam.getBuckets();
buckets.forEach(bucket -> { for (Terms.Bucket bucket : buckets) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
Map<String, Aggregation> map = bucket.getAggregations().asMap(); Map<String, Aggregation> map = bucket.getAggregations().asMap();
ParsedStringTerms countTeam = (ParsedStringTerms) map.get("emotion_count"); String source = bucket.getKeyAsString();
List<? extends Terms.Bucket> bucketList = countTeam.getBuckets(); // 过滤渠道名:”匿名“
jsonObject.put("source", bucket.getKeyAsString()); if (Tools.filterUselessSource(source)){
continue;
}
jsonObject.put("source", source);
// 发文次数 // 发文次数
jsonObject.put("count", bucket.getDocCount()); jsonObject.put("count", bucket.getDocCount());
// 负面发文次数 // 负面发文次数
ParsedStringTerms countTeam = (ParsedStringTerms) map.get("emotion_count");
List<? extends Terms.Bucket> bucketList = countTeam.getBuckets();
AtomicLong negativeCount = new AtomicLong(); AtomicLong negativeCount = new AtomicLong();
bucketList.forEach(data -> { bucketList.forEach(data -> {
if (Objects.equals(data.getKeyAsString(), EmotionEnum.NEGATIVE.getName())) { if (Objects.equals(data.getKeyAsString(), EmotionEnum.NEGATIVE.getName())) {
...@@ -2738,23 +2769,24 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2738,23 +2769,24 @@ public class MarkDataServiceImpl implements MarkDataService {
}); });
jsonObject.put("negativeCount", negativeCount.get()); jsonObject.put("negativeCount", negativeCount.get());
list.add(jsonObject); list.add(jsonObject);
}); }
}catch (Exception e){ }catch (Exception e){
ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getActiveChannels异常-", e); ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getActiveChannels异常-", e);
} }
return list; return list.stream().limit(20).collect(Collectors.toList());
} }
@Override @Override
public List<JSONObject> getArticleIpLocated(Long startTime, Long endTime, String planId, int size) { public List<JSONObject> getArticleIpLocated(MarkSearchDTO dto) {
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
try { try {
// 索引 // 索引
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
dto.setProjectId(UserThreadLocal.getProjectId());
// query // query
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, planId, null, null); BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
// 聚合请求 // 聚合请求
TermsAggregationBuilder ipAggregationBuilder = AggregationBuilders.terms("ip_count").field("ip_location.keyword").order(BucketOrder.count(false)).size(size); TermsAggregationBuilder ipAggregationBuilder = AggregationBuilders.terms("ip_count").field("ip_location.keyword").order(BucketOrder.count(false)).size(10);
// 情感倾向子聚合 // 情感倾向子聚合
TermsAggregationBuilder emotionAggregationBuilder = AggregationBuilders.terms("emotion_count").field("brandkbs_mark_cache_maps.name.keyword"); TermsAggregationBuilder emotionAggregationBuilder = AggregationBuilders.terms("emotion_count").field("brandkbs_mark_cache_maps.name.keyword");
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query, SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query,
...@@ -2793,29 +2825,57 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2793,29 +2825,57 @@ public class MarkDataServiceImpl implements MarkDataService {
// 列表数据最小mgid // 列表数据最小mgid
MarkFlowEntity markFlowEntity = yuqingMarkList.getList().stream() MarkFlowEntity markFlowEntity = yuqingMarkList.getList().stream()
.min(Comparator.comparingLong(entity -> JSONObject.parseObject(JSONObject.toJSONString(entity.getData())).getLongValue("mgid"))).orElse(null); .min(Comparator.comparingLong(entity -> JSONObject.parseObject(JSONObject.toJSONString(entity.getData())).getLongValue("mgid"))).orElse(null);
// yuqingMarkList.getInfo().put("stime", Objects.isNull(markFlowEntity) ? Long.MAX_VALUE : JSONObject.parseObject(JSONObject.toJSONString(markFlowEntity.getData())).getLongValue("stime"));
yuqingMarkList.getInfo().put("pageGid", Objects.isNull(markFlowEntity) ? Long.MAX_VALUE : JSONObject.parseObject(JSONObject.toJSONString(markFlowEntity.getData())).getLongValue("mgid")); yuqingMarkList.getInfo().put("pageGid", Objects.isNull(markFlowEntity) ? Long.MAX_VALUE : JSONObject.parseObject(JSONObject.toJSONString(markFlowEntity.getData())).getLongValue("mgid"));
return yuqingMarkList; return yuqingMarkList;
} }
@Override @Override
public List<JSONObject> getHighWord(Long startTime, Long endTime, String planId, boolean cache) { public void cacheHighWord(Long startTime, Long endTime, String planId, boolean cache) {
getAnalyzeHighWord(convertedToMarkSearch(null, startTime, endTime, planId), cache);
}
@Override
public List<JSONObject> getAnalyzeHighWord(MarkSearchDTO dto, boolean cache) {
String projectId = UserThreadLocal.getProjectId();
dto.setProjectId(projectId);
String redisKey = RedisUtil.getYuqingAnalyzeHighWordKey(projectId, Constant.PRIMARY_CONTEND_ID, dto.getPlanId(), dto.getStartTime(), dto.getEndTime());
String resultStr;
// 返回缓存
if (cache && StringUtils.isNotEmpty(resultStr = redisUtil.get(redisKey))) {
return JSONArray.parseArray(resultStr, JSONObject.class);
}
List<JSONObject> res = generateHighWord(dto);
redisUtil.setExpire(redisKey, JSONArray.toJSONString(res));
return res;
}
@Override
public List<JSONObject> getSearchAnalyzeHighWord(MarkSearchDTO dto) {
dto.setProjectId(UserThreadLocal.getProjectId());
MarkSearchAnalyzeTask existTask = markSearchAnalyzeTaskDao.findOne("markSearchDTO", dto);
if (Objects.nonNull(existTask)){
return existTask.getHighWord();
}
MarkSearchAnalyzeTask task = new MarkSearchAnalyzeTask(dto, null, false, System.currentTimeMillis());
markSearchAnalyzeTaskDao.insertOne(task);
List<JSONObject> highWord = generateHighWord(dto);
Update update = new Update();
update.set("finish", true);
update.set("highWord", highWord);
markSearchAnalyzeTaskDao.updateOneByIdWithField(task.getId(), update);
return highWord;
}
private List<JSONObject> generateHighWord(MarkSearchDTO dto){
List<JSONObject> res = new ArrayList<>(); List<JSONObject> res = new ArrayList<>();
try { try {
String projectId = UserThreadLocal.getProjectId();
String redisKey = RedisUtil.getYuqingAnalyzeHighWordKey(projectId, Constant.PRIMARY_CONTEND_ID, planId, startTime, endTime);
String resultStr;
// 返回缓存
if (cache && StringUtils.isNotEmpty(resultStr = redisUtil.get(redisKey))) {
return JSONArray.parseArray(resultStr, JSONObject.class);
}
EsClientDao.SearchHelper searchHelper = EsClientDao.createSearchHelper(); EsClientDao.SearchHelper searchHelper = EsClientDao.createSearchHelper();
// sort // sort
searchHelper.setSort(SortBuilders.fieldSort("time").order(SortOrder.DESC)); searchHelper.setSort(SortBuilders.fieldSort("time").order(SortOrder.DESC));
// fetchSource // fetchSource
searchHelper.setFetchSource(new String[]{"ind_title", "ind_full_text", "c5", "foreign", "brandkbs_mark_cache_maps"}); searchHelper.setFetchSource(new String[]{"ind_title", "ind_full_text", "c5", "foreign", "brandkbs_mark_cache_maps"});
// postFilter // postFilter
BoolQueryBuilder postFilter = yuqingAnalyzeQuery(startTime, endTime, planId, null, null); BoolQueryBuilder postFilter = yuqingAnalyzeQuery(dto);
searchHelper.setPostFilter(postFilter); searchHelper.setPostFilter(postFilter);
searchHelper.setSize(10000); searchHelper.setSize(10000);
List<String> textList = new ArrayList<>(); List<String> textList = new ArrayList<>();
...@@ -2830,7 +2890,6 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2830,7 +2890,6 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
} }
res = textUtil.getHighWordsJsonDifferentFieldName(textList, 20); res = textUtil.getHighWordsJsonDifferentFieldName(textList, 20);
redisUtil.setExpire(redisKey, JSONArray.toJSONString(res));
}catch (Exception e){ }catch (Exception e){
ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getHighWord异常-", e); ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getHighWord异常-", e);
} }
...@@ -2838,13 +2897,19 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2838,13 +2897,19 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
@Override @Override
public List<JSONObject> getLastNews(Long startTime, Long endTime, String planId, int size, boolean include) { public List<JSONObject> getLastNews(Long startTime, Long endTime, int size) {
return getLastNews(convertedToMarkSearch(null, startTime, endTime, null), size);
}
@Override
public List<JSONObject> getLastNews(MarkSearchDTO dto, int size) {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
try { try {
List<JSONObject> markTopTitleList = getMarkTopTitle(startTime, endTime, null, projectId, Constant.PRIMARY_CONTEND_ID, planId, size); dto.setProjectId(projectId);
List<JSONObject> markTopTitleList = getMarkTopTitle(dto, size);
CompletableFuture.allOf(markTopTitleList.stream().map(json -> CompletableFuture.supplyAsync(() -> { CompletableFuture.allOf(markTopTitleList.stream().map(json -> CompletableFuture.supplyAsync(() -> {
try { try {
BaseMap firstArticle = getFirstArticle(startTime, endTime, json.getString("title"), projectId, Constant.PRIMARY_CONTEND_ID, planId, include); BaseMap firstArticle = getAnalyzeFirstArticle(dto);
json.put("content", firstArticle.getContent()); json.put("content", firstArticle.getContent());
json.put("url", firstArticle.getUrl()); json.put("url", firstArticle.getUrl());
json.put("realSource", firstArticle.getRealSource()); json.put("realSource", firstArticle.getRealSource());
...@@ -2863,14 +2928,20 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2863,14 +2928,20 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override @Override
public JSONObject getAggTitleBaseInfo(String aggTitle, Long startTime, Long endTime, String planId) { public JSONObject getAggTitleBaseInfo(String aggTitle, Long startTime, Long endTime, String planId) {
return getAggTitleBaseInfo(convertedToMarkSearch(aggTitle, startTime, endTime, planId));
}
@Override
public JSONObject getAggTitleBaseInfo(MarkSearchDTO dto) {
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
try { try {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
dto.setProjectId(projectId);
String linkedGroupId = projectService.getProjectById(projectId).getBrandLinkedGroupId(); String linkedGroupId = projectService.getProjectById(projectId).getBrandLinkedGroupId();
CompletableFuture<JSONObject> firstArticleFuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<JSONObject> firstArticleFuture = CompletableFuture.supplyAsync(() -> {
try { try {
// 最早发布 // 最早发布
BaseMap firstArticle = getFirstArticle(startTime, endTime, aggTitle, projectId, Constant.PRIMARY_CONTEND_ID, planId, true); BaseMap firstArticle = getAnalyzeFirstArticle(dto);
// 匹配重要渠道 // 匹配重要渠道
JSONObject firstSensitiveChannel = channelService.matchYuQingSensitiveChannel(linkedGroupId, firstArticle.getSource()); JSONObject firstSensitiveChannel = channelService.matchYuQingSensitiveChannel(linkedGroupId, firstArticle.getSource());
JSONObject firstArticleJson = JSONObject.parseObject(JSONObject.toJSONString(firstArticle)); JSONObject firstArticleJson = JSONObject.parseObject(JSONObject.toJSONString(firstArticle));
...@@ -2883,7 +2954,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2883,7 +2954,7 @@ public class MarkDataServiceImpl implements MarkDataService {
CompletableFuture<JSONObject> lastArticleFuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<JSONObject> lastArticleFuture = CompletableFuture.supplyAsync(() -> {
try { try {
// 最新发布 // 最新发布
BaseMap lastArticle = getLastArticle(startTime, endTime, aggTitle, projectId, Constant.PRIMARY_CONTEND_ID, planId, true); BaseMap lastArticle = getAnalyzeLastArticle(dto);
// 匹配重要渠道 // 匹配重要渠道
JSONObject lastSensitiveChannel = channelService.matchYuQingSensitiveChannel(linkedGroupId, lastArticle.getSource()); JSONObject lastSensitiveChannel = channelService.matchYuQingSensitiveChannel(linkedGroupId, lastArticle.getSource());
JSONObject lastArticleJson = JSONObject.parseObject(JSONObject.toJSONString(lastArticle)); JSONObject lastArticleJson = JSONObject.parseObject(JSONObject.toJSONString(lastArticle));
...@@ -2909,11 +2980,17 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2909,11 +2980,17 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override @Override
public List<JSONObject> getAggTitleArticlePoints(String aggTitle, Long startTime, Long endTime, String planId) { public List<JSONObject> getAggTitleArticlePoints(String aggTitle, Long startTime, Long endTime, String planId) {
return getAggTitleArticlePoints(convertedToMarkSearch(aggTitle, startTime, endTime, planId));
}
@Override
public List<JSONObject> getAggTitleArticlePoints(MarkSearchDTO dto) {
List<JSONObject> jsonObject = new ArrayList<>(); List<JSONObject> jsonObject = new ArrayList<>();
try { try {
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
// query // query
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, null, planId, null, null, aggTitle); dto.setProjectId(UserThreadLocal.getProjectId());
BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
DateHistogramAggregationBuilder daysAggregationBuilder = DateHistogramAggregationBuilder daysAggregationBuilder =
AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.DAY); AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.DAY);
TermsAggregationBuilder sourceAggregationBuilder = AggregationBuilders.terms("sourceAgg").field("source").size(10000); TermsAggregationBuilder sourceAggregationBuilder = AggregationBuilders.terms("sourceAgg").field("source").size(10000);
...@@ -2958,8 +3035,13 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2958,8 +3035,13 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override @Override
public List<JSONObject> getAggTitlePlatformPercentage(String aggTitle, Long startTime, Long endTime, String planId) { public List<JSONObject> getAggTitlePlatformPercentage(String aggTitle, Long startTime, Long endTime, String planId) {
return getAggTitlePlatformPercentage(convertedToMarkSearch(aggTitle, startTime, endTime, planId));
}
@Override
public List<JSONObject> getAggTitlePlatformPercentage(MarkSearchDTO dto) {
try { try {
return getPlatformPercentage(aggTitle, startTime, endTime, planId); return getPlatformPercentage(dto);
}catch (Exception e){ }catch (Exception e){
ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getAggTitlePlatformPercentage异常-", e); ExceptionCast.cast(CommonCodeEnum.FAIL, "新舆情分析getAggTitlePlatformPercentage异常-", e);
} }
...@@ -2968,15 +3050,31 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -2968,15 +3050,31 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override @Override
public PageVO<JSONObject> getArticleList(String aggTitle, Long startTime, Long endTime, String planId, String platform, int page, int pageSize) { public PageVO<JSONObject> getArticleList(String aggTitle, Long startTime, Long endTime, String planId, String platform, int page, int pageSize) {
MarkSearchDTO dto = convertedToMarkSearch(aggTitle, startTime, endTime, planId);
dto.setPlatforms(Collections.singletonList(platform));
dto.setPage(page);
dto.setPageSize(pageSize);
return getArticleList(dto);
}
@Override
public PageVO<JSONObject> getArticleList(MarkSearchDTO dto) {
int page = Objects.isNull(dto.getPage()) ? 1 : dto.getPage();
int pageSize = Objects.isNull(dto.getPageSize()) ? 10 : dto.getPageSize();
try { try {
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
dto.setProjectId(UserThreadLocal.getProjectId());
// query // query
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, null, planId, null, Collections.singletonList(platform), aggTitle); if (Objects.nonNull(dto.getPlatforms()) && Objects.nonNull(dto.getPlatforms().get(0))){
if (Objects.equals("其他", platform)){ dto.setPlatforms(Collections.singletonList(GlobalPojo.getPlatformIdByName(dto.getPlatforms().get(0))));
List<String> platforms = getPlatformPercentage(aggTitle, startTime, endTime, planId).stream().map(json -> json.getString("platform")).collect(Collectors.toList()); }
BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
if (Objects.equals("其他", dto.getPlatforms().get(0))){
List<String> platforms = getPlatformPercentage(dto).stream().map(json -> json.getString("platform")).collect(Collectors.toList());
List<String> allPlatforms = GlobalPojo.PLATFORMS.stream().map(MessagePlatform::getName).collect(Collectors.toList()); List<String> allPlatforms = GlobalPojo.PLATFORMS.stream().map(MessagePlatform::getName).collect(Collectors.toList());
allPlatforms.removeAll(platforms); allPlatforms.removeAll(platforms);
query = yuqingAnalyzeQuery(startTime, endTime, null, planId, null, allPlatforms, aggTitle); dto.setPlatforms(allPlatforms.stream().map(GlobalPojo::getPlatformIdByName).collect(Collectors.toList()));
query = yuqingAnalyzeQuery(dto);
} }
// sort // sort
FieldSortBuilder sort = SortBuilders.fieldSort("time").order(SortOrder.DESC); FieldSortBuilder sort = SortBuilders.fieldSort("time").order(SortOrder.DESC);
...@@ -3000,33 +3098,43 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -3000,33 +3098,43 @@ public class MarkDataServiceImpl implements MarkDataService {
return PageVO.createPageVo(0, page, pageSize, Collections.emptyList()); return PageVO.createPageVo(0, page, pageSize, Collections.emptyList());
} }
private MarkSearchDTO convertedToMarkSearch(String aggTitle, Long startTime, Long endTime, String planId){
MarkSearchDTO dto = new MarkSearchDTO();
dto.setAggTitle(aggTitle);
dto.setStartTime(startTime);
dto.setEndTime(endTime);
dto.setPlanId(planId);
return dto;
}
/** /**
* 微博、微信、抖音、小红书平台趋势图 * 微博、微信、抖音、小红书平台趋势图
* @param startTime * @param dto
* @param endTime
* @param planId
* @return * @return
* @throws IOException * @throws IOException
*/ */
private Map<String, List<LineVO>> getPlatformSpreadTendency(Long startTime, Long endTime, String planId) throws IOException{ private Map<String, List<LineVO>> getPlatformSpreadTendency(MarkSearchDTO dto) throws IOException{
Map<String, List<LineVO>> res = new HashMap<>(4); Map<String, List<LineVO>> res = new HashMap<>(4);
// 平台 // 平台
List<String> platforms = Arrays.asList("微博", "微信", "抖音", "小红书"); List<String> platforms = new ArrayList<>();
for (String platformNames : Arrays.asList("微博", "微信", "抖音", "小红书")) {
platforms.add(GlobalPojo.getPlatformIdByName(platformNames));
}
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
// 聚合请求 // 聚合请求
TermsAggregationBuilder platformAggregationBuilder = AggregationBuilders.terms("platformAgg").field("platform_id").order(BucketOrder.count(false)); TermsAggregationBuilder platformAggregationBuilder = AggregationBuilders.terms("platformAgg").field("platform_id").order(BucketOrder.count(false));
DateHistogramAggregationBuilder daysAggregationBuilder; DateHistogramAggregationBuilder daysAggregationBuilder;
// 天级以小时为颗粒度,其他以天作为颗粒度 // 天级以小时为颗粒度,其他以天作为颗粒度
if (endTime - startTime <= Constant.ONE_DAY){ if (dto.getEndTime() - dto.getStartTime() <= Constant.ONE_DAY){
daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.HOUR); daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.HOUR);
}else { }else {
daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.DAY); daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.DAY);
} }
dto.setPlatforms(platforms);
// query // query
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, planId, null, platforms); BoolQueryBuilder query = yuqingAnalyzeQuery(dto);
// response // response
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query, SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query, platformAggregationBuilder.subAggregation(daysAggregationBuilder), null, null, 0, 0, null);
platformAggregationBuilder.subAggregation(daysAggregationBuilder), null, null, 0, 0, null);
Map<String, Aggregation> map = searchResponse.getAggregations().asMap(); Map<String, Aggregation> map = searchResponse.getAggregations().asMap();
ParsedStringTerms countTeam = (ParsedStringTerms) map.get("platformAgg"); ParsedStringTerms countTeam = (ParsedStringTerms) map.get("platformAgg");
List<? extends Terms.Bucket> platformBuckets = countTeam.getBuckets(); List<? extends Terms.Bucket> platformBuckets = countTeam.getBuckets();
...@@ -3048,26 +3156,24 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -3048,26 +3156,24 @@ public class MarkDataServiceImpl implements MarkDataService {
/** /**
* 新舆情分析-舆情趋势图 * 新舆情分析-舆情趋势图
* @param startTime * @param dto 标注数据搜索传输类
* @param endTime
* @param planId
* @param emotion
* @return * @return
* @throws IOException * @throws IOException
*/ */
private Pair<String, List<LineVO>> getSpreadTendency(Long startTime, Long endTime, String planId, String emotion) throws IOException { private Pair<String, List<LineVO>> getEmotionSpreadTendency(MarkSearchDTO dto, String emotion) throws IOException {
List<LineVO> res = new ArrayList<>(); List<LineVO> res = new ArrayList<>();
String[] indexes = esClientDao.getIndexes(); String[] indexes = esClientDao.getIndexes();
DateHistogramAggregationBuilder daysAggregationBuilder; DateHistogramAggregationBuilder daysAggregationBuilder;
// 天级以小时为颗粒度,其他以天作为颗粒度 // 天级以小时为颗粒度,其他以天作为颗粒度
if (endTime - startTime <= Constant.ONE_DAY){ if (dto.getEndTime() - dto.getStartTime() <= Constant.ONE_DAY){
daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.HOUR); daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.HOUR);
}else { }else {
daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.DAY); daysAggregationBuilder = AggregationBuilders.dateHistogram("timeAgg").field("time").calendarInterval(DateHistogramInterval.DAY);
} }
TermsAggregationBuilder titleAggregationBuilder = AggregationBuilders.terms("titleAgg").field("agg_title.keyword").order(BucketOrder.count(false)); TermsAggregationBuilder titleAggregationBuilder = AggregationBuilders.terms("titleAgg").field("agg_title.keyword").order(BucketOrder.count(false));
dto.setPlatforms(null);
// query // query
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, planId, emotion, null); BoolQueryBuilder query = yuqingAnalyzeQuery(dto, emotion);
// response // response
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query, SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query,
daysAggregationBuilder.subAggregation(titleAggregationBuilder), null, null, 0, 0, null); daysAggregationBuilder.subAggregation(titleAggregationBuilder), null, null, 0, 0, null);
...@@ -3093,13 +3199,13 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -3093,13 +3199,13 @@ public class MarkDataServiceImpl implements MarkDataService {
return Pair.of(maxAggTitle, res); return Pair.of(maxAggTitle, res);
} }
private Long getYuqingAnalyzeCount(Long startTime, Long endTime, String planId, List<String> platforms) throws IOException { private Long getYuqingAnalyzeCount(MarkSearchDTO dto) throws IOException {
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, planId, null, platforms); BoolQueryBuilder query = yuqingAnalyzeQuery(dto, null);
return esClientDao.count(query); return esClientDao.count(query);
} }
private Long getYuqingAnalyzeCount(Long startTime, Long endTime, String planId, String emotion) throws IOException { private Long getYuqingAnalyzeCount(MarkSearchDTO dto, String emotion) throws IOException {
BoolQueryBuilder query = yuqingAnalyzeQuery(startTime, endTime, planId, emotion, null); BoolQueryBuilder query = yuqingAnalyzeQuery(dto, emotion);
return esClientDao.count(query); return esClientDao.count(query);
} }
...@@ -3108,10 +3214,6 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -3108,10 +3214,6 @@ public class MarkDataServiceImpl implements MarkDataService {
return esClientDao.count(query); return esClientDao.count(query);
} }
private BoolQueryBuilder yuqingAnalyzeQuery(Long startTime, Long endTime, String planId, String emotion, List<String> platforms){
return yuqingAnalyzeQuery(startTime, endTime, null, planId, emotion, platforms, null);
}
private BoolQueryBuilder yuqingAnalyzeQuery(Long startTime, Long endTime, String projectId, String planId, String emotion, List<String> platforms, String aggTitle){ private BoolQueryBuilder yuqingAnalyzeQuery(Long startTime, Long endTime, String projectId, String planId, String emotion, List<String> platforms, String aggTitle){
if (Objects.isNull(projectId)) { if (Objects.isNull(projectId)) {
projectId = UserThreadLocal.getProjectId(); projectId = UserThreadLocal.getProjectId();
...@@ -3148,6 +3250,71 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -3148,6 +3250,71 @@ public class MarkDataServiceImpl implements MarkDataService {
} }
return query; return query;
} }
private BoolQueryBuilder yuqingAnalyzeQuery(MarkSearchDTO dto){
return yuqingAnalyzeQuery(dto, null);
}
private BoolQueryBuilder yuqingAnalyzeQuery(MarkSearchDTO dto, String emotion){
// projectId、contendId
String projectId = dto.getProjectId();
String contendId = dto.getContendId();
// PostFilter 后置过滤器
// 新增channelEmotion
BoolQueryBuilder postFilter = EsQueryTools.assembleCacheMapsQuery(projectId, contendId, dto.getPoliticsLevel(), dto.getField(), dto.getRegion(), dto.getMainBodyType(), dto.getChannelEmotion());
if (Objects.nonNull(dto.getPlanId())){
postFilter = EsQueryTools.assembleCacheMapsPlanQuery(projectId, dto.getPlanId());
}
// time
postFilter.must(QueryBuilders.rangeQuery("time").gte(dto.getStartTime()).lt(dto.getEndTime()));
// platform
if (CollectionUtils.isNotEmpty(dto.getPlatforms())) {
postFilter.must(EsQueryTools.assemblePlatformQuery(Tools.getPlatformByIds(dto.getPlatforms())));
}
// tags
if (CollectionUtils.isNotEmpty(dto.getTags())) {
postFilter.must(EsQueryTools.assembleTagQuery(dto.getTags()));
}
// customTags
if (CollectionUtils.isNotEmpty(dto.getCustomTags())) {
postFilter.must(EsQueryTools.assembleTagQuery(dto.getCustomTags()));
}
// Query 查询条件
String[] fieldSearch = "仅标题".equals(dto.getSearchField()) ? new String[]{GenericAttribute.ES_IND_TITLE} : new String[]{GenericAttribute.ES_IND_FULL_TEXT};
// keyword
if (StringUtils.isNotEmpty(dto.getKeyword())) {
// Query
postFilter.must(EsQueryTools.assembleNormalKeywordQuery(dto.getKeyword(), fieldSearch));
}
// emotion
if (StringUtils.isNotEmpty(emotion) && !EmotionEnum.ALL.getName().equals(emotion)) {
postFilter.must(QueryBuilders.termQuery("brandkbs_mark_cache_maps.name.keyword", emotion));
}
// shieldWord
if (StringUtils.isNotEmpty(dto.getShieldWord())) {
postFilter.mustNot(EsQueryTools.assembleNormalKeywordQuery(dto.getShieldWord(), fieldSearch));
}
// sourceKeyword
if (StringUtils.isNotEmpty(dto.getSourceKeyword())) {
postFilter.must(EsQueryTools.assembleSourceQuery(dto.getSourceKeyword()));
}
// hostKeyword
if (StringUtils.isNotEmpty(dto.getHostKeyword())) {
postFilter.must(EsQueryTools.assembleFiledKeywordQuery("host", dto.getHostKeyword()));
}
// ip
if (StringUtils.isNotEmpty(dto.getIp())){
postFilter.must(EsQueryTools.assembleIpQuery(dto.getIp()));
}
// mgid限制 舆情分析页面滚动翻页用
if (Objects.nonNull(dto.getPageGid())){
postFilter.must(QueryBuilders.rangeQuery(GenericAttribute.ES_MGID).lt(dto.getPageGid()));
}
// 聚合标题
if (Objects.nonNull(dto.getAggTitle())){
postFilter.must(QueryBuilders.termQuery("agg_title.keyword", dto.getAggTitle()));
}
return postFilter;
}
/** /**
* 获取最大的gid * 获取最大的gid
......
...@@ -302,89 +302,6 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -302,89 +302,6 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
return new BrandkbsWarnTemplate(firstCount, key1, key2, key3, key4, new BrandkbsYuQingWarn(collect)); return new BrandkbsWarnTemplate(firstCount, key1, key2, key3, key4, new BrandkbsYuQingWarn(collect));
} }
@Deprecated
private BrandkbsWarnTemplate brandkbsWarnTemplate4Yuqing(BrandkbsYuQingConfig config, List<BaseMap> datas, long start, long end, AbstractProject project) {
if (datas.isEmpty()) {
return null;
}
int firstCount = datas.size();
// key1
String key1 = "【品见】舆情动态-" + project.getProjectName();
// key2
// String key2Header = "全部";
String key2Header = "";
StringBuilder mediaChannel = new StringBuilder();
List<String> politicsLevels = config.getPoliticsLevels();
List<String> fields = config.getFields();
if(Tools.isEmpty(politicsLevels)){
key2Header += "【全部级别】";
}else if(politicsLevels.contains("全部")){
key2Header += "【重点级别】";
}else{
politicsLevels.forEach(politicsLevel -> mediaChannel.append(politicsLevel).append("、"));
}
if (Tools.isEmpty(fields)) {
if (0 != key2Header.length()) {
key2Header += "、";
key2Header += "【全部领域】,";
} else {
key2Header += "【全部领域】";
}
} else if (fields.contains("全部")) {
if (0 != key2Header.length()) {
key2Header += "、";
key2Header += "【重点领域】,";
} else {
key2Header += "【重点领域】";
}
} else {
fields.forEach(field -> mediaChannel.append(field).append("、"));
}
if (0 != mediaChannel.length()) {
if (0 != key2Header.length()) {
key2Header += "、";
}
// 替换“全部” 并去掉末位的、
key2Header += mediaChannel.deleteCharAt(mediaChannel.length() - 1).toString();
key2Header += "媒体,";
}
StringBuilder dataType = new StringBuilder();
config.getMarkerTags().forEach(emotion -> dataType.append(emotion).append(" "));
dataType.append("(本品)");
// 如果有竞品
if (CollectionUtils.isNotEmpty(config.getContends())) {
dataType.append(",");
config.getContends().forEach(contend -> dataType.append(projectService.getProjectByContendId(project.getId(), contend).getBrandName()).append(" "));
dataType.append("(竞品)");
}
String key2 = key2Header + dataType;
// key3
String key3 = Constant.SPEC_MINUTE_FORMAT.format(start) + " ~ " + Constant.SPEC_MINUTE_FORMAT.format(end);
// key4
String key4;
StringBuilder keyBuilder4 = new StringBuilder();
for (int i = 0; i < Math.min(datas.size(), 2); i++) {
BaseMap baseMap = datas.get(i);
String platform = baseMap.getPlatform();
String source = baseMap.getSource();
String title = baseMap.getTitle();
keyBuilder4.append(platform).append("-").append(source).append("\r\n");
// 最后一条
if (datas.size() == i + 1) {
keyBuilder4.append(i + 1).append("、").append(title);
} else {
keyBuilder4.append(i + 1).append("、").append(title).append("\r\n");
}
}
if (datas.size() > 2) {
key4 = keyBuilder4.append("...").toString();
} else {
key4 = keyBuilder4.toString();
}
List<BaseMapCompound> collect = datas.stream().map(baseMap -> BaseMapCompound.createFromBaseMap(baseMap, project.getId())).collect(Collectors.toList());
return new BrandkbsWarnTemplate(firstCount, key1, key2, key3, key4, new BrandkbsYuQingWarn(collect));
}
private BrandkbsWarnTemplate brandkbsWarnTemplate4Channel(BrandkbsChannelConfig config, List<BaseMap> datas, long start, long end, AbstractProject project) { private BrandkbsWarnTemplate brandkbsWarnTemplate4Channel(BrandkbsChannelConfig config, List<BaseMap> datas, long start, long end, AbstractProject project) {
if (datas.isEmpty()) { if (datas.isEmpty()) {
return null; return null;
...@@ -703,65 +620,6 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -703,65 +620,6 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
} }
@Override @Override
@Deprecated
public ResponseResult getYuqingWaring(String projectId, BrandkbsYuQingConfig config) {
Project project = null;
long end = System.currentTimeMillis();
long start = end - config.getPushInterval();
try {
project = projectService.getProjectById(projectId);
log.info("获取舆情动态预警开始,project:{}", project.getProjectName());
EsClientDao.SearchHelper helper = EsClientDao.createSearchHelper();
// 发声渠道
BoolQueryBuilder postFilter = EsQueryTools.assembleCacheMapsQueryWithProject(projectId, config);
// 时间(标注时间)
postFilter.must(QueryBuilders.rangeQuery("mtime").gte(start).lt(end));
// 文章类型
if (CollectionUtils.isNotEmpty(config.getPrimary()) && config.getPrimary().size() == 1) {
postFilter.must(EsQueryTools.assembleForwardQuery(config.getPrimary().get(0)));
}
// 本品舆情+竞品舆情
BoolQueryBuilder sourceBuilder = QueryBuilders.boolQuery();
if (CollectionUtils.isNotEmpty(config.getMarkerTags())) {
config.getMarkerTags().forEach(tagName -> sourceBuilder.should(QueryBuilders.termQuery("brandkbs_mark_cache_maps.name.keyword", tagName)));
}
postFilter.must(sourceBuilder);
EsQueryTools.assembleContendsQuery(postFilter, config.getContends());
// postFilter.must(EsQueryTools.assembleNormalKeywordQuery(config.getKeyword(), new String[]{GenericAttribute.ES_IND_FULL_TEXT}));
helper.setPostFilter(postFilter);
SearchHits searchHits = esClientDao.searchHits(helper);
log.info("获取舆情动态预警-es搜索到数据:{}条,剩余关键词筛选未进行,project:{}", searchHits.getHits().length, project.getProjectName());
List<BaseMap> datas = Arrays.stream(searchHits.getHits()).map(hit -> {
Map<String, Object> sourceMap = hit.getSourceAsMap();
BaseMap baseMap = Tools.getBaseFromEsMap(sourceMap);
// 关键词命中
if (!Tools.isContains(config.getKeyword(), baseMap.getTitle() + baseMap.getContent())) {
return null;
}
JSONObject hitMap = Tools.getBrandkbsHitMapWithProjectId(sourceMap, projectId);
String contendId = hitMap.getString("contend_id");
if (!hitMap.isEmpty() && (null != config.getContends() && config.getContends().contains(contendId))) {
baseMap.setBrandName(projectService.getProjectByContendId(projectId, contendId).getBrandName());
}
baseMap.setTitle(baseMap.getTitleNullOptionalContent());
baseMap.subStringContentTop();
return baseMap;
}).filter(Objects::nonNull).collect(Collectors.toList());
// 开启去重
if (Boolean.TRUE.equals(config.getDuplicate())) {
datas = duplicateBaseMapList(datas);
}
log.info("获取舆情动态预警结束,project:{}", project.getProjectName());
// 封装返回值
return ResponseResult.success(brandkbsWarnTemplate4Yuqing(config, datas, start, end, project));
} catch (Exception e) {
log.info("获取舆情动态预警失败,project:{}", project.getProjectName(), e);
}
return ResponseResult.failure("获取舆情动态预警失败");
}
@Override
public ResponseResult getYuqingWaringNew(String projectId, BrandkbsYuQingConfigNew config) { public ResponseResult getYuqingWaringNew(String projectId, BrandkbsYuQingConfigNew config) {
Project project; Project project;
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
...@@ -788,6 +646,10 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -788,6 +646,10 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
if (StringUtils.isNotBlank(config.getChannel())){ if (StringUtils.isNotBlank(config.getChannel())){
postFilter.must(EsQueryTools.assembleSourceQuery(config.getChannel())); postFilter.must(EsQueryTools.assembleSourceQuery(config.getChannel()));
} }
// 屏蔽渠道
if (StringUtils.isNotBlank(config.getNoiseChannel())){
postFilter.mustNot(EsQueryTools.assembleSourceQuery(config.getNoiseChannel()));
}
helper.setPostFilter(postFilter); helper.setPostFilter(postFilter);
SearchHits searchHits = esClientDao.searchHits(helper); SearchHits searchHits = esClientDao.searchHits(helper);
log.info("获取新舆情动态预警-es搜索到数据:{}条,剩余关键词筛选未进行,project:{}", searchHits.getHits().length, project.getProjectName()); log.info("获取新舆情动态预警-es搜索到数据:{}条,剩余关键词筛选未进行,project:{}", searchHits.getHits().length, project.getProjectName());
...@@ -795,7 +657,11 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -795,7 +657,11 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
Map<String, Object> sourceMap = hit.getSourceAsMap(); Map<String, Object> sourceMap = hit.getSourceAsMap();
BaseMap baseMap = Tools.getBaseFromEsMap(sourceMap); BaseMap baseMap = Tools.getBaseFromEsMap(sourceMap);
// 关键词命中 // 关键词命中
if (!Tools.isContains(config.getKeyword(), baseMap.getTitle() + baseMap.getContent())) { if (!Tools.isEmpty(config.getKeyword()) && !Tools.isContains(config.getKeyword(), baseMap.getTitle() + baseMap.getContent())) {
return null;
}
// 屏蔽关键词命中
if (!Tools.isEmpty(config.getNoiseKeyword()) && Tools.isContains(config.getNoiseKeyword(), baseMap.getTitle() + baseMap.getContent())) {
return null; return null;
} }
baseMap.setTitle(baseMap.getTitleNullOptionalContent()); baseMap.setTitle(baseMap.getTitleNullOptionalContent());
......
...@@ -3,19 +3,15 @@ package com.zhiwei.brandkbs2.service.impl; ...@@ -3,19 +3,15 @@ package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.zhiwei.brandkbs2.dao.ChannelTagDao; import com.zhiwei.brandkbs2.dao.*;
import com.zhiwei.brandkbs2.dao.MediaTypeDao; import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.dao.ProjectDao;
import com.zhiwei.brandkbs2.dao.QbjcPojoDao;
import com.zhiwei.brandkbs2.pojo.ChannelTag;
import com.zhiwei.brandkbs2.pojo.MediaType;
import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.SensitiveChannel;
import com.zhiwei.brandkbs2.service.SystemInfoService; import com.zhiwei.brandkbs2.service.SystemInfoService;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform; import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import com.zhiwei.qbjc.bean.pojo.common.Tag; import com.zhiwei.qbjc.bean.pojo.common.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -48,6 +44,9 @@ public class SystemInfoServiceImpl implements SystemInfoService { ...@@ -48,6 +44,9 @@ public class SystemInfoServiceImpl implements SystemInfoService {
@Resource @Resource
private ProjectDao projectDao; private ProjectDao projectDao;
@Resource(name = "bytedanceCustomChannelInfluenceDao")
private BytedanceCustomChannelInfluenceDao bytedanceCustomChannelInfluenceDao;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
...@@ -132,4 +131,10 @@ public class SystemInfoServiceImpl implements SystemInfoService { ...@@ -132,4 +131,10 @@ public class SystemInfoServiceImpl implements SystemInfoService {
List<SensitiveChannel> commonSensitiveChannel = qbjcPojoDao.findCommonSensitiveChannel(); List<SensitiveChannel> commonSensitiveChannel = qbjcPojoDao.findCommonSensitiveChannel();
return commonSensitiveChannel.stream().collect(Collectors.toMap(SensitiveChannel::getName, o-> o, (k1, k2) -> k1)); return commonSensitiveChannel.stream().collect(Collectors.toMap(SensitiveChannel::getName, o-> o, (k1, k2) -> k1));
} }
@Override
public Map<String, BytedanceCustomChannelInfluence> getByteDanceChannelInfluence() {
return bytedanceCustomChannelInfluenceDao.findList(new Query())
.stream().collect(Collectors.toMap(data -> Tools.concat(data.getPlatform(), data.getChannel()), o -> o, (v1, v2) -> v1));
}
} }
...@@ -188,6 +188,8 @@ public class TaskServiceImpl implements TaskService { ...@@ -188,6 +188,8 @@ public class TaskServiceImpl implements TaskService {
indexService.getPlatformInfo(null, null, false); indexService.getPlatformInfo(null, null, false);
// 首页-传播趋势 // 首页-传播趋势
indexService.getSpreadingTend(null, null, false); indexService.getSpreadingTend(null, null, false);
// 首页-净情感度
indexService.getEmotionPercent(null, null, false);
log.info("项目:{}-首页缓存已完成:{}个", project.getProjectName(), total.incrementAndGet()); log.info("项目:{}-首页缓存已完成:{}个", project.getProjectName(), total.incrementAndGet());
return null; return null;
}, cacheServiceExecutor)).toArray(CompletableFuture[]::new)).join(); }, cacheServiceExecutor)).toArray(CompletableFuture[]::new)).join();
...@@ -382,14 +384,14 @@ public class TaskServiceImpl implements TaskService { ...@@ -382,14 +384,14 @@ public class TaskServiceImpl implements TaskService {
Long[] time = commonService.getTimeRangeMonth(); Long[] time = commonService.getTimeRangeMonth();
List<CompletableFuture<Object>> projectFutures = GlobalPojo.PROJECT_MAP.values().stream().map(project -> CompletableFuture.supplyAsync(() -> { List<CompletableFuture<Object>> projectFutures = GlobalPojo.PROJECT_MAP.values().stream().map(project -> CompletableFuture.supplyAsync(() -> {
UserThreadLocal.set(new UserInfo().setProjectId(project.getId())); UserThreadLocal.set(new UserInfo().setProjectId(project.getId()));
markDataService.getHighWord(time[0], time[1], null, false); markDataService.cacheHighWord(time[0], time[1], null, false);
log.info("项目:{}-{}-词云缓存已完成:{}个", project.getProjectName(), project.getId(), total.incrementAndGet()); log.info("项目:{}-{}-词云缓存已完成:{}个", project.getProjectName(), project.getId(), total.incrementAndGet());
return null; return null;
}, cacheServiceExecutor)).collect(Collectors.toList()); }, cacheServiceExecutor)).collect(Collectors.toList());
AtomicInteger total2 = new AtomicInteger(); AtomicInteger total2 = new AtomicInteger();
List<CompletableFuture<Object>> planFutures = nonManualProjectPlanDao.findList(new Query()).stream().map(plan -> CompletableFuture.supplyAsync(() -> { List<CompletableFuture<Object>> planFutures = nonManualProjectPlanDao.findList(new Query()).stream().map(plan -> CompletableFuture.supplyAsync(() -> {
UserThreadLocal.set(new UserInfo().setProjectId(plan.getProjectId())); UserThreadLocal.set(new UserInfo().setProjectId(plan.getProjectId()));
markDataService.getHighWord(time[0], time[1], plan.getId(), false); markDataService.cacheHighWord(time[0], time[1], plan.getId(), false);
log.info("方案:{}-{}-词云缓存已完成:{}个", plan.getName(), plan.getId(), total2.incrementAndGet()); log.info("方案:{}-{}-词云缓存已完成:{}个", plan.getName(), plan.getId(), total2.incrementAndGet());
return null; return null;
}, cacheServiceExecutor)).collect(Collectors.toList()); }, cacheServiceExecutor)).collect(Collectors.toList());
......
package com.zhiwei.brandkbs2.service.impl; package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.GenericAttribute; import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.controller.app.AppToolsetController; import com.zhiwei.brandkbs2.controller.app.AppToolsetController;
import com.zhiwei.brandkbs2.dao.*; import com.zhiwei.brandkbs2.dao.*;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil; import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
...@@ -109,6 +109,9 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -109,6 +109,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Resource(name = "BytedanceCustomPlatformWeightDao") @Resource(name = "BytedanceCustomPlatformWeightDao")
private BytedanceCustomPlatformWeightDao bytedanceCustomPlatformWeightDao; private BytedanceCustomPlatformWeightDao bytedanceCustomPlatformWeightDao;
@Resource(name = "bytedanceCustomChannelLevelInfoDao")
private BytedanceCustomChannelLevelInfoDao bytedanceCustomChannelLevelInfoDao;
@Resource(name = "bytedanceCustomEventUpdateTaskDao") @Resource(name = "bytedanceCustomEventUpdateTaskDao")
private BytedanceCustomEventUpdateTaskDao bytedanceCustomEventUpdateTaskDao; private BytedanceCustomEventUpdateTaskDao bytedanceCustomEventUpdateTaskDao;
...@@ -388,6 +391,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -388,6 +391,7 @@ public class ToolsetServiceImpl implements ToolsetService {
} }
@Override @Override
@Deprecated // 2024.3.27 由于不再进行互动量更新故不再进行补充计算
public void eventAdditionalUpdate(MultipartFile file, String taskId) { public void eventAdditionalUpdate(MultipartFile file, String taskId) {
BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId); BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId);
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.CHANNEL_MATCH); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.CHANNEL_MATCH);
...@@ -400,11 +404,9 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -400,11 +404,9 @@ public class ToolsetServiceImpl implements ToolsetService {
// 将旧数据与新数据合并 // 将旧数据与新数据合并
List<BytedanceCustomEventUpdateTaskData> taskData = bytedanceCustomEventUpdateTaskDataDao.findList(new Query(Criteria.where("taskId").is(taskId))); List<BytedanceCustomEventUpdateTaskData> taskData = bytedanceCustomEventUpdateTaskDataDao.findList(new Query(Criteria.where("taskId").is(taskId)));
taskData.addAll(data); taskData.addAll(data);
// 清空错误旧数据
task.getErrorData().clear();
// 更新进度 // 更新进度
resetProcessSchedule(task.getId(), taskData.size()); resetProcessSchedule(task.getId(), data.size());
ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(taskData, task, task.getExtraCompute())); ApplicationProjectListener.getThreadPool().execute(() -> processEventUpdate(data, task, task.getExtraCompute()));
} }
@Override @Override
...@@ -451,7 +453,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -451,7 +453,7 @@ public class ToolsetServiceImpl implements ToolsetService {
return jsonObject; return jsonObject;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
JSONObject info = new JSONObject(); JSONObject info = new JSONObject();
info.put("error", CollectionUtils.isNotEmpty(task.getErrorData())); // info.put("error", CollectionUtils.isNotEmpty(task.getErrorData()));
PageVO<JSONObject> pageVo = PageVO.createPageVo(task.getEventInfo().size(), page, pageSize, list); PageVO<JSONObject> pageVo = PageVO.createPageVo(task.getEventInfo().size(), page, pageSize, list);
pageVo.setInfo(info); pageVo.setInfo(info);
return pageVo; return pageVo;
...@@ -475,6 +477,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -475,6 +477,7 @@ public class ToolsetServiceImpl implements ToolsetService {
dto.setInf(event.getInfluence()); dto.setInf(event.getInfluence());
dto.setRMI(event.getRMI()); dto.setRMI(event.getRMI());
dto.setFinalInf(event.getFinalInfluence()); dto.setFinalInf(event.getFinalInfluence());
dto.setDataCount(event.getDataCount());
return dto; return dto;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// excel写入至指定路径 // excel写入至指定路径
...@@ -485,13 +488,14 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -485,13 +488,14 @@ public class ToolsetServiceImpl implements ToolsetService {
} }
@Override @Override
@Deprecated // 2024.3.27 由于不再进行互动量更新故不会出现错误数据,无需再下载
public String downloadPrimaryErrorData(String taskId) { public String downloadPrimaryErrorData(String taskId) {
BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId); BytedanceCustomEventUpdateTask task = bytedanceCustomEventUpdateTaskDao.findOneById(taskId);
// excel写入至指定路径 // excel写入至指定路径
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName(); String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "报错数据"); String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "报错数据");
List<UploadBytedanceEventDTO> collect = task.getErrorData().stream().map(errorData -> Tools.convertMap(errorData, UploadBytedanceEventDTO.class)).collect(Collectors.toList()); // List<UploadBytedanceEventDTO> collect = task.getErrorData().stream().map(errorData -> Tools.convertMap(errorData, UploadBytedanceEventDTO.class)).collect(Collectors.toList());
EasyExcelUtil.write(filePath, "sheet1", UploadBytedanceEventDTO.class, collect); EasyExcelUtil.write(filePath, "sheet1", UploadBytedanceEventDTO.class, Collections.emptyList());
return filePath; return filePath;
} }
...@@ -546,15 +550,20 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -546,15 +550,20 @@ public class ToolsetServiceImpl implements ToolsetService {
private void processEventUpdate(List<BytedanceCustomEventUpdateTaskData> taskData, BytedanceCustomEventUpdateTask task, Boolean extraCompute){ private void processEventUpdate(List<BytedanceCustomEventUpdateTaskData> taskData, BytedanceCustomEventUpdateTask task, Boolean extraCompute){
String taskId = task.getId(); String taskId = task.getId();
try { try {
List<BytedanceCustomEventUpdateTask.EventInfo> eventInfos = new ArrayList<>(); Map<String, BytedanceCustomEventUpdateTask.EventInfo> eventInfoMap = new HashMap<>();
Map<String, List<BytedanceCustomEventUpdateTaskData>> map = taskData.stream().collect(Collectors.groupingBy(BytedanceCustomEventUpdateTaskData::getEventName)); Map<String, List<BytedanceCustomEventUpdateTaskData>> map = taskData.stream().collect(Collectors.groupingBy(BytedanceCustomEventUpdateTaskData::getEventName));
// 渠道等级对照表
Map<String, BytedanceCustomChannelLevelInfo> levelInfoMap = bytedanceCustomChannelLevelInfoDao.findList(new Query()).stream()
.collect(Collectors.toMap(BytedanceCustomChannelLevelInfo::getLevel, o -> o, (v1, v2) -> v1));
for (Map.Entry<String, List<BytedanceCustomEventUpdateTaskData>> entry : map.entrySet()) { for (Map.Entry<String, List<BytedanceCustomEventUpdateTaskData>> entry : map.entrySet()) {
String eventName = entry.getKey();
List<BytedanceCustomEventUpdateTaskData> data = entry.getValue(); List<BytedanceCustomEventUpdateTaskData> data = entry.getValue();
BytedanceCustomEventUpdateTask.EventInfo eventInfo = new BytedanceCustomEventUpdateTask.EventInfo(); BytedanceCustomEventUpdateTask.EventInfo eventInfo = new BytedanceCustomEventUpdateTask.EventInfo();
eventInfo.setName(entry.getKey()); eventInfo.setName(eventName);
eventInfo.setDataCount(data.size());
// 计算影响力指数 // 计算影响力指数
eventInfo.setInfluence(computeInf(data)); eventInfo.setInfluence(computeInf(data, levelInfoMap));
eventInfos.add(eventInfo); eventInfoMap.put(eventName, eventInfo);
// 更新渠道匹配处理进度 // 更新渠道匹配处理进度
addProcessSchedule(taskId, data.size()); addProcessSchedule(taskId, data.size());
} }
...@@ -562,20 +571,19 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -562,20 +571,19 @@ public class ToolsetServiceImpl implements ToolsetService {
if (extraCompute) { if (extraCompute) {
// 更新为互动量更新处理状态 // 更新为互动量更新处理状态
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INTERACTION_UPDATE); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INTERACTION_UPDATE);
long count = taskData.stream().filter(data -> Objects.isNull(data.getWechatRead()) && Objects.isNull(data.getWechatReading()) && Objects.isNull(data.getWeiboForward())
&& Objects.isNull(data.getWeiboComment()) && Objects.isNull(data.getWeiboLike())).count();
// 更新互动量更新处理进度 // 更新互动量更新处理进度
resetProcessSchedule(taskId, (int) count); resetProcessSchedule(taskId, taskData.size());
for (BytedanceCustomEventUpdateTask.EventInfo eventInfo : eventInfos) { for (Map.Entry<String, BytedanceCustomEventUpdateTask.EventInfo> entry : eventInfoMap.entrySet()) {
List<BytedanceCustomEventUpdateTaskData> data = map.get(eventInfo.getName()); List<BytedanceCustomEventUpdateTaskData> data = map.get(entry.getKey());
BytedanceCustomEventUpdateTask.EventInfo eventInfo = entry.getValue();
// 计算实时传播力 // 计算实时传播力
eventInfo.setRMI(computeRMI(data, task)); eventInfo.setRMI(computeRMI(data));
// 计算传播影响力 // 计算传播影响力
eventInfo.setFinalInfluence(computeFinalInf(eventInfo.getInfluence(), eventInfo.getRMI())); eventInfo.setFinalInfluence(computeFinalInf(eventInfo.getInfluence(), eventInfo.getRMI()));
} }
updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE); updateStatus(taskId, BytedanceCustomEventUpdateTask.TaskStatus.CALCULATING, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE);
} }
task.setEventInfo(eventInfos); task.setEventInfo(new ArrayList<>(eventInfoMap.values()));
updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH); updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH);
}catch (Exception e){ }catch (Exception e){
log.info("本品字节事件影响力补充计算出错-taskId:{}", taskId, e); log.info("本品字节事件影响力补充计算出错-taskId:{}", taskId, e);
...@@ -622,15 +630,18 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -622,15 +630,18 @@ public class ToolsetServiceImpl implements ToolsetService {
for (SearchHit hit : searchResponse.getHits().getHits()) { for (SearchHit hit : searchResponse.getHits().getHits()) {
BaseMap baseMap = Tools.getBaseFromEsMap(hit.getSourceAsMap()); BaseMap baseMap = Tools.getBaseFromEsMap(hit.getSourceAsMap());
BytedanceCustomEventUpdateTaskData dto = new BytedanceCustomEventUpdateTaskData(); BytedanceCustomEventUpdateTaskData dto = new BytedanceCustomEventUpdateTaskData();
dto.setPlatform(baseMap.getPlatform()); dto.setPlatformType(baseMap.getPlatform());
dto.setChannel(baseMap.getSource()); dto.setChannel(baseMap.getSource());
data.add(dto); data.add(dto);
} }
} }
updateStatus(taskId, null, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE); updateStatus(taskId, null, BytedanceCustomEventUpdateTask.ProcessStatus.INFLUENCE_COMPUTE);
resetProcessSchedule(taskId, data.size()); resetProcessSchedule(taskId, data.size());
// 渠道等级对照表
Map<String, BytedanceCustomChannelLevelInfo> levelInfoMap = bytedanceCustomChannelLevelInfoDao.findList(new Query()).stream()
.collect(Collectors.toMap(BytedanceCustomChannelLevelInfo::getLevel, o -> o, (v1, v2) -> v1));
// 计算影响力指数 // 计算影响力指数
task.setContendInfluence(computeInf(data)); task.setContendInfluence(computeInf(data, levelInfoMap));
addProcessSchedule(taskId, data.size()); addProcessSchedule(taskId, data.size());
updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH); updateStatus(task, BytedanceCustomEventUpdateTask.TaskStatus.FINISH, BytedanceCustomEventUpdateTask.ProcessStatus.FINISH);
}catch (Exception e){ }catch (Exception e){
...@@ -698,49 +709,45 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -698,49 +709,45 @@ public class ToolsetServiceImpl implements ToolsetService {
/** /**
* 计算影响力指数(Inf) * 计算影响力指数(Inf)
* @param data * @param datas
* @return * @return
*/ */
private double computeInf(List<BytedanceCustomEventUpdateTaskData> data){ private Double computeInf(List<BytedanceCustomEventUpdateTaskData> datas, Map<String, BytedanceCustomChannelLevelInfo> levelInfoMap){
double sumH = 0; Map<String, Double> levelSumH = new HashMap<>(5);
if (CollectionUtils.isEmpty(data)){ if (CollectionUtils.isEmpty(datas)){
return sumH; return 0d;
} }
for (BytedanceCustomEventUpdateTaskData datum : data) { for (BytedanceCustomEventUpdateTaskData data : datas) {
// 网媒、平媒、外媒和自媒体四个平台类型的渠道,匹配重要渠道表,如果匹配成功,则按照“网媒”算影响力值。 // 匹配渠道影响力,微博、微信以外的平台一律按照”网媒“处理
if (COMMON_MEDIA.contains(datum.getPlatform()) && bytedanceCustomChannelDao.exist(new Query(Criteria.where("channel").is(datum.getChannel())))){ BytedanceCustomChannelInfluence channelInfluence = GlobalPojo.BYTEDANCE_CHANNEL_INFLUENCE
datum.setPlatform("网媒"); .get(concat(Objects.equals("微博", data.getPlatformType()) && Objects.equals("微信", data.getPlatformType())
} ? data.getPlatformType() : "网媒", data.getChannel()));
// 匹配表中的渠道影响力 // 1.分别将等级为S,A,B,C的渠道各自加和
Query query = new Query();
query.addCriteria(Criteria.where("platform").is(datum.getPlatform()));
query.addCriteria(Criteria.where("channel").is(datum.getChannel()));
BytedanceCustomChannelInfluence channelInfluence = bytedanceCustomChannelInfluenceDao.findOne(query);
if (Objects.nonNull(channelInfluence)){ if (Objects.nonNull(channelInfluence)){
sumH = BigDecimal.valueOf(sumH).add(BigDecimal.valueOf(channelInfluence.getInfluence())).doubleValue(); levelSumH.compute(channelInfluence.getLevel(), (k, v) -> Objects.isNull(v)
}else { ? channelInfluence.getInfluence()
// 如果表中没有匹配,则取事见渠道库中的值 : BigDecimal.valueOf(v).add(BigDecimal.valueOf(channelInfluence.getInfluence())).doubleValue());
ResponseEntity<String> response = restTemplate.getForEntity(channelInfluenceUrl, String.class, datum.getPlatform(), datum.getChannel()); }else { // 如果表中没有匹配,则,影响力取1,渠道等级取D
JSONObject jsonObject = JSON.parseObject(response.getBody()); levelSumH.compute("D", (k, v) -> Objects.isNull(v) ? 1d : BigDecimal.valueOf(v).add(BigDecimal.valueOf(1)).doubleValue());
if (!jsonObject.getBoolean("status") && Objects.nonNull(jsonObject.getBigDecimal("data")) && -1 != jsonObject.getBigDecimal("data").doubleValue()){
sumH = BigDecimal.valueOf(sumH).add(jsonObject.getBigDecimal("data")).doubleValue();
}else { // 库中没有的结果取值为:1
sumH = BigDecimal.valueOf(sumH).add(BigDecimal.valueOf(1)).doubleValue();
}
} }
} }
BigDecimal lnSumH = BigDecimal.valueOf(Math.log(sumH)); // 2.分类各自的影响力计算
BigDecimal lnSumMaxAll = BigDecimal.valueOf(Math.log(SUM_MAX_ALL)); double result = 0;
BigDecimal partResult = lnSumH.divide(lnSumMaxAll, 9, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); BigDecimal bigDecimal100 = BigDecimal.valueOf(100);
// 若sumH<2000,inf=ln(sumH)/ln(sumMaxAll)*100*0.5+sumH/4268*100*0.5 for (Map.Entry<String, Double> entry : levelSumH.entrySet()) {
if (sumH < 2000){ BytedanceCustomChannelLevelInfo levelInfo = levelInfoMap.get(entry.getKey());
BigDecimal denominator = BigDecimal.valueOf(4268).multiply(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(0.5)); Double sumH = entry.getValue();
BigDecimal leftResult = partResult.multiply(BigDecimal.valueOf(0.5)); BigDecimal INF;
BigDecimal rightResult = BigDecimal.valueOf(sumH).divide(denominator, 9, RoundingMode.HALF_UP); // A.当相应等级的SUMH大于等于临界值 INF=LN(H)/LN(Hmax)*100
return leftResult.add(rightResult).setScale(7, RoundingMode.HALF_UP).doubleValue(); if (sumH >= levelInfo.getThreshold()){
INF = BigDecimal.valueOf(Math.log(sumH)).divide(BigDecimal.valueOf(Math.log(levelInfo.getHMax())), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
}else { // B.当相应等级的SUMH小于临界值 INF=sumH/系数*100
INF = BigDecimal.valueOf(sumH).divide(BigDecimal.valueOf(levelInfo.getCoefficient()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
}
// 3.各自乘以权重 结果相加
result = INF.multiply(BigDecimal.valueOf(levelInfo.getWeight())).add(BigDecimal.valueOf(result)).doubleValue();
} }
// 否则,inf=ln(sumH)/ln(sumMaxAll)*100 return BigDecimal.valueOf(result).setScale(1, RoundingMode.HALF_UP).doubleValue();
return partResult.setScale(7, RoundingMode.HALF_UP).doubleValue();
} }
/** /**
...@@ -748,124 +755,112 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -748,124 +755,112 @@ public class ToolsetServiceImpl implements ToolsetService {
* @param data * @param data
* @return * @return
*/ */
private double computeRMI(List<BytedanceCustomEventUpdateTaskData> data, BytedanceCustomEventUpdateTask task){ private Double computeRMI(List<BytedanceCustomEventUpdateTaskData> data){
List<BytedanceCustomEventUpdateTaskData> willBeInteractionUpdateData = new ArrayList<>(); // 1、初始值
int weiboForward = 0; // 微信文章数
int weiboComment = 0; int wechatArticle = (int) data.stream().filter(article -> Objects.equals("微信", article.getPlatformType())).count();
int weiboLike = 0; // 微信阅读数
int wechatRead = 0; int wechatRead = 0;
// 微信在看数
int wechatReading = 0; int wechatReading = 0;
// 微博消息数
int weiboArticle = (int) data.stream().filter(article -> Objects.equals("微博", article.getPlatform())).count(); // 微博消息数(文章数)
// 微信文章数 int weiboArticle = (int) data.stream().filter(article -> Objects.equals("微博", article.getPlatformType())).count();
int wechatArticle = (int) data.stream().filter(article -> Objects.equals("微信", article.getPlatform())).count(); // 微博互动数=转发+评论+点赞
// 网媒文章数 int weiboInteraction = 0;
int normalMediaArticle = (int) data.stream().filter(article -> Objects.equals("网媒", article.getPlatform())).count();
// 其他平台文章数 // 头条文章数
int otherPlatformArticle = (int) data.stream().filter(article -> !Objects.equals("网媒", article.getPlatform()) int toutiaoArticle = (int) data.stream().filter(article -> Objects.equals("今日头条", article.getPlatformType())).count();
&& !Objects.equals("微博", article.getPlatform()) && !Objects.equals("微信", article.getPlatform())).count(); // 头条阅读数
int toutiaoRead = 0;
// 头条互动数=点赞+pc评论
int toutiaoInteraction = 0;
// 网媒文章数=外媒+平媒+网媒+自媒体
int normalMediaArticle = (int) data.stream().filter(article -> Objects.equals("网媒", article.getPlatformType())
|| Objects.equals("外媒", article.getPlatformType()) || Objects.equals("平媒", article.getPlatformType())
|| Objects.equals("自媒体", article.getPlatformType())).count();
// 其他平台文章数 除以上平台以外
int otherPlatformArticle = (int) data.stream().filter(article -> !Objects.equals("网媒", article.getPlatformType())
&& !Objects.equals("微博", article.getPlatformType()) && !Objects.equals("微信", article.getPlatformType())
&& !Objects.equals("今日头条", article.getPlatformType()) && !Objects.equals("外媒", article.getPlatformType())
&& !Objects.equals("平媒", article.getPlatformType()) && !Objects.equals("自媒体", article.getPlatformType())).count();
// 2、统计数值
for (BytedanceCustomEventUpdateTaskData datum : data) { for (BytedanceCustomEventUpdateTaskData datum : data) {
// 选填字段全部未填,后续走互动量更新 if (Objects.equals("微信", datum.getPlatformType())) {
if (Objects.isNull(datum.getWechatRead()) && Objects.isNull(datum.getWechatReading()) && Objects.isNull(datum.getWeiboForward()) wechatRead = wechatRead + datum.getRead();
&& Objects.isNull(datum.getWeiboComment()) && Objects.isNull(datum.getWeiboLike())){ wechatReading = wechatReading + datum.getReading();
willBeInteractionUpdateData.add(datum);
continue;
} }
weiboForward = weiboForward + datum.getWeiboForward(); if (Objects.equals("微博", datum.getPlatformType())) {
weiboComment = weiboComment + datum.getWeiboComment(); // 微博互动数=转发+评论+点赞
weiboLike = weiboLike + datum.getWeiboLike(); weiboInteraction = weiboInteraction + datum.getForward() + datum.getComment() + datum.getLike();
wechatRead = wechatRead + datum.getWechatRead(); }
wechatReading = wechatReading + datum.getWechatReading(); if (Objects.equals("今日头条", datum.getPlatformType())) {
} // 头条阅读数中不包含微头条的数值
data.removeAll(willBeInteractionUpdateData); if (!Objects.equals("微头条", datum.getPlatform())){
// 选填字段全部未填的链接互动量更新结果 toutiaoRead = toutiaoRead + datum.getRead();
try {
List<String> successUrl = new ArrayList<>();
List<String> urls = willBeInteractionUpdateData.stream().map(BytedanceCustomEventUpdateTaskData::getUrl).collect(Collectors.toList());
Map<String, BytedanceCustomEventUpdateTaskData> urlMap = willBeInteractionUpdateData.stream().collect(Collectors.toMap(BytedanceCustomEventUpdateTaskData::getUrl, o -> o, (v1, v2) -> v1));
// 互动量更新
List<JSONObject> jsonObjects = urlInteractionUpdate(urls, task.getId());
for (JSONObject jsonObject : jsonObjects) {
if (200 == jsonObject.getInteger("code")) {
// 成功的链接
String url = jsonObject.getString("url");
successUrl.add(url);
// 转发数
int repostCount = Objects.isNull(jsonObject.getInteger("repostCount")) ? 0 : jsonObject.getIntValue("repostCount");
urlMap.get(url).setWeiboForward(repostCount);
// 评论数
int commentCount = Objects.isNull(jsonObject.getInteger("commentCount")) ? 0 : jsonObject.getIntValue("commentCount");
urlMap.get(url).setWeiboComment(commentCount);
// 点赞数
int likeCount = Objects.isNull(jsonObject.getInteger("likeCount")) ? 0 : jsonObject.getIntValue("likeCount");
urlMap.get(url).setWeiboLike(likeCount);
// 阅读数
int readCount = Objects.isNull(jsonObject.getInteger("readCount")) ? 0 : jsonObject.getIntValue("readCount");
urlMap.get(url).setWechatRead(readCount);
// 在看数,实际使用的是返回结果中的分享数
int shareCount = Objects.isNull(jsonObject.getInteger("shareCount")) ? 0 : jsonObject.getIntValue("shareCount");
urlMap.get(url).setWechatReading(shareCount);
// 累加
weiboForward = weiboForward + repostCount;
weiboComment = weiboComment + commentCount;
weiboLike = weiboLike + likeCount;
wechatRead = wechatRead + readCount;
wechatReading = wechatReading + shareCount;
} }
// 头条互动数=点赞+pc评论
toutiaoInteraction = toutiaoInteraction + datum.getLike() + datum.getComment();
} }
// 报错数据 }
urls.removeAll(successUrl); // 去除成功数据,剩余即为失败数据 // 3、根据公式计算结果
List<BytedanceCustomEventUpdateTaskData> errorData = urls.stream().map(urlMap::get).collect(Collectors.toList());
List<BytedanceCustomEventUpdateTaskData> error = task.getErrorData();
error.addAll(errorData);
task.setErrorData(error);
// 互动量更新成功数据
List<BytedanceCustomEventUpdateTaskData> successData = successUrl.stream().map(urlMap::get).collect(Collectors.toList());
data.addAll(successData);
}catch (Exception e){
log.info("字节事件影响力更新-互动量更新出错-id:{}", task.getId(), e);
List<BytedanceCustomEventUpdateTaskData> errorData = task.getErrorData();
errorData.addAll(willBeInteractionUpdateData);
task.setErrorData(errorData);
}
// 存储数据以用于补充计算
bytedanceCustomEventUpdateTaskDataDao.deleteOneByQuery(new Query(Criteria.where("taskId").is(task.getId())));
bytedanceCustomEventUpdateTaskDataDao.insertMany(data);
// 平台指标权重,常量 // 平台指标权重,常量
Map<String, BytedanceCustomPlatformWeight> weightMap = bytedanceCustomPlatformWeightDao.findList(new Query()) Map<String, BytedanceCustomPlatformWeight> weightMap = bytedanceCustomPlatformWeightDao.findList(new Query())
.stream() .stream()
.collect(Collectors.toMap(BytedanceCustomPlatformWeight::getType, o -> o)); .collect(Collectors.toMap(BytedanceCustomPlatformWeight::getType, o -> o));
BytedanceCustomPlatformWeight normalMediaArticleWeight = weightMap.get("网媒文章数"); BytedanceCustomPlatformWeight normalMediaArticleWeight = weightMap.get("网媒文章数");
BytedanceCustomPlatformWeight otherPlatformArticleWeight = weightMap.get("其他平台文章数"); BytedanceCustomPlatformWeight otherPlatformArticleWeight = weightMap.get("其他平台文章数");
BytedanceCustomPlatformWeight wechatArticleWeight = weightMap.get("微信文章数"); BytedanceCustomPlatformWeight wechatArticleWeight = weightMap.get("微信文章数");
BytedanceCustomPlatformWeight wechatReadWeight = weightMap.get("微信阅读数"); BytedanceCustomPlatformWeight wechatReadWeight = weightMap.get("微信阅读数");
BytedanceCustomPlatformWeight wechatReadingWeight = weightMap.get("微信在看数"); BytedanceCustomPlatformWeight wechatReadingWeight = weightMap.get("微信在看数");
BytedanceCustomPlatformWeight weiboArticleWeight = weightMap.get("微博消息数"); BytedanceCustomPlatformWeight weiboArticleWeight = weightMap.get("微博消息数");
BytedanceCustomPlatformWeight weiboForwardWeight = weightMap.get("微博转发数"); BytedanceCustomPlatformWeight weiboInteractionWeight = weightMap.get("微博互动数");
BytedanceCustomPlatformWeight weiboCommentWeight = weightMap.get("微博评论数");
BytedanceCustomPlatformWeight weiboLikeWeight = weightMap.get("微博点赞数"); BytedanceCustomPlatformWeight toutiaoArticleWeight = weightMap.get("头条文章数");
BytedanceCustomPlatformWeight toutiaoReadWeight = weightMap.get("头条阅读数");
BytedanceCustomPlatformWeight toutiaoInteractionWeight = weightMap.get("头条互动数");
// 标准值计算 // 标准值计算
BigDecimal bigDecimal100 = BigDecimal.valueOf(100); BigDecimal bigDecimal100 = BigDecimal.valueOf(100);
BigDecimal NM = BigDecimal.valueOf(normalMediaArticle).divide(BigDecimal.valueOf(normalMediaArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal OP = BigDecimal.valueOf(otherPlatformArticle).divide(BigDecimal.valueOf(otherPlatformArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 网媒文章数:NM标= NM/NM常*100.0
BigDecimal WC = BigDecimal.valueOf(wechatArticle).divide(BigDecimal.valueOf(wechatArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); BigDecimal NM = BigDecimal.valueOf(normalMediaArticle).divide(BigDecimal.valueOf(normalMediaArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WCR = BigDecimal.valueOf(Math.log(wechatRead + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 其他平台文章数:OM标= OM/OM常*100.0
BigDecimal WCL = BigDecimal.valueOf(Math.log(wechatReading + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadingWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); BigDecimal OM = BigDecimal.valueOf(otherPlatformArticle).divide(BigDecimal.valueOf(otherPlatformArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WB = BigDecimal.valueOf(weiboArticle).divide(BigDecimal.valueOf(weiboArticleWeight.getConstant()), 9, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WBF = BigDecimal.valueOf(Math.log(weiboForward + 1)).divide(BigDecimal.valueOf(Math.log(weiboForwardWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 微信文章数:WC标= WC/WC常*100.0
BigDecimal WBC = BigDecimal.valueOf(Math.log(weiboComment + 1)).divide(BigDecimal.valueOf(Math.log(weiboCommentWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); BigDecimal WC = BigDecimal.valueOf(wechatArticle).divide(BigDecimal.valueOf(wechatArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
BigDecimal WBL = BigDecimal.valueOf(Math.log(weiboLike + 1)).divide(BigDecimal.valueOf(Math.log(weiboLikeWeight.getConstant() + 1)), 9, RoundingMode.HALF_UP).multiply(bigDecimal100); // 微信阅读数:WCR标= ln(WCR+1)/ln(WCR常+1)*100.0
// 标准值与权重计算得RMI BigDecimal WCR = BigDecimal.valueOf(Math.log(wechatRead + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 微信在看数:WCL标= ln(WCL+1)/ln(WCL常+1)*100.0
BigDecimal WCL = BigDecimal.valueOf(Math.log(wechatReading + 1)).divide(BigDecimal.valueOf(Math.log(wechatReadingWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 微博消息数:WB标= ln(WB+1)/ln(WB常+1)*100.0
BigDecimal WB = BigDecimal.valueOf(Math.log(weiboArticle + 1)).divide(BigDecimal.valueOf(Math.log(weiboArticleWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 微博互动数:WBI标= ln(WBI+1)/ln(WBI常+1)*100.0
BigDecimal WBI = BigDecimal.valueOf(Math.log(weiboInteraction + 1)).divide(BigDecimal.valueOf(Math.log(weiboInteractionWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 头条文章数:T标= T/T常*100.0
BigDecimal T = BigDecimal.valueOf(toutiaoArticle).divide(BigDecimal.valueOf(toutiaoArticleWeight.getConstant()), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 头条阅读数:TR标=ln(TR+1)/ln(TR常+1)*100.0
BigDecimal TR = BigDecimal.valueOf(Math.log(toutiaoRead + 1)).divide(BigDecimal.valueOf(Math.log(toutiaoReadWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 头条互动数:TI标= ln(TI+1)/ln(TI常+1)*100.0
BigDecimal TI = BigDecimal.valueOf(Math.log(toutiaoInteraction + 1)).divide(BigDecimal.valueOf(Math.log(toutiaoInteractionWeight.getConstant() + 1)), 20, RoundingMode.HALF_UP).multiply(bigDecimal100);
// 标准值与权重计算取和得RMI
return NM.multiply(BigDecimal.valueOf(normalMediaArticleWeight.getWeight())) return NM.multiply(BigDecimal.valueOf(normalMediaArticleWeight.getWeight()))
.add(OP.multiply(BigDecimal.valueOf(otherPlatformArticleWeight.getWeight()))) .add(OM.multiply(BigDecimal.valueOf(otherPlatformArticleWeight.getWeight())))
.add(WC.multiply(BigDecimal.valueOf(wechatArticleWeight.getWeight()))) .add(WC.multiply(BigDecimal.valueOf(wechatArticleWeight.getWeight())))
.add(WCR.multiply(BigDecimal.valueOf(wechatReadWeight.getWeight()))) .add(WCR.multiply(BigDecimal.valueOf(wechatReadWeight.getWeight())))
.add(WCL.multiply(BigDecimal.valueOf(wechatReadingWeight.getWeight()))) .add(WCL.multiply(BigDecimal.valueOf(wechatReadingWeight.getWeight())))
.add(WB.multiply(BigDecimal.valueOf(weiboArticleWeight.getWeight()))) .add(WB.multiply(BigDecimal.valueOf(weiboArticleWeight.getWeight())))
.add(WBF.multiply(BigDecimal.valueOf(weiboForwardWeight.getWeight()))) .add(WBI.multiply(BigDecimal.valueOf(weiboInteractionWeight.getWeight())))
.add(WBC.multiply(BigDecimal.valueOf(weiboCommentWeight.getWeight()))) .add(T.multiply(BigDecimal.valueOf(toutiaoArticleWeight.getWeight())))
.add(WBL.multiply(BigDecimal.valueOf(weiboLikeWeight.getWeight()))) .add(TR.multiply(BigDecimal.valueOf(toutiaoReadWeight.getWeight())))
.setScale(7, RoundingMode.HALF_UP) .add(TI.multiply(BigDecimal.valueOf(toutiaoInteractionWeight.getWeight())))
.setScale(1, RoundingMode.HALF_UP)
.doubleValue(); .doubleValue();
} }
...@@ -876,7 +871,7 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -876,7 +871,7 @@ public class ToolsetServiceImpl implements ToolsetService {
* @return * @return
*/ */
private double computeFinalInf(double inf, double RMI){ private double computeFinalInf(double inf, double RMI){
return BigDecimal.valueOf(inf).add(BigDecimal.valueOf(RMI)).divide(BigDecimal.valueOf(2), 7, RoundingMode.HALF_UP).doubleValue(); return BigDecimal.valueOf(inf).add(BigDecimal.valueOf(RMI)).divide(BigDecimal.valueOf(2), 1, RoundingMode.HALF_UP).doubleValue();
} }
/** /**
......
...@@ -59,6 +59,10 @@ public class RedisUtil { ...@@ -59,6 +59,10 @@ public class RedisUtil {
return RedisKeyPrefix.INDEX_SPREAD + Tools.concat(projectId, startTime, endTime); return RedisKeyPrefix.INDEX_SPREAD + Tools.concat(projectId, startTime, endTime);
} }
public static String getIndexEmotionKey(String projectId, Long startTime, Long endTime) {
return RedisKeyPrefix.INDEX_EMOTION + Tools.concat(projectId, startTime, endTime);
}
public static String getChannelRecordList(String projectId, Long startTime, Long endTime, String platform, int emotion) { public static String getChannelRecordList(String projectId, Long startTime, Long endTime, String platform, int emotion) {
return RedisKeyPrefix.CHANNEL_RECORD_LIST + Tools.concat(projectId, startTime, endTime, platform, emotion); return RedisKeyPrefix.CHANNEL_RECORD_LIST + Tools.concat(projectId, startTime, endTime, platform, emotion);
} }
......
...@@ -52,7 +52,7 @@ import java.util.stream.Stream; ...@@ -52,7 +52,7 @@ import java.util.stream.Stream;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import static com.zhiwei.brandkbs2.common.GenericAttribute.ES_MARK_CACHE_MAPS; import static com.zhiwei.brandkbs2.common.GenericAttribute.*;
import static com.zhiwei.brandkbs2.config.Constant.*; import static com.zhiwei.brandkbs2.config.Constant.*;
import static java.util.Objects.nonNull; import static java.util.Objects.nonNull;
...@@ -75,6 +75,16 @@ public class Tools { ...@@ -75,6 +75,16 @@ public class Tools {
private static final DozerBeanMapper DOZER_BEAN_MAPPER = new DozerBeanMapper(); private static final DozerBeanMapper DOZER_BEAN_MAPPER = new DozerBeanMapper();
/**
* 须过滤的标题
*/
public static final List<String> FILTER_TITLE = Arrays.asList("Notitle", "分享一篇文章", "分享一篇文章。", "暂无标题");
/**
* 须过滤的渠道
*/
public static final List<String> FILTER_SOURCE = Arrays.asList("匿名");
/** /**
* 上传文件 * 上传文件
...@@ -1345,4 +1355,22 @@ public class Tools { ...@@ -1345,4 +1355,22 @@ public class Tools {
} }
return Arrays.stream(str.split("[\\u007c]+")).filter(StringUtils::isNotBlank).collect(Collectors.joining("|")); return Arrays.stream(str.split("[\\u007c]+")).filter(StringUtils::isNotBlank).collect(Collectors.joining("|"));
} }
/**
* 过滤 “分享一篇文章”,”暂无标题“,”Notitle“ 的无用标题
* @param title
* @return
*/
public static Boolean filterUselessTitle(String title){
return FILTER_TITLE.contains(title);
}
/**
* 过滤 “匿名“ 的无用渠道
* @param source
* @return
*/
public static Boolean filterUselessSource(String source){
return FILTER_SOURCE.contains(source);
}
} }
\ No newline at end of file
...@@ -2,9 +2,9 @@ application.name = brandkbs2 ...@@ -2,9 +2,9 @@ application.name = brandkbs2
server.port=8888 server.port=8888
spring.flyway.encoding=UTF-8 spring.flyway.encoding=UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E #\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-file-size=100MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E #\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size=20MB spring.servlet.multipart.max-request-size=200MB
server.servlet.context-path=/brandkbs server.servlet.context-path=/brandkbs
#jwt #jwt
jwt.key=Token jwt.key=Token
......
...@@ -2,9 +2,9 @@ application.name = brandkbs2 ...@@ -2,9 +2,9 @@ application.name = brandkbs2
server.port=8888 server.port=8888
spring.flyway.encoding=UTF-8 spring.flyway.encoding=UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E #\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-file-size=100MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E #\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size=20MB spring.servlet.multipart.max-request-size=200MB
server.servlet.context-path=/brandkbs server.servlet.context-path=/brandkbs
#jwt #jwt
jwt.key=Token jwt.key=Token
......
...@@ -2,9 +2,9 @@ application.name = brandkbs2 ...@@ -2,9 +2,9 @@ application.name = brandkbs2
server.port=8888 server.port=8888
spring.flyway.encoding=UTF-8 spring.flyway.encoding=UTF-8
#\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E #\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-file-size=100MB
#\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E #\u603B\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8BBE\u7F6E
spring.servlet.multipart.max-request-size=20MB spring.servlet.multipart.max-request-size=200MB
server.servlet.context-path=/brandkbs server.servlet.context-path=/brandkbs
#jwt #jwt
jwt.key=Token jwt.key=Token
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment