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
6be51646
Commit
6be51646
authored
Apr 07, 2023
by
fudahua
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-2023-04' into 'developer'
Feature 2023 04 See merge request
!83
parents
624fb42a
233a403c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
21 deletions
+36
-21
FlatQueryResultServiceImpl.java
...ud/data/hook/service/impl/FlatQueryResultServiceImpl.java
+21
-13
Test.java
gic-cloud-data-hook-service/src/test/java/Test.java
+1
-1
hdfs.java
gic-cloud-data-hook-service/src/test/java/hdfs.java
+14
-7
No files found.
gic-cloud-data-hook-service/src/main/java/com/gic/cloud/data/hook/service/impl/FlatQueryResultServiceImpl.java
View file @
6be51646
...
@@ -667,8 +667,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -667,8 +667,9 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
distService
.
scheduleAtFixedRate
(
new
Runnable
()
{
distService
.
scheduleAtFixedRate
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
String
traceId
=
UUID
.
randomUUID
().
toString
();
ProviderLocalTag
providerLocalTag
=
ProviderLocalTag
.
tag
.
get
();
ProviderLocalTag
providerLocalTag
=
ProviderLocalTag
.
tag
.
get
();
providerLocalTag
.
traceId
=
UUID
.
randomUUID
().
toString
()
;
providerLocalTag
.
traceId
=
traceId
;
logger
.
info
(
"执行hivefile"
);
logger
.
info
(
"执行hivefile"
);
try
{
try
{
String
lockKey
=
"data:hook:hive"
;
String
lockKey
=
"data:hook:hive"
;
...
@@ -683,6 +684,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -683,6 +684,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
}
RedisUtil
.
unlock
(
lockKey
);
RedisUtil
.
unlock
(
lockKey
);
downloadTasks
.
parallelStream
().
forEach
(
mid
->{
downloadTasks
.
parallelStream
().
forEach
(
mid
->{
ProviderLocalTag
localTag
=
ProviderLocalTag
.
tag
.
get
();
localTag
.
traceId
=
traceId
;
//下载处理
//下载处理
takeFileNew
(
mid
);
takeFileNew
(
mid
);
});
});
...
@@ -932,6 +935,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -932,6 +935,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private
class
XlsxFileInfo
{
private
class
XlsxFileInfo
{
String
filepath
;
String
filepath
;
SXSSFWorkbook
workbook
;
SXSSFWorkbook
workbook
;
CellStyle
yyyyMMddhhmmss
;
CellStyle
yyyyMMdd
;
}
}
...
@@ -1207,22 +1212,24 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -1207,22 +1212,24 @@ 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
());
}
}
count
.
incrementAndGet
();
}
logger
.
info
(
"{}-count:{}"
,
originalFilePath
,
count
.
get
());
SXSSFWorkbook
wb
=
xlsxFileInfo
.
workbook
;
// 内存中保留 100 行
if
(!
endFlag
)
{
Sheet
sheet
=
wb
.
getSheetAt
(
0
);
//日期
//日期
CellStyle
yyyyMMddhhmmss
=
wb
.
createCellStyle
();
CellStyle
yyyyMMddhhmmss
=
xlsxFileInfo
.
workbook
.
createCellStyle
();
DataFormat
dataFormat
=
wb
.
createDataFormat
();
DataFormat
dataFormat
=
xlsxFileInfo
.
workbook
.
createDataFormat
();
yyyyMMddhhmmss
.
setDataFormat
(
dataFormat
.
getFormat
(
"yyyy-MM-dd HH:mm:ss"
));
yyyyMMddhhmmss
.
setDataFormat
(
dataFormat
.
getFormat
(
"yyyy-MM-dd HH:mm:ss"
));
xlsxFileInfo
.
yyyyMMddhhmmss
=
yyyyMMddhhmmss
;
//日期
//日期
CellStyle
yyyyMMdd
=
wb
.
createCellStyle
();
CellStyle
yyyyMMdd
=
xlsxFileInfo
.
workbook
.
createCellStyle
();
DataFormat
yyyyMMddDataFormat
=
wb
.
createDataFormat
();
DataFormat
yyyyMMddDataFormat
=
xlsxFileInfo
.
workbook
.
createDataFormat
();
yyyyMMdd
.
setDataFormat
(
yyyyMMddDataFormat
.
getFormat
(
"yyyy-MM-dd"
));
yyyyMMdd
.
setDataFormat
(
yyyyMMddDataFormat
.
getFormat
(
"yyyy-MM-dd"
));
xlsxFileInfo
.
yyyyMMdd
=
yyyyMMdd
;
count
.
incrementAndGet
();
}
SXSSFWorkbook
wb
=
xlsxFileInfo
.
workbook
;
// 内存中保留 100 行
if
(!
endFlag
)
{
Sheet
sheet
=
wb
.
getSheetAt
(
0
);
Row
row
=
sheet
.
createRow
(
count
.
get
());
Row
row
=
sheet
.
createRow
(
count
.
get
());
for
(
int
j
=
0
;
j
<
cells
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
cells
.
length
;
j
++)
{
...
@@ -1236,10 +1243,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -1236,10 +1243,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
switch
(
type
)
{
switch
(
type
)
{
case
FlatQueryFieldType
.
DATE
:
case
FlatQueryFieldType
.
DATE
:
if
(
columnValue
.
length
()
==
10
)
{
if
(
columnValue
.
length
()
==
10
)
{
midCell
.
setCellStyle
(
yyyyMMdd
);
midCell
.
setCellStyle
(
xlsxFileInfo
.
yyyyMMdd
);
midCell
.
setCellValue
(
DateUtils
.
parseDate
(
columnValue
,
new
String
[]{
"yyyy-MM-dd"
}));
midCell
.
setCellValue
(
DateUtils
.
parseDate
(
columnValue
,
new
String
[]{
"yyyy-MM-dd"
}));
}
else
{
}
else
{
midCell
.
setCellStyle
(
yyyyMMddhhmmss
);
midCell
.
setCellStyle
(
xlsxFileInfo
.
yyyyMMddhhmmss
);
midCell
.
setCellValue
(
DateUtils
.
parseDate
(
columnValue
,
new
String
[]{
"yyyy-MM-dd HH:mm:ss"
}));
midCell
.
setCellValue
(
DateUtils
.
parseDate
(
columnValue
,
new
String
[]{
"yyyy-MM-dd HH:mm:ss"
}));
}
}
break
;
break
;
...
@@ -1258,6 +1265,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
...
@@ -1258,6 +1265,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
Integer
limitSize
=
FileUtil
.
getLimitSize
();
Integer
limitSize
=
FileUtil
.
getLimitSize
();
int
c
=
count
.
get
();
int
c
=
count
.
get
();
if
(
c
>
limitSize
||
endFlag
)
{
if
(
c
>
limitSize
||
endFlag
)
{
logger
.
info
(
"{}-count:{}"
,
originalFilePath
,
count
.
get
());
FileOutputStream
fileOut
=
new
FileOutputStream
(
originalFilePath
);
FileOutputStream
fileOut
=
new
FileOutputStream
(
originalFilePath
);
wb
.
write
(
fileOut
);
wb
.
write
(
fileOut
);
//fileOut.flush(); // SXSSFWorkbook 使用 auto-flush 模式
//fileOut.flush(); // SXSSFWorkbook 使用 auto-flush 模式
...
...
gic-cloud-data-hook-service/src/test/java/Test.java
View file @
6be51646
...
@@ -18,7 +18,7 @@ public class Test {
...
@@ -18,7 +18,7 @@ public class Test {
@org
.
junit
.
Test
@org
.
junit
.
Test
public
void
test
(){
public
void
test
(){
DownloadTask
downloadTask
=
downloadTaskService
.
getDownloadTaskById
(
"168083
2767459
"
);
DownloadTask
downloadTask
=
downloadTaskService
.
getDownloadTaskById
(
"168083
6264864
"
);
flatQueryResultService
.
takeFileNew
(
downloadTask
);
flatQueryResultService
.
takeFileNew
(
downloadTask
);
try
{
try
{
Thread
.
sleep
(
10000000000L
);
Thread
.
sleep
(
10000000000L
);
...
...
gic-cloud-data-hook-service/src/test/java/hdfs.java
View file @
6be51646
...
@@ -6,6 +6,7 @@ import org.apache.hadoop.fs.Path;
...
@@ -6,6 +6,7 @@ import org.apache.hadoop.fs.Path;
import
java.io.FileReader
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Arrays
;
public
class
hdfs
{
public
class
hdfs
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
@@ -20,14 +21,20 @@ public class hdfs {
...
@@ -20,14 +21,20 @@ public class hdfs {
// }
// }
// HDFSUtil.getInstance().downloadFile("/data/emr/order-1.csv","D:\\testorder");
// HDFSUtil.getInstance().downloadFile("/data/emr/order-1.csv","D:\\testorder");
Integer
[]
arr
=
new
Integer
[]{
1
,
2
,
3
,
4
,
5
,
6
};
Arrays
.
asList
(
arr
).
parallelStream
().
forEach
(
mid
->{
Thread
thread
=
Thread
.
currentThread
();
String
name
=
thread
.
getName
();
System
.
out
.
println
(
name
);
});
try
{
//
try{
CSVReader
csvReader
=
new
CSVReader
(
new
FileReader
(
"C:\\Users\\hua\\Desktop\\part-00000-fa2dd286-1eda-452d-91a3-a222beb0f327-c000.csv"
));
//
CSVReader csvReader = new CSVReader(new FileReader("C:\\Users\\hua\\Desktop\\part-00000-fa2dd286-1eda-452d-91a3-a222beb0f327-c000.csv"));
String
[]
cells
=
csvReader
.
readNext
();
//
String[] cells = csvReader.readNext();
System
.
out
.
println
(
cells
);
//
System.out.println(cells);
}
catch
(
Exception
e
)
{
//
}catch (Exception e) {
//
}
//
}
}
}
}
}
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