Commit 9ac58d98 by shenjunjie

Merge branch 'feature' into 'release'

Feature

See merge request !187
parents 9aa9c9ba 84b448c8
...@@ -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.2-SNAPSHOT</event-client.version> <event-client.version>1.0.4-SNAPSHOT</event-client.version>
</properties> </properties>
<dependencies> <dependencies>
......
...@@ -21,8 +21,6 @@ import org.springframework.http.ResponseEntity; ...@@ -21,8 +21,6 @@ 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 java.util.List;
/** /**
* @Description: 前台事件库 * @Description: 前台事件库
* @Author: shentao * @Author: shentao
...@@ -74,18 +72,21 @@ public class AppEventController extends BaseController { ...@@ -74,18 +72,21 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-事件详情-基础信息") @ApiOperation("前台事件库-事件详情-基础信息")
@GetMapping("/info/base/{id}") @GetMapping("/info/base/{id}")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult getEventBaseInfo(@PathVariable String id) { public ResponseResult getEventBaseInfo(@PathVariable String id) {
return ResponseResult.success(eventService.getEventBaseInfo(id)); return ResponseResult.success(eventService.getEventBaseInfo(id));
} }
@ApiOperation("前台事件库-事件详情-传播趋势图") @ApiOperation("前台事件库-事件详情-传播趋势图")
@GetMapping("/info/dissemination-trends/{id}") @GetMapping("/info/dissemination-trends/{id}")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult getEventDisseminationTrends(@PathVariable String id, @RequestParam(value = "type", defaultValue = "小时") String type) { public ResponseResult getEventDisseminationTrends(@PathVariable String id, @RequestParam(value = "type", defaultValue = "小时") String type) {
return ResponseResult.success(eventService.getEventDisseminationTrends(id, type)); return ResponseResult.success(eventService.getEventDisseminationTrends(id, type));
} }
@ApiOperation("前台事件库-事件详情-渠道发声") @ApiOperation("前台事件库-事件详情-渠道发声")
@GetMapping("/info/channel-voices/{id}") @GetMapping("/info/channel-voices/{id}")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult getEventChannelVoices(@PathVariable String id, public ResponseResult getEventChannelVoices(@PathVariable String id,
@RequestParam(value = "type", defaultValue = "重要渠道") String type, @RequestParam(value = "type", defaultValue = "重要渠道") String type,
@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "page", defaultValue = "1") int page,
...@@ -96,6 +97,7 @@ public class AppEventController extends BaseController { ...@@ -96,6 +97,7 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-事件详情-热门文章分析") @ApiOperation("前台事件库-事件详情-热门文章分析")
@GetMapping("/info/top-articles-analysis/{id}") @GetMapping("/info/top-articles-analysis/{id}")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult getEventTopArticlesAnalysis(@PathVariable String id, public ResponseResult getEventTopArticlesAnalysis(@PathVariable String id,
@RequestParam(value = "type", defaultValue = "按时间") String type, @RequestParam(value = "type", defaultValue = "按时间") String type,
@RequestParam(value = "emotion", defaultValue = "全部") String emotion, @RequestParam(value = "emotion", defaultValue = "全部") String emotion,
......
...@@ -10,8 +10,10 @@ import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil; ...@@ -10,8 +10,10 @@ import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
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.*; import com.zhiwei.brandkbs2.pojo.dto.*;
import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO;
import com.zhiwei.brandkbs2.service.*; import com.zhiwei.brandkbs2.service.*;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
...@@ -168,7 +170,11 @@ public class AppSearchController extends BaseController { ...@@ -168,7 +170,11 @@ public class AppSearchController extends BaseController {
@GetMapping("channel/list/active") @GetMapping("channel/list/active")
public ResponseResult getActiveChannelList(@RequestParam(value = "size", defaultValue = "2") int size) { public ResponseResult getActiveChannelList(@RequestParam(value = "size", defaultValue = "2") int size) {
Long[] timeRangeDay = commonService.getTimeRangeDay(); Long[] timeRangeDay = commonService.getTimeRangeDay();
return ResponseResult.success(channelService.getActiveChannelList("0", null, null, timeRangeDay[0], timeRangeDay[1], size, true)); List<ChannelListVO> activeChannelList = channelService.getActiveChannelList("0", null, null, timeRangeDay[0], timeRangeDay[1], size, true);
if (activeChannelList.size() > 2) {
activeChannelList = activeChannelList.subList(0, 2);
}
return ResponseResult.success(activeChannelList);
} }
@ApiOperation("搜索-渠道搜索条件") @ApiOperation("搜索-渠道搜索条件")
...@@ -203,6 +209,18 @@ public class AppSearchController extends BaseController { ...@@ -203,6 +209,18 @@ public class AppSearchController extends BaseController {
return ResponseResult.success(eventService.getEventList(eventSearchDTO)); return ResponseResult.success(eventService.getEventList(eventSearchDTO));
} }
@ApiOperation("搜索-前台事件库-搜索条件-新")
@GetMapping("/event/criteria/{brandId}")
public ResponseResult getEventSearchCriteriaMiddleware(@PathVariable String brandId){
return ResponseResult.success(eventService.getEventListCriteria(brandId));
}
@ApiOperation("搜索-前台事件库-品牌事件库-新")
@PostMapping("/event/newList")
public ResponseResult getEventListMiddleware(@RequestBody BrandkbsEventSearchDTO dto){
return ResponseResult.success(eventService.getEventListMiddleware(dto));
}
@ApiOperation("搜索-查竞品") @ApiOperation("搜索-查竞品")
@PostMapping("/contend/list") @PostMapping("/contend/list")
public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO) {
......
...@@ -54,6 +54,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -54,6 +54,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
} }
@Override @Override
@Deprecated
public List<String> getEvents(ChannelIndex channelIndex) { public List<String> getEvents(ChannelIndex channelIndex) {
// 添加渠道唯一标识 // 添加渠道唯一标识
Criteria criteria = addChannelIndex(channelIndex); Criteria criteria = addChannelIndex(channelIndex);
...@@ -68,18 +69,21 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -68,18 +69,21 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
} }
@Override @Override
@Deprecated
public Map<Long, List<Event>> getEventDay(ChannelIndex channelIndex, Long startTime, Long endTime) { public Map<Long, List<Event>> getEventDay(ChannelIndex channelIndex, Long startTime, Long endTime) {
// return getEventTimePattern(channelIndex, startTime, endTime, 8 + 2); // return getEventTimePattern(channelIndex, startTime, endTime, 8 + 2);
return getEventTimePatternNew(channelIndex, startTime, endTime, false); return getEventTimePatternNew(channelIndex, startTime, endTime, false);
} }
@Override @Override
@Deprecated
public Map<Long, List<Event>> getEventMonth(ChannelIndex channelIndex, Long startTime, Long endTime) { public Map<Long, List<Event>> getEventMonth(ChannelIndex channelIndex, Long startTime, Long endTime) {
// return getEventTimePattern(channelIndex, startTime, endTime, 6 + 1); // return getEventTimePattern(channelIndex, startTime, endTime, 6 + 1);
return getEventTimePatternNew(channelIndex, startTime, endTime, true); return getEventTimePatternNew(channelIndex, startTime, endTime, true);
} }
@Override @Override
@Deprecated
public long getEventCount(ChannelIndex channelIndex, List<String> eventEmotions, String emotion) { public long getEventCount(ChannelIndex channelIndex, List<String> eventEmotions, String emotion) {
long res = 0; long res = 0;
Criteria criteria = Criteria.where("channelFid").is(channelIndex.getFid()); Criteria criteria = Criteria.where("channelFid").is(channelIndex.getFid());
...@@ -98,11 +102,13 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -98,11 +102,13 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
} }
@Override @Override
@Deprecated
public long getEventCountByProjectIdAndContendId(Long startTime, Long endTime, String emotion, String projectId, String contendId) { public long getEventCountByProjectIdAndContendId(Long startTime, Long endTime, String emotion, String projectId, String contendId) {
return mongoTemplate.count(Query.query(eventCountCriteria(startTime, endTime, emotion, projectId, contendId)), COLLECTION_NAME); return mongoTemplate.count(Query.query(eventCountCriteria(startTime, endTime, emotion, projectId, contendId)), COLLECTION_NAME);
} }
@Override @Override
@Deprecated
public List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit) { public List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit) {
Query query = new Query(); Query query = new Query();
Criteria criteria = eventCountCriteria(startTime, endTime, emotion, projectId, contendId); Criteria criteria = eventCountCriteria(startTime, endTime, emotion, projectId, contendId);
...@@ -114,6 +120,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -114,6 +120,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
} }
@Override @Override
@Deprecated
public List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, List<String> emotions, String projectId, String contendId, int limit) { public List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, List<String> emotions, String projectId, String contendId, int limit) {
Query query = new Query(); Query query = new Query();
Criteria criteria = eventCountCriteria(startTime, endTime, emotions, projectId, contendId); Criteria criteria = eventCountCriteria(startTime, endTime, emotions, projectId, contendId);
...@@ -125,6 +132,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -125,6 +132,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
} }
@Override @Override
@Deprecated
public List<Event> getEventsByTotalChannelVolumeTop(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit) { public List<Event> getEventsByTotalChannelVolumeTop(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit) {
Query query = new Query(); Query query = new Query();
Criteria criteria = eventCountCriteria(startTime, endTime, emotion, projectId, contendId); Criteria criteria = eventCountCriteria(startTime, endTime, emotion, projectId, contendId);
...@@ -135,6 +143,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -135,6 +143,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
return mongoTemplate.find(query, clazz, COLLECTION_NAME); return mongoTemplate.find(query, clazz, COLLECTION_NAME);
} }
@Deprecated
private Criteria eventCountCriteria(Long startTime, Long endTime, String emotion, String projectId, String contendId) { private Criteria eventCountCriteria(Long startTime, Long endTime, String emotion, String projectId, String contendId) {
Criteria criteria = Criteria.where("projectId").is(projectId); Criteria criteria = Criteria.where("projectId").is(projectId);
criteria.and("contendId").is(contendId); criteria.and("contendId").is(contendId);
...@@ -257,6 +266,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -257,6 +266,7 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
return res; return res;
} }
@Deprecated
private Map<Long, List<Event>> getEventTimePatternNew(ChannelIndex channelIndex, Long startTime, Long endTime, boolean month) { private Map<Long, List<Event>> getEventTimePatternNew(ChannelIndex channelIndex, Long startTime, Long endTime, boolean month) {
Map<Long, List<Event>> res = new HashMap<>(); Map<Long, List<Event>> res = new HashMap<>();
String pattern; String pattern;
......
...@@ -58,11 +58,13 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve ...@@ -58,11 +58,13 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve
} }
@Override @Override
@Deprecated
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());
} }
@Override @Override
@Deprecated
public long getEventArticleWithChannelCount(Event event, ChannelIndex channelIndex) { public long getEventArticleWithChannelCount(Event event, ChannelIndex channelIndex) {
return count(Query.query(Criteria.where("eventId").is(event.getId()).and("source").is(channelIndex.getSource()).and("realSource").is(channelIndex.getRealSource()).and("platform").is(channelIndex.getPlatform())), event.getCollectionName()); return count(Query.query(Criteria.where("eventId").is(event.getId()).and("source").is(channelIndex.getSource()).and("realSource").is(channelIndex.getRealSource()).and("platform").is(channelIndex.getPlatform())), event.getCollectionName());
} }
...@@ -73,6 +75,7 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve ...@@ -73,6 +75,7 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve
} }
@Override @Override
@Deprecated
public List<EventData> findEventDataListByTime(String eventId, Date startTime, Date endTime, String collectionName) { public List<EventData> findEventDataListByTime(String eventId, Date startTime, Date endTime, String collectionName) {
Query query = Query.query(Criteria.where("eventId").is(eventId)); Query query = Query.query(Criteria.where("eventId").is(eventId));
query.addCriteria(Criteria.where("time").gte(startTime).lt(endTime)); query.addCriteria(Criteria.where("time").gte(startTime).lt(endTime));
...@@ -80,12 +83,14 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve ...@@ -80,12 +83,14 @@ public class EventDataDaoImpl extends BaseMongoDaoImpl<EventData> implements Eve
} }
@Override @Override
@Deprecated
public long findEventDataCount(String eventId, String collectionName) { public long findEventDataCount(String eventId, String collectionName) {
Query query = Query.query(Criteria.where("eventId").is(eventId)); Query query = Query.query(Criteria.where("eventId").is(eventId));
return mongoTemplate.count(query, EventData.class, collectionName); return mongoTemplate.count(query, EventData.class, collectionName);
} }
@Override @Override
@Deprecated
public Set<String> findEventIdsByChannelFid(String channelFid, long startTime, long endTime) { public Set<String> findEventIdsByChannelFid(String channelFid, long startTime, long endTime) {
Set<String> res = new HashSet<>(); Set<String> res = new HashSet<>();
Criteria criteria = Criteria.where("channelFid").is(channelFid).and("eventMapper.startTime").gte(startTime).lt(endTime); Criteria criteria = Criteria.where("channelFid").is(channelFid).and("eventMapper.startTime").gte(startTime).lt(endTime);
......
...@@ -22,7 +22,12 @@ public enum RoleEnum { ...@@ -22,7 +22,12 @@ public enum RoleEnum {
/** /**
* 客户 * 客户
*/ */
CUSTOMER(4, "客户"); CUSTOMER(4, "客户"),
/**
* 客户
*/
NO_AUTHORISE(-1, "无需权限");
private final int state; private final int state;
private final String name; private final String name;
......
...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.interceptor; ...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.interceptor;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.common.GenericAttribute; import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.CommonCodeEnum; import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.UserInfo; import com.zhiwei.brandkbs2.pojo.UserInfo;
...@@ -46,7 +47,7 @@ public class MainAuthInterceptor implements HandlerInterceptor { ...@@ -46,7 +47,7 @@ public class MainAuthInterceptor implements HandlerInterceptor {
} }
} }
// 不需要验证权限 // 不需要验证权限
if (null == auth) { if (null == auth || RoleEnum.NO_AUTHORISE == auth.role()) {
return true; return true;
} }
String token = request.getHeader("Token"); String token = request.getHeader("Token");
......
...@@ -2,7 +2,8 @@ package com.zhiwei.brandkbs2.pojo.dto; ...@@ -2,7 +2,8 @@ package com.zhiwei.brandkbs2.pojo.dto;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.zhiwei.brandkbs2.enmus.EventTagEnum; import com.zhiwei.brandkbs2.enmus.EventTagEnum;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.middleware.event.pojo.entity.Event;
import com.zhiwei.middleware.event.pojo.entity.EventTagBasicInfo;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
...@@ -39,10 +40,15 @@ public class ExportAppChannelEventDTO { ...@@ -39,10 +40,15 @@ public class ExportAppChannelEventDTO {
ExportAppChannelEventDTO dto = new ExportAppChannelEventDTO(); ExportAppChannelEventDTO dto = new ExportAppChannelEventDTO();
dto.setStartTime(new Date(event.getStartTime())); dto.setStartTime(new Date(event.getStartTime()));
dto.setEndTime(new Date(event.getEndTime())); dto.setEndTime(new Date(event.getEndTime()));
dto.setTitle(event.getTitle()); dto.setTitle(event.getName());
dto.setEmotion(event.getEmotion()); dto.setEmotion(event.getEmotionEventTag().getName());
dto.setInfluence(event.getInfluence()); dto.setInfluence(event.getInfluence());
dto.setEventType(event.getEventTag().getString(EventTagEnum.EVENT_TYPE.getName())); dto.setEventType(null);
for (EventTagBasicInfo eventTag : event.getEventTags()) {
if (eventTag.getGroupName().equals(EventTagEnum.EVENT_TYPE.getName())){
dto.setEventType(eventTag.getName());
}
}
return dto; return dto;
} }
} }
package com.zhiwei.brandkbs2.pojo.external; package com.zhiwei.brandkbs2.pojo.external;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.middleware.event.pojo.entity.Event;
import com.zhiwei.middleware.event.pojo.entity.EventTagBasicInfo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -65,14 +66,16 @@ public class BrandkbsHotEventWarn { ...@@ -65,14 +66,16 @@ public class BrandkbsHotEventWarn {
public static HotEvent createFromEvent(String type, Event event) { public static HotEvent createFromEvent(String type, Event event) {
HotEvent hotEvent = new HotEvent(); HotEvent hotEvent = new HotEvent();
hotEvent.setType(type); hotEvent.setType(type);
hotEvent.setTitle(event.getTitle()); hotEvent.setTitle(event.getName());
hotEvent.setEmotion(event.getEmotion()); hotEvent.setEmotion(event.getEmotionEventTag().getName());
hotEvent.setTotalChannelVolume(event.getTotalChannelVolume()); hotEvent.setTotalChannelVolume(event.getTotalChannelVolume());
hotEvent.setTotalDisseminationVolume(event.getTotalDisseminationVolume()); hotEvent.setTotalDisseminationVolume(event.getTotalDisseminationVolume());
hotEvent.setStartTime(event.getStartTime()); hotEvent.setStartTime(event.getStartTime());
hotEvent.setInfluence(event.getInfluence()); hotEvent.setInfluence(event.getInfluence());
List<String> tagList = // List<String> tagList = event.getEventTag().entrySet().stream().filter(entry -> !"情感倾向".equals(entry.getKey()))
event.getEventTag().entrySet().stream().filter(entry -> !"情感倾向".equals(entry.getKey())).map(entry -> String.valueOf(entry.getValue())).collect(Collectors.toList()); // .map(entry -> String.valueOf(entry.getValue())).collect(Collectors.toList());
List<String> tagList = event.getEventTags().stream().filter(eventTagBasicInfo -> !"情感倾向".equals(eventTagBasicInfo.getGroupName()))
.map(EventTagBasicInfo::getName).collect(Collectors.toList());
hotEvent.setTagList(tagList); hotEvent.setTagList(tagList);
return hotEvent; return hotEvent;
} }
......
...@@ -127,7 +127,7 @@ public class CommonServiceImpl implements CommonService { ...@@ -127,7 +127,7 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public Long[] getTimeRangeDay() { public Long[] getTimeRangeDay() {
long endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime(); long endTime = Tools.truncDate(new Date(), Constant.DAY_PATTERN).getTime();
long startTime = DateUtils.addDays(new Date(endTime), -1).getTime(); long startTime = DateUtils.addDays(new Date(endTime), -1).getTime();
return new Long[]{startTime, endTime}; return new Long[]{startTime, endTime};
} }
......
...@@ -19,12 +19,14 @@ import com.zhiwei.brandkbs2.service.MarkDataService; ...@@ -19,12 +19,14 @@ import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.RedisUtil; import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.event.core.EventClient;
import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform; import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.Period; import org.joda.time.Period;
import org.joda.time.PeriodType; import org.joda.time.PeriodType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -61,6 +63,9 @@ public class IndexServiceImpl implements IndexService { ...@@ -61,6 +63,9 @@ public class IndexServiceImpl implements IndexService {
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private EventClient eventClient;
@Override @Override
public JSONObject getYuqingAmount(Long startTime, Long endTime, boolean cache) { public JSONObject getYuqingAmount(Long startTime, Long endTime, boolean cache) {
if (null == startTime || null == endTime) { if (null == startTime || null == endTime) {
...@@ -184,11 +189,10 @@ public class IndexServiceImpl implements IndexService { ...@@ -184,11 +189,10 @@ public class IndexServiceImpl implements IndexService {
Long oldStartTime = startTime - (endTime - startTime); Long oldStartTime = startTime - (endTime - startTime);
int selectMonths = new Period(startTime, endTime, PeriodType.months()).getMonths(); int selectMonths = new Period(startTime, endTime, PeriodType.months()).getMonths();
selectMonths = 0 == selectMonths ? 1 : selectMonths; selectMonths = 0 == selectMonths ? 1 : selectMonths;
long total = eventDao.getEventCountByProjectIdAndContendId(null, null, EmotionEnum.ALL.getName(), projectId, contendId); // 调用事件中间件时,主品牌id使用项目id
long eventTotal = eventDao.getEventCountByProjectIdAndContendId long total = eventClient.getEventCountByProjectIdAndContendId(null, null, EmotionEnum.ALL.getName(), projectId, projectId);
(startTime, endTime, EmotionEnum.ALL.getName(), projectId, contendId); long eventTotal = eventClient.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.ALL.getName(), projectId, projectId);
long oldEventTotal = eventDao.getEventCountByProjectIdAndContendId long oldEventTotal = eventClient.getEventCountByProjectIdAndContendId(oldStartTime, endTime, EmotionEnum.ALL.getName(), projectId, projectId);
(oldStartTime, endTime, EmotionEnum.ALL.getName(), projectId, contendId);
jsonObject.put("eventTotal", eventTotal); jsonObject.put("eventTotal", eventTotal);
jsonObject.put("avgEventTotal", total * selectMonths / (totalMonths + 1)); jsonObject.put("avgEventTotal", total * selectMonths / (totalMonths + 1));
jsonObject.put("compare", oldEventTotal == 0 ? 0d : (eventTotal - oldEventTotal) / (double) oldEventTotal); jsonObject.put("compare", oldEventTotal == 0 ? 0d : (eventTotal - oldEventTotal) / (double) oldEventTotal);
...@@ -418,12 +422,14 @@ public class IndexServiceImpl implements IndexService { ...@@ -418,12 +422,14 @@ public class IndexServiceImpl implements IndexService {
*/ */
private JSONObject getTopEvent(Long startTime, Long endTime, String projectId, String contendId) { private JSONObject getTopEvent(Long startTime, Long endTime, String projectId, String contendId) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
List<Event> eventList = eventDao.getEventsByProjectIdAndContendId(startTime, endTime, EmotionEnum.ALL.getName(), projectId, contendId, 1); contendId = Objects.equals(contendId, Constant.PRIMARY_CONTEND_ID) ? projectId : contendId;
List<com.zhiwei.middleware.event.pojo.entity.Event> eventList =
eventClient.getEventsByProjectIdAndContendId(startTime, endTime, EmotionEnum.ALL.getName(), projectId, contendId, 1);
if (CollectionUtils.isNotEmpty(eventList)) { if (CollectionUtils.isNotEmpty(eventList)) {
Event event = eventList.get(0); com.zhiwei.middleware.event.pojo.entity.Event event = eventList.get(0);
long articleCount = eventDataDao.getEventArticleCount(event); long articleCount = eventClient.getEventArticleCount(event);
result.put("id", event.getId()); result.put("id", event.getId());
result.put("title", event.getTitle()); result.put("title", event.getName());
result.put("influence", event.getInfluence()); result.put("influence", event.getInfluence());
result.put("articleCount", articleCount); result.put("articleCount", articleCount);
} }
...@@ -535,7 +541,8 @@ public class IndexServiceImpl implements IndexService { ...@@ -535,7 +541,8 @@ public class IndexServiceImpl implements IndexService {
result.put("normalCount", normalCount); result.put("normalCount", normalCount);
result.put("time", startTime); result.put("time", startTime);
//统计时间段总事件数 //统计时间段总事件数
long eventCount = eventDao.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.ALL.getName(), projectId, "0"); // 调用事件中间件时,主品牌id使用项目id
long eventCount = eventClient.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.ALL.getName(), projectId, projectId);
result.put("eventCount", eventCount); result.put("eventCount", eventCount);
lineList.add(result); lineList.add(result);
} }
...@@ -556,10 +563,11 @@ public class IndexServiceImpl implements IndexService { ...@@ -556,10 +563,11 @@ public class IndexServiceImpl implements IndexService {
Long startTime = map.get("startTime"); Long startTime = map.get("startTime");
Long endTime = map.get("endTime"); Long endTime = map.get("endTime");
//统计时间段总事件数 //统计时间段总事件数
long totalEventCount = eventDao.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.ALL.getName(), projectId, contendId); // 调用事件中间件时,主品牌id使用项目id
long posEventCount = eventDao.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, contendId); long totalEventCount = eventClient.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.ALL.getName(), projectId, projectId);
long neuEventCount = eventDao.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, contendId); long posEventCount = eventClient.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, projectId);
long negEventCount = eventDao.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, contendId); long neuEventCount = eventClient.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, projectId);
long negEventCount = eventClient.getEventCountByProjectIdAndContendId(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, projectId);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("totalCount", totalEventCount); result.put("totalCount", totalEventCount);
result.put("posCount", posEventCount); result.put("posCount", posEventCount);
......
...@@ -18,6 +18,9 @@ import com.zhiwei.brandkbs2.service.ProjectService; ...@@ -18,6 +18,9 @@ import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.ProjectWarnService; import com.zhiwei.brandkbs2.service.ProjectWarnService;
import com.zhiwei.brandkbs2.util.RedisUtil; import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.event.core.EventClient;
import com.zhiwei.middleware.event.pojo.entity.Event;
import com.zhiwei.middleware.event.pojo.entity.EventTagBasicInfo;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -78,6 +81,9 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -78,6 +81,9 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
@Resource(name = "redisUtil") @Resource(name = "redisUtil")
RedisUtil redisUtil; RedisUtil redisUtil;
@Autowired
private EventClient eventClient;
private static final Map<String, String> TYPE_SEARCH = new HashMap<>(); private static final Map<String, String> TYPE_SEARCH = new HashMap<>();
static { static {
...@@ -297,7 +303,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -297,7 +303,7 @@ 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));
} }
private BrandkbsWarnTemplate brandkbsWarnTemplate4HotEvent(BrandkbsHotEventConfig config, Map<String, List<Event>> eventMap, long start, long end, AbstractProject project) { private BrandkbsWarnTemplate brandkbsWarnTemplate4HotEvent(BrandkbsHotEventConfig config, Map<String, List<com.zhiwei.middleware.event.pojo.entity.Event>> eventMap, long start, long end, AbstractProject project) {
int firstCount = eventMap.values().stream().mapToInt(List::size).sum(); int firstCount = eventMap.values().stream().mapToInt(List::size).sum();
if (firstCount == 0) { if (firstCount == 0) {
return null; return null;
...@@ -313,17 +319,17 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -313,17 +319,17 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
final int limit = 2; final int limit = 2;
int count = limit; int count = limit;
out: out:
for (List<Event> value : eventMap.values()) { for (List<com.zhiwei.middleware.event.pojo.entity.Event> value : eventMap.values()) {
for (Event event : value) { for (Event event : value) {
if (--count == 0) { if (--count == 0) {
if (firstCount <= limit) { if (firstCount <= limit) {
keyBuilder4.append(event.getTitle()); keyBuilder4.append(event.getName());
} else { } else {
keyBuilder4.append(event.getTitle()).append("\r\n"); keyBuilder4.append(event.getName()).append("\r\n");
} }
break out; break out;
} else { } else {
keyBuilder4.append(event.getTitle()).append("\r\n"); keyBuilder4.append(event.getName()).append("\r\n");
} }
} }
} }
...@@ -332,7 +338,8 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -332,7 +338,8 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
} else { } else {
key4 = keyBuilder4.toString(); key4 = keyBuilder4.toString();
} }
Map<String, List<BrandkbsHotEventWarn.HotEvent>> collect = eventMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().stream().map(event -> BrandkbsHotEventWarn.HotEvent.createFromEvent(entry.getKey(), event)).collect(Collectors.toList()))); Map<String, List<BrandkbsHotEventWarn.HotEvent>> collect = eventMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue()
.stream().map(event -> BrandkbsHotEventWarn.HotEvent.createFromEvent(entry.getKey(), event)).collect(Collectors.toList())));
// List<BrandkbsHotEventWarn.HotEvent> collect = eventMap.entrySet().stream().map(entry -> entry.getValue().stream(). // List<BrandkbsHotEventWarn.HotEvent> collect = eventMap.entrySet().stream().map(entry -> entry.getValue().stream().
// map(event -> BrandkbsHotEventWarn.HotEvent.createFromEvent(entry.getKey(), event)).collect(Collectors.toList())). // map(event -> BrandkbsHotEventWarn.HotEvent.createFromEvent(entry.getKey(), event)).collect(Collectors.toList())).
// collect(Collectors.toList()).stream().flatMap(List::stream).collect(Collectors.toList()); // collect(Collectors.toList()).stream().flatMap(List::stream).collect(Collectors.toList());
...@@ -718,30 +725,39 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -718,30 +725,39 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
long start = end - Constant.ONE_DAY * 7; long start = end - Constant.ONE_DAY * 7;
try { try {
log.info("获取热点事件预警开始,project:{}", project.getProjectName()); log.info("获取热点事件预警开始,project:{}", project.getProjectName());
Map<String, List<Event>> eventMap = new LinkedHashMap<>(); Map<String, List<com.zhiwei.middleware.event.pojo.entity.Event>> eventMap = new LinkedHashMap<>();
if (CollectionUtils.isNotEmpty(config.getOwnEvent())) { if (CollectionUtils.isNotEmpty(config.getOwnEvent())) {
List<Event> ownEvents = eventDao.getEventsByProjectIdAndContendId(start, end, config.getOwnEvent(), projectId, "0", config.getEventTop()); // 调用事件中间件时,使用项目id作为主品牌id
List<com.zhiwei.middleware.event.pojo.entity.Event> ownEvents =
eventClient.getEventsByProjectIdAndContendId(start, end, config.getOwnEvent(), projectId, projectId, config.getEventTop());
eventMap.put("品牌动态", ownEvents); eventMap.put("品牌动态", ownEvents);
} }
if (CollectionUtils.isNotEmpty(config.getContendsEvent())) { if (CollectionUtils.isNotEmpty(config.getContendsEvent())) {
List<Event> contentEvents = new ArrayList<>(); List<com.zhiwei.middleware.event.pojo.entity.Event> contentEvents = new ArrayList<>();
for (String contendId : config.getContendsEvent()) { for (String contendId : config.getContendsEvent()) {
contentEvents.addAll(eventDao.getEventsByProjectIdAndContendId(start, end, config.getOwnEvent(), projectId, contendId, config.getEventTop())); contendId = Objects.equals(Constant.PRIMARY_CONTEND_ID, contendId) ? projectId : contendId;
contentEvents.addAll(eventClient.getEventsByProjectIdAndContendId(start, end, config.getOwnEvent(), projectId, contendId, config.getEventTop()));
} }
eventMap.put("友商动态", contentEvents); eventMap.put("友商动态", contentEvents);
} }
if (CollectionUtils.isNotEmpty(config.getZhiWeiEvent())) { if (CollectionUtils.isNotEmpty(config.getZhiWeiEvent())) {
List<Event> externalEvents = new ArrayList<>(); List<com.zhiwei.middleware.event.pojo.entity.Event> externalEvents = new ArrayList<>();
ResponseEntity<String> forEntity = restTemplate.getForEntity(getExternalFilterNewUrl, String.class, config.getZhiWeiEvent().toArray(), start, end); ResponseEntity<String> forEntity = restTemplate.getForEntity(getExternalFilterNewUrl, String.class, config.getZhiWeiEvent().toArray(), start, end);
JSONObject jsonObject = JSON.parseObject(forEntity.getBody()); JSONObject jsonObject = JSON.parseObject(forEntity.getBody());
JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("events"); JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("events");
for (int i = 0; i < config.getEventTop(); i++) { for (int i = 0; i < config.getEventTop(); i++) {
JSONObject zhiweiEvent = jsonArray.getJSONObject(i); JSONObject zhiweiEvent = jsonArray.getJSONObject(i);
Event event = new Event(); com.zhiwei.middleware.event.pojo.entity.Event event = new com.zhiwei.middleware.event.pojo.entity.Event();
event.setTitle(zhiweiEvent.getString("eventname")); event.setName(zhiweiEvent.getString("eventname"));
JSONObject eventTag = new JSONObject(); // JSONObject eventTag = new JSONObject();
eventTag.put("事件类型", zhiweiEvent.getString("type")); // eventTag.put("事件类型", zhiweiEvent.getString("type"));
event.setEventTag(eventTag); // event.setEventTag(eventTag);
EventTagBasicInfo eventTagBasicInfo = new EventTagBasicInfo();
eventTagBasicInfo.setGroupName("事件类型");
eventTagBasicInfo.setName(zhiweiEvent.getString("type"));
List<EventTagBasicInfo> infos = new ArrayList<>(1);
infos.add(eventTagBasicInfo);
event.setEventTags(infos);
event.setTotalDisseminationVolume(zhiweiEvent.getLong("allCount")); event.setTotalDisseminationVolume(zhiweiEvent.getLong("allCount"));
event.setStartTime(zhiweiEvent.getLong("startTime")); event.setStartTime(zhiweiEvent.getLong("startTime"));
event.setInfluence(zhiweiEvent.getDouble("index")); event.setInfluence(zhiweiEvent.getDouble("index"));
......
...@@ -28,6 +28,8 @@ import com.zhiwei.brandkbs2.service.ReportService; ...@@ -28,6 +28,8 @@ import com.zhiwei.brandkbs2.service.ReportService;
import com.zhiwei.brandkbs2.util.MongoUtil; import com.zhiwei.brandkbs2.util.MongoUtil;
import com.zhiwei.brandkbs2.util.RedisUtil; import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.event.core.EventClient;
import com.zhiwei.middleware.event.pojo.entity.BrandkbsBasicInfo;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
...@@ -86,6 +88,9 @@ public class ReportServiceImpl implements ReportService { ...@@ -86,6 +88,9 @@ public class ReportServiceImpl implements ReportService {
@Autowired @Autowired
StringRedisTemplate stringRedisTemplate; StringRedisTemplate stringRedisTemplate;
@Autowired
private EventClient eventClient;
@Override @Override
public Map<String, ReportSettingsDTO> getReportSettings() { public Map<String, ReportSettingsDTO> getReportSettings() {
Map<String, ReportSettingsDTO> res = new HashMap<>(); Map<String, ReportSettingsDTO> res = new HashMap<>();
...@@ -348,7 +353,9 @@ public class ReportServiceImpl implements ReportService { ...@@ -348,7 +353,9 @@ public class ReportServiceImpl implements ReportService {
result.put("curPosTotal", curPositiveTotal); result.put("curPosTotal", curPositiveTotal);
result.put("curPosPro", curTotal == 0 ? 0 : curPositiveTotal * 1.0 / curTotal); result.put("curPosPro", curTotal == 0 ? 0 : curPositiveTotal * 1.0 / curTotal);
//正面事件传播量top //正面事件传播量top
List<Event> topPosEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, contendId, 3); // 调用事件中间件时,主品牌id使用项目id
List<com.zhiwei.middleware.event.pojo.entity.Event> topPosEventList =
eventClient.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, projectId, 3);
if (CollectionUtils.isEmpty(topPosEventList)) { if (CollectionUtils.isEmpty(topPosEventList)) {
List<Map.Entry<String, Integer>> topPosArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, linkedGroupId, contendId, 3); List<Map.Entry<String, Integer>> topPosArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, linkedGroupId, contendId, 3);
result.put("topPosSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topPosArticleList)); result.put("topPosSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topPosArticleList));
...@@ -364,7 +371,9 @@ public class ReportServiceImpl implements ReportService { ...@@ -364,7 +371,9 @@ public class ReportServiceImpl implements ReportService {
result.put("curNeuTotal", curNeutralTotal); result.put("curNeuTotal", curNeutralTotal);
result.put("curNeuPro", curTotal == 0 ? 0 : curNeutralTotal * 1.0 / curTotal); result.put("curNeuPro", curTotal == 0 ? 0 : curNeutralTotal * 1.0 / curTotal);
//中性事件传播量top //中性事件传播量top
List<Event> topNeuEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, contendId, 4); // 调用事件中间件时,主品牌id使用项目id
List<com.zhiwei.middleware.event.pojo.entity.Event> topNeuEventList =
eventClient.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, projectId, 4);
if (CollectionUtils.isEmpty(topNeuEventList)) { if (CollectionUtils.isEmpty(topNeuEventList)) {
List<Map.Entry<String, Integer>> topNeuArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, linkedGroupId, contendId, 4); List<Map.Entry<String, Integer>> topNeuArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, linkedGroupId, contendId, 4);
result.put("topNeuSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNeuArticleList)); result.put("topNeuSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNeuArticleList));
...@@ -380,7 +389,9 @@ public class ReportServiceImpl implements ReportService { ...@@ -380,7 +389,9 @@ public class ReportServiceImpl implements ReportService {
result.put("curNegTotal", curNegativeTotal); result.put("curNegTotal", curNegativeTotal);
result.put("curNegPro", curTotal == 0 ? 0 : curNegativeTotal * 1.0 / curTotal); result.put("curNegPro", curTotal == 0 ? 0 : curNegativeTotal * 1.0 / curTotal);
//中性事件传播量top //中性事件传播量top
List<Event> topNegEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, contendId, 4); // 调用事件中间件时,主品牌id使用项目id
List<com.zhiwei.middleware.event.pojo.entity.Event> topNegEventList =
eventClient.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, projectId, 4);
if (CollectionUtils.isEmpty(topNegEventList)) { if (CollectionUtils.isEmpty(topNegEventList)) {
List<Map.Entry<String, Integer>> topNegArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, linkedGroupId, contendId, 4); List<Map.Entry<String, Integer>> topNegArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, linkedGroupId, contendId, 4);
result.put("topNegSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNegArticleList)); result.put("topNegSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNegArticleList));
...@@ -457,17 +468,24 @@ public class ReportServiceImpl implements ReportService { ...@@ -457,17 +468,24 @@ public class ReportServiceImpl implements ReportService {
return emotions.stream().map(emotion -> { return emotions.stream().map(emotion -> {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("name", Objects.equals(emotion, EmotionEnum.POSITIVE.getName()) ? "正面事件" : Objects.equals(emotion, EmotionEnum.NEGATIVE.getName()) ? "负面事件" : "中性事件"); result.put("name", Objects.equals(emotion, EmotionEnum.POSITIVE.getName()) ? "正面事件" : Objects.equals(emotion, EmotionEnum.NEGATIVE.getName()) ? "负面事件" : "中性事件");
List<Event> topEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, emotion, projectId, contendId, 10); // 调用事件中间件时,主品牌id使用项目id
List<com.zhiwei.middleware.event.pojo.entity.Event> topEventList =
eventClient.getEventsByTotalChannelVolumeTop(startTime, endTime, emotion, projectId, projectId, 10);
result.put("events", topEventList.stream().map(event -> { result.put("events", topEventList.stream().map(event -> {
JSONObject topEvent = new JSONObject(); JSONObject topEvent = new JSONObject();
boolean hasAnalyze = Objects.equals(event.getContendId(), Constant.PRIMARY_CONTEND_ID); boolean hasAnalyze = false;
for (BrandkbsBasicInfo brandkbsInfo : event.getBrandkbsInfos()) {
if (brandkbsInfo.getBrandkbsProjectId().equals(projectId) && brandkbsInfo.getBrandkbsBrandId().equals(projectId)){
hasAnalyze = true;
}
}
topEvent.put("id", event.getId()); topEvent.put("id", event.getId());
String title = event.getTitle(); String title = event.getName();
topEvent.put("title", title.length() <= 30 ? title : title.substring(0, 30) + "..."); topEvent.put("title", title.length() <= 30 ? title : title.substring(0, 30) + "...");
topEvent.put("influence", event.getInfluence()); topEvent.put("influence", event.getInfluence());
topEvent.put("articleCount", event.getTotalDisseminationVolume()); topEvent.put("articleCount", event.getTotalDisseminationVolume());
//查询首发稿件 // 首发稿件
EventData firstData = eventDataDao.findFirstData(event.getId(), event.getCollectionName()); com.zhiwei.middleware.event.pojo.entity.EventData firstData = event.getOriginArticle();
topEvent.put("firstSource", Objects.isNull(firstData) ? "" : firstData.getSource()); topEvent.put("firstSource", Objects.isNull(firstData) ? "" : firstData.getSource());
topEvent.put("hasAnalyze", hasAnalyze); topEvent.put("hasAnalyze", hasAnalyze);
return topEvent; return topEvent;
...@@ -516,12 +534,18 @@ public class ReportServiceImpl implements ReportService { ...@@ -516,12 +534,18 @@ public class ReportServiceImpl implements ReportService {
* @param topEventList top事件集合 * @param topEventList top事件集合
* @return top事件信息 * @return top事件信息
*/ */
private List<JSONObject> getTopEventMsg(List<Event> topEventList) { private List<JSONObject> getTopEventMsg(List<com.zhiwei.middleware.event.pojo.entity.Event> topEventList) {
String projectId = UserThreadLocal.getProjectId();
return topEventList.stream().map(event -> { return topEventList.stream().map(event -> {
boolean hasAnalyze = Objects.equals(event.getContendId(), Constant.PRIMARY_CONTEND_ID); boolean hasAnalyze = false;
for (BrandkbsBasicInfo brandkbsInfo : event.getBrandkbsInfos()) {
if (brandkbsInfo.getBrandkbsProjectId().equals(projectId) && brandkbsInfo.getBrandkbsBrandId().equals(projectId)){
hasAnalyze = true;
}
}
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("id", event.getId()); jsonObject.put("id", event.getId());
String title = event.getTitle(); String title = event.getName();
jsonObject.put("title", title.length() <= 30 ? title : title.substring(0, 30) + "..."); jsonObject.put("title", title.length() <= 30 ? title : title.substring(0, 30) + "...");
jsonObject.put("hasAnalyze", hasAnalyze); jsonObject.put("hasAnalyze", hasAnalyze);
return jsonObject; return jsonObject;
......
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