Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenjunjie
brandkbs2
Commits
31c97c4e
Commit
31c97c4e
authored
Sep 15, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature' into 'release'
Feature See merge request
!386
parents
e9ddade4
07da5aee
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
853 additions
and
39 deletions
+853
-39
src/main/java/com/zhiwei/brandkbs2/aop/AopDownloadTask.java
+60
-0
src/main/java/com/zhiwei/brandkbs2/auth/AuthAspect.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/controller/admin/EventController.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppCrisisController.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppDownloadController.java
+368
-0
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
+55
-6
src/main/java/com/zhiwei/brandkbs2/controller/app/AppUserCenterController.java
+32
-0
src/main/java/com/zhiwei/brandkbs2/dao/DownloadTaskDao.java
+17
-0
src/main/java/com/zhiwei/brandkbs2/dao/impl/DownloadTaskDaoImpl.java
+23
-0
src/main/java/com/zhiwei/brandkbs2/easyexcel/EasyExcelUtil.java
+56
-0
src/main/java/com/zhiwei/brandkbs2/pojo/DownloadTask.java
+78
-0
src/main/java/com/zhiwei/brandkbs2/pojo/Project.java
+0
-6
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ProjectVO.java
+0
-7
src/main/java/com/zhiwei/brandkbs2/service/DownloadTaskService.java
+53
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/DownloadTaskServiceImpl.java
+100
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/EsSearchServiceImpl.java
+2
-0
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+1
-17
src/test/java/com/zhiwei/brandkbs2/MarkDataServiceTest.java
+2
-3
No files found.
src/main/java/com/zhiwei/brandkbs2/aop/AopDownloadTask.java
0 → 100644
View file @
31c97c4e
package
com
.
zhiwei
.
brandkbs2
.
aop
;
import
com.zhiwei.brandkbs2.exception.ExceptionCast
;
import
com.zhiwei.brandkbs2.model.CommonCodeEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.DownloadTask
;
import
com.zhiwei.brandkbs2.service.DownloadTaskService
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.lang.reflect.Method
;
/**
* @author cjz
* @ClassName AopDownloadTask
* @Description 下载任务Aop
* @date 2023-09-11 09:25
*/
@Aspect
@Component
@Order
(
2
)
public
class
AopDownloadTask
{
public
static
final
Logger
log
=
LogManager
.
getLogger
(
AopDownloadTask
.
class
);
@Resource
(
name
=
"downloadTaskServiceImpl"
)
DownloadTaskService
downloadTaskService
;
@Around
(
value
=
"execution(public * com..controller..app..AppDownloadController.*(..)))"
)
public
Object
around
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
Signature
signature
=
joinPoint
.
getSignature
();
Method
method
=
((
MethodSignature
)
signature
).
getMethod
();
// 生成下载任务
String
taskName
=
method
.
getAnnotation
(
ApiOperation
.
class
).
value
()
+
"下载"
;
String
description
=
method
.
getAnnotation
(
ApiOperation
.
class
).
value
();
String
taskId
=
downloadTaskService
.
createDownloadTask
(
taskName
,
description
);
Object
proceed
=
null
;
String
fileAddress
;
// 执行目标方法
try
{
proceed
=
joinPoint
.
proceed
();
}
catch
(
Exception
e
){
// 目标方法出错时更新下载任务
downloadTaskService
.
updateDownloadTask
(
taskId
,
100
,
DownloadTask
.
Status
.
FAILED
.
getName
(),
null
);
ExceptionCast
.
cast
(
CommonCodeEnum
.
FAIL
,
"下载异常"
,
e
);
}
// 更新下载任务
fileAddress
=
((
ResponseResult
)
proceed
).
getData
().
toString
();
downloadTaskService
.
updateDownloadTask
(
taskId
,
100
,
DownloadTask
.
Status
.
FINISH
.
getName
(),
fileAddress
);
return
proceed
;
}
}
src/main/java/com/zhiwei/brandkbs2/auth/AuthAspect.java
View file @
31c97c4e
...
...
@@ -18,6 +18,7 @@ import org.aspectj.lang.annotation.Aspect;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
...
...
@@ -38,6 +39,7 @@ import java.util.Map;
*/
@Aspect
@Component
@Order
(
1
)
public
class
AuthAspect
{
public
static
final
Logger
log
=
LogManager
.
getLogger
(
AuthAspect
.
class
);
...
...
src/main/java/com/zhiwei/brandkbs2/controller/admin/EventController.java
View file @
31c97c4e
...
...
@@ -44,6 +44,8 @@ import java.util.Set;
@RequestMapping
(
"/admin/event"
)
@Api
(
tags
=
"事件管理"
,
description
=
"提供事件的增、删、改、查等功能"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
@Deprecated
// 事件后台管理已下线,改用事件中间件
public
class
EventController
extends
BaseController
{
@Resource
(
name
=
"eventServiceImpl"
)
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppCrisisController.java
View file @
31c97c4e
...
...
@@ -26,6 +26,8 @@ import org.springframework.web.client.RestTemplate;
@RequestMapping
(
"/app/crisis"
)
@Api
(
tags
=
"前台危机库"
,
description
=
"提供前台危机相关信息展示"
)
@Auth
(
role
=
RoleEnum
.
CUSTOMER
)
@Deprecated
// 2023/9/7 全部迁移至事件模块
public
class
AppCrisisController
extends
BaseController
{
@Value
(
"${crisis.searchTags.url}"
)
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppDownloadController.java
0 → 100644
View file @
31c97c4e
package
com
.
zhiwei
.
brandkbs2
.
controller
.
app
;
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.*
;
import
com.zhiwei.brandkbs2.enmus.RoleEnum
;
import
com.zhiwei.brandkbs2.model.ResponseResult
;
import
com.zhiwei.brandkbs2.pojo.AbstractProject
;
import
com.zhiwei.brandkbs2.pojo.WholeSearchRecord
;
import
com.zhiwei.brandkbs2.pojo.dto.*
;
import
com.zhiwei.brandkbs2.pojo.vo.ProjectVO
;
import
com.zhiwei.brandkbs2.service.*
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
io.swagger.annotations.*
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.joda.time.Period
;
import
org.joda.time.PeriodType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RestController
@RequestMapping
(
"/app/download"
)
@Api
(
tags
=
"下载功能"
,
description
=
"提供项目所有的下载内容"
)
@Auth
(
role
=
RoleEnum
.
CUSTOMER
)
public
class
AppDownloadController
extends
BaseController
{
public
static
final
Logger
log
=
LogManager
.
getLogger
(
AppDownloadController
.
class
);
@Resource
(
name
=
"projectServiceImpl"
)
private
ProjectService
projectService
;
@Resource
(
name
=
"highlightWordServiceImpl"
)
HighlightWordService
highlightWordService
;
@Resource
(
name
=
"highWordServiceImpl"
)
HighWordService
highWordService
;
@Resource
(
name
=
"behaviorServiceImpl"
)
private
BehaviorService
behaviorService
;
@Resource
(
name
=
"channelServiceImpl"
)
ChannelService
channelService
;
@Resource
(
name
=
"wholeSearchServiceImpl"
)
private
WholeSearchService
wholeSearchService
;
@Resource
(
name
=
"markDataServiceImpl"
)
MarkDataService
markDataService
;
@Resource
(
name
=
"commonServiceImpl"
)
CommonService
commonService
;
@Value
(
"${qbjc.interface.url}"
)
private
String
yuqingInterface
;
@Value
(
"${qbjc.interface.upload.token}"
)
private
String
token
;
@Value
(
"${brandkbs.file.url}"
)
private
String
brandkbsFilePath
;
@Autowired
private
RestTemplate
restTemplate
;
@ApiOperation
(
"稿件模板"
)
@ApiImplicitParams
(
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
paramType
=
"query"
,
dataType
=
"string"
))
@GetMapping
(
"/back/template/article"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadTemplateForm
(
@RequestParam
(
defaultValue
=
"0"
)
String
contendId
)
{
try
{
AbstractProject
project
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
);
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
getHeaders
());
HttpEntity
<
org
.
springframework
.
core
.
io
.
Resource
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/template/form?projectId="
+
project
.
getBrandLinkedGroupId
(),
HttpMethod
.
GET
,
requestEntity
,
org
.
springframework
.
core
.
io
.
Resource
.
class
);
String
fileAddress
=
null
;
if
(
null
!=
entity
.
getBody
())
{
String
fileName
=
getFileNamePrefix
()
+
project
.
getBrandName
()
+
"_稿件模板"
;
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
entity
.
getBody
().
getInputStream
());
}
return
ResponseResult
.
success
(
fileAddress
);
}
catch
(
Exception
e
)
{
log
.
error
(
"稿件上传-稿件模板下载异常"
,
e
);
return
ResponseResult
.
failure
(
"稿件上传-稿件模板下载异常"
);
}
}
@ApiOperation
(
"表格上传信息"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"formType"
,
value
=
"表格类型:上传失败/上传成功"
,
paramType
=
"body"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"id"
,
value
=
"任务id"
,
paramType
=
"body"
,
dataType
=
"string"
)})
@PostMapping
(
value
=
"/back/template/form"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadUploadList
(
@RequestBody
JSONObject
info
)
{
try
{
String
id
=
info
.
getString
(
"id"
);
String
formType
=
info
.
getString
(
"formType"
);
HttpEntity
<
JSONObject
>
requestEntity
=
new
HttpEntity
<>(
getHeaders
());
HttpEntity
<
org
.
springframework
.
core
.
io
.
Resource
>
entity
=
restTemplate
.
exchange
(
yuqingInterface
+
"/upload/list/download/file/"
+
id
+
"?formType="
+
formType
,
HttpMethod
.
GET
,
requestEntity
,
org
.
springframework
.
core
.
io
.
Resource
.
class
);
String
fileAddress
=
null
;
if
(
null
!=
entity
.
getBody
())
{
String
fileName
=
getFileNamePrefix
()
+
id
+
"_"
+
formType
;
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
entity
.
getBody
().
getInputStream
());
}
return
ResponseResult
.
success
(
fileAddress
);
}
catch
(
Exception
e
)
{
log
.
error
(
"稿件上传-下载表格上传信息"
,
e
);
return
ResponseResult
.
failure
(
"稿件上传下载表格上传信息"
);
}
}
@ApiOperation
(
"高频关键词"
)
@GetMapping
(
value
=
"/back/module/high-word"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadHighWord
()
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
List
<
ExportWordDTO
>
list
=
highWordService
.
downloadWord
(
projectId
);
ProjectVO
projectVO
=
projectService
.
getProjectVOById
(
projectId
);
String
fileName
=
getFileNamePrefix
()
+
projectVO
.
getBrandName
()
+
"_高频关键词"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportWordDTO
.
class
,
list
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"舆情列表高亮关键词"
)
@GetMapping
(
value
=
"/back/module/highlight-word"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadHighlightWord
()
{
String
projectId
=
UserThreadLocal
.
getProjectId
();
List
<
ExportWordDTO
>
list
=
highlightWordService
.
downloadWord
(
projectId
);
ProjectVO
projectVO
=
projectService
.
getProjectVOById
(
projectId
);
String
fileName
=
getFileNamePrefix
()
+
projectVO
.
getBrandName
()
+
"_舆情列表高亮关键词"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportWordDTO
.
class
,
list
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"用户行为列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"behavior"
,
value
=
"行为所属(前台=false,后台=true)"
,
defaultValue
=
"true"
,
paramType
=
"query"
,
dataType
=
"boolean"
)
})
@GetMapping
(
"/back/behavior/behavior"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
download
(
@RequestParam
(
"startTime"
)
long
startTime
,
@RequestParam
(
"endTime"
)
long
endTime
,
@RequestParam
(
value
=
"behavior"
,
defaultValue
=
"true"
)
boolean
behavior
)
{
List
<
ExportBehaviorDTO
>
downloadList
=
behaviorService
.
download
(
startTime
,
endTime
,
behavior
);
String
behaviorName
=
behavior
?
"后台"
:
"前台"
;
String
sheetName
=
projectService
.
getProjectVOById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
()
+
"_"
+
behaviorName
;
String
fileName
=
getFileNamePrefix
()
+
behaviorName
+
"_用户行为"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
sheetName
,
ExportBehaviorDTO
.
class
,
downloadList
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"用户操作记录列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
})
@GetMapping
(
"/back/behavior/log-record"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadLogRecordList
(
@RequestParam
(
"startTime"
)
long
startTime
,
@RequestParam
(
"endTime"
)
long
endTime
)
{
List
<
ExportUserLogRecordDTO
>
list
=
behaviorService
.
downloadUserLogRecord
(
startTime
,
endTime
);
String
sheetName
=
projectService
.
getProjectVOById
(
UserThreadLocal
.
getProjectId
()).
getProjectName
()
+
"_操作记录"
;
String
fileName
=
getFileNamePrefix
()
+
"操作记录"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
sheetName
,
ExportUserLogRecordDTO
.
class
,
list
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"渠道列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌id"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"emotion"
,
value
=
"倾向筛选"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"platform"
,
value
=
"平台筛选"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"show"
,
value
=
"是否展示"
,
paramType
=
"query"
,
dataType
=
"boolean"
),
@ApiImplicitParam
(
name
=
"keyword"
,
value
=
"关键字搜索"
,
paramType
=
"query"
,
dataType
=
"string"
)
})
@GetMapping
(
"/back/channel/list"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadChannelList
(
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
,
@RequestParam
(
value
=
"emotion"
,
defaultValue
=
""
)
String
emotion
,
@RequestParam
(
value
=
"platform"
,
defaultValue
=
""
)
String
platform
,
@RequestParam
(
value
=
"show"
,
required
=
false
)
Boolean
show
,
@RequestParam
(
value
=
"keyword"
,
defaultValue
=
""
)
String
keyword
)
{
List
<
ExportChannelDTO
>
downloadChannelList
=
channelService
.
findDownloadChannelList
(
contendId
,
emotion
,
platform
,
show
,
keyword
);
String
brandName
=
projectService
.
getProjectByContendId
(
UserThreadLocal
.
getProjectId
(),
contendId
).
getBrandName
();
String
fileName
=
getFileNamePrefix
()
+
brandName
+
"_渠道列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
brandName
,
ExportChannelDTO
.
class
,
downloadChannelList
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"渠道稿件列表"
)
@ApiImplicitParam
(
name
=
"channelId"
,
value
=
"渠道ID"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"String"
)
@GetMapping
(
"/back/channel/article"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadArticleList
(
@RequestParam
(
value
=
"channelId"
)
String
channelId
)
{
List
<
ExportAdminChannelArticleDTO
>
downloadChannelArticleList
=
channelService
.
findDownloadChannelArticleList
(
channelId
);
String
fileName
=
getFileNamePrefix
()
+
channelId
+
"_渠道稿件列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
channelId
,
ExportAdminChannelArticleDTO
.
class
,
downloadChannelArticleList
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"渠道事件列表"
)
@ApiImplicitParam
(
name
=
"channelId"
,
value
=
"渠道ID"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"String"
)
@GetMapping
(
"/back/channel/event"
)
@Auth
(
role
=
RoleEnum
.
COMMON_ADMIN
)
public
ResponseResult
downloadEventList
(
@RequestParam
(
value
=
"channelId"
)
String
channelId
)
{
List
<
ExportAdminChannelEventDTO
>
downloadChannelEventList
=
channelService
.
findDownloadChannelEventList
(
channelId
);
String
fileName
=
getFileNamePrefix
()
+
channelId
+
"_渠道事件列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
channelId
,
ExportAdminChannelEventDTO
.
class
,
downloadChannelEventList
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"全网搜使用记录"
)
@PostMapping
(
"/back/search-whole/used"
)
@Auth
(
role
=
RoleEnum
.
ADMIN
)
public
ResponseResult
downloadUseList
(
@ApiParam
(
name
=
"json:{personal:个人明细=true,startTime:起始时间,endTime:结束时间,day:颗粒度天级=true}"
)
@RequestBody
JSONObject
json
)
{
boolean
personal
=
json
.
getBooleanValue
(
"personal"
);
Long
startTime
=
json
.
getLong
(
"startTime"
);
Long
endTime
=
json
.
getLong
(
"endTime"
);
boolean
day
=
json
.
getBooleanValue
(
"day"
);
List
<
JSONObject
>
collect
=
wholeSearchService
.
outputUsedList
(
personal
,
startTime
,
endTime
,
day
);
String
fileName
=
getFileNamePrefix
()
+
startTime
+
"_"
+
endTime
+
"使用记录"
;
String
fileAddress
=
null
;
if
(
personal
)
{
List
<
ExportWholeSearchRecordDTO
>
list
=
collect
.
stream
().
map
(
ExportWholeSearchRecordDTO:
:
createFromJSONObject
).
collect
(
Collectors
.
toList
());
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet"
,
ExportWholeSearchRecordDTO
.
class
,
list
);
}
else
{
List
<
ExportLineDTO
>
list
=
collect
.
stream
().
map
(
ExportLineDTO:
:
createFromJSONObject
).
collect
(
Collectors
.
toList
());
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet"
,
ExportLineDTO
.
class
,
list
);
}
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"项目关键词"
)
@ApiImplicitParam
(
name
=
"pid"
,
value
=
"项目ID"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"string"
)
@GetMapping
(
"/back/project/keyword/{pid}"
)
@Auth
(
role
=
RoleEnum
.
SUPER_ADMIN
)
public
ResponseResult
downloadArticles
(
@PathVariable
(
"pid"
)
String
pid
)
{
ProjectVO
project
=
projectService
.
getProjectVOById
(
pid
);
String
fileName
=
getFileNamePrefix
()
+
project
.
getBrandName
()
+
"_命中关键词"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
UploadKeywordDTO
.
class
,
UploadKeywordDTO
.
change2This
(
project
.
getHitKeywords
()));
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"舆情库原始数据"
)
@PostMapping
(
value
=
"/yuqing/origin"
)
@LogRecord
(
description
=
"舆情库-原始数据导出"
,
values
=
{
"startTime"
,
"endTime"
,
"keyword"
,
"platforms"
,
"searchField"
},
entity
=
true
,
arguments
=
true
)
public
ResponseResult
exportOriginList
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
Pair
<
String
,
List
<
ExportAppYuqingDTO
>>
stringListPair
=
markDataService
.
downloadYuqingMarkList
(
markSearchDTO
);
String
fileName
=
getFileNamePrefix
()
+
stringListPair
.
getLeft
()
+
"_原始数据列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportAppYuqingDTO
.
class
,
stringListPair
.
getRight
());
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"舆情库有效舆情数据"
)
@PostMapping
(
value
=
"/yuqing/mark"
)
@LogRecord
(
description
=
"舆情库-有效舆情导出"
,
values
=
{
"startTime"
,
"endTime"
,
"customTags"
,
"field"
,
"keyword"
,
"politicsLevel"
,
"mainBodyType"
,
"platforms"
,
"region"
,
"tags"
},
entity
=
true
,
arguments
=
true
)
public
ResponseResult
exportYuqingMarkList
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
Pair
<
String
,
List
<
ExportAppYuqingDTO
>>
stringListPair
=
markDataService
.
downloadYuqingMarkList
(
markSearchDTO
);
String
fileName
=
getFileNamePrefix
()
+
stringListPair
.
getLeft
()
+
"_舆情列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportAppYuqingDTO
.
class
,
stringListPair
.
getRight
());
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"渠道库文章列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"channelId"
,
value
=
"渠道ID"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"品牌ID"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
)
})
@GetMapping
(
"/channel/article"
)
public
ResponseResult
downloadArticles
(
@RequestParam
(
value
=
"startTime"
)
long
startTime
,
@RequestParam
(
value
=
"endTime"
)
long
endTime
,
@RequestParam
(
"channelId"
)
String
channelId
,
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
)
{
List
<
ExportAppChannelArticleDTO
>
exportAppChannelArticleDTOS
=
channelService
.
downloadArticlesByTime
(
startTime
,
endTime
,
channelId
,
contendId
);
String
fileName
=
getFileNamePrefix
()
+
channelId
+
"稿件列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportAppChannelArticleDTO
.
class
,
exportAppChannelArticleDTOS
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"渠道库事件列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"startTime"
,
value
=
"开始时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"endTime"
,
value
=
"结束时间"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"long"
),
@ApiImplicitParam
(
name
=
"channelId"
,
value
=
"渠道ID"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"contendId"
,
value
=
"竞品ID"
,
defaultValue
=
"0"
,
paramType
=
"query"
,
dataType
=
"string"
)
})
@GetMapping
(
"/channel/event"
)
public
ResponseResult
downloadEvents
(
@RequestParam
(
value
=
"startTime"
)
long
startTime
,
@RequestParam
(
value
=
"endTime"
)
long
endTime
,
@RequestParam
(
"channelId"
)
String
channelId
,
@RequestParam
(
value
=
"contendId"
,
defaultValue
=
"0"
)
String
contendId
)
{
List
<
ExportAppChannelEventDTO
>
exportAppChannelEventDTOS
=
channelService
.
downloadEventsByTime
(
startTime
,
endTime
,
channelId
,
contendId
);
String
fileName
=
getFileNamePrefix
()
+
channelId
+
"事件列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportAppChannelEventDTO
.
class
,
exportAppChannelEventDTOS
);
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"竞品库竞品舆情"
)
@PostMapping
(
value
=
"/contend/mark"
)
public
ResponseResult
exportContendMarkList
(
@RequestBody
MarkSearchDTO
markSearchDTO
)
{
Pair
<
String
,
List
<
ExportAppYuqingDTO
>>
stringListPair
=
markDataService
.
downloadContendMarkList
(
markSearchDTO
);
String
fileName
=
getFileNamePrefix
()
+
stringListPair
.
getLeft
()
+
"_舆情列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportAppYuqingDTO
.
class
,
stringListPair
.
getRight
());
return
ResponseResult
.
success
(
fileAddress
);
}
@ApiOperation
(
"全网搜舆情"
)
@PostMapping
(
"/search-whole"
)
@LogRecord
(
description
=
"全网搜-舆情导出"
,
values
=
{
"startTime"
,
"endTime"
,
"fans"
,
"filterType"
,
"filterWords"
,
"search"
,
"keyword"
,
"platforms"
,
"sensitiveChannels"
,
"sourceKeyword"
},
entity
=
true
,
arguments
=
true
)
public
ResponseResult
exportSearchWhole
(
@RequestBody
SearchFilterDTO
dto
)
{
// 针对商业数据库做限制
if
(
dto
.
isExternalDataSource
())
{
long
time
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
();
if
(
time
>
dto
.
getStartTime
())
{
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return
ResponseResult
.
failure
(
"仅能导出近3个月内信息"
);
}
Period
periodDay
=
new
Period
(
dto
.
getStartTime
(),
dto
.
getEndTime
(),
PeriodType
.
days
());
if
(
periodDay
.
getDays
()
>
30
)
{
// 仅对查商业数据库时限制时间,查舆情库时本质上无时间限制
return
ResponseResult
.
failure
(
"时间跨度不能超过30天"
);
}
if
(
dto
.
getOutputCount
()
>=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getWholeSearchBalance
())
{
return
ResponseResult
.
failure
(
"实时采集余额不足"
);
}
}
List
<
ExportSearchWholeDTO
>
exportList
=
markDataService
.
exportSearchWhole
(
dto
);
String
fileName
=
getFileNamePrefix
()
+
"全网搜舆情列表数据"
;
String
fileAddress
=
EasyExcelUtil
.
saveExcelWithPath
(
brandkbsFilePath
,
fileName
,
"sheet1"
,
ExportSearchWholeDTO
.
class
,
exportList
);
if
(
dto
.
isExternalDataSource
())
{
wholeSearchService
.
decreaseRecord
(
dto
.
getSearch
(),
WholeSearchRecord
.
UsedType
.
output
,
exportList
.
size
());
}
return
ResponseResult
.
success
(
fileAddress
);
}
private
HttpHeaders
getHeaders
()
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
set
(
"token"
,
token
);
httpHeaders
.
set
(
"Content-Type"
,
"application/json"
);
return
httpHeaders
;
}
private
String
getFileNamePrefix
(){
return
UserThreadLocal
.
getProjectId
()
+
"_"
+
UserThreadLocal
.
getNickname
()
+
"_"
+
System
.
currentTimeMillis
()
+
"_"
;
}
}
src/main/java/com/zhiwei/brandkbs2/controller/app/AppEventController.java
View file @
31c97c4e
...
...
@@ -52,6 +52,18 @@ public class AppEventController extends BaseController {
@Value
(
"${ef.checkCaptcha.url}"
)
private
String
efCheckCaptchaUrl
;
@Value
(
"${crisis.top3.url}"
)
private
String
crisisTop3Url
;
@Value
(
"${crisis.searchCriteria.url}"
)
private
String
crisisSearchCriteriaUrl
;
@Value
(
"${crisis.list.url}"
)
private
String
crisisListUrl
;
@Value
(
"${crisis.share.url}"
)
private
String
crisisEventShareUrl
;
private
final
EventService
eventService
;
public
AppEventController
(
EventService
eventService
)
{
...
...
@@ -105,7 +117,7 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
eventService
.
getEventTopArticlesAnalysis
(
id
,
type
,
emotion
,
aggTitle
));
}
@ApiOperation
(
"前台事件库-全网事件库-搜索"
)
@ApiOperation
(
"前台事件库-全网事件库-
行业热点-
搜索"
)
@GetMapping
(
"/getWholeNetworkEvents"
)
public
ResponseResult
getWholeNetworkEvents
(
@RequestParam
(
"keyword"
)
String
keyword
,
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
)
{
...
...
@@ -115,7 +127,7 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
jsonObject
);
}
@ApiOperation
(
"前台事件库-全网事件库-搜索条件"
)
@ApiOperation
(
"前台事件库-全网事件库-
行业热点-
搜索条件"
)
@GetMapping
(
"/getWholeNetworkSearchCriteria"
)
public
ResponseResult
getWholeNetworkSearchCriteria
()
{
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
getEfSearchCriteriaUrl
,
String
.
class
);
...
...
@@ -123,8 +135,8 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
jsonObject
);
}
@ApiOperation
(
"前台事件库-全网事件库-列表"
)
@LogRecord
(
description
=
"事件库-全网事件库"
)
@ApiOperation
(
"前台事件库-全网事件库-
行业热点-
列表"
)
@LogRecord
(
description
=
"事件库-全网事件库
-行业热点
"
)
@GetMapping
(
"/getWholeNetworkEventsList"
)
public
ResponseResult
getWholeNetworkEventsList
(
@RequestParam
(
value
=
"firstType"
,
required
=
false
,
defaultValue
=
""
)
String
firstType
,
@RequestParam
(
value
=
"start"
,
required
=
false
,
defaultValue
=
"0"
)
long
start
,
...
...
@@ -135,7 +147,7 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
jsonObject
);
}
@ApiOperation
(
"前台事件库-全网事件库-得到验证码"
)
@ApiOperation
(
"前台事件库-全网事件库-
行业热点-
得到验证码"
)
@GetMapping
(
"/getWholeNetworkCaptcha"
)
public
ResponseResult
getWholeNetworkCaptcha
()
{
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
efCaptchaUrl
,
String
.
class
);
...
...
@@ -143,7 +155,7 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
jsonObject
);
}
@ApiOperation
(
"前台事件库-全网事件库-校验验证码"
)
@ApiOperation
(
"前台事件库-全网事件库-
行业热点-
校验验证码"
)
@GetMapping
(
"/checkWholeNetworkCaptcha"
)
public
ResponseResult
checkWholeNetworkCaptcha
(
@RequestParam
(
value
=
"id"
,
required
=
false
,
defaultValue
=
""
)
String
id
,
@RequestParam
(
value
=
"captcha"
,
required
=
false
,
defaultValue
=
""
)
String
captcha
)
{
...
...
@@ -152,6 +164,43 @@ public class AppEventController extends BaseController {
return
ResponseResult
.
success
(
jsonObject
);
}
@ApiOperation
(
"前台事件库-全网事件库-企业危机-近期热点危机"
)
@GetMapping
(
"/recentHotCrisis"
)
public
ResponseResult
recentHotCrisis
(){
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
crisisTop3Url
,
String
.
class
);
Object
data
=
JSON
.
parseObject
(
responseEntity
.
getBody
()).
get
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
@ApiOperation
(
"前台事件库-全网事件库-企业危机-危机搜索条件"
)
@GetMapping
(
"/crisisSearchCriteria"
)
public
ResponseResult
crisisSearchCriteria
(){
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
crisisSearchCriteriaUrl
,
String
.
class
);
Object
data
=
JSON
.
parseObject
(
responseEntity
.
getBody
()).
get
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
@ApiOperation
(
"前台事件库-全网事件库-企业危机-危机库列表"
)
@LogRecord
(
description
=
"事件库-全网事件库-企业危机"
)
@GetMapping
(
"/crisisList"
)
public
ResponseResult
crisisList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
@RequestParam
(
value
=
"startTime"
,
required
=
false
)
String
startTime
,
@RequestParam
(
value
=
"endTime"
,
required
=
false
)
String
endTime
,
@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"
);
return
ResponseResult
.
success
(
data
);
}
@ApiOperation
(
"前台事件库-全网事件库-企业危机-获取危机事件分享id"
)
@GetMapping
(
"/getCrisisEventShareId/{id}"
)
public
ResponseResult
getCrisisEventShareId
(
@PathVariable
int
id
){
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
getForEntity
(
crisisEventShareUrl
,
String
.
class
,
id
);
Object
data
=
JSON
.
parseObject
(
responseEntity
.
getBody
()).
get
(
"data"
);
return
ResponseResult
.
success
(
data
);
}
@ApiOperation
(
"关联事件"
)
@ApiImplicitParam
(
name
=
"keyword"
,
value
=
"关键词"
,
paramType
=
"query"
,
dataType
=
"String"
)
@GetMapping
(
"/getRelevanceEvent"
)
...
...
src/main/java/com/zhiwei/brandkbs2/controller/app/AppUserCenterController.java
View file @
31c97c4e
...
...
@@ -4,7 +4,10 @@ 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.pojo.DownloadTask
;
import
com.zhiwei.brandkbs2.service.DownloadTaskService
;
import
com.zhiwei.brandkbs2.service.NoticeInfoService
;
import
com.zhiwei.brandkbs2.util.Tools
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
...
...
@@ -28,6 +31,9 @@ public class AppUserCenterController extends BaseController {
@Resource
(
name
=
"noticeInfoServiceImpl"
)
private
NoticeInfoService
noticeInfoService
;
@Resource
(
name
=
"downloadTaskServiceImpl"
)
DownloadTaskService
downloadTaskService
;
@ApiOperation
(
"个人中心-系统通知-公告列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
required
=
false
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
required
=
false
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
)})
...
...
@@ -50,4 +56,30 @@ public class AppUserCenterController extends BaseController {
noticeInfoService
.
updateReadUserId
(
id
);
return
ResponseResult
.
success
();
}
@ApiOperation
(
"任务中心-下拉选项列表"
)
@GetMapping
(
"/download-task/options"
)
public
ResponseResult
getDownloadTaskCriteria
()
{
return
ResponseResult
.
success
(
downloadTaskService
.
getDownloadTaskOptions
());
}
@ApiOperation
(
"任务中心-下载任务列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
required
=
false
,
defaultValue
=
"1"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
required
=
false
,
defaultValue
=
"10"
,
paramType
=
"query"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"keyword"
,
value
=
"关键词"
,
required
=
false
,
paramType
=
"query"
,
dataType
=
"string"
)})
@GetMapping
(
"/download-task/list"
)
public
ResponseResult
getDownloadTaskList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
int
size
,
@RequestParam
(
value
=
"keyword"
,
required
=
false
)
String
keyword
)
{
return
ResponseResult
.
success
(
downloadTaskService
.
getDownloadTaskList
(
page
,
size
,
keyword
));
}
@ApiOperation
(
"任务中心-下载"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"任务id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"string"
)
@GetMapping
(
"/download-task/download/{id}"
)
public
ResponseResult
download
(
@PathVariable
String
id
)
{
DownloadTask
task
=
downloadTaskService
.
findTask
(
id
);
Tools
.
downloadFile
(
task
.
getFileAddress
(),
response
);
return
ResponseResult
.
success
();
}
}
src/main/java/com/zhiwei/brandkbs2/dao/DownloadTaskDao.java
0 → 100644
View file @
31c97c4e
package
com
.
zhiwei
.
brandkbs2
.
dao
;
import
com.zhiwei.brandkbs2.pojo.DownloadTask
;
import
org.springframework.data.mongodb.core.query.Query
;
import
java.util.List
;
/**
* @ClassName: NoticeInfoDao
* @Description NoticeInfoDao
* @author: cjz
* @date: 2023-08-08 14:49
*/
public
interface
DownloadTaskDao
extends
BaseMongoDao
<
DownloadTask
>{
List
<
String
>
findDistinct
(
Query
query
,
String
filed
);
}
src/main/java/com/zhiwei/brandkbs2/dao/impl/DownloadTaskDaoImpl.java
0 → 100644
View file @
31c97c4e
package
com
.
zhiwei
.
brandkbs2
.
dao
.
impl
;
import
com.zhiwei.brandkbs2.dao.DownloadTaskDao
;
import
com.zhiwei.brandkbs2.pojo.DownloadTask
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
(
"downloadTaskDao"
)
public
class
DownloadTaskDaoImpl
extends
BaseMongoDaoImpl
<
DownloadTask
>
implements
DownloadTaskDao
{
private
static
final
String
COLLECTION_NAME
=
"brandkbs_download_task"
;
public
DownloadTaskDaoImpl
()
{
super
(
COLLECTION_NAME
);
}
@Override
public
List
<
String
>
findDistinct
(
Query
query
,
String
filed
)
{
return
mongoTemplate
.
findDistinct
(
query
,
filed
,
COLLECTION_NAME
,
String
.
class
);
}
}
src/main/java/com/zhiwei/brandkbs2/easyexcel/EasyExcelUtil.java
View file @
31c97c4e
...
...
@@ -14,8 +14,14 @@ import org.apache.logging.log4j.Logger;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.lang.reflect.Field
;
import
java.net.URLEncoder
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.Channels
;
import
java.nio.channels.ReadableByteChannel
;
import
java.nio.channels.WritableByteChannel
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -27,6 +33,7 @@ import java.util.List;
*/
public
class
EasyExcelUtil
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
EasyExcelUtil
.
class
);
private
EasyExcelUtil
()
{
}
...
...
@@ -190,6 +197,55 @@ public class EasyExcelUtil {
}
}
/**
* 将excel文件保存至指定路径
* @param filePath
* @param fileName
* @param sheetName
* @param clazz
* @param datas
* @param <T>
*/
public
static
<
T
>
String
saveExcelWithPath
(
String
filePath
,
String
fileName
,
String
sheetName
,
Class
<
T
>
clazz
,
List
<
T
>
datas
){
try
{
formatExcelExports
(
clazz
,
datas
);
String
fileAddress
=
filePath
+
fileName
+
".xlsx"
;
FileOutputStream
out
=
new
FileOutputStream
(
fileAddress
);
EasyExcel
.
write
(
out
,
clazz
).
sheet
(
sheetName
).
doWrite
(
datas
);
return
fileAddress
;
}
catch
(
Exception
e
){
log
.
error
(
"file:{},saveExcelWithPath error:"
,
fileName
,
e
);
return
null
;
}
}
/**
* InputStream转换excel文件保存至指定路径
* @param filePath
* @param fileName
* @param input
* @return
*/
public
static
String
saveExcelWithPath
(
String
filePath
,
String
fileName
,
InputStream
input
){
try
{
String
fileAddress
=
filePath
+
fileName
+
".xlsx"
;
FileOutputStream
output
=
new
FileOutputStream
(
fileAddress
);
ReadableByteChannel
inputChannel
=
Channels
.
newChannel
(
input
);
WritableByteChannel
outputChannel
=
Channels
.
newChannel
(
output
);
ByteBuffer
buffer
=
ByteBuffer
.
allocateDirect
(
10240
);
long
size
=
0
;
while
(
inputChannel
.
read
(
buffer
)
!=
-
1
)
{
buffer
.
flip
();
size
+=
outputChannel
.
write
(
buffer
);
buffer
.
clear
();
}
return
fileAddress
;
}
catch
(
Exception
e
){
log
.
error
(
"file:{},saveExcelWithPath error:"
,
fileName
,
e
);
return
null
;
}
}
private
static
<
T
>
void
formatExcelExports
(
Class
<
T
>
clazz
,
List
<
T
>
datas
){
List
<
Field
>
stringFields
=
new
ArrayList
<>();
// 记录需要设置的部分
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/DownloadTask.java
0 → 100644
View file @
31c97c4e
package
com
.
zhiwei
.
brandkbs2
.
pojo
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
/**
* @ClassName: DownloadTask
* @Description 下载任务
* @author: cjz
* @date: 2023-09-01 12:13
*/
@Getter
@Setter
@AllArgsConstructor
public
class
DownloadTask
extends
AbstractBaseMongo
{
/**
* 任务名
*/
private
String
taskName
;
/**
* 数据内容
*/
private
String
description
;
/**
* 进度
*/
private
Integer
schedule
;
/**
* 任务状态
*/
private
String
status
;
/**
* 文件地址
*/
private
String
fileAddress
;
/**
* 项目名
*/
private
String
project
;
/**
* 项目
*/
private
String
projectId
;
/**
* 用户id
*/
private
String
userId
;
/**
* nickname
*/
private
String
nickname
;
/**
* uTime 更新时间
*/
private
Long
uTime
;
/**
* cTime 创建时间
*/
private
Long
cTime
;
@Getter
public
enum
Status
{
GENERATING
(
"generating"
,
"生成中"
),
FINISH
(
"finish"
,
"完成"
),
FAILED
(
"failed"
,
"任务失败"
);
private
String
name
;
private
String
description
;
Status
(
String
name
,
String
description
){
this
.
name
=
name
;
this
.
description
=
description
;
}
}
}
src/main/java/com/zhiwei/brandkbs2/pojo/Project.java
View file @
31c97c4e
...
...
@@ -21,11 +21,6 @@ import java.util.Map;
public
class
Project
extends
AbstractProject
{
/**
* 全网搜数据源(1:舆情库,2:商业数据库)
*/
private
Integer
wholeSearchDataSource
;
/**
* 数据起始时间(能够绑定关联关系的时间点)
*/
private
Long
importTime
;
...
...
@@ -106,7 +101,6 @@ public class Project extends AbstractProject {
projectVO
.
setId
(
this
.
getId
());
// 主品牌
projectVO
.
setProjectName
(
this
.
getProjectName
());
projectVO
.
setWholeSearchDataSource
(
this
.
getWholeSearchDataSource
());
projectVO
.
setImportTime
(
new
Date
(
this
.
getImportTime
()));
projectVO
.
setBrandName
(
this
.
getBrandName
());
projectVO
.
setBrandLinkedGroup
(
this
.
getBrandLinkedGroup
());
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/vo/ProjectVO.java
View file @
31c97c4e
...
...
@@ -38,12 +38,6 @@ public class ProjectVO {
private
String
projectName
;
/**
* 全网搜数据源(1:舆情库,2:商业数据库)
*/
@ApiModelProperty
(
"全网搜数据源(1:舆情库,2:商业数据库)"
)
private
Integer
wholeSearchDataSource
;
/**
* 数据起始时间
*/
@ApiModelProperty
(
"数据起始时间"
)
...
...
@@ -149,7 +143,6 @@ public class ProjectVO {
}
else
{
project
.
setAvatarUrl
(
this
.
getAvatarUrl
());
}
project
.
setWholeSearchDataSource
(
this
.
getWholeSearchDataSource
());
project
.
setImportTime
(
this
.
getImportTime
().
getTime
());
project
.
setHasContend
(
null
!=
this
.
getContendList
());
project
.
setContendList
(
this
.
getContendList
().
stream
().
peek
(
contend
->
{
...
...
src/main/java/com/zhiwei/brandkbs2/service/DownloadTaskService.java
0 → 100644
View file @
31c97c4e
package
com
.
zhiwei
.
brandkbs2
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.pojo.DownloadTask
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
java.util.List
;
/**
* @ClassName: DownloadTaskService
* @Description 下载任务业务接口
* @author: cjz
* @date: 2023-09-04 10:32
*/
public
interface
DownloadTaskService
{
/**
* 新建下载任务
* @param taskName
* @param description
*/
String
createDownloadTask
(
String
taskName
,
String
description
);
/**
* 更新下载任务信息
* @param id
* @param schedule
* @param status
* @param fileAddress
*/
void
updateDownloadTask
(
String
id
,
Integer
schedule
,
String
status
,
String
fileAddress
);
/**
* 获取任务中心下拉选项
* @return
*/
List
<
String
>
getDownloadTaskOptions
();
/**
* 下载任务列表
* @param page
* @param size
* @return
*/
PageVO
<
JSONObject
>
getDownloadTaskList
(
int
page
,
int
size
,
String
keyword
);
/**
* 获取单个任务
* @param id
* @return
*/
DownloadTask
findTask
(
String
id
);
}
src/main/java/com/zhiwei/brandkbs2/service/impl/DownloadTaskServiceImpl.java
0 → 100644
View file @
31c97c4e
package
com
.
zhiwei
.
brandkbs2
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zhiwei.brandkbs2.auth.UserThreadLocal
;
import
com.zhiwei.brandkbs2.dao.DownloadTaskDao
;
import
com.zhiwei.brandkbs2.pojo.DownloadTask
;
import
com.zhiwei.brandkbs2.pojo.Project
;
import
com.zhiwei.brandkbs2.pojo.vo.PageVO
;
import
com.zhiwei.brandkbs2.service.DownloadTaskService
;
import
com.zhiwei.brandkbs2.service.ProjectService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
@Service
(
"downloadTaskServiceImpl"
)
public
class
DownloadTaskServiceImpl
implements
DownloadTaskService
{
@Resource
(
name
=
"downloadTaskDao"
)
DownloadTaskDao
downloadTaskDao
;
@Resource
(
name
=
"projectServiceImpl"
)
ProjectService
projectService
;
@Resource
(
name
=
"mongoUtil"
)
private
com
.
zhiwei
.
brandkbs2
.
util
.
MongoUtil
mongoUtil
;
@Override
public
String
createDownloadTask
(
String
taskName
,
String
description
)
{
Project
project
=
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
());
long
now
=
System
.
currentTimeMillis
();
DownloadTask
task
=
new
DownloadTask
(
taskName
,
description
,
0
,
DownloadTask
.
Status
.
GENERATING
.
getName
(),
null
,
project
.
getProjectName
(),
project
.
getId
(),
UserThreadLocal
.
getUserId
(),
UserThreadLocal
.
getNickname
(),
now
,
now
);
downloadTaskDao
.
insertOne
(
task
);
return
task
.
getId
();
}
@Override
public
void
updateDownloadTask
(
String
id
,
Integer
schedule
,
String
status
,
String
fileAddress
)
{
DownloadTask
task
=
downloadTaskDao
.
findOneById
(
id
);
if
(
Objects
.
nonNull
(
schedule
)){
task
.
setSchedule
(
schedule
);
}
if
(
Objects
.
nonNull
(
status
)){
task
.
setStatus
(
status
);
}
if
(
Objects
.
nonNull
(
fileAddress
)){
task
.
setFileAddress
(
fileAddress
);
}
downloadTaskDao
.
updateOne
(
task
);
}
@Override
public
List
<
String
>
getDownloadTaskOptions
()
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()));
query
.
addCriteria
(
Criteria
.
where
(
"userId"
).
is
(
UserThreadLocal
.
getUserId
()));
List
<
String
>
tasks
=
downloadTaskDao
.
findDistinct
(
query
,
"description"
);
return
tasks
.
stream
().
sorted
().
collect
(
Collectors
.
toList
());
}
@Override
public
PageVO
<
JSONObject
>
getDownloadTaskList
(
int
page
,
int
size
,
String
keyword
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
UserThreadLocal
.
getProjectId
()));
query
.
addCriteria
(
Criteria
.
where
(
"userId"
).
is
(
UserThreadLocal
.
getUserId
()));
if
(
StringUtils
.
isNotBlank
(
keyword
))
{
query
.
addCriteria
(
Criteria
.
where
(
"description"
).
is
(
keyword
));
}
query
.
with
(
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"cTime"
));
long
total
=
downloadTaskDao
.
count
(
query
);
mongoUtil
.
start
(
page
,
size
,
query
);
List
<
DownloadTask
>
taskList
=
downloadTaskDao
.
findList
(
query
);
List
<
JSONObject
>
res
=
new
ArrayList
<>();
for
(
DownloadTask
task
:
taskList
)
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
task
.
getId
());
jsonObject
.
put
(
"taskName"
,
task
.
getTaskName
());
jsonObject
.
put
(
"description"
,
task
.
getDescription
());
jsonObject
.
put
(
"schedule"
,
task
.
getSchedule
());
jsonObject
.
put
(
"status"
,
task
.
getStatus
());
jsonObject
.
put
(
"cTime"
,
task
.
getCTime
());
res
.
add
(
jsonObject
);
}
return
PageVO
.
createPageVo
(
total
,
page
,
size
,
res
);
}
@Override
public
DownloadTask
findTask
(
String
id
)
{
return
downloadTaskDao
.
findOneById
(
id
);
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/EsSearchServiceImpl.java
View file @
31c97c4e
...
...
@@ -196,8 +196,10 @@ public class EsSearchServiceImpl implements EsSearchService {
}
helper
.
setSort
(
sort
);
// from size
if
(
null
!=
dto
.
getPageSize
())
{
helper
.
setFrom
((
dto
.
getPage
()
-
1
)
*
dto
.
getPageSize
());
helper
.
setSize
(
dto
.
getPageSize
());
}
// HighlightBuilder ???
return
helper
;
}
...
...
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
31c97c4e
...
...
@@ -1121,24 +1121,8 @@ public class MarkDataServiceImpl implements MarkDataService {
JSONObject
result
=
new
JSONObject
();
// 搜索时间
result
.
put
(
"times"
,
Arrays
.
asList
(
"今天"
,
"24小时"
,
"三天"
,
"七天"
,
"近30天"
));
result
.
put
(
"ninetyDays"
,
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
());
List
<
JSONObject
>
platformList
=
new
ArrayList
<>();
if
(
2
==
project
.
getWholeSearchDataSource
())
{
result
.
put
(
"origin"
,
"商业"
);
JSONObject
backUpPlatform
=
getBackUpPlatform
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
backUpPlatform
.
entrySet
())
{
JSONObject
platformJSONObject
=
new
JSONObject
();
platformJSONObject
.
put
(
"name"
,
entry
.
getKey
());
platformJSONObject
.
put
(
"id"
,
entry
.
getValue
());
platformList
.
add
(
platformJSONObject
);
}
}
else
{
result
.
put
(
"origin"
,
"舆情"
);
platformList
=
commonService
.
getQbjcPlatform
(
"id"
,
"name"
).
stream
().
filter
(
s
->
!
s
.
get
(
"name"
).
equals
(
"脉脉"
)).
collect
(
Collectors
.
toList
());
}
result
.
put
(
"platformList"
,
platformList
);
result
.
put
(
"platformList"
,
commonService
.
getQbjcPlatform
(
"id"
,
"name"
).
stream
().
filter
(
s
->
!
s
.
get
(
"name"
).
equals
(
"脉脉"
)).
collect
(
Collectors
.
toList
()));
return
result
;
}
...
...
src/test/java/com/zhiwei/brandkbs2/MarkDataServiceTest.java
View file @
31c97c4e
...
...
@@ -61,7 +61,7 @@ public class MarkDataServiceTest {
@Test
public
void
getYuqingMarkCriteriaTest
(){
JSONObject
yuqingMarkCriteria
=
markDataService
.
getYuqingMarkCriteria
(
null
);
JSONObject
yuqingMarkCriteria
=
markDataService
.
getYuqingMarkCriteria
();
System
.
out
.
println
(
yuqingMarkCriteria
);
}
...
...
@@ -179,9 +179,8 @@ public class MarkDataServiceTest {
@Test
public
void
searchWholeNetworkTest
(){
SearchFilterDTO
dto
=
new
SearchFilterDTO
();
dto
.
setProjectId
(
"62beadd1bbf8eb20f96d2f2f"
);
dto
.
setSearch
(
"阿里"
);
JSONObject
jsonObject
=
markDataService
.
searchWholeNetwork
(
dto
);
JSONObject
jsonObject
=
markDataService
.
searchWholeNetwork
WithBalance
(
dto
).
getLeft
(
);
System
.
out
.
println
(
jsonObject
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment