Commit 86002fd9 authored by 赵啸非's avatar 赵啸非

优化考勤计算

parent ad66dec5
......@@ -138,8 +138,6 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
public void addAttendanceOtherRecordList(List<AttendanceRecordHikEntity> hikEntityList, AttendanceRecordHikEntity attendanceRecordHikQuery, Context context) throws Exception {
List<AttendanceRecordHikEntity> collect = hikEntityList.stream().sorted(Comparator.comparing(AttendanceRecordHikEntity::getAttendanceDate)).collect(Collectors.toList());
Map<Long, List<AttendanceRecordHikEntity>> listMap = collect.stream().collect(Collectors.groupingBy(AttendanceRecordHikEntity::getStaffId));
Map<Long, List<AttendanceGroupStaffEntity>> groupStaffMap = attendanceGroupStaffService.find(new AttendanceGroupStaffQuery()).parallelStream().collect(Collectors.groupingBy(x -> x.getStaffId()));
Map<Long, AttendanceGroupEntity> groupMap = attendanceGroupService.find(new AttendanceGroupQuery()).parallelStream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
Map<Long, AttendanceClassEntity> classEntityMap = attendanceClassService.find(new AttendanceClassQuery()).parallelStream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
......@@ -162,9 +160,11 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
List<AttendanceRecordEntity> saveList = new ArrayList<>();
List<AttendanceRecordEntity> updateList = new ArrayList<>();
for (Map.Entry<Long, List<AttendanceRecordHikEntity>> itemEntry : listMap.entrySet()) {
//按人员 todo 改为多线程并行计算
listMap.entrySet().parallelStream().forEach(itemEntry -> {
// });
// for (Map.Entry<Long, List<AttendanceRecordHikEntity>> itemEntry : listMap.entrySet()) {
//按人员 todo 改为多线程并行计算
Long staffId = itemEntry.getKey();
List<AttendanceRecordHikEntity> recordHikEntityList = itemEntry.getValue();
Map<String, List<AttendanceRecordHikEntity>> dateRecordMap = recordHikEntityList.stream().collect(Collectors.groupingBy(hikEntity -> DateUtil.formatDate(hikEntity.getAttendanceDate())));
......@@ -303,7 +303,8 @@ public class AttendanceRecordHikServiceImpl extends AbstractCRUDServiceImpl<Atte
}
}
}
}
});
// }
if (!ObjectUtils.isEmpty(saveList)) {
log.info("新增考勤记录数:" + saveList.size());
attendanceRecordService.save(saveList);
......
......@@ -517,7 +517,7 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
errorEntityList.add(errorEntity);
}
}
//删除当前员工当日未处理的异常后,重新添加
//删除当前员工当日未处理的异常后,重新添加 处理的 不做删除
deleteErrorRecord(dateStr, attendanceRecordEntity.getStaffId(), context);
AttendanceRecordErrorQuery errorQuery;
......@@ -536,6 +536,8 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
AttendanceRecordErrorEntity attendanceRecordErrorEntity = errorService.selectOne(errorQuery, context);
if (ObjectUtils.isEmpty(attendanceRecordErrorEntity)) {
errorService.save(errorEntity, context);
}else {
log.info("异常记录已存在,不添加");
}
}
}
......
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