Commit b99db0ec authored by chenying's avatar chenying

6.27修改下载仓库数据接口

parent 4703944b
......@@ -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);
......
......@@ -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");
......
......@@ -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);
}
......
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