|
@@ -345,19 +345,20 @@ public class EmployeeInfoController {
|
|
|
List<Map<String,Object>> fileList = new ArrayList<>();
|
|
|
|
|
|
//读取模板
|
|
|
- InputStream inputStream = this.getClass().getResourceAsStream("/static/模板.csv");
|
|
|
+ InputStream inputStream = this.getClass().getResourceAsStream("/static/template.csv");
|
|
|
byte[] bytes = new byte[inputStream.available()];
|
|
|
inputStream.read(bytes);
|
|
|
+ inputStream.close();
|
|
|
|
|
|
StringBuilder csvBuilder = new StringBuilder();
|
|
|
- csvBuilder.append(new String(bytes,"UTF-8"));
|
|
|
+ csvBuilder.append(new String(bytes,"GBK"));
|
|
|
|
|
|
List<EmployeeInfo> employeeInfos = employeeInfoService.findByArray(ids.split(","));
|
|
|
|
|
|
- String tmpdir = System.getProperty("java.io.tmpdir");
|
|
|
- String tmpFilePath = tmpdir + File.separator + DateTime.now().toString("yyyyMMhddHHmmssSSS") + ".csv";
|
|
|
+// String tmpdir = System.getProperty("java.io.tmpdir");
|
|
|
+// String tmpFilePath = tmpdir + File.separator + DateTime.now().toString("yyyyMMhddHHmmssSSS") + ".csv";
|
|
|
|
|
|
- File tmpFile = new File(tmpFilePath);
|
|
|
+// File tmpFile = new File(tmpFilePath);
|
|
|
|
|
|
if(employeeInfos.size()>0) {
|
|
|
for (EmployeeInfo employeeInfo : employeeInfos) {
|
|
@@ -369,13 +370,13 @@ public class EmployeeInfoController {
|
|
|
csvBuilder.append(localPath + "\\照片\\" + employeeInfo.getId() + photoExt + "\r\n");
|
|
|
}
|
|
|
|
|
|
- FileOutputStream fileOutput = new FileOutputStream(tmpFile);
|
|
|
- byte[] data = csvBuilder.toString().getBytes("UTF-8");
|
|
|
- fileOutput.write(data,0,data.length);
|
|
|
- fileOutput.close();
|
|
|
+// FileOutputStream fileOutput = new FileOutputStream(tmpFile);
|
|
|
+// byte[] data = csvBuilder.toString().getBytes("UTF-8");
|
|
|
+// fileOutput.write(data,0,data.length);
|
|
|
+// fileOutput.close();
|
|
|
|
|
|
Map<String, Object> fileMap = new HashMap<>();
|
|
|
- fileMap.put("localPath", tmpFilePath);
|
|
|
+ fileMap.put("fileData", csvBuilder.toString().getBytes("GBK"));
|
|
|
fileMap.put("fileName", "人员名单.csv");
|
|
|
|
|
|
fileList.add(fileMap);
|
|
@@ -401,9 +402,9 @@ public class EmployeeInfoController {
|
|
|
|
|
|
OSSUtil.batchDownload(fileList,output);
|
|
|
|
|
|
- if(tmpFile.exists()){
|
|
|
- tmpFile.delete();
|
|
|
- }
|
|
|
+// if (tmpFile.exists()){
|
|
|
+// tmpFile.delete();
|
|
|
+// }
|
|
|
|
|
|
output.flush();
|
|
|
output.close();
|