Updated code for appointment creation flow and productId field to appointmentTemplateId.

This commit is contained in:
piyushkag
2025-02-17 16:17:07 +05:30
parent af97be663e
commit 5e360845a7
17 changed files with 45 additions and 57 deletions

View File

@@ -425,7 +425,7 @@ public class GepafinConstant {
public static final String CRITERIA_TABLE_COLUMNS="criteria_table_columns";
public static final String APPOINTMENT_CANNOT_BE_CREATED = "appointment.cannot.be.created";
public static final String APPOINTMENT_CANNOT_BE_CREATED_BY_TEMPLATE = "appointment.cannot.be.created.by.template";
public static final String APPOINTMENT_NOT_CREATED = "appointment.not.created";
}

View File

@@ -23,7 +23,6 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
@@ -296,7 +295,7 @@ public class ApplicationEvaluationDao {
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
response.setNumberOfCheck(entity.getAssignedApplicationsEntity().getApplication().getCall().getNumberOfCheck());
response.setProductId(entity.getAssignedApplicationsEntity().getApplication().getCall().getProductId());
response.setAppointmentTemplateId(entity.getAssignedApplicationsEntity().getApplication().getCall().getAppointmentTemplateId());
}
@@ -1157,7 +1156,7 @@ public class ApplicationEvaluationDao {
LocalDateTime callEndDate = application.getCall().getEndDate();
response.setCallEndDate(callEndDate);
response.setNumberOfCheck(call.getNumberOfCheck());
response.setProductId(call.getProductId());
response.setAppointmentTemplateId(call.getAppointmentTemplateId());
setCriteriaResponses(entity, application.getId(), response, evaluationCriterias);
setChecklistResponses(entity, application.getId(), response, checklistEntities);
setFileResponses(entity, application.getId(), response, applicationFormEntities);

View File

@@ -627,7 +627,10 @@ public class AppointmentDao {
// Generate authorization token and fetch template data
String authorizationToken = getBearerToken(hub);
Long appointmentTemplateId = hub.getAppointmentTemplateId();
Long appointmentTemplateId = application.getCall().getAppointmentTemplateId();
if (appointmentTemplateId == null) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPOINTMENT_CANNOT_BE_CREATED));
}
ResponseEntity<Object> response = appointmentApiService.getAppointmentTemplateForTemplateCreation(authorizationToken, appointmentTemplateId);
if (response.getStatusCode() != HttpStatus.OK) {
@@ -637,10 +640,10 @@ public class AppointmentDao {
// Parse template data
String responseDataForTemplate = Utils.convertObjectToJson(response.getBody());
AppointmentCreationRequest templateRichiestaData = parseTemplateResponseData(responseDataForTemplate, application.getCall().getProductId());
AppointmentCreationRequest templateRichiestaData = parseTemplateResponseData(responseDataForTemplate);
// Build the appointment request body
AppointmentCreationRequest appointmentCreationRequest = buildAppointmentCreationRequest(applicationId, createAppointmentRequest, hub.getAppointmentTemplateId(),
AppointmentCreationRequest appointmentCreationRequest = buildAppointmentCreationRequest(applicationId, createAppointmentRequest, appointmentTemplateId,
templateRichiestaData);
String appointmentRequestBody = Utils.convertObjectToJson(appointmentCreationRequest);
@@ -648,16 +651,17 @@ public class AppointmentDao {
ResponseEntity<Object> appointmentResponse = appointmentApiService.createAppointment(authorizationToken, context, appointmentRequestBody);
String appointmentId = extractAppointmentIdFromResponse(appointmentResponse);
if (appointmentId != null) {
// Update application with the appointment ID
application.setAppointmentId(appointmentId);
application.setStatus(ApplicationStatusTypeEnum.APPOINTMENT.getValue());
applicationRepository.save(application);
// Log version history
loggingUtil.addVersionHistory(
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationData).newData(application).build());
if (appointmentId == null) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPOINTMENT_NOT_CREATED));
}
// Update application with the appointment ID
application.setAppointmentId(appointmentId);
application.setStatus(ApplicationStatusTypeEnum.APPOINTMENT.getValue());
applicationRepository.save(application);
// Log version history
loggingUtil.addVersionHistory(
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationData).newData(application).build());
appointmentCreationResponse.setAppointmentId(appointmentId);
return appointmentCreationResponse;
@@ -683,12 +687,10 @@ public class AppointmentDao {
return null;
}
public AppointmentCreationRequest parseTemplateResponseData(String jsonResponse, Long productId) {
public AppointmentCreationRequest parseTemplateResponseData(String jsonResponse) {
try {
if (productId == null) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPOINTMENT_CANNOT_BE_CREATED));
}
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonResponse);
JsonNode richiesteClienteArray = rootNode.path(GepafinConstant.DATA_STRING).path(GepafinConstant.RICHIESTE_CLIENTE_STRING);
@@ -701,7 +703,6 @@ public class AppointmentDao {
log.warn("richiesteCliente array is missing or not an array.");
return new AppointmentCreationRequest();
}
boolean isMatchedAtLeastOneId = false;
for (JsonNode richiestaNode : richiesteClienteArray) {
if (richiestaNode.isNull())
continue;
@@ -710,11 +711,8 @@ public class AppointmentDao {
JsonNode prodottoNode = richiestaNode.path(AppointmentApiConstant.PRODOTTO);
String prodottoCode = prodottoNode.path(AppointmentApiConstant.PRODOTTO_CODE).asText();
if (productId.toString().equals(prodottoCode)) {
isMatchedAtLeastOneId = true;
richiestaCliente.setCodProdotto(prodottoCode);
richiestaCliente.setIdMotivazione(getIntValue(richiestaNode));
richiestaCliente.setCodProdotto(productId.toString());
richiestaCliente.setCodAbi(getTextValue(richiestaNode, AppointmentApiConstant.COD_ABI));
richiestaCliente.setCodCab(getTextValue(richiestaNode, AppointmentApiConstant.COD_CAB));
richiestaCliente.setIdNota(getTextValue(richiestaNode, AppointmentApiConstant.ID_NOTA));
@@ -727,11 +725,6 @@ public class AppointmentDao {
richiestaClienteList.add(richiestaCliente);
}
}
if (!isMatchedAtLeastOneId) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPOINTMENT_CANNOT_BE_CREATED_BY_TEMPLATE));
}
input.setRichiestaCliente(richiestaClienteList);
appointmentCreationRequest.setInput(input);

View File

@@ -10,7 +10,6 @@ import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
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.repositories.ApplicationEvaluationRepository;
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
@@ -31,7 +30,6 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -201,7 +199,7 @@ public class AssignedApplicationsDao {
assignedApplicationsResponse.setEvaluationEndDate(applicationEvaluationEntity.get().getEndDate());
}
assignedApplicationsResponse.setNumberOfCheck(application.getCall().getNumberOfCheck());
assignedApplicationsResponse.setProductId(application.getCall().getProductId());
assignedApplicationsResponse.setAppointmentTemplateId(application.getCall().getAppointmentTemplateId());
return assignedApplicationsResponse;
}

View File

@@ -202,7 +202,7 @@ public class CallDao {
callEntity.setEndTime(DateTimeUtil.parseTime(createCallRequest.getEndTime()));
callEntity.setHub(userEntity.getHub());
callEntity.setNumberOfCheck(createCallRequest.getNumberOfCheck());
callEntity.setProductId(createCallRequest.getProductId());
callEntity.setAppointmentTemplateId(createCallRequest.getAppointmentTemplateId());
callEntity = callRepository.save(callEntity);
/** This code is responsible for adding a version history log for the "Create Call" operation. **/
@@ -610,7 +610,7 @@ public class CallDao {
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());
setIfUpdated(callEntity::getAppointmentTemplateId, callEntity::setAppointmentTemplateId, updateCallRequest.getAppointmentTemplateId());
callEntity = callRepository.save(callEntity);
/** This code is responsible for adding a version history log for the "update call step 1" operation **/
@@ -718,7 +718,7 @@ public class CallDao {
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
callDetailsResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
callDetailsResponseBean.setProductId(callEntity.getProductId());
callDetailsResponseBean.setAppointmentTemplateId(callEntity.getAppointmentTemplateId());
return callDetailsResponseBean;
}
@@ -743,7 +743,7 @@ public class CallDao {
createCallResponseBean.setAimedTo(amiedTo);
createCallResponseBean.setCheckList(checkList);
createCallResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
createCallResponseBean.setProductId(callEntity.getProductId());
createCallResponseBean.setAppointmentTemplateId(callEntity.getAppointmentTemplateId());
return createCallResponseBean;
}

View File

@@ -95,7 +95,7 @@ public class CallEntity extends BaseEntity {
@Column(name = "NUMBER_OF_CHECK")
private Long numberOfCheck;
@Column(name = "PRODUCT_ID")
private Long productId;
@Column(name = "APPOINTMENT_TEMPLATE_ID")
private Long appointmentTemplateId;
}

View File

@@ -64,9 +64,6 @@ public class HubEntity extends BaseEntity{
@Column(name = "AREA_CODE")
private String areaCode;
@Column(name = "APPOINTMENT_TEMPLATE_ID")
private Long appointmentTemplateId;
@Column(name = "EVALUATION_EXPIRATION_DAYS")
private Long evaluationExpirationDays;
}

View File

@@ -26,7 +26,7 @@ public class CreateCallRequestStep1 {
private Long numberOfCheck;
private Long productId;
private Long appointmentTemplateId;
private List<LookUpDataReq> aimedTo;

View File

@@ -2,7 +2,6 @@ package net.gepafin.tendermanagement.model.request;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import lombok.Data;
@@ -43,7 +42,7 @@ public class UpdateCallRequestStep1 {
private Long numberOfCheck;
private Long productId;
private Long appointmentTemplateId;
private EvaluationVersionEnum evaluationVersion;

View File

@@ -44,7 +44,5 @@ public class ApplicationEvaluationFormResponse {
private LocalDateTime dateAccepted;
private LocalDateTime dateRejected;
private EvaluationVersionEnum evaluationVersion;
private BigDecimal numberOfCheck;
private BigDecimal productId;
}

View File

@@ -45,7 +45,7 @@ public class ApplicationEvaluationResponse {
private LocalDateTime dateAccepted;
private LocalDateTime dateRejected;
private Long numberOfCheck;
private Long productId;
private Long appointmentTemplateId;
private EvaluationVersionEnum evaluationVersion;
}

View File

@@ -5,7 +5,6 @@ import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
import net.gepafin.tendermanagement.model.BaseBean;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@@ -25,7 +24,7 @@ public class AssignedApplicationsResponse extends BaseBean {
private String companyName;
private LocalDateTime evaluationEndDate;
private Long numberOfCheck;
private Long productId;
private Long appointmentTemplateId;
private EvaluationVersionEnum evaluationVersion;
}

View File

@@ -59,7 +59,7 @@ public class CallDetailsResponseBean {
private Long numberOfCheck;
private Long productId;
private Long appointmentTemplateId;
private EvaluationVersionEnum evaluationVersion;
}

View File

@@ -52,7 +52,7 @@ public class CallResponse {
private Long numberOfCheck;
private Long productId;
private Long appointmentTemplateId;
@JsonSerialize(using = DynamicLocalTimeSerializer.class)
private LocalTime startTime;

View File

@@ -2437,4 +2437,11 @@
</update>
</changeSet>
<changeSet id="17-02-2025_PK_025237" author="Piyush Kag">
<renameColumn tableName="call"
oldColumnName="product_id"
newColumnName="appointment_template_id"/>
<dropColumn tableName="hub" columnName="appointment_template_id"/>
</changeSet>
</databaseChangeLog>

View File

@@ -371,6 +371,5 @@ validation.required.requested.amount=The Requested Amount configuration should b
company.id.not.null=Company ID cannot be null.
formula.amount.not.matches.requested.amount= The {0} does not matches to calculated amount.
appointment.cannot.be.created = Appointment cannot be created because call doesn't have the productId.
appointment.cannot.be.created.by.template = Product ID does not match with appointment template.
appointment.cannot.be.created = Appointment cannot be created because call doesn't have the template id.
appointment.not.created = Appointment not created please try again.

View File

@@ -362,6 +362,5 @@ validation.required.requested.amount=La configurazione dell'importo richiesto
company.id.not.null=L'ID dell'azienda non pu? essere nullo.
formula.amount.not.matches.requested.amount=Il {0} non corrisponde all'importo calcolato.
appointment.cannot.be.created = Impossibile creare l'appuntamento perch<EFBFBD> la chiamata non ha l'ID prodotto.
appointment.cannot.be.created.by.template = L'ID prodotto non corrisponde al modello di appuntamento.
appointment.cannot.be.created = Impossibile creare l'appuntamento perché la chiamata non ha l'ID del modello di appuntamento.
appointment.not.created = Appuntamento non creato, riprova