|
@@ -630,29 +630,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
List<ReportExtraDegree> customerInfoList = reportExtraDegreeMapper.getAll(companyId);
|
|
|
List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
|
|
|
- //然后处理文件
|
|
|
- String fileName = multipartFile.getOriginalFilename();
|
|
|
- File file = new File(fileName == null ? "file" : fileName);
|
|
|
- InputStream inputStream = null;
|
|
|
- OutputStream outputStream = null;
|
|
|
- try {
|
|
|
- inputStream = multipartFile.getInputStream();
|
|
|
- outputStream = new FileOutputStream(file);
|
|
|
- byte[] buffer = new byte[4096];
|
|
|
- int temp = 0;
|
|
|
- while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
|
|
|
- outputStream.write(buffer, 0, temp);
|
|
|
- }
|
|
|
- inputStream.close();
|
|
|
- outputStream.close();
|
|
|
+ try(InputStream inputStream = multipartFile.getInputStream()) {
|
|
|
+
|
|
|
//然后解析表格
|
|
|
- XSSFWorkbook workbook = new XSSFWorkbook(file);
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
|
|
|
//我们只需要第一个sheet
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
|
- HttpRespMsg respMsg=new HttpRespMsg();
|
|
|
-
|
|
|
-
|
|
|
//由于第一行需要指明列对应的标题
|
|
|
int lastRowNum = sheet.getLastRowNum();
|
|
|
System.out.println("lastRowNum==>"+lastRowNum);
|
|
@@ -1163,23 +1147,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } catch (IOException e) {
|
|
|
+ }
|
|
|
+ catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
//httpRespMsg.setError("文件处理出错");
|
|
|
httpRespMsg.setError(MessageUtils.message("file.error"));
|
|
|
return httpRespMsg;
|
|
|
- } finally {
|
|
|
- //关闭流
|
|
|
- try {
|
|
|
- if (outputStream != null && inputStream != null) {
|
|
|
- outputStream.close();
|
|
|
- inputStream.close();
|
|
|
- System.out.println("流已关闭");
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- System.out.println(file.delete());
|
|
|
}
|
|
|
return httpRespMsg;
|
|
|
}
|