Commit a17d6c42 by shenjunjie

Merge branch 'feature' into 'dev'

Feature

See merge request !37
parents 15932139 79a94238
...@@ -106,7 +106,11 @@ public class GlobalPojo { ...@@ -106,7 +106,11 @@ public class GlobalPojo {
} }
public static String getMediaType(String projectId, String platform, String source) { public static String getMediaType(String projectId, String platform, String source) {
return MEDIA_TYPE.get(projectId).get(platform + source); Map<String, String> projectMap = MEDIA_TYPE.get(projectId);
if (null == projectMap) {
return null;
}
return projectMap.get(platform + source);
} }
} }
package com.zhiwei.brandkbs2.controller; package com.zhiwei.brandkbs2.controller;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
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.service.CommonService; import com.zhiwei.brandkbs2.service.CommonService;
...@@ -39,10 +40,11 @@ public class CommonController extends BaseController { ...@@ -39,10 +40,11 @@ public class CommonController extends BaseController {
ProjectService projectService; ProjectService projectService;
@ApiOperation("获取情感倾向标签信息") @ApiOperation("获取情感倾向标签信息")
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目ID", required = true, paramType = "path", dataType = "string") @ApiImplicitParam(name = "contendId", value = "品牌id", required = true, paramType = "path", dataType = "string")
@GetMapping("/get/tag/emotion/{linkedGroupId}") @GetMapping("/get/tag/emotion/{contendId}")
public ResponseResult getTagsWithEmotion(@PathVariable(value = "linkedGroupId") String linkedGroupId) { public ResponseResult getTagsWithEmotion(@PathVariable(value = "contendId") String contendId) {
List<String> res = new ArrayList<>(); List<String> res = new ArrayList<>();
String linkedGroupId = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId).getBrandLinkedGroupId();
List<MarkerTag> tags = commonService.getQbjcTags(linkedGroupId, TagField.GROUP_NAME.is("情感倾向")); List<MarkerTag> tags = commonService.getQbjcTags(linkedGroupId, TagField.GROUP_NAME.is("情感倾向"));
if (null != tags) { if (null != tags) {
res = tags.stream().map(MarkerTag::getName).collect(Collectors.toList()); res = tags.stream().map(MarkerTag::getName).collect(Collectors.toList());
......
...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal; ...@@ -6,6 +6,7 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
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.AbstractProject;
import com.zhiwei.brandkbs2.pojo.Behavior; import com.zhiwei.brandkbs2.pojo.Behavior;
import com.zhiwei.brandkbs2.service.BehaviorService; import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
...@@ -63,15 +64,16 @@ public class ArticleController extends BaseController { ...@@ -63,15 +64,16 @@ public class ArticleController extends BaseController {
private static final Behavior.Operation OPERATION = new Behavior.Operation("稿件上传", true); private static final Behavior.Operation OPERATION = new Behavior.Operation("稿件上传", true);
@ApiOperation("稿件上传-稿件模板下载") @ApiOperation("稿件上传-稿件模板下载")
@ApiImplicitParams(@ApiImplicitParam(name = "linkedGroupId", value = "绑定项目组名", required = true, paramType = "query", dataType = "string")) @ApiImplicitParams(@ApiImplicitParam(name = "contendId", value = "品牌id", paramType = "query", dataType = "string"))
@GetMapping("/upload/template/form") @GetMapping("/upload/template/form")
public ResponseResult downloadTemplateForm(@RequestParam String linkedGroupId) { public ResponseResult downloadTemplateForm(@RequestParam(defaultValue = "0") String contendId) {
try { try {
String group = projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandLinkedGroup(); AbstractProject project = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId);
HttpEntity<String> requestEntity = new HttpEntity<>(getHeaders()); HttpEntity<String> requestEntity = new HttpEntity<>(getHeaders());
HttpEntity<Resource> entity = restTemplate.exchange(yuqingInterface + "/upload/template/form?project=" + group, HttpMethod.GET, requestEntity, Resource.class); HttpEntity<Resource> entity = restTemplate.exchange(yuqingInterface + "/upload/template/form?projectId=" + project.getBrandLinkedGroupId(), HttpMethod.GET,
requestEntity, Resource.class);
if (null != entity.getBody()) { if (null != entity.getBody()) {
Tools.download(entity.getBody().getInputStream(), response.getOutputStream(), group + "_稿件模板", response); Tools.download(entity.getBody().getInputStream(), response.getOutputStream(), project.getBrandName() + "_稿件模板", response);
} }
return ResponseResult.success(); return ResponseResult.success();
} catch (Exception e) { } catch (Exception e) {
...@@ -125,16 +127,18 @@ public class ArticleController extends BaseController { ...@@ -125,16 +127,18 @@ public class ArticleController extends BaseController {
@ApiOperation("稿件上传-获取列表") @ApiOperation("稿件上传-获取列表")
@ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "linkedGroupId", value = "绑定项目组ID", required = true, paramType = "query", dataType = "string")}) @ApiImplicitParam(name = "contendId", value = "品牌id", paramType = "query", dataType = "string")})
@GetMapping("/upload/list") @GetMapping("/upload/list")
public ResponseResult getList(@RequestParam(value = "linkedGroupId") String linkedGroupId, @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) { public ResponseResult getList(@RequestParam(value = "contendId", defaultValue = "0") String contendId, @RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
try { try {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("page", page); params.put("page", page);
params.put("pageSize", pageSize); params.put("pageSize", pageSize);
params.put("project", projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandLinkedGroup()); params.put("projectId", projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId).getBrandLinkedGroupId());
HttpEntity<JSONObject> requestEntity = new HttpEntity<>(getHeaders()); HttpEntity<JSONObject> requestEntity = new HttpEntity<>(getHeaders());
HttpEntity<JSONObject> entity = restTemplate.exchange(yuqingInterface + "/upload/list?page={page}&pageSize={pageSize}&project={project}", HttpMethod.GET, requestEntity, JSONObject.class, params); HttpEntity<JSONObject> entity = restTemplate.exchange(yuqingInterface + "/upload/list?page={page}&pageSize={pageSize}&projectId={projectId}",
HttpMethod.GET, requestEntity, JSONObject.class, params);
return ResponseResult.convertFromYuQingInterface(entity.getBody(), pageSize); return ResponseResult.convertFromYuQingInterface(entity.getBody(), pageSize);
} catch (Exception e) { } catch (Exception e) {
log.error("稿件上传-获取列表异常", e); log.error("稿件上传-获取列表异常", e);
...@@ -158,9 +162,9 @@ public class ArticleController extends BaseController { ...@@ -158,9 +162,9 @@ public class ArticleController extends BaseController {
@ApiOperation("稿件上传-上传表格") @ApiOperation("稿件上传-上传表格")
@ApiImplicitParams({@ApiImplicitParam(name = "file", value = "上传表格", required = true, paramType = "form", dataType = "multipartFile"), @ApiImplicitParams({@ApiImplicitParam(name = "file", value = "上传表格", required = true, paramType = "form", dataType = "multipartFile"),
@ApiImplicitParam(name = "linkedGroupId", value = "绑定项目组ID", required = true, paramType = "form", dataType = "string")}) @ApiImplicitParam(name = "contendId", value = "品牌id", paramType = "form", dataType = "string")})
@PostMapping(value = "/upload/form", headers = "content-type=multipart/form-data") @PostMapping(value = "/upload/form", headers = "content-type=multipart/form-data")
public ResponseResult uploadForm(@RequestParam("file") MultipartFile file, @RequestParam String linkedGroupId) { public ResponseResult uploadForm(@RequestParam("file") MultipartFile file, @RequestParam(defaultValue = "0") String contendId) {
try { try {
MultiValueMap<String, Object> requestMap = new LinkedMultiValueMap<>(1); MultiValueMap<String, Object> requestMap = new LinkedMultiValueMap<>(1);
ByteArrayResource byteArrayResource = new ByteArrayResource(file.getBytes()) { ByteArrayResource byteArrayResource = new ByteArrayResource(file.getBytes()) {
...@@ -171,7 +175,7 @@ public class ArticleController extends BaseController { ...@@ -171,7 +175,7 @@ public class ArticleController extends BaseController {
}; };
requestMap.add("file", byteArrayResource); requestMap.add("file", byteArrayResource);
requestMap.add("nickName", UserThreadLocal.getNickname()); requestMap.add("nickName", UserThreadLocal.getNickname());
requestMap.add("project", projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandLinkedGroup()); requestMap.add("projectId", projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId).getBrandLinkedGroupId());
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(requestMap, getHeadersForm()); HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(requestMap, getHeadersForm());
HttpEntity<JSONObject> entity = restTemplate.exchange(yuqingInterface + "/upload/form", HttpMethod.POST, requestEntity, JSONObject.class); HttpEntity<JSONObject> entity = restTemplate.exchange(yuqingInterface + "/upload/form", HttpMethod.POST, requestEntity, JSONObject.class);
behaviorService.pushBehavior(OPERATION, "上传表格", request); behaviorService.pushBehavior(OPERATION, "上传表格", request);
......
...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.controller.admin; ...@@ -2,6 +2,7 @@ package com.zhiwei.brandkbs2.controller.admin;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
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.ExportAdminChannelArticleDTO; import com.zhiwei.brandkbs2.easyexcel.dto.ExportAdminChannelArticleDTO;
...@@ -56,7 +57,7 @@ public class ChannelController extends BaseController { ...@@ -56,7 +57,7 @@ public class ChannelController extends BaseController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目组ID", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(name = "contendId", value = "品牌id", required = false, paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "emotion", value = "倾向筛选", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "emotion", value = "倾向筛选", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "platform", value = "平台筛选", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "platform", value = "平台筛选", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "show", value = "是否展示", paramType = "query", dataType = "Boolean"), @ApiImplicitParam(name = "show", value = "是否展示", paramType = "query", dataType = "Boolean"),
...@@ -66,13 +67,13 @@ public class ChannelController extends BaseController { ...@@ -66,13 +67,13 @@ public class ChannelController extends BaseController {
@GetMapping("/list") @GetMapping("/list")
public ResponseResult findChannelList(@RequestParam(value = "page", defaultValue = "1") int page, public ResponseResult findChannelList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "10") int size, @RequestParam(value = "pageSize", defaultValue = "10") int size,
@RequestParam(value = "linkedGroupId") String linkedGroupId, @RequestParam(value = "contendId",defaultValue = "0") String contendId,
@RequestParam(value = "emotion", defaultValue = "") String emotion, @RequestParam(value = "emotion", defaultValue = "") String emotion,
@RequestParam(value = "platform", defaultValue = "") String platform, @RequestParam(value = "platform", defaultValue = "") String platform,
@RequestParam(value = "show", required = false) Boolean show, @RequestParam(value = "show", required = false) Boolean show,
@RequestParam(value = "keyword", defaultValue = "") String keyword, @RequestParam(value = "keyword", defaultValue = "") String keyword,
@RequestParam(value = "sorter", defaultValue = "{\"lastTime\":\"descend\"}") String sorter) { @RequestParam(value = "sorter", defaultValue = "{\"lastTime\":\"descend\"}") String sorter) {
PageVO<JSONObject> channelList = channelService.findChannelList(page, size, linkedGroupId, emotion, platform, show, keyword, sorter); PageVO<JSONObject> channelList = channelService.findChannelList(page, size, contendId, emotion, platform, show, keyword, sorter);
return ResponseResult.success(channelList); return ResponseResult.success(channelList);
} }
...@@ -152,20 +153,20 @@ public class ChannelController extends BaseController { ...@@ -152,20 +153,20 @@ public class ChannelController extends BaseController {
@ApiOperation("下载渠道列表") @ApiOperation("下载渠道列表")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目组ID", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(name = "contendId", value = "品牌id", required = true, paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "emotion", value = "倾向筛选", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "emotion", value = "倾向筛选", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "platform", value = "平台筛选", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "platform", value = "平台筛选", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "show", value = "是否展示", paramType = "query", dataType = "boolean"), @ApiImplicitParam(name = "show", value = "是否展示", paramType = "query", dataType = "boolean"),
@ApiImplicitParam(name = "keyword", value = "关键字搜索", paramType = "query", dataType = "string") @ApiImplicitParam(name = "keyword", value = "关键字搜索", paramType = "query", dataType = "string")
}) })
@GetMapping("/list/download") @GetMapping("/list/download")
public ResponseResult downloadChannelList(@RequestParam(value = "linkedGroupId") String linkedGroupId, public ResponseResult downloadChannelList(@RequestParam(value = "contendId",defaultValue = "0") String contendId,
@RequestParam(value = "emotion", defaultValue = "") String emotion, @RequestParam(value = "emotion", defaultValue = "") String emotion,
@RequestParam(value = "platform", defaultValue = "") String platform, @RequestParam(value = "platform", defaultValue = "") String platform,
@RequestParam(value = "show", required = false) Boolean show, @RequestParam(value = "show", required = false) Boolean show,
@RequestParam(value = "keyword", defaultValue = "") String keyword) { @RequestParam(value = "keyword", defaultValue = "") String keyword) {
List<ExportChannelDTO> downloadChannelList = channelService.findDownloadChannelList(linkedGroupId, emotion, platform, show, keyword); List<ExportChannelDTO> downloadChannelList = channelService.findDownloadChannelList(contendId, emotion, platform, show, keyword);
String brandName = projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandName(); String brandName = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId).getBrandName();
EasyExcelUtil.download(brandName + "_渠道列表数据", brandName, ExportChannelDTO.class, downloadChannelList, response); EasyExcelUtil.download(brandName + "_渠道列表数据", brandName, ExportChannelDTO.class, downloadChannelList, response);
return ResponseResult.success(); return ResponseResult.success();
} }
......
...@@ -61,10 +61,10 @@ public class EventController extends BaseController { ...@@ -61,10 +61,10 @@ public class EventController extends BaseController {
private String brandkbsFilePath; private String brandkbsFilePath;
@ApiOperation("舆情事件tag筛选") @ApiOperation("舆情事件tag筛选")
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目组id", paramType = "query", dataType = "string") @ApiImplicitParam(name = "contendId", value = "品牌id", paramType = "query", dataType = "string")
@GetMapping("/yq/tag") @GetMapping("/yq/tag")
public ResponseResult searchCriteria(@RequestParam(value = "linkedGroupId") String linkedGroupId) { public ResponseResult searchCriteria(@RequestParam(value = "contendId", defaultValue = "0") String contendId) {
return ResponseResult.success(eventService.findEventTagListAll(linkedGroupId)); return ResponseResult.success(eventService.findEventTagListAll(contendId));
} }
@ApiOperation("分页查询舆情事件列表") @ApiOperation("分页查询舆情事件列表")
...@@ -78,16 +78,16 @@ public class EventController extends BaseController { ...@@ -78,16 +78,16 @@ public class EventController extends BaseController {
@ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "size", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "size", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "keyword", value = "关键字搜索", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "keyword", value = "关键字搜索", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目组id", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "contendId", value = "关联项目组id", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "sorter", defaultValue = "{\"startTime\":\"descend\"}", value = "排序字段", paramType = "query", dataType = "string") @ApiImplicitParam(name = "sorter", defaultValue = "{\"startTime\":\"descend\"}", value = "排序字段", paramType = "query", dataType = "string")
}) })
@GetMapping("/list") @GetMapping("/list")
public ResponseResult findEventList(@RequestParam(value = "page", defaultValue = "1") int page, public ResponseResult findEventList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "size", defaultValue = "10") int size, @RequestParam(value = "size", defaultValue = "10") int size,
@RequestParam(value = "linkedGroupId") String linkedGroupId, @RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "keyword", defaultValue = "") String keyword, @RequestParam(value = "keyword", defaultValue = "") String keyword,
@RequestParam(value = "sorter", defaultValue = "{\"startTime\":\"descend\"}") String sorter) { @RequestParam(value = "sorter", defaultValue = "{\"startTime\":\"descend\"}") String sorter) {
return ResponseResult.success(eventService.findEventList(page, size, linkedGroupId, keyword, sorter)); return ResponseResult.success(eventService.findEventList(page, size, contendId, keyword, sorter));
} }
@ApiOperation("获取单个事件信息") @ApiOperation("获取单个事件信息")
...@@ -199,10 +199,10 @@ public class EventController extends BaseController { ...@@ -199,10 +199,10 @@ public class EventController extends BaseController {
} }
@ApiOperation("导出事件列表") @ApiOperation("导出事件列表")
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目组id", required = true, paramType = "query", dataType = "string") @ApiImplicitParam(name = "contendId", value = "品牌id", required = true, paramType = "query", dataType = "string")
@GetMapping("/download") @GetMapping("/download")
public ResponseResult downloadEvents(@RequestParam("linkedGroupId") String linkedGroupId) { public ResponseResult downloadEvents(@RequestParam(value = "contendId", defaultValue = "0") String contendId) {
Pair<String, List<ExportEventDTO>> result = eventService.downloadEvents(linkedGroupId); Pair<String, List<ExportEventDTO>> result = eventService.downloadEvents(contendId);
String fileName = result.getLeft(); String fileName = result.getLeft();
EasyExcelUtil.download(fileName + "_事件列表数据", fileName, ExportEventDTO.class, result.getRight(), response); EasyExcelUtil.download(fileName + "_事件列表数据", fileName, ExportEventDTO.class, result.getRight(), response);
return ResponseResult.success(); return ResponseResult.success();
...@@ -242,7 +242,7 @@ public class EventController extends BaseController { ...@@ -242,7 +242,7 @@ public class EventController extends BaseController {
value = "文件路径", required = true, paramType = "form", dataType = "string")}) value = "文件路径", required = true, paramType = "form", dataType = "string")})
@PostMapping(value = "/upload/file", headers = "content-type=multipart/form-data") @PostMapping(value = "/upload/file", headers = "content-type=multipart/form-data")
@Auth(role = RoleEnum.SUPER_ADMIN) @Auth(role = RoleEnum.SUPER_ADMIN)
public ResponseResult addEventsByFile(@RequestParam(value = "contendId",defaultValue = "0") String contendId, @RequestParam("fileUrl") String fileUrl) { public ResponseResult addEventsByFile(@RequestParam(value = "contendId", defaultValue = "0") String contendId, @RequestParam("fileUrl") String fileUrl) {
eventService.addFileEvents(contendId, fileUrl); eventService.addFileEvents(contendId, fileUrl);
behaviorService.pushBehavior(OPERATION, "文件上传事件", request); behaviorService.pushBehavior(OPERATION, "文件上传事件", request);
return ResponseResult.success(); return ResponseResult.success();
...@@ -252,23 +252,29 @@ public class EventController extends BaseController { ...@@ -252,23 +252,29 @@ public class EventController extends BaseController {
@ApiImplicitParams({@ApiImplicitParam(name = "file", value = "上传表格", paramType = "form", dataType = "multipartFile"), @ApiImplicitParam(name = @ApiImplicitParams({@ApiImplicitParam(name = "file", value = "上传表格", paramType = "form", dataType = "multipartFile"), @ApiImplicitParam(name =
"contendId", value = "竞品id", paramType = "form", dataType = "string")}) "contendId", value = "竞品id", paramType = "form", dataType = "string")})
@PostMapping(value = "/data/upload", headers = "content-type=multipart/form-data") @PostMapping(value = "/data/upload", headers = "content-type=multipart/form-data")
public ResponseResult uploadEventDatas(@RequestParam(value = "contendId",defaultValue = "0") String contendId, @RequestParam("file") MultipartFile file) { public ResponseResult uploadEventDatas(@RequestParam(value = "contendId", defaultValue = "0") String contendId, @RequestParam("file") MultipartFile file) {
eventService.uploadEventDatas(contendId, file); eventService.uploadEventDatas(contendId, file);
behaviorService.pushBehavior(OPERATION, "事件数据上传", request); behaviorService.pushBehavior(OPERATION, "事件数据上传", request);
return ResponseResult.success(); return ResponseResult.success();
} }
@ApiOperation("查询所有事件标签") @ApiOperation("查询所有事件标签")
@ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", required = false, defaultValue = "1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "size", value = "每页记录数", required = false, defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "linkedGroupId", value = "关联性项目组id", required = true, paramType = "query", dataType = "string"), @ApiImplicitParam(name = "tagGroupName", value = "标签组名", required = true, 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 = "contendId", value = "品牌id", required = true, paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "tagGroupName", value = "标签组名", required = true, paramType = "query", dataType = "string")})
@GetMapping("/tag/list") @GetMapping("/tag/list")
public ResponseResult findEventTagList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam(value = "linkedGroupId") String linkedGroupId, @RequestParam(value = "tagGroupName") String tagGroupName) { public ResponseResult findEventTagList(@RequestParam(value = "page", defaultValue = "1") int page,
return ResponseResult.success(eventService.findEventTagList(page, size, linkedGroupId, tagGroupName)); @RequestParam(value = "size", defaultValue = "10") int size,
@RequestParam(value = "contendId",defaultValue = "0") String contendId,
@RequestParam(value = "tagGroupName") String tagGroupName) {
return ResponseResult.success(eventService.findEventTagList(page, size, contendId, tagGroupName));
} }
@ApiOperation("查询所有事件标签组名") @ApiOperation("查询所有事件标签组名")
@GetMapping("/tag/groupName") @GetMapping("/tag/groupName")
public ResponseResult findEventTagGroupName(@RequestParam(value = "linkedGroupId") String linkedGroupId) { public ResponseResult findEventTagGroupName(@RequestParam(value = "contendId") String contendId) {
return ResponseResult.success(eventService.findEventTagGroupName(linkedGroupId)); return ResponseResult.success(eventService.findEventTagGroupName(contendId));
} }
} }
package com.zhiwei.brandkbs2.enmus.response;
import com.zhiwei.brandkbs2.model.ResultCode;
/**
* @author lxj
* @version 1.0
* @description 登录错误状态码及信息
* @date 2019/8/12 17:46
*/
public enum LoginCodeEnum implements ResultCode {
/**
* 项目名输入错误
*/
LOGIN_PROJECT_NAME_ERROR(false, 1001, "项目名输入错误!", 200),
/**
* 账号或密码输入错误
*/
LOGIN_USERNAME_OR_PASSWORD_ERROR(false, 1002, "账号或密码输入错误!", 200),
/**
* 客户账号无法登陆后台管理系统
*/
LOGIN_NOT_ADMIN_ERROR(false, 1003, "客户账号无法登陆后台管理系统!", 200),
/**
* 获取授权微信认证失败
*/
LOGIN_WX_AUTH_ERROR(false, 1004, "获取授权微信认证失败!", 200),
/**
* 该微信已被其他账号绑定
*/
LOGIN_WX_WITH_USER_ERROR(false, 1005, "该微信已被其他账号绑定,登陆失败!", 200),
/**
* 该账号已被其他微信绑定
*/
LOGIN_USER_WITH_WX_ERROR(false, 1006, "该账号已被其他微信绑定,登陆失败!", 200),
/**
* 该微信未绑定账号
*/
LOGIN_WX_WITH_OUT_USER_ERROR(false, 1007, "该微信未绑定账号", 200),
/**
* 该账号已过期
*/
LOGIN_EXPIRED_ERROR(false, 1008, "该账号已过期", 200),
/**
* 项目已停用
*/
LOGIN_PROJECT_STOPPED_ERROR(false, 1009, "当前项目已停用,请联系管理员恢复", 200);
/**
* 操作是否成功
*/
final boolean success;
/**
* 操作代码
*/
final int code;
/**
* 提示信息
*/
final String message;
/**
* 聚合状态码
*/
final int aggCode;
LoginCodeEnum(boolean success, int code, String message, int aggCode) {
this.success = success;
this.code = code;
this.message = message;
this.aggCode = aggCode;
}
@Override
public boolean success() {
return success;
}
@Override
public int code() {
return code;
}
@Override
public String message() {
return message;
}
@Override
public int aggCode() {
return aggCode;
}
}
...@@ -15,15 +15,19 @@ public class CustomException extends RuntimeException { ...@@ -15,15 +15,19 @@ public class CustomException extends RuntimeException {
*/ */
private final ResultCode resultCode; private final ResultCode resultCode;
private final String errorMessage;
private final Exception exception; private final Exception exception;
public CustomException(ResultCode resultCode) { public CustomException(ResultCode resultCode) {
this.resultCode = resultCode; this.resultCode = resultCode;
this.errorMessage = null;
this.exception = null; this.exception = null;
} }
public CustomException(ResultCode resultCode, Exception e) { public CustomException(ResultCode resultCode, String errorMessage, Exception e) {
this.resultCode = resultCode; this.resultCode = resultCode;
this.errorMessage = errorMessage;
this.exception = e; this.exception = e;
} }
......
...@@ -15,7 +15,11 @@ public class ExceptionCast { ...@@ -15,7 +15,11 @@ public class ExceptionCast {
throw new CustomException(resultCode); throw new CustomException(resultCode);
} }
public static void cast(ResultCode resultCode, Exception e) { public static void cast(ResultCode resultCode, String errorMessage) {
throw new CustomException(resultCode, e); throw new CustomException(resultCode, errorMessage, null);
}
public static void cast(ResultCode resultCode, String errorMessage, Exception e) {
throw new CustomException(resultCode, errorMessage, e);
} }
} }
...@@ -47,7 +47,7 @@ public enum CommonCodeEnum implements ResultCode { ...@@ -47,7 +47,7 @@ public enum CommonCodeEnum implements ResultCode {
/** /**
* 提示信息 * 提示信息
*/ */
String message; final String message;
/** /**
* 聚合状态码 * 聚合状态码
*/ */
...@@ -60,11 +60,6 @@ public enum CommonCodeEnum implements ResultCode { ...@@ -60,11 +60,6 @@ public enum CommonCodeEnum implements ResultCode {
this.aggCode = aggCode; this.aggCode = aggCode;
} }
public CommonCodeEnum message(String message){
this.message = message;
return this;
}
@Override @Override
public boolean success() { public boolean success() {
return success; return success;
......
package com.zhiwei.brandkbs2.model;
/**
* @author lxj
* @version 1.0
* @description 事件错误信息及状态码
* @date 2019/8/31 1:33
*/
public enum EventCodeEnum implements ResultCode {
/**
* 该事件已结束
*/
EVENT_STATUS_ERROR(false, 1401, "该事件已结束", 200),
/**
* 该事件不存在
*/
EVENT_NOT_EXISTS_ERROR(false, 1402, "该事件不存在", 200),
/**
* 事件首发平台或渠道填写错误
*/
EVENT_NOT_EXISTS_FIRST_CHANNEL_ERROR(false, 1403, "事件首发平台、来源、渠道填写错误", 200),
/**
* 当前品牌已有进行任务
*/
HAS_TASK_ERROR(false, 1401, "当前项目品牌已有进行任务", 200);
/**
* 操作是否成功
*/
final boolean success;
/**
* 操作代码
*/
final int code;
/**
* 提示信息
*/
final String message;
/**
* 聚合状态码
*/
final int aggCode;
EventCodeEnum(boolean success, int code, String message, int aggCode) {
this.success = success;
this.code = code;
this.message = message;
this.aggCode = aggCode;
}
@Override
public boolean success() {
return success;
}
@Override
public int code() {
return code;
}
@Override
public String message() {
return message;
}
@Override
public int aggCode() {
return aggCode;
}
}
...@@ -25,7 +25,7 @@ public class ResponseResult { ...@@ -25,7 +25,7 @@ public class ResponseResult {
* 操作是否成功 * 操作是否成功
*/ */
@ApiModelProperty("操作是否成功") @ApiModelProperty("操作是否成功")
private boolean success; private boolean status;
/** /**
* 操作状态码 * 操作状态码
...@@ -56,7 +56,7 @@ public class ResponseResult { ...@@ -56,7 +56,7 @@ public class ResponseResult {
} }
public ResponseResult(ResultCode resultCode, Object data) { public ResponseResult(ResultCode resultCode, Object data) {
this.success = resultCode.success(); this.status = resultCode.success();
this.code = resultCode.code(); this.code = resultCode.code();
this.message = resultCode.message(); this.message = resultCode.message();
this.aggCode = resultCode.aggCode(); this.aggCode = resultCode.aggCode();
......
...@@ -77,12 +77,12 @@ public class EventDisseminationTrend extends AbstractBaseMongo { ...@@ -77,12 +77,12 @@ public class EventDisseminationTrend extends AbstractBaseMongo {
Map<String, Object> element = new HashMap<>(); Map<String, Object> element = new HashMap<>();
element.put("time", start); element.put("time", start);
element.put("sum", count); element.put("sum", count);
negativeSpread.add(element); totalSpread.add(element);
// 负面统计 // 负面统计
Map<String, Object> negElement = new HashMap<>(); Map<String, Object> negElement = new HashMap<>();
negElement.put("time", start); negElement.put("time", start);
negElement.put("sum", negCount); negElement.put("sum", negCount);
totalSpread.add(negElement); negativeSpread.add(negElement);
// 推进节点并重置计量值 // 推进节点并重置计量值
count = 0; count = 0;
negCount = 0; negCount = 0;
......
...@@ -21,9 +21,6 @@ public class YqEventSearchVO { ...@@ -21,9 +21,6 @@ public class YqEventSearchVO {
@ApiModelProperty("每页记录数") @ApiModelProperty("每页记录数")
private Integer pageSize; private Integer pageSize;
@ApiModelProperty("关联项目组id")
private String linkedGroupId;
@ApiModelProperty("关联品牌id") @ApiModelProperty("关联品牌id")
private String contendId = "0"; private String contendId = "0";
......
...@@ -27,7 +27,7 @@ public interface ChannelService { ...@@ -27,7 +27,7 @@ public interface ChannelService {
* *
* @param page 页码 * @param page 页码
* @param size 大小 * @param size 大小
* @param linkedGroupId 关联项目ID * @param contendId 品牌id
* @param emotion 0:全部 1:友好 2:中性 3:不友好 * @param emotion 0:全部 1:友好 2:中性 3:不友好
* @param platform 平台 * @param platform 平台
* @param show 展示 * @param show 展示
...@@ -35,7 +35,7 @@ public interface ChannelService { ...@@ -35,7 +35,7 @@ public interface ChannelService {
* @param sorter 排序字段 * @param sorter 排序字段
* @return 渠道列表 * @return 渠道列表
*/ */
PageVO<JSONObject> findChannelList(int page, int size, String linkedGroupId, String emotion, String platform, Boolean show, String keyword, String sorter); PageVO<JSONObject> findChannelList(int page, int size, String contendId, String emotion, String platform, Boolean show, String keyword, String sorter);
/** /**
* 根据搜索条件查询稿件列表 * 根据搜索条件查询稿件列表
...@@ -90,7 +90,7 @@ public interface ChannelService { ...@@ -90,7 +90,7 @@ public interface ChannelService {
/** /**
* 获取下载渠道列表 * 获取下载渠道列表
*/ */
List<ExportChannelDTO> findDownloadChannelList(String linkedGroupId, String emotion, String platform, Boolean show, String keyword); List<ExportChannelDTO> findDownloadChannelList(String contendId, String emotion, String platform, Boolean show, String keyword);
/** /**
* 获取下载稿件列表 * 获取下载稿件列表
......
...@@ -5,7 +5,6 @@ import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDTO; ...@@ -5,7 +5,6 @@ import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDataDTO; import com.zhiwei.brandkbs2.easyexcel.dto.ExportEventDataDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO; import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventData;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend; import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO; import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO; import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
...@@ -55,12 +54,12 @@ public interface EventService { ...@@ -55,12 +54,12 @@ public interface EventService {
* *
* @param page 页码 * @param page 页码
* @param size 大小 * @param size 大小
* @param linkedGroupId 关联项目组id * @param contendId 品牌id
* @param keyword 搜索关键字 * @param keyword 搜索关键字
* @param sorter 排序字段 * @param sorter 排序字段
* @return 事件列表信息 * @return 事件列表信息
*/ */
PageVO<JSONObject> findEventList(int page, int size, String linkedGroupId, String keyword, String sorter); PageVO<JSONObject> findEventList(int page, int size, String contendId, String keyword, String sorter);
/** /**
* 分页查询舆情监测系统的事件列表 * 分页查询舆情监测系统的事件列表
...@@ -161,10 +160,10 @@ public interface EventService { ...@@ -161,10 +160,10 @@ public interface EventService {
/** /**
* 获取事件列表下载信息 * 获取事件列表下载信息
* *
* @param linkedGroupId 关联项目组id * @param contendId 品牌id
* @return 事件列表下载信息 * @return 事件列表下载信息
*/ */
Pair<String, List<ExportEventDTO>> downloadEvents(String linkedGroupId); Pair<String, List<ExportEventDTO>> downloadEvents(String contendId);
/** /**
* 添加文件上传事件信息 * 添加文件上传事件信息
...@@ -212,10 +211,10 @@ public interface EventService { ...@@ -212,10 +211,10 @@ public interface EventService {
/** /**
* 获取舆情事件标签组名 * 获取舆情事件标签组名
* *
* @param linkedGroupId 关联项目组ID * @param contendId 品牌id
* @return 事件标签组名列表 * @return 事件标签组名列表
*/ */
List<String> findEventTagGroupName(String linkedGroupId); List<String> findEventTagGroupName(String contendId);
/** /**
* 获取品牌事件搜索条件 * 获取品牌事件搜索条件
......
...@@ -110,8 +110,8 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -110,8 +110,8 @@ public class ChannelServiceImpl implements ChannelService {
ThreadPoolTaskExecutor esSearchExecutor; ThreadPoolTaskExecutor esSearchExecutor;
@Override @Override
public PageVO<JSONObject> findChannelList(int page, int size, String linkedGroupId, String emotion, String platform, Boolean show, String keyword, String sorter) { public PageVO<JSONObject> findChannelList(int page, int size, String contendId, String emotion, String platform, Boolean show, String keyword, String sorter) {
Query query = channelListQuery(linkedGroupId, show, emotion, platform, keyword, sorter); Query query = channelListQuery(contendId, show, emotion, platform, keyword, sorter);
long total = channelDao.count(query); long total = channelDao.count(query);
// 开启分页 // 开启分页
mongoUtil.start(page, size, query); mongoUtil.start(page, size, query);
...@@ -159,7 +159,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -159,7 +159,7 @@ public class ChannelServiceImpl implements ChannelService {
}); });
return PageVO.createPageVoNew(articleIds.size(), page, size, resList); return PageVO.createPageVoNew(articleIds.size(), page, size, resList);
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "查询异常", e);
} }
return null; return null;
} }
...@@ -193,7 +193,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -193,7 +193,7 @@ public class ChannelServiceImpl implements ChannelService {
public void switchChannelShow(String channelId) { public void switchChannelShow(String channelId) {
Channel channel = channelDao.findOneById(channelId); Channel channel = channelDao.findOneById(channelId);
if (Objects.isNull(channel)) { if (Objects.isNull(channel)) {
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("渠道不存在")); ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM, "渠道不存在");
} }
Update update = new Update(); Update update = new Update();
update.set("show", !channel.isShow()); update.set("show", !channel.isShow());
...@@ -212,7 +212,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -212,7 +212,7 @@ public class ChannelServiceImpl implements ChannelService {
Channel channel = channelDao.findOneById(channelId); Channel channel = channelDao.findOneById(channelId);
if (Objects.isNull(channel)) { if (Objects.isNull(channel)) {
//抛出未查询到相关ID的渠道信息异常 //抛出未查询到相关ID的渠道信息异常
ExceptionCast.cast(CommonCodeEnum.FAIL.message("渠道不存在")); ExceptionCast.cast(CommonCodeEnum.FAIL, "渠道不存在");
} }
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("id", channel.getId()); jsonObject.put("id", channel.getId());
...@@ -234,8 +234,8 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -234,8 +234,8 @@ public class ChannelServiceImpl implements ChannelService {
} }
@Override @Override
public List<ExportChannelDTO> findDownloadChannelList(String linkedGroupId, String emotion, String platform, Boolean show, String keyword) { public List<ExportChannelDTO> findDownloadChannelList(String contendId, String emotion, String platform, Boolean show, String keyword) {
Query query = channelListQuery(linkedGroupId, show, emotion, platform, keyword, null); Query query = channelListQuery(contendId, show, emotion, platform, keyword, null);
List<Channel> list = channelDao.findList(query); List<Channel> list = channelDao.findList(query);
return list.stream().map(ExportChannelDTO::createFromChannel).collect(Collectors.toList()); return list.stream().map(ExportChannelDTO::createFromChannel).collect(Collectors.toList());
} }
...@@ -255,7 +255,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -255,7 +255,7 @@ public class ChannelServiceImpl implements ChannelService {
resList.add(dto); resList.add(dto);
}); });
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "查询异常");
} }
return resList; return resList;
} }
...@@ -341,7 +341,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -341,7 +341,7 @@ public class ChannelServiceImpl implements ChannelService {
} }
}); });
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return resList; return resList;
} }
...@@ -432,7 +432,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -432,7 +432,7 @@ public class ChannelServiceImpl implements ChannelService {
} }
}); });
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return resList; return resList;
} }
...@@ -441,7 +441,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -441,7 +441,7 @@ public class ChannelServiceImpl implements ChannelService {
public boolean collectChannel(String channelId) { public boolean collectChannel(String channelId) {
Channel channel = channelDao.findOneById(channelId); Channel channel = channelDao.findOneById(channelId);
if (null == channel) { if (null == channel) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("该渠道不存在!")); ExceptionCast.cast(CommonCodeEnum.FAIL, "该渠道不存在!");
} }
Update update = Update.update("isCollect", true).set("collectTime", System.currentTimeMillis()); Update update = Update.update("isCollect", true).set("collectTime", System.currentTimeMillis());
channelDao.updateOneByIdWithField(channelId, update); channelDao.updateOneByIdWithField(channelId, update);
...@@ -452,7 +452,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -452,7 +452,7 @@ public class ChannelServiceImpl implements ChannelService {
public boolean removeCollectChannel(String channelId) { public boolean removeCollectChannel(String channelId) {
Channel channel = channelDao.findOneById(channelId); Channel channel = channelDao.findOneById(channelId);
if (null == channel) { if (null == channel) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("该渠道不存在!")); ExceptionCast.cast(CommonCodeEnum.FAIL, "该渠道不存在!");
} }
Update update = Update.update("isCollect", false); Update update = Update.update("isCollect", false);
channelDao.updateOneByIdWithField(channelId, update); channelDao.updateOneByIdWithField(channelId, update);
...@@ -477,7 +477,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -477,7 +477,7 @@ public class ChannelServiceImpl implements ChannelService {
public JSONObject getBaseInfoByChannelId(String channelId) { public JSONObject getBaseInfoByChannelId(String channelId) {
Channel channel = channelDao.findOneById(channelId); Channel channel = channelDao.findOneById(channelId);
if (null == channel) { if (null == channel) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("该渠道不存在!")); ExceptionCast.cast(CommonCodeEnum.FAIL, "该渠道不存在!");
} }
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("id", channel.getId()); jsonObject.put("id", channel.getId());
...@@ -639,7 +639,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -639,7 +639,7 @@ public class ChannelServiceImpl implements ChannelService {
return channelRecord.getRecord().getArticles().stream().sorted(Comparator.comparingLong(ChannelIndex.Article::getTime)).limit(1).collect(Collectors.toList()).get(0).getTime(); return channelRecord.getRecord().getArticles().stream().sorted(Comparator.comparingLong(ChannelIndex.Article::getTime)).limit(1).collect(Collectors.toList()).get(0).getTime();
} }
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return null; return null;
} }
...@@ -1234,7 +1234,7 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -1234,7 +1234,7 @@ public class ChannelServiceImpl implements ChannelService {
// 根据品牌分类 // 根据品牌分类
return convert2ContendMap(searchResponses, startTime, endTime, contendIds); return convert2ContendMap(searchResponses, startTime, endTime, contendIds);
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return Collections.emptyMap(); return Collections.emptyMap();
} }
...@@ -1419,9 +1419,9 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -1419,9 +1419,9 @@ public class ChannelServiceImpl implements ChannelService {
return helper; return helper;
} }
private Query channelListQuery(String linkedGroupId, Boolean show, String emotion, String platform, String keyword, String sorter) { private Query channelListQuery(String contendId, Boolean show, String emotion, String platform, String keyword, String sorter) {
Query query = new Query(); Query query = new Query();
query.addCriteria(Criteria.where("linkedGroupId").is(linkedGroupId)); query.addCriteria(Criteria.where("contendId").is(contendId));
if (null != show) { if (null != show) {
query.addCriteria(Criteria.where("show").is(show)); query.addCriteria(Criteria.where("show").is(show));
} }
...@@ -1433,8 +1433,8 @@ public class ChannelServiceImpl implements ChannelService { ...@@ -1433,8 +1433,8 @@ public class ChannelServiceImpl implements ChannelService {
} }
// 添加模糊匹配 // 添加模糊匹配
channelDao.addKeywordFuzz(query, keyword, "source"); channelDao.addKeywordFuzz(query, keyword, "source");
// 添加排序 // 添加排序 TODO 2
channelDao.addSort(query, sorter); // channelDao.addSort(query, sorter);
return query; return query;
} }
......
package com.zhiwei.brandkbs2.service.impl; package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.config.Constant; import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.enmus.EmotionEnum; import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.service.CommonService; import com.zhiwei.brandkbs2.service.CommonService;
...@@ -13,7 +14,6 @@ import com.zhiwei.middleware.mark.vo.TagSearch; ...@@ -13,7 +14,6 @@ import com.zhiwei.middleware.mark.vo.TagSearch;
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;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -77,14 +77,18 @@ public class CommonServiceImpl implements CommonService { ...@@ -77,14 +77,18 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public List<String> getQbjcPlatformNames() { public List<String> getQbjcPlatformNames() {
HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class); return getQbjcPlatform("name").stream().map(json -> json.getString("name")).collect(Collectors.toList());
return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).stream().map(json -> json.getString("name")).collect(Collectors.toList());
} }
@Override @Override
public List<JSONObject> getQbjcPlatform(String... includeFields) { public List<JSONObject> getQbjcPlatform(String... includeFields) {
HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class); List<JSONObject> collect = GlobalPojo.PLATFORMS.stream().filter(messagePlatform -> !"外媒".equals(messagePlatform.getName())).map(messagePlatform -> {
return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).stream().map(json -> { JSONObject json = new JSONObject();
json.put("id", messagePlatform.getId());
json.put("name", messagePlatform.getName());
return json;
}).collect(Collectors.toList());
return collect.stream().map(json -> {
if (null == includeFields) { if (null == includeFields) {
return json; return json;
} }
...@@ -94,6 +98,17 @@ public class CommonServiceImpl implements CommonService { ...@@ -94,6 +98,17 @@ public class CommonServiceImpl implements CommonService {
} }
return res; return res;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class);
// return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).stream().map(json -> {
// if (null == includeFields) {
// return json;
// }
// JSONObject res = new JSONObject();
// for (String field : includeFields) {
// res.put(field, json.get(field));
// }
// return res;
// }).collect(Collectors.toList());
} }
@Override @Override
......
...@@ -110,7 +110,7 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -110,7 +110,7 @@ public class CustomEventServiceImpl implements CustomEventService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
redisUtil.setExpire(redisKey, JSON.toJSONString(resultList)); redisUtil.setExpire(redisKey, JSON.toJSONString(resultList));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return resultList; return resultList;
} }
...@@ -131,10 +131,10 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -131,10 +131,10 @@ public class CustomEventServiceImpl implements CustomEventService {
public void updateCustomEvent(CustomEventDTO customEventDTO) { public void updateCustomEvent(CustomEventDTO customEventDTO) {
CustomEvent customEvent = customEventDao.findOneById(customEventDTO.getId()); CustomEvent customEvent = customEventDao.findOneById(customEventDTO.getId());
if (Objects.isNull(customEvent)) { if (Objects.isNull(customEvent)) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("自定义事件数据异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "自定义事件数据异常");
} }
if (Boolean.FALSE.equals(customEvent.getStatus())) { if (Boolean.FALSE.equals(customEvent.getStatus())) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("该事件数据更新中,无法修改该事件信息!")); ExceptionCast.cast(CommonCodeEnum.FAIL, "该事件数据更新中,无法修改该事件信息!");
} }
// 修改自定义事件及清空历史数据 // 修改自定义事件及清空历史数据
Update update = Update.update("title", customEventDTO.getTitle()).set("startTime", customEventDTO.getStartTime()). Update update = Update.update("title", customEventDTO.getTitle()).set("startTime", customEventDTO.getStartTime()).
...@@ -177,10 +177,10 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -177,10 +177,10 @@ public class CustomEventServiceImpl implements CustomEventService {
public void analyzeCustomEvent(String id) { public void analyzeCustomEvent(String id) {
CustomEvent customEvent = customEventDao.findOneById(id); CustomEvent customEvent = customEventDao.findOneById(id);
if (Objects.isNull(customEvent)) { if (Objects.isNull(customEvent)) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("自定义事件数据异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "自定义事件数据异常");
} }
if (Boolean.FALSE.equals(customEvent.getStatus())) { if (Boolean.FALSE.equals(customEvent.getStatus())) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("该事件数据更新中!")); ExceptionCast.cast(CommonCodeEnum.FAIL, "该事件数据更新中!");
} }
customEvent.setStatus(false); customEvent.setStatus(false);
Long now = System.currentTimeMillis(); Long now = System.currentTimeMillis();
...@@ -195,7 +195,7 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -195,7 +195,7 @@ public class CustomEventServiceImpl implements CustomEventService {
public JSONObject getCustomEventAnalyzeShareId(String id) { public JSONObject getCustomEventAnalyzeShareId(String id) {
CustomEvent customEvent = customEventDao.findOneById(id); CustomEvent customEvent = customEventDao.findOneById(id);
if (Objects.isNull(customEvent)) { if (Objects.isNull(customEvent)) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("自定义事件数据异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "自定义事件数据异常");
} }
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
String share = Tools.getUUID(); String share = Tools.getUUID();
...@@ -218,7 +218,7 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -218,7 +218,7 @@ public class CustomEventServiceImpl implements CustomEventService {
public JSONObject getShareCustomEventAnalyze(String share) { public JSONObject getShareCustomEventAnalyze(String share) {
String customEventId = redisUtil.get(RedisKeyPrefix.CUSTOM_EVENT_ANALYZE_SHARE + share); String customEventId = redisUtil.get(RedisKeyPrefix.CUSTOM_EVENT_ANALYZE_SHARE + share);
if (StringUtils.isEmpty(customEventId)) { if (StringUtils.isEmpty(customEventId)) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("自定义事件数据异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "自定义事件数据异常");
} }
return this.getCustomEventAnalyze(customEventId, true); return this.getCustomEventAnalyze(customEventId, true);
} }
...@@ -226,7 +226,7 @@ public class CustomEventServiceImpl implements CustomEventService { ...@@ -226,7 +226,7 @@ public class CustomEventServiceImpl implements CustomEventService {
private JSONObject getCustomEventAnalyzeInner(String id, boolean cache) throws IOException { private JSONObject getCustomEventAnalyzeInner(String id, boolean cache) throws IOException {
CustomEvent customEvent = customEventDao.findOneById(id); CustomEvent customEvent = customEventDao.findOneById(id);
if (Objects.isNull(customEvent)) { if (Objects.isNull(customEvent)) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("自定义事件数据异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "自定义事件数据异常");
} }
String redisKey = RedisKeyPrefix.CUSTOM_EVENT_ANALYZE + id; String redisKey = RedisKeyPrefix.CUSTOM_EVENT_ANALYZE + id;
if (cache) { if (cache) {
......
...@@ -24,10 +24,8 @@ import com.zhiwei.brandkbs2.enmus.ImportantChannelEnum; ...@@ -24,10 +24,8 @@ import com.zhiwei.brandkbs2.enmus.ImportantChannelEnum;
import com.zhiwei.brandkbs2.exception.ExceptionCast; import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.listener.ApplicationProjectListener; import com.zhiwei.brandkbs2.listener.ApplicationProjectListener;
import com.zhiwei.brandkbs2.model.CommonCodeEnum; import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.Event; import com.zhiwei.brandkbs2.model.EventCodeEnum;
import com.zhiwei.brandkbs2.pojo.EventData; import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.pojo.EventDisseminationTrend;
import com.zhiwei.brandkbs2.pojo.EventTopArticlesAnalysis;
import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO; import com.zhiwei.brandkbs2.pojo.dto.EventDataDTO;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO; import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO; import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO;
...@@ -119,7 +117,7 @@ public class EventServiceImpl implements EventService { ...@@ -119,7 +117,7 @@ public class EventServiceImpl implements EventService {
Event event = eventDao.findOneById(eventId); Event event = eventDao.findOneById(eventId);
if (Objects.isNull(event)) { if (Objects.isNull(event)) {
// 抛出事件不存在异常 // 抛出事件不存在异常
ExceptionCast.cast(CommonCodeEnum.FAIL.message("该事件不存在")); ExceptionCast.cast(CommonCodeEnum.FAIL, "该事件不存在");
} }
return event; return event;
} }
...@@ -133,7 +131,7 @@ public class EventServiceImpl implements EventService { ...@@ -133,7 +131,7 @@ public class EventServiceImpl implements EventService {
} }
String oldProgress = stringRedisTemplate.opsForValue().get(redisKey); String oldProgress = stringRedisTemplate.opsForValue().get(redisKey);
if (null != oldProgress) { if (null != oldProgress) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("当前项目品牌已有进行任务")); ExceptionCast.cast(EventCodeEnum.HAS_TASK_ERROR);
} }
stringRedisTemplate.opsForValue().set(redisKey, "0"); stringRedisTemplate.opsForValue().set(redisKey, "0");
String collectionName = eventDataDao.generateCollectionName(); String collectionName = eventDataDao.generateCollectionName();
...@@ -185,8 +183,8 @@ public class EventServiceImpl implements EventService { ...@@ -185,8 +183,8 @@ public class EventServiceImpl implements EventService {
} }
@Override @Override
public PageVO<JSONObject> findEventList(int page, int size, String linkedGroupId, String keyword, String sorter) { public PageVO<JSONObject> findEventList(int page, int size, String contendId, String keyword, String sorter) {
Query query = new Query(Criteria.where("linkedGroupId").is(linkedGroupId).and("projectId").is(UserThreadLocal.getProjectId())); Query query = new Query(Criteria.where("contendId").is(contendId).and("projectId").is(UserThreadLocal.getProjectId()));
// 添加模糊匹配 // 添加模糊匹配
eventDao.addKeywordFuzz(query, keyword, "title"); eventDao.addKeywordFuzz(query, keyword, "title");
// 添加排序 // 添加排序
...@@ -263,7 +261,7 @@ public class EventServiceImpl implements EventService { ...@@ -263,7 +261,7 @@ public class EventServiceImpl implements EventService {
String redisKey = RedisKeyPrefix.eventDataProgressKey(ticket); String redisKey = RedisKeyPrefix.eventDataProgressKey(ticket);
String progress = stringRedisTemplate.opsForValue().get(redisKey); String progress = stringRedisTemplate.opsForValue().get(redisKey);
if (StringUtils.isEmpty(progress)) { if (StringUtils.isEmpty(progress)) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("文件解析进度获取失败")); ExceptionCast.cast(CommonCodeEnum.FAIL);
} }
return Integer.parseInt(progress); return Integer.parseInt(progress);
} }
...@@ -410,9 +408,10 @@ public class EventServiceImpl implements EventService { ...@@ -410,9 +408,10 @@ public class EventServiceImpl implements EventService {
} }
@Override @Override
public Pair<String, List<ExportEventDTO>> downloadEvents(String linkedGroupId) { public Pair<String, List<ExportEventDTO>> downloadEvents(String contendId) {
String fileName = projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandName();
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectByContendId(projectId, contendId).getBrandLinkedGroupId();
String fileName = projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandName();
List<Event> eventList = eventDao.findList(Query.query(Criteria.where("projectId").is(projectId).and("linkedGroupId").is(linkedGroupId))); List<Event> eventList = eventDao.findList(Query.query(Criteria.where("projectId").is(projectId).and("linkedGroupId").is(linkedGroupId)));
if (eventList.isEmpty()) { if (eventList.isEmpty()) {
return Pair.of(fileName, Collections.emptyList()); return Pair.of(fileName, Collections.emptyList());
...@@ -474,36 +473,38 @@ public class EventServiceImpl implements EventService { ...@@ -474,36 +473,38 @@ public class EventServiceImpl implements EventService {
} }
@Override @Override
public JSONObject findEventTagListAll(String linkedGroupId) { public JSONObject findEventTagListAll(String contendId) {
String linkedGroup = projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandLinkedGroup(); String linkedGroup = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId).getBrandLinkedGroup();
ResponseEntity<JSONObject> entity = restTemplate.getForEntity(qbjcEventTagUrl, JSONObject.class, linkedGroup); ResponseEntity<JSONObject> entity = restTemplate.getForEntity(qbjcEventTagUrl, JSONObject.class, linkedGroup);
return Objects.requireNonNull(entity.getBody()).getJSONObject("data"); return Objects.requireNonNull(entity.getBody()).getJSONObject("data");
} }
@Override @Override
public PageVO<JSONObject> findEventTagList(int page, int size, String linkedGroupId, String tagGroupName) { public PageVO<JSONObject> findEventTagList(int page, int size, String contendId, String tagGroupName) {
if (page < 1) { if (page < 1) {
page = 1; page = 1;
} }
if (size < 0 || size > 50) { if (size < 0 || size > 50) {
size = 10; size = 10;
} }
String group = projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandLinkedGroup(); AbstractProject projectByContendId = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId);
ResponseEntity<JSONObject> entity = restTemplate.getForEntity(qbjcEventTagUrl, JSONObject.class, group); String linkedGroup = projectByContendId.getBrandLinkedGroup();
ResponseEntity<JSONObject> entity = restTemplate.getForEntity(qbjcEventTagUrl, JSONObject.class, linkedGroup);
List<JSONObject> tagGroupList = Objects.requireNonNull(entity.getBody()).getJSONObject("data").getJSONObject("tagList").getJSONArray(tagGroupName).toJavaList(JSONObject.class); List<JSONObject> tagGroupList = Objects.requireNonNull(entity.getBody()).getJSONObject("data").getJSONObject("tagList").getJSONArray(tagGroupName).toJavaList(JSONObject.class);
List<List<JSONObject>> partition = Lists.partition(tagGroupList, size); List<List<JSONObject>> partition = Lists.partition(tagGroupList, size);
List<JSONObject> resultList = partition.get(page - 1); List<JSONObject> resultList = partition.get(page - 1);
resultList = resultList.stream().peek(json -> { resultList = resultList.stream().peek(json -> {
String name = json.getString("name"); String name = json.getString("name");
Query query = Query.query(Criteria.where("eventTag." + tagGroupName).is(name).and("projectId").is(UserThreadLocal.getProjectId()).and("linkedGroupId").is(linkedGroupId)); Query query =
Query.query(Criteria.where("eventTag." + tagGroupName).is(name).and("projectId").is(UserThreadLocal.getProjectId()).and("contendId").is(contendId));
json.put("eventCount", eventDao.count(query)); json.put("eventCount", eventDao.count(query));
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return PageVO.createPageVo(tagGroupList.size(), page, partition.size(), size, resultList); return PageVO.createPageVo(tagGroupList.size(), page, partition.size(), size, resultList);
} }
@Override @Override
public List<String> findEventTagGroupName(String linkedGroupId) { public List<String> findEventTagGroupName(String contendId) {
String group = projectService.getProjectByLinkedGroupId(linkedGroupId).getBrandLinkedGroup(); String group = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId).getBrandLinkedGroup();
ResponseEntity<JSONObject> entity = restTemplate.getForEntity(qbjcEventTagUrl, JSONObject.class, group); ResponseEntity<JSONObject> entity = restTemplate.getForEntity(qbjcEventTagUrl, JSONObject.class, group);
return Objects.requireNonNull(entity.getBody()).getJSONObject("data").getJSONArray("tagNameList").toJavaList(String.class); return Objects.requireNonNull(entity.getBody()).getJSONObject("data").getJSONArray("tagNameList").toJavaList(String.class);
} }
...@@ -632,6 +633,9 @@ public class EventServiceImpl implements EventService { ...@@ -632,6 +633,9 @@ public class EventServiceImpl implements EventService {
boolean highLight = null == aggTitle || Objects.equals(aggTitle, eventTopArticlesAnalysis.getAggTitle()); boolean highLight = null == aggTitle || Objects.equals(aggTitle, eventTopArticlesAnalysis.getAggTitle());
return new EventTopArticlesAnalysisVO(eventTopArticlesAnalysis, highLight); return new EventTopArticlesAnalysisVO(eventTopArticlesAnalysis, highLight);
}).collect(Collectors.groupingBy(EventTopArticlesAnalysisVO::getTimePoint)); }).collect(Collectors.groupingBy(EventTopArticlesAnalysisVO::getTimePoint));
collect.forEach((k, v) -> {
v.sort((y, x) -> Integer.compare(x.getCount(), y.getCount()));
});
res.put("dataDay", Tools.sortTimeKeyMap(collect, Constant.SPEC_DAY_FORMAT, false)); res.put("dataDay", Tools.sortTimeKeyMap(collect, Constant.SPEC_DAY_FORMAT, false));
res.put("dataAmount", null); res.put("dataAmount", null);
return res; return res;
...@@ -824,7 +828,8 @@ public class EventServiceImpl implements EventService { ...@@ -824,7 +828,8 @@ public class EventServiceImpl implements EventService {
param.put("startTime", yqEventSearchVO.getStartTime()); param.put("startTime", yqEventSearchVO.getStartTime());
param.put("endTime", yqEventSearchVO.getEndTime()); param.put("endTime", yqEventSearchVO.getEndTime());
param.put("timeType", "startTime"); param.put("timeType", "startTime");
String linkedGroup = projectService.getProjectByLinkedGroupId(yqEventSearchVO.getLinkedGroupId()).getBrandLinkedGroup();
String linkedGroup = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), yqEventSearchVO.getContendId()).getBrandLinkedGroup();
param.put("project", linkedGroup); param.put("project", linkedGroup);
ResponseEntity<JSONObject> entity = restTemplate.postForEntity(qbjcEventUrl, param, JSONObject.class); ResponseEntity<JSONObject> entity = restTemplate.postForEntity(qbjcEventUrl, param, JSONObject.class);
if (null == entity.getBody()) { if (null == entity.getBody()) {
......
...@@ -101,7 +101,7 @@ public class IndexServiceImpl implements IndexService { ...@@ -101,7 +101,7 @@ public class IndexServiceImpl implements IndexService {
jsonObject.put("spread", this.getArticleSpreadWithBrand(projectId, Constant.PRIMARY_CONTEND_ID, dayList)); jsonObject.put("spread", this.getArticleSpreadWithBrand(projectId, Constant.PRIMARY_CONTEND_ID, dayList));
redisUtil.setExpire(redisKey, JSON.toJSONString(jsonObject)); redisUtil.setExpire(redisKey, JSON.toJSONString(jsonObject));
} catch (Exception e) { } catch (Exception e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("getYuqingAmount异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "getYuqingAmount异常", e);
} }
return jsonObject; return jsonObject;
} }
...@@ -158,7 +158,7 @@ public class IndexServiceImpl implements IndexService { ...@@ -158,7 +158,7 @@ public class IndexServiceImpl implements IndexService {
jsonObject.put("avgPosPro", avgPosPro); jsonObject.put("avgPosPro", avgPosPro);
redisUtil.setExpire(redisKey, JSON.toJSONString(jsonObject)); redisUtil.setExpire(redisKey, JSON.toJSONString(jsonObject));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return jsonObject; return jsonObject;
} }
...@@ -214,7 +214,7 @@ public class IndexServiceImpl implements IndexService { ...@@ -214,7 +214,7 @@ public class IndexServiceImpl implements IndexService {
jsonObject.put("spread", lineList); jsonObject.put("spread", lineList);
redisUtil.setExpire(redisKey, JSONObject.toJSONString(jsonObject)); redisUtil.setExpire(redisKey, JSONObject.toJSONString(jsonObject));
} catch (Exception e) { } catch (Exception e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("getEventAmount异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "getEventAmount异常", e);
} }
return jsonObject; return jsonObject;
} }
...@@ -240,7 +240,7 @@ public class IndexServiceImpl implements IndexService { ...@@ -240,7 +240,7 @@ public class IndexServiceImpl implements IndexService {
redisUtil.setExpire(redisKey, JSON.toJSONString(platforms)); redisUtil.setExpire(redisKey, JSON.toJSONString(platforms));
return platforms; return platforms;
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return Collections.emptyList(); return Collections.emptyList();
} }
...@@ -292,7 +292,7 @@ public class IndexServiceImpl implements IndexService { ...@@ -292,7 +292,7 @@ public class IndexServiceImpl implements IndexService {
resJson.put("summary", summary); resJson.put("summary", summary);
redisUtil.setExpire(redisKey, JSON.toJSONString(resJson)); redisUtil.setExpire(redisKey, JSON.toJSONString(resJson));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return resJson; return resJson;
} }
...@@ -300,17 +300,27 @@ public class IndexServiceImpl implements IndexService { ...@@ -300,17 +300,27 @@ public class IndexServiceImpl implements IndexService {
public List<JSONObject> getPlatformProportionWithPlatform(Long startTime, Long endTime, String emotion, String projectId, String contendId, long normalCount) { public List<JSONObject> getPlatformProportionWithPlatform(Long startTime, Long endTime, String emotion, String projectId, String contendId, long normalCount) {
List<String> platformIds = GlobalPojo.PLATFORMS.stream().map(MessagePlatform::getId).collect(Collectors.toList()); List<String> platformIds = GlobalPojo.PLATFORMS.stream().map(MessagePlatform::getId).collect(Collectors.toList());
List<JSONObject> resultList = new ArrayList<>(platformIds.size()); List<JSONObject> resultList = new ArrayList<>(platformIds.size());
Map<String, Long> platformCount = new HashMap<>();
platformIds.forEach(platformId -> { platformIds.forEach(platformId -> {
JSONObject result = new JSONObject();
long count; long count;
try { try {
count = markDataService.getYuqingMarkCount(startTime, endTime, emotion, platformId, projectId, contendId); count = markDataService.getYuqingMarkCount(startTime, endTime, emotion, platformId, projectId, contendId);
} catch (IOException ignored) { } catch (IOException ignored) {
count = -1; count = -1;
} }
result.put("platform", GlobalPojo.getPermanentPlatformNameById(platformId)); long finalCount = count;
result.put("num", count); platformCount.compute(GlobalPojo.getPermanentPlatformNameById(platformId), (k, v) -> {
result.put("proportion", normalCount == 0 ? 0d : count / (double) normalCount); if (null == v) {
return finalCount;
}
return v + finalCount;
});
});
platformCount.forEach((k, v) -> {
JSONObject result = new JSONObject();
result.put("platform", k);
result.put("num", v);
result.put("proportion", normalCount == 0 ? 0d : v / (double) normalCount);
resultList.add(result); resultList.add(result);
}); });
return resultList; return resultList;
......
...@@ -154,7 +154,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -154,7 +154,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 各平台计量 // 各平台计量
.setInfo(new JSONObject(ImmutableMap.of("platformCount", hitsAndCounts.getRight()))); .setInfo(new JSONObject(ImmutableMap.of("platformCount", hitsAndCounts.getRight())));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es检索异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return null; return null;
} }
...@@ -173,7 +173,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -173,7 +173,7 @@ public class MarkDataServiceImpl implements MarkDataService {
return Pair.of(project.getBrandName() + "_" + markSearchDTO.getStartTime() + "_" + markSearchDTO.getEndTime(), returnList); return Pair.of(project.getBrandName() + "_" + markSearchDTO.getStartTime() + "_" + markSearchDTO.getEndTime(), returnList);
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es检索异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return null; return null;
} }
...@@ -213,7 +213,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -213,7 +213,7 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override @Override
public PageVO<MarkFlowEntity> getYuqingMarkAggreeList(MarkSearchDTO dto) { public PageVO<MarkFlowEntity> getYuqingMarkAggreeList(MarkSearchDTO dto) {
if (null == dto.getAggreeId()) { if (null == dto.getAggreeId()) {
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("聚合id不得为空")); ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM);
} }
defaultMarkSearch(dto); defaultMarkSearch(dto);
Query query = assembleAggreeQuery(dto); Query query = assembleAggreeQuery(dto);
...@@ -392,7 +392,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -392,7 +392,7 @@ public class MarkDataServiceImpl implements MarkDataService {
redisUtil.setExpire(redisKey, JSON.toJSONString(result)); redisUtil.setExpire(redisKey, JSON.toJSONString(result));
return result; return result;
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return null; return null;
} }
...@@ -403,7 +403,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -403,7 +403,7 @@ public class MarkDataServiceImpl implements MarkDataService {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
return getMarkSpread(startTime, endTime, projectId, cache); return getMarkSpread(startTime, endTime, projectId, cache);
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return null; return null;
} }
...@@ -438,7 +438,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -438,7 +438,7 @@ public class MarkDataServiceImpl implements MarkDataService {
redisUtil.setExpire(redisKey, JSON.toJSONString(result)); redisUtil.setExpire(redisKey, JSON.toJSONString(result));
return result; return result;
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return null; return null;
} }
...@@ -462,7 +462,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -462,7 +462,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 渠道标签占比 // 渠道标签占比
result.put("importantChannelPercent", getImportantChannelPercent(projectId, linkedGroupId, startTime, endTime)); result.put("importantChannelPercent", getImportantChannelPercent(projectId, linkedGroupId, startTime, endTime));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
redisUtil.setExpire(redisKey, JSON.toJSONString(result)); redisUtil.setExpire(redisKey, JSON.toJSONString(result));
return result; return result;
...@@ -480,7 +480,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -480,7 +480,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 舆情库默认contendId为0 // 舆情库默认contendId为0
res = getMarkPlatformProportion(startTime, endTime, projectId, linkedGroupId, Constant.PRIMARY_CONTEND_ID, cache); res = getMarkPlatformProportion(startTime, endTime, projectId, linkedGroupId, Constant.PRIMARY_CONTEND_ID, cache);
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return res; return res;
} }
...@@ -508,7 +508,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -508,7 +508,7 @@ public class MarkDataServiceImpl implements MarkDataService {
redisUtil.setExpire(redisKey, JSON.toJSONString(highWords)); redisUtil.setExpire(redisKey, JSON.toJSONString(highWords));
return highWords; return highWords;
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常"), e); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return null; return null;
} }
...@@ -813,7 +813,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -813,7 +813,7 @@ public class MarkDataServiceImpl implements MarkDataService {
BoolQueryBuilder query; BoolQueryBuilder query;
if (include) { if (include) {
query = projectLinkedGroupContendIdQuery(projectId, linkedGroupId, contendId); query = projectLinkedGroupContendIdQuery(projectId, linkedGroupId, contendId);
}else { } else {
query = EsQueryTools.assembleCacheMapsQueryExcludePrimaryId(projectId); query = EsQueryTools.assembleCacheMapsQueryExcludePrimaryId(projectId);
} }
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime)) query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime))
...@@ -850,7 +850,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -850,7 +850,7 @@ public class MarkDataServiceImpl implements MarkDataService {
BoolQueryBuilder postFilter; BoolQueryBuilder postFilter;
if (include) { if (include) {
postFilter = projectLinkedGroupContendIdQuery(projectId, linkedGroupId, contendId); postFilter = projectLinkedGroupContendIdQuery(projectId, linkedGroupId, contendId);
}else { } else {
postFilter = EsQueryTools.assembleCacheMapsQueryExcludePrimaryId(projectId); postFilter = EsQueryTools.assembleCacheMapsQueryExcludePrimaryId(projectId);
} }
postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime)).must(QueryBuilders.termQuery("agg_title.keyword", aggTitle)); postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime)).must(QueryBuilders.termQuery("agg_title.keyword", aggTitle));
...@@ -945,7 +945,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -945,7 +945,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 各平台计量 // 各平台计量
.setInfo(new JSONObject(ImmutableMap.of("platformCount", hitsAndCounts.getRight()))); .setInfo(new JSONObject(ImmutableMap.of("platformCount", hitsAndCounts.getRight())));
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es检索异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
return null; return null;
} }
...@@ -1235,7 +1235,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -1235,7 +1235,7 @@ public class MarkDataServiceImpl implements MarkDataService {
return Pair.of(project.getBrandName() + "_" + markSearchDTO.getStartTime() + "_" + markSearchDTO.getEndTime(), returnList); return Pair.of(project.getBrandName() + "_" + markSearchDTO.getStartTime() + "_" + markSearchDTO.getEndTime(), returnList);
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es检索异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常", e);
} }
return null; return null;
} }
...@@ -1248,7 +1248,7 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -1248,7 +1248,7 @@ public class MarkDataServiceImpl implements MarkDataService {
// 搜索时间 // 搜索时间
result.put("times", Arrays.asList("今天", "24小时", "三天", "七天", "近30天")); result.put("times", Arrays.asList("今天", "24小时", "三天", "七天", "近30天"));
result.put("ninetyDays",DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), -89).getTime()); result.put("ninetyDays", DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), -89).getTime());
List<JSONObject> platformList = new ArrayList<>(); List<JSONObject> platformList = new ArrayList<>();
if (2 == project.getWholeSearchDataSource()) { if (2 == project.getWholeSearchDataSource()) {
...@@ -1260,36 +1260,36 @@ public class MarkDataServiceImpl implements MarkDataService { ...@@ -1260,36 +1260,36 @@ public class MarkDataServiceImpl implements MarkDataService {
platformJSONObject.put("id", entry.getValue()); platformJSONObject.put("id", entry.getValue());
platformList.add(platformJSONObject); platformList.add(platformJSONObject);
} }
}else { } else {
result.put("origin", "舆情"); result.put("origin", "舆情");
ResponseEntity<String> responseEntity = restTemplate.getForEntity(wholeSearchCriteriaUrl, String.class); ResponseEntity<String> responseEntity = restTemplate.getForEntity(wholeSearchCriteriaUrl, String.class);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
Map data = (Map) jsonObject.get("data"); Map data = (Map) jsonObject.get("data");
List<JSONObject> list = (List)data.get("list"); List<JSONObject> list = (List) data.get("list");
//发布平台删掉脉脉 //发布平台删掉脉脉
List<JSONObject> collect = list.stream().filter(s -> !s.get("name").equals("脉脉")).collect(Collectors.toList()); List<JSONObject> collect = list.stream().filter(s -> !s.get("name").equals("脉脉")).collect(Collectors.toList());
for (JSONObject object : collect) { for (JSONObject object : collect) {
JSONObject platformJSONObject = new JSONObject(); JSONObject platformJSONObject = new JSONObject();
platformJSONObject.put("name",object.get("name")); platformJSONObject.put("name", object.get("name"));
platformJSONObject.put("id",object.get("id")); platformJSONObject.put("id", object.get("id"));
platformList.add(platformJSONObject); platformList.add(platformJSONObject);
} }
} }
result.put("platformList",platformList); result.put("platformList", platformList);
return result; return result;
} }
private JSONObject getBackUpPlatform(){ private JSONObject getBackUpPlatform() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("全部",""); jsonObject.put("全部", "");
jsonObject.put("微博","微博"); jsonObject.put("微博", "微博");
jsonObject.put("微信","微信"); jsonObject.put("微信", "微信");
jsonObject.put("网媒","新闻"); jsonObject.put("网媒", "新闻");
jsonObject.put("平媒","平媒"); jsonObject.put("平媒", "平媒");
jsonObject.put("自媒体","自媒体"); jsonObject.put("自媒体", "自媒体");
jsonObject.put("贴吧论坛","论坛"); jsonObject.put("贴吧论坛", "论坛");
jsonObject.put("视频","视频"); jsonObject.put("视频", "视频");
jsonObject.put("短视频","短视频"); jsonObject.put("短视频", "短视频");
return jsonObject; return jsonObject;
} }
......
...@@ -60,7 +60,7 @@ public class MarkFlowServiceImpl implements MarkFlowService { ...@@ -60,7 +60,7 @@ public class MarkFlowServiceImpl implements MarkFlowService {
String key = RedisUtil.getShotPageKey(id, UserThreadLocal.getProjectId()); String key = RedisUtil.getShotPageKey(id, UserThreadLocal.getProjectId());
String data = redisUtil.get(key); String data = redisUtil.get(key);
if (null == data) { if (null == data) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("缓存不存在或已过期")); ExceptionCast.cast(CommonCodeEnum.FAIL);
} }
return JSON.parseObject(data, MarkFlowEntity.class); return JSON.parseObject(data, MarkFlowEntity.class);
// JSONObject dataJson = JSON.parseObject(data); // JSONObject dataJson = JSON.parseObject(data);
......
...@@ -94,7 +94,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -94,7 +94,7 @@ public class ProjectServiceImpl implements ProjectService {
Project project = projectDao.findOneById(id); Project project = projectDao.findOneById(id);
if (Objects.isNull(project)) { if (Objects.isNull(project)) {
//如果项目不存在,抛出非法参数异常 //如果项目不存在,抛出非法参数异常
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("该项目不存在")); ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM, "该项目不存在");
} }
return project.creatProjectVo(); return project.creatProjectVo();
} }
...@@ -157,7 +157,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -157,7 +157,7 @@ public class ProjectServiceImpl implements ProjectService {
public void switchProjectStart(String pid) { public void switchProjectStart(String pid) {
Project project = projectDao.findOneById(pid); Project project = projectDao.findOneById(pid);
if (Objects.isNull(project)) { if (Objects.isNull(project)) {
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("项目不存在")); ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM, "项目不存在");
} }
Update update = new Update(); Update update = new Update();
update.set("uTime", new Date()); update.set("uTime", new Date());
......
...@@ -210,7 +210,7 @@ public class ReportServiceImpl implements ReportService { ...@@ -210,7 +210,7 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public JSONObject getPcReportAnalyze(Report report, boolean cache) { public JSONObject getPcReportAnalyze(Report report, boolean cache) {
if (Objects.isNull(report)) { if (Objects.isNull(report)) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("获取报告数据异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "获取报告数据异常");
} }
String redisKey = RedisKeyPrefix.REPORT_PC + report.getId(); String redisKey = RedisKeyPrefix.REPORT_PC + report.getId();
String resultStr; String resultStr;
...@@ -232,7 +232,7 @@ public class ReportServiceImpl implements ReportService { ...@@ -232,7 +232,7 @@ public class ReportServiceImpl implements ReportService {
try { try {
result = getPcReportResult(report); result = getPcReportResult(report);
} catch (IOException e) { } catch (IOException e) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("es查询异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "es查询异常");
} }
redisUtil.set(redisKey, JSON.toJSONString(result)); redisUtil.set(redisKey, JSON.toJSONString(result));
return result; return result;
...@@ -355,8 +355,7 @@ public class ReportServiceImpl implements ReportService { ...@@ -355,8 +355,7 @@ public class ReportServiceImpl implements ReportService {
result.put("topPosSummary", this.getTopEventMsg(topPosEventList)); result.put("topPosSummary", this.getTopEventMsg(topPosEventList));
} }
//获取上个周期时间范围内总正面稿件数 //获取上个周期时间范围内总正面稿件数
long lastPositiveTotal = markDataService.getYuqingMarkCount(lastStartTime, startTime, long lastPositiveTotal = markDataService.getYuqingMarkCount(lastStartTime, startTime, EmotionEnum.POSITIVE.getName(), projectId, contendId);
EmotionEnum.POSITIVE.getName(), projectId, contendId);
result.put("lastPosTotal", lastPositiveTotal); result.put("lastPosTotal", lastPositiveTotal);
result.put("posCompare", lastPositiveTotal == 0 ? 0 : (curPositiveTotal - lastPositiveTotal) * 1.0 / lastPositiveTotal); result.put("posCompare", lastPositiveTotal == 0 ? 0 : (curPositiveTotal - lastPositiveTotal) * 1.0 / lastPositiveTotal);
//获取时间范围内总中性稿件数 //获取时间范围内总中性稿件数
...@@ -366,8 +365,7 @@ public class ReportServiceImpl implements ReportService { ...@@ -366,8 +365,7 @@ public class ReportServiceImpl implements ReportService {
//中性事件传播量top //中性事件传播量top
List<Event> topNeuEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, contendId, 4); List<Event> topNeuEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, contendId, 4);
if (CollectionUtils.isEmpty(topNeuEventList)) { if (CollectionUtils.isEmpty(topNeuEventList)) {
List<Map.Entry<String, Integer>> topNeuArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, List<Map.Entry<String, Integer>> topNeuArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, linkedGroupId, contendId, 4);
linkedGroupId, contendId, 4);
result.put("topNeuSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNeuArticleList)); result.put("topNeuSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNeuArticleList));
} else { } else {
result.put("topNeuSummary", this.getTopEventMsg(topNeuEventList)); result.put("topNeuSummary", this.getTopEventMsg(topNeuEventList));
...@@ -383,8 +381,7 @@ public class ReportServiceImpl implements ReportService { ...@@ -383,8 +381,7 @@ public class ReportServiceImpl implements ReportService {
//中性事件传播量top //中性事件传播量top
List<Event> topNegEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, contendId, 4); List<Event> topNegEventList = eventDao.getEventsByTotalChannelVolumeTop(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, contendId, 4);
if (CollectionUtils.isEmpty(topNegEventList)) { if (CollectionUtils.isEmpty(topNegEventList)) {
List<Map.Entry<String, Integer>> topNegArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEGATIVE.getName(), List<Map.Entry<String, Integer>> topNegArticleList = markDataService.getMarkTopTitle(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, linkedGroupId, contendId, 4);
projectId, linkedGroupId, contendId, 4);
result.put("topNegSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNegArticleList)); result.put("topNegSummary", this.getTopArticlesMsg(startTime, endTime, projectId, linkedGroupId, contendId, topNegArticleList));
} else { } else {
result.put("topNegSummary", this.getTopEventMsg(topNegEventList)); result.put("topNegSummary", this.getTopEventMsg(topNegEventList));
...@@ -428,10 +425,7 @@ public class ReportServiceImpl implements ReportService { ...@@ -428,10 +425,7 @@ public class ReportServiceImpl implements ReportService {
} }
result.put("spread", lineList); result.put("spread", lineList);
//获取稿件的传播峰值 //获取稿件的传播峰值
List<Long> dateList = lineList.stream() List<Long> dateList = lineList.stream().sorted((o1, o2) -> o2.getInteger("normalCount").compareTo(o1.getInteger("normalCount"))).map(json -> json.getLong("time")).collect(Collectors.toList());
.sorted((o1, o2) -> o2.getInteger("normalCount").compareTo(o1.getInteger("normalCount")))
.map(json -> json.getLong("time"))
.collect(Collectors.toList());
result.put("normalMaxTimes", dateList.size() > 2 ? dateList.subList(0, 3) : dateList); result.put("normalMaxTimes", dateList.size() > 2 ? dateList.subList(0, 3) : dateList);
if (CollectionUtils.isNotEmpty(dateList)) { if (CollectionUtils.isNotEmpty(dateList)) {
Long startTime = dateList.get(0); Long startTime = dateList.get(0);
...@@ -485,7 +479,7 @@ public class ReportServiceImpl implements ReportService { ...@@ -485,7 +479,7 @@ public class ReportServiceImpl implements ReportService {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
List<ReportSettings> reports = reportSettingsDao.findList(Query.query(Criteria.where("projectId").is(projectId))); List<ReportSettings> reports = reportSettingsDao.findList(Query.query(Criteria.where("projectId").is(projectId)));
if (reports.size() > 2) { if (reports.size() > 2) {
ExceptionCast.cast(CommonCodeEnum.FAIL.message("获取报告配置信息异常")); ExceptionCast.cast(CommonCodeEnum.FAIL, "获取报告配置信息异常");
} }
return reports; return reports;
} }
...@@ -522,16 +516,15 @@ public class ReportServiceImpl implements ReportService { ...@@ -522,16 +516,15 @@ public class ReportServiceImpl implements ReportService {
* @return top事件信息 * @return top事件信息
*/ */
private List<JSONObject> getTopEventMsg(List<Event> topEventList) { private List<JSONObject> getTopEventMsg(List<Event> topEventList) {
return topEventList.stream() return topEventList.stream().map(event -> {
.map(event -> { boolean hasAnalyze = Objects.equals(event.getContendId(), Constant.PRIMARY_CONTEND_ID);
boolean hasAnalyze = Objects.equals(event.getContendId(), Constant.PRIMARY_CONTEND_ID); JSONObject jsonObject = new JSONObject();
JSONObject jsonObject = new JSONObject(); jsonObject.put("id", event.getId());
jsonObject.put("id", event.getId()); String title = event.getTitle();
String title = event.getTitle(); jsonObject.put("title", title.length() <= 30 ? title : title.substring(0, 30) + "...");
jsonObject.put("title", title.length() <= 30 ? title : title.substring(0, 30) + "..."); jsonObject.put("hasAnalyze", hasAnalyze);
jsonObject.put("hasAnalyze", hasAnalyze); return jsonObject;
return jsonObject; }).collect(Collectors.toList());
}).collect(Collectors.toList());
} }
......
...@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.dao.UserDao; ...@@ -7,6 +7,7 @@ import com.zhiwei.brandkbs2.dao.UserDao;
import com.zhiwei.brandkbs2.dao.impl.UserOldDaoImpl; import com.zhiwei.brandkbs2.dao.impl.UserOldDaoImpl;
import com.zhiwei.brandkbs2.dao.impl.UserProjectOldDaoImpl; import com.zhiwei.brandkbs2.dao.impl.UserProjectOldDaoImpl;
import com.zhiwei.brandkbs2.enmus.RoleEnum; import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.enmus.response.LoginCodeEnum;
import com.zhiwei.brandkbs2.exception.ExceptionCast; import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.model.CommonCodeEnum; import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.User; import com.zhiwei.brandkbs2.pojo.User;
...@@ -119,7 +120,7 @@ public class UserServiceImpl implements UserService { ...@@ -119,7 +120,7 @@ public class UserServiceImpl implements UserService {
public void addUser(UserDTO userDTO) { public void addUser(UserDTO userDTO) {
if (Objects.isNull(userDTO.getRoleId()) || userDTO.getRoleId() < RoleEnum.ADMIN.getState()) { if (Objects.isNull(userDTO.getRoleId()) || userDTO.getRoleId() < RoleEnum.ADMIN.getState()) {
// 抛出用户权限设置错误异常 // 抛出用户权限设置错误异常
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("用户权限设置异常")); ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM,"用户权限设置异常");
} }
int roleId = UserThreadLocal.getRoleId(); int roleId = UserThreadLocal.getRoleId();
// 只有超管能设置管理员 // 只有超管能设置管理员
...@@ -139,7 +140,7 @@ public class UserServiceImpl implements UserService { ...@@ -139,7 +140,7 @@ public class UserServiceImpl implements UserService {
} else { } else {
if (roles.stream().map(UserRole::getProjectId).collect(Collectors.toList()).contains(userDTO.getProjectId())) { if (roles.stream().map(UserRole::getProjectId).collect(Collectors.toList()).contains(userDTO.getProjectId())) {
// 抛出用户权限设置错误异常 // 抛出用户权限设置错误异常
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("用户权限设置重复")); ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM,"用户权限设置重复");
} }
} }
roles.add(UserRole.createFromUserDto(userDTO)); roles.add(UserRole.createFromUserDto(userDTO));
...@@ -209,10 +210,10 @@ public class UserServiceImpl implements UserService { ...@@ -209,10 +210,10 @@ public class UserServiceImpl implements UserService {
public List<JSONObject> bindUser(String username, String password) { public List<JSONObject> bindUser(String username, String password) {
UserOldDaoImpl.UserOld userOld = userOldDao.findOneByUsernameAndPassword(username, password); UserOldDaoImpl.UserOld userOld = userOldDao.findOneByUsernameAndPassword(username, password);
if (null == userOld) { if (null == userOld) {
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("账号密码错误")); ExceptionCast.cast(LoginCodeEnum.LOGIN_USERNAME_OR_PASSWORD_ERROR);
} }
if (userOld.isBindUser()) { if (userOld.isBindUser()) {
ExceptionCast.cast(CommonCodeEnum.INVALID_PARAM.message("该账号已被绑定")); ExceptionCast.cast(LoginCodeEnum.LOGIN_WX_WITH_USER_ERROR);
} }
User user = userDao.findOneById(UserThreadLocal.getUserId()); User user = userDao.findOneById(UserThreadLocal.getUserId());
if (null == user) { if (null == user) {
...@@ -220,10 +221,6 @@ public class UserServiceImpl implements UserService { ...@@ -220,10 +221,6 @@ public class UserServiceImpl implements UserService {
CenterUser centerUser = userInfoClient.getUserById(Integer.parseInt(UserThreadLocal.getUserId())); CenterUser centerUser = userInfoClient.getUserById(Integer.parseInt(UserThreadLocal.getUserId()));
user = User.createFromCenterUser(centerUser); user = User.createFromCenterUser(centerUser);
} }
List<UserProjectOldDaoImpl.UserProjectOld> userProjects = userProjectOldDao.findList(new Query(Criteria.where("userId").is(user.getId())));
if (userProjects.isEmpty()) {
ExceptionCast.cast(CommonCodeEnum.FAIL);
}
// 超级管理员 // 超级管理员
if (userOld.isSuperAdmin()) { if (userOld.isSuperAdmin()) {
user.setSuperAdmin(true); user.setSuperAdmin(true);
...@@ -231,6 +228,10 @@ public class UserServiceImpl implements UserService { ...@@ -231,6 +228,10 @@ public class UserServiceImpl implements UserService {
userOldDao.updateOneByIdWithField(userOld.getId(), Update.update("bindUser", true)); userOldDao.updateOneByIdWithField(userOld.getId(), Update.update("bindUser", true));
return projectServiceImpl.getProjectListByUser(user, true); return projectServiceImpl.getProjectListByUser(user, true);
} }
List<UserProjectOldDaoImpl.UserProjectOld> userProjects = userProjectOldDao.findList(new Query(Criteria.where("userId").is(user.getId())));
if (userProjects.isEmpty()) {
ExceptionCast.cast(CommonCodeEnum.FAIL);
}
List<UserRole> userRoles = user.getRoles(); List<UserRole> userRoles = user.getRoles();
AtomicBoolean hit = new AtomicBoolean(false); AtomicBoolean hit = new AtomicBoolean(false);
// 遍历旧关系表 // 遍历旧关系表
......
...@@ -47,7 +47,7 @@ channel.index.application.name=brandkbs2 ...@@ -47,7 +47,7 @@ channel.index.application.name=brandkbs2
hqd.groupAll.url= https://sensitive.zhiweidata.com/sensitive/planA/groupAll hqd.groupAll.url= https://sensitive.zhiweidata.com/sensitive/planA/groupAll
#\u6807\u6CE8\u4E2D\u95F4\u4EF6 #\u6807\u6CE8\u4E2D\u95F4\u4EF6
mark.registry.address=zookeeper://192.168.0.11:2181?backup=192.168.0.30:2181,192.168.0.35:2181 mark.registry.address=zookeeper://192.168.0.11:2181?backup=192.168.0.30:2181,192.168.0.35:2181
mark.provider.group=zhiwei-mark-local-liuyu mark.provider.group=zhiwei-mark-test_liuyu
#\u7528\u6237\u4E2D\u5FC3 #\u7528\u6237\u4E2D\u5FC3
auth.center.client.consumer.group=zhiwei-auth-dev-liuyu auth.center.client.consumer.group=zhiwei-auth-dev-liuyu
auth.center.client.registry.address=zookeeper://192.168.0.11:2181?backup=192.168.0.30:2181,192.168.0.35:2181 auth.center.client.registry.address=zookeeper://192.168.0.11:2181?backup=192.168.0.30:2181,192.168.0.35:2181
......
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