Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
@@ -12,12 +13,13 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@Table(JtbCicl.ENTITY)
|
||||
@JsonTypeName(JtbCicl.ENTITY)
|
||||
public class JtbCicl extends EntityBase {
|
||||
public class JtbCicl extends EntityBase implements EquatableEntityInterface<JtbCicl> {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
@@ -586,4 +588,32 @@ public class JtbCicl extends EntityBase {
|
||||
JtbCiclCq jtbCiclCq = new JtbCiclCq();
|
||||
jtbCiclCq.deleteAllEntities(connection, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCodeKey() {
|
||||
return Objects.hash(getCodProd());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsKey(JtbCicl other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
|
||||
if (hashCodeKey() != other.hashCodeKey())
|
||||
return false;
|
||||
|
||||
return Objects.equals(getCodProd(), other.getCodProd());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof JtbCicl)) return false;
|
||||
JtbCicl jtbCicl = (JtbCicl) o;
|
||||
return Objects.equals(getCodProd(), jtbCicl.getCodProd()) && Objects.equals(getCodJfas(), jtbCicl.getCodJfas()) && Objects.equals(getQtaProd(), jtbCicl.getQtaProd()) && Objects.equals(getgIniz(), jtbCicl.getgIniz()) && Objects.equals(getGgTot(), jtbCicl.getGgTot()) && Objects.equals(getDescrizione(), jtbCicl.getDescrizione()) && Objects.equals(getDataUltVar(), jtbCicl.getDataUltVar()) && Objects.equals(getDescrizioneProd(), jtbCicl.getDescrizioneProd()) && Objects.equals(getUntMisProd(), jtbCicl.getUntMisProd()) && Objects.equals(getCaratteristica1(), jtbCicl.getCaratteristica1()) && Objects.equals(getDescrizioneCar1(), jtbCicl.getDescrizioneCar1()) && Objects.equals(getCaratteristica2(), jtbCicl.getCaratteristica2()) && Objects.equals(getDescrizioneCar2(), jtbCicl.getDescrizioneCar2()) && Objects.equals(getPesoSpec(), jtbCicl.getPesoSpec()) && Objects.equals(getDescrizioneEstesa(), jtbCicl.getDescrizioneEstesa()) && Objects.equals(getPercCostGen(), jtbCicl.getPercCostGen()) && Objects.equals(getPercRicLb(), jtbCicl.getPercRicLb()) && Objects.equals(getCodMart(), jtbCicl.getCodMart()) && Objects.equals(getFlagAttiva(), jtbCicl.getFlagAttiva()) && Objects.equals(getImgFile(), jtbCicl.getImgFile()) && Objects.equals(getRapConvProd(), jtbCicl.getRapConvProd()) && Objects.equals(getCodDiviCont(), jtbCicl.getCodDiviCont()) && Objects.equals(getCambioDiviCont(), jtbCicl.getCambioDiviCont()) && Objects.equals(getLunghezza(), jtbCicl.getLunghezza()) && Objects.equals(getLarghezza(), jtbCicl.getLarghezza()) && Objects.equals(getAltezza(), jtbCicl.getAltezza()) && Objects.equals(getLottoMinOrd(), jtbCicl.getLottoMinOrd()) && Objects.equals(getFlagQtaMultipla(), jtbCicl.getFlagQtaMultipla()) && Objects.equals(getQtaAllocazione(), jtbCicl.getQtaAllocazione()) && Objects.equals(getActivityTypeId(), jtbCicl.getActivityTypeId()) && Objects.equals(getFlagTipologia(), jtbCicl.getFlagTipologia()) && Objects.equals(getFlagTipoProd(), jtbCicl.getFlagTipoProd()) && Objects.equals(getSupplyDefault(), jtbCicl.getSupplyDefault()) && Objects.equals(getFlagScomposizione(), jtbCicl.getFlagScomposizione()) && Objects.equals(getCodCq(), jtbCicl.getCodCq()) && Objects.equals(getDataIns(), jtbCicl.getDataIns()) && Objects.equals(getPrezzoBase(), jtbCicl.getPrezzoBase()) && Objects.equals(getCostoProduzione(), jtbCicl.getCostoProduzione()) && Objects.equals(getCostoComplessivo(), jtbCicl.getCostoComplessivo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getCodProd(), getCodJfas(), getQtaProd(), getgIniz(), getGgTot(), getDescrizione(), getDataUltVar(), getDescrizioneProd(), getUntMisProd(), getCaratteristica1(), getDescrizioneCar1(), getCaratteristica2(), getDescrizioneCar2(), getPesoSpec(), getDescrizioneEstesa(), getPercCostGen(), getPercRicLb(), getCodMart(), getFlagAttiva(), getImgFile(), getRapConvProd(), getCodDiviCont(), getCambioDiviCont(), getLunghezza(), getLarghezza(), getAltezza(), getLottoMinOrd(), getFlagQtaMultipla(), getQtaAllocazione(), getActivityTypeId(), getFlagTipologia(), getFlagTipoProd(), getSupplyDefault(), getFlagScomposizione(), getCodCq(), getDataIns(), getPrezzoBase(), getCostoProduzione(), getCostoComplessivo());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,19 @@ import it.integry.ems_model.annotation.SqlDetailId;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.annotation.Table;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@PropertyReactive
|
||||
@Table(JtbDistMate.ENTITY)
|
||||
@JsonTypeName(JtbDistMate.ENTITY)
|
||||
public class JtbDistMate extends EntityBase {
|
||||
public class JtbDistMate extends EntityBase implements EquatableEntityInterface<JtbDistMate> {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
@@ -236,4 +238,32 @@ public class JtbDistMate extends EntityBase {
|
||||
this.codProdPri = codProdPri;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCodeKey() {
|
||||
return Objects.hash(getCodProd(), getIdRiga());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsKey(JtbDistMate other) {
|
||||
if (this == other)
|
||||
return true;
|
||||
|
||||
if (hashCodeKey() != other.hashCodeKey())
|
||||
return false;
|
||||
|
||||
return Objects.equals(getCodProd(), other.getCodProd()) && Objects.equals(getIdRiga(), other.getIdRiga());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof JtbDistMate)) return false;
|
||||
JtbDistMate that = (JtbDistMate) o;
|
||||
return Objects.equals(getCodProd(), that.getCodProd()) && Objects.equals(getIdRiga(), that.getIdRiga()) && Objects.equals(getCodMart(), that.getCodMart()) && Objects.equals(getQtaStd(), that.getQtaStd()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getRifProgetto(), that.getRifProgetto()) && Objects.equals(getNote(), that.getNote()) && Objects.equals(getPercSfrido(), that.getPercSfrido()) && Objects.equals(getDescrizioneEstesa(), that.getDescrizioneEstesa()) && Objects.equals(getUntMisDist(), that.getUntMisDist()) && Objects.equals(getRapConvDist(), that.getRapConvDist()) && Objects.equals(getFlagPri(), that.getFlagPri()) && Objects.equals(getCostoUnt(), that.getCostoUnt()) && Objects.equals(getNumFase(), that.getNumFase()) && Objects.equals(getDataUltMod(), that.getDataUltMod()) && Objects.equals(getModificatoDa(), that.getModificatoDa()) && Objects.equals(getCodProdPri(), that.getCodProdPri());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getCodProd(), getIdRiga(), getCodMart(), getQtaStd(), getDescrizione(), getRifProgetto(), getNote(), getPercSfrido(), getDescrizioneEstesa(), getUntMisDist(), getRapConvDist(), getFlagPri(), getCostoUnt(), getNumFase(), getDataUltMod(), getModificatoDa(), getCodProdPri());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package it.integry.ems.logistic.Import.service;
|
||||
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
@@ -68,10 +66,7 @@ public class BiolexchImportService {
|
||||
throw new Exception("CONFIGURARE PROFILEDB BIOLEXCH IN STB_GEST_SETUP.");
|
||||
}
|
||||
|
||||
// Connessione al database di interscambio
|
||||
DataSource dsBiolexch = new DataSource();
|
||||
dsBiolexch.initialize(profileSource);
|
||||
Connection connBiolexch = dsBiolexch.getConnection();
|
||||
try (MultiDBTransactionManager exchangeMultiDb = new MultiDBTransactionManager(profileSource)) {
|
||||
|
||||
// Acquisizione colli da importare
|
||||
sql = "select colli.SSCC " +
|
||||
@@ -194,6 +189,7 @@ public class BiolexchImportService {
|
||||
info.close();
|
||||
}
|
||||
|
||||
|
||||
// Verifica esistenza articolo/lotto
|
||||
int count = 0;
|
||||
sql = "SELECT count(*) " +
|
||||
@@ -314,26 +310,28 @@ public class BiolexchImportService {
|
||||
// Blocco collo registrato
|
||||
sql = "UPDATE ShippingList SET flagERPRead = 1 " +
|
||||
"WHERE SSCC = " + UtilityDB.valueToString(((MtbColt) entities.get(a)).getAnnotazioni());
|
||||
ps = connBiolexch.prepareStatement(sql);
|
||||
ps = exchangeMultiDb.prepareStatement(sql);
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
}
|
||||
multiDBTransactionManager.commitAll();
|
||||
connBiolexch.commit();
|
||||
exchangeMultiDb.commitAll();
|
||||
entities = new ArrayList<>();
|
||||
} catch (Exception e) {
|
||||
if (colTCheck != null) {
|
||||
anomalies.add(AnomalieDTO.warning(colTCheck.getAnnotazioni() + "\r\n" + e.getMessage()));
|
||||
}
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
connBiolexch.rollback();
|
||||
exchangeMultiDb.rollbackAll();
|
||||
entities = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
}
|
||||
if (entitiesReturn.isEmpty()) {
|
||||
entitiesReturn.add(new MtbColt());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package it.integry.ems.system.exchange.controller;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.exchange.service.ExchangeDistinteImportService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@RequestMapping("exchange/distinte/")
|
||||
public class ExchangeDistinteImportController {
|
||||
|
||||
@Autowired
|
||||
private ExchangeDistinteImportService exchangeDistinteImportService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
@GetMapping(value = "import")
|
||||
public @ResponseBody
|
||||
ServiceRestResponse importDistinte(@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||
@RequestParam() String profileDbExchange) throws Exception {
|
||||
|
||||
|
||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
|
||||
MultiDBTransactionManager exchangeDb = new MultiDBTransactionManager(profileDbExchange)) {
|
||||
exchangeDistinteImportService.importDistinte(internalDb, exchangeDb, requestDataDTO);
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package it.integry.ems.system.exchange.service;
|
||||
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.exchange.service.structure.ExchangeImportDataManagerService;
|
||||
import it.integry.ems.system.exchange.service.structure.ExchangeImportSchemaManagerService;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.entity.JtbCicl;
|
||||
import it.integry.ems_model.entity.JtbDistMate;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ExchangeDistinteImportService {
|
||||
|
||||
//TODO: To be remove, only for fast development
|
||||
private final String EXCHANGE_USER = "EXCHANGE";
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private ExchangeImportSchemaManagerService exchangeImportSchemaManagerService;
|
||||
|
||||
@Autowired
|
||||
private ExchangeImportDataManagerService exchangeImportDataManagerService;
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
public void importDistinte(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
|
||||
boolean useTempTable = true;
|
||||
ExchangeImportSchemaManagerService.SchemaType schemaType = ExchangeImportSchemaManagerService.SchemaType.DistinteBase;
|
||||
|
||||
String testataTableName = null;
|
||||
String righeTableName = null;
|
||||
|
||||
if (schemaType == ExchangeImportSchemaManagerService.SchemaType.DistinteBase) {
|
||||
testataTableName = "jtb_cicl";
|
||||
righeTableName = "jtb_dist_mate";
|
||||
}
|
||||
|
||||
try {
|
||||
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), schemaType, useTempTable);
|
||||
exchangeImportDataManagerService.prepareData(exchangeMultiDb.getPrimaryConnection(), useTempTable,
|
||||
exchangeImportSchemaManagerService.getTablesBySchemaType(schemaType));
|
||||
exchangeMultiDb.commitAll();
|
||||
|
||||
final List<JtbCicl> exchangeImportedData = retrieveDistinte(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
true, false,
|
||||
testataTableName, righeTableName);
|
||||
|
||||
final List<JtbCicl> exchangeUpdatedData = retrieveDistinte(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
false, useTempTable,
|
||||
testataTableName, righeTableName);
|
||||
|
||||
List<EquatableEntityInterface> allData = exchangeImportDataManagerService
|
||||
.runSync(JtbCicl.class, exchangeImportedData, exchangeUpdatedData);
|
||||
|
||||
allData.stream()
|
||||
.filter(x -> x.getOperation() == OperationType.INSERT)
|
||||
.map(x -> (JtbCicl) x)
|
||||
.forEach(x -> {
|
||||
x.setFlagAttiva("S");
|
||||
x.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
});
|
||||
|
||||
allData.removeIf(x -> x.getOperation() == OperationType.DELETE);
|
||||
|
||||
// allData.parallelStream()
|
||||
// .filter(x -> x.getOperation() == OperationType.DELETE)
|
||||
// .map(x -> (JtbCicl) x)
|
||||
// .forEach(x -> {
|
||||
// x.setFlagAttiva("N");
|
||||
// x.setOperation(OperationType.UPDATE);
|
||||
// });
|
||||
|
||||
final Exception[] firstExceptionToThrow = {null};
|
||||
|
||||
AtomicInteger importedCounter = new AtomicInteger();
|
||||
|
||||
for (EquatableEntityInterface<?> dataToSave : allData) {
|
||||
|
||||
JtbCicl distintaToSave = (JtbCicl) dataToSave;
|
||||
|
||||
logger.debug("Importate {} distinte di {}", importedCounter.incrementAndGet(), allData.size());
|
||||
try {
|
||||
entityProcessor.processEntity(distintaToSave, true, true, EXCHANGE_USER, internalMultiDb, requestDataDTO);
|
||||
|
||||
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), distintaToSave, useTempTable, testataTableName);
|
||||
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), distintaToSave.getJtbDistMate(), useTempTable, righeTableName);
|
||||
|
||||
internalMultiDb.commitAll();
|
||||
exchangeMultiDb.commitAll();
|
||||
} catch (Exception ex) {
|
||||
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = ex;
|
||||
|
||||
logger.error("Errore durante l'importazione della distinta [" +
|
||||
"cod prod: " + distintaToSave.getCodProd() + "]", ex);
|
||||
internalMultiDb.rollbackAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (firstExceptionToThrow[0] != null) throw firstExceptionToThrow[0];
|
||||
} finally {
|
||||
if (useTempTable)
|
||||
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), schemaType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<JtbCicl> retrieveDistinte(Connection connection, boolean retrieveAlreadyImported, boolean useTempTable,
|
||||
String testataOriginalName, String righeOriginalName) throws Exception {
|
||||
String testataTableName = testataOriginalName + (useTempTable ? "_tmp" : "");
|
||||
String righeTableName = righeOriginalName + (useTempTable ? "_tmp" : "");
|
||||
|
||||
|
||||
final List<JtbCicl> testate = exchangeImportDataManagerService.retrieveDataFromExchange(connection, JtbCicl.class,
|
||||
testataTableName, null, retrieveAlreadyImported);
|
||||
|
||||
final List<JtbDistMate> righe = exchangeImportDataManagerService.retrieveDataFromExchange(connection, JtbDistMate.class,
|
||||
righeTableName, null, retrieveAlreadyImported);
|
||||
|
||||
final List<JtbCicl> orphanTestateToAdd = righe.parallelStream()
|
||||
.filter(riga ->
|
||||
testate.parallelStream()
|
||||
.noneMatch(testata ->
|
||||
Objects.hash(riga.getCodProd()) ==
|
||||
Objects.hash(testata.getCodProd()) &&
|
||||
|
||||
(Objects.equals(riga.getCodProd(), testata.getCodProd()))))
|
||||
.map(riga -> {
|
||||
JtbCicl testata = new JtbCicl();
|
||||
testata.setCodProd(riga.getCodProd());
|
||||
testata.setOperation(OperationType.UPDATE);
|
||||
return testata;
|
||||
})
|
||||
.filter(testataOrphan -> testate.stream().noneMatch(testataOrphan::equalsKey))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
testate.addAll(orphanTestateToAdd);
|
||||
|
||||
testate.parallelStream()
|
||||
.forEach(testata -> {
|
||||
testata.setUsername(EXCHANGE_USER);
|
||||
//testata.setUpdProgMaga(false);
|
||||
|
||||
testata.setJtbDistMate(righe.parallelStream()
|
||||
.filter(riga ->
|
||||
Objects.hash(testata.getCodProd()) == Objects.hash(riga.getCodProd()) &&
|
||||
|
||||
(Objects.equals(testata.getCodProd(), riga.getCodProd())))
|
||||
.collect(Collectors.toList()));
|
||||
});
|
||||
|
||||
return testate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void singleUpdateImported(Connection connection, JtbCicl imported, boolean useTempTable, String tableName) throws Exception {
|
||||
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
|
||||
put("cod_prod", imported.getCodProd());
|
||||
}};
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedKey, useTempTable);
|
||||
}
|
||||
|
||||
private void singleUpdateImported(Connection connection, List<JtbDistMate> imported, boolean useTempTable, String tableName) throws Exception {
|
||||
final List<HashMap<String, Object>> importedRowKeys = imported.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("cod_prod", x.getCodProd());
|
||||
put("id_riga", x.getIdRiga());
|
||||
}}).collect(Collectors.toList());
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedRowKeys, useTempTable);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -259,20 +259,20 @@ public class ExchangeDocumentImportService {
|
||||
}
|
||||
|
||||
|
||||
private void singleUpdateImported(Connection connection, DtbDoct importedDtbDoct, boolean useTempTable, String tableName) throws Exception {
|
||||
private void singleUpdateImported(Connection connection, DtbDoct imported, 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());
|
||||
put("num_doc", importedDtbDoct.getNumDoc());
|
||||
put("cod_anag", importedDtbDoct.getCodAnag());
|
||||
put("cod_dtip", importedDtbDoct.getCodDtip());
|
||||
put("data_doc", imported.getDataDoc());
|
||||
put("ser_doc", imported.getSerDoc());
|
||||
put("num_doc", imported.getNumDoc());
|
||||
put("cod_anag", imported.getCodAnag());
|
||||
put("cod_dtip", imported.getCodDtip());
|
||||
}};
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedKey, useTempTable);
|
||||
}
|
||||
|
||||
private void singleUpdateImported(Connection connection, List<DtbDocr> importedDtbDocr, boolean useTempTable, String tableName) throws Exception {
|
||||
final List<HashMap<String, Object>> importedRowKeys = importedDtbDocr.stream()
|
||||
private void singleUpdateImported(Connection connection, List<DtbDocr> imported, boolean useTempTable, String tableName) throws Exception {
|
||||
final List<HashMap<String, Object>> importedRowKeys = imported.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("data_doc", x.getDataDoc());
|
||||
put("ser_doc", x.getSerDoc());
|
||||
|
||||
@@ -200,6 +200,11 @@ public class ExchangeSystemManagerService {
|
||||
final ExchangeContrattiImportService beanContrattiVendita = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeContrattiImportService.class);
|
||||
beanContrattiVendita.importVendita(internalDb, exchangeDb, requestDataDTO);
|
||||
break;
|
||||
|
||||
case DistinteBase:
|
||||
final ExchangeDistinteImportService beanDistinteBase = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeDistinteImportService.class);
|
||||
beanDistinteBase.importDistinte(internalDb, exchangeDb, requestDataDTO);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ public class ExchangeImportSchemaManagerService {
|
||||
DocumentiAcquisto(15),
|
||||
ColliVendita(16),
|
||||
OrdiniVendita(17),
|
||||
ContrattiVendita(18);
|
||||
ContrattiVendita(18),
|
||||
DistinteBase(19);
|
||||
|
||||
|
||||
private final int value;
|
||||
@@ -147,6 +148,10 @@ public class ExchangeImportSchemaManagerService {
|
||||
put("vtb_offt_vend", VtbOfft.class);
|
||||
put("vtb_offr_vend", VtbOffr.class);
|
||||
}});
|
||||
put(SchemaType.DistinteBase, new HashMap<String, Class<? extends EntityInterface>>() {{
|
||||
put("jtb_cicl", JtbCicl.class);
|
||||
put("jtb_dist_mate", JtbDistMate.class);
|
||||
}});
|
||||
|
||||
}};
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package it.integry.ems.system.service;
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.service.MapService;
|
||||
@@ -301,16 +300,16 @@ public class AnagImportService {
|
||||
if (UtilityString.streNull(profileSource).compareTo("") == 0) {
|
||||
throw new Exception("CONFIGURARE PROFILEDB EXCH2WINGEST IN STB_GEST_SETUP.");
|
||||
}
|
||||
DataSource dsExch2Wingest = new DataSource();
|
||||
dsExch2Wingest.initialize(profileSource);
|
||||
Connection connExch2Wingest = dsExch2Wingest.getConnection();
|
||||
|
||||
try(MultiDBTransactionManager exchangeMultiDb = new MultiDBTransactionManager(profileSource)) {
|
||||
Connection exchangeConnection = exchangeMultiDb.getPrimaryConnection();
|
||||
|
||||
sql = "select distinct Addresses.country as nazione " +
|
||||
" from Addresses " +
|
||||
" WHERE Addresses.country NOT IN (SELECT nazione FROM " + dbPrimaryName + ".dbo.gtb_nazi)";
|
||||
|
||||
List<GtbNazi> gtbNazi = new ResultSetMapper()
|
||||
.mapQuerySetToList(connExch2Wingest, sql, GtbNazi.class, OperationType.INSERT);
|
||||
.mapQuerySetToList(exchangeConnection, sql, GtbNazi.class, OperationType.INSERT);
|
||||
toBeProcessed.addAll(gtbNazi);
|
||||
|
||||
sql = "select Companies.CompID as diacod," +
|
||||
@@ -329,7 +328,7 @@ public class AnagImportService {
|
||||
" where Companies.CompID = Addresses.CompID and (left(Companies.CompID,1)+Right(Companies.CompID, 4) not in (select cod_anag from " + dbPrimaryName + ".dbo.gtb_anag ) OR (Right(Addresses.addressId,5) <>'00000' AND left(Companies.CompID,1)+Right(Companies.CompID, 4)+ Right(Addresses.addressId,5) not in (select cod_anag + cod_vdes from " + dbPrimaryName + ".dbo.vtb_dest )))" +
|
||||
" order by Companies.CompID, Addresses.addressId ";
|
||||
|
||||
info = connExch2Wingest.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
info = exchangeConnection.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
diacod = res.getString("diacod");
|
||||
@@ -400,6 +399,7 @@ public class AnagImportService {
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
}
|
||||
|
||||
if (!toBeProcessed.isEmpty()) {
|
||||
entitiesReturn = entityProcessor.processEntityList(toBeProcessed, true);
|
||||
|
||||
Reference in New Issue
Block a user