Commit b993b864 by shentao

2022/8/4 事件详情接口补充

parent 42eacde3
......@@ -7,10 +7,7 @@ import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.EventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.bind.annotation.*;
/**
* @Description: 前台事件库
......@@ -47,5 +44,35 @@ public class AppEventController extends BaseController {
return ResponseResult.success(eventService.getEventList(linkedGroupId, emotion, startTime, endTime, page, pageSize, sorter));
}
@ApiOperation("前台事件库-事件详情-基础信息")
@GetMapping("/info/base/{id}")
public ResponseResult getEventBaseInfo(@PathVariable String id) {
return ResponseResult.success(eventService.getEventBaseInfo(id));
}
@ApiOperation("前台事件库-事件详情-传播趋势图")
@GetMapping("/info/dissemination-trends/{id}")
public ResponseResult getEventDisseminationTrends(@PathVariable String id, @RequestParam(value = "type", defaultValue = "小时") String type) {
return ResponseResult.success(eventService.getEventDisseminationTrends(id, type));
}
@ApiOperation("前台事件库-事件详情-渠道发声")
@GetMapping("/info/channel-voices/{id}")
public ResponseResult getEventChannelVoices(@PathVariable String id,
@RequestParam(value = "type", defaultValue = "重要渠道") String type,
@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "50") int pageSize,
@RequestParam(value = "sorter", required = false) String sorter) {
return ResponseResult.success(eventService.getEventChannelVoices(id, type, page, pageSize, sorter));
}
@ApiOperation("前台事件库-事件详情-热门文章分析")
@GetMapping("/info/top-articles-analysis/{id}")
public ResponseResult getEventTopArticlesAnalysis(@PathVariable String id,
@RequestParam(value = "type", defaultValue = "按时间") String type,
@RequestParam(value = "emotion", defaultValue = "全部") String emotion,
@RequestParam(value = "aggTitle", required = false) String aggTitle) {
return ResponseResult.success(eventService.getEventTopArticlesAnalysis(id, type, emotion, aggTitle));
}
}
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import org.springframework.data.mongodb.core.query.Query;
/**
* @Description:EventDisseminationTrendDao
* @Author: shentao
* @Date: 2022/8/3 16:21
*/
public interface EventDisseminationTrendDao extends BaseMongoDao<EventDisseminationTrend>{
/**
* 按条件获取单个
* @param query
* @return
*/
EventDisseminationTrend findOne(Query query);
}
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis;
/**
* @Description:EventTopArticlesAnalysisDao
* @Author: shentao
* @Date: 2022/8/3 16:23
*/
public interface EventTopArticlesAnalysisDao extends BaseMongoDao<EventTopArticlesAnalysis>{
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.EventDisseminationTrendDao;
import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
/**
* @Description:
* @Author: shentao
* @Date: 2022/8/4 16:53
*/
@Component("eventDisseminationTrendDao")
public class EventDisseminationTrendDaoImpl extends BaseMongoDaoImpl<EventDisseminationTrend> implements EventDisseminationTrendDao {
private static final String COLLECTION_NAME = "brandkbs_event_dissemination_trend";
public EventDisseminationTrendDaoImpl() {
super(COLLECTION_NAME);
}
@Override
public EventDisseminationTrend findOne(Query query) {
return mongoTemplate.findOne(query, EventDisseminationTrend.class);
}
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.EventTopArticlesAnalysisDao;
import com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis;
import org.springframework.stereotype.Component;
/**
* @Description:
* @Author: shentao
* @Date: 2022/8/3 16:23
*/
@Component("eventTopArticlesAnalysisDao")
public class EventTopArticlesAnalysisDaoImpl extends BaseMongoDaoImpl<EventTopArticlesAnalysis> implements EventTopArticlesAnalysisDao {
private static final String COLLECTION_NAME = "brandkbs_event_top_articles_analysis";
public EventTopArticlesAnalysisDaoImpl() {
super(COLLECTION_NAME);
}
}
......@@ -86,6 +86,22 @@ public class Event extends AbstractBaseMongo {
* 参与渠道数
*/
private Long totalChannelVolume;
/**
* 负面稿件数
*/
private Long negativeArticleVolume;
/**
* 正负中稿件比例
*/
private JSONObject articleEmotionProportions;
/**
* 平台稿件比例
*/
private JSONObject articlePlatformProportions;
/**
* 热门文章分析,传播方向:
*/
private String eventTopArticlesAnalysisDetail;
public static Event createFromYqEventDTO(YqEventDTO yqEventDTO, String collectionName, String projectId, String linkedGroupId) {
Event event = new Event();
......
......@@ -83,6 +83,10 @@ public class EventData extends AbstractBaseMongo {
* 原创/转发(微博平台)
*/
private boolean isForward;
/**
* 来源标签(重要渠道)
*/
private String sourceTag;
public static EventData createFromEsMap(Map<String, Object> map, Event event) {
EventData data = new EventData();
......
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.List;
import java.util.Map;
/**
* @Description: 事件传播趋势
* @Author: shentao
* @Date: 2022/8/3 14:33
*/
@Getter
@Setter
@Document(collection = "brandkbs_event_dissemination_trend")
public class EventDisseminationTrend extends AbstractBaseMongo{
/**
* 负面稿件传播
*/
private List<Map<String,Object>> negativeSpread;
/**
* 总稿件传播
*/
private List<Map<String,Object>> totalSpread;
/**
* 类型 按小时、按天
*/
private String type;
/**
* 关联事件id
*/
private String eventId;
}
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* @Description: 事件热门文章分析
* @Author: shentao
* @Date: 2022/8/3 16:01
*/
@Getter
@Setter
@Document(collection = "brandkbs_event_top_articles_analysis")
public class EventTopArticlesAnalysis extends AbstractBaseMongo{
/**
* 聚合标题
*/
private String aggTitle;
/**
* 聚合标题
*/
private String emotion;
/**
* 聚合数
*/
private String count;
/**
* 发布时间
*/
private Long time;
/**
* 发布时间点(天级) 查询用
*/
private String timePoint;
/**
* type 按时间、按数量
*/
private String type;
/**
* 关联事件id
*/
private String eventId;
}
package com.zhiwei.brandkbs2.pojo.vo;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventData;
import io.swagger.annotations.ApiModel;
......@@ -7,8 +8,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -66,6 +65,21 @@ public class EventListInfoVO {
*/
@ApiModelProperty("事件首发稿件")
private EventData firstEventData;
/**
* 负面稿件数
*/
@ApiModelProperty("负面稿件数")
private Long negativeArticleVolume;
/**
* 正负中稿件比例
*/
@ApiModelProperty("正负中稿件比例")
private JSONObject articleEmotionProportions;
/**
* 平台稿件比例
*/
@ApiModelProperty("平台稿件比例")
private JSONObject articlePlatformProportions;
public EventListInfoVO(Event event) {
this.id = event.getId();
......@@ -78,5 +92,8 @@ public class EventListInfoVO {
this.eventTag = event.getEventTag().entrySet().stream()
.map(entry-> String.valueOf(entry.getValue()))
.collect(Collectors.joining("|"));
this.negativeArticleVolume = event.getNegativeArticleVolume();
this.articleEmotionProportions = event.getArticleEmotionProportions();
this.articlePlatformProportions = event.getArticlePlatformProportions();
}
}
package com.zhiwei.brandkbs2.pojo.vo;
import com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis;
import lombok.Data;
import lombok.ToString;
/**
* @Description:
* @Author: shentao
* @Date: 2022/8/4 17:56
*/
@Data
@ToString
public class EventTopArticlesAnalysisVO {
/**
* 聚合标题
*/
private String aggTitle;
/**
* 聚合标题
*/
private String emotion;
/**
* 聚合数
*/
private String count;
/**
* 发布时间
*/
private Long time;
/**
* 发布时间点(天级) 查询用
*/
private String timePoint;
/**
* type 按时间、按数量
*/
private String type;
/**
* 关联事件id
*/
private String eventId;
/**
* 选中高亮
*/
private Boolean highLight;
public EventTopArticlesAnalysisVO(EventTopArticlesAnalysis eventTopArticlesAnalysis, boolean highLight) {
this.aggTitle = eventTopArticlesAnalysis.getAggTitle();
this.emotion = eventTopArticlesAnalysis.getEmotion();
this.count = eventTopArticlesAnalysis.getCount();
this.time = eventTopArticlesAnalysis.getTime();
this.timePoint = eventTopArticlesAnalysis.getTimePoint();
this.type = eventTopArticlesAnalysis.getType();
this.eventId = eventTopArticlesAnalysis.getEventId();
this.highLight = highLight;
}
}
......@@ -5,16 +5,16 @@ import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDataDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO;
import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventData;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO;
import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.EventListInfoVO;
import com.zhiwei.brandkbs2.pojo.vo.EventVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.pojo.vo.YqEventSearchVO;
import com.zhiwei.brandkbs2.pojo.vo.*;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
/**
* @ClassName: EventService
......@@ -220,5 +220,52 @@ public interface EventService {
*/
JSONObject getEventsSearchCriteria();
/**
* 获取品牌事件列表信息
* @param linkedGroupId
* @param emotion
* @param startTime
* @param endTime
* @param page
* @param pageSize
* @param sorter
* @return
*/
PageVO<EventListInfoVO> getEventList(String linkedGroupId, String emotion, Long startTime, Long endTime, int page, int pageSize, String sorter);
/**
* 事件详情-基础静态信息
* @param eventId
* @return
*/
EventListInfoVO getEventBaseInfo(String eventId);
/**
* 事件详情-传播趋势图
* @param eventId
* @param type
* @return
*/
EventDisseminationTrend getEventDisseminationTrends(String eventId, String type);
/**
* 事件详情-渠道发声
* @param eventId
* @param type
* @param page
* @param pageSize
* @param sorter
* @return
*/
PageVO<EventData> getEventChannelVoices(String eventId, String type, int page, int pageSize, String sorter);
/**
* 事件详情-热门文章分析
* @param id
* @param type
* @param emotion
* @param aggTitle
* @return
*/
Map<String, List<EventTopArticlesAnalysisVO>> getEventTopArticlesAnalysis(String id, String type, String emotion, String aggTitle);
}
......@@ -7,6 +7,8 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import com.zhiwei.brandkbs2.dao.EventDao;
import com.zhiwei.brandkbs2.dao.EventDataDao;
import com.zhiwei.brandkbs2.dao.EventDisseminationTrendDao;
import com.zhiwei.brandkbs2.dao.EventTopArticlesAnalysisDao;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.config.ReadExcelDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDTO;
......@@ -22,6 +24,8 @@ import com.zhiwei.brandkbs2.listener.ApplicationProjectListener;
import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventData;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis;
import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO;
import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.*;
......@@ -81,6 +85,12 @@ public class EventServiceImpl implements EventService {
@Resource(name = "eventDataDao")
private EventDataDao eventDataDao;
@Resource(name = "eventDisseminationTrendDao")
private EventDisseminationTrendDao eventDisseminationTrendDao;
@Resource(name = "eventTopArticlesAnalysisDao")
private EventTopArticlesAnalysisDao eventTopArticlesAnalysisDao;
@Resource(name = "eventDataServiceImpl")
private EventDataService eventDataService;
......@@ -546,6 +556,73 @@ public class EventServiceImpl implements EventService {
return pageVo;
}
@Override
public EventListInfoVO getEventBaseInfo(String eventId) {
Event event = getEventById(eventId);
// vo封装
EventListInfoVO vo = new EventListInfoVO(event);
// 放入首发稿件
vo.setFirstEventData(eventDataDao.findFirstData(event.getId(), event.getCollectionName()));
return vo;
}
@Override
public EventDisseminationTrend getEventDisseminationTrends(String eventId, String type) {
Query query = new Query(Criteria.where("eventId").is(eventId).and("type").is(type));
return eventDisseminationTrendDao.findOne(query);
}
@Override
public PageVO<EventData> getEventChannelVoices(String eventId, String type, int page, int pageSize, String sorter) {
Event event = getEventById(eventId);
Query query = Query.query(Criteria.where("eventId").is(eventId));
if (Objects.equals("重要渠道", type)) {
query.addCriteria(Criteria.where("sourceTag").ne(null));
}
// 排序
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 = eventDataDao.count(query, event.getCollectionName());
int start = pageSize * (page - 1);
query.limit(pageSize).skip(start);
// 数据
List<EventData> eventDataList = eventDataDao.findList(query, event.getCollectionName());
PageVO<EventData> pageVo = PageVO.createPageVo(total, page, pageSize, eventDataList);
return pageVo;
}
@Override
public Map<String, List<EventTopArticlesAnalysisVO>> getEventTopArticlesAnalysis(String eventId, String type, String emotion, String aggTitle) {
Query query = new Query(Criteria.where("eventId").is(eventId).and("type").is(type));
if (!Objects.equals("全部", emotion)) {
query.addCriteria(Criteria.where("emotion").is(emotion));
}
List<EventTopArticlesAnalysis> eventTopArticlesAnalyses = eventTopArticlesAnalysisDao.findList(query);
switch (type){
case "按时间":
Map<String, List<EventTopArticlesAnalysisVO>> collect = eventTopArticlesAnalyses.stream()
.map(eventTopArticlesAnalysis -> {
boolean highLight = Objects.equals(aggTitle, eventTopArticlesAnalysis.getAggTitle());
return new EventTopArticlesAnalysisVO(eventTopArticlesAnalysis, highLight);
}).collect(Collectors.groupingBy(EventTopArticlesAnalysisVO::getTimePoint));
return collect;
case "按数量":
// TODO: 2022/8/4
return null;
default:
throw new IllegalStateException("Unexpected value: " + type);
}
}
/**
* 获取时间筛选条件
*
......
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