Commit fac87a3b by 陈健智

渠道库榜单调整

parent af665bc2
......@@ -260,7 +260,7 @@ public class AppChannelController extends BaseController {
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
return ResponseResult.success(channelService.getActiveChannelList(contendId, startTime, endTime, size));
return ResponseResult.success(channelService.getActiveChannelList(contendId, startTime, endTime, size, true));
}
@ApiImplicitParams({@ApiImplicitParam(name = "contendId", value = "品牌id", defaultValue = "0", paramType = "query", dataType = "string"),
......@@ -275,7 +275,7 @@ public class AppChannelController extends BaseController {
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
return ResponseResult.success(channelService.getPositiveChannelList(contendId, startTime, endTime, size));
return ResponseResult.success(channelService.getPositiveChannelList(contendId, startTime, endTime, size, true));
}
@ApiImplicitParams({@ApiImplicitParam(name = "contendId", value = "品牌id", defaultValue = "0", paramType = "query", dataType = "string"),
......@@ -290,7 +290,7 @@ public class AppChannelController extends BaseController {
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
return ResponseResult.success(channelService.getNegativeChannelList(contendId, startTime, endTime, size));
return ResponseResult.success(channelService.getNegativeChannelList(contendId, startTime, endTime, size, true));
}
@ApiOperation("渠道库-渠道申请")
......
......@@ -159,7 +159,7 @@ public interface ChannelService {
* @param size 数据量
* @return
*/
JSONObject getActiveChannelList(String contendId, Long startTime, Long endTime, int size);
JSONObject getActiveChannelList(String contendId, Long startTime, Long endTime, int size, boolean cache);
/**
* 新-友好渠道榜
......@@ -169,7 +169,7 @@ public interface ChannelService {
* @param size 数据量
* @return
*/
JSONObject getPositiveChannelList(String contendId, Long startTime, Long endTime, int size);
JSONObject getPositiveChannelList(String contendId, Long startTime, Long endTime, int size, boolean cache);
/**
* 新-敏感渠道榜
......@@ -179,7 +179,7 @@ public interface ChannelService {
* @param size 数据量
* @return
*/
JSONObject getNegativeChannelList(String contendId, Long startTime, Long endTime, int size);
JSONObject getNegativeChannelList(String contendId, Long startTime, Long endTime, int size, boolean cache);
/**
* 收藏渠道
......
......@@ -450,18 +450,18 @@ public class ChannelServiceImpl implements ChannelService {
}
@Override
public JSONObject getActiveChannelList(String contendId, Long startTime, Long endTime, int size) {
return getChannelListCache(contendId, startTime, endTime, EmotionEnum.ALL.getState(), size, true);
public JSONObject getActiveChannelList(String contendId, Long startTime, Long endTime, int size, boolean cache) {
return getChannelListCache(contendId, startTime, endTime, EmotionEnum.ALL.getState(), size, cache);
}
@Override
public JSONObject getPositiveChannelList(String contendId, Long startTime, Long endTime, int size) {
return getChannelListCache(contendId, startTime, endTime, EmotionEnum.POSITIVE.getState(), size, true);
public JSONObject getPositiveChannelList(String contendId, Long startTime, Long endTime, int size, boolean cache) {
return getChannelListCache(contendId, startTime, endTime, EmotionEnum.POSITIVE.getState(), size, cache);
}
@Override
public JSONObject getNegativeChannelList(String contendId, Long startTime, Long endTime, int size) {
return getChannelListCache(contendId, startTime, endTime, EmotionEnum.NEGATIVE.getState(), size, true);
public JSONObject getNegativeChannelList(String contendId, Long startTime, Long endTime, int size, boolean cache) {
return getChannelListCache(contendId, startTime, endTime, EmotionEnum.NEGATIVE.getState(), size, cache);
}
private JSONObject getChannelListCache(String contendId, Long startTime, Long endTime, int emotion, int size, boolean cache) {
......@@ -486,8 +486,7 @@ public class ChannelServiceImpl implements ChannelService {
private JSONObject getChannelList(String projectId, String contendId, Long startTime, Long endTime, int emotion, int size) throws IOException {
JSONObject res = new JSONObject(new LinkedHashMap<>());
Map<String, Pair<Long, ChannelRecord>> keyMap = new HashMap<>();
EsClientDao.SearchHelper searchHelper = createSearchHelperByChannelCriteria(projectId, null,
Collections.singleton(contendId), null, null, startTime, endTime);
EsClientDao.SearchHelper searchHelper = createSearchHelperByChannelCriteria(projectId, Collections.singleton(contendId), startTime, endTime, true);
// 分页查询所有结果
List<SearchResponse> searchResponses = channelEsDao.searchScrollResponse(searchHelper);
for (SearchResponse searchResponse : searchResponses) {
......@@ -1827,22 +1826,51 @@ public class ChannelServiceImpl implements ChannelService {
query.must(QueryBuilders.termQuery("channel_fid.keyword", channel.getFid()));
}
// platformId
String platformId = GlobalPojo.getPlatformIdByName(platform);
if (null != platformId) {
query.must(QueryBuilders.termQuery(GenericAttribute.ES_PLATFORM_ID, platformId));
} else if (GlobalPojo.ELSE_PLATFORM_NAME.equals(platform)) {
// 不是 网媒,微博,微信,今日头条
EsQueryTools.platformMustNot(query, GlobalPojo.PERMANENT_PLATFORM_NAMES.toArray(new String[0]));
}
// keyword
if (StringUtils.isNotEmpty(keyword)) {
query.must(EsQueryTools.assembleSourceQuery(keyword));
}
// timeRange
// 默认搜索一周
if (defaultTime && (null == startTime || null == endTime)) {
Long[] timeRangeWeek = commonService.getTimeRangeWeek();
startTime = timeRangeWeek[0];
endTime = timeRangeWeek[1];
}
RangeQueryBuilder timeRangeQuery = QueryBuilders.rangeQuery("record.articles.time").lt(endTime);
if (null != startTime) {
timeRangeQuery.gte(startTime);
}
query.must(timeRangeQuery);
helper.setQuery(query);
return helper;
}
private EsClientDao.SearchHelper createSearchHelperByChannelCriteria(String projectId, Collection<String> contendIds, Long startTime, Long endTime, boolean defaultTime) {
EsClientDao.SearchHelper helper = EsClientDao.createSearchHelper();
// query
BoolQueryBuilder query = QueryBuilders.boolQuery();
// project和contendId
query.must(QueryBuilders.termQuery("project_id.keyword", projectId));
// 添加contends集合 查询
if (null != contendIds) {
EsQueryTools.assembleContendsQuery4Channel(query, contendIds);
}
// platformId
List<String> platformIds = new ArrayList<>(6);
for (String platformName : PLATFORMS) {
platformIds.add(GlobalPojo.getPlatformIdByName(platformName));
}
// String platformId = GlobalPojo.getPlatformIdByName(platform);
if (CollectionUtils.isNotEmpty(platformIds)) {
query.must(QueryBuilders.termsQuery(GenericAttribute.ES_PLATFORM_ID, platformIds));
}
// else if (GlobalPojo.ELSE_PLATFORM_NAME.equals(platform)) {
// // 不是 网媒,微博,微信,今日头条
// EsQueryTools.platformMustNot(query, GlobalPojo.PERMANENT_PLATFORM_NAMES.toArray(new String[0]));
// }
// keyword
if (StringUtils.isNotEmpty(keyword)) {
query.must(EsQueryTools.assembleSourceQuery(keyword));
}
// timeRange
// 默认搜索一周
if (defaultTime && (null == startTime || null == endTime)) {
......
......@@ -152,10 +152,13 @@ public class TaskServiceImpl implements TaskService {
timeList.forEach(times -> {
// 活跃渠道榜
channelService.getActiveChannelList(Constant.PRIMARY_CONTEND_ID, null, null, times[0], times[1], 50, false);
channelService.getActiveChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, false);
// 友好渠道榜
channelService.getPositiveList(Constant.PRIMARY_CONTEND_ID, null, null, sorter, times[0], times[1], 50, false);
channelService.getPositiveChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, false);
// 敏感渠道榜
channelService.getNegativeList(Constant.PRIMARY_CONTEND_ID, null, null, sorter, times[0], times[1], 50, false);
channelService.getNegativeChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, false);
});
log.info("项目:{}-渠道榜单缓存已完成:{}个", project.getProjectName(), total.incrementAndGet());
return null;
......
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