开发OTA备案工具-导入导出
This commit is contained in:
+2
@@ -71,4 +71,6 @@ public interface IOtaBaCxAqcsService extends IService<OtaBaCxAqcs> {
|
||||
OtaBaCxAqcs importData(MultipartFile file, String otaId, String cut) throws Exception;
|
||||
|
||||
OtaBaCxAqcs parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
|
||||
|
||||
void exportData(File file, File attFile, String otaId, String cut) throws Exception;
|
||||
}
|
||||
|
||||
+2
@@ -71,4 +71,6 @@ public interface IOtaBaCxKsjjsmccsService extends IService<OtaBaCxKsjjsmccs> {
|
||||
void importData(MultipartFile file, String otaId, String cut) throws Exception;
|
||||
|
||||
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
|
||||
|
||||
void exportData(File file, File attFile, String otaId, String cut) throws Exception
|
||||
}
|
||||
|
||||
+2
@@ -71,4 +71,6 @@ public interface IOtaBaCxKsjxtmccsService extends IService<OtaBaCxKsjxtmccs> {
|
||||
void importData(MultipartFile file, String otaId, String cut) throws Exception;
|
||||
|
||||
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
|
||||
|
||||
void exportData(File file, File attFile, String otaId, String cut) throws Exception;
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,5 +73,5 @@ public interface IOtaBaCxZxsjyqService extends IService<OtaBaCxZxsjyq> {
|
||||
|
||||
OtaBaCxZxsjyq parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
|
||||
|
||||
void exportData(File file, String otaId, String cut) throws Exception;
|
||||
void exportData(File file, File attFile,String otaId, String cut) throws Exception;
|
||||
}
|
||||
|
||||
+47
@@ -3,6 +3,7 @@ package com.jero.modules.ota.service.impl;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.ota.entity.*;
|
||||
@@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -233,4 +235,49 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
|
||||
aqcs.setZmcl(obj.toString());
|
||||
return aqcs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
|
||||
OtaBaCxAqcs aqcs = getByOtaId(otaId);
|
||||
Workbook wb = ImportFileUtil.readExcel(file);
|
||||
Sheet s = wb.getSheetAt(0);
|
||||
|
||||
Row row = s.getRow(2);
|
||||
Cell cell = row.getCell(2);
|
||||
cell.setCellValue(sysDictService.queryDictItemByValue("protection_mechanism", aqcs.getBhjz(), cut));
|
||||
|
||||
row = s.getRow(3);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(sysDictService.queryDictItemByValue("fail_safe_mechanism", aqcs.getFsxjz(), cut));
|
||||
|
||||
row = s.getRow(4);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(sysDictService.queryDictItemByValue("upgrade_failure", aqcs.getSjsbcs(), cut));
|
||||
|
||||
row = s.getRow(5);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(sysDictService.queryDictItemByValue("Information_security_mechanism", aqcs.getXxaqjz(), cut));
|
||||
|
||||
row = s.getRow(2);
|
||||
cell = row.getCell(3);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String attStr = aqcs.getZmcl();
|
||||
List<AttachmentEO> attList = JSONArray.parseArray(attStr, AttachmentEO.class);
|
||||
if (ObjectUtils.isNotEmpty(attList)) {
|
||||
for (AttachmentEO aeo : attList) {
|
||||
List<OSSFile> ossFileList = ossFileService.getFileInfos(aeo.getId());
|
||||
for (OSSFile ossFile : ossFileList) {
|
||||
String filePath = ossFile.getUrl();
|
||||
boolean b = CosBootUtil.doesObjectExist(filePath);
|
||||
if (b) {
|
||||
InputStream download = CosBootUtil.download(filePath);
|
||||
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
|
||||
sb.append(ossFile.getFileName()).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cell.setCellValue(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
+67
@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.ota.entity.*;
|
||||
import com.jero.modules.ota.enums.OtaModuleEnum;
|
||||
@@ -27,6 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
@@ -299,4 +302,68 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
|
||||
}
|
||||
return mccsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
|
||||
List<OtaBaCxKsjjsmccs> mccsList = this.getByOtaId(otaId);
|
||||
Workbook wb = ImportFileUtil.readExcel(file);
|
||||
Sheet s = wb.getSheetAt(0);
|
||||
int startRow = 3;
|
||||
for (OtaBaCxKsjjsmccs mccs : mccsList) {
|
||||
Row row = s.getRow(startRow);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue(mccs.getGnmc());
|
||||
cell = row.createCell(1);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(mccs.getPzqk()));
|
||||
cell = row.createCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(mccs.getSfksj()));
|
||||
cell = row.createCell(3);
|
||||
cell.setCellValue(mccs.getJszdhjb());
|
||||
cell = row.createCell(4);
|
||||
cell.setCellValue(mccs.getSjggcs());
|
||||
cell = row.createCell(5);
|
||||
cell.setCellValue(mccs.getGnms());
|
||||
cell = row.createCell(6);
|
||||
cell.setCellValue(mccs.getSytj());
|
||||
cell = row.createCell(7);
|
||||
cell.setCellValue(mccs.getKzqmc());
|
||||
cell = row.createCell(8);
|
||||
cell.setCellValue(mccs.getKzqscqy());
|
||||
cell = row.createCell(9);
|
||||
cell.setCellValue(mccs.getKzqxh());
|
||||
cell = row.createCell(10);
|
||||
cell.setCellValue(mccs.getYjbbxx());
|
||||
cell = row.createCell(11);
|
||||
cell.setCellValue(mccs.getRjkfqy());
|
||||
cell = row.createCell(12);
|
||||
cell.setCellValue(mccs.getCzxtbbh());
|
||||
cell = row.createCell(13);
|
||||
cell.setCellValue(mccs.getCsyzsj());
|
||||
}
|
||||
Row row = s.getRow(startRow);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue("证明材料");
|
||||
cell = row.getCell(1);
|
||||
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
|
||||
if (ObjectUtils.isNotEmpty(otaBaCxList)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String fj = otaBaCxList.getZxsjjsfj();
|
||||
if (StringUtils.isNotEmpty(fj)) {
|
||||
String[] strs = fj.split(",");
|
||||
for (String str : strs) {
|
||||
List<OSSFile> ossFileList = ossFileService.getFileInfos(str);
|
||||
for (OSSFile ossFile : ossFileList) {
|
||||
String filePath = ossFile.getUrl();
|
||||
boolean b = CosBootUtil.doesObjectExist(filePath);
|
||||
if (b) {
|
||||
InputStream download = CosBootUtil.download(filePath);
|
||||
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
|
||||
sb.append(ossFile.getFileName()).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
cell.setCellValue(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+92
-1
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.ota.entity.*;
|
||||
@@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
@@ -300,4 +302,93 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
|
||||
}
|
||||
return mccsList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
|
||||
List<OtaBaCxKsjxtmccs> mccsList = this.getByOtaId(otaId);
|
||||
Workbook wb = ImportFileUtil.readExcel(file);
|
||||
Sheet s = wb.getSheetAt(0);
|
||||
|
||||
int startRow = 3;
|
||||
for (OtaBaCxKsjxtmccs mccs : mccsList) {
|
||||
Row row = s.getRow(startRow);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue(mccs.getXtlb());
|
||||
|
||||
cell = row.createCell(1);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(mccs.getSfksj()));
|
||||
|
||||
cell = row.createCell(2);
|
||||
cell.setCellValue(mccs.getSjbgcs());
|
||||
cell = row.createCell(3);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String tptStr = mccs.getTpt();
|
||||
if (StringUtils.isNotEmpty(tptStr)) {
|
||||
String[] strs = tptStr.split(",");
|
||||
for (String str : strs) {
|
||||
List<OSSFile> ossFileList = ossFileService.getFileInfos(str);
|
||||
for (OSSFile ossFile : ossFileList) {
|
||||
String filePath = ossFile.getUrl();
|
||||
boolean b = CosBootUtil.doesObjectExist(filePath);
|
||||
if (b) {
|
||||
InputStream download = CosBootUtil.download(filePath);
|
||||
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
|
||||
sb.append(ossFile.getFileName()).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
cell.setCellValue(sb.toString());
|
||||
}
|
||||
cell = row.createCell(4);
|
||||
cell.setCellValue(mccs.getKzqmc());
|
||||
cell = row.createCell(5);
|
||||
cell.setCellValue(mccs.getAqwzxdj());
|
||||
cell = row.createCell(6);
|
||||
cell.setCellValue(mccs.getKzqscqy());
|
||||
cell = row.createCell(7);
|
||||
cell.setCellValue(mccs.getKzqxh());
|
||||
cell = row.createCell(8);
|
||||
cell.setCellValue(mccs.getYjbbxx());
|
||||
cell = row.createCell(9);
|
||||
cell.setCellValue(mccs.getCsrjbbh());
|
||||
cell = row.createCell(10);
|
||||
cell.setCellValue(mccs.getCsrjbwzsj());
|
||||
cell = row.createCell(11);
|
||||
cell.setCellValue(mccs.getSjsfyx());
|
||||
cell = row.createCell(12);
|
||||
cell.setCellValue(mccs.getCzxtlx());
|
||||
cell = row.createCell(13);
|
||||
cell.setCellValue(mccs.getCzxtscqy());
|
||||
cell = row.createCell(14);
|
||||
cell.setCellValue(mccs.getCzxtbbh());
|
||||
startRow++;
|
||||
}
|
||||
Row row = s.getRow(startRow);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue("证明材料");
|
||||
cell = row.getCell(1);
|
||||
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
|
||||
if (ObjectUtils.isNotEmpty(otaBaCxList)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String fj = otaBaCxList.getZxsjxtfj();
|
||||
if (StringUtils.isNotEmpty(fj)) {
|
||||
String[] strs = fj.split(",");
|
||||
for (String str : strs) {
|
||||
List<OSSFile> ossFileList = ossFileService.getFileInfos(str);
|
||||
for (OSSFile ossFile : ossFileList) {
|
||||
String filePath = ossFile.getUrl();
|
||||
boolean b = CosBootUtil.doesObjectExist(filePath);
|
||||
if (b) {
|
||||
InputStream download = CosBootUtil.download(filePath);
|
||||
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
|
||||
sb.append(ossFile.getFileName()).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
cell.setCellValue(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+15
-4
@@ -187,16 +187,27 @@ public class OtaBaCxListServiceImpl extends ServiceImpl<OtaBaCxListMapper, OtaBa
|
||||
@Override
|
||||
public void exportData(String otaId, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
String cut = "cn";
|
||||
File template = new File(templatePath + "车型及功能备案.zip");
|
||||
File template = new File(templatePath + "车型及功能备案导出.zip");
|
||||
File exportFile = ImportFileUtil.copyZip(ImportFileUtil.createMfileByFile(template), cut, uploadPath);
|
||||
File jbxxFile = ImportFileUtil.findFile(exportFile, "车型基本信息.xlsx");
|
||||
if (ObjectUtils.isEmpty(jbxxFile)) {
|
||||
throw new JeroBootException("没有找到 车型基本信息.xlsx");
|
||||
}
|
||||
otaBaCxJbxxService.exportData(jbxxFile, otaId, cut);
|
||||
|
||||
File sjyqFile = ImportFileUtil.findFile(exportFile, "在线升级要求.xlsx");
|
||||
File sjyqAttFile = ImportFileUtil.findFoder(exportFile, "在线升级要求");
|
||||
otaBaCxZxsjyqService.exportData(sjyqFile, sjyqAttFile, otaId, cut);
|
||||
|
||||
|
||||
File aqcsFile = ImportFileUtil.findFile(exportFile, "安全措施.xlsx");
|
||||
File aqcsAttFile = ImportFileUtil.findFoder(exportFile, "安全措施");
|
||||
otaBaCxAqcsService.exportData(aqcsFile, aqcsAttFile, otaId, cut);
|
||||
|
||||
File mccsFile = ImportFileUtil.findFile(exportFile, "可在线升级的系统名称与参数.xlsx");
|
||||
File mccsAttFile = ImportFileUtil.findFoder(exportFile, "可在线升级的系统名称与参数");
|
||||
otaBaCxKsjxtmccsService.exportData(mccsFile, mccsAttFile, otaId, cut);
|
||||
|
||||
File jsmccsFile = ImportFileUtil.findFile(exportFile, "可在线升级的驾驶辅助功能名称与参数.xlsx");
|
||||
File jsmccsAttFile = ImportFileUtil.findFoder(exportFile, "可在线升级的驾驶辅助功能名称与参数");
|
||||
otaBaCxKsjjsmccsService.exportData(jsmccsFile, jsmccsAttFile, otaId, cut);
|
||||
|
||||
|
||||
String outPath = uploadPath + "/车型及功能备案" + System.currentTimeMillis() + ".zip";
|
||||
|
||||
+58
-1
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.ota.entity.AttachmentEO;
|
||||
@@ -16,6 +17,8 @@ import com.jero.modules.ota.service.IOtaBaCxZxsjyqService;
|
||||
import com.jero.modules.ota.utils.ComparisonUtil;
|
||||
import com.jero.modules.ota.utils.ImportFileUtil;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@@ -30,6 +33,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -252,7 +256,60 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportData(File file, String otaId, String cut) throws Exception {
|
||||
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
|
||||
OtaBaCxZxsjyq otaBaCxZxsjyq = this.getByOtaId(otaId);
|
||||
Workbook wb = ImportFileUtil.readExcel(file);
|
||||
Sheet s = wb.getSheetAt(0);
|
||||
Row row = s.getRow(2);
|
||||
Cell cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getBhsjb()));
|
||||
row = s.getRow(3);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getBhclbb()));
|
||||
row = s.getRow(4);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getClgxnl()));
|
||||
row = s.getRow(5);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getClsjtj()));
|
||||
row = s.getRow(6);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getClsjdl()));
|
||||
row = s.getRow(7);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjbhaq()));
|
||||
row = s.getRow(8);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjantj()));
|
||||
row = s.getRow(9);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjsbaq()));
|
||||
row = s.getRow(10);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjgg()));
|
||||
row = s.getRow(11);
|
||||
cell = row.getCell(2);
|
||||
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(otaBaCxZxsjyq.getSjzt()));
|
||||
|
||||
row = s.getRow(2);
|
||||
cell = row.getCell(3);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String attStr = otaBaCxZxsjyq.getZmcl();
|
||||
List<AttachmentEO> attList = JSONArray.parseArray(attStr, AttachmentEO.class);
|
||||
if (ObjectUtils.isNotEmpty(attList)) {
|
||||
for (AttachmentEO aeo : attList) {
|
||||
List<OSSFile> ossFileList = ossFileService.getFileInfos(aeo.getId());
|
||||
for (OSSFile ossFile : ossFileList) {
|
||||
String filePath = ossFile.getUrl();
|
||||
boolean b = CosBootUtil.doesObjectExist(filePath);
|
||||
if (b) {
|
||||
InputStream download = CosBootUtil.download(filePath);
|
||||
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
|
||||
sb.append(ossFile.getFileName()).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cell.setCellValue(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
+47
@@ -179,6 +179,18 @@ public class ImportFileUtil {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String getCellValueYesOrNo(String str) throws Exception {
|
||||
String res = "";
|
||||
if (StringUtils.isNotEmpty(str)) {
|
||||
if (str.equals("1")) {
|
||||
res = "是";
|
||||
} else if (str.equals("2")) {
|
||||
res = "否";
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String getCellValueDict(Cell cell, Workbook wb, String dictType, ISysDictService sysDictService, String cut) throws Exception {
|
||||
String res = "";
|
||||
String str = ImportFileUtil.getCellValue(cell, wb);
|
||||
@@ -212,6 +224,21 @@ public class ImportFileUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static File findFoder(File file, String fileName) throws Exception {
|
||||
// 获取此地址中的所有文件以及文件夹(File[] list)
|
||||
File[] listFiles = file.listFiles();// 获取此地址中的所有文件以及文件夹(File[] list)
|
||||
for (File file1 : listFiles) {// 遍历数组
|
||||
// 判断当前的File对象是否为文件夹
|
||||
if (file1.isDirectory()) {
|
||||
String name = file1.getName();
|
||||
if (name.equals(fileName)) {
|
||||
return file1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static File findFile(List<File> file, String fileName) throws Exception {
|
||||
for (File file1 : file) {// 遍历数组
|
||||
// 判断当前的File对象是否为文件夹
|
||||
@@ -401,5 +428,25 @@ public class ImportFileUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将InputStream写入本地文件
|
||||
*
|
||||
* @param input 输入流
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
public static void writeToLocal(String path, InputStream input)
|
||||
throws IOException {
|
||||
int index;
|
||||
byte[] bytes = new byte[1024];
|
||||
FileOutputStream downloadFile = new FileOutputStream(path);
|
||||
while ((index = input.read(bytes)) != -1) {
|
||||
downloadFile.write(bytes, 0, index);
|
||||
downloadFile.flush();
|
||||
}
|
||||
input.close();
|
||||
downloadFile.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user