Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into develop
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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) {
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(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());
|
||||
@@ -1089,4 +1114,4 @@ public class CallDao {
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.EVALUATION_V2_STEP_2);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user