From ec6fe90000492786c4ed81b121e83d04804e76ab Mon Sep 17 00:00:00 2001 From: rajesh Date: Thu, 27 Feb 2025 19:11:27 +0530 Subject: [PATCH 1/2] Done ticket GEPAFINBE-175 --- .../constants/GepafinConstant.java | 1 + .../tendermanagement/dao/ApplicationDao.java | 50 ++++++++++++++++++- .../dao/ApplicationEvaluationDao.java | 2 +- .../dao/EmailNotificationDao.java | 2 +- .../enums/ApplicationStatusTypeEnum.java | 3 +- .../enums/EmailScenarioTypeEnum.java | 2 +- .../db/changelog/db.changelog-1.0.0.xml | 5 ++ ...ail_template_email_scenario_27_02_2025.sql | 2 + src/main/resources/message_en.properties | 3 +- src/main/resources/message_it.properties | 2 + 10 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/db/dump/updated_system_email_template_email_scenario_27_02_2025.sql diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 4afb7238..c673a85d 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -468,6 +468,7 @@ public class GepafinConstant { public static final String SWITCH="switch"; public static final String IS_CHECK_LIST_ITEM="isChecklistItem"; public static final String VALIDATION_FAILED_FOR_CHECKLIST="validation.failed.checklist"; + public static final String INSUFFICIENT_SCORE_MESSAGE ="insufficient.score.msg"; } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 491e9796..ef145bc3 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -1,9 +1,10 @@ package net.gepafin.tendermanagement.dao; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Root; import net.gepafin.tendermanagement.config.Translator; -import net.gepafin.tendermanagement.config.jwt.TokenProvider; import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.entities.*; import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum; @@ -917,8 +918,10 @@ public class ApplicationDao { public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { + log.info("Updating status for Application id : " + applicationId); ApplicationEntity applicationEntity = validateApplication(applicationId); checkCallEndDate(applicationEntity.getCall()); + log.info("Call end date verified successfully | callId: {}", applicationEntity.getCall().getId()); //cloned entity for old application data ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity); @@ -949,14 +952,22 @@ public class ApplicationDao { sendMailToUserAndCompany(userEntity, applicationEntity); sendMailTodefaultSystemAndGepafin(userEntity, applicationEntity); applicationEntity.setStatus(status.getValue()); + log.info("Status updated to SUBMIT for applicationId: " + applicationId); } if (status.equals(ApplicationStatusTypeEnum.DRAFT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.AWAITING.getValue()))) { applicationEntity.setStatus(status.getValue()); + log.info("Status updated to DRAFT for applicationId: " + applicationId); } if(status.equals(ApplicationStatusTypeEnum.ADMISSIBLE) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.APPOINTMENT.getValue()))){ applicationEntity.setStatus(status.getValue()); + log.info("Status updated to ADMISSIBLE for applicationId: " + applicationId); + emailNotificationDao.sendAdmissibilityNotificationEmailForAdmissibleApplication(applicationEntity); + } + if(status.equals(ApplicationStatusTypeEnum.TECHNICAL_EVALUATION) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.ADMISSIBLE.getValue()))){ + processTechnicalEvaluation(applicationId, applicationEntity, status); } applicationEntity = applicationRepository.save(applicationEntity); + log.info("Application status updated successfully | applicationId: {}, newStatus: {}", applicationId, applicationEntity.getStatus()); if (!status.equals(ApplicationStatusTypeEnum.SUBMIT)) { /** This code is responsible for adding a version history log for "Update application status" operation. **/ @@ -966,6 +977,43 @@ public class ApplicationDao { return getApplicationResponse(applicationEntity); } + private void processTechnicalEvaluation(Long applicationId, ApplicationEntity applicationEntity, ApplicationStatusTypeEnum status){ + Optional evaluationEntityOpt = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId); + if (evaluationEntityOpt.isPresent()){ + ApplicationEvaluationEntity evaluationEntity = evaluationEntityOpt.get(); + String criteriaJson = evaluationEntity.getCriteria(); + if (criteriaJson != null){ + Integer totalScore = calculateTotalScore(evaluationEntity.getCriteria()); + if (totalScore > 40) { + applicationEntity.setStatus(status.getValue()); + log.info("Status updated to TECHNICAL_EVALUATION for applicationId: " + applicationId); + } + else{ + throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.INSUFFICIENT_SCORE_MESSAGE)); + } + } + } + } + + private Integer calculateTotalScore(String criteriaJson){ + try { + ObjectMapper objectMapper = new ObjectMapper(); + // Convert JSON string to List of Maps + List> criteriaList = objectMapper.readValue(criteriaJson, new TypeReference<>() { + }); + + // Sum all scores (ignoring null scores) + Integer totalScore = criteriaList.stream() + .mapToInt(obj -> obj.get("score") != null ? ((Number) obj.get("score")).intValue() : 0) + .sum(); + + return totalScore; + } + catch (Exception e) { + log.error(" Error parsing criteria JSON: {}", e.getMessage()); + return 0; + } + } public Integer calculateProgress(Long totalSteps, Long completedSteps) { if (FieldValidator.isNullOrZero(totalSteps)) { throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.TOTAL_STEPS_NOT_BE_ZERO)); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index 4902cc57..24ce6d55 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -1899,7 +1899,7 @@ public class ApplicationEvaluationDao { application.setDateAccepted(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); application.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); application = applicationRepository.save(application); - emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(application); +// emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(application); } if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) { application.setDateRejected(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java index 3988b35a..25b54319 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/EmailNotificationDao.java @@ -249,7 +249,7 @@ public class EmailNotificationDao { sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null,amendmentRequest.getId()); } - public void sendAdmissibilityNotificationEmailForApprovedApplication(ApplicationEntity applicationEntity) { + public void sendAdmissibilityNotificationEmailForAdmissibleApplication(ApplicationEntity applicationEntity) { Map bodyPlaceholders = new HashMap<>(); bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName()); bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString()); diff --git a/src/main/java/net/gepafin/tendermanagement/enums/ApplicationStatusTypeEnum.java b/src/main/java/net/gepafin/tendermanagement/enums/ApplicationStatusTypeEnum.java index b6fd00b3..041ec85a 100644 --- a/src/main/java/net/gepafin/tendermanagement/enums/ApplicationStatusTypeEnum.java +++ b/src/main/java/net/gepafin/tendermanagement/enums/ApplicationStatusTypeEnum.java @@ -15,7 +15,8 @@ public enum ApplicationStatusTypeEnum { EVALUATION("EVALUATION"), APPOINTMENT("APPOINTMENT"), NDG("NDG"), - ADMISSIBLE("ADMISSIBLE"); + ADMISSIBLE("ADMISSIBLE"), + TECHNICAL_EVALUATION("TECHNICAL_EVALUATION"); private String value; diff --git a/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java b/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java index 415f1dd2..479912d7 100644 --- a/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java +++ b/src/main/java/net/gepafin/tendermanagement/enums/EmailScenarioTypeEnum.java @@ -8,7 +8,7 @@ public enum EmailScenarioTypeEnum { APPLICATION_AMENDMENT_REQUESTED("APPLICATION_AMENDMENT_REQUESTED"), APPLICATION_AMENDMENT_EXPIRED("APPLICATION_AMENDMENT_EXPIRED"), APPLICATION_AMENDMENT_REMINDER("APPLICATION_AMENDMENT_REMINDER"), - APPLICATION_APPROVED("APPLICATION_APPROVED"), + APPLICATION_ADMISSIBLE("APPLICATION_ADMISSIBLE"), USER_CREATION("USER_CREATION"), PASSWORD_RESET_REQUEST("PASSWORD_RESET_REQUEST"), APPLICATION_REJECTED("APPLICATION_REJECTED"); diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index e4232f22..5f3bbf66 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -2532,4 +2532,9 @@ newColumnName="appointment_template_id"/> + + + + diff --git a/src/main/resources/db/dump/updated_system_email_template_email_scenario_27_02_2025.sql b/src/main/resources/db/dump/updated_system_email_template_email_scenario_27_02_2025.sql new file mode 100644 index 00000000..2605b579 --- /dev/null +++ b/src/main/resources/db/dump/updated_system_email_template_email_scenario_27_02_2025.sql @@ -0,0 +1,2 @@ + +UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_ADMISSIBLE' WHERE "type"='ADMISSIBILITY_NOTIFICATION' AND "system"=true ; \ No newline at end of file diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index 36970d79..d312160e 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -390,7 +390,8 @@ company.document.copied.successfully = Company Document Copied successfully. invalid.expiration.date = Invalid Expiration Date - appointment.cannot.be.created = Appointment cannot be created because call doesn't have the template id. appointment.not.created = Appointment not created please try again. validation.failed.checklist=Validation failed for checklist. + +insufficient.score.msg = Insufficient score to pass to the technical and economic-financial evaluation diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index ce2e539d..67a3921c 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -384,3 +384,5 @@ invalid.expiration.date = Data di scadenza non valida appointment.cannot.be.created = Impossibile creare l'appuntamento perch� la chiamata non ha l'ID del modello di appuntamento. appointment.not.created = Appuntamento non creato, riprova validation.failed.checklist=Convalida fallita per la checklist. + +insufficient.score.msg = Punteggio non sufficiente per passaggio alla valutazione tecnica ed economico finanziaria From 5b8020b3f9adbfd616f1ac92c34bf4450377790f Mon Sep 17 00:00:00 2001 From: rajesh Date: Thu, 27 Feb 2025 19:26:48 +0530 Subject: [PATCH 2/2] updated code --- src/main/resources/db/changelog/db.changelog-1.0.0.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index e88c0116..de68936a 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -2532,7 +2532,7 @@ newColumnName="appointment_template_id"/> - +