Done ticket GEPAFINBE-223 & GEPAFINBE-224
This commit is contained in:
@@ -572,6 +572,8 @@ public class GepafinConstant {
|
|||||||
public static final String PROTOCOL_EXTERNAL_DATE="DATA_PG_DT";
|
public static final String PROTOCOL_EXTERNAL_DATE="DATA_PG_DT";
|
||||||
public static final String PROTOCOL_DOC_SUFFIX="#noauth";
|
public static final String PROTOCOL_DOC_SUFFIX="#noauth";
|
||||||
public static final String CREATE_NDG="CHECK_OR_CREATE_NDG_CODE";
|
public static final String CREATE_NDG="CHECK_OR_CREATE_NDG_CODE";
|
||||||
|
public static final String NDG_NOT_FOUND="ndg.not.found";
|
||||||
|
public static final String EMAIL_PEC_REQUIRED="email.pec.cannot.null";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -557,25 +557,69 @@ public class ApplicationDao {
|
|||||||
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||||
|
|
||||||
contentResponseBeans.stream()
|
// contentResponseBeans.stream()
|
||||||
.filter(content -> "numberinput".equals(content.getName()) && content.getId().toString().equals(applicationFormFieldRequestBean.getFieldId()))
|
// .filter(content -> "numberinput".equals(content.getName()) && content.getId().toString().equals(applicationFormFieldRequestBean.getFieldId()))
|
||||||
.map(ContentResponseBean::getSettings)
|
// .map(ContentResponseBean::getSettings)
|
||||||
.flatMap(List::stream)
|
// .flatMap(List::stream)
|
||||||
.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 {
|
||||||
BigDecimal amountRequested = new BigDecimal(fieldValue.toString());
|
// BigDecimal amountRequested = new BigDecimal(fieldValue.toString());
|
||||||
applicationFormEntity.getApplication().setAmountRequested(amountRequested);
|
// applicationFormEntity.getApplication().setAmountRequested(amountRequested);
|
||||||
log.info("Set amountRequested to {} for Application ID: {}", amountRequested, applicationFormEntity.getApplication().getId());
|
// log.info("Set amountRequested to {} for Application ID: {}", amountRequested, applicationFormEntity.getApplication().getId());
|
||||||
} catch (NumberFormatException e) {
|
// } catch (NumberFormatException e) {
|
||||||
log.error("Invalid number format for requested amount: {}", fieldValue, e);
|
// log.error("Invalid number format for requested amount: {}", fieldValue, e);
|
||||||
throw new IllegalArgumentException("Field value is not a valid number: " + fieldValue, e);
|
// throw new IllegalArgumentException("Field value is not a valid number: " + fieldValue, e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
contentResponseBeans.stream()
|
||||||
|
.filter(content -> content.getId().toString().equals(applicationFormFieldRequestBean.getFieldId()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(content -> {
|
||||||
|
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||||
|
if (fieldValue == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert settings list to a map
|
||||||
|
Map<String, Object> settingMap = content.getSettings().stream()
|
||||||
|
.collect(Collectors.toMap(SettingResponseBean::getName, SettingResponseBean::getValue, (v1, v2) -> v1));
|
||||||
|
|
||||||
|
String fieldType = content.getName();
|
||||||
|
|
||||||
|
// Define handlers for different (fieldType + settingName) combinations
|
||||||
|
Map<String, Runnable> handlers = new HashMap<>();
|
||||||
|
|
||||||
|
// Add handler for isRequestedAmount
|
||||||
|
if ("numberinput".equals(fieldType) && Boolean.TRUE.equals(settingMap.get("isRequestedAmount"))) {
|
||||||
|
handlers.put("isRequestedAmount", () -> {
|
||||||
|
try {
|
||||||
|
BigDecimal amountRequested = new BigDecimal(fieldValue.toString());
|
||||||
|
applicationFormEntity.getApplication().setAmountRequested(amountRequested);
|
||||||
|
log.info("Set amountRequested to {} for Application ID: {}", amountRequested, applicationFormEntity.getApplication().getId());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.error("Invalid number format for requested amount: {}", fieldValue, e);
|
||||||
|
throw new IllegalArgumentException("Field value is not a valid number: " + fieldValue, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add handler for isPecEmail
|
||||||
|
if ("textinput".equals(fieldType) && Boolean.TRUE.equals(settingMap.get("isPecEmail"))) {
|
||||||
|
handlers.put("isPecEmail", () -> {
|
||||||
|
applicationFormEntity.getApplication().setPecEmail(fieldValue.toString());
|
||||||
|
log.info("Set PEC to {} for Application ID: {}", fieldValue, applicationFormEntity.getApplication().getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run all applicable handlers
|
||||||
|
handlers.values().forEach(Runnable::run);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
ApplicationFormFieldEntity oldApplicationFormFieldData = null;
|
ApplicationFormFieldEntity oldApplicationFormFieldData = null;
|
||||||
|
|||||||
@@ -138,6 +138,9 @@ public class AppointmentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationDao applicationEvaluationDao;
|
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NdganagRepository ndganagRepository;
|
||||||
|
|
||||||
private final Map<Long, ScheduledExecutorService> executorMap = new ConcurrentHashMap<>();
|
private final Map<Long, ScheduledExecutorService> executorMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
@@ -535,7 +538,13 @@ public class AppointmentDao {
|
|||||||
String authorizationToken = getBearerToken(hub);
|
String authorizationToken = getBearerToken(hub);
|
||||||
|
|
||||||
// Try retrieving NDG by VAT number
|
// Try retrieving NDG by VAT number
|
||||||
AppointmentLoginResponse ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application);
|
NdganagEntity ndganagEntity = ndganagRepository.findByVatNumber(company.getVatNumber());
|
||||||
|
AppointmentLoginResponse ndgResponse=new AppointmentLoginResponse();
|
||||||
|
if (ndganagEntity != null || ndganagEntity.getNdg() != null) {
|
||||||
|
ndgResponse.setNdg(ndganagEntity.getNdg());
|
||||||
|
}else {
|
||||||
|
ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application);
|
||||||
|
}
|
||||||
if (isNdgValid(ndgResponse.getNdg())) {
|
if (isNdgValid(ndgResponse.getNdg())) {
|
||||||
saveNdg(application, company, ndgResponse.getNdg());
|
saveNdg(application, company, ndgResponse.getNdg());
|
||||||
log.info("NDG successfully generated for applicationId: {}", applicationId);
|
log.info("NDG successfully generated for applicationId: {}", applicationId);
|
||||||
@@ -716,10 +725,7 @@ public class AppointmentDao {
|
|||||||
try {
|
try {
|
||||||
log.info("Initiating NDG retrieval by VAT number | ApplicationId: {}, HubId: {}, VAT: {}", application.getId(), hub.getId(), vatNumber);
|
log.info("Initiating NDG retrieval by VAT number | ApplicationId: {}, HubId: {}, VAT: {}", application.getId(), hub.getId(), vatNumber);
|
||||||
// Prepare the NDG request
|
// Prepare the NDG request
|
||||||
AppointmentNdgRequest ndgRequest = getAppointmentNdgRequest(vatNumber);
|
String responseJson = getNdgFromExternalService(vatNumber, authorizationToken);
|
||||||
// Call the API to retrieve NDG
|
|
||||||
ResponseEntity<Object> response = appointmentApiService.getNdgByVatNumber(ndgRequest, authorizationToken);
|
|
||||||
String responseJson = Utils.convertObjectToJson(response.getBody());
|
|
||||||
// Parse and return the NDG response
|
// Parse and return the NDG response
|
||||||
return parseNdgResponse(responseJson);
|
return parseNdgResponse(responseJson);
|
||||||
} catch (FeignException.Forbidden forbiddenException) {
|
} catch (FeignException.Forbidden forbiddenException) {
|
||||||
@@ -875,30 +881,38 @@ public class AppointmentDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AppointmentLoginResponse parseNdgResponse(String jsonResponse) {
|
public AppointmentLoginResponse parseNdgResponse(String jsonResponse) {
|
||||||
|
AppointmentLoginResponse loginResponse = new AppointmentLoginResponse();
|
||||||
|
String ndg=extractNdg(jsonResponse);
|
||||||
|
if (ndg==null){ return null;}
|
||||||
|
else {
|
||||||
|
loginResponse.setNdg(ndg);
|
||||||
|
}
|
||||||
|
return loginResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractNdg(String jsonResponse) {
|
||||||
try {
|
try {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode rootNode = objectMapper.readTree(jsonResponse);
|
JsonNode rootNode = objectMapper.readTree(jsonResponse);
|
||||||
JsonNode dataArray = rootNode.get(GepafinConstant.DATA_STRING);
|
JsonNode dataArray = rootNode.get(GepafinConstant.DATA_STRING);
|
||||||
if (dataArray == null || !dataArray.isArray() || dataArray.isEmpty()) {
|
if (dataArray == null || !dataArray.isArray() || dataArray.isEmpty()) {
|
||||||
log.info("NDG data is empty or missing in the response.");
|
log.info("NDG data is empty or missing in the response.");
|
||||||
AppointmentLoginResponse emptyResponse = new AppointmentLoginResponse();
|
return null;
|
||||||
emptyResponse.setNdg(null);
|
|
||||||
return emptyResponse;
|
|
||||||
}
|
}
|
||||||
JsonNode firstDataEntry = dataArray.get(0);
|
JsonNode firstDataEntry = dataArray.get(0);
|
||||||
AppointmentLoginResponse response = new AppointmentLoginResponse();
|
AppointmentLoginResponse response = new AppointmentLoginResponse();
|
||||||
if (firstDataEntry.has(GepafinConstant.NDG_STRING)) {
|
if (firstDataEntry.has(GepafinConstant.NDG_STRING)) {
|
||||||
response.setNdg(normalizeNullValue(firstDataEntry.get(GepafinConstant.NDG_STRING).asText()));
|
String ndg=normalizeNullValue(firstDataEntry.get(GepafinConstant.NDG_STRING).asText());
|
||||||
|
return ndg;
|
||||||
}
|
}
|
||||||
return response;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to parse response: {}", e.getMessage(), e);
|
log.error("Failed to parse response: {}", e.getMessage(), e);
|
||||||
throw new RuntimeException("Failed to parse NDG response.", e);
|
throw new RuntimeException("Failed to parse NDG response.", e);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String normalizeNullValue(String value) {
|
public String normalizeNullValue(String value) {
|
||||||
|
|
||||||
return (value == null || GepafinConstant.NULL_STRING.equalsIgnoreCase(value.trim())) ? null : value;
|
return (value == null || GepafinConstant.NULL_STRING.equalsIgnoreCase(value.trim())) ? null : value;
|
||||||
}
|
}
|
||||||
@@ -1415,5 +1429,54 @@ public class AppointmentDao {
|
|||||||
futureRef.set(future);
|
futureRef.set(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NdgResponse getNdgByVatNumber(String vatNumber, UserEntity userEntity) {
|
||||||
|
HubEntity hub=userEntity.getHub();
|
||||||
|
NdganagEntity ndganagEntity = ndganagRepository.findByVatNumber(vatNumber);
|
||||||
|
NdgResponse ndgResponse=new NdgResponse();
|
||||||
|
String jsonResponse=null;
|
||||||
|
String authorizationToken = hub.getAppointmentAuthTokenId();
|
||||||
|
if (ndganagEntity == null || ndganagEntity.getNdg() == null) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("Initiating NDG retrieval by VAT number | HubId: {}, VAT: {}", hub.getId(), vatNumber);
|
||||||
|
// Prepare the NDG request
|
||||||
|
jsonResponse=getNdgFromExternalService(vatNumber, authorizationToken);
|
||||||
|
checkAndSaveNdg(jsonResponse, ndgResponse);
|
||||||
|
// Parse and return the NDG response
|
||||||
|
} catch (FeignException.Forbidden forbiddenException) {
|
||||||
|
log.error("403 Forbidden during NDG retrieval | HubId: {}", hub.getId());
|
||||||
|
logForbiddenError();
|
||||||
|
// Regenerate the token and retry
|
||||||
|
String newAuthorizationToken = regenerateTokenAndSave(hub, null);
|
||||||
|
jsonResponse= getNdgFromExternalService(vatNumber,newAuthorizationToken);
|
||||||
|
if (checkAndSaveNdg(jsonResponse, ndgResponse)) return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error during NDG retrieval |, HubId: {}, Message: {}", hub.getId(), e.getMessage(), e);
|
||||||
|
throw new RuntimeException("NDG retrieval failed.", e);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
ndgResponse.setNdg(ndganagEntity.getNdg());
|
||||||
|
}
|
||||||
|
return ndgResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkAndSaveNdg(String jsonResponse, NdgResponse ndgResponse) {
|
||||||
|
String ndg=extractNdg(jsonResponse);
|
||||||
|
if (ndg==null){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ndgResponse.setNdg(ndg);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNdgFromExternalService(String vatNumber, String authorizationToken) {
|
||||||
|
AppointmentNdgRequest ndgRequest = getAppointmentNdgRequest(vatNumber);
|
||||||
|
// Call the API to retrieve NDG
|
||||||
|
ResponseEntity<Object> response = appointmentApiService.getNdgByVatNumber(ndgRequest, authorizationToken);
|
||||||
|
String responseJson = Utils.convertObjectToJson(response.getBody());
|
||||||
|
return responseJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.dao;
|
|||||||
|
|
||||||
import org.springframework.data.domain.Pageable; // Correct package
|
import org.springframework.data.domain.Pageable; // Correct package
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -413,7 +414,7 @@ public class CompanyDao {
|
|||||||
Translator.toLocale(GepafinConstant.INVALID_LIMIT));
|
Translator.toLocale(GepafinConstant.INVALID_LIMIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
int successfulUpdates = 0;
|
int successfulUpdates = 0;
|
||||||
int failedUpdates = 0;
|
int failedUpdates = 0;
|
||||||
int invalidVatNumbers = 0;
|
int invalidVatNumbers = 0;
|
||||||
|
|
||||||
@@ -531,7 +532,11 @@ public class CompanyDao {
|
|||||||
Map<String, Object> dataMap = Utils.extractMap(companyDataMap, "data");
|
Map<String, Object> dataMap = Utils.extractMap(companyDataMap, "data");
|
||||||
Object dataObj = companyDataMap.get("data");
|
Object dataObj = companyDataMap.get("data");
|
||||||
|
|
||||||
if (dataMap == null) {
|
if (dataObj instanceof Map<?, ?> singleMap) {
|
||||||
|
dataMap = (Map<String, Object>) singleMap;
|
||||||
|
} else if (dataObj instanceof List<?> list && !list.isEmpty() && list.get(0) instanceof Map<?, ?> firstMap) {
|
||||||
|
dataMap = (Map<String, Object>) firstMap;
|
||||||
|
} else {
|
||||||
log.warn("Company ID {}: 'data' section is missing or invalid in the JSON.", company.getId());
|
log.warn("Company ID {}: 'data' section is missing or invalid in the JSON.", company.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -540,11 +545,11 @@ public class CompanyDao {
|
|||||||
updateCodiceAtecoField(company);
|
updateCodiceAtecoField(company);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Object pecEmail = Utils.extractMap(dataMap, "pec");
|
Object pecEmail = dataMap.get("pec");
|
||||||
if (pecEmail == null) {
|
if (pecEmail == null) {
|
||||||
log.warn("Company ID {}: 'pec' section is missing or invalid.", company.getId());
|
log.warn("Company ID {}: 'pec' section is missing or invalid.", company.getId());
|
||||||
company.setPec((String) pecEmail);
|
|
||||||
}
|
}
|
||||||
|
company.setPec((String) pecEmail);
|
||||||
|
|
||||||
// Extract 'atecoClassification' section
|
// Extract 'atecoClassification' section
|
||||||
Map<String, Object> atecoClassificationMap = Utils.extractMap(dataMap, "atecoClassification");
|
Map<String, Object> atecoClassificationMap = Utils.extractMap(dataMap, "atecoClassification");
|
||||||
@@ -577,49 +582,79 @@ public class CompanyDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getCompanyEntity() {
|
public void getCompanyEntity() {
|
||||||
List<CompanyEntity> companyEntities=companyRepository.findAll();
|
List<CompanyEntity> companyEntities=companyRepository.findByJsonIsNotNullAndPecIsNull();
|
||||||
|
List<CompanyEntity> companyEntityList=new ArrayList<>();
|
||||||
for (CompanyEntity company:companyEntities){
|
for (CompanyEntity company:companyEntities){
|
||||||
if(company.getJson()!=null){
|
if(company.getJson()!=null && company.getPec()==null){
|
||||||
if (company == null || company.getJson() == null || company.getJson().isEmpty()) {
|
if (company == null || company.getJson() == null || company.getJson().isEmpty()) {
|
||||||
log.warn("Company is null or JSON data is empty.");
|
log.warn("Company is null or JSON data is empty.");
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
Map<String, Object> vatCheckResponse = Utils.convertJsonStringToMap(company.getJson());
|
Map<String, Object> vatCheckResponse = Utils.convertJsonStringToMap(company.getJson());
|
||||||
|
|
||||||
if (vatCheckResponse == null) {
|
if (vatCheckResponse == null) {
|
||||||
log.warn("Company ID {}: Invalid JSON response.", company.getId());
|
log.warn("Company ID {}: Invalid JSON response.", company.getId());
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
Map<String, Object> companyDataMap = Utils.convertJsonStringToMap(company.getJson());
|
Map<String, Object> companyDataMap = Utils.convertJsonStringToMap(company.getJson());
|
||||||
if (companyDataMap == null) {
|
if (companyDataMap == null) {
|
||||||
log.warn("Company ID {}: Failed to parse JSON data.", company.getId());
|
log.warn("Company ID {}: Failed to parse JSON data.", company.getId());
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object dataObj = vatCheckResponse.get("data");
|
Object dataObj = vatCheckResponse.get("data");
|
||||||
if (!(dataObj instanceof Map<?, ?> dataMap)) {
|
Map<String, Object> dataMap=null;
|
||||||
log.warn("Company ID {}: 'data' is missing or not a valid object.", company.getId());
|
// if (!(dataObj instanceof Map<?, ?> dataMap)) {
|
||||||
return;
|
// log.warn("Company ID {}: 'data' is missing or not a valid object.", company.getId());
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (dataObj instanceof Map<?, ?> singleMap) {
|
||||||
|
dataMap = (Map<String, Object>) singleMap;
|
||||||
|
} else if (dataObj instanceof List<?> list && !list.isEmpty() && list.get(0) instanceof Map<?, ?> firstMap) {
|
||||||
|
dataMap = (Map<String, Object>) firstMap;
|
||||||
|
} else {
|
||||||
|
log.warn("Company ID {}: 'data' section is missing or invalid in the JSON.", company.getId());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (dataMap.containsKey("pec")) {
|
||||||
|
Object pecEmailObj = dataMap.get("pec");
|
||||||
|
if (pecEmailObj instanceof String pec && !pec.isEmpty()) {
|
||||||
|
company.setPec(pec); // Only set if valid string
|
||||||
|
companyEntityList.add(company);
|
||||||
|
} else {
|
||||||
|
log.warn("Company ID {}: 'pec' is missing, empty, or not a string.", company.getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!dataMap.containsKey("dettaglio")) {
|
if (!dataMap.containsKey("dettaglio")) {
|
||||||
log.warn("Company ID {}: 'dettaglio' not present inside 'data'. Skipping codiceAteco update.", company.getId());
|
log.warn("Company ID {}: 'dettaglio' not present inside 'data'. Skipping codiceAteco update.", company.getId());
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object dettaglioObj = dataMap.get("dettaglio");
|
Object dettaglioObj = dataMap.get("dettaglio");
|
||||||
if (!(dettaglioObj instanceof Map<?, ?> dettaglio)) {
|
if (!(dettaglioObj instanceof Map<?, ?> dettaglio)) {
|
||||||
log.warn("Company ID {}: 'dettaglio' is not a valid object.", company.getId());
|
log.warn("Company ID {}: 'dettaglio' is not a valid object.", company.getId());
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object pecEmailObj = dettaglio.get("pec");
|
Object pecEmailObj = dettaglio.get("pec");
|
||||||
if (pecEmailObj instanceof String pec && !pec.isEmpty()) {
|
if (pecEmailObj instanceof String pec && !pec.isEmpty()) {
|
||||||
company.setPec(pec); // Only set if valid string
|
if(pec!=null) {
|
||||||
|
company.setPec(pec); // Only set if valid string
|
||||||
|
companyEntityList.add(company);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Company ID {}: 'pec' is missing, empty, or not a string.", company.getId());
|
log.warn("Company ID {}: 'pec' is missing, empty, or not a string.", company.getId());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
companyRepository.saveAll(companyEntityList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,4 +73,7 @@ public class ApplicationEntity extends BaseEntity {
|
|||||||
@Column(name = "APPLICATION_EVALUATION_ID")
|
@Column(name = "APPLICATION_EVALUATION_ID")
|
||||||
private Long applicationEvaluationId;
|
private Long applicationEvaluationId;
|
||||||
|
|
||||||
|
@Column(name = "PEC_EMAIL")
|
||||||
|
private String pecEmail;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.annotations.Where;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "NDGANAG")
|
||||||
|
@Data
|
||||||
|
@Where(clause = "is_deleted = false")
|
||||||
|
public class NdganagEntity extends BaseEntity{
|
||||||
|
|
||||||
|
@Column(name = "NDG")
|
||||||
|
private String ndg;
|
||||||
|
|
||||||
|
@Column(name = "COMPANY_NAME")
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
|
@Column(name = "VAT_NUMBER")
|
||||||
|
private String vatNumber;
|
||||||
|
|
||||||
|
@Column(name = "CODICE_FISCALE")
|
||||||
|
private String codiceFiscale;
|
||||||
|
|
||||||
|
@Column(name = "JSON")
|
||||||
|
private String json;
|
||||||
|
|
||||||
|
@Column(name = "IS_DELETED")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -67,6 +67,7 @@ public enum UserActionContextEnum {
|
|||||||
GET_COMPANY_BY_USER("GET_COMPANY_BY_USER"),
|
GET_COMPANY_BY_USER("GET_COMPANY_BY_USER"),
|
||||||
REMOVE_COMPANY_FROM_USER("REMOVE_COMPANY_FROM_USER"),
|
REMOVE_COMPANY_FROM_USER("REMOVE_COMPANY_FROM_USER"),
|
||||||
UPDATE_COMPANY_JSON("UPDATE_COMPANY_JSON"),
|
UPDATE_COMPANY_JSON("UPDATE_COMPANY_JSON"),
|
||||||
|
EXTRACT_PEC_FROM_COMPANY("EXTRACT_PEC_FROM_COMPANY"),
|
||||||
|
|
||||||
/** LookUpData action context **/
|
/** LookUpData action context **/
|
||||||
CREATE_LOOKUP_DATA("CREATE_LOOKUP_DATA"),
|
CREATE_LOOKUP_DATA("CREATE_LOOKUP_DATA"),
|
||||||
@@ -180,6 +181,7 @@ public enum UserActionContextEnum {
|
|||||||
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_NDG_BY_VAT_NUMBER("GET_NDG_BY_VAT_NUMBER"),
|
||||||
|
|
||||||
GET_ALL_NOTIFICATION_BY_PAGINATION("GET_ALL_NOTIFICATION_BY_PAGINATION"),
|
GET_ALL_NOTIFICATION_BY_PAGINATION("GET_ALL_NOTIFICATION_BY_PAGINATION"),
|
||||||
GET_ALL_CALL_BY_PAGINATION("GET_ALL_CALL_BY_PAGINATION"),
|
GET_ALL_CALL_BY_PAGINATION("GET_ALL_CALL_BY_PAGINATION"),
|
||||||
|
|||||||
@@ -31,5 +31,7 @@ public interface CompanyRepository extends JpaRepository<CompanyEntity, Long> {
|
|||||||
""")
|
""")
|
||||||
Page<CompanyEntity> findCompaniesWithMissingVatCheck(Pageable pageable);
|
Page<CompanyEntity> findCompaniesWithMissingVatCheck(Pageable pageable);
|
||||||
|
|
||||||
|
List<CompanyEntity> findByJsonIsNotNullAndPecIsNull();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.NdganagEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface NdganagRepository extends JpaRepository<NdganagEntity,Long> {
|
||||||
|
|
||||||
|
NdganagEntity findByVatNumber(String vatNumber);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,4 +13,7 @@ public interface AppointmentService {
|
|||||||
AppointmentCreationResponse createAppointmentForApplication(HttpServletRequest request, Long applicationId, CreateAppointmentRequest createAppointmentRequest);
|
AppointmentCreationResponse createAppointmentForApplication(HttpServletRequest request, Long applicationId, CreateAppointmentRequest createAppointmentRequest);
|
||||||
|
|
||||||
DocumentUploadResponse uploadDocToExternalSystem(HttpServletRequest request, Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest);
|
DocumentUploadResponse uploadDocToExternalSystem(HttpServletRequest request, Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest);
|
||||||
|
|
||||||
|
NdgResponse getNdgByVatNumber(HttpServletRequest request,String vatNumber);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,4 +47,5 @@ public interface CompanyService {
|
|||||||
|
|
||||||
void updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest);
|
void updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest);
|
||||||
|
|
||||||
|
void extractPecFromJson(HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ package net.gepafin.tendermanagement.service.impl;
|
|||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.dao.AppointmentDao;
|
import net.gepafin.tendermanagement.dao.AppointmentDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.model.request.CreateAppointmentRequest;
|
import net.gepafin.tendermanagement.model.request.CreateAppointmentRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.UploadDocToExternalSystemRequest;
|
import net.gepafin.tendermanagement.model.request.UploadDocToExternalSystemRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.AppointmentCreationResponse;
|
import net.gepafin.tendermanagement.model.response.AppointmentCreationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.DocumentUploadResponse;
|
import net.gepafin.tendermanagement.model.response.DocumentUploadResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.NdgResponse;
|
import net.gepafin.tendermanagement.model.response.NdgResponse;
|
||||||
import net.gepafin.tendermanagement.service.AppointmentService;
|
import net.gepafin.tendermanagement.service.AppointmentService;
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -17,6 +19,9 @@ public class AppointmentServiceImpl implements AppointmentService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AppointmentDao appointmentDao;
|
private AppointmentDao appointmentDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NdgResponse checkNdgForAppointment(HttpServletRequest request, Long applicationId) {
|
public NdgResponse checkNdgForAppointment(HttpServletRequest request, Long applicationId) {
|
||||||
|
|
||||||
@@ -34,4 +39,11 @@ public class AppointmentServiceImpl implements AppointmentService {
|
|||||||
|
|
||||||
return appointmentDao.uploadDocumentToExternalSystem(documentId, docToExternalSystemRequest);
|
return appointmentDao.uploadDocumentToExternalSystem(documentId, docToExternalSystemRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NdgResponse getNdgByVatNumber(HttpServletRequest request,String vatNumber) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
NdgResponse ndgResponse= appointmentDao.getNdgByVatNumber(vatNumber,userEntity);
|
||||||
|
return ndgResponse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,12 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
@Override
|
@Override
|
||||||
public void updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest) {
|
public void updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest) {
|
||||||
UserEntity userEntity =validator.validateUser(request);
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
companyDao.updateMissingVatCheckResponses(request, limitRequest);
|
companyDao.updateMissingVatCheckResponses(request,limitRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void extractPecFromJson(HttpServletRequest request) {
|
||||||
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
|
companyDao.getCompanyEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,4 +56,15 @@ public interface AppointmentApi {
|
|||||||
ResponseEntity<Response<DocumentUploadResponse>> uploadDocumentToExternalSystem(HttpServletRequest request,
|
ResponseEntity<Response<DocumentUploadResponse>> uploadDocumentToExternalSystem(HttpServletRequest request,
|
||||||
@Parameter(description = "The document id", required = true) @PathVariable(value = "documentId", required = true) Long documentId,
|
@Parameter(description = "The document id", required = true) @PathVariable(value = "documentId", required = true) Long documentId,
|
||||||
@RequestBody UploadDocToExternalSystemRequest docToExternalSystemRequest);
|
@RequestBody UploadDocToExternalSystemRequest docToExternalSystemRequest);
|
||||||
|
|
||||||
|
@Operation(summary = "API to get ndg by vatNumber", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
|
@GetMapping(value = "/vatNumber/{vatNumber}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
ResponseEntity<Response<NdgResponse>> getNdgByVatNumber(HttpServletRequest request,@PathVariable(value = "vatNumber", required = true) @Parameter(description = "vatNumber",required = true)String vatNumber);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,4 +169,17 @@ public interface CompanyApi {
|
|||||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') ")
|
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') ")
|
||||||
ResponseEntity<Response<Void>> updateMissingVatCheckResponses(HttpServletRequest request,
|
ResponseEntity<Response<Void>> updateMissingVatCheckResponses(HttpServletRequest request,
|
||||||
@Parameter(description = "Limit request object ", required = true) @RequestBody LimitRequest limitRequest);
|
@Parameter(description = "Limit request object ", required = true) @RequestBody LimitRequest limitRequest);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to extract pec from the company json", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
|
@GetMapping(value = "/pec", produces = { "application/json" })
|
||||||
|
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') ")
|
||||||
|
ResponseEntity<Response<Void>> extractPecFromJson(HttpServletRequest request);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import net.gepafin.tendermanagement.service.AppointmentService;
|
|||||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.AppointmentApi;
|
import net.gepafin.tendermanagement.web.rest.api.AppointmentApi;
|
||||||
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.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -81,4 +82,19 @@ public class AppointmentController implements AppointmentApi {
|
|||||||
.body(new Response<>(documentUploadResponse, Status.SUCCESS, Translator.toLocale(message)));
|
.body(new Response<>(documentUploadResponse, Status.SUCCESS, Translator.toLocale(message)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<NdgResponse>> getNdgByVatNumber(HttpServletRequest request,String vatNumber) {
|
||||||
|
loggingUtil.logUserAction(
|
||||||
|
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPLOAD).actionContext(UserActionContextEnum.GET_NDG_BY_VAT_NUMBER).build());
|
||||||
|
|
||||||
|
NdgResponse ndgResponse= appointmentService.getNdgByVatNumber(request,vatNumber);
|
||||||
|
if(ndgResponse==null){
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<>(ndgResponse, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.NDG_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<>(ndgResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_FETCH_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,4 +201,17 @@ public class CompanyApiController implements CompanyApi{
|
|||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_UPDATED_SUCCESS_MSG)));
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_UPDATED_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> extractPecFromJson(HttpServletRequest request) {
|
||||||
|
|
||||||
|
log.info("Api to set pec from json field");
|
||||||
|
|
||||||
|
companyService.extractPecFromJson(request);
|
||||||
|
|
||||||
|
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.EXTRACT_PEC_FROM_COMPANY).build());
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_UPDATED_SUCCESS_MSG)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2955,4 +2955,24 @@
|
|||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="06-06-2025_RK_180524" author="Rajesh Khore">
|
||||||
|
<createTable tableName="ndganag">
|
||||||
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" primaryKeyName="ndganag_pkey" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="ndg" type="VARCHAR(255)" />
|
||||||
|
<column name="company_name" type="VARCHAR(255)"/>
|
||||||
|
<column name="vat_number" type="VARCHAR(255)" />
|
||||||
|
<column name="codice_fiscale" type="VARCHAR(255)" />
|
||||||
|
<column name="json" type="TEXT"/>
|
||||||
|
<column name="is_deleted" type="BOOLEAN"/>
|
||||||
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addColumn tableName="application">
|
||||||
|
<column name="pec_email" type="VARCHAR(255)"></column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
@@ -408,3 +408,5 @@ resend.email.sent.failed.msg = Failed to resend the email.
|
|||||||
application.readmit.success=Application has been readmitted successfully.
|
application.readmit.success=Application has been readmitted successfully.
|
||||||
no.email.log.msg = No failed emails found for given userActionId.
|
no.email.log.msg = No failed emails found for given userActionId.
|
||||||
user.action.id.not.found = User Action id not found.
|
user.action.id.not.found = User Action id not found.
|
||||||
|
ndg.not.found=NDG not found.
|
||||||
|
email.pec.cannot.null=Email pec is required.
|
||||||
|
|||||||
@@ -399,3 +399,5 @@ resend.email.sent.failed.msg = Impossibile inviare nuovamente l'e-mail.
|
|||||||
application.readmit.success=L'applicazione è stata riammessa con successo.
|
application.readmit.success=L'applicazione è stata riammessa con successo.
|
||||||
no.email.log.msg = Nessuna email trovata per userActionId specificato.
|
no.email.log.msg = Nessuna email trovata per userActionId specificato.
|
||||||
user.action.id.not.found = ID azione utente non trovato.
|
user.action.id.not.found = ID azione utente non trovato.
|
||||||
|
ndg.not.found=NDG non trovato.
|
||||||
|
email.pec.cannot.null=L'indirizzo email pec è obbligatorio.
|
||||||
|
|||||||
Reference in New Issue
Block a user