use of amu.zhcet.data.attendance.Attendance in project zhcet-web by zhcet-amu.
the class AttendanceUploadService method updateAttendance.
@Transactional
public void updateAttendance(CourseInCharge courseInCharge, List<AttendanceUpload> uploadList) {
Map<String, AttendanceUpload> attendanceUploadMap = uploadList.stream().collect(Collectors.toMap(AttendanceUpload::getEnrolmentNo, item -> item));
List<Attendance> attendances = attendanceService.getAttendanceByCourseInChargeAndStudents(courseInCharge, attendanceUploadMap.keySet());
for (Attendance attendance : attendances) {
AttendanceUpload attendanceUpload = attendanceUploadMap.get(attendance.getCourseRegistration().getStudent().getEnrolmentNumber());
attendance.setDelivered(attendanceUpload.getDelivered());
attendance.setAttended(attendanceUpload.getAttended());
}
attendanceService.save(attendances);
eventPublisher.publishEvent(new AttendanceUploadEvent(courseInCharge, attendances));
}
use of amu.zhcet.data.attendance.Attendance in project zhcet-web by zhcet-amu.
the class AttendanceDownloadController method downloadAttendance.
private ResponseEntity<InputStreamResource> downloadAttendance(String context, String suffix, List<CourseRegistration> courseRegistrations) {
try {
InputStream stream = attendanceDownloadService.getAttendanceStream(suffix, context, courseRegistrations);
String lastModified = getLastModifiedDate(courseRegistrations).map(localDateTime -> "_" + localDateTime.format(DateTimeFormatter.ISO_DATE_TIME)).orElse("");
return ResponseEntity.ok().contentType(MediaType.parseMediaType("text/csv")).header("Content-disposition", "attachment;filename=attendance_" + suffix + lastModified + ".csv").body(new InputStreamResource(stream));
} catch (IOException e) {
log.error("Attendance Download Error", e);
return ResponseEntity.notFound().build();
}
}
Aggregations