Commit 2d6c5e36 by 谢春璐

fix

parent 436d473d
...@@ -9,8 +9,10 @@ import java.io.InputStream; ...@@ -9,8 +9,10 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -48,40 +50,44 @@ public class FileController { ...@@ -48,40 +50,44 @@ public class FileController {
List<Staff> staffList = new ArrayList<>(); List<Staff> staffList = new ArrayList<>();
files.forEach(file -> { files = files.stream().filter(f -> StringUtils.isNotBlank(f.getOriginalFilename())).collect(Collectors.toList());
try { files.forEach(file -> {
try {
InputStream inputStream = file.getInputStream();
String fileName = file.getOriginalFilename(); InputStream inputStream = file.getInputStream();
ExcelData data = null; String fileName = file.getOriginalFilename();
List<Staff> staffs = null; ExcelData data = null;
List<Staff> staffs = new ArrayList<>(0);
if (fileName.contains("上下班打卡_日报")) {
data = inst.parse(inputStream, fileName, false, 2); if (fileName.contains("上下班打卡_日报")) {
staffs = fileService.wechatWorkInStatistics(data); data = inst.parse(inputStream, fileName, false, 2);
} else if (fileName.contains("外出打卡_日报")) { staffs = fileService.wechatWorkInStatistics(data);
data = inst.parse(inputStream, fileName, false, 2); } else if (fileName.contains("外出打卡_日报")) {
staffs = fileService.wechatWorkOutStatistics(data); data = inst.parse(inputStream, fileName, false, 2);
} else if (fileName.contains("考勤导出")) { staffs = fileService.wechatWorkOutStatistics(data);
data = inst.parse(inputStream, fileName, false, 0); } else if (fileName.contains("考勤导出")) {
staffs = fileService.workRecord(data); data = inst.parse(inputStream, fileName, false, 0);
staffs = fileService.workRecord(data);
}
staffList.addAll(staffs);
} catch (IOException e) {
e.printStackTrace();
} }
staffList.addAll(staffs); });
} catch (IOException e) {
e.printStackTrace();
}
});
List<Staff> staffList1 = fileService.staffListCollect(staffList); List<Staff> staffList1 = fileService.staffListCollect(staffList);
return fileService.checkExport(staffList1); return fileService.checkExport(staffList1);
} catch (Exception e) { } catch (Exception e) {
try { try {
e.printStackTrace();
response.getWriter().print(e.getMessage()); response.getWriter().print(e.getMessage());
} catch (IOException e2) { } catch (IOException e2) {
return null; e2.printStackTrace();
} }
e.printStackTrace();
} }
return null; return null;
......
...@@ -13,7 +13,7 @@ public class Staff { ...@@ -13,7 +13,7 @@ public class Staff {
/** /**
* 考勤号 * 考勤号
*/ */
private Integer id; private String id;
/** /**
* 员工名 * 员工名
......
...@@ -133,7 +133,7 @@ public class FileServiceImpl implements FileService { ...@@ -133,7 +133,7 @@ public class FileServiceImpl implements FileService {
map.entrySet().forEach(entry -> { map.entrySet().forEach(entry -> {
Staff staff = new Staff(); Staff staff = new Staff();
staff.setId(Integer.valueOf(entry.getKey())); staff.setId(entry.getKey());
entry.getValue().entrySet().forEach(entry2 -> { entry.getValue().entrySet().forEach(entry2 -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment