Commit b99db0ec authored by chenying's avatar chenying

6.27修改下载仓库数据接口

parent 4703944b
...@@ -117,6 +117,14 @@ public class AliyunOSSClientUtil { ...@@ -117,6 +117,14 @@ public class AliyunOSSClientUtil {
AliyunOSSClientUtil.FOLDER4 = FOLDER4; AliyunOSSClientUtil.FOLDER4 = FOLDER4;
} }
public static String getFOLDER5() {
return FOLDER5;
}
public static void setFOLDER5(String FOLDER5) {
AliyunOSSClientUtil.FOLDER5 = FOLDER5;
}
/** /**
* 获取阿里云OSS客户端对象 * 获取阿里云OSS客户端对象
* @return ossClient * @return ossClient
...@@ -358,7 +366,7 @@ public class AliyunOSSClientUtil { ...@@ -358,7 +366,7 @@ public class AliyunOSSClientUtil {
putResult = ossClient.putObject(BACKET_NAME, FOLDER3+ fileName, is, metadata); putResult = ossClient.putObject(BACKET_NAME, FOLDER3+ fileName, is, metadata);
} else if(fileName.contains("CHN")){ } else if(fileName.contains("CHN")){
putResult = ossClient.putObject(BACKET_NAME, FOLDER4+ fileName, is, metadata); 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); putResult = ossClient.putObject(BACKET_NAME, FOLDER5+ fileName, is, metadata);
} else { } else {
putResult = ossClient.putObject(BACKET_NAME, FOLDER1+ fileName, is, metadata); putResult = ossClient.putObject(BACKET_NAME, FOLDER1+ fileName, is, metadata);
...@@ -408,7 +416,7 @@ public class AliyunOSSClientUtil { ...@@ -408,7 +416,7 @@ public class AliyunOSSClientUtil {
//初始化OSSClient //初始化OSSClient
OSSClient ossClient=AliyunOSSClientUtil.getOSSClient(); OSSClient ossClient=AliyunOSSClientUtil.getOSSClient();
//上传文件 //上传文件
String files="D://专用工具登记表-761923471.xls"; String files="E://仓库温湿度观测记录-1529909289444.zip";
File filess=new File(files); File filess=new File(files);
String md5key = AliyunOSSClientUtil.uploadObject2OSS(ossClient, filess); String md5key = AliyunOSSClientUtil.uploadObject2OSS(ossClient, filess);
logger.info("上传后的文件MD5数字唯一签名:" + md5key); logger.info("上传后的文件MD5数字唯一签名:" + md5key);
......
...@@ -98,7 +98,7 @@ public class DownloadController { ...@@ -98,7 +98,7 @@ public class DownloadController {
} }
String sqls=""; String sqls="";
String fileName =""; String fileName ="";
String name="仓库温湿度观测记录"+System.currentTimeMillis(); String name=downloadForWarehouseVo.getWarehouseNo()+"仓库温湿度观测记录-"+System.currentTimeMillis();
File file = new File("E:" + File.separator + name); File file = new File("E:" + File.separator + name);
if (!file.exists()) { if (!file.exists()) {
file.mkdir(); file.mkdir();
...@@ -129,7 +129,6 @@ public class DownloadController { ...@@ -129,7 +129,6 @@ public class DownloadController {
try { try {
WarehouseExcel warehouseExcel = new WarehouseExcel(resultWarehouseNoAndTDLSNAndTimeVo, user.getUserName(), response); WarehouseExcel warehouseExcel = new WarehouseExcel(resultWarehouseNoAndTDLSNAndTimeVo, user.getUserName(), response);
HSSFWorkbook wb = warehouseExcel.downloadExcel(); HSSFWorkbook wb = warehouseExcel.downloadExcel();
if (wb != null) {
request.setCharacterEncoding("utf-8"); request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
...@@ -138,15 +137,12 @@ public class DownloadController { ...@@ -138,15 +137,12 @@ public class DownloadController {
wb.write(os); wb.write(os);
os.flush(); os.flush();
os.close(); os.close();
} else {
fb.setCode(0);
fb.setMessage("上传失败");
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.info(e.toString()); logger.info(e.toString());
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传失败"); fb.setMessage("上传失败");
return gson.toJson(fb);
} }
} }
try { try {
...@@ -168,6 +164,7 @@ public class DownloadController { ...@@ -168,6 +164,7 @@ public class DownloadController {
logger.info(e.toString()); logger.info(e.toString());
fb.setCode(0); fb.setCode(0);
fb.setMessage("上传失败"); fb.setMessage("上传失败");
return gson.toJson(fb);
} }
return gson.toJson(fb); return gson.toJson(fb);
} }
...@@ -187,7 +184,6 @@ public class DownloadController { ...@@ -187,7 +184,6 @@ public class DownloadController {
if (dirFile.isFile()) { if (dirFile.isFile()) {
return dirFile.delete(); return dirFile.delete();
} else { } else {
for (File file : dirFile.listFiles()) { for (File file : dirFile.listFiles()) {
deleteFile(file); deleteFile(file);
} }
......
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