Commit d961690e by shenjunjie

接口命名规范调整

parent 7d0bd200
......@@ -5,7 +5,7 @@ import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.UserInfo;
import com.zhiwei.brandkbs2.service.IUserService;
import com.zhiwei.brandkbs2.service.UserService;
import com.zhiwei.middleware.auth.util.JwtUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
......@@ -40,7 +40,7 @@ public class AuthAspect {
private String jwtKey;
@Resource(name = "userServiceImpl")
private IUserService iUserService;
private UserService UserService;
@Pointcut("execution(com.zhiwei.brandkbs2.model.ResponseResult com.zhiwei.brandkbs2.controller..*.*(..))")
// @Pointcut("within(com.zhiwei.brandkbs2.controller..*)")
......@@ -73,7 +73,7 @@ public class AuthAspect {
return unAuthenticatedResponse(response, noAuth, joinPoint);
}
String uid = tokenInfo.get(GenericAttribute.USER_ID).toString();
UserInfo userInfo = iUserService.queryUserInfo(uid, request.getHeader("pid"));
UserInfo userInfo = UserService.queryUserInfo(uid, request.getHeader("pid"));
if (!noAuth && null == userInfo) {
return unAuthoriseResponse(response);
}
......
package com.zhiwei.brandkbs2.common;
import com.zhiwei.brandkbs2.service.ISystemInfoService;
import com.zhiwei.brandkbs2.service.SystemInfoService;
import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import com.zhiwei.qbjc.bean.pojo.common.Tag;
import org.apache.logging.log4j.LogManager;
......@@ -26,7 +26,7 @@ public class GlobalPojo {
public static final Logger log = LogManager.getLogger(GlobalPojo.class);
@Resource(name = "systemInfoServiceImpl")
private ISystemInfoService systemInfoService;
private SystemInfoService systemInfoService;
/**
* 监测系统平台
......
......@@ -8,6 +8,7 @@ package com.zhiwei.brandkbs2.config;
*/
public class Constant {
public static final String HOUR_PATTERN = "yyyy-MM-dd HH";
public static final String DAY_PATTERN = "yyyy-MM-dd";
/**
......
......@@ -4,8 +4,9 @@ import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import com.zhiwei.brandkbs2.service.IMarkDataService;
import com.zhiwei.brandkbs2.service.IReportService;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -27,10 +28,13 @@ import javax.annotation.Resource;
public class AppArticleController extends BaseController {
@Resource(name = "markDataServiceImpl")
IMarkDataService markDataService;
MarkDataService markDataService;
@Resource(name = "reportServiceImpl")
IReportService reportService;
ReportService reportService;
@Resource(name = "commonServiceImpl")
CommonService commonService;
@ApiOperation("舆情列表")
@PostMapping("/mark/list")
......@@ -62,7 +66,7 @@ public class AppArticleController extends BaseController {
return ResponseResult.success(markDataService.getMarkSpread(startTime, endTime, true));
}
@ApiOperation("舆情分析-平台曝光对比")
@ApiOperation("舆情分析-品牌曝光对比")
@ApiImplicitParams({
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "long")
......@@ -102,12 +106,16 @@ public class AppArticleController extends BaseController {
return ResponseResult.success(markDataService.getMarkHighWord(startTime, endTime));
}
@ApiOperation("舆情分析-获取默认时间")
@GetMapping("/default/time")
public ResponseResult getDefaultTime() {
return ResponseResult.success(commonService.getTimeRangeMonth());
}
@ApiOperation("舆情简报-分类统计")
@GetMapping("/aggCount")
public ResponseResult getReportsAggCount() {
return ResponseResult.success(reportService.getReportsAggCount());
}
}
......@@ -3,8 +3,8 @@ package com.zhiwei.brandkbs2.controller;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.ICommonService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.middleware.mark.pojo.enums.TagField;
import com.zhiwei.middleware.mark.vo.MarkerTag;
import io.swagger.annotations.Api;
......@@ -33,10 +33,10 @@ import java.util.stream.Collectors;
public class CommonController extends BaseController {
@Resource(name = "commonServiceImpl")
ICommonService commonService;
CommonService commonService;
@Resource(name = "projectServiceImpl")
IProjectService projectService;
ProjectService projectService;
@ApiOperation("获取情感倾向标签信息")
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目ID", required = true, paramType = "path", dataType = "string")
......@@ -67,4 +67,18 @@ public class CommonController extends BaseController {
return ResponseResult.success(projectService.getUserAllProjects());
}
// @ApiOperation("获取默认月间隔时间节点")
// @GetMapping("/time/month")
// @Auth(role = RoleEnum.CUSTOMER)
// public ResponseResult getTimeRangeMonth() {
// return ResponseResult.success(commonService.getTimeRangeMonth());
// }
//
// @ApiOperation("获取默认周间隔时间节点")
// @GetMapping("/time/week")
// @Auth(role = RoleEnum.CUSTOMER)
// public ResponseResult getTimeRangeWeek() {
// return ResponseResult.success(commonService.getTimeRangeWeek());
// }
}
......@@ -5,8 +5,8 @@ import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.IUserService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -36,15 +36,15 @@ public class LoginController extends BaseController {
private int jwtHour;
@Resource(name = "userServiceImpl")
private IUserService iUserService;
private UserService UserService;
@Resource(name = "projectServiceImpl")
private IProjectService iProjectService;
private ProjectService ProjectService;
@ApiOperation("用户登录")
@PostMapping("/user/login")
public ResponseResult login() {
return ResponseResult.success(iUserService.login().toMap());
return ResponseResult.success(UserService.login().toMap());
}
@ApiOperation("用户信息获取")
......@@ -59,7 +59,7 @@ public class LoginController extends BaseController {
@ApiImplicitParam(name = "username", value = "用户名", required = false, paramType = "query", dataType = "string"))
@PostMapping("/user/bind/reset")
public ResponseResult resetBind(@RequestBody JSONObject json) {
iUserService.resetBind(json.getString("username"));
UserService.resetBind(json.getString("username"));
return ResponseResult.success();
}
......@@ -71,25 +71,25 @@ public class LoginController extends BaseController {
public ResponseResult bindUser(@RequestBody JSONObject json) {
String username = json.getString("username");
String password = json.getString("password");
return ResponseResult.success(iUserService.bindUser(username, password));
return ResponseResult.success(UserService.bindUser(username, password));
}
@ApiOperation("跳过绑定(赋默认权限)")
@PostMapping("/user/bind/skip")
public ResponseResult skipBindUser() {
return ResponseResult.success(iUserService.skipBindUser());
return ResponseResult.success(UserService.skipBindUser());
}
@ApiOperation("校验用户是否已有绑定关系")
@GetMapping("/user/login/checkBind")
public ResponseResult checkBind() {
return ResponseResult.success(iUserService.checkUserRoles());
return ResponseResult.success(UserService.checkUserRoles());
}
@ApiOperation("获取当前用户拥有的所有项目(含过期)")
@GetMapping("/user/login/getUserAllProjects")
public ResponseResult getLoginUserAllProjects() {
return ResponseResult.success(iProjectService.getLoginUserAllProjects());
return ResponseResult.success(ProjectService.getLoginUserAllProjects());
}
@ApiOperation("测试接口")
......
......@@ -7,8 +7,8 @@ import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.Behavior;
import com.zhiwei.brandkbs2.service.IBehaviorService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -55,10 +55,10 @@ public class ArticleController extends BaseController {
private RestTemplate restTemplate;
@javax.annotation.Resource(name = "behaviorServiceImpl")
private IBehaviorService behaviorService;
private BehaviorService behaviorService;
@javax.annotation.Resource(name = "projectServiceImpl")
private IProjectService projectService;
private ProjectService projectService;
private static final Behavior.Operation OPERATION = new Behavior.Operation("稿件上传", true);
......
......@@ -10,9 +10,9 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.TagFilterDTO;
import com.zhiwei.brandkbs2.pojo.vo.ProjectVO;
import com.zhiwei.brandkbs2.service.IHighWordService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.ITagFilterService;
import com.zhiwei.brandkbs2.service.HighWordService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.TagFilterService;
import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -37,13 +37,13 @@ import java.util.List;
public class BaseModuleController extends BaseController {
@Resource(name = "tagFilterServiceImpl")
ITagFilterService tagFilterService;
TagFilterService tagFilterService;
@Resource(name = "highWordServiceImpl")
IHighWordService highWordService;
HighWordService highWordService;
@Resource(name = "projectServiceImpl")
IProjectService projectService;
ProjectService projectService;
@ApiOperation("获取在用筛选器列表")
@GetMapping("/tagFilter")
......
......@@ -7,8 +7,8 @@ import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportBehaviorDTO;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.IBehaviorService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.ProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -34,10 +34,10 @@ import java.util.List;
public class BehaviorController extends BaseController {
@Resource(name = "behaviorServiceImpl")
private IBehaviorService behaviorService;
private BehaviorService behaviorService;
@Resource(name = "projectServiceImpl")
private IProjectService iProjectService;
private ProjectService ProjectService;
@ApiOperation("分页查询用户行为列表")
@ApiImplicitParams({
......@@ -72,7 +72,7 @@ public class BehaviorController extends BaseController {
@RequestParam(value = "behavior", defaultValue = "true") boolean behavior) {
List<ExportBehaviorDTO> downloadList = behaviorService.download(startTime, endTime, behavior);
String behaviorName = behavior ? "后台" : "前台";
String sheetName = iProjectService.getProjectVOById(UserThreadLocal.getProjectId()).getProjectName() + "_" + behaviorName;
String sheetName = ProjectService.getProjectVOById(UserThreadLocal.getProjectId()).getProjectName() + "_" + behaviorName;
EasyExcelUtil.download(sheetName + "用户行为", sheetName, ExportBehaviorDTO.class, downloadList, response);
return ResponseResult.success();
}
......
......@@ -12,8 +12,8 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.ChannelDTO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.IChannelService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -41,10 +41,10 @@ import java.util.stream.Collectors;
public class ChannelController extends BaseController {
@Resource(name = "channelServiceImpl")
IChannelService channelService;
ChannelService channelService;
@Resource(name = "projectServiceImpl")
IProjectService projectService;
ProjectService projectService;
@Value("${brandkbs.img.url}")
private String brandkbsImgPath;
......
......@@ -6,8 +6,8 @@ import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.Behavior;
import com.zhiwei.brandkbs2.service.IBehaviorService;
import com.zhiwei.brandkbs2.service.ICustomTagService;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.CustomTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -33,10 +33,10 @@ import static com.alibaba.fastjson.JSON.parseArray;
public class CustomTagController extends BaseController {
@Resource(name = "customTagServiceImpl")
private ICustomTagService customTagService;
private CustomTagService customTagService;
@Resource(name = "behaviorServiceImpl")
private IBehaviorService behaviorService;
private BehaviorService behaviorService;
private static final Behavior.Operation OPERATION = new Behavior.Operation("自定义标签管理", true);
......
......@@ -15,8 +15,8 @@ import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.EventVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.pojo.vo.YqEventSearchVO;
import com.zhiwei.brandkbs2.service.IBehaviorService;
import com.zhiwei.brandkbs2.service.IEventService;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.EventService;
import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -47,10 +47,10 @@ import java.util.Set;
public class EventController extends BaseController {
@Resource(name = "eventServiceImpl")
private IEventService iEventService;
private EventService EventService;
@Resource(name = "behaviorServiceImpl")
private IBehaviorService behaviorService;
private BehaviorService behaviorService;
private static final Behavior.Operation OPERATION = new Behavior.Operation("事件管理", true);
......@@ -64,13 +64,13 @@ public class EventController extends BaseController {
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目组id", paramType = "query", dataType = "string")
@GetMapping("/yq/tag")
public ResponseResult searchCriteria(@RequestParam(value = "linkedGroupId") String linkedGroupId) {
return ResponseResult.success(iEventService.findEventTagListAll(linkedGroupId));
return ResponseResult.success(EventService.findEventTagListAll(linkedGroupId));
}
@ApiOperation("分页查询舆情事件列表")
@PostMapping("/yq/list")
public ResponseResult findYqEventList(@RequestBody YqEventSearchVO yqEventSearchVO) {
PageVO<JSONObject> yqEventList = iEventService.findYqEventList(yqEventSearchVO);
PageVO<JSONObject> yqEventList = EventService.findYqEventList(yqEventSearchVO);
return ResponseResult.success(yqEventList);
}
......@@ -87,27 +87,27 @@ public class EventController extends BaseController {
@RequestParam(value = "linkedGroupId") String linkedGroupId,
@RequestParam(value = "keyword", defaultValue = "") String keyword,
@RequestParam(value = "sorter", defaultValue = "{\"startTime\":\"descend\"}") String sorter) {
return ResponseResult.success(iEventService.findEventList(page, size, linkedGroupId, keyword, sorter));
return ResponseResult.success(EventService.findEventList(page, size, linkedGroupId, keyword, sorter));
}
@ApiOperation("获取单个事件信息")
@ApiImplicitParam(name = "eventId", value = "事件ID", required = true, paramType = "path", dataType = "string")
@GetMapping("/get/{eventId}")
public ResponseResult getEvent(@PathVariable("eventId") String eventId) {
return ResponseResult.success(iEventService.getEventJSONByEventId(eventId));
return ResponseResult.success(EventService.getEventJSONByEventId(eventId));
}
@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 = "eventId", value = "事件ID", required = true, paramType = "query", dataType = "string")})
@GetMapping("/data/get")
public ResponseResult getEventDatas(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam(value = "eventId") String eventId) {
return ResponseResult.success(iEventService.getEventDatas(page, size, eventId));
return ResponseResult.success(EventService.getEventDatas(page, size, eventId));
}
@ApiOperation("修改事件信息")
@PutMapping("/update")
public ResponseResult updateEvent(@RequestBody EventVO eventVO) {
iEventService.updateEvent(eventVO);
EventService.updateEvent(eventVO);
behaviorService.pushBehavior(OPERATION, "修改事件信息:" + eventVO.getId(), request);
return ResponseResult.success();
}
......@@ -115,7 +115,7 @@ public class EventController extends BaseController {
@ApiOperation("修改事件首发信息")
@PutMapping("/updateFirst")
public ResponseResult updateEventFirst(@RequestBody EventDataDTO eventDataDTO) {
iEventService.updateEventFirst(eventDataDTO);
EventService.updateEventFirst(eventDataDTO);
behaviorService.pushBehavior(OPERATION, "修改事件首发信息:" + eventDataDTO.getEventId(), request);
return ResponseResult.success();
}
......@@ -124,7 +124,7 @@ public class EventController extends BaseController {
@ApiImplicitParam(name = "eventIds", value = "事件ID集合", paramType = "body", dataType = "list")
@PostMapping("/analyze")
public ResponseResult analysisEvents(@RequestBody JSONObject info) {
iEventService.analysisEvents(info.getJSONArray("eventIds").toJavaList(String.class));
EventService.analysisEvents(info.getJSONArray("eventIds").toJavaList(String.class));
behaviorService.pushBehavior(OPERATION, "批量更新事件", request);
return ResponseResult.success();
}
......@@ -133,7 +133,7 @@ public class EventController extends BaseController {
@ApiImplicitParam(name = "eventId", value = "事件ID", required = true, paramType = "path", dataType = "string")
@PutMapping("/end/{eventId}")
public ResponseResult endEvent(@PathVariable("eventId") String eventId) {
iEventService.endEvent(eventId);
EventService.endEvent(eventId);
behaviorService.pushBehavior(OPERATION, "结束事件:" + eventId, request);
return ResponseResult.success();
}
......@@ -142,7 +142,7 @@ public class EventController extends BaseController {
@ApiImplicitParam(name = "eventId", value = "事件ID", required = true, paramType = "path", dataType = "string")
@DeleteMapping("/delete/{eventId}")
public ResponseResult deleteEvent(@PathVariable("eventId") String eventId) {
String title = iEventService.deleteEvent(eventId);
String title = EventService.deleteEvent(eventId);
behaviorService.pushBehavior(OPERATION, "删除事件:" + title, request);
return ResponseResult.success();
}
......@@ -153,7 +153,7 @@ public class EventController extends BaseController {
public ResponseResult deleteEventData(@RequestBody JSONObject info) {
String id = info.getString("id");
String eventId = info.getString("eventId");
String title = iEventService.deleteEventData(id, eventId);
String title = EventService.deleteEventData(id, eventId);
behaviorService.pushBehavior(OPERATION, "删除事件单条数据,eventId:" + eventId + ",数据id:" + id + ",事件标题:" + title, request);
return ResponseResult.success();
}
......@@ -172,14 +172,14 @@ public class EventController extends BaseController {
@ApiOperation("事件上传进度获取")
@GetMapping("data/upload/progress/{ticket}")
public ResponseResult getEventDataUploadProgress(@PathVariable String ticket) {
return ResponseResult.success(iEventService.getEventDataUploadProgress(ticket));
return ResponseResult.success(EventService.getEventDataUploadProgress(ticket));
}
@ApiOperation("事件数据上传进度获取")
@ApiImplicitParams(@ApiImplicitParam(name = "eventIds", value = "事件id列表", paramType = "body", dataType = "list"))
@PostMapping("analyze/progress")
public ResponseResult getEventAnalyzeProgress(@RequestBody JSONObject info) {
return ResponseResult.success(iEventService.getEventAnalyzeProgress(info.getJSONArray("eventIds").toJavaList(String.class)));
return ResponseResult.success(EventService.getEventAnalyzeProgress(info.getJSONArray("eventIds").toJavaList(String.class)));
}
@ApiOperation("事件上传模板下载")
......@@ -202,7 +202,7 @@ public class EventController extends BaseController {
@ApiImplicitParam(name = "linkedGroupId", value = "关联项目组id", required = true, paramType = "query", dataType = "string")
@GetMapping("/download")
public ResponseResult downloadEvents(@RequestParam("linkedGroupId") String linkedGroupId) {
Pair<String, List<ExportEventDTO>> result = iEventService.downloadEvents(linkedGroupId);
Pair<String, List<ExportEventDTO>> result = EventService.downloadEvents(linkedGroupId);
String fileName = result.getLeft();
EasyExcelUtil.download(fileName + "_事件列表数据", fileName, ExportEventDTO.class, result.getRight(), response);
return ResponseResult.success();
......@@ -212,7 +212,7 @@ public class EventController extends BaseController {
@ApiImplicitParam(name = "eventId", value = "事件ID", required = true, paramType = "query", dataType = "string")
@GetMapping("/data/download")
public ResponseResult downloadEventDatas(@RequestParam("eventId") String eventId) {
Pair<String, List<ExportEventDataDTO>> result = iEventService.downloadEventDatas(eventId);
Pair<String, List<ExportEventDataDTO>> result = EventService.downloadEventDatas(eventId);
String title = result.getLeft();
EasyExcelUtil.download(title, title, ExportEventDataDTO.class, result.getRight(), response);
return ResponseResult.success();
......@@ -224,7 +224,7 @@ public class EventController extends BaseController {
public ResponseResult addEventsByYq(@RequestBody JSONObject info) {
String linkedGroupId = info.getString("linkedGroupId");
List<YqEventDTO> yqEventList = info.getJSONArray("list").toJavaList(YqEventDTO.class);
iEventService.addYqEvents(linkedGroupId, yqEventList);
EventService.addYqEvents(linkedGroupId, yqEventList);
behaviorService.pushBehavior(OPERATION, "批量导入舆情事件数据", request);
return ResponseResult.success();
}
......@@ -232,7 +232,7 @@ public class EventController extends BaseController {
@ApiOperation("按搜索条件全部导入舆情事件数据")
@PutMapping("/upload/yqAll")
public ResponseResult addEventAllByYq(@RequestBody YqEventSearchVO yqEventSearchVO) {
iEventService.addYqEventAll(yqEventSearchVO);
EventService.addYqEventAll(yqEventSearchVO);
behaviorService.pushBehavior(OPERATION, "全部导入舆情事件数据", request);
return ResponseResult.success();
}
......@@ -242,7 +242,7 @@ public class EventController extends BaseController {
@PostMapping(value = "/upload/file", headers = "content-type=multipart/form-data")
@Auth(role = RoleEnum.SUPER_ADMIN)
public ResponseResult addEventsByFile(@RequestParam(value = "linkedGroupId") String linkedGroupId, @RequestParam("fileUrl") String fileUrl) {
iEventService.addFileEvents(linkedGroupId, fileUrl);
EventService.addFileEvents(linkedGroupId, fileUrl);
behaviorService.pushBehavior(OPERATION, "文件上传事件", request);
return ResponseResult.success();
}
......@@ -252,7 +252,7 @@ public class EventController extends BaseController {
"linkedGroupId", value = "关联项目id", paramType = "form", dataType = "string")})
@PostMapping(value = "/data/upload", headers = "content-type=multipart/form-data")
public ResponseResult uploadEventDatas(@RequestParam("linkedGroupId") String linkedGroupId, @RequestParam("file") MultipartFile file) {
iEventService.uploadEventDatas(linkedGroupId, file);
EventService.uploadEventDatas(linkedGroupId, file);
behaviorService.pushBehavior(OPERATION, "事件数据上传", request);
return ResponseResult.success();
}
......@@ -261,13 +261,13 @@ public class EventController extends BaseController {
@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")})
@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) {
return ResponseResult.success(iEventService.findEventTagList(page, size, linkedGroupId, tagGroupName));
return ResponseResult.success(EventService.findEventTagList(page, size, linkedGroupId, tagGroupName));
}
@ApiOperation("查询所有事件标签组名")
@GetMapping("/tag/groupName")
public ResponseResult findEventTagGroupName(@RequestParam(value = "linkedGroupId") String linkedGroupId) {
return ResponseResult.success(iEventService.findEventTagGroupName(linkedGroupId));
return ResponseResult.success(EventService.findEventTagGroupName(linkedGroupId));
}
}
......@@ -11,9 +11,9 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.Behavior;
import com.zhiwei.brandkbs2.pojo.vo.ProjectVO;
import com.zhiwei.brandkbs2.service.IBehaviorService;
import com.zhiwei.brandkbs2.service.ICommonService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.mark.vo.MarkerTag;
import io.swagger.annotations.Api;
......@@ -50,13 +50,13 @@ public class ProjectController extends BaseController {
private RestTemplate restTemplate;
@Resource(name = "projectServiceImpl")
private IProjectService iProjectService;
private ProjectService ProjectService;
@Resource(name = "behaviorServiceImpl")
private IBehaviorService behaviorService;
private BehaviorService behaviorService;
@Resource(name = "commonServiceImpl")
private ICommonService commonService;
private CommonService commonService;
private static final Behavior.Operation OPERATION = new Behavior.Operation("项目管理", true);
......@@ -75,7 +75,7 @@ public class ProjectController extends BaseController {
@ApiOperation("添加项目配置")
@PostMapping("/add")
public ResponseResult addProject(@RequestBody ProjectVO projectVO) {
iProjectService.addProject(projectVO);
ProjectService.addProject(projectVO);
behaviorService.pushBehavior(OPERATION, "添加项目配置:" + projectVO.getId(), request);
return ResponseResult.success();
}
......@@ -85,14 +85,14 @@ public class ProjectController extends BaseController {
@ApiImplicitParam(name = "size", value = "每页记录数", required = false, defaultValue = "10", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "keyword", value = "搜索关键字", required = false, defaultValue = "", paramType = "query", dataType = "string")})
@GetMapping("/list")
public ResponseResult findProjectList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam(value = "keyword", defaultValue = "") String keyword) {
return ResponseResult.success(iProjectService.findProjectList(page, size, keyword));
return ResponseResult.success(ProjectService.findProjectList(page, size, keyword));
}
@ApiOperation("修改项目")
@PutMapping("/update")
public ResponseResult updateProject(@RequestBody ProjectVO projectVO) {
iProjectService.updateProject(projectVO);
ProjectService.updateProject(projectVO);
behaviorService.pushBehavior(OPERATION, "修改项目:" + projectVO.getId(), request);
return ResponseResult.success();
}
......@@ -101,7 +101,7 @@ public class ProjectController extends BaseController {
@ApiImplicitParam(name = "pid", value = "项目ID", required = true, paramType = "path", dataType = "string")
@DeleteMapping("/delete/{pid}")
public ResponseResult deleteProject(@PathVariable("pid") String pid) {
iProjectService.deleteProject(pid, UserThreadLocal.getProjectId());
ProjectService.deleteProject(pid, UserThreadLocal.getProjectId());
behaviorService.pushBehavior(OPERATION, "删除项目:" + pid, request);
return ResponseResult.success();
}
......@@ -110,7 +110,7 @@ public class ProjectController extends BaseController {
@ApiImplicitParam(name = "pid", value = "项目ID", required = true, paramType = "path", dataType = "string")
@PutMapping("/switch/projectShow/{pid}")
public ResponseResult switchProjectShow(@PathVariable String pid) {
boolean result = iProjectService.switchProjectShow(pid);
boolean result = ProjectService.switchProjectShow(pid);
if (result) {
behaviorService.pushBehavior(OPERATION, "切换项目展示状态:" + pid, request);
return ResponseResult.success();
......@@ -123,7 +123,7 @@ public class ProjectController extends BaseController {
@ApiImplicitParam(name = "pid", value = "项目ID", required = true, paramType = "path", dataType = "string")
@PutMapping("/switch/projectStart/{pid}")
public ResponseResult switchProjectStart(@PathVariable String pid) {
iProjectService.switchProjectStart(pid);
ProjectService.switchProjectStart(pid);
behaviorService.pushBehavior(OPERATION, "切换项目状态:" + pid, request);
return ResponseResult.success();
}
......@@ -132,7 +132,7 @@ public class ProjectController extends BaseController {
@ApiImplicitParam(name = "pid", value = "项目ID", required = true, paramType = "path", dataType = "string")
@GetMapping("/get/{pid}")
public ResponseResult getProjectVOById(@PathVariable("pid") String pid) {
return ResponseResult.success(iProjectService.getProjectVOById(pid));
return ResponseResult.success(ProjectService.getProjectVOById(pid));
}
@ApiOperation("图片上传")
......@@ -153,7 +153,7 @@ public class ProjectController extends BaseController {
@ApiImplicitParam(name = "pid", value = "项目ID", required = true, paramType = "path", dataType = "string")
@GetMapping("/download/keyword/{pid}")
public ResponseResult downloadArticles(@PathVariable("pid") String pid) {
ProjectVO project = iProjectService.getProjectVOById(pid);
ProjectVO project = ProjectService.getProjectVOById(pid);
EasyExcelUtil.download(project.getBrandName() + "_命中关键词", "sheet1", UploadKeywordDTO.class, UploadKeywordDTO.change2This(project.getHitKeywords()), response);
return ResponseResult.success();
}
......@@ -202,7 +202,7 @@ public class ProjectController extends BaseController {
@GetMapping("/user/getUserAllProjects")
@Auth(role = RoleEnum.CUSTOMER)
public ResponseResult getUserAllProjects() {
return ResponseResult.success(iProjectService.getUserAllProjects());
return ResponseResult.success(ProjectService.getUserAllProjects());
}
}
......@@ -4,7 +4,7 @@ import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.ReportSettingsDTO;
import com.zhiwei.brandkbs2.service.IReportService;
import com.zhiwei.brandkbs2.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
......@@ -24,7 +24,7 @@ import javax.annotation.Resource;
public class ReportController {
@Resource(name = "reportServiceImpl")
private IReportService reportService;
private ReportService reportService;
@ApiOperation("获取简报设置")
......
......@@ -6,8 +6,8 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.Behavior;
import com.zhiwei.brandkbs2.pojo.dto.UserDTO;
import com.zhiwei.brandkbs2.service.IBehaviorService;
import com.zhiwei.brandkbs2.service.IUserService;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.UserService;
import com.zhiwei.middleware.auth.pojo.CenterUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -31,10 +31,10 @@ import javax.annotation.Resource;
public class UserController extends BaseController {
@Resource(name = "userServiceImpl")
private IUserService iUserService;
private UserService UserService;
@Resource(name = "behaviorServiceImpl")
private IBehaviorService behaviorService;
private BehaviorService behaviorService;
private static final Behavior.Operation OPERATION = new Behavior.Operation("用户管理", true);
......@@ -55,7 +55,7 @@ public class UserController extends BaseController {
@RequestParam(value = "keyword", defaultValue = "") String keyword,
@RequestParam(value = "pid") String pid,
@RequestParam(value = "role", defaultValue = "-1") int role) {
return ResponseResult.success(iUserService.findUserList(page, size, keyword, pid, role));
return ResponseResult.success(UserService.findUserList(page, size, keyword, pid, role));
}
@ApiOperation("根据手机号搜索用户信息")
......@@ -77,7 +77,7 @@ public class UserController extends BaseController {
@ApiOperation("添加用户")
@PostMapping("/add")
public ResponseResult addUser(@RequestBody UserDTO userDTO) {
iUserService.addUser(userDTO);
UserService.addUser(userDTO);
behaviorService.pushBehavior(OPERATION, "添加用户:" + userDTO.getId(), request);
return ResponseResult.success();
}
......@@ -89,7 +89,7 @@ public class UserController extends BaseController {
@DeleteMapping("/delete")
@Auth(role = RoleEnum.ADMIN)
public ResponseResult deleteUser(@RequestParam(value = "uid") String userId, @RequestParam(value = "pid") String pid) {
iUserService.deleteUser(userId, pid);
UserService.deleteUser(userId, pid);
behaviorService.pushBehavior(OPERATION, "删除用户:" + userId, request);
return ResponseResult.success();
}
......@@ -97,7 +97,7 @@ public class UserController extends BaseController {
@ApiOperation("编辑用户")
@PutMapping("/update")
public ResponseResult updateUser(@RequestBody UserDTO userDTO) {
iUserService.updateUser(userDTO);
UserService.updateUser(userDTO);
behaviorService.pushBehavior(OPERATION, "编辑用户:" + userDTO, request);
return ResponseResult.success();
}
......@@ -113,14 +113,14 @@ public class UserController extends BaseController {
public ResponseResult findSuperAdminList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "size", defaultValue = "10") int size,
@RequestParam(value = "keyword", defaultValue = "") String keyword) {
return ResponseResult.success(iUserService.findSuperAdminList(page, size, keyword));
return ResponseResult.success(UserService.findSuperAdminList(page, size, keyword));
}
@ApiOperation("添加超级管理员")
@PostMapping("/add/superAdmin")
@Auth(role = RoleEnum.SUPER_ADMIN)
public ResponseResult addSuperAdmin(@RequestBody UserDTO userDTO) {
iUserService.addSuperAdmin(userDTO);
UserService.addSuperAdmin(userDTO);
behaviorService.pushBehavior(OPERATION, "添加超级管理员:" + userDTO.getId(), request);
return ResponseResult.success();
}
......@@ -131,7 +131,7 @@ public class UserController extends BaseController {
@DeleteMapping("/delete/superAdmin")
@Auth(role = RoleEnum.SUPER_ADMIN)
public ResponseResult deleteSuperAdmin(@RequestParam(value = "uid") String userId) {
iUserService.deleteSuperAdmin(userId);
UserService.deleteSuperAdmin(userId);
behaviorService.pushBehavior(OPERATION, "删除超级管理员:" + userId, request);
return ResponseResult.success();
}
......
......@@ -3,7 +3,7 @@ package com.zhiwei.brandkbs2.easyexcel.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadEventDTO;
import com.zhiwei.brandkbs2.service.IEventService;
import com.zhiwei.brandkbs2.service.EventService;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
......@@ -25,12 +25,12 @@ public class EventFileListener extends AnalysisEventListener<UploadEventDTO> {
* 储存解析数据集合
*/
private final List<UploadEventDTO> datas = new ArrayList<>(BATCH_COUNT);
private final IEventService iEventService;
private final EventService EventService;
private final String projectId;
private final String linkedGroupId;
public EventFileListener(IEventService iEventService, String projectId, String linkedGroupId) {
this.iEventService = iEventService;
public EventFileListener(EventService EventService, String projectId, String linkedGroupId) {
this.EventService = EventService;
this.projectId = projectId;
this.linkedGroupId = linkedGroupId;
}
......@@ -65,6 +65,6 @@ public class EventFileListener extends AnalysisEventListener<UploadEventDTO> {
* 保存更新事件信息逻辑
*/
private void addFileEvent() {
datas.forEach(eventDTO -> iEventService.addFileEvent(projectId, linkedGroupId, eventDTO));
datas.forEach(eventDTO -> EventService.addFileEvent(projectId, linkedGroupId, eventDTO));
}
}
......@@ -37,6 +37,11 @@ public class MarkFlowEntity {
private JSONObject type;
/**
* 信息字段
*/
private JSONObject info;
/**
* 消息内容
*/
private Object data;
......@@ -82,6 +87,7 @@ public class MarkFlowEntity {
CompleteText completeText = CompleteText.restoreFromEs(tJson);
this.type = FlowEntityUtil.getCompleteTextType(completeText);
this.data = completeText;
this.info = createInfoWithEmotion(tJson);
break;
case INCOMPLETE:
if (!Tools.isEmpty(tJson.get("ind_full_text"))) {
......@@ -90,6 +96,7 @@ public class MarkFlowEntity {
IncompleteText incompleteText = IncompleteText.restoreFromEs(tJson);
this.type = FlowEntityUtil.getIncompleteTextType(incompleteText);
this.data = incompleteText;
this.info = createInfoWithEmotion(tJson);
break;
case QA:
if (!Tools.isEmpty(tJson.get("ind_full_text"))) {
......@@ -104,6 +111,7 @@ public class MarkFlowEntity {
QAText qaText = QAText.restoreFromEs(tJson);
this.type = FlowEntityUtil.getQaTextType(qaText);
this.data = qaText;
this.info = createInfoWithEmotion(tJson);
break;
case VIDEO:
if (!Tools.isEmpty(tJson.get("ind_full_text"))) {
......@@ -115,10 +123,23 @@ public class MarkFlowEntity {
Video video = Video.restoreFromEs(tJson);
this.type = FlowEntityUtil.getVideoType(video);
this.data = video;
this.info = createInfoWithEmotion(tJson);
break;
default:
break;
}
}
private JSONObject createInfoWithEmotion(JSONObject tJson) {
JSONObject info = new JSONObject();
String emotion = Tools.getEmotion(tJson);
if (null == emotion) {
info.put("hasTag", false);
return info;
}
info.put("hasTag", true);
info.put("showEmotion", emotion);
return info;
}
}
......@@ -10,7 +10,7 @@ import java.util.Map;
/**
* @ClassName: EventSearchDto
* @Description TODO
* @Description EventSearchDto
* @author: sjj
* @date: 2022-05-20 14:07
*/
......
......@@ -9,12 +9,12 @@ import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @ClassName: IBehaviorService
* @ClassName: BehaviorService
* @Description 用户行为业务接口
* @author: sjj
* @date: 2022-05-27 11:05
*/
public interface IBehaviorService {
public interface BehaviorService {
/**
* 添加用户行为
*
......
......@@ -9,7 +9,7 @@ import com.zhiwei.brandkbs2.pojo.BrandkbsTask;
* @description 定时任务业务接口
* @date 2019/12/12 13:58
*/
public interface IBrandkbsTaskService {
public interface BrandkbsTaskService {
/**
* 根据任务名称获取任务
*
......
......@@ -10,12 +10,12 @@ import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List;
/**
* @ClassName: IChannelService
* @Description IChannelService
* @ClassName: ChannelService
* @Description ChannelService
* @author: sjj
* @date: 2022-06-16 16:00
*/
public interface IChannelService {
public interface ChannelService {
/**
* 根据搜索条件查询渠道列表
......
......@@ -12,7 +12,7 @@ import java.util.List;
* @author: sjj
* @date: 2022-06-02 11:22
*/
public interface ICommonService {
public interface CommonService {
/**
* 获取qbjcTags
......@@ -34,13 +34,20 @@ public interface ICommonService {
/**
* 获取qbjcPlatform名称
*
* @return 平台名称
*/
List<String> getQbjcPlatformNames();
/**
* 获取qbjcPlatform
*
* @return 平台
*/
List<JSONObject> getQbjcPlatform(String... includeFields);
Long[] getTimeRangeMonth();
Long[] getTimeRangeWeek();
}
......@@ -12,7 +12,7 @@ import java.util.List;
* @description 自定义标签业务接口
* @date 2022年3月24日15:20:16
*/
public interface ICustomTagService {
public interface CustomTagService {
/**
* 分页查询该项目所有自定义标签数据
......
......@@ -3,12 +3,12 @@ package com.zhiwei.brandkbs2.service;
import com.zhiwei.brandkbs2.pojo.Event;
/**
* @ClassName: IEventDataService
* @ClassName: EventDataService
* @Description 事件数据业务接口抽象类
* @author: sjj
* @date: 2022-05-23 17:48
*/
public interface IEventDataService {
public interface EventDataService {
/**
* 更新事件数据
......
......@@ -16,12 +16,12 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @ClassName: IEventService
* @ClassName: EventService
* @Description 事件管理业务接口
* @author: sjj
* @date: 2022-05-17 16:32
*/
public interface IEventService {
public interface EventService {
/**
* 根据事件id查询事件
......
......@@ -7,12 +7,12 @@ import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List;
/**
* @ClassName: IHighWordService
* @ClassName: HighWordService
* @Description 高频词服务接口
* @author: sjj
* @date: 2022-06-06 09:59
*/
public interface IHighWordService {
public interface HighWordService {
/**
* 分页查询高频词列表
......
......@@ -8,12 +8,12 @@ import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List;
/**
* @ClassName: IMarkDataService
* @ClassName: MarkDataService
* @Description: 标注数据服务抽象类
* @author: sjj
* @date: 2022-06-28 14:04
*/
public interface IMarkDataService {
public interface MarkDataService {
/**
* @param markSearchDTO 标注数据搜索传输类
......
......@@ -13,7 +13,7 @@ import java.util.List;
* @description 项目业务接口
* @date 2022年4月18日16:49:10
*/
public interface IProjectService {
public interface ProjectService {
/**
* 添加项目
......
......@@ -6,12 +6,12 @@ import com.zhiwei.brandkbs2.pojo.dto.ReportSettingsDTO;
import java.util.Map;
/**
* @ClassName: IReportService
* @ClassName: ReportService
* @Description 报告业务接口
* @author: sjj
* @date: 2022-05-31 18:00
*/
public interface IReportService {
public interface ReportService {
/**
* 获取项目报告配置信息
......
......@@ -6,12 +6,12 @@ import com.zhiwei.qbjc.bean.pojo.common.Tag;
import java.util.List;
/**
* @ClassName: ISystemInfoService
* @ClassName: SystemInfoService
* @Description 监测系统相关infoService
* @author: sjj
* @date: 2022-06-16 14:19
*/
public interface ISystemInfoService {
public interface SystemInfoService {
/**
* 获取监测系统Platforms
......
......@@ -10,7 +10,7 @@ import java.util.List;
* @author: sjj
* @date: 2022-06-01 13:40
*/
public interface ITagFilterService {
public interface TagFilterService {
/**
* 获取在用筛选器列表
......
package com.zhiwei.brandkbs2.service;
/**
* @ClassName: ITaskService
* @ClassName: TaskService
* @Description 定时服务抽象类
* @author: sjj
* @date: 2022-06-16 15:27
*/
public interface ITaskService{
public interface TaskService{
/**
* 渠道记录
......
......@@ -8,12 +8,12 @@ import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import java.util.List;
/**
* @ClassName: IUserService
* @ClassName: UserService
* @Description 用户管理服务接口
* @author: sjj
* @date: 2022-04-28 14:58
*/
public interface IUserService {
public interface UserService {
/**
* 用户登录
......
......@@ -11,7 +11,7 @@ import com.zhiwei.brandkbs2.pojo.User;
import com.zhiwei.brandkbs2.pojo.UserRole;
import com.zhiwei.brandkbs2.pojo.vo.BehaviorVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.IBehaviorService;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import com.zhiwei.brandkbs2.util.Tools;
import org.apache.commons.collections4.CollectionUtils;
......@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
* @date: 2022-05-27 13:41
*/
@Service("behaviorServiceImpl")
public class BehaviorServiceImpl implements IBehaviorService {
public class BehaviorServiceImpl implements BehaviorService {
public static final Logger log = LogManager.getLogger(BehaviorServiceImpl.class);
@Resource(name = "behaviorDao")
......
......@@ -3,7 +3,7 @@ package com.zhiwei.brandkbs2.service.impl;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.dao.IBrandkbsTaskDao;
import com.zhiwei.brandkbs2.pojo.BrandkbsTask;
import com.zhiwei.brandkbs2.service.IBrandkbsTaskService;
import com.zhiwei.brandkbs2.service.BrandkbsTaskService;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
......@@ -17,7 +17,7 @@ import java.util.Objects;
* @date: 2022-07-12 17:38
*/
@Service
public class BrandkbsTaskServiceImpl implements IBrandkbsTaskService {
public class BrandkbsTaskServiceImpl implements BrandkbsTaskService {
@Resource(name = "brandkbsTaskDao")
private IBrandkbsTaskDao brandkbsTaskDao;
......
......@@ -16,7 +16,7 @@ import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.pojo.dto.ChannelDTO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.IChannelService;
import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import com.zhiwei.brandkbs2.util.Tools;
import org.apache.commons.collections4.CollectionUtils;
......@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
* @date: 2022-06-16 16:07
*/
@Service("channelServiceImpl")
public class ChannelServiceImpl implements IChannelService {
public class ChannelServiceImpl implements ChannelService {
@Resource(name = "eventDataDao")
IEventDataDao eventDataDao;
......
package com.zhiwei.brandkbs2.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.service.ICommonService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.mark.pojo.enums.TagField;
import com.zhiwei.middleware.mark.service.MarkerClient;
import com.zhiwei.middleware.mark.vo.MarkerTag;
import com.zhiwei.middleware.mark.vo.TagSearch;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
......@@ -14,10 +18,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -27,13 +28,13 @@ import java.util.stream.Collectors;
* @date: 2022-06-02 11:23
*/
@Service("commonServiceImpl")
public class CommonServiceImpl implements ICommonService {
public class CommonServiceImpl implements CommonService {
@Value("${qbjc.platform.url}")
private String qbjcPlatformUrl;
@Resource(name = "projectServiceImpl")
private IProjectService projectService;
private ProjectService projectService;
@Autowired
private MarkerClient markClient;
......@@ -71,8 +72,7 @@ public class CommonServiceImpl implements ICommonService {
@Override
public List<String> getQbjcPlatformNames() {
HttpEntity<JSONObject> entity = restTemplate.getForEntity(qbjcPlatformUrl, JSONObject.class);
return Objects.requireNonNull(entity.getBody()).getJSONArray("data").toJavaList(JSONObject.class).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
......@@ -90,4 +90,18 @@ public class CommonServiceImpl implements ICommonService {
}).collect(Collectors.toList());
}
@Override
public Long[] getTimeRangeMonth() {
long endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
long startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
return new Long[]{startTime, endTime};
}
@Override
public Long[] getTimeRangeWeek() {
long endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
long startTime = DateUtils.addWeeks(new Date(endTime), -1).getTime();
return new Long[]{startTime, endTime};
}
}
......@@ -10,7 +10,7 @@ import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.CustomTag;
import com.zhiwei.brandkbs2.pojo.vo.CustomTagVo;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.ICustomTagService;
import com.zhiwei.brandkbs2.service.CustomTagService;
import org.apache.commons.collections.CollectionUtils;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.update.UpdateRequest;
......@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
* @date 2022年3月24日18:22:53
*/
@Service
public class CustomTagServiceImpl implements ICustomTagService {
public class CustomTagServiceImpl implements CustomTagService {
@Resource(name = "customTagDao")
private ICustomTagDao customTagDao;
......
......@@ -5,7 +5,7 @@ import com.zhiwei.brandkbs2.dao.IEventDataDao;
import com.zhiwei.brandkbs2.es.EsClientDao;
import com.zhiwei.brandkbs2.pojo.Event;
import com.zhiwei.brandkbs2.pojo.EventData;
import com.zhiwei.brandkbs2.service.IEventDataService;
import com.zhiwei.brandkbs2.service.EventDataService;
import com.zhiwei.brandkbs2.util.Tools;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
* @date: 2022-05-23 17:49
*/
@Service("eventDataServiceImpl")
public class EventDataServiceImpl implements IEventDataService {
public class EventDataServiceImpl implements EventDataService {
public static final Logger log = LogManager.getLogger(EventDataServiceImpl.class);
@Resource(name = "eventDao")
......
......@@ -26,9 +26,9 @@ import com.zhiwei.brandkbs2.pojo.dto.YqEventDTO;
import com.zhiwei.brandkbs2.pojo.vo.EventVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.pojo.vo.YqEventSearchVO;
import com.zhiwei.brandkbs2.service.IEventDataService;
import com.zhiwei.brandkbs2.service.IEventService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.EventDataService;
import com.zhiwei.brandkbs2.service.EventService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import com.zhiwei.brandkbs2.util.Tools;
import org.apache.commons.collections4.CollectionUtils;
......@@ -62,7 +62,7 @@ import java.util.stream.Collectors;
* @date: 2022-05-17 16:36
*/
@Service("eventServiceImpl")
public class EventServiceImpl implements IEventService {
public class EventServiceImpl implements EventService {
private static final Logger log = LogManager.getLogger(EventServiceImpl.class);
@Value("${qbjc.event.tag.url}")
......@@ -81,10 +81,10 @@ public class EventServiceImpl implements IEventService {
private IEventDataDao eventDataDao;
@Resource(name = "eventDataServiceImpl")
private IEventDataService eventDataService;
private EventDataService eventDataService;
@Resource(name = "projectServiceImpl")
private IProjectService projectService;
private ProjectService projectService;
@Resource(name = "mongoUtil")
private com.zhiwei.brandkbs2.util.MongoUtil mongoUtil;
......
......@@ -6,7 +6,7 @@ import com.zhiwei.brandkbs2.dao.IHighWordDao;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportHighWordDTO;
import com.zhiwei.brandkbs2.pojo.HighWord;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.IHighWordService;
import com.zhiwei.brandkbs2.service.HighWordService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
......@@ -23,7 +23,7 @@ import java.util.stream.Collectors;
* @date: 2022-06-06 10:02
*/
@Service("highWordServiceImpl")
public class HighWordServiceImpl implements IHighWordService {
public class HighWordServiceImpl implements HighWordService {
@Resource(name = "highWordDao")
IHighWordDao highWordDao;
......
......@@ -8,7 +8,6 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.common.RedisKeyPrefix;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.enmus.EmotionEnum;
import com.zhiwei.brandkbs2.enmus.ImportantChannelEnum;
import com.zhiwei.brandkbs2.es.EsClientDao;
......@@ -57,13 +56,10 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.zhiwei.brandkbs2.config.Constant.DAY_PATTERN;
/**
* @ClassName: MarkDataServiceImpl
* @Description
......@@ -71,23 +67,23 @@ import static com.zhiwei.brandkbs2.config.Constant.DAY_PATTERN;
* @date: 2022-06-28 14:07
*/
@Service("markDataServiceImpl")
public class MarkDataServiceImpl implements IMarkDataService {
public class MarkDataServiceImpl implements MarkDataService {
private static final Logger log = LogManager.getLogger(MarkDataServiceImpl.class);
@Resource(name = "projectServiceImpl")
private IProjectService projectService;
private ProjectService projectService;
@Resource(name = "esClientDao")
private EsClientDao esClientDao;
@Resource(name = "commonServiceImpl")
private ICommonService commonService;
private CommonService commonService;
@Resource(name = "customTagServiceImpl")
private ICustomTagService customTagService;
private CustomTagService customTagService;
@Resource(name = "tagFilterServiceImpl")
ITagFilterService tagFilterService;
TagFilterService tagFilterService;
@Autowired
private StringRedisTemplate stringRedisTemplate;
......@@ -124,7 +120,6 @@ public class MarkDataServiceImpl implements IMarkDataService {
linkedGroupId = projectService.getProjectVOById(UserThreadLocal.getProjectId()).getBrandLinkedGroupId();
}
JSONObject result = new JSONObject();
Date endDate = new Date();
// 搜索时间
result.put("times", Arrays.asList("今天", "24小时", "三天", "七天", "近30天"));
// 平台
......@@ -151,10 +146,9 @@ public class MarkDataServiceImpl implements IMarkDataService {
@Override
public JSONObject getAnalyzeSummary(Long startTime, Long endTime, boolean cache) {
try {
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
endTime = DateUtils.addDays(Tools.truncDate(new Date(), DAY_PATTERN), 1).getTime();
startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
}
Long[] timeRange = Tools.formatTimeRange(startTime, endTime);
startTime = timeRange[0];
endTime = timeRange[1];
String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId();
String redisKey = RedisKeyPrefix.MARK_ANALYZE_SUMMARY + Tools.concat(projectId, startTime, endTime);
......@@ -178,13 +172,21 @@ public class MarkDataServiceImpl implements IMarkDataService {
// 负面舆情峰值平台
platformsCount.stream().max(Comparator.comparing(o -> o.getInteger(EmotionEnum.NEGATIVE.getName()))).ifPresent(e -> result.put("negTopPlatform", e.getString("platform_id")));
// 获取时间段正面情感数据最多的标题
String posTopTitle = getMarkTopTitle(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, linkedGroupId, 1).get(0).getKey();
result.put("posTopTitle", posTopTitle);
String topTitle = "";
List<Map.Entry<String, Integer>> markTopTitle = getMarkTopTitle(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, linkedGroupId, 1);
if (!markTopTitle.isEmpty()) {
topTitle = markTopTitle.get(0).getKey();
}
result.put("posTopTitle", topTitle);
// 正面舆情峰值时间
markSpread.stream().max(Comparator.comparing(o -> o.getInteger("negNormalCount"))).ifPresent(e -> result.put("negMaxTime", e.getLong("time")));
// 获取时间段负面情感数据最多的标题
String negTopTitle = getMarkTopTitle(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, linkedGroupId, 1).get(0).getKey();
result.put("negTopTitle", negTopTitle);
topTitle = "";
List<Map.Entry<String, Integer>> negTopTitle = getMarkTopTitle(startTime, endTime, EmotionEnum.NEGATIVE.getName(), projectId, linkedGroupId, 1);
if (!negTopTitle.isEmpty()) {
topTitle = negTopTitle.get(0).getKey();
}
result.put("negTopTitle", topTitle);
List<JSONObject> articlePlatformProportion = getMarkPlatformProportion(startTime, endTime, projectId, linkedGroupId, true);
result.put("platformRank", articlePlatformProportion.stream().filter(articlePlatform -> articlePlatform.getLongValue("count") > 0).sorted((o1, o2) -> o2.getLong("count").compareTo(o1.getLong("count"))).collect(Collectors.toList()));
stringRedisTemplate.opsForValue().set(redisKey, JSON.toJSONString(result), 1, TimeUnit.HOURS);
......@@ -209,10 +211,9 @@ public class MarkDataServiceImpl implements IMarkDataService {
@Override
public JSONObject getMarkEmotionProportion(Long startTime, Long endTime, boolean cache) {
try {
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
}
Long[] timeRange = Tools.formatTimeRange(startTime, endTime);
startTime = timeRange[0];
endTime = timeRange[1];
String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId();
String redisKey = RedisKeyPrefix.MARK_EMOTION_PROPORTION + Tools.concat(projectId, startTime, endTime);
......@@ -244,10 +245,9 @@ public class MarkDataServiceImpl implements IMarkDataService {
@Override
public List<JSONObject> getMarkChannelProportion(Long startTime, Long endTime, boolean cache) {
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
}
Long[] timeRange = Tools.formatTimeRange(startTime, endTime);
startTime = timeRange[0];
endTime = timeRange[1];
String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId();
String redisKey = RedisKeyPrefix.MARK_CHANNEL_PROPORTION + Tools.concat(projectId, startTime, endTime);
......@@ -293,10 +293,9 @@ public class MarkDataServiceImpl implements IMarkDataService {
public List<JSONObject> getMarkPlatformProportion(Long startTime, Long endTime, boolean cache) {
List<JSONObject> res = null;
try {
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
}
Long[] timeRange = Tools.formatTimeRange(startTime, endTime);
startTime = timeRange[0];
endTime = timeRange[1];
String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId();
res = getMarkPlatformProportion(startTime, endTime, projectId, linkedGroupId, cache);
......@@ -309,10 +308,9 @@ public class MarkDataServiceImpl implements IMarkDataService {
@Override
public List<JSONObject> getMarkHighWord(Long startTime, Long endTime) {
try {
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
}
Long[] timeRange = Tools.formatTimeRange(startTime, endTime);
startTime = timeRange[0];
endTime = timeRange[1];
String projectId = UserThreadLocal.getProjectId();
String linkedGroupId = projectService.getProjectVOById(projectId).getBrandLinkedGroupId();
String redisKey = RedisKeyPrefix.MARK_HIGH_WORD + Tools.concat(projectId, startTime, endTime);
......@@ -482,8 +480,6 @@ public class MarkDataServiceImpl implements IMarkDataService {
int lastNeuCount = lastArticleEmotions.get(2).getIntValue("count");
int curArticleTotal = curPosCount + curNegCount + curNeuCount;
int oldArticleTotal = lastPosCount + lastNegCount + lastNeuCount;
result.put("startTime", startTime);
result.put("endTime", endTime);
result.put("articlesCount", curArticleTotal);
result.put("compare", oldArticleTotal == 0 ? 0d : curArticleTotal / (double) oldArticleTotal);
result.put("posProportion", curPosCount * 1.0 / curArticleTotal);
......@@ -515,15 +511,13 @@ public class MarkDataServiceImpl implements IMarkDataService {
String[] fieldSearch = "标题".equals(searchField) ? new String[]{GenericAttribute.ES_IND_TITLE} : new String[]{GenericAttribute.ES_IND_FULL_TEXT};
query.must(EsQueryTools.assembleNormalKeywordQuery(keyword, fieldSearch));
}
// postFilter
BoolQueryBuilder postFilter = QueryBuilders.boolQuery();
postFilter.must(QueryBuilders.termQuery("brandkbs_cache_maps.linkedGroupId.keyword", linkedGroupId)).must(QueryBuilders.termQuery("brandkbs_cache_maps.projectId.keyword", projectId));
query.must(QueryBuilders.termQuery("brandkbs_cache_maps.linkedGroupId.keyword", linkedGroupId)).must(QueryBuilders.termQuery("brandkbs_cache_maps.projectId.keyword", projectId));
// time range
postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
List<JSONObject> resultList = new ArrayList<>(emotionList.size());
Map<String, Aggregation> aggMap =
esClientDao.searchResponse(indexes, postFilter, query, aggregationBuilder, null, null, 0, 0, null).getAggregations().asMap();
esClientDao.searchResponse(indexes, null, query, aggregationBuilder, null, null, 0, 0, null).getAggregations().asMap();
ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("count");
List<? extends Terms.Bucket> buckets = teamAgg.getBuckets();
for (String emotion : emotionList) {
......@@ -539,17 +533,15 @@ public class MarkDataServiceImpl implements IMarkDataService {
public List<JSONObject> getMarkSpread(Long startTime, Long endTime, String projectId, boolean cache) throws IOException {
ProjectVO project = projectService.getProjectVOById(projectId);
String linkedGroupId = project.getBrandLinkedGroupId();
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
endTime = DateUtils.addDays(Tools.truncDate(new Date(), Constant.DAY_PATTERN), 1).getTime();
startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
}
Long[] timeRange = Tools.formatTimeRange(startTime, endTime);
startTime = timeRange[0];
endTime = timeRange[1];
String redisKey = RedisKeyPrefix.MARK_SPREAD + Tools.concat(projectId, startTime, endTime);
String resultStr;
if (cache && StringUtils.isNotEmpty(resultStr = stringRedisTemplate.opsForValue().get(redisKey))) {
return JSON.parseArray(resultStr, JSONObject.class);
}
List<JSONObject> lineList = new ArrayList<>();
List<JSONObject> result = getDayMarkEmotionCount(startTime, endTime, projectId, linkedGroupId);
result.forEach(day -> {
JSONObject line = new JSONObject();
......@@ -581,17 +573,17 @@ public class MarkDataServiceImpl implements IMarkDataService {
// TODO script使用
Script script = new Script("params._source.ind_title");
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("titles").script(script).order(BucketOrder.count(false)).size(60000);
// postFilter
BoolQueryBuilder postFilter = projectLinkedGroupQuery(projectId, linkedGroupId);
postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime))
// query
BoolQueryBuilder query = projectLinkedGroupQuery(projectId, linkedGroupId);
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime))
// 过滤微博
.mustNot(QueryBuilders.termQuery("platform_id.keyword", "5d02236e6395002a7c380b79"));
if (null != emotion) {
postFilter.must(QueryBuilders.termQuery("mark_cache_maps.name.keyword", emotion));
query.must(QueryBuilders.termQuery("mark_cache_maps.name.keyword", emotion));
}
Map<String, Integer> result = new HashMap<>();
SearchResponse searchResponse = esClientDao.searchResponse(indexes, postFilter, null, aggregationBuilder, null, null, 0, 0, null);
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query, aggregationBuilder, null, null, 0, 0, null);
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("titles");
List<? extends Terms.Bucket> buckets = teamAgg.getBuckets();
......@@ -615,19 +607,21 @@ public class MarkDataServiceImpl implements IMarkDataService {
* @return 所有稿件倾向稿件数量信息
*/
private List<JSONObject> getDayMarkEmotionCount(Long startTime, Long endTime, String projectId, String linkedGroupId) throws IOException {
List<JSONObject> ResultList = new ArrayList<>();
List<JSONObject> resultList = new ArrayList<>();
// 索引
String[] indexes = esClientDao.getIndexes();
// ??? TODO 为什么是16h offset
DateHistogramAggregationBuilder daysAggregationBuilder = AggregationBuilders.dateHistogram("dayAgg").field("time").calendarInterval(DateHistogramInterval.DAY);
TermsAggregationBuilder emotionAggregationBuilder = AggregationBuilders.terms("count").field("mark_cache_maps.name.keyword");
// postFilter
BoolQueryBuilder postFilter = QueryBuilders.boolQuery();
postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime)).must(QueryBuilders.termQuery("brandkbs_cache_maps.projectId.keyword", projectId)).must(QueryBuilders.termQuery("brandkbs_cache_maps.linkedGroupId.keyword", linkedGroupId));
// query
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime)).
must(QueryBuilders.termQuery("brandkbs_cache_maps.projectId.keyword", projectId)).
must(QueryBuilders.termQuery("brandkbs_cache_maps.linkedGroupId.keyword", linkedGroupId));
// 情感倾向限制
postFilter.must(QueryBuilders.termQuery("mark_cache_maps.group_name.keyword", "情感倾向"));
query.must(QueryBuilders.termQuery("mark_cache_maps.group_name.keyword", "情感倾向"));
// response
SearchResponse searchResponse = esClientDao.searchResponse(indexes, postFilter, null,
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query,
daysAggregationBuilder.subAggregation(emotionAggregationBuilder), null, null, 0, 0, null);
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
ParsedDateHistogram dayAggTeam = (ParsedDateHistogram) aggMap.get("dayAgg");
......@@ -639,9 +633,9 @@ public class MarkDataServiceImpl implements IMarkDataService {
List<? extends Terms.Bucket> list = countTeam.getBuckets();
result.put("date", bucket.getKeyAsString());
emotionCount(result, bucket.getDocCount(), list);
ResultList.add(result);
resultList.add(result);
});
return ResultList;
return resultList;
}
/**
......@@ -661,12 +655,12 @@ public class MarkDataServiceImpl implements IMarkDataService {
TermsAggregationBuilder platformAggregationBuilder = AggregationBuilders.terms("platform_count").field("platform_id.keyword").order(BucketOrder.count(false));
TermsAggregationBuilder emotionAggregationBuilder = AggregationBuilders.terms("emotion_count").field("mark_cache_maps.name.keyword");
// postFilter
BoolQueryBuilder postFilter = projectLinkedGroupQuery(projectId, linkedGroupId);
BoolQueryBuilder query = projectLinkedGroupQuery(projectId, linkedGroupId);
// time
postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
// 情感倾向限制
postFilter.must(QueryBuilders.termQuery("mark_cache_maps.group_name.keyword", "情感倾向"));
SearchResponse searchResponse = esClientDao.searchResponse(indexes, postFilter, null,
query.must(QueryBuilders.termQuery("mark_cache_maps.group_name.keyword", "情感倾向"));
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query,
platformAggregationBuilder.subAggregation(emotionAggregationBuilder), null, null, 0, 0, null);
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("platform_count");
......@@ -684,6 +678,7 @@ public class MarkDataServiceImpl implements IMarkDataService {
}
private void emotionCount(JSONObject result, long total, List<? extends Terms.Bucket> list) {
result.put("total", total);
result.put(EmotionEnum.POSITIVE.getName(), 0);
result.put(EmotionEnum.NEUTRAL.getName(), 0);
result.put(EmotionEnum.NEGATIVE.getName(), 0);
......@@ -708,7 +703,8 @@ public class MarkDataServiceImpl implements IMarkDataService {
List<JSONObject> platformList = commonService.getQbjcPlatform("id", "name");
List<JSONObject> platformsCount = getPlatformsCount(startTime, endTime, null, null, projectId, linkedGroupId, platformList);
long articlesCount = platformsCount.stream().mapToLong(platform -> platform.getLongValue("count")).sum();
List<JSONObject> resultList = platformsCount.stream().peek(platform -> platform.put("proportion", platform.getLongValue("count") * 1.0 / articlesCount)).collect(Collectors.toList());
List<JSONObject> resultList = platformsCount.stream().peek(platform -> platform.put("proportion",
0 == articlesCount ? 0 : platform.getLongValue("count") * 1.0 / articlesCount)).collect(Collectors.toList());
stringRedisTemplate.opsForValue().set(redisKey, JSON.toJSONString(resultList), 1, TimeUnit.HOURS);
return resultList;
}
......@@ -730,19 +726,16 @@ public class MarkDataServiceImpl implements IMarkDataService {
// 聚合请求
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count").field("platform_id.keyword").order(BucketOrder.count(false)).size(100);
// query
BoolQueryBuilder query = QueryBuilders.boolQuery();
BoolQueryBuilder query = projectLinkedGroupQuery(projectId, linedGroupId);
// keyword
if (StringUtils.isNotEmpty(keyword)) {
String[] fieldSearch = "标题".equals(searchField) ? new String[]{GenericAttribute.ES_IND_TITLE} : new String[]{GenericAttribute.ES_IND_FULL_TEXT};
query.must(EsQueryTools.assembleNormalKeywordQuery(keyword, fieldSearch));
}
// postFilter
BoolQueryBuilder postFilter = projectLinkedGroupQuery(projectId, linedGroupId);
// time
postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
query.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
List<JSONObject> platformResultList = new ArrayList<>(platformList.size());
SearchResponse searchResponse = esClientDao.searchResponse(indexes, postFilter, query, aggregationBuilder, null, null, 0, 0, null);
SearchResponse searchResponse = esClientDao.searchResponse(indexes, null, query, aggregationBuilder, null, null, 0, 0, null);
Map<String, Aggregation> aggMap = searchResponse.getAggregations().asMap();
ParsedStringTerms teamAgg = (ParsedStringTerms) aggMap.get("count");
List<? extends Terms.Bucket> buckets = teamAgg.getBuckets();
......@@ -779,7 +772,6 @@ public class MarkDataServiceImpl implements IMarkDataService {
BoolQueryBuilder postFilter = projectLinkedGroupQuery(projectId, linkedGroupId);
postFilter.must(QueryBuilders.rangeQuery("time").gte(startTime).lt(endTime));
searchHelper.setPostFilter(postFilter);
// TODO 临时添加
searchHelper.setSize(10000);
List<String> textList = new ArrayList<>();
List<SearchResponse> searchResponses = Collections.singletonList(esClientDao.searchResponse(searchHelper));
......
......@@ -13,7 +13,7 @@ import com.zhiwei.brandkbs2.pojo.Project;
import com.zhiwei.brandkbs2.pojo.User;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.pojo.vo.ProjectVO;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
......@@ -32,7 +32,7 @@ import java.util.stream.Collectors;
* @date 2022年4月18日16:49:10
*/
@Service("projectServiceImpl")
public class ProjectServiceImpl implements IProjectService {
public class ProjectServiceImpl implements ProjectService {
@Resource(name = "userDao")
private IUserDao userDao;
......@@ -62,7 +62,7 @@ public class ProjectServiceImpl implements IProjectService {
}
//给超管添加该项目权限,并且初始化预警推送 TODO
// for (Integer SUPER_ADMINUid : userMapper.getAllSUPER_ADMINUids()) {
// iUserService.insertAdminRoleAndWarn(SUPER_ADMINUid, project.getId());
// UserService.insertAdminRoleAndWarn(SUPER_ADMINUid, project.getId());
// }
projectDao.insertOneWithoutId(projectVO.creatProject(new Date()));
}
......
......@@ -9,8 +9,8 @@ import com.zhiwei.brandkbs2.exception.ExceptionCast;
import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.pojo.ReportSettings;
import com.zhiwei.brandkbs2.pojo.dto.ReportSettingsDTO;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.IReportService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.ReportService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -31,7 +31,7 @@ import java.util.stream.Collectors;
* @date: 2022-05-31 18:01
*/
@Service("reportServiceImpl")
public class ReportServiceImpl implements IReportService {
public class ReportServiceImpl implements ReportService {
public static final Logger log = LogManager.getLogger(ReportServiceImpl.class);
@Resource(name = "reportDao")
......@@ -41,7 +41,7 @@ public class ReportServiceImpl implements IReportService {
IReportSettingsDao reportSettingsDao;
@Resource(name = "projectServiceImpl")
IProjectService projectService;
ProjectService projectService;
@Override
public Map<String, ReportSettingsDTO> getReportSettings() {
......
package com.zhiwei.brandkbs2.service.impl;
import com.zhiwei.brandkbs2.dao.IQbjcPojoDao;
import com.zhiwei.brandkbs2.service.ISystemInfoService;
import com.zhiwei.brandkbs2.service.SystemInfoService;
import com.zhiwei.qbjc.bean.pojo.common.MessagePlatform;
import com.zhiwei.qbjc.bean.pojo.common.Tag;
import org.springframework.stereotype.Service;
......@@ -10,13 +10,13 @@ import javax.annotation.Resource;
import java.util.List;
/**
* @ClassName: ISystemInfoServiceImpl
* @Description ISystemInfoServiceImpl
* @ClassName: SystemInfoServiceImpl
* @Description SystemInfoServiceImpl
* @author: sjj
* @date: 2022-06-16 14:21
*/
@Service("systemInfoServiceImpl")
public class SystemInfoServiceImpl implements ISystemInfoService {
public class SystemInfoServiceImpl implements SystemInfoService {
@Resource(name = "qbjcPojoDao")
private IQbjcPojoDao qbjcPojoDao;
......
......@@ -4,12 +4,11 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.dao.ITagFilterDao;
import com.zhiwei.brandkbs2.pojo.TagFilter;
import com.zhiwei.brandkbs2.pojo.dto.TagFilterDTO;
import com.zhiwei.brandkbs2.service.ICommonService;
import com.zhiwei.brandkbs2.service.IProjectService;
import com.zhiwei.brandkbs2.service.ITagFilterService;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.TagFilterService;
import com.zhiwei.brandkbs2.service.ProjectService;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -24,16 +23,16 @@ import java.util.stream.Collectors;
* @date: 2022-06-01 13:40
*/
@Service("tagFilterServiceImpl")
public class TagFilterServiceImpl implements ITagFilterService {
public class TagFilterServiceImpl implements TagFilterService {
@Resource(name = "tagFilterDao")
private ITagFilterDao tagFilterDao;
@Resource(name = "commonServiceImpl")
private ICommonService commonService;
private CommonService commonService;
@Resource(name = "projectServiceImpl")
private IProjectService projectService;
private ProjectService projectService;
@Override
public List<TagFilterDTO> getTagFilter() {
......
......@@ -8,7 +8,7 @@ import com.zhiwei.brandkbs2.es.EsClientDao;
import com.zhiwei.brandkbs2.pojo.BrandkbsTask;
import com.zhiwei.brandkbs2.pojo.Channel;
import com.zhiwei.brandkbs2.pojo.ChannelIndex;
import com.zhiwei.brandkbs2.service.ITaskService;
import com.zhiwei.brandkbs2.service.TaskService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
......@@ -25,7 +25,7 @@ import java.util.Map;
* @date: 2022-06-16 15:28
*/
@Service("taskServiceImpl")
public class TaskServiceImpl implements ITaskService {
public class TaskServiceImpl implements TaskService {
public static final Logger log = LogManager.getLogger(TaskServiceImpl.class);
@Resource(name = "esClientDao")
......@@ -66,5 +66,8 @@ public class TaskServiceImpl implements ITaskService {
public void reportSend() {
Date now = new Date();
BrandkbsTask task = brandkbsTaskDao.findTaskByTaskNameAndVersion(Constant.TASK_REPORT_JOB, Constant.INIT_VERSION);
}
}
......@@ -14,7 +14,7 @@ import com.zhiwei.brandkbs2.pojo.UserInfo;
import com.zhiwei.brandkbs2.pojo.UserRole;
import com.zhiwei.brandkbs2.pojo.dto.UserDTO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
import com.zhiwei.brandkbs2.service.IUserService;
import com.zhiwei.brandkbs2.service.UserService;
import com.zhiwei.brandkbs2.util.MongoUtil;
import com.zhiwei.middleware.auth.pojo.CenterUser;
import org.apache.commons.collections4.CollectionUtils;
......@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
* @date: 2022-04-28 17:34
*/
@Service("userServiceImpl")
public class UserServiceImpl implements IUserService {
public class UserServiceImpl implements UserService {
@Resource(name = "userDao")
private IUserDao userDao;
......
package com.zhiwei.brandkbs2.task;
import com.zhiwei.brandkbs2.service.ITaskService;
import com.zhiwei.brandkbs2.service.TaskService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.annotation.Profile;
......@@ -22,7 +22,7 @@ public class ControlCenter {
public static final Logger log = LogManager.getLogger(ControlCenter.class);
@Resource(name = "taskServiceImpl")
private ITaskService taskService;
private TaskService taskService;
@Async("scheduledExecutor")
@Scheduled(cron = "0 0 1 * * ?")
......
......@@ -20,6 +20,7 @@ import com.zhiwei.qbjc.bean.tools.BeanTools;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.dozer.DozerBeanMapper;
import org.springframework.data.mapping.MappingException;
......@@ -39,6 +40,8 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.zhiwei.brandkbs2.common.GenericAttribute.ES_MARK_CACHE_MAPS;
import static com.zhiwei.brandkbs2.config.Constant.DAY_PATTERN;
import static com.zhiwei.brandkbs2.config.Constant.HOUR_PATTERN;
import static java.util.Objects.nonNull;
/**
......@@ -516,4 +519,28 @@ public class Tools {
return result;
}
public static Long[] formatTimeRange(Long startTime, Long endTime) {
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
endTime = DateUtils.addDays(Tools.truncDate(new Date(), DAY_PATTERN), 1).getTime();
startTime = DateUtils.addMonths(new Date(endTime), -1).getTime();
} else {
startTime = Tools.truncDate(new Date(startTime), HOUR_PATTERN).getTime();
endTime = Tools.truncDate(new Date(endTime), HOUR_PATTERN).getTime();
}
return new Long[]{startTime, endTime};
}
public String getEmotionByEsMarkMap(Map<String, Object> map) {
List<JSONObject> cacheMaps = (List<JSONObject>) map.get(GenericAttribute.ES_MARK_CACHE_MAPS);
if (null == cacheMaps) {
return null;
}
for (JSONObject json : cacheMaps) {
if (Constant.EMOTION_LABEL_KEY.equals(json.getString("group_name"))) {
return json.getString("name");
}
}
return null;
}
}
\ No newline at end of file
package com.zhiwei.brandkbs2;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.controller.AppArticleController;
import com.zhiwei.brandkbs2.dao.IChannelLabelDao;
import com.zhiwei.brandkbs2.dao.IEventDataDao;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.ChannelIndex;
import com.zhiwei.brandkbs2.service.ITaskService;
import com.zhiwei.brandkbs2.pojo.UserInfo;
import com.zhiwei.brandkbs2.service.TaskService;
import com.zhiwei.brandkbs2.util.TextUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
......@@ -18,7 +22,7 @@ import java.util.List;
/**
* @ClassName: TestRunWith
* @Description TODO
* @Description TestRunWith
* @author: sjj
* @date: 2022-06-16 16:27
*/
......@@ -28,7 +32,7 @@ import java.util.List;
public class TestRunWith {
@Autowired
ITaskService iTaskService;
TaskService TaskService;
@Autowired
IEventDataDao eventDataDao;
......@@ -39,13 +43,20 @@ public class TestRunWith {
@Autowired
TextUtil textUtil;
@Autowired
AppArticleController appArticleController;
@Test
public void test1(){
iTaskService.messageFlowCount(1);
public void test1() {
UserInfo userInfo = new UserInfo();
userInfo.setProjectId("62beadd1bbf8eb20f96d2f2f");
UserThreadLocal.set(userInfo);
ResponseResult result = appArticleController.getMarkSpread(1657468800000L, 1657555200000L);
System.out.println(JSONObject.toJSONString(result));
}
@Test
public void test2(){
public void test2() {
ChannelIndex channelIndex = new ChannelIndex();
channelIndex.setPlatform("微信");
channelIndex.setRealSource("微信公众号");
......@@ -55,16 +66,16 @@ public class TestRunWith {
}
@Test
public void test3(){
public void test3() {
channelLabelDao.getChannelLabelType();
}
@Test
public void test4(){
public void test4() {
List<String> list = new ArrayList<>();
list.add("分析高频词耗时");
list.add("分析高频词");
List<JSONObject> highWordsJson = TextUtil.getHighWordsJson(list,1);
List<JSONObject> highWordsJson = TextUtil.getHighWordsJson(list, 1);
System.out.println(JSONObject.toJSONString(highWordsJson));
}
......
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