Merge remote-tracking branch 'origin/develop' 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:
@@ -77,9 +77,12 @@ public class EmsCoreContext implements ApplicationListener<ContextRefreshedEvent
|
||||
logger.debug("Init");
|
||||
|
||||
try {
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
emsCoreDBLoader.load(this::onPostDBLoaded);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).start();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.service.UserCacheService;
|
||||
@@ -43,15 +44,23 @@ public class EmsCoreDBLoader {
|
||||
@Autowired
|
||||
private UserCacheService userCacheService;
|
||||
|
||||
@Autowired
|
||||
private BasicConnectionPool connectionPool;
|
||||
|
||||
@PostContextConstruct(priority = 10)
|
||||
public void init() {
|
||||
public void init() throws Exception {
|
||||
this.settingsController.addOnConfigUpdated(() -> {
|
||||
try {
|
||||
load(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void load(final RunnableArgs<MultiDBTransactionManager> onComplete) {
|
||||
multiDBTransactionManager = new MultiDBTransactionManager();
|
||||
public void load(final RunnableArgs<MultiDBTransactionManager> onComplete) throws Exception {
|
||||
connectionPool.init();
|
||||
multiDBTransactionManager = new MultiDBTransactionManager(connectionPool);
|
||||
|
||||
try {
|
||||
discoverAllConnections();
|
||||
@@ -92,19 +101,15 @@ public class EmsCoreDBLoader {
|
||||
for (AvailableConnectionsModel model : settingsModel.getAvailableConnections()) {
|
||||
if (!model.getInternalDb())
|
||||
continue;
|
||||
|
||||
try {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(model.getProfileName());
|
||||
final DataSource ds = connectionPool.getConnection(model.getProfileName());
|
||||
|
||||
String dbDistributore = null;
|
||||
|
||||
boolean isInternalDb = model.getInternalDb();
|
||||
if (isInternalDb) {
|
||||
String sql = "SELECT db_distributore FROM azienda";
|
||||
dbDistributore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(ds.getConnection(), sql);
|
||||
}
|
||||
String dbDistributore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(ds.getConnection(), sql);
|
||||
|
||||
multiDBTransactionManager.addConnection(model.getProfileName(), ds, model.getDbName().equalsIgnoreCase(dbDistributore));
|
||||
|
||||
} catch (Exception ex) {
|
||||
logger.error(String.format("La connessione al DB \"%s\" non è valida. %s", model.getProfileName(), ex.getMessage()), ex);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class DataSource {
|
||||
private String profile;
|
||||
private Short sessionID;
|
||||
private Connection connection = null;
|
||||
private String applicationName;
|
||||
|
||||
public String getDbName() {
|
||||
return connectionModel.getDbName();
|
||||
@@ -41,13 +42,15 @@ public class DataSource {
|
||||
return connectionModel.getConnectionType();
|
||||
}
|
||||
|
||||
public String getApplicationName() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
public int getSessionID() {
|
||||
return sessionID;
|
||||
}
|
||||
|
||||
public synchronized Connection getConnection() throws IOException, SQLException {
|
||||
if (connection == null || connection.isClosed())
|
||||
init();
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -55,10 +58,11 @@ public class DataSource {
|
||||
return !(connection != null && !connection.isClosed());
|
||||
}
|
||||
|
||||
private void init() throws SQLException, IOException {
|
||||
private void init(String applicationName) throws SQLException, IOException {
|
||||
this.applicationName = applicationName;
|
||||
|
||||
connection = Connection.fromConnection(
|
||||
DriverManager.getConnection(connectionModel.getDbConnectionString(), connectionModel.getUsername(), connectionModel.getPasswordDecrypted())
|
||||
DriverManager.getConnection(connectionModel.getDbConnectionString(applicationName), connectionModel.getUsername(), connectionModel.getPasswordDecrypted())
|
||||
);
|
||||
connection.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
|
||||
connection.setAutoCommit(false);
|
||||
@@ -112,7 +116,7 @@ public class DataSource {
|
||||
this.connectionModel = connectionModel;
|
||||
|
||||
if (autoOpenConnection) {
|
||||
init();
|
||||
init(connectionName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250109154212 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
dropColumn("gtb_porto", "flag_fattura_vettore");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250109161329 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE azienda ADD cod_lucid VARCHAR(20)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class AvailableConnectionsModel {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDbConnectionString() throws IOException {
|
||||
public String getDbConnectionString(String applicationName) throws IOException {
|
||||
|
||||
if (UtilityString.isNullOrEmpty(host)) {
|
||||
throw new IOException(String.format("HOST di connessione al database non configurato correttamente (%s)", profileName));
|
||||
@@ -135,7 +135,7 @@ public class AvailableConnectionsModel {
|
||||
return String.format("jdbc:mysql://%s:3306/%s", host, dbName);
|
||||
|
||||
case MSSQL:
|
||||
return String.format("jdbc:sqlserver://%s;databaseName=%s;applicationName=%s", host, dbName, "EMS Connection");
|
||||
return String.format("jdbc:sqlserver://%s;databaseName=%s;applicationName=%s", host, dbName, applicationName);
|
||||
|
||||
case POSTGRES:
|
||||
return String.format("jdbc:postgresql://%s:5432/%s", host, dbName);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package it.integry.ems.sync.MultiDBTransaction;
|
||||
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class BasicConnectionPool {
|
||||
|
||||
@Autowired
|
||||
private SettingsModel settingsModel;
|
||||
|
||||
private final HashMap<String, List<DataSource>> connectionPool = new HashMap<>();
|
||||
private final HashMap<String, List<DataSource>> usedConnections = new HashMap<>();
|
||||
|
||||
public synchronized void init() throws Exception {
|
||||
|
||||
int poolSize =
|
||||
UtilityDebug.isIntegryServerMaster() ? 1 :
|
||||
UtilityDebug.isIntegryServerDev() ? 2 :
|
||||
UtilityDebug.isDebugExecution() ? 0 :
|
||||
Runtime.getRuntime().availableProcessors();
|
||||
|
||||
poolSize = Math.min(poolSize, 8);
|
||||
|
||||
final List<AvailableConnectionsModel> availableConnections = settingsModel.getAvailableConnections(true);
|
||||
|
||||
for (final AvailableConnectionsModel availableConnectionsModel : availableConnections) {
|
||||
synchronized (connectionPool) {
|
||||
if (!connectionPool.containsKey(availableConnectionsModel.getProfileName()))
|
||||
connectionPool.put(availableConnectionsModel.getProfileName(), new ArrayList<>());
|
||||
|
||||
if (!usedConnections.containsKey(availableConnectionsModel.getProfileName()))
|
||||
usedConnections.put(availableConnectionsModel.getProfileName(), new ArrayList<>());
|
||||
|
||||
int createdConnections = connectionPool.get(availableConnectionsModel.getProfileName()).size() +
|
||||
usedConnections.get(availableConnectionsModel.getProfileName()).size();
|
||||
|
||||
for (int j = 0; j < poolSize - createdConnections; j++) {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(availableConnectionsModel.getProfileName(), "EMS Pool Connection #" + j, true);
|
||||
connectionPool.get(availableConnectionsModel.getProfileName()).add(ds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized DataSource getConnection(String profileName) throws Exception {
|
||||
DataSource ds = null;
|
||||
|
||||
synchronized (connectionPool) {
|
||||
if (!connectionPool.containsKey(profileName) || connectionPool.get(profileName).isEmpty()) {
|
||||
ds = createExtraConnection(profileName);
|
||||
} else {
|
||||
ds = connectionPool.get(profileName)
|
||||
.remove(connectionPool.get(profileName).size() - 1);
|
||||
|
||||
if(ds.isClosed()) ds.initialize(profileName, ds.getApplicationName(), true);
|
||||
|
||||
usedConnections.get(profileName).add(ds);
|
||||
}
|
||||
}
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
public synchronized boolean releaseConnection(String profileName, DataSource ds) throws SQLException {
|
||||
if (ds.getApplicationName().equals("EMS Connection")) { //Extra connection
|
||||
ds.forceClose();
|
||||
return true;
|
||||
} else {
|
||||
synchronized (connectionPool) {
|
||||
connectionPool.get(profileName).add(ds);
|
||||
return usedConnections.get(profileName).remove(ds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DataSource createExtraConnection(String profileName) throws Exception {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(profileName, "EMS Connection", true);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package it.integry.ems.sync.MultiDBTransaction;
|
||||
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class DBConnectionChecker {
|
||||
|
||||
private final int DELAY_CHECK = 5 * 1000;
|
||||
private final String applicationName = "EMS CHK_CONN";
|
||||
private Logger logger = LogManager.getLogger();
|
||||
private MultiDBTransactionManager mMultiDBTransactionManager;
|
||||
|
||||
private String mCheckSql = null;
|
||||
|
||||
private int mConnectionNumber = -1;
|
||||
|
||||
public void init(String profileDB) throws Exception {
|
||||
|
||||
mMultiDBTransactionManager = new MultiDBTransactionManager();
|
||||
mMultiDBTransactionManager.setPrimaryDs(profileDB, applicationName);
|
||||
|
||||
mCheckSql = "SELECT (COUNT(dbid) - 1) as NumberOfConnections "
|
||||
+ "FROM sys.sysprocesses WHERE dbid > 0 and DB_NAME(dbid) = " + UtilityDB.valueToString(mMultiDBTransactionManager.getPrimaryDatasource().getProfile())
|
||||
+ " and program_name <> " + UtilityDB.valueToString(applicationName);
|
||||
|
||||
}
|
||||
|
||||
public void startChecking() throws Exception {
|
||||
|
||||
if (mMultiDBTransactionManager != null) {
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
do {
|
||||
try {
|
||||
checkNow();
|
||||
Thread.sleep(DELAY_CHECK);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("DBConnectionChecker", e);
|
||||
mConnectionNumber = -1;
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
|
||||
}
|
||||
}).start();
|
||||
|
||||
} else throw new Exception("Prima di avviare il monitoring è necessario inizializzare il DBConnectionChecker");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void checkNow() {
|
||||
try {
|
||||
mConnectionNumber = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(mMultiDBTransactionManager.getPrimaryConnection(), mCheckSql);
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getCurrentNumberOfConnections() {
|
||||
return mConnectionNumber;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
@@ -33,6 +33,9 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
private List<AdvancedDataSource> dbDatasources = new ArrayList<>();
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private BasicConnectionPool connectionPool;
|
||||
|
||||
@Autowired
|
||||
private SettingsModel settingsModel;
|
||||
|
||||
@@ -43,6 +46,11 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
private boolean enableLog = true;
|
||||
|
||||
public MultiDBTransactionManager() {
|
||||
connectionPool = ContextLoader.getCurrentWebApplicationContext().getBean(BasicConnectionPool.class);
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(BasicConnectionPool connectionPool) throws Exception {
|
||||
this.connectionPool = connectionPool;
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(AvailableConnectionsModel connectionsModel) throws Exception {
|
||||
@@ -54,6 +62,7 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(String profileDb, boolean enableLog) throws Exception {
|
||||
this();
|
||||
this.enableLog = enableLog;
|
||||
this.setPrimaryDs(profileDb);
|
||||
}
|
||||
@@ -78,7 +87,7 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
public void Destroy() throws Exception {
|
||||
this.commitAll();
|
||||
this.closeAll();
|
||||
this.dbDatasources = null;
|
||||
this.dbDatasources.clear();
|
||||
this.dbPrimary = null;
|
||||
}
|
||||
|
||||
@@ -87,14 +96,12 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
}
|
||||
|
||||
public void addConnection(String profileName) throws Exception {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(profileName);
|
||||
|
||||
this.addConnection(profileName, ds);
|
||||
this.addConnection(profileName, false);
|
||||
}
|
||||
|
||||
public void addConnection(String profileName, DataSource dataSource) {
|
||||
this.addConnection(profileName, dataSource, false);
|
||||
public void addConnection(String profileName, boolean isDistributore) throws Exception {
|
||||
DataSource ds = connectionPool.getConnection(profileName);
|
||||
this.addConnection(profileName, ds, isDistributore);
|
||||
}
|
||||
|
||||
public void addConnection(String profileName, DataSource dataSource, boolean isDistributore) {
|
||||
@@ -208,14 +215,6 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
return connection.prepareStatement(sql);
|
||||
}
|
||||
|
||||
/*public AdvancedDataSource getPrimaryDatasource()throws Exception {
|
||||
if(dbDatasources != null){
|
||||
return dbDatasources.get(PRIMARY_DB_KEY);
|
||||
} else {
|
||||
throw new Exception("Database not present in connections list");
|
||||
}
|
||||
}*/
|
||||
|
||||
public ArrayList<AdvancedDataSource> getActiveConnections() throws SQLException {
|
||||
ArrayList<AdvancedDataSource> activeConnections = new ArrayList<AdvancedDataSource>();
|
||||
|
||||
@@ -258,8 +257,10 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
logger.debug("Closing manually: " + advancedDataSource.getDataSource().getProfile() + " (#" + advancedDataSource.getDataSource().getSessionID() + ")");
|
||||
}
|
||||
advancedDataSource.commit();
|
||||
advancedDataSource.close();
|
||||
|
||||
}
|
||||
|
||||
connectionPool.releaseConnection(advancedDataSource.getProfileName(), advancedDataSource.getDataSource());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,19 +295,8 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public void setPrimaryDs(String profileDb, String applicationName) throws Exception {
|
||||
if (dataSource == null) {
|
||||
dataSource = new DataSource();
|
||||
} else {
|
||||
dataSource.forceClose();
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(applicationName)) {
|
||||
dataSource.initialize(profileDb);
|
||||
} else {
|
||||
dataSource.initialize(profileDb, applicationName, true);
|
||||
}
|
||||
|
||||
public void setPrimaryDs(String profileDb) throws Exception {
|
||||
dataSource = connectionPool.getConnection(profileDb);
|
||||
|
||||
java.util.Optional<AvailableConnectionsModel> availableConnectionsModel = SettingsModel.getInstance().getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileDb))
|
||||
@@ -321,11 +311,7 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
this.dbPrimary = new AdvancedDataSource(dataSource.getProfile().toUpperCase(), dataSource, false, isInternalDb);
|
||||
|
||||
this.dbDatasources = new ArrayList<>();
|
||||
this.addConnection(dataSource.getProfile().toUpperCase(), dataSource);
|
||||
}
|
||||
|
||||
public void setPrimaryDs(String profileDb) throws Exception {
|
||||
this.setPrimaryDs(profileDb, null);
|
||||
this.addConnection(dataSource.getProfile().toUpperCase(), dataSource, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
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.base.EntityInterface;
|
||||
@@ -25,9 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -190,9 +188,7 @@ public class SyncManager {
|
||||
}
|
||||
|
||||
if (!multiDBTransactionManager.containsDB(database)) {
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(database);
|
||||
multiDBTransactionManager.addConnection(database, dsSync);
|
||||
multiDBTransactionManager.addConnection(database);
|
||||
}
|
||||
|
||||
Connection syncConnection = multiDBTransactionManager.getDatabaseDataSource(database).getConnection();
|
||||
|
||||
@@ -3,12 +3,12 @@ package it.integry.ems.user.service;
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.expansion.RunnableThrowable;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
@@ -20,8 +20,6 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -57,11 +55,9 @@ public class UserCacheService {
|
||||
|
||||
try {
|
||||
for (AvailableConnectionsModel model : availableConnectionsModels) {
|
||||
DataSource ds = new DataSource();
|
||||
|
||||
try {
|
||||
ds.initialize(model.getProfileName());
|
||||
multiDBTransactionManager.addConnection(model.getProfileName(), ds);
|
||||
multiDBTransactionManager.addConnection(model.getProfileName());
|
||||
} catch (Exception ex) {
|
||||
logger.info(String.format("Cannot find %s database", model.getDbName()), ex);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package it.integry.ems.utility;
|
||||
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class UtilityDebug {
|
||||
@@ -10,7 +7,6 @@ public class UtilityDebug {
|
||||
private static final String INTEGRY_DOMAIN = "STUDIO-ML";
|
||||
|
||||
public static boolean isDebugExecution() {
|
||||
|
||||
//Controllo il dominio del PC attuale
|
||||
String domainName = System.getenv("USERDOMAIN");
|
||||
return INTEGRY_DOMAIN.equalsIgnoreCase(domainName);
|
||||
@@ -18,16 +14,17 @@ public class UtilityDebug {
|
||||
|
||||
|
||||
public static boolean isIntegryServer() {
|
||||
SettingsModel settingsModel = ContextLoader.getCurrentWebApplicationContext().getBean(SettingsModel.class);
|
||||
return isIntegryServerDev() || isIntegryServerMaster();
|
||||
}
|
||||
|
||||
return settingsModel.getDefaultProfile().equalsIgnoreCase("INTEGRY") ||
|
||||
settingsModel.getDefaultProfile().equalsIgnoreCase("STUDIO-ML");
|
||||
public static boolean isIntegryServerMaster() {
|
||||
String computerName = getComputerName();
|
||||
return computerName.equalsIgnoreCase("SERVERTOMCAT");
|
||||
}
|
||||
|
||||
public static boolean isIntegryServerDev() {
|
||||
String computerName = getComputerName();
|
||||
|
||||
return computerName.equalsIgnoreCase("SERVERDEV");
|
||||
return isDebugExecution() && computerName.equalsIgnoreCase("SERVERDEV");
|
||||
}
|
||||
|
||||
private static String getComputerName() {
|
||||
|
||||
@@ -44,9 +44,6 @@ public class GtbPorto extends EntityBase {
|
||||
@SqlField(value = "flag_attivo", nullable = false)
|
||||
private Boolean flagAttivo;
|
||||
|
||||
@SqlField(value = "flag_fattura_vettore", nullable = false)
|
||||
private Boolean flagFatturaVettore;
|
||||
|
||||
@SqlField(value = "flag_incoterms", nullable = false)
|
||||
private Boolean flagIncoterms;
|
||||
|
||||
@@ -114,15 +111,6 @@ public class GtbPorto extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlagFatturaVettore() {
|
||||
return flagFatturaVettore;
|
||||
}
|
||||
|
||||
public GtbPorto setFlagFatturaVettore(Boolean flagFatturaVettore) {
|
||||
this.flagFatturaVettore = flagFatturaVettore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlagIncoterms() {
|
||||
return flagIncoterms;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DocumentExtEntityRules {
|
||||
|
||||
@@ -25,7 +26,23 @@ public class DocumentExtEntityRules {
|
||||
|
||||
if ( mtbColts != null && mtbColts.size() > 0) {
|
||||
for (MtbColt mtbColt : mtbColts) {
|
||||
|
||||
Optional<MtbColt> first = entity.getMtbColt()
|
||||
.stream()
|
||||
.filter(colt -> colt.getGestione().equalsIgnoreCase(mtbColt.getGestione()) &&
|
||||
colt.getDataCollo().equals(mtbColt.getDataCollo()) &&
|
||||
colt.getSerCollo().equalsIgnoreCase(mtbColt.getSerCollo()) &&
|
||||
colt.getNumCollo().equals(mtbColt.getNumCollo()))
|
||||
.findFirst();
|
||||
if (first.isPresent()) {
|
||||
first.get().setCodDtip(EmsRestConstants.NULL)
|
||||
.setCodAnag(EmsRestConstants.NULL)
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
||||
.setCodAnag(mtbColt.getFlagColloAnonimo().equalsIgnoreCase("S")?EmsRestConstants.NULL:mtbColt.getCodAnag())
|
||||
.setCodVdes(mtbColt.getFlagColloAnonimo().equalsIgnoreCase("S")?EmsRestConstants.NULL:mtbColt.getCodVdes());
|
||||
first.get().setOperation(OperationType.UPDATE);
|
||||
} else {
|
||||
mtbColt.setCodDtip(EmsRestConstants.NULL)
|
||||
.setCodAnag(EmsRestConstants.NULL)
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||
@@ -34,8 +51,9 @@ public class DocumentExtEntityRules {
|
||||
.setCodAnag(mtbColt.getFlagColloAnonimo().equalsIgnoreCase("S")?EmsRestConstants.NULL:mtbColt.getCodAnag())
|
||||
.setCodVdes(mtbColt.getFlagColloAnonimo().equalsIgnoreCase("S")?EmsRestConstants.NULL:mtbColt.getCodVdes());
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
entity.getMtbColt().addAll(mtbColts);
|
||||
entity.getMtbColt().add(mtbColt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +84,6 @@ public class SetupGest {
|
||||
}
|
||||
|
||||
private String getSetup(Connection connection, String gestName, String section, String keySection, String precode) throws SQLException {
|
||||
|
||||
PreparedStatement info;
|
||||
ResultSet res;
|
||||
String value = null;
|
||||
|
||||
if (!precode.isEmpty()) {
|
||||
gestName = precode + "_" + gestName;
|
||||
}
|
||||
@@ -97,15 +92,9 @@ public class SetupGest {
|
||||
+ " AND section = " + UtilityDB.valueToString(section)
|
||||
+ " AND key_section = " + UtilityDB.valueToString(keySection);
|
||||
|
||||
info = connection.prepareStatement(query);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
value = res.getString(1) == null ? "" : res.getString(1);
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
String value = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, query);
|
||||
|
||||
return value;
|
||||
return UtilityString.isNull(value, "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package it.integry.security.cache;
|
||||
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
@@ -114,11 +113,8 @@ public class JwtTokenCacheComponent implements ApplicationListener {
|
||||
continue;
|
||||
|
||||
try {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(availableConnectionsModel.getProfileName());
|
||||
|
||||
multiDBTransactionManager.addConnection(
|
||||
availableConnectionsModel.getProfileName(), ds);
|
||||
availableConnectionsModel.getProfileName());
|
||||
} catch (Exception ex) {
|
||||
logger.error("Database connection error", ex);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package it.integry.ems.activity.service;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.activity.dto.*;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.media.MediaImageService;
|
||||
import it.integry.ems.media.MediaVideoService;
|
||||
@@ -12,7 +11,6 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.UtilityFile;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
@@ -1522,15 +1520,13 @@ public class ActivityService {
|
||||
|
||||
public List<ActivityHistoryDTO> getActivityHistory(String activityId) throws Exception {
|
||||
MultiDBTransactionManager m = new MultiDBTransactionManager();
|
||||
DataSource ds = new DataSource();
|
||||
|
||||
String historyProfileDb = settingsController.getHistoryProfileDb();
|
||||
ds.initialize(historyProfileDb);
|
||||
|
||||
List<ActivityHistoryDTO> returnList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
m.addConnection(historyProfileDb, ds);
|
||||
m.addConnection(historyProfileDb);
|
||||
m.setPrimaryDs(historyProfileDb);
|
||||
|
||||
String sql = "select stb_activity.activity_id,\n" +
|
||||
|
||||
@@ -13,7 +13,6 @@ import it.integry.ems.contabil.partitaIva.enums.SupportedStates;
|
||||
import it.integry.ems.contabil.partitaIva.exceptions.CheckVatException;
|
||||
import it.integry.ems.contabil.partitaIva.interfaces.CheckVatPortType;
|
||||
import it.integry.ems.contabil.partitaIva.services.CheckVatService;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.rules.businessLogic.AccountingBusinessLogic;
|
||||
import it.integry.ems.rules.businessLogic.enums.TipoPartita;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
@@ -1416,9 +1415,7 @@ public class ContabilService {
|
||||
profileScontrini = multiDBTransactionManager.getPrimaryDatasource().getProfile();
|
||||
}
|
||||
//Definizione Connection DB scontrini
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileScontrini);
|
||||
multiDBTransactionManager.addConnection(profileScontrini, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileScontrini);
|
||||
|
||||
setup.put("isRemoteDbScontrini", (profileScontrini.compareTo(multiDBTransactionManager.getPrimaryDatasource().getProfile()) != 0 ? "S" : "N"));
|
||||
setup.put("profileDbScontrini", profileScontrini);
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.document.Import.dto.EloDTO;
|
||||
import it.integry.ems.document.Import.dto.EloRowsDTO;
|
||||
import it.integry.ems.document.Import.dto.RifOrdApuliaDTO;
|
||||
@@ -35,7 +34,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.checkerframework.checker.units.qual.m;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -921,13 +919,13 @@ public class DocumentiAcquistoImportService {
|
||||
while (rowIterator.hasNext()) {
|
||||
Row row = rowIterator.next();
|
||||
|
||||
String numOrd = UtilityExcel.getCellAsString(row, 0).replace("-", "");
|
||||
String codiceAzienda = UtilityExcel.getCellAsString(row, 4);
|
||||
String codicePv = UtilityExcel.getCellAsString(row, 5);
|
||||
String numOrd = UtilityExcel.getCellAsString(row, 0).replace("-", "").trim();
|
||||
String codiceAzienda = UtilityExcel.getCellAsString(row, 4).trim();
|
||||
String codicePv = UtilityExcel.getCellAsString(row, 5).trim();
|
||||
|
||||
Date dataFattura;
|
||||
|
||||
String numFattura = UtilityExcel.getCellAsString(row, 6, false);
|
||||
String numFattura = UtilityExcel.getCellAsString(row, 6, false).trim();
|
||||
if (UtilityString.isNullOrEmpty(numFattura) || numFattura.equalsIgnoreCase("0")) {
|
||||
numFattura = UtilityExcel.getCellAsString(row, 1);
|
||||
dataFattura = UtilityExcel.getCellAsDate(row, 2, "yyyyMMdd");
|
||||
@@ -972,10 +970,7 @@ public class DocumentiAcquistoImportService {
|
||||
|
||||
for (String profileDb : profileDbList) {
|
||||
if (!profileDb.equalsIgnoreCase(multiDBTransactionManager.getPrimaryDatasource().getProfile())) {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(profileDb);
|
||||
|
||||
multiDBTransactionManager.addConnection(profileDb, ds);
|
||||
multiDBTransactionManager.addConnection(profileDb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1198,7 +1193,6 @@ public class DocumentiAcquistoImportService {
|
||||
|
||||
MultiDBTransactionManager m = new MultiDBTransactionManager();
|
||||
try {
|
||||
m.addConnection(ds.getProfileName(), ds.getDataSource());
|
||||
m.setPrimaryDs(ds.getProfileName());
|
||||
|
||||
if (!isWdtb) {
|
||||
@@ -1260,12 +1254,28 @@ public class DocumentiAcquistoImportService {
|
||||
String codAnag = (String) resultQury.get("cod_anag");
|
||||
String codAlis = (String) resultQury.get("cod_alis");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codAnag)) {
|
||||
anomalie.add(AnomalieDTO.error(String.format("Nessun fornitore trovato con la partita iva %s", filconad.getCodForn())));
|
||||
}
|
||||
|
||||
String codVdes = null;
|
||||
if (UtilityString.isNullOrEmpty(codAlis)) {
|
||||
sql = "SELECT cod_vdes, cod_alis FROM vtb_dest WHERE cod_anag = %s AND flag_attivo = 'S' and cod_alis is not null";
|
||||
HashMap<String, Object> datiDest = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
|
||||
codVdes = (String) datiDest.get("cod_vdes");
|
||||
codAlis = (String) datiDest.get("cod_alis");
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codAlis)) {
|
||||
anomalie.add(AnomalieDTO.error(String.format("Codice listino non trovato sul fornitore %s", codAnag)));
|
||||
}
|
||||
|
||||
String intercode = filconad.getCodClie().substring(4, 8) + "|" + filconad.getCodSocio();
|
||||
sql = Query.format(
|
||||
"SELECT cod_mdep\n" +
|
||||
"FROM mtb_depo_intercode\n" +
|
||||
"WHERE intercode = %s AND cod_forn = %s",
|
||||
intercode, codAnag
|
||||
"WHERE intercode = %s AND cod_forn = %s %s",
|
||||
intercode, codAnag, (UtilityString.isNullOrEmpty(codVdes)?"":"AND cod_vdes = " + UtilityDB.valueToString(codVdes))
|
||||
);
|
||||
String codMdep = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
@@ -1280,7 +1290,8 @@ public class DocumentiAcquistoImportService {
|
||||
.setDataDoc(filconad.getDataBolla())
|
||||
.setCodDtip(codDtip)
|
||||
.setListino(codAlis)
|
||||
.setCodMdep(codMdep);
|
||||
.setCodMdep(codMdep)
|
||||
.setCodVdes(codVdes);
|
||||
|
||||
for (FilconadrDTO filconadr : filconad.getFilconadr()) {
|
||||
sql = Query.format(
|
||||
@@ -1300,9 +1311,7 @@ public class DocumentiAcquistoImportService {
|
||||
new DtbDocr()
|
||||
.setCodArtFor(filconadr.getCodArt())
|
||||
.setQtaDoc(filconadr.getQtaFatturata())
|
||||
.setDescrizione(filconadr.getDescArt())
|
||||
.setValUnt(filconadr.getPrzUnitario())
|
||||
.setImportoRiga(filconadr.getImpTot());
|
||||
.setDescrizione(filconadr.getDescArt());
|
||||
|
||||
dtbDocr.setOperation(OperationType.INSERT);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.base.EntityImportResponse;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.Import.enums.EntityImportType;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.document.Import.DocumentiImporter;
|
||||
import it.integry.ems.document.Import.dto.EloDTO;
|
||||
import it.integry.ems.document.Import.dto.ResiDTO;
|
||||
@@ -248,9 +247,7 @@ public class DocumentController {
|
||||
//definizione Connection su DB scontrini
|
||||
String profileDbScontrini = datiDoc.getProfileDbScontrini();
|
||||
if (!UtilityString.isNullOrEmpty(profileDbScontrini)) {
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDbScontrini);
|
||||
multiDBTransactionManager.addConnection(profileDbScontrini, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDbScontrini);
|
||||
}
|
||||
DtbDoct dtbDoctRet = documentService.emissioneDocumentiDaScontrino(multiDBTransactionManager, datiDoc, false);
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package it.integry.ems.document.export.service;
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
@@ -18,9 +18,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
@@ -51,15 +48,11 @@ public class SicilianiDMSExportService {
|
||||
Connection con = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
//Acquisizione Connection DB TRAXAL
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBTraxal);
|
||||
multiDBTransactionManager.addConnection(profileDBTraxal, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBTraxal);
|
||||
Connection conTraxal = multiDBTransactionManager.getDatabaseDataSource(profileDBTraxal).getConnection();
|
||||
|
||||
//Acquisizione Connection DB ALYANTE
|
||||
DataSource dsSyncAlyante = new DataSource();
|
||||
dsSync.initialize(profileDBAlyante);
|
||||
multiDBTransactionManager.addConnection(profileDBAlyante, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBAlyante);
|
||||
Connection conAlyante = multiDBTransactionManager.getDatabaseDataSource(profileDBTraxal).getConnection();
|
||||
|
||||
// ACQUISIZIONE ELENCO RIGHE ORDINE SU CUI E' STATA CAMBIATA LA DATA CONSEGNA
|
||||
@@ -196,9 +189,7 @@ public class SicilianiDMSExportService {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
// Acquisizione Connection DB ALYANTE
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBAlyante);
|
||||
multiDBTransactionManager.addConnection(profileDBAlyante, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBAlyante);
|
||||
Connection conAlyante = multiDBTransactionManager.getDatabaseDataSource(profileDBAlyante).getConnection();
|
||||
|
||||
try {
|
||||
|
||||
@@ -58,10 +58,12 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.sql.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -926,9 +928,7 @@ public class DocumentService {
|
||||
profileScontrini = multiDBTransactionManager.getPrimaryDatasource().getProfile();
|
||||
|
||||
//Acquisizione Connection DB scontrini
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileScontrini);
|
||||
multiDBTransactionManager.addConnection(profileScontrini, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileScontrini);
|
||||
Connection connScontrini = multiDBTransactionManager.getDatabaseDataSource(profileScontrini).getConnection();
|
||||
Statement cmdSc = connScontrini.createStatement();
|
||||
ResultSet resArt;
|
||||
|
||||
@@ -132,11 +132,14 @@ public class DocumentiDirettiService {
|
||||
|
||||
boolean fatturaPedaneCliente = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
boolean fatturaVettore = false;
|
||||
if (!UtilityString.isNullOrEmpty(dtbDoct.getIncoterms())) {
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT flag_fattura_vettore FROM gtb_porto WHERE porto = %s",
|
||||
"SELECT CAST(IIF(costo=2,1,0) as bit) FROM gtb_porto WHERE porto = %s",
|
||||
dtbDoct.getIncoterms());
|
||||
boolean fatturaVettore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
fatturaVettore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
|
||||
if ((fatturaPedaneCliente || fatturaVettore) &&
|
||||
dtbDoct.getDtbDocImb().stream().anyMatch(x->x.getTipoReso()!= 2 && !x.getNumImbCons().equals(x.getNumImbResi()))
|
||||
|
||||
@@ -2,7 +2,6 @@ package it.integry.ems.logistic.Export.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.logistic.Export.dto.MagAutoPickingRequestDTO;
|
||||
@@ -87,9 +86,7 @@ public class ICONExportService {
|
||||
String codjcom = UtilityHashMap.getValueIfExists(result, "cod_jcom");
|
||||
|
||||
// Acquisizione Connection DB ICON
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBICON);
|
||||
multiDBTransactionManager.addConnection(profileDBICON, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBICON);
|
||||
Connection conICON = multiDBTransactionManager.getDatabaseDataSource(profileDBICON).getConnection();
|
||||
|
||||
try {
|
||||
@@ -228,9 +225,7 @@ public class ICONExportService {
|
||||
|
||||
// Acquisizione Connection DB ICON
|
||||
String profileDBICON = setupGest.getSetup("ICON", "SETUP", "PROFILE_DB_INTERSCAMBIO");
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBICON);
|
||||
multiDBTransactionManager.addConnection(profileDBICON, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBICON);
|
||||
Connection conICON = multiDBTransactionManager.getDatabaseDataSource(profileDBICON).getConnection();
|
||||
|
||||
try {
|
||||
|
||||
@@ -2,7 +2,6 @@ package it.integry.ems.logistic.Import.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.logistic.controller.dto.ICONDTO;
|
||||
import it.integry.ems.logistic.dto.sm2.FiltroDistribuzioneColloDTO;
|
||||
import it.integry.ems.logistic.service.DistribuzioneColliService;
|
||||
@@ -69,9 +68,7 @@ public class ICONImportService {
|
||||
String posizione = setupGest.getSetup("ICON", "SETUP", "POSIZIONE");
|
||||
|
||||
// Acquisizione Connection DB ICON
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBICON);
|
||||
multiDBTransactionManager.addConnection(profileDBICON, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBICON);
|
||||
Connection conICON = multiDBTransactionManager.getDatabaseDataSource(profileDBICON).getConnection();
|
||||
|
||||
try {
|
||||
@@ -217,9 +214,7 @@ public class ICONImportService {
|
||||
String posizione = setupGest.getSetup("ICON", "SETUP", "POSIZIONE");
|
||||
|
||||
// Acquisizione Connection DB ICON
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBICON);
|
||||
multiDBTransactionManager.addConnection(profileDBICON, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBICON);
|
||||
Connection conICON = multiDBTransactionManager.getDatabaseDataSource(profileDBICON).getConnection();
|
||||
|
||||
try {
|
||||
@@ -484,9 +479,7 @@ public class ICONImportService {
|
||||
|
||||
try {
|
||||
// Acquisizione Connection DB ICON
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBICON);
|
||||
multiDBTransactionManager.addConnection(profileDBICON, dsSync);
|
||||
multiDBTransactionManager.addConnection(profileDBICON);
|
||||
Connection conICON = multiDBTransactionManager.getDatabaseDataSource(profileDBICON).getConnection();
|
||||
|
||||
// Acquisizione posizione magazzino automatizzato ICON
|
||||
|
||||
@@ -66,9 +66,8 @@ public class ProductionOrderDataHandlerService {
|
||||
}
|
||||
|
||||
String finalHistoryProfileDb = historyProfileDb;
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections(true)
|
||||
.stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.filter(x -> finalHistoryProfileDb != null && !finalHistoryProfileDb.equalsIgnoreCase(x.getProfileName()))
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.google.common.base.Joiner;
|
||||
import com.google.firebase.messaging.FirebaseMessagingException;
|
||||
import com.google.firebase.messaging.MessagingErrorCode;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.order.dto.UserGroupENUM;
|
||||
@@ -120,9 +119,9 @@ public class PvmService {
|
||||
HashMap<String, Object> userData = systemService.login(requestDataDTO.getUsername(), requestDataDTO.getPassword(), "", profileDb);
|
||||
|
||||
profileDb = (String) userData.get("profile_db");
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(profileDb);
|
||||
multiDBTransactionManager.addConnection(profileDb, ds);
|
||||
multiDBTransactionManager.addConnection(profileDb);
|
||||
Connection conn = multiDBTransactionManager.getDatabaseDataSource(profileDb).getConnection();
|
||||
|
||||
|
||||
String dataInizCons = new SimpleDateFormat(DATE_FORMAT_YMD).format(dataCons) + " 10:00:00";
|
||||
String dataFineCons = new SimpleDateFormat(DATE_FORMAT_YMD).format(dataCons) + " 22:00:00";
|
||||
@@ -164,7 +163,7 @@ public class PvmService {
|
||||
" WHERE STB_GEST_SETUP_DEPO.citta_cons like '%" + citta + "%' " +
|
||||
" GROUP BY num_range, dstart, dEnd, num_cons_max, CITTA_CONS ";
|
||||
|
||||
PreparedStatement ps = ds.getConnection().prepareStatement(sql);
|
||||
PreparedStatement ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
ResultSetMapper rsChkCons = new ResultSetMapper();
|
||||
|
||||
@@ -787,6 +787,7 @@ public class WMSGenericService {
|
||||
(!UtilityString.isNullOrEmpty(codMdep) ? " AND col.cod_mdep = " + UtilityDB.valueToString(codMdep) : "") + " " +
|
||||
" AND ISNULL(data_scad, GETDATE()) >= GETDATE() " +
|
||||
" ORDER BY CASE WHEN ISNULL(cod_jcom, " + UtilityDB.valueToString(commessaMagazzino) + ") = " + UtilityDB.valueToString(commessaMagazzino) + " THEN " + UtilityDB.valueToString(commessaMagazzino) + " END, " +
|
||||
" CASE WHEN ISNULL(col.posizione, '') = '' THEN '' END, " +
|
||||
" ISNULL(cod_jcom, ''), " +
|
||||
" ISNULL(data_scad, GETDATE()), " +
|
||||
" ISNULL(mtb_depo_posizioni.priorita, 0)," +
|
||||
|
||||
@@ -558,13 +558,10 @@ public class SystemService {
|
||||
while (rs.next()) {
|
||||
String profileDb = rs.getString("user_name");
|
||||
DataSource dsDb;
|
||||
if (multiDBTransactionManager.containsDB(profileDb)) {
|
||||
dsDb = multiDBTransactionManager.getDatabaseDataSource(profileDb).getDataSource();
|
||||
} else {
|
||||
dsDb = new DataSource();
|
||||
dsDb.initialize(profileDb);
|
||||
multiDBTransactionManager.addConnection(profileDb, dsDb);
|
||||
if (!multiDBTransactionManager.containsDB(profileDb)) {
|
||||
multiDBTransactionManager.addConnection(profileDb);
|
||||
}
|
||||
dsDb = multiDBTransactionManager.getDatabaseDataSource(profileDb).getDataSource();
|
||||
dsDb.getConnection().prepareStatement(sqlUpdate).execute();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user