修改OTA生成CSV文件去掉header
This commit is contained in:
+29
-15
@@ -31,9 +31,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -262,19 +260,35 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
|
||||
mbcl.setVinList(vinList.get(0).getVin() + "-" + vinList.get(vinList.size() - 1).getVin());
|
||||
|
||||
//生成VIN码文件
|
||||
LinkedHashMap map = new LinkedHashMap();
|
||||
map.put("1", "VIN");
|
||||
List exportData = new ArrayList<Map>();
|
||||
Map vrow = null;
|
||||
for (int i = 0; i < vinList.size(); i++) {
|
||||
vrow = new LinkedHashMap<String, String>();
|
||||
vrow.put("1", vinList.get(i).getVin());
|
||||
exportData.add(vrow);
|
||||
}
|
||||
// LinkedHashMap map = new LinkedHashMap();
|
||||
// map.put("1", "VIN");
|
||||
// List exportData = new ArrayList<Map>();
|
||||
// Map vrow = null;
|
||||
// for (int i = 0; i < vinList.size(); i++) {
|
||||
// vrow = new LinkedHashMap<String, String>();
|
||||
// vrow.put("1", vinList.get(i).getVin());
|
||||
// exportData.add(vrow);
|
||||
// }
|
||||
// String fileName = "VIN码.csv";
|
||||
// File file = CSVUtil.createCSVFile(exportData, map, uploadPath + System.currentTimeMillis(), fileName);
|
||||
// String filePath = uploadPath + "/" + file.getName();
|
||||
|
||||
String fileName = "VIN码.csv";
|
||||
File file = CSVUtil.createCSVFile(exportData, map, uploadPath + System.currentTimeMillis(), fileName);
|
||||
String filePath = uploadPath + "/" + file.getName();
|
||||
OSSFile ossFile = ossFileService.uploadLocalOfCos(ImportFileUtil.createMfileByFile(file), "/ota", "", CutEnum.CN.getValue());
|
||||
File csvFileDir = new File(uploadPath + System.currentTimeMillis());
|
||||
csvFileDir.mkdirs();
|
||||
File csvFile = new File(csvFileDir.getAbsolutePath() + "/" + fileName);
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(csvFile))) {
|
||||
// 写入数据
|
||||
for (VinObj data : vinList) {
|
||||
String row = data.getVin();
|
||||
writer.write(row);
|
||||
writer.newLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("生成CSV文件失败:" + e.getMessage());
|
||||
}
|
||||
|
||||
OSSFile ossFile = ossFileService.uploadLocalOfCos(ImportFileUtil.createMfileByFile(csvFile), "/ota", "", CutEnum.CN.getValue());
|
||||
mbcl.setCsv(ossFile.getId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user