Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -3,6 +3,7 @@ package it.integry.ems.dto;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import it.integry.ems.report.dto.JasperDTO;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.DtbDocPdf;
|
||||
import it.integry.ems_model.entity.MtbAartLink;
|
||||
import it.integry.ems_model.entity.MtbUntMis;
|
||||
import it.integry.ems_model.entity.StbActivityFile;
|
||||
@@ -18,6 +19,8 @@ public class CreateZipDTO {
|
||||
|
||||
private List<MtbAartLink> listMtbAartLink;
|
||||
|
||||
private List<DtbDocPdf> listDtbDocPdf;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private SaveMode saveMode = SaveMode.STB_FILES_ATTACHED;
|
||||
@@ -51,6 +54,15 @@ public class CreateZipDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<DtbDocPdf> getListDtbDocPdf() {
|
||||
return listDtbDocPdf;
|
||||
}
|
||||
|
||||
public CreateZipDTO setListDtbDocPdf(List<DtbDocPdf> listDtbDocPdf) {
|
||||
this.listDtbDocPdf = listDtbDocPdf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@@ -685,6 +685,22 @@ public class EmsServices {
|
||||
}
|
||||
}
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(createZipDTO.getListDtbDocPdf())){
|
||||
List<DtbDocPdf> listDtbDocPdf = createZipDTO.getListDtbDocPdf().stream()
|
||||
.peek(dtbDocPdf -> dtbDocPdf.setOperation(OperationType.SELECT_OBJECT))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<EntityBase> entityBases = Collections.unmodifiableList(entityProcessor.processEntityList(listDtbDocPdf, true));
|
||||
|
||||
UtilityEntity.throwEntitiesException(entityBases);
|
||||
|
||||
listDtbDocPdf = UtilityEntity.toCustomEntity(entityBases);
|
||||
|
||||
for (DtbDocPdf dtbDocPdf : listDtbDocPdf) {
|
||||
UtilityZip.addFileToArchive(zos, dtbDocPdf.getFilename(), Base64.decodeBase64(dtbDocPdf.getFilecontentByteArr(false)));
|
||||
}
|
||||
}
|
||||
|
||||
if (baos.size() > 0) {
|
||||
zos.close();
|
||||
|
||||
|
||||
@@ -217,8 +217,9 @@ public class ContabilController {
|
||||
|
||||
@RequestMapping(value = "/checkPartitaIva", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse checkPartitaIva(HttpServletResponse response, HttpServletRequest request, @RequestBody CheckVat json) throws Exception {
|
||||
CheckVatRestResponse checkVatRestResponse = contabilService.checkVat(json.getCountryCode(), json.getVatNumber());
|
||||
ServiceRestResponse checkPartitaIva(@RequestParam(required = false, defaultValue = "true") boolean enableLocationCheck,
|
||||
@RequestBody CheckVat json) throws Exception {
|
||||
CheckVatRestResponse checkVatRestResponse = contabilService.checkVat(json.getCountryCode(), json.getVatNumber(), enableLocationCheck);
|
||||
return ServiceRestResponse.createPositiveResponse(checkVatRestResponse);
|
||||
}
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ public class ContabilService {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CheckVatRestResponse checkVat(String countryCode, String vatNumber) throws Exception {
|
||||
public CheckVatRestResponse checkVat(String countryCode, String vatNumber, boolean enableLocationCheck) throws Exception {
|
||||
String sql =
|
||||
"SELECT IsNull(cod_nazi_alpha_2, gtb_nazi.nazione) as nazione , gtb_nazi.chk_part_iva " +
|
||||
" FROM gtb_nazi INNER JOIN gtb_nazi_iso ON gtb_nazi.cod_nazione_iso = gtb_nazi_iso.cod_nazione_iso " +
|
||||
@@ -522,12 +522,12 @@ public class ContabilService {
|
||||
Boolean chkPartIva = (Boolean) datiNazione.get("chk_part_iva");
|
||||
|
||||
if (chkPartIva) {
|
||||
return checkVatNazioneIso(isoCountry, vatNumber);
|
||||
return checkVatNazioneIso(isoCountry, vatNumber, enableLocationCheck);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private CheckVatRestResponse checkVatNazioneIso(String countryCode, String vatNumber) throws Exception {
|
||||
private CheckVatRestResponse checkVatNazioneIso(String countryCode, String vatNumber, boolean enableLocationCheck) throws Exception {
|
||||
SupportedStates state = SupportedStates.fromString(countryCode);
|
||||
|
||||
if (state == null) {
|
||||
@@ -569,33 +569,35 @@ public class ContabilService {
|
||||
response.setValid(valid.value);
|
||||
|
||||
if (response.isValid()) {
|
||||
response.setCountryCode(code.value);
|
||||
response.setVatNumber(pIva.value);
|
||||
response.setRequestDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(date.value.toGregorianCalendar().getTimeInMillis())));
|
||||
if (enableLocationCheck) {
|
||||
response.setCountryCode(code.value);
|
||||
response.setVatNumber(pIva.value);
|
||||
response.setRequestDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(date.value.toGregorianCalendar().getTimeInMillis())));
|
||||
|
||||
response.setName(name.value);
|
||||
response.setAddress(address.value);
|
||||
response.setRagSoc(name.value);// alias di 'name'
|
||||
response.setName(name.value);
|
||||
response.setAddress(address.value);
|
||||
response.setRagSoc(name.value);// alias di 'name'
|
||||
|
||||
String indirizzo = null, cap = null, citta = null, prov = null;
|
||||
if (address.value != null) {
|
||||
IndirizzoDTO indirizzoDTO = null;
|
||||
try {
|
||||
indirizzoDTO = mapService.geocode(address.value);
|
||||
} catch (Exception e) {
|
||||
logger.error("checkVat", e);
|
||||
}
|
||||
if (indirizzoDTO != null) {
|
||||
indirizzo = indirizzoDTO.getIndirizzo();
|
||||
cap = indirizzoDTO.getCap();
|
||||
citta = indirizzoDTO.getCitta();
|
||||
prov = indirizzoDTO.getProv();
|
||||
String indirizzo = null, cap = null, citta = null, prov = null;
|
||||
if (address.value != null) {
|
||||
IndirizzoDTO indirizzoDTO = null;
|
||||
try {
|
||||
indirizzoDTO = mapService.geocode(address.value);
|
||||
} catch (Exception e) {
|
||||
logger.error("checkVat", e);
|
||||
}
|
||||
if (indirizzoDTO != null) {
|
||||
indirizzo = indirizzoDTO.getIndirizzo();
|
||||
cap = indirizzoDTO.getCap();
|
||||
citta = indirizzoDTO.getCitta();
|
||||
prov = indirizzoDTO.getProv();
|
||||
}
|
||||
}
|
||||
response.setIndirizzo(indirizzo);
|
||||
response.setCap(cap);
|
||||
response.setCitta(citta);
|
||||
response.setProv(prov);
|
||||
}
|
||||
response.setIndirizzo(indirizzo);
|
||||
response.setCap(cap);
|
||||
response.setCitta(citta);
|
||||
response.setProv(prov);
|
||||
|
||||
} else {
|
||||
throw new CheckVatException(String.format("Partita IVA %s [Stato: %s] non registrata al VIES", partitaIVA, countryCode));
|
||||
|
||||
@@ -1661,13 +1661,16 @@ public class SystemController {
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/system/test", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/system/test", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse systemTest() throws Exception {
|
||||
|
||||
mailService.sendErrorMail(multiDBTransactionManager, "g.scorrano@integry.it", "Test",
|
||||
"Test email", null, null, null,
|
||||
Collections.singletonList(new NotValidLicenseException()));
|
||||
Thread.sleep(10 * 60 * 1000);
|
||||
|
||||
|
||||
// mailService.sendErrorMail(multiDBTransactionManager, "g.scorrano@integry.it", "Test",
|
||||
// "Test email", null, null, null,
|
||||
// Collections.singletonList(new NotValidLicenseException()));
|
||||
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
|
||||
@@ -30,13 +30,28 @@ public class ExchangeDocumentImportController {
|
||||
|
||||
@RequestMapping(value = "importLavorazione", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse importDocumentiLavorazione(HttpServletRequest request,
|
||||
ServiceRestResponse importLavorazione(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||
@RequestParam() String profileDbExchange) throws Exception {
|
||||
|
||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
|
||||
MultiDBTransactionManager exchangeDb = new MultiDBTransactionManager(profileDbExchange)) {
|
||||
exchangeDocumentImportService.importTestateDocumentiLavorazione(internalDb, exchangeDb, requestDataDTO);
|
||||
exchangeDocumentImportService.importLavorazione(internalDb, exchangeDb, requestDataDTO);
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "importVendita", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse importVendita(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||
@RequestParam() String profileDbExchange) throws Exception {
|
||||
|
||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
|
||||
MultiDBTransactionManager exchangeDb = new MultiDBTransactionManager(profileDbExchange)) {
|
||||
exchangeDocumentImportService.importVendita(internalDb, exchangeDb, requestDataDTO);
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@@ -43,16 +43,39 @@ public class ExchangeDocumentImportService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public void importTestateDocumentiLavorazione(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
|
||||
|
||||
public void importLavorazione(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
|
||||
this.internalImport(internalMultiDb, exchangeMultiDb, requestDataDTO, ExchangeImportSchemaManagerService.SchemaType.DocumentiLavorazione);
|
||||
}
|
||||
|
||||
public void importVendita(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
|
||||
this.internalImport(internalMultiDb, exchangeMultiDb, requestDataDTO, ExchangeImportSchemaManagerService.SchemaType.DocumentiVendita);
|
||||
}
|
||||
|
||||
private void internalImport(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO, ExchangeImportSchemaManagerService.SchemaType schemaType) throws Exception {
|
||||
|
||||
boolean useTempTable = true;
|
||||
ExchangeImportSchemaManagerService.SchemaType schemaType = ExchangeImportSchemaManagerService.SchemaType.DocumentiLavorazione;
|
||||
|
||||
try {
|
||||
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), schemaType, useTempTable);
|
||||
exchangeImportDataManagerService.prepareData(exchangeMultiDb.getPrimaryConnection(), useTempTable,
|
||||
exchangeImportSchemaManagerService.getTablesBySchemaType(schemaType));
|
||||
|
||||
String testataTableName;
|
||||
String righeTableName;
|
||||
|
||||
if (schemaType == ExchangeImportSchemaManagerService.SchemaType.DocumentiLavorazione) {
|
||||
testataTableName = "dtb_doct_lav";
|
||||
righeTableName = "dtb_docr_lav";
|
||||
|
||||
} else if (schemaType == ExchangeImportSchemaManagerService.SchemaType.DocumentiVendita) {
|
||||
testataTableName = "dtb_doct_vend";
|
||||
righeTableName = "dtb_docr_vend";
|
||||
} else {
|
||||
righeTableName = null;
|
||||
testataTableName = null;
|
||||
}
|
||||
|
||||
AtomicInteger dataCount = new AtomicInteger(0);
|
||||
AtomicInteger importedCounter = new AtomicInteger(0);
|
||||
|
||||
@@ -66,30 +89,30 @@ public class ExchangeDocumentImportService {
|
||||
|
||||
startDate = startDate.plusDays(1);
|
||||
|
||||
final List<DtbDoct> exchangeImportedTestateData = importTestateDocumentiLavorazione(
|
||||
final List<DtbDoct> exchangeImportedTestateData = importTestateDocumenti(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
tempStartDate,
|
||||
tempEndDate,
|
||||
true, false);
|
||||
true, false, testataTableName);
|
||||
|
||||
final List<DtbDoct> exchangeUpdatedTestateData = importTestateDocumentiLavorazione(
|
||||
final List<DtbDoct> exchangeUpdatedTestateData = importTestateDocumenti(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
tempStartDate,
|
||||
tempEndDate,
|
||||
false, useTempTable);
|
||||
false, useTempTable, testataTableName);
|
||||
|
||||
|
||||
final List<DtbDocr> exchangeImportedRigheData = importRigheDocumentiLavorazione(
|
||||
final List<DtbDocr> exchangeImportedRigheData = importRigheDocumenti(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
tempStartDate,
|
||||
tempEndDate,
|
||||
true, false);
|
||||
true, false, righeTableName);
|
||||
|
||||
final List<DtbDocr> exchangeUpdatedRigheData = importRigheDocumentiLavorazione(
|
||||
final List<DtbDocr> exchangeUpdatedRigheData = importRigheDocumenti(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
tempStartDate,
|
||||
tempEndDate,
|
||||
false, useTempTable);
|
||||
false, useTempTable, righeTableName);
|
||||
|
||||
List<EquatableEntityInterface> allTestateData = exchangeImportDataManagerService
|
||||
.runSync(DtbDoct.class, exchangeImportedTestateData, exchangeUpdatedTestateData);
|
||||
@@ -160,7 +183,7 @@ public class ExchangeDocumentImportService {
|
||||
//ignore error if is DELETE
|
||||
if (document.getOperation() != OperationType.DELETE) throw mergeEntityDBToObjectException;
|
||||
}
|
||||
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (DtbDoct) dataToSave, useTempTable);
|
||||
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (DtbDoct) dataToSave, useTempTable, testataTableName);
|
||||
|
||||
if (!document.getDtbDocr().isEmpty()) {
|
||||
|
||||
@@ -169,7 +192,7 @@ public class ExchangeDocumentImportService {
|
||||
entityProcessor.processEntity(document, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDb, requestDataDTO);
|
||||
}
|
||||
|
||||
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), document.getDtbDocr(), useTempTable);
|
||||
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), document.getDtbDocr(), useTempTable, righeTableName);
|
||||
}
|
||||
|
||||
internalMultiDb.commitAll();
|
||||
@@ -202,16 +225,15 @@ public class ExchangeDocumentImportService {
|
||||
}
|
||||
|
||||
|
||||
private List<DtbDoct> importTestateDocumentiLavorazione(Connection connection,
|
||||
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
|
||||
private List<DtbDoct> importTestateDocumenti(Connection connection, LocalDate minDate, LocalDate maxDate,
|
||||
boolean retrieveAlreadyImported, boolean useTempTable, String tableName) throws Exception {
|
||||
|
||||
String dtbDoctLavOriginalName = "dtb_doct_lav";
|
||||
String dtbDoctLavOriginalName = tableName;
|
||||
String dtbDoctLavTableName = dtbDoctLavOriginalName + (useTempTable ? "_tmp" : "");
|
||||
|
||||
final List<DtbDoct> dtbDoctLav = exchangeImportDataManagerService.retrieveDataFromExchange(connection, DtbDoct.class,
|
||||
dtbDoctLavTableName, Query.format("data_doc BETWEEN {} AND {}", minDate, maxDate), retrieveAlreadyImported);
|
||||
|
||||
|
||||
dtbDoctLav
|
||||
.forEach(x -> {
|
||||
x.setUserName(ROSSOGARGANO_EXCHANGE_USER);
|
||||
@@ -222,10 +244,10 @@ public class ExchangeDocumentImportService {
|
||||
}
|
||||
|
||||
|
||||
private List<DtbDocr> importRigheDocumentiLavorazione(Connection connection,
|
||||
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
|
||||
private List<DtbDocr> importRigheDocumenti(Connection connection, LocalDate minDate, LocalDate maxDate,
|
||||
boolean retrieveAlreadyImported, boolean useTempTable, String tableName) throws Exception {
|
||||
|
||||
String dtbDocrLavOriginalName = "dtb_docr_lav";
|
||||
String dtbDocrLavOriginalName = tableName;
|
||||
String dtbDocrLavTableName = dtbDocrLavOriginalName + (useTempTable ? "_tmp" : "");
|
||||
|
||||
|
||||
@@ -234,7 +256,7 @@ public class ExchangeDocumentImportService {
|
||||
}
|
||||
|
||||
|
||||
private void singleUpdateImported(Connection connection, DtbDoct importedDtbDoct, boolean useTempTable) throws Exception {
|
||||
private void singleUpdateImported(Connection connection, DtbDoct importedDtbDoct, boolean useTempTable, String tableName) throws Exception {
|
||||
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
|
||||
put("data_doc", importedDtbDoct.getDataDoc());
|
||||
put("ser_doc", importedDtbDoct.getSerDoc());
|
||||
@@ -243,10 +265,10 @@ public class ExchangeDocumentImportService {
|
||||
put("cod_dtip", importedDtbDoct.getCodDtip());
|
||||
}};
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "dtb_doct_lav", importedKey, useTempTable);
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedKey, useTempTable);
|
||||
}
|
||||
|
||||
private void singleUpdateImported(Connection connection, List<DtbDocr> importedDtbDocr, boolean useTempTable) throws Exception {
|
||||
private void singleUpdateImported(Connection connection, List<DtbDocr> importedDtbDocr, boolean useTempTable, String tableName) throws Exception {
|
||||
final List<HashMap<String, Object>> importedRowKeys = importedDtbDocr.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("data_doc", x.getDataDoc());
|
||||
@@ -256,7 +278,7 @@ public class ExchangeDocumentImportService {
|
||||
put("cod_dtip", x.getCodDtip());
|
||||
put("id_riga", x.getIdRiga());
|
||||
}}).collect(Collectors.toList());
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "dtb_docr_lav", importedRowKeys, useTempTable);
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedRowKeys, useTempTable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ public class ExchangeImportSchemaManagerService {
|
||||
VersamentoGrezzo(6),
|
||||
CampiRaccolta(7),
|
||||
BancheAziendali(8),
|
||||
ValorizzazioneCertificati(9);
|
||||
ValorizzazioneCertificati(9),
|
||||
DocumentiVendita(10),;
|
||||
|
||||
|
||||
private final int value;
|
||||
@@ -65,6 +66,7 @@ public class ExchangeImportSchemaManagerService {
|
||||
put(SchemaType.ColliLavorazione, Arrays.asList("mtb_colt_lav", "mtb_colr_lav"));
|
||||
put(SchemaType.OrdiniLavorazione, Arrays.asList("dtb_ordt_lav", "dtb_ordr_lav"));
|
||||
put(SchemaType.DocumentiLavorazione, Arrays.asList("dtb_doct_lav", "dtb_docr_lav"));
|
||||
put(SchemaType.DocumentiVendita, Arrays.asList("dtb_doct_vend", "dtb_docr_vend"));
|
||||
put(SchemaType.Articoli, Arrays.asList("mtb_aart", "mtb_grup", "mtb_sgrp", "mtb_sfam", "mtb_tipi", "mtb_aart_marchio"));
|
||||
put(SchemaType.PartiteMagazzinoLavorazione, Arrays.asList("mtb_partita_mag_lav"));
|
||||
put(SchemaType.VersamentoGrezzo, Arrays.asList("mtb_colt_versamento_grezzo", "mtb_colr_versamento_grezzo"));
|
||||
|
||||
@@ -118,7 +118,7 @@ public class ExchangeSystemManagerService {
|
||||
|
||||
case DocumentiLavorazione:
|
||||
final ExchangeDocumentImportService beanDocumentiLavorazione = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeDocumentImportService.class);
|
||||
beanDocumentiLavorazione.importTestateDocumentiLavorazione(internalDb, exchangeDb, requestDataDTO);
|
||||
beanDocumentiLavorazione.importTestateDocumenti(internalDb, exchangeDb, requestDataDTO);
|
||||
break;
|
||||
|
||||
case Articoli:
|
||||
|
||||
Reference in New Issue
Block a user