Commit fddf6786 by shenjunjie

Merge branch 'feature' into 'dev'

Feature

See merge request !22
parents 80d39e08 4e60b856
...@@ -31,7 +31,7 @@ public class RedisKeyPrefix { ...@@ -31,7 +31,7 @@ public class RedisKeyPrefix {
* 自定义事件相关缓存 * 自定义事件相关缓存
*/ */
public static final String CUSTOM_EVENT_LIST = "BRANDKBS:CUSTOM_EVENT:LIST:"; public static final String CUSTOM_EVENT_LIST = "BRANDKBS:CUSTOM_EVENT:LIST:";
public static final String CUSTOM_EVENT_ANALYZE_SHARE = "BRANDKBS:CUSTOM_EVENT:SHARE"; public static final String CUSTOM_EVENT_ANALYZE_SHARE = "BRANDKBS:CUSTOM_EVENT:SHARE:";
public static final String CUSTOM_EVENT_ANALYZE = "BRANDKBS:CUSTOM_EVENT:ANALYZE:"; public static final String CUSTOM_EVENT_ANALYZE = "BRANDKBS:CUSTOM_EVENT:ANALYZE:";
/** /**
...@@ -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";
} }
...@@ -84,9 +84,9 @@ public class TaskPoolConfig { ...@@ -84,9 +84,9 @@ public class TaskPoolConfig {
log.info("start taskServiceExecutor"); log.info("start taskServiceExecutor");
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 配置核心线程数 // 配置核心线程数
executor.setCorePoolSize(8); executor.setCorePoolSize(16);
// 配置最大线程数 // 配置最大线程数
executor.setMaxPoolSize(16); executor.setMaxPoolSize(32);
// 配置线程池中的线程的名称前缀 // 配置线程池中的线程的名称前缀
executor.setThreadNamePrefix("taskServiceExecutor-"); executor.setThreadNamePrefix("taskServiceExecutor-");
// rejection-policy:当pool已经达到max size的时候,如何处理新任务 // rejection-policy:当pool已经达到max size的时候,如何处理新任务
......
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,
......
...@@ -57,14 +57,14 @@ public class AppEventController extends BaseController { ...@@ -57,14 +57,14 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-品牌事件库") @ApiOperation("前台事件库-品牌事件库")
@GetMapping("/list") @GetMapping("/list")
public ResponseResult getEventList(@RequestParam(value = "brandLinkedGroupId", required = false) String linkedGroupId, public ResponseResult getEventList(@RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "emotion", defaultValue = "全部") String emotion, @RequestParam(value = "emotion", defaultValue = "全部") String emotion,
@RequestParam(value = "startTime", required = false) Long startTime, @RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime, @RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "50") int pageSize, @RequestParam(value = "pageSize", defaultValue = "50") int pageSize,
@RequestParam(value = "sorter", required = false) String sorter) { @RequestParam(value = "sorter", required = false) String sorter) {
return ResponseResult.success(eventService.getEventList(linkedGroupId, emotion, startTime, endTime, page, pageSize, sorter)); return ResponseResult.success(eventService.getEventList(contendId, emotion, startTime, endTime, page, pageSize, sorter));
} }
@ApiOperation("前台事件库-事件详情-基础信息") @ApiOperation("前台事件库-事件详情-基础信息")
...@@ -101,7 +101,7 @@ public class AppEventController extends BaseController { ...@@ -101,7 +101,7 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-全网事件库-搜索") @ApiOperation("前台事件库-全网事件库-搜索")
@GetMapping("/getWholeNetworkEvents") @GetMapping("/getWholeNetworkEvents")
public ResponseResult getWholeNetworkEvents(@RequestParam("keyword") String keyword, public ResponseResult getWholeNetworkEvents(@RequestParam("keyword") String keyword,
@RequestParam(value = "page",defaultValue = "1") Integer page){ @RequestParam(value = "page", defaultValue = "1") Integer page) {
String name = keyword.trim(); String name = keyword.trim();
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getEfSearchUrl, String.class, name, page); ResponseEntity<String> responseEntity = restTemplate.getForEntity(getEfSearchUrl, String.class, name, page);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
...@@ -110,7 +110,7 @@ public class AppEventController extends BaseController { ...@@ -110,7 +110,7 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-全网事件库-搜索条件") @ApiOperation("前台事件库-全网事件库-搜索条件")
@GetMapping("/getWholeNetworkSearchCriteria") @GetMapping("/getWholeNetworkSearchCriteria")
public ResponseResult getWholeNetworkSearchCriteria(){ public ResponseResult getWholeNetworkSearchCriteria() {
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getEfSearchCriteriaUrl, String.class); ResponseEntity<String> responseEntity = restTemplate.getForEntity(getEfSearchCriteriaUrl, String.class);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
return ResponseResult.success(jsonObject); return ResponseResult.success(jsonObject);
...@@ -121,7 +121,7 @@ public class AppEventController extends BaseController { ...@@ -121,7 +121,7 @@ public class AppEventController extends BaseController {
public ResponseResult getWholeNetworkEventsList(@RequestParam(value = "firstType", required = false, defaultValue = "") String firstType, public ResponseResult getWholeNetworkEventsList(@RequestParam(value = "firstType", required = false, defaultValue = "") String firstType,
@RequestParam(value = "start", required = false, defaultValue = "0") long start, @RequestParam(value = "start", required = false, defaultValue = "0") long start,
@RequestParam(value = "end", required = false, defaultValue = "0") long end, @RequestParam(value = "end", required = false, defaultValue = "0") long end,
@RequestParam(value = "page", required = false, defaultValue = "1") int page){ @RequestParam(value = "page", required = false, defaultValue = "1") int page) {
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getFilterNewUrl, String.class, firstType, start, end, page); ResponseEntity<String> responseEntity = restTemplate.getForEntity(getFilterNewUrl, String.class, firstType, start, end, page);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
return ResponseResult.success(jsonObject); return ResponseResult.success(jsonObject);
...@@ -129,7 +129,7 @@ public class AppEventController extends BaseController { ...@@ -129,7 +129,7 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-全网事件库-得到验证码") @ApiOperation("前台事件库-全网事件库-得到验证码")
@GetMapping("/getWholeNetworkCaptcha") @GetMapping("/getWholeNetworkCaptcha")
public ResponseResult getWholeNetworkCaptcha(){ public ResponseResult getWholeNetworkCaptcha() {
ResponseEntity<String> responseEntity = restTemplate.getForEntity(efCaptchaUrl, String.class); ResponseEntity<String> responseEntity = restTemplate.getForEntity(efCaptchaUrl, String.class);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
return ResponseResult.success(jsonObject); return ResponseResult.success(jsonObject);
...@@ -138,7 +138,7 @@ public class AppEventController extends BaseController { ...@@ -138,7 +138,7 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-全网事件库-校验验证码") @ApiOperation("前台事件库-全网事件库-校验验证码")
@GetMapping("/checkWholeNetworkCaptcha") @GetMapping("/checkWholeNetworkCaptcha")
public ResponseResult checkWholeNetworkCaptcha(@RequestParam(value = "id", required = false, defaultValue = "") String id, public ResponseResult checkWholeNetworkCaptcha(@RequestParam(value = "id", required = false, defaultValue = "") String id,
@RequestParam(value = "captcha", required = false, defaultValue = "") String captcha){ @RequestParam(value = "captcha", required = false, defaultValue = "") String captcha) {
ResponseEntity<String> responseEntity = restTemplate.getForEntity(efCheckCaptchaUrl, String.class, id, captcha); ResponseEntity<String> responseEntity = restTemplate.getForEntity(efCheckCaptchaUrl, String.class, id, captcha);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
return ResponseResult.success(jsonObject); return ResponseResult.success(jsonObject);
......
...@@ -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);
}
}
...@@ -155,4 +155,10 @@ public interface BaseMongoDao<T extends AbstractBaseMongo> { ...@@ -155,4 +155,10 @@ public interface BaseMongoDao<T extends AbstractBaseMongo> {
criteria.and("channelFid").is(channelIndex.getFid()); criteria.and("channelFid").is(channelIndex.getFid());
return criteria; return criteria;
} }
@FunctionalInterface
interface VoidSetFunction {
<T> void set(T t);
}
} }
...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.pojo.EventData; ...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.pojo.EventData;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
/** /**
* @ClassName: EventDataDao * @ClassName: EventDataDao
...@@ -23,6 +24,13 @@ public interface EventDataDao extends BaseMongoDao<EventData>, ShardingMongo { ...@@ -23,6 +24,13 @@ public interface EventDataDao extends BaseMongoDao<EventData>, ShardingMongo {
EventData findFirstData(String eventId, String collectionName); EventData findFirstData(String eventId, String collectionName);
/** /**
* 异步获取首发稿件并设置相关操作
*
* @return EventData
*/
CompletableFuture<EventData> findFirstDataAsync(String eventId, String collectionName);
/**
* 获取传播量 * 获取传播量
* *
* @param event 事件 * @param event 事件
......
...@@ -10,6 +10,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; ...@@ -10,6 +10,7 @@ import org.springframework.data.mongodb.core.MongoTemplate;
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.data.mongodb.core.query.Update;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
...@@ -33,6 +34,9 @@ public class BaseMongoDaoImpl<T extends AbstractBaseMongo> implements BaseMongoD ...@@ -33,6 +34,9 @@ public class BaseMongoDaoImpl<T extends AbstractBaseMongo> implements BaseMongoD
@Resource(name = "primaryMongoTemplate") @Resource(name = "primaryMongoTemplate")
protected MongoTemplate mongoTemplate; protected MongoTemplate mongoTemplate;
@Resource(name = "mongoQueryExecutor")
protected ThreadPoolTaskExecutor taskExecutor;
public BaseMongoDaoImpl(String collectionName) { public BaseMongoDaoImpl(String collectionName) {
this.collectionName = collectionName; this.collectionName = collectionName;
this.clazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; this.clazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
......
...@@ -76,7 +76,8 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -76,7 +76,8 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
String aliasName = "events"; String aliasName = "events";
Criteria lookUpCriteria = Criteria.where(aliasName + ".emotion").in(eventEmotions); Criteria lookUpCriteria = Criteria.where(aliasName + ".emotion").in(eventEmotions);
List<AggregationOperation> operations = Arrays.asList(Aggregation.match(criteria), List<AggregationOperation> operations = Arrays.asList(Aggregation.match(criteria),
Aggregation.lookup(COLLECTION_NAME, "eventId", "_id", aliasName), Aggregation.match(lookUpCriteria), Aggregation.lookup(COLLECTION_NAME, "eventId", "_id", aliasName),
Aggregation.match(lookUpCriteria),
Aggregation.project("events._id")); Aggregation.project("events._id"));
Aggregation aggregation = Aggregation.newAggregation(operations); Aggregation aggregation = Aggregation.newAggregation(operations);
AggregationResults<JSONObject> aggregate = mongoTemplate.aggregate(aggregation, primaryCollection, JSONObject.class); AggregationResults<JSONObject> aggregate = mongoTemplate.aggregate(aggregation, primaryCollection, JSONObject.class);
......
...@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component; ...@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
/** /**
* @ClassName: EventDataDaoImpl * @ClassName: EventDataDaoImpl
...@@ -48,6 +49,11 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve ...@@ -48,6 +49,11 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve
} }
@Override @Override
public CompletableFuture<EventData> findFirstDataAsync(String eventId, String collectionName) {
return CompletableFuture.supplyAsync(() -> findFirstData(eventId, collectionName), taskExecutor);
}
@Override
public long getEventArticleCount(Event event) { public long getEventArticleCount(Event event) {
return count(Query.query(Criteria.where("eventId").is(event.getId())), event.getCollectionName()); return count(Query.query(Criteria.where("eventId").is(event.getId())), event.getCollectionName());
} }
......
...@@ -89,9 +89,7 @@ public class EventListInfoVO { ...@@ -89,9 +89,7 @@ public class EventListInfoVO {
this.totalDisseminationVolume = event.getTotalDisseminationVolume(); this.totalDisseminationVolume = event.getTotalDisseminationVolume();
this.totalChannelVolume = event.getTotalChannelVolume(); this.totalChannelVolume = event.getTotalChannelVolume();
this.emotion = event.getEmotion(); this.emotion = event.getEmotion();
this.eventTag = event.getEventTag().entrySet().stream() this.eventTag = event.getEventTag().values().stream().map(String::valueOf).collect(Collectors.joining("|"));
.map(entry-> String.valueOf(entry.getValue()))
.collect(Collectors.joining("|"));
this.negativeArticleVolume = event.getNegativeArticleVolume(); this.negativeArticleVolume = event.getNegativeArticleVolume();
this.articleEmotionProportions = event.getArticleEmotionProportions(); this.articleEmotionProportions = event.getArticleEmotionProportions();
this.articlePlatformProportions = event.getArticlePlatformProportions(); this.articlePlatformProportions = event.getArticlePlatformProportions();
......
...@@ -222,7 +222,7 @@ public interface EventService { ...@@ -222,7 +222,7 @@ public interface EventService {
/** /**
* 获取品牌事件列表信息 * 获取品牌事件列表信息
* @param linkedGroupId * @param contendId
* @param emotion * @param emotion
* @param startTime * @param startTime
* @param endTime * @param endTime
...@@ -231,7 +231,7 @@ public interface EventService { ...@@ -231,7 +231,7 @@ public interface EventService {
* @param sorter * @param sorter
* @return * @return
*/ */
PageVO<EventListInfoVO> getEventList(String linkedGroupId, String emotion, Long startTime, Long endTime, int page, int pageSize, String sorter); PageVO<EventListInfoVO> getEventList(String contendId, String emotion, Long startTime, Long endTime, int page, int pageSize, String sorter);
/** /**
* 事件详情-基础静态信息 * 事件详情-基础静态信息
......
...@@ -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;
} }
...@@ -17,9 +17,10 @@ public interface MarkFlowService { ...@@ -17,9 +17,10 @@ public interface MarkFlowService {
* @param json * @param json
* @param projectId * @param projectId
* @param linkedGroupId * @param linkedGroupId
* @param contendId
* @return * @return
*/ */
JSONObject createMarkFlowInfo(JSONObject json, String projectId, String linkedGroupId); JSONObject createMarkFlowInfo(JSONObject json, String projectId,String linkedGroupId, String contendId);
/** /**
* 快照页信息组装 * 快照页信息组装
......
...@@ -808,6 +808,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -808,6 +808,7 @@ public class ChannelServiceImpl implements ChannelService {
} }
channel.setEmotionIndex(index); channel.setEmotionIndex(index);
channel.setEmotion(emotion); channel.setEmotion(emotion);
channel.setEventCount(eventDao.getEventCount(new ChannelIndex(channel)).size());
} }
/** /**
......
...@@ -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());
...@@ -142,7 +142,7 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -142,7 +142,7 @@ public class CustomEventServiceImpl implements CustomEventService {
set("endTime", customEventDTO.getEndTime()).set("keywords", customEventDTO.getKeywords()); set("endTime", customEventDTO.getEndTime()).set("keywords", customEventDTO.getKeywords());
customEventDao.updateOneByIdWithField(customEvent.getId(), update); customEventDao.updateOneByIdWithField(customEvent.getId(), update);
customEventDataDao.deleteOneByQuery(Query.query(Criteria.where("customEventId").is(customEventDTO.getId()))); customEventDataDao.deleteOneByQuery(Query.query(Criteria.where("customEventId").is(customEventDTO.getId())));
// this.saveCustomEvent(customEventDTO); analyzeCustomEventDataByCustomEventDTO(customEvent, customEventDTO);
} }
@Override @Override
...@@ -278,6 +278,13 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -278,6 +278,13 @@ public class CustomEventServiceImpl implements CustomEventService {
return result; return result;
} }
private void analyzeCustomEventDataByCustomEventDTO(CustomEvent customEvent, CustomEventDTO customEventDTO) {
customEvent.setStartTime(customEventDTO.getStartTime());
customEvent.setEndTime(customEventDTO.getEndTime());
customEvent.setKeywords(customEventDTO.getKeywords());
analyzeCustomEventData(customEvent);
}
/** /**
* 自定义事件更新 * 自定义事件更新
* *
...@@ -285,10 +292,10 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -285,10 +292,10 @@ public class CustomEventServiceImpl implements CustomEventService {
*/ */
private void analyzeCustomEventData(CustomEvent customEvent) { private void analyzeCustomEventData(CustomEvent customEvent) {
String eventId = customEvent.getId(); String eventId = customEvent.getId();
log.info("自定义事件:{} 更新开始", eventId);
customEventDao.updateOneByIdWithField(eventId, Update.update("status", false));
ApplicationProjectListener.getThreadPool().execute(() -> { ApplicationProjectListener.getThreadPool().execute(() -> {
try { try {
log.info("自定义事件:{} 更新开始", eventId);
customEventDao.updateOneByIdWithField(eventId, Update.update("status", false));
//查询符合该事件时间段的所有稿件信息 //查询符合该事件时间段的所有稿件信息
List<JSONObject> articles = markDataService.searchMarkDataByTime(customEvent.getProjectId(), customEvent.getLinkedGroupId(), "0", List<JSONObject> articles = markDataService.searchMarkDataByTime(customEvent.getProjectId(), customEvent.getLinkedGroupId(), "0",
customEvent.getStartTime(), customEvent.getEndTime()); customEvent.getStartTime(), customEvent.getEndTime());
......
...@@ -513,7 +513,7 @@ public class EventServiceImpl implements EventService { ...@@ -513,7 +513,7 @@ public class EventServiceImpl implements EventService {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
// 品牌 // 品牌
result.put("brands", getBrands(projectId)); result.put("brands", projectService.getBrands(projectId, true));
// 事件调性 // 事件调性
result.put("emotions", getEventEmotions()); result.put("emotions", getEventEmotions());
// 事件类型 todo 后续用筛选器配置,和品牌关联 // 事件类型 todo 后续用筛选器配置,和品牌关联
...@@ -525,42 +525,39 @@ public class EventServiceImpl implements EventService { ...@@ -525,42 +525,39 @@ public class EventServiceImpl implements EventService {
} }
@Override @Override
public PageVO<EventListInfoVO> getEventList(String linkedGroupId, String emotion, Long startTime, Long endTime, int page, int pageSize, String sorter) { public PageVO<EventListInfoVO> getEventList(String contendId, String emotion, Long startTime, Long endTime, int page, int pageSize, String sorter) {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
// 查询条件 // 查询条件
Query query = Query.query(Criteria.where("projectId").is(projectId).and("linkedGroupId").is(linkedGroupId)); Query query = Query.query(Criteria.where("projectId").is(projectId).and("contendId").is(contendId));
if (Objects.nonNull(emotion) && !"全部".equals(emotion)) { if (Objects.nonNull(emotion) && !"全部".equals(emotion)) {
query.addCriteria(Criteria.where("emotion").is(emotion)); query.addCriteria(Criteria.where("emotion").is(emotion));
} }
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)) { if (Objects.nonNull(startTime) && Objects.nonNull(endTime)) {
query.addCriteria(Criteria.where("startTime").gte(new Date(startTime)).lt(new Date(endTime))); query.addCriteria(Criteria.where("startTime").gte(startTime).lt(endTime));
} }
// 排序
JSONObject sortJson = JSONObject.parseObject(sorter);
sortJson.entrySet().forEach(sortEntry -> {
String sort = String.valueOf(sortEntry.getValue()).replace("end", "");
String sortField = sortEntry.getKey();
if (Sort.Direction.ASC.name().equalsIgnoreCase(sort)) {
query.with(Sort.by(Sort.Direction.ASC, sortField));
} else {
query.with(Sort.by(Sort.Direction.DESC, sortField));
}
});
// 总数 // 总数
long total = eventDao.count(query); long total = eventDao.count(query);
int start = pageSize * (page - 1); // 排序
query.limit(pageSize).skip(start); eventDao.addSort(query, sorter);
mongoUtil.start(page, pageSize, query);
// 数据 // 数据
List<Event> eventList = eventDao.findList(query); List<Event> eventList = eventDao.findList(query);
// vo封装 // vo封装
List<EventListInfoVO> eventListInfoVOList = eventList.stream().map(event -> { // List<EventListInfoVO> eventListInfoVOList = eventList.stream().map(event -> {
EventListInfoVO vo = new EventListInfoVO(event); // EventListInfoVO vo = new EventListInfoVO(event);
// // 放入首发稿件
// vo.setFirstEventData(eventDataDao.findFirstData(event.getId(), event.getCollectionName()));
// return vo;
// }).collect(Collectors.toList());
// 未保证排序
Map<String, EventListInfoVO> sortMap = eventList.stream().collect(Collectors.toConcurrentMap(Event::getId, EventListInfoVO::new));
CompletableFuture.allOf(eventList.stream().map(event -> eventDataDao.findFirstDataAsync(event.getId(), event.getCollectionName()).thenApply((r) -> {
// 放入首发稿件 // 放入首发稿件
vo.setFirstEventData(eventDataDao.findFirstData(event.getId(), event.getCollectionName())); EventListInfoVO vo = new EventListInfoVO(event);
return vo; sortMap.get(event.getId()).setFirstEventData(r);
}).collect(Collectors.toList()); return null;
PageVO<EventListInfoVO> pageVo = PageVO.createPageVo(total, page, pageSize, eventListInfoVOList); })).toArray(CompletableFuture[]::new)).join();
return pageVo; return PageVO.createPageVo(total, page, pageSize, eventList.stream().map(event -> sortMap.get(event.getId())).collect(Collectors.toList()));
} }
@Override @Override
...@@ -683,6 +680,7 @@ public class EventServiceImpl implements EventService { ...@@ -683,6 +680,7 @@ public class EventServiceImpl implements EventService {
* @param projectId * @param projectId
* @return * @return
*/ */
@Deprecated
private List<JSONObject> getBrands(String projectId) { private List<JSONObject> getBrands(String projectId) {
ProjectVO projectVO = projectService.getProjectVOById(projectId); ProjectVO projectVO = projectService.getProjectVOById(projectId);
JSONObject priBrandResult = new JSONObject(); JSONObject priBrandResult = new JSONObject();
......
...@@ -11,8 +11,6 @@ import com.zhiwei.brandkbs2.dao.ChannelTagDao; ...@@ -11,8 +11,6 @@ import com.zhiwei.brandkbs2.dao.ChannelTagDao;
import com.zhiwei.brandkbs2.enmus.ChannelEmotion; import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
import com.zhiwei.brandkbs2.exception.ExceptionCast; import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.model.CommonCodeEnum; import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.Channel;
import com.zhiwei.brandkbs2.pojo.ChannelIndex;
import com.zhiwei.brandkbs2.pojo.MarkFlowEntity; import com.zhiwei.brandkbs2.pojo.MarkFlowEntity;
import com.zhiwei.brandkbs2.service.MarkFlowService; import com.zhiwei.brandkbs2.service.MarkFlowService;
import com.zhiwei.brandkbs2.util.RedisUtil; import com.zhiwei.brandkbs2.util.RedisUtil;
...@@ -22,9 +20,6 @@ import org.springframework.stereotype.Service; ...@@ -22,9 +20,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/** /**
* @ClassName: MarkFlowServiceImpl * @ClassName: MarkFlowServiceImpl
...@@ -45,9 +40,9 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -45,9 +40,9 @@ public class MarkFlowServiceImpl implements MarkFlowService {
RedisUtil redisUtil; RedisUtil redisUtil;
@Override @Override
public JSONObject createMarkFlowInfo(JSONObject json, String projectId, String contendId) { public JSONObject createMarkFlowInfo(JSONObject json, String projectId, String linkedGroupId, String contendId) {
JSONObject resultInfo = createInfoWithEmotion(json); JSONObject resultInfo = createInfoWithEmotion(json);
resultInfo.put("sourceDetails", getSourceDetails(json, projectId, contendId)); resultInfo.put("sourceDetails", getSourceDetails(json, projectId, linkedGroupId, contendId));
return resultInfo; return resultInfo;
} }
...@@ -106,7 +101,7 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -106,7 +101,7 @@ public class MarkFlowServiceImpl implements MarkFlowService {
return info; return info;
} }
private JSONObject getSourceDetails(JSONObject tJson, String projectId, String contendId) { private JSONObject getSourceDetails(JSONObject tJson, String projectId, String linkedGroupId, String contendId) {
JSONObject sourceDetails = new JSONObject(); JSONObject sourceDetails = new JSONObject();
String source = tJson.getString(GenericAttribute.ES_SOURCE); String source = tJson.getString(GenericAttribute.ES_SOURCE);
// 是否原创 // 是否原创
...@@ -123,20 +118,28 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -123,20 +118,28 @@ public class MarkFlowServiceImpl implements MarkFlowService {
sourceDetails.put("followersNum", followersNum); sourceDetails.put("followersNum", followersNum);
} }
// 渠道标签 // 渠道标签
sourceDetails.put("channelTag", channelTagDao.getTagByChannelName(source));
// 渠道倾向及id String channelTag = tJson.getString("channel_tag");
Channel channel = channelDao.queryUnique(ChannelIndex.createChannelIndex(tJson, projectId, contendId)); if (null != channelTag) {
if (null != channel) { sourceDetails.put("channelTag", channelTag.replaceAll(",", "|"));
sourceDetails.put("channelId", channel.getId()); }
sourceDetails.put("channelEmotion", ChannelEmotion.getNameFromState(channel.getEmotion())); // 渠道倾向及id(调整为快照属性)
} else { // Channel channel = channelDao.queryUnique(ChannelIndex.createChannelIndex(tJson, projectId, contendId));
List<Map<String, Object>> cacheMaps = (List<Map<String, Object>>) tJson.get(GenericAttribute.ES_BRANDKBS_CACHE_MAPS); // if (null != channel) {
if (null != cacheMaps) { // sourceDetails.put("channelId", channel.getId());
Map<String, Object> hitMap = // sourceDetails.put("channelEmotion", ChannelEmotion.getNameFromState(channel.getEmotion()));
cacheMaps.stream().filter(map -> projectId.equals(map.get("project_id")) && contendId.equals(map.get("contend_id"))).findAny().orElse(Collections.emptyMap()); // } else {
sourceDetails.put("channelId", hitMap.get("channel_id")); // List<Map<String, Object>> cacheMaps = (List<Map<String, Object>>) tJson.get(GenericAttribute.ES_BRANDKBS_CACHE_MAPS);
sourceDetails.put("channelEmotion", ChannelEmotion.getNameFromState(hitMap.get("channel_emotion"))); // if (null != cacheMaps) {
} // Map<String, Object> hitMap =
// cacheMaps.stream().filter(map -> projectId.equals(map.get("project_id")) && contendId.equals(map.get("contend_id"))).findAny().orElse(Collections.emptyMap());
// sourceDetails.put("channelId", hitMap.get("channel_id"));
// sourceDetails.put("channelEmotion", ChannelEmotion.getNameFromState(hitMap.get("channel_emotion")));
// }
// }
JSONObject brandkbsHitJson = Tools.getBrandkbsHitMap(tJson, Tools.concat(projectId, linkedGroupId, contendId));
if (null != brandkbsHitJson.get("channel_emotion")) {
sourceDetails.put("channelEmotion", ChannelEmotion.getNameFromState(brandkbsHitJson.getIntValue("channel_emotion")));
} }
double channelValue = tJson.getDoubleValue(GenericAttribute.ES_CHANNEL_INDEX); double channelValue = tJson.getDoubleValue(GenericAttribute.ES_CHANNEL_INDEX);
if (channelValue > 0) { if (channelValue > 0) {
......
...@@ -93,7 +93,7 @@ public class TaskServiceImpl implements TaskService { ...@@ -93,7 +93,7 @@ public class TaskServiceImpl implements TaskService {
insertList.addAll(batchHandle(batchList, newRecordMap)); insertList.addAll(batchHandle(batchList, newRecordMap));
batchList = new ArrayList<>(); batchList = new ArrayList<>();
} }
if (handleSize % 100 == 0) { if (handleSize % 10000 == 0) {
log.info("渠道统计-渠道总计-查询更新已完成{}/{}", handleSize, channelIndexRecordMap.size()); log.info("渠道统计-渠道总计-查询更新已完成{}/{}", handleSize, channelIndexRecordMap.size());
} }
} }
......
...@@ -779,14 +779,14 @@ public class Tools { ...@@ -779,14 +779,14 @@ public class Tools {
return contains; return contains;
} }
public static Map<String, Object> getBrandkbsHitMap(Map<String, Object> esMap, String hitKey) { public static JSONObject getBrandkbsHitMap(Map<String, Object> esMap, String hitKey) {
List<Map<String, Object>> cacheMaps = (List<Map<String, Object>>) esMap.get("brandkbs_cache_maps"); List<Map<String, Object>> cacheMaps = (List<Map<String, Object>>) esMap.get("brandkbs_cache_maps");
for (Map<String, Object> cacheMap : cacheMaps) { for (Map<String, Object> cacheMap : cacheMaps) {
if (hitKey.equals(cacheMap.get("key"))) { if (hitKey.equals(cacheMap.get("key"))) {
return cacheMap; return new JSONObject(cacheMap);
} }
} }
return Collections.emptyMap(); return new JSONObject();
} }
public static <T> Map<Long, T> sortTimeKeyMap(Map<Long, T> map, boolean isDesc) { public static <T> Map<Long, T> sortTimeKeyMap(Map<Long, T> map, boolean isDesc) {
......
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