Commit aaeb0883 by shenjunjie

2022/8/22 15:41

parent 628bd882
...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.auth.Auth; ...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.auth.Auth;
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;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
import com.zhiwei.brandkbs2.service.EventService; import com.zhiwei.brandkbs2.service.EventService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -56,15 +57,9 @@ public class AppEventController extends BaseController { ...@@ -56,15 +57,9 @@ public class AppEventController extends BaseController {
} }
@ApiOperation("前台事件库-品牌事件库") @ApiOperation("前台事件库-品牌事件库")
@GetMapping("/list") @PostMapping("/list")
public ResponseResult getEventList(@RequestParam(value = "contendId", defaultValue = "0") String contendId, public ResponseResult getEventList(@RequestBody EventSearchDTO eventSearchDTO) {
@RequestParam(value = "emotion", defaultValue = "全部") String emotion, return ResponseResult.success(eventService.getEventList(eventSearchDTO));
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@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.getEventList(contendId, emotion, startTime, endTime, page, pageSize, sorter));
} }
@ApiOperation("前台事件库-事件详情-基础信息") @ApiOperation("前台事件库-事件详情-基础信息")
......
package com.zhiwei.brandkbs2.pojo.dto; package com.zhiwei.brandkbs2.pojo.dto;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @ClassName: EventSearchDto * @ClassName: EventSearchDto
...@@ -19,18 +19,50 @@ import java.util.Map; ...@@ -19,18 +19,50 @@ import java.util.Map;
@ApiModel("事件信息传输类") @ApiModel("事件信息传输类")
public class EventSearchDTO { public class EventSearchDTO {
private Map<String, List<String>> tags; /**
* 页码
@ApiModelProperty("搜索条件") */
private String searchInfo; @ApiModelProperty("页码")
private Integer page = 1;
private Integer page; /**
* 大小
private Integer pageSize; */
@ApiModelProperty("页码大小")
private Integer brandId; private Integer pageSize = 50;
/**
* 开始时间
*/
@ApiModelProperty("开始时间")
private Long startTime; private Long startTime;
/**
* 结束时间
*/
@ApiModelProperty("结束时间")
private Long endTime; private Long endTime;
/**
* 品牌ID结合
*/
@ApiModelProperty(value = "品牌ID")
private String contendId= "0";
/**
* 情感倾向集合
*/
@ApiModelProperty(value = "情感倾向集合")
private List<String> emotions;
/**
* 排序字段
*/
@ApiModelProperty(value = "排序字段")
private JSONObject sorter = JSONObject.parseObject("{\"startTime\":\"descend\"}");
/**
* 搜索关键词
*/
@ApiModelProperty(value = "关键词")
private String keyword;
/**
* 传播量
*/
@ApiModelProperty(value = "传播量")
private Long[] totalDisseminationVolumes;
} }
package com.zhiwei.brandkbs2.pojo.vo; package com.zhiwei.brandkbs2.pojo.vo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.enmus.EventTagEnum;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventData; import com.zhiwei.brandkbs2.pojo.EventData;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -8,8 +9,6 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -8,8 +9,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import java.util.stream.Collectors;
/** /**
* @Description: 事件库列表VO * @Description: 事件库列表VO
* @Author: shentao * @Author: shentao
...@@ -89,7 +88,7 @@ public class EventListInfoVO { ...@@ -89,7 +88,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().values().stream().map(String::valueOf).collect(Collectors.joining("|")); this.eventTag = null == event.getEventTag() ? null : event.getEventTag().getString(EventTagEnum.EVENT_TYPE.getName());
this.negativeArticleVolume = event.getNegativeArticleVolume(); this.negativeArticleVolume = event.getNegativeArticleVolume();
this.articleEmotionProportions = event.getArticleEmotionProportions(); this.articleEmotionProportions = event.getArticleEmotionProportions();
this.articlePlatformProportions = event.getArticlePlatformProportions(); this.articlePlatformProportions = event.getArticlePlatformProportions();
......
...@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO; ...@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend; import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO; import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO; import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.EventListInfoVO; import com.zhiwei.brandkbs2.pojo.vo.EventListInfoVO;
import com.zhiwei.brandkbs2.pojo.vo.EventVO; import com.zhiwei.brandkbs2.pojo.vo.EventVO;
...@@ -223,16 +224,10 @@ public interface EventService { ...@@ -223,16 +224,10 @@ public interface EventService {
/** /**
* 获取品牌事件列表信息 * 获取品牌事件列表信息
* @param contendId * @param eventSearchDTO 事件搜索类
* @param emotion
* @param startTime
* @param endTime
* @param page
* @param pageSize
* @param sorter
* @return * @return
*/ */
PageVO<EventListInfoVO> getEventList(String contendId, String emotion, Long startTime, Long endTime, int page, int pageSize, String sorter); PageVO<EventListInfoVO> getEventList(EventSearchDTO eventSearchDTO);
/** /**
* 事件详情-基础静态信息 * 事件详情-基础静态信息
......
...@@ -27,6 +27,7 @@ import com.zhiwei.brandkbs2.pojo.EventData; ...@@ -27,6 +27,7 @@ import com.zhiwei.brandkbs2.pojo.EventData;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend; import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis; import com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis;
import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO; import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO; import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.*; import com.zhiwei.brandkbs2.pojo.vo.*;
import com.zhiwei.brandkbs2.service.EventDataService; import com.zhiwei.brandkbs2.service.EventDataService;
...@@ -522,26 +523,35 @@ public class EventServiceImpl implements EventService { ...@@ -522,26 +523,35 @@ public class EventServiceImpl implements EventService {
// 时间 // 时间
result.put("times", getDefaultTimes()); result.put("times", getDefaultTimes());
// 传播量 // 传播量
result.put("articleAmount", Arrays.asList("全部", "1-100", "100-500", "1000-5000", ">5000")); result.put("totalDisseminationVolume", getDefaultVolumes());
return result; return result;
} }
@Override @Override
public PageVO<EventListInfoVO> getEventList(String contendId, String emotion, Long startTime, Long endTime, int page, int pageSize, String sorter) { public PageVO<EventListInfoVO> getEventList(EventSearchDTO eventSearchDTO) {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
// 查询条件 // 查询条件
Query query = Query.query(Criteria.where("projectId").is(projectId).and("contendId").is(contendId)); Query query = Query.query(Criteria.where("projectId").is(projectId).and("contendId").is(eventSearchDTO.getContendId()));
if (Objects.nonNull(emotion) && !"全部".equals(emotion)) { if (!(Objects.isNull(eventSearchDTO.getEmotions()) || eventSearchDTO.getEmotions().contains("全部"))) {
query.addCriteria(Criteria.where("emotion").is(emotion)); query.addCriteria(Criteria.where("emotion").in(eventSearchDTO.getEmotions()));
}
if (Objects.nonNull(eventSearchDTO.getStartTime()) && Objects.nonNull(eventSearchDTO.getEndTime())) {
query.addCriteria(Criteria.where("startTime").gte(eventSearchDTO.getStartTime()).lt(eventSearchDTO.getEndTime()));
} }
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)) { // 传播量
query.addCriteria(Criteria.where("startTime").gte(startTime).lt(endTime)); if (Objects.nonNull(eventSearchDTO.getTotalDisseminationVolumes())) {
Long[] totalDisseminationVolumes = eventSearchDTO.getTotalDisseminationVolumes();
Criteria volumeCriteria = Criteria.where("totalDisseminationVolume").gte(totalDisseminationVolumes[0]);
if (-1 != totalDisseminationVolumes[1]) {
volumeCriteria.lt(totalDisseminationVolumes[1]);
}
query.addCriteria(volumeCriteria);
} }
// 总数 // 总数
long total = eventDao.count(query); long total = eventDao.count(query);
// 排序 // 排序
eventDao.addSort(query, sorter); eventDao.addSort(query, eventSearchDTO.getSorter().toJSONString());
mongoUtil.start(page, pageSize, query); mongoUtil.start(eventSearchDTO.getPage(), eventSearchDTO.getPageSize(), query);
// 数据 // 数据
List<Event> eventList = eventDao.findList(query); List<Event> eventList = eventDao.findList(query);
// vo封装 // vo封装
...@@ -558,7 +568,8 @@ public class EventServiceImpl implements EventService { ...@@ -558,7 +568,8 @@ public class EventServiceImpl implements EventService {
sortMap.get(event.getId()).setFirstEventData(r); sortMap.get(event.getId()).setFirstEventData(r);
return null; return null;
})).toArray(CompletableFuture[]::new)).join(); })).toArray(CompletableFuture[]::new)).join();
return PageVO.createPageVo(total, page, pageSize, eventList.stream().map(event -> sortMap.get(event.getId())).collect(Collectors.toList())); return PageVO.createPageVo(total, eventSearchDTO.getPage(), eventSearchDTO.getPageSize(),
eventList.stream().map(event -> sortMap.get(event.getId())).collect(Collectors.toList()));
} }
@Override @Override
...@@ -659,6 +670,28 @@ public class EventServiceImpl implements EventService { ...@@ -659,6 +670,28 @@ public class EventServiceImpl implements EventService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
private List<JSONObject> getDefaultVolumes() {
List<JSONObject> res = new ArrayList<>();
for (String name : Arrays.asList("全部", "1-100", "100-1000", "1000-5000", ">=5000")) {
JSONObject json = new JSONObject();
json.put("name", name);
switch (name) {
case "全部":
json.put("totalDisseminationVolumes", null);
break;
case ">=5000":
json.put("totalDisseminationVolumes", new Long[]{5000L, -1L});
break;
default:
String[] split = name.split("-");
json.put("totalDisseminationVolumes", new Long[]{Long.parseLong(split[0]), Long.parseLong(split[1])});
}
res.add(json);
}
return res;
}
/** /**
* 获取事件调性筛选条件 * 获取事件调性筛选条件
* *
......
...@@ -428,13 +428,25 @@ public class IndexServiceImpl implements IndexService { ...@@ -428,13 +428,25 @@ public class IndexServiceImpl implements IndexService {
*/ */
private JSONObject getTopSource(long startTime, long endTime, String projectId, String linkedGroupId, String contendId) throws IOException { private JSONObject getTopSource(long startTime, long endTime, String projectId, String linkedGroupId, String contendId) throws IOException {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
List<Map<String, Object>> positiveList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.POSITIVE.getName(), 3); // TODO 等待线上es数据格式调整
List<Map<String, Object>> negativeList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.NEGATIVE.getName(), 1); // List<Map<String, Object>> positiveList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.POSITIVE.getName(), 3);
result.put("positiveList", positiveList); // List<Map<String, Object>> negativeList = markDataService.getEsTopSource(startTime, endTime, projectId, linkedGroupId, contendId, EmotionEnum.NEGATIVE.getName(), 1);
result.put("negativeList", negativeList); result.put("positiveList", tempTopSource());
result.put("negativeList", tempTopSource());
return result; return result;
} }
private List<Map<String, Object>> tempTopSource() {
List<Map<String, Object>> channelResultList = new ArrayList<>();
Map<String, Object> result = new HashMap<>();
result.put("id", "testId");
result.put("source", "source");
result.put("platform", "微信");
result.put("num", "1");
channelResultList.add(result);
return channelResultList;
}
/** /**
* 传播趋势 * 传播趋势
* *
......
...@@ -1302,7 +1302,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -1302,7 +1302,7 @@ public class MarkDataServiceImpl implements MarkDataService {
public List<Map<String, Object>> getEsTopSource(Long startTime, Long endTime, String projectId, String linkedGroupId, String contendId, String emotion, int size) throws IOException { public List<Map<String, Object>> getEsTopSource(Long startTime, Long endTime, String projectId, String linkedGroupId, String contendId, String emotion, int size) throws IOException {
EsClientDao.SearchHelper searchHelper = EsClientDao.createSearchHelper(); EsClientDao.SearchHelper searchHelper = EsClientDao.createSearchHelper();
// 聚合条件 // 聚合条件
Script script = new Script("doc['platform_id'].keyword +'_' +doc['real_source'].keyword+'_' +doc['source'].keyword"); Script script = new Script("doc['platform_id'].value +'_' +doc['real_source'].value+'_' +doc['source'].value");
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("agg").script(script).order(BucketOrder.count(false)); TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("agg").script(script).order(BucketOrder.count(false));
searchHelper.setAggregationBuilder(aggregationBuilder); searchHelper.setAggregationBuilder(aggregationBuilder);
// query // query
......
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