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
d827216c
Commit
d827216c
authored
Apr 07, 2023
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新版本的下载
parent
e564d1bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
FlatQueryResultServiceImpl.java
...ud/data/hook/service/impl/FlatQueryResultServiceImpl.java
+9
-13
No files found.
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryResultServiceImpl.java
View file @
d827216c
...
@@ -53,8 +53,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
...
@@ -53,8 +53,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/** 自助指标查询服务实现
/** 自助指标查询服务实现
...
@@ -68,8 +66,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -68,8 +66,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private
static
LogPak
log
=
new
LogPak
(
FlatQueryResultServiceImpl
.
class
);
private
static
LogPak
log
=
new
LogPak
(
FlatQueryResultServiceImpl
.
class
);
/** csv / xls 下载目录 */
/** csv / xls 下载目录 */
public
static
final
String
SAVE_FOLDER
=
"/usr/local/data-hook-file"
;
//
public static final String SAVE_FOLDER = "/usr/local/data-hook-file";
//
public static final String SAVE_FOLDER = "D:\\testorder";
public
static
final
String
SAVE_FOLDER
=
"D:\\testorder"
;
public
static
final
String
HDFS_URL
=
"/data/hook"
;
public
static
final
String
HDFS_URL
=
"/data/hook"
;
...
@@ -107,7 +105,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -107,7 +105,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private
FlatQueryResultServiceImpl
()
{
private
FlatQueryResultServiceImpl
()
{
log
.
debug
(
"construct"
,
"准备初始化 FlatQuery 查询服务"
);
log
.
debug
(
"construct"
,
"准备初始化 FlatQuery 查询服务"
);
runDealHiveFile
(
3
);
//
runDealHiveFile(3);
// runDistTask(3);
// runDistTask(3);
runDownloadTask
(
3
);
runDownloadTask
(
3
);
runBalaDownloadTask
(
3
);
runBalaDownloadTask
(
3
);
...
@@ -874,15 +872,15 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -874,15 +872,15 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
List
<
String
>
xlsxFiles
=
new
ArrayList
<>();
List
<
String
>
xlsxFiles
=
new
ArrayList
<>();
AtomicInteger
count
=
new
AtomicInteger
(
0
);
AtomicInteger
count
=
new
AtomicInteger
(
0
);
AtomicReference
<
XlsxFileInfo
>
currentFile
=
new
AtomicReference
<>();
AtomicReference
<
XlsxFileInfo
>
currentFile
=
new
AtomicReference
<>();
readCsvFile
(
condition
.
getTableId
()
,
dirName
,(
cells
,
titles
,
firstFlag
)->{
readCsvFile
(
condition
,
dirName
,(
cells
,
titles
,
firstFlag
)->{
if
(
count
.
get
()==
0
)
{
if
(
count
.
get
()==
0
)
{
XlsxFileInfo
xlsxFileInfo
=
new
XlsxFileInfo
();
XlsxFileInfo
xlsxFileInfo
=
new
XlsxFileInfo
();
xlsxFileInfo
.
filepath
=
SAVE_FOLDER
+
"/"
+
task
.
getId
()
+
xlsxFiles
.
size
()
+
".xlsx"
;
xlsxFileInfo
.
filepath
=
SAVE_FOLDER
+
"/"
+
task
.
getId
()
+
xlsxFiles
.
size
()
+
".xlsx"
;
currentFile
.
set
(
xlsxFileInfo
);
currentFile
.
set
(
xlsxFileInfo
);
xlsxFiles
.
add
(
currentFile
.
get
().
filepath
);
xlsxFiles
.
add
(
currentFile
.
get
().
filepath
);
}
}
count
.
incrementAndGet
();
saveXlsSplitNew
(
currentFile
.
get
().
filepath
,
cells
,
titles
,
currentFile
.
get
(),
count
,
false
);
saveXlsSplitNew
(
currentFile
.
get
().
filepath
,
cells
,
titles
,
currentFile
.
get
(),
count
,
false
);
count
.
incrementAndGet
();
});
});
//结束
//结束
saveXlsSplitNew
(
currentFile
.
get
().
filepath
,
null
,
null
,
currentFile
.
get
(),
count
,
true
);
saveXlsSplitNew
(
currentFile
.
get
().
filepath
,
null
,
null
,
currentFile
.
get
(),
count
,
true
);
...
@@ -928,10 +926,12 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -928,10 +926,12 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
* @param dirName
* @param dirName
* @param func
* @param func
*/
*/
private
void
readCsvFile
(
String
tableId
,
String
dirName
,
DownloadFunc
func
){
private
void
readCsvFile
(
FlatQueryTaskCondition
condition
,
String
dirName
,
DownloadFunc
func
){
File
file
=
new
File
(
SAVE_FOLDER
+
"/"
+
dirName
);
File
file
=
new
File
(
SAVE_FOLDER
+
"/"
+
dirName
);
File
[]
files
=
file
.
listFiles
();
File
[]
files
=
file
.
listFiles
();
List
<
ColumnInfo
>
titles
=
null
;
List
<
ColumnInfo
>
titles
=
null
;
List
<
FlatQueryCondition
>
conditions
=
condition
.
getConditions
();
Map
<
String
,
ColumnInfo
>
columnInfoMap
=
conditions
.
stream
().
collect
(
Collectors
.
toMap
(
mid
->
mid
.
getFieldMark
(),
mid
->
new
ColumnInfo
(
mid
.
getFieldType
(),
mid
.
getFieldMark
())));
for
(
File
midFile
:
files
)
{
for
(
File
midFile
:
files
)
{
if
(!
midFile
.
getName
().
endsWith
(
"csv"
))
{
if
(!
midFile
.
getName
().
endsWith
(
"csv"
))
{
continue
;
continue
;
...
@@ -943,10 +943,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -943,10 +943,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
do
{
do
{
if
(
titles
==
null
)
{
if
(
titles
==
null
)
{
titles
=
new
ArrayList
<>();
titles
=
new
ArrayList
<>();
List
<
String
>
cellsList
=
Arrays
.
asList
(
cells
);
List
<
FlatQueryField
>
fields
=
flatQueryFieldDao
.
getFlatQueryFieldByTableId
(
tableId
);
Map
<
String
,
ColumnInfo
>
columnInfoMap
=
fields
.
stream
().
filter
(
mid
->
cellsList
.
contains
(
mid
.
getFieldName
())).
collect
(
Collectors
.
toMap
(
mid
->
mid
.
getFieldName
(),
mid
->
new
ColumnInfo
(
mid
.
getFieldType
(),
mid
.
getFieldMark
())));
for
(
String
cell
:
cells
)
{
for
(
String
cell
:
cells
)
{
logger
.
info
(
"cell:{}"
,
cell
);
logger
.
info
(
"cell:{}"
,
cell
);
titles
.
add
(
columnInfoMap
.
get
(
cell
));
titles
.
add
(
columnInfoMap
.
get
(
cell
));
...
@@ -1168,7 +1164,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -1168,7 +1164,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
cell
=
row
.
createCell
(
j
);
cell
=
row
.
createCell
(
j
);
cell
.
setCellValue
(
titles
.
get
(
j
).
getTitle
());
cell
.
setCellValue
(
titles
.
get
(
j
).
getTitle
());
}
}
return
;
count
.
incrementAndGet
()
;
}
}
...
...
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