Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-cloud
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
data-hook
gic-cloud
Commits
39d6eb99
Commit
39d6eb99
authored
Jun 07, 2022
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:自定义查询zip测试
parent
c1ac971c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
FileUtil.java
...c/main/java/com/gic/cloud/data/hook/service/FileUtil.java
+12
-0
FlatQueryResultServiceImpl.java
...ud/data/hook/service/impl/FlatQueryResultServiceImpl.java
+5
-4
FreeQueryServiceImpl.java
...ic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
+6
-3
No files found.
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/FileUtil.java
View file @
39d6eb99
package
com
.
gic
.
cloud
.
data
.
hook
.
service
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.ConfigService
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
...
...
@@ -47,4 +50,13 @@ public class FileUtil {
}
}
}
/**
* 获取限制调试
* @return
*/
public
static
Integer
getLimitSize
(){
Config
appConfig
=
ConfigService
.
getAppConfig
();
return
appConfig
.
getIntProperty
(
"xls.size.limit"
,
1000000
);
}
}
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryResultServiceImpl.java
View file @
39d6eb99
...
...
@@ -811,7 +811,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
if
(
conn
!=
null
)
{
try
{
Statement
stat
=
conn
.
createStatement
();
Integer
limitSize
=
FileUtil
.
getLimitSize
();
// stat.setQueryTimeout(60 * 1000);
stat
.
execute
(
"REFRESH TABLE "
+
condition
.
getTableId
());
// 强制刷新表结构
ResultSet
rs
=
stat
.
executeQuery
(
fullQuery
);
...
...
@@ -840,8 +840,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
else
{
// 如果指定为 XLS 格式
logger
.
info
(
"[ runDownloadTask.run ]: {}"
,
"准备生成自助指标下载文件 "
+
condition
.
getTaskId
()
+
".xlsx"
);
int
filePos
=
0
;
if
(
condition
.
getAmount
()>
XLS_SIZE
){
int
num
=
(
condition
.
getAmount
()
/
XLS_SIZE
)+(
condition
.
getAmount
()%
XLS_SIZE
>
0
?
1
:
0
);
if
(
condition
.
getAmount
()>
limitSize
){
int
num
=
(
condition
.
getAmount
()
/
limitSize
)+(
condition
.
getAmount
()%
limitSize
>
0
?
1
:
0
);
while
(
num
-->
0
)
{
originalFilePath
=
SAVE_FOLDER
+
"/"
+
condition
.
getTaskId
()+
"-"
+
filePos
+
".xlsx"
;
filePos
++;
...
...
@@ -963,6 +963,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private
void
saveXlsSplit
(
String
originalFilePath
,
ResultSetHelper
helper
,
ResultSet
rs
,
FlatQueryTaskCondition
condition
){
try
{
Integer
limitSize
=
FileUtil
.
getLimitSize
();
// String originalFilePath = SAVE_FOLDER + "/" + condition.getTaskId() + ".xlsx";
SXSSFWorkbook
wb
=
new
SXSSFWorkbook
(
100
);
// 内存中保留 100 行
Sheet
sheet
=
wb
.
createSheet
();
...
...
@@ -975,7 +976,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
// 遍历输出行
int
rowCount
=
0
;
while
(
rowCount
<
XLS_SIZE
&&
rs
.
next
())
{
while
(
rowCount
<
limitSize
&&
rs
.
next
())
{
rowCount
++;
row
=
sheet
.
createRow
(
rowCount
);
String
[]
columnValues
=
helper
.
getColumnValues
(
rs
,
true
,
""
,
""
);
...
...
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FreeQueryServiceImpl.java
View file @
39d6eb99
...
...
@@ -398,6 +398,8 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
// IF OVER
}
// FOR OVER
if
(
condition
!=
null
)
{
Integer
limitSize
=
FileUtil
.
getLimitSize
();
// 更新任务状态
DownloadTask
task
=
DownloadTaskServiceImpl
.
getInstance
().
getDownloadTaskById
(
condition
.
getTaskId
());
task
.
setStatus
(
DownloadTaskStatus
.
BUILDING
);
...
...
@@ -439,8 +441,8 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
else
{
log
.
debug
(
"runDownloadTask.run"
,
"准备生成自定义查询下载文件 "
+
condition
.
getTaskId
()
+
".xlsx"
);
int
filePos
=
0
;
if
(
condition
.
getAmount
()>
XLS_SIZE
){
int
num
=
(
condition
.
getAmount
()
/
XLS_SIZE
)+(
condition
.
getAmount
()%
XLS_SIZE
>
0
?
1
:
0
);
if
(
condition
.
getAmount
()>
limitSize
){
int
num
=
(
condition
.
getAmount
()
/
limitSize
)+(
condition
.
getAmount
()%
limitSize
>
0
?
1
:
0
);
while
(
num
-->
0
)
{
originalFilePath
=
SAVE_FOLDER
+
"/"
+
condition
.
getTaskId
()+
"-"
+
filePos
+
".xlsx"
;
filePos
++;
...
...
@@ -591,6 +593,7 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
private
void
saveXlsx
(
FreeQueryTaskCondition
condition
,
String
originalFilePath
,
ResultSet
rs
,
DownloadTask
task
)
throws
Exception
{
Integer
limitSize
=
FileUtil
.
getLimitSize
();
originalFilePath
=
SAVE_FOLDER
+
"/"
+
condition
.
getTaskId
()
+
".xlsx"
;
SXSSFWorkbook
wb
=
new
SXSSFWorkbook
(
100
);
// 内存中保留 100 行
Sheet
sheet
=
wb
.
createSheet
();
...
...
@@ -603,7 +606,7 @@ public class FreeQueryServiceImpl implements IFreeQueryService {
}
// 遍历输出行
int
rowCount
=
0
;
while
(
rs
.
next
())
{
while
(
rs
.
next
()
&&
rowCount
<
limitSize
)
{
rowCount
++;
row
=
sheet
.
createRow
(
rowCount
);
for
(
int
j
=
0
;
j
<
rs
.
getMetaData
().
getColumnCount
();
++
j
)
{
...
...
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