Commit ae7cf13b by shentao

Merge branch 'feature' into 'dev'

Feature

See merge request !344
parents 17cb1c34 87f255d7
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
<springboot.version>2.2.5.RELEASE</springboot.version> <springboot.version>2.2.5.RELEASE</springboot.version>
<qbjc.bean.version>1.1.7.1-SNAPSHOT</qbjc.bean.version> <qbjc.bean.version>1.1.7.1-SNAPSHOT</qbjc.bean.version>
<springfox.version>2.7.0</springfox.version> <springfox.version>2.9.2</springfox.version>
<fastjson.version>1.2.47</fastjson.version> <fastjson.version>1.2.47</fastjson.version>
<easyexcel.version>3.0.5</easyexcel.version> <easyexcel.version>3.0.5</easyexcel.version>
<marker.client.version>1.1.9-SNAPSHOT</marker.client.version> <marker.client.version>1.1.9-SNAPSHOT</marker.client.version>
...@@ -40,6 +40,12 @@ ...@@ -40,6 +40,12 @@
</properties> </properties>
<dependencies> <dependencies>
<!-- 自动化中间件客户端 -->
<dependency>
<groupId>com.zhiwei.middleware</groupId>
<artifactId>automaticmark-client</artifactId>
<version>2.3.1.1-SNAPSHOT</version>
</dependency>
<!-- 去重 --> <!-- 去重 -->
<dependency> <dependency>
<groupId>com.zhiwei.middleware</groupId> <groupId>com.zhiwei.middleware</groupId>
......
...@@ -16,7 +16,7 @@ public class ChannelType { ...@@ -16,7 +16,7 @@ public class ChannelType {
private static final List<String> MAIN_BODY_TYPES = Arrays.asList("媒体", "团体", "普通用户", "企业", "名人", "政务机构"); private static final List<String> MAIN_BODY_TYPES = Arrays.asList("媒体", "团体", "普通用户", "企业", "名人", "政务机构");
public static final List<String> POLITICS_LEVELS = Arrays.asList("央级", "省级", "地级"); public static final List<String> POLITICS_LEVELS = Arrays.asList("央级", "省级", "地级");
private static final List<String> FIELDS = Arrays.asList("情感", "综合", "财经", "家居", "社会", "时尚", "文化", "历史", "母婴育儿", "体育", "娱乐", "动漫", "汽车", "美食", "健康养生", "国际", "音乐", "游戏", "科技", "旅游", "军事", "时事", "教育"); private static final List<String> FIELDS = Arrays.asList("时政", "财经", "科技", "社会民生", "交通", "综合", "娱乐", "生活", "体育", "教育", "文化", "母婴育儿", "健康");
private static final JSONArray REGION = GlobalPojo.CHINA_AREA_TAGS; private static final JSONArray REGION = GlobalPojo.CHINA_AREA_TAGS;
public static JSONObject channelOption = new JSONObject(); public static JSONObject channelOption = new JSONObject();
public static final List<String> COMMON_FIELDS = Arrays.asList("财经", "科技", "时政", "社会民生", "交通"); public static final List<String> COMMON_FIELDS = Arrays.asList("财经", "科技", "时政", "社会民生", "交通");
......
...@@ -3,14 +3,19 @@ package com.zhiwei.brandkbs2.common; ...@@ -3,14 +3,19 @@ package com.zhiwei.brandkbs2.common;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.pojo.ChannelTag; import com.zhiwei.brandkbs2.pojo.ChannelTag;
import com.zhiwei.brandkbs2.pojo.HighlightWord;
import com.zhiwei.brandkbs2.pojo.Project; import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.service.SystemInfoService; import com.zhiwei.brandkbs2.service.SystemInfoService;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.automaticmark.graphs.Graphs;
import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform; import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import com.zhiwei.qbjc.bean.pojo.common.Tag; import com.zhiwei.qbjc.bean.pojo.common.Tag;
import com.zhiwei.brandkbs2.dao.HighlightWordDao;
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.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -18,9 +23,7 @@ import org.springframework.stereotype.Component; ...@@ -18,9 +23,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -40,6 +43,9 @@ public class GlobalPojo { ...@@ -40,6 +43,9 @@ public class GlobalPojo {
@Resource(name = "systemInfoServiceImpl") @Resource(name = "systemInfoServiceImpl")
private SystemInfoService systemInfoService; private SystemInfoService systemInfoService;
@Resource(name = "highlightWordDao")
private HighlightWordDao highlightWordDao;
/** /**
* 监测系统平台 * 监测系统平台
**/ **/
...@@ -72,6 +78,10 @@ public class GlobalPojo { ...@@ -72,6 +78,10 @@ public class GlobalPojo {
public static JSONArray CHINA_AREA_TAGS; public static JSONArray CHINA_AREA_TAGS;
public static Map<String, List<String>> HIGHLIGHT_MAP = new HashMap<>();
public static Map<String, Graphs> PROJECT_GRAPHS = new HashMap<>();
public static final List<String> PERMANENT_PLATFORM_NAMES = Arrays.asList("网媒", "微博", "微信", "今日头条"); public static final List<String> PERMANENT_PLATFORM_NAMES = Arrays.asList("网媒", "微博", "微信", "今日头条");
public static final String ELSE_PLATFORM_NAME = "其他自媒体"; public static final String ELSE_PLATFORM_NAME = "其他自媒体";
...@@ -109,6 +119,7 @@ public class GlobalPojo { ...@@ -109,6 +119,7 @@ public class GlobalPojo {
MEDIA_TYPE = systemInfoService.getMediaTypes(); MEDIA_TYPE = systemInfoService.getMediaTypes();
PROJECT_MAP = systemInfoService.getProjects(); PROJECT_MAP = systemInfoService.getProjects();
YU_QING_PROJECTS = systemInfoService.getYuQingProjects(); YU_QING_PROJECTS = systemInfoService.getYuQingProjects();
updateHighlightGraphs();
log.info("{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{}", logMsg, PLATFORMS.size(), TAGS.size(), log.info("{}-获取PLATFORMS-size:{},TAGS-size:{},LINKED_GROUP_ID_TAGS:{},CHANNEL_TAGS:{},MEDIA_TYPE:{},PROJECT_MAP:{},YUQING-PROJECTS-size:{}", logMsg, PLATFORMS.size(), TAGS.size(),
LINKED_GROUP_ID_TAGS.size(), CHANNEL_TAGS.size(), MEDIA_TYPE.size(), PROJECT_MAP.size(), YU_QING_PROJECTS.size()); LINKED_GROUP_ID_TAGS.size(), CHANNEL_TAGS.size(), MEDIA_TYPE.size(), PROJECT_MAP.size(), YU_QING_PROJECTS.size());
} catch (Exception e) { } catch (Exception e) {
...@@ -116,6 +127,20 @@ public class GlobalPojo { ...@@ -116,6 +127,20 @@ public class GlobalPojo {
} }
} }
private void updateHighlightGraphs() {
PROJECT_MAP.forEach((key, project) -> {
String id = project.getId();
List<String> list = highlightWordDao.findList(Query.query(Criteria.where("projectId").is(id))).stream().map(HighlightWord::getKeyword).collect(Collectors.toList());
List<String> keywords = new ArrayList<>();
// 拆分关键词中的且逻辑
list.forEach(word -> keywords.addAll(Arrays.asList(word.trim().split(" +"))));
Graphs graphs = new Graphs();
graphs.addGraph(keywords);
HIGHLIGHT_MAP.put(id, list);
PROJECT_GRAPHS.put(id, graphs);
});
}
public static String getPlatformIdByName(String platformName) { public static String getPlatformIdByName(String platformName) {
for (MessagePlatform platform : PLATFORMS) { for (MessagePlatform platform : PLATFORMS) {
if (platform.getName().equals(platformName)) { if (platform.getName().equals(platformName)) {
......
...@@ -63,6 +63,7 @@ public class RedisKeyPrefix { ...@@ -63,6 +63,7 @@ public class RedisKeyPrefix {
public static final String HOT_RANK_LIST = "BRANDKBS:HOT:RANK_LIST:"; public static final String HOT_RANK_LIST = "BRANDKBS:HOT:RANK_LIST:";
public static final String HOT_LIST = "BRANDKBS:HOT:LIST:"; public static final String HOT_LIST = "BRANDKBS:HOT:LIST:";
public static final String HOT_KEYWORD = "BRANDKBS:HOT:KEYWORD:"; public static final String HOT_KEYWORD = "BRANDKBS:HOT:KEYWORD:";
public static final String HOT_SUPPLEMENT_WORD = "BRANDKBS:HOT:SUPPLEMENT_WORD:";
/** /**
* 项目简报报相关缓存KEY * 项目简报报相关缓存KEY
...@@ -125,6 +126,10 @@ public class RedisKeyPrefix { ...@@ -125,6 +126,10 @@ public class RedisKeyPrefix {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.HOT_KEYWORD, projectId); return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.HOT_KEYWORD, projectId);
} }
public static String supplementWordKey(String projectId) {
return RedisKeyPrefix.generateRedisKey(RedisKeyPrefix.HOT_SUPPLEMENT_WORD, projectId);
}
private static String generateRedisKey(String... keys) { private static String generateRedisKey(String... keys) {
Objects.requireNonNull(keys); Objects.requireNonNull(keys);
boolean contains = keys[0].endsWith(":"); boolean contains = keys[0].endsWith(":");
......
...@@ -16,6 +16,7 @@ public class Constant { ...@@ -16,6 +16,7 @@ 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_WEEK = 7 * 24 * 60 * 60 * 1000L; public static final Long ONE_WEEK = 7 * 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 Long ONE_YEAR = ONE_MONTH * 12;
public static final String SPEC_MINUTE_PATTERN = "yyyy.MM.dd HH:mm"; 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";
......
...@@ -5,12 +5,13 @@ import com.zhiwei.brandkbs2.auth.Auth; ...@@ -5,12 +5,13 @@ import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.controller.BaseController; import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil; import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO; import com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO;
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.TagFilterDTO; import com.zhiwei.brandkbs2.pojo.dto.TagFilterDTO;
import com.zhiwei.brandkbs2.pojo.vo.ProjectVO; import com.zhiwei.brandkbs2.pojo.vo.ProjectVO;
import com.zhiwei.brandkbs2.service.HighWordService; import com.zhiwei.brandkbs2.service.HighWordService;
import com.zhiwei.brandkbs2.service.HighlightWordService;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.TagFilterService; import com.zhiwei.brandkbs2.service.TagFilterService;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
...@@ -42,6 +43,9 @@ public class BaseModuleController extends BaseController { ...@@ -42,6 +43,9 @@ public class BaseModuleController extends BaseController {
@Resource(name = "highWordServiceImpl") @Resource(name = "highWordServiceImpl")
HighWordService highWordService; HighWordService highWordService;
@Resource(name = "highlightWordServiceImpl")
HighlightWordService highlightWordService;
@Resource(name = "projectServiceImpl") @Resource(name = "projectServiceImpl")
ProjectService projectService; ProjectService projectService;
...@@ -68,7 +72,7 @@ public class BaseModuleController extends BaseController { ...@@ -68,7 +72,7 @@ public class BaseModuleController extends BaseController {
@ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "size", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "keyword", value = "搜索关键字", paramType = "query", dataType = "string")}) @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "size", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "keyword", value = "搜索关键字", paramType = "query", dataType = "string")})
@GetMapping("/highWord/list") @GetMapping("/highWord/list")
public ResponseResult findHighWordList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam(value = "keyword", defaultValue = "") String keyword) { public ResponseResult findHighWordList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam(value = "keyword", defaultValue = "") String keyword) {
return ResponseResult.success(highWordService.findHighWord(page, size, keyword)); return ResponseResult.success(highWordService.findWord(page, size, keyword));
} }
@ApiOperation("添加高频关键词列表") @ApiOperation("添加高频关键词列表")
...@@ -76,14 +80,13 @@ public class BaseModuleController extends BaseController { ...@@ -76,14 +80,13 @@ public class BaseModuleController extends BaseController {
@PostMapping("/highWord/add") @PostMapping("/highWord/add")
public ResponseResult addHighWordList(@RequestBody JSONObject info) { public ResponseResult addHighWordList(@RequestBody JSONObject info) {
List<String> highWords = info.getJSONArray("list").toJavaList(String.class); List<String> highWords = info.getJSONArray("list").toJavaList(String.class);
highWordService.addHighWordList(highWords); return highWordService.addWordList(highWords, UserThreadLocal.getProjectId(), UserThreadLocal.getNickname());
return ResponseResult.success();
} }
@ApiOperation("高频关键词删除") @ApiOperation("高频关键词删除")
@DeleteMapping(value = "/highWord/delete/{id}") @DeleteMapping(value = "/highWord/delete/{id}")
public ResponseResult deleteHighWord(@PathVariable String id) { public ResponseResult deleteHighWord(@PathVariable String id) {
highWordService.deleteHighWord(id); highWordService.deleteWord(id);
return ResponseResult.success(); return ResponseResult.success();
} }
...@@ -96,9 +99,50 @@ public class BaseModuleController extends BaseController { ...@@ -96,9 +99,50 @@ public class BaseModuleController extends BaseController {
@ApiOperation("高频关键词下载") @ApiOperation("高频关键词下载")
@GetMapping(value = "/highWord/download") @GetMapping(value = "/highWord/download")
public ResponseResult downloadHighWord() { public ResponseResult downloadHighWord() {
List<ExportHighWordDTO> list = highWordService.downloadHighWord(); String projectId = UserThreadLocal.getProjectId();
ProjectVO projectVO = projectService.getProjectVOById(UserThreadLocal.getProjectId()); List<ExportWordDTO> list = highWordService.downloadWord(projectId);
EasyExcelUtil.download(projectVO.getBrandName() + "_高频关键词", "sheet1", ExportHighWordDTO.class, list, response); ProjectVO projectVO = projectService.getProjectVOById(projectId);
EasyExcelUtil.download(projectVO.getBrandName() + "_高频关键词", "sheet1", ExportWordDTO.class, list, response);
return ResponseResult.success();
}
@ApiOperation("获取舆情列表高亮关键词")
@ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "size", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "keyword", value = "搜索关键字", paramType = "query", dataType = "string")})
@GetMapping("/highlightWord/list")
public ResponseResult findHighlightKeywordList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
@RequestParam(value = "keyword", defaultValue = "") String keyword) {
return ResponseResult.success(highlightWordService.findWord(page, pageSize, keyword));
}
@ApiOperation("添加舆情列表高亮关键词列表")
@ApiImplicitParams(@ApiImplicitParam(name = "list", value = "高亮关键词列表", paramType = "body", dataType = "list"))
@PostMapping("/highlightWord/add")
public ResponseResult addHighlightWordList(@RequestBody JSONObject info) {
List<String> highWords = info.getJSONArray("list").toJavaList(String.class);
return highlightWordService.addWordList(highWords, UserThreadLocal.getProjectId(), UserThreadLocal.getNickname());
}
@ApiOperation("舆情列表高亮关键词删除")
@DeleteMapping(value = "/highlightWord/delete/{id}")
public ResponseResult deleteHighlightWord(@PathVariable String id) {
highlightWordService.deleteWord(id);
return ResponseResult.success();
}
@ApiOperation("舆情列表高亮关键词excel解析")
@PostMapping(value = "/highlightWord/excel/parse", headers = "content-type=multipart/form-data")
public ResponseResult parseExcelHighlightWord(@RequestParam("file") MultipartFile file) {
return Tools.parseExcelInfo(file);
}
@ApiOperation("舆情列表高亮关键词下载")
@GetMapping(value = "/highlightWord/download")
public ResponseResult downloadHighlightWord() {
String projectId = UserThreadLocal.getProjectId();
List<ExportWordDTO> list = highlightWordService.downloadWord(projectId);
ProjectVO projectVO = projectService.getProjectVOById(projectId);
EasyExcelUtil.download(projectVO.getBrandName() + "_舆情列表高亮关键词", "sheet1", ExportWordDTO.class, list, response);
return ResponseResult.success(); return ResponseResult.success();
} }
......
...@@ -4,9 +4,7 @@ import com.zhiwei.brandkbs2.auth.Auth; ...@@ -4,9 +4,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.Behavior;
import com.zhiwei.brandkbs2.pojo.dto.UserDTO; import com.zhiwei.brandkbs2.pojo.dto.UserDTO;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.UserService; import com.zhiwei.brandkbs2.service.UserService;
import com.zhiwei.middleware.auth.pojo.CenterUser; import com.zhiwei.middleware.auth.pojo.CenterUser;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -33,11 +31,6 @@ public class UserController extends BaseController { ...@@ -33,11 +31,6 @@ public class UserController extends BaseController {
@Resource(name = "userServiceImpl") @Resource(name = "userServiceImpl")
private UserService userService; private UserService userService;
@Resource(name = "behaviorServiceImpl")
private BehaviorService behaviorService;
private static final Behavior.Operation OPERATION = new Behavior.Operation("用户管理", true);
@Autowired @Autowired
private com.zhiwei.middleware.auth.core.UserInfoClient userInfoClient; private com.zhiwei.middleware.auth.core.UserInfoClient userInfoClient;
...@@ -47,15 +40,17 @@ public class UserController extends BaseController { ...@@ -47,15 +40,17 @@ public class UserController extends BaseController {
@ApiImplicitParam(name = "size", value = "每页记录数", required = false, defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "size", value = "每页记录数", required = false, defaultValue = "10", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "keyword", value = "搜索关键字", required = false, defaultValue = "", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "keyword", value = "搜索关键字", required = false, defaultValue = "", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pid", value = "搜索项目ID", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(name = "pid", value = "搜索项目ID", required = true, paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "role", value = "角色类型", required = false, defaultValue = "-1", paramType = "query", dataType = "string") @ApiImplicitParam(name = "role", value = "角色类型", required = false, defaultValue = "-1", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "sorter", defaultValue = "{\"cTime\":\"descend\"}", value = "排序字段", paramType = "query", dataType = "string")
}) })
@GetMapping("/list") @GetMapping("/list")
public ResponseResult findList(@RequestParam(value = "page", defaultValue = "1") int page, public ResponseResult findList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "size", defaultValue = "10") int size, @RequestParam(value = "size", defaultValue = "10") int size,
@RequestParam(value = "keyword", defaultValue = "") String keyword, @RequestParam(value = "keyword", defaultValue = "") String keyword,
@RequestParam(value = "pid") String pid, @RequestParam(value = "pid") String pid,
@RequestParam(value = "role", defaultValue = "-1") int role) { @RequestParam(value = "role", defaultValue = "-1") int role,
return ResponseResult.success(userService.findUserList(page, size, keyword, pid, role)); @RequestParam(value = "sorter", defaultValue = "{\"cTime\":\"descend\"}") String sorter) {
return ResponseResult.success(userService.findUserList(page, size, keyword, pid, role, sorter));
} }
@ApiOperation("根据手机号搜索用户信息") @ApiOperation("根据手机号搜索用户信息")
......
...@@ -9,14 +9,17 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal; ...@@ -9,14 +9,17 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.RedisKeyPrefix; import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import com.zhiwei.brandkbs2.config.Constant; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.controller.BaseController; import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.HotPlatformEnum;
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.BaseMap; import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.vo.SupplementWord;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.MarkDataService; 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 io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation; 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;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -64,12 +67,23 @@ public class AppHotController extends BaseController { ...@@ -64,12 +67,23 @@ public class AppHotController extends BaseController {
@Resource(name = "projectServiceImpl") @Resource(name = "projectServiceImpl")
ProjectService projectService; ProjectService projectService;
@Resource(name = "commonServiceImpl")
CommonService commonService;
@Resource(name = "esSearchExecutor") @Resource(name = "esSearchExecutor")
ThreadPoolTaskExecutor executor; ThreadPoolTaskExecutor executor;
@Value("${trends.getHotSearchFromEsInTimeAndTypeOrWord.url}") @Value("${trends.getHotSearchFromEsInTimeAndTypeOrWord.url}")
private String hotSearchUrl; private String hotSearchUrl;
@Value("${trends.queryHotSearchTrendInner.url}")
private String hotSearchTrendUrl;
@Value("${trends.getHotSearchSnapshot.url}")
private String hotSearchSnapshotUrl;
private final String allPlatform = "brandkbs-all";
/** /**
* weibo 热搜 * weibo 热搜
* weibo-topic 话题 * weibo-topic 话题
...@@ -87,32 +101,28 @@ public class AppHotController extends BaseController { ...@@ -87,32 +101,28 @@ public class AppHotController extends BaseController {
@RequestParam(value = "sort", defaultValue = "endTime") String sort, @RequestParam(value = "sort", defaultValue = "endTime") String sort,
@RequestParam(value = "startTime", required = false) Long startTime, @RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime) { @RequestParam(value = "endTime", required = false) Long endTime) {
String keywordStr = redisUtil.get(RedisKeyPrefix.hotKeywordKey(UserThreadLocal.getProjectId())); JSONObject result = searchHotHandler(pageSize, page, type, sort, startTime, endTime);
if (null == keywordStr) {
return ResponseResult.success();
}
String keyword = StringUtils.join(JSONArray.parseArray(keywordStr, String.class), "|");
ResponseEntity<JSONObject> jsonObjectResponseEntity;
if (null != startTime && null != endTime) {
jsonObjectResponseEntity = restTemplate.getForEntity(hotSearchUrl + "&startTime={6}&endTime={7}", JSONObject.class, pageSize, page, type, keyword, sort, startTime, endTime);
} else {
jsonObjectResponseEntity = restTemplate.getForEntity(hotSearchUrl, JSONObject.class, pageSize, page, type, keyword, sort);
}
JSONObject result = jsonObjectResponseEntity.getBody();
if (Objects.isNull(result)) { if (Objects.isNull(result)) {
return ResponseResult.failure("响应超时"); return ResponseResult.success();
} }
// 查询在榜数据 // 查询在榜数据
ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(trendsListUrl, JSONObject.class, null, type, null); ResponseEntity<JSONObject> responseEntity = restTemplate.getForEntity(trendsListUrl, JSONObject.class, null, type, null);
if (Objects.isNull(responseEntity.getBody())) { List<String> rankingIds = new ArrayList<>();
return ResponseResult.success(result); if (Objects.nonNull(responseEntity.getBody())) {
rankingIds = responseEntity.getBody().getJSONArray("data").stream().map(obj -> ((JSONObject) obj).getString("_id")).collect(Collectors.toList());
} }
List<String> rankingIds = responseEntity.getBody().getJSONArray("data").stream().map(obj -> ((JSONObject) obj).getString("_id")).collect(Collectors.toList()); List<String> finalRankingIds = rankingIds;
// 对比补录词
List<Object> valueList = redisUtil.getMapValueAll(RedisKeyPrefix.supplementWordKey(UserThreadLocal.getProjectId()));
List<String> supplementList = valueList.stream().map(word -> JSON.parseObject((String) word, SupplementWord.class).getTitle()).collect(Collectors.toList());
List<JSONObject> list = result.getJSONArray("data").stream().map(obj -> { List<JSONObject> list = result.getJSONArray("data").stream().map(obj -> {
JSONObject json = (JSONObject) obj; JSONObject json = (JSONObject) obj;
if (rankingIds.contains(json.getString("id"))) { if (finalRankingIds.contains(json.getString("id"))) {
json.put("inTheList", true); json.put("inTheList", true);
} }
if (supplementList.contains(json.getString("name"))) {
json.put("supplement", true);
}
return json; return json;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
result.put("data", list); result.put("data", list);
...@@ -187,6 +197,136 @@ public class AppHotController extends BaseController { ...@@ -187,6 +197,136 @@ public class AppHotController extends BaseController {
} }
} }
@ApiOperation("热点库-根据热搜平台和标题匹配查询条件")
@GetMapping("/match-criteria")
public ResponseResult matchSearchCriteria(@RequestParam String name, @RequestParam String type) {
Long[] timeRangeMonth = commonService.getTimeRangeMonth();
int defaultPageSize = 5;
JSONObject result = searchHotHandler(10000, 1, HotPlatformEnum.convertFromName2Eng(type), "endTime", timeRangeMonth[0], timeRangeMonth[1]);
int index = 0;
boolean matched = false;
List<JSONObject> data = result.getJSONArray("data").toJavaList(JSONObject.class);
for (JSONObject json : data) {
index++;
if (name.equals(json.getString("name"))) {
matched = true;
break;
}
}
JSONObject res = new JSONObject();
res.put("matched", matched);
if (matched) {
res.put("page", (index + defaultPageSize - 1) / defaultPageSize);
res.put("type", HotPlatformEnum.convertFromName2Eng(type));
}
return ResponseResult.success(res);
}
@ApiOperation("热点库-品牌热点-补录获取")
@GetMapping("/supplementWord/get")
public ResponseResult getSupplementWord() {
String projectId = UserThreadLocal.getProjectId();
String key = RedisKeyPrefix.supplementWordKey(projectId);
List<Object> valueList = redisUtil.getMapValueAll(key);
List<SupplementWord> collect = valueList.stream().map(word -> JSON.parseObject((String) word, SupplementWord.class)).sorted((x, y) -> Long.compare(y.getUpdateTime(), x.getUpdateTime())).collect(Collectors.toList());
return ResponseResult.success(collect);
}
@ApiOperation("热点库-品牌热点-补录新增")
@PostMapping("/supplementWord/add")
public ResponseResult addSupplementWord(@ApiParam(name = "json:{title:标题}") @RequestBody JSONObject json) {
String key = RedisKeyPrefix.supplementWordKey(UserThreadLocal.getProjectId());
if (redisUtil.getMapSize(key) >= 50) {
return ResponseResult.failure("补录超过预设上限");
}
String title = json.getString("title");
if (StringUtils.isEmpty(title)) {
return ResponseResult.failure("补录新增失败");
}
SupplementWord supplementWord = new SupplementWord(title, UserThreadLocal.getNickname());
boolean result = redisUtil.setMapValue(key, supplementWord.uniqueKey(), JSON.toJSONString(supplementWord));
if (!result) {
return ResponseResult.failure("补录新增失败");
}
return ResponseResult.success();
}
@ApiOperation("热点库-品牌热点-补录修改")
@PutMapping("/supplementWord/update")
public ResponseResult updateSupplementWord(@ApiParam(name = "json:{title:原标题,newTitle:新标题,updateTime:更新时间}") @RequestBody JSONObject json) {
String newTitle = json.getString("newTitle");
String title = json.getString("title");
Long updateTime = json.getLong("updateTime");
SupplementWord supplementWord = new SupplementWord(newTitle, UserThreadLocal.getNickname());
boolean result = redisUtil.resetMapValue(RedisKeyPrefix.supplementWordKey(UserThreadLocal.getProjectId()), title + updateTime, supplementWord.uniqueKey(), JSON.toJSONString(supplementWord));
if (!result) {
return ResponseResult.failure("补录修改失败");
}
return ResponseResult.success();
}
@ApiOperation("热点库-品牌热点-补录删除")
@DeleteMapping("/supplementWord/delete")
public ResponseResult deleteSupplementWord(@ApiParam(name = "json:{title:原标题,updateTime:更新时间}") @RequestBody JSONObject json) {
String title = json.getString("title");
Long updateTime = json.getLong("updateTime");
redisUtil.deleteMapValue(RedisKeyPrefix.supplementWordKey(UserThreadLocal.getProjectId()), title + updateTime);
return ResponseResult.success();
}
@ApiOperation("热点库-品牌热点-热点总览")
@GetMapping("/overview")
public ResponseResult hotOverview() {
Long[] timeMonth = commonService.getTimeRangeFormatMonth();
JSONObject result = searchHotHandler(10000, 1, allPlatform, "endTime", timeMonth[0], timeMonth[1]);
if (Objects.isNull(result)) {
return ResponseResult.success();
}
List<JSONObject> list = result.getJSONArray("data").stream().map(obj -> {
JSONObject json = (JSONObject) obj;
json.put("platform", HotPlatformEnum.convertPlatform(json.getString("type")));
return json;
}).collect(Collectors.toList());
result.put("data", list);
return ResponseResult.success(result);
}
@ApiOperation("热点库-品牌热点-热搜对比")
@GetMapping("/contrast")
public ResponseResult hotContrast() {
// 默认返回近一年的数据
JSONObject result = searchHotHandler(10000, 1, allPlatform, "endTime", null, null);
if (Objects.isNull(result)) {
return ResponseResult.success();
}
JSONObject data = new JSONObject();
List<JSONObject> list = result.getJSONArray("data").toJavaList(JSONObject.class);
// 近一周的数据统计
data.put("weekContrast", contrastReport(list, commonService.getTimeRangeFormatWeek(), Constant.ONE_WEEK));
data.put("monthContrast", contrastReport(list, commonService.getTimeRangeFormatMonth(), Constant.ONE_MONTH));
return ResponseResult.success(data);
}
@ApiOperation("热点库-品牌热点-热搜趋势")
@GetMapping("/trend")
public ResponseResult hotSearchTrend(@RequestParam String name, @RequestParam Long startTime, @RequestParam String type) {
ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplate.getForEntity(hotSearchTrendUrl, JSONObject.class, name, startTime, HotPlatformEnum.convertFromName2Eng(type));
if (Objects.isNull(jsonObjectResponseEntity.getBody())) {
return ResponseResult.failure("查询热搜趋势失败");
}
return ResponseResult.success(jsonObjectResponseEntity.getBody());
}
@ApiOperation("热点库-品牌热点-上榜/峰值截图")
@GetMapping("/snapshot")
public ResponseResult hotSnapshot(@RequestParam String type, @RequestParam Long time, @RequestParam Integer rank) {
ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplate.getForEntity(hotSearchSnapshotUrl, JSONObject.class, HotPlatformEnum.convertFromName2Eng(type), time, rank);
if (Objects.isNull(jsonObjectResponseEntity.getBody())) {
return ResponseResult.failure("上榜/峰值截图失败");
}
return ResponseResult.success(jsonObjectResponseEntity.getBody());
}
@ApiOperation("首页-近24小时热门舆情,查竞品-竞品动态") @ApiOperation("首页-近24小时热门舆情,查竞品-竞品动态")
@GetMapping("/latestNews") @GetMapping("/latestNews")
public ResponseResult latestNews(@RequestParam(value = "size", defaultValue = "5") Integer size, public ResponseResult latestNews(@RequestParam(value = "size", defaultValue = "5") Integer size,
...@@ -217,4 +357,56 @@ public class AppHotController extends BaseController { ...@@ -217,4 +357,56 @@ public class AppHotController extends BaseController {
}, executor)).toArray(CompletableFuture[]::new)).join(); }, executor)).toArray(CompletableFuture[]::new)).join();
return ResponseResult.success(resultList); return ResponseResult.success(resultList);
} }
/**
* 通过热搜中间件获取数据
*
* @param pageSize
* @param page
* @param type
* @param sort
* @param startTime
* @param endTime
* @return
*/
private JSONObject searchHotHandler(int pageSize, int page, String type, String sort, Long startTime, Long endTime) {
String keywordStr = redisUtil.get(RedisKeyPrefix.hotKeywordKey(UserThreadLocal.getProjectId()));
if (null == keywordStr) {
return null;
}
String accurateWord = null;
List<Object> valueList = redisUtil.getMapValueAll(RedisKeyPrefix.supplementWordKey(UserThreadLocal.getProjectId()));
if (CollectionUtils.isNotEmpty(valueList)) {
List<String> collect = valueList.stream().map(word -> JSON.parseObject((String) word, SupplementWord.class).getTitle()).collect(Collectors.toList());
accurateWord = StringUtils.join(collect, "|");
}
String keyword = StringUtils.join(JSONArray.parseArray(keywordStr, String.class), "|");
ResponseEntity<JSONObject> jsonObjectResponseEntity;
if (null != startTime && null != endTime) {
jsonObjectResponseEntity = restTemplate.getForEntity(hotSearchUrl + "&startTime={7}&endTime={8}", JSONObject.class, pageSize, page, type, keyword, sort, accurateWord, startTime, endTime);
} else {
jsonObjectResponseEntity = restTemplate.getForEntity(hotSearchUrl, JSONObject.class, pageSize, page, type, keyword, sort, accurateWord);
}
return jsonObjectResponseEntity.getBody();
}
private JSONObject contrastReport(List<JSONObject> source, Long[] timeRange, Long space) {
JSONObject result = new JSONObject();
List<JSONObject> list = source.stream().filter(json -> json.getLong("startTime") >= timeRange[0]).collect(Collectors.toList());
List<JSONObject> lastList = source.stream().filter(json -> json.getLong("startTime") >= (timeRange[0] - space) && json.getLong("startTime") < timeRange[0]).collect(Collectors.toList());
result.put("currentCount", list.size());
result.put("lastCount", list.size() - lastList.size());
Map<String, List<JSONObject>> platformMap = list.stream().collect(Collectors.groupingBy(json -> HotPlatformEnum.convertPlatform(json.getString("type"))));
List<JSONObject> platformCount = new ArrayList<>();
platformMap.forEach((platform, datas) -> {
JSONObject json = new JSONObject();
json.put("platform", platform);
json.put("count", datas.size());
platformCount.add(json);
});
result.put("platformCount", platformCount);
result.put("averageCount", source.size() / (Constant.ONE_YEAR / space));
return result;
}
} }
...@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Map; import java.util.Map;
...@@ -92,33 +93,54 @@ public class AppWarnController extends BaseController { ...@@ -92,33 +93,54 @@ public class AppWarnController extends BaseController {
@Value("${warn.taskSwitch.url}") @Value("${warn.taskSwitch.url}")
private String warnTaskSwitchUrl; private String warnTaskSwitchUrl;
@ApiOperation("情报预警-推送任务获取/新增") @ApiOperation("情报预警-推送任务获取")
@GetMapping("/project") @GetMapping("/project")
public ResponseResult getPushTaskId() { public ResponseResult getPushTaskId() {
try { try {
String projectId = UserThreadLocal.getProjectId(); return pushTaskId(null, null, HttpMethod.GET);
String projectName = projectService.getProjectById(projectId).getProjectName(); } catch (Exception e) {
String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString(); log.error("情报预警-推送任务获取失败", e);
// header不支持中文 故对userName进行encode操作 return ResponseResult.failure("情报预警-推送任务获取失败");
String userName = URLEncoder.encode(userService.queryUserInfo(userId, projectId).getNickname(), "UTF-8"); }
// 请求头参数设置 }
HttpHeaders headers = new HttpHeaders();
headers.add("token", token);
headers.add("userId", userId);
headers.add("userName", userName);
HttpEntity<Object> request = new HttpEntity<>(headers);
JSONObject data = restTemplate.exchange(warnProjectUrl, HttpMethod.GET, request, JSONObject.class, projectId, projectName).getBody().getJSONObject("data"); @ApiOperation("情报预警-推送任务新增")
return ResponseResult.success(data); @PostMapping("/project")
}catch (Exception e){ public ResponseResult postPushTaskId(@RequestBody JSONObject json) {
log.error("情报预警-推送任务获取/新增失败", e); try {
return ResponseResult.failure("情报预警-推送任务获取/新增失败"); return pushTaskId(null, json.getString("planName"), HttpMethod.POST);
} catch (Exception e) {
log.error("情报预警-推送任务新增失败", e);
return ResponseResult.failure("情报预警-推送任务新增失败");
}
}
@ApiOperation("情报预警-推送任务修改")
@PutMapping("/project")
public ResponseResult putPushTaskId(@RequestBody JSONObject json) {
try {
return pushTaskId(json.getString("taskId"), json.getString("planName"), HttpMethod.PUT);
} catch (Exception e) {
log.error("情报预警-推送任务修改失败", e);
return ResponseResult.failure("情报预警-推送任务修改失败");
}
}
@ApiOperation("情报预警-推送任务删除")
@DeleteMapping("/project")
@Auth(role = RoleEnum.ADMIN)
public ResponseResult deletePushTaskId(@RequestParam(value = "taskId") String taskId) {
try {
return pushTaskId(taskId, null, HttpMethod.DELETE);
} catch (Exception e) {
log.error("情报预警-推送任务删除失败", e);
return ResponseResult.failure("情报预警-推送任务删除失败");
} }
} }
@ApiOperation("情报预警-获取项目预警更新条件") @ApiOperation("情报预警-获取项目预警更新条件")
@GetMapping("/warnCriteria") @GetMapping("/warnCriteria")
public ResponseResult getProjectWarnCriteria(@RequestParam(value = "type") String type){ public ResponseResult getProjectWarnCriteria(@RequestParam(value = "type") String type) {
return ResponseResult.success(projectWarnService.getProjectWarnCriteria(UserThreadLocal.getProjectId(), type)); return ResponseResult.success(projectWarnService.getProjectWarnCriteria(UserThreadLocal.getProjectId(), type));
} }
...@@ -136,7 +158,7 @@ public class AppWarnController extends BaseController { ...@@ -136,7 +158,7 @@ public class AppWarnController extends BaseController {
@ApiOperation("情报预警-已扫码推送名单获取") @ApiOperation("情报预警-已扫码推送名单获取")
@GetMapping("/pushRecipientsList") @GetMapping("/pushRecipientsList")
public ResponseResult pushRecipientList(@RequestParam(value = "pushTaskId") String pushTaskId){ public ResponseResult pushRecipientList(@RequestParam(value = "pushTaskId") String pushTaskId) {
// 请求头 // 请求头
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("token", token); headers.add("token", token);
...@@ -149,7 +171,7 @@ public class AppWarnController extends BaseController { ...@@ -149,7 +171,7 @@ public class AppWarnController extends BaseController {
@ApiOperation("情报预警-删除推送人") @ApiOperation("情报预警-删除推送人")
@GetMapping("/deletePushRecipients") @GetMapping("/deletePushRecipients")
public ResponseResult deletePushRecipients(@RequestParam(value = "recipientsId") String recipientsId, public ResponseResult deletePushRecipients(@RequestParam(value = "recipientsId") String recipientsId,
@RequestParam(value = "pushTaskId") String pushTaskId){ @RequestParam(value = "pushTaskId") String pushTaskId) {
// 请求头 // 请求头
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("token", token); headers.add("token", token);
...@@ -163,7 +185,7 @@ public class AppWarnController extends BaseController { ...@@ -163,7 +185,7 @@ public class AppWarnController extends BaseController {
@PutMapping("/channel/{pushTaskId}") @PutMapping("/channel/{pushTaskId}")
public ResponseResult channel(@ApiParam(name = "channelConfig", value = "情报预警-渠道参与配置-json:{\"channel\": \"string\", \"configName\": \"string\", \"duplicate\": true, \"friendlyChannel\": true, \"markerTags\": [\"string\"], \"primary\": [true], \"pushInterval\": 0, \"threshold\": 0, \"used\": true}", required = true) public ResponseResult channel(@ApiParam(name = "channelConfig", value = "情报预警-渠道参与配置-json:{\"channel\": \"string\", \"configName\": \"string\", \"duplicate\": true, \"friendlyChannel\": true, \"markerTags\": [\"string\"], \"primary\": [true], \"pushInterval\": 0, \"threshold\": 0, \"used\": true}", required = true)
@RequestBody JSONObject channelConfig, @RequestBody JSONObject channelConfig,
@PathVariable(value = "pushTaskId") String pushTaskId){ @PathVariable(value = "pushTaskId") String pushTaskId) {
try { try {
String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString(); String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString();
String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8"); String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8");
...@@ -178,9 +200,9 @@ public class AppWarnController extends BaseController { ...@@ -178,9 +200,9 @@ public class AppWarnController extends BaseController {
JSONObject data = restTemplate.exchange(warnChannelUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data"); JSONObject data = restTemplate.exchange(warnChannelUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data");
return ResponseResult.success(data); return ResponseResult.success(data);
}catch (Exception e){ } catch (Exception e) {
log.error("情报预警-渠道参与配置失败", e); log.error("情报预警-渠道参与配置失败", e);
return ResponseResult.failure("情报预警-渠道参与配置失败"); return ResponseResult.failure("情报预警-渠道参与配置失败");
} }
} }
...@@ -188,7 +210,7 @@ public class AppWarnController extends BaseController { ...@@ -188,7 +210,7 @@ public class AppWarnController extends BaseController {
@PutMapping("/hotTop/{pushTaskId}") @PutMapping("/hotTop/{pushTaskId}")
public ResponseResult hotTop(@ApiParam(name = "hotTopConfig", value = "情报预警-热点榜单配置-json:{\"configName\": \"string\", \"filterKeyword\": \"string\", \"firstTop\": true, \"introduction\": true,\"listType\": [\"string\"], \"newHeight\": true, \"pushInterval\": 0, \"topNewHeight\": 0, \"topOnceAgain\": true, \"used\": true, \"warnKeyword\": \"string\"}", required = true) public ResponseResult hotTop(@ApiParam(name = "hotTopConfig", value = "情报预警-热点榜单配置-json:{\"configName\": \"string\", \"filterKeyword\": \"string\", \"firstTop\": true, \"introduction\": true,\"listType\": [\"string\"], \"newHeight\": true, \"pushInterval\": 0, \"topNewHeight\": 0, \"topOnceAgain\": true, \"used\": true, \"warnKeyword\": \"string\"}", required = true)
@RequestBody JSONObject hotTopConfig, @RequestBody JSONObject hotTopConfig,
@PathVariable(value = "pushTaskId") String pushTaskId){ @PathVariable(value = "pushTaskId") String pushTaskId) {
try { try {
String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString(); String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString();
String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8"); String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8");
...@@ -203,7 +225,7 @@ public class AppWarnController extends BaseController { ...@@ -203,7 +225,7 @@ public class AppWarnController extends BaseController {
JSONObject data = restTemplate.exchange(warnHotTopUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data"); JSONObject data = restTemplate.exchange(warnHotTopUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data");
return ResponseResult.success(data); return ResponseResult.success(data);
}catch (Exception e){ } catch (Exception e) {
log.error("情报预警-热点榜单配置失败", e); log.error("情报预警-热点榜单配置失败", e);
return ResponseResult.failure("情报预警-热点榜单配置失败"); return ResponseResult.failure("情报预警-热点榜单配置失败");
} }
...@@ -213,7 +235,7 @@ public class AppWarnController extends BaseController { ...@@ -213,7 +235,7 @@ public class AppWarnController extends BaseController {
@PutMapping("/hotEvent/{pushTaskId}") @PutMapping("/hotEvent/{pushTaskId}")
public ResponseResult hotEvent(@ApiParam(name = "hotEventConfig", value = "情报预警-热点事件配置-json:{\"configName\": \"string\", \"contendsEvent\": [\"string\"], \"eventTop\": 0, \"ownEvent\": [\"string\"], \"timeCycles\": 0,\"used\": true, \"zhiWeiEvent\": [\"string\"]}", required = true) public ResponseResult hotEvent(@ApiParam(name = "hotEventConfig", value = "情报预警-热点事件配置-json:{\"configName\": \"string\", \"contendsEvent\": [\"string\"], \"eventTop\": 0, \"ownEvent\": [\"string\"], \"timeCycles\": 0,\"used\": true, \"zhiWeiEvent\": [\"string\"]}", required = true)
@RequestBody JSONObject hotEventConfig, @RequestBody JSONObject hotEventConfig,
@PathVariable(value = "pushTaskId") String pushTaskId){ @PathVariable(value = "pushTaskId") String pushTaskId) {
try { try {
String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString(); String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString();
String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8"); String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8");
...@@ -228,7 +250,7 @@ public class AppWarnController extends BaseController { ...@@ -228,7 +250,7 @@ public class AppWarnController extends BaseController {
JSONObject data = restTemplate.exchange(warnHotEventUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data"); JSONObject data = restTemplate.exchange(warnHotEventUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data");
return ResponseResult.success(data); return ResponseResult.success(data);
}catch (Exception e){ } catch (Exception e) {
log.error("情报预警-热点事件配置失败- ", e); log.error("情报预警-热点事件配置失败- ", e);
return ResponseResult.failure("情报预警-热点事件配置失败"); return ResponseResult.failure("情报预警-热点事件配置失败");
} }
...@@ -238,7 +260,7 @@ public class AppWarnController extends BaseController { ...@@ -238,7 +260,7 @@ public class AppWarnController extends BaseController {
@PutMapping("/yuQing/{pushTaskId}") @PutMapping("/yuQing/{pushTaskId}")
public ResponseResult yuQing(@ApiParam(name = "yuQingConfig", value = "情报预警-舆情动态配置-json:{\"channelTypes\": [\"string\"], \"configName\": \"string\", \"contends\": [\"string\"], \"duplicate\": true, \"keyword\": \"string\", \"markerTags\": [\"string\"], \"primary\": [true], \"pushInterval\": 0, \"used\": true}", required = true) public ResponseResult yuQing(@ApiParam(name = "yuQingConfig", value = "情报预警-舆情动态配置-json:{\"channelTypes\": [\"string\"], \"configName\": \"string\", \"contends\": [\"string\"], \"duplicate\": true, \"keyword\": \"string\", \"markerTags\": [\"string\"], \"primary\": [true], \"pushInterval\": 0, \"used\": true}", required = true)
@RequestBody JSONObject yuQingConfig, @RequestBody JSONObject yuQingConfig,
@PathVariable(value = "pushTaskId") String pushTaskId){ @PathVariable(value = "pushTaskId") String pushTaskId) {
try { try {
String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString(); String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString();
String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8"); String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8");
...@@ -253,7 +275,7 @@ public class AppWarnController extends BaseController { ...@@ -253,7 +275,7 @@ public class AppWarnController extends BaseController {
JSONObject data = restTemplate.exchange(warnYuQingUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data"); JSONObject data = restTemplate.exchange(warnYuQingUrl, HttpMethod.PUT, request, JSONObject.class, pushTaskId).getBody().getJSONObject("data");
return ResponseResult.success(data); return ResponseResult.success(data);
}catch (Exception e){ } catch (Exception e) {
log.error("情报预警-舆情动态配置失败", e); log.error("情报预警-舆情动态配置失败", e);
return ResponseResult.failure("情报预警-舆情动态配置失败"); return ResponseResult.failure("情报预警-舆情动态配置失败");
} }
...@@ -262,7 +284,7 @@ public class AppWarnController extends BaseController { ...@@ -262,7 +284,7 @@ public class AppWarnController extends BaseController {
@ApiOperation("情报预警-任务开关") @ApiOperation("情报预警-任务开关")
@PutMapping("/taskSwitch") @PutMapping("/taskSwitch")
public ResponseResult taskSwitch(@ApiParam(name = "info", value = "推送任务-开关-json:{id:, used:true|false, configType:HOT_EVENT}", required = true) public ResponseResult taskSwitch(@ApiParam(name = "info", value = "推送任务-开关-json:{id:, used:true|false, configType:HOT_EVENT}", required = true)
@RequestBody JSONObject info){ @RequestBody JSONObject info) {
try { try {
String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString(); String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString();
String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8"); String userName = URLEncoder.encode(userService.queryUserInfo(userId, UserThreadLocal.getProjectId()).getNickname(), "UTF-8");
...@@ -277,9 +299,43 @@ public class AppWarnController extends BaseController { ...@@ -277,9 +299,43 @@ public class AppWarnController extends BaseController {
JSONObject data = restTemplate.exchange(warnTaskSwitchUrl, HttpMethod.PUT, request, JSONObject.class).getBody().getJSONObject("data"); JSONObject data = restTemplate.exchange(warnTaskSwitchUrl, HttpMethod.PUT, request, JSONObject.class).getBody().getJSONObject("data");
return ResponseResult.success(data); return ResponseResult.success(data);
}catch (Exception e){ } catch (Exception e) {
log.error("情报预警-任务开关失败", e); log.error("情报预警-任务开关失败", e);
return ResponseResult.failure("情报预警-任务开关失败"); return ResponseResult.failure("情报预警-任务开关失败");
} }
} }
private ResponseResult pushTaskId(String taskId, String planName, HttpMethod httpMethod) throws UnsupportedEncodingException {
String projectId = UserThreadLocal.getProjectId();
String projectName = projectService.getProjectById(projectId).getProjectName();
String userId = JwtUtil.unsign(request.getHeader(jwtKey), Map.class).get(GenericAttribute.USER_ID).toString();
// header不支持中文 故对userName进行encode操作
String userName = URLEncoder.encode(userService.queryUserInfo(userId, projectId).getNickname(), "UTF-8");
// 请求头参数设置
HttpHeaders headers = new HttpHeaders();
headers.add("token", token);
headers.add("userId", userId);
headers.add("userName", userName);
HttpEntity<Object> request;
if (HttpMethod.GET == httpMethod) {
request = new HttpEntity<>(headers);
return ResponseResult.success(restTemplate.exchange(warnProjectUrl + "?projectId={1}&projectName={2}", httpMethod, request, JSONObject.class, projectId, projectName).getBody().getJSONArray("data"));
}
if (HttpMethod.DELETE == httpMethod) {
request = new HttpEntity<>(headers);
return ResponseResult.success(restTemplate.exchange(warnProjectUrl + "/"+taskId, httpMethod, request, JSONObject.class).getBody().getJSONArray(
"data"));
}
JSONObject paramMap = new JSONObject();
paramMap.put("planName", planName);
if (HttpMethod.PUT == httpMethod) {
paramMap.put("taskId", taskId);
} else {
paramMap.put("projectId", projectId);
paramMap.put("projectName", projectName);
}
request = new HttpEntity<>(paramMap, headers);
return ResponseResult.success(restTemplate.exchange(warnProjectUrl, httpMethod, request, JSONObject.class).getBody().getJSONArray("data"));
}
} }
...@@ -76,12 +76,14 @@ public class MobileEventController extends BaseController { ...@@ -76,12 +76,14 @@ public class MobileEventController extends BaseController {
@ApiOperation("移动端事件详情-事件基础信息") @ApiOperation("移动端事件详情-事件基础信息")
@GetMapping("/detail/baseInfo") @GetMapping("/detail/baseInfo")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult eventBaseInfo(@RequestParam(value = "eventId") String eventId){ public ResponseResult eventBaseInfo(@RequestParam(value = "eventId") String eventId){
return ResponseResult.success(eventService.eventBaseInfo(eventId)); return ResponseResult.success(eventService.eventBaseInfo(eventId));
} }
@ApiOperation("移动端事件详情-传播趋势图") @ApiOperation("移动端事件详情-传播趋势图")
@GetMapping("/detail/dissemination-trends") @GetMapping("/detail/dissemination-trends")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult eventDisseminationTrends(@RequestParam(value = "eventId") String eventId, public ResponseResult eventDisseminationTrends(@RequestParam(value = "eventId") String eventId,
@RequestParam(value = "type", defaultValue = "小时") String type){ @RequestParam(value = "type", defaultValue = "小时") String type){
return ResponseResult.success(eventService.eventDisseminationTrends(eventId, type)); return ResponseResult.success(eventService.eventDisseminationTrends(eventId, type));
...@@ -89,6 +91,7 @@ public class MobileEventController extends BaseController { ...@@ -89,6 +91,7 @@ public class MobileEventController extends BaseController {
@ApiOperation("移动端事件详情-渠道发声") @ApiOperation("移动端事件详情-渠道发声")
@GetMapping("/detail/channel-voices") @GetMapping("/detail/channel-voices")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult eventChannelVoices(@RequestParam(value = "eventId") String eventId, public ResponseResult eventChannelVoices(@RequestParam(value = "eventId") String eventId,
@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,
...@@ -100,6 +103,7 @@ public class MobileEventController extends BaseController { ...@@ -100,6 +103,7 @@ public class MobileEventController extends BaseController {
@ApiOperation("移动端事件详情-热门文章分析") @ApiOperation("移动端事件详情-热门文章分析")
@GetMapping("/detail/top-articles-analysis") @GetMapping("/detail/top-articles-analysis")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult eventTopArticlesAnalysis(@RequestParam(value = "eventId") String eventId, public ResponseResult eventTopArticlesAnalysis(@RequestParam(value = "eventId") String eventId,
@RequestParam(value = "type", defaultValue = "按时间") String type, @RequestParam(value = "type", defaultValue = "按时间") String type,
@RequestParam(value = "emotion", defaultValue = "全部") String emotion, @RequestParam(value = "emotion", defaultValue = "全部") String emotion,
...@@ -109,6 +113,7 @@ public class MobileEventController extends BaseController { ...@@ -109,6 +113,7 @@ public class MobileEventController extends BaseController {
@ApiOperation("移动端事件详情-热门渠道发声、上榜热搜、词云") @ApiOperation("移动端事件详情-热门渠道发声、上榜热搜、词云")
@GetMapping("/detail/additional-info") @GetMapping("/detail/additional-info")
@Auth(role = RoleEnum.NO_AUTHORISE)
public ResponseResult eventDetailAdditionalInfo(@RequestParam(value = "eventId") String eventId){ public ResponseResult eventDetailAdditionalInfo(@RequestParam(value = "eventId") String eventId){
return ResponseResult.success(eventService.eventDetailAdditionalInfo(eventId)); return ResponseResult.success(eventService.eventDetailAdditionalInfo(eventId));
} }
......
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.HighlightWord;
/**
* @ClassName: HighlightWordDao
* @Description HighlightWordDao
* @author: sjj
* @date: 2022-06-06 09:47
*/
public interface HighlightWordDao extends BaseMongoDao<HighlightWord>{
}
...@@ -172,7 +172,7 @@ public class BaseMongoDaoImpl<T extends AbstractBaseMongo> implements BaseMongoD ...@@ -172,7 +172,7 @@ public class BaseMongoDaoImpl<T extends AbstractBaseMongo> implements BaseMongoD
return; return;
} }
for (Map.Entry<String, Object> entry : JSONObject.parseObject(sorter).entrySet()) { for (Map.Entry<String, Object> entry : JSONObject.parseObject(sorter).entrySet()) {
if (entry.getValue().toString().contains("desc")) { if (null != entry.getValue() && entry.getValue().toString().contains("desc")) {
query.with(Sort.by(Sort.Order.desc(entry.getKey()))); query.with(Sort.by(Sort.Order.desc(entry.getKey())));
} else { } else {
query.with(Sort.by(Sort.Order.asc(entry.getKey()))); query.with(Sort.by(Sort.Order.asc(entry.getKey())));
......
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.HighlightWordDao;
import com.zhiwei.brandkbs2.pojo.HighlightWord;
import org.springframework.stereotype.Component;
/**
* @ClassName: HighlightWordDaoImpl
* @Description HighlightWordDaoImpl
* @author: sjj
* @date: 2022-06-06 09:48
*/
@Component("highlightWordDao")
public class HighlightWordDaoImpl extends BaseMongoDaoImpl<HighlightWord> implements HighlightWordDao {
private static final String COLLECTION_NAME = "brandkbs_highlight_word";
public HighlightWordDaoImpl() {
super(COLLECTION_NAME);
}
}
package com.zhiwei.brandkbs2.easyexcel.dto; package com.zhiwei.brandkbs2.easyexcel.dto;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.zhiwei.brandkbs2.pojo.HighWord; import com.zhiwei.brandkbs2.pojo.AbstractBaseWord;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
...@@ -16,7 +16,7 @@ import java.util.Date; ...@@ -16,7 +16,7 @@ import java.util.Date;
*/ */
@Data @Data
@ToString @ToString
public class ExportHighWordDTO { public class ExportWordDTO {
/** /**
* 名称 * 名称
...@@ -36,8 +36,8 @@ public class ExportHighWordDTO { ...@@ -36,8 +36,8 @@ public class ExportHighWordDTO {
@ExcelProperty("上传人") @ExcelProperty("上传人")
private String submitter; private String submitter;
public static ExportHighWordDTO createFromHighWord(HighWord highWord){ public static ExportWordDTO createFromWord(AbstractBaseWord word) {
return Tools.convertMap(highWord,ExportHighWordDTO.class); return Tools.convertMap(word, ExportWordDTO.class);
} }
} }
package com.zhiwei.brandkbs2.enmus;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName: HotPlatformEnum
* @Description 热搜中间件返回平台枚举
* @author: sjj
* @date: 2023-06-13 14:30
*/
@Getter
public enum HotPlatformEnum {
WEIBO("微博", "weibo", "微博热搜"),
WEIBO_TOPIC("微博", "weibo-topic", "微博话题"),
WEIBO_RISE("微博", "weibo-rise", "微博预热榜"),
ZHIHU("知乎", "zhihu", "知乎热搜"),
JINRITOUTIAO("今日头条", "toutiao", "今日头条热搜"),
DOUYIN("抖音", "douyin", "抖音热搜"),
BILIBILI("B站", "bilibili-ranking", "B站热搜"),
KUAISHOU("快手", "kuaishou", "快手热榜"),
BAIDU("百度", "baidu", "百度热搜");
private final String platform;
private final String engName;
private final String name;
private static final Map<String, String> CONVERT_MAP = new HashMap<>();
static {
for (HotPlatformEnum platform : HotPlatformEnum.values()) {
CONVERT_MAP.put(platform.name, platform.platform);
}
}
HotPlatformEnum(String platform, String engName, String name) {
this.platform = platform;
this.engName = engName;
this.name = name;
}
public static String convertPlatform(String name) {
return CONVERT_MAP.get(name);
}
public static String convertFromName2Eng(String name) {
for (HotPlatformEnum platform : HotPlatformEnum.values()) {
if (name.equals(platform.name)) {
return platform.engName;
}
}
return name;
}
}
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: AbstractBaseWord
* @Description AbstractBaseWord
* @author: sjj
* @date: 2023-05-25 14:41
*/
@Setter
@Getter
public abstract class AbstractBaseWord extends AbstractBaseMongo {
/**
* 名称
*/
private String keyword;
/**
* 创建时间
*/
private Long cTime;
/**
* 上传人
*/
private String submitter;
/**
* 项目ID
*/
private String projectId;
public static <T> List<T> createFromList(List<String> keywords, String projectId, String submitter) {
List<T> res = new ArrayList<>();
Long now = System.currentTimeMillis();
for (String keyword : keywords) {
AbstractBaseWord word = new HighWord();
word.setKeyword(keyword);
word.setCTime(now);
word.setProjectId(projectId);
word.setSubmitter(submitter);
res.add((T) word);
}
return res;
}
}
...@@ -4,10 +4,6 @@ import lombok.Getter; ...@@ -4,10 +4,6 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/** /**
* @ClassName: HighWord * @ClassName: HighWord
* @Description 高频词实体 * @Description 高频词实体
...@@ -17,40 +13,5 @@ import java.util.List; ...@@ -17,40 +13,5 @@ import java.util.List;
@Getter @Getter
@Setter @Setter
@Document(collection = "brandkbs_high_word") @Document(collection = "brandkbs_high_word")
public class HighWord extends AbstractBaseMongo { public class HighWord extends AbstractBaseWord {
/**
* 名称
*/
private String keyword;
/**
* 创建时间
*/
private Long cTime;
/**
* 上传人
*/
private String submitter;
/**
* 项目ID
*/
private String projectId;
public static List<HighWord> createFromList(List<String> keywords, String projectId, String submitter) {
List<HighWord> res = new ArrayList<>();
Long now = new Date().getTime();
for (String keyword : keywords) {
HighWord highWord = new HighWord();
highWord.setKeyword(keyword);
highWord.setCTime(now);
highWord.setProjectId(projectId);
highWord.setSubmitter(submitter);
res.add(highWord);
}
return res;
}
} }
package com.zhiwei.brandkbs2.pojo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* @ClassName: HighWord
* @Description 高频词实体
* @author: sjj
* @date: 2022-06-06 09:36
*/
@Getter
@Setter
@Document(collection = "brandkbs_highlight_word")
public class HighlightWord extends AbstractBaseWord {
}
...@@ -87,6 +87,11 @@ public class Project extends AbstractProject { ...@@ -87,6 +87,11 @@ public class Project extends AbstractProject {
private Long uTime; private Long uTime;
/** /**
* 高亮关键词
*/
private List<String> highlightKeyword;
/**
* 项目主品牌配置信息转换 * 项目主品牌配置信息转换
* *
* @return 项目对象 * @return 项目对象
......
package com.zhiwei.brandkbs2.pojo; package com.zhiwei.brandkbs2.pojo;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.pojo.dto.UserDTO;
import com.zhiwei.middleware.auth.pojo.CenterUser; import com.zhiwei.middleware.auth.pojo.CenterUser;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -70,15 +72,41 @@ public class User extends AbstractBaseMongo { ...@@ -70,15 +72,41 @@ public class User extends AbstractBaseMongo {
*/ */
private String subscriptionAccountOpenId; private String subscriptionAccountOpenId;
public static User createFromCenterUser(CenterUser centerUser) { /**
* 操作人
*/
private String submitter;
private User(){
}
public static User createFromUserDTO(UserDTO userDTO, String submitter) {
User user = new User();
user.setId(userDTO.getId());
user.setNickname(userDTO.getNickname());
user.setCTime(System.currentTimeMillis());
user.setUsername(userDTO.getUsername());
user.setPhoneNumber(userDTO.getPhoneNumber());
if (RoleEnum.SUPER_ADMIN.getState() == userDTO.getRoleId()) {
user.setSuperAdmin(true);
} else {
user.setRoles(Collections.singletonList(UserRole.createFromUserDto(userDTO)));
user.setSuperAdmin(false);
}
user.setSubmitter(submitter);
return user;
}
public static User createFromCenterUser(CenterUser centerUser, String submitter) {
User user = new User(); User user = new User();
user.setId(String.valueOf(centerUser.getId())); user.setId(String.valueOf(centerUser.getId()));
user.setNickname(centerUser.getNickName()); user.setNickname(centerUser.getNickName());
user.setCTime(System.currentTimeMillis());
user.setUsername(centerUser.getName()); user.setUsername(centerUser.getName());
user.setPhoneNumber(Long.parseLong(centerUser.getPhone())); user.setPhoneNumber(Long.parseLong(centerUser.getPhone()));
user.setAvatarUrl(centerUser.getAvatarUrl()); user.setAvatarUrl(centerUser.getAvatarUrl());
user.setCTime(new Date().getTime());
user.setRoles(new ArrayList<>()); user.setRoles(new ArrayList<>());
user.setSubmitter(submitter);
return user; return user;
} }
......
package com.zhiwei.brandkbs2.pojo.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @ClassName: SupplementWord
* @Description SupplementWord
* @author: sjj
* @date: 2023-06-12 17:42
*/
@Data
@NoArgsConstructor
public class SupplementWord {
/**
* 补录标题
*/
private String title;
/**
* 更新时间
*/
private Long updateTime;
/**
* 提交人
*/
private String submitter;
public SupplementWord(String title, String submitter) {
this.title = title;
this.submitter = submitter;
this.updateTime = System.currentTimeMillis();
}
public String uniqueKey() {
return title + updateTime;
}
}
...@@ -59,6 +59,8 @@ public interface CommonService { ...@@ -59,6 +59,8 @@ public interface CommonService {
*/ */
void addMtagBatch(List<MarkInfo> markInfos); void addMtagBatch(List<MarkInfo> markInfos);
Long[] getTimeRangeYear();
Long[] getTimeRangeMonth(); Long[] getTimeRangeMonth();
Long[] getTimeRangeWeek(); Long[] getTimeRangeWeek();
......
package com.zhiwei.brandkbs2.service; package com.zhiwei.brandkbs2.service;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List;
/** /**
* @ClassName: HighWordService * @ClassName: HighWordService
* @Description 高频词服务接口 * @Description 高频词服务接口
* @author: sjj * @author: sjj
* @date: 2022-06-06 09:59 * @date: 2022-06-06 09:59
*/ */
public interface HighWordService { public interface HighWordService extends TableWordService{
}
/** \ No newline at end of file
* 分页查询高频词列表
*
* @param page 页码
* @param size 页码大小
* @param keyword 关键词
* @return PageVO<JSONObject>
*/
PageVO<JSONObject> findHighWord(int page, int size, String keyword);
/**
* 添加高频关键词
*
* @param highWords 高频词
*/
void addHighWordList(List<String> highWords);
/**
* 删除高频关键词
*
* @param id 高频词id
*/
void deleteHighWord(String id);
/**
* 下载高频关键词
*
* @return List<ExportHighWordDTO>
*/
List<ExportHighWordDTO> downloadHighWord();
}
package com.zhiwei.brandkbs2.service;
/**
* @ClassName: HighlightWordService
* @Description HighlightWordService
* @author: sjj
* @date: 2023-05-25 15:10
*/
public interface HighlightWordService extends TableWordService{
}
...@@ -133,4 +133,12 @@ public interface ProjectService { ...@@ -133,4 +133,12 @@ public interface ProjectService {
* @return * @return
*/ */
ResponseResult getHitTagsByLinkedGroupId(String linkedGroupId); ResponseResult getHitTagsByLinkedGroupId(String linkedGroupId);
/**
*
* @param projectId 项目id
* @return 高亮关键词
*/
List<String> getHighlightKeyword(String projectId);
} }
package com.zhiwei.brandkbs2.service;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List;
/**
* @ClassName: TableWordService
* @Description TableWordService
* @author: sjj
* @date: 2023-05-25 14:13
*/
public interface TableWordService{
/**
* 分页查询词组列表
*
* @param page 页码
* @param size 页码大小
* @param keyword 关键词
* @return PageVO<JSONObject>
*/
PageVO<JSONObject> findWord(int page, int size, String keyword);
/**
* 添加词组
*
* @param words 词组
*/
ResponseResult addWordList(List<String> words, String projectId, String submitter);
/**
* 删除词组
*
* @param id 词组id
*/
void deleteWord(String id);
/**
* 导出词组
*
* @return List<ExportWordDTO>
*/
List<ExportWordDTO> downloadWord(String projectId);
}
...@@ -49,9 +49,10 @@ public interface UserService { ...@@ -49,9 +49,10 @@ public interface UserService {
* @param keyword 关键字 * @param keyword 关键字
* @param pid 项目ID * @param pid 项目ID
* @param role 角色 * @param role 角色
* @param sorter 排序
* @return 所有用户 * @return 所有用户
*/ */
PageVO<JSONObject> findUserList(int page, int size, String keyword, String pid, int role); PageVO<JSONObject> findUserList(int page, int size, String keyword, String pid, int role, String sorter);
/** /**
* 添加用户 * 添加用户
......
...@@ -132,6 +132,13 @@ public class CommonServiceImpl implements CommonService { ...@@ -132,6 +132,13 @@ public class CommonServiceImpl implements CommonService {
} }
@Override @Override
public Long[] getTimeRangeYear() {
long endTime = Tools.truncDate(new Date(), Constant.DAY_PATTERN).getTime();
long startTime = DateUtils.addYears(new Date(endTime), -1).getTime();
return new Long[]{startTime, endTime};
}
@Override
public Long[] getTimeRangeMonth() { public Long[] getTimeRangeMonth() {
long endTime = Tools.truncDate(new Date(), Constant.DAY_PATTERN).getTime(); long endTime = Tools.truncDate(new Date(), Constant.DAY_PATTERN).getTime();
long startTime = DateUtils.addMonths(new Date(endTime), -1).getTime(); long startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
......
package com.zhiwei.brandkbs2.service.impl; package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.dao.HighWordDao; import com.zhiwei.brandkbs2.dao.HighWordDao;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO;
import com.zhiwei.brandkbs2.pojo.HighWord;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.HighWordService; import com.zhiwei.brandkbs2.service.HighWordService;
import com.zhiwei.brandkbs2.util.MongoUtil; import com.zhiwei.brandkbs2.util.MongoUtil;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* @ClassName: HighWordServiceImpl * @ClassName: HighWordServiceImpl
* @Description 高频词服务接口实现类 * @Description 高频词服务接口实现类
...@@ -23,49 +13,9 @@ import java.util.stream.Collectors; ...@@ -23,49 +13,9 @@ import java.util.stream.Collectors;
* @date: 2022-06-06 10:02 * @date: 2022-06-06 10:02
*/ */
@Service("highWordServiceImpl") @Service("highWordServiceImpl")
public class HighWordServiceImpl implements HighWordService { public class HighWordServiceImpl extends TableWordServiceImpl implements HighWordService {
@Resource(name = "highWordDao")
HighWordDao highWordDao;
@Resource(name = "mongoUtil")
private com.zhiwei.brandkbs2.util.MongoUtil mongoUtil;
@Override
public PageVO<JSONObject> findHighWord(int page, int size, String keyword) {
String projectId = UserThreadLocal.getProjectId();
Query query = Query.query(Criteria.where("projectId").is(projectId));
long count = highWordDao.count(query);
mongoUtil.start(page, size, query);
List<HighWord> highWordList = highWordDao.findListByKeywordFuzz(query, keyword, new String[]{"keyword"});
List<JSONObject> resList = highWordList.stream().map(highWord -> {
JSONObject result = new JSONObject();
result.put("id", highWord.getId());
result.put("keyword", highWord.getKeyword());
result.put("cTime", highWord.getCTime());
result.put("submitter", highWord.getSubmitter());
return result;
}).collect(Collectors.toList());
MongoUtil.PageHelper<JSONObject> pageHelper = mongoUtil.pageHelper(count, resList);
return PageVO.createPageVo(pageHelper, resList);
}
@Override public HighWordServiceImpl(@Qualifier("highWordDao") HighWordDao highWordDao, @Qualifier("mongoUtil") MongoUtil mongoUtil) {
public void addHighWordList(List<String> highWords) { super(highWordDao, mongoUtil);
List<String> existList = highWordDao.findList(null).stream().map(HighWord::getKeyword).collect(Collectors.toList());
// 去除重复数据
List<String> newList = highWords.stream().filter(word -> !existList.contains(word)).collect(Collectors.toList());
highWordDao.insertMany(HighWord.createFromList(newList, UserThreadLocal.getProjectId(), UserThreadLocal.getNickname()));
} }
@Override
public void deleteHighWord(String id) {
highWordDao.deleteOneById(id);
}
@Override
public List<ExportHighWordDTO> downloadHighWord() {
return highWordDao.findList(null).stream().map(ExportHighWordDTO::createFromHighWord).collect(Collectors.toList());
}
} }
package com.zhiwei.brandkbs2.service.impl;
import com.zhiwei.brandkbs2.dao.HighlightWordDao;
import com.zhiwei.brandkbs2.service.HighlightWordService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
/**
* @ClassName: HighlightWordServiceImpl
* @Description HighlightWordServiceImpl
* @author: sjj
* @date: 2023-05-25 15:11
*/
@Service("highlightWordServiceImpl")
public class HighlightWordServiceImpl extends TableWordServiceImpl implements HighlightWordService {
public HighlightWordServiceImpl(@Qualifier("highlightWordDao") HighlightWordDao highlightWordDao, @Qualifier("mongoUtil") MongoUtil mongoUtil) {
super(highlightWordDao, mongoUtil);
}
}
...@@ -15,6 +15,7 @@ import com.zhiwei.brandkbs2.common.RedisKeyPrefix; ...@@ -15,6 +15,7 @@ import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import com.zhiwei.brandkbs2.config.Constant; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.dao.AggreeResultDao; import com.zhiwei.brandkbs2.dao.AggreeResultDao;
import com.zhiwei.brandkbs2.dao.ChannelDao; import com.zhiwei.brandkbs2.dao.ChannelDao;
import com.zhiwei.brandkbs2.dao.HighlightWordDao;
import com.zhiwei.brandkbs2.enmus.ChannelEmotion; import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
import com.zhiwei.brandkbs2.enmus.EmotionEnum; import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.enmus.ImportantChannelEnum; import com.zhiwei.brandkbs2.enmus.ImportantChannelEnum;
...@@ -149,6 +150,9 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -149,6 +150,9 @@ public class MarkDataServiceImpl implements MarkDataService {
@Resource(name = "esSearchServiceImpl") @Resource(name = "esSearchServiceImpl")
EsSearchService esSearchService; EsSearchService esSearchService;
@Resource(name = "highlightWordDao")
HighlightWordDao highlightWordDao;
@Override @Override
public PageVO<MarkFlowEntity> getOriginList(MarkSearchDTO markSearchDTO) { public PageVO<MarkFlowEntity> getOriginList(MarkSearchDTO markSearchDTO) {
try { try {
...@@ -168,7 +172,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -168,7 +172,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 返回分页结果并设置平台count // 返回分页结果并设置平台count
return PageVO.createPageVo(total, markSearchDTO.getPage(), markSearchDTO.getPageSize(), flowEntityList) return PageVO.createPageVo(total, markSearchDTO.getPage(), markSearchDTO.getPageSize(), flowEntityList)
// 各平台计量 // 各平台计量
.setInfo(new JSONObject(ImmutableMap.of("platformCount", hitsAndCounts.getRight()))); .setInfo(new JSONObject(ImmutableMap.of("highlightWord", highlightWordDao.findList(Query.query(Criteria.where("projectId").is(UserThreadLocal.getProjectId()))).stream().map(HighlightWord::getKeyword).collect(Collectors.toList()))));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常"); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
...@@ -247,10 +251,10 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -247,10 +251,10 @@ public class MarkDataServiceImpl implements MarkDataService {
long total = hitsAndCounts.getLeft()[0].getTotalHits().value; long total = hitsAndCounts.getLeft()[0].getTotalHits().value;
// 消息列表 // 消息列表
List<MarkFlowEntity> flowEntityList = getMarkFlowEntity(markSearchDTO, hitsAndCounts.getLeft()[0]); List<MarkFlowEntity> flowEntityList = getMarkFlowEntity(markSearchDTO, hitsAndCounts.getLeft()[0]);
// 返回分页结果并设置平台count // 返回分页结果并返回高亮关键词
return PageVO.createPageVo(total, markSearchDTO.getPage(), markSearchDTO.getPageSize(), flowEntityList) return PageVO.createPageVo(total, markSearchDTO.getPage(), markSearchDTO.getPageSize(), flowEntityList)
// 各平台计量 // 高亮关键词
.setInfo(new JSONObject(ImmutableMap.of("platformCount", hitsAndCounts.getRight()))); .setInfo(new JSONObject(ImmutableMap.of("highlightWord", GlobalPojo.HIGHLIGHT_MAP.get(UserThreadLocal.getProjectId()))));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常"); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
......
...@@ -10,6 +10,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal; ...@@ -10,6 +10,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.GenericAttribute; import com.zhiwei.brandkbs2.common.GenericAttribute;
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.HighlightWordDao;
import com.zhiwei.brandkbs2.enmus.ChannelEmotion; import com.zhiwei.brandkbs2.enmus.ChannelEmotion;
import com.zhiwei.brandkbs2.exception.ExceptionCast; import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.model.CommonCodeEnum; import com.zhiwei.brandkbs2.model.CommonCodeEnum;
...@@ -17,6 +18,7 @@ import com.zhiwei.brandkbs2.pojo.MarkFlowEntity; ...@@ -17,6 +18,7 @@ import com.zhiwei.brandkbs2.pojo.MarkFlowEntity;
import com.zhiwei.brandkbs2.service.MarkFlowService; import com.zhiwei.brandkbs2.service.MarkFlowService;
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.automaticmark.vo.Keyword;
import com.zhiwei.middleware.cleaner.filter.UnifiedFilterClient; import com.zhiwei.middleware.cleaner.filter.UnifiedFilterClient;
import com.zhiwei.middleware.mark.service.MarkerClient; import com.zhiwei.middleware.mark.service.MarkerClient;
import com.zhiwei.middleware.mark.vo.QueryResult; import com.zhiwei.middleware.mark.vo.QueryResult;
...@@ -57,9 +59,11 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -57,9 +59,11 @@ public class MarkFlowServiceImpl implements MarkFlowService {
@Resource(name = "filterClient") @Resource(name = "filterClient")
UnifiedFilterClient filterClient; UnifiedFilterClient filterClient;
@Resource(name = "highlightWordDao")
HighlightWordDao highlightWordDao;
@Override @Override
public JSONObject createMarkFlowInfo(MarkInfoSource markInfoSource) { public JSONObject createMarkFlowInfo(MarkInfoSource markInfoSource) {
JSONObject resultInfo = createInfoWithEmotion(markInfoSource.getJson()); JSONObject resultInfo = createInfoWithEmotion(markInfoSource.getJson());
resultInfo.put("sourceDetails", getSourceDetails(markInfoSource)); resultInfo.put("sourceDetails", getSourceDetails(markInfoSource));
return resultInfo; return resultInfo;
...@@ -70,7 +74,7 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -70,7 +74,7 @@ public class MarkFlowServiceImpl implements MarkFlowService {
JSONObject json = markInfoSource.getJson(); JSONObject json = markInfoSource.getJson();
String linkedGroupId = markInfoSource.getLinkedGroupId(); String linkedGroupId = markInfoSource.getLinkedGroupId();
JSONObject resultInfo = createInfoWithEmotion(json); JSONObject resultInfo = createInfoWithEmotion(json);
resultInfo.put("sourceDetails", getSourceDetails4Origin(json, linkedGroupId)); resultInfo.put("sourceDetails", getSourceDetails4Origin(json, UserThreadLocal.getProjectId(), linkedGroupId));
String zip = Tools.gzip(JSON.toJSONString(json)); String zip = Tools.gzip(JSON.toJSONString(json));
resultInfo.put("zip", zip); resultInfo.put("zip", zip);
return resultInfo; return resultInfo;
...@@ -229,10 +233,11 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -229,10 +233,11 @@ public class MarkFlowServiceImpl implements MarkFlowService {
// 保留两位小数 // 保留两位小数
sourceDetails.put("channelInfluence", new BigDecimal(channelValue).setScale(2, RoundingMode.UP)); sourceDetails.put("channelInfluence", new BigDecimal(channelValue).setScale(2, RoundingMode.UP));
} }
sourceDetails.put("highlightWordMap", getHighlightWordMap(markInfoSource.getProjectId(), tJson));
return sourceDetails; return sourceDetails;
} }
private JSONObject getSourceDetails4Origin(JSONObject tJson, String linkedGroupId) { private JSONObject getSourceDetails4Origin(JSONObject tJson, String projectId, String linkedGroupId) {
JSONObject sourceDetails = new JSONObject(); JSONObject sourceDetails = new JSONObject();
String source = tJson.getString(GenericAttribute.ES_SOURCE); String source = tJson.getString(GenericAttribute.ES_SOURCE);
// 是否原创 // 是否原创
...@@ -251,9 +256,36 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -251,9 +256,36 @@ public class MarkFlowServiceImpl implements MarkFlowService {
if (followersNum > 0) { if (followersNum > 0) {
sourceDetails.put("followersNum", followersNum); sourceDetails.put("followersNum", followersNum);
} }
sourceDetails.put("highlightWordMap", getHighlightWordMap(projectId, tJson));
return sourceDetails; return sourceDetails;
} }
private Map<String, Integer> getHighlightWordMap(String projectId, JSONObject json) {
List<Keyword> hitKeywords = GlobalPojo.PROJECT_GRAPHS.get(projectId).find(json.getString(GenericAttribute.ES_IND_FULL_TEXT));
List<String> preWords = GlobalPojo.HIGHLIGHT_MAP.get(projectId);
if (null != preWords && !hitKeywords.isEmpty()) {
Map<String, Integer> resMap = new HashMap<>();
Map<String, Integer> hitMap = new HashMap<>();
hitKeywords.forEach(keyword -> hitMap.compute(keyword.getKey(), (k, v) -> null == v ? 1 : ++v));
outer:
for (String preWord : preWords) {
Integer count = null;
String[] split = preWord.trim().split(" +");
for (String s : split) {
Integer rate = hitMap.get(s);
// 未命中词语
if (null == rate) {
continue outer;
}
count = count == null ? rate : Math.min(count, rate);
}
resMap.put(preWord, count);
}
return Tools.sortMap(resMap, null);
}
return null;
}
/** /**
* 按c4、origin获取ClientFrom * 按c4、origin获取ClientFrom
* *
......
...@@ -427,6 +427,12 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -427,6 +427,12 @@ public class ProjectServiceImpl implements ProjectService {
} }
} }
@Override
public List<String> getHighlightKeyword(String projectId) {
Project project = projectDao.findOneById(projectId);
return Objects.requireNonNull(project).getHighlightKeyword();
}
/** /**
* 获取舆情对应项目的情感标签 * 获取舆情对应项目的情感标签
* @param brandName * @param brandName
...@@ -448,8 +454,12 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -448,8 +454,12 @@ public class ProjectServiceImpl implements ProjectService {
} else { } else {
lists = new ArrayList<>(); lists = new ArrayList<>();
user.getRoles().forEach(userRole -> { user.getRoles().forEach(userRole -> {
lists.add(projectDao.findOneById(userRole.getProjectId())); Project project = projectDao.findOneById(userRole.getProjectId());
roleExpired.put(userRole.getProjectId(), null == userRole.getExpiredTime() ? null : new Date(userRole.getExpiredTime())); // 项目可能被删除
if (null != project) {
lists.add(projectDao.findOneById(userRole.getProjectId()));
roleExpired.put(userRole.getProjectId(), null == userRole.getExpiredTime() ? null : new Date(userRole.getExpiredTime()));
}
}); });
} }
return lists.stream().filter(Project::isShow).map(project -> { return lists.stream().filter(Project::isShow).map(project -> {
......
package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.dao.BaseMongoDao;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.AbstractBaseWord;
import com.zhiwei.brandkbs2.pojo.HighWord;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.TableWordService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import java.util.List;
import java.util.stream.Collectors;
/**
* @ClassName: TableWordServiceImpl
* @Description TableWordServiceImpl
* @author: sjj
* @date: 2023-05-25 14:35
*/
public class TableWordServiceImpl implements TableWordService{
final BaseMongoDao<? extends AbstractBaseWord> baseMongoDao;
final MongoUtil mongoUtil;
public TableWordServiceImpl(BaseMongoDao<? extends AbstractBaseWord> baseMongoDao, MongoUtil mongoUtil) {
this.baseMongoDao = baseMongoDao;
this.mongoUtil = mongoUtil;
}
@Override
public PageVO<JSONObject> findWord(int page, int size, String keyword) {
String projectId = UserThreadLocal.getProjectId();
Query query = Query.query(Criteria.where("projectId").is(projectId));
long count = baseMongoDao.count(query);
mongoUtil.start(page, size, query);
List<? extends AbstractBaseWord> highWordList = baseMongoDao.findListByKeywordFuzz(query, keyword, new String[]{"keyword"});
List<JSONObject> resList = highWordList.stream().map(highWord -> {
JSONObject result = new JSONObject();
result.put("id", highWord.getId());
result.put("keyword", highWord.getKeyword());
result.put("cTime", highWord.getCTime());
result.put("submitter", highWord.getSubmitter());
return result;
}).collect(Collectors.toList());
MongoUtil.PageHelper<JSONObject> pageHelper = mongoUtil.pageHelper(count, resList);
return PageVO.createPageVo(pageHelper, resList);
}
@Override
public ResponseResult addWordList(List<String> words, String projectId, String submitter) {
List<String> existList = baseMongoDao.findList(Query.query(Criteria.where("projectId").is(projectId))).stream().map(AbstractBaseWord::getKeyword).collect(Collectors.toList());
// 去除重复数据
List<String> newList = words.stream().filter(word -> !existList.contains(word)).collect(Collectors.toList());
// 关键词100上限
if (newList.size() + existList.size() > 100) {
return ResponseResult.failure("关键词添加超过上限值100");
}
baseMongoDao.insertMany(HighWord.createFromList(newList, projectId, submitter));
return ResponseResult.success();
}
@Override
public void deleteWord(String id) {
baseMongoDao.deleteOneById(id);
}
@Override
public List<ExportWordDTO> downloadWord(String projectId) {
return baseMongoDao.findList(Query.query(Criteria.where("projectId").is(projectId))).stream().map(ExportWordDTO::createFromWord).collect(Collectors.toList());
}
}
...@@ -133,13 +133,13 @@ public class UserServiceImpl implements UserService { ...@@ -133,13 +133,13 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public PageVO<JSONObject> findUserList(int page, int size, String keyword, String pid, int role) { public PageVO<JSONObject> findUserList(int page, int size, String keyword, String pid, int role,String sorter) {
Criteria criteria = Criteria.where("roles.projectId").is(pid).and("superAdmin").is(false); Criteria criteria = Criteria.where("roles.projectId").is(pid).and("superAdmin").is(false);
if (-1 != role) { if (-1 != role) {
criteria = criteria.andOperator(Criteria.where("roles.key").is(Tools.concat(pid, role))); criteria = criteria.andOperator(Criteria.where("roles.key").is(Tools.concat(pid, role)));
// criteria = criteria.andOperator(Criteria.where("roles.roleId").is(role)); // criteria = criteria.andOperator(Criteria.where("roles.roleId").is(role));
} }
return findList(page, size, keyword, pid, new Query(criteria)); return findList(page, size, keyword, pid, new Query(criteria),sorter);
} }
@Override @Override
...@@ -149,6 +149,7 @@ public class UserServiceImpl implements UserService { ...@@ -149,6 +149,7 @@ public class UserServiceImpl implements UserService {
ExceptionCast.cast(CommonCodeEnum.UN_AUTHORISE); ExceptionCast.cast(CommonCodeEnum.UN_AUTHORISE);
} }
int roleId = UserThreadLocal.getRoleId(); int roleId = UserThreadLocal.getRoleId();
String nickname = UserThreadLocal.getNickname();
// 只有超管能设置管理员 // 只有超管能设置管理员
if (roleId != RoleEnum.SUPER_ADMIN.getState() && userDTO.getRoleId() <= RoleEnum.ADMIN.getState()) { if (roleId != RoleEnum.SUPER_ADMIN.getState() && userDTO.getRoleId() <= RoleEnum.ADMIN.getState()) {
ExceptionCast.cast(CommonCodeEnum.UN_AUTHORISE); ExceptionCast.cast(CommonCodeEnum.UN_AUTHORISE);
...@@ -166,15 +167,16 @@ public class UserServiceImpl implements UserService { ...@@ -166,15 +167,16 @@ public class UserServiceImpl implements UserService {
User newUser; User newUser;
// 优先使用用户中心信息 // 优先使用用户中心信息
if (null != centerUser) { if (null != centerUser) {
newUser = User.createFromCenterUser(centerUser); newUser = User.createFromCenterUser(centerUser, nickname);
newUser.setNickname(userDTO.getNickname()); newUser.setNickname(userDTO.getNickname());
newUser.setRoles(Collections.singletonList(UserRole.createFromUserDto(userDTO))); newUser.setRoles(Collections.singletonList(UserRole.createFromUserDto(userDTO)));
newUser.setSuperAdmin(false); newUser.setSuperAdmin(false);
userDao.insertOne(newUser);
userCenterService.addProduct(newUser.getId());
} else { } else {
newUser = createNewUser(userDTO); newUser = User.createFromUserDTO(userDTO, nickname);
userDao.insertOne(newUser);
} }
userDao.insertOne(newUser);
userCenterService.addProduct(newUser.getId());
return ResponseResult.success(); return ResponseResult.success();
} }
List<UserRole> roles = user.getRoles(); List<UserRole> roles = user.getRoles();
...@@ -190,6 +192,7 @@ public class UserServiceImpl implements UserService { ...@@ -190,6 +192,7 @@ public class UserServiceImpl implements UserService {
roles.add(UserRole.createFromUserDto(userDTO)); roles.add(UserRole.createFromUserDto(userDTO));
Update update = new Update(); Update update = new Update();
update.set("roles", roles); update.set("roles", roles);
update.set("submitter", nickname);
userDao.updateOneByIdWithField(userDTO.getId(), update); userDao.updateOneByIdWithField(userDTO.getId(), update);
return ResponseResult.success(); return ResponseResult.success();
} }
...@@ -203,6 +206,7 @@ public class UserServiceImpl implements UserService { ...@@ -203,6 +206,7 @@ public class UserServiceImpl implements UserService {
List<UserRole> roles = user.getRoles().stream().filter(userRole -> !userRole.getProjectId().equals(pid)).collect(Collectors.toList()); List<UserRole> roles = user.getRoles().stream().filter(userRole -> !userRole.getProjectId().equals(pid)).collect(Collectors.toList());
Update update = new Update(); Update update = new Update();
update.set("roles", roles); update.set("roles", roles);
update.set("submitter", UserThreadLocal.getNickname());
userDao.updateOneByIdWithField(userId, update); userDao.updateOneByIdWithField(userId, update);
} }
...@@ -230,7 +234,7 @@ public class UserServiceImpl implements UserService { ...@@ -230,7 +234,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public PageVO<JSONObject> findSuperAdminList(int page, int size, String keyword) { public PageVO<JSONObject> findSuperAdminList(int page, int size, String keyword) {
Query query = new Query().addCriteria(Criteria.where("superAdmin").is(true)); Query query = new Query().addCriteria(Criteria.where("superAdmin").is(true));
return findList(page, size, keyword, null, query); return findList(page, size, keyword, null, query, null);
} }
@Override @Override
...@@ -242,26 +246,28 @@ public class UserServiceImpl implements UserService { ...@@ -242,26 +246,28 @@ public class UserServiceImpl implements UserService {
return ResponseResult.failure("用户中心注册账号失败"); return ResponseResult.failure("用户中心注册账号失败");
} }
} }
String nickname = UserThreadLocal.getNickname();
User user = userDao.findOneById(userDTO.getId()); User user = userDao.findOneById(userDTO.getId());
// 老用户 // 老用户
if (null != user) { if (null != user) {
if (!user.isSuperAdmin()) { if (user.isSuperAdmin()) {
Update update = new Update();
update.set("superAdmin", true);
update.set("roles", null);
userDao.updateOneByIdWithField(user.getId(), update);
return ResponseResult.success(); return ResponseResult.success();
} }
Update update = new Update();
update.set("superAdmin", true);
update.set("submitter", nickname);
userDao.updateOneByIdWithField(user.getId(), update);
return ResponseResult.success();
} }
// 新用户 // 新用户
User newUser; User newUser;
// 优先使用用户中心信息 // 优先使用用户中心信息
if (null != centerUser) { if (null != centerUser) {
newUser = User.createFromCenterUser(centerUser); newUser = User.createFromCenterUser(centerUser, nickname);
newUser.setNickname(userDTO.getNickname()); newUser.setNickname(userDTO.getNickname());
newUser.setSuperAdmin(true); newUser.setSuperAdmin(true);
} else { } else {
newUser = createNewUser(userDTO); newUser = User.createFromUserDTO(userDTO, nickname);
} }
userDao.insertOne(newUser); userDao.insertOne(newUser);
userCenterService.addProduct(newUser.getId()); userCenterService.addProduct(newUser.getId());
...@@ -275,6 +281,7 @@ public class UserServiceImpl implements UserService { ...@@ -275,6 +281,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public List<JSONObject> bindUser(String username, String password) { public List<JSONObject> bindUser(String username, String password) {
String nickname = UserThreadLocal.getNickname();
UserOldDaoImpl.UserOld userOld = userOldDao.findOneByUsernameAndPassword(username, password); UserOldDaoImpl.UserOld userOld = userOldDao.findOneByUsernameAndPassword(username, password);
if (null == userOld) { if (null == userOld) {
ExceptionCast.cast(LoginCodeEnum.LOGIN_USERNAME_OR_PASSWORD_ERROR); ExceptionCast.cast(LoginCodeEnum.LOGIN_USERNAME_OR_PASSWORD_ERROR);
...@@ -286,7 +293,7 @@ public class UserServiceImpl implements UserService { ...@@ -286,7 +293,7 @@ public class UserServiceImpl implements UserService {
if (null == user) { if (null == user) {
// 通过用户中心查询 // 通过用户中心查询
CenterUser centerUser = userInfoClient.getUserById(Integer.parseInt(UserThreadLocal.getUserId())); CenterUser centerUser = userInfoClient.getUserById(Integer.parseInt(UserThreadLocal.getUserId()));
user = User.createFromCenterUser(centerUser); user = User.createFromCenterUser(centerUser,nickname);
} }
// 超级管理员 // 超级管理员
if (userOld.isSuperAdmin()) { if (userOld.isSuperAdmin()) {
...@@ -330,7 +337,7 @@ public class UserServiceImpl implements UserService { ...@@ -330,7 +337,7 @@ public class UserServiceImpl implements UserService {
@Override @Override
public List<JSONObject> skipBindUser() { public List<JSONObject> skipBindUser() {
CenterUser centerUser = userInfoClient.getUserById(Integer.parseInt(UserThreadLocal.getUserId())); CenterUser centerUser = userInfoClient.getUserById(Integer.parseInt(UserThreadLocal.getUserId()));
User user = User.createFromCenterUser(centerUser).defaultRoleUser(); User user = User.createFromCenterUser(centerUser, "admin").defaultRoleUser();
userDao.insertOne(user); userDao.insertOne(user);
return projectServiceImpl.getProjectListByUser(user, true); return projectServiceImpl.getProjectListByUser(user, true);
} }
...@@ -414,25 +421,13 @@ public class UserServiceImpl implements UserService { ...@@ -414,25 +421,13 @@ public class UserServiceImpl implements UserService {
return queryUserInfo(UserThreadLocal.getUserId(), UserThreadLocal.getProjectId()).toMap(); return queryUserInfo(UserThreadLocal.getUserId(), UserThreadLocal.getProjectId()).toMap();
} }
private User createNewUser(UserDTO userDTO) { private PageVO<JSONObject> findList(int page, int size, String keyword, String pid, Query query,String sorter) {
User user = new User(); userDao.addKeywordFuzz(query, keyword, "nickname");
user.setId(userDTO.getId()); if (null == sorter) {
user.setNickname(userDTO.getNickname()); userDao.addSort(query, "{\"cTime\":\"descend\"}");
user.setCTime(System.currentTimeMillis());
user.setUsername(userDTO.getUsername());
user.setPhoneNumber(userDTO.getPhoneNumber());
if (RoleEnum.SUPER_ADMIN.getState() == userDTO.getRoleId()) {
user.setSuperAdmin(true);
} else { } else {
user.setRoles(Collections.singletonList(UserRole.createFromUserDto(userDTO))); userDao.addSort(query, sorter);
user.setSuperAdmin(false);
} }
return user;
}
private PageVO<JSONObject> findList(int page, int size, String keyword, String pid, Query query) {
userDao.addKeywordFuzz(query, keyword, "nickname");
userDao.addSort(query, "{\"cTime\":\"descend\"}");
long count = userDao.count(query); long count = userDao.count(query);
mongoUtil.start(page, size, query); mongoUtil.start(page, size, query);
List<User> userList = userDao.findList(query); List<User> userList = userDao.findList(query);
...@@ -443,6 +438,7 @@ public class UserServiceImpl implements UserService { ...@@ -443,6 +438,7 @@ public class UserServiceImpl implements UserService {
result.put("username", user.getUsername()); result.put("username", user.getUsername());
result.put("cTime", user.getCTime()); result.put("cTime", user.getCTime());
result.put("phoneNumber", user.getPhoneNumber()); result.put("phoneNumber", user.getPhoneNumber());
result.put("submitter", user.getSubmitter());
Optional.ofNullable(user.getRoles()).flatMap(roles -> roles.stream().filter(ur -> { Optional.ofNullable(user.getRoles()).flatMap(roles -> roles.stream().filter(ur -> {
if (null == pid) { if (null == pid) {
return true; return true;
......
...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.util; ...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.util;
import com.zhiwei.brandkbs2.common.RedisKeyPrefix; import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -92,15 +93,35 @@ public class RedisUtil { ...@@ -92,15 +93,35 @@ public class RedisUtil {
return stringRedisTemplate.keys(key); return stringRedisTemplate.keys(key);
} }
public void setListLeft(String key, String value) { public List<Object> getMapValueAll(String key) {
if (null == key) { return stringRedisTemplate.opsForHash().values(key);
return; }
public boolean setMapValue(String key, String field, String value) {
HashOperations<String, Object, Object> operations = stringRedisTemplate.opsForHash();
Boolean result = operations.putIfAbsent(key, field, value);
return Boolean.TRUE.equals(result);
}
public boolean resetMapValue(String key, String field, String newField, String value) {
HashOperations<String, Object, Object> operations = stringRedisTemplate.opsForHash();
if (operations.hasKey(key, field)) {
operations.put(key, newField, value);
deleteMapValue(key, field);
return true;
}
return false;
}
public void deleteMapValue(String key, String field) {
HashOperations<String, Object, Object> operations = stringRedisTemplate.opsForHash();
if (operations.hasKey(key, field)) {
operations.delete(key, field);
} }
stringRedisTemplate.opsForList().leftPush(key, value);
} }
public List<String> getListAll(String key) { public long getMapSize(String key){
return stringRedisTemplate.opsForList().range(key, 0, -1); return stringRedisTemplate.opsForHash().size(key);
} }
public void remove(String key) { public void remove(String key) {
......
...@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2} ...@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3} trends.longTimeInListSearchByInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4} trends.findHotSearchESDataInTimeByInner.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url=https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime trends.longTimeInListSearch.url=https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5} trends.getHotSearchFromEsInTimeAndTypeOrWord.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5\}&accurateWord={6}
trends.queryHotSearchTrendInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3 #\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url=https://ef.zhiweidata.com/external/search.do?name={1}&page={2} ef.search.url=https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.searchCriteria.url=https://ef.zhiweidata.com/index/getSearchKey.do ef.searchCriteria.url=https://ef.zhiweidata.com/index/getSearchKey.do
...@@ -99,7 +101,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface ...@@ -99,7 +101,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface
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 #\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/ warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project?projectId={1}&projectName={2} warn.project.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project
warn.ticket.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2} warn.ticket.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2} warn.pushRecipientsList.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3} warn.deletePushRecipients.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
......
...@@ -87,7 +87,10 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2} ...@@ -87,7 +87,10 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3} trends.longTimeInListSearchByInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4} trends.findHotSearchESDataInTimeByInner.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url=https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime trends.longTimeInListSearch.url=https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5} trends.getHotSearchFromEsInTimeAndTypeOrWord.url=http://192.168.0.192:9091/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}&accurateWord={6}
trends.queryHotSearchTrendInner.url=http://192.168.27.203:9094/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3 #\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url=https://ef.zhiweidata.com/external/search.do?name={1}&page={2}&size={3} ef.search.url=https://ef.zhiweidata.com/external/search.do?name={1}&page={2}&size={3}
ef.searchCriteria.url=https://ef.zhiweidata.com/index/getSearchKey.do ef.searchCriteria.url=https://ef.zhiweidata.com/index/getSearchKey.do
...@@ -102,7 +105,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface ...@@ -102,7 +105,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface
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 #\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/ warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/project?projectId={1}&projectName={2} warn.project.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/project
warn.ticket.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2} warn.ticket.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2} warn.pushRecipientsList.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3} warn.deletePushRecipients.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
......
...@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2} ...@@ -84,7 +84,9 @@ crisis.event.url =https://crisis.zhiweidata.com/event/{1}/general?share={2}
trends.longTimeInListSearchByInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3} trends.longTimeInListSearchByInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/longTimeInListSearchByInner?sortType={1}&type={2}&day={3}
trends.findHotSearchESDataInTimeByInner.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4} trends.findHotSearchESDataInTimeByInner.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findHotSearchESDataInTimeByInner?limit={1}&page={2}&type={3}&word={4}
trends.longTimeInListSearch.url=https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime trends.longTimeInListSearch.url=https://trends.zhiweidata.com/hotSearchTrend/search/longTimeInListSearch?type={1}&sortType=realTime
trends.getHotSearchFromEsInTimeAndTypeOrWord.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5} trends.getHotSearchFromEsInTimeAndTypeOrWord.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchFromEsInTimeAndTypeOrWord?limit={1}&page={2}&type={3}&word={4}&sort={5}&accurateWord={6}
trends.queryHotSearchTrendInner.url=https://trends.zhiweidata.com/hotSearchTrend/inner/queryHotSearchTrendInner?name={1}&startTime={2}&type={3}
trends.getHotSearchSnapshot.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/getHotSearchSnapshot?type={1}&time={2}&rank={3}
#\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3 #\u4E8B\u4EF6\u5E93\u5916\u90E8\u63A5\u53E3
ef.search.url=https://ef.zhiweidata.com/external/search.do?name={1}&page={2} ef.search.url=https://ef.zhiweidata.com/external/search.do?name={1}&page={2}
ef.searchCriteria.url=https://ef.zhiweidata.com/index/getSearchKey.do ef.searchCriteria.url=https://ef.zhiweidata.com/index/getSearchKey.do
...@@ -99,7 +101,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface ...@@ -99,7 +101,7 @@ whole.searchCriteria.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface
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 #\u60C5\u62A5\u9884\u8B66\u5916\u90E8\u63A5\u53E3
warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/ warn.pushTask.token=AoJ0ooy3H2BpHmuaviYObTKw/Xfw/oA5aKccNYhYnoJFJQ/BgeW/
warn.project.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project?projectId={1}&projectName={2} warn.project.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/project
warn.ticket.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2} warn.ticket.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/code?pushId={1}&taskType={2}
warn.pushRecipientsList.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2} warn.pushRecipientsList.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/{1}?taskType={2}
warn.deletePushRecipients.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3} warn.deletePushRecipients.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/pushRecipients/?pushId={1}&recipientsId={2}&taskType={3}
......
package com.zhiwei.brandkbs2; package com.zhiwei.brandkbs2;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportWordDTO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO; import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.HighWordService; import com.zhiwei.brandkbs2.service.HighWordService;
import org.junit.Test; import org.junit.Test;
import org.junit.jupiter.api.Tags;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
...@@ -21,7 +21,7 @@ public class HighWordServiceTest { ...@@ -21,7 +21,7 @@ public class HighWordServiceTest {
@Test @Test
public void findHighWordTest(){ public void findHighWordTest(){
PageVO<JSONObject> ls = highWordService.findHighWord(1, 10, "里"); PageVO<JSONObject> ls = highWordService.findWord(1, 10, "里");
for (JSONObject jsonObject : ls.getList()) { for (JSONObject jsonObject : ls.getList()) {
System.out.println(jsonObject); System.out.println(jsonObject);
} }
...@@ -29,8 +29,8 @@ public class HighWordServiceTest { ...@@ -29,8 +29,8 @@ public class HighWordServiceTest {
@Test @Test
public void downloadHighWordTest(){ public void downloadHighWordTest(){
List<ExportHighWordDTO> exportHighWordDTOS = highWordService.downloadHighWord(); List<ExportWordDTO> exportHighWordDTOS = highWordService.downloadWord(Constant.DEFAULT_PROJECT_ID);
for (ExportHighWordDTO exportHighWordDTO : exportHighWordDTOS) { for (ExportWordDTO exportHighWordDTO : exportHighWordDTOS) {
System.out.println(exportHighWordDTO); System.out.println(exportHighWordDTO);
} }
} }
......
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