Commit 4e793e56 by shenjunjie

Merge branch 'feature' into 'release'

新版用户操作记录

See merge request !617
parents 34273db3 f6ebc0e7
......@@ -44,6 +44,7 @@ public class Constant {
* 自定义fid分隔符号
*/
public static final String DEFAULT_SEPARATOR = "_";
public static final String MINUS_SEPARATOR = "-";
/**
* 标签相关
......@@ -75,4 +76,8 @@ public class Constant {
public static final String PRIMARY_CONTEND_ID = "0";
public final static String DEFAULT_PROJECT_ID = "62beadd1bbf8eb20f96d2f1c";
public final static String MANUAL_PROJECT = "服务版";
public final static String NO_MANUAL_PROJECT = "自助版";
}
package com.zhiwei.brandkbs2.controller.admin;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.controller.BaseController;
......@@ -115,4 +116,59 @@ public class BehaviorController extends BaseController {
EasyExcelUtil.download(sheetName, sheetName, ExportUserLogRecordDTO.class, list, response);
return ResponseResult.success();
}
@ApiOperation("新版-记录用户操作记录")
@ApiImplicitParams({
@ApiImplicitParam(name = "backstage", value = "前后台(前台=false,后台=true)", defaultValue = "true", paramType = "query", dataType = "boolean"),
@ApiImplicitParam(name = "module", value = "模块", defaultValue = "服务版", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathOne", value = "一级路径", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathTwo", value = "二级路径", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathThree", value = "三级路径", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathFour", value = "四级路径", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathFive", value = "五级路径", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "param", value = "记录参数", paramType = "query", dataType = "string"),
})
@PostMapping("/userRecord/save")
@Auth(role = RoleEnum.CUSTOMER)
public ResponseResult saveUserRecord(@RequestBody JSONObject jsonObject) {
Boolean backstage = jsonObject.getBoolean("backstage");
String module = jsonObject.getString("module");
String pathOne = jsonObject.getString("pathOne");
String pathTwo = jsonObject.getString("pathTwo");
String pathThree = jsonObject.getString("pathThree");
String pathFour = jsonObject.getString("pathFour");
String pathFive = jsonObject.getString("pathFive");
String param = jsonObject.getString("param");
behaviorService.saveUserRecord(backstage, module, pathOne, pathTwo, pathThree, pathFour, pathFive, param);
return ResponseResult.success();
}
@ApiOperation("新版-分页查询用户操作记录列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", defaultValue = "1", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "每页记录数", defaultValue = "10", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "startTime", value = "开始时间", required = true, paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "endTime", value = "结束时间", required = true, paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "keyword", value = "关键词", defaultValue = "", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "roleId", value = "用户权限", defaultValue = "", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pathOne", value = "一级路径", defaultValue = "", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathTwo", value = "二级路径", defaultValue = "", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathThree", value = "三级路径", defaultValue = "", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathFour", value = "四级路径", defaultValue = "", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "pathFive", value = "五级路径", defaultValue = "", paramType = "query", dataType = "string")
})
@GetMapping("/userRecord/list")
public ResponseResult findUserRecordList(@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
@RequestParam(value = "startTime") long startTime,
@RequestParam(value = "endTime") long endTime,
@RequestParam(value = "keyword", defaultValue = "", required = false) String keyword,
@RequestParam(value = "roleId", required = false) Integer roleId,
@RequestParam(value = "pathOne", required = false) String pathOne,
@RequestParam(value = "pathTwo", required = false) String pathTwo,
@RequestParam(value = "pathThree", required = false) String pathThree,
@RequestParam(value = "pathFour", required = false) String pathFour,
@RequestParam(value = "pathFive", required = false) String pathFive) {
return ResponseResult.success(behaviorService.findUserRecordList(page, pageSize, startTime, endTime, keyword, roleId, pathOne, pathTwo, pathThree, pathFour, pathFive));
}
}
......@@ -5,7 +5,10 @@ import com.zhiwei.brandkbs2.aop.DownloadTask;
import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.GlobalPojo;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.dao.NonManualProjectPlanDao;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
......@@ -14,6 +17,7 @@ import com.zhiwei.brandkbs2.service.*;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.mark.vo.MarkerTag;
import io.swagger.annotations.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -23,6 +27,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -49,6 +54,12 @@ public class AppArticleController extends BaseController {
@Resource(name = "projectServiceImpl")
ProjectService projectService;
@Resource(name = "behaviorServiceImpl")
private BehaviorService behaviorService;
@Resource(name = "nonManualProjectPlanDao")
NonManualProjectPlanDao nonManualProjectPlanDao;
@Autowired
private RestTemplate restTemplate;
......@@ -119,15 +130,31 @@ public class AppArticleController extends BaseController {
@PostMapping("/mark/list")
@LogRecord(description = "舆情库-舆情数据")
public ResponseResult getYuqingMarkList(@RequestBody MarkSearchDTO markSearchDTO) {
if (CollectionUtils.isNotEmpty(markSearchDTO.getPlatforms())){
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "选择平台", null, GlobalPojo.getPlatformNameById(markSearchDTO.getPlatforms().get(0)));
}
if (markSearchDTO.isFold()){
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "去重", null, null);
}
if (!Objects.equals(markSearchDTO.getSorter().toJSONString(), "{\"time\":\"descending\"}")){
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "排序", null, markSearchDTO.getSorter().toJSONString());
}
if (Objects.nonNull(markSearchDTO.getSourceKeyword())){
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "渠道名搜索", null, markSearchDTO.getSourceKeyword());
}
if (Objects.nonNull(markSearchDTO.getHostKeyword())){
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "域名搜索", null, markSearchDTO.getHostKeyword());
}
return ResponseResult.success(markDataService.getYuqingMarkList(markSearchDTO));
}
@ApiOperation("舆情列表-生成聚合")
@PostMapping("/mark/aggree")
@LogRecord(description = "舆情库-有效舆情-聚合")
// @LogRecord(description = "舆情库-有效舆情-聚合")
public ResponseResult generateYuqingMarkAggreeList(@RequestBody JSONObject info) {
Long startTime = info.getLong("startTime");
Long endTime = info.getLong("endTime");
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "聚合", null, null);
return ResponseResult.success(markDataService.generateYuqingMarkAggreeList(startTime, endTime));
}
......@@ -259,8 +286,9 @@ public class AppArticleController extends BaseController {
@ApiOperation("舆情简报-全部报告列表")
@GetMapping("/report/list")
@LogRecord(description = "舆情库-其他简报")
// @LogRecord(description = "舆情库-其他简报")
public ResponseResult findReportList(ReportSearchDTO reportSearch) {
behaviorService.saveUserRecord("舆情库", "舆情简报", "其他简报", null, null, null);
return ResponseResult.success(reportService.findReportList(reportSearch));
}
......@@ -283,7 +311,9 @@ public class AppArticleController extends BaseController {
@ApiImplicitParam(name = "id", value = "报告ID", required = true, paramType = "path", dataType = "String")
@GetMapping("/analyze/{id}")
public ResponseResult getReportAnalyze(@PathVariable String id) {
return ResponseResult.success(reportService.getPcReportAnalyze(id, true));
JSONObject pcReportAnalyze = reportService.getPcReportAnalyze(id, true);
behaviorService.saveUserRecord("舆情库", "舆情简报", "其他简报", "查看简报", null, pcReportAnalyze.getString("title"));
return ResponseResult.success(pcReportAnalyze);
}
@ApiOperation("舆情简报-更新报告结果")
......@@ -304,9 +334,10 @@ public class AppArticleController extends BaseController {
@ApiOperation("舆情库-有效舆情-互动量更新")
@PostMapping("/mark/interaction-update")
@LogRecord(description = "舆情库-有效舆情互动量更新")
// @LogRecord(description = "舆情库-有效舆情互动量更新")
@DownloadTask(taskName = "有效舆情互动量更新结果下载", description = "有效舆情互动量更新结果", entity = true)
public ResponseResult getMarkInteractionUpdate(@RequestBody MarkSearchDTO markSearchDTO){
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "互动量更新", null, null);
return markDataService.markInteractionUpdate(markSearchDTO);
}
......@@ -319,6 +350,8 @@ public class AppArticleController extends BaseController {
@ApiOperation("非人工项目-方案设置-新建方案")
@PostMapping("/non-manual/plan/add")
public ResponseResult addNonManualProjectPlan(@RequestBody NonManualProjectPlanDTO dto){
behaviorService.saveUserRecord(false, Constant.NO_MANUAL_PROJECT, "舆情库", "方案设置",
"新建方案", null, null, JSONObject.toJSONString(dto));
return markDataService.addNonManualProjectPlan(dto);
}
......@@ -337,6 +370,8 @@ public class AppArticleController extends BaseController {
@ApiOperation("非人工项目-方案设置-编辑方案")
@PostMapping("/non-manual/plan/update")
public ResponseResult updateNonManualProjectPlan(@RequestBody NonManualProjectPlanDTO dto){
behaviorService.saveUserRecord(false, Constant.NO_MANUAL_PROJECT, "舆情库", "方案设置",
"编辑方案", null, null, JSONObject.toJSONString(dto));
return markDataService.updateNonManualProjectPlan(dto);
}
......@@ -344,6 +379,8 @@ public class AppArticleController extends BaseController {
@PostMapping("/non-manual/plan/config/update")
public ResponseResult updateNonManualModelCustomConfig(@ApiParam(name = "json:{id:方案id, modelCustomConfig:{coreWordType:核心词类型,coreWord:核心词,negativeWord:负面词,negativePoints:[负面观点,...],positiveWord:正面词,positivePoints:[正面观点,...]} }") @RequestBody JSONObject json){
markDataService.updateNonManualModelCustomConfig(json);
behaviorService.saveUserRecord(false, Constant.NO_MANUAL_PROJECT, "舆情库", "方案设置",
"编辑模型", null, null, json.getJSONObject("modelCustomConfig").toJSONString());
return ResponseResult.success();
}
......@@ -356,6 +393,8 @@ public class AppArticleController extends BaseController {
@ApiOperation("非人工项目-方案设置-方案列表")
@GetMapping("/non-manual/plan/list")
public ResponseResult getNonManualProjectPlanList(){
behaviorService.saveUserRecord(false, Constant.NO_MANUAL_PROJECT, "舆情库", "方案设置",
null, null, null, null);
return ResponseResult.success(markDataService.getNonManualProjectPlanList());
}
......@@ -389,6 +428,9 @@ public class AppArticleController extends BaseController {
@ApiOperation("非人工项目-舆情数据-舆情数据列表")
@PostMapping("/non-manual/mark/list")
public ResponseResult getNonManualMarkList(@RequestBody MarkSearchDTO markSearchDTO){
String paramStr = nonManualProjectPlanDao.findOneById(markSearchDTO.getPlanId()).getName();
behaviorService.saveUserRecord(false, Constant.NO_MANUAL_PROJECT, "舆情库", "舆情数据",
null, null, null, paramStr);
return ResponseResult.success(markDataService.getNonManualMarkList(markSearchDTO));
}
......
......@@ -4,15 +4,19 @@ import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportAppChannelArticleDTO;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.ExportAppChannelEventDTO;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.ChannelService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.*;
import org.joda.time.Period;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
......@@ -44,6 +48,9 @@ public class AppChannelController extends BaseController {
@Resource(name = "projectServiceImpl")
ProjectService projectService;
@Resource(name = "behaviorServiceImpl")
private BehaviorService behaviorService;
@Autowired
private RestTemplate restTemplate;
......@@ -58,7 +65,7 @@ public class AppChannelController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "选取前几", defaultValue = "50", paramType = "query", dataType = "int"),
})
@ApiOperation("渠道库-活跃渠道榜")
@LogRecord(description = "渠道库-活跃渠道榜")
// @LogRecord(description = "渠道库-活跃渠道榜")
@GetMapping("/list/active")
public ResponseResult getActiveChannelList(@RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "platform", required = false) String platform,
......@@ -79,7 +86,7 @@ public class AppChannelController extends BaseController {
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "pageSize", value = "选取前几", defaultValue = "50", paramType = "query", dataType = "int")
})
@LogRecord(description = "渠道库-友好渠道榜")
// @LogRecord(description = "渠道库-友好渠道榜")
@GetMapping("/list/positive")
public ResponseResult getPositiveList(@RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "platform", required = false) String platform,
......@@ -101,7 +108,7 @@ public class AppChannelController extends BaseController {
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "pageSize", value = "选取前几", defaultValue = "50", paramType = "query", dataType = "int")
})
@LogRecord(description = "渠道库-敏感渠道榜")
// @LogRecord(description = "渠道库-敏感渠道榜")
@GetMapping("/list/negative")
public ResponseResult getNegativeList(@RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "platform", required = false) String platform,
......@@ -139,7 +146,10 @@ public class AppChannelController extends BaseController {
@ApiImplicitParam(name = "channelId", value = "渠道ID", required = true, paramType = "path", dataType = "string")
@GetMapping("/baseInfo/{channelId}")
public ResponseResult getBaseInfoByChannelId(@PathVariable("channelId") String channelId) {
return ResponseResult.success(channelService.getBaseInfoByChannelId(channelId));
JSONObject baseInfo = channelService.getBaseInfoByChannelId(channelId);
// String paramStr = Tools.concatWithMinus(baseInfo.getString("platform"), baseInfo.getString("source"), baseInfo.getString("id"));
// userRecordService.saveUserRecord("渠道库", "渠道排行榜", "查看渠道", null, null, paramStr);
return ResponseResult.success(baseInfo);
}
@ApiOperation("渠道库-渠道动向")
......@@ -254,12 +264,28 @@ public class AppChannelController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "选取前几", defaultValue = "50", paramType = "query", dataType = "int"),
})
@ApiOperation("渠道库-活跃渠道榜")
@LogRecord(description = "渠道库-活跃渠道榜")
// @LogRecord(description = "渠道库-活跃渠道榜")
@GetMapping("/list/new/active")
public ResponseResult getActiveChannelList(@RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)){
Period period = new Period(startTime, endTime);
String type = null;
if (0 != period.getMonths()){
type = "月榜";
}
if (0 != period.getWeeks()){
type = "周榜";
}
if (0 != period.getDays()){
type = "日榜";
}
String startTimeStr = Constant.EXCEL_TIME_FORMAT.format(startTime);
String paramStr = Tools.concatWithMinus(type, "活跃渠道榜", startTimeStr);
behaviorService.saveUserRecord("渠道库", "渠道排行榜", "查看期刊", null, null, paramStr);
}
return ResponseResult.success(channelService.getActiveChannelList(contendId, startTime, endTime, size, true));
}
......@@ -270,13 +296,29 @@ public class AppChannelController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "选取前几", defaultValue = "50", paramType = "query", dataType = "int"),
})
@ApiOperation("渠道库-友好渠道榜")
@LogRecord(description = "渠道库-友好渠道榜")
// @LogRecord(description = "渠道库-友好渠道榜")
@GetMapping("/list/new/positive")
public ResponseResult getPositiveChannelList(@RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "sorter", defaultValue = "{\"index\":\"descend\"}") String sorter,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)){
Period period = new Period(startTime, endTime);
String type = null;
if (0 != period.getMonths()){
type = "月榜";
}
if (0 != period.getWeeks()){
type = "周榜";
}
if (0 != period.getDays()){
type = "日榜";
}
String startTimeStr = Constant.EXCEL_TIME_FORMAT.format(startTime);
String paramStr = Tools.concatWithMinus(type, "正面渠道榜", startTimeStr);
behaviorService.saveUserRecord("渠道库", "渠道排行榜", "查看期刊", null, null, paramStr);
}
return ResponseResult.success(channelService.getPositiveChannelList(contendId, startTime, endTime, size, null, true));
}
......@@ -287,13 +329,29 @@ public class AppChannelController extends BaseController {
@ApiImplicitParam(name = "pageSize", value = "选取前几", defaultValue = "50", paramType = "query", dataType = "int"),
})
@ApiOperation("渠道库-敏感渠道榜")
@LogRecord(description = "渠道库-敏感渠道榜")
// @LogRecord(description = "渠道库-敏感渠道榜")
@GetMapping("/list/new/negative")
public ResponseResult getNegativeChannelList(@RequestParam(value = "contendId", defaultValue = "0") String contendId,
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "sorter", defaultValue = "{\"index\":\"descend\"}") String sorter,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)){
Period period = new Period(startTime, endTime);
String type = null;
if (0 != period.getMonths()){
type = "月榜";
}
if (0 != period.getWeeks()){
type = "周榜";
}
if (0 != period.getDays()){
type = "日榜";
}
String startTimeStr = Constant.EXCEL_TIME_FORMAT.format(startTime);
String paramStr = Tools.concatWithMinus(type, "负面渠道榜", startTimeStr);
behaviorService.saveUserRecord("渠道库", "渠道排行榜", "查看期刊", null, null, paramStr);
}
return ResponseResult.success(channelService.getNegativeChannelList(contendId, startTime, endTime, size, null, true));
}
......@@ -320,6 +378,11 @@ public class AppChannelController extends BaseController {
@GetMapping("/important-channel/list")
public ResponseResult getImportantChannelList(@RequestParam(value = "type", defaultValue = "市监局") String type,
@RequestParam(value = "keyword", required = false) String keyword) {
String listType = "机构清单";
if (Objects.equals(type, "18家媒体") || Objects.equals(type, "区域媒体")){
listType = "媒体清单";
}
behaviorService.saveUserRecord("渠道库", "重要渠道清单", "查看清单", null, null, Tools.concatWithMinus(listType, type));
return ResponseResult.success(channelService.getImportantChannelList(type, keyword));
}
......@@ -328,6 +391,7 @@ public class AppChannelController extends BaseController {
public ResponseResult getImportantChannelListDetail(@RequestParam(value = "type") String type,
@RequestParam(value = "name") String name,
@RequestParam(value = "keyword", required = false) String keyword) {
behaviorService.saveUserRecord("渠道库", "重要渠道清单", "清单明细", null, null, Tools.concatWithMinus(type, name));
return ResponseResult.success(channelService.getImportantChannelListDetail(type, name, keyword));
}
}
......@@ -4,13 +4,16 @@ import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.ExportAppYuqingDTO;
import com.zhiwei.brandkbs2.pojo.dto.MarkSearchDTO;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.tuple.Pair;
......@@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
/**
* @ClassName AppContendController
......@@ -35,6 +39,9 @@ public class AppContendController extends BaseController {
@Resource(name = "markDataServiceImpl")
MarkDataService markDataService;
@Resource(name = "behaviorServiceImpl")
private BehaviorService behaviorService;
@ApiOperation("竞品库-竞品舆情-搜索条件")
@GetMapping("/searchCriteria")
public ResponseResult getContendSearchCriteria(@RequestParam(required = false) String contendId) {
......@@ -42,16 +49,25 @@ public class AppContendController extends BaseController {
}
@ApiOperation("竞品库-竞品舆情-搜索结果列表")
@LogRecord(description = "竞品舆情库-竞品舆情")
// @LogRecord(description = "竞品舆情库-竞品舆情")
@PostMapping("/list")
public ResponseResult getContendSearchList(@RequestBody MarkSearchDTO markSearchDTO){
behaviorService.saveUserRecord("竞品库", "竞品舆情", "查询记录", null, null, JSONObject.toJSONString(markSearchDTO));
return ResponseResult.success(markDataService.getContendSearchList(markSearchDTO));
}
@ApiOperation("竞品库-竞品分析-舆情总结页面")
@LogRecord(description = "竞品舆情库-竞品对比")
// @LogRecord(description = "竞品舆情库-竞品对比")
@PostMapping("/summary")
public ResponseResult getSummary(@RequestBody MarkSearchDTO markSearchDTO) throws IOException {
String startTimeStr = null;
String endTimeStr = null;
if (Objects.nonNull(markSearchDTO.getStartTime()) && Objects.nonNull(markSearchDTO.getEndTime())){
startTimeStr = Constant.EXCEL_TIME_FORMAT.format(markSearchDTO.getStartTime());
endTimeStr = Constant.EXCEL_TIME_FORMAT.format(markSearchDTO.getEndTime());
}
String param = Tools.concatWithMinus(startTimeStr, endTimeStr, markSearchDTO.getContendId());
behaviorService.saveUserRecord("竞品库", "竞品对比", "查询记录", null, null, param);
return ResponseResult.success(markDataService.getContendSummary(markSearchDTO, true));
}
......
......@@ -337,6 +337,7 @@ public class AppDownloadController extends BaseController {
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getExtraProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), stringPairPair.getLeft() + "_舆情列表数据");
EasyExcelUtil.dynamicHeadWrite(filePath, "sheet1", stringPairPair.getRight().getLeft(), stringPairPair.getRight().getRight());
behaviorService.saveUserRecord("舆情库", "舆情数据", "数据结果", "舆情导出", null, filePath);
return ResponseResult.success(filePath);
}
......@@ -566,6 +567,20 @@ public class AppDownloadController extends BaseController {
return ResponseResult.success(toolsetService.downloadPrimaryErrorData(taskId));
}
@ApiOperation("新-下载用户操作记录列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "startTime", value = "开始时间", required = true, paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "endTime", value = "结束时间", required = true, paramType = "query", dataType = "long"),
})
@GetMapping("/userRecord/download")
public ResponseResult downloadUserRecordList(@RequestParam("startTime") long startTime,
@RequestParam("endTime") long endTime) {
List<ExportUserRecordDTO> list = behaviorService.downloadUserRecord(startTime, endTime);
String sheetName = projectService.getProjectVOById(UserThreadLocal.getProjectId()).getExtraProjectName() + "_新版操作记录";
EasyExcelUtil.download(sheetName, sheetName, ExportUserRecordDTO.class, list, response);
return ResponseResult.success();
}
private HttpHeaders getHeaders() {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set("token", token);
......
......@@ -4,17 +4,21 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.dto.EventSearchDTO;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.EventService;
import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.util.Tools;
import com.zhiwei.middleware.event.pojo.dto.BrandkbsEventSearchDTO;
import com.zhiwei.middleware.event.pojo.dto.EventDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.joda.time.Period;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
......@@ -23,6 +27,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
/**
* @Description: 前台事件库
......@@ -69,6 +74,9 @@ public class AppEventController extends BaseController {
@Resource(name = "markDataServiceImpl")
MarkDataService markDataService;
@Resource(name = "behaviorServiceImpl")
BehaviorService behaviorService;
public AppEventController(EventService eventService) {
this.eventService = eventService;
}
......@@ -145,7 +153,7 @@ public class AppEventController extends BaseController {
}
@ApiOperation("前台事件库-全网事件库-行业热点-列表")
@LogRecord(description = "事件库-全网事件库")
// @LogRecord(description = "事件库-全网事件库")
@GetMapping("/getWholeNetworkEventsList")
public ResponseResult getWholeNetworkEventsList(@RequestParam(value = "firstType", required = false, defaultValue = "") String firstType,
@RequestParam(value = "start", required = false, defaultValue = "0") long start,
......@@ -153,6 +161,14 @@ public class AppEventController extends BaseController {
@RequestParam(value = "page", required = false, defaultValue = "1") int page) {
ResponseEntity<String> responseEntity = restTemplate.getForEntity(getFilterNewUrl, String.class, firstType, start, end, page);
JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
String startTimeStr = null;
String endTimeStr = null;
if (0 != start || 0 != end) {
startTimeStr = Constant.EXCEL_TIME_FORMAT.format(start);
endTimeStr = Constant.EXCEL_TIME_FORMAT.format(end);
}
String paramStr = Tools.concatWithMinus(startTimeStr, endTimeStr, firstType, "page:" + page);
behaviorService.saveUserRecord("事件库", "全网事件库", "查询记录", null, null, paramStr);
return ResponseResult.success(jsonObject);
}
......@@ -190,7 +206,7 @@ public class AppEventController extends BaseController {
}
@ApiOperation("前台事件库-全网事件库-企业危机-危机库列表")
@LogRecord(description = "事件库-危机案例库")
// @LogRecord(description = "事件库-危机案例库")
@GetMapping("/crisisList")
public ResponseResult crisisList(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
......@@ -199,6 +215,14 @@ public class AppEventController extends BaseController {
@RequestParam(value = "category",defaultValue = "不限") String category){
ResponseEntity<String> responseEntity = restTemplate.getForEntity(crisisListUrl, String.class, page, pageSize, startTime, endTime, category);
Object data = JSON.parseObject(responseEntity.getBody()).get("data");
String startTimeStr = null;
String endTimeStr = null;
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)){
startTimeStr = Constant.EXCEL_TIME_FORMAT.format(Long.valueOf(startTime));
endTimeStr = Constant.EXCEL_TIME_FORMAT.format(Long.valueOf(endTime));
}
String paramStr = Tools.concatWithMinus(startTimeStr, endTimeStr, "事件类型:" + category, "page:" + page, "pageSize:" + pageSize);
behaviorService.saveUserRecord("事件库", "危机案例库", "查询记录", null, null, paramStr);
return ResponseResult.success(data);
}
......@@ -224,9 +248,10 @@ public class AppEventController extends BaseController {
}
@ApiOperation("前台事件库-品牌事件库-获取品牌事件库事件列表")
@LogRecord(description = "事件库-品牌事件库-事件中心")
// @LogRecord(description = "事件库-品牌事件库-事件中心")
@PostMapping("/eventList")
public ResponseResult getEventListMiddleware(@RequestBody BrandkbsEventSearchDTO dto){
behaviorService.saveUserRecord("事件库", "品牌事件库", "事件中心", "查询记录", null, JSONObject.toJSONString(dto));
return ResponseResult.success(eventService.getEventListMiddleware(dto));
}
......@@ -251,6 +276,7 @@ public class AppEventController extends BaseController {
return ResponseResult.failure("监测事件数量不得超过5");
}
eventService.addEventMonitor(dto);
behaviorService.saveUserRecord("事件库", "品牌事件库", "事件监测", "新增事件", null, dto.getName());
return ResponseResult.success();
}
......@@ -349,15 +375,32 @@ public class AppEventController extends BaseController {
@ApiOperation("前台事件库-品牌事件库标题聚合分析")
@GetMapping("/analyze/aggregate-titles")
@LogRecord(description = "事件库-品牌事件库-标题聚合分析")
// @LogRecord(description = "事件库-品牌事件库-标题聚合分析")
public ResponseResult getLastNews(@RequestParam(value = "startTime") Long startTime,
@RequestParam(value = "endTime") Long endTime) {
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)){
Period period = new Period(startTime, endTime);
String type = null;
if (0 != period.getMonths()){
type = "月榜";
}
if (0 != period.getWeeks()){
type = "周榜";
}
if (0 != period.getDays()){
type = "日榜";
}
String startTimeStr = Constant.EXCEL_TIME_FORMAT.format(startTime);
String paramStr = Tools.concatWithMinus(type, startTimeStr);
behaviorService.saveUserRecord("事件库", "品牌事件库", "标题聚合分析", "查看期刊", null, paramStr);
}
return ResponseResult.success(eventService.getEventAggTitleList(startTime, endTime, true));
}
@ApiOperation("前台事件库-品牌事件库-分析")
@PostMapping("/analyze")
public ResponseResult aggTitleAnalyze(@RequestBody EventDTO dto){
behaviorService.saveUserRecord("事件库", "品牌事件库", "标题聚合分析", "事件分析", null, dto.getName());
return eventService.aggTitleAnalyze(dto);
}
......@@ -367,7 +410,9 @@ public class AppEventController extends BaseController {
@RequestParam(value = "endTime") Long endTime,
@RequestParam(value = "aggTitle") String aggTitle,
@RequestParam(value = "planId", required = false) String planId) {
return ResponseResult.success(markDataService.getAggTitleBaseInfo(aggTitle, startTime, endTime, planId));
JSONObject baseInfo = markDataService.getAggTitleBaseInfo(aggTitle, startTime, endTime, planId);
behaviorService.saveUserRecord("事件库", "品牌事件库", "标题聚合分析", "标题详情", null, baseInfo.getString("title"));
return ResponseResult.success(baseInfo);
}
@ApiOperation("新-舆情分析-高频标题-发布节点")
......
......@@ -14,10 +14,12 @@ import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.BaseMap;
import com.zhiwei.brandkbs2.pojo.vo.SupplementWord;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.CommonService;
import com.zhiwei.brandkbs2.service.MarkDataService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -74,6 +76,9 @@ public class AppHotController extends BaseController {
@Resource(name = "commonServiceImpl")
CommonService commonService;
@Resource(name = "behaviorServiceImpl")
BehaviorService behaviorService;
@Resource(name = "esSearchExecutor")
ThreadPoolTaskExecutor executor;
......@@ -134,6 +139,16 @@ public class AppHotController extends BaseController {
return json;
}).collect(Collectors.toList());
result.put("data", list);
// 操作记录
String startTimeStr = null;
String endTimeStr = null;
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)){
startTimeStr = Constant.EXCEL_TIME_FORMAT.format(startTime);
endTimeStr = Constant.EXCEL_TIME_FORMAT.format(endTime);
}
String param = Tools.concatWithMinus(startTimeStr, endTimeStr, "sort:" + sort, "type:" + type, "page:" + page, "pageSize:" + pageSize, "contendId" + contendId);
behaviorService.saveUserRecord("热点库", "品牌热点", "品牌热点", "查询记录", null, param);
behaviorService.saveUserRecord("热点库", "品牌热点", "品牌热点", "查询记录", null, Tools.concatWithMinus(startTimeStr, endTimeStr));
return ResponseResult.success(result);
}
......@@ -174,11 +189,12 @@ public class AppHotController extends BaseController {
@ApiOperation("热点库-品牌热点-关键词调整")
@PutMapping("/keyword/update")
@LogRecord(description = "热点库-关键词调整", values = "list", entity = true, arguments = true)
// @LogRecord(description = "热点库-关键词调整", values = "list", entity = true, arguments = true)
public ResponseResult updateKeyword(@ApiParam(name = "json:{list:关键词数组,contendId:竞品id}") @RequestBody JSONObject json) {
JSONArray list = json.getJSONArray("list");
String contendId = json.getString("contendId");
redisUtil.set(RedisKeyPrefix.hotKeywordKey(null == contendId ? UserThreadLocal.getProjectId() : contendId), list.toJSONString());
behaviorService.saveUserRecord("热点库", "品牌热点", "品牌关键词", null, null, Tools.concatWithMinus(list.toJSONString(), contendId));
return ResponseResult.success();
}
......@@ -289,6 +305,7 @@ public class AppHotController extends BaseController {
if (!result) {
return ResponseResult.failure("补录新增失败");
}
behaviorService.saveUserRecord("热点库", "品牌热点", "热搜补录", null, null, json.toJSONString());
return ResponseResult.success();
}
......
......@@ -5,6 +5,7 @@ import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -34,15 +35,19 @@ public class AppIndexController extends BaseController {
@Resource
private IndexService indexService;
@Resource(name = "behaviorServiceImpl")
BehaviorService behaviorService;
@ApiOperation("首页-舆情总量")
@ApiImplicitParams({
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "long")
})
@LogRecord(description = "首页")
// @LogRecord(description = "首页")
@GetMapping("/yuqing-amount")
public ResponseResult getYuqingAmount(@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime) {
behaviorService.saveUserRecord("首页", "驾驶舱", null, null, null, null);
return ResponseResult.success(indexService.getYuqingAmount(startTime, endTime, true));
}
......
......@@ -36,10 +36,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
......@@ -94,6 +91,9 @@ public class AppSearchController extends BaseController {
@Resource(name = "searchWholeServiceImpl")
SearchWholeService searchWholeService;
@Resource(name = "behaviorServiceImpl")
BehaviorService behaviorService;
@Resource(name = "redisUtil")
RedisUtil redisUtil;
......@@ -108,6 +108,7 @@ public class AppSearchController extends BaseController {
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime) {
cacheSearchKeyword(keyword, "hot");
behaviorService.saveUserRecord("首页", "查热点", null, null, null, keyword);
ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplate.getForEntity(trendsSearchUrl, JSONObject.class, limit, page, type, keyword, sort, startTime, endTime);
JSONObject result = jsonObjectResponseEntity.getBody();
if (Objects.nonNull(result)) {
......@@ -126,6 +127,7 @@ public class AppSearchController extends BaseController {
cacheSearchKeyword(keyword, "crisis");
ResponseEntity<String> responseEntity = restTemplate.getForEntity(crisisSearchUrl, String.class, page, pageSize, keyword);
Object result = JSON.parseObject(responseEntity.getBody()).get("data");
behaviorService.saveUserRecord("首页", "查危机", null, null, null, keyword);
return ResponseResult.success(result);
}
......@@ -190,6 +192,7 @@ public class AppSearchController extends BaseController {
commonService.sentimentAnalysis(list);
}
extraService.decreaseRecord(dto.getKeyword(), WholeSearchRecord.UsedType.query, pair.getRight());
behaviorService.saveUserRecord("首页", "全网搜", null, null, null, dto.getKeyword());
return ResponseResult.success(pair.getLeft());
}
......@@ -249,6 +252,7 @@ public class AppSearchController extends BaseController {
}
yuqingMarkList.setInfo(info);
}
behaviorService.saveUserRecord("首页", "查舆情", null, null, null, markSearchDTO.getKeyword());
return ResponseResult.success(yuqingMarkList);
}
......@@ -296,6 +300,7 @@ public class AppSearchController extends BaseController {
@PostMapping(value = "/channel/channelList")
public ResponseResult getChannelList(@RequestBody ChannelSearchDTO channelSearchDTO) {
cacheSearchKeyword(channelSearchDTO.getKeyword(), "channel");
behaviorService.saveUserRecord("首页", "查渠道", null, null, null, channelSearchDTO.getKeyword());
return ResponseResult.success(channelService.getChannelListNew(channelSearchDTO.getPage(), channelSearchDTO.getPageSize(),
channelSearchDTO.getKeyword(), channelSearchDTO.getPlatform(), channelSearchDTO.getEmotions(), channelSearchDTO.getMediaTypes(), channelSearchDTO.getArticlesCount(), channelSearchDTO.getSorter()));
}
......@@ -335,6 +340,7 @@ public class AppSearchController extends BaseController {
@PostMapping("/event/newList")
public ResponseResult getEventListMiddleware(@RequestBody BrandkbsEventSearchDTO dto){
cacheSearchKeyword(dto.getKeyword(), "event");
behaviorService.saveUserRecord("首页", "查事件", null, null, null, dto.getKeyword());
return ResponseResult.success(eventService.getEventListMiddleware(dto));
}
......@@ -346,6 +352,7 @@ public class AppSearchController extends BaseController {
// return ResponseResult.failure("不支持特殊符号字段查询");
// }
cacheSearchKeyword(markSearchDTO.getKeyword(), "contend");
behaviorService.saveUserRecord("首页", "查竞品", null, null, null, markSearchDTO.getKeyword());
return ResponseResult.success(markDataService.getContendSearchList(markSearchDTO));
}
......@@ -361,6 +368,14 @@ public class AppSearchController extends BaseController {
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "startTime", required = false) Long startTime,
@RequestParam(value = "endTime", required = false) Long endTime) {
String startTimeStr = null;
String endTimeStr = null;
if (Objects.nonNull(startTime) && Objects.nonNull(endTime)){
startTimeStr = Constant.EXCEL_TIME_FORMAT.format(endTime);
endTimeStr = Constant.EXCEL_TIME_FORMAT.format(startTime);
}
behaviorService.saveUserRecord("首页", "AI搜索", null, null, null,
Tools.concatWithMinus(question, keyword, startTimeStr, endTimeStr));
return ResponseResult.success(markDataService.getAISearchResult(question, keyword, startTime, endTime));
}
......@@ -385,7 +400,7 @@ public class AppSearchController extends BaseController {
@ApiOperation("新-舆情分析-舆情总量")
@PostMapping("/analyze/amount")
@LogRecord(description = "舆情库-舆情分析")
@LogRecord(description = "舆情库-全网搜舆情分析")
public ResponseResult getYuqingAmount(@RequestBody SearchFilterDTO searchFilterDTO) {
if (searchFilterDTO.isExternalDataSource()){
return ResponseResult.failure("多元接口不支持数据分析");
......
......@@ -5,6 +5,7 @@ import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.ToolsetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -29,18 +30,23 @@ public class AppToolsetController {
@Resource(name = "toolsetServiceImpl")
private ToolsetService toolsetService;
@Resource(name = "behaviorServiceImpl")
BehaviorService behaviorService;
@ApiOperation("工具库-摘要提取-单条")
@GetMapping("/article-summary/single")
@LogRecord(description = "工具库-摘要提取-单条")
// @LogRecord(description = "工具库-摘要提取-单条")
public ResponseResult getSingleArticleSummary(@RequestParam(value = "url") String url) {
behaviorService.saveUserRecord("工具集", "摘要提取", "使用记录", null, null, "单条");
return toolsetService.getSingleArticleSummary(url);
}
@ApiOperation("工具库-摘要提取-批量")
@PostMapping("/article-summary/batch")
@LogRecord(description = "工具库-摘要提取-批量")
// @LogRecord(description = "工具库-摘要提取-批量")
@DownloadTask(taskName = "批量摘要提取结果下载", description = "批量摘要提取结果", entity = true)
public ResponseResult downloadBatchArticleSummary(@RequestParam(value = "file") MultipartFile file){
behaviorService.saveUserRecord("工具集", "摘要提取", "使用记录", null, null, "多条");
return toolsetService.getBatchArticleSummary(file);
}
......@@ -52,9 +58,10 @@ public class AppToolsetController {
@ApiOperation("工具库-互动量更新-链接互动量更新")
@PostMapping("/interaction-update/url")
@LogRecord(description = "工具库-链接互动量更新")
// @LogRecord(description = "工具库-链接互动量更新")
@DownloadTask(taskName = "链接互动量更新结果下载", description = "链接互动量更新结果", entity = true)
public ResponseResult downloadUrlInteractionUpdate(@RequestParam(value = "file") MultipartFile file){
behaviorService.saveUserRecord("工具集", "互动量更新", "使用记录", null, null, null);
return toolsetService.urlInteractionUpdate(file);
}
......@@ -66,9 +73,10 @@ public class AppToolsetController {
@ApiOperation("工具库-词云提取")
@PostMapping("/high-word")
@LogRecord(description = "工具库-词云提取")
// @LogRecord(description = "工具库-词云提取")
public ResponseResult getHighWord(@RequestParam MultipartFile file,
@ApiParam(name = "type", value = "关键词|文章") @RequestParam String type){
behaviorService.saveUserRecord("工具集", "词云提取", "使用记录", null, null, type);
return toolsetService.getHighWord(file, type);
}
......
......@@ -9,6 +9,7 @@ import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.controller.BaseController;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.BehaviorService;
import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.ProjectWarnService;
import com.zhiwei.brandkbs2.service.UserService;
......@@ -64,6 +65,9 @@ public class AppWarnController extends BaseController {
@Resource(name = "userServiceImpl")
private UserService userService;
@Resource(name = "behaviorServiceImpl")
BehaviorService behaviorService;
@Value("${warn.pushTask.token}")
private String token;
......@@ -101,6 +105,7 @@ public class AppWarnController extends BaseController {
@GetMapping("/project")
public ResponseResult getPushTaskId() {
try {
behaviorService.saveUserRecord("其他", "情报预警", null, null, null, null);
return pushTaskId(null, null, HttpMethod.GET);
} catch (Exception e) {
log.error("情报预警-推送任务获取失败", e);
......
package com.zhiwei.brandkbs2.dao;
import com.zhiwei.brandkbs2.pojo.UserRecord;
/**
* @ClassName: UserLogRecordNewDao
* @Description UserLogRecordNewDao
* @author: cjz
* @date: 2024-12-18 14:26
*/
public interface UserRecordDao extends BaseMongoDao<UserRecord>, ShardingMongo{
}
package com.zhiwei.brandkbs2.dao.impl;
import com.zhiwei.brandkbs2.dao.UserRecordDao;
import com.zhiwei.brandkbs2.pojo.UserRecord;
import org.springframework.stereotype.Component;
/**
* @ClassName: UserLogRecordNewDaoImpl
* @Description UserLogRecordNewDaoImpl
* @author: cjz
* @date: 2024-12-18 14:26
*/
@Component("userRecordDao")
public class UserRecordDaoImpl extends BaseMongoDaoImpl<UserRecord> implements UserRecordDao {
private static final String COLLECTION_PREFIX = "brandkbs_user_record";
private static final String TIME_PATTERN = "yyyy";
public UserRecordDaoImpl() {
super(null);
}
@Override
public String collectionPrefix() {
return COLLECTION_PREFIX;
}
@Override
public String timePattern() {
return TIME_PATTERN;
}
}
package com.zhiwei.brandkbs2.easyexcel.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author cjz
* @version 1.0
* @description 导出新版用户操作实体类
* @date 2025/01/10 14:10
*/
@Data
public class ExportUserRecordDTO {
@ExcelProperty("用户名")
private String nickname;
@ExcelProperty("操作记录")
private String description;
@ExcelProperty("操作时间")
private Date time;
@ExcelProperty("前后台")
private String backstage;
@ExcelProperty("用户身份")
private String role;
}
package com.zhiwei.brandkbs2.pojo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @ClassName: UserLogRecordNew
* @Description 用户操作记录实体类
* @author: cjz
* @date: 2023-03-21 10:16
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class UserRecord extends AbstractBaseMongo {
/**
* 项目id
*/
private String projectId;
/**
* 用户id
*/
private String userId;
/**
* nickname
*/
private String nickname;
/**
* false:前台,true:后台
*/
private boolean backstage;
/**
* 模块 服务版/自助版
*/
private String module;
/**
* 一级路径
*/
private String pathOne;
/**
* 二级路径
*/
private String pathTwo;
/**
* 三级路径
*/
private String pathThree;
/**
* 四级路径
*/
private String pathFour;
/**
* 五级路径
*/
private String pathFive;
/**
*
*/
private String params;
/**
* 用户权限id
*/
private Integer roleId;
/**
* 创建时间
*/
private Long cTime;
}
......@@ -2,8 +2,10 @@ package com.zhiwei.brandkbs2.service;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportBehaviorDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportUserLogRecordDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportUserRecordDTO;
import com.zhiwei.brandkbs2.pojo.Behavior;
import com.zhiwei.brandkbs2.pojo.UserLogRecord;
import com.zhiwei.brandkbs2.pojo.UserRecord;
import com.zhiwei.brandkbs2.pojo.vo.BehaviorVO;
import com.zhiwei.brandkbs2.pojo.vo.PageVO;
......@@ -74,4 +76,47 @@ public interface BehaviorService {
* @return
*/
List<ExportUserLogRecordDTO> downloadUserLogRecord(long startTime, long endTime);
/**
* 新版用户操作记录保存
* @param backstage
* @param module
* @param pathOne
* @param pathTwo
* @param pathThree
* @param pathFour
* @param pathFive
* @param paramStr
*/
void saveUserRecord(Boolean backstage, String module, String pathOne, String pathTwo,
String pathThree, String pathFour, String pathFive, String paramStr);
void saveUserRecord(String pathOne, String pathTwo,
String pathThree, String pathFour, String pathFive, String paramStr);
/**
* 新版用户操作记录列表
* @param page
* @param size
* @param startTime
* @param endTime
* @param nickname
* @param roleId
* @param pathOne
* @param pathTwo
* @param pathThree
* @param pathFour
* @param pathFive
* @return
*/
PageVO<UserRecord> findUserRecordList(int page, int size, long startTime, long endTime, String nickname, Integer roleId, String pathOne, String pathTwo,
String pathThree, String pathFour, String pathFive);
/**
* 下载新版用户操作记录列表
* @param startTime
* @param endTime
* @return
*/
List<ExportUserRecordDTO> downloadUserRecord(long startTime, long endTime);
}
......@@ -2,11 +2,14 @@ package com.zhiwei.brandkbs2.service.impl;
import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.common.GenericAttribute;
import com.zhiwei.brandkbs2.config.Constant;
import com.zhiwei.brandkbs2.dao.BehaviorDao;
import com.zhiwei.brandkbs2.dao.UserDao;
import com.zhiwei.brandkbs2.dao.UserLogRecordDao;
import com.zhiwei.brandkbs2.dao.UserRecordDao;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportBehaviorDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportUserLogRecordDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportUserRecordDTO;
import com.zhiwei.brandkbs2.enmus.RoleEnum;
import com.zhiwei.brandkbs2.pojo.*;
import com.zhiwei.brandkbs2.pojo.vo.BehaviorVO;
......@@ -53,6 +56,9 @@ public class BehaviorServiceImpl implements BehaviorService {
@Resource(name = "UserLogRecordDao")
private UserLogRecordDao userLogRecordDao;
@Resource(name = "userRecordDao")
private UserRecordDao userRecordDao;
@Resource(name = "userServiceImpl")
private UserService userService;
......@@ -238,6 +244,93 @@ public class BehaviorServiceImpl implements BehaviorService {
return resList;
}
@Override
public void saveUserRecord(Boolean backstage, String module, String pathOne, String pathTwo, String pathThree, String pathFour, String pathFive, String paramStr) {
UserRecord userRecord = new UserRecord(UserThreadLocal.getProjectId(), UserThreadLocal.getUserId(), UserThreadLocal.getNickname(), backstage,
module, pathOne, pathTwo, pathThree, pathFour, pathFive, paramStr, UserThreadLocal.getRoleId(), System.currentTimeMillis());
userRecordDao.insertOne(userRecord, userRecordDao.generateCollectionName());
}
@Override
public void saveUserRecord(String pathOne, String pathTwo, String pathThree, String pathFour, String pathFive, String paramStr) {
saveUserRecord(false, Constant.MANUAL_PROJECT, pathOne, pathTwo, pathThree, pathFour, pathFive, paramStr);
}
@Override
public PageVO<UserRecord> findUserRecordList(int page, int size, long startTime, long endTime, String nickname, Integer roleId,
String pathOne, String pathTwo, String pathThree, String pathFour, String pathFive) {
Date start = new Date(startTime);
Date end = new Date(endTime);
String projectId = UserThreadLocal.getProjectId();
Query query = new Query();
query.addCriteria(Criteria.where("cTime").gte(startTime).lt(endTime));
query.addCriteria(Criteria.where("projectId").is(projectId));
String[] collectionNames = userRecordDao.generateCollectionNames(start, end);
userRecordDao.addSort(query, "{\"cTime\":\"descend\"}");
if (StringUtils.isNotEmpty(nickname)) {
userRecordDao.addKeywordFuzz(query, nickname, "nickname");
}
if (Objects.nonNull(roleId)){
query.addCriteria(Criteria.where("roleId").is(roleId));
}
if (StringUtils.isNotEmpty(pathOne)) {
query.addCriteria(Criteria.where("pathOne").is(pathOne));
}
if (StringUtils.isNotEmpty(pathTwo)) {
query.addCriteria(Criteria.where("pathTwo").is(pathTwo));
}
if (StringUtils.isNotEmpty(pathThree)) {
query.addCriteria(Criteria.where("pathThree").is(pathThree));
}
if (StringUtils.isNotEmpty(pathFour)) {
query.addCriteria(Criteria.where("pathFour").is(pathFour));
}
if (StringUtils.isNotEmpty(pathFive)) {
query.addCriteria(Criteria.where("pathFive").is(pathFive));
}
long count = userRecordDao.count(query, collectionNames);
List<UserRecord> behaviorList = new ArrayList<>();
int pageSizeFlag = size;
int skipCount = (page - 1) * size;
if (0 != collectionNames.length) {
for (int i = collectionNames.length - 1; i >= 0; i--) {
if (behaviorList.size() >= size) {
break;
} else {
query.limit(pageSizeFlag);
query.skip(skipCount);
List<UserRecord> list = userRecordDao.findList(query, collectionNames[i]);
behaviorList.addAll(list);
}
skipCount = 0;
pageSizeFlag = size - behaviorList.size();
}
}
return PageVO.createPageVo(count, page, size, behaviorList);
}
@Override
public List<ExportUserRecordDTO> downloadUserRecord(long startTime, long endTime) {
String projectId = UserThreadLocal.getProjectId();
Query query = new Query();
query.addCriteria(Criteria.where("cTime").gte(startTime).lt(endTime));
query.addCriteria(Criteria.where("projectId").is(projectId));
userRecordDao.addSort(query, "{\"cTime\":\"descend\"}");
String[] collectionNames = userRecordDao.generateCollectionNames(new Date(startTime), new Date(endTime));
List<UserRecord> userLogRecordList = userRecordDao.findList(query, collectionNames);
List<ExportUserRecordDTO> resList = new ArrayList<>(userLogRecordList.size());
userLogRecordList.forEach(record -> {
ExportUserRecordDTO dto = new ExportUserRecordDTO();
dto.setNickname(record.getNickname());
dto.setDescription(Tools.concatWithMinus(record.getPathOne(), record.getPathTwo(), record.getPathThree(), record.getPathFour(), record.getPathFive(), record.getParams()));
dto.setTime(new Date(record.getCTime()));
dto.setBackstage(record.isBackstage() ? "后台" : "前台");
dto.setRole(RoleEnum.getNameByState(record.getRoleId()));
resList.add(dto);
});
return resList;
}
private Integer getRoleId(String userId, String projectId) {
User user = userDao.findOneById(userId);
Integer roleId = -1;
......
......@@ -552,18 +552,21 @@ public class Tools {
* @return 拼接后的字符串
*/
public static String concatWithMinus(List<Object> objects) {
String separator = "-";
StringBuilder sb = new StringBuilder();
for (Object obj : objects) {
if (Objects.isNull(obj)){
if (Tools.isEmpty(obj)){
continue;
}
sb.append(obj).append(separator);
sb.append(obj).append(Constant.MINUS_SEPARATOR);
}
String resultStr = sb.toString();
return StringUtils.isBlank(resultStr) ? resultStr : resultStr.substring(0, resultStr.length() - 1);
}
public static String concatWithMinus(Object... objects) {
return concatWithMinus(Arrays.stream(objects).collect(Collectors.toList()));
}
public static String[] split(String concatStr) {
return concatStr.split(Constant.DEFAULT_SEPARATOR);
}
......
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