Merge pull request #213 from Kitzanos/develop
Sync Master with develop (13/02/2025)
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -245,6 +245,12 @@
|
|||||||
<artifactId>reactor-netty</artifactId>
|
<artifactId>reactor-netty</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.objecthunter</groupId>
|
||||||
|
<artifactId>exp4j</artifactId>
|
||||||
|
<version>0.4.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ public class GepafinConstant {
|
|||||||
public static final String APPLICATION_UPDATED_SUCCESS_MSG = "application.updated.success";
|
public static final String APPLICATION_UPDATED_SUCCESS_MSG = "application.updated.success";
|
||||||
public static final String DELETE_APPLICATION_SUCCESS_MSG = "application.deleted.success";
|
public static final String DELETE_APPLICATION_SUCCESS_MSG = "application.deleted.success";
|
||||||
public static final String GET_APPLICATION_SUCCESS_MSG = "application.get.success";
|
public static final String GET_APPLICATION_SUCCESS_MSG = "application.get.success";
|
||||||
|
public static final String GET_APPLICATION_EVALUATION_VERSION_SUCCESS_MSG = "application.evaluation.version.get.success";
|
||||||
public static final String APPLICATION_NOT_FOUND_MSG = "application.not.found";
|
public static final String APPLICATION_NOT_FOUND_MSG = "application.not.found";
|
||||||
public static final String APPLICATION_FORM_FIELD_NOT_FOUND = "application.form.field.not.found";
|
public static final String APPLICATION_FORM_FIELD_NOT_FOUND = "application.form.field.not.found";
|
||||||
public static final String FORM_ID_DOES_NOT_MACTHES = "Form.not.matches.to.call.initial.form";
|
public static final String FORM_ID_DOES_NOT_MACTHES = "Form.not.matches.to.call.initial.form";
|
||||||
@@ -237,6 +238,7 @@ public class GepafinConstant {
|
|||||||
public static final String EVALUATION_UPDATED_SUCCESSFULLY = "evaluation.updated.successfully";
|
public static final String EVALUATION_UPDATED_SUCCESSFULLY = "evaluation.updated.successfully";
|
||||||
public static final String EVALUATION_FETCHED_SUCCESSFULLY = "evaluation.fetched.successfully";
|
public static final String EVALUATION_FETCHED_SUCCESSFULLY = "evaluation.fetched.successfully";
|
||||||
public static final String EVALUATION_DELETED_SUCCESSFULLY = "evaluation.deleted.successfully";
|
public static final String EVALUATION_DELETED_SUCCESSFULLY = "evaluation.deleted.successfully";
|
||||||
|
public static final String GET_APPLICATION_EVALUATION_FORM_SUCCESS_MSG = "application.evaluation.form.get.success";
|
||||||
public static final String EVALUATIONS_FETCHED_SUCCESSFULLY = "evaluations.fetched.successfully";
|
public static final String EVALUATIONS_FETCHED_SUCCESSFULLY = "evaluations.fetched.successfully";
|
||||||
public static final String APPLICATION_EVALUATION_NOT_FOUND = "application.evaluation.not.found";
|
public static final String APPLICATION_EVALUATION_NOT_FOUND = "application.evaluation.not.found";
|
||||||
public static final String APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY = "application.evaluation.status.updated.successfully";
|
public static final String APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY = "application.evaluation.status.updated.successfully";
|
||||||
@@ -355,18 +357,39 @@ public class GepafinConstant {
|
|||||||
public static final String NOTIFICATION_DELETED_SUCCESSFULLY="notification.deleted.successfully";
|
public static final String NOTIFICATION_DELETED_SUCCESSFULLY="notification.deleted.successfully";
|
||||||
public static final String NOTIFICATION_UPDATED_SUCCESSFULLY="notification.updated.successfully";
|
public static final String NOTIFICATION_UPDATED_SUCCESSFULLY="notification.updated.successfully";
|
||||||
public static final String USER_WITH_COMPANY_NOT_FOUND = "user.with.company.not.found";
|
public static final String USER_WITH_COMPANY_NOT_FOUND = "user.with.company.not.found";
|
||||||
|
public static final String STATUS = "status";
|
||||||
|
public static final String CALL="call";
|
||||||
|
public static final String TITLE="title";
|
||||||
|
public static final String MESSAGE="message";
|
||||||
|
public static final String HUB_ID="hubId";
|
||||||
|
public static final String ID="id";
|
||||||
|
public static final String IS_DELETED="isDeleted";
|
||||||
|
public static final String COMPANY_ID="companyId";
|
||||||
|
public static final String COMMENTS="comments";
|
||||||
|
public static final String DESCRIPTION_LONG="descriptionLong";
|
||||||
|
public static final String DESCRIPTION_SHORT="descriptionShort";
|
||||||
|
public static final String HUB="hub";
|
||||||
|
public static final String NAME="name";
|
||||||
|
|
||||||
|
public static final String USER_ACTION_FETCHED_SUCCESSFULLY = "user.action.fetched.successfully";
|
||||||
|
public static final String ACTION_CONTEXT_LABELS_FETCHED_SUCCESSFULLY = "action.context.labels.fetched.successfully";
|
||||||
//action log response
|
//action log response
|
||||||
public static final String STATUS_CODE_STRING = "statusCode";
|
public static final String STATUS_CODE_STRING = "statusCode";
|
||||||
public static final String GET_STATUS_CODE_STRING = "status";
|
public static final String GET_STATUS_CODE_STRING = "status";
|
||||||
public static final String MESSAGE_STRING = "message";
|
public static final String MESSAGE_STRING = "message";
|
||||||
|
|
||||||
|
public static final String SUM="sum";
|
||||||
|
public static final String MULTIPLY="multiply";
|
||||||
|
public static final String NUMERIC="numeric";
|
||||||
public static final String AMOUNT_ACCEPTED_REQUIRED_WHILE_APPROVING_APPLICATION="amount.accepted.required";
|
public static final String AMOUNT_ACCEPTED_REQUIRED_WHILE_APPROVING_APPLICATION="amount.accepted.required";
|
||||||
public static final String CALL_NAME="callName";
|
public static final String CALL_NAME="callName";
|
||||||
public static final String NUMBER_OF_APPLICATIONS="numberOfApplications";
|
public static final String NUMBER_OF_APPLICATIONS="numberOfSubmitedApplications";
|
||||||
public static final String STATUS="status";
|
public static final String NUMBER_OF_DRAFT_APPLICATIONS="numberOfDraftApplications";
|
||||||
public static final String COUNT="count";
|
public static final String COUNT="count";
|
||||||
public static final String APPLICATION_PER_CALL="applicationPerCall";
|
public static final String APPLICATION_PER_CALL="applicationPerCall";
|
||||||
public static final String APPLICATION_PER_STATUS="applicationPerStatus";
|
public static final String APPLICATION_PER_STATUS="applicationPerStatus";
|
||||||
|
public static final String NON_EMPTY_TABLES="nonEmptyTables";
|
||||||
|
public static final String VALIDATION_IN_TABLE = "validation.table.message";
|
||||||
public static final String CALL_EXPIRED="call.expired";
|
public static final String CALL_EXPIRED="call.expired";
|
||||||
public static final String AMOUNT_REQUEST_SHOULD_GREATED_THEN_ZERO = "amount.request.should.greated.then.zero";
|
public static final String AMOUNT_REQUEST_SHOULD_GREATED_THEN_ZERO = "amount.request.should.greated.then.zero";
|
||||||
|
|
||||||
@@ -385,45 +408,23 @@ public class GepafinConstant {
|
|||||||
public static final String ASSIGNED_APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "assigned.application.status.updated.successfully";
|
public static final String ASSIGNED_APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "assigned.application.status.updated.successfully";
|
||||||
|
|
||||||
public static final String REQUIRED_REQUESTED_AMOUNT_MSG = "validation.required.requested.amount";
|
public static final String REQUIRED_REQUESTED_AMOUNT_MSG = "validation.required.requested.amount";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String REQUESTED_VS_APPROVED_AMOUNTS="requestedVsApprovedAmount";
|
||||||
|
public static final String MONTH="month";
|
||||||
|
public static final String TOTAL_REQUESTED="totalRequested";
|
||||||
|
public static final String TOTAL_APPROVED="totalApproved";
|
||||||
|
|
||||||
|
public static final String NUMBER_OF_APPLICATION="numberOfApplication";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String COMPANY_ID_NOT_NULL_MSG = "company.id.not.null";
|
||||||
|
public static final String USER_WITH_COMPANY="userWithCompany";
|
||||||
|
|
||||||
|
public static final String FORMULA_AMOUNT_NOT_MATCHED="formula.amount.not.matches.requested.amount";
|
||||||
public static final String CRITERIA_TABLE_COLUMNS="criteria_table_columns";
|
public static final String CRITERIA_TABLE_COLUMNS="criteria_table_columns";
|
||||||
|
|
||||||
public static final String DOCUMENTATION_INTEGRATION_REQUEST_SVILUPPUMBRIA= "<html>\n" +
|
|
||||||
" <body style=\"font-family: Arial, sans-serif; color: #000; line-height: 1.6;\">\n" +
|
|
||||||
" <div style=\"padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;\">\n" +
|
|
||||||
" <p><strong>RICHIESTA INTEGRAZIONE DOCUMENTALE</strong></p>\n" +
|
|
||||||
" <p>Buongiorno,</p>\n" +
|
|
||||||
" <p>In riferimento alla domanda di concessione di Finanziamento agevolato a valere sul Bando \n" +
|
|
||||||
" “<strong>{{call_name}}</strong>“ di cui al <strong>Protocollo n. {{protocol_number}} del\n" +
|
|
||||||
" {{protocol_date}} e {{protocol_time}}</strong>, alla luce dell'attività istruttoria svolta,\n" +
|
|
||||||
" segnaliamo quanto segue:\n" +
|
|
||||||
" </p>\n" +
|
|
||||||
" {{note}}\n" +
|
|
||||||
" <p>Vi invitiamo a fornire quanto sopra richiesto integrando la documentazione caricandola all'interno dello sportello\n" +
|
|
||||||
" online <a href=\"{{platform_link}}\">{{platform_link}}</a> entro e <strong>non oltre {{response_days}} giorni</strong> dal ricevimento della presente comunicazione,\n" +
|
|
||||||
" precisando che, in caso di mancata ricezione nei termini indicati, saremo costretti a non prendere in considerazione la Vostra richiesta di finanziamento.\n" +
|
|
||||||
" </p>\n" +
|
|
||||||
" <p>La documentazione trasmessa e le informazioni fornite saranno processate dall'istruttore assegnatario della pratica.\n" +
|
|
||||||
" </p>\n" +
|
|
||||||
" <p>Distinti Saluti,</p>\n" +
|
|
||||||
" <p><strong>{{email_signature}}</strong></p>\n" +
|
|
||||||
" </div>\n" +
|
|
||||||
" </body>\n" +
|
|
||||||
"</html>";
|
|
||||||
|
|
||||||
|
|
||||||
public static final String APPLICATION_REJECTED_SVILUPPUMBRIA = "<html>\n" +
|
|
||||||
" <body style=\"font-family: Arial, sans-serif; color: #000; line-height: 1.6;\">\n" +
|
|
||||||
" <div style=\"padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;\">\n" +
|
|
||||||
" <p>Buongiorno,</p>\n" +
|
|
||||||
" <p>Si comunica che, in riferimento alla domanda a valere sul bando “<strong>{{call_name}}</strong>” di cui al\n" +
|
|
||||||
" <strong>Protocollo n. {{protocol_number}} del {{protocol_date}} alle {{protocol_time}}</strong>,\n" +
|
|
||||||
" la stessa è stata sottoposta ad istruttoria di ammissibilità con esito negativo.</p>\n" +
|
|
||||||
" <p>Le motivazioni sono le seguenti: <strong>{{form_text}}</strong></p>\n" +
|
|
||||||
" <p>Vi ricordiamo che i Beneficiari che hanno presentato richieste valutate non ammissibili entro 10 giorni dalla data di ricevimento della presente potranno finoltrare richiesta di chiarimenti e/o osservazioni alla scrivente Società ai sensi e per gli effetti dell’art.10 bis della L.241/1990 e s.m.i.</p>\n" +
|
|
||||||
" <p>Distinti Saluti,</p>\n" +
|
|
||||||
" <p><strong>{{email_signature}}</strong></p>\n" +
|
|
||||||
" </div>\n" +
|
|
||||||
" </body>\n" +
|
|
||||||
"</html>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
public List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
||||||
if (validator.checkIsPreInstructor() && userId == null) {
|
if (validator.checkIsPreInstructor() && userId == null) {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
||||||
}
|
}
|
||||||
@@ -604,7 +604,7 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
applicationAmendmentRequestRepository.findAll(spec);
|
applicationAmendmentRequestRepository.findAll(spec);
|
||||||
|
|
||||||
return applicationAmendmentRequestEntities.stream()
|
return applicationAmendmentRequestEntities.stream()
|
||||||
.map(entity -> convertEntityToResponse(entity, false))
|
.map(this::initializeGetAllBasicResponse)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -990,7 +990,7 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
}
|
}
|
||||||
setIfUpdated(existingApplicationAmendment::getInternalNote, existingApplicationAmendment::setInternalNote, closeAmendmentRequest.getInternalNote());
|
setIfUpdated(existingApplicationAmendment::getInternalNote, existingApplicationAmendment::setInternalNote, closeAmendmentRequest.getInternalNote());
|
||||||
setIfUpdated(existingApplicationAmendment::getStatus, existingApplicationAmendment::setStatus, ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
setIfUpdated(existingApplicationAmendment::getStatus, existingApplicationAmendment::setStatus, ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
||||||
|
existingApplicationAmendment.setClosingDate(LocalDateTime.now());
|
||||||
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment, oldApplicationAmendmentEntity,
|
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment, oldApplicationAmendmentEntity,
|
||||||
VersionActionTypeEnum.UPDATE);
|
VersionActionTypeEnum.UPDATE);
|
||||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment,false);
|
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment,false);
|
||||||
@@ -1178,6 +1178,37 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
return applicationEvaluation;
|
return applicationEvaluation;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private GetAllAmendmentResponseBean initializeGetAllBasicResponse(ApplicationAmendmentRequestEntity entity) {
|
||||||
|
GetAllAmendmentResponseBean response = new GetAllAmendmentResponseBean();
|
||||||
|
ApplicationEntity applicationEntity = entity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication();
|
||||||
|
response.setId(entity.getId());
|
||||||
|
response.setApplicationId(entity.getApplicationId());
|
||||||
|
response.setApplicationEvaluationId(entity.getApplicationEvaluationEntity().getId());
|
||||||
|
response.setNote(entity.getNote());
|
||||||
|
response.setStatus(ApplicationAmendmentRequestEnum.valueOf(entity.getStatus()));
|
||||||
|
response.setResponseDays(entity.getResponseDays());
|
||||||
|
response.setInternalNote(entity.getInternalNote());
|
||||||
|
|
||||||
|
LocalDateTime startDate = entity.getStartDate();
|
||||||
|
response.setStartDate(startDate);
|
||||||
|
response.setExpirationDate(entity.getEndDate());
|
||||||
|
response.setEvaluationEndDate(entity.getApplicationEvaluationEntity().getEndDate());
|
||||||
|
response.setIsSendEmail(entity.getIsEmail());
|
||||||
|
response.setIsSendNotification(entity.getIsNotification());
|
||||||
|
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(entity.getApplicationId());
|
||||||
|
response.setCallEmail(application.getCall().getEmail());
|
||||||
|
response.setCallName(application.getCall().getName());
|
||||||
|
|
||||||
|
UserEntity userEntity = userService.validateUser(application.getUserId());
|
||||||
|
response.setBeneficiaryName(buildBeneficiaryName(userEntity));
|
||||||
|
CompanyEntity company = companyService.validateCompany(application.getCompanyId());
|
||||||
|
response.setCompanyName(company.getCompanyName());
|
||||||
|
Long protocolNumber = entity.getProtocol() != null ? entity.getProtocol().getProtocolNumber() : null;
|
||||||
|
response.setProtocolNumber(protocolNumber);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
private void softDeleteDocument(Long documentId) {
|
private void softDeleteDocument(Long documentId) {
|
||||||
documentService.deleteFile(documentId);
|
documentService.deleteFile(documentId);
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Root;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.*;
|
import net.gepafin.tendermanagement.enums.*;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBean;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
|
||||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
|
||||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
|
||||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
|
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||||
@@ -33,10 +31,13 @@ import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundExceptio
|
|||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
import org.h2.util.IOUtils;
|
import org.h2.util.IOUtils;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -49,14 +50,21 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ApplicationDao {
|
public class ApplicationDao {
|
||||||
|
|
||||||
@@ -181,6 +189,7 @@ public class ApplicationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||||
|
|
||||||
|
|
||||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||||
FormEntity formEntity = formService.validateForm(formId);
|
FormEntity formEntity = formService.validateForm(formId);
|
||||||
// callService.validatePublishedCall(formEntity.getCall().getId());
|
// callService.validatePublishedCall(formEntity.getCall().getId());
|
||||||
@@ -232,6 +241,7 @@ public class ApplicationDao {
|
|||||||
entity.setUserWithCompany(userWithCompany);
|
entity.setUserWithCompany(userWithCompany);
|
||||||
entity.setIsDeleted(false);
|
entity.setIsDeleted(false);
|
||||||
entity.setStatus(ApplicationStatusTypeEnum.DRAFT.getValue());
|
entity.setStatus(ApplicationStatusTypeEnum.DRAFT.getValue());
|
||||||
|
entity.setEvaluationVersion(call.getEvaluationVersion());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +410,7 @@ public class ApplicationDao {
|
|||||||
ApplicationResponse responseBean = new ApplicationResponse();
|
ApplicationResponse responseBean = new ApplicationResponse();
|
||||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
||||||
Long totalFormSteps = flowFormDao.calculateTotalSteps(flowEdgesList);
|
Long totalFormSteps = flowFormDao.calculateTotalSteps(flowEdgesList);
|
||||||
Long completedSteps= Long.valueOf(flowFormDao.getCompletedSteps(applicationEntity));
|
Long completedSteps= Long.valueOf(flowFormDao.getCompletedSteps(applicationEntity, false));
|
||||||
Integer progress = calculateProgress(totalFormSteps, completedSteps);
|
Integer progress = calculateProgress(totalFormSteps, completedSteps);
|
||||||
responseBean.setId(applicationEntity.getId());
|
responseBean.setId(applicationEntity.getId());
|
||||||
responseBean.setProgress(progress);
|
responseBean.setProgress(progress);
|
||||||
@@ -411,6 +421,7 @@ public class ApplicationDao {
|
|||||||
responseBean.setCallId(applicationEntity.getCall().getId());
|
responseBean.setCallId(applicationEntity.getCall().getId());
|
||||||
responseBean.setSubmissionDate(applicationEntity.getSubmissionDate());
|
responseBean.setSubmissionDate(applicationEntity.getSubmissionDate());
|
||||||
responseBean.setStatus(applicationEntity.getStatus());
|
responseBean.setStatus(applicationEntity.getStatus());
|
||||||
|
responseBean.setEvaluationVersion(EvaluationVersionEnum.valueOf(applicationEntity.getCall().getEvaluationVersion()));
|
||||||
responseBean.setComments(applicationEntity.getComments());
|
responseBean.setComments(applicationEntity.getComments());
|
||||||
responseBean.setCompanyId(applicationEntity.getCompanyId());
|
responseBean.setCompanyId(applicationEntity.getCompanyId());
|
||||||
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
||||||
@@ -478,15 +489,18 @@ public class ApplicationDao {
|
|||||||
|
|
||||||
public List<ApplicationFormFieldEntity> createOrUpdateMultipleFormFields(List<ApplicationFormFieldRequestBean> formFieldResponseBeans,
|
public List<ApplicationFormFieldEntity> createOrUpdateMultipleFormFields(List<ApplicationFormFieldRequestBean> formFieldResponseBeans,
|
||||||
ApplicationFormEntity applicationFormEntity, FormEntity formEntity) {
|
ApplicationFormEntity applicationFormEntity, FormEntity formEntity) {
|
||||||
|
FieldValidator fieldValidator = FieldValidator.create();
|
||||||
|
|
||||||
List<ApplicationFormFieldEntity> existingFields = applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId());
|
List<ApplicationFormFieldEntity> existingFields = applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId());
|
||||||
|
|
||||||
return formFieldResponseBeans.stream().map(requestBean -> createOrUpdateApplicationFormField(requestBean, applicationFormEntity, existingFields, formEntity))
|
List<ApplicationFormFieldEntity> applicationFormFieldEntities=formFieldResponseBeans.stream().map(requestBean -> createOrUpdateApplicationFormField(requestBean, applicationFormEntity, existingFields, formEntity,fieldValidator))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
fieldValidator.validate();
|
||||||
|
return applicationFormFieldEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationFormFieldEntity createOrUpdateApplicationFormField(ApplicationFormFieldRequestBean applicationFormFieldRequestBean,
|
public ApplicationFormFieldEntity createOrUpdateApplicationFormField(ApplicationFormFieldRequestBean applicationFormFieldRequestBean,
|
||||||
ApplicationFormEntity applicationFormEntity, List<ApplicationFormFieldEntity> applicationFormFieldEntities, FormEntity formEntity) {
|
ApplicationFormEntity applicationFormEntity, List<ApplicationFormFieldEntity> applicationFormFieldEntities, FormEntity formEntity,FieldValidator fieldValidator) {
|
||||||
|
|
||||||
ApplicationFormFieldEntity applicationFormFieldEntity = new ApplicationFormFieldEntity();
|
ApplicationFormFieldEntity applicationFormFieldEntity = new ApplicationFormFieldEntity();
|
||||||
|
|
||||||
@@ -502,7 +516,6 @@ public class ApplicationDao {
|
|||||||
.filter(setting -> "isRequestedAmount".equals(setting.getName()) && Boolean.TRUE.equals(setting.getValue()))
|
.filter(setting -> "isRequestedAmount".equals(setting.getName()) && Boolean.TRUE.equals(setting.getValue()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(setting -> {
|
.ifPresent(setting -> {
|
||||||
|
|
||||||
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||||
if(fieldValue!=null) {
|
if(fieldValue!=null) {
|
||||||
try {
|
try {
|
||||||
@@ -534,6 +547,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
calculationProcessForFormula(applicationFormEntity,contentResponseBeans,applicationFormFieldRequestBean,fieldValidator);
|
||||||
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
||||||
|
|
||||||
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
||||||
@@ -556,7 +570,6 @@ public class ApplicationDao {
|
|||||||
VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationFormFieldData).newData(applicationFormField).build());
|
VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationFormFieldData).newData(applicationFormField).build());
|
||||||
|
|
||||||
log.info("Version history logged for action: {}, Field ID: {}", actionType, applicationFormFieldEntity.getFieldId());
|
log.info("Version history logged for action: {}, Field ID: {}", actionType, applicationFormFieldEntity.getFieldId());
|
||||||
|
|
||||||
return applicationFormField;
|
return applicationFormField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +678,7 @@ public class ApplicationDao {
|
|||||||
return documentIds;
|
return documentIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Long> validateDocumentIds(String documentId) {
|
public List<Long> validateDocumentIds(String documentId) {
|
||||||
if (documentId != null && !documentId.isEmpty()) {
|
if (documentId != null && !documentId.isEmpty()) {
|
||||||
return Arrays.stream(documentId.split(","))
|
return Arrays.stream(documentId.split(","))
|
||||||
.map(Long::parseLong)
|
.map(Long::parseLong)
|
||||||
@@ -1286,7 +1299,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
||||||
Long totalSteps = flowFormDao.calculateTotalSteps(flowEdgesList);
|
Long totalSteps = flowFormDao.calculateTotalSteps(flowEdgesList);
|
||||||
Integer completedSteps = flowFormDao.getCompletedSteps(applicationEntity);
|
Integer completedSteps = flowFormDao.getCompletedSteps(applicationEntity, true);
|
||||||
if (totalSteps.intValue() != completedSteps) {
|
if (totalSteps.intValue() != completedSteps) {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
|
||||||
}
|
}
|
||||||
@@ -1419,6 +1432,142 @@ public class ApplicationDao {
|
|||||||
throw new RuntimeException("Error while creating ZIP file", e);
|
throw new RuntimeException("Error while creating ZIP file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(UserEntity userEntity, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean) {
|
||||||
|
Integer pageNo = null;
|
||||||
|
Integer pageLimit = null;
|
||||||
|
|
||||||
|
UserWithCompanyEntity userWithCompany= userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyId).orElse(null);
|
||||||
|
|
||||||
|
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
||||||
|
pageNo = applicationPageableRequestBean.getGlobalFilters().getPage();
|
||||||
|
pageLimit = applicationPageableRequestBean.getGlobalFilters().getLimit();
|
||||||
|
}
|
||||||
|
if (pageLimit == null || pageLimit <= 0) {
|
||||||
|
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||||
|
}
|
||||||
|
if (pageNo == null || pageNo <= 0) {
|
||||||
|
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||||
|
}
|
||||||
|
Specification<ApplicationEntity> spec = search(callId,companyId, userWithCompany.getId(), applicationPageableRequestBean, userEntity);
|
||||||
|
Page<ApplicationEntity> entityPage = applicationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||||
|
// Prepare the response
|
||||||
|
|
||||||
|
|
||||||
|
List<ApplicationResponse> applicationResponses = entityPage.getContent().stream()
|
||||||
|
.map(application -> {
|
||||||
|
ApplicationResponse response = getApplicationResponse(application);
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
PageableResponseBean<List<ApplicationResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||||
|
pageableResponseBean.setBody(applicationResponses);
|
||||||
|
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||||
|
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||||
|
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||||
|
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||||
|
|
||||||
|
return pageableResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Specification<ApplicationEntity> search(Long callId, Long companyId, Long userWithCompanyId, ApplicationPageableRequestBean applicationPageableRequestBean, UserEntity userEntity) {
|
||||||
|
return (root, query, criteriaBuilder) -> {
|
||||||
|
|
||||||
|
List<Predicate> predicates = getPredicates(applicationPageableRequestBean, criteriaBuilder, root, callId,companyId, userWithCompanyId, userEntity);
|
||||||
|
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||||
|
|
||||||
|
if (applicationPageableRequestBean.getGlobalFilters() != null
|
||||||
|
&& applicationPageableRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||||
|
applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||||
|
isEmpty(applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||||
|
sortBy.setColumnName(applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||||
|
sortBy.setSortDesc(true);
|
||||||
|
if (applicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||||
|
sortBy.setSortDesc(applicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||||
|
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||||
|
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||||
|
}
|
||||||
|
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<Predicate> getPredicates(ApplicationPageableRequestBean applicationPageableRequestBean,
|
||||||
|
CriteriaBuilder criteriaBuilder, Root<ApplicationEntity> root, Long callId,Long companyId, Long userWithCompanyId, UserEntity userEntity) {
|
||||||
|
|
||||||
|
Integer year = null;
|
||||||
|
String search = null;
|
||||||
|
Integer daysRange = null;
|
||||||
|
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
||||||
|
year = applicationPageableRequestBean.getGlobalFilters().getYear();
|
||||||
|
search = applicationPageableRequestBean.getGlobalFilters().getSearch();
|
||||||
|
daysRange = applicationPageableRequestBean.getDaysRange();
|
||||||
|
}
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
|
||||||
|
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||||
|
if (isBeneficiary) {
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userEntity.getId()));
|
||||||
|
}
|
||||||
|
if (year != null && year > 0) {
|
||||||
|
int filterYear = applicationPageableRequestBean.getGlobalFilters().getYear();
|
||||||
|
|
||||||
|
// Create LocalDateTime boundaries for the start and end of the year
|
||||||
|
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||||
|
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||||
|
|
||||||
|
// Add the range comparison to filter records within the year
|
||||||
|
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||||
|
|
||||||
|
}
|
||||||
|
// Search in `title` and `message` (if search term is provided)
|
||||||
|
if (search != null && !search.isEmpty()) {
|
||||||
|
Predicate titlePredicate = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.COMMENTS)),
|
||||||
|
"%" + search.toUpperCase() + "%"
|
||||||
|
);
|
||||||
|
predicates.add(criteriaBuilder.or(titlePredicate));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by `status` (if status list is provided)
|
||||||
|
if (applicationPageableRequestBean.getStatus() != null && !applicationPageableRequestBean.getStatus().isEmpty()) {
|
||||||
|
List<String> statusValues = applicationPageableRequestBean.getStatus().stream()
|
||||||
|
.map(ApplicationStatusTypeEnum::name) // Convert enum to string
|
||||||
|
.toList();
|
||||||
|
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callId != null) {
|
||||||
|
CallEntity call = callService.validateCall(callId);
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.CALL).get(GepafinConstant.ID), callId));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional companyId filter
|
||||||
|
if (userWithCompanyId != null) {
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_WITH_COMPANY).get(GepafinConstant.ID), userWithCompanyId));
|
||||||
|
}
|
||||||
|
if (companyId != null) {
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.COMPANY_ID), companyId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (daysRange != null && daysRange >= 0) {
|
||||||
|
LocalDateTime today = LocalDateTime.now();
|
||||||
|
LocalDateTime pastDate = today.minusDays(daysRange);
|
||||||
|
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
|
||||||
|
}
|
||||||
|
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||||
|
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB_ID), userEntity.getHub().getId()));
|
||||||
|
|
||||||
|
|
||||||
|
return predicates;
|
||||||
|
}
|
||||||
public void checkCallEndDate(CallEntity call) {
|
public void checkCallEndDate(CallEntity call) {
|
||||||
LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
||||||
|
|
||||||
@@ -1435,5 +1584,135 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void calculationProcessForFormula(ApplicationFormEntity applicationFormEntity, List<ContentResponseBean> contentResponseBeans, ApplicationFormFieldRequestBean applicationFormFieldRequestBean,FieldValidator fieldValidator) {
|
||||||
|
List<String> formulaValue = new ArrayList<>();
|
||||||
|
String formulaValueOpt=null;
|
||||||
|
String label=null;
|
||||||
|
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
||||||
|
if(contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())){
|
||||||
|
for (SettingResponseBean settingResponseBean:contentResponseBean.getSettings()){
|
||||||
|
if (settingResponseBean.getName().equals("label")){
|
||||||
|
label= String.valueOf(settingResponseBean.getValue());
|
||||||
|
}
|
||||||
|
if(settingResponseBean.getName().equals("formula")){
|
||||||
|
String value= (String) settingResponseBean.getValue();
|
||||||
|
formulaValueOpt=value;
|
||||||
|
formulaValue=Utils.extractValues(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, String> mappedFormulaValue = new HashMap<>();
|
||||||
|
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||||
|
if (formulaValueOpt != null && fieldValue==null) {
|
||||||
|
fieldValue=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||||
|
String contentId = contentResponseBean.getId();
|
||||||
|
|
||||||
|
// Extract variable values once per contentResponseBean to avoid repeated stream operations
|
||||||
|
Set<String> variableValues = contentResponseBean.getSettings().stream()
|
||||||
|
.filter(setting -> "variable".equals(setting.getName()))
|
||||||
|
.flatMap(setting -> {
|
||||||
|
Object value = setting.getValue(); // Get the raw value
|
||||||
|
if (value instanceof String) {
|
||||||
|
return Stream.of((String) value); // Handle single String case
|
||||||
|
} else if (value instanceof List) {
|
||||||
|
return ((List<?>) value).stream()
|
||||||
|
.filter(item -> item instanceof String) // Ensure it's a String
|
||||||
|
.map(item -> (String) item); // Convert to String
|
||||||
|
} else {
|
||||||
|
return Stream.empty(); // Ignore unexpected types
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect(Collectors.toSet()); // Collect into a Set for uniqueness
|
||||||
|
|
||||||
|
for (String formula : formulaValue) {
|
||||||
|
if (variableValues.contains(formula)) { // O(1) lookup instead of O(n)
|
||||||
|
mappedFormulaValue.put(formula, contentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, String> updatedMappedFormulaValue = new HashMap<>();
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : mappedFormulaValue.entrySet()) {
|
||||||
|
String variable = entry.getKey();
|
||||||
|
String contentId = entry.getValue();
|
||||||
|
|
||||||
|
// Repository call using contentId
|
||||||
|
Optional<ApplicationFormFieldEntity> optionalEntity = applicationFormFieldRepository.findByApplicationFormIdAndFieldId(applicationFormEntity.getId(),contentId);
|
||||||
|
// If entity is found, extract fieldValue and fieldId
|
||||||
|
optionalEntity.ifPresent(entity -> {
|
||||||
|
String entityFieldValue = entity.getFieldValue(); // Assuming getter method exists
|
||||||
|
String fieldId = entity.getFieldId(); // Assuming getter method exists
|
||||||
|
String tableType = contentResponseBeans.stream()
|
||||||
|
.filter(content -> content.getId().equals(fieldId)) // Match Content ID with fieldId
|
||||||
|
.flatMap(content -> content.getSettings().stream()) // Extract settings
|
||||||
|
.filter(setting -> "criteria_table_columns".equals(setting.getName())) // Match name
|
||||||
|
.map(setting -> setting.getName()) // Return the name of the setting
|
||||||
|
.findFirst() // Get the first match
|
||||||
|
.orElse(null); // Default to null if no match
|
||||||
|
|
||||||
|
if(tableType!=null){
|
||||||
|
JSONObject jsonObject = new JSONObject(entityFieldValue);
|
||||||
|
|
||||||
|
// Extract the value of total
|
||||||
|
entityFieldValue = jsonObject.getString("total");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
updatedMappedFormulaValue.put(fieldId, entityFieldValue);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(formulaValueOpt==null || formulaValueOpt.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double finalValue = evaluateFormula(formulaValueOpt, mappedFormulaValue, updatedMappedFormulaValue);
|
||||||
|
|
||||||
|
fieldValidator.formulaValidation(fieldValue, finalValue, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static double evaluateFormula(String formula, Map<String, String> mappedFormulaValue, Map<String, String> updatedMappedFormulaValue) {
|
||||||
|
// Step 1: Extract all placeholders (variables) like {rest}, {another_var}, etc.
|
||||||
|
Pattern pattern = Pattern.compile("\\{(.*?)\\}");
|
||||||
|
Matcher matcher = pattern.matcher(formula);
|
||||||
|
List<String> variables = new ArrayList<>();
|
||||||
|
|
||||||
|
while (matcher.find()) {
|
||||||
|
variables.add(matcher.group(1)); // Extract variable names inside the curly braces
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2: Replace placeholders with corresponding fieldValue
|
||||||
|
Map<String, Double> variableValues = new HashMap<>();
|
||||||
|
|
||||||
|
for (String variable : variables) {
|
||||||
|
String fieldId = mappedFormulaValue.get(variable);
|
||||||
|
if (fieldId != null && updatedMappedFormulaValue.containsKey(fieldId)) {
|
||||||
|
String fieldValueStr = updatedMappedFormulaValue.get(fieldId);
|
||||||
|
try {
|
||||||
|
double fieldValue = Double.parseDouble(fieldValueStr); // Assuming fieldValue is numeric
|
||||||
|
variableValues.put(variable, fieldValue);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// Handle invalid number format gracefully (e.g., log an error or default to 0)
|
||||||
|
variableValues.put(variable, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 3: Replace variables in the formula with their corresponding values
|
||||||
|
String expression = formula;
|
||||||
|
for (String variable : variables) {
|
||||||
|
Double value = variableValues.get(variable);
|
||||||
|
if (value != null) {
|
||||||
|
// Replace {variable} with its corresponding value in the formula
|
||||||
|
expression = expression.replace("{" + variable + "}", String.valueOf(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 4: Evaluate the mathematical expression
|
||||||
|
return Utils.evaluateExpression(expression);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ import net.gepafin.tendermanagement.model.request.*;
|
|||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
import net.gepafin.tendermanagement.service.*;
|
import net.gepafin.tendermanagement.service.*;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.*;
|
||||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
@@ -25,6 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
@@ -32,6 +30,7 @@ import java.util.*;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static net.gepafin.tendermanagement.util.Utils.log;
|
||||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -113,12 +112,49 @@ public class ApplicationEvaluationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
|
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HubService hubService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationFormService evaluationFormService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationFormDao evaluationFormDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEvaluationFormRepository applicationEvaluationFormRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEvaluationFormFieldRepository applicationEvaluationFormFieldRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationDao applicationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEvaluationService applicationEvaluationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallDao callDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationFormRepository evaluationFormRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
|
||||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||||
|
|
||||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||||
|
|
||||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsService.validateAssignedApplication(assignedApplciationId);
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsService.validateAssignedApplication(assignedApplciationId);
|
||||||
ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId());
|
ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId());
|
||||||
|
|
||||||
|
Long hubId = application.getHubId();
|
||||||
|
HubEntity hub = hubService.valdateHub(hubId);
|
||||||
|
|
||||||
|
Long initialDays = (hub != null) ? hub.getEvaluationExpirationDays() : 30L;
|
||||||
|
|
||||||
entity.setApplicationId(application.getId());
|
entity.setApplicationId(application.getId());
|
||||||
entity.setAssignedApplicationsEntity(assignedApplications);
|
entity.setAssignedApplicationsEntity(assignedApplications);
|
||||||
entity.setUserId(user.getId());
|
entity.setUserId(user.getId());
|
||||||
@@ -128,11 +164,12 @@ public class ApplicationEvaluationDao {
|
|||||||
entity.setNote(req.getNote());
|
entity.setNote(req.getNote());
|
||||||
entity.setMotivation(req.getMotivation());
|
entity.setMotivation(req.getMotivation());
|
||||||
entity.setIsDeleted(false);
|
entity.setIsDeleted(false);
|
||||||
entity.setInitialDays(30L);
|
entity.setInitialDays(initialDays);
|
||||||
entity.setRemainingDays(30L);
|
entity.setRemainingDays(initialDays);
|
||||||
entity.setSuspendedDays(0L);
|
entity.setSuspendedDays(0L);
|
||||||
entity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
entity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
entity.setEndDate(DateTimeUtil.DateServerToUTC(application.getSubmissionDate().plusDays(30)));
|
entity.setEndDate(DateTimeUtil.DateServerToUTC(application.getSubmissionDate().plusDays(initialDays)));
|
||||||
|
entity.setEvaluationVersion(application.getEvaluationVersion());
|
||||||
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@@ -254,9 +291,13 @@ public class ApplicationEvaluationDao {
|
|||||||
response.setNote(entity.getNote());
|
response.setNote(entity.getNote());
|
||||||
response.setMotivation(entity.getMotivation());
|
response.setMotivation(entity.getMotivation());
|
||||||
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus()));
|
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus()));
|
||||||
|
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(entity.getEvaluationVersion()));
|
||||||
response.setEvaluationEndDate(entity.getEndDate());
|
response.setEvaluationEndDate(entity.getEndDate());
|
||||||
response.setCreatedDate(entity.getCreatedDate());
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
response.setUpdatedDate(entity.getUpdatedDate());
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
response.setNumberOfCheck(entity.getAssignedApplicationsEntity().getApplication().getCall().getNumberOfCheck());
|
||||||
|
response.setProductId(entity.getAssignedApplicationsEntity().getApplication().getCall().getProductId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -603,6 +644,7 @@ public class ApplicationEvaluationDao {
|
|||||||
ApplicationEvaluationEntity oldApplicationEvaluation = null;
|
ApplicationEvaluationEntity oldApplicationEvaluation = null;
|
||||||
ApplicationEntity application = applicationService.validateApplication(assignedApplications.get().getApplication().getId());
|
ApplicationEntity application = applicationService.validateApplication(assignedApplications.get().getApplication().getId());
|
||||||
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||||
|
validateApplicationEvaluationRequest(req, application);
|
||||||
if (existingEntityOptional.isPresent()) {
|
if (existingEntityOptional.isPresent()) {
|
||||||
entity = existingEntityOptional.get();
|
entity = existingEntityOptional.get();
|
||||||
oldApplicationEvaluation = Utils.getClonedEntityForData(entity);
|
oldApplicationEvaluation = Utils.getClonedEntityForData(entity);
|
||||||
@@ -625,16 +667,33 @@ public class ApplicationEvaluationDao {
|
|||||||
application.setAmountAccepted(req.getAmountAccepted());
|
application.setAmountAccepted(req.getAmountAccepted());
|
||||||
}
|
}
|
||||||
actionType = VersionActionTypeEnum.UPDATE;
|
actionType = VersionActionTypeEnum.UPDATE;
|
||||||
|
|
||||||
|
entity = applicationEvaluationRepository.save(entity);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
||||||
entity = convertToEntity(user, req, assignedApplicationId);
|
entity = convertToEntity(user, req, assignedApplicationId);
|
||||||
actionType = VersionActionTypeEnum.INSERT;
|
actionType = VersionActionTypeEnum.INSERT;
|
||||||
|
|
||||||
|
entity = applicationEvaluationRepository.save(entity);
|
||||||
|
|
||||||
|
ApplicationEntity oldApplication = Utils.getClonedEntityForData(application);
|
||||||
|
|
||||||
|
application.setApplicationEvaluationId(entity.getId());
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplication).newData(application).build());
|
||||||
|
|
||||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_CREATION);
|
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_CREATION);
|
||||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_CREATION);
|
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_CREATION);
|
||||||
notificationDao.sendNotificationToInstructor(placeHolders,entity,NotificationTypeEnum.EVALUATION_CREATION);
|
notificationDao.sendNotificationToInstructor(placeHolders,entity,NotificationTypeEnum.EVALUATION_CREATION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationEvaluation).newData(entity).build());
|
||||||
|
|
||||||
ApplicationStatusForEvaluation status = req.getApplicationStatus();
|
ApplicationStatusForEvaluation status = req.getApplicationStatus();
|
||||||
// Fetch all amendment request entities associated with the evaluation ID
|
// Fetch all amendment request entities associated with the evaluation ID
|
||||||
List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities =
|
List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities =
|
||||||
@@ -647,18 +706,20 @@ public class ApplicationEvaluationDao {
|
|||||||
List<AmendmentDetailsRequest> amendmentDetailsRequests = req.getAmendmentDetails();
|
List<AmendmentDetailsRequest> amendmentDetailsRequests = req.getAmendmentDetails();
|
||||||
|
|
||||||
updateAmendmentDocumentsAndFormFields(applicationAmendmentRequestEntities, amendmentDetailsRequests);
|
updateAmendmentDocumentsAndFormFields(applicationAmendmentRequestEntities, amendmentDetailsRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(entity);
|
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
|
||||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationEvaluation).newData(entity).build());
|
|
||||||
|
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplications.get();
|
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplications.get();
|
||||||
return updateApplicationEvaluationStatus(application, assignedApplicationsEntity, status);
|
return updateApplicationEvaluationStatus(application, assignedApplicationsEntity, status);
|
||||||
} else {
|
} else {
|
||||||
return convertToResponse(savedEntity);
|
return convertToResponse(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateApplicationEvaluationRequest(ApplicationEvaluationRequest req, ApplicationEntity application) {
|
||||||
|
if(EvaluationVersionEnum.V2.getValue().equals(application.getEvaluationVersion())) {
|
||||||
|
req.setChecklist(null);
|
||||||
|
req.setCriteria(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1086,6 +1147,7 @@ public class ApplicationEvaluationDao {
|
|||||||
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
response.setApplicationId(application.getId());
|
response.setApplicationId(application.getId());
|
||||||
response.setAssignedApplicationId(assignedApplications.getId());
|
response.setAssignedApplicationId(assignedApplications.getId());
|
||||||
|
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(application.getEvaluationVersion()));
|
||||||
response.setNote(null);
|
response.setNote(null);
|
||||||
response.setMotivation(null);
|
response.setMotivation(null);
|
||||||
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
||||||
@@ -1094,6 +1156,8 @@ public class ApplicationEvaluationDao {
|
|||||||
response.setEvaluationEndDate(entity.getEndDate());
|
response.setEvaluationEndDate(entity.getEndDate());
|
||||||
LocalDateTime callEndDate = application.getCall().getEndDate();
|
LocalDateTime callEndDate = application.getCall().getEndDate();
|
||||||
response.setCallEndDate(callEndDate);
|
response.setCallEndDate(callEndDate);
|
||||||
|
response.setNumberOfCheck(call.getNumberOfCheck());
|
||||||
|
response.setProductId(call.getProductId());
|
||||||
setCriteriaResponses(entity, application.getId(), response, evaluationCriterias);
|
setCriteriaResponses(entity, application.getId(), response, evaluationCriterias);
|
||||||
setChecklistResponses(entity, application.getId(), response, checklistEntities);
|
setChecklistResponses(entity, application.getId(), response, checklistEntities);
|
||||||
setFileResponses(entity, application.getId(), response, applicationFormEntities);
|
setFileResponses(entity, application.getId(), response, applicationFormEntities);
|
||||||
@@ -1886,5 +1950,321 @@ public class ApplicationEvaluationDao {
|
|||||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluation).newData(savedEntity).build());
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluation).newData(savedEntity).build());
|
||||||
return convertToResponse(savedEntity);
|
return convertToResponse(savedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long evaluationFormId, Long assignedApplicationId){
|
||||||
|
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(assignedApplicationsEntity.getApplication().getId());
|
||||||
|
|
||||||
|
// Convert FormRequestBean to ApplicationEvaluationRequest
|
||||||
|
ApplicationEvaluationRequest req = convertToApplicationEvaluationRequest(applicationEvaluationFormRequestBean);
|
||||||
|
|
||||||
|
// Call the existing method to create or update evaluation
|
||||||
|
ApplicationEvaluationResponse evaluationResponse = createOrUpdateApplicationEvaluation(user, req, assignedApplicationId);
|
||||||
|
|
||||||
|
ApplicationEvaluationEntity entity = applicationEvaluationService.validateApplicationEvaluation(evaluationResponse.getId());
|
||||||
|
|
||||||
|
//Handling Application Evaluation form
|
||||||
|
EvaluationFormEntity evaluationFormEntity = evaluationFormService.validateEvaluationForm(evaluationFormId);
|
||||||
|
validateFormFields(applicationEvaluationFormRequestBean,evaluationFormEntity);
|
||||||
|
// ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationRepository.findByAssignedApplicationsId(assignedApplicationId);
|
||||||
|
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = getApplicationEvaluationFormOrCreate(evaluationFormEntity,entity);
|
||||||
|
createOrUpdateMultipleFormFields(applicationEvaluationFormRequestBean.getFormFields(), applicationEvaluationFormEntity, evaluationFormEntity);
|
||||||
|
return processEvaluationForm(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationFormEntity getApplicationEvaluationFormOrCreate(EvaluationFormEntity evaluationFormEntity, ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||||
|
|
||||||
|
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(), evaluationFormEntity.getId());
|
||||||
|
ApplicationEvaluationFormEntity oldApplicationEvaluationFormEntity = Utils.getClonedEntityForData(applicationEvaluationFormEntity);
|
||||||
|
if (applicationEvaluationFormEntity == null) {
|
||||||
|
applicationEvaluationFormEntity = createApplicationEvaluationFormEntity(applicationEvaluationEntity, evaluationFormEntity);
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Create application evalaution form" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(
|
||||||
|
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(oldApplicationEvaluationFormEntity).newData(applicationEvaluationFormEntity)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
return applicationEvaluationFormEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationFormEntity createApplicationEvaluationFormEntity(ApplicationEvaluationEntity applicationEvaluationEntity, EvaluationFormEntity evaluationFormEntity) {
|
||||||
|
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = new ApplicationEvaluationFormEntity();
|
||||||
|
applicationEvaluationFormEntity.setApplicationId(applicationEvaluationEntity.getApplicationId());
|
||||||
|
applicationEvaluationFormEntity.setEvaluationForm(evaluationFormEntity);
|
||||||
|
applicationEvaluationFormEntity.setApplicationEvaluation(applicationEvaluationEntity);
|
||||||
|
applicationEvaluationFormEntity.setIsDeleted(false);
|
||||||
|
return saveApplicationEvaluationFormEntity(applicationEvaluationFormEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateFormFields(ApplicationEvaluationFormRequestBean request, EvaluationFormEntity evaluationFormEntity) {
|
||||||
|
|
||||||
|
List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent();
|
||||||
|
|
||||||
|
List<ApplicationFormFieldRequestBean> requestFields = request.getFormFields();
|
||||||
|
|
||||||
|
Map<String, String> contentMap = contentResponseBeans.stream()
|
||||||
|
.collect(Collectors.toMap(ContentResponseBean::getId, ContentResponseBean::getLabel)); // Change getLabel() if needed
|
||||||
|
FieldValidator validator = FieldValidator.create();
|
||||||
|
for (ApplicationFormFieldRequestBean requestField : requestFields) {
|
||||||
|
String fieldId = requestField.getFieldId();
|
||||||
|
|
||||||
|
if (!contentMap.containsKey(fieldId)) {
|
||||||
|
validator.addError(MessageFormat.format(Translator.toLocale(GepafinConstant.FIELD_ID_NOT_FOUND), fieldId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
validator.validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationFormEntity saveApplicationEvaluationFormEntity(ApplicationEvaluationFormEntity applicationEvaluationFormEntity) {
|
||||||
|
return applicationEvaluationFormRepository.save(applicationEvaluationFormEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ApplicationEvaluationFormFieldEntity> createOrUpdateMultipleFormFields(List<ApplicationFormFieldRequestBean> formFieldRequestBeans,
|
||||||
|
ApplicationEvaluationFormEntity applicationEvaluationFormEntity, EvaluationFormEntity evaluationFormEntity) {
|
||||||
|
|
||||||
|
List<ApplicationEvaluationFormFieldEntity> existingFields = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
|
||||||
|
|
||||||
|
return formFieldRequestBeans.stream().map(requestBean -> createOrUpdateApplicationEvaluationFormField(requestBean, applicationEvaluationFormEntity, existingFields, evaluationFormEntity))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationFormFieldEntity createOrUpdateApplicationEvaluationFormField(ApplicationFormFieldRequestBean applicationFormFieldRequestBean,
|
||||||
|
ApplicationEvaluationFormEntity applicationEvaluationFormEntity,
|
||||||
|
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities,
|
||||||
|
EvaluationFormEntity evaluationFormEntity){
|
||||||
|
ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity = new ApplicationEvaluationFormFieldEntity();
|
||||||
|
validateFileUploadDocuments(applicationFormFieldRequestBean, evaluationFormEntity);
|
||||||
|
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||||
|
ApplicationEvaluationFormFieldEntity oldApplicationEvaluationFormFieldData = null;
|
||||||
|
if (applicationEvaluationFormFieldEntities == null || applicationEvaluationFormFieldEntities.isEmpty()) {
|
||||||
|
applicationEvaluationFormFieldEntity = new ApplicationEvaluationFormFieldEntity();
|
||||||
|
applicationEvaluationFormFieldEntity.setApplicationEvaluationForm(applicationEvaluationFormEntity);
|
||||||
|
applicationEvaluationFormFieldEntity.setIsDeleted(false);
|
||||||
|
}else{
|
||||||
|
for (ApplicationEvaluationFormFieldEntity existingFieldEntity : applicationEvaluationFormFieldEntities) {
|
||||||
|
if (existingFieldEntity.getFieldId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
||||||
|
applicationEvaluationFormFieldEntity = existingFieldEntity;
|
||||||
|
oldApplicationEvaluationFormFieldData = Utils.getClonedEntityForData(existingFieldEntity);
|
||||||
|
actionType = VersionActionTypeEnum.UPDATE;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
applicationEvaluationFormFieldEntity.setApplicationEvaluationForm(applicationEvaluationFormEntity);
|
||||||
|
applicationEvaluationFormFieldEntity.setIsDeleted(Boolean.FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Utils.setIfUpdated(applicationEvaluationFormFieldEntity::getFieldId, applicationEvaluationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
||||||
|
|
||||||
|
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
||||||
|
applicationEvaluationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
|
||||||
|
} else {
|
||||||
|
applicationEvaluationFormFieldEntity.setFieldValue(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationEvaluationFormFieldEntity savedEvaluationFormFieldEntity = applicationEvaluationFormFieldRepository.save(applicationEvaluationFormFieldEntity);
|
||||||
|
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationEvaluationFormFieldData).newData(savedEvaluationFormFieldEntity).build());
|
||||||
|
|
||||||
|
log.info("Version history logged for action: {}, Field ID: {}", actionType, applicationEvaluationFormFieldEntity.getFieldId());
|
||||||
|
|
||||||
|
return savedEvaluationFormFieldEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Long> validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, EvaluationFormEntity evaluationFormEntity) {
|
||||||
|
List<Long> documentIds=null;
|
||||||
|
|
||||||
|
List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent();
|
||||||
|
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
||||||
|
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) {
|
||||||
|
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
||||||
|
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
|
||||||
|
if (fieldValueObject instanceof String) {
|
||||||
|
// Safely cast the object to a string
|
||||||
|
String documentId = (String) fieldValueObject;
|
||||||
|
// Now you can use documentId as needed
|
||||||
|
documentIds = applicationDao.validateDocumentIds(documentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return documentIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<ApplicationEvaluationFormFieldReponseBean> createEvaluationFormFieldResponse(
|
||||||
|
List<ApplicationEvaluationFormFieldEntity> evaluationFormFieldEntities,
|
||||||
|
ApplicationEvaluationFormEntity applicationEvaluationFormEntity){
|
||||||
|
List<ApplicationEvaluationFormFieldReponseBean> evaluationFormFieldResponseBeans = new ArrayList<>();
|
||||||
|
List<ContentResponseBean> contentResponseBeans =evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(applicationEvaluationFormEntity.getEvaluationForm()).getContent();
|
||||||
|
|
||||||
|
for (ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity : evaluationFormFieldEntities) {
|
||||||
|
|
||||||
|
Optional<ContentResponseBean> fileUploadContent = contentResponseBeans.stream()
|
||||||
|
.filter(contentResponseBean -> "fileupload".equals(contentResponseBean.getName()) &&
|
||||||
|
contentResponseBean.getId().equals(applicationEvaluationFormFieldEntity.getFieldId()))
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
if (fileUploadContent.isPresent()) {
|
||||||
|
String documentId = applicationEvaluationFormFieldEntity.getFieldValue();
|
||||||
|
if (documentId != null && !documentId.isEmpty()) {
|
||||||
|
documentResponseBeans = Arrays.stream(documentId.split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.map(docId -> {
|
||||||
|
DocumentEntity documentEntity = documentService.validateDocument(docId);
|
||||||
|
// if (Boolean.FALSE.equals(DocumentSourceTypeEnum.APPLICATION.getValue().equals(documentEntity.getSource()))) {
|
||||||
|
// throw new CustomValidationException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||||
|
// }
|
||||||
|
return documentEntity;
|
||||||
|
})
|
||||||
|
.map(callDao::convertToDocumentResponseBean)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ApplicationEvaluationFormFieldReponseBean responseBean = convertToEvaluationFormFieldResponseBean(
|
||||||
|
applicationEvaluationFormFieldEntity, applicationEvaluationFormEntity.getId());
|
||||||
|
if (!documentResponseBeans.isEmpty()) {
|
||||||
|
responseBean.setFieldValue(documentResponseBeans);
|
||||||
|
}
|
||||||
|
evaluationFormFieldResponseBeans.add(responseBean);
|
||||||
|
}
|
||||||
|
return evaluationFormFieldResponseBeans;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationFormFieldReponseBean convertToEvaluationFormFieldResponseBean(ApplicationEvaluationFormFieldEntity entity,Long applicationEvaluationFormId){
|
||||||
|
ApplicationEvaluationFormFieldReponseBean applicationEvaluationFormFieldReponseBean = new ApplicationEvaluationFormFieldReponseBean();
|
||||||
|
applicationEvaluationFormFieldReponseBean.setApplicationEvaluationFormId(applicationEvaluationFormId);
|
||||||
|
applicationEvaluationFormFieldReponseBean.setFieldId(entity.getFieldId());
|
||||||
|
if(entity.getFieldValue() != null) {
|
||||||
|
applicationEvaluationFormFieldReponseBean.setFieldValue(Utils.getFieldValueAsObject(entity.getFieldValue()));
|
||||||
|
}
|
||||||
|
applicationEvaluationFormFieldReponseBean.setId(entity.getId());
|
||||||
|
applicationEvaluationFormFieldReponseBean.setCreatedDate(entity.getCreatedDate());
|
||||||
|
applicationEvaluationFormFieldReponseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
return applicationEvaluationFormFieldReponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationFormResponse convertToApplicationEvaluationResponseBean(ApplicationEvaluationResponse applicationEvaluationResponse){
|
||||||
|
ApplicationEvaluationFormResponse response = new ApplicationEvaluationFormResponse();
|
||||||
|
response.setId(applicationEvaluationResponse.getId());
|
||||||
|
response.setApplicationId(applicationEvaluationResponse.getApplicationId());
|
||||||
|
response.setNote(applicationEvaluationResponse.getNote());
|
||||||
|
response.setEvaluationVersion(applicationEvaluationResponse.getEvaluationVersion());
|
||||||
|
response.setCreatedDate(applicationEvaluationResponse.getCreatedDate());
|
||||||
|
response.setUpdatedDate(applicationEvaluationResponse.getUpdatedDate());
|
||||||
|
response.setApplicationStatus(applicationEvaluationResponse.getApplicationStatus());
|
||||||
|
response.setAssignedApplicationId(applicationEvaluationResponse.getAssignedApplicationId());
|
||||||
|
response.setMinScore(applicationEvaluationResponse.getMinScore());
|
||||||
|
response.setStatus(applicationEvaluationResponse.getStatus());
|
||||||
|
response.setFiles(applicationEvaluationResponse.getFiles());
|
||||||
|
response.setEvaluationDocument(applicationEvaluationResponse.getEvaluationDocument());
|
||||||
|
response.setAmendmentDetails(applicationEvaluationResponse.getAmendmentDetails());
|
||||||
|
response.setBeneficiary(applicationEvaluationResponse.getBeneficiary());
|
||||||
|
response.setAssignedUserId(applicationEvaluationResponse.getAssignedUserId());
|
||||||
|
response.setAssignedUserName(applicationEvaluationResponse.getAssignedUserName());
|
||||||
|
response.setProtocolNumber(applicationEvaluationResponse.getProtocolNumber());
|
||||||
|
response.setCallName(applicationEvaluationResponse.getCallName());
|
||||||
|
response.setMotivation(applicationEvaluationResponse.getMotivation());
|
||||||
|
response.setSubmissionDate(applicationEvaluationResponse.getSubmissionDate());
|
||||||
|
response.setEvaluationEndDate(applicationEvaluationResponse.getEvaluationEndDate());
|
||||||
|
response.setCallEndDate(applicationEvaluationResponse.getCallEndDate());
|
||||||
|
response.setCompanyName(applicationEvaluationResponse.getCompanyName());
|
||||||
|
response.setAssignedAt(applicationEvaluationResponse.getAssignedAt());
|
||||||
|
response.setNdg(applicationEvaluationResponse.getNdg());
|
||||||
|
response.setAppointmentId(applicationEvaluationResponse.getAppointmentId());
|
||||||
|
response.setAmountRequested(applicationEvaluationResponse.getAmountRequested());
|
||||||
|
response.setAmountAccepted(applicationEvaluationResponse.getAmountAccepted());
|
||||||
|
response.setDateAccepted(applicationEvaluationResponse.getDateAccepted());
|
||||||
|
response.setDateRejected(applicationEvaluationResponse.getDateRejected());
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId ){
|
||||||
|
|
||||||
|
if (applicationId == null && assignedApplicationId == null) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.EITHER_APPLICATION_ID_OR_ASSIGNED_APPLICATION_ID_MUST_BE_PROVIDED));
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationEvaluationEntity evaluationEntity = applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationId(applicationId, assignedApplicationId);
|
||||||
|
|
||||||
|
return (evaluationEntity != null) ? processEvaluationForm(evaluationEntity) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationFormResponse processEvaluationForm(ApplicationEvaluationEntity evaluationEntity){
|
||||||
|
|
||||||
|
Object convertedResponse = convertToResponse(evaluationEntity);
|
||||||
|
|
||||||
|
ApplicationEvaluationFormResponse response = objectMapper.convertValue(convertedResponse, ApplicationEvaluationFormResponse.class);
|
||||||
|
EvaluationFormEntity evaluationFormEntity = evaluationFormRepository.findByCallIdAndIsDeletedFalse(evaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId());
|
||||||
|
|
||||||
|
if (evaluationFormEntity != null) {
|
||||||
|
response.setApplicationEvaluationFormResponse(convertEvaluationFormToResponse(evaluationFormEntity, evaluationEntity));
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationFormResponseBean convertEvaluationFormToResponse(EvaluationFormEntity evaluationForm, ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||||
|
ApplicationEvaluationFormResponseBean applicationEvaluationFormResponseBean = createEvaluationFormResponse(evaluationForm);
|
||||||
|
|
||||||
|
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(), evaluationForm.getId());
|
||||||
|
|
||||||
|
if(applicationEvaluationFormEntity!=null) {
|
||||||
|
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
|
||||||
|
List<ApplicationEvaluationFormFieldReponseBean> evaluationFormFieldResponseBeans = createEvaluationFormFieldResponse(applicationEvaluationFormFieldEntities, applicationEvaluationFormEntity);
|
||||||
|
applicationEvaluationFormResponseBean.setFormFields(evaluationFormFieldResponseBeans);
|
||||||
|
}
|
||||||
|
|
||||||
|
return applicationEvaluationFormResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationFormResponseBean createEvaluationFormResponse(EvaluationFormEntity evaluationFormEntity) {
|
||||||
|
ApplicationEvaluationFormResponseBean evaluationFormResponseBean = new ApplicationEvaluationFormResponseBean();
|
||||||
|
evaluationFormResponseBean.setId(evaluationFormEntity.getId());
|
||||||
|
evaluationFormResponseBean.setLabel(evaluationFormEntity.getLabel());
|
||||||
|
evaluationFormResponseBean.setCallId(evaluationFormEntity.getCall().getId());
|
||||||
|
evaluationFormResponseBean.setContent(evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent());
|
||||||
|
return evaluationFormResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId){
|
||||||
|
|
||||||
|
log.info("Fetching application evaluation version with ID: {}", applicationId);
|
||||||
|
|
||||||
|
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||||
|
return buildApplicationEvaluationVersionResponse(applicationEntity);
|
||||||
|
|
||||||
|
}
|
||||||
|
private ApplicationEvaluationVersionResponse buildApplicationEvaluationVersionResponse(ApplicationEntity applicationEntity) {
|
||||||
|
ApplicationEvaluationVersionResponse response = new ApplicationEvaluationVersionResponse();
|
||||||
|
response.setApplicationId(applicationEntity.getId());
|
||||||
|
response.setCallId(applicationEntity.getCall().getId());
|
||||||
|
response.setCompanyId(applicationEntity.getCompanyId());
|
||||||
|
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(applicationEntity.getEvaluationVersion()));
|
||||||
|
response.setEvaluationId(applicationEntity.getApplicationEvaluationId());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ApplicationEvaluationRequest convertToApplicationEvaluationRequest(ApplicationEvaluationFormRequestBean formRequestBean) {
|
||||||
|
ApplicationEvaluationRequest request = new ApplicationEvaluationRequest();
|
||||||
|
request.setFiles(formRequestBean.getFiles());
|
||||||
|
request.setEvaluationDocument(formRequestBean.getEvaluationDocument());
|
||||||
|
request.setAmendmentDetails(formRequestBean.getAmendmentDetails());
|
||||||
|
request.setNote(formRequestBean.getNote());
|
||||||
|
request.setApplicationStatus(formRequestBean.getApplicationStatus());
|
||||||
|
request.setMotivation(formRequestBean.getMotivation());
|
||||||
|
request.setAmountAccepted(formRequestBean.getAmountAccepted());
|
||||||
|
|
||||||
|
request.setCriteria(null);
|
||||||
|
request.setChecklist(null);
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,13 @@ import jakarta.persistence.criteria.Predicate;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
import net.gepafin.tendermanagement.enums.*;
|
||||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
|
||||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
@@ -36,6 +31,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -119,6 +115,7 @@ public class AssignedApplicationsDao {
|
|||||||
setIfUpdated(assignedApplication::getAssignedBy, assignedApplication::setAssignedBy, assignedByUser.getId());
|
setIfUpdated(assignedApplication::getAssignedBy, assignedApplication::setAssignedBy, assignedByUser.getId());
|
||||||
setIfUpdated(assignedApplication::getUserId, assignedApplication::setUserId, userId);
|
setIfUpdated(assignedApplication::getUserId, assignedApplication::setUserId, userId);
|
||||||
assignedApplication.setAssignedAt(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
assignedApplication.setAssignedAt(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
assignedApplication.setStatus(AssignedApplicationEnum.AWAITING.getValue());
|
||||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplication.getId());
|
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplication.getId());
|
||||||
if(entityOptional.isPresent()) {
|
if(entityOptional.isPresent()) {
|
||||||
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(entityOptional.get());
|
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(entityOptional.get());
|
||||||
@@ -140,10 +137,7 @@ public class AssignedApplicationsDao {
|
|||||||
assignApplication.setApplication(application);
|
assignApplication.setApplication(application);
|
||||||
assignApplication.setAssignedBy(assignedByUser.getId());
|
assignApplication.setAssignedBy(assignedByUser.getId());
|
||||||
assignApplication.setUserId(userId);
|
assignApplication.setUserId(userId);
|
||||||
assignApplication.setStatus(AssignedApplicationEnum.OPEN.getValue());
|
assignApplication.setStatus(AssignedApplicationEnum.AWAITING.getValue());
|
||||||
if (assignedApplicationsRequest.getStatus() != null) {
|
|
||||||
assignApplication.setStatus(assignedApplicationsRequest.getStatus().getValue());
|
|
||||||
}
|
|
||||||
assignApplication.setNote(assignedApplicationsRequest.getNote());
|
assignApplication.setNote(assignedApplicationsRequest.getNote());
|
||||||
assignApplication.setIsDeleted(false);
|
assignApplication.setIsDeleted(false);
|
||||||
assignApplication.setAssignedAt(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
assignApplication.setAssignedAt(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
@@ -202,9 +196,12 @@ public class AssignedApplicationsDao {
|
|||||||
assignedApplicationsResponse.setSubmissionDate(submissionDate);
|
assignedApplicationsResponse.setSubmissionDate(submissionDate);
|
||||||
assignedApplicationsResponse.setCallEndDate(callEndDate);
|
assignedApplicationsResponse.setCallEndDate(callEndDate);
|
||||||
assignedApplicationsResponse.setCallStartDate(callStartDate);
|
assignedApplicationsResponse.setCallStartDate(callStartDate);
|
||||||
|
assignedApplicationsResponse.setEvaluationVersion(EvaluationVersionEnum.valueOf(application.getCall().getEvaluationVersion()));
|
||||||
if(applicationEvaluationEntity.isPresent()){
|
if(applicationEvaluationEntity.isPresent()){
|
||||||
assignedApplicationsResponse.setEvaluationEndDate(applicationEvaluationEntity.get().getEndDate());
|
assignedApplicationsResponse.setEvaluationEndDate(applicationEvaluationEntity.get().getEndDate());
|
||||||
}
|
}
|
||||||
|
assignedApplicationsResponse.setNumberOfCheck(application.getCall().getNumberOfCheck());
|
||||||
|
assignedApplicationsResponse.setProductId(application.getCall().getProductId());
|
||||||
return assignedApplicationsResponse;
|
return assignedApplicationsResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +221,7 @@ public class AssignedApplicationsDao {
|
|||||||
log.info("Assigned Application deleted with ID: {}", id);
|
log.info("Assigned Application deleted with ID: {}", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId) {
|
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId,List<AssignedApplicationEnum> statusList) {
|
||||||
UserEntity user = validator.validateUser(request);
|
UserEntity user = validator.validateUser(request);
|
||||||
if(validator.checkIsPreInstructor() && userId == null) {
|
if(validator.checkIsPreInstructor() && userId == null) {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
||||||
@@ -232,18 +229,24 @@ public class AssignedApplicationsDao {
|
|||||||
if(userId != null) {
|
if(userId != null) {
|
||||||
validator.validatePreInstructor(request, userId);
|
validator.validatePreInstructor(request, userId);
|
||||||
}
|
}
|
||||||
Specification<AssignedApplicationsEntity> spec = search(user.getHub().getId() ,userId);
|
Specification<AssignedApplicationsEntity> spec = search(user.getHub().getId() ,userId,statusList);
|
||||||
List<AssignedApplicationsEntity> assignedApplicationsEntityList = assignedApplicationsRepository.findAll(spec);
|
List<AssignedApplicationsEntity> assignedApplicationsEntityList = assignedApplicationsRepository.findAll(spec);
|
||||||
return assignedApplicationsEntityList.stream()
|
return assignedApplicationsEntityList.stream()
|
||||||
.map(entity -> convertEntityToResponse(entity))
|
.map(entity -> convertEntityToResponse(entity))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
private Specification<AssignedApplicationsEntity> search(Long hubId, Long userId) {
|
private Specification<AssignedApplicationsEntity> search(Long hubId, Long userId,List<AssignedApplicationEnum> statusList) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
||||||
}
|
}
|
||||||
|
if (statusList != null && !statusList.isEmpty()) {
|
||||||
|
List<String> statusNames = statusList.stream()
|
||||||
|
.map(Enum::name)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
predicate = builder.and(predicate, root.get("status").in(statusNames));
|
||||||
|
}
|
||||||
query.orderBy(
|
query.orderBy(
|
||||||
builder.desc(builder.isNotNull(root.get(GepafinConstant.ASSIGNED_AT))),
|
builder.desc(builder.isNotNull(root.get(GepafinConstant.ASSIGNED_AT))),
|
||||||
builder.desc(root.get(GepafinConstant.ASSIGNED_AT))
|
builder.desc(root.get(GepafinConstant.ASSIGNED_AT))
|
||||||
@@ -285,5 +288,14 @@ public class AssignedApplicationsDao {
|
|||||||
log.info("Assigned application fetched successfully: {}", response);
|
log.info("Assigned application fetched successfully: {}", response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
public AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status) {
|
||||||
|
|
||||||
|
AssignedApplicationsEntity assignedApplication = validateAssignedApplication(assignedApplicationId);
|
||||||
|
validator.validatePreInstructor(request, assignedApplication.getUserId());
|
||||||
|
|
||||||
|
AssignedApplicationsEntity oldAssignedApplicationEntity = Utils.getClonedEntityForData(assignedApplication);
|
||||||
|
assignedApplication.setStatus(status.getValue());
|
||||||
|
AssignedApplicationsEntity updatedAssignment = saveAssignedApplication(assignedApplication, oldAssignedApplicationEntity, VersionActionTypeEnum.UPDATE);
|
||||||
|
return convertEntityToResponse(updatedAssignment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,15 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import jakarta.persistence.criteria.Root;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.*;
|
||||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
|
||||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
|
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
import net.gepafin.tendermanagement.service.*;
|
import net.gepafin.tendermanagement.service.*;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
@@ -28,6 +29,9 @@ import net.gepafin.tendermanagement.util.Utils;
|
|||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import org.h2.util.IOUtils;
|
import org.h2.util.IOUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -35,15 +39,6 @@ import org.springframework.util.StringUtils;
|
|||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
|
||||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
|
||||||
import net.gepafin.tendermanagement.model.request.DocumentReq;
|
|
||||||
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaReq;
|
|
||||||
import net.gepafin.tendermanagement.model.request.FaqReq;
|
|
||||||
import net.gepafin.tendermanagement.model.request.LookUpDataReq;
|
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
|
||||||
import net.gepafin.tendermanagement.service.impl.CallValidatorServiceImpl;
|
import net.gepafin.tendermanagement.service.impl.CallValidatorServiceImpl;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
@@ -51,6 +46,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
|||||||
|
|
||||||
import static net.gepafin.tendermanagement.enums.RoleStatusEnum.ROLE_SUPER_ADMIN;
|
import static net.gepafin.tendermanagement.enums.RoleStatusEnum.ROLE_SUPER_ADMIN;
|
||||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -120,6 +116,9 @@ public class CallDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private NotificationTypeRepository notificationTypeRepository;
|
private NotificationTypeRepository notificationTypeRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationFormDao evalualtionFormDao;
|
||||||
|
|
||||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
||||||
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||||
CallEntity callEntity = convertToCallEntity(createCallRequest, userEntity);
|
CallEntity callEntity = convertToCallEntity(createCallRequest, userEntity);
|
||||||
@@ -182,6 +181,7 @@ public class CallDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
callEntity.setStatus(CallStatusEnum.DRAFT.getValue());
|
callEntity.setStatus(CallStatusEnum.DRAFT.getValue());
|
||||||
|
callEntity.setEvaluationVersion(createCallRequest.getEvaluationVersion().getValue());
|
||||||
callEntity.setAmountMax(createCallRequest.getAmountMax());
|
callEntity.setAmountMax(createCallRequest.getAmountMax());
|
||||||
callEntity.setAmount(createCallRequest.getAmount());
|
callEntity.setAmount(createCallRequest.getAmount());
|
||||||
callEntity.setConfidi(false);
|
callEntity.setConfidi(false);
|
||||||
@@ -201,6 +201,8 @@ public class CallDao {
|
|||||||
callEntity.setStartTime(DateTimeUtil.parseTime(createCallRequest.getStartTime()));
|
callEntity.setStartTime(DateTimeUtil.parseTime(createCallRequest.getStartTime()));
|
||||||
callEntity.setEndTime(DateTimeUtil.parseTime(createCallRequest.getEndTime()));
|
callEntity.setEndTime(DateTimeUtil.parseTime(createCallRequest.getEndTime()));
|
||||||
callEntity.setHub(userEntity.getHub());
|
callEntity.setHub(userEntity.getHub());
|
||||||
|
callEntity.setNumberOfCheck(createCallRequest.getNumberOfCheck());
|
||||||
|
callEntity.setProductId(createCallRequest.getProductId());
|
||||||
callEntity = callRepository.save(callEntity);
|
callEntity = callRepository.save(callEntity);
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "Create Call" operation. **/
|
/** This code is responsible for adding a version history log for the "Create Call" operation. **/
|
||||||
@@ -366,6 +368,7 @@ public class CallDao {
|
|||||||
createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||||
createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||||
createCallResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
createCallResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
||||||
|
createCallResponseBean.setEvaluationVersion(EvaluationVersionEnum.valueOf(callEntity.getEvaluationVersion()));
|
||||||
createCallResponseBean.setRegionId(callEntity.getRegion().getId());
|
createCallResponseBean.setRegionId(callEntity.getRegion().getId());
|
||||||
createCallResponseBean.setAmount(callEntity.getAmount());
|
createCallResponseBean.setAmount(callEntity.getAmount());
|
||||||
createCallResponseBean.setAmountMax(callEntity.getAmountMax());
|
createCallResponseBean.setAmountMax(callEntity.getAmountMax());
|
||||||
@@ -605,6 +608,9 @@ public class CallDao {
|
|||||||
setIfUpdated(callEntity::getStartTime, callEntity::setStartTime, DateTimeUtil.parseTime(updateCallRequest.getStartTime()));
|
setIfUpdated(callEntity::getStartTime, callEntity::setStartTime, DateTimeUtil.parseTime(updateCallRequest.getStartTime()));
|
||||||
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
||||||
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
|
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
|
||||||
|
setIfUpdated(callEntity::getEvaluationVersion, callEntity::setEvaluationVersion, updateCallRequest.getEvaluationVersion().getValue());
|
||||||
|
setIfUpdated(callEntity::getNumberOfCheck, callEntity::setNumberOfCheck, updateCallRequest.getNumberOfCheck());
|
||||||
|
setIfUpdated(callEntity::getProductId, callEntity::setProductId, updateCallRequest.getProductId());
|
||||||
callEntity = callRepository.save(callEntity);
|
callEntity = callRepository.save(callEntity);
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "update call step 1" operation **/
|
/** This code is responsible for adding a version history log for the "update call step 1" operation **/
|
||||||
@@ -695,6 +701,7 @@ public class CallDao {
|
|||||||
callDetailsResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
callDetailsResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||||
callDetailsResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
callDetailsResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||||
callDetailsResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
callDetailsResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
||||||
|
callDetailsResponseBean.setEvaluationVersion(EvaluationVersionEnum.valueOf(callEntity.getEvaluationVersion()));
|
||||||
callDetailsResponseBean.setRegionId(callEntity.getRegion().getId());
|
callDetailsResponseBean.setRegionId(callEntity.getRegion().getId());
|
||||||
callDetailsResponseBean.setAmount(callEntity.getAmount());
|
callDetailsResponseBean.setAmount(callEntity.getAmount());
|
||||||
callDetailsResponseBean.setAmountMax(callEntity.getAmountMax());
|
callDetailsResponseBean.setAmountMax(callEntity.getAmountMax());
|
||||||
@@ -710,7 +717,8 @@ public class CallDao {
|
|||||||
callDetailsResponseBean.setPhoneNumber(callEntity.getPhoneNumber());
|
callDetailsResponseBean.setPhoneNumber(callEntity.getPhoneNumber());
|
||||||
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
||||||
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
||||||
|
callDetailsResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
|
||||||
|
callDetailsResponseBean.setProductId(callEntity.getProductId());
|
||||||
return callDetailsResponseBean;
|
return callDetailsResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -734,6 +742,8 @@ public class CallDao {
|
|||||||
createCallResponseBean.setFaq(faqService.getFaqByCallId(callEntity.getId()));
|
createCallResponseBean.setFaq(faqService.getFaqByCallId(callEntity.getId()));
|
||||||
createCallResponseBean.setAimedTo(amiedTo);
|
createCallResponseBean.setAimedTo(amiedTo);
|
||||||
createCallResponseBean.setCheckList(checkList);
|
createCallResponseBean.setCheckList(checkList);
|
||||||
|
createCallResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
|
||||||
|
createCallResponseBean.setProductId(callEntity.getProductId());
|
||||||
return createCallResponseBean;
|
return createCallResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,7 +825,8 @@ public class CallDao {
|
|||||||
CallResponse callResponseBean = getCallResponseBean(callEntity);
|
CallResponse callResponseBean = getCallResponseBean(callEntity);
|
||||||
FlowResponseBean flowResponseBean = flowDao.getFlowByCallId(callEntity.getId());
|
FlowResponseBean flowResponseBean = flowDao.getFlowByCallId(callEntity.getId());
|
||||||
List<FormResponseBean> formResponseBean = formDao.getFormsByCallId(callEntity);
|
List<FormResponseBean> formResponseBean = formDao.getFormsByCallId(callEntity);
|
||||||
CallValidatorServiceImpl.validateResponse(callResponseBean,flowResponseBean,formResponseBean);
|
EvaluationFormResponseBean evaluationFormResponseBean = evalualtionFormDao.getEvaluationFormByCallId(callEntity);
|
||||||
|
CallValidatorServiceImpl.validateResponse(callResponseBean,flowResponseBean,formResponseBean,evaluationFormResponseBean);
|
||||||
callEntity.setStatus(CallStatusEnum.READY_TO_PUBLISH.getValue());
|
callEntity.setStatus(CallStatusEnum.READY_TO_PUBLISH.getValue());
|
||||||
callEntity = callRepository.save(callEntity);
|
callEntity = callRepository.save(callEntity);
|
||||||
|
|
||||||
@@ -917,4 +928,165 @@ public class CallDao {
|
|||||||
return callEntity;
|
return callEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,UserEntity user,Long companyId , Boolean onlyPreferredCall, CallPageableRequestBean callPageableRequestBean) {
|
||||||
|
Integer pageNo = null;
|
||||||
|
Integer pageLimit = null;
|
||||||
|
if (callPageableRequestBean.getGlobalFilters() != null) {
|
||||||
|
pageNo = callPageableRequestBean.getGlobalFilters().getPage();
|
||||||
|
pageLimit = callPageableRequestBean.getGlobalFilters().getLimit();
|
||||||
|
}
|
||||||
|
if (pageLimit == null || pageLimit <= 0) {
|
||||||
|
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||||
|
}
|
||||||
|
if (pageNo == null || pageNo <= 0) {
|
||||||
|
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||||
|
}
|
||||||
|
if (Boolean.TRUE.equals(onlyPreferredCall) && companyId == null) {
|
||||||
|
throw new CustomValidationException(
|
||||||
|
Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Specification<CallEntity> spec = search(user, callPageableRequestBean);
|
||||||
|
Page<CallEntity> entityPage;
|
||||||
|
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||||
|
validator.validateUserWithCompany(request, companyId);
|
||||||
|
UserWithCompanyEntity userWithCompanyEntity = companyService.getUserWithCompany(user.getId(), companyId);
|
||||||
|
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository
|
||||||
|
.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), userWithCompanyEntity.getId());
|
||||||
|
List<Long> preferredCallIds = preferredCalls.stream()
|
||||||
|
.map(BeneficiaryPreferredCallEntity::getCallId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// Add preferredCallIds filtering to the specification
|
||||||
|
spec = spec.and((root, query, criteriaBuilder) ->
|
||||||
|
root.get(GepafinConstant.ID).in(preferredCallIds)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
entityPage = callRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||||
|
List<Long> callIds=new ArrayList<>();
|
||||||
|
if(entityPage!=null && entityPage.getContent()!=null && Boolean.FALSE.equals(entityPage.getContent().isEmpty())) {
|
||||||
|
callIds = entityPage.getContent().stream().map(CallEntity::getId).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap =
|
||||||
|
getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId);
|
||||||
|
|
||||||
|
List<CallDetailsResponseBean> callDetailsResponseBeans = entityPage.getContent().stream()
|
||||||
|
.map(callEntity -> {
|
||||||
|
CallDetailsResponseBean responseBean = convertToCallDetailsResponseBean(callEntity);
|
||||||
|
String key = user.getId() + "_" + callEntity.getId();
|
||||||
|
BeneficiaryPreferredCallEntity preferredCall = preferredCallsMap.get(key);
|
||||||
|
Long preferredId = preferredCall != null ? preferredCall.getId() : null;
|
||||||
|
responseBean.setPreferredCallId(preferredId);
|
||||||
|
|
||||||
|
return responseBean;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
PageableResponseBean<List<CallDetailsResponseBean>> pageableResponseBean = new PageableResponseBean<>();
|
||||||
|
pageableResponseBean.setBody(callDetailsResponseBeans);
|
||||||
|
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||||
|
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||||
|
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||||
|
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||||
|
|
||||||
|
return pageableResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Specification<CallEntity> search(UserEntity userEntity, CallPageableRequestBean callPageableRequestBean) {
|
||||||
|
return (root, query, criteriaBuilder) -> {
|
||||||
|
|
||||||
|
List<Predicate> predicates = getPredicates(callPageableRequestBean, criteriaBuilder, root, userEntity);
|
||||||
|
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||||
|
|
||||||
|
if (callPageableRequestBean.getGlobalFilters() != null
|
||||||
|
&& callPageableRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||||
|
callPageableRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||||
|
isEmpty(callPageableRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||||
|
sortBy.setColumnName(callPageableRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||||
|
sortBy.setSortDesc(true);
|
||||||
|
if (callPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||||
|
sortBy.setSortDesc(callPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||||
|
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||||
|
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||||
|
}
|
||||||
|
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<Predicate> getPredicates(CallPageableRequestBean callPageableRequestBean,
|
||||||
|
CriteriaBuilder criteriaBuilder, Root<CallEntity> root, UserEntity userEntity) {
|
||||||
|
|
||||||
|
Integer year = null;
|
||||||
|
String search = null;
|
||||||
|
if (callPageableRequestBean.getGlobalFilters() != null) {
|
||||||
|
year = callPageableRequestBean.getGlobalFilters().getYear();
|
||||||
|
search = callPageableRequestBean.getGlobalFilters().getSearch();
|
||||||
|
}
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (year != null && year > 0) {
|
||||||
|
int filterYear = callPageableRequestBean.getGlobalFilters().getYear();
|
||||||
|
|
||||||
|
// Create LocalDateTime boundaries for the start and end of the year
|
||||||
|
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||||
|
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||||
|
|
||||||
|
// Add the range comparison to filter records within the year
|
||||||
|
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||||
|
|
||||||
|
}
|
||||||
|
// Search in `title` and `message` (if search term is provided)
|
||||||
|
if (search != null && !search.isEmpty()) {
|
||||||
|
Predicate descriptionShort = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.DESCRIPTION_SHORT)),
|
||||||
|
"%" + search.toUpperCase() + "%"
|
||||||
|
);
|
||||||
|
predicates.add(criteriaBuilder.or(descriptionShort));
|
||||||
|
|
||||||
|
Predicate descriptionLong = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.DESCRIPTION_LONG)),
|
||||||
|
"%" + search.toUpperCase() + "%"
|
||||||
|
);
|
||||||
|
predicates.add(criteriaBuilder.or(descriptionLong));
|
||||||
|
|
||||||
|
Predicate name = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.NAME)),
|
||||||
|
"%" + search.toUpperCase() + "%"
|
||||||
|
);
|
||||||
|
predicates.add(criteriaBuilder.or(name));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by `status` (if status list is provided)
|
||||||
|
if (callPageableRequestBean.getStatus() != null && !callPageableRequestBean.getStatus().isEmpty()) {
|
||||||
|
List<String> statusValues = callPageableRequestBean.getStatus().stream()
|
||||||
|
.map(CallStatusEnum::name) // Convert enum to string
|
||||||
|
.toList();
|
||||||
|
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||||
|
}
|
||||||
|
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB).get(GepafinConstant.ID), userEntity.getHub().getId()));
|
||||||
|
|
||||||
|
|
||||||
|
return predicates;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CallResponse createCallStep2EvaluationV2(CallEntity callEntity, CreateCallRequestStep2EvaluationV2 createCallRequest, UserEntity user) {
|
||||||
|
|
||||||
|
convertToDocumentEntities(createCallRequest.getDocs(), callEntity.getId(), DocumentTypeEnum.DOCUMENT);
|
||||||
|
|
||||||
|
convertToDocumentEntities(createCallRequest.getImages(), callEntity.getId(), DocumentTypeEnum.IMAGES);
|
||||||
|
|
||||||
|
CallResponse createCallResponseBean = getCallResponseBean(callEntity);
|
||||||
|
createCallResponseBean.setCurrentStep(GepafinConstant.EVALUATION_V2_STEP_2);
|
||||||
|
return createCallResponseBean;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,33 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.*;
|
||||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationWidgetResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.Widget1;
|
|
||||||
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
import net.gepafin.tendermanagement.service.CompanyService;
|
import net.gepafin.tendermanagement.service.CompanyService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -57,12 +55,17 @@ public class DashboardDao {
|
|||||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserActionsRepository userActionsRepository;
|
private ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
public SuperAdminWidgetResponseBean getDashboardWidget(UserEntity requestedUserEntity) {
|
public SuperAdminWidgetResponseBean getDashboardWidget(UserEntity requestedUserEntity) {
|
||||||
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
||||||
widgetResponseBean.setWidget1(createWidget1(requestedUserEntity));
|
widgetResponseBean.setWidget1(createWidget1(requestedUserEntity));
|
||||||
Map<String, Object> widgetBars =getStatistics(requestedUserEntity);
|
Map<String, Object> widgetBars = getStatistics(requestedUserEntity);
|
||||||
widgetResponseBean.setWidgetBars(widgetBars);
|
widgetResponseBean.setWidgetBars(widgetBars);
|
||||||
return widgetResponseBean;
|
return widgetResponseBean;
|
||||||
}
|
}
|
||||||
@@ -76,8 +79,8 @@ public class DashboardDao {
|
|||||||
setSubmittedApplications(widget1, requestedUserEntity);
|
setSubmittedApplications(widget1, requestedUserEntity);
|
||||||
setDraftApplications(widget1, requestedUserEntity);
|
setDraftApplications(widget1, requestedUserEntity);
|
||||||
setNumberOfCompanies(widget1, requestedUserEntity);
|
setNumberOfCompanies(widget1, requestedUserEntity);
|
||||||
setAmountRequested(widget1,requestedUserEntity);
|
setAmountRequested(widget1, requestedUserEntity);
|
||||||
setAmountAccepted(widget1,requestedUserEntity);
|
setAmountAccepted(widget1, requestedUserEntity);
|
||||||
return widget1;
|
return widget1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +182,8 @@ public class DashboardDao {
|
|||||||
stats.put(GepafinConstant.APPLICATION_PER_CALL, applicationsPerCall.stream().map(result -> {
|
stats.put(GepafinConstant.APPLICATION_PER_CALL, applicationsPerCall.stream().map(result -> {
|
||||||
Map<String, Object> callData = new HashMap<>();
|
Map<String, Object> callData = new HashMap<>();
|
||||||
callData.put(GepafinConstant.CALL_NAME, result[0]); // Call name
|
callData.put(GepafinConstant.CALL_NAME, result[0]); // Call name
|
||||||
callData.put(GepafinConstant.NUMBER_OF_APPLICATIONS, result[1]); // Application count
|
callData.put(GepafinConstant.NUMBER_OF_APPLICATIONS, result[1]);// Application count
|
||||||
|
callData.put(GepafinConstant.NUMBER_OF_DRAFT_APPLICATIONS, result[2]);// Application count
|
||||||
return callData;
|
return callData;
|
||||||
}).toList());
|
}).toList());
|
||||||
|
|
||||||
@@ -194,7 +198,8 @@ public class DashboardDao {
|
|||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
// public Page<UserActionEntity> getUserAction(UserEntity requestedUserEntity){
|
|
||||||
|
// public Page<UserActionEntity> getUserAction(UserEntity requestedUserEntity){
|
||||||
// Pageable pageable = PageRequest.of(0, 20); // Get the first 20 records
|
// Pageable pageable = PageRequest.of(0, 20); // Get the first 20 records
|
||||||
// List<String> roles=List.of(RoleStatusEnum.ROLE_PRE_INSTRUCTOR.getValue(),RoleStatusEnum.ROLE_GEPAFIN_OPERATOR.getValue(),RoleStatusEnum.ROLE_INSTRUCTOR_MANAGER.getValue());
|
// List<String> roles=List.of(RoleStatusEnum.ROLE_PRE_INSTRUCTOR.getValue(),RoleStatusEnum.ROLE_GEPAFIN_OPERATOR.getValue(),RoleStatusEnum.ROLE_INSTRUCTOR_MANAGER.getValue());
|
||||||
// Page<UserActionEntity> userActionEntities=userActionsRepository.findActionsByRoleNamesAndHubId(roles,requestedUserEntity.getHub().getId(),pageable);
|
// Page<UserActionEntity> userActionEntities=userActionsRepository.findActionsByRoleNamesAndHubId(roles,requestedUserEntity.getHub().getId(),pageable);
|
||||||
@@ -249,14 +254,15 @@ public class DashboardDao {
|
|||||||
|
|
||||||
if (Boolean.FALSE.equals(applicationIds.isEmpty())) {
|
if (Boolean.FALSE.equals(applicationIds.isEmpty())) {
|
||||||
BigDecimal averageTime = applicationEvaluationRepository.findAverageEvaluationTimeByApplicationIds(applicationIds);
|
BigDecimal averageTime = applicationEvaluationRepository.findAverageEvaluationTimeByApplicationIds(applicationIds);
|
||||||
responseBean.setEvaluationAverageTime(averageTime != null ? averageTime : BigDecimal.ZERO);
|
responseBean.setEvaluationAverageTime(averageTime != null ? averageTime.setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
LocalDate twoDaysLater = LocalDate.now().plusDays(2);
|
LocalDate twoDaysLater = LocalDate.now().plusDays(2);
|
||||||
|
List<String> statusList = Arrays.asList(ApplicationEvaluationStatusTypeEnum.OPEN.getValue(), ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||||
Long dueApplications = applicationEvaluationRepository.countDueApplicationsBetween(
|
Long dueApplications = applicationEvaluationRepository.countDueApplicationsBetween(
|
||||||
applicationIds,
|
applicationIds,
|
||||||
LocalDate.now(),
|
LocalDate.now(),
|
||||||
twoDaysLater
|
twoDaysLater,
|
||||||
|
statusList
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dueApplications != null) {
|
if (dueApplications != null) {
|
||||||
@@ -264,5 +270,351 @@ public class DashboardDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AmendmentWidgetResponseBean initializeAmendmentResponseBean() {
|
||||||
|
return AmendmentWidgetResponseBean.builder()
|
||||||
|
.totalAmendments(0L)
|
||||||
|
.waitingForResponseAmendments(0L)
|
||||||
|
.responseReceivedAmendments(0L)
|
||||||
|
.averageResponseDays(BigDecimal.ZERO)
|
||||||
|
.expiringRequestsIn48Hours(0L)
|
||||||
|
.expiredAmendments(0L)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmendmentWidgetResponseBean getAmendmentDetails(UserEntity userEntity) {
|
||||||
|
AmendmentWidgetResponseBean amendmentWidgetResponseBean = initializeAmendmentResponseBean();
|
||||||
|
|
||||||
|
Long hubId = userEntity.getHub().getId();
|
||||||
|
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity, hubId, null);
|
||||||
|
setAmendmentCounts(applicationIds, amendmentWidgetResponseBean, hubId);
|
||||||
|
calculateExpiringRequestsIn48Hours(applicationIds, amendmentWidgetResponseBean, hubId);
|
||||||
|
calculateAverageResponseDays(applicationIds, amendmentWidgetResponseBean, hubId);
|
||||||
|
return amendmentWidgetResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Long> getApplicationIdsForUserOrHub(UserEntity userEntity, Long hubId, Long userId) {
|
||||||
|
if (userId != null) {
|
||||||
|
return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userId);
|
||||||
|
} else if (validator.checkIsPreInstructor()) {
|
||||||
|
return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userEntity.getId());
|
||||||
|
} else {
|
||||||
|
return applicationRepository.findApplicationIdsByHubId(hubId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAmendmentCounts(List<Long> applicationIds, AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||||
|
|
||||||
|
Long totalAmendment = applicationAmendmentRequestRepository.countAmendmentsByApplicationIds(applicationIds);
|
||||||
|
if (totalAmendment != null) {
|
||||||
|
responseBean.setTotalAmendments(totalAmendment);
|
||||||
|
}
|
||||||
|
|
||||||
|
Long awaitingAmendments = applicationAmendmentRequestRepository.countAmendmentsByApplicationIdsAndStatus(
|
||||||
|
applicationIds, ApplicationAmendmentRequestEnum.AWAITING.getValue());
|
||||||
|
if (awaitingAmendments != null) {
|
||||||
|
responseBean.setWaitingForResponseAmendments(awaitingAmendments);
|
||||||
|
}
|
||||||
|
Long responseRecievedAmendments = applicationAmendmentRequestRepository.countAmendmentsByApplicationIdsAndStatus(
|
||||||
|
applicationIds, ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
||||||
|
if (responseRecievedAmendments != null) {
|
||||||
|
responseBean.setResponseReceivedAmendments(responseRecievedAmendments);
|
||||||
|
}
|
||||||
|
Long expiredAmendments = applicationAmendmentRequestRepository.countAmendmentsByApplicationIdsAndStatus(
|
||||||
|
applicationIds, ApplicationAmendmentRequestEnum.EXPIRED.getValue());
|
||||||
|
if (expiredAmendments != null) {
|
||||||
|
responseBean.setExpiredAmendments(expiredAmendments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateExpiringRequestsIn48Hours(List<Long> applicationIds, AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||||
|
|
||||||
|
// Define the statuses to filter
|
||||||
|
List<String> statuses = List.of(
|
||||||
|
ApplicationAmendmentRequestEnum.AWAITING.getValue(),
|
||||||
|
ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue()
|
||||||
|
);
|
||||||
|
|
||||||
|
LocalDateTime twoDaysLater = LocalDateTime.now().plusDays(2);
|
||||||
|
|
||||||
|
Long expiringRequestsIn48Hours = applicationAmendmentRequestRepository.countExpiringRequestsIn48Hours(
|
||||||
|
applicationIds,
|
||||||
|
statuses,
|
||||||
|
LocalDateTime.now(),
|
||||||
|
twoDaysLater
|
||||||
|
);
|
||||||
|
|
||||||
|
if (expiringRequestsIn48Hours != null) {
|
||||||
|
responseBean.setExpiringRequestsIn48Hours(expiringRequestsIn48Hours);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateAverageResponseDays(List<Long> applicationIds, AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||||
|
|
||||||
|
if (!applicationIds.isEmpty()) {
|
||||||
|
BigDecimal averageResponseDays = applicationAmendmentRequestRepository
|
||||||
|
.findAverageResponseDaysByApplicationIdsAndStatus(
|
||||||
|
applicationIds,
|
||||||
|
ApplicationAmendmentRequestEnum.CLOSE.getValue()
|
||||||
|
);
|
||||||
|
|
||||||
|
responseBean.setAverageResponseDays(averageResponseDays);
|
||||||
|
} else {
|
||||||
|
responseBean.setAverageResponseDays(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(UserEntity userEntity) {
|
||||||
|
Long userId = userEntity.getId();
|
||||||
|
Long hubId = userEntity.getHub().getId();
|
||||||
|
|
||||||
|
Object[] results;
|
||||||
|
List<Long> applicationIds;
|
||||||
|
if (validator.checkIsPreInstructor()) {
|
||||||
|
results = assignedApplicationsRepository.countAssignedApplicationsWithStatus(userId, hubId);
|
||||||
|
applicationIds = assignedApplicationsRepository.findApplicationIdsByUserIdAndHubIdAndIsDeletedFalse(userId, hubId);
|
||||||
|
} else {
|
||||||
|
results = assignedApplicationsRepository.countAssignedApplicationsForHub(hubId);
|
||||||
|
applicationIds = assignedApplicationsRepository.findApplicationIdsByHubId(hubId);
|
||||||
|
}
|
||||||
|
AssignedApplicationWidgetResponseBean response = convertToResponse(results);
|
||||||
|
calculateEvaluationAvgTimeForAssignedApplication(response, applicationIds);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateEvaluationAvgTimeForAssignedApplication(AssignedApplicationWidgetResponseBean response, List<Long> applicationIds) {
|
||||||
|
if (applicationIds == null || applicationIds.isEmpty()) {
|
||||||
|
response.setAverageEvaluationDays(BigDecimal.ZERO);
|
||||||
|
response.setNumberOfApplicationExpiringIn48Hours(0L);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal averageTime = applicationEvaluationRepository.findAverageEvaluationTimeByApplicationIds(applicationIds);
|
||||||
|
response.setAverageEvaluationDays(averageTime != null ? averageTime.setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO);
|
||||||
|
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
LocalDate twoDaysLater = today.plusDays(2);
|
||||||
|
List<String> statusList = Arrays.asList(ApplicationEvaluationStatusTypeEnum.OPEN.getValue(), ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||||
|
Long dueApplications = applicationEvaluationRepository.countDueApplicationsBetween(
|
||||||
|
applicationIds, today, twoDaysLater, statusList
|
||||||
|
);
|
||||||
|
response.setNumberOfApplicationExpiringIn48Hours(dueApplications != null ? dueApplications : 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AssignedApplicationWidgetResponseBean convertToResponse(Object[] results) {
|
||||||
|
AssignedApplicationWidgetResponseBean response = new AssignedApplicationWidgetResponseBean();
|
||||||
|
|
||||||
|
Object[] data = (Object[]) results[0];
|
||||||
|
|
||||||
|
response.setNumberOfAssignedApplication(data[0] instanceof Number ? ((Number) data[0]).longValue() : 0L);
|
||||||
|
response.setNumberOfApplicationInAmendmentState(data[1] instanceof Number ? ((Number) data[1]).longValue() : 0L);
|
||||||
|
response.setNumberOfApplicationInOpenState(data[2] instanceof Number ? ((Number) data[2]).longValue() : 0L);
|
||||||
|
response.setNumberOfApplicationInCloseState(data[3] instanceof Number ? ((Number) data[3]).longValue() : 0L);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getStatusList() {
|
||||||
|
return List.of(
|
||||||
|
ApplicationStatusTypeEnum.SUBMIT.getValue(),
|
||||||
|
ApplicationStatusTypeEnum.EVALUATION.getValue(),
|
||||||
|
ApplicationStatusTypeEnum.APPROVED.getValue(),
|
||||||
|
ApplicationStatusTypeEnum.REJECTED.getValue(),
|
||||||
|
ApplicationStatusTypeEnum.SOCCORSO.getValue(),
|
||||||
|
ApplicationStatusTypeEnum.APPOINTMENT.getValue(),
|
||||||
|
ApplicationStatusTypeEnum.NDG.getValue(),
|
||||||
|
ApplicationStatusTypeEnum.ADMISSIBLE.getValue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BeneficiaryStatisticsResponseBean getStatisticsPageForBeneficiary(UserEntity userEntity, CompanyEntity company) {
|
||||||
|
BeneficiaryStatisticsResponseBean widgetResponseBean = initializeBeneficiaryStatisticsBean();
|
||||||
|
UserWithCompanyEntity userWithCompanyEntity = companyService.getUserWithCompany(userEntity.getId(), company.getId());
|
||||||
|
Long hubId = userEntity.getHub().getId();
|
||||||
|
List<String> statusList = getStatusList();
|
||||||
|
Long submittedApplication = applicationRepository.countSubmittedApplicationsByHubIdAndUserId(hubId, userEntity.getId(), userWithCompanyEntity.getId(), statusList);
|
||||||
|
Long approvedApplication = getApplicationCountByStatus(hubId, userEntity.getId(), userWithCompanyEntity.getId(), ApplicationStatusTypeEnum.APPROVED);
|
||||||
|
BigDecimal successRate = getSuccessRate(hubId, userEntity.getId(), userWithCompanyEntity.getId());
|
||||||
|
BigDecimal totalAmountRequested = applicationRepository.sumAmountRequestedByHubIdAndUserId(hubId, userEntity.getId(), userWithCompanyEntity.getId());
|
||||||
|
|
||||||
|
updateApplicationWidget(widgetResponseBean.getApplicationWidget(), submittedApplication, approvedApplication, successRate, totalAmountRequested);
|
||||||
|
|
||||||
|
Map<String, Object> widgetBars = getApplicationStatistics(userEntity, userWithCompanyEntity.getId());
|
||||||
|
widgetResponseBean.setApplicationWidgetBars(widgetBars);
|
||||||
|
return widgetResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BeneficiaryStatisticsResponseBean initializeBeneficiaryStatisticsBean() {
|
||||||
|
return BeneficiaryStatisticsResponseBean.builder()
|
||||||
|
.applicationWidget(ApplicationWidget.builder()
|
||||||
|
.submittedApplication(0L)
|
||||||
|
.approvedApplication(0L)
|
||||||
|
.successRate(BigDecimal.ZERO)
|
||||||
|
.totalAmountFinanced(BigDecimal.ZERO)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long getApplicationCountByStatus(Long hubId, Long userId, Long userWithCompanyId, ApplicationStatusTypeEnum status) {
|
||||||
|
return applicationRepository.countSubmittedApplicationsByHubIdAndUserIdAndStatus(hubId, userId, userWithCompanyId, status.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal getSuccessRate(Long hubId, Long userId, Long userWithCompanyId) {
|
||||||
|
return applicationRepository.findSuccessRateByHubIdAndUserIdAndUserWithCompanyId(hubId, userId, userWithCompanyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateApplicationWidget(ApplicationWidget applicationWidget, Long submittedApplication, Long approvedApplication, BigDecimal successRate, BigDecimal totalAmountRequested) {
|
||||||
|
applicationWidget.setSubmittedApplication(submittedApplication != null ? submittedApplication : 0L);
|
||||||
|
applicationWidget.setApprovedApplication(approvedApplication != null ? approvedApplication : 0L);
|
||||||
|
applicationWidget.setSuccessRate(successRate != null ? successRate : BigDecimal.ZERO);
|
||||||
|
applicationWidget.setTotalAmountFinanced(totalAmountRequested != null ? totalAmountRequested : BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getApplicationStatistics(UserEntity requestedUser, Long userWithCompanyId) {
|
||||||
|
Map<String, Object> stats = new HashMap<>();
|
||||||
|
|
||||||
|
Map<String, Long> statusData = new HashMap<>();
|
||||||
|
for (ApplicationStatusTypeEnum status : ApplicationStatusTypeEnum.values()) {
|
||||||
|
statusData.put(status.name(), 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get applications per status
|
||||||
|
List<Object[]> applicationsByStatus = applicationRepository.findApplicationsByStatusAndUserIdAndUserWithCompanyId(
|
||||||
|
requestedUser.getHub().getId(),
|
||||||
|
requestedUser.getId(),
|
||||||
|
userWithCompanyId
|
||||||
|
);
|
||||||
|
|
||||||
|
applicationsByStatus.forEach(result -> {
|
||||||
|
String status = (String) result[0];
|
||||||
|
Long count = (Long) result[1];
|
||||||
|
statusData.put(status, count);
|
||||||
|
});
|
||||||
|
|
||||||
|
List<Map<String, Object>> statusList = statusData.entrySet().stream().map(entry -> {
|
||||||
|
Map<String, Object> statusMap = new HashMap<>();
|
||||||
|
statusMap.put(GepafinConstant.STATUS, entry.getKey());
|
||||||
|
statusMap.put(GepafinConstant.NUMBER_OF_APPLICATION, entry.getValue());
|
||||||
|
return statusMap;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
stats.put(GepafinConstant.APPLICATION_PER_STATUS, statusList);
|
||||||
|
|
||||||
|
|
||||||
|
// Requested VS Approved Amounts
|
||||||
|
List<Object[]> requestedVsApprovedAmounts = applicationRepository.findRequestedVsApprovedAmountsPerMonth(
|
||||||
|
requestedUser.getHub().getId(),
|
||||||
|
requestedUser.getId(),
|
||||||
|
userWithCompanyId
|
||||||
|
);
|
||||||
|
|
||||||
|
stats.put(GepafinConstant.REQUESTED_VS_APPROVED_AMOUNTS, requestedVsApprovedAmounts.stream().map(result -> {
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put(GepafinConstant.MONTH, result[0]);
|
||||||
|
data.put(GepafinConstant.TOTAL_REQUESTED, result[1]!= null ? result[1] : 0L);
|
||||||
|
data.put(GepafinConstant.TOTAL_APPROVED, result[2] != null ? result[2] : 0L);
|
||||||
|
return data;
|
||||||
|
}).toList());
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
private PreInstructorWidgetResponseBean initializeDashboardPreInstructorResponseBean() {
|
||||||
|
return PreInstructorWidgetResponseBean.builder()
|
||||||
|
.assignedApplication(ApplicationToConsider.builder()
|
||||||
|
.totalAssignedApplication(0L)
|
||||||
|
.additionalApplicationPercentage(BigDecimal.ZERO)
|
||||||
|
.build())
|
||||||
|
.evaluatedApplication(EvaluatedApplication.builder()
|
||||||
|
.evaluatedApplication(0L)
|
||||||
|
.dailyAverage(BigDecimal.ZERO)
|
||||||
|
.build())
|
||||||
|
.averageEvaluationDays(AverageEvaluationTime.builder()
|
||||||
|
.averageEvlauationDaysRating(BigDecimal.ZERO)
|
||||||
|
.timeDifferenceFromAverage(BigDecimal.ZERO)
|
||||||
|
.build())
|
||||||
|
.amendmentInProgress(RescueInstructorInProgress.builder()
|
||||||
|
.totalAmendmentInProgress(0L)
|
||||||
|
.expiringToday(0L)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(HttpServletRequest request, Long userId) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
if (validator.checkIsPreInstructor() && userId == null) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
||||||
|
}
|
||||||
|
if (userId != null) {
|
||||||
|
validator.validatePreInstructor(request, userId);
|
||||||
|
if (validator.checkIsInstructorManager() && !userEntity.getId().equals(userId)) {
|
||||||
|
throw new ForbiddenAccessException(Status.FORBIDDEN,
|
||||||
|
Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PreInstructorWidgetResponseBean preInstructorWidgetResponseBean = initializeDashboardPreInstructorResponseBean();
|
||||||
|
Long hubId = userEntity.getHub().getId();
|
||||||
|
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity, hubId,userId);
|
||||||
|
setPreInstructorWidgets(applicationIds, preInstructorWidgetResponseBean,hubId);
|
||||||
|
calculateAverageEvaluationTime(applicationIds, preInstructorWidgetResponseBean, hubId);
|
||||||
|
return preInstructorWidgetResponseBean;
|
||||||
|
}
|
||||||
|
private void setPreInstructorWidgets(List<Long> applicationIds, PreInstructorWidgetResponseBean responseBean,Long hubId) {
|
||||||
|
List<String> assignedApplicationStatus = Arrays.asList(AssignedApplicationEnum.AWAITING.getValue(), AssignedApplicationEnum.OPEN.getValue());
|
||||||
|
Long totalAssignedApplications = assignedApplicationsRepository.countAssignedApplicationsByApplicationIds(applicationIds,assignedApplicationStatus);
|
||||||
|
if (totalAssignedApplications != null) {
|
||||||
|
responseBean.getAssignedApplication().setTotalAssignedApplication(totalAssignedApplications);
|
||||||
|
}
|
||||||
|
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
||||||
|
|
||||||
|
Long newApplicationsAddedYesterday = assignedApplicationsRepository.countApplicationsAddedYesterdayForHub(applicationIds, hubId, yesterday,assignedApplicationStatus);
|
||||||
|
if (newApplicationsAddedYesterday != null && totalAssignedApplications != null && totalAssignedApplications > 0) {
|
||||||
|
BigDecimal percentageAdded = BigDecimal.valueOf(newApplicationsAddedYesterday)
|
||||||
|
.divide(BigDecimal.valueOf(totalAssignedApplications), 4, RoundingMode.HALF_UP)
|
||||||
|
.multiply(BigDecimal.valueOf(100));
|
||||||
|
responseBean.getAssignedApplication().setAdditionalApplicationPercentage(percentageAdded.setScale(2, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> statuses = Arrays.asList(ApplicationStatusTypeEnum.APPROVED.getValue(), ApplicationStatusTypeEnum.REJECTED.getValue());
|
||||||
|
LocalDateTime sevenDaysAgo = LocalDateTime.now().minusDays(7);
|
||||||
|
Long evaluatedApplication = assignedApplicationsRepository.countEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
|
||||||
|
if (evaluatedApplication != null) {
|
||||||
|
responseBean.getEvaluatedApplication().setEvaluatedApplication(evaluatedApplication);
|
||||||
|
|
||||||
|
BigDecimal dailyAverage = assignedApplicationsRepository.countDailyAverageEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
|
||||||
|
if (dailyAverage != null) {
|
||||||
|
responseBean.getEvaluatedApplication().setDailyAverage(dailyAverage.setScale(2, RoundingMode.HALF_UP)); // Rounded to 2 decimal places
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> amendmentStatus =Arrays.asList( ApplicationAmendmentRequestEnum.AWAITING.getValue(), ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
||||||
|
Long rescueInstructorsInProgress = applicationAmendmentRequestRepository.countAmendmentsByApplicationIds(applicationIds,amendmentStatus);
|
||||||
|
if (rescueInstructorsInProgress != null) {
|
||||||
|
responseBean.getAmendmentInProgress().setTotalAmendmentInProgress(rescueInstructorsInProgress);
|
||||||
|
}
|
||||||
|
calculateExpiringRescueInstructorsToday(applicationIds,responseBean);
|
||||||
|
|
||||||
|
}
|
||||||
|
private void calculateExpiringRescueInstructorsToday(List<Long> applicationIds, PreInstructorWidgetResponseBean responseBean) {
|
||||||
|
List<String> statuses =Arrays.asList( ApplicationAmendmentRequestEnum.AWAITING.getValue(), ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
||||||
|
|
||||||
|
LocalDateTime startOfDay = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||||
|
|
||||||
|
LocalDateTime endOfDay = startOfDay.plusDays(1).minusNanos(1);
|
||||||
|
|
||||||
|
Long expiringToday = applicationAmendmentRequestRepository.countAmendmentsExpiringToday(applicationIds, statuses, startOfDay, endOfDay);
|
||||||
|
|
||||||
|
if (expiringToday != null) {
|
||||||
|
responseBean.getAmendmentInProgress().setExpiringToday(expiringToday);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateAverageEvaluationTime(List<Long> applicationIds, PreInstructorWidgetResponseBean responseBean, Long hubId) {
|
||||||
|
|
||||||
|
if (Boolean.FALSE.equals(applicationIds.isEmpty())) {
|
||||||
|
BigDecimal averageTime = applicationEvaluationRepository.findAverageEvaluationTimeByApplicationIds(applicationIds);
|
||||||
|
responseBean.getAverageEvaluationDays().setAverageEvlauationDaysRating(
|
||||||
|
averageTime != null ? averageTime.setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// BigDecimal timeDifference = applicationEvaluationRepository.findTimeDifferenceFromAverage(applicationIds);
|
||||||
|
// responseBean.getAverageEvaluationTime().setTimeDifferenceFromAverage(timeDifference != null ? timeDifference : BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,19 +94,7 @@ public class EmailNotificationDao {
|
|||||||
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
||||||
// bodyPlaceholders.put("{{legal_mail}}", legalMail);
|
// bodyPlaceholders.put("{{legal_mail}}", legalMail);
|
||||||
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||||
String body;
|
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||||
if ("t7jh5wfg9QXylNaTZkPoE".equals(hubEntity.getUniqueUuid()) && templateType.equals(SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST)) {
|
|
||||||
bodyPlaceholders.put("{{email_signature}}", hubEntity.getEmailSignature());
|
|
||||||
bodyPlaceholders.put("{{platform_link}}",hubEntity.getDomainName());
|
|
||||||
body = Utils.replacePlaceholders(GepafinConstant.DOCUMENTATION_INTEGRATION_REQUEST_SVILUPPUMBRIA, bodyPlaceholders);
|
|
||||||
}
|
|
||||||
else if ("t7jh5wfg9QXylNaTZkPoE".equals(hubEntity.getUniqueUuid()) && templateType.equals(SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE)) {
|
|
||||||
bodyPlaceholders.put("{{email_signature}}", hubEntity.getEmailSignature());
|
|
||||||
body = Utils.replacePlaceholders(GepafinConstant.APPLICATION_REJECTED_SVILUPPUMBRIA, bodyPlaceholders);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EmailContentResponse(subject, body, systemEmailTemplateResponse);
|
return new EmailContentResponse(subject, body, systemEmailTemplateResponse);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
|
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ContentResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.EvaluationFormResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
|
import net.gepafin.tendermanagement.service.EvaluationCriteriaService;
|
||||||
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
|
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||||
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EvaluationFormDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationFormRepository evaluationFormRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallDao callDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VatCheckDao vatCheckDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallRepository callRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CriteriaFormFieldRepository criteriaFormFieldRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationCriteriaService evaluationCriteriaService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LoggingUtil loggingUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
public EvaluationFormEntity saveEvaluationFormEntity(EvaluationFormEntity evaluationFormEntity){
|
||||||
|
evaluationFormEntity= evaluationFormRepository.save(evaluationFormEntity);
|
||||||
|
return evaluationFormEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EvaluationFormEntity convertEvaluationFormRequestToEvaluationFormEntity(CallEntity callEntity, EvaluationFormRequest formRequest) {
|
||||||
|
|
||||||
|
EvaluationFormEntity evaluationFormEntity = new EvaluationFormEntity();
|
||||||
|
evaluationFormEntity.setCall(callEntity);
|
||||||
|
evaluationFormEntity.setLabel(formRequest.getLabel());
|
||||||
|
evaluationFormEntity.setContent(setContentResponseBean(formRequest.getContent()));
|
||||||
|
evaluationFormEntity.setIsDeleted(false);
|
||||||
|
evaluationFormEntity = saveEvaluationFormEntity(evaluationFormEntity);
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Create form" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(evaluationFormEntity).build());
|
||||||
|
|
||||||
|
return evaluationFormEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EvaluationFormResponseBean convertEvaluationFormEntityToEvaluationFormResponseBean(EvaluationFormEntity formEntity) {
|
||||||
|
EvaluationFormResponseBean evaluationFormResponseBean =new EvaluationFormResponseBean();
|
||||||
|
evaluationFormResponseBean.setId(formEntity.getId());
|
||||||
|
evaluationFormResponseBean.setContent(setContent(formEntity));
|
||||||
|
evaluationFormResponseBean.setLabel(formEntity.getLabel());
|
||||||
|
evaluationFormResponseBean.setCallId(formEntity.getCall().getId());
|
||||||
|
evaluationFormResponseBean.setCallStatus(formEntity.getCall().getStatus());
|
||||||
|
return evaluationFormResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ContentResponseBean> setContent(EvaluationFormEntity formEntity) {
|
||||||
|
List<ContentResponseBean> contentList = Utils.convertJsonStringToList(formEntity.getContent(),
|
||||||
|
ContentResponseBean.class);
|
||||||
|
return contentList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EvaluationFormResponseBean createEvaluationForm(CallEntity callEntity, EvaluationFormRequest formRequest) {
|
||||||
|
|
||||||
|
validateEvaluationForm(formRequest);
|
||||||
|
EvaluationFormEntity formEntity = convertEvaluationFormRequestToEvaluationFormEntity(callEntity, formRequest);
|
||||||
|
return convertEvaluationFormEntityToEvaluationFormResponseBean(formEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateEvaluationForm(EvaluationFormRequest formRequest){
|
||||||
|
if(formRequest.getContent()==null || formRequest.getLabel()==null ){
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.REQUIRED_PARAMETER_NOT_FOUND_FOR_FORM));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public EvaluationFormResponseBean updateEvaluationForm(UserEntity user, Long formId, EvaluationFormRequest formRequest) {
|
||||||
|
EvaluationFormEntity evaluationFormEntity = validateForm(formId);
|
||||||
|
//cloned for old form data
|
||||||
|
EvaluationFormEntity oldFormData = Utils.getClonedEntityForData(evaluationFormEntity);
|
||||||
|
|
||||||
|
Utils.setIfUpdated(evaluationFormEntity::getLabel, evaluationFormEntity::setLabel, formRequest.getLabel());
|
||||||
|
Utils.setIfUpdated(evaluationFormEntity::getContent, evaluationFormEntity::setContent, setContentResponseBean(formRequest.getContent()));
|
||||||
|
evaluationFormEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
evaluationFormEntity = saveEvaluationFormEntity(evaluationFormEntity);
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Update form data" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldFormData).newData(evaluationFormEntity).build());
|
||||||
|
return convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EvaluationFormEntity validateForm(Long formId) {
|
||||||
|
EvaluationFormEntity evaluationFormEntity = evaluationFormRepository.findByIdAndIsDeletedFalse(formId);
|
||||||
|
if (evaluationFormEntity == null) {
|
||||||
|
throw new ResourceNotFoundException(
|
||||||
|
Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.EVALUATION_FORM_NOT_FOUND)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return evaluationFormEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public EvaluationFormResponseBean getEvaluationFormById(UserEntity user, Long formId) {
|
||||||
|
EvaluationFormEntity evaluationFormEntity = validateForm(formId);
|
||||||
|
validator.validateUserWithCall(user, evaluationFormEntity.getCall().getId());
|
||||||
|
return convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity);
|
||||||
|
}
|
||||||
|
public void deleteEvaluationForm(UserEntity user, Long formId){
|
||||||
|
EvaluationFormEntity evaluationFormEntity = validateForm(formId);
|
||||||
|
EvaluationFormEntity clonedData = Utils.getClonedEntityForData(evaluationFormEntity);
|
||||||
|
validator.validateUserWithCall(user, evaluationFormEntity.getCall().getId());
|
||||||
|
evaluationFormEntity.setIsDeleted(Boolean.TRUE);
|
||||||
|
evaluationFormEntity = saveEvaluationFormEntity(evaluationFormEntity);
|
||||||
|
/** This code is responsible for adding a version history log for the "soft deleting evaluation from field" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(clonedData).newData(evaluationFormEntity).build());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public EvaluationFormResponseBean getEvaluationFormByCallId(CallEntity callEntity) {
|
||||||
|
if (callEntity == null) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND));
|
||||||
|
}
|
||||||
|
|
||||||
|
EvaluationFormEntity formEntity = evaluationFormRepository
|
||||||
|
.findByCallIdAndIsDeletedFalse(callEntity.getId());
|
||||||
|
if(formEntity!=null)
|
||||||
|
return convertEvaluationFormEntityToEvaluationFormResponseBean(formEntity);
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String setContentResponseBean(List<ContentRequestBean> contentRequestBeans){
|
||||||
|
String stringContentRequest = Utils.convertListToJsonString(contentRequestBeans);
|
||||||
|
List<ContentRequestBean> cloneContentRequestBeans = Utils.convertJsonStringToList(stringContentRequest, ContentRequestBean.class);
|
||||||
|
cloneContentRequestBeans.forEach(data->data.setCriteria(null));
|
||||||
|
return Utils.convertListToJsonString(cloneContentRequestBeans);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -305,7 +305,7 @@ public class FlowFormDao {
|
|||||||
Long totalFormSteps = calculateTotalSteps(flowEdgesList);
|
Long totalFormSteps = calculateTotalSteps(flowEdgesList);
|
||||||
Long currentStep = calculateCurrentStep(flowEdgesList, formEntity);
|
Long currentStep = calculateCurrentStep(flowEdgesList, formEntity);
|
||||||
nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps);
|
nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps);
|
||||||
completedSteps = getCompletedSteps(applicationEntity);
|
completedSteps = getCompletedSteps(applicationEntity, false);
|
||||||
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(completedSteps));
|
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(completedSteps));
|
||||||
nextOrPreviousFormResponse.setCurrentStep(currentStep);
|
nextOrPreviousFormResponse.setCurrentStep(currentStep);
|
||||||
if(applicationEntity.getProtocol() != null) {
|
if(applicationEntity.getProtocol() != null) {
|
||||||
@@ -318,13 +318,13 @@ public class FlowFormDao {
|
|||||||
return nextOrPreviousFormResponse;
|
return nextOrPreviousFormResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCompletedSteps(ApplicationEntity applicationEntity) {
|
public Integer getCompletedSteps(ApplicationEntity applicationEntity, Boolean isSendValidationError) {
|
||||||
Integer completedSteps=0;
|
Integer completedSteps=0;
|
||||||
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
||||||
List<ApplicationFormFieldEntity> applicationFormFieldEntities=new ArrayList<>();
|
List<ApplicationFormFieldEntity> applicationFormFieldEntities=new ArrayList<>();
|
||||||
for (ApplicationFormEntity applicationFormEntity:applicationFormList){
|
for (ApplicationFormEntity applicationFormEntity:applicationFormList){
|
||||||
applicationFormFieldEntities=applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId());
|
applicationFormFieldEntities=applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId());
|
||||||
Boolean isCompleted=formDao.validateCompletedSteps(applicationFormFieldEntities, applicationEntity, applicationFormEntity.getForm());
|
Boolean isCompleted=formDao.validateCompletedSteps(applicationFormFieldEntities, applicationEntity, applicationFormEntity.getForm(), isSendValidationError);
|
||||||
if(Boolean.TRUE.equals(isCompleted)){
|
if(Boolean.TRUE.equals(isCompleted)){
|
||||||
completedSteps++;
|
completedSteps++;
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ public class FlowFormDao {
|
|||||||
FormEntity currentFormEntity = applicationFormList.get(applicationFormList.size() - 1).getForm();
|
FormEntity currentFormEntity = applicationFormList.get(applicationFormList.size() - 1).getForm();
|
||||||
|
|
||||||
for (ApplicationFormEntity applicationFormEntity : applicationFormList) {
|
for (ApplicationFormEntity applicationFormEntity : applicationFormList) {
|
||||||
Boolean isCompleted = formDao.validateCompletedSteps(applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId()), applicationEntity, applicationFormEntity.getForm());
|
Boolean isCompleted = formDao.validateCompletedSteps(applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId()), applicationEntity, applicationFormEntity.getForm(), false);
|
||||||
if (Boolean.FALSE.equals(isCompleted)) {
|
if (Boolean.FALSE.equals(isCompleted)) {
|
||||||
return applicationFormEntity.getForm().getId();
|
return applicationFormEntity.getForm().getId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.*;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.response.ContentResponseBean;
|
import net.gepafin.tendermanagement.model.response.ContentResponseBean;
|
||||||
@@ -35,6 +38,8 @@ import java.util.stream.Collectors;
|
|||||||
@Component
|
@Component
|
||||||
public class FormDao {
|
public class FormDao {
|
||||||
|
|
||||||
|
private final Logger log = LoggerFactory.getLogger(FormDao.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FormRepository formRepository;
|
private FormRepository formRepository;
|
||||||
|
|
||||||
@@ -118,6 +123,10 @@ public class FormDao {
|
|||||||
//cloned entity for old call data.
|
//cloned entity for old call data.
|
||||||
CallEntity oldCallData = Utils.getClonedEntityForData(callEntity);
|
CallEntity oldCallData = Utils.getClonedEntityForData(callEntity);
|
||||||
|
|
||||||
|
if(callEntity.getStatus().equals(CallStatusEnum.PUBLISH.getValue())) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.PUBLISHED_CALL_NOT_UPDATE));
|
||||||
|
}
|
||||||
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(callEntity.getId());
|
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(callEntity.getId());
|
||||||
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(callEntity.getId());
|
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(callEntity.getId());
|
||||||
if (Boolean.FALSE.equals(flowDataEntities.isEmpty() || flowDataEntities == null) || Boolean.FALSE.equals(flowEdgesEntities.isEmpty() || flowEdgesEntities == null)) {
|
if (Boolean.FALSE.equals(flowDataEntities.isEmpty() || flowDataEntities == null) || Boolean.FALSE.equals(flowEdgesEntities.isEmpty() || flowEdgesEntities == null)) {
|
||||||
@@ -198,8 +207,9 @@ public class FormDao {
|
|||||||
String formFieldId,Long evaluationCriteriaId) {
|
String formFieldId,Long evaluationCriteriaId) {
|
||||||
EvaluationCriteriaEntity evaluationCriteria = evaluationCriteriaService.validateEvaluationCriteria(evaluationCriteriaId);
|
EvaluationCriteriaEntity evaluationCriteria = evaluationCriteriaService.validateEvaluationCriteria(evaluationCriteriaId);
|
||||||
if (Boolean.FALSE.equals(evaluationCriteria.getCall().getId().equals(callEntity.getId()))) {
|
if (Boolean.FALSE.equals(evaluationCriteria.getCall().getId().equals(callEntity.getId()))) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
log.info("This evaluation criterion does not belong to the current call. Expected Call ID = {}, Found Call ID = {}",
|
||||||
Translator.toLocale(GepafinConstant.EVALUATIONCRITERIA_INVALID));
|
callEntity.getId(), evaluationCriteria.getCall().getId());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
CriteriaFormFieldEntity criteriaFormField = new CriteriaFormFieldEntity();
|
CriteriaFormFieldEntity criteriaFormField = new CriteriaFormFieldEntity();
|
||||||
criteriaFormField.setCallId(callEntity.getId());
|
criteriaFormField.setCallId(callEntity.getId());
|
||||||
@@ -397,9 +407,9 @@ public class FormDao {
|
|||||||
FieldValidator validator = FieldValidator.create();
|
FieldValidator validator = FieldValidator.create();
|
||||||
formResponseBean.getContent().forEach(contentResponseBean -> {
|
formResponseBean.getContent().forEach(contentResponseBean -> {
|
||||||
String fieldId = contentResponseBean.getId();
|
String fieldId = contentResponseBean.getId();
|
||||||
String value = (String) formFieldMap.get(fieldId);
|
|
||||||
String fieldLabel=contentResponseBean.getLabel();
|
String fieldLabel=contentResponseBean.getLabel();
|
||||||
|
Object object=formFieldMap.get(fieldId);
|
||||||
|
String value =Utils.convertToStringForFormFieldValue(object);
|
||||||
if(value == null && isApplicationFormExist) {
|
if(value == null && isApplicationFormExist) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -408,7 +418,7 @@ public class FormDao {
|
|||||||
.minLength(value, fieldValidatorBean.getMinLength(), fieldLabel) // Only applies if minLength is not null
|
.minLength(value, fieldValidatorBean.getMinLength(), fieldLabel) // Only applies if minLength is not null
|
||||||
.maxLength(value, fieldValidatorBean.getMaxLength(), fieldLabel) // Only applies if maxLength is not null
|
.maxLength(value, fieldValidatorBean.getMaxLength(), fieldLabel) // Only applies if maxLength is not null
|
||||||
.matchesPattern(value, fieldValidatorBean.getPattern(), fieldLabel) // Only applies if pattern is present
|
.matchesPattern(value, fieldValidatorBean.getPattern(), fieldLabel) // Only applies if pattern is present
|
||||||
.validateCustom(value, fieldValidatorBean.getCustom(), fieldLabel); // Add the custom validation here
|
.validateCustom(value, fieldValidatorBean.getCustom(), fieldLabel,contentResponseBean); // Add the custom validation here
|
||||||
if (fieldValidatorBean.getCustom() != null && fieldValidatorBean.getCustom().equals(GepafinConstant.IS_PIVA)) {
|
if (fieldValidatorBean.getCustom() != null && fieldValidatorBean.getCustom().equals(GepafinConstant.IS_PIVA)) {
|
||||||
String error = validateVatNumber(value, fieldValidatorBean.getCustom(), fieldLabel);
|
String error = validateVatNumber(value, fieldValidatorBean.getCustom(), fieldLabel);
|
||||||
if(error != null) {
|
if(error != null) {
|
||||||
@@ -428,11 +438,14 @@ public class FormDao {
|
|||||||
for (Object value : list) {
|
for (Object value : list) {
|
||||||
setFormFieldMap(fieldId, formFieldMap, value);
|
setFormFieldMap(fieldId, formFieldMap, value);
|
||||||
}
|
}
|
||||||
|
}else if (list.stream().allMatch(item -> item instanceof Map<?, ?> map &&
|
||||||
|
map.keySet().stream().allMatch(String.class::isInstance))) {
|
||||||
|
if (fieldValue != null) {
|
||||||
|
formFieldMap.put(fieldId, fieldValue);
|
||||||
|
}
|
||||||
|
} else setFormFieldMap(fieldId, formFieldMap, fieldValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else setFormFieldMap(fieldId, formFieldMap, fieldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFormFieldMap(String fieldId, Map<String, Object> formFieldMap, Object value) {
|
private void setFormFieldMap(String fieldId, Map<String, Object> formFieldMap, Object value) {
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
if(value !=null && Boolean.FALSE.equals(StringUtils.isEmpty((String)value))) {
|
if(value !=null && Boolean.FALSE.equals(StringUtils.isEmpty((String)value))) {
|
||||||
@@ -448,7 +461,8 @@ public class FormDao {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean validateCompletedSteps(List<ApplicationFormFieldEntity> applicationFormFieldEntityList, ApplicationEntity applicationEntity, FormEntity formEntity) {
|
public Boolean validateCompletedSteps(List<ApplicationFormFieldEntity> applicationFormFieldEntityList, ApplicationEntity applicationEntity, FormEntity formEntity,
|
||||||
|
Boolean isSendValidationError) {
|
||||||
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
|
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
|
||||||
for(ApplicationFormFieldEntity applicationFormFieldEntity:applicationFormFieldEntityList) {
|
for(ApplicationFormFieldEntity applicationFormFieldEntity:applicationFormFieldEntityList) {
|
||||||
formFieldMap.put(applicationFormFieldEntity.getFieldId(),applicationFormFieldEntity.getFieldValue());
|
formFieldMap.put(applicationFormFieldEntity.getFieldId(),applicationFormFieldEntity.getFieldValue());
|
||||||
@@ -461,14 +475,29 @@ public class FormDao {
|
|||||||
String value = (String) formFieldMap.get(fieldId);
|
String value = (String) formFieldMap.get(fieldId);
|
||||||
|
|
||||||
FieldValidatorBean fieldValidatorBean = Utils.convertSourceObjectToDestinationObject(contentResponseBean.getValidators(), FieldValidatorBean.class);
|
FieldValidatorBean fieldValidatorBean = Utils.convertSourceObjectToDestinationObject(contentResponseBean.getValidators(), FieldValidatorBean.class);
|
||||||
validator
|
String fieldValue = getFieldValue(contentResponseBean);
|
||||||
.isRequired(value,fieldValidatorBean.getIsRequired(),fieldId);
|
|
||||||
|
validator.isRequired(value, fieldValidatorBean.getIsRequired(), fieldValue)
|
||||||
|
.validateCustomTableValidation(value,fieldValidatorBean.getCustom(),fieldValue,contentResponseBean);
|
||||||
});
|
});
|
||||||
if (validator.hasErrors()) {
|
if (Boolean.TRUE.equals(isSendValidationError)) {
|
||||||
return false; // Validation failed, return false
|
validator.validate();
|
||||||
}
|
}
|
||||||
return true;
|
return !validator.hasErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFieldValue(ContentResponseBean contentResponseBean) {
|
||||||
|
// Use Optional with pattern matching for type checks
|
||||||
|
return contentResponseBean.getSettings().stream().filter(setting -> "label".equals(setting.getName()) && setting.getValue() != null)
|
||||||
|
.map(setting -> {
|
||||||
|
if (setting.getValue() instanceof String value) {
|
||||||
|
return value.trim();
|
||||||
|
} else {
|
||||||
|
return String.valueOf(setting.getValue()).trim();
|
||||||
|
}
|
||||||
|
}).filter(value -> !value.isEmpty()).findFirst().orElse(contentResponseBean.getId());
|
||||||
|
}
|
||||||
|
|
||||||
public String validateVatNumber(String value,String customRule,String fieldId){
|
public String validateVatNumber(String value,String customRule,String fieldId){
|
||||||
String error=null;
|
String error=null;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Expression;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import jakarta.persistence.criteria.Root;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
@@ -12,8 +16,12 @@ import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
|||||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||||
|
import net.gepafin.tendermanagement.model.request.NotificationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||||
import net.gepafin.tendermanagement.repositories.NotificationRepository;
|
import net.gepafin.tendermanagement.repositories.NotificationRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.NotificationTypeRepository;
|
import net.gepafin.tendermanagement.repositories.NotificationTypeRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||||
@@ -23,9 +31,16 @@ import net.gepafin.tendermanagement.util.DateTimeUtil;
|
|||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.opensaml.xmlsec.signature.G;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -34,6 +49,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -289,4 +305,113 @@ public class NotificationDao {
|
|||||||
return notificationEntities.stream().map(this::convertNotificationEntityToNotificationResponse).toList();
|
return notificationEntities.stream().map(this::convertNotificationEntityToNotificationResponse).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PageableResponseBean<List<NotificationResponse>> getAllNotification(Long userId, NotificationRequestBean notificationRequestBean) {
|
||||||
|
Integer pageNo = null;
|
||||||
|
Integer pageLimit = null;
|
||||||
|
if (notificationRequestBean.getGlobalFilters() != null) {
|
||||||
|
pageNo = notificationRequestBean.getGlobalFilters().getPage();
|
||||||
|
pageLimit = notificationRequestBean.getGlobalFilters().getLimit();
|
||||||
|
}
|
||||||
|
if (pageLimit == null || pageLimit <= 0) {
|
||||||
|
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||||
|
}
|
||||||
|
if (pageNo == null || pageNo <= 0) {
|
||||||
|
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||||
|
}
|
||||||
|
Specification<NotificationEntity> spec = search(userId, notificationRequestBean);
|
||||||
|
Page<NotificationEntity> entityPage = notificationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||||
|
// Prepare the response
|
||||||
|
|
||||||
|
|
||||||
|
List<NotificationResponse> notificationResponses = entityPage.getContent().stream()
|
||||||
|
.map(notification -> {
|
||||||
|
NotificationResponse response = convertNotificationEntityToNotificationResponse(notification);
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
PageableResponseBean<List<NotificationResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||||
|
pageableResponseBean.setBody(notificationResponses);
|
||||||
|
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||||
|
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||||
|
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||||
|
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||||
|
|
||||||
|
return pageableResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Specification<NotificationEntity> search(Long userId, NotificationRequestBean notificationRequestBean) {
|
||||||
|
return (root, query, criteriaBuilder) -> {
|
||||||
|
|
||||||
|
List<Predicate> predicates = getPredicates(notificationRequestBean, criteriaBuilder, root, userId);
|
||||||
|
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||||
|
|
||||||
|
if (notificationRequestBean.getGlobalFilters() != null
|
||||||
|
&& notificationRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||||
|
notificationRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||||
|
isEmpty(notificationRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||||
|
sortBy.setColumnName(notificationRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||||
|
sortBy.setSortDesc(true);
|
||||||
|
if (notificationRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||||
|
sortBy.setSortDesc(notificationRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||||
|
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||||
|
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||||
|
}
|
||||||
|
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<Predicate> getPredicates(NotificationRequestBean notificationRequestBean,
|
||||||
|
CriteriaBuilder criteriaBuilder, Root<NotificationEntity> root, Long userId) {
|
||||||
|
|
||||||
|
Integer year = null;
|
||||||
|
String search = null;
|
||||||
|
if (notificationRequestBean.getGlobalFilters() != null) {
|
||||||
|
year = notificationRequestBean.getGlobalFilters().getYear();
|
||||||
|
search = notificationRequestBean.getGlobalFilters().getSearch();
|
||||||
|
}
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (year != null && year > 0) {
|
||||||
|
int filterYear = notificationRequestBean.getGlobalFilters().getYear();
|
||||||
|
|
||||||
|
// Create LocalDateTime boundaries for the start and end of the year
|
||||||
|
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||||
|
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||||
|
|
||||||
|
// Add the range comparison to filter records within the year
|
||||||
|
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||||
|
|
||||||
|
}
|
||||||
|
// Search in `title` and `message` (if search term is provided)
|
||||||
|
if (search != null && !search.isEmpty()) {
|
||||||
|
Predicate titlePredicate = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.TITLE)),
|
||||||
|
"%" + search.toUpperCase() + "%"
|
||||||
|
);
|
||||||
|
Predicate messagePredicate = criteriaBuilder.like(
|
||||||
|
criteriaBuilder.upper(root.get(GepafinConstant.MESSAGE)),
|
||||||
|
"%" + search.toUpperCase() + "%"
|
||||||
|
);
|
||||||
|
predicates.add(criteriaBuilder.or(titlePredicate, messagePredicate));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by `status` (if status list is provided)
|
||||||
|
if (notificationRequestBean.getStatus() != null && !notificationRequestBean.getStatus().isEmpty()) {
|
||||||
|
List<String> statusValues = notificationRequestBean.getStatus().stream()
|
||||||
|
.map(NotificationEnum::name) // Convert enum to string
|
||||||
|
.toList();
|
||||||
|
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||||
|
}
|
||||||
|
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||||
|
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userId));
|
||||||
|
return predicates;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.itextpdf.text.Rectangle;
|
|||||||
import com.itextpdf.text.pdf.*;
|
import com.itextpdf.text.pdf.*;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
import net.gepafin.tendermanagement.model.request.FieldLabelValuePairRequest;
|
import net.gepafin.tendermanagement.model.request.FieldLabelValuePairRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
@@ -29,6 +30,8 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -149,6 +152,31 @@ public class PdfDao {
|
|||||||
// Create value cell with rounded corners
|
// Create value cell with rounded corners
|
||||||
PdfPTable valueTable = new PdfPTable(1);
|
PdfPTable valueTable = new PdfPTable(1);
|
||||||
valueTable.setWidthPercentage(100);
|
valueTable.setWidthPercentage(100);
|
||||||
|
|
||||||
|
|
||||||
|
Object finalValue = value;
|
||||||
|
List<Object> criteriaObject = (List<Object>) contentResponseBean.getSettings().stream()
|
||||||
|
.filter(setting -> GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(setting.getName()))
|
||||||
|
.findFirst()
|
||||||
|
.map(setting -> {
|
||||||
|
try {
|
||||||
|
// Assuming setting.getValue() contains the JSON string or object
|
||||||
|
return PdfUtils.extractRows(finalValue);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Error extracting rows from setting value", e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
|
||||||
|
// Update value if criteriaObject is not null
|
||||||
|
if (criteriaObject != null) {
|
||||||
|
value = criteriaObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Update value if criteriaObject is not null
|
||||||
|
|
||||||
if (value instanceof List<?>) {
|
if (value instanceof List<?>) {
|
||||||
// Further check if the list contains Strings
|
// Further check if the list contains Strings
|
||||||
List<?> list = (List<?>) value;
|
List<?> list = (List<?>) value;
|
||||||
@@ -181,7 +209,6 @@ public class PdfDao {
|
|||||||
Object object = value;
|
Object object = value;
|
||||||
String stringvalue = Utils.convertToString(object);
|
String stringvalue = Utils.convertToString(object);
|
||||||
List<Map<String, Object>> fieldValueList = Utils.convertJsonStringIntoJsonList(stringvalue);
|
List<Map<String, Object>> fieldValueList = Utils.convertJsonStringIntoJsonList(stringvalue);
|
||||||
|
|
||||||
document = createPdfTable(fieldValueList, document, contentResponseBean);
|
document = createPdfTable(fieldValueList, document, contentResponseBean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,12 +255,13 @@ public class PdfDao {
|
|||||||
document.add(valueTable);
|
document.add(valueTable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String fieldValue1= (String) value;
|
if (value instanceof String) {
|
||||||
if(Utils.isValidDateString(fieldValue1)){
|
String fieldValue1 = (String) value;
|
||||||
fieldValue1=Utils.formatDateString(String.valueOf(value));
|
if (Utils.isValidDateString(fieldValue1)) {
|
||||||
|
fieldValue1 = Utils.formatDateString(String.valueOf(value));
|
||||||
}
|
}
|
||||||
if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
if(contentResponseBean.getName().equals("numberinput") && Boolean.TRUE.equals(Utils.isNumeric(fieldValue))){
|
||||||
fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue));
|
fieldValue1=Utils.convertToItalianFormat(fieldValue);
|
||||||
}
|
}
|
||||||
// PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont));
|
// PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont));
|
||||||
PdfPCell valueCell = PdfUtils.htmlToPdfPCell(fieldValue1, valueFont);
|
PdfPCell valueCell = PdfUtils.htmlToPdfPCell(fieldValue1, valueFont);
|
||||||
@@ -249,6 +277,7 @@ public class PdfDao {
|
|||||||
valueTable.addCell(valueCell);
|
valueTable.addCell(valueCell);
|
||||||
document.add(valueTable);
|
document.add(valueTable);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
document.add(new Paragraph("\n")); // Add line break after each value
|
document.add(new Paragraph("\n")); // Add line break after each value
|
||||||
@@ -258,11 +287,15 @@ public class PdfDao {
|
|||||||
// Create a PdfPTable with dynamic column count based on stateFieldMap size
|
// Create a PdfPTable with dynamic column count based on stateFieldMap size
|
||||||
Map<String, String> stateFieldMap = new HashMap<>();
|
Map<String, String> stateFieldMap = new HashMap<>();
|
||||||
Map<String, Boolean> stateFieldBoolean = new HashMap<>();
|
Map<String, Boolean> stateFieldBoolean = new HashMap<>();
|
||||||
// Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(178, 190, 181)); // Gray text
|
Map<String, Boolean> formulaEnabledMap = new HashMap<>();
|
||||||
|
Map<String, String> formulaTypeMap = new HashMap<>();
|
||||||
|
Map<String, String> fieldTypeMap = new HashMap<>();
|
||||||
|
Map<String, String> totalMap = new HashMap<>();
|
||||||
|
Font lightGrayFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(110, 110, 110)); // Light gray
|
||||||
|
|
||||||
|
|
||||||
// Populate stateFieldMap from contentResponseBean settings
|
|
||||||
contentResponseBean.getSettings().stream()
|
contentResponseBean.getSettings().stream()
|
||||||
.filter(setting -> "table_columns".equals(setting.getName())) // Check for "table_columns"
|
.filter(setting -> "table_columns".equals(setting.getName()) || "criteria_table_columns".equals(setting.getName())) // Check for "table_columns"
|
||||||
.map(SettingResponseBean::getValue)
|
.map(SettingResponseBean::getValue)
|
||||||
.filter(Objects::nonNull) // Ensure value is not null
|
.filter(Objects::nonNull) // Ensure value is not null
|
||||||
.filter(settingValue -> settingValue instanceof Map) // Ensure value is a Map
|
.filter(settingValue -> settingValue instanceof Map) // Ensure value is a Map
|
||||||
@@ -273,27 +306,29 @@ public class PdfDao {
|
|||||||
.forEach(fieldData -> {
|
.forEach(fieldData -> {
|
||||||
String fieldName = (String) fieldData.get("name"); // Get the name field
|
String fieldName = (String) fieldData.get("name"); // Get the name field
|
||||||
String fieldDataValue = (String) fieldData.get("label"); // Get the predefined field
|
String fieldDataValue = (String) fieldData.get("label"); // Get the predefined field
|
||||||
|
Boolean predefined = (Boolean) fieldData.get("predefined"); // Get the predefined field
|
||||||
|
Boolean isFormulaEnabled = (Boolean) fieldData.get("enableFormula");
|
||||||
|
String formulaType = (String) fieldData.get("lastRowFormula");
|
||||||
|
String fieldType = (String) fieldData.get("fieldtype"); // Get the field type (e.g., numeric)
|
||||||
|
String total= (String) fieldData.get("lastRowText");
|
||||||
if (fieldName != null && fieldDataValue != null) {
|
if (fieldName != null && fieldDataValue != null) {
|
||||||
stateFieldMap.put(fieldName, fieldDataValue);
|
stateFieldMap.put(fieldName, fieldDataValue);
|
||||||
}
|
}
|
||||||
});
|
if (fieldName != null && predefined != null) {
|
||||||
contentResponseBean.getSettings().stream()
|
|
||||||
.filter(setting -> "table_columns".equals(setting.getName())) // Check for "table_columns"
|
|
||||||
.map(SettingResponseBean::getValue)
|
|
||||||
.filter(Objects::nonNull) // Ensure value is not null
|
|
||||||
.filter(settingValue -> settingValue instanceof Map) // Ensure value is a Map
|
|
||||||
.map(settingValue -> (Map<String, Object>) settingValue) // Cast to Map
|
|
||||||
.map(valueMap -> (List<Map<String, Object>>) valueMap.get("stateFieldData")) // Extract stateFieldData list
|
|
||||||
.filter(Objects::nonNull) // Ensure stateFieldData is not null
|
|
||||||
.flatMap(List::stream) // Flatten the list of field data maps
|
|
||||||
.forEach(fieldData -> {
|
|
||||||
String fieldName = (String) fieldData.get("name"); // Get the name field
|
|
||||||
Boolean predefined = (Boolean) fieldData.get("predefined"); // Get the predefined field
|
|
||||||
if (fieldName != null && fieldName != null) {
|
|
||||||
stateFieldBoolean.put(fieldName, predefined);
|
stateFieldBoolean.put(fieldName, predefined);
|
||||||
}
|
}
|
||||||
|
formulaEnabledMap.put(fieldName, isFormulaEnabled != null && isFormulaEnabled);
|
||||||
|
if (formulaType != null) {
|
||||||
|
formulaTypeMap.put(fieldName, formulaType);
|
||||||
|
}
|
||||||
|
if (fieldType != null) {
|
||||||
|
fieldTypeMap.put(fieldName, fieldType); // Store the fieldType in the map
|
||||||
|
}
|
||||||
|
if(total!=null){
|
||||||
|
totalMap.put(fieldName,total);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
PdfPTable table = new PdfPTable(stateFieldMap.size()); // Number of columns equals the number of map entries
|
PdfPTable table = new PdfPTable(stateFieldMap.size()); // Number of columns equals the number of map entries
|
||||||
table.setWidthPercentage(100); // Set table width to 100%
|
table.setWidthPercentage(100); // Set table width to 100%
|
||||||
table.setTableEvent(new RoundedBorderEvent());
|
table.setTableEvent(new RoundedBorderEvent());
|
||||||
@@ -314,12 +349,9 @@ public class PdfDao {
|
|||||||
}
|
}
|
||||||
List<String> orderedKeys = new ArrayList<>(trueKeys);
|
List<String> orderedKeys = new ArrayList<>(trueKeys);
|
||||||
orderedKeys.addAll(falseKeys);
|
orderedKeys.addAll(falseKeys);
|
||||||
// Iterate through extracted data to populate the table
|
|
||||||
// Add headers once
|
|
||||||
if (!headersAdded) {
|
if (!headersAdded) {
|
||||||
for (String key : orderedKeys) {
|
for (String key : orderedKeys) {
|
||||||
String headerValue = stateFieldMap.get(key); // Header text
|
String headerValue = stateFieldMap.get(key); // Header text
|
||||||
// PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header
|
|
||||||
PdfPCell headerCell = PdfUtils.htmlToPdfPCell(headerValue, textFont);
|
PdfPCell headerCell = PdfUtils.htmlToPdfPCell(headerValue, textFont);
|
||||||
headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
||||||
headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
@@ -332,19 +364,24 @@ public class PdfDao {
|
|||||||
}
|
}
|
||||||
headersAdded = true; // Prevent headers from being added again
|
headersAdded = true; // Prevent headers from being added again
|
||||||
}
|
}
|
||||||
|
Map<String, Double> columnSums = new HashMap<>();
|
||||||
|
|
||||||
// Add data rows matching stateFieldMap keys
|
|
||||||
for (Map<String, Object> row : extractedData) {
|
for (Map<String, Object> row : extractedData) {
|
||||||
// Add data rows matching stateFieldMap keys
|
|
||||||
for (String key : orderedKeys) {
|
for (String key : orderedKeys) {
|
||||||
if (stateFieldMap.containsKey(key)) { // Only add data cell if key is in stateFieldMap
|
if (stateFieldMap.containsKey(key)) { // Only add data cell if key is in stateFieldMap
|
||||||
Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present
|
Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present
|
||||||
// String fieldValue= (String) value;
|
// String fieldValue= (String) value;
|
||||||
String fieldValue = value != null ? value.toString() : "";
|
String fieldValue = value != null ? value.toString() : "";
|
||||||
if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
// if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
||||||
fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue));
|
//// fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue));
|
||||||
|
// }
|
||||||
|
if (Boolean.TRUE.equals(formulaEnabledMap.get(key)) && Boolean.TRUE.equals(GepafinConstant.NUMERIC.equalsIgnoreCase(fieldTypeMap.get(key)))) {
|
||||||
|
calculateValue(key, fieldValue, formulaTypeMap, columnSums);
|
||||||
}
|
}
|
||||||
// PdfPCell dataCell = new PdfPCell(new Phrase(fieldValue != null ?fieldValue: "", textFont));
|
if(Boolean.TRUE.equals(Utils.isNumeric(fieldValue))){
|
||||||
|
fieldValue=Utils.convertToItalianFormat(fieldValue);
|
||||||
|
}
|
||||||
|
|
||||||
PdfPCell dataCell = PdfUtils.htmlToPdfPCell(fieldValue != null ? fieldValue : "", textFont);
|
PdfPCell dataCell = PdfUtils.htmlToPdfPCell(fieldValue != null ? fieldValue : "", textFont);
|
||||||
dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell
|
dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell
|
||||||
dataCell.setMinimumHeight(30f);
|
dataCell.setMinimumHeight(30f);
|
||||||
@@ -357,23 +394,79 @@ public class PdfDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if adding another row would exceed max height
|
|
||||||
if (table.getTotalHeight() + rowHeight > maxTableHeight) {
|
if (table.getTotalHeight() + rowHeight > maxTableHeight) {
|
||||||
document.add(table); // Add the table to the document
|
document.add(table); // Add the table to the document
|
||||||
document.newPage(); // Start a new page
|
document.newPage(); // Start a new page
|
||||||
table = new PdfPTable(stateFieldMap.size()); // Create a new table for the new page
|
table = new PdfPTable(stateFieldMap.size()); // Create a new table for the new page
|
||||||
table.setWidthPercentage(100); // Reset table width
|
table.setWidthPercentage(100); // Reset table width
|
||||||
|
|
||||||
headersAdded = false; // Reset the header flag for the new page
|
headersAdded = false; // Reset the header flag for the new page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (String key : orderedKeys) {
|
||||||
|
if (Boolean.TRUE.equals(formulaEnabledMap.get(key)) &&
|
||||||
|
(GepafinConstant.SUM.equalsIgnoreCase(formulaTypeMap.get(key)) ||
|
||||||
|
GepafinConstant.MULTIPLY.equalsIgnoreCase(formulaTypeMap.get(key)))) {
|
||||||
|
|
||||||
|
if (columnSums.containsKey(key)) {
|
||||||
|
double total = columnSums.getOrDefault(key, 0.0); // Get the total for the column
|
||||||
|
// PdfPCell sumCell = PdfUtils.htmlToPdfPCell(Utils.convertToItalianFormat(String.valueOf(total)), textFont);
|
||||||
|
// Convert total to Italian format, defaulting to "0" if null
|
||||||
|
String formattedTotal = Utils.convertToItalianFormat(String.valueOf(total));
|
||||||
|
|
||||||
|
// Create a table cell with the formatted value
|
||||||
|
PdfPCell sumCell = new PdfPCell(new Phrase(formattedTotal,lightGrayFont));
|
||||||
|
|
||||||
|
|
||||||
|
sumCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for totals
|
||||||
|
sumCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||||
|
sumCell.setPaddingTop(8f);
|
||||||
|
sumCell.setMinimumHeight(30f);
|
||||||
|
table.addCell(sumCell); // Add total for the column
|
||||||
|
} else {
|
||||||
|
PdfPCell emptyCell = new PdfPCell(new Phrase(""));
|
||||||
|
emptyCell.setBackgroundColor(new BaseColor(239, 243, 248));
|
||||||
|
table.addCell(emptyCell);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String total=null;
|
||||||
|
if (totalMap.containsKey(key)) {
|
||||||
|
total=totalMap.getOrDefault(key, "");
|
||||||
|
}
|
||||||
|
PdfPCell emptyCell = new PdfPCell(new Phrase(total,lightGrayFont));
|
||||||
|
emptyCell.setPaddingTop(8f);
|
||||||
|
emptyCell.setPaddingLeft(8f);
|
||||||
|
emptyCell.setBackgroundColor(new BaseColor(239, 243, 248));
|
||||||
|
table.addCell(emptyCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Add the last table to the document
|
// Add the last table to the document
|
||||||
document.add(table);
|
document.add(table);
|
||||||
|
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void calculateValue(String key, String fieldValue, Map<String, String> formulaTypeMap, Map<String, Double> columnSums) {
|
||||||
|
try {
|
||||||
|
if (Boolean.FALSE.equals(StringUtils.isEmpty(fieldValue))) {
|
||||||
|
// Use Locale.ITALY to parse the number with the Italian format (comma as decimal separator)
|
||||||
|
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
|
||||||
|
Number number = format.parse(fieldValue); // Parse the fieldValue as a number
|
||||||
|
double numericValue = number.doubleValue(); // Convert the parsed number to double
|
||||||
|
|
||||||
|
if (GepafinConstant.SUM.equalsIgnoreCase(formulaTypeMap.get(key))) {
|
||||||
|
columnSums.merge(key, numericValue, Double::sum);
|
||||||
|
} else if (GepafinConstant.MULTIPLY.equalsIgnoreCase(formulaTypeMap.get(key))) {
|
||||||
|
columnSums.merge(key, numericValue, (existing, newValue) -> existing == null ? newValue : existing * newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ParseException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class RoundedBorderEvent implements PdfPTableEvent {
|
public static class RoundedBorderEvent implements PdfPTableEvent {
|
||||||
@Override
|
@Override
|
||||||
public void tableLayout(PdfPTable table, float[][] widths, float[] heights,
|
public void tableLayout(PdfPTable table, float[][] widths, float[] heights,
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ public class SystemEmailTemplatesDao {
|
|||||||
public SystemEmailTemplateResponse retrieveTemplate(SystemEmailTemplatesEntityTypeEnum type, HubEntity hub, Locale language) {
|
public SystemEmailTemplateResponse retrieveTemplate(SystemEmailTemplatesEntityTypeEnum type, HubEntity hub, Locale language) {
|
||||||
SystemEmailTemplatesEntity dbSystemEmailTemplatesEntity = null;
|
SystemEmailTemplatesEntity dbSystemEmailTemplatesEntity = null;
|
||||||
if(hub != null){
|
if(hub != null){
|
||||||
// dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
|
dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
|
||||||
// .findByTypeAndCallId(type.getValue(), call.getId());
|
.findByTypeAndHubEntityId(type.getValue(), hub.getId());
|
||||||
}
|
}
|
||||||
if(dbSystemEmailTemplatesEntity == null) {
|
if(dbSystemEmailTemplatesEntity == null){
|
||||||
dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
|
dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
|
||||||
.findByType(type.getValue());
|
.findByType(type.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.entities.RoleActionContextEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.RoleActionContextRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.UserActionsRepository;
|
||||||
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class UserActionDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserActionsRepository userActionsRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RoleActionContextRepository roleActionContextRepository;
|
||||||
|
|
||||||
|
public SummaryPageResponseBean getUserAction(HttpServletRequest request, UserEntity userEntity, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext){
|
||||||
|
Long numberOfLoginAttempts = userActionsRepository.countUserLoginAttempts(userEntity.getId());
|
||||||
|
Long applicationsProcessed = assignedApplicationsRepository.countAssignedApplicationsByUserId(userEntity.getId());
|
||||||
|
|
||||||
|
List<UserActionEntity> userActions = getFilterUserActions(userEntity.getId(),timeFilter,actionContext);
|
||||||
|
|
||||||
|
return createSummaryPageResponse(userEntity,numberOfLoginAttempts,applicationsProcessed,userActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SummaryPageResponseBean createSummaryPageResponse(UserEntity user, Long numberOfLoginAttempts, Long applicationsProcessed, List<UserActionEntity> userActions){
|
||||||
|
SummaryPageResponseBean response = new SummaryPageResponseBean();
|
||||||
|
response.setRole(user.getRoleEntity().getRoleName());
|
||||||
|
response.setLastLogin(user.getLastLogin());
|
||||||
|
response.setRegistrationDate(user.getCreatedDate());
|
||||||
|
response.setUsername(user.getFirstName());
|
||||||
|
response.setEmail(user.getEmail());
|
||||||
|
response.setNumberOfLoginAttempts(numberOfLoginAttempts);
|
||||||
|
response.setApplicationsProcessed(applicationsProcessed);
|
||||||
|
|
||||||
|
List<UserActionResponseBean> userAction = convertEntityToResponse(userActions);
|
||||||
|
response.setUserActions(userAction);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<UserActionEntity> getFilterUserActions(Long userId ,TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContextList) {
|
||||||
|
LocalDateTime endDate = LocalDateTime.now();
|
||||||
|
LocalDateTime startDate = (timeFilter != null) ? getStartTimeFromFilter(timeFilter) : null;
|
||||||
|
Pageable pageable = PageRequest.of(0, 25);
|
||||||
|
|
||||||
|
// String actionContextLabel = (actionContext != null) ? actionContext.toString() : null;
|
||||||
|
List<String> actionContextLabels = (actionContextList != null && !actionContextList.isEmpty())
|
||||||
|
? actionContextList.stream().map(Enum::toString).collect(Collectors.toList())
|
||||||
|
: null;
|
||||||
|
|
||||||
|
Specification<UserActionEntity> spec = getUserActionsSpecification(userId, startDate, endDate, actionContextLabels);
|
||||||
|
Page<UserActionEntity> pageResult = userActionsRepository.findAll(spec, pageable);
|
||||||
|
|
||||||
|
return pageResult.getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalDateTime getStartTimeFromFilter(TimePeriodEnum timeFilter) {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
if (timeFilter.equals(TimePeriodEnum.LAST_WEEK)) {
|
||||||
|
return now.minusDays(7);
|
||||||
|
} else if (timeFilter.equals(TimePeriodEnum.LAST_QUARTER)) {
|
||||||
|
return now.minusMonths(4);
|
||||||
|
} else if (timeFilter.equals(TimePeriodEnum.LAST_SEMESTER)) {
|
||||||
|
return now.minusMonths(6);
|
||||||
|
} else if (timeFilter.equals(TimePeriodEnum.LAST_YEAR)) {
|
||||||
|
return now.minusYears(1);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Specification<UserActionEntity> getUserActionsSpecification(Long userId, LocalDateTime startDate, LocalDateTime endDate, List<String> actionContextList) {
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||||
|
|
||||||
|
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
||||||
|
|
||||||
|
if (startDate != null && endDate != null) {
|
||||||
|
predicate = builder.and(predicate, builder.between(root.get("createdDate"), startDate, endDate));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (actionContextList != null && !actionContextList.isEmpty()) {
|
||||||
|
CriteriaBuilder.In<Object> inClause = builder.in(root.get("actionContext"));
|
||||||
|
for (String actionContext : actionContextList) {
|
||||||
|
inClause.value(actionContext);
|
||||||
|
}
|
||||||
|
predicate = builder.and(predicate, inClause);
|
||||||
|
}
|
||||||
|
query.orderBy(builder.desc(root.get("createdDate")));
|
||||||
|
|
||||||
|
return predicate;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UserActionResponseBean> convertEntityToResponse(List<UserActionEntity> userActions) {
|
||||||
|
return userActions.stream().map(action -> {
|
||||||
|
UserActionResponseBean responseBean = new UserActionResponseBean();
|
||||||
|
responseBean.setId(action.getId());
|
||||||
|
responseBean.setUserId(action.getUserId());
|
||||||
|
responseBean.setActionType(action.getActionType());
|
||||||
|
responseBean.setRequestBody(action.getRequestBody());
|
||||||
|
responseBean.setLoginAttemptId(action.getLoginAttemptId());
|
||||||
|
responseBean.setIpAddress(action.getIpAddress());
|
||||||
|
responseBean.setActionContext(action.getActionContext());
|
||||||
|
responseBean.setHubId(action.getHubId());
|
||||||
|
responseBean.setUrl(action.getUrl());
|
||||||
|
responseBean.setResponse(action.getResponse());
|
||||||
|
responseBean.setCreatedDate(action.getCreatedDate());
|
||||||
|
responseBean.setUpdatedDate(action.getUpdatedDate());
|
||||||
|
return responseBean;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, UserEntity userEntity){
|
||||||
|
List<RoleActionContextEntity> actionContextLabel = roleActionContextRepository.findActionContextLabel(userEntity.getRoleEntity().getId());
|
||||||
|
return convertRoleContextEntityToResponse(actionContextLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ActionContextLabelResponse> convertRoleContextEntityToResponse(List<RoleActionContextEntity> actionContextEntities){
|
||||||
|
return actionContextEntities.stream().map(actionContext -> {
|
||||||
|
ActionContextLabelResponse responseBean = new ActionContextLabelResponse();
|
||||||
|
responseBean.setId(actionContext.getId());
|
||||||
|
responseBean.setActionContext(UserActionContextEnum.valueOf(actionContext.getActionContext()));
|
||||||
|
responseBean.setRoleId(actionContext.getRoleId());
|
||||||
|
responseBean.setDescription(actionContext.getDescription());
|
||||||
|
responseBean.setIsViewed(actionContext.getIsViewed());
|
||||||
|
return responseBean;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import net.gepafin.tendermanagement.util.LoggingUtil;
|
|||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
@@ -597,5 +598,58 @@ public class UserDao {
|
|||||||
return userResponseBeans;
|
return userResponseBeans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserResponseBean updateUserDetails(HttpServletRequest request , Long userId, UpdateUserReqForBeneficiary userReq){
|
||||||
|
log.info("Updating user by beneficiary with ID: {}", userId);
|
||||||
|
UserEntity userEntity = validator.validateUserId(request, userId);
|
||||||
|
|
||||||
|
UserEntity oldUserEntity = Utils.getClonedEntityForData(userEntity);
|
||||||
|
log.info("Current user details: {}", userEntity);
|
||||||
|
log.info("New user details: {}", userReq);
|
||||||
|
|
||||||
|
HubEntity hubEntity = hubService.valdateHub(userEntity.getHub().getId());
|
||||||
|
String beneficiaryRoleType = RoleStatusEnum.ROLE_BENEFICIARY.getValue();
|
||||||
|
|
||||||
|
if (validator.checkIsBeneficiary()) {
|
||||||
|
// Validate if the new email already exists for another beneficiary in the same hub
|
||||||
|
boolean emailExistsForBeneficiary = userRepository.existsByEmailIgnoreCaseForBeneficiaries(
|
||||||
|
userReq.getEmail(), hubEntity.getUniqueUuid(), beneficiaryRoleType);
|
||||||
|
|
||||||
|
if (emailExistsForBeneficiary) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
||||||
|
}
|
||||||
|
|
||||||
|
setIfUpdated(userEntity::getEmail,userEntity::setEmail,userReq.getEmail()); // Only update email if role is beneficiary
|
||||||
|
}
|
||||||
|
|
||||||
|
BeneficiaryEntity oldBeneficiaryEntity = null;
|
||||||
|
|
||||||
|
if(userEntity.getBeneficiary()!=null) {
|
||||||
|
oldBeneficiaryEntity = Utils.getClonedEntityForData(userEntity.getBeneficiary());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getFirstName, userEntity.getBeneficiary()::setFirstName, userReq.getFirstName());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getLastName, userEntity.getBeneficiary()::setLastName, userReq.getLastName());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getOrganization, userEntity.getBeneficiary()::setOrganization, userReq.getOrganization());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getAddress, userEntity.getBeneficiary()::setAddress, userReq.getAddress());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getPhoneNumber, userEntity.getBeneficiary()::setPhoneNumber, userReq.getPhoneNumber());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getDateOfBirth, userEntity.getBeneficiary()::setDateOfBirth, userReq.getDateOfBirth());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getCity, userEntity.getBeneficiary()::setCity, userReq.getCity());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getCountry, userEntity.getBeneficiary()::setCountry, userReq.getCountry());
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Update beneficiary details " operation **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(oldBeneficiaryEntity).newData(userEntity.getBeneficiary()).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
userEntity = userRepository.save(userEntity);
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Update user details by beneficiary" operation **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(oldUserEntity).newData(userEntity).build());
|
||||||
|
|
||||||
|
return convertUserEntityToUserResponse(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,4 +53,7 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity {
|
|||||||
@Column(name = "amendment_document")
|
@Column(name = "amendment_document")
|
||||||
private String amendmentDocument;
|
private String amendmentDocument;
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "CLOSING_DATE")
|
||||||
|
private LocalDateTime closingDate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,4 +68,10 @@ public class ApplicationEntity extends BaseEntity {
|
|||||||
@Column(name="DATE_REJECTED")
|
@Column(name="DATE_REJECTED")
|
||||||
private LocalDateTime dateRejected;
|
private LocalDateTime dateRejected;
|
||||||
|
|
||||||
|
@Column(name = "evaluationVersion")
|
||||||
|
private String evaluationVersion;
|
||||||
|
|
||||||
|
@Column(name = "APPLICATION_EVALUATION_ID")
|
||||||
|
private Long applicationEvaluationId;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -68,4 +68,7 @@ public class ApplicationEvaluationEntity extends BaseEntity{
|
|||||||
@Column(name = "ACTIVE_DAYS")
|
@Column(name = "ACTIVE_DAYS")
|
||||||
private Long activeDays;
|
private Long activeDays;
|
||||||
|
|
||||||
|
@Column(name = "evaluationVersion")
|
||||||
|
private String evaluationVersion;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name = "APPLICATION_EVALUATION_FORM")
|
||||||
|
public class ApplicationEvaluationFormEntity extends BaseEntity{
|
||||||
|
private Long applicationId;
|
||||||
|
|
||||||
|
@Column(name="IS_DELETED")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "EVALUATION_ID")
|
||||||
|
private ApplicationEvaluationEntity applicationEvaluation;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "EVALUATION_FORM_ID")
|
||||||
|
private EvaluationFormEntity evaluationForm;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name = "APPLICATION_EVALUATION_FORM_FIELD")
|
||||||
|
public class ApplicationEvaluationFormFieldEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "APPLICATION_EVALUATION_FORM_ID")
|
||||||
|
private ApplicationEvaluationFormEntity applicationEvaluationForm;
|
||||||
|
|
||||||
|
@Column(name = "FIELD_ID")
|
||||||
|
private String fieldId;
|
||||||
|
|
||||||
|
@Column(name = "FIELD_VALUE")
|
||||||
|
private String fieldValue;
|
||||||
|
|
||||||
|
@Column(name="IS_DELETED")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -88,5 +88,14 @@ public class CallEntity extends BaseEntity {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "HUB_ID")
|
@JoinColumn(name = "HUB_ID")
|
||||||
private HubEntity hub;
|
private HubEntity hub;
|
||||||
|
|
||||||
|
@Column(name = "evaluationVersion")
|
||||||
|
private String evaluationVersion;
|
||||||
|
|
||||||
|
@Column(name = "NUMBER_OF_CHECK")
|
||||||
|
private Long numberOfCheck;
|
||||||
|
|
||||||
|
@Column(name = "PRODUCT_ID")
|
||||||
|
private Long productId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
@Entity
|
||||||
|
@Table(name = "EVALUATION_FORM")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class EvaluationFormEntity extends BaseEntity{
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "LABEL")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "CALL_ID")
|
||||||
|
private CallEntity call;
|
||||||
|
|
||||||
|
@Column(name = "CONTENT")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Column(name="IS_DELETED")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
}
|
||||||
@@ -63,4 +63,7 @@ public class HubEntity extends BaseEntity{
|
|||||||
|
|
||||||
@Column(name = "AREA_CODE")
|
@Column(name = "AREA_CODE")
|
||||||
private String areaCode;
|
private String areaCode;
|
||||||
|
|
||||||
|
@Column(name = "EVALUATION_EXPIRATION_DAYS")
|
||||||
|
private Long evaluationExpirationDays;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name ="role_action_context")
|
||||||
|
public class RoleActionContextEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column(name = "action_context")
|
||||||
|
private String actionContext;
|
||||||
|
|
||||||
|
@Column(name = "role_id")
|
||||||
|
private Long roleId;
|
||||||
|
|
||||||
|
@Column(name="is_deleted")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
@Column(name = "is_viewed")
|
||||||
|
private Boolean isViewed;
|
||||||
|
|
||||||
|
@Column(name = "description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,6 +39,11 @@ public class SystemEmailTemplatesEntity extends BaseEntity {
|
|||||||
@Column(name = "email_scenario")
|
@Column(name = "email_scenario")
|
||||||
private String emailScenario;
|
private String emailScenario;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "HUB_ID")
|
||||||
|
private HubEntity hubEntity;
|
||||||
|
|
||||||
|
|
||||||
public enum SystemEmailTemplatesEntityTypeEnum {
|
public enum SystemEmailTemplatesEntityTypeEnum {
|
||||||
|
|
||||||
APPLICATION_SUBMISSION_TO_USER_AND_COMPANY("APPLICATION_SUBMISSION_TO_USER_AND_COMPANY"),
|
APPLICATION_SUBMISSION_TO_USER_AND_COMPANY("APPLICATION_SUBMISSION_TO_USER_AND_COMPANY"),
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
public enum AssignedApplicationEnum {
|
public enum AssignedApplicationEnum {
|
||||||
OPEN ("OPEN"),
|
OPEN ("OPEN"),
|
||||||
SOCCORSO("SOCCORSO"),
|
SOCCORSO("SOCCORSO"),
|
||||||
|
|
||||||
|
AWAITING("AWAITING"),
|
||||||
|
|
||||||
CLOSE("CLOSE");
|
CLOSE("CLOSE");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public enum EvaluationVersionEnum {
|
||||||
|
V1("V1"),
|
||||||
|
V2("V2");
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
EvaluationVersionEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public static EvaluationVersionEnum fromValue(String value) {
|
||||||
|
for (EvaluationVersionEnum b : EvaluationVersionEnum.values()) {
|
||||||
|
if (b.value.equals(value)) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||||
|
}
|
||||||
|
public static List<String> getStatusValues() {
|
||||||
|
return Arrays.stream(EvaluationVersionEnum.values())
|
||||||
|
.map(EvaluationVersionEnum::getValue)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum TimePeriodEnum {
|
||||||
|
|
||||||
|
LAST_WEEK ("LAST_WEEK"),
|
||||||
|
LAST_QUARTER("LAST_QUARTER"),
|
||||||
|
LAST_SEMESTER("LAST_SEMESTER"),
|
||||||
|
LAST_YEAR("LAST_YEAR");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
TimePeriodEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,11 @@ public enum UserActionContextEnum {
|
|||||||
GET_CALL("GET_CALL"),
|
GET_CALL("GET_CALL"),
|
||||||
DOWNLOAD_CALL_DOCUMENT("DOWNLOAD_CALL_DOCUMENT"),
|
DOWNLOAD_CALL_DOCUMENT("DOWNLOAD_CALL_DOCUMENT"),
|
||||||
|
|
||||||
|
|
||||||
|
/** Evaluation V2 call action context **/
|
||||||
|
EVALUATION_V2_CREATE_UPDATE_CALL_STEP_2("EVALUATION_V2_CREATE_UPDATE_CALL_STEP_2"),
|
||||||
|
|
||||||
|
|
||||||
/** user action context **/
|
/** user action context **/
|
||||||
CREATE_USER("CREATE_USER"),
|
CREATE_USER("CREATE_USER"),
|
||||||
USER_LOGIN("USER_LOGIN"),
|
USER_LOGIN("USER_LOGIN"),
|
||||||
@@ -30,6 +35,7 @@ public enum UserActionContextEnum {
|
|||||||
/** application action context **/
|
/** application action context **/
|
||||||
GET_APPLICATION("GET_APPLICATION"),
|
GET_APPLICATION("GET_APPLICATION"),
|
||||||
CREATE_UPDATE_APPLICATION_FORM("CREATE_UPDATE_APPLICATION_FORM"),
|
CREATE_UPDATE_APPLICATION_FORM("CREATE_UPDATE_APPLICATION_FORM"),
|
||||||
|
GET_APPLICATION_EVALUATION_VERSION("GET_APPLICATION_EVALUATION_VERSION"),
|
||||||
CREATE_APPLICATION("CREATE_APPLICATION"),
|
CREATE_APPLICATION("CREATE_APPLICATION"),
|
||||||
DELETE_APPLICATION("DELETE_APPLICATION"),
|
DELETE_APPLICATION("DELETE_APPLICATION"),
|
||||||
GET_ALL_APPLICATION("GET_ALL_APPLICATION"),
|
GET_ALL_APPLICATION("GET_ALL_APPLICATION"),
|
||||||
@@ -92,6 +98,8 @@ public enum UserActionContextEnum {
|
|||||||
CREATE_UPDATE_APPLICATION_EVALUATION("CREATE_UPDATE_APPLICATION_EVALUATION"),
|
CREATE_UPDATE_APPLICATION_EVALUATION("CREATE_UPDATE_APPLICATION_EVALUATION"),
|
||||||
GET_APPLICATION_EVALUATION("GET_APPLICATION_EVALUATION"),
|
GET_APPLICATION_EVALUATION("GET_APPLICATION_EVALUATION"),
|
||||||
DELETE_APPLICATION_EVALUATION("DELETE_APPLICATION_EVALUATION"),
|
DELETE_APPLICATION_EVALUATION("DELETE_APPLICATION_EVALUATION"),
|
||||||
|
CREATE_UPDATE_APPLICATION_EVALUATION_FORM("CREATE_UPDATE_APPLICATION_EVALUATION_FORM"),
|
||||||
|
GET_APPLICATION_EVALUATION_FORM("GET_APPLICATION_EVALUATION_FORM"),
|
||||||
|
|
||||||
/** Beneficiary Preferred Call action context **/
|
/** Beneficiary Preferred Call action context **/
|
||||||
CREATE_BENEFICIARY_PREFERRED_CALL("CREATE_BENEFICIARY_PREFERRED_CALL"),
|
CREATE_BENEFICIARY_PREFERRED_CALL("CREATE_BENEFICIARY_PREFERRED_CALL"),
|
||||||
@@ -104,6 +112,7 @@ public enum UserActionContextEnum {
|
|||||||
DELETE_ASSIGNED_APPLICATION("DELETE_ASSIGNED_APPLICATION"),
|
DELETE_ASSIGNED_APPLICATION("DELETE_ASSIGNED_APPLICATION"),
|
||||||
GET_ASSIGNED_APPLICATION("GET_ASSIGNED_APPLICATION"),
|
GET_ASSIGNED_APPLICATION("GET_ASSIGNED_APPLICATION"),
|
||||||
UPDATE_ASSIGNED_APPLICATION_DETAILS("UPDATE_ASSIGNED_APPLICATION_DETAILS"),
|
UPDATE_ASSIGNED_APPLICATION_DETAILS("UPDATE_ASSIGNED_APPLICATION_DETAILS"),
|
||||||
|
UPDATE_ASSIGNED_APPLICATION_STATUS("UPDATE_ASSIGNED_APPLICATION_STATUS"),
|
||||||
|
|
||||||
/** Assigned form field context **/
|
/** Assigned form field context **/
|
||||||
CREATE_FORM_FIELD("CREATE_FORM_FIELD"),
|
CREATE_FORM_FIELD("CREATE_FORM_FIELD"),
|
||||||
@@ -137,6 +146,10 @@ public enum UserActionContextEnum {
|
|||||||
GET_DASHBOARD_WIDGET_FOR_SUPER_ADMIN("GET_DASHBOARD_WIDGET_FOR_SUPER_ADMIN"),
|
GET_DASHBOARD_WIDGET_FOR_SUPER_ADMIN("GET_DASHBOARD_WIDGET_FOR_SUPER_ADMIN"),
|
||||||
GET_DASHBOARD_WIDGET_FOR_BENEFICIARY("GET_DASHBOARD_WIDGET_FOR_BENEFICIARY"),
|
GET_DASHBOARD_WIDGET_FOR_BENEFICIARY("GET_DASHBOARD_WIDGET_FOR_BENEFICIARY"),
|
||||||
GET_APPLICATION_DETAILS("GET_APPLICATION_DETAILS"),
|
GET_APPLICATION_DETAILS("GET_APPLICATION_DETAILS"),
|
||||||
|
GET_AMENDMENT_DETAILS("GET_AMENDMENT_DETAILS"),
|
||||||
|
GET_DASHBOARD_WIDGET_FOR_PRE_INSTRUCTOR("GET_DASHBOARD_WIDGET_FOR_PRE_INSTRUCTOR"),
|
||||||
|
GET_APPLICATION_DETAILS_FOR_EVALUATION("GET_APPLICATION_DETAILS_FOR_EVALUATION"),
|
||||||
|
GET_STATISTICS_PAGE_FOR_BENEFICIARY("GET_STATISTICS_PAGE_FOR_BENEFICIARY"),
|
||||||
|
|
||||||
/** Evaluation criteria action context **/
|
/** Evaluation criteria action context **/
|
||||||
GET_EVALUATION_CRITERIA("GET_EVALUATION_CRITERIA"),
|
GET_EVALUATION_CRITERIA("GET_EVALUATION_CRITERIA"),
|
||||||
@@ -164,7 +177,22 @@ public enum UserActionContextEnum {
|
|||||||
/** appointment action context **/
|
/** appointment action context **/
|
||||||
CHECK_OR_CREATE_NDG_CODE("CHECK_OR_CREATE_NDG_CODE"),
|
CHECK_OR_CREATE_NDG_CODE("CHECK_OR_CREATE_NDG_CODE"),
|
||||||
CREATE_APPOINTMENT("CREATE_APPOINTMENT"),
|
CREATE_APPOINTMENT("CREATE_APPOINTMENT"),
|
||||||
UPLOAD_DOCUMENT_TO_EXTERNAL_SYSTEM("UPLOAD_DOCUMENT_TO_EXTERNAL_SYSTEM");
|
UPLOAD_DOCUMENT_TO_EXTERNAL_SYSTEM("UPLOAD_DOCUMENT_TO_EXTERNAL_SYSTEM"),
|
||||||
|
|
||||||
|
GET_ALL_NOTIFICATION_BY_PAGINATION("GET_ALL_NOTIFICATION_BY_PAGINATION"),
|
||||||
|
GET_ALL_CALL_BY_PAGINATION("GET_ALL_CALL_BY_PAGINATION"),
|
||||||
|
GET_ALL_APPLICATION_BY_PAGINATION("GET_ALL_APPLICATION_BY_PAGINATION"),
|
||||||
|
|
||||||
|
|
||||||
|
/** Evaluation form action context **/
|
||||||
|
GET_EVALUATION_FORM("GET_EVALUATION_FORM"),
|
||||||
|
CREATE_EVALUATION_FORM("CREATE_EVALUATION_FORM"),
|
||||||
|
UPDATE_EVALUATION_FORM("UPDATE_EVALUATION_FORM"),
|
||||||
|
DELETE_EVALUATION_FORM("DELETE_EVALUATION_FORM"),
|
||||||
|
|
||||||
|
|
||||||
|
GET_USER_ACTION("GET_USER_ACTION"),
|
||||||
|
GET_ACTION_CONTEXT_LABELS("GET_ACTION_CONTEXT_LABELS");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusForEvaluation;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationEvaluationFormRequestBean {
|
||||||
|
private List<FieldRequest> files;
|
||||||
|
private List<EvaluationDocumentRequest> evaluationDocument;
|
||||||
|
private List<AmendmentDetailsRequest> amendmentDetails;
|
||||||
|
private String note;
|
||||||
|
private ApplicationStatusForEvaluation applicationStatus;
|
||||||
|
private List<ApplicationFormFieldRequestBean> formFields;
|
||||||
|
private String motivation;
|
||||||
|
private BigDecimal amountAccepted;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationPageableRequestBean {
|
||||||
|
|
||||||
|
private GlobalFilters globalFilters;
|
||||||
|
|
||||||
|
private Integer daysRange;
|
||||||
|
|
||||||
|
private List<ApplicationStatusTypeEnum> status;
|
||||||
|
}
|
||||||
@@ -6,5 +6,4 @@ import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
|||||||
@Data
|
@Data
|
||||||
public class AssignedApplicationsRequest {
|
public class AssignedApplicationsRequest {
|
||||||
private String note;
|
private String note;
|
||||||
private AssignedApplicationEnum status;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CallPageableRequestBean {
|
||||||
|
|
||||||
|
private GlobalFilters globalFilters;
|
||||||
|
|
||||||
|
private List<CallStatusEnum> status;
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CreateCallRequestStep1 {
|
public class CreateCallRequestStep1 {
|
||||||
@@ -23,6 +24,10 @@ public class CreateCallRequestStep1 {
|
|||||||
|
|
||||||
private BigDecimal amountMax;
|
private BigDecimal amountMax;
|
||||||
|
|
||||||
|
private Long numberOfCheck;
|
||||||
|
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
private List<LookUpDataReq> aimedTo;
|
private List<LookUpDataReq> aimedTo;
|
||||||
|
|
||||||
private String documentationRequested;
|
private String documentationRequested;
|
||||||
@@ -41,4 +46,5 @@ public class CreateCallRequestStep1 {
|
|||||||
|
|
||||||
private List<FaqReq> faq;
|
private List<FaqReq> faq;
|
||||||
|
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CreateCallRequestStep2EvaluationV2 {
|
||||||
|
|
||||||
|
private List<DocumentReq> docs;
|
||||||
|
|
||||||
|
private List<DocumentReq> images;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EvaluationFormRequest {
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
private List<ContentRequestBean> content;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GlobalFilters {
|
||||||
|
private Integer year;
|
||||||
|
|
||||||
|
private Integer page;
|
||||||
|
|
||||||
|
private String search;
|
||||||
|
|
||||||
|
private Integer limit;
|
||||||
|
|
||||||
|
private SortBy sortBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class NotificationRequestBean {
|
||||||
|
|
||||||
|
private GlobalFilters globalFilters;
|
||||||
|
|
||||||
|
private List<NotificationEnum> status;
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import java.time.LocalTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class UpdateCallRequestStep1 {
|
public class UpdateCallRequestStep1 {
|
||||||
@@ -40,4 +41,10 @@ public class UpdateCallRequestStep1 {
|
|||||||
|
|
||||||
private List<FaqReq> faq;
|
private List<FaqReq> faq;
|
||||||
|
|
||||||
|
private Long numberOfCheck;
|
||||||
|
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UpdateUserReqForBeneficiary {
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private String email;
|
||||||
|
private String phoneNumber;
|
||||||
|
private String organization;
|
||||||
|
private String address;
|
||||||
|
private String city;
|
||||||
|
private String country;
|
||||||
|
private LocalDateTime dateOfBirth;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ActionContextLabelResponse {
|
||||||
|
private Long id;
|
||||||
|
private UserActionContextEnum actionContext;
|
||||||
|
private Long roleId;
|
||||||
|
private Boolean isViewed;
|
||||||
|
private String description;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class AmendmentWidgetResponseBean {
|
||||||
|
|
||||||
|
private Long totalAmendments;
|
||||||
|
|
||||||
|
private Long waitingForResponseAmendments;
|
||||||
|
|
||||||
|
private Long responseReceivedAmendments;
|
||||||
|
|
||||||
|
private BigDecimal averageResponseDays;
|
||||||
|
|
||||||
|
private Long expiringRequestsIn48Hours;
|
||||||
|
|
||||||
|
private Long expiredAmendments;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationEvaluationFormFieldReponseBean extends BaseBean {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long applicationEvaluationFormId;
|
||||||
|
|
||||||
|
private String fieldId;
|
||||||
|
|
||||||
|
private Object fieldValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationEvaluationFormResponse {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long applicationId;
|
||||||
|
private ApplicationStatusTypeEnum applicationStatus;
|
||||||
|
private Long assignedApplicationId;
|
||||||
|
private String note;
|
||||||
|
private ApplicationEvaluationStatusTypeEnum status;
|
||||||
|
private Long minScore;
|
||||||
|
private ApplicationEvaluationFormResponseBean applicationEvaluationFormResponse;
|
||||||
|
private List<FieldResponse> files;
|
||||||
|
private List<EvaluationDocumentResponse> evaluationDocument;
|
||||||
|
private List<AmendmentDocumentResponseBean> amendmentDetails;
|
||||||
|
private LocalDateTime createdDate;
|
||||||
|
private LocalDateTime updatedDate;
|
||||||
|
private String beneficiary;
|
||||||
|
private Long assignedUserId;
|
||||||
|
private String assignedUserName;
|
||||||
|
private Long protocolNumber;
|
||||||
|
private String callName;
|
||||||
|
private String motivation;
|
||||||
|
private LocalDateTime submissionDate;
|
||||||
|
private LocalDateTime evaluationEndDate;
|
||||||
|
private LocalDateTime callEndDate;
|
||||||
|
private String companyName;
|
||||||
|
private LocalDateTime assignedAt;
|
||||||
|
private String ndg;
|
||||||
|
private String appointmentId;
|
||||||
|
private BigDecimal amountRequested;
|
||||||
|
private BigDecimal amountAccepted;
|
||||||
|
private LocalDateTime dateAccepted;
|
||||||
|
private LocalDateTime dateRejected;
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
|
private BigDecimal numberOfCheck;
|
||||||
|
private BigDecimal productId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationEvaluationFormResponseBean {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
private Long callId;
|
||||||
|
|
||||||
|
private List<ContentResponseBean> content;
|
||||||
|
|
||||||
|
private List<ApplicationEvaluationFormFieldReponseBean> formFields;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.model.response;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -43,4 +44,8 @@ public class ApplicationEvaluationResponse {
|
|||||||
private BigDecimal amountAccepted;
|
private BigDecimal amountAccepted;
|
||||||
private LocalDateTime dateAccepted;
|
private LocalDateTime dateAccepted;
|
||||||
private LocalDateTime dateRejected;
|
private LocalDateTime dateRejected;
|
||||||
|
private Long numberOfCheck;
|
||||||
|
private Long productId;
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationEvaluationVersionResponse {
|
||||||
|
private Long callId;
|
||||||
|
private Long companyId;
|
||||||
|
private Long applicationId;
|
||||||
|
private Long evaluationId;
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.gepafin.tendermanagement.model.response;
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationFormFieldResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationFormFieldResponseBean;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -49,4 +50,6 @@ public class ApplicationResponse{
|
|||||||
|
|
||||||
private LocalDateTime dateRejected;
|
private LocalDateTime dateRejected;
|
||||||
|
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class ApplicationToConsider {
|
||||||
|
|
||||||
|
public Long totalAssignedApplication;
|
||||||
|
|
||||||
|
private BigDecimal additionalApplicationPercentage;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class ApplicationWidget {
|
||||||
|
|
||||||
|
private Long submittedApplication;
|
||||||
|
|
||||||
|
private BigDecimal successRate;
|
||||||
|
|
||||||
|
private Long approvedApplication;
|
||||||
|
|
||||||
|
private BigDecimal totalAmountFinanced;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AssignedApplicationWidgetResponseBean {
|
||||||
|
private Long numberOfAssignedApplication;
|
||||||
|
private Long numberOfApplicationInAmendmentState;
|
||||||
|
private Long numberOfApplicationInCloseState;
|
||||||
|
private Long numberOfApplicationInOpenState;
|
||||||
|
private Long numberOfApplicationExpiringIn48Hours;
|
||||||
|
private BigDecimal averageEvaluationDays;
|
||||||
|
}
|
||||||
@@ -2,8 +2,10 @@ package net.gepafin.tendermanagement.model.response;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
import net.gepafin.tendermanagement.model.BaseBean;
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -22,6 +24,9 @@ public class AssignedApplicationsResponse extends BaseBean {
|
|||||||
private LocalDateTime callEndDate;
|
private LocalDateTime callEndDate;
|
||||||
private String companyName;
|
private String companyName;
|
||||||
private LocalDateTime evaluationEndDate;
|
private LocalDateTime evaluationEndDate;
|
||||||
|
private Long numberOfCheck;
|
||||||
|
private Long productId;
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class AverageEvaluationTime {
|
||||||
|
|
||||||
|
private BigDecimal averageEvlauationDaysRating;
|
||||||
|
|
||||||
|
private BigDecimal timeDifferenceFromAverage;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class BeneficiaryStatisticsResponseBean {
|
||||||
|
|
||||||
|
|
||||||
|
private ApplicationWidget applicationWidget;
|
||||||
|
|
||||||
|
private Map<String, Object> applicationWidgetBars;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.model.response;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -55,4 +56,10 @@ public class CallDetailsResponseBean {
|
|||||||
private LocalDateTime updatedDate;
|
private LocalDateTime updatedDate;
|
||||||
|
|
||||||
private Long preferredCallId;
|
private Long preferredCallId;
|
||||||
|
|
||||||
|
private Long numberOfCheck;
|
||||||
|
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
import net.gepafin.tendermanagement.util.DynamicLocalTimeSerializer;
|
import net.gepafin.tendermanagement.util.DynamicLocalTimeSerializer;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -49,6 +50,10 @@ public class CallResponse {
|
|||||||
|
|
||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
|
|
||||||
|
private Long numberOfCheck;
|
||||||
|
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
@JsonSerialize(using = DynamicLocalTimeSerializer.class)
|
@JsonSerialize(using = DynamicLocalTimeSerializer.class)
|
||||||
private LocalTime startTime;
|
private LocalTime startTime;
|
||||||
|
|
||||||
@@ -74,6 +79,8 @@ public class CallResponse {
|
|||||||
private String currentStep;
|
private String currentStep;
|
||||||
|
|
||||||
private Long preferredCallId;
|
private Long preferredCallId;
|
||||||
|
|
||||||
|
private EvaluationVersionEnum evaluationVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class EvaluatedApplication {
|
||||||
|
|
||||||
|
public Long evaluatedApplication;
|
||||||
|
|
||||||
|
private BigDecimal dailyAverage;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EvaluationFormResponseBean {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String callStatus;
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
private Long callId;
|
||||||
|
|
||||||
|
private List<ContentResponseBean> content;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GetAllAmendmentResponseBean {
|
||||||
|
private Long id;
|
||||||
|
private String callEmail;
|
||||||
|
private String note;
|
||||||
|
private Long responseDays;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private Boolean isSendNotification;
|
||||||
|
private Boolean isSendEmail;
|
||||||
|
private Long protocolNumber;
|
||||||
|
private String callName;
|
||||||
|
private String beneficiaryName;
|
||||||
|
private String companyName;
|
||||||
|
private String amendmentNotes;
|
||||||
|
private Long applicationId;
|
||||||
|
private Long applicationEvaluationId;
|
||||||
|
private LocalDateTime evaluationEndDate;
|
||||||
|
private LocalDateTime expirationDate;
|
||||||
|
private String internalNote;
|
||||||
|
private ApplicationAmendmentRequestEnum status;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PageableResponseBean<T> {
|
||||||
|
|
||||||
|
private T body;
|
||||||
|
private Long totalRecords;
|
||||||
|
private int currentPage;
|
||||||
|
private int totalPages;
|
||||||
|
private int pageSize;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class PreInstructorWidgetResponseBean {
|
||||||
|
|
||||||
|
private ApplicationToConsider assignedApplication;
|
||||||
|
|
||||||
|
private EvaluatedApplication evaluatedApplication;
|
||||||
|
|
||||||
|
private AverageEvaluationTime averageEvaluationDays;
|
||||||
|
|
||||||
|
private RescueInstructorInProgress amendmentInProgress;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class RescueInstructorInProgress {
|
||||||
|
|
||||||
|
private Long totalAmendmentInProgress;
|
||||||
|
|
||||||
|
private Long expiringToday;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SummaryPageResponseBean {
|
||||||
|
private String username;
|
||||||
|
private String email;
|
||||||
|
private String role;
|
||||||
|
private LocalDateTime lastLogin;
|
||||||
|
private LocalDateTime registrationDate;
|
||||||
|
private Long numberOfLoginAttempts;
|
||||||
|
private Long applicationsProcessed;
|
||||||
|
private List<UserActionResponseBean> userActions;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserActionResponseBean {
|
||||||
|
private Long id;
|
||||||
|
private Long userId;
|
||||||
|
private String actionType;
|
||||||
|
private String requestBody;
|
||||||
|
private Long loginAttemptId;
|
||||||
|
private String actionContext;
|
||||||
|
private String ipAddress;
|
||||||
|
private String methodType;
|
||||||
|
private Long hubId;
|
||||||
|
private String url;
|
||||||
|
private String response;
|
||||||
|
private LocalDateTime createdDate;
|
||||||
|
private LocalDateTime updatedDate;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.util;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SortBy {
|
||||||
|
|
||||||
|
String columnName;
|
||||||
|
Boolean sortDesc;
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -80,4 +82,72 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
|
|||||||
"AND a.endDate BETWEEN :startTime AND :endTime")
|
"AND a.endDate BETWEEN :startTime AND :endTime")
|
||||||
List<ApplicationAmendmentRequestEntity> findExpiringBetween(LocalDateTime startTime, LocalDateTime endTime);
|
List<ApplicationAmendmentRequestEntity> findExpiringBetween(LocalDateTime startTime, LocalDateTime endTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM ApplicationAmendmentRequestEntity a WHERE a.applicationId IN :applicationIds AND a.isDeleted = false")
|
||||||
|
Long countAmendmentsByApplicationIds(@Param("applicationIds") List<Long> applicationIds);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM ApplicationAmendmentRequestEntity a WHERE a.applicationId IN :applicationIds AND a.status = :status AND a.isDeleted = false")
|
||||||
|
Long countAmendmentsByApplicationIdsAndStatus(@Param("applicationIds") List<Long> applicationIds, @Param("status") String status);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT e
|
||||||
|
FROM ApplicationAmendmentRequestEntity e
|
||||||
|
WHERE e.applicationId IN :applicationIds
|
||||||
|
AND e.status IN :statuses
|
||||||
|
AND e.isDeleted = false
|
||||||
|
""")
|
||||||
|
List<ApplicationAmendmentRequestEntity> findAllByApplicationIdsAndStatuses(
|
||||||
|
@Param("applicationIds") List<Long> applicationIds,
|
||||||
|
@Param("statuses") List<String> statuses
|
||||||
|
);
|
||||||
|
List<ApplicationAmendmentRequestEntity> findAllByApplicationIdInAndStatusAndIsDeletedFalse(List<Long> applicationIds, String status);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT COALESCE(AVG(TIMESTAMPDIFF(DAY, a.startDate, a.closingDate)), 0)
|
||||||
|
FROM ApplicationAmendmentRequestEntity a
|
||||||
|
WHERE a.applicationId IN :applicationIds
|
||||||
|
AND a.status = :status
|
||||||
|
AND a.isDeleted = false
|
||||||
|
AND a.closingDate IS NOT NULL
|
||||||
|
""")
|
||||||
|
BigDecimal findAverageResponseDaysByApplicationIdsAndStatus(
|
||||||
|
@Param("applicationIds") List<Long> applicationIds,
|
||||||
|
@Param("status") String status
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@Query(value = """
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM {h-schema}application_amendment_request e
|
||||||
|
WHERE e.application_id IN :applicationIds
|
||||||
|
AND e.status IN :statuses
|
||||||
|
AND e.start_date + INTERVAL '1 DAY' * e.response_days <= :endDate
|
||||||
|
AND e.start_date + INTERVAL '1 DAY' * e.response_days >= :startDate
|
||||||
|
AND e.is_deleted = false
|
||||||
|
""", nativeQuery = true)
|
||||||
|
Long countExpiringRequestsIn48Hours(
|
||||||
|
@Param("applicationIds") List<Long> applicationIds,
|
||||||
|
@Param("statuses") List<String> statuses,
|
||||||
|
@Param("startDate") LocalDateTime startDate,
|
||||||
|
@Param("endDate") LocalDateTime endDate
|
||||||
|
);
|
||||||
|
@Query(value = """
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM {h-schema}application_amendment_request e
|
||||||
|
WHERE e.application_id IN :applicationIds
|
||||||
|
AND e.status IN :statuses
|
||||||
|
AND e.start_date + INTERVAL '1 DAY' * e.response_days >= :startOfDay
|
||||||
|
AND e.start_date + INTERVAL '1 DAY' * e.response_days < :endOfDay
|
||||||
|
AND e.is_deleted = false
|
||||||
|
""", nativeQuery = true)
|
||||||
|
Long countAmendmentsExpiringToday(
|
||||||
|
@Param("applicationIds") List<Long> applicationIds,
|
||||||
|
@Param("statuses") List<String> statuses,
|
||||||
|
@Param("startOfDay") LocalDateTime startOfDay,
|
||||||
|
@Param("endOfDay") LocalDateTime endOfDay
|
||||||
|
);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM ApplicationAmendmentRequestEntity a WHERE a.applicationId IN :applicationIds AND a.status IN :statuses AND a.isDeleted = false")
|
||||||
|
Long countAmendmentsByApplicationIds(@Param("applicationIds") List<Long> applicationIds, @Param("statuses") List<String> statuses);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationEvaluationFormFieldEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ApplicationEvaluationFormFieldRepository extends JpaRepository<ApplicationEvaluationFormFieldEntity,Long> {
|
||||||
|
@Query("SELECT f FROM ApplicationEvaluationFormFieldEntity f " +
|
||||||
|
"WHERE f.applicationEvaluationForm.id = :applicationEvaluationFormId " +
|
||||||
|
"AND f.isDeleted = false")
|
||||||
|
List<ApplicationEvaluationFormFieldEntity> findByApplicationEvaluationFormId(
|
||||||
|
@Param("applicationEvaluationFormId") Long applicationEvaluationFormId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationEvaluationFormEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ApplicationEvaluationFormRepository extends JpaRepository<ApplicationEvaluationFormEntity,Long> {
|
||||||
|
|
||||||
|
@Query("SELECT a FROM ApplicationEvaluationFormEntity a " +
|
||||||
|
"WHERE a.applicationEvaluation.id = :evaluationId " +
|
||||||
|
"AND a.evaluationForm.id = :evaluationFormId " +
|
||||||
|
"AND a.isDeleted = false")
|
||||||
|
ApplicationEvaluationFormEntity findByEvaluationIdAndEvaluationFormId(
|
||||||
|
@Param("evaluationId") Long evaluationId,
|
||||||
|
@Param("evaluationFormId") Long evaluationFormId);
|
||||||
|
|
||||||
|
ApplicationEvaluationFormEntity findByApplicationEvaluation_IdAndIsDeletedFalse(Long evaluationId);
|
||||||
|
}
|
||||||
@@ -21,6 +21,9 @@ public interface ApplicationEvaluationRepository extends JpaRepository<Applicati
|
|||||||
Optional<ApplicationEvaluationEntity> findByIdAndIsDeletedFalse(Long id);
|
Optional<ApplicationEvaluationEntity> findByIdAndIsDeletedFalse(Long id);
|
||||||
Optional<ApplicationEvaluationEntity> findByAssignedApplicationsEntity_IdAndIsDeletedFalse(Long assignedApplicationId);
|
Optional<ApplicationEvaluationEntity> findByAssignedApplicationsEntity_IdAndIsDeletedFalse(Long assignedApplicationId);
|
||||||
|
|
||||||
|
@Query("SELECT ae FROM ApplicationEvaluationEntity ae WHERE ae.assignedApplicationsEntity.id = :assignedApplicationId AND ae.isDeleted = false")
|
||||||
|
ApplicationEvaluationEntity findByAssignedApplicationsId(Long assignedApplicationId);
|
||||||
|
|
||||||
Optional<ApplicationEvaluationEntity> findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(Long applicationId, Long assignedApplicationId);
|
Optional<ApplicationEvaluationEntity> findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(Long applicationId, Long assignedApplicationId);
|
||||||
|
|
||||||
Optional<ApplicationEvaluationEntity> findFirstByIsDeletedFalseOrderByCreatedDateDesc();
|
Optional<ApplicationEvaluationEntity> findFirstByIsDeletedFalseOrderByCreatedDateDesc();
|
||||||
@@ -55,11 +58,22 @@ public interface ApplicationEvaluationRepository extends JpaRepository<Applicati
|
|||||||
WHERE e.applicationId IN :applicationIds
|
WHERE e.applicationId IN :applicationIds
|
||||||
AND FUNCTION('DATE', e.endDate) BETWEEN :startDate AND :endDate
|
AND FUNCTION('DATE', e.endDate) BETWEEN :startDate AND :endDate
|
||||||
AND e.isDeleted = false
|
AND e.isDeleted = false
|
||||||
|
AND e.status IN :statusList
|
||||||
""")
|
""")
|
||||||
Long countDueApplicationsBetween(
|
Long countDueApplicationsBetween(
|
||||||
@Param("applicationIds") List<Long> applicationIds,
|
@Param("applicationIds") List<Long> applicationIds,
|
||||||
@Param("startDate") LocalDate startDate,
|
@Param("startDate") LocalDate startDate,
|
||||||
@Param("endDate") LocalDate endDate
|
@Param("endDate") LocalDate endDate,
|
||||||
|
@Param("statusList") List<String> statusList
|
||||||
|
);
|
||||||
|
|
||||||
|
@Query("SELECT ae FROM ApplicationEvaluationEntity ae " +
|
||||||
|
"WHERE ae.isDeleted = false " +
|
||||||
|
"AND (:applicationId IS NULL OR ae.applicationId = :applicationId) " +
|
||||||
|
"AND (:assignedApplicationId IS NULL OR ae.assignedApplicationsEntity.id = :assignedApplicationId)")
|
||||||
|
ApplicationEvaluationEntity findByApplicationIdAndAssignedApplicationId(
|
||||||
|
@Param("applicationId") Long applicationId,
|
||||||
|
@Param("assignedApplicationId") Long assignedApplicationId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import org.springframework.data.repository.query.Param;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -45,9 +47,25 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
|||||||
@Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id AND a.isDeleted = false")
|
@Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id AND a.isDeleted = false")
|
||||||
Long findCallIdById(@Param("id") Long id);
|
Long findCallIdById(@Param("id") Long id);
|
||||||
|
|
||||||
@Query("SELECT a.call.name, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.call.name")
|
// @Query(value = "SELECT c.name AS callName, " +
|
||||||
|
// "SUM(CASE WHEN a.status IN ('DISCARD', 'SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'APPOINTMENT', 'NDG', 'ADMISSIBLE', 'SUBMIT') THEN 1 ELSE 0 END) AS totalApplications, " +
|
||||||
|
// "SUM(CASE WHEN a.status IN ('DRAFT', 'AWAITING', 'READY') THEN 1 ELSE 0 END) AS draftApplications " +
|
||||||
|
// "FROM application a " +
|
||||||
|
// "JOIN call c ON a.call_id = c.id " +
|
||||||
|
// "WHERE a.is_deleted = false AND c.hub_id = :hubId " +
|
||||||
|
// "GROUP BY c.name", nativeQuery = true)
|
||||||
|
// List<Object[]> findApplicationsPerCallWithName(@Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
@Query(value = "SELECT c.name AS callName, " +
|
||||||
|
"SUM(CASE WHEN a.status IN ('DISCARD', 'SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'APPOINTMENT', 'NDG', 'ADMISSIBLE', 'SUBMIT') THEN 1 ELSE 0 END) AS totalApplications, " +
|
||||||
|
"SUM(CASE WHEN a.status IN ('DRAFT', 'AWAITING', 'READY') THEN 1 ELSE 0 END) AS draftApplications " +
|
||||||
|
"FROM ApplicationEntity a " +
|
||||||
|
"JOIN a.call c " +
|
||||||
|
"WHERE a.isDeleted = false AND c.hub.id = :hubId " +
|
||||||
|
"GROUP BY c.name")
|
||||||
List<Object[]> findApplicationsPerCallWithName(@Param("hubId") Long hubId);
|
List<Object[]> findApplicationsPerCallWithName(@Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
|
||||||
// Count Applications by Status by Hub ID
|
// Count Applications by Status by Hub ID
|
||||||
@Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.status")
|
@Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.status")
|
||||||
List<Object[]> findApplicationsByStatus(@Param("hubId") Long hubId);
|
List<Object[]> findApplicationsByStatus(@Param("hubId") Long hubId);
|
||||||
@@ -76,6 +94,17 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
|||||||
@Query("SELECT a.id FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.isDeleted = false")
|
@Query("SELECT a.id FROM ApplicationEntity a WHERE a.hubId = :hubId AND a.isDeleted = false")
|
||||||
List<Long> findApplicationIdsByHubId(@Param("hubId") Long hubId);
|
List<Long> findApplicationIdsByHubId(@Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
@Query("SELECT CASE WHEN COUNT(CASE WHEN a.submissionDate IS NOT NULL THEN 1 ELSE NULL END) > 0 THEN " +
|
||||||
|
"CAST((SUM(CASE WHEN a.status = 'APPROVED' THEN 1 ELSE 0 END) * 100.0) / " +
|
||||||
|
"COUNT(CASE WHEN a.submissionDate IS NOT NULL THEN 1 ELSE NULL END) AS BigDecimal) " +
|
||||||
|
"ELSE CAST(0 AS BigDecimal) END " +
|
||||||
|
"FROM ApplicationEntity a " +
|
||||||
|
"WHERE a.hubId = :hubId AND a.userId = :userId AND a.userWithCompany.id = :userWithCompanyId " +
|
||||||
|
"AND a.isDeleted = false")
|
||||||
|
BigDecimal findSuccessRateByHubIdAndUserIdAndUserWithCompanyId(
|
||||||
|
@Param("hubId") Long hubId,
|
||||||
|
@Param("userId") Long userId,
|
||||||
|
@Param("userWithCompanyId") Long userWithCompanyId);
|
||||||
|
|
||||||
|
|
||||||
@Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.userId = :userId AND a.userWithCompany.id = :userWithCompanyId AND a.call.hub.id = :hubId GROUP BY a.status")
|
@Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.userId = :userId AND a.userWithCompany.id = :userWithCompanyId AND a.call.hub.id = :hubId GROUP BY a.status")
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query;
|
|||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -20,6 +22,92 @@ public interface AssignedApplicationsRepository extends JpaRepository<AssignedAp
|
|||||||
@Param("applicationId") Long applicationId,
|
@Param("applicationId") Long applicationId,
|
||||||
@Param("id") Long id);
|
@Param("id") Long id);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(aa) FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false AND aa.userId = :userId AND aa.status <> 'CLOSE'")
|
||||||
|
Long countAssignedApplicationsByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
@Query("SELECT aa.application.id FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false AND aa.userId = :userId")
|
||||||
|
List<Long> findApplicationIdsByUserIdAndIsDeletedFalse(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM AssignedApplicationsEntity a WHERE a.application.id IN :applicationIds AND a.status IN :statuses AND a.isDeleted = false")
|
||||||
|
Long countAssignedApplicationsByApplicationIds(@Param("applicationIds") List<Long> applicationIds, @Param("statuses") List<String> statuses);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT COUNT(aa)
|
||||||
|
FROM AssignedApplicationsEntity aa
|
||||||
|
JOIN aa.application a
|
||||||
|
WHERE a.hubId = :hubId
|
||||||
|
AND a.isDeleted = false
|
||||||
|
AND aa.status IN :statuses
|
||||||
|
AND aa.createdDate >= :yesterday
|
||||||
|
AND aa.isDeleted = false
|
||||||
|
AND (:applicationIds IS NULL OR aa.application.id IN :applicationIds)
|
||||||
|
""")
|
||||||
|
Long countApplicationsAddedYesterdayForHub(@Param("applicationIds") List<Long> applicationIds, @Param("hubId") Long hubId, @Param("yesterday") LocalDateTime yesterday, @Param("statuses") List<String> statuses);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM AssignedApplicationsEntity a WHERE a.application.id IN :applicationIds AND a.status = :status AND a.isDeleted = false")
|
||||||
|
Long countApplicationsByIdsAndStatus(@Param("applicationIds") List<Long> applicationIds, @Param("status") String status);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT
|
||||||
|
COALESCE(COUNT(a.id), 0) AS totalAssigned,
|
||||||
|
COALESCE(SUM(CASE WHEN a.status = 'SOCCORSO' THEN 1 ELSE 0 END), 0) AS amendmentCount,
|
||||||
|
COALESCE(SUM(CASE WHEN a.status = 'OPEN' THEN 1 ELSE 0 END), 0) AS openCount,
|
||||||
|
COALESCE(SUM(CASE WHEN a.status = 'CLOSE' THEN 1 ELSE 0 END), 0) AS closeCount
|
||||||
|
FROM AssignedApplicationsEntity a
|
||||||
|
JOIN a.application app
|
||||||
|
WHERE a.isDeleted = false
|
||||||
|
AND a.userId = :userId
|
||||||
|
AND app.isDeleted = false
|
||||||
|
AND app.hubId = :hubId
|
||||||
|
""")
|
||||||
|
Object[] countAssignedApplicationsWithStatus(
|
||||||
|
@Param("userId") Long userId,
|
||||||
|
@Param("hubId") Long hubId
|
||||||
|
);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT
|
||||||
|
COALESCE(COUNT(a.id), 0) AS totalAssigned,
|
||||||
|
COALESCE(SUM(CASE WHEN a.status = 'SOCCORSO' THEN 1 ELSE 0 END), 0) AS amendmentCount,
|
||||||
|
COALESCE(SUM(CASE WHEN a.status = 'OPEN' THEN 1 ELSE 0 END), 0) AS openCount,
|
||||||
|
COALESCE(SUM(CASE WHEN a.status = 'CLOSE' THEN 1 ELSE 0 END), 0) AS closeCount
|
||||||
|
FROM AssignedApplicationsEntity a
|
||||||
|
JOIN a.application app
|
||||||
|
WHERE a.isDeleted = false
|
||||||
|
AND app.isDeleted = false
|
||||||
|
AND app.hubId = :hubId
|
||||||
|
""")
|
||||||
|
Object[] countAssignedApplicationsForHub(@Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
@Query("SELECT aa.application.id FROM AssignedApplicationsEntity aa " +
|
||||||
|
"WHERE aa.userId = :userId AND aa.application.hubId = :hubId AND aa.isDeleted = false")
|
||||||
|
List<Long> findApplicationIdsByUserIdAndHubIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
@Query("SELECT aa.application.id FROM AssignedApplicationsEntity aa " +
|
||||||
|
"WHERE aa.application.hubId = :hubId AND aa.isDeleted = false")
|
||||||
|
List<Long> findApplicationIdsByHubId(@Param("hubId") Long hubId);
|
||||||
|
@Query(" SELECT COUNT(aa) FROM AssignedApplicationsEntity aa " +
|
||||||
|
"JOIN aa.application a " +
|
||||||
|
"WHERE a.status IN :statuses " +
|
||||||
|
"AND a.isDeleted = false " +
|
||||||
|
"AND a.updatedDate >= :sevenDaysAgo " +
|
||||||
|
"AND aa.status = 'CLOSE'" +
|
||||||
|
"AND aa.isDeleted = false " +
|
||||||
|
" AND (:applicationIds IS NULL OR aa.application.id IN :applicationIds) ")
|
||||||
|
Long countEvaluatedApplicationsInLast7Days(@Param("applicationIds") List<Long> applicationIds,
|
||||||
|
@Param("statuses") List<String> statuses,
|
||||||
|
@Param("sevenDaysAgo") LocalDateTime sevenDaysAgo);
|
||||||
|
@Query("SELECT (COUNT(a) / 7.0) FROM AssignedApplicationsEntity aa " +
|
||||||
|
"JOIN aa.application a " +
|
||||||
|
"WHERE a.status IN :statuses " +
|
||||||
|
"AND a.isDeleted = false " +
|
||||||
|
"AND a.updatedDate >= :sevenDaysAgo " +
|
||||||
|
"AND aa.status = 'CLOSE'" +
|
||||||
|
"AND aa.isDeleted = false " +
|
||||||
|
"AND (:applicationIds IS NULL OR aa.application.id IN :applicationIds)")
|
||||||
|
BigDecimal countDailyAverageEvaluatedApplicationsInLast7Days(@Param("applicationIds") List<Long> applicationIds,
|
||||||
|
@Param("statuses") List<String> statuses,
|
||||||
|
@Param("sevenDaysAgo") LocalDateTime sevenDaysAgo);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -9,7 +10,7 @@ import java.math.BigDecimal;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CallRepository extends JpaRepository<CallEntity, Long> {
|
public interface CallRepository extends JpaRepository<CallEntity, Long>, JpaSpecificationExecutor<CallEntity> {
|
||||||
|
|
||||||
// public CallEntity findByIdAndStatusNotIn(Long id, List<String> status);
|
// public CallEntity findByIdAndStatusNotIn(Long id, List<String> status);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.EvaluationFormEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
@Repository
|
||||||
|
public interface EvaluationFormRepository extends JpaRepository<EvaluationFormEntity,Long> {
|
||||||
|
|
||||||
|
EvaluationFormEntity findByCallIdAndIsDeletedFalse(Long callId);
|
||||||
|
EvaluationFormEntity findByIdAndIsDeletedFalse(Long formId);
|
||||||
|
List<EvaluationFormEntity> findByIdInAndIsDeletedFalse(List<Long> evaluationFormId);
|
||||||
|
}
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.NotificationEntity;
|
import net.gepafin.tendermanagement.entities.NotificationEntity;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface NotificationRepository extends JpaRepository<NotificationEntity, Long> {
|
public interface NotificationRepository extends JpaRepository<NotificationEntity, Long> , JpaSpecificationExecutor<NotificationEntity> {
|
||||||
|
|
||||||
NotificationEntity findByIdAndIsDeletedFalse(Long id);
|
NotificationEntity findByIdAndIsDeletedFalse(Long id);
|
||||||
|
|
||||||
@@ -17,4 +23,5 @@ public interface NotificationRepository extends JpaRepository<NotificationEntity
|
|||||||
List<NotificationEntity> findByUserIdAndIsDeletedFalseAndStatusIn(Long userId, List<String> statuses);
|
List<NotificationEntity> findByUserIdAndIsDeletedFalseAndStatusIn(Long userId, List<String> statuses);
|
||||||
|
|
||||||
List<NotificationEntity> findByUserWithCompanyIdAndUserIdAndIsDeletedFalse(Long userWithCompanyId, Long userId);
|
List<NotificationEntity> findByUserWithCompanyIdAndUserIdAndIsDeletedFalse(Long userWithCompanyId, Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.RoleActionContextEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface RoleActionContextRepository extends JpaRepository<RoleActionContextEntity,Long>, JpaSpecificationExecutor<RoleActionContextEntity> {
|
||||||
|
|
||||||
|
@Query("SELECT r FROM RoleActionContextEntity r WHERE r.roleId = :roleId AND r.isDeleted = false AND r.isViewed = true")
|
||||||
|
List<RoleActionContextEntity> findActionContextLabel(@Param("roleId") Long roleId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,4 +14,7 @@ public interface SystemEmailTemplatesRespository extends JpaRepository<SystemEma
|
|||||||
@Query("select s from SystemEmailTemplatesEntity s where s.type=:type and s.isDeleted =false and s.system = true")
|
@Query("select s from SystemEmailTemplatesEntity s where s.type=:type and s.isDeleted =false and s.system = true")
|
||||||
SystemEmailTemplatesEntity findByType(@Param("type") String type);
|
SystemEmailTemplatesEntity findByType(@Param("type") String type);
|
||||||
|
|
||||||
|
@Query("select s from SystemEmailTemplatesEntity s where s.type=:type and s.hubEntity.id=:hubId and s.isDeleted =false and s.system = false")
|
||||||
|
SystemEmailTemplatesEntity findByTypeAndHubEntityId(@Param("type") String type, @Param("hubId") Long hubId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface UserActionsRepository extends JpaRepository<UserActionEntity, Long> {
|
public interface UserActionsRepository extends JpaRepository<UserActionEntity, Long> , JpaSpecificationExecutor<UserActionEntity> {
|
||||||
UserActionEntity findUserActionById(Long id);
|
UserActionEntity findUserActionById(Long id);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(u) FROM UserActionEntity u " +
|
||||||
|
"WHERE u.userId = :userId " +
|
||||||
|
"AND u.actionContext = 'USER_LOGIN' " +
|
||||||
|
"AND u.isDeleted = false")
|
||||||
|
Long countUserLoginAttempts(@Param("userId") Long userId);
|
||||||
|
|
||||||
UserActionEntity findUserActionByIdAndIsDeletedFalse(Long id);
|
UserActionEntity findUserActionByIdAndIsDeletedFalse(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
|||||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ public interface ApplicationAmendmentRequestService {
|
|||||||
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest);
|
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest);
|
||||||
void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id);
|
void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id);
|
||||||
ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
|
ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
|
||||||
List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId);
|
List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId);
|
||||||
ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
|
ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
|
||||||
ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId);
|
ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId);
|
||||||
List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,Long beneficiaryId);
|
List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,Long beneficiaryId);
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package net.gepafin.tendermanagement.service;
|
|||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationFormRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -21,4 +24,10 @@ public interface ApplicationEvaluationService {
|
|||||||
|
|
||||||
ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId);
|
ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId);
|
||||||
|
|
||||||
|
ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long evaluationId, Long evaluationFormId);
|
||||||
|
|
||||||
|
ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId);
|
||||||
|
|
||||||
|
ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,17 @@ package net.gepafin.tendermanagement.service;
|
|||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResponse;
|
|
||||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
public interface ApplicationService {
|
public interface ApplicationService {
|
||||||
@@ -41,5 +40,9 @@ public interface ApplicationService {
|
|||||||
public void deleteSignedDocument(HttpServletRequest request, Long applicationId);
|
public void deleteSignedDocument(HttpServletRequest request, Long applicationId);
|
||||||
|
|
||||||
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId);
|
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId);
|
||||||
|
|
||||||
byte[] downloadApplicationDocumentsAsZip(HttpServletRequest request, Long applicationId);
|
byte[] downloadApplicationDocumentsAsZip(HttpServletRequest request, Long applicationId);
|
||||||
}
|
|
||||||
|
PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(HttpServletRequest request, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean);
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package net.gepafin.tendermanagement.service;
|
|||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||||
@@ -15,8 +17,9 @@ public interface AssignedApplicationsService {
|
|||||||
|
|
||||||
void deleteApplication(HttpServletRequest request, Long id);
|
void deleteApplication(HttpServletRequest request, Long id);
|
||||||
|
|
||||||
List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId);
|
List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId,List<AssignedApplicationEnum> statusList);
|
||||||
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, UpdateAssignedApplicationRequest assignedApplicationsRequest);
|
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, UpdateAssignedApplicationRequest assignedApplicationsRequest);
|
||||||
AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id);
|
AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id);
|
||||||
AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId);
|
AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId);
|
||||||
|
AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ import java.util.List;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
|
||||||
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
|
|
||||||
public interface CallService {
|
public interface CallService {
|
||||||
|
|
||||||
CallResponse createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest);
|
CallResponse createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest );
|
||||||
|
|
||||||
CallResponse createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest);
|
CallResponse createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest);
|
||||||
|
|
||||||
@@ -30,5 +30,11 @@ public interface CallService {
|
|||||||
CallEntity validateCall(Long callId);
|
CallEntity validateCall(Long callId);
|
||||||
|
|
||||||
CallEntity validatePublishedCall(Long callId, Long hubId);
|
CallEntity validatePublishedCall(Long callId, Long hubId);
|
||||||
|
|
||||||
byte[] downloadCallDocumentsAsZip(HttpServletRequest request, Long callId);
|
byte[] downloadCallDocumentsAsZip(HttpServletRequest request, Long callId);
|
||||||
|
|
||||||
|
PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request, Long companyId , Boolean onlyPreferredCall,CallPageableRequestBean callPageableRequestBean);
|
||||||
|
|
||||||
|
CallResponse createCallStep2EvaluationV2(HttpServletRequest request, Long callId, CreateCallRequestStep2EvaluationV2 createCallRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package net.gepafin.tendermanagement.service;
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
|
import net.gepafin.tendermanagement.model.response.AmendmentWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationWidgetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationWidgetResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.AssignedApplicationWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
|
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
|
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
|
||||||
|
|
||||||
@@ -11,4 +14,10 @@ public interface DashboardService {
|
|||||||
|
|
||||||
public BeneficiaryWidgetResponseBean getDashboardWidgetForBeneficiary(HttpServletRequest request, Long companyId);
|
public BeneficiaryWidgetResponseBean getDashboardWidgetForBeneficiary(HttpServletRequest request, Long companyId);
|
||||||
public ApplicationWidgetResponseBean getApplicationDetails(HttpServletRequest request);
|
public ApplicationWidgetResponseBean getApplicationDetails(HttpServletRequest request);
|
||||||
|
public AmendmentWidgetResponseBean getAmendmentDetails(HttpServletRequest request);
|
||||||
|
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(HttpServletRequest request,Long userId);
|
||||||
|
public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(HttpServletRequest request);
|
||||||
|
|
||||||
|
public BeneficiaryStatisticsResponseBean getStatisticsPageForBeneficiary(HttpServletRequest request,Long companyId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.EvaluationFormEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.FormEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBean;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EvaluationFormRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.EvaluationFormResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.FormResponseBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface EvaluationFormService {
|
||||||
|
|
||||||
|
public EvaluationFormResponseBean createEvaluationForm(HttpServletRequest request, Long callId, EvaluationFormRequest formRequest);
|
||||||
|
|
||||||
|
public EvaluationFormResponseBean updateEvaluationForm(HttpServletRequest request, Long evaluationFormId, EvaluationFormRequest formRequest);
|
||||||
|
|
||||||
|
public EvaluationFormResponseBean getEvaluationFormById(HttpServletRequest request, Long evaluationFormId);
|
||||||
|
|
||||||
|
public void deleteEvaluationForm(HttpServletRequest request, Long evaluationFormId);
|
||||||
|
|
||||||
|
public EvaluationFormEntity validateEvaluationForm(Long id);
|
||||||
|
|
||||||
|
public EvaluationFormResponseBean getEvaluationFormByCallId(HttpServletRequest request, Long callId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,8 +2,12 @@ package net.gepafin.tendermanagement.service;
|
|||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||||
|
import net.gepafin.tendermanagement.model.request.NotificationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -20,4 +24,5 @@ public interface NotificationService {
|
|||||||
|
|
||||||
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses);
|
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses);
|
||||||
|
|
||||||
|
PageableResponseBean<List<NotificationResponse>> getAllNotification(HttpServletRequest request,Long userId, NotificationRequestBean notificationRequestBean);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UserActionService {
|
||||||
|
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext);
|
||||||
|
|
||||||
|
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, Long userId);
|
||||||
|
}
|
||||||
@@ -47,4 +47,6 @@ public interface UserService {
|
|||||||
public UserEntity getUserEntityById(Long userId);
|
public UserEntity getUserEntityById(Long userId);
|
||||||
List<UserResponseBean> getAllUsers(HttpServletRequest request, List<Long> roleIds);
|
List<UserResponseBean> getAllUsers(HttpServletRequest request, List<Long> roleIds);
|
||||||
|
|
||||||
|
UserResponseBean updateUserDetails(HttpServletRequest request, Long userId, UpdateUserReqForBeneficiary userReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
|||||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||||
@@ -83,8 +84,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) {
|
public List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
||||||
UserEntity user = validator.validatePreInstructor(request, userId);
|
|
||||||
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest(request,userId);
|
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest(request,userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,18 @@ package net.gepafin.tendermanagement.service.impl;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.dao.ApplicationEvaluationDao;
|
import net.gepafin.tendermanagement.dao.ApplicationEvaluationDao;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationFormRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationFormResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationVersionResponse;
|
||||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||||
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -34,6 +37,9 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationService applicationEvaluationService;
|
private ApplicationEvaluationService applicationEvaluationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationService applicationService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
|
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
|
||||||
@@ -78,4 +84,27 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
|||||||
return applicationEvaluationDao.validateApplicationEvaluationByApplicationId(applicationId);
|
return applicationEvaluationDao.validateApplicationEvaluationByApplicationId(applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long assignedApplicationId, Long evaluationFormId) {
|
||||||
|
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
||||||
|
validator.validatePreInstructor(request, assignedApplicationsEntity.getUserId());
|
||||||
|
return applicationEvaluationDao.createApplicationEvaluation(request,applicationEvaluationFormRequestBean,evaluationFormId,assignedApplicationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||||
|
validator.validateUser(request);
|
||||||
|
return applicationEvaluationDao.getApplicationEvaluationForm(request,applicationId,assignedApplicationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId) {
|
||||||
|
validator.validateUser(request);
|
||||||
|
return applicationEvaluationDao.getApplicationEvaluationVersion(request,applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,12 @@ import net.gepafin.tendermanagement.dao.FlowFormDao;
|
|||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResponse;
|
|
||||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
@@ -129,4 +126,13 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
return applicationDao.downloadApplicationDocumentsAsZip(request,applicationId);
|
return applicationDao.downloadApplicationDocumentsAsZip(request,applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(HttpServletRequest request, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
if (companyId != null) {
|
||||||
|
validator.validateUserWithCompany(request, companyId);
|
||||||
|
}
|
||||||
|
return applicationDao.getAllApplicationByPagination(userEntity,callId,companyId,applicationPageableRequestBean);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
import net.gepafin.tendermanagement.dao.AssignedApplicationsDao;
|
import net.gepafin.tendermanagement.dao.AssignedApplicationsDao;
|
||||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||||
@@ -40,8 +42,8 @@ public class AssignedApplicationsServiceImpl implements AssignedApplicationsServ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId) {
|
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId,List<AssignedApplicationEnum> statusList) {
|
||||||
return assignedApplicationsDao.getAllAssignedApplications(request, userId);
|
return assignedApplicationsDao.getAllAssignedApplications(request, userId,statusList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,5 +62,8 @@ public class AssignedApplicationsServiceImpl implements AssignedApplicationsServ
|
|||||||
public AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId) {
|
public AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId) {
|
||||||
return assignedApplicationsDao.validateAssignedApplication(assignedApplicationId);
|
return assignedApplicationsDao.validateAssignedApplication(assignedApplicationId);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status) {
|
||||||
|
return assignedApplicationsDao.updateAssignedApplicationStatus(request, assignedApplicationId, status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import net.gepafin.tendermanagement.dao.CallDao;
|
|||||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
|
||||||
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
import net.gepafin.tendermanagement.service.CallService;
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
|
||||||
@@ -103,4 +103,16 @@ public class CallServiceImpl implements CallService {
|
|||||||
return callDao.downloadCallDocumentsAsZip(callId);
|
return callDao.downloadCallDocumentsAsZip(callId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,Long companyId , Boolean onlyPreferredCall, CallPageableRequestBean callPageableRequestBean) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
return callDao.getAllCallsByPagination(request,user,companyId,onlyPreferredCall,callPageableRequestBean);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CallResponse createCallStep2EvaluationV2(HttpServletRequest request, Long callId, CreateCallRequestStep2EvaluationV2 createCallRequest) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
CallEntity call = validator.validateUserWithCall(user, callId);
|
||||||
|
return callDao.createCallStep2EvaluationV2(call, createCallRequest, user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,16 +6,15 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.model.response.FormResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
public class CallValidatorServiceImpl {
|
public class CallValidatorServiceImpl {
|
||||||
public static void validateResponse(CallResponse response, FlowResponseBean flowResponse, List<FormResponseBean> formResponses) {
|
public static void validateResponse(CallResponse response, FlowResponseBean flowResponse, List<FormResponseBean> formResponses, EvaluationFormResponseBean evaluationFormResponseBean) {
|
||||||
// Validate CallResponse (existing logic)
|
// Validate CallResponse (existing logic)
|
||||||
FieldValidator data = FieldValidator.create()
|
FieldValidator data = FieldValidator.create()
|
||||||
.notNull(response.getId(), "id")
|
.notNull(response.getId(), "id")
|
||||||
@@ -28,31 +27,65 @@ public class CallValidatorServiceImpl {
|
|||||||
.notNull(response.getRegionId(), "regionId")
|
.notNull(response.getRegionId(), "regionId")
|
||||||
.notNull(response.getAmount(), "amount")
|
.notNull(response.getAmount(), "amount")
|
||||||
.notNull(response.getAmountMax(), "amountMax")
|
.notNull(response.getAmountMax(), "amountMax")
|
||||||
.notNull(response.getThreshold(), "threshold")
|
|
||||||
.notNull(response.getEmail(),"email")
|
.notNull(response.getEmail(),"email")
|
||||||
.notNull(response.getAmountMin(),"amountMin")
|
.notNull(response.getAmountMin(),"amountMin")
|
||||||
.notNull(response.getStartTime(),"startTime")
|
.notNull(response.getStartTime(),"startTime")
|
||||||
.notNull(response.getEndTime(),"endTime")
|
.notNull(response.getEndTime(),"endTime")
|
||||||
.notNull(response.getDocumentationRequested(), "documentationRequested")
|
.notNull(response.getDocumentationRequested(), "documentationRequested")
|
||||||
.notEmpty(response.getAimedTo(), "aimedTo")
|
.notEmpty(response.getAimedTo(), "aimedTo")
|
||||||
|
.notEmpty(response.getDocs(), "docs");
|
||||||
|
if (response.getEvaluationVersion() == EvaluationVersionEnum.V1) {
|
||||||
|
|
||||||
|
data = data.notEmpty(response.getCheckList(), "checkList")
|
||||||
.notEmpty(response.getCriteria(), "criteria")
|
.notEmpty(response.getCriteria(), "criteria")
|
||||||
.notEmpty(response.getDocs(), "docs")
|
.notNull(response.getThreshold(), "threshold");
|
||||||
.notEmpty(response.getCheckList(), "checkList");
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (response.getEvaluationVersion() == EvaluationVersionEnum.V2 && evaluationFormResponseBean == null) {
|
||||||
|
data.addError(Translator.toLocale(GepafinConstant.EVALUATION_FORM_NOT_FOUND));
|
||||||
|
}
|
||||||
if (response.getDates().get(0) == null || response.getDates().get(1) == null
|
if (response.getDates().get(0) == null || response.getDates().get(1) == null
|
||||||
|| response.getDates().get(0).toLocalDate().isBefore(LocalDate.now())
|
|| response.getDates().get(0).toLocalDate().isBefore(LocalDate.now())
|
||||||
|| response.getDates().get(1).toLocalDate().isBefore(LocalDate.now())
|
|| response.getDates().get(1).toLocalDate().isBefore(LocalDate.now())
|
||||||
|| response.getDates().get(0).toLocalDate().isAfter(response.getDates().get(1).toLocalDate())) {
|
|| response.getDates().get(0).toLocalDate().isAfter(response.getDates().get(1).toLocalDate())) {
|
||||||
data = data.addError(Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
data = data.addError(Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||||
}
|
}
|
||||||
if (flowResponse == null || ((flowResponse.getFlowData() == null || flowResponse.getFlowData().isEmpty())
|
|
||||||
&& (flowResponse.getFlowEdges() == null || flowResponse.getFlowEdges().isEmpty()))) {
|
if (flowResponse == null || ((flowResponse.getFlowData() == null || flowResponse.getFlowData().isEmpty()))
|
||||||
|
&& (flowResponse.getFlowEdges() == null || flowResponse.getFlowEdges().isEmpty())) {
|
||||||
data.addError(Translator.toLocale(GepafinConstant.FLOW_NOT_FOUND));
|
data.addError(Translator.toLocale(GepafinConstant.FLOW_NOT_FOUND));
|
||||||
}
|
}
|
||||||
if (formResponses == null || formResponses.isEmpty()) {
|
if (formResponses == null || formResponses.isEmpty()) {
|
||||||
data.addError(Translator.toLocale(GepafinConstant.FORM_NOT_FOUND));
|
data.addError(Translator.toLocale(GepafinConstant.FORM_NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
boolean isAmountRequestedValid = false;
|
||||||
|
if (formResponses != null && !formResponses.isEmpty()) {
|
||||||
|
outerloop:
|
||||||
|
for (FormResponseBean formResponse : formResponses) {
|
||||||
|
|
||||||
|
if (formResponse.getContent() != null && !formResponse.getContent().isEmpty()) {
|
||||||
|
for (ContentResponseBean content : formResponse.getContent()) {
|
||||||
|
if ("numberinput".equals(content.getName()) && content.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : content.getSettings()) {
|
||||||
|
if ("isRequestedAmount".equals(setting.getName())) {
|
||||||
|
Object value = setting.getValue();
|
||||||
|
if (Boolean.TRUE.equals(value)) {
|
||||||
|
isAmountRequestedValid = true;
|
||||||
|
break outerloop;
|
||||||
|
} else if (value == null) {
|
||||||
|
data.addError(Translator.toLocale(GepafinConstant.REQUIRED_REQUESTED_AMOUNT_MSG));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAmountRequestedValid) {
|
||||||
|
data.addError(Translator.toLocale(GepafinConstant.REQUIRED_REQUESTED_AMOUNT_MSG));
|
||||||
|
}
|
||||||
data.validate();
|
data.validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
import net.gepafin.tendermanagement.dao.DashboardDao;
|
import net.gepafin.tendermanagement.dao.DashboardDao;
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
|
import net.gepafin.tendermanagement.model.response.AmendmentWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationWidgetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationWidgetResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.AssignedApplicationWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
|
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
|
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.service.DashboardService;
|
import net.gepafin.tendermanagement.service.DashboardService;
|
||||||
@@ -39,4 +42,26 @@ public class DashboardServiceImpl implements DashboardService {
|
|||||||
UserEntity userEntity=validator.validateUser(request);
|
UserEntity userEntity=validator.validateUser(request);
|
||||||
return dashboardDao.getApplicationDetails(userEntity);
|
return dashboardDao.getApplicationDetails(userEntity);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public AmendmentWidgetResponseBean getAmendmentDetails(HttpServletRequest request) {
|
||||||
|
UserEntity userEntity=validator.validateUser(request);
|
||||||
|
return dashboardDao.getAmendmentDetails(userEntity);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(HttpServletRequest request,Long userId) {
|
||||||
|
validator.validateUser(request);
|
||||||
|
return dashboardDao.getDashboardWidgetForPreInstructor(request,userId);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(HttpServletRequest request) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
return dashboardDao.getApplicationDetailsForEvaluation(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BeneficiaryStatisticsResponseBean getStatisticsPageForBeneficiary(HttpServletRequest request, Long companyId) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
CompanyEntity company = validator.validateUserWithCompany(request, companyId);
|
||||||
|
return dashboardDao.getStatisticsPageForBeneficiary(userEntity,company);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.dao.EvaluationFormDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EvaluationFormRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.EvaluationFormResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.service.EvaluationFormService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EvaluationFormServiceImpl implements EvaluationFormService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationFormDao evalauationFormDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationFormResponseBean createEvaluationForm(HttpServletRequest request, Long callId, EvaluationFormRequest evaluationFormRequest) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
CallEntity call = validator.validateUserWithCall(user, callId);
|
||||||
|
return evalauationFormDao.createEvaluationForm(call,evaluationFormRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationFormResponseBean updateEvaluationForm(HttpServletRequest request, Long evaluationFormId, EvaluationFormRequest evaluationFormRequest) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
return evalauationFormDao.updateEvaluationForm(user, evaluationFormId,evaluationFormRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationFormResponseBean getEvaluationFormById(HttpServletRequest request, Long evaluationFormId) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
return evalauationFormDao.getEvaluationFormById(user, evaluationFormId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEvaluationForm(HttpServletRequest request, Long evaluationFormId) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
evalauationFormDao.deleteEvaluationForm(user, evaluationFormId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationFormEntity validateEvaluationForm(Long id) {
|
||||||
|
return evalauationFormDao.validateForm(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationFormResponseBean getEvaluationFormByCallId(HttpServletRequest request, Long callId) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
CallEntity call = validator.validateUserWithCall(user, callId);
|
||||||
|
return evalauationFormDao.getEvaluationFormByCallId(call);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.util.Validator;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ public class FormServiceImpl implements FormService {
|
|||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public FormResponseBean createForm(HttpServletRequest request,Long callId, FormRequest formRequest) {
|
public FormResponseBean createForm(HttpServletRequest request,Long callId, FormRequest formRequest) {
|
||||||
UserEntity user = validator.validateUser(request);
|
UserEntity user = validator.validateUser(request);
|
||||||
CallEntity call = validator.validateUserWithCall(user, callId);
|
CallEntity call = validator.validateUserWithCall(user, callId);
|
||||||
@@ -34,18 +36,21 @@ public class FormServiceImpl implements FormService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public FormResponseBean updateForm(HttpServletRequest request, Long formId, FormRequest formRequest,Boolean forceDeleteFlow) {
|
public FormResponseBean updateForm(HttpServletRequest request, Long formId, FormRequest formRequest,Boolean forceDeleteFlow) {
|
||||||
UserEntity user = validator.validateUser(request);
|
UserEntity user = validator.validateUser(request);
|
||||||
return formDao.updateForm(user, formId,formRequest,forceDeleteFlow);
|
return formDao.updateForm(user, formId,formRequest,forceDeleteFlow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public FormResponseBean getFormById(HttpServletRequest request, Long formId) {
|
public FormResponseBean getFormById(HttpServletRequest request, Long formId) {
|
||||||
UserEntity user = validator.validateUser(request);
|
UserEntity user = validator.validateUser(request);
|
||||||
return formDao.getFormEntityById(user, formId);
|
return formDao.getFormEntityById(user, formId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteForm(HttpServletRequest request, Long formId) {
|
public void deleteForm(HttpServletRequest request, Long formId) {
|
||||||
UserEntity user = validator.validateUser(request);
|
UserEntity user = validator.validateUser(request);
|
||||||
formDao.deleteFormById(user, formId);
|
formDao.deleteFormById(user, formId);
|
||||||
@@ -57,6 +62,7 @@ public class FormServiceImpl implements FormService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public List<FormResponseBean> getFormsByCallId(HttpServletRequest request, Long callId) {
|
public List<FormResponseBean> getFormsByCallId(HttpServletRequest request, Long callId) {
|
||||||
UserEntity user = validator.validateUser(request);
|
UserEntity user = validator.validateUser(request);
|
||||||
CallEntity call = validator.validateUserWithCall(user, callId);
|
CallEntity call = validator.validateUserWithCall(user, callId);
|
||||||
|
|||||||
@@ -3,11 +3,17 @@ package net.gepafin.tendermanagement.service.impl;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||||
|
import net.gepafin.tendermanagement.model.request.NotificationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||||
import net.gepafin.tendermanagement.service.NotificationService;
|
import net.gepafin.tendermanagement.service.NotificationService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -21,6 +27,9 @@ public class NotificationServiceImpl implements NotificationService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private NotificationDao notificationDao;
|
private NotificationDao notificationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId) {
|
public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId) {
|
||||||
|
|
||||||
@@ -59,4 +68,10 @@ public class NotificationServiceImpl implements NotificationService {
|
|||||||
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses) {
|
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses) {
|
||||||
return notificationDao.getNotificationByCompanyIdAndUserId(userId, companyId, statuses);
|
return notificationDao.getNotificationByCompanyIdAndUserId(userId, companyId, statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageableResponseBean<List<NotificationResponse>> getAllNotification(HttpServletRequest request, Long userId, NotificationRequestBean notificationRequestBean) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
return notificationDao.getAllNotification(userId,notificationRequestBean);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.dao.UserActionDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.service.UserActionService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserActionServiceImpl implements UserActionService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserActionDao userActionDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext) {
|
||||||
|
UserEntity user = validator.validateUserId(request, userId);
|
||||||
|
return userActionDao.getUserAction(request,user,timeFilter,actionContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, Long userId) {
|
||||||
|
UserEntity user = validator.validateUserId(request, userId);
|
||||||
|
return userActionDao.getActionContextLabels(request,user);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user