Commit d3b75160 by 陈健智

2022/8/16 14:06 竞品库,查热点,查危机,全网事件库-查事件

parent 790d1431
...@@ -60,10 +60,24 @@ public class RedisKeyPrefix { ...@@ -60,10 +60,24 @@ public class RedisKeyPrefix {
*/ */
private static final String EVENT_ANALYZE_PROGRESS = "BRANDKBS:EVENT:ANALYZE:PROGRESS:"; private static final String EVENT_ANALYZE_PROGRESS = "BRANDKBS:EVENT:ANALYZE:PROGRESS:";
/**
* 竞品库-获取竞品对比舆情解读数据(PC
*/
public static final String INDEX_COMPARE_SUMMARY_PC = "BRANDKBS:CONTEND:COMPARESUMMARY:PC:";
/**
* 竞品库-获取竞品对比传播分析数据
*/
public static final String INDEX_COMPARE_ANALYZE = "BRANDKBS:CONTEND:COMPAREANALYZE:";
public static String eventAnalysisProgress(String eventId, String projectId) { public static String eventAnalysisProgress(String eventId, String projectId) {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.EVENT_ANALYZE_PROGRESS, projectId, eventId); return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.EVENT_ANALYZE_PROGRESS, projectId, eventId);
} }
public static String eventAnalysisProgress(String eventId) {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.EVENT_ANALYZE_PROGRESS, UserThreadLocal.getProjectId(), eventId);
}
public static String yuqingProgressKey(String linkedGroupId) { public static String yuqingProgressKey(String linkedGroupId) {
return yuqingProgressKey(UserThreadLocal.getProjectId(), linkedGroupId); return yuqingProgressKey(UserThreadLocal.getProjectId(), linkedGroupId);
} }
......
...@@ -51,4 +51,9 @@ public class Constant { ...@@ -51,4 +51,9 @@ public class Constant {
return -1L; return -1L;
} }
/**
* 主品牌默认竞品ID
*/
public static final String PRIMARY_CONTENDID = "0";
} }
package com.zhiwei.brandkbs2.controller.app;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import com.zhiwei.brandkbs2.service.MarkDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.text.ParseException;
import java.util.List;
/**
* @ClassName AppContendController
* @Description 提供前台竞品库相关信息展示
* @author cjz
* @date 2022-08-09 10:22
*/
@RestController
@RequestMapping("/app/contend")
@Api(tags = "前台竞品库展示接口",description = "提供前台竞品库相关信息展示")
@Auth(role = RoleEnum.CUSTOMER)
public class AppContendController extends BaseController {
@Resource(name = "markDataServiceImpl")
MarkDataService markDataService;
@ApiOperation("竞品库-竞品舆情-搜索条件")
@GetMapping("/searchCriteria")
public ResponseResult getContendSearchCriteria(@RequestParam(required = false) String linkedGroupId) {
return ResponseResult.success(markDataService.getContendSearchCriteria(linkedGroupId));
}
@ApiOperation("竞品库-竞品舆情-搜索结果列表")
@GetMapping("/list")
public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO) throws IOException {
return ResponseResult.success(markDataService.getContendSearchList(markSearchDTO));
}
@ApiOperation("竞品库-竞品分析-舆情总结页面")
@GetMapping("/summary")
public ResponseResult getSummary(@RequestBody MarkSearchDTO markSearchDTO) throws IOException {
return ResponseResult.success(markDataService.getContendSummary(markSearchDTO, true));
}
@ApiOperation("竞品库-竞品对比-传播分析页面")
@GetMapping("/spread/analyze")
public ResponseResult getSpreadAnalyze(@RequestBody MarkSearchDTO markSearchDTO) throws IOException {
return ResponseResult.success(markDataService.getContendSpreadAnalyze(markSearchDTO, 5, true));
}
}
...@@ -26,8 +26,6 @@ import org.springframework.web.client.RestTemplate; ...@@ -26,8 +26,6 @@ import org.springframework.web.client.RestTemplate;
@Api(tags = "前台危机展示接口",description = "提供前台危机相关信息展示") @Api(tags = "前台危机展示接口",description = "提供前台危机相关信息展示")
@Auth(role = RoleEnum.CUSTOMER) @Auth(role = RoleEnum.CUSTOMER)
public class AppCrisisController extends BaseController { public class AppCrisisController extends BaseController {
@Value("${crisis.search.url}")
private String crisisSearchUrl;
@Value("${crisis.searchTags.url}") @Value("${crisis.searchTags.url}")
private String crisisTagsUrl; private String crisisTagsUrl;
...@@ -47,16 +45,6 @@ public class AppCrisisController extends BaseController { ...@@ -47,16 +45,6 @@ public class AppCrisisController extends BaseController {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@ApiOperation("危机库-查危机")
@GetMapping("/crisisSearch")
public ResponseResult crisisSearch(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "pageSize",defaultValue = "3") Integer pageSize,
@RequestParam("keyword") String keyword){
ResponseEntity<String> responseEntity = restTemplate.getForEntity(crisisSearchUrl, String.class, page, pageSize, keyword);
Object data = JSON.parseObject(responseEntity.getBody()).get("data");
return ResponseResult.success(data);
}
@ApiOperation("危机库-通过标签查危机") @ApiOperation("危机库-通过标签查危机")
@GetMapping("/crisisTags") @GetMapping("/crisisTags")
public ResponseResult crisisTags(@RequestParam(value = "page",defaultValue = "1") Integer page, public ResponseResult crisisTags(@RequestParam(value = "page",defaultValue = "1") Integer page,
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.RedisKeyPrefix; import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.controller.BaseController; import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.RoleEnum; import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
...@@ -48,9 +49,6 @@ public class AppHotController extends BaseController { ...@@ -48,9 +49,6 @@ public class AppHotController extends BaseController {
@Value("${trends.longTimeInListSearchByInner.url}") @Value("${trends.longTimeInListSearchByInner.url}")
private String trendsListUrl; private String trendsListUrl;
@Value("${trends.findHotSearchESDataInTimeByInner.url}")
private String trendsSearchUrl;
@Value("${trends.longTimeInListSearch.url}") @Value("${trends.longTimeInListSearch.url}")
private String longTimeInListSearchUrl; private String longTimeInListSearchUrl;
...@@ -74,7 +72,7 @@ public class AppHotController extends BaseController { ...@@ -74,7 +72,7 @@ public class AppHotController extends BaseController {
* douyin 抖音 * douyin 抖音
* bilibili-ranking B站 * bilibili-ranking B站
*/ */
@ApiOperation("热点库") @ApiOperation("热点库-列表")
@GetMapping("/getHotList") @GetMapping("/getHotList")
public ResponseResult getHotList(@RequestParam(value = "sortType",defaultValue = "realTime") String sortType, public ResponseResult getHotList(@RequestParam(value = "sortType",defaultValue = "realTime") String sortType,
@RequestParam(value = "type",defaultValue = "weibo") String type){ @RequestParam(value = "type",defaultValue = "weibo") String type){
...@@ -96,21 +94,6 @@ public class AppHotController extends BaseController { ...@@ -96,21 +94,6 @@ public class AppHotController extends BaseController {
} }
} }
@ApiOperation("热点库-查热点")
@GetMapping("/searchHotList")
public ResponseResult searchHotList(@RequestParam(value = "pageSize",defaultValue ="10") Integer limit,
@RequestParam(value = "page",defaultValue ="1") Integer page,
@RequestParam(value = "type",defaultValue = "weibo") String type,
@RequestParam(value = "word") String word){
ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplate.getForEntity(trendsSearchUrl, JSONObject.class, limit, page, type, word);
JSONObject body = jsonObjectResponseEntity.getBody();
if(Objects.nonNull(body)){
return ResponseResult.success(body);
}else{
return ResponseResult.failure("响应超时");
}
}
@ApiOperation("热点库-热点榜单") @ApiOperation("热点库-热点榜单")
@GetMapping("/hot") @GetMapping("/hot")
public ResponseResult hot(){ public ResponseResult hot(){
...@@ -142,14 +125,14 @@ public class AppHotController extends BaseController { ...@@ -142,14 +125,14 @@ public class AppHotController extends BaseController {
Date startDate = DateUtils.addHours(endDate, -24); Date startDate = DateUtils.addHours(endDate, -24);
List<Map.Entry<String, Integer>> markTopTitleList = List<Map.Entry<String, Integer>> markTopTitleList =
markDataService.getMarkTopTitle(startDate.getTime(), endDate.getTime(), null, projectId, linkedGroupId,"0", size); markDataService.getMarkTopTitle(startDate.getTime(), endDate.getTime(), null, projectId, linkedGroupId, Constant.PRIMARY_CONTENDID, size);
List<JSONObject> resultList = markTopTitleList.stream().map(map -> { List<JSONObject> resultList = markTopTitleList.stream().map(map -> {
JSONObject resultJsonObject = new JSONObject(); JSONObject resultJsonObject = new JSONObject();
resultJsonObject.put("title", map.getKey()); resultJsonObject.put("title", map.getKey());
resultJsonObject.put("num", map.getValue()); resultJsonObject.put("num", map.getValue());
try { try {
BaseMap firstArticle = markDataService.getFirstArticle(startDate.getTime(), endDate.getTime(), map.getKey(), projectId, linkedGroupId); BaseMap firstArticle = markDataService.getFirstArticle(startDate.getTime(), endDate.getTime(), map.getKey(), projectId, linkedGroupId, Constant.PRIMARY_CONTENDID);
resultJsonObject.put("content", firstArticle.getContent()); resultJsonObject.put("content", firstArticle.getContent());
resultJsonObject.put("url", firstArticle.getUrl()); resultJsonObject.put("url", firstArticle.getUrl());
resultJsonObject.put("realSource", firstArticle.getRealSource()); resultJsonObject.put("realSource", firstArticle.getRealSource());
......
package com.zhiwei.brandkbs2.controller.app;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.util.Objects;
/**
* @ClassName AppSearchController
* @Description 提供前台搜索相关功能
* @author cjz
* @date 2022-08-15 16:17
*/
@RestController
@RequestMapping("/app/search")
@Api(tags = "前台搜索相关接口",description = "提供搜索相关功能")
@Auth(role = RoleEnum.CUSTOMER)
public class AppSearchController {
@Autowired
private RestTemplate restTemplate;
@Value("${trends.findHotSearchESDataInTimeByInner.url}")
private String trendsSearchUrl;
@Value("${crisis.search.url}")
private String crisisSearchUrl;
@Value("${ef.search.url}")
private String getEfSearchUrl;
@ApiOperation("搜索-查热点")
@GetMapping("/hot/list")
public ResponseResult searchHotList(@RequestParam(value = "pageSize",defaultValue ="10") Integer limit,
@RequestParam(value = "page",defaultValue ="1") Integer page,
@RequestParam(value = "type",defaultValue = "weibo") String type,
@RequestParam(value = "word") String word){
ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplate.getForEntity(trendsSearchUrl, JSONObject.class, limit, page, type, word);
JSONObject body = jsonObjectResponseEntity.getBody();
if(Objects.nonNull(body)){
return ResponseResult.success(body);
}else{
return ResponseResult.failure("响应超时");
}
}
@ApiOperation("搜索-查危机")
@GetMapping("/crisisSearch")
public ResponseResult crisisSearch(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "pageSize",defaultValue = "3") Integer pageSize,
@RequestParam("keyword") String keyword){
ResponseEntity<String> responseEntity = restTemplate.getForEntity(crisisSearchUrl, String.class, page, pageSize, keyword);
Object data = JSON.parseObject(responseEntity.getBody()).get("data");
return ResponseResult.success(data);
}
@ApiOperation("搜索-全网事件库-查事件")
@GetMapping("/getWholeNetworkEvents")
public ResponseResult getWholeNetworkEvents(@RequestParam("keyword") String keyword,
@RequestParam(value = "page",defaultValue = "1") Integer page){
String name = keyword.trim();
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getEfSearchUrl, String.class, name, page);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
return ResponseResult.success(jsonObject);
}
}
...@@ -8,8 +8,10 @@ import com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO; ...@@ -8,8 +8,10 @@ import com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO; import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
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;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -141,7 +143,7 @@ public interface MarkDataService { ...@@ -141,7 +143,7 @@ public interface MarkDataService {
* @param linkedGroupId 关联组id * @param linkedGroupId 关联组id
* @return 首发稿件 * @return 首发稿件
*/ */
BaseMap getFirstArticle(Long startTime, Long endTime, String aggTitle, String projectId, String linkedGroupId) throws IOException; BaseMap getFirstArticle(Long startTime, Long endTime, String aggTitle, String projectId, String linkedGroupId, String contendId) throws IOException;
/** /**
* 搜索标注数据通过事件 * 搜索标注数据通过事件
...@@ -163,4 +165,36 @@ public interface MarkDataService { ...@@ -163,4 +165,36 @@ public interface MarkDataService {
*/ */
List<JSONObject> searchMarkDataByTime(String projectId, String linkedGroupId, String contendId, Long startTime, Long endTime, String... fetchSource); List<JSONObject> searchMarkDataByTime(String projectId, String linkedGroupId, String contendId, Long startTime, Long endTime, String... fetchSource);
/**
* 竞品库-获取搜索条件
* @param linkedGroupId 关联组Id
* @return 搜索条件
*/
JSONObject getContendSearchCriteria(String linkedGroupId);
/**
* 竞品库-获取搜索结果列表
* @param markSearchDTO 标注数据搜索传输类
* @return 搜索结果列表
*/
PageVO<MarkFlowEntity> getContendSearchList(MarkSearchDTO markSearchDTO) throws IOException;
/**
* 竞品库-获取竞品对比舆情解读数据
*
* @param markSearchDTO 标注数据搜索传输类
* @param cache 是否启用缓存
* @return 竞品对比舆情解读数据
*/
JSONObject getContendSummary(MarkSearchDTO markSearchDTO, boolean cache) throws IOException;
/**
* 竞品库-获取竞品对比传播分析数据
* @param markSearchDTO 标注数据搜索传输类
* @param hotArticleSize 热门稿件数量
* @param cache 是否启用缓存
* @return
*/
JSONObject getContendSpreadAnalyze(MarkSearchDTO markSearchDTO, int hotArticleSize, boolean cache) throws IOException;
} }
...@@ -99,7 +99,7 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -99,7 +99,7 @@ public class CustomEventServiceImpl implements CustomEventService {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
String aggTitle = map.getKey(); String aggTitle = map.getKey();
try { try {
BaseMap firstArticle = markDataService.getFirstArticle(startTime, endTime, aggTitle, projectId, linkedGroupId); BaseMap firstArticle = markDataService.getFirstArticle(startTime, endTime, aggTitle, projectId, linkedGroupId, Constant.PRIMARY_CONTENDID);
result.put("title", firstArticle.getTitle()); result.put("title", firstArticle.getTitle());
result.put("time", firstArticle.getTime()); result.put("time", firstArticle.getTime());
result.put("url", firstArticle.getUrl()); result.put("url", firstArticle.getUrl());
......
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