Implemented new email sending flow for type BLUE TONGUE

This commit is contained in:
rajesh
2026-02-23 12:53:06 +05:30
parent 822917a16c
commit ccef97b0ac
14 changed files with 96 additions and 17 deletions

View File

@@ -636,6 +636,7 @@ public class GepafinConstant {
public static final String APPLICATION_AMENDMENT_APPROPIATE_STATUS="amendment.appropiate.status";
public static final String UPLOAD_COMPANY_DOCUMENT_TO_APPLICATION_MSG="upload.company.document.to.application";
public static final String COMPANY_DOCUMENT_NOT_FOUND_WITH_IDS="company.document.not.found.with.ids";
public static final String REQUIRED_AMOUNT_FIELD_NOT_PROVIDED = "amount.field.not.provided";
}

View File

@@ -1859,6 +1859,11 @@ public class ApplicationAmendmentRequestDao {
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(applicationEvaluationEntity);
ApplicationEntity applicationEntity=applicationDao.validateApplication(applicationEvaluationEntity.getApplicationId());
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
if(Boolean.TRUE.equals(applicationAmendmentRequest.getAmendmentDocumentType().equals(AmendmentDocumentTypeEnum.BLUE_TONGUE))) {
if(applicationAmendmentRequest.getBlueTongueField1()==null || applicationAmendmentRequest.getBlueTongueField2()==null){
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.REQUIRED_AMOUNT_FIELD_NOT_PROVIDED));
}
}
if(Boolean.FALSE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.ADMISSIBLE.getValue()))) {
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.INVALID_APPLICATION_STATUS));
@@ -1922,6 +1927,8 @@ public class ApplicationAmendmentRequestDao {
protocolDao.saveProtocolEntity(protocolEntity);
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
applicationAmendmentRequestEntity.setAmendmentDocumentType(applicationAmendmentRequest.getAmendmentDocumentType().getValue());
applicationAmendmentRequestEntity.setBlueTongueField1(applicationAmendmentRequest.getBlueTongueField1());
applicationAmendmentRequestEntity.setBlueTongueField2(applicationAmendmentRequest.getBlueTongueField2());
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
log.info("Amendment request saved with ID={}", applicationAmendment.getId());

View File

@@ -145,7 +145,7 @@ public class EmailNotificationDao {
List<AttachmentRequest> attachmentRequests =new ArrayList<>();
List<String> urls=new ArrayList<>();
List<DocumentEntity> documentEntities=new ArrayList<>();
if(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED)) {
if(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED) || systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE)) {
if(Boolean.TRUE.equals(AmendmentDocumentTypeEnum.ALTRE_GARANZIE.getValue().equals(applicationAmendmentRequest.getAmendmentDocumentType()))){
documentEntities=documentRepository.findBySourceInAndIsDeletedFalse(List.of(applicationAmendmentRequest.getAmendmentDocumentType(),"MODELLO_AUTOCERTIFICAZIONE","MODELLO_PRIVACY"));
}else {
@@ -517,7 +517,11 @@ public class EmailNotificationDao {
public void sendMailforSpecialAmendment(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity,ApplicationEntity applicationEntity) {
Map<String, String> bodyPlaceholders = prepareEmailPlaceholders(applicationEntity, applicationAmendmentRequestEntity);
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED, bodyPlaceholders, null,
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum systemEmailTemplatesEntityTypeEnum= SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED;
if(applicationAmendmentRequestEntity.getAmendmentDocumentType().equals(AmendmentDocumentTypeEnum.BLUE_TONGUE.getValue())){
systemEmailTemplatesEntityTypeEnum= SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE;
}
sendEmail(applicationEntity,systemEmailTemplatesEntityTypeEnum, bodyPlaceholders, null,
applicationAmendmentRequestEntity.getId(),null);
}
public void sendEmailForApplicationContracted(ApplicationEntity applicationEntity,ApplicationContractEntity applicationContractEntity,UserEntity user) {

View File

@@ -5,6 +5,7 @@ import lombok.Data;
import org.hibernate.annotations.Where;
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@@ -77,4 +78,10 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity {
@Column(name = "AMENDMENT_INITIAL_DOCUMENT")
private String amendmentInitialDocument;
@Column(name = "BLUE_TONGUE_FIELD_1")
private BigDecimal blueTongueField1;
@Column(name = "BLUE_TONGUE_FIELD_2")
private BigDecimal blueTongueField2;
}

View File

@@ -57,7 +57,8 @@ public class SystemEmailTemplatesEntity extends BaseEntity {
INADMISSIBILITY_TEMPLATE("INADMISSIBILITY_NOTIFICATION"),
APPLICATION_SUBMISSION_FAILURE_NOTIFICATION("APPLICATION_SUBMISSION_FAILURE_NOTIFICATION"),
INADMISSIBILITY_NOTIFICATION_DUE_TO_TECHNICAL_EVALUATION_FAILURE("INADMISSIBILITY_NOTIFICATION_DUE_TO_TECHNICAL_EVALUATION_FAILURE"),
SPECIAL_APPLICATION_AMENDMENT_REQUESTED("SPECIAL_APPLICATION_AMENDMENT_REQUESTED");
SPECIAL_APPLICATION_AMENDMENT_REQUESTED("SPECIAL_APPLICATION_AMENDMENT_REQUESTED"),
SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE("SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE");
private String value;
SystemEmailTemplatesEntityTypeEnum(String value) {

View File

@@ -10,7 +10,9 @@ public enum AmendmentDocumentTypeEnum {
MCC_START_UP("MCC_START_UP"),
ALTRE_GARANZIE("ALTRE_GARANZIE");
ALTRE_GARANZIE("ALTRE_GARANZIE"),
BLUE_TONGUE("BLUE_TONGUE");
private final String value;

View File

@@ -15,6 +15,7 @@ public enum EmailScenarioTypeEnum {
APPLICATION_SUBMISSION_FAILURE("APPLICATION_SUBMISSION_FAILURE"),
APPLICATION_TECHNICAL_EVALUATION_REJECTED("APPLICATION_TECHNICAL_EVALUATION_REJECTED"),
SPECIAL_APPLICATION_AMENDMENT_REQUESTED("SPECIAL_APPLICATION_AMENDMENT_REQUESTED"),
SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE("SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE"),
APPLICATION_CONTRACT_CREATED("APPLICATION_CONTRACT_CREATED");
private final String value;

View File

@@ -13,4 +13,8 @@ public class ApplicationAmendmentSpecialRequest {
private AmendmentDocumentTypeEnum amendmentDocumentType;
private String pec;
private BigDecimal blueTongueField1;
private BigDecimal blueTongueField2;
}

View File

@@ -156,4 +156,6 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
ApplicationAmendmentRequestEntity findByIdAndIsDeletedFalseAndStatusIn(Long id, List<String> statusList);
ApplicationAmendmentRequestEntity findByApplicationIdAndIsDeletedFalseAndAmendmentDocumentTypeAndType(Long applicationId,String amendmentDocumentType, String type);
}

View File

@@ -10,14 +10,13 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.dao.ApplicationDao;
import net.gepafin.tendermanagement.dao.EmailLogDao;
import net.gepafin.tendermanagement.dao.NotificationDao;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.CompanyEntity;
import net.gepafin.tendermanagement.entities.EmailLogEntity;
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
import net.gepafin.tendermanagement.enums.*;
import net.gepafin.tendermanagement.model.request.*;
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
import net.gepafin.tendermanagement.repositories.EmailLogRepository;
import net.gepafin.tendermanagement.service.CompanyService;
import net.gepafin.tendermanagement.util.DateTimeUtil;
@@ -68,6 +67,9 @@ public class PecEmailService implements EmailService {
@Autowired
private EmailLogRepository emailLogRepository;
@Autowired
private ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
@Override
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogEntity emailLogEntity, Boolean isSendEmail) {
@@ -80,7 +82,7 @@ public class PecEmailService implements EmailService {
S3DocxProcessor processor = new S3DocxProcessor(s3Client);
List<String> urls = Utils.convertJsonStringToList(emailLogEntity.getAttachments(), String.class);
if(emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED.getValue())) {
if(emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED.getValue()) || emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE.getValue()) ) {
ApplicationEntity applicationEntity = applicationDao.validateApplication(emailLogEntity.getApplicationId());
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
String amount = Utils.convertToItalianFormat(String.valueOf(applicationEntity.getAmountAccepted()));
@@ -88,13 +90,27 @@ public class PecEmailService implements EmailService {
if (protocolNumber == null) {
protocolNumber = String.valueOf(applicationEntity.getProtocol().getProtocolNumber());
}
replacements = Map.of(
"{call_name}", applicationEntity.getCall().getName(),
"{amount_accepted}", amount,
"{pec}", "bandi.gepafin@legalmail.it",
"{company_name}", company.getCompanyName(),
"{protocol_number}", protocolNumber
);
replacements.put("{call_name}", applicationEntity.getCall().getName());
replacements.put("{amount_accepted}", amount);
replacements.put("{pec}", "bandi.gepafin@legalmail.it");
replacements.put("{company_name}", company.getCompanyName());
replacements.put("{protocol_number}", protocolNumber);
if (emailLogEntity.getEmailType().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED_BLUE_TONGUE.getValue())){
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity=applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalseAndAmendmentDocumentTypeAndType(applicationEntity.getId(), AmendmentDocumentTypeEnum.BLUE_TONGUE.getValue(),ApplicationAmendmentRequestTypeEnum.SPECIAL.getValue());
if(applicationAmendmentRequestEntity!=null){
if (applicationAmendmentRequestEntity.getBlueTongueField1() != null) {
replacements.put("{blue_tongue_field_1}",
Utils.convertToItalianFormat(applicationAmendmentRequestEntity.getBlueTongueField1().toString()));
}
if (applicationAmendmentRequestEntity.getBlueTongueField2() != null) {
replacements.put("{blue_tongue_field_2}",
Utils.convertToItalianFormat(applicationAmendmentRequestEntity.getBlueTongueField2().toString()));
}
}
}
}
if (urls!=null && Boolean.FALSE.equals(urls.isEmpty())) {
Map<String, AttachmentRequest> processedFiles = null;