Commit a03528a4 by 陈健智

舆情分析-舆情驾驶舱

parent 51723f75
...@@ -47,6 +47,7 @@ public class GenericAttribute { ...@@ -47,6 +47,7 @@ public class GenericAttribute {
* es gid * es gid
**/ **/
public static final String ES_GID = "gid"; public static final String ES_GID = "gid";
public static final String ES_MGID = "mgid";
public static final String ES_PROJECT_ID = "project_id"; public static final String ES_PROJECT_ID = "project_id";
public static final String ES_CONTEND_ID = "contend_id"; public static final String ES_CONTEND_ID = "contend_id";
public static final String ES_CHANNEL_FID = "fid"; public static final String ES_CHANNEL_FID = "fid";
...@@ -88,6 +89,7 @@ public class GenericAttribute { ...@@ -88,6 +89,7 @@ public class GenericAttribute {
* es mtime * es mtime
**/ **/
public static final String ES_MTIME = "mtime"; public static final String ES_MTIME = "mtime";
public static final String ES_STIME = "stime";
/** /**
* es mtag * es mtag
**/ **/
......
...@@ -102,6 +102,17 @@ public class RedisKeyPrefix { ...@@ -102,6 +102,17 @@ public class RedisKeyPrefix {
public static final String NON_MANUAL_PROJECT_MARK_MAX_GID = "BRANDKBS:NON_MANUAL:PROJECT:MARK:MAX_GID:"; public static final String NON_MANUAL_PROJECT_MARK_MAX_GID = "BRANDKBS:NON_MANUAL:PROJECT:MARK:MAX_GID:";
/**
* 新舆情分析页面相关缓存
*/
public static final String YUQING_ANALYZE_PROJECT_AVG_COUNT = "BRANDKBS:YUQING:ANALYZE:AMOUNT:AVG:";
public static final String YUQING_ANALYZE_EMOTION_DISTRIBUTION_AVG = "BRANDKBS:YUQING:ANALYZE:EMOTION:AVG:";
public static final String YUQING_ANALYZE_PLATFORM_AVG_COUNT = "BRANDKBS:YUQING:ANALYZE:PLATFORM:AVG:";
public static final String YUQING_ANALYZE_HIGH_WORD = "BRANDKBS:YUQING:ANALYZE:HIGH:WORD:";
public static String projectWarnHotTopKeyAll(String projectId, String type) { public static String projectWarnHotTopKeyAll(String projectId, String type) {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.PROJECT_WARN_HOT_TOP, projectId, Tools.concat(type, "*")); return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.PROJECT_WARN_HOT_TOP, projectId, Tools.concat(type, "*"));
} }
......
...@@ -54,6 +54,16 @@ public class CommonController extends BaseController { ...@@ -54,6 +54,16 @@ public class CommonController extends BaseController {
} }
} }
@ApiOperation("获取平台类型及id")
@GetMapping("/get/platform-id")
public ResponseResult getPlatformWithId() {
try {
return ResponseResult.success(commonService.getQbjcPlatform("id", "name"));
} catch (Exception e) {
return ResponseResult.failure(e.getMessage());
}
}
@ApiOperation("获取当前用户拥有的所有项目及品牌列表") @ApiOperation("获取当前用户拥有的所有项目及品牌列表")
@GetMapping("/user/getUserAllProjects") @GetMapping("/user/getUserAllProjects")
@Auth(role = RoleEnum.CUSTOMER) @Auth(role = RoleEnum.CUSTOMER)
......
...@@ -440,6 +440,91 @@ public class AppArticleController extends BaseController { ...@@ -440,6 +440,91 @@ public class AppArticleController extends BaseController {
return ResponseResult.success(markDataService.getNonManualMarkAggreeList(markSearchDTO)); return ResponseResult.success(markDataService.getNonManualMarkAggreeList(markSearchDTO));
} }
@ApiOperation("获取方案列表")
@GetMapping("/analyze/plan/list")
public ResponseResult getNonManualPlanList(){
return ResponseResult.success(markDataService.getNonManualPlanList());
}
@ApiOperation("新-舆情分析-舆情总量")
@GetMapping("/analyze/amount")
public ResponseResult getYuqingAmount(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getYuqingAmount(startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-情感分布")
@GetMapping("/analyze/emotion")
public ResponseResult getYuqingEmotionDistribution(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getYuqingEmotionDistribution(startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-重点平台")
@GetMapping("/analyze/important-platform")
public ResponseResult getImportantPlatformPercentage(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getImportantPlatformPercentage(startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-平台占比")
@GetMapping("/analyze/platform-percent")
public ResponseResult getPlatformPercentage(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getPlatformPercentage(startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-舆情走势图")
@GetMapping("/analyze/tendency")
public ResponseResult getSpreadTendency(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getSpreadTendency(startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-活跃渠道")
@GetMapping("/analyze/active-channel")
public ResponseResult getActiveChannels(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getActiveChannels(startTime, endTime, planId));
}
@ApiOperation("新-舆情分析-ip分布")
@GetMapping("/analyze/ip-located")
public ResponseResult getArticleIpLocated(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId,
@RequestParam(value = "size") int size) {
return ResponseResult.success(markDataService.getArticleIpLocated(startTime, endTime, planId, size));
}
@ApiOperation("新-舆情分析-词云")
@GetMapping("/analyze/high-word")
public ResponseResult getHighWord(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getHighWord(startTime, endTime, planId, true));
}
@ApiOperation("新-舆情分析-高频标题")
@GetMapping("/analyze/frequent-title")
public ResponseResult getLastNews(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getLastNews(startTime, endTime, planId, 5, true));
}
@ApiOperation("新-舆情分析-活跃渠道、ip分布、词云详情页面,社媒平台发文")
@PostMapping("/analyze/mark-data")
public ResponseResult getYuqingAnalyzeDetail(@RequestBody MarkSearchDTO markSearchDTO) {
return ResponseResult.success(markDataService.getYuqingAnalyzeDetail(markSearchDTO));
}
private boolean checkMTagIllegal(StringBuilder mtag) { private boolean checkMTagIllegal(StringBuilder mtag) {
List<MarkerTag> hitTags = projectService.getProjectById(UserThreadLocal.getProjectId()).getHitTags(); List<MarkerTag> hitTags = projectService.getProjectById(UserThreadLocal.getProjectId()).getHitTags();
if (!Tools.isEmpty(hitTags)) { if (!Tools.isEmpty(hitTags)) {
......
...@@ -311,6 +311,18 @@ public class EsQueryTools { ...@@ -311,6 +311,18 @@ public class EsQueryTools {
} }
/** /**
* ip查询
*
* @param ip ip地址
* @return
*/
public static BoolQueryBuilder assembleIpQuery(String ip) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
queryBuilder.should(QueryBuilders.termQuery("ip_location.keyword", ip));
return queryBuilder;
}
/**
* 字段不拆封,多字段 同关键词 * 字段不拆封,多字段 同关键词
* *
* @param @param boolQueryBuilder * @param @param boolQueryBuilder
......
...@@ -181,7 +181,18 @@ public class MarkSearchDTO { ...@@ -181,7 +181,18 @@ public class MarkSearchDTO {
@ApiModelProperty(value = "数据类型(1:长文本, 2:短文本, 3:问答, 5:视频)") @ApiModelProperty(value = "数据类型(1:长文本, 2:短文本, 3:问答, 5:视频)")
private Integer dataType; private Integer dataType;
/** /**
* gid用于未读已读筛选,仅非人工项目 * ip地址
*/ */
@ApiModelProperty(value = "ip地址")
private String ip;
/**
* gid用于未读已读筛选,非人工项目舆情数据用
*/
@ApiModelProperty(value = "gid")
private Long gid; private Long gid;
/**
* gid限制 舆情分析页面滚动翻页用
*/
@ApiModelProperty(value = "gid限制")
private Long pageGid;
} }
...@@ -163,7 +163,7 @@ public class ProjectVO { ...@@ -163,7 +163,7 @@ public class ProjectVO {
project.setPositiveChannelParams((this.getPositiveChannelParams())); project.setPositiveChannelParams((this.getPositiveChannelParams()));
project.setBlackChannelGroup(this.getBlackChannelGroup()); project.setBlackChannelGroup(this.getBlackChannelGroup());
project.setShow(true); project.setShow(true);
project.setStart(false); project.setStart(true);
project.setManual(true); project.setManual(true);
project.setCTime(time.getTime()); project.setCTime(time.getTime());
project.setUTime(time.getTime()); project.setUTime(time.getTime());
...@@ -189,7 +189,7 @@ public class ProjectVO { ...@@ -189,7 +189,7 @@ public class ProjectVO {
// 非人工项目 // 非人工项目
project.setManual(false); project.setManual(false);
project.setShow(true); project.setShow(true);
project.setStart(false); project.setStart(true);
project.setCTime(System.currentTimeMillis()); project.setCTime(System.currentTimeMillis());
project.setUTime(System.currentTimeMillis()); project.setUTime(System.currentTimeMillis());
return project; return project;
......
...@@ -436,6 +436,12 @@ public interface MarkDataService { ...@@ -436,6 +436,12 @@ public interface MarkDataService {
PageVO<JSONObject> getNonManualProjectPlanList(); PageVO<JSONObject> getNonManualProjectPlanList();
/** /**
* 获取方案列表
* @return
*/
List<JSONObject> getNonManualPlanList();
/**
* 获取方案设置-方案列表-昨日,今日数据消耗量 * 获取方案设置-方案列表-昨日,今日数据消耗量
* @return * @return
*/ */
...@@ -511,4 +517,121 @@ public interface MarkDataService { ...@@ -511,4 +517,121 @@ public interface MarkDataService {
* @return * @return
*/ */
List<JSONObject> getNonManualMarkCountList(); List<JSONObject> getNonManualMarkCountList();
/**
* 计算近一年舆情总量项目日均
* @param projectId
* @param planId
* @return
* @throws IOException
*/
void countYuqingAmountAvg(Long startTime, Long endTime, String projectId, String planId) throws IOException;
/**
* 计算近一年情感分布均值
* @param projectId
* @param planId
* @throws IOException
*/
void countEmotionDistributionAvg(Long startTime, Long endTime, String projectId, String planId) throws IOException;
/**
* 计算项目近一年重点平台均值
* @param projectId
* @param planId
* @throws IOException
*/
void countImportantPlatformPercentageAvg(Long startTime, Long endTime, String projectId, String planId) throws IOException;
/**
* 新-舆情分析-舆情总量
* @param startTime
* @param endTime
* @param planId
* @return
* @throws IOException
*/
JSONObject getYuqingAmount(Long startTime, Long endTime, String planId);
/**
* 新-舆情分析-情感分布
* @param startTime
* @param endTime
* @param planId
* @return
* @throws IOException
*/
JSONObject getYuqingEmotionDistribution(Long startTime, Long endTime, String planId);
/**
* 新-舆情分析-重点平台
* @param startTime
* @param endTime
* @param planId
* @return
*/
JSONObject getImportantPlatformPercentage(Long startTime, Long endTime, String planId);
/**
* 新-舆情分析-平台占比
* @param startTime
* @param endTime
* @param planId
* @return
*/
List<JSONObject> getPlatformPercentage(Long startTime, Long endTime, String planId);
/**
* 新-舆情分析-舆情走势图
* @param startTime
* @param endTime
* @param planId
* @return
*/
JSONObject getSpreadTendency(Long startTime, Long endTime, String planId);
/**
* 新-舆情分析-活跃渠道
* @param startTime
* @param endTime
* @param planId
* @return
*/
List<JSONObject> getActiveChannels(Long startTime, Long endTime, String planId);
/**
* 新-舆情分析-ip分布
* @param startTime
* @param endTime
* @param planId
* @return
*/
List<JSONObject> getArticleIpLocated(Long startTime, Long endTime, String planId, int size);
/**
* 新-舆情分析-活跃渠道、ip分布、词云详情页面
* @param dto
* @return
*/
PageVO<MarkFlowEntity> getYuqingAnalyzeDetail(MarkSearchDTO dto);
/**
* 新-舆情分析-词云
* @param startTime
* @param endTime
* @param planId
* @return
*/
List<JSONObject> getHighWord(Long startTime, Long endTime, String planId, boolean cache);
/**
* 新-舆情分析-高频标题
* @param startTime
* @param endTime
* @param planId
* @param size
* @param include
* @return
*/
List<JSONObject> getLastNews(Long startTime, Long endTime, String planId, int size, boolean include);
} }
...@@ -42,4 +42,14 @@ public interface TaskService{ ...@@ -42,4 +42,14 @@ public interface TaskService{
* 事件相关更新 * 事件相关更新
*/ */
void eventUpdate(); void eventUpdate();
/**
* 计算项目舆情总量、情感分布、重点平台均值
*/
void calculateProjectAvg();
/**
* 生成舆情分析词云缓存
*/
void yuqingAnalyzeHighWordCache();
} }
...@@ -131,6 +131,14 @@ public class EsSearchServiceImpl implements EsSearchService { ...@@ -131,6 +131,14 @@ public class EsSearchServiceImpl implements EsSearchService {
if (StringUtils.isNotEmpty(dto.getHostKeyword())) { if (StringUtils.isNotEmpty(dto.getHostKeyword())) {
postFilter.must(EsQueryTools.assembleFiledKeywordQuery("host", dto.getHostKeyword())); postFilter.must(EsQueryTools.assembleFiledKeywordQuery("host", dto.getHostKeyword()));
} }
// ip
if (StringUtils.isNotEmpty(dto.getIp())){
postFilter.must(EsQueryTools.assembleIpQuery(dto.getIp()));
}
// mgid限制 舆情分析页面滚动翻页用
if (Objects.nonNull(dto.getPageGid())){
postFilter.must(QueryBuilders.rangeQuery(GenericAttribute.ES_MGID).lt(dto.getPageGid()));
}
helper.setPostFilter(postFilter); helper.setPostFilter(postFilter);
// helper.setQuery(query); // helper.setQuery(query);
// sort // sort
...@@ -315,6 +323,14 @@ public class EsSearchServiceImpl implements EsSearchService { ...@@ -315,6 +323,14 @@ public class EsSearchServiceImpl implements EsSearchService {
if (Objects.nonNull(dto.getDataType())){ if (Objects.nonNull(dto.getDataType())){
postFilter.must(EsQueryTools.assembleC2Query(dto.getDataType())); postFilter.must(EsQueryTools.assembleC2Query(dto.getDataType()));
} }
// ip
if (StringUtils.isNotEmpty(dto.getIp())){
postFilter.must(EsQueryTools.assembleIpQuery(dto.getIp()));
}
// mgid限制 舆情分析页面滚动翻页用
if (Objects.nonNull(dto.getPageGid())){
postFilter.must(QueryBuilders.rangeQuery(GenericAttribute.ES_MGID).lt(dto.getPageGid()));
}
helper.setPostFilter(postFilter); helper.setPostFilter(postFilter);
// sort // sort
FieldSortBuilder sort = null; FieldSortBuilder sort = null;
......
...@@ -3,14 +3,13 @@ package com.zhiwei.brandkbs2.service.impl; ...@@ -3,14 +3,13 @@ package com.zhiwei.brandkbs2.service.impl;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.GlobalPojo; import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.config.Constant; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.dao.AggreeResultDao; import com.zhiwei.brandkbs2.dao.*;
import com.zhiwei.brandkbs2.dao.BrandkbsTaskDao;
import com.zhiwei.brandkbs2.dao.ChannelDao;
import com.zhiwei.brandkbs2.dao.ReportSettingsDao;
import com.zhiwei.brandkbs2.enmus.ReportTypeEnum; import com.zhiwei.brandkbs2.enmus.ReportTypeEnum;
import com.zhiwei.brandkbs2.es.ChannelEsDao; import com.zhiwei.brandkbs2.es.ChannelEsDao;
import com.zhiwei.brandkbs2.es.EsClientDao; import com.zhiwei.brandkbs2.es.EsClientDao;
import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.listener.ApplicationProjectListener; import com.zhiwei.brandkbs2.listener.ApplicationProjectListener;
import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.*; import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.service.*; import com.zhiwei.brandkbs2.service.*;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
...@@ -19,6 +18,8 @@ import org.apache.commons.lang3.tuple.Pair; ...@@ -19,6 +18,8 @@ import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.ElasticsearchStatusException;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,6 +29,7 @@ import java.util.concurrent.CompletableFuture; ...@@ -28,6 +29,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -61,6 +63,9 @@ public class TaskServiceImpl implements TaskService { ...@@ -61,6 +63,9 @@ public class TaskServiceImpl implements TaskService {
@Resource(name = "aggreeResultDaoImpl") @Resource(name = "aggreeResultDaoImpl")
AggreeResultDao aggreeResultDao; AggreeResultDao aggreeResultDao;
@Resource(name = "nonManualProjectPlanDao")
NonManualProjectPlanDao nonManualProjectPlanDao;
@Resource(name = "brandkbsTaskServiceImpl") @Resource(name = "brandkbsTaskServiceImpl")
BrandkbsTaskService brandkbsTaskService; BrandkbsTaskService brandkbsTaskService;
...@@ -82,6 +87,9 @@ public class TaskServiceImpl implements TaskService { ...@@ -82,6 +87,9 @@ public class TaskServiceImpl implements TaskService {
@Resource(name = "customEventServiceImpl") @Resource(name = "customEventServiceImpl")
CustomEventService customEventService; CustomEventService customEventService;
@Resource(name = "markDataServiceImpl")
MarkDataService markDataService;
@Resource(name = "taskServiceExecutor") @Resource(name = "taskServiceExecutor")
ThreadPoolTaskExecutor taskServiceExecutor; ThreadPoolTaskExecutor taskServiceExecutor;
...@@ -324,6 +332,56 @@ public class TaskServiceImpl implements TaskService { ...@@ -324,6 +332,56 @@ public class TaskServiceImpl implements TaskService {
} }
} }
@Override
public void calculateProjectAvg() {
AtomicLong total = new AtomicLong();
GlobalPojo.PROJECT_MAP.forEach((projectId, project) ->{
try {
// 取近一年
long endTime = System.currentTimeMillis();
long startTime = endTime - Constant.ONE_YEAR;
// 项目创建时间在近一年内则取项目创建时间
startTime = project.getCTime() > startTime ? project.getCTime() : startTime;
// 同时计算非人工项目各方案均值
if (!project.isManual()) {
List<NonManualProjectPlan> plans = nonManualProjectPlanDao.findList(new Query(Criteria.where("projectId").is(projectId)));
for (NonManualProjectPlan plan : plans) {
markDataService.countYuqingAmountAvg(startTime, endTime, projectId, plan.getId());
markDataService.countEmotionDistributionAvg(startTime, endTime, projectId, plan.getId());
markDataService.countImportantPlatformPercentageAvg(startTime, endTime, projectId, plan.getId());
}
}
markDataService.countYuqingAmountAvg(startTime, endTime, projectId, null);
markDataService.countEmotionDistributionAvg(startTime, endTime, projectId, null);
markDataService.countImportantPlatformPercentageAvg(startTime, endTime, projectId, null);
log.info("项目:{}-均值计算已完成:{}个", project.getProjectName(), total.incrementAndGet());
}catch (Exception e){
ExceptionCast.cast(CommonCodeEnum.FAIL, "calculateProjectAvg异常-projectId:" + projectId, e);
}
});
}
@Override
public void yuqingAnalyzeHighWordCache() {
AtomicInteger total = new AtomicInteger();
Long[] time = commonService.getTimeRangeMonth();
List<CompletableFuture<Object>> projectFutures = GlobalPojo.PROJECT_MAP.values().stream().map(project -> CompletableFuture.supplyAsync(() -> {
UserThreadLocal.set(new UserInfo().setProjectId(project.getId()));
markDataService.getHighWord(time[0], time[1], null, false);
log.info("项目:{}-{}-词云缓存已完成:{}个", project.getProjectName(), project.getId(), total.incrementAndGet());
return null;
}, cacheServiceExecutor)).collect(Collectors.toList());
AtomicInteger total2 = new AtomicInteger();
List<CompletableFuture<Object>> planFutures = nonManualProjectPlanDao.findList(new Query()).stream().map(plan -> CompletableFuture.supplyAsync(() -> {
UserThreadLocal.set(new UserInfo().setProjectId(plan.getProjectId()));
markDataService.getHighWord(time[0], time[1], plan.getId(), false);
log.info("方案:{}-{}-词云缓存已完成:{}个", plan.getName(), plan.getId(), total2.incrementAndGet());
return null;
}, cacheServiceExecutor)).collect(Collectors.toList());
projectFutures.addAll(planFutures);
CompletableFuture.allOf(projectFutures.toArray(new CompletableFuture[0])).join();
}
private boolean reportSendByProject(Project project) { private boolean reportSendByProject(Project project) {
boolean flag = false; boolean flag = false;
// 扫描setting信息并生成对应报告 // 扫描setting信息并生成对应报告
......
...@@ -45,6 +45,7 @@ public class ControlCenter { ...@@ -45,6 +45,7 @@ public class ControlCenter {
try { try {
taskService.messageFlowCache(); taskService.messageFlowCache();
taskService.customEventCache(); taskService.customEventCache();
taskService.yuqingAnalyzeHighWordCache();
} catch (Exception e) { } catch (Exception e) {
log.error("定时按天缓存数据-出错", e); log.error("定时按天缓存数据-出错", e);
} finally { } finally {
...@@ -91,4 +92,16 @@ public class ControlCenter { ...@@ -91,4 +92,16 @@ public class ControlCenter {
} }
} }
@Async("scheduledExecutor")
@Scheduled(cron = "0 0 3 ? * SUN")
public void calculateProjectAvg() {
log.info("定时每周计算项目均值-启动");
try {
taskService.calculateProjectAvg();
} catch (Exception e) {
log.error("定时按周计算项目均值-出错", e);
} finally {
log.info("定时按周计算项目均值-结束");
}
}
} }
...@@ -7,6 +7,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; ...@@ -7,6 +7,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -82,6 +83,34 @@ public class RedisUtil { ...@@ -82,6 +83,34 @@ public class RedisUtil {
return RedisKeyPrefix.NON_MANUAL_PROJECT_MARK_MAX_GID + Tools.concat(projectId, planId, userId); return RedisKeyPrefix.NON_MANUAL_PROJECT_MARK_MAX_GID + Tools.concat(projectId, planId, userId);
} }
public static String getYuqingAnalyzeProjectAvgCountKey(String projectId, String contendId, String planId){
if (Objects.isNull(planId)){
return RedisKeyPrefix.YUQING_ANALYZE_PROJECT_AVG_COUNT + Tools.concat(projectId, contendId);
}
return RedisKeyPrefix.YUQING_ANALYZE_PROJECT_AVG_COUNT + Tools.concat(projectId, contendId, planId);
}
public static String getYuqingAnalyzeEmotionDistributionAvgKey(String projectId, String contendId, String emotion, String planId){
if (Objects.isNull(planId)){
return RedisKeyPrefix.YUQING_ANALYZE_EMOTION_DISTRIBUTION_AVG + Tools.concat(projectId, contendId, emotion);
}
return RedisKeyPrefix.YUQING_ANALYZE_EMOTION_DISTRIBUTION_AVG + Tools.concat(projectId, contendId, emotion, planId);
}
public static String getYuqingAnalyzePlatformAvgCountKey(String projectId, String contendId, String planId){
if (Objects.isNull(planId)){
return RedisKeyPrefix.YUQING_ANALYZE_PLATFORM_AVG_COUNT + Tools.concat(projectId, contendId);
}
return RedisKeyPrefix.YUQING_ANALYZE_PLATFORM_AVG_COUNT + Tools.concat(projectId, contendId, planId);
}
public static String getYuqingAnalyzeHighWordKey(String projectId, String contendId, String planId, Long startTime, Long endTime){
if (Objects.isNull(planId)){
return RedisKeyPrefix.YUQING_ANALYZE_HIGH_WORD + Tools.concat(projectId, contendId, startTime, endTime);
}
return RedisKeyPrefix.YUQING_ANALYZE_HIGH_WORD + Tools.concat(projectId, contendId, planId, startTime, endTime);
}
public void setExpire(String key, String value, long timeout, TimeUnit unit) { public void setExpire(String key, String value, long timeout, TimeUnit unit) {
stringRedisTemplate.opsForValue().set(key, value, timeout, unit); stringRedisTemplate.opsForValue().set(key, value, timeout, unit);
} }
......
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