|
@@ -79,13 +79,16 @@ public class AttendanceService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<StaffAttendanceBrief> departmentReport(String departmentName, LocalDate start, LocalDate end) {
|
|
|
|
|
- Department department = departmentRepo.findByName(departmentName);
|
|
|
|
|
- return staffInfoRepo.findByDepartment(departmentName)
|
|
|
|
|
- .stream()
|
|
|
|
|
- .parallel()
|
|
|
|
|
- .map(staffInfo -> staffAttendance1(staffInfo, start, end, department))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
|
+ public List<StaffAttendanceBrief> departmentReport(List<String> departmentNames, LocalDate start, LocalDate end) {
|
|
|
|
|
+ List<StaffAttendanceBrief> list = new ArrayList<>();
|
|
|
|
|
+ for (String departmentName : departmentNames) {
|
|
|
|
|
+ Department department = departmentRepo.findByName(departmentName);
|
|
|
|
|
+ list.addAll(staffInfoRepo.findByDepartment(departmentName)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(staffInfo -> staffAttendance1(staffInfo, start, end, department))
|
|
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public StaffAttendanceBrief staffReport(Long id, LocalDate start, LocalDate end) {
|
|
public StaffAttendanceBrief staffReport(Long id, LocalDate start, LocalDate end) {
|
|
@@ -327,6 +330,9 @@ public class AttendanceService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public StaffAttendanceBrief staffAttendance1(StaffInfo staffInfo, LocalDate start, LocalDate end, Department department) {
|
|
public StaffAttendanceBrief staffAttendance1(StaffInfo staffInfo, LocalDate start, LocalDate end, Department department) {
|
|
|
|
|
+ if (department == null) {
|
|
|
|
|
+ log.error("department null: staffid {}", staffInfo.getId());
|
|
|
|
|
+ }
|
|
|
department = departmentRepo.findById(department.getId()).orElseThrow(new BusinessException("部门不存在"));
|
|
department = departmentRepo.findById(department.getId()).orElseThrow(new BusinessException("部门不存在"));
|
|
|
List<StaffAccess> accessList = staffAccessRepo
|
|
List<StaffAccess> accessList = staffAccessRepo
|
|
|
.findByEmployNoAndAccessTimeBetweenOrderByAccessTimeAsc(staffInfo.getEmployNo(),
|
|
.findByEmployNoAndAccessTimeBetweenOrderByAccessTimeAsc(staffInfo.getEmployNo(),
|
|
@@ -357,7 +363,7 @@ public class AttendanceService {
|
|
|
staffAttendanceDetailList.add(detail);
|
|
staffAttendanceDetailList.add(detail);
|
|
|
brief.setHours(brief.getHours() + detail.getHours());
|
|
brief.setHours(brief.getHours() + detail.getHours());
|
|
|
if (detail.isAbsent()) {
|
|
if (detail.isAbsent()) {
|
|
|
- brief.setAbsentDays(brief.getAttendDays() + 1);
|
|
|
|
|
|
|
+ brief.setAbsentDays(brief.getAbsentDays() + 1);
|
|
|
brief.addAbsentDetail(DateTimeUtils.format(date, "yyyy-MM-dd"));
|
|
brief.addAbsentDetail(DateTimeUtils.format(date, "yyyy-MM-dd"));
|
|
|
} else {
|
|
} else {
|
|
|
brief.setAttendDays(brief.getAttendDays() + 1);
|
|
brief.setAttendDays(brief.getAttendDays() + 1);
|
|
@@ -392,6 +398,12 @@ public class AttendanceService {
|
|
|
TimeBucket timeBucket = null;
|
|
TimeBucket timeBucket = null;
|
|
|
Shift shift = null;
|
|
Shift shift = null;
|
|
|
List<Shift> shifts = department.getShifts();
|
|
List<Shift> shifts = department.getShifts();
|
|
|
|
|
+ shifts.sort((o1, o2) -> {
|
|
|
|
|
+ if (o1.getAttendanceType() == AttendanceType.FIX && o2.getAttendanceType() == AttendanceType.FIX) {
|
|
|
|
|
+ return o1.getStart().compareTo(o2.getStart());
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ });
|
|
|
for (Shift s : shifts) {
|
|
for (Shift s : shifts) {
|
|
|
TimeBucket t = null;
|
|
TimeBucket t = null;
|
|
|
t = calcTimeBucket(allList, s, date);
|
|
t = calcTimeBucket(allList, s, date);
|