Commit 74c1cf6a by 陈健智

工具库-词云提取功能

parent 810414be
...@@ -6,7 +6,6 @@ import com.zhiwei.brandkbs2.model.CommonCodeEnum; ...@@ -6,7 +6,6 @@ import com.zhiwei.brandkbs2.model.CommonCodeEnum;
import com.zhiwei.brandkbs2.model.ResponseResult; import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.pojo.DownloadTask; import com.zhiwei.brandkbs2.pojo.DownloadTask;
import com.zhiwei.brandkbs2.service.DownloadTaskService; import com.zhiwei.brandkbs2.service.DownloadTaskService;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -19,8 +18,6 @@ import org.springframework.stereotype.Component; ...@@ -19,8 +18,6 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
/** /**
* @author cjz * @author cjz
...@@ -37,18 +34,20 @@ public class AopDownloadTask { ...@@ -37,18 +34,20 @@ public class AopDownloadTask {
@Resource(name = "downloadTaskServiceImpl") @Resource(name = "downloadTaskServiceImpl")
DownloadTaskService downloadTaskService; DownloadTaskService downloadTaskService;
private static final List<String> METHOD = Arrays.asList("downloadBatchArticleSummary", "downloadUrlInteractionUpdate", "getMarkInteractionUpdate"); @Around(value = "execution(public * com..controller..admin..*Controller.*(..)) || execution(* com..controller..app..*Controller.*(..))")
@Around(value = "execution(public * com..controller..app..AppDownloadController.*(..)) || execution(* com..controller..app..AppToolsetController.download*(..)) || execution(* com..controller..app..AppArticleController.getMarkInteractionUpdate(..))")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable{ public Object around(ProceedingJoinPoint joinPoint) throws Throwable{
Signature signature = joinPoint.getSignature(); Signature signature = joinPoint.getSignature();
Method method = ((MethodSignature) signature).getMethod(); Method method = ((MethodSignature) signature).getMethod();
// 方法上无此注解,无需生成下载任务
if (!method.isAnnotationPresent(com.zhiwei.brandkbs2.aop.DownloadTask.class)){
return joinPoint.proceed();
}
// 生成下载任务 // 生成下载任务
String taskName = method.getAnnotation(ApiOperation.class).value() + "下载"; String taskName = method.getAnnotation(com.zhiwei.brandkbs2.aop.DownloadTask.class).taskName();
String description = method.getAnnotation(ApiOperation.class).value(); String description = method.getAnnotation(com.zhiwei.brandkbs2.aop.DownloadTask.class).description();
String taskId = downloadTaskService.createDownloadTask(taskName, description); String taskId = downloadTaskService.createDownloadTask(taskName, description);
Object proceed = null;
String fileAddress; String fileAddress;
Object proceed = null;
// 执行目标方法 // 执行目标方法
try { try {
proceed = joinPoint.proceed(); proceed = joinPoint.proceed();
...@@ -58,7 +57,7 @@ public class AopDownloadTask { ...@@ -58,7 +57,7 @@ public class AopDownloadTask {
ExceptionCast.cast(CommonCodeEnum.FAIL, "下载异常", e); ExceptionCast.cast(CommonCodeEnum.FAIL, "下载异常", e);
} }
// 更新下载任务 // 更新下载任务
if (METHOD.contains(method.getName())){ if (method.getAnnotation(com.zhiwei.brandkbs2.aop.DownloadTask.class).entity()){
fileAddress = JSONObject.parseObject(((ResponseResult) proceed).getData().toString()).getString("filePath"); fileAddress = JSONObject.parseObject(((ResponseResult) proceed).getData().toString()).getString("filePath");
}else { }else {
fileAddress = ((ResponseResult) proceed).getData().toString(); fileAddress = ((ResponseResult) proceed).getData().toString();
......
package com.zhiwei.brandkbs2.aop;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DownloadTask {
String taskName();
String description();
boolean entity() default false;
}
package com.zhiwei.brandkbs2.controller.app; package com.zhiwei.brandkbs2.controller.app;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.aop.DownloadTask;
import com.zhiwei.brandkbs2.aop.LogRecord; import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
...@@ -306,9 +307,10 @@ public class AppArticleController extends BaseController { ...@@ -306,9 +307,10 @@ public class AppArticleController extends BaseController {
return reportService.getReportSchedule(idList); return reportService.getReportSchedule(idList);
} }
@ApiOperation("有效舆情互动量更新") @ApiOperation("舆情库-有效舆情-互动量更新")
@PostMapping("/mark/interaction-update") @PostMapping("/mark/interaction-update")
@LogRecord(description = "舆情库-有效舆情互动量更新") @LogRecord(description = "舆情库-有效舆情互动量更新")
@DownloadTask(taskName = "有效舆情互动量更新结果下载", description = "有效舆情互动量更新结果", entity = true)
public ResponseResult getMarkInteractionUpdate(@RequestBody MarkSearchDTO markSearchDTO){ public ResponseResult getMarkInteractionUpdate(@RequestBody MarkSearchDTO markSearchDTO){
return markDataService.markInteractionUpdate(markSearchDTO); return markDataService.markInteractionUpdate(markSearchDTO);
} }
......
package com.zhiwei.brandkbs2.controller.app; package com.zhiwei.brandkbs2.controller.app;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zhiwei.brandkbs2.aop.DownloadTask;
import com.zhiwei.brandkbs2.aop.LogRecord; import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.auth.UserThreadLocal; import com.zhiwei.brandkbs2.auth.UserThreadLocal;
...@@ -30,6 +31,7 @@ import org.springframework.http.HttpHeaders; ...@@ -30,6 +31,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
...@@ -64,9 +66,6 @@ public class AppDownloadController extends BaseController { ...@@ -64,9 +66,6 @@ public class AppDownloadController extends BaseController {
@Resource(name = "markDataServiceImpl") @Resource(name = "markDataServiceImpl")
MarkDataService markDataService; MarkDataService markDataService;
@Resource(name = "commonServiceImpl")
CommonService commonService;
@Value("${qbjc.interface.url}") @Value("${qbjc.interface.url}")
private String yuqingInterface; private String yuqingInterface;
...@@ -79,10 +78,11 @@ public class AppDownloadController extends BaseController { ...@@ -79,10 +78,11 @@ public class AppDownloadController extends BaseController {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@ApiOperation("稿件模板") @ApiOperation("后台-稿件上传-稿件模板下载")
@ApiImplicitParams(@ApiImplicitParam(name = "contendId", value = "品牌id", paramType = "query", dataType = "string")) @ApiImplicitParams(@ApiImplicitParam(name = "contendId", value = "品牌id", paramType = "query", dataType = "string"))
@GetMapping("/back/template/article") @GetMapping("/back/template/article")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "稿件模板下载", description = "稿件模板")
public ResponseResult downloadTemplateForm(@RequestParam(defaultValue = "0") String contendId) { public ResponseResult downloadTemplateForm(@RequestParam(defaultValue = "0") String contendId) {
try { try {
AbstractProject project = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId); AbstractProject project = projectService.getProjectByContendId(UserThreadLocal.getProjectId(), contendId);
...@@ -101,11 +101,12 @@ public class AppDownloadController extends BaseController { ...@@ -101,11 +101,12 @@ public class AppDownloadController extends BaseController {
} }
} }
@ApiOperation("表格上传信息") @ApiOperation("后台-稿件上传-下载表格上传信息")
@ApiImplicitParams({@ApiImplicitParam(name = "formType", value = "表格类型:上传失败/上传成功", paramType = "body", dataType = "string"), @ApiImplicitParams({@ApiImplicitParam(name = "formType", value = "表格类型:上传失败/上传成功", paramType = "body", dataType = "string"),
@ApiImplicitParam(name = "id", value = "任务id", paramType = "body", dataType = "string")}) @ApiImplicitParam(name = "id", value = "任务id", paramType = "body", dataType = "string")})
@PostMapping(value = "/back/template/form") @PostMapping(value = "/back/template/form")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "表格上传信息下载", description = "表格上传信息")
public ResponseResult downloadUploadList(@RequestBody JSONObject info) { public ResponseResult downloadUploadList(@RequestBody JSONObject info) {
try { try {
String id = info.getString("id"); String id = info.getString("id");
...@@ -128,6 +129,7 @@ public class AppDownloadController extends BaseController { ...@@ -128,6 +129,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("高频关键词") @ApiOperation("高频关键词")
@GetMapping(value = "/back/module/high-word") @GetMapping(value = "/back/module/high-word")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "高频关键词下载", description = "高频关键词")
public ResponseResult downloadHighWord() { public ResponseResult downloadHighWord() {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
List<ExportWordDTO> list = highWordService.downloadWord(projectId); List<ExportWordDTO> list = highWordService.downloadWord(projectId);
...@@ -142,6 +144,7 @@ public class AppDownloadController extends BaseController { ...@@ -142,6 +144,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("舆情列表高亮关键词") @ApiOperation("舆情列表高亮关键词")
@GetMapping(value = "/back/module/highlight-word") @GetMapping(value = "/back/module/highlight-word")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "舆情列表高亮关键词下载", description = "舆情列表高亮关键词")
public ResponseResult downloadHighlightWord() { public ResponseResult downloadHighlightWord() {
String projectId = UserThreadLocal.getProjectId(); String projectId = UserThreadLocal.getProjectId();
List<ExportWordDTO> list = highlightWordService.downloadWord(projectId); List<ExportWordDTO> list = highlightWordService.downloadWord(projectId);
...@@ -161,6 +164,7 @@ public class AppDownloadController extends BaseController { ...@@ -161,6 +164,7 @@ public class AppDownloadController extends BaseController {
}) })
@GetMapping("/back/behavior/behavior") @GetMapping("/back/behavior/behavior")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "用户行为列表下载", description = "用户行为列表")
public ResponseResult download(@RequestParam("startTime") long startTime, public ResponseResult download(@RequestParam("startTime") long startTime,
@RequestParam("endTime") long endTime, @RequestParam("endTime") long endTime,
@RequestParam(value = "behavior", defaultValue = "true") boolean behavior) { @RequestParam(value = "behavior", defaultValue = "true") boolean behavior) {
...@@ -180,6 +184,7 @@ public class AppDownloadController extends BaseController { ...@@ -180,6 +184,7 @@ public class AppDownloadController extends BaseController {
}) })
@GetMapping("/back/behavior/log-record") @GetMapping("/back/behavior/log-record")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "用户操作记录列表下载", description = "用户操作记录列表")
public ResponseResult downloadLogRecordList(@RequestParam("startTime") long startTime, public ResponseResult downloadLogRecordList(@RequestParam("startTime") long startTime,
@RequestParam("endTime") long endTime) { @RequestParam("endTime") long endTime) {
List<ExportUserLogRecordDTO> list = behaviorService.downloadUserLogRecord(startTime, endTime); List<ExportUserLogRecordDTO> list = behaviorService.downloadUserLogRecord(startTime, endTime);
...@@ -200,6 +205,7 @@ public class AppDownloadController extends BaseController { ...@@ -200,6 +205,7 @@ public class AppDownloadController extends BaseController {
}) })
@GetMapping("/back/channel/list") @GetMapping("/back/channel/list")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "渠道列表下载", description = "渠道列表")
public ResponseResult downloadChannelList(@RequestParam(value = "contendId",defaultValue = "0") String contendId, public ResponseResult downloadChannelList(@RequestParam(value = "contendId",defaultValue = "0") String contendId,
@RequestParam(value = "emotion", defaultValue = "") String emotion, @RequestParam(value = "emotion", defaultValue = "") String emotion,
@RequestParam(value = "platform", defaultValue = "") String platform, @RequestParam(value = "platform", defaultValue = "") String platform,
...@@ -217,6 +223,7 @@ public class AppDownloadController extends BaseController { ...@@ -217,6 +223,7 @@ public class AppDownloadController extends BaseController {
@ApiImplicitParam(name = "channelId", value = "渠道ID", required = true, paramType = "query", dataType = "String") @ApiImplicitParam(name = "channelId", value = "渠道ID", required = true, paramType = "query", dataType = "String")
@GetMapping("/back/channel/article") @GetMapping("/back/channel/article")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "渠道稿件列表下载", description = "渠道稿件列表")
public ResponseResult downloadArticleList(@RequestParam(value = "channelId") String channelId) { public ResponseResult downloadArticleList(@RequestParam(value = "channelId") String channelId) {
List<ExportAdminChannelArticleDTO> downloadChannelArticleList = channelService.findDownloadChannelArticleList(channelId); List<ExportAdminChannelArticleDTO> downloadChannelArticleList = channelService.findDownloadChannelArticleList(channelId);
// excel写入至指定路径 // excel写入至指定路径
...@@ -230,6 +237,7 @@ public class AppDownloadController extends BaseController { ...@@ -230,6 +237,7 @@ public class AppDownloadController extends BaseController {
@ApiImplicitParam(name = "channelId", value = "渠道ID", required = true, paramType = "query", dataType = "String") @ApiImplicitParam(name = "channelId", value = "渠道ID", required = true, paramType = "query", dataType = "String")
@GetMapping("/back/channel/event") @GetMapping("/back/channel/event")
@Auth(role = RoleEnum.COMMON_ADMIN) @Auth(role = RoleEnum.COMMON_ADMIN)
@DownloadTask(taskName = "渠道事件列表下载", description = "渠道事件列表")
public ResponseResult downloadEventList(@RequestParam(value = "channelId") String channelId) { public ResponseResult downloadEventList(@RequestParam(value = "channelId") String channelId) {
List<ExportAdminChannelEventDTO> downloadChannelEventList = channelService.findDownloadChannelEventList(channelId); List<ExportAdminChannelEventDTO> downloadChannelEventList = channelService.findDownloadChannelEventList(channelId);
// excel写入至指定路径 // excel写入至指定路径
...@@ -242,6 +250,7 @@ public class AppDownloadController extends BaseController { ...@@ -242,6 +250,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("全网搜使用记录") @ApiOperation("全网搜使用记录")
@PostMapping("/back/search-whole/used") @PostMapping("/back/search-whole/used")
@Auth(role = RoleEnum.ADMIN) @Auth(role = RoleEnum.ADMIN)
@DownloadTask(taskName = "全网搜使用记录下载", description = "全网搜使用记录")
public ResponseResult downloadUseList(@ApiParam(name = "json:{personal:个人明细=true,startTime:起始时间,endTime:结束时间,day:颗粒度天级=true}") @RequestBody JSONObject json) { public ResponseResult downloadUseList(@ApiParam(name = "json:{personal:个人明细=true,startTime:起始时间,endTime:结束时间,day:颗粒度天级=true}") @RequestBody JSONObject json) {
boolean personal = json.getBooleanValue("personal"); boolean personal = json.getBooleanValue("personal");
Long startTime = json.getLong("startTime"); Long startTime = json.getLong("startTime");
...@@ -264,6 +273,7 @@ public class AppDownloadController extends BaseController { ...@@ -264,6 +273,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("互动量更新使用记录") @ApiOperation("互动量更新使用记录")
@PostMapping("/back/interaction/used") @PostMapping("/back/interaction/used")
@Auth(role = RoleEnum.ADMIN) @Auth(role = RoleEnum.ADMIN)
@DownloadTask(taskName = "互动量更新使用记录下载", description = "互动量更新使用记录")
public ResponseResult outputInteractionUsedList(@ApiParam(name = "json:{personal:个人明细=true,startTime:起始时间,endTime:结束时间,day:颗粒度天级=true}") public ResponseResult outputInteractionUsedList(@ApiParam(name = "json:{personal:个人明细=true,startTime:起始时间,endTime:结束时间,day:颗粒度天级=true}")
@RequestBody JSONObject json) { @RequestBody JSONObject json) {
boolean personal = json.getBooleanValue("personal"); boolean personal = json.getBooleanValue("personal");
...@@ -288,6 +298,7 @@ public class AppDownloadController extends BaseController { ...@@ -288,6 +298,7 @@ public class AppDownloadController extends BaseController {
@ApiImplicitParam(name = "pid", value = "项目ID", required = true, paramType = "path", dataType = "string") @ApiImplicitParam(name = "pid", value = "项目ID", required = true, paramType = "path", dataType = "string")
@GetMapping("/back/project/keyword/{pid}") @GetMapping("/back/project/keyword/{pid}")
@Auth(role = RoleEnum.SUPER_ADMIN) @Auth(role = RoleEnum.SUPER_ADMIN)
@DownloadTask(taskName = "项目关键词下载", description = "项目关键词")
public ResponseResult downloadArticles(@PathVariable("pid") String pid) { public ResponseResult downloadArticles(@PathVariable("pid") String pid) {
ProjectVO project = projectService.getProjectVOById(pid); ProjectVO project = projectService.getProjectVOById(pid);
// excel写入至指定路径 // excel写入至指定路径
...@@ -299,6 +310,7 @@ public class AppDownloadController extends BaseController { ...@@ -299,6 +310,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("舆情库原始数据") @ApiOperation("舆情库原始数据")
@PostMapping(value = "/yuqing/origin") @PostMapping(value = "/yuqing/origin")
@LogRecord(description = "舆情库-原始数据导出", values = {"startTime", "endTime", "keyword", "platforms", "searchField"}, entity = true, arguments = true) @LogRecord(description = "舆情库-原始数据导出", values = {"startTime", "endTime", "keyword", "platforms", "searchField"}, entity = true, arguments = true)
@DownloadTask(taskName = "舆情库原始数据下载", description = "舆情库原始数据")
public ResponseResult exportOriginList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult exportOriginList(@RequestBody MarkSearchDTO markSearchDTO) {
Pair<String, List<ExportAppYuqingDTO>> stringListPair = markDataService.downloadYuqingMarkList(markSearchDTO); Pair<String, List<ExportAppYuqingDTO>> stringListPair = markDataService.downloadYuqingMarkList(markSearchDTO);
// excel写入至指定路径 // excel写入至指定路径
...@@ -311,6 +323,7 @@ public class AppDownloadController extends BaseController { ...@@ -311,6 +323,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("舆情库有效舆情数据") @ApiOperation("舆情库有效舆情数据")
@PostMapping(value = "/yuqing/mark") @PostMapping(value = "/yuqing/mark")
@LogRecord(description = "舆情库-有效舆情导出", values = {"startTime", "endTime", "customTags", "field", "keyword", "politicsLevel", "mainBodyType", "platforms", "region", "tags"}, entity = true, arguments = true) @LogRecord(description = "舆情库-有效舆情导出", values = {"startTime", "endTime", "customTags", "field", "keyword", "politicsLevel", "mainBodyType", "platforms", "region", "tags"}, entity = true, arguments = true)
@DownloadTask(taskName = "舆情库有效舆情数据下载", description = "舆情库有效舆情数据")
public ResponseResult exportYuqingMarkList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult exportYuqingMarkList(@RequestBody MarkSearchDTO markSearchDTO) {
Pair<String, List<ExportAppYuqingDTO>> stringListPair = markDataService.downloadYuqingMarkList(markSearchDTO); Pair<String, List<ExportAppYuqingDTO>> stringListPair = markDataService.downloadYuqingMarkList(markSearchDTO);
// excel写入至指定路径 // excel写入至指定路径
...@@ -328,6 +341,7 @@ public class AppDownloadController extends BaseController { ...@@ -328,6 +341,7 @@ public class AppDownloadController extends BaseController {
@ApiImplicitParam(name = "contendId", value = "品牌ID", defaultValue = "0", paramType = "query", dataType = "string") @ApiImplicitParam(name = "contendId", value = "品牌ID", defaultValue = "0", paramType = "query", dataType = "string")
}) })
@GetMapping("/channel/article") @GetMapping("/channel/article")
@DownloadTask(taskName = "渠道库文章列表下载", description = "渠道库文章列表")
public ResponseResult downloadArticles(@RequestParam(value = "startTime") long startTime, public ResponseResult downloadArticles(@RequestParam(value = "startTime") long startTime,
@RequestParam(value = "endTime") long endTime, @RequestParam(value = "endTime") long endTime,
@RequestParam("channelId") String channelId, @RequestParam("channelId") String channelId,
...@@ -348,6 +362,7 @@ public class AppDownloadController extends BaseController { ...@@ -348,6 +362,7 @@ public class AppDownloadController extends BaseController {
@ApiImplicitParam(name = "contendId", value = "竞品ID", defaultValue = "0", paramType = "query", dataType = "string") @ApiImplicitParam(name = "contendId", value = "竞品ID", defaultValue = "0", paramType = "query", dataType = "string")
}) })
@GetMapping("/channel/event") @GetMapping("/channel/event")
@DownloadTask(taskName = "渠道库事件列表下载", description = "渠道库事件列表")
public ResponseResult downloadEvents(@RequestParam(value = "startTime") long startTime, public ResponseResult downloadEvents(@RequestParam(value = "startTime") long startTime,
@RequestParam(value = "endTime") long endTime, @RequestParam(value = "endTime") long endTime,
@RequestParam("channelId") String channelId, @RequestParam("channelId") String channelId,
...@@ -362,6 +377,7 @@ public class AppDownloadController extends BaseController { ...@@ -362,6 +377,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("竞品库竞品舆情") @ApiOperation("竞品库竞品舆情")
@PostMapping(value = "/contend/mark") @PostMapping(value = "/contend/mark")
@DownloadTask(taskName = "竞品库竞品舆情下载", description = "竞品库竞品舆情")
public ResponseResult exportContendMarkList(@RequestBody MarkSearchDTO markSearchDTO) { public ResponseResult exportContendMarkList(@RequestBody MarkSearchDTO markSearchDTO) {
Pair<String, List<ExportAppYuqingDTO>> stringListPair = markDataService.downloadContendMarkList(markSearchDTO); Pair<String, List<ExportAppYuqingDTO>> stringListPair = markDataService.downloadContendMarkList(markSearchDTO);
// excel写入至指定路径 // excel写入至指定路径
...@@ -374,6 +390,7 @@ public class AppDownloadController extends BaseController { ...@@ -374,6 +390,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("全网搜舆情") @ApiOperation("全网搜舆情")
@PostMapping("/search-whole") @PostMapping("/search-whole")
@LogRecord(description = "全网搜-舆情导出", values = {"startTime", "endTime", "fans", "filterType", "filterWords", "search", "keyword", "platforms", "sensitiveChannels", "sourceKeyword"}, entity = true, arguments = true) @LogRecord(description = "全网搜-舆情导出", values = {"startTime", "endTime", "fans", "filterType", "filterWords", "search", "keyword", "platforms", "sensitiveChannels", "sourceKeyword"}, entity = true, arguments = true)
@DownloadTask(taskName = "全网搜舆情下载", description = "全网搜舆情")
public ResponseResult exportSearchWhole(@RequestBody SearchFilterDTO dto) { public ResponseResult exportSearchWhole(@RequestBody SearchFilterDTO dto) {
// 针对商业数据库做限制 // 针对商业数据库做限制
if (dto.isExternalDataSource()) { if (dto.isExternalDataSource()) {
...@@ -404,6 +421,7 @@ public class AppDownloadController extends BaseController { ...@@ -404,6 +421,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("摘要提取批量模板") @ApiOperation("摘要提取批量模板")
@GetMapping(value = "/article-summary/template") @GetMapping(value = "/article-summary/template")
@DownloadTask(taskName = "摘要提取批量模板下载", description = "摘要提取批量模板")
public ResponseResult downloadArticleSummaryTemplate() { public ResponseResult downloadArticleSummaryTemplate() {
List<List<String>> head = new ArrayList<>(); List<List<String>> head = new ArrayList<>();
head.add(Collections.singletonList("序号")); head.add(Collections.singletonList("序号"));
...@@ -418,6 +436,7 @@ public class AppDownloadController extends BaseController { ...@@ -418,6 +436,7 @@ public class AppDownloadController extends BaseController {
@ApiOperation("链接互动量更新模板") @ApiOperation("链接互动量更新模板")
@GetMapping(value = "/interaction-update/template") @GetMapping(value = "/interaction-update/template")
@DownloadTask(taskName = "链接互动量更新模板下载", description = "链接互动量更新模板")
public ResponseResult downloadInteractionUpdateTemplate() { public ResponseResult downloadInteractionUpdateTemplate() {
List<List<String>> head = new ArrayList<>(); List<List<String>> head = new ArrayList<>();
head.add(Collections.singletonList("序号")); head.add(Collections.singletonList("序号"));
...@@ -429,6 +448,56 @@ public class AppDownloadController extends BaseController { ...@@ -429,6 +448,56 @@ public class AppDownloadController extends BaseController {
return ResponseResult.success(filePath); return ResponseResult.success(filePath);
} }
@ApiOperation("词云提取模板")
@GetMapping(value = "/high-word/template")
@DownloadTask(taskName = "词云提取模板下载", description = "词云提取模板")
public ResponseResult downloadHighWordTemplate(@ApiParam(name = "type", value = "关键词|文章", required = true) @RequestParam String type) {
List<List<String>> head = new ArrayList<>();
head.add(Collections.singletonList("序号"));
if (Objects.equals("关键词", type)) {
head.add(Collections.singletonList("关键词"));
head.add(Collections.singletonList("词频"));
}else {
head.add(Collections.singletonList("标题"));
head.add(Collections.singletonList("文本"));
head.add(Collections.singletonList("链接"));
}
// excel写入至指定路径
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), type + "词云提取模板");
EasyExcelUtil.dynamicHeadWrite(filePath, "模板", head, Collections.emptyList());
return ResponseResult.success(filePath);
}
@ApiOperation("词云提取结果")
@PostMapping("/high-word/result")
@DownloadTask(taskName = "词云提取结果下载", description = "词云提取结果")
public ResponseResult getHighWordResult(@RequestParam MultipartFile file){
String filePath = Tools.uploadFileUrl(file, brandkbsFilePath, brandkbsFilePath);
return ResponseResult.success(filePath);
}
@ApiOperation("词云提取词组")
@PostMapping("/high-word/words")
@DownloadTask(taskName = "词云提取词组下载", description = "词云提取词组")
public ResponseResult getHighWordWords(@ApiParam(name = "info", value = "{\"words\":[{\"name\":\"阿里\",\"value\":23},{\"name\":\"腾讯\",\"value\":19}]}") @RequestBody JSONObject info){
List<JSONObject> list = info.getJSONArray("words").toJavaList(JSONObject.class);
List<UploadHighWordKeywordDTO> exportList = new ArrayList<>();
int id = 1;
for (JSONObject jsonObject : list) {
UploadHighWordKeywordDTO dto = new UploadHighWordKeywordDTO();
dto.setId(String.valueOf(id++));
dto.setKeyword(jsonObject.getString("name"));
dto.setFrequency(jsonObject.getInteger("value"));
exportList.add(dto);
}
// excel写入至指定路径
String projectName = projectService.getProjectById(UserThreadLocal.getProjectId()).getProjectName();
String filePath = EasyExcelUtil.generateExcelFilePath(brandkbsFilePath, projectName, UserThreadLocal.getNickname(), "词云词组");
EasyExcelUtil.write(filePath, "sheet1", UploadHighWordKeywordDTO.class, exportList);
return ResponseResult.success(filePath);
}
private HttpHeaders getHeaders() { private HttpHeaders getHeaders() {
HttpHeaders httpHeaders = new HttpHeaders(); HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set("token", token); httpHeaders.set("token", token);
......
package com.zhiwei.brandkbs2.controller.app; package com.zhiwei.brandkbs2.controller.app;
import com.zhiwei.brandkbs2.aop.DownloadTask;
import com.zhiwei.brandkbs2.aop.LogRecord; import com.zhiwei.brandkbs2.aop.LogRecord;
import com.zhiwei.brandkbs2.auth.Auth; import com.zhiwei.brandkbs2.auth.Auth;
import com.zhiwei.brandkbs2.enmus.RoleEnum; import com.zhiwei.brandkbs2.enmus.RoleEnum;
...@@ -7,6 +8,7 @@ import com.zhiwei.brandkbs2.model.ResponseResult; ...@@ -7,6 +8,7 @@ import com.zhiwei.brandkbs2.model.ResponseResult;
import com.zhiwei.brandkbs2.service.ToolsetService; import com.zhiwei.brandkbs2.service.ToolsetService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -27,36 +29,46 @@ public class AppToolsetController { ...@@ -27,36 +29,46 @@ public class AppToolsetController {
@Resource(name = "toolsetServiceImpl") @Resource(name = "toolsetServiceImpl")
private ToolsetService toolsetService; private ToolsetService toolsetService;
@ApiOperation("摘要提取-单条") @ApiOperation("工具库-摘要提取-单条")
@GetMapping("/article-summary/single") @GetMapping("/article-summary/single")
@LogRecord(description = "工具库-摘要提取-单条") @LogRecord(description = "工具库-摘要提取-单条")
public ResponseResult getSingleArticleSummary(@RequestParam(value = "url") String url) { public ResponseResult getSingleArticleSummary(@RequestParam(value = "url") String url) {
return toolsetService.getSingleArticleSummary(url); return toolsetService.getSingleArticleSummary(url);
} }
@ApiOperation("摘要提取") @ApiOperation("工具库-摘要提取-批量")
@PostMapping("/article-summary/batch") @PostMapping("/article-summary/batch")
@LogRecord(description = "工具库-摘要提取-批量") @LogRecord(description = "工具库-摘要提取-批量")
@DownloadTask(taskName = "批量摘要提取结果下载", description = "批量摘要提取结果", entity = true)
public ResponseResult downloadBatchArticleSummary(@RequestParam(value = "file") MultipartFile file){ public ResponseResult downloadBatchArticleSummary(@RequestParam(value = "file") MultipartFile file){
return toolsetService.getBatchArticleSummary(file); return toolsetService.getBatchArticleSummary(file);
} }
@ApiOperation("摘要提取-剩余可用次数") @ApiOperation("工具库-摘要提取-剩余可用次数")
@GetMapping("/article-summary/remaining") @GetMapping("/article-summary/remaining")
public ResponseResult getArticleSummaryRemainingCount(){ public ResponseResult getArticleSummaryRemainingCount(){
return toolsetService.getArticleSummaryRemainingCount(); return toolsetService.getArticleSummaryRemainingCount();
} }
@ApiOperation("链接互动量更新") @ApiOperation("工具库-互动量更新-链接互动量更新")
@PostMapping("/interaction-update/url") @PostMapping("/interaction-update/url")
@LogRecord(description = "工具库-链接互动量更新") @LogRecord(description = "工具库-链接互动量更新")
@DownloadTask(taskName = "链接互动量更新结果下载", description = "链接互动量更新结果", entity = true)
public ResponseResult downloadUrlInteractionUpdate(@RequestParam(value = "file") MultipartFile file){ public ResponseResult downloadUrlInteractionUpdate(@RequestParam(value = "file") MultipartFile file){
return toolsetService.urlInteractionUpdate(file); return toolsetService.urlInteractionUpdate(file);
} }
@ApiOperation("互动量更新-剩余可用次数") @ApiOperation("工具库-互动量更新-剩余可用次数")
@GetMapping("/interaction-update/remaining") @GetMapping("/interaction-update/remaining")
public ResponseResult getInteractionRemainingCount(){ public ResponseResult getInteractionRemainingCount(){
return ResponseResult.success(toolsetService.getInteractionRemainingCount()); return ResponseResult.success(toolsetService.getInteractionRemainingCount());
} }
@ApiOperation("工具库-词云提取")
@PostMapping("/high-word")
@LogRecord(description = "工具库-词云提取")
public ResponseResult getHighWord(@RequestParam MultipartFile file,
@ApiParam(name = "type", value = "关键词|文章") @RequestParam String type){
return ResponseResult.success(toolsetService.getHighWord(file, type));
}
} }
package com.zhiwei.brandkbs2.easyexcel.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* @author cjz
* @version 1.0
* @description 解析文章词云提取上传文件
* @date 2023/10/10 10:22
*/
@Data
public class UploadHighWordArticleDTO {
@ExcelProperty("序号")
private String id;
@ExcelProperty("标题")
private String title;
@ExcelProperty("文本")
private String content;
@ExcelProperty("链接")
private String url;
}
package com.zhiwei.brandkbs2.easyexcel.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author cjz
* @version 1.0
* @description 解析关键词词云提取上传文件
* @date 2023/10/10 10:22
*/
@Data
@NoArgsConstructor
public class UploadHighWordKeywordDTO {
@ExcelProperty("序号")
private String id;
@ExcelProperty("关键词")
private String keyword;
@ExcelProperty("词频")
private Integer frequency;
}
package com.zhiwei.brandkbs2.easyexcel.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadHighWordArticleDTO;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
/**
* @author cjz
* @version 1.0
* @description 解析文章词云提取上传文件
* @date 2023/10/10 10:23
*/
public class HighWordArticleListener extends AnalysisEventListener<UploadHighWordArticleDTO> {
List<String> contents;
public HighWordArticleListener(List<String> contents){
this.contents = contents;
}
@Override
public void invoke(UploadHighWordArticleDTO data, AnalysisContext context) {
if (StringUtils.isNotBlank(data.getContent())) {
contents.add(data.getContent());
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
}
}
package com.zhiwei.brandkbs2.easyexcel.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadHighWordKeywordDTO;
import java.util.Map;
import java.util.Objects;
/**
* @author lxj
* @version 1.0
* @description 解析词云关键词文件监听器
* @date 2023/10/10 10:30
*/
public class HighWordKeywordListener extends AnalysisEventListener<UploadHighWordKeywordDTO> {
private Map<String, Integer> map;
public HighWordKeywordListener(Map<String, Integer> map){
this.map = map;
}
@Override
public void invoke(UploadHighWordKeywordDTO data, AnalysisContext context) {
map.compute(data.getKeyword(), (k, v) ->{
if (Objects.isNull(v)){
return data.getFrequency();
}
if (v < data.getFrequency()){
return data.getFrequency();
}
return v;
});
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
}
}
...@@ -62,4 +62,11 @@ public interface ToolsetService { ...@@ -62,4 +62,11 @@ public interface ToolsetService {
*/ */
List<JSONObject> getInteractionResult(List<String> taskId); List<JSONObject> getInteractionResult(List<String> taskId);
/**
* 词云提取
* @param file excel文件
* @param type 类型 关键词|文章
* @return
*/
List<JSONObject> getHighWord(MultipartFile file, String type);
} }
...@@ -5,11 +5,10 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal; ...@@ -5,11 +5,10 @@ import com.zhiwei.brandkbs2.auth.UserThreadLocal;
import com.zhiwei.brandkbs2.controller.app.AppToolsetController; import com.zhiwei.brandkbs2.controller.app.AppToolsetController;
import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil; import com.zhiwei.brandkbs2.easyexcel.EasyExcelUtil;
import com.zhiwei.brandkbs2.easyexcel.config.ReadExcelDTO; import com.zhiwei.brandkbs2.easyexcel.config.ReadExcelDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportArticleSummaryDTO; import com.zhiwei.brandkbs2.easyexcel.dto.*;
import com.zhiwei.brandkbs2.easyexcel.dto.ExportInteractionUpdateDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadArticleSummaryDTO;
import com.zhiwei.brandkbs2.easyexcel.dto.UploadInteractionUpdateDTO;
import com.zhiwei.brandkbs2.easyexcel.listener.ArticleSummaryListener; import com.zhiwei.brandkbs2.easyexcel.listener.ArticleSummaryListener;
import com.zhiwei.brandkbs2.easyexcel.listener.HighWordArticleListener;
import com.zhiwei.brandkbs2.easyexcel.listener.HighWordKeywordListener;
import com.zhiwei.brandkbs2.easyexcel.listener.InteractionUpdateListener; import com.zhiwei.brandkbs2.easyexcel.listener.InteractionUpdateListener;
import com.zhiwei.brandkbs2.enmus.InteractionEnum; import com.zhiwei.brandkbs2.enmus.InteractionEnum;
import com.zhiwei.brandkbs2.exception.ExceptionCast; import com.zhiwei.brandkbs2.exception.ExceptionCast;
...@@ -21,6 +20,7 @@ import com.zhiwei.brandkbs2.service.ExtraService; ...@@ -21,6 +20,7 @@ import com.zhiwei.brandkbs2.service.ExtraService;
import com.zhiwei.brandkbs2.service.ProjectService; import com.zhiwei.brandkbs2.service.ProjectService;
import com.zhiwei.brandkbs2.service.ToolsetService; import com.zhiwei.brandkbs2.service.ToolsetService;
import com.zhiwei.brandkbs2.util.RedisUtil; import com.zhiwei.brandkbs2.util.RedisUtil;
import com.zhiwei.brandkbs2.util.TextUtil;
import com.zhiwei.brandkbs2.util.Tools; import com.zhiwei.brandkbs2.util.Tools;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
...@@ -62,6 +62,9 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -62,6 +62,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Autowired
private TextUtil textUtil;
@Value("${toolset.articleSummary.url}") @Value("${toolset.articleSummary.url}")
private String articleSummaryUrl; private String articleSummaryUrl;
...@@ -287,6 +290,56 @@ public class ToolsetServiceImpl implements ToolsetService { ...@@ -287,6 +290,56 @@ public class ToolsetServiceImpl implements ToolsetService {
return res; return res;
} }
@Override
public List<JSONObject> getHighWord(MultipartFile file, String type) {
if (Objects.equals("关键词", type)){
return getKeywordHighWord(file);
}
return getArticleHighWord(file);
}
/**
* 关键词词云提取
* @param file excel文件
* @return
*/
private List<JSONObject> getKeywordHighWord(MultipartFile file){
Map<String, Integer> map = new HashMap<>();
// excel信息提取
ReadExcelDTO<UploadHighWordKeywordDTO> readExcel = new ReadExcelDTO<>();
readExcel.setClazz(UploadHighWordKeywordDTO.class);
readExcel.setAnalysisEventListener(new HighWordKeywordListener(map));
EasyExcelUtil.read(file, readExcel);
Map<String, Integer> sortMap = Tools.sortMap(map, 200);
List<JSONObject> res = new ArrayList<>();
for (Map.Entry<String, Integer> entry : sortMap.entrySet()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", entry.getKey());
jsonObject.put("value", entry.getValue());
res.add(jsonObject);
}
return res;
}
/**
* 文章词云提取
* @param file excel文件
* @return
*/
private List<JSONObject> getArticleHighWord(MultipartFile file){
List<String> contents = new ArrayList<>();
// excel信息提取
ReadExcelDTO<UploadHighWordArticleDTO> readExcel = new ReadExcelDTO<>();
readExcel.setClazz(UploadHighWordArticleDTO.class);
readExcel.setAnalysisEventListener(new HighWordArticleListener(contents));
EasyExcelUtil.read(file, readExcel);
return textUtil.getHighWordsJsonDifferentFieldName(contents, 200);
}
/**
* 获取互动量请求头
* @return
*/
private HttpHeaders getInteractionRequestHeader(){ private HttpHeaders getInteractionRequestHeader(){
// 请求头参数 // 请求头参数
Long timeStamp = System.currentTimeMillis(); Long timeStamp = System.currentTimeMillis();
......
...@@ -120,4 +120,16 @@ public class TextUtil { ...@@ -120,4 +120,16 @@ public class TextUtil {
return result; return result;
} }
public List<JSONObject> getHighWordsJsonDifferentFieldName(List<String> texts, Integer maxSize) {
// Map<String, Integer> highWords = getHighWords(texts, maxSize);
List<Map.Entry<String, Integer>> wordRate = ansjSeg.getFenCi(texts, maxSize);
List<JSONObject> result = new ArrayList<>(wordRate.size());
for (Map.Entry<String, Integer> entry : wordRate) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", entry.getKey());
jsonObject.put("value", entry.getValue());
result.add(jsonObject);
}
return result;
}
} }
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