Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
fangxinjiang
yifu-mvp
Commits
4bd0566b
Commit
4bd0566b
authored
Jan 13, 2026
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
huych-电子档案批量导入第五次提交
parent
9a7278aa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
128 deletions
+71
-128
TElectronicArchiveDetailServiceImpl.java
...tch/service/impl/TElectronicArchiveDetailServiceImpl.java
+40
-75
OSSUtil.java
...com/yifu/cloud/plus/v1/yifu/common/core/util/OSSUtil.java
+31
-53
No files found.
yifu-batch/yifu-batch-biz/src/main/java/com/yifu/cloud/plus/v1/batch/service/impl/TElectronicArchiveDetailServiceImpl.java
View file @
4bd0566b
This diff is collapsed.
Click to expand it.
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/util/OSSUtil.java
View file @
4bd0566b
...
...
@@ -245,59 +245,37 @@ public class OSSUtil {
int
fileIndex
=
0
;
long
totalBytesRead
=
0
;
// #endregion
for
(
OSSObjectBean
key:
srcList
){
// #region agent log
fileIndex
++;
long
fileBytesRead
=
0
;
String
fileName
=
key
.
getName
()!=
null
?
key
.
getName
().
replace
(
"\""
,
"\\\""
).
replace
(
"\\"
,
"/"
):
"null"
;
try
{
java
.
nio
.
file
.
Files
.
write
(
java
.
nio
.
file
.
Paths
.
get
(
"e:\\IdeaProjects\\yifu_mvp\\.cursor\\debug.log"
),(
"{\"location\":\"OSSUtil.java:246\",\"message\":\"开始读取OSS文件\",\"data\":{\"fileIndex\":"
+
fileIndex
+
",\"fileName\":\""
+
fileName
+
"\",\"key\":\""
+
key
.
getKey
().
replace
(
"\""
,
"\\\""
).
replace
(
"\\"
,
"/"
)+
"\"},\"timestamp\":"
+
System
.
currentTimeMillis
()+
",\"sessionId\":\"debug-session\",\"runId\":\"run1\",\"hypothesisId\":\"H3,H5\"}\n"
).
getBytes
(
java
.
nio
.
charset
.
StandardCharsets
.
UTF_8
),
java
.
nio
.
file
.
StandardOpenOption
.
CREATE
,
java
.
nio
.
file
.
StandardOpenOption
.
APPEND
);}
catch
(
Exception
ex
){}
// #endregion
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
ossObject
=
client
.
getObject
(
bucketName
,
key
.
getKey
());
if
(
null
!=
ossObject
){
// 读取文件内容。
log
.
info
(
"Object content:"
);
inputStream
=
ossObject
.
getObjectContent
();
//添加到zip
zip
.
putNextEntry
(
new
ZipEntry
(
key
.
getName
()));
byte
[]
buf
=
new
byte
[
1024
];
int
len
;
while
((
len
=
inputStream
.
read
(
buf
))
!=
-
1
){
zip
.
write
(
buf
,
0
,
len
);
// #region agent log
fileBytesRead
+=
len
;
totalBytesRead
+=
len
;
// #endregion
}
}
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
IoUtil
.
close
(
inputStream
);
zip
.
closeEntry
();
// #region agent log
try
{
java
.
nio
.
file
.
Files
.
write
(
java
.
nio
.
file
.
Paths
.
get
(
"e:\\IdeaProjects\\yifu_mvp\\.cursor\\debug.log"
),(
"{\"location\":\"OSSUtil.java:262\",\"message\":\"OSS文件读取完成\",\"data\":{\"fileIndex\":"
+
fileIndex
+
",\"fileName\":\""
+
fileName
+
"\",\"fileBytesRead\":"
+
fileBytesRead
+
",\"totalBytesRead\":"
+
totalBytesRead
+
"},\"timestamp\":"
+
System
.
currentTimeMillis
()+
",\"sessionId\":\"debug-session\",\"runId\":\"run1\",\"hypothesisId\":\"H3,H5\"}\n"
).
getBytes
(
java
.
nio
.
charset
.
StandardCharsets
.
UTF_8
),
java
.
nio
.
file
.
StandardOpenOption
.
CREATE
,
java
.
nio
.
file
.
StandardOpenOption
.
APPEND
);}
catch
(
Exception
ex
){}
// #endregion
}
}
// 关闭OSSClient。
}
catch
(
OSSException
oe
)
{
ossexceptionlog
(
oe
);
// #region agent log
try
{
java
.
nio
.
file
.
Files
.
write
(
java
.
nio
.
file
.
Paths
.
get
(
"e:\\IdeaProjects\\yifu_mvp\\.cursor\\debug.log"
),(
"{\"location\":\"OSSUtil.java:266\",\"message\":\"OSS异常\",\"data\":{\"error\":\""
+
oe
.
getMessage
().
replace
(
"\""
,
"\\\""
).
replace
(
"\\"
,
"/"
).
substring
(
0
,
Math
.
min
(
100
,
oe
.
getMessage
().
length
()))+
"\",\"errorCode\":\""
+
oe
.
getErrorCode
()+
"\"},\"timestamp\":"
+
System
.
currentTimeMillis
()+
",\"sessionId\":\"debug-session\",\"runId\":\"run1\",\"hypothesisId\":\"H3,H5\"}\n"
).
getBytes
(
java
.
nio
.
charset
.
StandardCharsets
.
UTF_8
),
java
.
nio
.
file
.
StandardOpenOption
.
CREATE
,
java
.
nio
.
file
.
StandardOpenOption
.
APPEND
);}
catch
(
Exception
ex
){}
// #endregion
}
catch
(
ClientException
ce
)
{
clientExceptionLog
(
ce
);
// #region agent log
try
{
java
.
nio
.
file
.
Files
.
write
(
java
.
nio
.
file
.
Paths
.
get
(
"e:\\IdeaProjects\\yifu_mvp\\.cursor\\debug.log"
),(
"{\"location\":\"OSSUtil.java:268\",\"message\":\"OSS Client异常\",\"data\":{\"error\":\""
+
ce
.
getMessage
().
replace
(
"\""
,
"\\\""
).
replace
(
"\\"
,
"/"
).
substring
(
0
,
Math
.
min
(
100
,
ce
.
getMessage
().
length
()))+
"\",\"errorCode\":\""
+
ce
.
getErrorCode
()+
"\"},\"timestamp\":"
+
System
.
currentTimeMillis
()+
",\"sessionId\":\"debug-session\",\"runId\":\"run1\",\"hypothesisId\":\"H3,H5\"}\n"
).
getBytes
(
java
.
nio
.
charset
.
StandardCharsets
.
UTF_8
),
java
.
nio
.
file
.
StandardOpenOption
.
CREATE
,
java
.
nio
.
file
.
StandardOpenOption
.
APPEND
);}
catch
(
Exception
ex
){}
// #endregion
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
// #region agent log
try
{
java
.
nio
.
file
.
Files
.
write
(
java
.
nio
.
file
.
Paths
.
get
(
"e:\\IdeaProjects\\yifu_mvp\\.cursor\\debug.log"
),(
"{\"location\":\"OSSUtil.java:270\",\"message\":\"IO异常\",\"data\":{\"error\":\""
+
e
.
getMessage
().
replace
(
"\""
,
"\\\""
).
replace
(
"\\"
,
"/"
).
substring
(
0
,
Math
.
min
(
100
,
e
.
getMessage
().
length
()))+
"\",\"exceptionClass\":\""
+
e
.
getClass
().
getName
()+
"\"},\"timestamp\":"
+
System
.
currentTimeMillis
()+
",\"sessionId\":\"debug-session\",\"runId\":\"run1\",\"hypothesisId\":\"H1,H3,H4,H5\"}\n"
).
getBytes
(
java
.
nio
.
charset
.
StandardCharsets
.
UTF_8
),
java
.
nio
.
file
.
StandardOpenOption
.
CREATE
,
java
.
nio
.
file
.
StandardOpenOption
.
APPEND
);}
catch
(
Exception
ex
){}
// #endregion
}
finally
{
IoUtil
.
close
(
inputStream
);
}
}
for
(
OSSObjectBean
key:
srcList
){
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
ossObject
=
client
.
getObject
(
bucketName
,
key
.
getKey
());
if
(
null
!=
ossObject
){
// 读取文件内容。
log
.
info
(
"Object content:"
);
inputStream
=
ossObject
.
getObjectContent
();
//添加到zip
zip
.
putNextEntry
(
new
ZipEntry
(
key
.
getName
()));
byte
[]
buf
=
new
byte
[
1024
];
int
len
;
while
((
len
=
inputStream
.
read
(
buf
))
!=
-
1
){
zip
.
write
(
buf
,
0
,
len
);
}
}
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
IoUtil
.
close
(
inputStream
);
zip
.
closeEntry
();
}
}
// 关闭OSSClient。
}
catch
(
OSSException
oe
)
{
ossexceptionlog
(
oe
);
}
catch
(
ClientException
ce
)
{
clientExceptionLog
(
ce
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
IoUtil
.
close
(
inputStream
);
}
}
/**
* @author fang
...
...
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