Commit 8408fc8b by shenjunjie

Merge branch 'feature' into 'dev'

Feature

See merge request !72
parents 563923c7 61c2e442
...@@ -16,11 +16,13 @@ public class Constant { ...@@ -16,11 +16,13 @@ public class Constant {
public static final Long ONE_DAY = 24 * 60 * 60 * 1000L; public static final Long ONE_DAY = 24 * 60 * 60 * 1000L;
public static final Long ONE_MONTH = 30 * 24 * 60 * 60 * 1000L; public static final Long ONE_MONTH = 30 * 24 * 60 * 60 * 1000L;
public static final String SPEC_MINUTE_PATTERN = "yyyy.MM.dd HH:mm";
public static final String HOUR_PATTERN = "yyyy-MM-dd HH"; public static final String HOUR_PATTERN = "yyyy-MM-dd HH";
public static final String DAY_PATTERN = "yyyy-MM-dd"; public static final String DAY_PATTERN = "yyyy-MM-dd";
public static final String MONTH_PATTERN = "yyyy-MM"; public static final String MONTH_PATTERN = "yyyy-MM";
public static final String YEAR_PATTERN = "yyyy"; public static final String YEAR_PATTERN = "yyyy";
public static final FastDateFormat SPEC_MINUTE_FORMAT = FastDateFormat.getInstance(SPEC_MINUTE_PATTERN);
public static final FastDateFormat HOUR_FORMAT = FastDateFormat.getInstance(HOUR_PATTERN); public static final FastDateFormat HOUR_FORMAT = FastDateFormat.getInstance(HOUR_PATTERN);
public static final FastDateFormat DAY_FORMAT = FastDateFormat.getInstance(DAY_PATTERN); public static final FastDateFormat DAY_FORMAT = FastDateFormat.getInstance(DAY_PATTERN);
public static final FastDateFormat SPEC_DAY_FORMAT = FastDateFormat.getInstance("yyyy/MM/dd"); public static final FastDateFormat SPEC_DAY_FORMAT = FastDateFormat.getInstance("yyyy/MM/dd");
......
package com.zhiwei.brandkbs2.controller; package com.zhiwei.brandkbs2.controller;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsChannelConfig;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsHotEventConfig;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsHotTopConfig;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsYuQingConfig;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.ProjectWarnService; import com.zhiwei.brandkbs2.service.ProjectWarnService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -34,10 +37,55 @@ public class InterfaceController { ...@@ -34,10 +37,55 @@ public class InterfaceController {
return projectWarnService.getProjectWarnCriteria(projectId, type); return projectWarnService.getProjectWarnCriteria(projectId, type);
} }
@ApiOperation("获取项目预警详细信息默认值")
@GetMapping("/getProjectWarnCriteria/default")
public ResponseResult getProjectWarnCriteriaDefault(String projectId, String type) {
return projectWarnService.getProjectWarnCriteriaDefault(projectId, type);
}
@ApiOperation("根据userId获取拥有权限项目") @ApiOperation("根据userId获取拥有权限项目")
@GetMapping("/getUserAllProjectsByUserId") @GetMapping("/getUserAllProjectsByUserId")
public ResponseResult getUserAllProjectsByUserId(String userId) { public ResponseResult getUserAllProjectsByUserId(String userId) {
return ResponseResult.success(projectService.getUserAllProjectsPrimary(userId)); return ResponseResult.success(projectService.getUserAllProjectsPrimary(userId));
} }
@ApiOperation("获取舆情动态-预警结果")
@PostMapping("/warn/yuqing")
public ResponseResult getYuqingWaring(@RequestBody JSONObject json) {
String projectId = json.getString("projectId");
BrandkbsYuQingConfig config = json.getObject("config", BrandkbsYuQingConfig.class);
return projectWarnService.getYuqingWaring(projectId, config);
}
@ApiOperation("获取渠道参与-预警结果")
@PostMapping("/warn/channel")
public ResponseResult getChannelWaring(@RequestBody JSONObject json) {
String projectId = json.getString("projectId");
BrandkbsChannelConfig config = json.getObject("config", BrandkbsChannelConfig.class);
return projectWarnService.getChannelWaring(projectId, config);
}
@ApiOperation("获取热点事件-预警结果")
@PostMapping("/warn/hotEvent")
public ResponseResult getHotEventWaring(@RequestBody JSONObject json) {
String projectId = json.getString("projectId");
BrandkbsHotEventConfig config = json.getObject("config", BrandkbsHotEventConfig.class);
return projectWarnService.getHotEventWaring(projectId, config);
}
@ApiOperation("获取热点事件-预警结果")
@PostMapping("/warn/hotTop")
public ResponseResult getHotTopWaring(@RequestBody JSONObject json) {
String projectId = json.getString("projectId");
BrandkbsHotTopConfig config = json.getObject("config", BrandkbsHotTopConfig.class);
return projectWarnService.getHotTopWaring(projectId, config);
}
@ApiOperation("获取热点事件-预警结果")
@PostMapping("/warn/newCase")
public ResponseResult getNewCaseWaring(@RequestBody JSONObject json) {
String projectId = json.getString("projectId");
return projectWarnService.getNewCaseWaring(projectId);
}
} }
...@@ -94,6 +94,18 @@ public interface EventDao extends BaseMongoDao<Event> { ...@@ -94,6 +94,18 @@ public interface EventDao extends BaseMongoDao<Event> {
*/ */
List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit); List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit);
/**
* 根据特征值获取事件
*
* @param startTime
* @param endTime
* @param emotions
* @param projectId
* @param contendId
* @return
*/
List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, List<String> emotions, String projectId, String contendId, int limit);
List<Event> getEventsByTotalChannelVolumeTop(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit); List<Event> getEventsByTotalChannelVolumeTop(Long startTime, Long endTime, String emotion, String projectId, String contendId, int limit);
......
...@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.enmus.EmotionEnum; ...@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.pojo.ChannelIndex; import com.zhiwei.brandkbs2.pojo.ChannelIndex;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.mongodb.core.aggregation.Aggregation; import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationOperation; import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
...@@ -106,6 +107,17 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -106,6 +107,17 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
} }
@Override @Override
public List<Event> getEventsByProjectIdAndContendId(Long startTime, Long endTime, List<String> emotions, String projectId, String contendId, int limit) {
Query query = new Query();
Criteria criteria = eventCountCriteria(startTime, endTime, emotions, projectId, contendId);
query.addCriteria(criteria);
query.limit(limit);
// 按影响力排序
addSort(query, "{\"influence\":\"descend\"}");
return mongoTemplate.find(query, clazz, COLLECTION_NAME);
}
@Override
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);
...@@ -132,6 +144,28 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao { ...@@ -132,6 +144,28 @@ public class EventDaoImpl extends BaseMongoDaoImpl<Event> implements EventDao {
return criteria; return criteria;
} }
private Criteria eventCountCriteria(Long startTime, Long endTime, List<String> emotions, String projectId, String contendId) {
Criteria criteria = Criteria.where("projectId").is(projectId);
criteria.and("contendId").is(contendId);
Criteria startTimeCriteria = criteria.and("startTime");
if (null != startTime) {
startTimeCriteria.gte(startTime);
}
if (null != endTime) {
startTimeCriteria.lt(endTime);
}
List<Criteria> criteriaList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(emotions) && !emotions.contains(EmotionEnum.ALL.getName())) {
for (String emotion : emotions) {
criteriaList.add(Criteria.where("emotion").is(emotion));
}
}
if (!criteriaList.isEmpty()) {
criteria.orOperator(criteriaList.toArray(new Criteria[0]));
}
return criteria;
}
/** /**
* mongo版本不支持toString/toObjectId 表达式 * mongo版本不支持toString/toObjectId 表达式
* 已被getEventCount 代替 * 已被getEventCount 代替
......
...@@ -110,6 +110,21 @@ public class EsQueryTools { ...@@ -110,6 +110,21 @@ public class EsQueryTools {
return nestedBoolQueryBuilder; return nestedBoolQueryBuilder;
} }
public static BoolQueryBuilder assembleCacheMapsQueryWithProject(String projectId, List<String> mediaTypes) {
BoolQueryBuilder nestedBoolQueryBuilder = QueryBuilders.boolQuery();
// must key
nestedBoolQueryBuilder.must(cacheMapsNestedQuery(QueryBuilders.termQuery("brandkbs_cache_maps.project_id.keyword", projectId)));
// mediaType
if (CollectionUtils.isNotEmpty(mediaTypes)) {
BoolQueryBuilder mediaTypeQueryBuilder = QueryBuilders.boolQuery();
mediaTypes.forEach(e -> {
mediaTypeQueryBuilder.should(cacheMapsNestedQuery(QueryBuilders.termQuery("brandkbs_cache_maps.channel_type.keyword", e)));
});
nestedBoolQueryBuilder.must(mediaTypeQueryBuilder);
}
return nestedBoolQueryBuilder;
}
public static BoolQueryBuilder assembleCacheMapsQueryExcludePrimaryId(String projectId){ public static BoolQueryBuilder assembleCacheMapsQueryExcludePrimaryId(String projectId){
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(cacheMapsNestedQuery(QueryBuilders.termQuery("brandkbs_cache_maps.project_id.keyword", projectId))); query.must(cacheMapsNestedQuery(QueryBuilders.termQuery("brandkbs_cache_maps.project_id.keyword", projectId)));
...@@ -176,7 +191,7 @@ public class EsQueryTools { ...@@ -176,7 +191,7 @@ public class EsQueryTools {
BoolQueryBuilder contendQuery = QueryBuilders.boolQuery(); BoolQueryBuilder contendQuery = QueryBuilders.boolQuery();
// 主品牌一定参与 // 主品牌一定参与
// contendQuery.should(QueryBuilders.termQuery("contend_id.keyword", "0")); // contendQuery.should(QueryBuilders.termQuery("contend_id.keyword", "0"));
if (null == contends) { if (CollectionUtils.isEmpty(contends)) {
return; return;
} }
for (String contendId : contends) { for (String contendId : contends) {
...@@ -210,6 +225,20 @@ public class EsQueryTools { ...@@ -210,6 +225,20 @@ public class EsQueryTools {
} }
/** /**
* 针对微博平台转发 查询语句
*
* @param isForward
* @return
*/
public static BoolQueryBuilder assembleForwardQuery(boolean isForward) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
BoolQueryBuilder notWeiboCondition = QueryBuilders.boolQuery();
queryBuilder.should(notWeiboCondition.mustNot(QueryBuilders.termQuery("platform_id", "5d02236e6395002a7c380b79")));
queryBuilder.should(QueryBuilders.termQuery("is_forward", isForward));
return queryBuilder;
}
/**
* 字段不拆封,多字段 同关键词 * 字段不拆封,多字段 同关键词
* *
* @param @param boolQueryBuilder * @param @param boolQueryBuilder
......
...@@ -70,6 +70,10 @@ public class BaseMap { ...@@ -70,6 +70,10 @@ public class BaseMap {
private JSONObject sourceJson; private JSONObject sourceJson;
private String brandName;
private Double channelEmotionIndex;
/** /**
* 当标题为空时用文本截取前20个字代替 * 当标题为空时用文本截取前20个字代替
* *
......
package com.zhiwei.brandkbs2.pojo.external;
import com.zhiwei.base.category.ClassB;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.pojo.BaseMap;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: BaseMapCompound
* @Description BaseMapCompound
* @author: sjj
* @date: 2022-11-02 16:21
*/
@Data
@AllArgsConstructor
public class BaseMapCompound {
/**
* 基础字段
*/
private BaseMap baseMap;
/**
* 标签列表
*/
private List<String> tags;
public static BaseMapCompound createFromBaseMap(BaseMap baseMap, String projectId) {
List<String> tagList = new ArrayList<>();
// 情感倾向
tagList.add(baseMap.getEmotion());
// 媒体类型
String mediaType = GlobalPojo.getMediaType(projectId, baseMap.getPlatform(), baseMap.getSource());
if (null != mediaType) {
tagList.add(mediaType);
}
// 仅针对微博平台的 原创/转发 标签
if (ClassB.TypeB.INCOMPLETE.equals(baseMap.getTypeB())) {
tagList.add(baseMap.isForward() ? "转发" : "原创");
}
// 竞品品牌标签
if (null != baseMap.getBrandName()) {
tagList.add(baseMap.getBrandName());
}
return new BaseMapCompound(baseMap, tagList);
}
}
\ No newline at end of file
package com.zhiwei.brandkbs2.pojo.external;
import lombok.Data;
import java.util.List;
@Data
public class BrandkbsChannelConfig {
private String configName;
/**
* 友好渠道
*/
private Boolean friendlyChannel;
/**
* 阈值
*/
private int threshold;
/**
* 自定义渠道
*/
private String channel;
/**
* 是否转发
*/
private List<Boolean> primary;
/**
* 舆情标签
*/
private List<String> markerTags;
/**
* 是否去重
*/
private Boolean duplicate;
/**
* pushInterval 推送间隔
*/
private Long pushInterval;
private boolean used;
public BrandkbsChannelConfig() {
this.used = false;
this.pushInterval = 10 * 60 * 1000L;
}
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @ClassName: BrandkbsChannelWarn
* @Description BrandkbsChannelWarn
* @author: sjj
* @date: 2022-11-02 16:45
*/
@Data
@AllArgsConstructor
public class BrandkbsChannelWarn {
/**
* 基础数据
*/
private List<BaseMapCompound> list;
/**
* 预警理由
*/
private String channelWarnReason;
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.Data;
import java.util.List;
@Data
public class BrandkbsHotEventConfig {
private String configName;
/**
* 本品事件
*/
private List<String> ownEvent;
/**
* 竞品事件
*/
private List<String> contendsEvent;
/**
* zhiwei事件
*/
private List<String> zhiWeiEvent;
/**
* 事件top
*/
private int eventTop;
/**
* 时间周期
*/
private int timeCycles;
private boolean used;
public BrandkbsHotEventConfig() {
this.used = false;
this.timeCycles = 2;
}
}
package com.zhiwei.brandkbs2.pojo.external;
import com.zhiwei.brandkbs2.pojo.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
import java.util.stream.Collectors;
/**
* @ClassName: BrandkbsHotEventWarn
* @Description BrandkbsHotEventWarn
* @author: sjj
* @date: 2022-11-02 16:49
*/
@Data
@AllArgsConstructor
public class BrandkbsHotEventWarn {
private List<HotEvent> hotEventList;
@Data
public static class HotEvent {
/**
* 类别名称
*/
private String type;
/**
* 事件标题
*/
private String title;
/**
* 事件情感倾向
*/
private String emotion;
/**
* 总传播量
*/
private Long totalDisseminationVolume;
/**
* 参与渠道数
*/
private Long totalChannelVolume;
/**
* 开始时间
*/
private Long startTime;
/**
* 影响力
*/
private double influence;
/**
* 标签列表
*/
private List<String> tagList;
public static HotEvent createFromEvent(String type, Event event) {
HotEvent hotEvent = new HotEvent();
hotEvent.setType(type);
hotEvent.setTitle(event.getTitle());
hotEvent.setEmotion(event.getEmotion());
hotEvent.setTotalChannelVolume(event.getTotalChannelVolume());
hotEvent.setTotalDisseminationVolume(event.getTotalDisseminationVolume());
hotEvent.setStartTime(event.getStartTime());
hotEvent.setInfluence(event.getInfluence());
List<String> tagList =
event.getEventTag().entrySet().stream().filter(entry -> !"情感倾向".equals(entry.getKey())).map(entry -> String.valueOf(entry.getValue())).collect(Collectors.toList());
hotEvent.setTagList(tagList);
return hotEvent;
}
}
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.Data;
import java.util.List;
@Data
public class BrandkbsHotTopConfig {
private String configName;
/**
* 预警关键字
*/
private String warnKeyword;
/**
* 过滤词
*/
private String filterKeyword;
/**
* 榜单类型
*/
private List<String> listType;
/**
* 预警类型 首次上榜
*/
private Boolean firstTop;
/**
*
*/
private Boolean newHeight;
/**
* 新高
*/
private int topNewHeight;
/**
* 再一次上榜
*/
private Boolean topOnceAgain;
private Boolean introduction;
/**
* pushInterval 推送间隔
*/
private Long pushInterval;
private boolean used;
public BrandkbsHotTopConfig() {
this.used = false;
this.pushInterval = 5 * 60 * 1000L;
}
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @ClassName: BrandkbsHotTopWarn
* @Description BrandkbsHotTopWarn
* @author: sjj
* @date: 2022-11-03 17:00
*/
@Data
@AllArgsConstructor
public class BrandkbsHotTopWarn {
private String warnKeyword;
private String filterKeyword;
private List<HotTop> list;
@Data
public static class HotTop {
/**
* 热搜标题
*/
private String title;
/**
* 上榜理由
*/
private String topReason;
/**
* 上榜排名
*/
private String rank;
/**
* 热度
*/
private String hot;
/**
* 榜单名称
*/
private String topName;
/**
* 上榜时间
*/
private Long time;
}
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @ClassName: BrandkbsNewCaseWarn
* @Description BrandkbsNewCaseWarn
* @author: sjj
* @date: 2022-11-03 17:11
*/
@Data
@AllArgsConstructor
public class BrandkbsNewCaseWarn {
private List<NewCase> list;
@Data
public static class NewCase {
/**
* 标题
*/
private String title;
/**
* 标签列表
*/
private List<String> tagList;
/**
* 正文本
*/
private String content;
/**
* 公关传播效果指数
*/
private Double spreadIndex;
/**
* 案例类别
*/
private String caseType;
}
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @ClassName: BrandkbsWarnTemplate
* @Description BrandkbsWarnTemplate
* @author: sjj
* @date: 2022-11-03 13:48
*/
@Data
@AllArgsConstructor
public class BrandkbsWarnTemplate {
private String id;
private String detailsUrl;
private int firstCount;
private String keyword1;
private String keyword2;
private String keyword3;
private String keyword4;
private BrandkbsYuQingWarn warn1;
private BrandkbsChannelWarn warn2;
private BrandkbsHotEventWarn warn3;
private BrandkbsHotTopWarn warn4;
private BrandkbsNewCaseWarn warn5;
private String warnType;
private Long pushTime;
public BrandkbsWarnTemplate(int firstCount, String keyword1, String keyword2, String keyword3, String keyword4, BrandkbsYuQingWarn warn1) {
this.firstCount = firstCount;
this.keyword1 = keyword1;
this.keyword2 = keyword2;
this.keyword3 = keyword3;
this.keyword4 = keyword4;
this.warn1 = warn1;
}
public BrandkbsWarnTemplate(int firstCount, String keyword1, String keyword2, String keyword3, String keyword4, BrandkbsChannelWarn warn2) {
this.firstCount = firstCount;
this.keyword1 = keyword1;
this.keyword2 = keyword2;
this.keyword3 = keyword3;
this.keyword4 = keyword4;
this.warn2 = warn2;
}
public BrandkbsWarnTemplate(int firstCount, String keyword1, String keyword2, String keyword3, String keyword4, BrandkbsHotEventWarn warn3) {
this.firstCount = firstCount;
this.keyword1 = keyword1;
this.keyword2 = keyword2;
this.keyword3 = keyword3;
this.keyword4 = keyword4;
this.warn3 = warn3;
}
public BrandkbsWarnTemplate(int firstCount, String keyword1, String keyword2, String keyword3, String keyword4, BrandkbsHotTopWarn warn4) {
this.firstCount = firstCount;
this.keyword1 = keyword1;
this.keyword2 = keyword2;
this.keyword3 = keyword3;
this.keyword4 = keyword4;
this.warn4 = warn4;
}
public BrandkbsWarnTemplate(int firstCount, String keyword1, String keyword2, String keyword3, String keyword4, BrandkbsNewCaseWarn warn5) {
this.firstCount = firstCount;
this.keyword1 = keyword1;
this.keyword2 = keyword2;
this.keyword3 = keyword3;
this.keyword4 = keyword4;
this.warn5 = warn5;
}
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.Data;
import java.util.List;
@Data
public class BrandkbsYuQingConfig {
private String configName;
/**
* 发声渠道
*/
private List<String> channelTypes;
/**
* 文章类型
*/
private List<Boolean> primary;
/**
* 本品舆情
*/
private List<String> markerTags;
/**
* 竞品舆情
*/
private List<String> contends;
/**
* 是否去重
*/
private Boolean duplicate;
/**
* 关键字命中
*/
private String keyword;
/**
* pushInterval 推送间隔
*/
private Long pushInterval;
private boolean used;
public BrandkbsYuQingConfig() {
this.used = false;
this.pushInterval = 60 * 60 * 1000L;
}
}
package com.zhiwei.brandkbs2.pojo.external;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @ClassName: BrandkbsYuQingWarn
* @Description BrandkbsYuQingWarn
* @author: sjj
* @date: 2022-11-02 16:10
*/
@Data
@AllArgsConstructor
public class BrandkbsYuQingWarn {
/**
* 基础数据
*/
private List<BaseMapCompound> list;
}
package com.zhiwei.brandkbs2.service; package com.zhiwei.brandkbs2.service;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsChannelConfig;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsHotEventConfig;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsHotTopConfig;
import com.zhiwei.brandkbs2.pojo.external.BrandkbsYuQingConfig;
public interface ProjectWarnService { public interface ProjectWarnService {
...@@ -12,4 +16,16 @@ public interface ProjectWarnService { ...@@ -12,4 +16,16 @@ public interface ProjectWarnService {
*/ */
ResponseResult getProjectWarnCriteria(String projectId, String type); ResponseResult getProjectWarnCriteria(String projectId, String type);
ResponseResult getProjectWarnCriteriaDefault(String projectId, String type);
ResponseResult getYuqingWaring(String projectId, BrandkbsYuQingConfig brandkbsYuQingConfig);
ResponseResult getChannelWaring(String projectId, BrandkbsChannelConfig brandkbsChannelConfig);
ResponseResult getHotEventWaring(String projectId, BrandkbsHotEventConfig brandkbsHotEventConfig);
ResponseResult getHotTopWaring(String projectId, BrandkbsHotTopConfig config);
ResponseResult getNewCaseWaring(String projectId);
} }
...@@ -876,7 +876,11 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -876,7 +876,11 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override @Override
public List<JSONObject> searchMarkDataByEvent(Event event) { public List<JSONObject> searchMarkDataByEvent(Event event) {
String linkedGroupId = projectService.getProjectByContendId(event.getProjectId(), event.getContendId()).getBrandLinkedGroupId(); String linkedGroupId = projectService.getProjectByContendId(event.getProjectId(), event.getContendId()).getBrandLinkedGroupId();
return searchMarkDataByTime(event.getProjectId(), linkedGroupId, event.getContendId(), event.getStartTime(), event.getEndTime(), EVENT_FETCH_SOURCE); Long endTime = null;
if (event.isEndStatus()) {
endTime = event.getEndTime();
}
return searchMarkDataByTime(event.getProjectId(), linkedGroupId, event.getContendId(), event.getStartTime(), endTime, EVENT_FETCH_SOURCE);
} }
@Override @Override
......
...@@ -894,6 +894,16 @@ public class Tools { ...@@ -894,6 +894,16 @@ public class Tools {
return new JSONObject(); return new JSONObject();
} }
public static JSONObject getBrandkbsHitMapWithProjectId(Map<String, Object> esMap, String projectId) {
List<Map<String, Object>> cacheMaps = (List<Map<String, Object>>) esMap.get(GenericAttribute.ES_BRANDKBS_CACHE_MAPS);
for (Map<String, Object> cacheMap : cacheMaps) {
if (projectId.equals(cacheMap.get("project_id"))) {
return new JSONObject(cacheMap);
}
}
return new JSONObject();
}
public static <T> Map<String, T> sortTimeKeyMap(Map<String, T> map, FastDateFormat timePattern, boolean isDesc) { public static <T> Map<String, T> sortTimeKeyMap(Map<String, T> map, FastDateFormat timePattern, boolean isDesc) {
Map<String, T> res = new LinkedHashMap<>(); Map<String, T> res = new LinkedHashMap<>();
List<Map.Entry<String, T>> sortKey = map.entrySet().stream().sorted((x, y) -> { List<Map.Entry<String, T>> sortKey = map.entrySet().stream().sorted((x, y) -> {
......
...@@ -80,3 +80,16 @@ istarshine.getIStarShineKSInfoData.url=https://istarshine-service.zhiweidata.com ...@@ -80,3 +80,16 @@ istarshine.getIStarShineKSInfoData.url=https://istarshine-service.zhiweidata.com
whole.search.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/yuqing whole.search.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/yuqing
whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/pt whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/pt
whole.extraParam.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param whole.extraParam.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param
#\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/project?projectId={1}&projectName={2}
warn.ticket.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
warn.channel.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/channel/{1}
warn.hotEvent.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/hotEvent/{1}
warn.hotTop.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/hotTop/{1}
warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/yuQing/{1}
warn.taskSwitch.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
\ No newline at end of file
...@@ -39,8 +39,8 @@ es.password=3vh65l$i6qQA ...@@ -39,8 +39,8 @@ es.password=3vh65l$i6qQA
es.index.test = true es.index.test = true
#channel-index #channel-index
channel.index.registry=zookeeper://192.168.0.11:2182?backup=192.168.0.30:2182,192.168.0.35:2182&timeout=60000 channel.index.registry=zookeeper://192.168.0.11:2181?backup=192.168.0.30:2181,192.168.0.35:2181
channel.index.consumer.group=channel-index-nb channel.index.consumer.group=channel-index-local
channel.index.application.name=brandkbs2 channel.index.application.name=brandkbs2
#\u5916\u90E8\u63A5\u53E3 #\u5916\u90E8\u63A5\u53E3
#qbjc.project.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/aplan/project #qbjc.project.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/aplan/project
...@@ -82,3 +82,16 @@ istarshine.getIStarShineKSInfoData.url=https://istarshine-service.zhiweidata.com ...@@ -82,3 +82,16 @@ istarshine.getIStarShineKSInfoData.url=https://istarshine-service.zhiweidata.com
whole.search.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/yuqing whole.search.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/yuqing
whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/pt whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/pt
whole.extraParam.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param whole.extraParam.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param
#\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url=http://192.168.0.225:11003/qbjc/pushTask/interface/brandkbs/project?projectId={1}&projectName={2}
warn.ticket.url=http://192.168.0.225:11003/qbjc/pushTask/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url=http://192.168.0.225:11003/qbjc/pushTask/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url=http://192.168.0.225:11003/qbjc/pushTask/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
warn.channel.url=http://192.168.0.225:11003/qbjc/pushTask/interface/brandkbs/config/channel/{1}
warn.hotEvent.url=http://192.168.0.225:11003/qbjc/pushTask/interface/brandkbs/config/hotEvent/{1}
warn.hotTop.url=http://192.168.0.225:11003/qbjc/pushTask/interface/brandkbs/config/hotTop/{1}
warn.yuQing.url=http://192.168.0.225:11003/qbjc/pushTask/interface/brandkbs/config/yuQing/{1}
warn.taskSwitch.url=http://192.168.0.225:11003/qbjc/pushTask/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
\ No newline at end of file
...@@ -80,3 +80,16 @@ istarshine.getIStarShineKSInfoData.url=https://istarshine-service.zhiweidata.com ...@@ -80,3 +80,16 @@ istarshine.getIStarShineKSInfoData.url=https://istarshine-service.zhiweidata.com
whole.search.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/yuqing whole.search.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/yuqing
whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/pt whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/pt
whole.extraParam.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param whole.extraParam.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/search/extra/param
#\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/project?projectId={1}&projectName={2}
warn.ticket.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
warn.channel.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/channel/{1}
warn.hotEvent.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/hotEvent/{1}
warn.hotTop.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/hotTop/{1}
warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/config/yuQing/{1}
warn.taskSwitch.url=https://auto-push.zhiweidata.com/qbjc/pushTask/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
\ No newline at end of file
package com.zhiwei.brandkbs2; package com.zhiwei.brandkbs2;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.pojo.UserInfo;
import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO; import com.zhiwei.brandkbs2.pojo.vo.ChannelListVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.ChannelService; import com.zhiwei.brandkbs2.service.ChannelService;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -12,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.security.PublicKey;
import java.util.List; import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
...@@ -25,7 +21,7 @@ public class ChannelServiceTest { ...@@ -25,7 +21,7 @@ public class ChannelServiceTest {
@Test @Test
public void getActiveChannelListTest(){ public void getActiveChannelListTest(){
List<ChannelListVO> activeChannelList = List<ChannelListVO> activeChannelList =
channelService.getActiveChannelList("0", null, null, null, null, 50); channelService.getActiveChannelList("0", null, null, null, null, 50,true);
for (ChannelListVO channelListVO : activeChannelList) { for (ChannelListVO channelListVO : activeChannelList) {
System.out.println(channelListVO); System.out.println(channelListVO);
} }
...@@ -34,7 +30,7 @@ public class ChannelServiceTest { ...@@ -34,7 +30,7 @@ public class ChannelServiceTest {
@Test @Test
public void getPositiveListTest(){ public void getPositiveListTest(){
List<ChannelListVO> positiveList = List<ChannelListVO> positiveList =
channelService.getPositiveList("0", null, null, "{\"index\":\"descend\"}", null, null, 50); channelService.getPositiveList("0", null, null, "{\"index\":\"descend\"}", null, null, 50,true);
for (ChannelListVO channelListVO : positiveList) { for (ChannelListVO channelListVO : positiveList) {
System.out.println(channelListVO); System.out.println(channelListVO);
} }
...@@ -43,7 +39,7 @@ public class ChannelServiceTest { ...@@ -43,7 +39,7 @@ public class ChannelServiceTest {
@Test @Test
public void getNegativeListTest(){ public void getNegativeListTest(){
List<ChannelListVO> negativeList = List<ChannelListVO> negativeList =
channelService.getNegativeList("0", null, null, "{\"index\":\"descend\"}", null, null, 50); channelService.getNegativeList("0", null, null, "{\"index\":\"descend\"}", null, null, 50,true);
for (ChannelListVO channelListVO : negativeList) { for (ChannelListVO channelListVO : negativeList) {
System.out.println(channelListVO); System.out.println(channelListVO);
} }
......
package com.zhiwei.brandkbs2; package com.zhiwei.brandkbs2;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.sun.media.sound.SoftTuning; import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.pojo.BaseMap; import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.MarkFlowEntity; import com.zhiwei.brandkbs2.pojo.MarkFlowEntity;
...@@ -9,7 +9,6 @@ import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO; ...@@ -9,7 +9,6 @@ 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.pojo.vo.PageVO; import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.MarkDataService; import com.zhiwei.brandkbs2.service.MarkDataService;
import org.checkerframework.checker.units.qual.K;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -204,9 +203,15 @@ public class MarkDataServiceTest { ...@@ -204,9 +203,15 @@ public class MarkDataServiceTest {
@Test @Test
public void getEsTopSourceTest() throws IOException { public void getEsTopSourceTest() throws IOException {
List<Map<String, Object>> esTopSource = markDataService.getEsTopSource(1658073600000L, 1661727700000L, "62beadd1bbf8eb20f96d2f2e", "136", "0", null, 5); List<Map<String, Object>> esTopSource = markDataService.getEsTopSource(1663516800000L, 1666108800000L, "62beadd1bbf8eb20f96d2f1a", "25", "0",
EmotionEnum.POSITIVE.getName(), 3);
for (Map<String, Object> stringObjectMap : esTopSource) { for (Map<String, Object> stringObjectMap : esTopSource) {
System.out.println(stringObjectMap.entrySet()); System.out.println(stringObjectMap.entrySet());
} }
List<Map<String, Object>> esTopSource2 = markDataService.getEsTopSource(1663516800000L, 1666108800000L, "62beadd1bbf8eb20f96d2f1a", "25", "0",
EmotionEnum.NEGATIVE.getName(), 3);
for (Map<String, Object> stringObjectMap : esTopSource2) {
System.out.println(stringObjectMap.entrySet());
}
} }
} }
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