Merge pull request #217 from Kitzanos/appointment-creation-prod

Cherry-pick (Production Create Appointments (Only for Hub Gepafin) - GEPAFINBE-126 & GEPAFINBE-165 - (Company Json))
This commit is contained in:
Rinaldo
2025-02-17 14:35:05 +01:00
committed by GitHub
23 changed files with 182 additions and 66 deletions

View File

@@ -6,7 +6,7 @@ public class AppointmentApiConstant {
public static final String GET_NDG_BY_VAT_NUMBER = "/WSAnagrafica.getListaNdg"; public static final String GET_NDG_BY_VAT_NUMBER = "/WSAnagrafica.getListaNdg";
public static final String CREATE_VISURA = "/WSAnagrafica.createVisura"; public static final String CREATE_VISURA = "/WSAnagrafica.createVisura";
public static final String GET_VISURA_LIST = "/WSAnagrafica.getVisuraList"; public static final String GET_VISURA_LIST = "/WSAnagrafica.getVisuraList";
public static final String GET_APPOINTMENT_TEMPLATE = "/WSCrmConsulenza.getAppuntamentoTemplate?idAppuntamentoTemplate=7"; public static final String GET_APPOINTMENT_TEMPLATE = "/WSCrmConsulenza.getAppuntamentoTemplate";
public static final String CREATE_APPOINTMENT_FROM_TEMPLATE = "/WSCrmConsulenza.createAppointmentFromTemplate"; public static final String CREATE_APPOINTMENT_FROM_TEMPLATE = "/WSCrmConsulenza.createAppointmentFromTemplate";
public static final String UPLOAD_APOOINTMENT_DOCUMENT = "/WSDocumentDetail.createStream"; public static final String UPLOAD_APOOINTMENT_DOCUMENT = "/WSDocumentDetail.createStream";
@@ -24,4 +24,18 @@ public class AppointmentApiConstant {
public static final boolean IS_FROM_RATING = Boolean.FALSE; public static final boolean IS_FROM_RATING = Boolean.FALSE;
public static final boolean IS_ANAGRAFICA_LEGAME = Boolean.FALSE; public static final boolean IS_ANAGRAFICA_LEGAME = Boolean.FALSE;
//Appointment creation request body fields
public static final String MOTIVAZIONE = "motivazione";
public static final String PRODOTTO = "prodotto";
public static final String COD_ABI = "codAbi";
public static final String COD_CAB = "codCab";
public static final String ID_NOTA = "idNota";
public static final String IMPORTO_AGEVOLATO = "importoAgevolato";
public static final String IMPORTO_MEDIOLUNGO_TERMINE = "importoMedioLungoTermine";
public static final String COD_TIPO_PRODOTTO = "codTipoProdotto";
public static final String COD_CATEGORIA_PRODOTTO = "codCategoriaProdotto";
public static final String COD_FORMATECNICA = "codFormaTecnica";
public static final String COD_OPERAZIONE = "codOperazione";
public static final String MOTIVAZIONE_ID = "id";
public static final String PRODOTTO_CODE = "code";
} }

View File

@@ -332,7 +332,7 @@ public class GepafinConstant {
public static final String DATA_STRING = "data"; public static final String DATA_STRING = "data";
public static final String DOCUMENT_ATTACHMENT_ID_STRING = "documentAttachmentId"; public static final String DOCUMENT_ATTACHMENT_ID_STRING = "documentAttachmentId";
public static final String TEMP_FILE_PATH = "/tmp/"; public static final String TEMP_FILE_PATH = "/tmp/";
public static final String RICHIESTA_CLIENTE_STRING = "richiestaCliente"; public static final String RICHIESTE_CLIENTE_STRING = "richiesteCliente";
public static final String ID_STRING = "id"; public static final String ID_STRING = "id";
public static final String NULL_STRING = "null"; public static final String NULL_STRING = "null";
public static final String NDG_STRING = "ndg"; public static final String NDG_STRING = "ndg";
@@ -423,6 +423,9 @@ public class GepafinConstant {
public static final String FORMULA_AMOUNT_NOT_MATCHED="formula.amount.not.matches.requested.amount"; 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 APPOINTMENT_CANNOT_BE_CREATED = "appointment.cannot.be.created";
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.math.BigDecimal;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
@@ -296,7 +295,7 @@ public class ApplicationEvaluationDao {
response.setCreatedDate(entity.getCreatedDate()); response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate()); response.setUpdatedDate(entity.getUpdatedDate());
response.setNumberOfCheck(entity.getAssignedApplicationsEntity().getApplication().getCall().getNumberOfCheck()); 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(); LocalDateTime callEndDate = application.getCall().getEndDate();
response.setCallEndDate(callEndDate); response.setCallEndDate(callEndDate);
response.setNumberOfCheck(call.getNumberOfCheck()); response.setNumberOfCheck(call.getNumberOfCheck());
response.setProductId(call.getProductId()); response.setAppointmentTemplateId(call.getAppointmentTemplateId());
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);

View File

@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.dao;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.GetObjectRequest; import com.amazonaws.services.s3.model.GetObjectRequest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import feign.FeignException; import feign.FeignException;
@@ -16,18 +17,14 @@ import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.CompanyEntity; import net.gepafin.tendermanagement.entities.CompanyEntity;
import net.gepafin.tendermanagement.entities.DocumentEntity; import net.gepafin.tendermanagement.entities.DocumentEntity;
import net.gepafin.tendermanagement.entities.HubEntity; import net.gepafin.tendermanagement.entities.HubEntity;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
import net.gepafin.tendermanagement.enums.NotificationTypeEnum; import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum; import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
import net.gepafin.tendermanagement.model.request.AppointmentCreationRequest; import net.gepafin.tendermanagement.model.request.AppointmentCreationRequest;
import net.gepafin.tendermanagement.model.request.AppointmentNdgRequest; import net.gepafin.tendermanagement.model.request.AppointmentNdgRequest;
import net.gepafin.tendermanagement.model.request.AppointmentVisuraListRequest; import net.gepafin.tendermanagement.model.request.AppointmentVisuraListRequest;
import net.gepafin.tendermanagement.model.request.AppointmentVisuraRequest; import net.gepafin.tendermanagement.model.request.AppointmentVisuraRequest;
import net.gepafin.tendermanagement.model.request.CreateAppointmentRequest; import net.gepafin.tendermanagement.model.request.CreateAppointmentRequest;
import net.gepafin.tendermanagement.model.request.NotificationReq;
import net.gepafin.tendermanagement.model.request.UploadDocToExternalSystemRequest; import net.gepafin.tendermanagement.model.request.UploadDocToExternalSystemRequest;
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest; import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
import net.gepafin.tendermanagement.model.response.AppointmentCreationResponse; import net.gepafin.tendermanagement.model.response.AppointmentCreationResponse;
@@ -63,7 +60,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@@ -406,10 +402,15 @@ public class AppointmentDao {
} }
// Handle non-OK response // Handle non-OK response
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN)); throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
} catch (FeignException.Forbidden forbiddenException) {
logForbiddenError();
// Regenerate the token and retry
regenerateTokenAndSave(hub);
} catch (Exception e) { } catch (Exception e) {
log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e); log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e);
throw new RuntimeException("Authentication failed on Odessa. try again", e); throw new RuntimeException("Authentication failed on Odessa. try again", e);
} }
return null;
} }
private AppointmentLoginResponse retrieveNdgByVatNumber(String vatNumber, String authorizationToken, HubEntity hub, ApplicationEntity application) { private AppointmentLoginResponse retrieveNdgByVatNumber(String vatNumber, String authorizationToken, HubEntity hub, ApplicationEntity application) {
@@ -626,7 +627,11 @@ public class AppointmentDao {
// Generate authorization token and fetch template data // Generate authorization token and fetch template data
String authorizationToken = getBearerToken(hub); String authorizationToken = getBearerToken(hub);
ResponseEntity<Object> response = appointmentApiService.getAppointmentTemplateForTemplateCreation(authorizationToken); 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) { if (response.getStatusCode() != HttpStatus.OK) {
log.error("Failed to retrieve appointment template for appointment creation. Status: {}", response.getStatusCode()); log.error("Failed to retrieve appointment template for appointment creation. Status: {}", response.getStatusCode());
@@ -638,7 +643,7 @@ public class AppointmentDao {
AppointmentCreationRequest templateRichiestaData = parseTemplateResponseData(responseDataForTemplate); AppointmentCreationRequest templateRichiestaData = parseTemplateResponseData(responseDataForTemplate);
// Build the appointment request body // Build the appointment request body
AppointmentCreationRequest appointmentCreationRequest = buildAppointmentCreationRequest(applicationId, createAppointmentRequest, hub.getAreaCode(), AppointmentCreationRequest appointmentCreationRequest = buildAppointmentCreationRequest(applicationId, createAppointmentRequest, appointmentTemplateId,
templateRichiestaData); templateRichiestaData);
String appointmentRequestBody = Utils.convertObjectToJson(appointmentCreationRequest); String appointmentRequestBody = Utils.convertObjectToJson(appointmentCreationRequest);
@@ -646,16 +651,17 @@ public class AppointmentDao {
ResponseEntity<Object> appointmentResponse = appointmentApiService.createAppointment(authorizationToken, context, appointmentRequestBody); ResponseEntity<Object> appointmentResponse = appointmentApiService.createAppointment(authorizationToken, context, appointmentRequestBody);
String appointmentId = extractAppointmentIdFromResponse(appointmentResponse); String appointmentId = extractAppointmentIdFromResponse(appointmentResponse);
if (appointmentId != null) { if (appointmentId == null) {
// Update application with the appointment ID throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPOINTMENT_NOT_CREATED));
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());
} }
// 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); appointmentCreationResponse.setAppointmentId(appointmentId);
return appointmentCreationResponse; return appointmentCreationResponse;
@@ -684,32 +690,64 @@ public class AppointmentDao {
public AppointmentCreationRequest parseTemplateResponseData(String jsonResponse) { public AppointmentCreationRequest parseTemplateResponseData(String jsonResponse) {
try { try {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonResponse); JsonNode rootNode = objectMapper.readTree(jsonResponse);
JsonNode richiestaClienteArray = rootNode.path(GepafinConstant.DATA_STRING).path(GepafinConstant.RICHIESTA_CLIENTE_STRING); JsonNode richiesteClienteArray = rootNode.path(GepafinConstant.DATA_STRING).path(GepafinConstant.RICHIESTE_CLIENTE_STRING);
// Initialize the result object
AppointmentCreationRequest appointmentCreationRequest = new AppointmentCreationRequest(); AppointmentCreationRequest appointmentCreationRequest = new AppointmentCreationRequest();
AppointmentCreationRequest.Input input = new AppointmentCreationRequest.Input(); AppointmentCreationRequest.Input input = new AppointmentCreationRequest.Input();
// Map `richiestaCliente` array
List<AppointmentCreationRequest.RichiestaCliente> richiestaClienteList = new ArrayList<>(); List<AppointmentCreationRequest.RichiestaCliente> richiestaClienteList = new ArrayList<>();
if (richiestaClienteArray.isArray()) { if (!richiesteClienteArray.isArray()) {
for (JsonNode richiestaNode : richiestaClienteArray) { log.warn("richiesteCliente array is missing or not an array.");
richiestaClienteList.add(objectMapper.treeToValue(richiestaNode, AppointmentCreationRequest.RichiestaCliente.class)); return new AppointmentCreationRequest();
}
} }
for (JsonNode richiestaNode : richiesteClienteArray) {
if (richiestaNode.isNull())
continue;
AppointmentCreationRequest.RichiestaCliente richiestaCliente = new AppointmentCreationRequest.RichiestaCliente();
JsonNode prodottoNode = richiestaNode.path(AppointmentApiConstant.PRODOTTO);
String prodottoCode = prodottoNode.path(AppointmentApiConstant.PRODOTTO_CODE).asText();
richiestaCliente.setCodProdotto(prodottoCode);
richiestaCliente.setIdMotivazione(getIntValue(richiestaNode));
richiestaCliente.setCodAbi(getTextValue(richiestaNode, AppointmentApiConstant.COD_ABI));
richiestaCliente.setCodCab(getTextValue(richiestaNode, AppointmentApiConstant.COD_CAB));
richiestaCliente.setIdNota(getTextValue(richiestaNode, AppointmentApiConstant.ID_NOTA));
richiestaCliente.setImportoAgevolato(getTextValue(richiestaNode, AppointmentApiConstant.IMPORTO_AGEVOLATO));
richiestaCliente.setImportoMedioLungoTermine(getTextValue(richiestaNode, AppointmentApiConstant.IMPORTO_MEDIOLUNGO_TERMINE));
richiestaCliente.setCodTipoProdotto(getTextValue(richiestaNode, AppointmentApiConstant.COD_TIPO_PRODOTTO));
richiestaCliente.setCodCategoriaProdotto(getTextValue(richiestaNode, AppointmentApiConstant.COD_CATEGORIA_PRODOTTO));
richiestaCliente.setCodFormaTecnica(getTextValue(richiestaNode, AppointmentApiConstant.COD_FORMATECNICA));
richiestaCliente.setCodOperazione(getTextValue(richiestaNode, AppointmentApiConstant.COD_OPERAZIONE));
richiestaClienteList.add(richiestaCliente);
}
input.setRichiestaCliente(richiestaClienteList); input.setRichiestaCliente(richiestaClienteList);
appointmentCreationRequest.setInput(input); appointmentCreationRequest.setInput(input);
return appointmentCreationRequest; return appointmentCreationRequest;
} catch (Exception e) { } catch (JsonProcessingException e) {
log.error("Error parsing template response: {}", e.getMessage(), e); log.error("JSON processing error: {}", e.getMessage(), e);
throw new IllegalStateException("Failed to parse template response", e); throw new IllegalStateException("Invalid JSON structure in template response", e);
} }
} }
public AppointmentCreationRequest buildAppointmentCreationRequest(Long applicationId, CreateAppointmentRequest createAppointmentRequest, String areaCode, private String getTextValue(JsonNode node, String fieldName) {
return node.path(fieldName).isTextual() ? node.path(fieldName).asText() : null;
}
private int getIntValue(JsonNode node) {
return node.path(AppointmentApiConstant.MOTIVAZIONE).path(AppointmentApiConstant.MOTIVAZIONE_ID).asInt();
}
public AppointmentCreationRequest buildAppointmentCreationRequest(Long applicationId, CreateAppointmentRequest createAppointmentRequest, Long areaCode,
AppointmentCreationRequest templateRichiestaData) { AppointmentCreationRequest templateRichiestaData) {
ApplicationEntity application = applicationService.validateApplication(applicationId); ApplicationEntity application = applicationService.validateApplication(applicationId);
@@ -733,7 +771,8 @@ public class AppointmentDao {
requestNota.setTitolo(nota.getTitolo()); requestNota.setTitolo(nota.getTitolo());
requestNota.setTesto(nota.getTesto()); requestNota.setTesto(nota.getTesto());
richiestaCliente.setNota(requestNota); richiestaCliente.setNota(requestNota);
richiestaCliente.setDurataMesiFinanziamento(createAppointmentRequest.getDurataMesiFinanziamento());
richiestaCliente.setImportoBreveTermine(createAppointmentRequest.getImportoBreveTermine());
richiestaClienteList.add(richiestaCliente); richiestaClienteList.add(richiestaCliente);
} }

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.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;
@@ -31,7 +30,6 @@ 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;
@@ -201,7 +199,7 @@ public class AssignedApplicationsDao {
assignedApplicationsResponse.setEvaluationEndDate(applicationEvaluationEntity.get().getEndDate()); assignedApplicationsResponse.setEvaluationEndDate(applicationEvaluationEntity.get().getEndDate());
} }
assignedApplicationsResponse.setNumberOfCheck(application.getCall().getNumberOfCheck()); assignedApplicationsResponse.setNumberOfCheck(application.getCall().getNumberOfCheck());
assignedApplicationsResponse.setProductId(application.getCall().getProductId()); assignedApplicationsResponse.setAppointmentTemplateId(application.getCall().getAppointmentTemplateId());
return assignedApplicationsResponse; return assignedApplicationsResponse;
} }

View File

@@ -202,7 +202,7 @@ public class CallDao {
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.setNumberOfCheck(createCallRequest.getNumberOfCheck());
callEntity.setProductId(createCallRequest.getProductId()); callEntity.setAppointmentTemplateId(createCallRequest.getAppointmentTemplateId());
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. **/
@@ -610,7 +610,7 @@ public class CallDao {
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi()); setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
setIfUpdated(callEntity::getEvaluationVersion, callEntity::setEvaluationVersion, updateCallRequest.getEvaluationVersion().getValue()); setIfUpdated(callEntity::getEvaluationVersion, callEntity::setEvaluationVersion, updateCallRequest.getEvaluationVersion().getValue());
setIfUpdated(callEntity::getNumberOfCheck, callEntity::setNumberOfCheck, updateCallRequest.getNumberOfCheck()); 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); 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 **/
@@ -718,7 +718,7 @@ public class CallDao {
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate()); callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate()); callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
callDetailsResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck()); callDetailsResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
callDetailsResponseBean.setProductId(callEntity.getProductId()); callDetailsResponseBean.setAppointmentTemplateId(callEntity.getAppointmentTemplateId());
return callDetailsResponseBean; return callDetailsResponseBean;
} }
@@ -743,7 +743,7 @@ public class CallDao {
createCallResponseBean.setAimedTo(amiedTo); createCallResponseBean.setAimedTo(amiedTo);
createCallResponseBean.setCheckList(checkList); createCallResponseBean.setCheckList(checkList);
createCallResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck()); createCallResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
createCallResponseBean.setProductId(callEntity.getProductId()); createCallResponseBean.setAppointmentTemplateId(callEntity.getAppointmentTemplateId());
return createCallResponseBean; return createCallResponseBean;
} }

View File

@@ -122,10 +122,40 @@ public class CompanyDao {
userWithCompanyEntity.setPec(companyRequest.getPec()); userWithCompanyEntity.setPec(companyRequest.getPec());
userWithCompanyEntity.setContactName(companyRequest.getContactName()); userWithCompanyEntity.setContactName(companyRequest.getContactName());
userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail()); userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail());
userWithCompanyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) );
UserWithCompanyEntity userWithCompany = userWithCompanyRepository.save(userWithCompanyEntity); UserWithCompanyEntity userWithCompany = userWithCompanyRepository.save(userWithCompanyEntity);
/** This code is responsible for adding a version history log for the "adding user with company" operation. **/ /** This code is responsible for adding a version history log for the "adding user with company" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(userWithCompany).build()); loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(userWithCompany).build());
if (StringUtils.isEmpty(companyEntity.getJson())) {
companyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()));
Map<String, Object> vatCheckResponse = companyRequest.getVatCheckResponse();
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
if (data != null) {
if (data.containsKey("dettaglio")) {
Map<String, Object> dettaglio = (Map<String, Object>) data.get("dettaglio");
if (dettaglio != null) {
if (dettaglio.containsKey("codice_ateco")) {
Object codiceAtecoObj = dettaglio.get("codice_ateco");
String codiceAteco = (codiceAtecoObj != null) ? codiceAtecoObj.toString() : null;
if (codiceAteco != null) {
companyEntity.setCodiceAteco(codiceAteco);
}
}
}
}
}
companyEntity = companyRepository.save(companyEntity);
/** This code is responsible for adding a version history log for "updating company json field" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder()
.request(request)
.actionType(VersionActionTypeEnum.INSERT)
.oldData(null)
.newData(companyEntity)
.build());
}
return userWithCompany; return userWithCompany;
} }
@@ -143,6 +173,7 @@ public class CompanyDao {
entity.setNumberOfEmployees(request.getNumberOfEmployees()); entity.setNumberOfEmployees(request.getNumberOfEmployees());
entity.setAnnualRevenue(request.getAnnualRevenue()); entity.setAnnualRevenue(request.getAnnualRevenue());
entity.setHub(userEntity.getHub()); entity.setHub(userEntity.getHub());
entity.setJson(Utils.convertMapIntoJsonString(request.getVatCheckResponse()));
if (request.getVatCheckResponse() != null) { if (request.getVatCheckResponse() != null) {
Map<String, Object> vatCheckResponse = request.getVatCheckResponse(); Map<String, Object> vatCheckResponse = request.getVatCheckResponse();
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data"); Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
@@ -226,10 +257,10 @@ public class CompanyDao {
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId); UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId);
//cloned entity for old data //cloned entity for old data
UserWithCompanyEntity oldUserWithCompanyData = Utils.getClonedEntityForData(userWithCompanyEntity); UserWithCompanyEntity oldUserWithCompanyData = Utils.getClonedEntityForData(userWithCompanyEntity);
if(StringUtils.isNotBlank(companyRequest.getVatNumber())) { // if(StringUtils.isNotBlank(companyRequest.getVatNumber())) {
String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null; // String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null;
setIfUpdated(userWithCompanyEntity::getJson, userWithCompanyEntity::setJson, responseJson); // setIfUpdated(companyEntity::getJson, companyEntity::setJson, responseJson);
} // }
setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, companyRequest.getPec()); setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, companyRequest.getPec());
setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, companyRequest.getEmail()); setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, companyRequest.getEmail());
setIfUpdated(userWithCompanyEntity::getContactName, userWithCompanyEntity::setContactName, companyRequest.getContactName()); setIfUpdated(userWithCompanyEntity::getContactName, userWithCompanyEntity::setContactName, companyRequest.getContactName());

View File

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

View File

@@ -59,4 +59,7 @@ public class CompanyEntity extends BaseEntity{
@Column(name = "CODICE_ATECO") @Column(name = "CODICE_ATECO")
private String codiceAteco; private String codiceAteco;
@Column(name = "JSON")
private String json;
} }

View File

@@ -35,9 +35,6 @@ public class UserWithCompanyEntity extends BaseEntity{
@Column(name = "EMAIL") @Column(name = "EMAIL")
private String email; private String email;
@Column(name = "JSON")
private String json;
@Column(name = "IS_DELETED") @Column(name = "IS_DELETED")
private Boolean isDeleted = false; private Boolean isDeleted = false;

View File

@@ -11,7 +11,7 @@ public class AppointmentCreationRequest {
@Data @Data
public static class Input { public static class Input {
private String id; private Long id;
private String ndg; private String ndg;
private List<RichiestaCliente> richiestaCliente; private List<RichiestaCliente> richiestaCliente;
} }
@@ -20,8 +20,8 @@ public class AppointmentCreationRequest {
public static class RichiestaCliente { public static class RichiestaCliente {
private String codAbi; private String codAbi;
private String codCab; private String codCab;
private Integer durataMesiFinanziamento; private int durataMesiFinanziamento;
private Integer idMotivazione; private int idMotivazione;
private String idNota; private String idNota;
private String importoAgevolato; private String importoAgevolato;
private Double importoBreveTermine; private Double importoBreveTermine;

View File

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

View File

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

View File

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

View File

@@ -45,7 +45,7 @@ public class ApplicationEvaluationResponse {
private LocalDateTime dateAccepted; private LocalDateTime dateAccepted;
private LocalDateTime dateRejected; private LocalDateTime dateRejected;
private Long numberOfCheck; private Long numberOfCheck;
private Long productId; private Long appointmentTemplateId;
private EvaluationVersionEnum evaluationVersion; 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.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
@@ -25,7 +24,7 @@ public class AssignedApplicationsResponse extends BaseBean {
private String companyName; private String companyName;
private LocalDateTime evaluationEndDate; private LocalDateTime evaluationEndDate;
private Long numberOfCheck; private Long numberOfCheck;
private Long productId; private Long appointmentTemplateId;
private EvaluationVersionEnum evaluationVersion; private EvaluationVersionEnum evaluationVersion;
} }

View File

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

View File

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

View File

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -31,7 +32,7 @@ public interface AppointmentApiService {
ResponseEntity<Object> getVisuraList(@RequestBody String visuraRequest, @RequestHeader("Authorization") String token); ResponseEntity<Object> getVisuraList(@RequestBody String visuraRequest, @RequestHeader("Authorization") String token);
@GetMapping(value = AppointmentApiConstant.GET_APPOINTMENT_TEMPLATE, consumes = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = AppointmentApiConstant.GET_APPOINTMENT_TEMPLATE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Object> getAppointmentTemplateForTemplateCreation(@RequestHeader("Authorization") String token); ResponseEntity<Object> getAppointmentTemplateForTemplateCreation(@RequestHeader("Authorization") String token, @RequestParam("idAppuntamentoTemplate") Long templateId);
@PostMapping(value = AppointmentApiConstant.CREATE_APPOINTMENT_FROM_TEMPLATE, consumes = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = AppointmentApiConstant.CREATE_APPOINTMENT_FROM_TEMPLATE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Object> createAppointment(@RequestHeader("Authorization") String token, @RequestHeader("context") String context, String appointmentCreationRequest); ResponseEntity<Object> createAppointment(@RequestHeader("Authorization") String token, @RequestHeader("context") String context, String appointmentCreationRequest);

View File

@@ -2418,4 +2418,21 @@
<modifyDataType tableName="call" columnName="product_id" newDataType="INTEGER"/> <modifyDataType tableName="call" columnName="product_id" newDataType="INTEGER"/>
</changeSet> </changeSet>
<changeSet id="17-02-2025_PK_025237" author="Piyush Kag">
<renameColumn tableName="call"
oldColumnName="product_id"
newColumnName="appointment_template_id"/>
</changeSet>
<changeSet id="14-02-2025_PK_124000" author="Piyush Kag">
<addColumn tableName="COMPANY">
<column name="JSON" type="TEXT"/>
</addColumn>
<sqlFile dbms="postgresql"
path="db/dump/insert_json_column_in_company_data_06_02_2025.sql"/>
<dropColumn tableName="USER_WITH_COMPANY" columnName="JSON"/>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -0,0 +1,16 @@
UPDATE COMPANY C
SET JSON = (
SELECT U.JSON
FROM USER_WITH_COMPANY U
WHERE U.COMPANY_ID = C.ID
AND U.JSON IS NOT NULL
AND U.JSON <> ''
ORDER BY U.ID ASC
LIMIT 1
)
WHERE EXISTS (
SELECT 1 FROM USER_WITH_COMPANY U
WHERE U.COMPANY_ID = C.ID
AND U.JSON IS NOT NULL
AND U.JSON <> ''
);

View File

@@ -371,4 +371,5 @@ validation.required.requested.amount=The Requested Amount configuration should b
company.id.not.null=Company ID cannot be null. company.id.not.null=Company ID cannot be null.
formula.amount.not.matches.requested.amount= The {0} does not matches to calculated amount. 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 template id.
appointment.not.created = Appointment not created please try again.

View File

@@ -362,4 +362,5 @@ validation.required.requested.amount=La configurazione dell'importo richiesto
company.id.not.null=L'ID dell'azienda non pu? essere nullo. 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. formula.amount.not.matches.requested.amount=Il {0} non corrisponde all'importo calcolato.
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