From 18d68cdcfa7cd07b3a06367cb528bc4919eb7507 Mon Sep 17 00:00:00 2001 From: Radheshhathwar <radheshhathwar.bh@gmail.com> Date: Thu, 9 Nov 2023 17:24:47 +0530 Subject: [PATCH] Bulk upload with multiple exams --- .../repository/StudentResultRepository.java | 7 ++++--- .../examsAndAdmissions/service/DataImporterService.java | 4 ++-- .../examsAndAdmissions/service/StudentResultService.java | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java index deca016..0f95508 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/repository/StudentResultRepository.java @@ -39,11 +39,12 @@ public interface StudentResultRepository extends JpaRepository<StudentResult, Lo @Transactional @Query("UPDATE StudentResult sr SET sr.externalMarks = null, sr.passingExternalMarks = null, sr.externalMarksObtained = null, sr.finalMarkFlag = false, sr.published = false WHERE sr.examCycle_name = :examCycleName AND sr.instituteId = :instituteId") int setExternalMarksToNull(@Param("examCycleName") String examCycleName, @Param("instituteId") Long instituteId); - @Query("SELECT sr FROM StudentResult sr WHERE sr.firstName = :firstName AND sr.lastName = :lastName AND sr.enrollmentNumber = :enrollmentNumber") - StudentResult findByFirstNameAndLastNameAndEnrollmentNumber( + @Query("SELECT sr FROM StudentResult sr WHERE sr.firstName = :firstName AND sr.lastName = :lastName AND sr.enrollmentNumber = :enrollmentNumber AND sr.exam_name = :examName") + StudentResult findByFirstNameAndLastNameAndEnrollmentNumberAndExamName( @Param("firstName") String firstName, @Param("lastName") String lastName, - @Param("enrollmentNumber") String enrollmentNumber + @Param("enrollmentNumber") String enrollmentNumber, + @Param("examName") String examName ); Optional<StudentResult> findByExamId(Long id); diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java index 6544c97..3441102 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/DataImporterService.java @@ -425,7 +425,7 @@ public class DataImporterService { } } if (validationErrors.isEmpty()) { - StudentResult existingEntity = repository.findByFirstNameAndLastNameAndEnrollmentNumber(dto.getFirstName(), dto.getLastName(), dto.getEnrollmentNumber()); + StudentResult existingEntity = repository.findByFirstNameAndLastNameAndEnrollmentNumberAndExamName(dto.getFirstName(), dto.getLastName(), dto.getEnrollmentNumber(), dto.getExam_name()); List<StudentResult> marks = calculateResult(existingEntity.getInternalMarks(), existingEntity.getPassingInternalMarks(), existingEntity.getInternalMarksObtained(), existingEntity.getPracticalMarks(), existingEntity.getPassingPracticalMarks(), existingEntity.getPracticalMarksObtained(), dto.getExternalMarks(), dto.getPassingExternalMarks(), dto.getExternalMarksObtained()); @@ -483,7 +483,7 @@ public class DataImporterService { } } if (validationErrors.isEmpty()) { - StudentResult existingEntity = repository.findByFirstNameAndLastNameAndEnrollmentNumber(dto.getFirstName(), dto.getLastName(), dto.getEnrollmentNumber()); + StudentResult existingEntity = repository.findByFirstNameAndLastNameAndEnrollmentNumberAndExamName(dto.getFirstName(), dto.getLastName(), dto.getEnrollmentNumber(),dto.getExam_name()); List<StudentResult> marks = calculateResult(existingEntity.getInternalMarks(), existingEntity.getPassingInternalMarks(), existingEntity.getInternalMarksObtained(), existingEntity.getPracticalMarks(), existingEntity.getPassingPracticalMarks(), existingEntity.getPracticalMarksObtained(), dto.getExternalMarks(), dto.getPassingExternalMarks(), dto.getExternalMarksObtained()); diff --git a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java index f41a91b..45ad381 100644 --- a/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java +++ b/src/main/java/com/tarento/upsmf/examsAndAdmissions/service/StudentResultService.java @@ -659,7 +659,7 @@ public class StudentResultService { // Handle unsupported file type return ResponseDto.setErrorResponse(response, "UNSUPPORTED_FILE_TYPE", "Unsupported file type", HttpStatus.BAD_REQUEST); } - String[] selectedColumns = { "First Name", "Last Name", "Enrolment Number","External Marks", "Passing External Marks", "External Marks Obtained" }; + String[] selectedColumns = { "First Name", "Last Name", "Enrolment Number", "Exam", "External Marks", "Passing External Marks", "External Marks Obtained" }; JSONArray filteredJsonArray = dataImporterService.filterColumns(jsonArray, selectedColumns); List<StudentResult> dtoList = dataImporterService.convertJsonToDtoList(filteredJsonArray, StudentResult.class); ValidationResultDto validationResult = dataImporterService.convertResultDtoListToEntitiesExternalMarks(dtoList, studentResultRepository); @@ -698,7 +698,7 @@ public class StudentResultService { // Handle unsupported file type return ResponseDto.setErrorResponse(response, "UNSUPPORTED_FILE_TYPE", "Unsupported file type", HttpStatus.BAD_REQUEST); } - String[] selectedColumns = { "First Name", "Last Name", "Enrolment Number","External Marks", "Passing External Marks", "External Marks Obtained" }; + String[] selectedColumns = { "First Name", "Last Name", "Enrolment Number", "Exam", "External Marks", "Passing External Marks", "External Marks Obtained" }; JSONArray filteredJsonArray = dataImporterService.filterColumns(jsonArray, selectedColumns); List<StudentResult> dtoList = dataImporterService.convertJsonToDtoList(filteredJsonArray, StudentResult.class); ValidationResultDto validationResult = dataImporterService.convertResultDtoListToEntitiesRevisedMarks(dtoList, studentResultRepository); -- GitLab