Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into develop

This commit is contained in:
rajesh
2025-02-27 22:01:16 +05:30
13 changed files with 101 additions and 12 deletions

View File

@@ -478,6 +478,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";
public static final String PEC_SERVICE_URL="https://ws.pecmassiva.com";
public static final String PEC_SERVICE_SEND_MAIL="/send";
public static final String PEC_SERVICE_INBOX_MAIL="/quota/inbox";

View File

@@ -1,5 +1,9 @@
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 jakarta.persistence.criteria.*;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
@@ -918,8 +922,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);
@@ -950,14 +956,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. **/
@@ -967,6 +981,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));

View File

@@ -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()));

View File

@@ -571,7 +571,7 @@ public class CallDao {
}
}
public CallResponse updateCallStep1(CallEntity callEntity, UpdateCallRequestStep1 updateCallRequest, UserEntity userEntity) {
public CallResponse updateCallStep1(HttpServletRequest request,CallEntity callEntity, UpdateCallRequestStep1 updateCallRequest, UserEntity userEntity) {
CallEntity oldCallEntity = Utils.getClonedEntityForData(callEntity);
isValidDateRange(updateCallRequest, callEntity);
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
@@ -580,15 +580,41 @@ public class CallDao {
setIfUpdated(callEntity::getDescriptionLong, callEntity::setDescriptionLong,
updateCallRequest.getDescriptionLong());
List<LocalDateTime> dates=updateCallRequest.getDates();
boolean isEndDateUpdated = false;
boolean isEndTimeUpdated = false;
if (dates != null && dates.size()>1) {
if (dates.size() > 0) {
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, dates.get(0));
}
if (dates.size() > 1) {
LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
isEndDateUpdated = true;
}
}
}
if (updateCallRequest.getEndTime() != null) {
LocalTime requestEndTime = DateTimeUtil.parseTime(updateCallRequest.getEndTime());
LocalTime storedEndTime = callEntity.getEndTime();
if (!requestEndTime.equals(storedEndTime)) {
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
isEndTimeUpdated = true;
}
}
if (isEndDateUpdated || isEndTimeUpdated) {
loggingUtil.logUserAction(UserActionRequest.builder()
.request(request)
.actionType(UserActionLogsEnum.UPDATE)
.actionContext(UserActionContextEnum.UPDATE_CALL_END_DATE_AND_TIME)
.build());
}
// setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, updateCallRequest.getStartDate());
// setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, updateCallRequest.getEndDate());
setIfUpdated(callEntity::getAmount, callEntity::setAmount, updateCallRequest.getAmount());
@@ -606,7 +632,6 @@ public class CallDao {
setIfUpdated(callEntity::getEmail, callEntity::setEmail, updateCallRequest.getEmail());
setIfUpdated(callEntity::getPhoneNumber, callEntity::setPhoneNumber, updateCallRequest.getPhoneNumber());
setIfUpdated(callEntity::getStartTime, callEntity::setStartTime, DateTimeUtil.parseTime(updateCallRequest.getStartTime()));
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
setIfUpdated(callEntity::getEvaluationVersion, callEntity::setEvaluationVersion, updateCallRequest.getEvaluationVersion().getValue());
setIfUpdated(callEntity::getNumberOfCheck, callEntity::setNumberOfCheck, updateCallRequest.getNumberOfCheck());

View File

@@ -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());

View File

@@ -15,7 +15,8 @@ public enum ApplicationStatusTypeEnum {
EVALUATION("EVALUATION"),
APPOINTMENT("APPOINTMENT"),
NDG("NDG"),
ADMISSIBLE("ADMISSIBLE");
ADMISSIBLE("ADMISSIBLE"),
TECHNICAL_EVALUATION("TECHNICAL_EVALUATION");
private String value;

View File

@@ -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");

View File

@@ -212,7 +212,8 @@ public enum UserActionContextEnum {
GET_ALL_ASSIGNED_APPLICATION_BY_PAGINATION("GET_ALL_ASSIGNED_APPLICATION_BY_PAGINATION"),
GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION("GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION"),
GET_ALL_USER_ACTION_BY_PAGINATION("GET_ALL_USER_ACTION_BY_PAGINATION"),
GET_ALL_USER_BY_PAGINATION("GET_ALL_USER_BY_PAGINATION");
GET_ALL_USER_BY_PAGINATION("GET_ALL_USER_BY_PAGINATION"),
UPDATE_CALL_END_DATE_AND_TIME("UPDATE_CALL_END_DATE_AND_TIME");
private final String value;

View File

@@ -50,7 +50,7 @@ public class CallServiceImpl implements CallService {
UpdateCallRequestStep1 updateCallRequest) {
UserEntity user = validator.validateUser(request);
CallEntity call = validator.validateUserWithCall(user, callId);
return callDao.updateCallStep1(call, updateCallRequest, user);
return callDao.updateCallStep1(request,call, updateCallRequest, user);
}
@Override
@Transactional(readOnly = true)

View File

@@ -2532,6 +2532,11 @@
newColumnName="appointment_template_id"/>
</changeSet>
<changeSet id="27-02-2025_RK_192415" author="Rajesh Khore">
<sqlFile dbms="postgresql"
path="db/dump/updated_system_email_template_email_scenario_27_02_2025.sql"/>
</changeSet>
<changeSet id="26-02-2025_NK_180530" author="Nisha Kashyap">
<sqlFile dbms="postgresql"
path="db/dump/updated_hub_data_for_email_service_config_25-02-2025.sql"/>

View File

@@ -0,0 +1,2 @@
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_ADMISSIBLE' WHERE "type"='ADMISSIBILITY_NOTIFICATION' AND "system"=true ;

View File

@@ -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

View File

@@ -384,3 +384,5 @@ invalid.expiration.date = Data di scadenza non valida
appointment.cannot.be.created = Impossibile creare l'appuntamento perch<63> 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