Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
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
常超
map-parent
Commits
6072904b
Commit
6072904b
authored
Dec 14, 2022
by
宋珺琪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资源管理模块入库大小处理(重庆)
parent
2bb7fc18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
service/publicapi/src/main/java/com/founder/publicapi/controller/ResourceManager/ResourceManagerController.java
+21
-3
No files found.
service/publicapi/src/main/java/com/founder/publicapi/controller/ResourceManager/ResourceManagerController.java
View file @
6072904b
...
...
@@ -24,6 +24,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.URL
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
...
...
@@ -66,7 +67,7 @@ public class ResourceManagerController {
resourceManagerEntity
.
setId
(
ZyId
);
resourceManagerEntity
.
setFileName
(
originalFilename
);
resourceManagerEntity
.
setFilePath
(
RESOURCE_MANAGER_DOWNLOAD
+
ZyId
+
postfix
);
resourceManagerEntity
.
setFileSize
(
String
.
valueOf
(
file
.
getSize
()));
resourceManagerEntity
.
setFileSize
(
formatFileSize
(
file
.
getSize
()));
resourceManagerEntity
.
setFileType
(
postfix
);
resourceManagerEntity
.
setCjsj
(
nowTime
());
resourceManagerEntity
.
setGxsj
(
nowTime
());
...
...
@@ -104,7 +105,7 @@ public class ResourceManagerController {
@PostMapping
(
"resourceUpdate"
)
@ApiOperation
(
value
=
"资源管理修改"
)
@OperLog
(
message
=
"资源管理修改"
,
operation
=
OperationType
.
UPDATE
)
public
MapRestResult
scheduleUpdate
(
ResourceManagerEntity
resourceManagerEntity
,
MultipartFile
file
){
public
MapRestResult
scheduleUpdate
(
ResourceManagerEntity
resourceManagerEntity
,
MultipartFile
file
){
if
(
file
!=
null
)
{
//文件名
...
...
@@ -122,7 +123,7 @@ public class ResourceManagerController {
resourceManagerEntity
.
setId
(
resourceManagerEntity
.
getId
());
resourceManagerEntity
.
setFileName
(
originalFilename
);
resourceManagerEntity
.
setFilePath
(
RESOURCE_MANAGER_DOWNLOAD
+
resourceManagerEntity
.
getId
()
+
postfix
);
resourceManagerEntity
.
setFileSize
(
String
.
valueOf
(
file
.
getSize
()));
resourceManagerEntity
.
setFileSize
(
formatFileSize
(
file
.
getSize
()));
resourceManagerEntity
.
setFileType
(
postfix
);
resourceManagerEntity
.
setGxsj
(
nowTime
());
...
...
@@ -170,6 +171,7 @@ public class ResourceManagerController {
return
new
MapRestResult
(
200
,
"ok"
,
resourceManagerEntity1
);
}
@GetMapping
(
value
=
"download"
)
@OperLog
(
message
=
"文件下载"
,
operation
=
OperationType
.
QUERY
)
@ApiOperation
(
value
=
"文件下载"
)
...
...
@@ -207,5 +209,21 @@ public class ResourceManagerController {
return
formatter
.
format
(
date
);
}
/**
* 转换文件大小
*/
public
static
String
formatFileSize
(
long
fileS
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"#.0"
);
String
fileSizeString
=
""
;
String
wrongSize
=
"0KB"
;
if
(
fileS
==
0
)
{
return
wrongSize
;
}
if
(
fileS
!=
0
)
{
fileSizeString
=
df
.
format
((
double
)
fileS
/
1024
);
}
return
fileSizeString
+
"KB"
;
}
}
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