Commit 6072904b by 宋珺琪

资源管理模块入库大小处理(重庆)

parent 2bb7fc18
......@@ -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";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment