Done ticket GEPAFINBE-175
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<ApplicationEvaluationEntity> 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<Map<String, Object>> 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));
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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<String, String> bodyPlaceholders = new HashMap<>();
|
||||
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
||||
bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString());
|
||||
|
||||
@@ -15,7 +15,8 @@ public enum ApplicationStatusTypeEnum {
|
||||
EVALUATION("EVALUATION"),
|
||||
APPOINTMENT("APPOINTMENT"),
|
||||
NDG("NDG"),
|
||||
ADMISSIBLE("ADMISSIBLE");
|
||||
ADMISSIBLE("ADMISSIBLE"),
|
||||
TECHNICAL_EVALUATION("TECHNICAL_EVALUATION");
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user