Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TDLCloud
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
WitCloud
TDLCloud
Commits
b99db0ec
Commit
b99db0ec
authored
Jun 27, 2018
by
chenying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6.27修改下载仓库数据接口
parent
4703944b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
18 deletions
+22
-18
AliyunOSSClientUtil.java
src/main/java/com/example/tdl/util/AliyunOSSClientUtil.java
+10
-2
AlarmDataController.java
src/main/java/com/example/tdl/web/AlarmDataController.java
+1
-1
DownloadController.java
src/main/java/com/example/tdl/web/DownloadController.java
+11
-15
No files found.
src/main/java/com/example/tdl/util/AliyunOSSClientUtil.java
View file @
b99db0ec
...
...
@@ -117,6 +117,14 @@ public class AliyunOSSClientUtil {
AliyunOSSClientUtil
.
FOLDER4
=
FOLDER4
;
}
public
static
String
getFOLDER5
()
{
return
FOLDER5
;
}
public
static
void
setFOLDER5
(
String
FOLDER5
)
{
AliyunOSSClientUtil
.
FOLDER5
=
FOLDER5
;
}
/**
* 获取阿里云OSS客户端对象
* @return ossClient
...
...
@@ -358,7 +366,7 @@ public class AliyunOSSClientUtil {
putResult
=
ossClient
.
putObject
(
BACKET_NAME
,
FOLDER3
+
fileName
,
is
,
metadata
);
}
else
if
(
fileName
.
contains
(
"CHN"
)){
putResult
=
ossClient
.
putObject
(
BACKET_NAME
,
FOLDER4
+
fileName
,
is
,
metadata
);
}
else
if
(
fileName
.
contains
(
"仓库温湿度观测记录
表
"
)){
}
else
if
(
fileName
.
contains
(
"仓库温湿度观测记录"
)){
putResult
=
ossClient
.
putObject
(
BACKET_NAME
,
FOLDER5
+
fileName
,
is
,
metadata
);
}
else
{
putResult
=
ossClient
.
putObject
(
BACKET_NAME
,
FOLDER1
+
fileName
,
is
,
metadata
);
...
...
@@ -408,7 +416,7 @@ public class AliyunOSSClientUtil {
//初始化OSSClient
OSSClient
ossClient
=
AliyunOSSClientUtil
.
getOSSClient
();
//上传文件
String
files
=
"
D://专用工具登记表-761923471.xls
"
;
String
files
=
"
E://仓库温湿度观测记录-1529909289444.zip
"
;
File
filess
=
new
File
(
files
);
String
md5key
=
AliyunOSSClientUtil
.
uploadObject2OSS
(
ossClient
,
filess
);
logger
.
info
(
"上传后的文件MD5数字唯一签名:"
+
md5key
);
...
...
src/main/java/com/example/tdl/web/AlarmDataController.java
View file @
b99db0ec
...
...
@@ -220,7 +220,7 @@ public class AlarmDataController {
zipCom
.
zip
();
try
{
OSSClient
ossClient
=
AliyunOSSClientUtil
.
getOSSClient
();
String
resultStr
=
AliyunOSSClientUtil
.
uploadObject2OSS
(
ossClient
,
new
File
(
file
+
".zip"
));
String
resultStr
=
AliyunOSSClientUtil
.
uploadObject2OSS
(
ossClient
,
new
File
(
file
+
".zip"
));
if
(
new
File
(
file
+
".xls"
).
delete
()){
fb
.
setCode
(
1
);
fb
.
setMessage
(
"https://witcloud-oss.oss-cn-shanghai.aliyuncs.com/tdlAlarmData/"
+
fileName
+
".zip"
);
...
...
src/main/java/com/example/tdl/web/DownloadController.java
View file @
b99db0ec
...
...
@@ -98,7 +98,7 @@ public class DownloadController {
}
String
sqls
=
""
;
String
fileName
=
""
;
String
name
=
"仓库温湿度观测记录
"
+
System
.
currentTimeMillis
();
String
name
=
downloadForWarehouseVo
.
getWarehouseNo
()+
"仓库温湿度观测记录-
"
+
System
.
currentTimeMillis
();
File
file
=
new
File
(
"E:"
+
File
.
separator
+
name
);
if
(!
file
.
exists
())
{
file
.
mkdir
();
...
...
@@ -129,24 +129,20 @@ public class DownloadController {
try
{
WarehouseExcel
warehouseExcel
=
new
WarehouseExcel
(
resultWarehouseNoAndTDLSNAndTimeVo
,
user
.
getUserName
(),
response
);
HSSFWorkbook
wb
=
warehouseExcel
.
downloadExcel
();
if
(
wb
!=
null
)
{
request
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
fileName
);
OutputStream
os
=
new
FileOutputStream
(
new
File
(
file
+
File
.
separator
+
fileName
+
".xls"
));
wb
.
write
(
os
);
os
.
flush
();
os
.
close
();
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传失败"
);
}
request
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
fileName
);
OutputStream
os
=
new
FileOutputStream
(
new
File
(
file
+
File
.
separator
+
fileName
+
".xls"
));
wb
.
write
(
os
);
os
.
flush
();
os
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
e
.
toString
());
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传失败"
);
return
gson
.
toJson
(
fb
);
}
}
try
{
...
...
@@ -168,6 +164,7 @@ public class DownloadController {
logger
.
info
(
e
.
toString
());
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传失败"
);
return
gson
.
toJson
(
fb
);
}
return
gson
.
toJson
(
fb
);
}
...
...
@@ -187,7 +184,6 @@ public class DownloadController {
if
(
dirFile
.
isFile
())
{
return
dirFile
.
delete
();
}
else
{
for
(
File
file
:
dirFile
.
listFiles
())
{
deleteFile
(
file
);
}
...
...
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