1.修正文件无法读取和文件名称不准确导致预切板数据计算失败的逻辑

master
董哲奇 2 weeks ago
parent 8df1f359db
commit aed3ce7ad2

@ -56,7 +56,7 @@ public class DmBclqmxpServiceImpl extends ServiceImpl<DmBclqmxpMapper, DmBclqmxp
plList.forEach(pl->{ plList.forEach(pl->{
String dirStr="static/upload/"+dcCh+"/"+pl+"/其他"; String dirStr="static/upload/"+dcCh+"/"+pl+"/其他";
File fileDir = new File(dirStr); File fileDir = new File(dirStr);
String patternStr = pl + "批量钢材领取表"; String patternStr = "批量钢材领取表";
List<File> fileList = FileUtil.loopFiles(fileDir); List<File> fileList = FileUtil.loopFiles(fileDir);
fileList.stream() fileList.stream()
.filter(file -> file.getName().contains(patternStr)) .filter(file -> file.getName().contains(patternStr))

@ -25,13 +25,13 @@ public class ExcelUtil {
public static List<String> ReadExcelByLine(File file){ public static List<String> ReadExcelByLine(File file){
try (FileInputStream fis = new FileInputStream(file); try (FileInputStream fis = new FileInputStream(file);
Workbook workbook = new XSSFWorkbook(fis)) { // 对于xls文件使用HSSFWorkbook Workbook workbook = WorkbookFactory.create(fis)) {
return handler(workbook); return handler(workbook);
} catch (IOException e) { } catch (Exception e) {
try (FileInputStream fis = new FileInputStream(file); try (FileInputStream fis = new FileInputStream(file);
Workbook workbook = new HSSFWorkbook(fis)){ Workbook workbook = new HSSFWorkbook(fis)){
return handler(workbook); return handler(workbook);
}catch (IOException e1){ }catch (Exception e1){
log.info("{}损坏",file.getName()); log.info("{}损坏",file.getName());
} }
} }
@ -41,10 +41,10 @@ public class ExcelUtil {
public static List<String> ReadExcelByLine(InputStream fis, String fileName){ public static List<String> ReadExcelByLine(InputStream fis, String fileName){
try (Workbook workbook = new XSSFWorkbook(fis)) { // 对于xls文件使用HSSFWorkbook try (Workbook workbook = new XSSFWorkbook(fis)) { // 对于xls文件使用HSSFWorkbook
return handler(workbook); return handler(workbook);
} catch (IOException e) { } catch (Exception e) {
try (Workbook workbook = new HSSFWorkbook(fis)){ try (Workbook workbook = new HSSFWorkbook(fis)){
return handler(workbook); return handler(workbook);
}catch (IOException e1){ }catch (Exception e1){
log.info("{}损坏",fileName); log.info("{}损坏",fileName);
} }
} }

Loading…
Cancel
Save