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
1b1f6d42
Commit
1b1f6d42
authored
Mar 03, 2023
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' into 'master'
Release See merge request
!237
parents
71303afd
917a3985
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
8 deletions
+38
-8
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
+12
-3
src/main/java/com/zhiwei/brandkbs2/pojo/dto/ExportSearchWholeDTO.java
+5
-3
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
+21
-2
No files found.
src/main/java/com/zhiwei/brandkbs2/controller/app/AppSearchController.java
View file @
1b1f6d42
...
...
@@ -152,9 +152,18 @@ public class AppSearchController extends BaseController {
@ApiOperation
(
"搜索-全网搜-舆情导出"
)
@PostMapping
(
"/exportSearchWhole"
)
public
ResponseResult
exportSearchWhole
(
@RequestBody
SearchFilterDTO
dto
)
{
long
time
=
DateUtils
.
addDays
(
Tools
.
truncDate
(
new
Date
(),
Constant
.
DAY_PATTERN
),
-
89
).
getTime
();
if
(
time
>
dto
.
getStartTime
())
{
return
ResponseResult
.
failure
(
"仅能导出近3个月内信息"
);
// 针对商业数据库做限制
if
(
2
==
projectService
.
getProjectById
(
UserThreadLocal
.
getProjectId
()).
getWholeSearchDataSource
())
{
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天"
);
}
}
List
<
ExportSearchWholeDTO
>
exportList
=
markDataService
.
exportSearchWhole
(
dto
);
EasyExcelUtil
.
download
(
"全网搜舆情列表数据"
,
"sheet1"
,
ExportSearchWholeDTO
.
class
,
exportList
,
response
);
...
...
src/main/java/com/zhiwei/brandkbs2/pojo/dto/ExportSearchWholeDTO.java
View file @
1b1f6d42
...
...
@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Data
;
import
lombok.ToString
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Date
;
...
...
@@ -43,9 +44,10 @@ public class ExportSearchWholeDTO {
dto
.
setTime
(
new
Date
((
Long
)
jsonObject
.
get
(
"time"
)));
dto
.
setPlatform
(
jsonObject
.
getString
(
"platform"
));
dto
.
setChannel
(
jsonObject
.
getString
(
"channel"
));
dto
.
setTitle
(
jsonObject
.
getString
(
"title"
));
dto
.
setContent
(
jsonObject
.
getString
(
"content"
));
dto
.
setUrl
(
jsonObject
.
getString
(
"url"
));
// 截取为excel单元格允许的最大长度
dto
.
setTitle
(
StringUtils
.
substring
(
jsonObject
.
getString
(
"title"
),
0
,
32767
));
dto
.
setContent
(
StringUtils
.
substring
(
jsonObject
.
getString
(
"content"
),
0
,
32767
));
dto
.
setUrl
(
StringUtils
.
substring
(
jsonObject
.
getString
(
"url"
),
0
,
32767
));
return
dto
;
}
}
src/main/java/com/zhiwei/brandkbs2/service/impl/MarkDataServiceImpl.java
View file @
1b1f6d42
...
...
@@ -131,6 +131,9 @@ public class MarkDataServiceImpl implements MarkDataService {
@Resource
(
name
=
"channelDao"
)
ChannelDao
channelDao
;
@Resource
(
name
=
"userServiceImpl"
)
private
UserService
userService
;
@Resource
(
name
=
"redisUtil"
)
RedisUtil
redisUtil
;
...
...
@@ -1337,8 +1340,24 @@ public class MarkDataServiceImpl implements MarkDataService {
@Override
public
List
<
ExportSearchWholeDTO
>
exportSearchWhole
(
SearchFilterDTO
dto
)
{
JSONObject
jsonObject
=
searchWholeNetwork
(
dto
);
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"list"
);
Integer
exportAmount
=
userService
.
queryUserInfo
(
UserThreadLocal
.
getUserId
(),
UserThreadLocal
.
getProjectId
()).
getExportAmount
();
exportAmount
=
Objects
.
isNull
(
exportAmount
)
?
10000
:
exportAmount
;
JSONArray
jsonArray
=
new
JSONArray
();
dto
.
setPageSize
(
50
);
dto
.
setPage
(
1
);
while
(
true
){
if
(
dto
.
getPage
()
*
dto
.
getPageSize
()
>
exportAmount
){
break
;
}
// 获取当页数据
JSONObject
jsonObject
=
searchWholeNetwork
(
dto
);
JSONArray
array
=
jsonObject
.
getJSONArray
(
"list"
);
if
(
Objects
.
isNull
(
array
)
||
0
==
array
.
size
()){
break
;
}
jsonArray
.
addAll
(
array
);
dto
.
setPage
(
dto
.
getPage
()
+
1
);
}
return
jsonArray
.
stream
().
map
(
json
->
ExportSearchWholeDTO
.
creatExportSearchWholeDTO
((
JSONObject
)
json
)).
collect
(
Collectors
.
toList
());
}
...
...
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