Finish Hotfix-1
This commit is contained in:
@@ -1661,13 +1661,16 @@ public class SystemController {
|
|||||||
return ServiceRestResponse.createPositiveResponse();
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/system/test", method = RequestMethod.POST)
|
@RequestMapping(value = "/system/test", method = RequestMethod.GET)
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ServiceRestResponse systemTest() throws Exception {
|
ServiceRestResponse systemTest() throws Exception {
|
||||||
|
|
||||||
mailService.sendErrorMail(multiDBTransactionManager, "g.scorrano@integry.it", "Test",
|
Thread.sleep(10 * 60 * 1000);
|
||||||
"Test email", null, null, null,
|
|
||||||
Collections.singletonList(new NotValidLicenseException()));
|
|
||||||
|
// mailService.sendErrorMail(multiDBTransactionManager, "g.scorrano@integry.it", "Test",
|
||||||
|
// "Test email", null, null, null,
|
||||||
|
// Collections.singletonList(new NotValidLicenseException()));
|
||||||
|
|
||||||
|
|
||||||
return ServiceRestResponse.createPositiveResponse();
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
|||||||
@@ -30,13 +30,28 @@ public class ExchangeDocumentImportController {
|
|||||||
|
|
||||||
@RequestMapping(value = "importLavorazione", method = RequestMethod.GET)
|
@RequestMapping(value = "importLavorazione", method = RequestMethod.GET)
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ServiceRestResponse importDocumentiLavorazione(HttpServletRequest request,
|
ServiceRestResponse importLavorazione(HttpServletRequest request,
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||||
@RequestParam() String profileDbExchange) throws Exception {
|
@RequestParam() String profileDbExchange) throws Exception {
|
||||||
|
|
||||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
|
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
|
||||||
MultiDBTransactionManager exchangeDb = new MultiDBTransactionManager(profileDbExchange)) {
|
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();
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,16 +43,39 @@ public class ExchangeDocumentImportService {
|
|||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
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;
|
boolean useTempTable = true;
|
||||||
ExchangeImportSchemaManagerService.SchemaType schemaType = ExchangeImportSchemaManagerService.SchemaType.DocumentiLavorazione;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), schemaType, useTempTable);
|
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), schemaType, useTempTable);
|
||||||
exchangeImportDataManagerService.prepareData(exchangeMultiDb.getPrimaryConnection(), useTempTable,
|
exchangeImportDataManagerService.prepareData(exchangeMultiDb.getPrimaryConnection(), useTempTable,
|
||||||
exchangeImportSchemaManagerService.getTablesBySchemaType(schemaType));
|
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 dataCount = new AtomicInteger(0);
|
||||||
AtomicInteger importedCounter = new AtomicInteger(0);
|
AtomicInteger importedCounter = new AtomicInteger(0);
|
||||||
|
|
||||||
@@ -66,30 +89,30 @@ public class ExchangeDocumentImportService {
|
|||||||
|
|
||||||
startDate = startDate.plusDays(1);
|
startDate = startDate.plusDays(1);
|
||||||
|
|
||||||
final List<DtbDoct> exchangeImportedTestateData = importTestateDocumentiLavorazione(
|
final List<DtbDoct> exchangeImportedTestateData = importTestateDocumenti(
|
||||||
exchangeMultiDb.getPrimaryConnection(),
|
exchangeMultiDb.getPrimaryConnection(),
|
||||||
tempStartDate,
|
tempStartDate,
|
||||||
tempEndDate,
|
tempEndDate,
|
||||||
true, false);
|
true, false, testataTableName);
|
||||||
|
|
||||||
final List<DtbDoct> exchangeUpdatedTestateData = importTestateDocumentiLavorazione(
|
final List<DtbDoct> exchangeUpdatedTestateData = importTestateDocumenti(
|
||||||
exchangeMultiDb.getPrimaryConnection(),
|
exchangeMultiDb.getPrimaryConnection(),
|
||||||
tempStartDate,
|
tempStartDate,
|
||||||
tempEndDate,
|
tempEndDate,
|
||||||
false, useTempTable);
|
false, useTempTable, testataTableName);
|
||||||
|
|
||||||
|
|
||||||
final List<DtbDocr> exchangeImportedRigheData = importRigheDocumentiLavorazione(
|
final List<DtbDocr> exchangeImportedRigheData = importRigheDocumenti(
|
||||||
exchangeMultiDb.getPrimaryConnection(),
|
exchangeMultiDb.getPrimaryConnection(),
|
||||||
tempStartDate,
|
tempStartDate,
|
||||||
tempEndDate,
|
tempEndDate,
|
||||||
true, false);
|
true, false, righeTableName);
|
||||||
|
|
||||||
final List<DtbDocr> exchangeUpdatedRigheData = importRigheDocumentiLavorazione(
|
final List<DtbDocr> exchangeUpdatedRigheData = importRigheDocumenti(
|
||||||
exchangeMultiDb.getPrimaryConnection(),
|
exchangeMultiDb.getPrimaryConnection(),
|
||||||
tempStartDate,
|
tempStartDate,
|
||||||
tempEndDate,
|
tempEndDate,
|
||||||
false, useTempTable);
|
false, useTempTable, righeTableName);
|
||||||
|
|
||||||
List<EquatableEntityInterface> allTestateData = exchangeImportDataManagerService
|
List<EquatableEntityInterface> allTestateData = exchangeImportDataManagerService
|
||||||
.runSync(DtbDoct.class, exchangeImportedTestateData, exchangeUpdatedTestateData);
|
.runSync(DtbDoct.class, exchangeImportedTestateData, exchangeUpdatedTestateData);
|
||||||
@@ -160,7 +183,7 @@ public class ExchangeDocumentImportService {
|
|||||||
//ignore error if is DELETE
|
//ignore error if is DELETE
|
||||||
if (document.getOperation() != OperationType.DELETE) throw mergeEntityDBToObjectException;
|
if (document.getOperation() != OperationType.DELETE) throw mergeEntityDBToObjectException;
|
||||||
}
|
}
|
||||||
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (DtbDoct) dataToSave, useTempTable);
|
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (DtbDoct) dataToSave, useTempTable, testataTableName);
|
||||||
|
|
||||||
if (!document.getDtbDocr().isEmpty()) {
|
if (!document.getDtbDocr().isEmpty()) {
|
||||||
|
|
||||||
@@ -169,7 +192,7 @@ public class ExchangeDocumentImportService {
|
|||||||
entityProcessor.processEntity(document, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDb, requestDataDTO);
|
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();
|
internalMultiDb.commitAll();
|
||||||
@@ -202,16 +225,15 @@ public class ExchangeDocumentImportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<DtbDoct> importTestateDocumentiLavorazione(Connection connection,
|
private List<DtbDoct> importTestateDocumenti(Connection connection, LocalDate minDate, LocalDate maxDate,
|
||||||
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
|
boolean retrieveAlreadyImported, boolean useTempTable, String tableName) throws Exception {
|
||||||
|
|
||||||
String dtbDoctLavOriginalName = "dtb_doct_lav";
|
String dtbDoctLavOriginalName = tableName;
|
||||||
String dtbDoctLavTableName = dtbDoctLavOriginalName + (useTempTable ? "_tmp" : "");
|
String dtbDoctLavTableName = dtbDoctLavOriginalName + (useTempTable ? "_tmp" : "");
|
||||||
|
|
||||||
final List<DtbDoct> dtbDoctLav = exchangeImportDataManagerService.retrieveDataFromExchange(connection, DtbDoct.class,
|
final List<DtbDoct> dtbDoctLav = exchangeImportDataManagerService.retrieveDataFromExchange(connection, DtbDoct.class,
|
||||||
dtbDoctLavTableName, Query.format("data_doc BETWEEN {} AND {}", minDate, maxDate), retrieveAlreadyImported);
|
dtbDoctLavTableName, Query.format("data_doc BETWEEN {} AND {}", minDate, maxDate), retrieveAlreadyImported);
|
||||||
|
|
||||||
|
|
||||||
dtbDoctLav
|
dtbDoctLav
|
||||||
.forEach(x -> {
|
.forEach(x -> {
|
||||||
x.setUserName(ROSSOGARGANO_EXCHANGE_USER);
|
x.setUserName(ROSSOGARGANO_EXCHANGE_USER);
|
||||||
@@ -222,10 +244,10 @@ public class ExchangeDocumentImportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<DtbDocr> importRigheDocumentiLavorazione(Connection connection,
|
private List<DtbDocr> importRigheDocumenti(Connection connection, LocalDate minDate, LocalDate maxDate,
|
||||||
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
|
boolean retrieveAlreadyImported, boolean useTempTable, String tableName) throws Exception {
|
||||||
|
|
||||||
String dtbDocrLavOriginalName = "dtb_docr_lav";
|
String dtbDocrLavOriginalName = tableName;
|
||||||
String dtbDocrLavTableName = dtbDocrLavOriginalName + (useTempTable ? "_tmp" : "");
|
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>() {{
|
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
|
||||||
put("data_doc", importedDtbDoct.getDataDoc());
|
put("data_doc", importedDtbDoct.getDataDoc());
|
||||||
put("ser_doc", importedDtbDoct.getSerDoc());
|
put("ser_doc", importedDtbDoct.getSerDoc());
|
||||||
@@ -243,10 +265,10 @@ public class ExchangeDocumentImportService {
|
|||||||
put("cod_dtip", importedDtbDoct.getCodDtip());
|
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()
|
final List<HashMap<String, Object>> importedRowKeys = importedDtbDocr.stream()
|
||||||
.map(x -> new HashMap<String, Object>() {{
|
.map(x -> new HashMap<String, Object>() {{
|
||||||
put("data_doc", x.getDataDoc());
|
put("data_doc", x.getDataDoc());
|
||||||
@@ -256,7 +278,7 @@ public class ExchangeDocumentImportService {
|
|||||||
put("cod_dtip", x.getCodDtip());
|
put("cod_dtip", x.getCodDtip());
|
||||||
put("id_riga", x.getIdRiga());
|
put("id_riga", x.getIdRiga());
|
||||||
}}).collect(Collectors.toList());
|
}}).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),
|
VersamentoGrezzo(6),
|
||||||
CampiRaccolta(7),
|
CampiRaccolta(7),
|
||||||
BancheAziendali(8),
|
BancheAziendali(8),
|
||||||
ValorizzazioneCertificati(9);
|
ValorizzazioneCertificati(9),
|
||||||
|
DocumentiVendita(10),;
|
||||||
|
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
@@ -65,6 +66,7 @@ public class ExchangeImportSchemaManagerService {
|
|||||||
put(SchemaType.ColliLavorazione, Arrays.asList("mtb_colt_lav", "mtb_colr_lav"));
|
put(SchemaType.ColliLavorazione, Arrays.asList("mtb_colt_lav", "mtb_colr_lav"));
|
||||||
put(SchemaType.OrdiniLavorazione, Arrays.asList("dtb_ordt_lav", "dtb_ordr_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.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.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.PartiteMagazzinoLavorazione, Arrays.asList("mtb_partita_mag_lav"));
|
||||||
put(SchemaType.VersamentoGrezzo, Arrays.asList("mtb_colt_versamento_grezzo", "mtb_colr_versamento_grezzo"));
|
put(SchemaType.VersamentoGrezzo, Arrays.asList("mtb_colt_versamento_grezzo", "mtb_colr_versamento_grezzo"));
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class ExchangeSystemManagerService {
|
|||||||
|
|
||||||
case DocumentiLavorazione:
|
case DocumentiLavorazione:
|
||||||
final ExchangeDocumentImportService beanDocumentiLavorazione = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeDocumentImportService.class);
|
final ExchangeDocumentImportService beanDocumentiLavorazione = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeDocumentImportService.class);
|
||||||
beanDocumentiLavorazione.importTestateDocumentiLavorazione(internalDb, exchangeDb, requestDataDTO);
|
beanDocumentiLavorazione.importTestateDocumenti(internalDb, exchangeDb, requestDataDTO);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Articoli:
|
case Articoli:
|
||||||
|
|||||||
Reference in New Issue
Block a user