merge
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-08-26 10:09:18 +02:00
373 changed files with 7435 additions and 4468 deletions

2
.idea/dataSources.xml generated
View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
<data-source source="LOCAL" name="Biolevante" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
<driver-ref>sqlserver.ms</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>

View File

@@ -10,12 +10,29 @@ pipeline {
stage('PreBuild Steps (Master)') {
when {
expression {
return env.GIT_BRANCH == "master"
return env.GIT_BRANCH == "master" || env.GIT_BRANCH == "feature/RefactoringGestioneColli"
}
}
steps {
echo "Creo version tag su Git"
bat 'build\\create_build_tag.bat'
script {
def date = new Date()
def formattedDate = date.format('yyyyMMdd_HHmm')
def tagName = "${env.GIT_BRANCH.toLowerCase().replace('/', '-')}-${formattedDate}"
def tagMessage = "Build #${env.BUILD_NUMBER} - ${env.GIT_BRANCH}"
def envPropertiesText = "project.version=${formattedDate}"
writeFile(
'file': 'ems-core\\src\\main\\resources\\configs\\env.properties',
'text': envPropertiesText
)
bat "git add . -A"
bat "git tag -a ${tagName} -m \"${tagMessage}\""
bat "git push origin ${tagName}"
}
}
}
stage('Maven Build') {

View File

@@ -1,43 +0,0 @@
REM SET YEAR
set YEAR=%date:~6,4%
REM SET MONTH
set MONTH=%date:~3,2%
if %MONTH% LSS 10 set MONTH=%MONTH:~1,2%
if %MONTH% LSS 10 set MONTH=0%MONTH%
REM SET DAY
set DAY=%date:~0,2%
if %DAY% LSS 10 set DAY=%DAY:~1,2%
if %DAY% LSS 10 set DAY=0%DAY%
REM SET HOUR
set HOUR=%time:~0,2%
if %HOUR% LSS 10 set HOUR=%HOUR:~1,2%
if %HOUR% LSS 10 set HOUR=0%HOUR%
REM SET MINUTE
set MINUTE=%time:~3,2%
if %MINUTE% LSS 10 set MINUTE=%MINUTE:~1,2%
if %MINUTE% LSS 10 set MINUTE=0%MINUTE%
REM SET SECOND
set SECOND=%time:~6,2%
if %SECOND% LSS 10 set SECOND=%SECOND:~1,2%
if %SECOND% LSS 10 set SECOND=0%SECOND%
set mydate=%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%%SECOND%
echo #spring.profiles.active=@activatedProperties@ > ems-core\src\main\resources\configs\env.properties
echo project.version=%mydate% >> ems-core\src\main\resources\configs\env.properties
git add . -A
git commit -m "%mydate%"
git tag "%mydate%"
git push https://git.studioml.it/Integry/IntegryManagementSystem.git --tags
git push https://git.studioml.it/Integry/IntegryManagementSystem.git --all

View File

@@ -24,7 +24,9 @@ public enum EntityImportType {
MOVIMENTI_CONTABILI("MOVIMENTI CONTABILI"),
GRIGLIA_VENDITA("GRIGLIA VENDITA"),
GRIGLIA_ACQUISTO("GRIGLIA ACQUISTO"),
SCADENZE("SCADENZE");
SCADENZE("SCADENZE"),
BILANCE("BILANCE"),
BANCA("BANCA");
private String text;

View File

@@ -2,12 +2,10 @@ package it.integry.ems._context;
import it.integry.annotations.PostContextConstruct;
import it.integry.common.var.EmsDBConst;
import it.integry.ems.datasource.DataSource;
import it.integry.ems.expansion.RunnableArgsThrowable;
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;
@@ -58,6 +56,7 @@ public class EmsCoreDBLoader {
public void init() throws Exception {
this.settingsController.addOnConfigUpdated(() -> {
try {
connectionPool.init();
load(null);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -66,8 +65,6 @@ public class EmsCoreDBLoader {
}
public void load(final RunnableArgsThrowable<MultiDBTransactionManager> onComplete) throws Exception {
connectionPool.init();
taskExecutorService.executeTask(() -> {
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionPool)){
discoverAllConnections(multiDBTransactionManager);
@@ -92,12 +89,11 @@ public class EmsCoreDBLoader {
futureTasks.add(() -> {
try {
final DataSource ds = connectionPool.getConnection(modelAtomicReference.get().getProfileName());
Connection connection = connectionPool.getConnection(modelAtomicReference.get());
String sql = "SELECT db_distributore FROM azienda";
String dbDistributore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(ds.getConnection(), sql);
String dbDistributore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
multiDBTransactionManager.addConnection(modelAtomicReference.get().getProfileName(), ds, modelAtomicReference.get().getDbName().equalsIgnoreCase(dbDistributore));
multiDBTransactionManager.addConnection(connection, modelAtomicReference.get().getDbName().equalsIgnoreCase(dbDistributore));
return null;
} catch (Exception ex) {
@@ -113,13 +109,11 @@ public class EmsCoreDBLoader {
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
for (final AdvancedDataSource advancedDataSource : multiDBTransactionManager.getActiveConnections()) {
AtomicReference<AdvancedDataSource> atomicAdvancedDataSource = new AtomicReference<>(advancedDataSource);
for (final Connection connection : multiDBTransactionManager.getActiveConnections()) {
futureTasks.add(() -> {
Connection conn = atomicAdvancedDataSource.get().getConnection();
Azienda azienda = Azienda.getDefaultAzienda(conn);
String dbName = atomicAdvancedDataSource.get().getDataSource().getDbName();
Azienda azienda = Azienda.getDefaultAzienda(connection);
String dbName = connection.getDbName();
try {
if (azienda != null) {
@@ -131,7 +125,7 @@ public class EmsCoreDBLoader {
}
HashMap<String, String> gestSetupValues =
setupGest.getSetupSection(conn, "DATI_AZIENDA", "FATTURAZIONE_ELETTRONICA");
setupGest.getSetupSection(connection, "DATI_AZIENDA", "FATTURAZIONE_ELETTRONICA");
emsDBConst.getConsts(dbName)
.setApplicationDbName(applicationDbName)
@@ -142,7 +136,7 @@ public class EmsCoreDBLoader {
throw new Exception("Non è stato possibile leggere i dati dalla tabella azienda");
}
} catch (Exception ex) {
throw new Exception("[" + atomicAdvancedDataSource.get().getProfileName() + "] " + ex.getMessage(), ex.getCause());
throw new Exception("[" + connection.getProfileName() + "] " + ex.getMessage(), ex.getCause());
}
return null;
});

View File

@@ -70,8 +70,8 @@ import java.math.BigDecimal;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.*;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -227,7 +227,7 @@ public class EmsController {
response = new ServiceRestResponse(EsitoType.OK);
} else {
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), new Exception("Il contenuto del file non è valido"));
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), new Exception("Il contenuto del file non è valido"));
}
}
@@ -298,11 +298,11 @@ public class EmsController {
sql = sql.replaceAll("select", "select TOP " + numResult + " ");
sql = sql.replaceAll("SELECT", "SELECT TOP " + numResult + " ");
}
objs = entityProcessor.selectRawData(sql, multiDBTransactionManager.getPrimaryDatasource());
objs = entityProcessor.selectRawData(sql, multiDBTransactionManager.getPrimaryConnection());
response = new ServiceRestResponse(EsitoType.OK, objs);
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
}
return response;
}
@@ -339,7 +339,7 @@ public class EmsController {
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryConnection().getProfileName(), entity);
}
if (entity.getOperation() == OperationType.SELECT_OBJECT) {
@@ -386,7 +386,7 @@ public class EmsController {
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryConnection().getProfileName(), entity);
}
if (entity.getOperation() == OperationType.SELECT_OBJECT) {
@@ -483,7 +483,7 @@ public class EmsController {
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
}
return response;
@@ -687,7 +687,7 @@ public class EmsController {
} catch (Exception e) {
e.printStackTrace();
logger.error(request.getRequestURI(), e);
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryConnection().getProfileName(), entity);
responseList.add(response);
if (forceTransaction) {
break;
@@ -700,16 +700,6 @@ public class EmsController {
logger.error(request.getRequestURI(), e);
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
responseList.add(response);
} finally {
if (multiDBTransactionManager != null) {
try {
multiDBTransactionManager.closeAll();
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
responseList.add(response);
}
}
}
return responseList;
@@ -1171,7 +1161,7 @@ public class EmsController {
return ServiceRestResponse.createPositiveResponse();
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
}
}
@@ -1190,7 +1180,7 @@ public class EmsController {
return ServiceRestResponse.createPositiveResponse(mapping);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
}
}
@@ -1202,7 +1192,7 @@ public class EmsController {
return ServiceRestResponse.createPositiveResponse(historyProfileDb);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
}
}
@@ -1219,7 +1209,7 @@ public class EmsController {
return ServiceRestResponse.createPositiveResponse(entityFields);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
}
}

View File

@@ -1,44 +0,0 @@
package it.integry.ems.controller;
import it.integry.ems.response.ServiceRestResponse;
import it.integry.ems.service.MapService;
import it.integry.ems_model.config.EmsRestConstants;
import it.integry.ems_model.types.LatLng;
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.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@RestController
@Scope("request")
public class MapController {
private final Logger logger = LogManager.getLogger();
@Autowired
private MapService mapService;
@RequestMapping(value = EmsRestConstants.PATH_MAP_GETCOORDINATE_BY_CITY, method = RequestMethod.GET)
public @ResponseBody
ServiceRestResponse getCoordinateByCity(HttpServletRequest request,
@RequestParam String cityName) {
ServiceRestResponse resp;
try {
LatLng coordinates = mapService.getCoordinateByCity(cityName);
resp = ServiceRestResponse.createPositiveResponse(coordinates);
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
resp = ServiceRestResponse.createNegativeResponse();
}
return resp;
}
}

View File

@@ -3,76 +3,51 @@ package it.integry.ems.datasource;
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.utility.UtilityDebug;
import it.integry.ems_model.config.EmsRestConstants;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityHashMap;
import it.integry.ems_model.utility.UtilityString;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.apache.commons.dbcp2.BasicDataSource;
import javax.annotation.PreDestroy;
import java.io.IOException;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
@Service
@Scope(value = "request")
public class DataSource {
public class DataSource extends BasicDataSource {
private AvailableConnectionsModel connectionModel;
private String profile;
private Short sessionID;
private Connection connection = null;
private String applicationName;
public String getDbName() {
return connectionModel.getDbName();
}
public String getProfile() {
return profile;
/**
* Instanzia un nuovo datasource.
*
* @deprecated Il datasource non deve essere istanziato direttamente ma bisogna utilizzare il metodo
* {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(AvailableConnectionsModel)} per ottenere una connessione.
*/
@Deprecated
public DataSource() {
super();
}
public EmsRestConstants.DB_TYPE getTypeDB() {
return connectionModel.getConnectionType();
}
public String getApplicationName() {
return applicationName;
}
/**
* Ottiene una connessione dal pool. La connessione è wrappata in it.integry.ems.sync.MultiDBTransaction.Connection.
* È responsabilità del chiamante chiudere la connessione per restituirla al pool.
*
* @return una connessione dal pool
* @throws SQLException se si verifica un errore di accesso al database
*/
public int getSessionID() {
return sessionID;
}
public synchronized Connection getConnection() throws IOException, SQLException {
return connection;
}
public boolean isClosed() throws SQLException {
return !(connection != null && !connection.isClosed());
}
private void init(String applicationName) throws SQLException, IOException {
this.applicationName = applicationName;
connection = Connection.fromConnection(
DriverManager.getConnection(connectionModel.getDbConnectionString(applicationName), connectionModel.getUsername(), connectionModel.getPasswordDecrypted())
);
connection.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
connection.setAutoCommit(false);
public Connection getConnection() throws SQLException {
// Restituisce una nuova connessione dal pool di BasicDataSource, wrappata nel nostro tipo Connection
final Connection connection = Connection.fromConnection(super.getConnection());
// Prova a ottenere una connessione per verificare la configurazione e ottenere il sessionID
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
try (final PreparedStatement setNocountOn = connection.prepareStatement("SET NOCOUNT ON")) {
boolean resultNoCount = setNocountOn.execute();
}
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select @@spid AS session_id," +
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select CAST(@@spid AS BIGINT) AS session_id," +
" user_name() AS [user_name]," +
" suser_name() AS [suser_name]," +
" current_user AS [current_user]," +
@@ -80,32 +55,109 @@ public class DataSource {
" session_user AS [session_user]," +
" user AS [user]");
this.sessionID = UtilityHashMap.getValueIfExists(resultSessionData, "session_id");
connection.setSessionId(UtilityHashMap.getValueIfExists(resultSessionData, "session_id"));
}
connection.setProfileName(connectionModel.getProfileName())
.setInternalDb(connectionModel.getInternalDb());
return connection;
}
public synchronized void initialize(AvailableConnectionsModel connectionModel) throws Exception {
this.connectionModel = connectionModel;
this.setDriverClassName(connectionModel.getDriverClassName());
this.setUrl(connectionModel.getDbConnectionString("EMS Connection"));
this.setUsername(connectionModel.getUsername());
this.setPassword(connectionModel.getPasswordDecrypted());
this.setDefaultTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
this.setDefaultAutoCommit(false);
// ===== OTTIMIZZAZIONI CRITICHE =====
// Pool sizing ottimizzato per READ_UNCOMMITTED (meno locking = più connessioni possibili)
this.setInitialSize(5); // Inizia con più connessioni
this.setMaxTotal(20); // Aumentato il massimo
this.setMaxIdle(15); // Mantieni più connessioni idle
this.setMinIdle(5); // Non scendere sotto 5
// Timeout ottimizzati per performance massime
this.setMaxWaitMillis(2000); // Ridotto a 2 secondi
// Validazione veloce ed efficiente
this.setValidationQuery("SELECT 1");
this.setValidationQueryTimeout(1); // Ridotto a 1 secondo
this.setTestOnBorrow(true); // Testa quando prendi la connessione
this.setTestOnReturn(false); // Non testare quando restituisci (performance)
this.setTestWhileIdle(true); // Testa connessioni idle
// Eviction ottimizzata per READ_UNCOMMITTED
this.setTimeBetweenEvictionRunsMillis(30000); // Ogni 30 secondi
this.setMinEvictableIdleTimeMillis(180000); // 3 minuti (ridotto da 5)
this.setNumTestsPerEvictionRun(5); // Testa più connessioni per volta
// Connection leak protection
this.setRemoveAbandonedOnBorrow(true);
this.setRemoveAbandonedOnMaintenance(true);
this.setRemoveAbandonedTimeout(60 * 10); // 60 secondi
this.setLogAbandoned(UtilityDebug.isDebugExecution()); // Disabilita in produzione per performance
// Performance boosts massimi
this.setPoolPreparedStatements(true);
this.setMaxOpenPreparedStatements(200); // Aumentato da 100
this.setCacheState(true);
this.setFastFailValidation(true);
// Ottimizzazioni specifiche per SQL Server con READ_UNCOMMITTED
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
// Impostazioni connection specifiche per SQL Server
//this.setConnectionInitSqls(java.util.Arrays.asList(
//"SET NOCOUNT ON",
//"SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED",
//"SET ARITHABORT ON"
//));
}
// Logging ottimizzato (disabilita in produzione)
this.setLogExpiredConnections(UtilityDebug.isDebugExecution());
this.setAccessToUnderlyingConnectionAllowed(true); // Per performance avanzate
// ==================== ULTERIORI OTTIMIZZAZIONI ====================
// Connection properties specifiche per performance
this.setDefaultReadOnly(false);
this.setDefaultCatalog(null); // Lascia che sia il driver a gestire
// Ottimizzazioni DBCP2 avanzate
this.setLifo(false); // FIFO per distribuzione equa delle connessioni
this.setSoftMinEvictableIdleTimeMillis(120000); // 2 minuti soft eviction
if (!connectionModel.getInternalDb() ||
UtilityDebug.isDebugExecution() ||
UtilityDebug.isIntegryServerDev() ||
!SettingsModel.getInstance().isPrimaryInstance()) {
this.setInitialSize(0);
this.setMaxTotal(2);
this.setMinIdle(0);
this.setMaxIdle(0);
}
}
@PreDestroy
private void destroy() throws SQLException {
forceClose();
}
public synchronized void initialize(String profileDB, String connectionName, boolean autoOpenConnection) throws Exception {
public synchronized void initialize(String profileDB, String connectionName) throws Exception {
if (UtilityString.isNullOrEmpty(profileDB)) {
throw new Exception("Profile DB non valorizzato - controllare la chiamata del servizio");
}
this.profile = profileDB;
this.sessionID = -1;
AvailableConnectionsModel connectionModel = null;
List<AvailableConnectionsModel> availableConnectionsModels = SettingsModel.getInstance().getAvailableConnections();
List<AvailableConnectionsModel> availableConnectionsModels = SettingsModel.getInstance().getAvailableConnectionsWithoutDuplicatedProfiles(false);
if (!UtilityString.isNullOrEmpty(profileDB)) {
for (AvailableConnectionsModel connectionsModel : availableConnectionsModels) {
if (connectionsModel.getProfileName().equalsIgnoreCase(profileDB)) {
connectionModel = connectionsModel;
}
for (AvailableConnectionsModel connectionsModel : availableConnectionsModels) {
if (connectionsModel.getProfileName().equalsIgnoreCase(profileDB)) {
connectionModel = connectionsModel;
}
}
@@ -113,28 +165,11 @@ public class DataSource {
throw new Exception(String.format("Configurazione DB non trovata o dati mancanti (%s)", profileDB));
}
this.connectionModel = connectionModel;
if (autoOpenConnection) {
init(connectionName);
}
}
public synchronized void initialize(String profileDB, boolean autoOpenConnection) throws Exception {
initialize(profileDB, "EMS Connection", autoOpenConnection);
initialize(connectionModel);
}
public synchronized void initialize(String profileDB) throws Exception {
initialize(profileDB, "EMS Connection", true);
}
public void forceClose() throws SQLException {
if (connection != null) {
synchronized (connection) {
connection.close();
}
}
initialize(profileDB, "EMS Connection");
}
}

View File

@@ -35,12 +35,12 @@ import java.util.TimerTask;
public class EmailWatcherListener extends TimerTask {
private Logger logger = LogManager.getLogger();
private final Logger logger = LogManager.getLogger();
private EmailListenerInfo emailListenerInfo;
private EmsProperties prop;
private SetupGest setupGest;
private ResponseJSONObjectMapper jsonObjectMapper;
private final EmailListenerInfo emailListenerInfo;
private final EmsProperties prop;
private final SetupGest setupGest;
private final ResponseJSONObjectMapper jsonObjectMapper;
public EmailWatcherListener(EmailListenerInfo emailListenerInfo, EmsProperties prop,
SetupGest setupGest, ResponseJSONObjectMapper jsonObjectMapper) {
@@ -88,7 +88,7 @@ public class EmailWatcherListener extends TimerTask {
if (UtilityString.isNullOrEmpty(imapPort))
throw new Exception(params[0] + "/" + params[1] + "/IMAP_PORT non configurato correttamente");
}
ds.forceClose();
ds.close();
if (!UtilityString.isNullOrEmpty(flagAttivo) && "S".equals(flagAttivo)) {
Properties sysProperties = System.getProperties();
Session session = Session.getDefaultInstance(sysProperties);

View File

@@ -1,4 +1,4 @@
package it.integry.ems.dto;
package it.integry.ems.dto.info;
public class ApplicationInfoDTO {

View File

@@ -1,4 +1,4 @@
package it.integry.ems.dto;
package it.integry.ems.dto.info;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package it.integry.ems.dto;
package it.integry.ems.dto.info;
public class DatabaseInfoDTO {

View File

@@ -0,0 +1,114 @@
package it.integry.ems.dto.info;
public class PvmInfoDTO {
private String phpVersion;
private String timezone;
private String imagick;
private boolean sodiumMissing;
private int maxExecutionTime;
private boolean magicQuotesGpc;
private String defaultCharset;
private String memoryLimit;
private String postMaxSize;
private String uploadMaxSize;
private int maxInputVars;
public String getPhpVersion() {
return phpVersion;
}
public PvmInfoDTO setPhpVersion(String phpVersion) {
this.phpVersion = phpVersion;
return this;
}
public String getTimezone() {
return timezone;
}
public PvmInfoDTO setTimezone(String timezone) {
this.timezone = timezone;
return this;
}
public String getImagick() {
return imagick;
}
public PvmInfoDTO setImagick(String imagick) {
this.imagick = imagick;
return this;
}
public boolean isSodiumMissing() {
return sodiumMissing;
}
public PvmInfoDTO setSodiumMissing(boolean sodiumMissing) {
this.sodiumMissing = sodiumMissing;
return this;
}
public int getMaxExecutionTime() {
return maxExecutionTime;
}
public PvmInfoDTO setMaxExecutionTime(int maxExecutionTime) {
this.maxExecutionTime = maxExecutionTime;
return this;
}
public boolean isMagicQuotesGpc() {
return magicQuotesGpc;
}
public PvmInfoDTO setMagicQuotesGpc(boolean magicQuotesGpc) {
this.magicQuotesGpc = magicQuotesGpc;
return this;
}
public String getDefaultCharset() {
return defaultCharset;
}
public PvmInfoDTO setDefaultCharset(String defaultCharset) {
this.defaultCharset = defaultCharset;
return this;
}
public String getMemoryLimit() {
return memoryLimit;
}
public PvmInfoDTO setMemoryLimit(String memoryLimit) {
this.memoryLimit = memoryLimit;
return this;
}
public String getPostMaxSize() {
return postMaxSize;
}
public PvmInfoDTO setPostMaxSize(String postMaxSize) {
this.postMaxSize = postMaxSize;
return this;
}
public String getUploadMaxSize() {
return uploadMaxSize;
}
public PvmInfoDTO setUploadMaxSize(String uploadMaxSize) {
this.uploadMaxSize = uploadMaxSize;
return this;
}
public int getMaxInputVars() {
return maxInputVars;
}
public PvmInfoDTO setMaxInputVars(int maxInputVars) {
this.maxInputVars = maxInputVars;
return this;
}
}

View File

@@ -174,7 +174,7 @@ public abstract class BaseEntityExporter implements IEntityExporter {
.map(x -> (FileItem) x)
.toList();
String pathFile = UtilityDirs.getDirectoryExport(multiDBTransactionManager.getPrimaryDatasource().getDbName(), type, format).getAbsolutePath();
String pathFile = UtilityDirs.getDirectoryExport(multiDBTransactionManager.getPrimaryConnection().getDbName(), type, format).getAbsolutePath();
for (FileItem file : files) {
File tempFile = new File(pathFile + File.separator + file.getFileName());

View File

@@ -4,6 +4,7 @@ import it.integry.ems.response.FileItem;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems_model.entity.WtbUsersInfo;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityResultSet;
@@ -27,8 +28,13 @@ public class ExportFromQuery {
@Autowired
private EntityProcessor entityProcessor;
@Autowired
private SetupGest setupGest;
public EntityExportResponse export (String userName, String type, String format, String whereCond) throws Exception {
String query = setupGest.getExportSetup(multiDBTransactionManager.getPrimaryConnection(), type, format, "QUERY");
WtbUsersInfo wtbUsersInfo =
new WtbUsersInfo()
.setUserName(userName)
@@ -38,18 +44,20 @@ public class ExportFromQuery {
entityProcessor.processEntity(wtbUsersInfo, multiDBTransactionManager);
String queryCustom = wtbUsersInfo.getQueryCustom();
if (UtilityString.isNullOrEmpty(queryCustom))
if (UtilityString.isNullOrEmpty(wtbUsersInfo.getQueryCustom()) && UtilityString.isNullOrEmpty(query))
throw new Exception(
String.format(
"Query non configurata per l'utente %s tipo %s formato %s",
"Query non configurata per l'utente %s tipo %s formato %s o per il formato.",
userName, type, format));
queryCustom = UtilityDB.addwhereCond(queryCustom, whereCond, true);
if (UtilityString.isNullOrEmpty(wtbUsersInfo.getQueryCustom())) {
query = wtbUsersInfo.getQueryCustom();
}
query = UtilityDB.addwhereCond(query, whereCond, true);
PreparedStatement stm = multiDBTransactionManager
.getPrimaryConnection()
.prepareStatement(queryCustom,
.prepareStatement(query,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);

View File

@@ -10,7 +10,7 @@ import it.integry.ems.response.ServiceRestResponse;
import it.integry.ems.service.HttpRestWrapper;
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.utility.UtilityDebug;
import it.integry.ems_model.config.EmsRestConstants;
@@ -82,12 +82,12 @@ public class LicenseComponent {
final HashMap<String, String> listAziende = new HashMap<>();
for (AdvancedDataSource model : multiDBTransactionManager.getActiveConnections()) {
for (Connection connection : multiDBTransactionManager.getActiveConnections()) {
String sql = "SELECT part_iva FROM azienda WHERE part_iva is not null";
String partIva = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(model.getConnection(), sql);
String partIva = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
if (!UtilityString.isNullOrEmpty(partIva))
listAziende.put(model.getProfileName(), partIva);
listAziende.put(connection.getProfileName(), partIva);
}
String jsonBody = jsonObjectMapper.writeValueAsString(listAziende.values());

View File

@@ -1,6 +1,7 @@
package it.integry.ems.menu.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
import it.integry.annotations.PostContextAutowired;
import it.integry.annotations.PostContextConstruct;
@@ -11,7 +12,6 @@ import it.integry.ems.menu.dto.StbMenuOpzDTO;
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
import it.integry.ems.service.MailService;
import it.integry.ems.settings.SettingsController;
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.utility.UtilityDirs;
@@ -57,17 +57,17 @@ public class MenuConfigurationService {
final MenuConfigDTO menuConfig = loadMenuData();
for (AdvancedDataSource advancedDataSource : multiDBTransactionManager.getActiveConnections()) {
for (Connection connection : multiDBTransactionManager.getActiveConnections()) {
if (advancedDataSource.getDataSource().getDbName().equalsIgnoreCase("menu") || isHistoryDB(advancedDataSource))
if (connection.getDbName().equalsIgnoreCase("menu") || isHistoryDB(connection))
continue;
try {
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
internalRefresh(advancedDataSource.getConnection(), menuConfig);
internalRefresh(connection, menuConfig);
//logger.debug("Menu refresh time: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
} catch (Exception ex) {
logger.error("Errore durante l'aggiornamento del menu di " + advancedDataSource.getProfileName(), ex);
logger.error("Errore durante l'aggiornamento del menu di " + connection.getProfileName(), ex);
throw ex;
}
}
@@ -75,9 +75,9 @@ public class MenuConfigurationService {
logger.debug(MenuConfigurationService.class.getSimpleName() + ": Fine refresh menu");
}
private boolean isHistoryDB(AdvancedDataSource advancedDataSource) throws Exception {
private boolean isHistoryDB(Connection connection) throws Exception {
String historyProfileDB = settingsController.getHistoryProfileDb();
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
return historyProfileDB.equalsIgnoreCase(connection.getProfileName());
}
public void refresh(Connection connection, boolean forceRefresh) throws Exception {
@@ -101,6 +101,7 @@ public class MenuConfigurationService {
}
private void internalRefresh(Connection connection, MenuConfigDTO menuConfig, boolean forceRefresh) throws Exception {
SQLServerConnection sqlServerConnection = connection.unwrap(SQLServerConnection.class);
final Azienda azienda = Azienda.getDefaultAzienda(connection);
if (azienda.getTipoAzienda() == null)
@@ -121,7 +122,7 @@ public class MenuConfigurationService {
"descrizione, gest_name, entity_name, picture_menu, picture_select, object_type, flag_printer_setup, parameter, note, open_type, is_deprecated)" +
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) connection.prepareStatement(insertStbMenuOpzSQL)) {
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) sqlServerConnection.prepareStatement(insertStbMenuOpzSQL)) {
for (StbMenuOpzDTO stbMenuOpzDto : menuConfig.getStbMenuOpz()) {
insertBulkPs.setString(1, stbMenuOpzDto.getCodOpz());
@@ -169,7 +170,7 @@ public class MenuConfigurationService {
"pos_tipo_azienda, pos_cliente, descrizione_estesa) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) connection.prepareStatement(insertStbMenuSql)) {
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) sqlServerConnection.prepareStatement(insertStbMenuSql)) {
for (StbMenuDTO stbMenuDto : stbMenus) {
insertBulkPs.setString(1, stbMenuDto.getCodOpz());

View File

@@ -7,7 +7,7 @@ import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems.service.MailService;
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.Connection;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems.utility.UtilityDebug;
import it.integry.ems_model.config.EmsRestConstants;
@@ -25,7 +25,6 @@ import org.reflections.Reflections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.sql.SQLException;
import java.util.*;
@@ -75,12 +74,12 @@ public class MigrationComponent {
}
public void startMigrationsGlobally(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
List<AdvancedDataSource> advancedDataSources;
List<Connection> advancedDataSources;
try {
advancedDataSources = multiDBTransactionManager.getActiveConnections();
advancedDataSources = advancedDataSources.stream()
.filter(AdvancedDataSource::isInternalDb)
.filter(Connection::isInternalDb)
.collect(Collectors.toList());
} catch (SQLException e) {
advancedDataSources = new ArrayList<>();
@@ -89,7 +88,7 @@ public class MigrationComponent {
Exception firstException = null;
for (final AdvancedDataSource advancedDataSource : advancedDataSources) {
for (final Connection advancedDataSource : advancedDataSources) {
try {
executeMigrationGroup(advancedDataSource);
} catch (Exception e) {
@@ -102,9 +101,9 @@ public class MigrationComponent {
// throw firstException;
}
public void executeMigrationGroup(AdvancedDataSource advancedDataSource) throws Exception {
migrateStatus(advancedDataSource);
List<StbMigrationStatus> migrationStatuses = retrieveAllMigrationsStatus(advancedDataSource);
public void executeMigrationGroup(Connection connection) throws Exception {
migrateStatus(connection);
List<StbMigrationStatus> migrationStatuses = retrieveAllMigrationsStatus(connection);
for (Class<? extends MigrationModelInterface> migrationClass : allMigrationsList) {
long migrationNumber = Long.parseLong(migrationClass.getSimpleName().replace("Migration_", ""));
@@ -113,47 +112,47 @@ public class MigrationComponent {
continue;
try {
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
executeMigration(migrationClass, connection, settingsController, settingsModel, droolsDataCompleting);
updateLastMigrationIntoDB(connection, migrationNumber);
advancedDataSource.getConnection().commit();
connection.commit();
} catch (Exception e) {
try {
advancedDataSource.getConnection().rollback();
connection.rollback();
} catch (Exception ex) {
ex.printStackTrace();
logger.error("MigrationService - Rollback", ex);
}
trackMigrationError(advancedDataSource, migrationNumber, e);
trackMigrationError(connection, migrationNumber, e);
throw e;
}
}
migrationsErrorMapByProfiles.putIfAbsent(advancedDataSource.getProfileName(), false);
migrationsErrorMapByProfiles.replace(advancedDataSource.getProfileName(), false);
migrationsErrorMapByProfiles.putIfAbsent(connection.getProfileName(), false);
migrationsErrorMapByProfiles.replace(connection.getProfileName(), false);
}
private void executeMigration(Class<? extends MigrationModelInterface> migrationClass,
AdvancedDataSource advancedDataSource,
Connection connection,
SettingsController settingsController,
SettingsModel settingsModel,
DroolsDataCompleting droolsDataCompleting) throws Exception {
logger.info("Applico " + migrationClass.getSimpleName() + " " + advancedDataSource.getProfileName());
logger.info("Applico " + migrationClass.getSimpleName() + " " + connection.getProfileName());
MigrationModelInterface migrationInstance = migrationClass.newInstance();
migrationInstance.init(advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
migrationInstance.init(connection, settingsController, settingsModel, droolsDataCompleting);
migrationInstance.up();
advancedDataSource.getConnection().commit();
connection.commit();
}
public void updateLastMigrationIntoDB(AdvancedDataSource advancedDataSource, long lastMigraton) throws Exception {
public void updateLastMigrationIntoDB(Connection connection, long lastMigraton) throws Exception {
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + lastMigraton;
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(advancedDataSource.getConnection(), sql, StbMigrationStatus.class);
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, StbMigrationStatus.class);
if (stbMigrationStatus == null) {
stbMigrationStatus = new StbMigrationStatus()
@@ -171,9 +170,9 @@ public class MigrationComponent {
stbMigrationStatus.setOperation(OperationType.UPDATE);
}
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
stbMigrationStatus.manageWithParentConnection(connection);
advancedDataSource.getConnection().commit();
connection.commit();
}
@@ -185,9 +184,9 @@ public class MigrationComponent {
}
private void migrateStatus(AdvancedDataSource advancedDataSource) throws Exception {
final long lastMigrationNumber = getLastMigrationFromDB(advancedDataSource);
final List<Long> alreadyExecutedMigrations = retrieveAllMigrationsStatus(advancedDataSource)
private void migrateStatus(Connection connection) throws Exception {
final long lastMigrationNumber = getLastMigrationFromDB(connection);
final List<Long> alreadyExecutedMigrations = retrieveAllMigrationsStatus(connection)
.stream()
.map(StbMigrationStatus::getMigrationCode)
.collect(Collectors.toList());
@@ -205,25 +204,25 @@ public class MigrationComponent {
.collect(Collectors.toList());
for (StbMigrationStatus stbMigrationStatus : migrationStatusesToMigrate)
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
stbMigrationStatus.manageWithParentConnection(connection);
advancedDataSource.getConnection().commit();
connection.commit();
}
private Long getLastMigrationFromDB(AdvancedDataSource advancedDataSource) throws Exception {
private Long getLastMigrationFromDB(Connection connection) throws Exception {
String sql = "SELECT last_migration FROM azienda";
String lastMigration = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
String lastMigration = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
lastMigration = UtilityString.isNullOrEmpty(lastMigration) ? "-1" : lastMigration;
return Long.parseLong(lastMigration);
}
private List<StbMigrationStatus> retrieveAllMigrationsStatus(AdvancedDataSource advancedDataSource) throws
SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
private List<StbMigrationStatus> retrieveAllMigrationsStatus(Connection connection) throws
SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY;
List<StbMigrationStatus> stbMigrationStatuses = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, StbMigrationStatus.class);
List<StbMigrationStatus> stbMigrationStatuses = UtilityDB.executeSimpleQueryDTO(connection, sql, StbMigrationStatus.class);
if (stbMigrationStatuses == null) return new ArrayList<>();
@@ -234,14 +233,14 @@ public class MigrationComponent {
return stbMigrationStatuses;
}
private void trackMigrationError(AdvancedDataSource advancedDataSource, long migrationCode, Exception e) {
migrationsErrorMapByProfiles.putIfAbsent(advancedDataSource.getProfileName(), true);
migrationsErrorMapByProfiles.replace(advancedDataSource.getProfileName(), true);
private void trackMigrationError(Connection connection, long migrationCode, Exception e) {
migrationsErrorMapByProfiles.putIfAbsent(connection.getProfileName(), true);
migrationsErrorMapByProfiles.replace(connection.getProfileName(), true);
e.printStackTrace();
logger.error("MigrationService (" + advancedDataSource.getProfileName() + ")", e);
logger.error("MigrationService (" + connection.getProfileName() + ")", e);
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(advancedDataSource.getProfileName())) {
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connection.getProfileName())) {
final String exceptionTraceAsString = GeneralUtils.getExceptionTraceAsString(e);
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + migrationCode;
@@ -259,8 +258,8 @@ public class MigrationComponent {
.setCompleted(false)
.setSkipped(false)
.setErrorMessage(e.getMessage() + "\n" + exceptionTraceAsString);
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
advancedDataSource.getConnection().commit();
stbMigrationStatus.manageWithParentConnection(connection);
connection.commit();
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) return;
@@ -268,7 +267,7 @@ public class MigrationComponent {
mailService.sendSystemWarningLog("[" + azienda.getNomeDitta() + "][" + UtilityServer.getHostName() + "] Aggiornamento sistema",
"anomalia durante l'aggiornamento",
"La migrazione " + migrationCode + " non è andata a buon fine sul DB " + advancedDataSource.getProfileName() + ". Controllare il log per ulteriori dettagli.",
"La migrazione " + migrationCode + " non è andata a buon fine sul DB " + connection.getProfileName() + ". Controllare il log per ulteriori dettagli.",
e, new Date());
} catch (Exception ex) {
logger.error("MigrationService - Mail", ex);

View File

@@ -7,7 +7,6 @@ import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseSche
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
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.Connection;
import it.integry.ems.utility.UtilityDebug;
import it.integry.ems_model.entity.Azienda;
@@ -38,7 +37,7 @@ import java.util.List;
public abstract class BaseMigration implements MigrationModelInterface {
protected AdvancedDataSource advancedDataSource;
protected Connection connection;
protected SettingsController settingsController;
protected SettingsModel settingsModel;
protected DroolsDataCompleting droolsDataCompleting;
@@ -46,8 +45,8 @@ public abstract class BaseMigration implements MigrationModelInterface {
protected final Logger logger = LogManager.getLogger();
@Override
public void init(AdvancedDataSource advancedDataSource, SettingsController settingsController, SettingsModel settingsModel, DroolsDataCompleting droolsDataCompleting) {
this.advancedDataSource = advancedDataSource;
public void init(Connection connection, SettingsController settingsController, SettingsModel settingsModel, DroolsDataCompleting droolsDataCompleting) {
this.connection = connection;
this.settingsController = settingsController;
this.settingsModel = settingsModel;
this.droolsDataCompleting = droolsDataCompleting;
@@ -59,7 +58,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
protected boolean isHistoryDB() throws Exception {
String historyProfileDB = settingsController.getHistoryProfileDb();
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
return historyProfileDB.equalsIgnoreCase(connection.getProfileName());
}
protected boolean isDebug() {
@@ -67,16 +66,16 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
protected @NotNull List<HashMap<String, Object>> executeQuery(String sql) throws SQLException, IOException {
return UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
protected @NotNull List<HashMap<String, Object>> executeQuery(String sql) throws SQLException {
return UtilityDB.executeSimpleQuery(connection, sql);
}
protected @NotNull <T> List<T> executeQueryDTO(String sql, Class<T> clazz) throws Exception {
return UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, clazz);
return UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
}
protected void executeStatement(String... sqls) throws SQLException, IOException {
executeStatement(advancedDataSource.getConnection(), sqls);
protected void executeStatement(String... sqls) throws SQLException {
executeStatement(connection, sqls);
}
protected void executeStatement(Connection connection, String... sqls) throws SQLException {
@@ -90,7 +89,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
protected long executeInsertStatement(String sql) throws SQLException {
long generatedId = -1;
try (PreparedStatement pstmt = advancedDataSource.getConnection().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
try (PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
int affectedRows = pstmt.executeUpdate();
@@ -102,8 +101,6 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return generatedId;
@@ -130,8 +127,8 @@ public abstract class BaseMigration implements MigrationModelInterface {
alterObject(SqlObjectTypeEnum.VIEW, objectName, createViewSql);
}
protected boolean existsView(String objectName) throws SQLException, IOException {
return UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), "SELECT COUNT(*) FROM SYSOBJECTS WHERE id = object_id('" + objectName + "')") > 0;
protected boolean existsView(String objectName) throws SQLException {
return UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT COUNT(*) FROM SYSOBJECTS WHERE id = object_id('" + objectName + "')") > 0;
}
protected void createOrUpdateProcedure(String objectName, String createProcedureSql) throws SQLException, IOException {
@@ -154,15 +151,15 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
protected void createIndex(IndexTableDTO indexTableDTO) throws Exception {
UtilityDB.createIndex(advancedDataSource.getConnection(), indexTableDTO);
UtilityDB.createIndex(connection, indexTableDTO);
}
protected void dropIndex(String tableName, String indexName) throws Exception {
UtilityDB.dropIndex(advancedDataSource.getConnection(), tableName, indexName);
UtilityDB.dropIndex(connection, tableName, indexName);
}
protected boolean existsColumn(String tableName, String columnName) throws SQLException, IOException {
protected boolean existsColumn(String tableName, String columnName) throws SQLException {
String schema = null;
if (tableName.contains(".")) {
schema = tableName.substring(0, tableName.indexOf("."));
@@ -173,7 +170,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
" WHERE Name = N{}\n" +
" AND Object_ID = Object_ID(N{})", columnName, (schema != null ? schema : "dbo") + "." + tableName);
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
return val != null && val == 1;
}
@@ -192,7 +189,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
protected <T> void addDefault(String tableName, String columnName, T defaultValue) throws SQLException, IOException {
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
"FROM sys.syscolumns\n" +
"WHERE name = %s\n" +
@@ -203,7 +200,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
protected void dropDefault(String tableName, String columnName) throws SQLException, IOException {
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
"FROM sys.syscolumns\n" +
"WHERE name = %s\n" +
@@ -216,7 +213,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
protected void dropChecks(String tableName, String columnName) throws SQLException, IOException {
boolean checkExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
boolean checkExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
"FROM sys.objects obj_table\n" +
" JOIN sys.objects obj_Constraint\n" +
@@ -235,7 +232,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
}
protected boolean existsTable(String tableName) throws SQLException, IOException {
protected boolean existsTable(String tableName) throws SQLException {
String schema = null;
if (tableName.contains(".")) {
schema = tableName.substring(0, tableName.indexOf("."));
@@ -248,7 +245,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
if (schema != null)
sql += Query.format("AND TABLE_SCHEMA = N%s", schema);
return UtilityDB.<Boolean>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
return UtilityDB.<Boolean>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
}
protected void dropTable(String tableName) throws SQLException, IOException {
@@ -264,7 +261,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
return;
}
String sql = Query.format("SELECT cast(count(*) as bit) FROM stb_gest_setup_query WHERE cod_query = %s", codQuery);
boolean existQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
boolean existQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
if (existQuery)
executeStatement(Query.format("UPDATE stb_gest_setup_query SET query_default = %S, description = %S WHERE cod_query = %s ",
@@ -274,20 +271,20 @@ public abstract class BaseMigration implements MigrationModelInterface {
" VALUES (%s, %s, %s);", codQuery, query, name));
}
protected boolean existsSetup(String gestName, String section, String keySection) throws SQLException, IOException {
protected boolean existsSetup(String gestName, String section, String keySection) throws SQLException {
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM " + StbGestSetup.ENTITY +
" WHERE gest_name = %s AND" +
" section = %s AND" +
" key_section = %s", gestName, section, keySection);
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
}
protected boolean existsSetupQuery(String codQuery) throws SQLException, IOException {
protected boolean existsSetupQuery(String codQuery) throws SQLException {
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM " + StbGestSetupQuery.ENTITY +
" WHERE cod_query = %s", codQuery);
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
}
protected void createSetup(String gestName, String section, String keySection, String value, String description, String codQuery) throws Exception {
@@ -297,7 +294,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
"(gest_name, section, key_section, value, description, query_default) VALUES (?, ?, ?, ?, ?, ?)";
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
ps.setString(1, gestName);
ps.setString(2, section);
ps.setString(3, keySection);
@@ -316,7 +313,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
"(gest_name, section, key_section, value, description, query_default, flag_multi_value) VALUES (?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
ps.setString(1, gestName);
ps.setString(2, section);
ps.setString(3, keySection);
@@ -336,7 +333,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
"(gest_name, section, key_section, value, description, query_default, flag_multi_value, flag_setup_user_web) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
ps.setString(1, gestName);
ps.setString(2, section);
ps.setString(3, keySection);
@@ -366,7 +363,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
return;
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
}
@@ -375,7 +372,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
"flag_user_view, flag_setup_depo, flag_setup_user_web,\n" +
"flag_tipo_json, flag_tipo_colore, tipo_setup, flag_multi_value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
ps.setString(1, gestName);
ps.setString(2, section);
ps.setString(3, keySection);
@@ -402,7 +399,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
.setKeySection(keySection);
stbGestSetup.setOperation(OperationType.DELETE);
stbGestSetup.manageWithParentConnection(advancedDataSource.getConnection());
stbGestSetup.manageWithParentConnection(connection);
}
protected void updateSetupValue(String gestName, String section, String keySection, String newValue) throws Exception {
@@ -422,7 +419,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
Boolean flagTipoJson, Boolean flagTipoColore, String tipoSetup, Boolean flagMultiValue,
String query) throws Exception {
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
}
@@ -457,13 +454,13 @@ public abstract class BaseMigration implements MigrationModelInterface {
stbGestSetup.setFlagMultiValue(flagMultiValue);
stbGestSetup.setOperation(OperationType.UPDATE);
stbGestSetup.manageWithParentConnection(advancedDataSource.getConnection());
stbGestSetup.manageWithParentConnection(connection);
}
protected void updateSetupQuery(String gestName, String section, String keySection,
String codQuery, String query) throws Exception {
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
}
@@ -474,7 +471,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
.setQueryDefault(codQuery);
stbGestSetup.setOperation(OperationType.UPDATE);
stbGestSetup.manageWithParentConnection(advancedDataSource.getConnection());
stbGestSetup.manageWithParentConnection(connection);
}
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
@@ -508,7 +505,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
protected boolean isCustomer(IntegryCustomer... customers) {
String currentDbName = advancedDataSource.getDataSource().getDbName();
String currentDbName = connection.getDbName();
return Arrays.stream(customers)
.anyMatch(x ->
@@ -517,31 +514,31 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
protected boolean isCustomerDb(IntegryCustomerDB... customersDbs) {
String currentDbName = advancedDataSource.getDataSource().getDbName();
String currentDbName = connection.getDbName();
return Arrays.stream(customersDbs)
.anyMatch(y -> y.getValue().equalsIgnoreCase(currentDbName));
}
protected boolean isWingest() throws SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
Azienda currentAzienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
protected boolean isWingest() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
Azienda currentAzienda = Azienda.getDefaultAzienda(connection);
return currentAzienda.getApplicationNameEnum() == ApplicationName.WINGEST;
}
protected boolean isTextiles() throws SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
Azienda currentAzienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
protected boolean isTextiles() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
Azienda currentAzienda = Azienda.getDefaultAzienda(connection);
return currentAzienda.getApplicationNameEnum() == ApplicationName.TEXTILES;
}
protected boolean isDMS() throws SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
Azienda currentAzienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
protected boolean isDMS() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
Azienda currentAzienda = Azienda.getDefaultAzienda(connection);
return currentAzienda.getApplicationNameEnum() == ApplicationName.DMS;
}
protected void enableSaveToRest(String gestName) throws Exception {
boolean existRow =
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT cast(count(*) as bit) FROM stb_gest_sync WHERE gest_name = %s", gestName));
StbGestSync gestSync =
@@ -552,21 +549,21 @@ public abstract class BaseMigration implements MigrationModelInterface {
gestSync.setOperation(OperationType.UPDATE);
} else {
String entityName =
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT entity_name FROM stb_menu_opz WHERE gest_name = %s", gestName));
gestSync.setEntityName(entityName);
gestSync.setOperation(OperationType.INSERT);
}
gestSync.manageWithParentConnection(advancedDataSource.getConnection());
gestSync.manageWithParentConnection(connection);
}
private DatabaseVersionEnum getSqlCompatibilityLevel() throws Exception {
short compatibilityLevel =
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
Query.format("SELECT compatibility_level FROM sys.databases WHERE name = %s", advancedDataSource.getDataSource().getDbName()));
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
Query.format("SELECT compatibility_level FROM sys.databases WHERE name = %s", connection.getDbName()));
return DatabaseVersionEnum.fromCode(compatibilityLevel);

View File

@@ -2,12 +2,12 @@ package it.integry.ems.migration._base;
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.Connection;
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
public interface MigrationModelInterface {
void init(AdvancedDataSource advancedDataSource,
void init(Connection connection,
SettingsController settingsController,
SettingsModel settingsModel,
DroolsDataCompleting droolsDataCompleting);

View File

@@ -3,9 +3,8 @@ package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems.settings.Model.AvailableConnectionsModel;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems_model.utility.UtilityDB;
import java.sql.DriverManager;
import java.sql.Statement;
@@ -17,7 +16,7 @@ public class Migration_20210721093948 extends BaseMigration implements Migration
public void up() throws Exception {
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(advancedDataSource.getProfileName()))
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
return;
if (historyDBModel == null)

View File

@@ -12,7 +12,7 @@ public class Migration_20210721125744 extends BaseMigration implements Migration
@Override
public void up() throws Exception {
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(advancedDataSource.getDataSource().getDbName()))
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getDbName()))
return;
String tomcatPath = System.getProperty("catalina.home");

View File

@@ -3,9 +3,8 @@ package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems.settings.Model.AvailableConnectionsModel;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems_model.utility.UtilityDB;
import java.sql.DriverManager;
import java.sql.Statement;
@@ -17,7 +16,7 @@ public class Migration_20210924152555 extends BaseMigration implements Migration
public void up() throws Exception {
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(advancedDataSource.getProfileName()))
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
return;
if (historyDBModel == null)

View File

@@ -38,7 +38,7 @@ public class Migration_20211022131206 extends BaseMigration implements Migration
" WHERE stb_user.user_name IS NULL ";
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, WtbUsers.class);
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(connection, sql, WtbUsers.class);
if (wtbUsersList == null) return;
@@ -54,7 +54,7 @@ public class Migration_20211022131206 extends BaseMigration implements Migration
.setFlagAttivo(wtbUser.getCtrlState());
stbUser.setOperation(OperationType.INSERT);
stbUser.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
stbUser.manageWithParentConnection(connection, droolsDataCompleting);
}

View File

@@ -19,10 +19,10 @@ public class Migration_20211027170945 extends BaseMigration implements Migration
"WHERE Name = N'orientation' " +
" AND Object_ID = Object_ID(N'dbo.wtb_jrept')";
boolean fieldExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
boolean fieldExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
if (!fieldExists) {
sql = "ALTER TABLE wtb_jrept ADD orientation INT DEFAULT 0 NOT NULL CHECK (orientation IN (0, 1))";
Statement statement = advancedDataSource.getConnection().createStatement();
Statement statement = connection.createStatement();
statement.execute(sql);
statement.close();
}

View File

@@ -18,12 +18,12 @@ public class Migration_20211108185224 extends BaseMigration implements Migration
AutomatedOperationHandlerComponent automatedOperationHandlerComponent = ContextLoader.getCurrentWebApplicationContext().getBean(AutomatedOperationHandlerComponent.class);
final String migrateFileOperationName = "Migrate files grlAnagNote " + advancedDataSource.getProfileName().toUpperCase();
final String migrateFileOperationName = "Migrate files grlAnagNote " + connection.getProfileName().toUpperCase();
ServiceCallAutomatedOperationDTO serviceCallAutomatedOperationDTO = new ServiceCallAutomatedOperationDTO()
.setMethodName("migrateGtbAnagNoteFiles")
.setProfileDb(advancedDataSource.getProfileName())
.setUsername(advancedDataSource.getProfileName());
.setProfileDb(connection.getProfileName())
.setUsername(connection.getProfileName());
serviceCallAutomatedOperationDTO
.setCronTrigger("0 0 0 1/1 * ?")

View File

@@ -3,6 +3,7 @@ package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems.service.PrinterService;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems_model.entity.GrlAnagJrept;
import it.integry.ems_model.entity.MtbDepo;
import it.integry.ems_model.entity.WtbJreptSetup;
@@ -13,8 +14,6 @@ import it.integry.ems_model.utility.UtilityString;
import org.json.JSONArray;
import org.json.JSONObject;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
@@ -29,11 +28,11 @@ public class Migration_20220405180136 extends BaseMigration implements Migration
String checkTableSpesExistsSql = "SELECT CAST(COUNT(*) AS BIT) AS exist_table " +
"FROM INFORMATION_SCHEMA.TABLES " +
"WHERE TABLE_NAME = 'wtb_jrept_setup'";
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
if (!existTable) {
Statement statement = advancedDataSource.getConnection().createStatement();
Statement statement = connection.createStatement();
statement.execute("CREATE TABLE wtb_jrept_setup\n" +
"(\n" +
" id BIGINT IDENTITY\n" +
@@ -51,26 +50,26 @@ public class Migration_20220405180136 extends BaseMigration implements Migration
")");
statement.close();
statement = advancedDataSource.getConnection().createStatement();
statement = connection.createStatement();
statement.execute("CREATE UNIQUE INDEX wtb_jrept_setup_report_id_cod_mdep_tipo_uindex " +
"ON wtb_jrept_setup (report_id, cod_mdep, tipo)");
statement.close();
advancedDataSource.getConnection().commit();
connection.commit();
ArrayList<WtbJreptSetup> jreptSetupsToInsert = new ArrayList<>();
String sqlDepo = "SELECT cod_mdep FROM " + MtbDepo.ENTITY;
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sqlDepo);
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sqlDepo);
if (codMdeps != null && !codMdeps.isEmpty()) {
for (String codMdep : codMdeps) {
String stampantePrimaria = getPrinterNameByDepo(advancedDataSource.getConnection(), codMdep, null, PrinterService.Type.PRIMARIA);
String stampanteSecondaria = getPrinterNameByDepo(advancedDataSource.getConnection(), codMdep, null, PrinterService.Type.SECONDARIA);
String stampantePrimaria = getPrinterNameByDepo(connection, codMdep, null, PrinterService.Type.PRIMARIA);
String stampanteSecondaria = getPrinterNameByDepo(connection, codMdep, null, PrinterService.Type.SECONDARIA);
String grlAnagJreptSql = "SELECT DISTINCT report_id, tipo FROM " + GrlAnagJrept.ENTITY;
List<GrlAnagJrept> grlAnagJrepts = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), grlAnagJreptSql, GrlAnagJrept.class);
List<GrlAnagJrept> grlAnagJrepts = UtilityDB.executeSimpleQueryDTO(connection, grlAnagJreptSql, GrlAnagJrept.class);
if (grlAnagJrepts != null && !UtilityString.isNullOrEmpty(stampantePrimaria)) {
for (GrlAnagJrept grlAnagJrept : grlAnagJrepts) {
@@ -90,7 +89,7 @@ public class Migration_20220405180136 extends BaseMigration implements Migration
}
for (WtbJreptSetup wtbJreptSetup : jreptSetupsToInsert) {
wtbJreptSetup.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
wtbJreptSetup.manageWithParentConnection(connection, droolsDataCompleting);
}
}
}

View File

@@ -38,7 +38,7 @@ public class Migration_20220413102657 extends BaseMigration implements Migration
" WHERE stb_user.user_name IS NULL ";
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, WtbUsers.class);
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(connection, sql, WtbUsers.class);
if (wtbUsersList == null) return;
@@ -63,11 +63,10 @@ public class Migration_20220413102657 extends BaseMigration implements Migration
.setCreationDatetime(wtbUser.getCreationDatetime())
.setPasswordExpiresDays(wtbUser.getPasswordExpiresDays())
.setLastPasswords(wtbUser.getLastPasswords())
.setFlagPasswordExpiring(wtbUser.getFlagPasswordExpiring())
.setDestructionDatetime(wtbUser.getDestructionDatetime());;
.setFlagPasswordExpiring(wtbUser.getFlagPasswordExpiring());
stbUser.setOperation(OperationType.INSERT);
stbUser.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
stbUser.manageWithParentConnection(connection, droolsDataCompleting);
}
}

View File

@@ -20,7 +20,7 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
"SET flag_default_contabilita = 'S', flag_default = 'N' " +
"WHERE flag_default = 'S'";
PreparedStatement updateDefaultFlagPS = advancedDataSource.getConnection().prepareStatement(updateDefaultFlagSql);
PreparedStatement updateDefaultFlagPS = connection.prepareStatement(updateDefaultFlagSql);
updateDefaultFlagPS.setQueryTimeout(30);
updateDefaultFlagPS.executeUpdate();
updateDefaultFlagPS.close();
@@ -38,13 +38,13 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
" FROM " + StbEmail.ENTITY +
" WHERE e_mail = " + UtilityDB.valueToString(mailConfiguration.getFrom());
boolean exists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
boolean exists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
if (!exists) {
boolean isOffice365 = mailConfiguration.getSmtp().contains("office365");
int newId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
int newId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
"SELECT ISNULL(MAX(id_riga), 0) + 1 as new_id " +
"FROM stb_email");
@@ -61,7 +61,7 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
.setFlagDefault(isOffice365 ? "S" : "N");
stbEmail.setOperation(OperationType.INSERT);
stbEmail.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
stbEmail.manageWithParentConnection(connection, droolsDataCompleting);
if (!isOffice365) {
String noReplyFrom = "noreply@" + mailConfiguration.getFrom().split("@")[1];
@@ -79,14 +79,14 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
.setFlagDefault("S");
stbEmailNoReply.setOperation(OperationType.INSERT);
stbEmailNoReply.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
stbEmailNoReply.manageWithParentConnection(connection, droolsDataCompleting);
}
} else {
updateDefaultFlagSql = "UPDATE stb_email " +
"SET flag_default = 'S' " +
"WHERE e_mail = " + UtilityDB.valueToString(mailConfiguration.getFrom());
updateDefaultFlagPS = advancedDataSource.getConnection().prepareStatement(updateDefaultFlagSql);
updateDefaultFlagPS = connection.prepareStatement(updateDefaultFlagSql);
updateDefaultFlagPS.setQueryTimeout(30);
updateDefaultFlagPS.executeUpdate();
updateDefaultFlagPS.close();

View File

@@ -3,6 +3,7 @@ package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems.service.PrinterService;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems_model.entity.GrlAnagJrept;
import it.integry.ems_model.entity.MtbDepo;
import it.integry.ems_model.entity.WtbJrept;
@@ -14,8 +15,6 @@ import it.integry.ems_model.utility.UtilityString;
import org.json.JSONArray;
import org.json.JSONObject;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
@@ -30,15 +29,15 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
String checkTableSpesExistsSql = "SELECT CAST(COUNT(*) AS BIT) AS exist_table " +
"FROM INFORMATION_SCHEMA.TABLES " +
"WHERE TABLE_NAME = 'wtb_jrept_setup'";
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
if (existTable) {
Statement statement = advancedDataSource.getConnection().createStatement();
Statement statement = connection.createStatement();
statement.execute("drop table wtb_jrept_setup");
statement.close();
}
Statement statement = advancedDataSource.getConnection().createStatement();
Statement statement = connection.createStatement();
statement.execute("create table wtb_jrept_setup\n" +
"(\n" +
" id bigint identity\n" +
@@ -60,7 +59,7 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
")");
statement.close();
statement = advancedDataSource.getConnection().createStatement();
statement = connection.createStatement();
statement.execute("create unique index wtb_jrept_setup_cod_mdep_tipo_cod_anag_uindex" +
" on wtb_jrept_setup (cod_mdep, tipo, cod_anag)");
statement.close();
@@ -68,17 +67,17 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
ArrayList<WtbJreptSetup> jreptSetupsToInsert = new ArrayList<>();
String sqlAnagJrept = "SELECT * FROM " + GrlAnagJrept.ENTITY + " ";
List<GrlAnagJrept> anagJrepts = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sqlAnagJrept, GrlAnagJrept.class);
List<GrlAnagJrept> anagJrepts = UtilityDB.executeSimpleQueryDTO(connection, sqlAnagJrept, GrlAnagJrept.class);
String sqlDepo = "SELECT cod_mdep FROM " + MtbDepo.ENTITY;
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sqlDepo);
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sqlDepo);
if (anagJrepts != null && !anagJrepts.isEmpty()) {
for (GrlAnagJrept anagReport : anagJrepts) {
String sqlOrientationReport = "SELECT orientation FROM " + WtbJrept.ENTITY + " where id = " + UtilityDB.valueToString(anagReport.getReportId());
int orientation = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sqlOrientationReport);
int orientation = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sqlOrientationReport);
WtbJreptSetup wtbJreptSetup = new WtbJreptSetup()
.setCodMdep(null)
@@ -92,7 +91,7 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
if (codMdeps != null && !codMdeps.isEmpty()) {
for (String codMdep : codMdeps) {
String stampantePrimaria = getPrinterNameByDepo(advancedDataSource.getConnection(), codMdep, null, PrinterService.Type.PRIMARIA);
String stampantePrimaria = getPrinterNameByDepo(connection, codMdep, null, PrinterService.Type.PRIMARIA);
if (!UtilityString.isNullOrEmpty(stampantePrimaria)) {
WtbJreptSetup wtbJreptSetupDepo = new WtbJreptSetup()
@@ -116,7 +115,7 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
}
for (WtbJreptSetup wtbJreptSetup : jreptSetupsToInsert) {
wtbJreptSetup.manageWithParentConnection(advancedDataSource.getConnection());
wtbJreptSetup.manageWithParentConnection(connection);
}
}

View File

@@ -17,13 +17,13 @@ public class Migration_20220510103554 extends BaseMigration implements Migration
"FROM sys.columns " +
"WHERE Name = N'ref_uuid' " +
"AND Object_ID = Object_ID(N'dbo.stb_activity_file')";
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
if (existColumn) {
return;
}
Statement statement = advancedDataSource.getConnection().createStatement();
Statement statement = connection.createStatement();
statement.execute("ALTER TABLE stb_activity_file " +
"ADD ref_uuid VARCHAR(36) NULL");
statement.close();

View File

@@ -17,13 +17,13 @@ public class Migration_20220510123355 extends BaseMigration implements Migration
"FROM sys.columns " +
"WHERE Name = N'ref_uuid1' " +
"AND Object_ID = Object_ID(N'dbo.stb_activity_file')";
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
if (existColumn) {
return;
}
Statement statement = advancedDataSource.getConnection().createStatement();
Statement statement = connection.createStatement();
statement.execute("ALTER TABLE stb_activity_file " +
"ADD ref_uuid1 VARCHAR(36) NULL");
statement.close();

View File

@@ -28,11 +28,11 @@ public class Migration_20221128123233 extends BaseMigration implements Migration
"ALTER TABLE azienda\n" +
" ADD jwt_secret_key VARCHAR(MAX)");
Azienda azienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
Azienda azienda = Azienda.getDefaultAzienda(connection);
azienda.setJwtSecretKey(secretKeyToUse)
.setOperation(OperationType.UPDATE);
azienda.manageWithParentConnection(advancedDataSource.getConnection());
azienda.manageWithParentConnection(connection);
}
@Override

View File

@@ -25,12 +25,12 @@ public class Migration_20230411163906 extends BaseMigration implements Migration
"ALTER TABLE stb_files_attached\n" +
" ADD mime_type VARCHAR(MAX)");
final List<HashMap<String, Object>> stbFilesAttached = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(),
final List<HashMap<String, Object>> stbFilesAttached = UtilityDB.executeSimpleQuery(connection,
"SELECT id_attach, file_name FROM stb_files_attached\n" +
"WHERE mime_type IS NULL");
new Thread(() -> {
String profileDb = advancedDataSource.getProfileName();
String profileDb = connection.getProfileName();
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDb, false)) {
for (HashMap<String, Object> stbFileAttached : stbFilesAttached) {
final MediaType mimeType = mimeTypesHandler.getContentType((String) stbFileAttached.get("file_name"));

View File

@@ -23,7 +23,7 @@ public class Migration_20230523130047 extends BaseMigration implements Migration
.setIndexName("ix_dtb_ordr_id_contratto")
.setColumnsIndex(columnsIndex)/*
.setColumnsInclude("ciao", "prova", "sole") */;
UtilityDB.createIndex(advancedDataSource.getConnection(),indexTableDTO );
UtilityDB.createIndex(connection,indexTableDTO );
}
@Override

View File

@@ -27,7 +27,7 @@ public class Migration_20231025100023 extends BaseMigration implements Migration
.setColumnsIndex(columnsIndex)
.setUnique(true)/*
.setColumnsInclude("ciao", "prova", "sole") */;
UtilityDB.createIndex(advancedDataSource.getConnection(),indexTableDTO );
UtilityDB.createIndex(connection,indexTableDTO );
}

View File

@@ -8,7 +8,7 @@ public class Migration_20231130152938 extends BaseMigration implements Migration
@Override
public void up() throws Exception {
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(advancedDataSource.getDataSource().getDbName()))
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getDbName()))
return;
settingsModel.setEnableTokenCaching(!UtilityDebug.isDebugExecution());

View File

@@ -15,7 +15,7 @@ public class Migration_20231201094005 extends BaseMigration implements Migration
return;
String sql = "select cast(COUNT(*) as bit) from sys.syscolumns where OBJECT_NAME(id) = 'mtb_colt' and name = 'id_lotto'";
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
if (!existColumn )
executeStatement(
@@ -30,7 +30,7 @@ public class Migration_20231201094005 extends BaseMigration implements Migration
new IndexTableDTO.ColumnIndex("cod_jfas"),
new IndexTableDTO.ColumnIndex("id_lotto")
));
UtilityDB.createIndex(advancedDataSource.getConnection(), indexTableDTO);
UtilityDB.createIndex(connection, indexTableDTO);
}
@Override

View File

@@ -17,7 +17,7 @@ public class Migration_20231201161808 extends BaseMigration implements Migration
@Override
public void up() throws Exception {
SetupGest setupGest = getContextBean(SetupGest.class);
String datiFornitori = setupGest.getSetup(advancedDataSource.getConnection(), "PVM", "DOC_INTERNI", "CHECK_FORNITORE");
String datiFornitori = setupGest.getSetup(connection, "PVM", "DOC_INTERNI", "CHECK_FORNITORE");
if (UtilityString.isNullOrEmpty(datiFornitori))
return;
@@ -30,7 +30,7 @@ public class Migration_20231201161808 extends BaseMigration implements Migration
" INNER JOIN azienda ON gtb_anag.part_iva = azienda.part_iva\n" +
" INNER JOIN atb_forn ON gtb_anag.cod_anag = atb_forn.cod_anag ";
List<String> fornitori = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sql);
List<String> fornitori = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
List<String> queries = new ArrayList<>();

View File

@@ -22,7 +22,7 @@ public class Migration_20240125114347 extends BaseMigration implements Migration
final String gestName = "PICKING";
final String section = "LOGISTICA";
final String keySection = "COD_DTIP_DOC_TRASF_INTERNI";
String jsonString = setupGest.getSetup(advancedDataSource.getConnection(), gestName, section, keySection);
String jsonString = setupGest.getSetup(connection, gestName, section, keySection);
if (UtilityString.isNullOrEmpty(jsonString))
return;

View File

@@ -12,7 +12,7 @@ public class Migration_20240201160125 extends BaseMigration implements Migration
return;
String existsCheckSql = "SELECT CAST(COUNT(*) AS BIT) AS exist FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'stb_migration_status'";
boolean exists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), existsCheckSql);
boolean exists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, existsCheckSql);
if(exists)
return;

View File

@@ -2,15 +2,13 @@ package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems_model.utility.Query;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityHashMap;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
@@ -23,13 +21,13 @@ public class Migration_20240212000000 extends BaseMigration implements Migration
return;
String sql = "SELECT * FROM stb_publications";
final List<HashMap<String, Object>> oldStbPublications = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
final List<HashMap<String, Object>> oldStbPublications = UtilityDB.executeSimpleQuery(connection, sql);
sql = "SELECT * FROM stb_publications_detail";
final List<HashMap<String, Object>> oldStbPublicationsDetails = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
final List<HashMap<String, Object>> oldStbPublicationsDetails = UtilityDB.executeSimpleQuery(connection, sql);
dropOldTables();
createNewTables(advancedDataSource.getConnection());
createNewTables(connection);
for (HashMap<String, Object> oldStbPublication : oldStbPublications) {

View File

@@ -10,9 +10,9 @@ public class Migration_20240304165725 extends BaseMigration implements Migration
if (isHistoryDB())
return;
if (advancedDataSource.getProfileName().equalsIgnoreCase("carelli") ||
advancedDataSource.getProfileName().equalsIgnoreCase("gestfood") ||
advancedDataSource.getProfileName().equalsIgnoreCase("panimal")) {
if (connection.getProfileName().equalsIgnoreCase("carelli") ||
connection.getProfileName().equalsIgnoreCase("gestfood") ||
connection.getProfileName().equalsIgnoreCase("panimal")) {
String sql = "UPDATE carelli_giacenza_prog\n" +
"SET tipo_car = 'R'\n" +

View File

@@ -22,7 +22,7 @@ public class Migration_20240307103608 extends BaseMigration implements Migration
add("PANIMAL");
}};
if (elencoDb.stream().noneMatch(x -> x.equalsIgnoreCase(advancedDataSource.getDataSource().getDbName())))
if (elencoDb.stream().noneMatch(x -> x.equalsIgnoreCase(connection.getDbName())))
return;
String sql =
@@ -39,7 +39,7 @@ public class Migration_20240307103608 extends BaseMigration implements Migration
" AND wtb_users_info.flag_state = 'S'\n" +
" AND stb_user.key_group = '10'";
List<HashMap<String, Object>> elencoUtenti = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
List<HashMap<String, Object>> elencoUtenti = UtilityDB.executeSimpleQuery(connection, sql);
List<ExportAutomatedOperationDTO> operations = new ArrayList<>();
for (HashMap<String, Object> user : elencoUtenti) {
@@ -53,7 +53,7 @@ public class Migration_20240307103608 extends BaseMigration implements Migration
.setUsername((String) user.get("user_name"))
.setPassword((String) user.get("password"))
.setJsonRequest("{ \t\"tipoReport\": \"G\" }")
.setProfileDb(advancedDataSource.getProfileName());
.setProfileDb(connection.getProfileName());
exportAutomatedOperationDTO
.setCronTrigger("0 0 22 1/1 * *")
.setName(operationName);

View File

@@ -15,7 +15,7 @@ public class Migration_20240312093539 extends BaseMigration implements Migration
boolean existTable = existsTable(tableName);
if (existTable) {
boolean existRow = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), "SELECT cast(count(*) as bit) FROM " + tableName);
boolean existRow = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT cast(count(*) as bit) FROM " + tableName);
if (existRow) return;
dropTable(tableName);
}
@@ -40,12 +40,12 @@ public class Migration_20240312093539 extends BaseMigration implements Migration
" orientation int default 0 not null\n" +
")";
executeStatement(advancedDataSource.getConnection(), createSql);
executeStatement(connection, createSql);
String createIndex = "create unique index wtb_jrept_setup_cod_mdep_tipo_cod_anag_uindex" +
" on wtb_jrept_setup (cod_mdep, tipo, cod_anag)";
executeStatement(advancedDataSource.getConnection(), createIndex);
executeStatement(connection, createIndex);
}
@Override

View File

@@ -25,7 +25,7 @@ public class Migration_20240321144750 extends BaseMigration implements Migration
if (!isCustomer(IntegryCustomer.Tosca)) return;
String currentDbName = advancedDataSource.getDataSource().getDbName();
String currentDbName = connection.getDbName();
IntegryCustomerDB db = Arrays.stream(IntegryCustomer.Tosca.getValues()).filter(x -> x.getValue().equalsIgnoreCase(currentDbName)).findFirst().orElse(null);
LocalDate giorno = UtilityLocalDate.getNow();
@@ -52,7 +52,7 @@ public class Migration_20240321144750 extends BaseMigration implements Migration
}
String sql = "SELECT MAX(id_riga) from stb_calr_ore_gg where cod_Cal = 'DEFAULT'";
Integer idRiga = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
Integer idRiga = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
if (idRiga == null) {
throw new Exception("Calendario DEFAULT non configurato!");
@@ -71,7 +71,7 @@ public class Migration_20240321144750 extends BaseMigration implements Migration
.setOperation(OperationType.INSERT);
calendario.getStbCalrOreGg().add(firstWorkingHour);
calendario.manageWithParentConnection(advancedDataSource.getConnection());
calendario.manageWithParentConnection(connection);
}
@Override

View File

@@ -33,7 +33,7 @@ public class Migration_20240408151803 extends BaseMigration implements Migration
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_ANSI_PADDING", "S");
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_CONCAT_NULL_YIELDS_NULL", "S");
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.advancedDataSource.getConnection());
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.connection);
final List<String> queries = schemaManager.generateAlterTableToDisableAnsiPadding();
//executeStatement(queries.toArray(new String[0]));

View File

@@ -24,7 +24,7 @@ public class Migration_20240411152632 extends BaseMigration implements Migration
.setIndexName("ix_mtb_movi_kit")
.setColumnsIndex(columnsIndex)
.setColumnsInclude("anno");
UtilityDB.createIndex(advancedDataSource.getConnection(),indexTableDTO );
UtilityDB.createIndex(connection,indexTableDTO );
}
@Override

View File

@@ -43,7 +43,7 @@ public class Migration_20240514113425 extends BaseMigration implements Migration
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_ANSI_PADDING", "S");
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_CONCAT_NULL_YIELDS_NULL", "S");
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.advancedDataSource.getConnection());
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.connection);
final List<String> queries = schemaManager.generateAlterTableToDisableAnsiPadding();
//executeStatement(queries.toArray(new String[0]));

View File

@@ -20,7 +20,7 @@ public class Migration_20240626095147 extends BaseMigration implements Migration
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_ANSI_PADDING", "S");
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_CONCAT_NULL_YIELDS_NULL", "S");
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.advancedDataSource.getConnection());
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.connection);
final List<String> queries = schemaManager.generateAlterTableToDisableAnsiPadding();
//executeStatement(queries.toArray(new String[0]));

View File

@@ -28,7 +28,7 @@ public class Migration_20240828094457 extends BaseMigration implements Migration
return;
String sql = "SELECT * from vtb_clie";
List<VtbClie> listaClienti = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, VtbClie.class);
List<VtbClie> listaClienti = UtilityDB.executeSimpleQueryDTO(connection, sql, VtbClie.class);
if (listaClienti.isEmpty())
return;
@@ -40,8 +40,8 @@ public class Migration_20240828094457 extends BaseMigration implements Migration
.setOperation(OperationType.INSERT);
clie
.setOperation(OperationType.DELETE);
forn.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
clie.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
forn.manageWithParentConnection(connection, droolsDataCompleting);
clie.manageWithParentConnection(connection, droolsDataCompleting);
}
List<String> queryDiacod = new ArrayList<>();
@@ -78,7 +78,7 @@ public class Migration_20240828094457 extends BaseMigration implements Migration
for (String updateDiacodSql : queryDiacod) {
PreparedStatement updateDefaultFlagPS = advancedDataSource.getConnection().prepareStatement(updateDiacodSql);
PreparedStatement updateDefaultFlagPS = connection.prepareStatement(updateDiacodSql);
updateDefaultFlagPS.setQueryTimeout(30);
updateDefaultFlagPS.executeUpdate();
updateDefaultFlagPS.close();

View File

@@ -17,7 +17,7 @@ public class Migration_20240909153448 extends BaseMigration implements Migration
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_ANSI_PADDING", "S");
updateSetupValue("DATI_AZIENDA", "SETUP", "FLAG_CONCAT_NULL_YIELDS_NULL", "S");
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.advancedDataSource.getConnection());
SQLServerDBSchemaManager schemaManager = new SQLServerDBSchemaManager(this.connection);
final List<String> queries = schemaManager.generateAlterTableToDisableAnsiPadding();
//executeStatement(queries.toArray(new String[0]));

View File

@@ -302,7 +302,7 @@ public class Migration_20240920113346 extends BaseMigration implements Migration
// .setB64Jrxml(jrxml);
//
// wtbJrept.setOperation(OperationType.UPDATE);
// wtbJrept.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
// wtbJrept.manageWithParentConnection(connection, droolsDataCompleting);
// }
}

View File

@@ -84,7 +84,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setOperation(OperationType.INSERT);
anagPublication.getStbPublicationsDetails().add(detailAtbForn);
anagPublication.manageWithParentConnection(advancedDataSource.getConnection(),droolsDataCompleting);
anagPublication.manageWithParentConnection(connection,droolsDataCompleting);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Triggiano)">
StbPublications impegnatoTriggiano = new StbPublications();
@@ -113,7 +113,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoTriggiano.getStbPublicationsDetails().add(detailDtbOrdrBA);
impegnatoTriggiano.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoTriggiano.manageWithParentConnection(connection);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Caserta)">
StbPublications impegnatoCaserta = new StbPublications();
@@ -142,7 +142,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoCaserta.getStbPublicationsDetails().add(detailDtbOrdrCE);
impegnatoCaserta.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoCaserta.manageWithParentConnection(connection);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Catanzaro)">
StbPublications impegnatoCatanzaro = new StbPublications();
@@ -171,7 +171,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoCatanzaro.getStbPublicationsDetails().add(detailDtbOrdrCZ);
impegnatoCatanzaro.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoCatanzaro.manageWithParentConnection(connection);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Forlì-Cesena)">
StbPublications impegnatoFC = new StbPublications();
@@ -200,7 +200,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoFC.getStbPublicationsDetails().add(detailDtbOrdrFC);
impegnatoFC.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoFC.manageWithParentConnection(connection);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Milano)">
StbPublications impegnatoMI = new StbPublications();
@@ -229,7 +229,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoMI.getStbPublicationsDetails().add(detailDtbOrdrMI);
impegnatoMI.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoMI.manageWithParentConnection(connection);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Ragusa)">
StbPublications impegnatoRG = new StbPublications();
@@ -258,7 +258,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoRG.getStbPublicationsDetails().add(detailDtbOrdrRG);
impegnatoRG.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoRG.manageWithParentConnection(connection);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Roma)">
StbPublications impegnatoRoma = new StbPublications();
@@ -286,7 +286,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoRoma.getStbPublicationsDetails().add(detailDtbOrdrRM);
impegnatoRoma.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoRoma.manageWithParentConnection(connection);
//</editor-fold>
//<editor-fold desc="Pubblicazione impegnato (Verona)">
StbPublications impegnatoVR = new StbPublications();
@@ -315,7 +315,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
impegnatoVR.getStbPublicationsDetails().add(detailDtbOrdrVR);
impegnatoVR.manageWithParentConnection(advancedDataSource.getConnection());
impegnatoVR.manageWithParentConnection(connection);
//</editor-fold>
} else {
//<editor-fold desc="sottoscrizione anagrafiche">
@@ -331,7 +331,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setPassword("sql")
.setProfileDb("TOSCA_CLOUD")
.setOperation(OperationType.INSERT);
anagSubscription.manageWithParentConnection(advancedDataSource.getConnection());
anagSubscription.manageWithParentConnection(connection);
;
//</editor-fold>
@@ -347,7 +347,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoBa.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoBa.manageWithParentConnection(connection);
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Ce)) {
StbRemoteSubscription syncImpegnatoCe = new StbRemoteSubscription();
syncImpegnatoCe.setActive(true)
@@ -360,7 +360,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoCe.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoCe.manageWithParentConnection(connection);
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Cz)) {
StbRemoteSubscription syncImpegnatoCz = new StbRemoteSubscription();
syncImpegnatoCz.setActive(true)
@@ -373,7 +373,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoCz.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoCz.manageWithParentConnection(connection);
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Fc)) {
StbRemoteSubscription syncImpegnatoFc = new StbRemoteSubscription();
syncImpegnatoFc.setActive(true)
@@ -386,7 +386,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoFc.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoFc.manageWithParentConnection(connection);
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Mi)) {
StbRemoteSubscription syncImpegnatoMi = new StbRemoteSubscription();
syncImpegnatoMi.setActive(true)
@@ -399,7 +399,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoMi.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoMi.manageWithParentConnection(connection);
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Rg)) {
StbRemoteSubscription syncImpegnatoRg = new StbRemoteSubscription();
syncImpegnatoRg.setActive(true)
@@ -412,7 +412,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoRg.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoRg.manageWithParentConnection(connection);
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Rm)) {
StbRemoteSubscription syncImpegnatoRm = new StbRemoteSubscription();
syncImpegnatoRm.setActive(true)
@@ -425,7 +425,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoRm.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoRm.manageWithParentConnection(connection);
} else if (isCustomerDb(IntegryCustomerDB.Tosca_Vr)) {
StbRemoteSubscription syncImpegnatoVr = new StbRemoteSubscription();
syncImpegnatoVr.setActive(true)
@@ -438,7 +438,7 @@ public class Migration_20240930110848 extends BaseMigration implements Migration
.setUsernameField("dba")
.setPassword("sql")
.setOperation(OperationType.INSERT);
syncImpegnatoVr.manageWithParentConnection(advancedDataSource.getConnection());
syncImpegnatoVr.manageWithParentConnection(connection);
}
}

View File

@@ -22,11 +22,11 @@ public class Migration_20241021113736 extends BaseMigration implements Migration
String maxTransactionIdSql = "SELECT MAX(group_id) AS max_id " +
"FROM stb_transaction_log";
Long maxTransactionId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), maxTransactionIdSql);
Long maxTransactionId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, maxTransactionIdSql);
maxTransactionId = maxTransactionId == null ? 0 : ++maxTransactionId;
String retrievePublicationsSql = "SELECT * FROM stb_publications";
final List<StbPublications> stbPublications = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), retrievePublicationsSql, StbPublications.class);
final List<StbPublications> stbPublications = UtilityDB.executeSimpleQueryDTO(connection, retrievePublicationsSql, StbPublications.class);
if (stbPublications == null || stbPublications.isEmpty())
return;
@@ -35,7 +35,7 @@ public class Migration_20241021113736 extends BaseMigration implements Migration
stbPublication.setLastGroupId(maxTransactionId);
stbPublication.setOperation(OperationType.UPDATE);
stbPublication.manageWithParentConnection(advancedDataSource.getConnection());
stbPublication.manageWithParentConnection(connection);
}
}

View File

@@ -27,7 +27,7 @@ public class Migration_20241107192339 extends BaseMigration implements Migration
mtbDepo.getMrlDepoArtEsclusiWms().add(mrlDepoArtEsclusiWms);
mtbDepo.manageWithParentConnection(advancedDataSource.getConnection());
mtbDepo.manageWithParentConnection(connection);
}

View File

@@ -43,7 +43,7 @@ public class Migration_20241108153628 extends BaseMigration implements Migration
w.setCompiledJasper(ArrayUtils.toObject(baos.toByteArray()));
w.setOperation(OperationType.UPDATE);
w.manageWithParentConnection(advancedDataSource.getConnection());
w.manageWithParentConnection(connection);
}
// throw new RuntimeException("TEST");

View File

@@ -32,7 +32,7 @@ public class Migration_20241114130118 extends BaseMigration implements Migration
.setExportHistory(false)
.setOperation(OperationType.INSERT);
anagPublication.getStbPublicationsDetails().add(detailVtbVett);
anagPublication.manageWithParentConnection(advancedDataSource.getConnection(),droolsDataCompleting);
anagPublication.manageWithParentConnection(connection,droolsDataCompleting);
}

View File

@@ -330,8 +330,8 @@ public class Migration_20241213163759 extends BaseMigration implements Migration
.setCodMdep(getInternalCodMdep());
mtbColt.setOperation(OperationType.INSERT);
mtbColt.dataCompleting(advancedDataSource.getConnection());
mtbColt.manageWithParentConnection(advancedDataSource.getConnection());
mtbColt.dataCompleting(connection);
mtbColt.manageWithParentConnection(connection);
executeStatement(Query.format(
@@ -393,7 +393,7 @@ public class Migration_20241213163759 extends BaseMigration implements Migration
private String getInternalCodMdep() throws Exception {
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), "SELECT TOP 1 cod_mdep" +
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT TOP 1 cod_mdep" +
" FROM mtb_depo" +
" INNER JOIN dbo.gtb_anag ga ON mtb_depo.cod_anag = ga.cod_anag" +
" inner join azienda on ga.part_iva = azienda.part_iva");

View File

@@ -41,7 +41,7 @@ public class Migration_20250113112138 extends BaseMigration implements Migration
.setFlagDocTd("N")
.setFlagCalcPesoIntra("N");
dtbTipi.setOperation(OperationType.INSERT);
dtbTipi.manageWithParentConnection(advancedDataSource.getConnection());
dtbTipi.manageWithParentConnection(connection);
dtbTipi = new DtbTipi()
.setCodDtip("DDTP-")
@@ -68,7 +68,7 @@ public class Migration_20250113112138 extends BaseMigration implements Migration
.setFlagDocTd("N")
.setFlagCalcPesoIntra("N");
dtbTipi.setOperation(OperationType.INSERT);
dtbTipi.manageWithParentConnection(advancedDataSource.getConnection());
dtbTipi.manageWithParentConnection(connection);
updateSetupValue("DTB_DOCT", "FATTURA_PEDANE", "TIPO_DOC_CONS", "DDTP+");
updateSetupValue("DTB_DOCT", "FATTURA_PEDANE", "TIPO_DOC_RESI", "DDTP-");

View File

@@ -20,7 +20,7 @@ public class Migration_20250114155646 extends BaseMigration implements Migration
return;
//Eseguo la alter di tutte le SP che risultano QuotedIdentifier OFF in modo da farle elaborare come ON
final List<String> spToUpdate = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), "SELECT QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(name) AS name\n" +
final List<String> spToUpdate = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, "SELECT QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(name) AS name\n" +
"FROM sys.sql_modules m\n" +
"INNER JOIN sys.objects o ON m.object_id = o.object_id\n" +
"WHERE o.type = 'P' -- Solo stored procedure\n" +
@@ -29,7 +29,7 @@ public class Migration_20250114155646 extends BaseMigration implements Migration
final SystemMigrationService systemMigrationService = getContextBean(SystemMigrationService.class);
String[] spToUpdateArray = spToUpdate.toArray(new String[0]);
final List<SqlObjectDTO> querySyntaxFromExistingObjects = systemMigrationService.createQuerySyntaxFromExistingObjects(advancedDataSource.getConnection(), spToUpdateArray);
final List<SqlObjectDTO> querySyntaxFromExistingObjects = systemMigrationService.createQuerySyntaxFromExistingObjects(connection, spToUpdateArray);
for (SqlObjectDTO sqlObjectDTO : querySyntaxFromExistingObjects) {
try {

View File

@@ -5,7 +5,6 @@ import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.dto.IndexTableDTO;
import java.util.Arrays;
import java.util.Collections;
public class Migration_20250211173350 extends BaseMigration implements MigrationModelInterface {
@@ -23,7 +22,7 @@ public class Migration_20250211173350 extends BaseMigration implements Migration
.setColumnsIndex(Collections.singletonList(
new IndexTableDTO.ColumnIndex("id_lotto")
));
UtilityDB.createIndex(advancedDataSource.getConnection(),indexTableDTO);
UtilityDB.createIndex(connection,indexTableDTO);
}
@Override

View File

@@ -15,7 +15,7 @@ public class Migration_20250303123610 extends BaseMigration implements Migration
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
return;
Boolean exist = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
Boolean exist = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
"SELECT Cast( COUNT(*) as bit)\n" +
"FROM \n" +
" INFORMATION_SCHEMA.KEY_COLUMN_USAGE c\n" +
@@ -28,10 +28,10 @@ public class Migration_20250303123610 extends BaseMigration implements Migration
"\tand c.COLUMN_NAME = 'cod_anag'");
if ( exist ){
Boolean newSp = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
Boolean newSp = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
"SELECT cast(IIF(value='S',1,0) as bit) FROM stb_gest_setup where gest_name = 'DATI_AZIENDA' AND section = 'PROGRESSIVI_MAG' and key_section = 'NUOVA_PROCEDURA'"
);
Boolean existMov = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
Boolean existMov = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
"SELECT cast(count(*) as bit) from mtb_movi"
);

View File

@@ -21,7 +21,7 @@ public class Migration_20250404180134 extends BaseMigration implements Migration
"FROM stb_gest_setup\n" +
"WHERE key_section = 'ENABLE_MODIFICA_LOTTO_SUGGERITO'";
String value = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(this.advancedDataSource.getConnection(), sql);
String value = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(this.connection, sql);
if (UtilityString.isNullOrEmpty(value)) {
value = "N";
@@ -38,7 +38,7 @@ public class Migration_20250404180134 extends BaseMigration implements Migration
"FROM wtb_gest_setup_user\n" +
"WHERE key_section = 'ENABLE_MODIFICA_LOTTO_SUGGERITO'";
List<WtbGestSetupUser> userSetupConfig = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, WtbGestSetupUser.class);
List<WtbGestSetupUser> userSetupConfig = UtilityDB.executeSimpleQueryDTO(connection, sql, WtbGestSetupUser.class);
if (userSetupConfig != null && !userSetupConfig.isEmpty()) {
for (WtbGestSetupUser userSetup : userSetupConfig) {
@@ -47,7 +47,7 @@ public class Migration_20250404180134 extends BaseMigration implements Migration
userSetup.setOperation(OperationType.INSERT_OR_UPDATE);
userSetup.manageWithParentConnection(advancedDataSource.getConnection());
userSetup.manageWithParentConnection(connection);
}
}
}

View File

@@ -61,7 +61,7 @@ public class Migration_20250404180249 extends BaseMigration implements Migration
"WHERE key_section = 'ABILITA_CREA_DUPLICA_ORDINE'\n" +
" AND value = 'S'";
List<String> setupAbilitaCreaDuplicaOrdine = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sql);
List<String> setupAbilitaCreaDuplicaOrdine = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
if (setupAbilitaCreaDuplicaOrdine != null && !setupAbilitaCreaDuplicaOrdine.isEmpty()) {
for (String userName : setupAbilitaCreaDuplicaOrdine) {
@@ -77,7 +77,7 @@ public class Migration_20250404180249 extends BaseMigration implements Migration
"WHERE key_section = 'ABILITA_MODIFICA_ARTICOLI'\n" +
" AND value = 'S'";
List<String> setupAbilitaModificaArticoli = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sql);
List<String> setupAbilitaModificaArticoli = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
if (setupAbilitaModificaArticoli != null && !setupAbilitaModificaArticoli.isEmpty()) {
for (String userName : setupAbilitaModificaArticoli) {
@@ -108,7 +108,7 @@ public class Migration_20250404180249 extends BaseMigration implements Migration
COD_OPZ_MES
);
List<String> stbAbilMES = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sql);
List<String> stbAbilMES = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
if (stbAbilMES != null && !stbAbilMES.isEmpty()) {
for (String userName : stbAbilMES) {
@@ -168,7 +168,7 @@ public class Migration_20250404180249 extends BaseMigration implements Migration
}
for (EntityBase entity : entitiesToSave) {
entity.manageWithParentConnection(advancedDataSource.getConnection());
entity.manageWithParentConnection(connection);
}
}
}

View File

@@ -40,7 +40,7 @@ public class Migration_20250508103620 extends BaseMigration implements Migration
"GROUP BY id_bdg, cod_anag, cod_mart\n" +
"HAVING COUNT(*) > 1";
List<HashMap<String, Object>> listBdgDuplicati = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
List<HashMap<String, Object>> listBdgDuplicati = UtilityDB.executeSimpleQuery(connection, sql);
if (!listBdgDuplicati.isEmpty()) {
for (HashMap<String, Object> bdgDuplicati : listBdgDuplicati) {
@@ -55,7 +55,7 @@ public class Migration_20250508103620 extends BaseMigration implements Migration
vtbBdgr.setOperation(OperationType.INSERT);
vtbBdgr.manageWithParentConnection(advancedDataSource.getConnection());
vtbBdgr.manageWithParentConnection(connection);
String idRowDuplicati = UtilityHashMap.getValueIfExists(bdgDuplicati, "id_row_duplicati");

View File

@@ -7,9 +7,7 @@ import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.entity.StbEditLimit;
import it.integry.ems_model.entity.StbUser;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.Query;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityHashMap;
import it.integry.ems_model.utility.UtilityList;
import java.util.*;
@@ -43,7 +41,7 @@ public class Migration_20250516180736 extends BaseMigration implements Migration
" AND flag_abil = 'S'"
);
List<String> stbAbilControlloGiacenze = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sql);
List<String> stbAbilControlloGiacenze = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
if (!UtilityList.isNullOrEmpty(stbAbilControlloGiacenze)) {
for (String userName : stbAbilControlloGiacenze) {
@@ -94,7 +92,7 @@ public class Migration_20250516180736 extends BaseMigration implements Migration
}
for (EntityBase entity : entitiesToSave) {
entity.manageWithParentConnection(advancedDataSource.getConnection());
entity.manageWithParentConnection(connection);
}
}

View File

@@ -39,7 +39,7 @@ public class Migration_20250520110003 extends BaseMigration implements Migration
" AND flag_abil = 'S'"
);
List<String> stbAbilMES = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sql);
List<String> stbAbilMES = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
if (!UtilityList.isNullOrEmpty(stbAbilMES)) {
for (String userName : stbAbilMES) {
@@ -90,7 +90,7 @@ public class Migration_20250520110003 extends BaseMigration implements Migration
}
for (EntityBase entity : entitiesToSave) {
entity.manageWithParentConnection(advancedDataSource.getConnection());
entity.manageWithParentConnection(connection);
}
}

View File

@@ -0,0 +1,24 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250728173657 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
createSetup("PVM", "SETUP", "CAN_EDIT_PERM", null,
"Setup per mostrare o meno il pulsante per modificare i permessi.", false, "SI_NO", false, false,
true, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -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_20250729103953 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("alter table gtb_anag_note add flag_stampa_pkl bit not null default 0");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,20 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250729124207 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("alter table ctb_nc_intracee alter column taric varchar(10) null",
"alter table mtb_aart alter column taric varchar(10) null");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,26 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250729170848 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isCustomer(IntegryCustomer.FolliesGroup)) {
updateSetupValue("DATI_AZIENDA", "SETUP", "DELIMITED_IDENTIFIER", "1");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -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_20250730152443 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("ALTER TABLE stb_posizioni ADD descrizione VARCHAR(50) NULL");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,21 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250730153210 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("ALTER TABLE stb_activity\n" +
" ADD id_posizione BIGINT\n" +
" CONSTRAINT fk_stb_activity_stb_posizioni REFERENCES dbo.stb_posizioni");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,20 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250731175503 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isCustomer(IntegryCustomer.Smetar)) enableSaveToRest("w_ppros_transfer_dlg");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,71 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250805155057 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("EXPORT_ORDINI VENDITA", "EXCEL_IMMAGINI", "QUERY", null,
"inserire la query base per tutte le esportazioni", false, null, false, false,
false, false, false, null, false, null);
if (isCustomer(IntegryCustomer.FolliesGroup)) {
updateSetupValue("EXPORT_ORDINI VENDITA", "EXCEL_IMMAGINI",
"QUERY", "\n" +
"SELECT mtb_aart.cod_mart,\n" +
" mtb_aart.descrizione,\n" +
" dtb_ordr.cod_col,\n" +
" dtb_ordr.cod_tagl,\n" +
" ttb_bar_code.cod_barre,\n" +
" dtb_ordr.qta_ord,\n" +
" dtb_ordr.val_unt,\n" +
" CEILING((dtb_ordr.val_unt + (ttb_style.val_scatto * ttb_style_taglie.num_scatto)) *\n" +
" (ttb_style.prz_retail_vend_iva / ttb_style.prezzo_base) / 0.10) * 0.10 AS przvendretail,\n" +
" ttb_style.des_comp,\n" +
" ttb_style_dazi_usa.cod_dazio,\n" +
" ttb_style.cod_nazi\n" +
"FROM dtb_ordt\n" +
" INNER JOIN dtb_ordr\n" +
" ON dtb_ordt.gestione = dtb_ordr.gestione\n" +
" AND dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
" AND dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
" INNER JOIN mtb_aart\n" +
" ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
" INNER JOIN ttb_style\n" +
" ON dtb_ordr.cod_mart = ttb_style.cod_style\n" +
" LEFT OUTER JOIN ttb_comp ON ttb_style.cod_comp = ttb_comp.cod_comp\n" +
" LEFT OUTER JOIN ttb_style_taglie\n" +
" ON dtb_ordr.cod_mart = ttb_style_taglie.cod_style\n" +
" AND dtb_ordr.cod_tagl = ttb_style_taglie.cod_tagl\n" +
" LEFT OUTER JOIN ttb_style_dazi_usa ON ttb_style_taglie.cod_style = ttb_style_dazi_usa.cod_style AND\n" +
" ttb_style_taglie.babynobaby = ttb_style_dazi_usa.babynobaby\n" +
" LEFT OUTER JOIN ttb_bar_code\n" +
" ON dtb_ordr.cod_mart = ttb_bar_code.cod_style\n" +
" AND dtb_ordr.cod_col = ttb_bar_code.cod_col\n" +
" AND dtb_ordr.cod_tagl = ttb_bar_code.cod_tagl\n" +
"WHERE dtb_ordr.gestione = 'V'\n" +
" AND dtb_ordr.flag_evaso <> 'A'\n" +
"ORDER BY mtb_aart.cod_mart,\n" +
" mtb_aart.descrizione,\n" +
" dtb_ordr.cod_col,\n" +
" ttb_style_taglie.pos");
executeStatement("update wtb_users_info SET query_custom = null\n" +
"where export_type = 'ORDINI VENDITA' AND \n" +
"format_file = 'EXCEL_IMMAGINI'");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,24 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250805173242 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
createSetup("PVM", "MONITORAGGIO_LINEE_V2", "PROPONI_ULTIMO_VALORE_UDC", "S",
"Proponi l'ultimo valore inserito in creazione udc.", false, "SI_NO", false, false,
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,29 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250806103557 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("w_ddocu_ord_rc", "SETUP", "VISUALIZZA_TUTTI_ALLEGATI", "S",
"se impostata ad S permette di visualizzare tutte le versioni delle stampe, ad N solo l'ultima", false, null, false, false,
false, false, false, null, false, null);
if (isCustomerDb(IntegryCustomerDB.Cosmapack_Cosmint)){
updateSetupValue("w_ddocu_ord_rc","SETUP","VISUALIZZA_TUTTI_ALLEGATI","N");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,41 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250806105411 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomerDb(IntegryCustomerDB.Vinella_Vinella))
return;
updateSetupValue("w_jriep_presenze_dip_disp", "DATAWINDOW", "D_JRIEP_PRESENZE_DIP_COMM_REP", "D_JRIEP_PRESENZE_DIP_ORE_VINELLA_REP",
null, false, null, false, false, false,
false, false, null, false, null);
executeStatement("DELETE\n" +
"FROM stb_gest_setup_depo\n" +
"WHERE gest_name = 'w_jriep_presenze_dip_disp'\n" +
" AND section = 'DATAWINDOW'\n" +
" AND key_section = 'D_JRIEP_PRESENZE_DIP_COMM_REP'"
);
executeStatement("DELETE\n" +
"FROM wtb_gest_setup_user\n" +
"WHERE gest_name = 'w_jriep_presenze_dip_disp'\n" +
" AND section = 'DATAWINDOW'\n" +
" AND key_section = 'D_JRIEP_PRESENZE_DIP_COMM_REP'"
);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,139 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250806163114 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isDMS()) return;
createOrUpdateProcedure("UpdProgOrdini", "CREATE PROCEDURE [dbo].[UpdProgOrdini](\n" +
" @codAnag varchar(5),\n" +
" @codDtip varchar(5),\n" +
" @dataDoc dateTime,\n" +
" @serDoc varchar(2),\n" +
" @numDoc integer,\n" +
" @segno integer,\n" +
" @Operation varchar(1))\n" +
" /***DESCRIZIONE: Questa storedProcedure aggiorna la quantitÃÆÃ†â€™Ãƒâ€šÃ  evasa degli ordini e anche il \n" +
" numero di pezzi, non contiene una serie di logiche particolarti tipo la \n" +
" sostuzione dell'articolo nell'ordine\n" +
" \n" +
" */\n" +
"AS\n" +
"BEGIN\n" +
" SET NOCOUNT ON;\n" +
" \n" +
"\n" +
" UPDATE dtb_ordr\n" +
" SET dtb_ordr.qta_evasa = CASE WHEN (SELECT application_name from azienda ) = 'WINGEST' THEN dtb_ordr.qta_evasa + CASE dtb_ordr.unt_ord\n" +
" when doc.unt_doc then doc.qta_doc\n" +
" when doc.unt_doc2 then doc.qta_doc2\n" +
" when doc.unt_doc3 then doc.qta_doc3\n" +
" else \n" +
"Round((@segno * (doc.qta_doc_no_um / dtb_ordr.rap_conv)),mtb_unt_mis.cifre_dec) end \n" +
" ELSE dtb_ordr.qta_evasa END, \n" +
" dtb_ordr.num_cnf_evasa = dtb_ordr.num_cnf_evasa + (@segno * doc.num_cnf),\n" +
" dtb_ordr.flag_evaso_forzato = CASE WHEN @Operation = 'D' THEN 'N' ELSE doc.flag_evaso_forzato END,\n" +
" dtb_ordr.flag_evaso = CASE WHEN @Operation = 'D' THEN 'I'\n" +
" WHEN doc.flag_evaso_forzato = 'S' THEN 'E' ELSE dtb_ordr.flag_evaso END \n" +
" FROM dtb_ordr INNER JOIN mtb_unt_mis ON dtb_ordr.unt_ord = mtb_unt_mis.unt_mis\n" +
" INNER JOIN \n" +
" (SELECT dtb_doct.gestione,\n" +
" dtb_docr.data_ord,\n" +
" dtb_docr.num_ord,\n" +
" dtb_docr.riga_ord,\n" +
" sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc_no_um,\n" +
" \n" +
" dtb_docr.unt_doc,\n" +
" sum(dtb_docr.qta_doc) as qta_doc,\n" +
" \n" +
" dtb_docr.unt_doc2,\n" +
" sum(dtb_docr.qta_doc2) as qta_doc2,\n" +
" \n" +
" dtb_docr.unt_doc3,\n" +
" sum(dtb_docr.qta_doc3) as qta_doc3,\n" +
" sum(dtb_docr.num_cnf) as num_cnf,\n" +
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
" dtb_doct.num_doc = dtb_docr.num_doc \n" +
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
" dtb_doct.cod_anag = @codAnag AND\n" +
" dtb_doct.data_doc = @dataDoc AND\n" +
" dtb_doct.ser_doc = @serDoc AND\n" +
" dtb_doct.num_doc = @numDoc AND\n" +
" dtb_docr.data_ord is not null AND\n" +
" ( dtb_doct.gestione <> 'L' AND (dtb_tipi.segno_qta_car = 1 OR dtb_tipi.segno_qta_scar = 1 ) OR \n" +
" ( dtb_doct.gestione = 'L' AND dtb_tipi.segno_qta_scar = 1 ))\n" +
" GROUP BY dtb_doct.gestione,\n" +
" dtb_docr.data_ord,\n" +
" dtb_docr.num_ord,\n" +
" dtb_docr.riga_ord, \n" +
" dtb_docr.unt_doc, \n" +
" dtb_docr.unt_doc2, \n" +
" dtb_docr.unt_doc3 \n" +
" UNION ALL\n" +
" SELECT dtb_ordt.gestione_rif,\n" +
" dtb_ordt.data_ord_rif, \n" +
" dtb_ordt.num_ord_rif, \n" +
" dtb_ordt.riga_ord_rif,\n" +
" sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc_no_um,\n" +
" \n" +
" dtb_docr.unt_doc,\n" +
" sum(dtb_docr.qta_doc) as qta_doc,\n" +
" \n" +
" dtb_docr.unt_doc2,\n" +
" sum(dtb_docr.qta_doc2) as qta_doc2,\n" +
" \n" +
" dtb_docr.unt_doc3,\n" +
" sum(dtb_docr.qta_doc3) as qta_doc3,\n" +
" sum(dtb_docr.num_cnf) as num_cnf,\n" +
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
" left outer join dtb_ordt ON dtb_tipi.gestione = dtb_ordt.gestione and\n" +
" dtb_docr.data_ord = dtb_ordt.data_ord and\n" +
" dtb_docr.num_ord = dtb_ordt.num_ord\n" +
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
" dtb_doct.cod_anag = @codAnag AND\n" +
" dtb_doct.data_doc = @dataDoc AND\n" +
" dtb_doct.ser_doc = @serDoc AND\n" +
" dtb_doct.num_doc = @numDoc AND\n" +
" dtb_docr.data_ord is not null AND\n" +
" dtb_doct.gestione = 'L' AND dtb_tipi.segno_qta_car = 1 AND\n" +
" (SELECT application_name from azienda ) = 'WINGEST'\n" +
" GROUP BY dtb_ordt.gestione_rif,\n" +
" dtb_ordt.data_ord_rif,\n" +
" dtb_ordt.num_ord_rif,\n" +
" dtb_ordt.riga_ord_rif, \n" +
" dtb_docr.unt_doc, \n" +
" dtb_docr.unt_doc2, \n" +
" dtb_docr.unt_doc3 ) doc ON\n" +
" dtb_ordr.gestione = doc.gestione AND\n" +
" dtb_ordr.data_ord = doc.data_ord AND\n" +
" dtb_ordr.num_ord = doc.num_ord AND\n" +
" dtb_ordr.riga_ord = doc.riga_ord;\n" +
" \n" +
" \n" +
"END");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,45 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250807105039 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isDMS()) return;
createOrUpdateView(
"wtb_users",
"CREATE VIEW [dbo].[Wtb_users] AS\n" +
" SELECT [User_name],\n" +
" [Full_name],\n" +
" CASE\n" +
" WHEN stb_user.key_group = 1 OR stb_user.flag_dba = 'S' THEN NULL\n" +
" ELSE dbo.sys_dcd_pss([Password]) END AS [Password],\n" +
" [key_group],\n" +
" [User_code],\n" +
" [Details],\n" +
" [Last_access_datetime],\n" +
" [flag_attivo] AS ctrl_state,\n" +
" [password_endtime],\n" +
" [url_css],\n" +
" [cod_lang],\n" +
" [creation_datetime],\n" +
" [e_mail],\n" +
" [password_expires_days],\n" +
" [last_passwords],\n" +
" [flag_password_expiring],\n" +
" password_endtime AS [destruction_datetime]\n" +
" FROM [dbo].stb_user\n" +
" WHERE flag_extra_user = 'S'\n"
);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -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_20250807112659 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
dropColumn("stb_user", "destruction_datetime");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,44 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250807114849 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("IMPORT_BILANCE", "DIGI", "ATTIVO", "N",
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BILANCE", "DIGI", "EMAIL_FOR_LOG", null,
"Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BILANCE", "DIGI", "FILE_FILTER", null,
"Inserire il criterio di filtro dei file o il nome del file specifio (seguire la sintassi di java)", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BILANCE", "DIGI", "GG_CANC_FILE", null,
"Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BILANCE", "DIGI", "IMPORT_REST", "S",
"Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BILANCE", "DIGI", "LISTENING", "N",
"Se LISTENIG = 'N' la procedura di importazione non si potrà mai mettere in ascolto sulla directory perchè nella procedura vengono prese in considerazione più file.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BILANCE", "DIGI", "PATH_FILE", null,
"Directory contente i file da importare.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BILANCE", "DIGI", "PATH_FILE_IMPORTED", null,
"Directory dove vengono spostati i file dopo l'importazione.", false, null, false, false,
false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,34 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250807114902 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (isDMS()) return;
executeStatement("CREATE TABLE ntb_pesate\n" +
"(\n" +
" id BIGINT IDENTITY PRIMARY KEY,\n" +
" cod_mdep VARCHAR(5) NOT NULL,\n" +
" data_pesate DATETIME NOT NULL,\n" +
" cod_mart VARCHAR(15) NOT NULL,\n" +
" qta_pesata NUMERIC(10, 5) NOT NULL DEFAULT 0,\n" +
" prz_vend NUMERIC(20, 5) NOT NULL DEFAULT 0,\n" +
"\n" +
" CONSTRAINT fk_ntb_pesate_mtb_depo\n" +
" FOREIGN KEY (cod_mdep) REFERENCES mtb_depo (cod_mdep),\n" +
" CONSTRAINT fk_ntb_pesate_mtb_aart\n" +
" FOREIGN KEY (cod_mart) REFERENCES mtb_aart (cod_mart)\n" +
");");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,47 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomerDB;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems_model.entity.StbGestSetupDet;
import it.integry.ems_model.types.OperationType;
public class Migration_20250807165031 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
deleteSetup("PVM", "CHIUSURA_TAGLI_PREZZO", "COD_MGRP");
createSetup("PVM", "CHIUSURA_TAGLI_PREZZO", "COD_MGRP", null,
"Setup per filtrare i gruppi disponibili per gruppo utente.", false, "COD_MGRP", false, false,
false, false, false, "Wtb_user_groups", true);
if (isCustomerDb(IntegryCustomerDB.Carelli_Carelli)) {
StbGestSetupDet stbGestSetupDet = new StbGestSetupDet()
.setGestName("PVM")
.setSection("CHIUSURA_TAGLI_PREZZO")
.setKeySection("COD_MGRP")
.setTipoSetup("Wtb_user_groups")
.setValColRif("10")
.setValue("02");
stbGestSetupDet.setOperation(OperationType.INSERT_OR_UPDATE);
stbGestSetupDet.manageWithParentConnection(connection);
}
createSetupQuery("COD_PROMO", "COD_PROMO", "SELECT cod_promo FROM vtb_promo");
createSetup("PVM", "CHIUSURA_TAGLI_PREZZO", "COD_PROMO", null,
"Setup per filtrare le promo disponibili per gruppo utente.", false, "COD_PROMO", false, false,
false, false, false, "Wtb_user_groups", true);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,20 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250807171229 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("ALTER TABLE dtb_tipi add cod_paga varchar(5), \n" +
"\tFOREIGN KEY (cod_paga) REFERENCES gtb_paga(cod_paga);");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,44 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250808161600 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "ATTIVO", "N",
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "EMAIL_FOR_LOG", null,
"Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "FILE_FILTER", null,
"Inserire il criterio di filtro dei file o il nome del file specifio (seguire la sintassi di java)", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "GG_CANC_FILE", null,
"Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "IMPORT_REST", "S",
"Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "LISTENING", "N",
"Se LISTENIG = 'N' la procedura di importazione non si potrà mai mettere in ascolto sulla directory perchè nella procedura vengono prese in considerazione più file.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "PATH_FILE", null,
"Directory contente i file da importare.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_BANCA", "TASSI_DI_CAMBIO", "PATH_FILE_IMPORTED", null,
"Directory dove vengono spostati i file dopo l'importazione.", false, null, false, false,
false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -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_20250811101036 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("drop table drl_tipi_mod_stampa");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,24 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250811102732 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement(" CREATE TABLE drl_tipi_report (id bigint identity not null, cod_dtip varchar(5) not null, report_id bigint not null, \n" +
" \tsort_id TinyInt not null default 0, report_type tinyInt, is_required bit default 0,\n" +
" CONSTRAINT PK_drl_tipi_report PRIMARY KEY (id),\n" +
" CONSTRAINT FK_drl_tipi_report_cod_dtip FOREIGN KEY (cod_dtip) REFERENCES dtb_tipi(cod_dtip),\n" +
" CONSTRAINT FK_drl_tipi_report_report_id FOREIGN KEY (report_id) REFERENCES wtb_jrept(id))",
" CREATE UNIQUE INDEX idx_cod_dtip_sort_id ON drl_tipi_report (cod_dtip, sort_id)");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,47 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250812171739 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("IMPORT_COLLI", "SONOCO", "ATTIVO", "N",
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "COD_ANAG", null,
"Codice fornitore", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "EMAIL_FOR_LOG", null,
"Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "FILE_FILTER", null,
"Inserire il criterio di filtro dei file o il nome del file specifio (seguire la sintassi di java)", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "GG_CANC_FILE", null,
"Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "IMPORT_REST", "S",
"Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "LISTENING", "N",
"Se LISTENIG = 'N' la procedura di importazione non si potrà mai mettere in ascolto sulla directory perchè nella procedura vengono prese in considerazione più file.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "PATH_FILE", null,
"Directory contente i file da importare.", false, null, false, false,
false, false, false, null, false, null);
createSetup("IMPORT_COLLI", "SONOCO", "PATH_FILE_IMPORTED", null,
"Directory dove vengono spostati i file dopo l'importazione.", false, null, false, false,
false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,57 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
import it.integry.ems_model.entity.JtbFasi;
import it.integry.ems_model.entity.StbGestSetup;
import it.integry.ems_model.entity.StbGestSetupDet;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityList;
import java.util.List;
public class Migration_20250818162653 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
StbGestSetup setup = new StbGestSetup()
.setGestName("PVM")
.setSection("MONITORAGGIO_LINEE_V2")
.setKeySection("REPORT_NAME_ORDINE")
.setTipoSetup(JtbFasi.ENTITY);
setup.setOperation(OperationType.UPDATE);
if (isCustomer(IntegryCustomer.RossoGargano)){
String sql = "SELECT cod_jfas,cod_jfas_parent from jtb_fasi where cod_jfas_parent in ('CONF','PROD') and um_prod is not null";
List<JtbFasi> listFasi = UtilityDB.executeSimpleQueryDTO(connection, sql, JtbFasi.class);
if (!UtilityList.isNullOrEmpty(listFasi)){
for (JtbFasi jtbFasi: listFasi){
StbGestSetupDet setupDet = new StbGestSetupDet()
.setValColRif(jtbFasi.getCodJfas())
.setGestName(setup.getGestName())
.setSection(setup.getSection())
.setKeySection(setup.getKeySection())
.setTipoSetup(setup.getTipoSetup())
.setValue("CONF".equalsIgnoreCase(jtbFasi.getCodJfasParent()) ? "StampaOrdineDiEtichettatura" : "StampaOrdineDiLavorazione");
setupDet.setOperation(OperationType.INSERT);
setup.getStbGestSetupDet().add(setupDet);
}
}
}
setup.manageWithParentConnection(connection);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,433 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250825162112 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
if (!isCustomer(IntegryCustomer.Smetar)) return;
createOrUpdateView("vsvw_vendite", "CREATE view [dbo].[vsvw_vendite] as \n" +
"SELECT DISTINCT dtb_doct_b.cod_dtip_val AS cod_dtip,\n" +
" dtb_doct_b.data_doc_val AS data_doc,\n" +
" dtb_doct_b.ser_doc_val AS ser_doc,\n" +
" dtb_doct_b.num_doc_val AS num_doc,\n" +
" dtb_docr.cod_dtip_comp,\n" +
" dtb_docr.data_doc_comp,\n" +
" dtb_docr.ser_doc_comp,\n" +
" dtb_docr.num_doc_comp,\n" +
" dtb_doct_a.cod_vage,\n" +
" ISNULL(vtb_clie.cod_anag_stat, dtb_doct_b.cod_anag) AS cod_anag,\n" +
" dtb_doct_b.cod_vdes,\n" +
" dtb_doct_b.cod_vzon,\n" +
" vtb_clie.cod_vtip,\n" +
" dtb_doct_b.cod_dtip AS cod_dtip_bolla,\n" +
" dtb_doct_b.data_doc AS data_doc_bolla,\n" +
" dtb_doct_b.ser_doc AS ser_doc_bolla,\n" +
" dtb_doct_b.num_doc AS num_doc_bolla,\n" +
" dtb_doct_b.cod_mdep,\n" +
" ISNULL(mtb_aart.cod_mart_stat, dtb_docr.cod_mart) AS cod_mart,\n" +
" mtb_aart.cod_mgrp,\n" +
" mtb_aart.cod_msgr,\n" +
" mtb_aart.cod_mtip,\n" +
" mtb_aart.cod_mstp,\n" +
" ISNULL(mtb_aart.descrizione_stat, dtb_docr.descrizione) AS descrizione,\n" +
" dtb_docr.unt_doc,\n" +
" (segno_val_scar - segno_val_car) * dtb_doct_a.tot_imponib /\n" +
" dtb_doct_a.cambio AS tot_imponib,\n" +
" (segno_val_scar - segno_val_car) * dtb_doct_a.tot_iva /\n" +
" dtb_doct_a.cambio AS tot_iva,\n" +
" dtb_doct_b.tot_imponib / dtb_doct_b.cambio AS tot_imponib_bolla,\n" +
" dtb_doct_b.tot_iva / dtb_doct_b.cambio AS tot_iva_bolla,\n" +
" (segno_val_scar - segno_val_car) * dtb_docr.importo_riga /\n" +
" dtb_doct_b.cambio AS importo_riga,\n" +
" CASE\n" +
" WHEN sconto5 <> 100 AND sconto6 <> 100 AND sconto7 <> 100 AND sconto8 <> 100\n" +
" THEN (segno_qta_scar - segno_qta_car) * qta_doc\n" +
" ELSE 0 END AS qta_vend,\n" +
" CASE\n" +
" WHEN mtb_aart.peso_kg <> 0 AND mtb_aart.peso_kg IS NOT NULL THEN (CASE\n" +
" WHEN sconto5 <> 100 AND sconto6 <> 100 AND sconto7 <> 100 AND sconto8 <> 100\n" +
" THEN\n" +
" (segno_qta_scar - segno_qta_car) *\n" +
" qta_doc *\n" +
" dtb_docr.rap_conv *\n" +
" mtb_aart.peso_kg\n" +
" ELSE 0 END)\n" +
" ELSE 0 END AS qta_vend_kg,\n" +
" CASE\n" +
" WHEN sconto5 <> 100 AND sconto6 <> 100 AND sconto7 <> 100 AND sconto8 <> 100 THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) *\n" +
" (1 - dtb_docr.sconto5 / 100) * (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) *\n" +
" (1 - dtb_docr.sconto8 / 100)) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_vend,\n" +
" CASE\n" +
" WHEN sconto5 = 100 OR sconto6 = 100 OR sconto7 = 100 THEN (segno_qta_scar - segno_qta_car) * qta_doc\n" +
" ELSE 0 END AS qta_omg,\n" +
" CASE\n" +
" WHEN mtb_aart.peso_kg <> 0 AND mtb_aart.peso_kg IS NOT NULL THEN (CASE\n" +
" WHEN sconto5 = 100 OR sconto6 = 100 OR sconto7 = 100\n" +
" THEN\n" +
" (segno_qta_scar - segno_qta_car) *\n" +
" qta_doc *\n" +
" dtb_docr.rap_conv *\n" +
" mtb_aart.peso_kg\n" +
" ELSE 0 END)\n" +
" ELSE 0 END AS qta_omg_kg,\n" +
" CASE\n" +
" WHEN sconto5 = 100 OR sconto6 = 100 OR sconto7 = 100 THEN\n" +
" ((segno_qta_scar - segno_qta_car) * qta_doc * val_unt) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_omg,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_prov / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_prov) /\n" +
" dtb_doct_b.cambio AS importo_prov,\n" +
" dtb_docr.id_riga,\n" +
" gtb_divi.cod_divi,\n" +
" dtb_doct_a.listino AS cod_vlis,\n" +
" CASE\n" +
" WHEN sconto5 <> 100 AND sconto6 <> 100 AND sconto7 <> 100 AND sconto8 <> 100\n" +
" THEN (segno_qta_scar - segno_qta_car) * qta_doc * costo_unt / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_costo,\n" +
" CASE\n" +
" WHEN sconto5 = 100 OR sconto6 = 100 OR sconto7 = 100 THEN\n" +
" ((segno_qta_scar - segno_qta_car) * qta_doc * costo_unt) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_omg_costo,\n" +
" CASE\n" +
" WHEN sconto8 = 100 THEN ((segno_qta_scar - segno_qta_car) * qta_doc * costo_unt) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_scarti_prod,\n" +
" CASE\n" +
" WHEN flag_tipo_reso = 'R' THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) *\n" +
" (1 - dtb_docr.sconto5 / 100) * (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) *\n" +
" (1 - dtb_docr.sconto8 / 100)) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_resi_rivendibili,\n" +
" CASE\n" +
" WHEN flag_tipo_reso = 'S' THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) *\n" +
" (1 - dtb_docr.sconto5 / 100) * (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) *\n" +
" (1 - dtb_docr.sconto8 / 100)) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_resi_non_rivendibili,\n" +
" CASE\n" +
" WHEN flag_tipo_reso = 'P' THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) *\n" +
" (1 - dtb_docr.sconto5 / 100) * (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) *\n" +
" (1 - dtb_docr.sconto8 / 100)) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_resi_rettifica_prezzo,\n" +
" CASE\n" +
" WHEN flag_tipo_reso IS NOT NULL THEN (segno_qta_scar - segno_qta_car) * qta_doc\n" +
" ELSE 0 END AS qta_resi_rivendibili,\n" +
" dtb_docr.rap_conv,\n" +
" qta_doc * dtb_docr.rap_conv * peso_kg * (segno_qta_scar - segno_qta_car) AS pesokg,\n" +
" CASE\n" +
" WHEN dtb_docr.qta_cnf * (segno_qta_scar - segno_qta_car) = 0 THEN 0\n" +
" ELSE qta_doc * dtb_docr.rap_conv / dtb_docr.qta_cnf *\n" +
" (segno_qta_scar - segno_qta_car) END AS confezioni,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (dtb_doct_b.sconto1 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto1,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (dtb_doct_b.sconto2 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto2,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (dtb_doct_b.sconto3 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto3,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_doct_b.sconto4 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto4,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (dtb_docr.sconto5 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto5,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (dtb_docr.sconto6 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto6,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (dtb_docr.sconto7 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto7,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (dtb_docr.sconto8 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto8,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt) /\n" +
" dtb_doct_b.cambio AS fatturato_lordo,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_doct_b.sconto4 / 100) *\n" +
" (1 - dtb_docr.sconto5 / 100) * (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) *\n" +
" (1 - dtb_docr.sconto8 / 100) * (dtb_docr.perc_gest / 100) +\n" +
" (segno_val_scar - segno_val_car) * qta_doc * val_gest) /\n" +
" dtb_doct_b.cambio AS importo_gest,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_ispe / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_ispe) /\n" +
" dtb_doct_b.cambio AS importo_prov_ispe,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_promo / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_promo) /\n" +
" dtb_doct_b.cambio AS importo_promo,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_oneri / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_oneri) /\n" +
" dtb_doct_b.cambio) + ISNULL(\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) *\n" +
" (1 - dtb_docr.sconto5 / 100) * (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) *\n" +
" (1 - dtb_docr.sconto8 / 100) * (venditeoneri.perc_oneri_art / 100) +\n" +
" (segno_val_scar - segno_val_car) * qta_doc * venditeoneri.val_oneri_art) / dtb_doct_b.cambio),\n" +
" 0) AS importo_oneri,\n" +
" dtb_docr.cod_promo,\n" +
" vtb_clie.cod_vass,\n" +
" vtb_clie.cod_vgrp_acq,\n" +
" mtb_aart.peso_kg,\n" +
" mtb_aart.qta_cnf,\n" +
" CONVERT(INT, CASE WHEN dtb_doct_b.cod_forn_td IS NULL THEN 0 ELSE 1 END) AS flag_doc_td,\n" +
" dtb_docr.cod_jcom\n" +
"FROM dtb_docr\n" +
" LEFT OUTER JOIN dbo.getviewvenditeoneri() venditeoneri ON dtb_docr.cod_anag = venditeoneri.cod_anag_comp AND\n" +
" dtb_docr.cod_dtip = venditeoneri.cod_dtip_comp AND\n" +
" dtb_docr.data_doc = venditeoneri.data_doc_comp AND\n" +
" dtb_docr.num_doc = venditeoneri.num_doc_comp AND\n" +
" dtb_docr.ser_doc = venditeoneri.ser_doc_comp AND\n" +
" dtb_docr.cod_mart = venditeoneri.cod_mart,\n" +
" dtb_doct AS dtb_doct_a,\n" +
" dtb_doct AS dtb_doct_b,\n" +
" dtb_tipi,\n" +
" gtb_divi,\n" +
" azienda,\n" +
" mtb_aart,\n" +
" mtb_sgrp,\n" +
" vtb_clie\n" +
"WHERE (dtb_doct_b.cod_anag = dtb_docr.cod_anag)\n" +
" AND (dtb_doct_b.cod_dtip = dtb_docr.cod_dtip)\n" +
" AND (dtb_doct_b.data_doc = dtb_docr.data_doc)\n" +
" AND (dtb_doct_b.ser_doc = dtb_docr.ser_doc)\n" +
" AND (dtb_doct_b.num_doc = dtb_docr.num_doc)\n" +
" AND (dtb_doct_b.cod_anag = dtb_doct_a.cod_anag)\n" +
" AND (dtb_doct_b.cod_dtip_val = dtb_doct_a.cod_dtip)\n" +
" AND (dtb_doct_b.data_doc_val = dtb_doct_a.data_doc)\n" +
" AND (dtb_doct_b.ser_doc_val = dtb_doct_a.ser_doc)\n" +
" AND (dtb_doct_b.num_doc_val = dtb_doct_a.num_doc)\n" +
" AND (dtb_doct_b.cod_anag = vtb_clie.cod_anag)\n" +
" AND (dtb_tipi.cod_dtip = dtb_doct_b.cod_dtip)\n" +
" AND (azienda.cod_divi_contab = gtb_divi.cod_divi)\n" +
" AND (dtb_docr.cod_mart = mtb_aart.cod_mart)\n" +
" AND (mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp)\n" +
" AND (mtb_aart.cod_msgr = mtb_sgrp.cod_msgr)\n" +
" AND (mtb_sgrp.incl_in_stat = 'S')\n" +
" AND ((dtb_doct_b.gestione = 'V') AND (dtb_tipi.tipo_emissione = 'DIRETTA') AND (dtb_docr.cod_mart IS NOT NULL))\n" +
" AND (dtb_tipi.flag_incl_stat = 'S')\n" +
" AND not Exists ( select * from mtb_aart inner join ctb_cont on mtb_aart.cod_ccon_ricavi = ctb_cont.cod_ccon\n" +
" inner join ctb_grup on ctb_cont.cod_cgrp = ctb_grup.cod_cgrp\n" +
"where ctb_grup.sezione = 1 and mtb_aart.cod_mart = dtb_docr.cod_mart) \n" +
"UNION ALL\n" +
"SELECT dtb_doct_b.cod_dtip_val,\n" +
" dtb_doct_b.data_doc_val,\n" +
" dtb_doct_b.ser_doc_val,\n" +
" dtb_doct_b.num_doc_val,\n" +
" dtb_docr.cod_dtip_comp,\n" +
" dtb_docr.data_doc_comp,\n" +
" dtb_docr.ser_doc_comp,\n" +
" dtb_docr.num_doc_comp,\n" +
" dtb_doct_a.cod_vage,\n" +
" ISNULL(vtb_clie.cod_anag_stat, dtb_doct_b.cod_anag) AS cod_anag,\n" +
" dtb_doct_b.cod_vdes,\n" +
" dtb_doct_b.cod_vzon,\n" +
" vtb_clie.cod_vtip,\n" +
" dtb_doct_b.cod_dtip,\n" +
" dtb_doct_b.data_doc,\n" +
" dtb_doct_b.ser_doc,\n" +
" dtb_doct_b.num_doc,\n" +
" dtb_doct_b.cod_mdep,\n" +
" dtb_docr.cod_mart,\n" +
" NULL,\n" +
" NULL,\n" +
" NULL,\n" +
" NULL,\n" +
" dtb_docr.descrizione,\n" +
" dtb_docr.unt_doc,\n" +
" (segno_val_scar - segno_val_car) * dtb_doct_a.tot_imponib /\n" +
" dtb_doct_a.cambio AS tot_imponib,\n" +
" (segno_val_scar - segno_val_car) * dtb_doct_a.tot_iva /\n" +
" dtb_doct_a.cambio AS tot_iva,\n" +
" dtb_doct_b.tot_imponib / dtb_doct_b.cambio AS tot_imponib_bolla,\n" +
" dtb_doct_b.tot_iva / dtb_doct_b.cambio AS tot_iva_bolla,\n" +
" (segno_val_scar - segno_val_car) * dtb_docr.importo_riga /\n" +
" dtb_doct_b.cambio AS importo_riga,\n" +
" CASE\n" +
" WHEN sconto5 <> 100 AND sconto6 <> 100 AND sconto7 <> 100 AND sconto8 <> 100\n" +
" THEN (segno_qta_scar - segno_qta_car) * qta_doc\n" +
" ELSE 0 END AS qta_vend,\n" +
" CONVERT(NUMERIC(15, 5), 0) AS qta_vend_kg,\n" +
" CASE\n" +
" WHEN sconto5 <> 100 AND sconto6 <> 100 AND sconto7 <> 100 AND sconto8 <> 100 THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100)) /\n" +
" dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_vend,\n" +
" CASE\n" +
" WHEN sconto5 = 100 OR sconto6 = 100 OR sconto7 = 100 THEN (segno_qta_scar - segno_qta_car) * qta_doc\n" +
" ELSE 0 END AS qta_omg,\n" +
" CONVERT(NUMERIC(15, 5), 0) AS qta_omg_kg,\n" +
" CASE\n" +
" WHEN sconto5 = 100 OR sconto6 = 100 OR sconto7 = 100 THEN\n" +
" ((segno_qta_scar - segno_qta_car) * qta_doc * val_unt) / dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_omg,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_prov / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_prov) /\n" +
" dtb_doct_b.cambio AS importo_prov,\n" +
" dtb_docr.id_riga,\n" +
" gtb_divi.cod_divi,\n" +
" dtb_doct_a.listino AS cod_vlis,\n" +
" CONVERT(NUMERIC(20, 5), 0) AS val_costo,\n" +
" CONVERT(NUMERIC(20, 5), 0) AS val_omg_costo,\n" +
" CONVERT(NUMERIC(20, 5), 0) AS val_scarti_prod,\n" +
" CASE\n" +
" WHEN flag_tipo_reso = 'R' THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100)) /\n" +
" dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_resi_rivendibili,\n" +
" CASE\n" +
" WHEN flag_tipo_reso = 'S' THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100)) /\n" +
" dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_resi_non_rivendibili,\n" +
" CASE\n" +
" WHEN flag_tipo_reso = 'P' THEN\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100)) /\n" +
" dtb_doct_b.cambio\n" +
" ELSE 0 END AS val_resi_rettifica_prezzo,\n" +
" CASE\n" +
" WHEN flag_tipo_reso IS NOT NULL THEN (segno_qta_scar - segno_qta_car) * qta_doc\n" +
" ELSE 0 END AS qta_resi_rivendibili,\n" +
" dtb_docr.rap_conv,\n" +
" 0 AS pesokg,\n" +
" CASE\n" +
" WHEN dtb_docr.qta_cnf * (segno_qta_scar - segno_qta_car) = 0 THEN 0\n" +
" ELSE qta_doc * dtb_docr.rap_conv / dtb_docr.qta_cnf *\n" +
" (segno_qta_scar - segno_qta_car) END AS confezioni,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (dtb_doct_b.sconto1 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto1,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (dtb_doct_b.sconto2 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto2,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (dtb_doct_b.sconto3 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto3,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_doct_b.sconto4 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto4,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (dtb_docr.sconto5 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto5,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (dtb_docr.sconto6 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto6,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (dtb_docr.sconto7 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto7,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (dtb_docr.sconto8 / 100))) /\n" +
" dtb_doct_b.cambio AS val_sconto8,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt) /\n" +
" dtb_doct_b.cambio AS fatturato_lordo,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_doct_b.sconto4 / 100) *\n" +
" (1 - dtb_docr.sconto5 / 100) * (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) *\n" +
" (1 - dtb_docr.sconto8 / 100) * (dtb_docr.perc_gest / 100) +\n" +
" (segno_val_scar - segno_val_car) * qta_doc * val_gest) /\n" +
" dtb_doct_b.cambio AS importo_gest,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_ispe / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_ispe) /\n" +
" dtb_doct_b.cambio AS importo_prov_ispe,\n" +
" ((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_promo / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_promo) /\n" +
" dtb_doct_b.cambio AS importo_promo,\n" +
" (((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (dtb_docr.perc_oneri / 100) + (segno_val_scar - segno_val_car) * qta_doc * val_oneri) / dtb_doct_b.cambio) +\n" +
" ISNULL((((segno_val_scar - segno_val_car) * qta_doc * val_unt * (1 - dtb_doct_b.sconto1 / 100) *\n" +
" (1 - dtb_doct_b.sconto2 / 100) * (1 - dtb_doct_b.sconto3 / 100) * (1 - dtb_docr.sconto5 / 100) *\n" +
" (1 - dtb_docr.sconto6 / 100) * (1 - dtb_docr.sconto7 / 100) * (1 - dtb_docr.sconto8 / 100) *\n" +
" (venditeoneri.perc_oneri_art / 100) +\n" +
" (segno_val_scar - segno_val_car) * qta_doc * venditeoneri.val_oneri_art) / dtb_doct_b.cambio),\n" +
" 0) AS importo_oneri,\n" +
" dtb_docr.cod_promo,\n" +
" vtb_clie.cod_vass,\n" +
" vtb_clie.cod_vgrp_acq,\n" +
" NULL,\n" +
" NULL,\n" +
" CONVERT(INT, CASE WHEN dtb_doct_b.cod_forn_td IS NULL THEN 0 ELSE 1 END) AS flag_doc_td,\n" +
" dtb_docr.cod_jcom\n" +
"FROM dtb_docr\n" +
" LEFT OUTER JOIN dbo.getviewvenditeoneri() venditeoneri ON dtb_docr.cod_anag = venditeoneri.cod_anag_comp AND\n" +
" dtb_docr.cod_dtip = venditeoneri.cod_dtip_comp AND\n" +
" dtb_docr.data_doc = venditeoneri.data_doc_comp AND\n" +
" dtb_docr.num_doc = venditeoneri.num_doc_comp AND\n" +
" dtb_docr.ser_doc = venditeoneri.ser_doc_comp AND\n" +
" dtb_docr.cod_mart = venditeoneri.cod_mart,\n" +
" dtb_doct AS dtb_doct_b,\n" +
" dtb_doct AS dtb_doct_a,\n" +
" dtb_tipi,\n" +
" gtb_divi,\n" +
" azienda,\n" +
" vtb_clie\n" +
"WHERE (dtb_doct_b.cod_anag = dtb_docr.cod_anag)\n" +
" AND (dtb_doct_b.cod_dtip = dtb_docr.cod_dtip)\n" +
" AND (dtb_doct_b.data_doc = dtb_docr.data_doc)\n" +
" AND (dtb_doct_b.ser_doc = dtb_docr.ser_doc)\n" +
" AND (dtb_doct_b.num_doc = dtb_docr.num_doc)\n" +
" AND (dtb_doct_b.cod_anag = dtb_doct_a.cod_anag)\n" +
" AND (dtb_doct_b.cod_dtip_val = dtb_doct_a.cod_dtip)\n" +
" AND (dtb_doct_b.data_doc_val = dtb_doct_a.data_doc)\n" +
" AND (dtb_doct_b.ser_doc_val = dtb_doct_a.ser_doc)\n" +
" AND (dtb_doct_b.num_doc_val = dtb_doct_a.num_doc)\n" +
" AND (dtb_doct_b.cod_anag = vtb_clie.cod_anag)\n" +
" AND (dtb_tipi.cod_dtip = dtb_doct_b.cod_dtip)\n" +
" AND (azienda.cod_divi_contab = gtb_divi.cod_divi)\n" +
" AND ((dtb_doct_b.gestione = 'V') AND (dtb_tipi.tipo_emissione = 'DIRETTA') AND (dtb_docr.cod_mart IS NULL) AND\n" +
" (dtb_docr.qta_doc <> 0))\n" +
" AND (dtb_tipi.flag_incl_stat = 'S')");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,29 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250825165957 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("W_CSITUAZ_CNTECONCOMM_DISP", "SETUP", "REPARTI_DA_ESCLUDERE", null,
"inseire l'elenco dei reparti da escludere dai rapportini di lavoro ( separati con |)", false, null, false, false,
false, false, false, null, false, null);
if (isCustomer(IntegryCustomer.Smetar)) {
updateSetupValue("W_CSITUAZ_CNTECONCOMM_DISP", "SETUP", "REPARTI_DA_ESCLUDERE", "FALE|2-LAV");
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,38 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.IntegryCustomer;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20250825170241 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("W_CSITUAZ_CNTECONCOMM_DISP", "DATAWINDOW", "D_CSIT_CNTECONCOMM_DETTAGLIATO_REP", null,
null, false, null, false, false,
false, false, false, null, false, null);
String dwName = "";
if (isCustomer(IntegryCustomer.Smetar)) {
dwName = "D_CSIT_CNTECONCOMM_DETTAGLIATO_SMETAR_REP";
} else if (isCustomer(IntegryCustomer.Cosmapack)) {
dwName = "d_csit_cnteconcomm_dett_cosm_rep";
} else if (isCustomer(IntegryCustomer.Vinella)) {
dwName = "d_csit_cnteconcomm_dett_vin_rep";
} else if (isCustomer(IntegryCustomer.Agricoper)) {
dwName = "d_csit_cnteconcomm_dett_agric_rep";
}
if (!dwName.equalsIgnoreCase("")) {
updateSetupValue("W_CSITUAZ_CNTECONCOMM_DISP", "DATAWINDOW", "D_CSIT_CNTECONCOMM_DETTAGLIATO_REP", dwName);
}
}
@Override
public void down() throws Exception {
}
}

View File

@@ -8,7 +8,7 @@ import it.integry.ems.migration.dto.MigrationStatusEnum;
import it.integry.ems.service.EntityProcessor;
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.utility.UtilityDebug;
import it.integry.ems_model.entity.StbMigrationStatus;
@@ -110,7 +110,7 @@ public class MigrationSetupService {
}
public void skip(long migrationCode) throws Exception {
final AdvancedDataSource advancedDataSource = multiDBTransactionManager.getActiveConnections().get(0);
final Connection activeConnection = multiDBTransactionManager.getActiveConnections().get(0);
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + migrationCode;
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbMigrationStatus.class);
@@ -125,16 +125,16 @@ public class MigrationSetupService {
entityProcessor.processEntity(stbMigrationStatus, multiDBTransactionManager);
}
migrationComponent.updateLastMigrationIntoDB(advancedDataSource, migrationCode);
migrationComponent.executeMigrationGroup(advancedDataSource);
migrationComponent.updateLastMigrationIntoDB(activeConnection, migrationCode);
migrationComponent.executeMigrationGroup(activeConnection);
}
public void executeAll() throws Exception {
for (AvailableConnectionsModel availableConnectionsModel : settingsModel.getAvailableConnections(true)) {
if (multiDBTransactionManager.getActiveConnections().stream()
.noneMatch(advancedDataSource ->
advancedDataSource.getDataSource().getDbName().equalsIgnoreCase(availableConnectionsModel.getDbName()))) {
.noneMatch(connection ->
connection.getDbName().equalsIgnoreCase(availableConnectionsModel.getDbName()))) {
multiDBTransactionManager.addConnection(availableConnectionsModel);
}
}

View File

@@ -68,7 +68,7 @@ public class StoredProcedure {
StoredProcedure.close();
multiDBTransactionManager.commitAll();
multiDBTransactionManager.closeAll();
multiDBTransactionManager.close();
this.logger.debug("UpdProgMaga - Aggiornato movimento : " + inputData);
@@ -76,7 +76,7 @@ public class StoredProcedure {
try {
if (multiDBTransactionManager != null) {
multiDBTransactionManager.rollbackAll();
multiDBTransactionManager.closeAll();
multiDBTransactionManager.close();
}
} catch (Exception ex) {
this.logger.error("UpdProgMaga", ex);
@@ -123,7 +123,7 @@ public class StoredProcedure {
StoredProcedure.close();
multiDBTransactionManager.commitAll();
multiDBTransactionManager.closeAll();
multiDBTransactionManager.close();
this.logger.debug("MRP_UpdateQtaImpProx - Aggiornato impegni prossimi articoli : " + StringUtils.join(listaArticoli, ','));
@@ -136,7 +136,7 @@ public class StoredProcedure {
}
if (multiDBTransactionManager != null) {
multiDBTransactionManager.rollbackAll();
multiDBTransactionManager.closeAll();
multiDBTransactionManager.close();
}
} catch (Exception ex) {
this.logger.error("MRP_UpdateQtaImpProx", ex);

View File

@@ -174,12 +174,15 @@ public class AccountingRules extends QueryRules {
String codBiva = getCodBiva(connection, codAnag);
List<CtbMovi> movi = new ArrayList<>();
for (CtbMovi ctbMovi : ctbMovt.getCtbMovi()) {
if (UtilityString.isNullOrEmpty(ctbMovi.getCodBiva())) {
ctbMovi.setCodBiva(codBiva);
if (!UtilityString.isNullOrEmpty(codBiva)) {
for (CtbMovi ctbMovi : ctbMovt.getCtbMovi()) {
if (UtilityString.isNullOrEmpty(ctbMovi.getCodBiva())) {
ctbMovi.setCodBiva(codBiva);
}
movi.add(ctbMovi);
}
movi.add(ctbMovi);
}
} else
movi = ctbMovt.getCtbMovi();
return movi;
}
@@ -609,8 +612,8 @@ public class AccountingRules extends QueryRules {
// impAvere = ctbScad.getImpAvere().divide(cambioScad).setScale(5, RoundingMode.HALF_UP);
// }
Boolean riperta = ctbScad.getRiaperta()==null?false:ctbScad.getRiaperta();
if ( tipoPartita == 0 || (riperta && tipoPartita == 1)){
Boolean riperta = ctbScad.getRiaperta() == null ? false : ctbScad.getRiaperta();
if (tipoPartita == 0 || (riperta && tipoPartita == 1)) {
if (ctbScad.getImpDare() == null)
impDare = ctbMovr.getImpDare();
else
@@ -764,6 +767,17 @@ public class AccountingRules extends QueryRules {
return campi;
}
public static void setImportoMov(CtbMovt ctbMovt) throws Exception {
if (UtilityBigDecimal.isNullOrZero(ctbMovt.getImporto())) {
ctbMovt.getCtbMovr()
.stream()
.filter(x -> x.getOperation() != OperationType.DELETE).forEach(x -> {
BigDecimal impDare = x.getImpDare() == null ? BigDecimal.ZERO : x.getImpDare();
ctbMovt.setImporto(ctbMovt.getImporto().add(impDare));
});
}
}
public static Boolean chkMovimentoBilanciato(CtbMovt ctbMovt) throws Exception {
BigDecimal totDare = BigDecimal.ZERO, totAvere = BigDecimal.ZERO;

View File

@@ -918,10 +918,10 @@ public class CommonRules extends QueryRules {
}
public static BigDecimal completeValUntULTC(Connection conn, String codMdep, String codMart, Date dataValidita, BigDecimal rapConv) throws Exception {
if (rapConv.compareTo(BigDecimal.ZERO) != 0) rapConv = BigDecimal.ONE;
if (rapConv.compareTo(BigDecimal.ZERO) == 0) rapConv = BigDecimal.ONE;
String sql = "SELECT Round(isNull(dbo.f_GetCostoUltArt_depo("
+ UtilityDB.valueDateToString(dataValidita, CommonConstants.DATE_FORMAT_YMD) + ","
+ UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codMart) + "), 0)/" + UtilityDB.valueToString(rapConv) + ", 5) as costo_ult";
+ UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codMart) + "), 0)*" + UtilityDB.valueToString(rapConv) + ", 5) as costo_ult";
BigDecimal valUnt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
return valUnt;
}

View File

@@ -27,6 +27,8 @@ public class ConfigActivityRules extends QueryRules {
public static boolean checkAttivita(Connection conn, StbActivity stbActivity) throws Exception {
boolean blocca = false;
if (stbActivity.getFlagTipologia().equalsIgnoreCase("P")) {
if (stbActivity.getOperation() == OperationType.INSERT)
return false;
String sql =
Query.format("SELECT parent_activity_id FROM stb_activity WHERE activity_id = %s", stbActivity.getActivityId());
String parentActivityId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
@@ -52,15 +54,7 @@ public class ConfigActivityRules extends QueryRules {
return false;
String sql =
Query.format(
"SELECT CAST(COUNT(*) AS BIT)\n" +
"FROM stb_activity_check\n" +
"WHERE stb_activity_check.cod_jcom = %s\n" +
" AND %s BETWEEN stb_activity_check.data_iniz AND stb_activity_check.data_fine",
stbActivity.getCodJcom(), dataCheck);
blocca = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
blocca = checkAttivita(conn, stbActivity.getCodJcom(), dataCheck);
}
}
if (blocca)
@@ -69,6 +63,19 @@ public class ConfigActivityRules extends QueryRules {
return false;
}
public static boolean checkAttivita(Connection conn, String codJcom, Date dataCheck) throws Exception {
String sql =
Query.format(
"SELECT CAST(COUNT(*) AS BIT)\n" +
"FROM stb_activity_check\n" +
"WHERE stb_activity_check.cod_jcom = %s\n" +
" AND %s BETWEEN stb_activity_check.data_iniz AND stb_activity_check.data_fine",
codJcom, dataCheck);
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
}
public static List<JtbRLavt> completeJtbRlavtActivity(Connection connection, StbActivity entity) throws Exception {
String sql =
"SELECT jrl_flav_users.cod_jflav" +

View File

@@ -668,7 +668,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
**************************/
if (calcColli && codMart != null) {
if (!changeQta) changeQta = checkQtaChange(testata, row);
calcPesoColli(row, qta, datiTrasp, prendiNeiTotali);
calcPesoColli(row, qta, row.getNumCnf(), datiTrasp, prendiNeiTotali);
}
//Assegna costo
if (row instanceof DtbDocr && (((DtbDocr) row).getCostoUnt() == null || ((DtbDocr) row).getCostoUnt().compareTo(BigDecimal.ZERO) == 0)) {
@@ -985,7 +985,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
return totImposta;
}
private static void calcPesoColli(DtbDocOrdR row, BigDecimal qta, DatiTrasportoDTO datiTrasp, boolean prendiNeiTotali) {
private static void calcPesoColli(DtbDocOrdR row, BigDecimal qta, BigDecimal numCnf, DatiTrasportoDTO datiTrasp, boolean prendiNeiTotali) {
BigDecimal taraKgArt = BigDecimal.ZERO;
if (!row.getMtbAart().getQtaCnf().equals(BigDecimal.ZERO) && !UtilityBigDecimal.isNullOrZero(row.getMtbAart().getTaraKg())) {
taraKgArt = row.getMtbAart().getTaraKg().divide(row.getMtbAart().getQtaCnf(), 5, RoundingMode.HALF_UP);
@@ -1007,9 +1007,9 @@ public class DocOrdCalTotaliRules extends QueryRules {
datiTrasp.setPesoLordoKg(UtilityBigDecimal.isNull(datiTrasp.getPesoLordoKg(), BigDecimal.ZERO).add(pesoLordoRow));
/*CALCOLO NUMERO COLLI*/
BigDecimal qtaCnf = row.getQtaCnf();
BigDecimal colliRiga, sfusoRiga, qtaCnfInt;
if (prendiNeiTotali) {
BigDecimal qtaCnf = row.getQtaCnf().multiply(rapConv);
datiTrasp.setPesoNettoKg(UtilityBigDecimal.isNull(datiTrasp.getPesoNettoKg(), BigDecimal.ZERO).add(pesoNettoKg));
if (qtaCnf.compareTo(BigDecimal.ZERO) == 0) {
colliRiga = BigDecimal.ZERO;
@@ -1017,11 +1017,18 @@ public class DocOrdCalTotaliRules extends QueryRules {
} else {
qtaCnfInt = qtaCnf.setScale(0, RoundingMode.DOWN);
if (qtaCnf.subtract(qtaCnfInt).compareTo(BigDecimal.ZERO) > 0) {
colliRiga = IntegerUtility.round(qta.divide(qtaCnf, RoundingMode.HALF_UP), 0);
if (UtilityBigDecimal.isNullOrZero(numCnf))
colliRiga = qta.divide(qtaCnf, RoundingMode.HALF_UP);
else
colliRiga = numCnf;
colliRiga = IntegerUtility.round(colliRiga, 0);
colliRiga = colliRiga.setScale(0, RoundingMode.DOWN);
sfusoRiga = BigDecimal.ZERO;
} else {
colliRiga = qta.divide(qtaCnf, RoundingMode.HALF_UP);
if (UtilityBigDecimal.isNullOrZero(numCnf))
colliRiga = qta.divide(qtaCnf, RoundingMode.HALF_UP);
else
colliRiga = numCnf;
colliRiga = colliRiga.setScale(0, RoundingMode.DOWN);
sfusoRiga = new BigDecimal(qtaCnfInt.doubleValue() % qtaCnf.doubleValue());
sfusoRiga = IntegerUtility.round(sfusoRiga, 0);

Some files were not shown because too many files have changed in this diff Show More