Commit cfdc79ca by shenjunjie

2022/9/6 16:33

parent 618c0907
...@@ -33,7 +33,7 @@ public class GenericAttribute { ...@@ -33,7 +33,7 @@ public class GenericAttribute {
/** /**
* es media_type * es media_type
*/ */
public static final String ES_MEDIA_TYPE = "media_type"; // public static final String ES_MEDIA_TYPE = "media_type";
// es platform_id // es platform_id
public static final String ES_PLATFORM_ID = "platform_id"; public static final String ES_PLATFORM_ID = "platform_id";
// es channel_influence // es channel_influence
......
...@@ -140,12 +140,6 @@ public class AppEventController extends BaseController { ...@@ -140,12 +140,6 @@ public class AppEventController extends BaseController {
return ResponseResult.success(jsonObject); return ResponseResult.success(jsonObject);
} }
@ApiOperation("最新事件")
@GetMapping("/getLastEventTop")
public ResponseResult getLastEventTop() {
return ResponseResult.success(eventService.getLastEventTop(null, 5));
}
@ApiOperation("关联事件") @ApiOperation("关联事件")
@ApiImplicitParam(name = "keyword", value = "关键词", paramType = "query", dataType = "String") @ApiImplicitParam(name = "keyword", value = "关键词", paramType = "query", dataType = "String")
@GetMapping("/getRelevanceEvent") @GetMapping("/getRelevanceEvent")
......
...@@ -7,9 +7,12 @@ import com.zhiwei.brandkbs2.auth.Auth; ...@@ -7,9 +7,12 @@ import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.config.Constant; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.enmus.RoleEnum; 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.MarkSearchDTO; import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO; import com.zhiwei.brandkbs2.pojo.dto.SearchFilterDTO;
import com.zhiwei.brandkbs2.service.ChannelService; import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.EventService;
import com.zhiwei.brandkbs2.service.MarkDataService; import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -57,6 +60,12 @@ public class AppSearchController { ...@@ -57,6 +60,12 @@ public class AppSearchController {
@Resource(name = "channelServiceImpl") @Resource(name = "channelServiceImpl")
ChannelService channelService; ChannelService channelService;
@Resource(name = "eventServiceImpl")
EventService eventService;
@Resource(name = "commonServiceImpl")
CommonService commonService;
@ApiOperation("搜索-查热点") @ApiOperation("搜索-查热点")
@GetMapping("/hot/list") @GetMapping("/hot/list")
public ResponseResult searchHotList(@RequestParam(value = "pageSize", defaultValue = "10") Integer limit, public ResponseResult searchHotList(@RequestParam(value = "pageSize", defaultValue = "10") Integer limit,
...@@ -106,27 +115,33 @@ public class AppSearchController { ...@@ -106,27 +115,33 @@ public class AppSearchController {
return ResponseResult.success(markDataService.searchWholeNetwork(dto)); return ResponseResult.success(markDataService.searchWholeNetwork(dto));
} }
@ApiOperation("舆情列表") @ApiOperation("搜索-舆情列表")
@PostMapping("/mark/list") @PostMapping("/mark/list")
public ResponseResult getYuqingMarkList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult getYuqingMarkList(@RequestBody MarkSearchDTO markSearchDTO) {
return ResponseResult.success(markDataService.getYuqingMarkList(markSearchDTO)); return ResponseResult.success(markDataService.getYuqingMarkList(markSearchDTO));
} }
@ApiOperation("舆情列表-搜索条件") @ApiOperation("搜索-舆情列表-搜索条件")
@GetMapping("/mark/list/criteria") @GetMapping("/mark/list/criteria")
public ResponseResult getYuqingMarkCriteria(@RequestParam(required = false) String linkedGroupId) { public ResponseResult getYuqingMarkCriteria(@RequestParam(required = false) String linkedGroupId) {
return ResponseResult.success(markDataService.getYuqingMarkCriteria(linkedGroupId)); return ResponseResult.success(markDataService.getYuqingMarkCriteria(linkedGroupId));
} }
@ApiOperation("搜索-活跃渠道")
@GetMapping("channel/list/active")
public ResponseResult getActiveChannelList(@RequestParam(value = "size", defaultValue = "2") int size) {
Long[] timeRangeDay = commonService.getTimeRangeDay();
return ResponseResult.success(channelService.getActiveChannelList("0", null, null, timeRangeDay[0], timeRangeDay[1], size));
}
@ApiOperation("渠道搜索条件") @ApiOperation("搜索-渠道搜索条件")
@GetMapping("/channel/getChannelSearchCriteria") @GetMapping("/channel/getChannelSearchCriteria")
public ResponseResult getChannelSearchCriteria() { public ResponseResult getChannelSearchCriteria() {
return ResponseResult.success(channelService.getChannelSearchCriteria()); return ResponseResult.success(channelService.getChannelSearchCriteria());
} }
@ApiOperation("查渠道 渠道库") @ApiOperation("搜索-渠道列表")
@PostMapping(value = "/channel/channelList") @PostMapping(value = "/channel/channelList")
public ResponseResult getChannelList(@RequestParam(value = "page", defaultValue = "1") int page, public ResponseResult getChannelList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "20") int pageSize, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
...@@ -139,13 +154,31 @@ public class AppSearchController { ...@@ -139,13 +154,31 @@ public class AppSearchController {
return ResponseResult.success(channelService.getChannelList(page, pageSize, keyword, platforms, emotions, mediaTypes, articlesCount, sorter)); return ResponseResult.success(channelService.getChannelList(page, pageSize, keyword, platforms, emotions, mediaTypes, articlesCount, sorter));
} }
@ApiOperation("查竞品") @ApiOperation("搜索-热门事件")
@GetMapping("/getLastEventTop")
public ResponseResult getLastEventTop() {
return ResponseResult.success(eventService.getLastEventTop(null, 5));
}
@ApiOperation("搜索-前台事件库-搜索条件")
@GetMapping("/event/list/criteria")
public ResponseResult getEventsSearchCriteria() {
return ResponseResult.success(eventService.getEventsSearchCriteria());
}
@ApiOperation("搜索-前台事件库-品牌事件库")
@PostMapping("/event/list")
public ResponseResult getEventList(@RequestBody EventSearchDTO eventSearchDTO) {
return ResponseResult.success(eventService.getEventList(eventSearchDTO));
}
@ApiOperation("搜索-查竞品")
@PostMapping("/contend/list") @PostMapping("/contend/list")
public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO) {
return ResponseResult.success(markDataService.getContendSearchList(markSearchDTO)); return ResponseResult.success(markDataService.getContendSearchList(markSearchDTO));
} }
@ApiOperation("查竞品-搜索条件") @ApiOperation("搜索-查竞品-搜索条件")
@GetMapping("/contend/list/criteria") @GetMapping("/contend/list/criteria")
public ResponseResult getContendSearchCriteria(@RequestParam(required = false) String contendId) { public ResponseResult getContendSearchCriteria(@RequestParam(required = false) String contendId) {
return ResponseResult.success(markDataService.getContendSearchCriteria(contendId)); return ResponseResult.success(markDataService.getContendSearchCriteria(contendId));
......
...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.pojo; ...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.pojo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.common.GenericAttribute; import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -82,16 +83,16 @@ public class AggreeResult extends AbstractBaseMongo { ...@@ -82,16 +83,16 @@ public class AggreeResult extends AbstractBaseMongo {
*/ */
private boolean isFather; private boolean isFather;
public static AggreeResult createFather(JSONObject json, String taskId, Integer aggreeSize) { public static AggreeResult createFather(JSONObject json, String taskId,String projectId, Integer aggreeSize) {
AggreeResult aggreeResult = getInstance(json, taskId); AggreeResult aggreeResult = getInstance(json, taskId,projectId);
aggreeResult.setFather(true); aggreeResult.setFather(true);
aggreeResult.setAggreeSize(aggreeSize); aggreeResult.setAggreeSize(aggreeSize);
aggreeResult.setCTime(System.currentTimeMillis()); aggreeResult.setCTime(System.currentTimeMillis());
return aggreeResult; return aggreeResult;
} }
public static AggreeResult createSon(JSONObject json, String taskId, String fatherId, String fatherTitle) { public static AggreeResult createSon(JSONObject json, String taskId,String projectId, String fatherId,String fatherTitle) {
AggreeResult aggreeResult = getInstance(json, taskId); AggreeResult aggreeResult = getInstance(json, taskId,projectId);
aggreeResult.setFatherId(fatherId); aggreeResult.setFatherId(fatherId);
// 使用父聚合标题 // 使用父聚合标题
aggreeResult.setAggreeTitle(fatherTitle); aggreeResult.setAggreeTitle(fatherTitle);
...@@ -99,13 +100,13 @@ public class AggreeResult extends AbstractBaseMongo { ...@@ -99,13 +100,13 @@ public class AggreeResult extends AbstractBaseMongo {
return aggreeResult; return aggreeResult;
} }
private static AggreeResult getInstance(JSONObject json, String taskId) { private static AggreeResult getInstance(JSONObject json, String taskId,String projectId) {
AggreeResult aggreeResult = new AggreeResult(); AggreeResult aggreeResult = new AggreeResult();
aggreeResult.setTaskId(taskId); aggreeResult.setTaskId(taskId);
BaseMap baseMap = Tools.getBaseFromEsMap(json); BaseMap baseMap = Tools.getBaseFromEsMap(json);
aggreeResult.setTime(baseMap.getTime()); aggreeResult.setTime(baseMap.getTime());
aggreeResult.setPlatformId(json.getString(GenericAttribute.ES_PLATFORM_ID)); aggreeResult.setPlatformId(json.getString(GenericAttribute.ES_PLATFORM_ID));
String mediaType = json.getString(GenericAttribute.ES_MEDIA_TYPE); String mediaType = GlobalPojo.getMediaType(projectId, baseMap.getPlatform(), baseMap.getSource());
if (StringUtils.isNotEmpty(mediaType)) { if (StringUtils.isNotEmpty(mediaType)) {
aggreeResult.setMediaTypes(Arrays.asList(mediaType.split(","))); aggreeResult.setMediaTypes(Arrays.asList(mediaType.split(",")));
} }
......
...@@ -62,6 +62,8 @@ public class Channel extends ChannelIndex { ...@@ -62,6 +62,8 @@ public class Channel extends ChannelIndex {
*/ */
private Long collectTime; private Long collectTime;
private Double influence;
public void setLastTime(Long lastTime) { public void setLastTime(Long lastTime) {
if (null == this.lastTime || this.lastTime < lastTime) { if (null == this.lastTime || this.lastTime < lastTime) {
this.lastTime = lastTime; this.lastTime = lastTime;
......
...@@ -48,7 +48,7 @@ public class CustomEvent extends AbstractBaseMongo { ...@@ -48,7 +48,7 @@ public class CustomEvent extends AbstractBaseMongo {
/** /**
* 关联项目组ID * 关联项目组ID
*/ */
private String linkedGroupId; private String contendId;
/** /**
* 将自定义事件传输对象转换为自定义事件对象 * 将自定义事件传输对象转换为自定义事件对象
......
...@@ -63,7 +63,10 @@ public class ChannelVO { ...@@ -63,7 +63,10 @@ public class ChannelVO {
channelVO.setArticleCount(channel.getArticleCount()); channelVO.setArticleCount(channel.getArticleCount());
// TODO influence实现 // TODO influence实现
channelVO.setInfluence(null); channelVO.setInfluence(null);
channelVO.setMediaType(GlobalPojo.getMediaType(projectId, channel.getPlatform(), channel.getSource())); String mediaType = GlobalPojo.getMediaType(projectId, channel.getPlatform(), channel.getSource());
if (null != mediaType) {
channelVO.setMediaType(mediaType.replaceAll(",", " "));
}
channelVO.setLastArticle(lastArticle); channelVO.setLastArticle(lastArticle);
return channelVO; return channelVO;
} }
......
...@@ -52,4 +52,6 @@ public interface CommonService { ...@@ -52,4 +52,6 @@ public interface CommonService {
Long[] getTimeRangeWeek(); Long[] getTimeRangeWeek();
Long[] getTimeRangeDay();
} }
...@@ -110,4 +110,11 @@ public class CommonServiceImpl implements CommonService { ...@@ -110,4 +110,11 @@ public class CommonServiceImpl implements CommonService {
return new Long[]{startTime, endTime}; return new Long[]{startTime, endTime};
} }
@Override
public Long[] getTimeRangeDay() {
long endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
long startTime = DateUtils.addDays(new Date(endTime), -1).getTime();
return new Long[]{startTime, endTime};
}
} }
...@@ -118,11 +118,11 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -118,11 +118,11 @@ public class CustomEventServiceImpl implements CustomEventService {
@Override @Override
public void saveCustomEvent(CustomEventDTO customEventDTO) { public void saveCustomEvent(CustomEventDTO customEventDTO) {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId(); String contendId = "0";
CustomEvent customEvent = CustomEvent.creatFromCustomEventDTO(customEventDTO); CustomEvent customEvent = CustomEvent.creatFromCustomEventDTO(customEventDTO);
customEvent.setUpdateTime(System.currentTimeMillis()); customEvent.setUpdateTime(System.currentTimeMillis());
customEvent.setProjectId(projectId); customEvent.setProjectId(projectId);
customEvent.setLinkedGroupId(linkedGroupId); customEvent.setContendId(contendId);
customEventDao.insertOneWithoutId(customEvent); customEventDao.insertOneWithoutId(customEvent);
this.analyzeCustomEventData(customEvent); this.analyzeCustomEventData(customEvent);
} }
...@@ -293,8 +293,9 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -293,8 +293,9 @@ public class CustomEventServiceImpl implements CustomEventService {
customEventDao.updateOneByIdWithField(eventId, Update.update("status", false)); customEventDao.updateOneByIdWithField(eventId, Update.update("status", false));
ApplicationProjectListener.getThreadPool().execute(() -> { ApplicationProjectListener.getThreadPool().execute(() -> {
try { try {
String linkedGroupId = projectService.getProjectByContendId(customEvent.getProjectId(), customEvent.getContendId()).getBrandLinkedGroupId();
//查询符合该事件时间段的所有稿件信息 //查询符合该事件时间段的所有稿件信息
List<JSONObject> articles = markDataService.searchMarkDataByTime(customEvent.getProjectId(), customEvent.getLinkedGroupId(), "0", List<JSONObject> articles = markDataService.searchMarkDataByTime(customEvent.getProjectId(), linkedGroupId, customEvent.getContendId(),
customEvent.getStartTime(), customEvent.getEndTime()); customEvent.getStartTime(), customEvent.getEndTime());
log.info("自定义事件:{} 查询到符合该事件时间段的所有稿件数{}个", eventId, articles.size()); log.info("自定义事件:{} 查询到符合该事件时间段的所有稿件数{}个", eventId, articles.size());
List<String> keywords = customEvent.getKeywords(); List<String> keywords = customEvent.getKeywords();
......
...@@ -546,11 +546,11 @@ public class EventServiceImpl implements EventService { ...@@ -546,11 +546,11 @@ public class EventServiceImpl implements EventService {
} }
query.addCriteria(volumeCriteria); query.addCriteria(volumeCriteria);
} }
mongoUtil.start(eventSearchDTO.getPage(), eventSearchDTO.getPageSize(), query);
// 总数 // 总数
long total = eventDao.count(query); long total = eventDao.count(query);
// 排序 // 排序
eventDao.addSort(query, eventSearchDTO.getSorter().toJSONString()); eventDao.addSort(query, eventSearchDTO.getSorter().toJSONString());
mongoUtil.start(eventSearchDTO.getPage(), eventSearchDTO.getPageSize(), query);
// 数据 // 数据
List<Event> eventList = eventDao.findList(query); List<Event> eventList = eventDao.findList(query);
// vo封装 // vo封装
......
...@@ -190,7 +190,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -190,7 +190,7 @@ public class MarkDataServiceImpl implements MarkDataService {
List<List<JSONObject>> groupList = aggregation(hitsAndCounts.getLeft(), "id"); List<List<JSONObject>> groupList = aggregation(hitsAndCounts.getLeft(), "id");
log.info("taskId:{},聚合完成,聚合组:{}个", uuid, groupList.size()); log.info("taskId:{},聚合完成,聚合组:{}个", uuid, groupList.size());
// 入mongo缓存 // 入mongo缓存
cacheAggreeResult(groupList, uuid); cacheAggreeResult(groupList, uuid, projectId);
redisUtil.setExpire(redisKey, "100"); redisUtil.setExpire(redisKey, "100");
} catch (Exception e) { } catch (Exception e) {
log.error("generateYuqingMarkAggreeList-", e); log.error("generateYuqingMarkAggreeList-", e);
...@@ -279,11 +279,11 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -279,11 +279,11 @@ public class MarkDataServiceImpl implements MarkDataService {
query.addCriteria((orCriteria.orOperator(tagCriteria.toArray(new Criteria[0])))); query.addCriteria((orCriteria.orOperator(tagCriteria.toArray(new Criteria[0]))));
} }
// 关键词模糊查询 // 关键词模糊查询
aggreeResultDao.addKeywordFuzz(query, dto.getKeyword(), "aggreeTitle"); aggreeResultDao.addKeywordFuzz(query, dto.getKeyword(), "data.source");
return query; return query;
} }
private void cacheAggreeResult(List<List<JSONObject>> groupList, String taskId) { private void cacheAggreeResult(List<List<JSONObject>> groupList, String taskId, String projectId) {
int count = 0; int count = 0;
int percent; int percent;
for (List<JSONObject> list : groupList) { for (List<JSONObject> list : groupList) {
...@@ -294,12 +294,12 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -294,12 +294,12 @@ public class MarkDataServiceImpl implements MarkDataService {
AggreeResult aggreeResult; AggreeResult aggreeResult;
// 父聚合处理 // 父聚合处理
if (i == 0) { if (i == 0) {
aggreeResult = AggreeResult.createFather(json, taskId, list.size()); aggreeResult = AggreeResult.createFather(json, taskId, projectId, list.size());
aggreeResultDao.insertOneWithoutId(aggreeResult); aggreeResultDao.insertOneWithoutId(aggreeResult);
fatherId = aggreeResult.getId(); fatherId = aggreeResult.getId();
fatherTitle = aggreeResult.getAggreeTitle(); fatherTitle = aggreeResult.getAggreeTitle();
} else { } else {
aggreeResult = AggreeResult.createSon(json, taskId, fatherId, fatherTitle); aggreeResult = AggreeResult.createSon(json, taskId, projectId, fatherId, fatherTitle);
aggreeResultDao.insertOneWithoutId(aggreeResult); aggreeResultDao.insertOneWithoutId(aggreeResult);
} }
} }
......
...@@ -118,7 +118,6 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -118,7 +118,6 @@ public class MarkFlowServiceImpl implements MarkFlowService {
sourceDetails.put("followersNum", followersNum); sourceDetails.put("followersNum", followersNum);
} }
// 渠道标签 // 渠道标签
String channelTag = tJson.getString("channel_tag"); String channelTag = tJson.getString("channel_tag");
if (null != channelTag) { if (null != channelTag) {
sourceDetails.put("channelTag", channelTag.replaceAll(",", "|")); sourceDetails.put("channelTag", channelTag.replaceAll(",", "|"));
......
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