Compare commits
168 Commits
feature-re
...
68a45a9eea
| Author | SHA1 | Date | |
|---|---|---|---|
| 68a45a9eea | |||
| 8fe752e595 | |||
| 71ffc5b4cf | |||
| cc189f4761 | |||
| bd3bf9a8dc | |||
| 7fd4b6236c | |||
| 5075e17078 | |||
| 656f2018a2 | |||
| 2b4cea4ada | |||
| 72ebb39b22 | |||
| 8e01509e99 | |||
| 18da8c2763 | |||
| a770e150a4 | |||
| 72059e4623 | |||
| db5ee20a39 | |||
| 7b40578ea4 | |||
| 9685bff5ef | |||
| bfa48cbbb1 | |||
| 4f2b251d20 | |||
| a1f1ffba95 | |||
| 1ab59fa9a6 | |||
| 800407ebd7 | |||
| 3dad6790fc | |||
| d073a8fd17 | |||
| a9068c45cd | |||
| ca78b09ad8 | |||
| 3e17a7239a | |||
| d78597cba4 | |||
| 91f28a8c82 | |||
| 03a7877899 | |||
| 46e8a19c53 | |||
| 81a42fc1d9 | |||
| fdbcc0c539 | |||
| 7d51ddb868 | |||
| 9f25bd2bf6 | |||
| a9ce0d82b6 | |||
| 83d2f329ce | |||
| 7e06512598 | |||
| b5776e82c9 | |||
| 05dd42b0bf | |||
| 636774ed86 | |||
| 6649af6e92 | |||
| acfff8e8d6 | |||
| 44c1bd7cee | |||
| c712e729cc | |||
| b684129f39 | |||
| 1b339289c1 | |||
| b246991600 | |||
| dc578d1f17 | |||
| 6c6f6d4d7e | |||
| 50dcb999f1 | |||
| c656cc95de | |||
| 0b0b5bbf33 | |||
| c2310327d2 | |||
| 9962471f71 | |||
| 8ad86f71d3 | |||
| 3a42baab00 | |||
| a1bfd0150c | |||
| 2e420fc540 | |||
| f591246ae3 | |||
| d4c02cf504 | |||
| e15878a9eb | |||
| 39f43b3361 | |||
| 18a6756860 | |||
| 3640b08041 | |||
| 928d47f772 | |||
| 28478cb11d | |||
| 0c48df7895 | |||
| 327f5af3dd | |||
| 62234f2edf | |||
| 2fcba55965 | |||
| d29768776a | |||
| 3dcf6d3ee0 | |||
| 7c2aa55eb8 | |||
| e92d64a05e | |||
| 0fa021be3e | |||
| 086bd574d5 | |||
| b46f26790d | |||
| c364d57e86 | |||
| 6d89e4d09b | |||
| 3391051bb8 | |||
| acba051357 | |||
| 785ae254ee | |||
| 21a189ea66 | |||
| 3a4a11d9e8 | |||
| 6d5d021884 | |||
| 185d403d7a | |||
| 349d983b7f | |||
| 85ed6b54f9 | |||
| 9b6b0c87aa | |||
| fd68a9b73a | |||
| 433ab4b0ec | |||
| df9fbc7f65 | |||
| a8253614b4 | |||
| 9977cae821 | |||
| 344010ed90 | |||
| 1c51fb717a | |||
| 81827a8368 | |||
| 21222a25e9 | |||
| 838f32e04c | |||
| d24a033e01 | |||
| bdaf4a5ac6 | |||
| 5e76d8db2a | |||
| bae92e626b | |||
| 0d471db37d | |||
| c4c6875e16 | |||
| 3515e5c976 | |||
| 84a6f4c4f1 | |||
| ee9ec1a8a7 | |||
| 1884a9184e | |||
| caa62588b6 | |||
| 8bb9803f5b | |||
| ea27c26597 | |||
| 80aaa94036 | |||
| a82c0de415 | |||
| 762ae4827f | |||
| 68b12b0cba | |||
| f61577ee64 | |||
| 87e4d8704c | |||
| a5f22e68d2 | |||
| cf261ab427 | |||
| 5bd3b02ff0 | |||
| 10f62b669c | |||
| 565aec0739 | |||
| 7112cf15da | |||
| 03a061ae1f | |||
| 1e21e37e3c | |||
| 9da3fe3daa | |||
| b127ca2222 | |||
| be688efd2c | |||
| 94b1318a56 | |||
| 2e9e120cdb | |||
| 1000b1abbe | |||
| 0f2246f033 | |||
| 9dfee9d605 | |||
| 3ecd9e365e | |||
| 78a13ae89b | |||
| 6f8ddf6aa5 | |||
| 03f9de19b3 | |||
| a74e9aeb92 | |||
| 709422856b | |||
| 034a3cb2b5 | |||
| a9caf10897 | |||
| 659908ecf7 | |||
| 7ebecd94cd | |||
| 5bcb9000a9 | |||
| fe622dd742 | |||
| ab5d7e74a2 | |||
| 68e6dd246f | |||
| 8fe2b50d5c | |||
| ebc8401989 | |||
| 67765fc7d2 | |||
| a303459b7d | |||
| 2b68967ce0 | |||
| 164516166f | |||
| 069ee22499 | |||
| ebf3a750a2 | |||
| 38a5b2510a | |||
| fe2d868ca6 | |||
| aca7cc07e6 | |||
| a1618ad2ad | |||
| 84560a94ea | |||
| 8b9454a684 | |||
| 0c6f7f769b | |||
| 62458a0640 | |||
| 5106ff9f12 | |||
| 62857a9bb0 | |||
| 5052f6dc2d |
1701
.idea/inspectionProfiles/LocalDate_passato_a_SimpleDate.xml
generated
Normal file
1701
.idea/inspectionProfiles/LocalDate_passato_a_SimpleDate.xml
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
.idea/structuralSearch.xml
generated
Normal file
10
.idea/structuralSearch.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="StructuralSearch">
|
||||
<searchConfiguration name="LocalDate passato a SimpleDateFormat" text="$formatter$.format($date$)" recursive="true" caseInsensitive="true" type="JAVA" pattern_context="default">
|
||||
<constraint name="__context__" within="" contains="" />
|
||||
<constraint name="formatter" nameOfExprType="java\.text\.SimpleDateFormat" within="" contains="" />
|
||||
<constraint name="date" nameOfExprType="java\.time\.LocalDate" within="" contains="" />
|
||||
</searchConfiguration>
|
||||
</component>
|
||||
</project>
|
||||
@@ -3,7 +3,7 @@ package it.integry.ems._context;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.common.var.EmsDBConst;
|
||||
import it.integry.ems.expansion.RunnableArgsThrowable;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||
@@ -83,9 +83,9 @@ public class EmsCoreDBLoader {
|
||||
private void discoverAllConnections(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
|
||||
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
||||
for (AvailableConnectionsModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
||||
for (AvailableConnectionModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
||||
|
||||
AtomicReference<AvailableConnectionsModel> modelAtomicReference = new AtomicReference<>(model);
|
||||
AtomicReference<AvailableConnectionModel> modelAtomicReference = new AtomicReference<>(model);
|
||||
|
||||
futureTasks.add(() -> {
|
||||
try {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package it.integry.ems.datasource;
|
||||
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
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.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
import java.sql.SQLException;
|
||||
@@ -13,17 +14,26 @@ import java.util.HashMap;
|
||||
|
||||
public class DataSource extends BasicDataSource {
|
||||
|
||||
private AvailableConnectionsModel connectionModel;
|
||||
private final int POOL_SIZE;
|
||||
|
||||
private AvailableConnectionModel connectionModel;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(AvailableConnectionModel)} per ottenere una connessione.
|
||||
*/
|
||||
@Deprecated
|
||||
public DataSource() {
|
||||
super();
|
||||
POOL_SIZE = 5;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DataSource(int poolSize) {
|
||||
super();
|
||||
POOL_SIZE = poolSize;
|
||||
}
|
||||
|
||||
public EmsRestConstants.DB_TYPE getTypeDB() {
|
||||
@@ -62,12 +72,20 @@ public class DataSource extends BasicDataSource {
|
||||
}
|
||||
|
||||
public synchronized void initialize(String profileDB) throws Exception {
|
||||
AvailableConnectionsModel connectionsModel = SettingsModel.getInstance().findConnectionModel(profileDB);
|
||||
|
||||
initialize(connectionsModel);
|
||||
initialize(profileDB, null);
|
||||
}
|
||||
|
||||
public synchronized void initialize(AvailableConnectionsModel connectionModel) throws Exception {
|
||||
public synchronized void initialize(String profileDB, String customAppName) throws Exception {
|
||||
AvailableConnectionModel connectionsModel = SettingsModel.getInstance().findConnectionModel(profileDB);
|
||||
|
||||
initialize(connectionsModel, customAppName);
|
||||
}
|
||||
|
||||
public synchronized void initialize(AvailableConnectionModel connectionModel) throws Exception {
|
||||
initialize(connectionModel, null);
|
||||
}
|
||||
|
||||
public synchronized void initialize(AvailableConnectionModel connectionModel, String customAppName) throws Exception {
|
||||
if (connectionModel == null) {
|
||||
throw new Exception("Configurazione DB non trovata");
|
||||
}
|
||||
@@ -76,7 +94,7 @@ public class DataSource extends BasicDataSource {
|
||||
|
||||
this.setDriverClassName(connectionModel.getDriverClassName());
|
||||
|
||||
this.setUrl(connectionModel.getDbConnectionString("EMS Connection"));
|
||||
this.setUrl(connectionModel.getDbConnectionString(UtilityString.isNull(customAppName, "EMS Connection")));
|
||||
this.setUsername(connectionModel.getUsername());
|
||||
this.setPassword(connectionModel.getPasswordDecrypted());
|
||||
this.setDefaultCatalog(connectionModel.getDbName());
|
||||
@@ -87,9 +105,9 @@ public class DataSource extends BasicDataSource {
|
||||
// ===== OTTIMIZZAZIONI CRITICHE =====
|
||||
|
||||
// Pool sizing ottimizzato per READ_UNCOMMITTED (meno locking = più connessioni possibili)
|
||||
this.setInitialSize(5); // Inizia con più connessioni
|
||||
this.setInitialSize(POOL_SIZE); // Inizia con più connessioni
|
||||
this.setMaxTotal(-1); // Aumentato il massimo
|
||||
this.setMinIdle(5); // Non scendere sotto 5
|
||||
this.setMinIdle(POOL_SIZE); // Non scendere sotto 5
|
||||
this.setMaxIdle(-1); // Mantieni più connessioni idle
|
||||
|
||||
// Timeout ottimizzati per performance massime
|
||||
@@ -97,8 +115,8 @@ public class DataSource extends BasicDataSource {
|
||||
|
||||
// Validazione veloce ed efficiente
|
||||
this.setValidationQuery("SELECT 1");
|
||||
// this.setValidationQueryTimeout(60); // Ridotto a 1 secondo
|
||||
// this.setTestWhileIdle(true); // Testa connessioni idle
|
||||
this.setValidationQueryTimeout(30); // Ridotto a 1 secondo
|
||||
this.setTestWhileIdle(true); // Testa connessioni idle
|
||||
|
||||
// Eviction ottimizzata per READ_UNCOMMITTED
|
||||
// this.setTimeBetweenEvictionRunsMillis(1 * 1000); // Ogni 30 secondi
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
package it.integry.ems.dbms_change_tracker.component;
|
||||
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.dbms_change_tracker.model.ChangeTrackingConfigDTO;
|
||||
import it.integry.ems.dbms_change_tracker.model.DetectedChangeDataDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DbmsChangeTracker {
|
||||
|
||||
private DataSource dataSource;
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
|
||||
private final int CHANGE_RETENTION_HOURS = 1;
|
||||
private final boolean AUTO_CLEANUP = true;
|
||||
|
||||
private Connection integryConnection;
|
||||
private boolean trackerEnabled = false;
|
||||
private long currentVersion;
|
||||
|
||||
|
||||
private Listener eventListener;
|
||||
|
||||
public DbmsChangeTracker(String profileDb) throws Exception {
|
||||
createDataSource(profileDb);
|
||||
createConnection();
|
||||
}
|
||||
|
||||
private void createDataSource(String profileDb) throws Exception {
|
||||
DataSource ds = new DataSource(1);
|
||||
ds.initialize(profileDb, "Integry Changes Tracker");
|
||||
this.dataSource = ds;
|
||||
}
|
||||
|
||||
private void createConnection() throws SQLException {
|
||||
integryConnection = dataSource.getConnection();
|
||||
if (!(integryConnection.isWrapperFor(SQLServerConnection.class))) {
|
||||
integryConnection.close();
|
||||
|
||||
throw new SQLException("Connection is not a SQL Server connection");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkConnection() {
|
||||
try {
|
||||
UtilityDB.executeSimpleQuery(integryConnection, "SELECT 1");
|
||||
if (integryConnection.isClosed())
|
||||
createConnection();
|
||||
} catch (SQLException e) {
|
||||
try {
|
||||
integryConnection.close();
|
||||
createConnection();
|
||||
} catch (SQLException ex) {
|
||||
logger.error("Unable to reestablish DB connection for Change Tracker", ex);
|
||||
throw new RuntimeException("Unable to reestablish DB connection for Change Tracker");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableTrackerInDbms() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
final ChangeTrackingConfigDTO currentConfig = retrieveTrackerCurrentConfig();
|
||||
if (currentConfig != null) {
|
||||
logInfo("Changes Tracker is already enabled (with " + currentConfig.getRetentionPeriod() + " " + currentConfig.getRetentionPeriodUnit().toLowerCase() + " retention and auto cleanup " + (currentConfig.isAutoCleanupOn() ? "ON" : "OFF") + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
String enableSql = "ALTER DATABASE [" + integryConnection.getDbName() + "] \n" +
|
||||
"SET CHANGE_TRACKING = ON (" +
|
||||
"CHANGE_RETENTION = " + CHANGE_RETENTION_HOURS + " HOURS, " +
|
||||
"AUTO_CLEANUP = " + (AUTO_CLEANUP ? "ON" : "OFF") +
|
||||
");\n";
|
||||
|
||||
//COMMIT necessario perché ALTER DATABASE richiede che non ci siano altre transazioni attive
|
||||
UtilityDB.executeStatement(integryConnection, "COMMIT", enableSql);
|
||||
|
||||
logInfo("Changes Tracker is now enabled (with " + CHANGE_RETENTION_HOURS + " hours retention and auto cleanup " + (AUTO_CLEANUP ? "ON" : "OFF") + ")");
|
||||
}
|
||||
|
||||
|
||||
public void enableTrackerOnTable(String tableName) throws SQLException {
|
||||
if (isTableTrackingEnabled(tableName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
UtilityDB.executeStatement(integryConnection, "ALTER TABLE dbo." + tableName + "\n" +
|
||||
"ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON);", "COMMIT");
|
||||
}
|
||||
|
||||
|
||||
public void disableTrackerOnNotUsedTables(List<String> usedTables) throws SQLException {
|
||||
final List<String> trackedTables = retrieveTrackedTables();
|
||||
|
||||
trackedTables.removeAll(usedTables);
|
||||
|
||||
for (String tableName : trackedTables) {
|
||||
disableTrackerOnTable(tableName);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableTrackerOnTable(String tableName) throws SQLException {
|
||||
if (!isTableTrackingEnabled(tableName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
UtilityDB.executeStatement(integryConnection, "ALTER TABLE dbo." + tableName + "\n" +
|
||||
"DISABLE CHANGE_TRACKING;", "COMMIT");
|
||||
}
|
||||
|
||||
|
||||
public void startTracking() throws SQLException {
|
||||
currentVersion = retrieveCurrentVersion();
|
||||
trackerEnabled = true;
|
||||
}
|
||||
|
||||
public void checkForChanges() throws Exception {
|
||||
if (!trackerEnabled)
|
||||
return;
|
||||
|
||||
checkConnection();
|
||||
|
||||
final List<String> trackedTables = retrieveTrackedTables();
|
||||
|
||||
HashMap<Long, DetectedChangeDataDTO> changesByVersion = new HashMap<>();
|
||||
|
||||
for (String trackedTable : trackedTables) {
|
||||
long minValidVersion = getMinValidVersion(trackedTable);
|
||||
if (currentVersion < minValidVersion) {
|
||||
throw new SQLException("Change Tracking on table " + trackedTable + " has been reset. Current version: " + currentVersion + ", Min valid version: " + minValidVersion);
|
||||
}
|
||||
|
||||
|
||||
final List<DetectedChangeDataDTO> detectedChanges = retrieveChangeList(trackedTable);
|
||||
|
||||
detectedChanges.forEach(detectedChangeDataDTO -> {
|
||||
changesByVersion.put(detectedChangeDataDTO.getSysChangeVersion(), detectedChangeDataDTO);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
logTrace("Detected " + changesByVersion.size() + " changes since version " + currentVersion);
|
||||
|
||||
dispatchChanges(changesByVersion);
|
||||
}
|
||||
|
||||
private void dispatchChanges(HashMap<Long, DetectedChangeDataDTO> changesByVersion) throws Exception {
|
||||
final List<Long> sortedChanges = changesByVersion.keySet().stream()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
for (Long changeId : sortedChanges) {
|
||||
final DetectedChangeDataDTO detectedChange = changesByVersion.get(changeId);
|
||||
|
||||
switch (detectedChange.getSysChangeOperation()) {
|
||||
case INSERT:
|
||||
if (eventListener != null)
|
||||
eventListener.onInsertDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
|
||||
case UPDATE:
|
||||
if (eventListener != null)
|
||||
eventListener.onUpdateDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
if (eventListener != null)
|
||||
eventListener.onDeleteDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||
break;
|
||||
}
|
||||
|
||||
currentVersion = changeId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<DetectedChangeDataDTO> retrieveChangeList(String tableName) throws SQLException {
|
||||
String sql = "SELECT *\n" +
|
||||
"FROM CHANGETABLE(CHANGES dbo." + tableName + ", " + currentVersion + ") AS c";
|
||||
final List<HashMap<String, Object>> result = UtilityDB.executeSimpleQuery(integryConnection, sql);
|
||||
|
||||
return result.stream()
|
||||
.map(x -> {
|
||||
DetectedChangeDataDTO detectedChangeDataDTO = new DetectedChangeDataDTO()
|
||||
.setTableName(tableName);
|
||||
|
||||
Long sysChangeVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_VERSION");
|
||||
detectedChangeDataDTO.setSysChangeVersion(sysChangeVersion);
|
||||
|
||||
|
||||
Long sysChangeCreationVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_CREATION_VERSION");
|
||||
detectedChangeDataDTO.setSysChangeCreationVersion(sysChangeCreationVersion);
|
||||
|
||||
detectedChangeDataDTO.setSysChangeOperation(DetectedChangeDataDTO.Operation.from(UtilityHashMap.<String>getValueIfExists(x, "SYS_CHANGE_OPERATION")));
|
||||
|
||||
List<String> keysToRemove = new ArrayList<>();
|
||||
for (String colName : x.keySet()) {
|
||||
if (colName.startsWith("SYS_"))
|
||||
keysToRemove.add(colName);
|
||||
}
|
||||
|
||||
for (String colName : keysToRemove) {
|
||||
x.remove(colName);
|
||||
}
|
||||
|
||||
detectedChangeDataDTO.setPrimaryKey(x);
|
||||
|
||||
return detectedChangeDataDTO;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private long retrieveCurrentVersion() throws SQLException {
|
||||
String sql = "SELECT CHANGE_TRACKING_CURRENT_VERSION() AS current_version";
|
||||
|
||||
long currentVersion = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||
return currentVersion;
|
||||
}
|
||||
|
||||
private long getMinValidVersion(String table) throws SQLException {
|
||||
String sql = "SELECT CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID(" + UtilityDB.valueToString(table) + "))";
|
||||
|
||||
long minValidVersion = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||
return minValidVersion;
|
||||
}
|
||||
|
||||
private List<String> retrieveTrackedTables() throws SQLException {
|
||||
String sql = "SELECT OBJECT_NAME(object_id) AS table_name\n" +
|
||||
" FROM sys.change_tracking_tables";
|
||||
|
||||
List<String> trackedTables = UtilityDB.executeSimpleQueryOnlyFirstColumn(integryConnection, sql);
|
||||
return trackedTables;
|
||||
}
|
||||
|
||||
private boolean isTableTrackingEnabled(String tableName) throws SQLException {
|
||||
String sql = "SELECT CAST(COUNT(is_track_columns_updated_on) AS BIT) AS enabled\n" +
|
||||
" FROM sys.change_tracking_tables \n" +
|
||||
" WHERE object_id = OBJECT_ID('dbo." + tableName + "')";
|
||||
|
||||
boolean enabled = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private ChangeTrackingConfigDTO retrieveTrackerCurrentConfig() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
String checkSql = "SELECT DB_NAME(database_id) as database_name,\n" +
|
||||
"CAST(is_auto_cleanup_on AS BIT) AS is_auto_cleanup_on,\n" +
|
||||
"retention_period,\n" +
|
||||
"retention_period_units_desc,\n" +
|
||||
"max_cleanup_version\n" +
|
||||
"FROM sys.change_tracking_databases \n" +
|
||||
"WHERE DB_NAME(database_id)=DB_NAME()";
|
||||
|
||||
final ChangeTrackingConfigDTO currentConfig = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(integryConnection, checkSql, ChangeTrackingConfigDTO.class);
|
||||
|
||||
return currentConfig;
|
||||
}
|
||||
|
||||
|
||||
private void logInfo(String message) {
|
||||
logger.info("[" + integryConnection.getProfileName() + "] " + message);
|
||||
}
|
||||
|
||||
private void logTrace(String message) {
|
||||
logger.trace("[" + integryConnection.getProfileName() + "] " + message);
|
||||
}
|
||||
|
||||
|
||||
public DbmsChangeTracker setEventListener(Listener eventListener) {
|
||||
this.eventListener = eventListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||
|
||||
void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||
|
||||
void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package it.integry.ems.dbms_change_tracker.component;
|
||||
|
||||
import it.integry.annotations.PostContextAutowired;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.dbms_change_tracker.model.events.TableRecordDeletedEvent;
|
||||
import it.integry.ems.dbms_change_tracker.model.events.TableRecordInsertedEvent;
|
||||
import it.integry.ems.dbms_change_tracker.model.events.TableRecordUpdatedEvent;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class DbmsChangeTrackerComponent {
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private final HashMap<IntegryCustomerDB, DbmsChangeTracker> activeChangeTrackers = new HashMap<>();
|
||||
|
||||
private final ArrayList<String> trackedTables = new ArrayList<String>() {{
|
||||
add(MtbAart.ENTITY);
|
||||
add(MtbAartBarCode.ENTITY);
|
||||
add(MtbUntMis.ENTITY);
|
||||
add(StbEditLimit.ENTITY);
|
||||
add(StbGestSetup.ENTITY);
|
||||
add(StbGestSetupDepo.ENTITY);
|
||||
add(WtbGestSetupUser.ENTITY);
|
||||
}};
|
||||
|
||||
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@PostContextAutowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
public DbmsChangeTrackerComponent(ApplicationEventPublisher applicationEventPublisher) {
|
||||
this.applicationEventPublisher = applicationEventPublisher;
|
||||
}
|
||||
|
||||
|
||||
@PostContextConstruct(priority = 10)
|
||||
public void init() throws Exception {
|
||||
for (Connection conn : multiDBTransactionManager.getActiveConnections()) {
|
||||
IntegryCustomerDB customerDB = IntegryCustomerDB.parse(conn.getDbName());
|
||||
activeChangeTrackers.put(customerDB, new DbmsChangeTracker(conn.getProfileName()));
|
||||
}
|
||||
|
||||
enableAllChangeTracking();
|
||||
}
|
||||
|
||||
|
||||
private void enableAllChangeTracking() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
for (Map.Entry<IntegryCustomerDB, DbmsChangeTracker> entrySet : activeChangeTrackers.entrySet()) {
|
||||
IntegryCustomerDB customerDB = entrySet.getKey();
|
||||
DbmsChangeTracker dbmsChangeTracker = entrySet.getValue();
|
||||
|
||||
dbmsChangeTracker.enableTrackerInDbms();
|
||||
|
||||
for (String tableName : trackedTables) {
|
||||
dbmsChangeTracker.enableTrackerOnTable(tableName);
|
||||
}
|
||||
|
||||
dbmsChangeTracker.disableTrackerOnNotUsedTables(trackedTables);
|
||||
|
||||
dbmsChangeTracker.setEventListener(new DbmsChangeTracker.Listener() {
|
||||
@Override
|
||||
public void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemInserted(customerDB, tableName, primaryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemUpdated(customerDB, tableName, primaryKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||
onItemDeleted(customerDB, tableName, primaryKey);
|
||||
}
|
||||
});
|
||||
|
||||
dbmsChangeTracker.startTracking();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS)
|
||||
private void checkAllChanges() throws Exception {
|
||||
for (DbmsChangeTracker dbmsChangeTracker : activeChangeTrackers.values()) {
|
||||
dbmsChangeTracker.checkForChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onItemInserted(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||
logger.trace("Item inserted in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||
applicationEventPublisher.publishEvent(new TableRecordInsertedEvent(this, customerDB, tableName, primaryKey));
|
||||
}
|
||||
|
||||
private void onItemUpdated(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||
logger.trace("Item updated in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||
applicationEventPublisher.publishEvent(new TableRecordUpdatedEvent(this, customerDB, tableName, primaryKey));
|
||||
}
|
||||
|
||||
private void onItemDeleted(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||
logger.trace("Item deleted in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||
applicationEventPublisher.publishEvent(new TableRecordDeletedEvent(this, customerDB, tableName, primaryKey));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package it.integry.ems.dbms_change_tracker.model;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
public class ChangeTrackingConfigDTO {
|
||||
|
||||
@SqlField("database_name")
|
||||
private String databaseName;
|
||||
|
||||
@SqlField("is_auto_cleanup_on")
|
||||
private boolean autoCleanupOn;
|
||||
|
||||
@SqlField("retention_period")
|
||||
private int retentionPeriod;
|
||||
|
||||
@SqlField("retention_period_units_desc")
|
||||
private String retentionPeriodUnit;
|
||||
|
||||
// @SqlField("max_cleanup_version")
|
||||
private Object maxCleanupVersion;
|
||||
|
||||
|
||||
public String getDatabaseName() {
|
||||
return databaseName;
|
||||
}
|
||||
|
||||
public ChangeTrackingConfigDTO setDatabaseName(String databaseName) {
|
||||
this.databaseName = databaseName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAutoCleanupOn() {
|
||||
return autoCleanupOn;
|
||||
}
|
||||
|
||||
public ChangeTrackingConfigDTO setAutoCleanupOn(boolean autoCleanupOn) {
|
||||
this.autoCleanupOn = autoCleanupOn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getRetentionPeriod() {
|
||||
return retentionPeriod;
|
||||
}
|
||||
|
||||
public ChangeTrackingConfigDTO setRetentionPeriod(int retentionPeriod) {
|
||||
this.retentionPeriod = retentionPeriod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRetentionPeriodUnit() {
|
||||
return retentionPeriodUnit;
|
||||
}
|
||||
|
||||
public ChangeTrackingConfigDTO setRetentionPeriodUnit(String retentionPeriodUnit) {
|
||||
this.retentionPeriodUnit = retentionPeriodUnit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object getMaxCleanupVersion() {
|
||||
return maxCleanupVersion;
|
||||
}
|
||||
|
||||
public ChangeTrackingConfigDTO setMaxCleanupVersion(Object maxCleanupVersion) {
|
||||
this.maxCleanupVersion = maxCleanupVersion;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package it.integry.ems.dbms_change_tracker.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DetectedChangeDataDTO {
|
||||
|
||||
private long sysChangeVersion;
|
||||
private Long sysChangeCreationVersion;
|
||||
private Operation sysChangeOperation;
|
||||
|
||||
private String tableName;
|
||||
private HashMap<String, Object> primaryKey;
|
||||
|
||||
|
||||
public long getSysChangeVersion() {
|
||||
return sysChangeVersion;
|
||||
}
|
||||
|
||||
public DetectedChangeDataDTO setSysChangeVersion(long sysChangeVersion) {
|
||||
this.sysChangeVersion = sysChangeVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getSysChangeCreationVersion() {
|
||||
return sysChangeCreationVersion;
|
||||
}
|
||||
|
||||
public DetectedChangeDataDTO setSysChangeCreationVersion(Long sysChangeCreationVersion) {
|
||||
this.sysChangeCreationVersion = sysChangeCreationVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Operation getSysChangeOperation() {
|
||||
return sysChangeOperation;
|
||||
}
|
||||
|
||||
public DetectedChangeDataDTO setSysChangeOperation(Operation sysChangeOperation) {
|
||||
this.sysChangeOperation = sysChangeOperation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public DetectedChangeDataDTO setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getPrimaryKey() {
|
||||
return primaryKey;
|
||||
}
|
||||
|
||||
public DetectedChangeDataDTO setPrimaryKey(HashMap<String, Object> primaryKey) {
|
||||
this.primaryKey = primaryKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public enum Operation implements IBaseEnum<Operation> {
|
||||
INSERT('I'),
|
||||
UPDATE('U'),
|
||||
DELETE('D');
|
||||
|
||||
private final char value;
|
||||
|
||||
Operation(char value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static Operation from(Object value) {
|
||||
if (value instanceof String && ((String) value).length() == 1) {
|
||||
value = ((String) value).charAt(0);
|
||||
}
|
||||
|
||||
char castValue = (char) value;
|
||||
for (Operation b : Operation.values()) {
|
||||
if (b.value == castValue)
|
||||
return b;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public char getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation fromInternal(Object val) {
|
||||
return from(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.dbms_change_tracker.model.events;
|
||||
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.event.BaseCustomerDBEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TableRecordDeletedEvent extends BaseCustomerDBEvent {
|
||||
|
||||
private final String tableName;
|
||||
private final HashMap<String, Object> primaryKey;
|
||||
|
||||
public TableRecordDeletedEvent(Object source, IntegryCustomerDB integryCustomerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||
super(source, integryCustomerDB);
|
||||
|
||||
this.tableName = tableName;
|
||||
this.primaryKey = primaryKey;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getPrimaryKey() {
|
||||
return primaryKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.dbms_change_tracker.model.events;
|
||||
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.event.BaseCustomerDBEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TableRecordInsertedEvent extends BaseCustomerDBEvent {
|
||||
|
||||
private final String tableName;
|
||||
private final HashMap<String, Object> primaryKey;
|
||||
|
||||
public TableRecordInsertedEvent(Object source, IntegryCustomerDB integryCustomerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||
super(source, integryCustomerDB);
|
||||
|
||||
this.tableName = tableName;
|
||||
this.primaryKey = primaryKey;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getPrimaryKey() {
|
||||
return primaryKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.dbms_change_tracker.model.events;
|
||||
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.event.BaseCustomerDBEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TableRecordUpdatedEvent extends BaseCustomerDBEvent {
|
||||
|
||||
private final String tableName;
|
||||
private final HashMap<String, Object> primaryKey;
|
||||
|
||||
public TableRecordUpdatedEvent(Object source, IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||
super(source, customerDB);
|
||||
|
||||
this.tableName = tableName;
|
||||
this.primaryKey = primaryKey;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getPrimaryKey() {
|
||||
return primaryKey;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class DevicesRequestInterceptor implements HandlerInterceptor {
|
||||
RequestDataDTO requestDataDTO = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
||||
|
||||
if (requestDataDTO.isValidProfileDB() && requestDataDTO.isValidDeviceId()) {
|
||||
deviceService.updateUsage(requestDataDTO.getApplication(), requestDataDTO.getDeviceId());
|
||||
deviceService.updateUsage(requestDataDTO.getDeviceId());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,7 +3,7 @@ package it.integry.ems.dynamic_cache;
|
||||
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
||||
import it.integry.ems.expansion.RunnableWithReturn;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -37,8 +37,7 @@ public class DynamicCacheService {
|
||||
DATI_AZIENDA_KEY,
|
||||
ENTITY_LOGGER_SETUP,
|
||||
GRIGLIA_ACQUISTO_KEY,
|
||||
ENTITY_SYNC_KEY,
|
||||
STB_GEST_SETUP_KEY
|
||||
ENTITY_SYNC_KEY
|
||||
}
|
||||
|
||||
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
||||
@@ -51,11 +50,11 @@ public class DynamicCacheService {
|
||||
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
||||
RunnableWithReturn<Object> internalRefreshAction = () -> {
|
||||
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||
.stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.filter(AvailableConnectionModel::getInternalDb)
|
||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||
|
||||
final HashMap<String, T> cachedDataByDB = new HashMap<>();
|
||||
|
||||
@@ -83,11 +82,11 @@ public class DynamicCacheService {
|
||||
|
||||
RunnableWithReturn<Object> refreshAction = () -> {
|
||||
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||
.stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.filter(AvailableConnectionModel::getInternalDb)
|
||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||
|
||||
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = new HashMap<>();
|
||||
|
||||
@@ -138,11 +137,11 @@ public class DynamicCacheService {
|
||||
|
||||
RunnableWithReturn<Object> refreshAction = () -> {
|
||||
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||
.stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.filter(AvailableConnectionModel::getInternalDb)
|
||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||
|
||||
final HashMap<String, List<?>> cacheQueryByDB = new HashMap<>();
|
||||
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
package it.integry.ems.dynamic_cache;
|
||||
|
||||
import it.integry.annotations.PostContextAutowired;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.dbms_change_tracker.component.DbmsChangeTrackerComponent;
|
||||
import it.integry.ems.dbms_change_tracker.model.events.TableRecordDeletedEvent;
|
||||
import it.integry.ems.dbms_change_tracker.model.events.TableRecordInsertedEvent;
|
||||
import it.integry.ems.dbms_change_tracker.model.events.TableRecordUpdatedEvent;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
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.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityQuery;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Component
|
||||
public class EntityCacheComponent implements ApplicationListener {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private final DbmsChangeTrackerComponent dbmsChangeTrackerComponent;
|
||||
private final EntityPropertyHolder entityPropertyHolder;
|
||||
|
||||
private final HashMap<IntegryCustomerDB, ConcurrentHashMap<String, ConcurrentHashMap<HashMap<String, Object>, EntityBase>>> entityCache = new HashMap<>();
|
||||
|
||||
private final HashMap<String, Class<? extends EntityBase>> enabledEntities = new HashMap<String, Class<? extends EntityBase>>() {{
|
||||
put(MtbAart.ENTITY, MtbAart.class);
|
||||
put(MtbAartBarCode.ENTITY, MtbAartBarCode.class);
|
||||
put(MtbUntMis.ENTITY, MtbUntMis.class);
|
||||
put(StbEditLimit.ENTITY, StbEditLimit.class);
|
||||
put(StbGestSetup.ENTITY, StbGestSetup.class);
|
||||
put(StbGestSetupDepo.ENTITY, StbGestSetupDepo.class);
|
||||
put(WtbGestSetupUser.ENTITY, WtbGestSetupUser.class);
|
||||
}};
|
||||
|
||||
public EntityCacheComponent(DbmsChangeTrackerComponent dbmsChangeTrackerComponent, EntityPropertyHolder entityPropertyHolder) {
|
||||
this.dbmsChangeTrackerComponent = dbmsChangeTrackerComponent;
|
||||
this.entityPropertyHolder = entityPropertyHolder;
|
||||
}
|
||||
|
||||
@PostContextAutowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@PostContextConstruct
|
||||
private void init() throws Exception {
|
||||
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||
return;
|
||||
|
||||
for (Connection conn : multiDBTransactionManager.getActiveConnections()) {
|
||||
IntegryCustomerDB customerDB = IntegryCustomerDB.parse(conn.getDbName());
|
||||
|
||||
if (customerDB == null)
|
||||
throw new RuntimeException("Impossibile inizializzare IntegryCustomerDB per il database: " + conn.getDbName());
|
||||
|
||||
|
||||
for (Map.Entry<String, Class<? extends EntityBase>> enabledEntity : enabledEntities.entrySet()) {
|
||||
String tableName = enabledEntity.getKey();
|
||||
|
||||
refreshCacheForEntity(conn, customerDB, tableName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshCacheForEntity(IntegryCustomerDB customerDB, String tableName) throws Exception {
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(customerDB)) {
|
||||
Connection conn = mdb.getPrimaryConnection();
|
||||
refreshCacheForEntity(conn, customerDB, tableName);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshCacheForEntity(Connection connection, IntegryCustomerDB customerDB, String tableName) throws Exception {
|
||||
Class<? extends EntityBase> clazz = enabledEntities.get(tableName);
|
||||
// if (clazz == null)
|
||||
// throw new RuntimeException("Entity cache is not enabled for table " + tableName);
|
||||
|
||||
entityCache.putIfAbsent(customerDB, new ConcurrentHashMap<>());
|
||||
entityCache.get(customerDB).remove(tableName);
|
||||
|
||||
ConcurrentHashMap<HashMap<String, Object>, EntityBase> entities = retrieveEntityList(connection, tableName, clazz);
|
||||
entityCache.get(customerDB).put(tableName, entities);
|
||||
|
||||
logger.trace(String.format("[%s] Cached %d records for entity %s",
|
||||
customerDB.getValue(),
|
||||
entities.size(),
|
||||
clazz.getSimpleName()));
|
||||
}
|
||||
|
||||
public <T extends EntityBase> List<T> getCachedEntitiesList(IntegryCustomerDB customerDB, String tableName, Predicate<T> filterPredicate) {
|
||||
return getCachedEntitiesStream(customerDB, tableName, filterPredicate)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public <T extends EntityBase> Stream<T> getCachedEntitiesStream(IntegryCustomerDB customerDB, String tableName, Predicate<T> filterPredicate) {
|
||||
if (!isCacheEnabled(customerDB, tableName)) {
|
||||
try {
|
||||
refreshCacheForEntity(customerDB, tableName);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return entityCache.get(customerDB).get(tableName)
|
||||
.values()
|
||||
.parallelStream()
|
||||
.map(x -> (T) x)
|
||||
.filter(filterPredicate)
|
||||
.map(x -> (T) x.clone());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (event instanceof TableRecordInsertedEvent) {
|
||||
handleRecordInserted((TableRecordInsertedEvent) event);
|
||||
|
||||
} else if (event instanceof TableRecordUpdatedEvent) {
|
||||
handleRecordUpdated((TableRecordUpdatedEvent) event);
|
||||
|
||||
} else if (event instanceof TableRecordDeletedEvent) {
|
||||
handleRecordDeleted((TableRecordDeletedEvent) event);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handleRecordInserted(TableRecordInsertedEvent event) {
|
||||
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||
return;
|
||||
|
||||
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(event.getCustomerDB())) {
|
||||
EntityBase newItem = retrieveEntityItem(mdb.getPrimaryConnection(), event.getTableName(),
|
||||
enabledEntities.get(event.getTableName()),
|
||||
event.getPrimaryKey());
|
||||
|
||||
|
||||
entityCache.get(event.getCustomerDB())
|
||||
.get(event.getTableName())
|
||||
.put(entityPrimaryKey, newItem);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRecordUpdated(TableRecordUpdatedEvent event) {
|
||||
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||
return;
|
||||
|
||||
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(event.getCustomerDB())) {
|
||||
EntityBase newItem = retrieveEntityItem(mdb.getPrimaryConnection(), event.getTableName(),
|
||||
enabledEntities.get(event.getTableName()),
|
||||
event.getPrimaryKey());
|
||||
|
||||
entityCache.get(event.getCustomerDB())
|
||||
.get(event.getTableName())
|
||||
.put(entityPrimaryKey, newItem);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRecordDeleted(TableRecordDeletedEvent event) {
|
||||
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||
return;
|
||||
|
||||
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||
|
||||
final EntityBase removedItem = entityCache.get(event.getCustomerDB())
|
||||
.get(event.getTableName())
|
||||
.remove(entityPrimaryKey);
|
||||
}
|
||||
|
||||
|
||||
private ConcurrentHashMap<HashMap<String, Object>, EntityBase> retrieveEntityList(Connection connection, String tableName, Class<? extends EntityBase> clazz) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
String sql = "SELECT * FROM " + tableName;
|
||||
|
||||
List<? extends EntityBase> objects = UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
||||
if (objects == null)
|
||||
objects = new ArrayList<>();
|
||||
final List<EntityHierarchy.Field> pkFields = entityPropertyHolder.getEntityFields(clazz, EntityHierarchy.Field::isPrimaryKey);
|
||||
|
||||
|
||||
ConcurrentHashMap<HashMap<String, Object>, EntityBase> objectsMap = new ConcurrentHashMap<>();
|
||||
for (EntityBase object : objects) {
|
||||
HashMap<String, Object> pkMap = new HashMap<>();
|
||||
for (EntityHierarchy.Field pkField : pkFields) {
|
||||
Object pkValue = pkField.getField().get(object);
|
||||
pkMap.put(pkField.getFieldName(), pkValue);
|
||||
}
|
||||
objectsMap.put(pkMap, object);
|
||||
}
|
||||
|
||||
return objectsMap;
|
||||
}
|
||||
|
||||
private EntityBase retrieveEntityItem(Connection connection, String tableName, Class<?> clazz, HashMap<String, Object> primaryKey) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
String sql = "SELECT * FROM " + tableName + "\n" +
|
||||
" WHERE " + UtilityQuery.concatFieldsInWhereCond(primaryKey);
|
||||
|
||||
final EntityBase object = (EntityBase) UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, clazz);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
private HashMap<String, Object> convertSqlMapToEntityMap(HashMap<String, Object> sqlMap, Class<? extends EntityBase> clazz) {
|
||||
HashMap<String, Object> entityMap = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : sqlMap.entrySet()) {
|
||||
String fieldName = entityPropertyHolder.getEntityFields(clazz, f -> f.isSqlField() && f.getSqlField().value().equals(entry.getKey()))
|
||||
.stream()
|
||||
.findFirst()
|
||||
.map(EntityHierarchy.Field::getFieldName)
|
||||
.orElse(entry.getKey());
|
||||
entityMap.put(fieldName, entry.getValue());
|
||||
}
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
private boolean isCacheEnabled(IntegryCustomerDB customerDB, String tableName) {
|
||||
return (entityCache.containsKey(customerDB) && entityCache.get(customerDB).containsKey(tableName)) ||
|
||||
!(UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
||||
import it.integry.ems.entity_logger.db_schema_manager.dto.*;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -57,7 +57,7 @@ public class EntityLoggerComponent {
|
||||
|
||||
private void syncDBScheme() throws Exception {
|
||||
|
||||
AvailableConnectionsModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
AvailableConnectionModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
|
||||
if (connectionsModel == null) {
|
||||
throw new Exception("Impossibile ricavare la default connection");
|
||||
@@ -107,7 +107,7 @@ public class EntityLoggerComponent {
|
||||
}
|
||||
|
||||
if (settingsModel.getAvailableConnections().stream().noneMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
||||
settingsModel.addAvailableConnection(new AvailableConnectionsModel()
|
||||
settingsModel.addAvailableConnection(new AvailableConnectionModel()
|
||||
.setInternalDb(false)
|
||||
.setHost(dbHost)
|
||||
.setUsername(dbUsername)
|
||||
@@ -210,12 +210,12 @@ public class EntityLoggerComponent {
|
||||
return;
|
||||
|
||||
try {
|
||||
List<AvailableConnectionsModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
List<AvailableConnectionModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||
|
||||
try (MultiDBTransactionManager historyMultiDB = new MultiDBTransactionManager(historyProfileDB)) {
|
||||
|
||||
for (AvailableConnectionsModel sourceConnectionModel : connectionsModels) {
|
||||
for (AvailableConnectionModel sourceConnectionModel : connectionsModels) {
|
||||
String sql = "SELECT * FROM stb_log_entity_setup" +
|
||||
" WHERE entity_name <> " + UtilityDB.valueToString(StbLogEntitySetup.ENTITY);
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@ package it.integry.ems.javabeans;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.model.IntegryApplicationEnum;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
@@ -138,6 +141,16 @@ public class RequestDataDTO {
|
||||
return profileDB;
|
||||
}
|
||||
|
||||
public IntegryCustomerDB getCustomerDB() {
|
||||
if (UtilityString.isNullOrEmpty(profileDB))
|
||||
return null;
|
||||
|
||||
final SettingsModel settingsModel = ApplicationContextProvider.getApplicationContext().getBean(SettingsModel.class);
|
||||
final String dbName = settingsModel.getDbNameFromProfileDb(profileDB);
|
||||
|
||||
return IntegryCustomerDB.parse(dbName);
|
||||
}
|
||||
|
||||
public Long getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
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.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -60,11 +60,11 @@ public class LicenseComponent {
|
||||
if (!canStart)
|
||||
return;
|
||||
|
||||
List<AvailableConnectionsModel> availableConnectionsModels = settingsModel.getAvailableConnections(true);
|
||||
List<AvailableConnectionModel> availableConnectionModels = settingsModel.getAvailableConnections(true);
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager()) {
|
||||
|
||||
for (AvailableConnectionsModel model : availableConnectionsModels) {
|
||||
for (AvailableConnectionModel model : availableConnectionModels) {
|
||||
multiDBTransactionManager.addConnection(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
return UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
||||
}
|
||||
|
||||
protected @NotNull <T> List<T> executeQueryOnlyFirstColumn(String sql) throws SQLException {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
protected void executeStatement(String... sqls) throws SQLException {
|
||||
executeStatement(connection, sqls);
|
||||
}
|
||||
@@ -141,6 +145,10 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
}
|
||||
|
||||
private void alterObject(SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
||||
if (UtilityString.isNullOrEmpty(objectName)) {
|
||||
throw new IllegalArgumentException("ObjectName in createOrUpdateFunction(), createOrUpdateView(), createOrUpdateTrigger(), createOrUpdateProcedure() cannot be null or empty");
|
||||
}
|
||||
|
||||
executeStatement("IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||
"\tDROP " + sqlObject.toString() + " " + objectName,
|
||||
sql);
|
||||
|
||||
@@ -8,7 +8,7 @@ public enum IntegryCustomer {
|
||||
IntegryCustomerDB.Agricoper_IlVisone,
|
||||
IntegryCustomerDB.Agricoper_Luva),
|
||||
|
||||
ATI(IntegryCustomerDB.ATI_Finpart),
|
||||
ATI(IntegryCustomerDB.ATI, IntegryCustomerDB.ATI_Finpart),
|
||||
Auricchio(IntegryCustomerDB.Auricchio_Auricchio,
|
||||
IntegryCustomerDB.Auricchio_AuricchioMiki,
|
||||
IntegryCustomerDB.Auricchio_AuricchioSrl,
|
||||
|
||||
@@ -9,7 +9,9 @@ public enum IntegryCustomerDB {
|
||||
Agricoper_IlVisone("ilvisone"),
|
||||
Agricoper_Luva("luva"),
|
||||
|
||||
ATI("atisrl"),
|
||||
ATI_Finpart("Finpart"),
|
||||
|
||||
Auricchio_Auricchio("auricchio"),
|
||||
Auricchio_AuricchioMiki("auricchio_miki"),
|
||||
Auricchio_AuricchioSrl("auricchiosrl"),
|
||||
@@ -31,6 +33,7 @@ public enum IntegryCustomerDB {
|
||||
Carelli_Chiuso("chiuso"),
|
||||
Carelli_Format("format"),
|
||||
Carelli_Murgia("murgia"),
|
||||
Carelli_MurgiaTest("murgia_test"),
|
||||
Carelli_Panimal("panimal"),
|
||||
Carelli_Winact("winact"),
|
||||
Carelli_Csgr("csgr"),
|
||||
@@ -123,6 +126,7 @@ public enum IntegryCustomerDB {
|
||||
Levanplast_Perilflor("perilflor"),
|
||||
Levanplast_PerilflorSrl("perilflorsrl"),
|
||||
Levanplast_Levanplast("levanplast"),
|
||||
Levanplast_Levanplastsrl("levanplastsrl"),
|
||||
|
||||
Maggio_MaggioSrl("maggiosrl"),
|
||||
Maggio_GiovMaggio("giovmaggio"),
|
||||
|
||||
@@ -2,7 +2,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.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Migration_20210721093948 extends BaseMigration implements Migration
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
|
||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,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.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Migration_20210924152555 extends BaseMigration implements Migration
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
|
||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||
return;
|
||||
|
||||
@@ -10,6 +10,8 @@ public class Migration_20251022125946 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("getListinoVendita", "CREATE FUNCTION [dbo].[getListinoVendita](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
|
||||
@@ -10,6 +10,9 @@ public class Migration_20251024175524 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"exec DropForeignKey 'ctb_amac', 'mtb_depo_posizioni'",
|
||||
"exec DropForeignKey 'jrl_fase_posizioni', 'mtb_depo_posizioni'",
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Migration_20251027172319 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"CREATE TABLE [dbo].[mtb_ssfam]("
|
||||
+ " [cod_mgrp] varchar(5) NOT NULL, "
|
||||
+ " [cod_msgr] varchar(5) NOT NULL, "
|
||||
+ " [cod_msfa] varchar(6) NOT NULL, "
|
||||
+ " [cod_mssfa] varchar(6) NOT NULL, "
|
||||
+ " [descrizione] varchar(40) NOT NULL);",
|
||||
|
||||
"ALTER TABLE mtb_ssfam ADD CONSTRAINT pk_mtb_ssfam PRIMARY KEY ("
|
||||
+ " cod_mgrp ASC, cod_msgr ASC, cod_msfa ASC, cod_mssfa ASC );",
|
||||
|
||||
"ALTER TABLE [dbo].[mtb_ssfam] WITH CHECK ADD CONSTRAINT fk_mtb_ssfam_mtb_grup "
|
||||
+ "FOREIGN KEY(cod_mgrp) REFERENCES [dbo].[mtb_grup](cod_mgrp);",
|
||||
|
||||
"ALTER TABLE [dbo].[mtb_ssfam] WITH CHECK ADD CONSTRAINT fk_mtb_ssfam_mtb_sgrp "
|
||||
+ "FOREIGN KEY(cod_mgrp, cod_msgr) REFERENCES [dbo].[mtb_sgrp](cod_mgrp, cod_msgr);",
|
||||
|
||||
"ALTER TABLE [dbo].[mtb_ssfam] WITH CHECK ADD CONSTRAINT fk_mtb_ssfam_mtb_sfam "
|
||||
+ "FOREIGN KEY(cod_mgrp, cod_msgr, cod_msfa) REFERENCES [dbo].[mtb_sfam](cod_mgrp, cod_msgr, cod_msfa);",
|
||||
"exec DropForeignKey 'mtb_aart', 'mtb_aart_marchio';",
|
||||
"exec DropPrimaryKey 'mtb_aart_marchio';",
|
||||
"ALTER TABLE mtb_aart_marchio ADD id bigint identity NOT NULL;",
|
||||
"ALTER TABLE mtb_aart_marchio ADD CONSTRAINT pk_mtb_aart_marchio PRIMARY KEY (id);",
|
||||
"CREATE TABLE mtb_marchio_linea ("
|
||||
+ " id_marchio bigint NOT NULL, "
|
||||
+ " cod_linea varchar(6) NOT NULL, "
|
||||
+ " descrizione varchar(255) NOT NULL );",
|
||||
"ALTER TABLE mtb_marchio_linea ADD CONSTRAINT pk_mtb_marchio_linea PRIMARY KEY (cod_linea);",
|
||||
"ALTER TABLE mtb_marchio_linea ADD CONSTRAINT fk_mtb_marchio_linea_mtb_aart_marchio "
|
||||
+ "FOREIGN KEY (id_marchio) REFERENCES mtb_aart_marchio(id);",
|
||||
|
||||
"ALTER TABLE mtb_aart ADD id_marchio bigint;",
|
||||
"UPDATE mtb_aart SET id_marchio = mtb_aart_marchio.id "
|
||||
+ "FROM mtb_aart INNER JOIN mtb_aart_marchio ON mtb_aart.marchio = mtb_aart_marchio.marchio;",
|
||||
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_aart_marchio "
|
||||
+ "FOREIGN KEY (id_marchio) REFERENCES mtb_aart_marchio(id);",
|
||||
|
||||
"ALTER TABLE mtb_aart ADD cod_mssfa varchar(6);",
|
||||
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_ssfam "
|
||||
+ "FOREIGN KEY (cod_mgrp, cod_msgr, cod_msfa, cod_mssfa) "
|
||||
+ "REFERENCES mtb_ssfam (cod_mgrp, cod_msgr, cod_msfa, cod_mssfa);",
|
||||
|
||||
"ALTER TABLE mtb_aart ADD cod_linea varchar(6);",
|
||||
"ALTER TABLE mtb_aart ADD cod_slinea varchar(6);",
|
||||
"ALTER TABLE mtb_aart ADD cod_sslinea varchar(6);",
|
||||
"CREATE TABLE mtb_marchio_slinea ("
|
||||
+ " cod_linea varchar(6) NOT NULL, "
|
||||
+ " cod_slinea varchar(6) NOT NULL, "
|
||||
+ " descrizione varchar(255) NOT NULL );",
|
||||
"ALTER TABLE mtb_marchio_slinea ADD CONSTRAINT pk_mtb_marchio_slinea PRIMARY KEY (cod_slinea);",
|
||||
"ALTER TABLE mtb_marchio_slinea ADD CONSTRAINT fk_mtb_marchio_slinea_mtb_marchio_linea "
|
||||
+ "FOREIGN KEY (cod_linea) REFERENCES mtb_marchio_linea (cod_linea);",
|
||||
|
||||
"CREATE TABLE mtb_marchio_sslinea ("
|
||||
+ " cod_slinea varchar(6) NOT NULL, "
|
||||
+ " cod_sslinea varchar(6) NOT NULL, "
|
||||
+ " descrizione varchar(255) NOT NULL );",
|
||||
"ALTER TABLE mtb_marchio_sslinea ADD CONSTRAINT pk_mtb_marchio_sslinea PRIMARY KEY (cod_sslinea);",
|
||||
"ALTER TABLE mtb_marchio_sslinea ADD CONSTRAINT fk_mtb_marchio_sslinea_mtb_marchio_slinea "
|
||||
+ "FOREIGN KEY (cod_slinea) REFERENCES mtb_marchio_slinea (cod_slinea);",
|
||||
|
||||
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_marchio_linea "
|
||||
+ "FOREIGN KEY (cod_linea) REFERENCES mtb_marchio_linea(cod_linea);",
|
||||
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_marchio_slinea "
|
||||
+ "FOREIGN KEY (cod_slinea) REFERENCES mtb_marchio_slinea(cod_slinea);",
|
||||
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_marchio_sslinea "
|
||||
+ "FOREIGN KEY (cod_sslinea) REFERENCES mtb_marchio_sslinea(cod_sslinea);"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Migration_20251027173518 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
IndexTableDTO indexTableDTO =
|
||||
new IndexTableDTO()
|
||||
.setTableName("mtb_aart_marchio")
|
||||
.setIndexName("ix_mtb_aart_marchio_unique")
|
||||
.setUnique(true)
|
||||
.setColumnsIndex(Arrays.asList(
|
||||
new IndexTableDTO.ColumnIndex("marchio")
|
||||
));
|
||||
createIndex(indexTableDTO);
|
||||
|
||||
if (!existsColumn("ctb_movt", "rif_import")){
|
||||
executeStatement("ALTER TABLE ctb_movt ADD rif_import varchar(40)");
|
||||
}
|
||||
|
||||
if (!existsColumn("ctb_varbeni", "num_cmov")) {
|
||||
executeStatement("ALTER TABLE ctb_varbeni add num_cmov int",
|
||||
"ALTER TABLE ctb_varbeni ADD CONSTRAINT fk_ctb_varbeni_ctb_movt FOREIGN KEY (num_cmov) REFERENCES ctb_movt (num_cmov)");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ public class Migration_20251029153203 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateView("[vw_tracciabUDCVend]", "CREATE VIEW [dbo].[vw_tracciabUDCVend] AS\n" +
|
||||
"SELECT mtb_colt.cod_anag AS codAnag,\n" +
|
||||
|
||||
@@ -10,6 +10,8 @@ public class Migration_20251029170931 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("getDettMatricoleDaOrdine", "CREATE Function [dbo].[getDettMatricoleDaOrdine] (@codJcom varchar(10)) \n" +
|
||||
"RETURNS @dettMatricole TABLE( cod_prod varchar(15),\n" +
|
||||
|
||||
@@ -21,6 +21,9 @@ public class Migration_20251029181607 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"EXEC sp_updateextendedproperty 'MS_Description',\n" +
|
||||
" 'Valori possibili: 0 -> Testo, 1 -> Boolean, 2 -> Intero, 3 -> Decimale, 4 -> Date, 5 -> Datetime, 6 -> Time, 7 -> DropdownList',\n" +
|
||||
|
||||
@@ -10,6 +10,9 @@ public class Migration_20251031092657 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement("alter table dtb_tipi add flag_delete_plk bit not null default 0");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ public class Migration_20251031100008 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement("exec sp_rename 'dtb_tipi.flag_delete_plk', 'flag_delete_pkl'");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
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_20251103103545 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("CREATE TABLE [dbo].[srl_activity_art](\n" +
|
||||
"\tid bigint identity,\n" +
|
||||
"\t[activity_id] [varchar](15) NOT NULL,\n" +
|
||||
"\t[cod_mart] [varchar](15) not NULL\n" +
|
||||
")\n"
|
||||
,
|
||||
"alter table srl_activity_art add constraint pk_srl_activity_art primary key(id);\n");
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_Winact)) {
|
||||
executeStatement("insert into srl_activity_art\n" +
|
||||
"select activity_id, cod_mart\n" +
|
||||
"from stb_activity\n" +
|
||||
"where cod_jcom = 'MODEL'\n" +
|
||||
"and activity_type_id = 'SEGNALAZIONE'\n" +
|
||||
"and cod_mart is not null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251103175252 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"CREATE TABLE mtb_colori ("
|
||||
+ " cod_col varchar(6) NOT NULL, "
|
||||
+ " descrizione varchar(255) NOT NULL );",
|
||||
"ALTER TABLE mtb_colori ADD CONSTRAINT pk_mtb_colori PRIMARY KEY (cod_col);",
|
||||
"CREATE TABLE mtb_aart_colori ("
|
||||
+ " cod_mart varchar(15) NOT NULL, "
|
||||
+ " cod_col varchar(6) NOT NULL, "
|
||||
+ " cod_barre varchar(25) NULL);",
|
||||
"ALTER TABLE mtb_aart_colori ADD CONSTRAINT pk_mtb_aart_colori PRIMARY KEY (cod_mart, cod_col);",
|
||||
"ALTER TABLE mtb_aart_colori ADD CONSTRAINT fk_mtb_aart_colori_mtb_aart "
|
||||
+ "FOREIGN KEY (cod_mart) REFERENCES mtb_aart (cod_mart);",
|
||||
"ALTER TABLE mtb_aart_colori ADD CONSTRAINT fk_mtb_aart_colori_mtb_colori "
|
||||
+ "FOREIGN KEY (cod_col) REFERENCES mtb_colori (cod_col);"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251104122721 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"ALTER TABLE dbo.vtb_offt\n" +
|
||||
" ADD cod_banc VARCHAR(5)\n" +
|
||||
" CONSTRAINT vtb_offt_gtb_banc_cod_banc_fk\n" +
|
||||
" REFERENCES dbo.gtb_banc;",
|
||||
"ALTER TABLE dbo.vtb_offt\n" +
|
||||
" ADD cod_banc_azi VARCHAR(5)\n" +
|
||||
" CONSTRAINT vtb_offt_gtb_banc_azi_cod_banc_fk\n" +
|
||||
" REFERENCES dbo.gtb_banc_azi;"
|
||||
);
|
||||
|
||||
createOrUpdateView(
|
||||
"vvw_contratti_vendita",
|
||||
"CREATE VIEW [dbo].[vvw_contratti_vendita] AS\n" +
|
||||
"WITH depo AS (SELECT TOP 1 cod_mdep\n" +
|
||||
" FROM mtb_depo\n" +
|
||||
" WHERE mtb_depo.flag_movimentabile = 'S'\n" +
|
||||
" AND (cod_anag IS NULL OR cod_anag IN (SELECT gtb_anag.cod_anag\n" +
|
||||
" FROM gtb_anag,\n" +
|
||||
" azienda\n" +
|
||||
" WHERE gtb_anag.part_iva = azienda.part_iva))),\n" +
|
||||
" contratto AS (SELECT vtb_offt.cod_anag,\n" +
|
||||
" vtb_offt.cod_vdes,\n" +
|
||||
" vtb_offt.note,\n" +
|
||||
" vtb_offr.id_offerta,\n" +
|
||||
" vtb_offr.cod_mart,\n" +
|
||||
" vtb_offr.unt_mis,\n" +
|
||||
" vtb_offr.descrizione,\n" +
|
||||
" vtb_offr.descrizione_html,\n" +
|
||||
" vtb_offr.json_costi,\n" +
|
||||
" vtb_offr.costo_unt,\n" +
|
||||
" vtb_offr.unt_mis_vend,\n" +
|
||||
" vtb_offr.prz_unt,\n" +
|
||||
" vtb_offr.qta_off,\n" +
|
||||
" vtb_offr.data_iniz_contr,\n" +
|
||||
" vtb_offr.data_fine_contr,\n" +
|
||||
" vtb_offt.cod_paga,\n" +
|
||||
" vtb_offt.descrizione_paga,\n" +
|
||||
" vtb_offr.perc_sco1,\n" +
|
||||
" vtb_offr.perc_sco2,\n" +
|
||||
" vtb_offr.perc_sco3,\n" +
|
||||
" vtb_offr.perc_sco4,\n" +
|
||||
" vtb_offr.rap_conv_vend,\n" +
|
||||
" vtb_offr.qta_ord,\n" +
|
||||
" vtb_offr.qta_doc,\n" +
|
||||
" vtb_offr.qta_fatt,\n" +
|
||||
" vtb_offr.note AS note_riga,\n" +
|
||||
" vtb_offt.condizioni_commerciali,\n" +
|
||||
" vtb_offt.incoterms,\n" +
|
||||
" vtb_offt.note_incoterms,\n" +
|
||||
" vtb_offt.data_rif_scad,\n" +
|
||||
" vtb_offt.perc_prov,\n" +
|
||||
" vtb_offt.note_carico,\n" +
|
||||
" vtb_offt.term_cons,\n" +
|
||||
" vtb_offt.cod_banc,\n" +
|
||||
" vtb_offt.cod_banc_azi\n" +
|
||||
" FROM vtb_offt\n" +
|
||||
" INNER JOIN vtb_offr ON vtb_offt.id_offerta = vtb_offr.id_offerta\n" +
|
||||
" CROSS APPLY [dbo].[getUntMisArticolo](vtb_offr.cod_mart, vtb_offr.unt_mis_vend) um\n" +
|
||||
" WHERE stato_offerta = 3)\n" +
|
||||
"\n" +
|
||||
"SELECT contratto.data_iniz_contr AS data_iniz,\n" +
|
||||
" contratto.data_fine_contr AS data_fine,\n" +
|
||||
" contratto.id_offerta AS id_contratto,\n" +
|
||||
" contratto.note,\n" +
|
||||
" contratto.cod_mart,\n" +
|
||||
" contratto.descrizione AS descrizione_articolo,\n" +
|
||||
" contratto.unt_mis_vend AS unt_mis_ven,\n" +
|
||||
" contratto.qta_off AS qta_vend_contratto,\n" +
|
||||
" contratto.prz_unt AS prz_vend,\n" +
|
||||
" contratto.perc_sco1,\n" +
|
||||
" contratto.perc_sco2,\n" +
|
||||
" contratto.perc_sco3,\n" +
|
||||
" contratto.perc_sco4,\n" +
|
||||
" ISNULL(contratto.qta_ord, 0) AS qta_ord,\n" +
|
||||
" ISNULL(contratto.qta_doc, 0) AS qta_doc,\n" +
|
||||
" gtb_anag.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" gtb_anag.indirizzo,\n" +
|
||||
" gtb_anag.cap,\n" +
|
||||
" gtb_anag.citta,\n" +
|
||||
" gtb_anag.prov,\n" +
|
||||
" gtb_anag.nazione,\n" +
|
||||
" gtb_anag.e_mail,\n" +
|
||||
" gtb_anag.telefono,\n" +
|
||||
" gtb_anag.part_iva,\n" +
|
||||
" ISNULL(giacenza.qta_disp * rap_conv_vend, 0) AS qta_disp,\n" +
|
||||
" (SELECT cod_mdep FROM depo) AS cod_mdep,\n" +
|
||||
" contratto.prz_unt * (1 - contratto.perc_sco1 / 100) * (1 - contratto.perc_sco2 / 100) -\n" +
|
||||
" (1 * contratto.perc_sco3 / 100) *\n" +
|
||||
" (1 - contratto.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||
" contratto.cod_paga,\n" +
|
||||
" ISNULL(contratto.descrizione_paga, gtb_paga.descrizione) AS descrizione_paga,\n" +
|
||||
" contratto.qta_off -\n" +
|
||||
" ISNULL(contratto.qta_ord, 0) -\n" +
|
||||
" ISNULL(contratto.qta_doc, 0) AS qta_residua,\n" +
|
||||
" ISNULL(contratto.qta_ord + contratto.qta_doc, 0) AS qta_usata,\n" +
|
||||
" contratto.rap_conv_vend AS rap_conv,\n" +
|
||||
" contratto.cod_vdes,\n" +
|
||||
" vd.destinatario,\n" +
|
||||
" vd.indirizzo AS indirizzo_dest,\n" +
|
||||
" vc.cod_vlis,\n" +
|
||||
" contratto.qta_fatt,\n" +
|
||||
" contratto.note_riga,\n" +
|
||||
" contratto.condizioni_commerciali,\n" +
|
||||
" contratto.incoterms,\n" +
|
||||
" gp.descrizione AS desc_incoterms,\n" +
|
||||
" contratto.note_incoterms,\n" +
|
||||
" contratto.data_rif_scad,\n" +
|
||||
" contratto.perc_prov,\n" +
|
||||
" contratto.note_carico,\n" +
|
||||
" contratto.term_cons,\n" +
|
||||
" gtb_tipi_paga.flag_banca_ven,\n" +
|
||||
" IIF(gtb_tipi_paga.flag_banca_ven = 'C', gb.cod_banc, gba.cod_banc_azi) AS cod_banc,\n" +
|
||||
" IIF(gtb_tipi_paga.flag_banca_ven = 'C', gb.descrizione, gba.descrizione) AS descr_banc\n" +
|
||||
"FROM contratto\n" +
|
||||
" INNER JOIN gtb_anag ON contratto.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" INNER JOIN vtb_clie vc ON contratto.cod_anag = vc.cod_anag\n" +
|
||||
" LEFT OUTER JOIN vtb_dest vd ON contratto.cod_anag = vd.cod_anag AND contratto.cod_vdes = vd.cod_vdes\n" +
|
||||
" LEFT OUTER JOIN gtb_paga ON contratto.cod_paga = gtb_paga.cod_paga\n" +
|
||||
" LEFT OUTER JOIN gtb_tipi_paga ON gtb_paga.tipo_paga = gtb_tipi_paga.tipo_paga\n" +
|
||||
" LEFT OUTER JOIN gtb_porto gp ON contratto.incoterms = gp.porto\n" +
|
||||
" LEFT OUTER JOIN gtb_banc gb ON contratto.cod_banc = gb.cod_banc\n" +
|
||||
" LEFT OUTER JOIN gtb_banc_azi gba ON contratto.cod_banc_azi = gba.cod_banc_azi\n" +
|
||||
" OUTER APPLY (SELECT SUM(mtb_part.qta_esistente + mtb_part.qta_imp_lav - mtb_part.qta_imp_cli) AS qta_disp\n" +
|
||||
" FROM mtb_part\n" +
|
||||
" INNER JOIN mtb_depo ON mtb_part.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||
" WHERE mtb_depo.flag_movimentabile = 'S'\n" +
|
||||
" AND mtb_part.cod_mart = contratto.cod_mart) giacenza");
|
||||
|
||||
createOrUpdateFunction(
|
||||
"pvm_getassortimentoClientePedane",
|
||||
"CREATE FUNCTION [dbo].[pvm_getassortimentoClientePedane](\n" +
|
||||
" @codAnag VARCHAR(5), @codVlis VARCHAR(5), @codVdes VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT,\n" +
|
||||
" @pedane INT = 0\n" +
|
||||
")\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS\n" +
|
||||
" RETURN( /*\n" +
|
||||
"\n" +
|
||||
" declare @codAnag VARCHAR(5), @codVlis VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT\n" +
|
||||
" set @codAnag = 'C3355'\n" +
|
||||
" set @codVlis = 'C3355'\n" +
|
||||
" set @dataValidita = '2023/04/04'\n" +
|
||||
" set @viewPromo = 1;\n" +
|
||||
" */\n" +
|
||||
" WITH assortimento AS (SELECT vtb_griglia_art.cod_mart\n" +
|
||||
" FROM vtb_clie\n" +
|
||||
" INNER JOIN vtb_griglia ON vtb_clie.cod_griglia = vtb_griglia.cod_griglia\n" +
|
||||
" INNER JOIN vtb_griglia_art\n" +
|
||||
" ON vtb_griglia.cod_griglia = vtb_griglia_art.cod_griglia AND\n" +
|
||||
" vtb_griglia.data_validita = vtb_griglia_art.data_validita\n" +
|
||||
" WHERE vtb_clie.cod_anag = @codAnag\n" +
|
||||
" AND vtb_griglia.data_validita = (SELECT MAX(g.data_validita)\n" +
|
||||
" FROM vtb_griglia g\n" +
|
||||
" WHERE g.cod_griglia = vtb_clie.cod_griglia\n" +
|
||||
" AND g.data_validita <= ISNULL(@dataValidita, CAST(GETDATE() AS DATE)))),\n" +
|
||||
" lisv AS (SELECT cod_vlis, cod_vlis AS cod_vlis_rif\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" WHERE cod_vlis_rif IS NULL\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_vlis, cod_vlis_rif\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" WHERE cod_vlis_rif IS NOT NULL),\n" +
|
||||
" listino AS (SELECT DISTINCT cod_mart, tipo_variazione\n" +
|
||||
" FROM (SELECT lisv.cod_vlis,\n" +
|
||||
" mtb_lisv.cod_mart,\n" +
|
||||
" LAST_VALUE(CASE\n" +
|
||||
" WHEN vtb_list_data.data_iniz IS NULL THEN NULL\n" +
|
||||
" ELSE mtb_lisv_data.tipo_variazione END)\n" +
|
||||
" OVER (PARTITION BY lisv.cod_vlis, mtb_lisv.cod_mart\n" +
|
||||
" ORDER BY vtb_list_data.data_iniz, CASE WHEN vtb_list_data.cod_promo IS NULL THEN 0 ELSE 1 END, vtb_list_data.versione\n" +
|
||||
" RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS tipo_variazione\n" +
|
||||
" FROM lisv\n" +
|
||||
" INNER JOIN mtb_lisv ON lisv.cod_vlis_rif = mtb_lisv.cod_vlis\n" +
|
||||
" INNER JOIN mtb_lisv_data ON mtb_lisv.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" mtb_lisv.cod_mart = mtb_lisv_data.cod_mart\n" +
|
||||
" LEFT OUTER JOIN vtb_list_data\n" +
|
||||
" ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
|
||||
" vtb_list_data.data_iniz <=\n" +
|
||||
" ISNULL(@dataValidita, CAST(GETDATE() AS DATE))\n" +
|
||||
" WHERE lisv.cod_vlis = @codVlis\n" +
|
||||
" AND NOT EXISTS(SELECT cod_mart FROM assortimento)) t\n" +
|
||||
" WHERE (t.tipo_variazione IS NULL OR t.tipo_variazione <> 'D')),\n" +
|
||||
" tmp_lisv AS (SELECT l.cod_mart,\n" +
|
||||
" l.cod_vlis,\n" +
|
||||
" ISNULL(p.data_iniz, l.data_iniz) AS data_iniz,\n" +
|
||||
" p.data_fine,\n" +
|
||||
" l.da,\n" +
|
||||
" l.a,\n" +
|
||||
" ISNULL(p.prz_vend, l.prz_vend_trasp) AS prz_vend,\n" +
|
||||
" ISNULL(p.prz_vend_netto, l.prz_vend_trasp_netto) AS prz_vend_netto,\n" +
|
||||
" ISNULL(p.perc_sco1, l.perc_sco1) AS perc_sco1,\n" +
|
||||
" ISNULL(p.perc_sco2, l.perc_sco2) AS perc_sco2,\n" +
|
||||
" ISNULL(p.perc_sco3, l.perc_sco3) AS perc_sco3,\n" +
|
||||
" ISNULL(p.perc_sco4, l.perc_sco4) AS perc_sco4,\n" +
|
||||
" p.perc_prov,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), 0) AS qta_residua,\n" +
|
||||
" CONVERT(BIGINT, NULL) AS id_contratto,\n" +
|
||||
" ISNULL(p.rap_conv, l.rap_conv) AS rap_conv,\n" +
|
||||
" ISNULL(p.note, l.note) AS note,\n" +
|
||||
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||
" l.cod_tcol_ul AS cod_tcol_ul,\n" +
|
||||
" ISNULL(p.unt_mis_ven, l.unt_mis_ven) AS unt_mis_ven,\n" +
|
||||
" l.colli_pedana AS colli_pedana,\n" +
|
||||
" ISNULL(p.tipo_variazione, l.tipo_variazione) AS tipo_variazione,\n" +
|
||||
" CONVERT(VARCHAR(1), CASE\n" +
|
||||
" WHEN p.cod_promo IS NULL THEN NULL\n" +
|
||||
" ELSE 'P' END) AS tipo_promo,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||
" l.porto,\n" +
|
||||
" l.qta_cnf,\n" +
|
||||
" NULL AS note_incoterms,\n" +
|
||||
" NULL AS data_rif_scad,\n" +
|
||||
" NULL AS note_carico,\n" +
|
||||
" NULL AS term_cons,\n" +
|
||||
" NULL AS cod_banc,\n" +
|
||||
" NULL AS descr_banc\n" +
|
||||
" FROM dbo.getListinoVenditaPedane(@dataValidita, @codVlis, NULL, @pedane) l\n" +
|
||||
" LEFT OUTER JOIN dbo.getPromozioneVendita(@dataValidita, @dataValidita,\n" +
|
||||
" @codVlis, NULL, NULL) p\n" +
|
||||
" ON l.cod_vlis = p.cod_vlis AND l.cod_mart = p.cod_mart AND\n" +
|
||||
" ISNULL(@viewPromo, 0) = 1\n" +
|
||||
" WHERE l.cod_vlis = @codVlis\n" +
|
||||
" AND l.cod_mart IN (SELECT cod_mart\n" +
|
||||
" FROM assortimento\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_mart\n" +
|
||||
" FROM listino)\n" +
|
||||
" AND l.tipo_variazione <> 'D'\n" +
|
||||
" AND l.tipo_variazione IS NOT NULL\n" +
|
||||
" AND l.flag_attivo = 'S'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT l.cod_mart,\n" +
|
||||
" l.cod_vlis,\n" +
|
||||
" NULL AS data_iniz,\n" +
|
||||
" NULL AS data_fine,\n" +
|
||||
" NULL AS da,\n" +
|
||||
" NULL AS a,\n" +
|
||||
" NULL AS prz_vend,\n" +
|
||||
" NULL AS prz_vend_netto,\n" +
|
||||
" NULL AS perc_sco1,\n" +
|
||||
" NULL AS perc_sco2,\n" +
|
||||
" NULL AS perc_sco3,\n" +
|
||||
" NULL AS perc_sco4,\n" +
|
||||
" NULL AS perc_prov,\n" +
|
||||
" NULL AS qta_residua,\n" +
|
||||
" NULL AS id_contratto,\n" +
|
||||
" um.rap_conv AS rap_conv,\n" +
|
||||
" NULL AS note,\n" +
|
||||
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||
" NULL AS cod_tcol_ul,\n" +
|
||||
" l.unt_mis_ven AS unt_mis_ven,\n" +
|
||||
" NULL AS colli_pedana,\n" +
|
||||
" NULL AS tipo_variazione,\n" +
|
||||
" NULL AS tipo_promo,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||
" NULL porto,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" NULL AS note_incoterms,\n" +
|
||||
" NULL AS data_rif_scad,\n" +
|
||||
" NULL AS note_carico,\n" +
|
||||
" NULL AS term_cons,\n" +
|
||||
" NULL AS cod_banc,\n" +
|
||||
" NULL AS descr_banc\n" +
|
||||
" FROM mtb_lisv l\n" +
|
||||
" INNER JOIN listino ON l.cod_mart = listino.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON l.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" CROSS APPLY dbo.getUntMisArticolo(l.cod_mart, l.unt_mis_ven) um\n" +
|
||||
" WHERE l.cod_vlis = @codVlis\n" +
|
||||
" AND listino.tipo_variazione IS NULL\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT vvw_contratti_vendita.cod_mart,\n" +
|
||||
" NULL AS cod_vlis,\n" +
|
||||
" vvw_contratti_vendita.data_iniz,\n" +
|
||||
" vvw_contratti_vendita.data_fine,\n" +
|
||||
" NULL AS da,\n" +
|
||||
" NULL AS a,\n" +
|
||||
" vvw_contratti_vendita.prz_vend,\n" +
|
||||
" ROUND(vvw_contratti_vendita.prz_vend *\n" +
|
||||
" (1 - ISNULL(vvw_contratti_vendita.perc_sco1, 0))\n" +
|
||||
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco2, 0))\n" +
|
||||
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco3, 0))\n" +
|
||||
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco4, 0)),\n" +
|
||||
" 5) AS prz_vend_netto,\n" +
|
||||
" vvw_contratti_vendita.perc_sco1,\n" +
|
||||
" vvw_contratti_vendita.perc_sco2,\n" +
|
||||
" vvw_contratti_vendita.perc_sco3,\n" +
|
||||
" vvw_contratti_vendita.perc_sco4,\n" +
|
||||
" vvw_contratti_vendita.perc_prov,\n" +
|
||||
" vvw_contratti_vendita.qta_residua,\n" +
|
||||
" vvw_contratti_vendita.id_contratto,\n" +
|
||||
" vvw_contratti_vendita.rap_conv,\n" +
|
||||
" vvw_contratti_vendita.note,\n" +
|
||||
" vvw_contratti_vendita.cod_vdes,\n" +
|
||||
" NULL,\n" +
|
||||
" vvw_contratti_vendita.unt_mis_ven,\n" +
|
||||
" NULL,\n" +
|
||||
" NULL,\n" +
|
||||
" 'C' AS tipo_promo,\n" +
|
||||
" vvw_contratti_vendita.cod_paga,\n" +
|
||||
" vvw_contratti_vendita.descrizione_paga AS descr_paga,\n" +
|
||||
" vvw_contratti_vendita.incoterms AS porto,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" vvw_contratti_vendita.note_incoterms,\n" +
|
||||
" vvw_contratti_vendita.data_rif_scad,\n" +
|
||||
" vvw_contratti_vendita.note_carico,\n" +
|
||||
" vvw_contratti_vendita.term_cons,\n" +
|
||||
" vvw_contratti_vendita.cod_banc,\n" +
|
||||
" vvw_contratti_vendita.descr_banc\n" +
|
||||
" FROM vvw_contratti_vendita\n" +
|
||||
" INNER JOIN mtb_aart ON vvw_contratti_vendita.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" WHERE vvw_contratti_vendita.cod_anag = @codAnag\n" +
|
||||
" AND (@codVdes IS NULL OR vvw_contratti_vendita.cod_vdes IS NULL OR\n" +
|
||||
" vvw_contratti_vendita.cod_vdes = @codVdes)\n" +
|
||||
" AND (ISNULL(@dataValidita, CAST(GETDATE() AS DATE)) BETWEEN\n" +
|
||||
" vvw_contratti_vendita.data_iniz AND vvw_contratti_vendita.data_fine)\n" +
|
||||
"-- AND vvw_contratti_vendita.qta_residua >= 0\n" +
|
||||
" )\n" +
|
||||
"\n" +
|
||||
" SELECT tmp_lisv.cod_mart,\n" +
|
||||
" ISNULL(maa.cod_mart_anag, tmp_lisv.cod_mart) AS cod_mart_anag,\n" +
|
||||
" cod_vlis,\n" +
|
||||
" data_iniz,\n" +
|
||||
" data_fine,\n" +
|
||||
" da,\n" +
|
||||
" a,\n" +
|
||||
" prz_vend,\n" +
|
||||
" prz_vend_netto,\n" +
|
||||
" perc_sco1,\n" +
|
||||
" perc_sco2,\n" +
|
||||
" perc_sco3,\n" +
|
||||
" perc_sco4,\n" +
|
||||
" perc_prov,\n" +
|
||||
" qta_residua,\n" +
|
||||
" id_contratto,\n" +
|
||||
" rap_conv,\n" +
|
||||
" ISNULL(maa.note, tmp_lisv.note) AS note,\n" +
|
||||
" cod_tcol_ul,\n" +
|
||||
" unt_mis_ven,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN maa.colli_pedana IS NULL OR maa.colli_pedana = 0 THEN tmp_lisv.colli_pedana\n" +
|
||||
" ELSE maa.colli_pedana END AS colli_pedana,\n" +
|
||||
" tipo_variazione,\n" +
|
||||
" tipo_promo,\n" +
|
||||
" cod_paga,\n" +
|
||||
" descr_paga,\n" +
|
||||
" porto,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" CAST(CASE WHEN tmp_lisv.data_iniz IS NULL THEN 0 ELSE 1 END AS BIT) AS art_lisv,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" note_incoterms,\n" +
|
||||
" data_rif_scad,\n" +
|
||||
" note_carico,\n" +
|
||||
" term_cons,\n" +
|
||||
" cod_banc,\n" +
|
||||
" descr_banc\n" +
|
||||
" FROM tmp_lisv\n" +
|
||||
" LEFT OUTER JOIN mtb_aart_anag maa\n" +
|
||||
" ON tmp_lisv.cod_mart = maa.cod_mart AND maa.cod_anag = @codAnag)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251105171403 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement("delete dtb_ordr\n" +
|
||||
"from dtb_ordr \n" +
|
||||
"where not exists (select *\n" +
|
||||
"from dtb_ordt \n" +
|
||||
"where 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" +
|
||||
"\n",
|
||||
"alter table dtb_ordr add constraint fk_dtb_ordr_dtb_ordt foreign key (gestione, data_ord, num_ord) references dbo.dtb_ordt (gestione, data_ord, num_ord)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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_20251106104752 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
dropDefault("mtb_lisv", "flag_primario");
|
||||
|
||||
addDefault("mtb_lisv", "flag_primario", 1);
|
||||
|
||||
if (!isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
executeStatement(
|
||||
"UPDATE mtb_lisv\n" +
|
||||
"SET flag_primario = DEFAULT\n" +
|
||||
"WHERE flag_primario = 0"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251106113104 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction(
|
||||
"pvm_getassortimentoClientePedane",
|
||||
"CREATE FUNCTION [dbo].[pvm_getassortimentoClientePedane](\n" +
|
||||
" @codAnag VARCHAR(5), @codVlis VARCHAR(5), @codVdes VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT,\n" +
|
||||
" @pedane INT = 0\n" +
|
||||
")\n" +
|
||||
" RETURNS TABLE\n" +
|
||||
" AS\n" +
|
||||
" RETURN( /*\n" +
|
||||
"\n" +
|
||||
" declare @codAnag VARCHAR(5), @codVlis VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT\n" +
|
||||
" set @codAnag = 'C3355'\n" +
|
||||
" set @codVlis = 'C3355'\n" +
|
||||
" set @dataValidita = '2023/04/04'\n" +
|
||||
" set @viewPromo = 1;\n" +
|
||||
" */\n" +
|
||||
" WITH assortimento AS (SELECT vtb_griglia_art.cod_mart\n" +
|
||||
" FROM vtb_clie\n" +
|
||||
" INNER JOIN vtb_griglia ON vtb_clie.cod_griglia = vtb_griglia.cod_griglia\n" +
|
||||
" INNER JOIN vtb_griglia_art\n" +
|
||||
" ON vtb_griglia.cod_griglia = vtb_griglia_art.cod_griglia AND\n" +
|
||||
" vtb_griglia.data_validita = vtb_griglia_art.data_validita\n" +
|
||||
" WHERE vtb_clie.cod_anag = @codAnag\n" +
|
||||
" AND vtb_griglia.data_validita = (SELECT MAX(g.data_validita)\n" +
|
||||
" FROM vtb_griglia g\n" +
|
||||
" WHERE g.cod_griglia = vtb_clie.cod_griglia\n" +
|
||||
" AND g.data_validita <= ISNULL(@dataValidita, CAST(GETDATE() AS DATE)))),\n" +
|
||||
" lisv AS (SELECT cod_vlis, cod_vlis AS cod_vlis_rif\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" WHERE cod_vlis_rif IS NULL\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_vlis, cod_vlis_rif\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" WHERE cod_vlis_rif IS NOT NULL),\n" +
|
||||
" listino AS (SELECT DISTINCT cod_mart, tipo_variazione\n" +
|
||||
" FROM (SELECT lisv.cod_vlis,\n" +
|
||||
" mtb_lisv.cod_mart,\n" +
|
||||
" LAST_VALUE(CASE\n" +
|
||||
" WHEN vtb_list_data.data_iniz IS NULL THEN NULL\n" +
|
||||
" ELSE mtb_lisv_data.tipo_variazione END)\n" +
|
||||
" OVER (PARTITION BY lisv.cod_vlis, mtb_lisv.cod_mart\n" +
|
||||
" ORDER BY vtb_list_data.data_iniz, CASE WHEN vtb_list_data.cod_promo IS NULL THEN 0 ELSE 1 END, vtb_list_data.versione\n" +
|
||||
" RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS tipo_variazione\n" +
|
||||
" FROM lisv\n" +
|
||||
" INNER JOIN mtb_lisv ON lisv.cod_vlis_rif = mtb_lisv.cod_vlis\n" +
|
||||
" INNER JOIN mtb_lisv_data ON mtb_lisv.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" mtb_lisv.cod_mart = mtb_lisv_data.cod_mart\n" +
|
||||
" LEFT OUTER JOIN vtb_list_data\n" +
|
||||
" ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
|
||||
" vtb_list_data.data_iniz <=\n" +
|
||||
" ISNULL(@dataValidita, CAST(GETDATE() AS DATE))\n" +
|
||||
" WHERE lisv.cod_vlis = @codVlis\n" +
|
||||
" AND NOT EXISTS(SELECT cod_mart FROM assortimento)) t\n" +
|
||||
" WHERE (t.tipo_variazione IS NULL OR t.tipo_variazione <> 'D')),\n" +
|
||||
" tmp_lisv AS (SELECT l.cod_mart,\n" +
|
||||
" l.cod_vlis,\n" +
|
||||
" ISNULL(p.data_iniz, l.data_iniz) AS data_iniz,\n" +
|
||||
" p.data_fine,\n" +
|
||||
" l.da,\n" +
|
||||
" l.a,\n" +
|
||||
" ISNULL(p.prz_vend, l.prz_vend_trasp) AS prz_vend,\n" +
|
||||
" ISNULL(p.prz_vend_netto, l.prz_vend_trasp_netto) AS prz_vend_netto,\n" +
|
||||
" ISNULL(p.perc_sco1, l.perc_sco1) AS perc_sco1,\n" +
|
||||
" ISNULL(p.perc_sco2, l.perc_sco2) AS perc_sco2,\n" +
|
||||
" ISNULL(p.perc_sco3, l.perc_sco3) AS perc_sco3,\n" +
|
||||
" ISNULL(p.perc_sco4, l.perc_sco4) AS perc_sco4,\n" +
|
||||
" p.perc_prov,\n" +
|
||||
" CONVERT(NUMERIC(20, 5), 0) AS qta_residua,\n" +
|
||||
" CONVERT(BIGINT, NULL) AS id_contratto,\n" +
|
||||
" ISNULL(p.rap_conv, l.rap_conv) AS rap_conv,\n" +
|
||||
" ISNULL(p.note, l.note) AS note,\n" +
|
||||
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||
" l.cod_tcol_ul AS cod_tcol_ul,\n" +
|
||||
" ISNULL(p.unt_mis_ven, l.unt_mis_ven) AS unt_mis_ven,\n" +
|
||||
" l.colli_pedana AS colli_pedana,\n" +
|
||||
" ISNULL(p.tipo_variazione, l.tipo_variazione) AS tipo_variazione,\n" +
|
||||
" CONVERT(VARCHAR(1), CASE\n" +
|
||||
" WHEN p.cod_promo IS NULL THEN NULL\n" +
|
||||
" ELSE 'P' END) AS tipo_promo,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||
" l.porto,\n" +
|
||||
" l.qta_cnf,\n" +
|
||||
" NULL AS note_incoterms,\n" +
|
||||
" NULL AS data_rif_scad,\n" +
|
||||
" NULL AS note_carico,\n" +
|
||||
" NULL AS term_cons,\n" +
|
||||
" NULL AS cod_banc,\n" +
|
||||
" NULL AS descr_banc,\n" +
|
||||
" l.flag_primario\n" +
|
||||
" FROM dbo.getListinoVenditaPedane(@dataValidita, @codVlis, NULL, @pedane) l\n" +
|
||||
" LEFT OUTER JOIN dbo.getPromozioneVendita(@dataValidita, @dataValidita,\n" +
|
||||
" @codVlis, NULL, NULL) p\n" +
|
||||
" ON l.cod_vlis = p.cod_vlis AND l.cod_mart = p.cod_mart AND\n" +
|
||||
" ISNULL(@viewPromo, 0) = 1\n" +
|
||||
" WHERE l.cod_vlis = @codVlis\n" +
|
||||
" AND l.cod_mart IN (SELECT cod_mart\n" +
|
||||
" FROM assortimento\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT cod_mart\n" +
|
||||
" FROM listino)\n" +
|
||||
" AND l.tipo_variazione <> 'D'\n" +
|
||||
" AND l.tipo_variazione IS NOT NULL\n" +
|
||||
" AND l.flag_attivo = 'S'\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT l.cod_mart,\n" +
|
||||
" l.cod_vlis,\n" +
|
||||
" NULL AS data_iniz,\n" +
|
||||
" NULL AS data_fine,\n" +
|
||||
" NULL AS da,\n" +
|
||||
" NULL AS a,\n" +
|
||||
" NULL AS prz_vend,\n" +
|
||||
" NULL AS prz_vend_netto,\n" +
|
||||
" NULL AS perc_sco1,\n" +
|
||||
" NULL AS perc_sco2,\n" +
|
||||
" NULL AS perc_sco3,\n" +
|
||||
" NULL AS perc_sco4,\n" +
|
||||
" NULL AS perc_prov,\n" +
|
||||
" NULL AS qta_residua,\n" +
|
||||
" NULL AS id_contratto,\n" +
|
||||
" um.rap_conv AS rap_conv,\n" +
|
||||
" NULL AS note,\n" +
|
||||
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||
" NULL AS cod_tcol_ul,\n" +
|
||||
" l.unt_mis_ven AS unt_mis_ven,\n" +
|
||||
" NULL AS colli_pedana,\n" +
|
||||
" NULL AS tipo_variazione,\n" +
|
||||
" NULL AS tipo_promo,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||
" NULL porto,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" NULL AS note_incoterms,\n" +
|
||||
" NULL AS data_rif_scad,\n" +
|
||||
" NULL AS note_carico,\n" +
|
||||
" NULL AS term_cons,\n" +
|
||||
" NULL AS cod_banc,\n" +
|
||||
" NULL AS descr_banc,\n" +
|
||||
" 1 AS flag_primario\n" +
|
||||
" FROM mtb_lisv l\n" +
|
||||
" INNER JOIN listino ON l.cod_mart = listino.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON l.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" CROSS APPLY dbo.getUntMisArticolo(l.cod_mart, l.unt_mis_ven) um\n" +
|
||||
" WHERE l.cod_vlis = @codVlis\n" +
|
||||
" AND listino.tipo_variazione IS NULL\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT vvw_contratti_vendita.cod_mart,\n" +
|
||||
" NULL AS cod_vlis,\n" +
|
||||
" vvw_contratti_vendita.data_iniz,\n" +
|
||||
" vvw_contratti_vendita.data_fine,\n" +
|
||||
" NULL AS da,\n" +
|
||||
" NULL AS a,\n" +
|
||||
" vvw_contratti_vendita.prz_vend,\n" +
|
||||
" ROUND(vvw_contratti_vendita.prz_vend *\n" +
|
||||
" (1 - ISNULL(vvw_contratti_vendita.perc_sco1, 0))\n" +
|
||||
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco2, 0))\n" +
|
||||
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco3, 0))\n" +
|
||||
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco4, 0)),\n" +
|
||||
" 5) AS prz_vend_netto,\n" +
|
||||
" vvw_contratti_vendita.perc_sco1,\n" +
|
||||
" vvw_contratti_vendita.perc_sco2,\n" +
|
||||
" vvw_contratti_vendita.perc_sco3,\n" +
|
||||
" vvw_contratti_vendita.perc_sco4,\n" +
|
||||
" vvw_contratti_vendita.perc_prov,\n" +
|
||||
" vvw_contratti_vendita.qta_residua,\n" +
|
||||
" vvw_contratti_vendita.id_contratto,\n" +
|
||||
" vvw_contratti_vendita.rap_conv,\n" +
|
||||
" vvw_contratti_vendita.note,\n" +
|
||||
" vvw_contratti_vendita.cod_vdes,\n" +
|
||||
" NULL,\n" +
|
||||
" vvw_contratti_vendita.unt_mis_ven,\n" +
|
||||
" NULL,\n" +
|
||||
" NULL,\n" +
|
||||
" 'C' AS tipo_promo,\n" +
|
||||
" vvw_contratti_vendita.cod_paga,\n" +
|
||||
" vvw_contratti_vendita.descrizione_paga AS descr_paga,\n" +
|
||||
" vvw_contratti_vendita.incoterms AS porto,\n" +
|
||||
" mtb_aart.qta_cnf,\n" +
|
||||
" vvw_contratti_vendita.note_incoterms,\n" +
|
||||
" vvw_contratti_vendita.data_rif_scad,\n" +
|
||||
" vvw_contratti_vendita.note_carico,\n" +
|
||||
" vvw_contratti_vendita.term_cons,\n" +
|
||||
" vvw_contratti_vendita.cod_banc,\n" +
|
||||
" vvw_contratti_vendita.descr_banc,\n" +
|
||||
" 1 AS flag_primario\n" +
|
||||
" FROM vvw_contratti_vendita\n" +
|
||||
" INNER JOIN mtb_aart ON vvw_contratti_vendita.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" WHERE vvw_contratti_vendita.cod_anag = @codAnag\n" +
|
||||
" AND (@codVdes IS NULL OR vvw_contratti_vendita.cod_vdes IS NULL OR\n" +
|
||||
" vvw_contratti_vendita.cod_vdes = @codVdes)\n" +
|
||||
" AND (ISNULL(@dataValidita, CAST(GETDATE() AS DATE)) BETWEEN\n" +
|
||||
" vvw_contratti_vendita.data_iniz AND vvw_contratti_vendita.data_fine)\n" +
|
||||
"-- AND vvw_contratti_vendita.qta_residua >= 0\n" +
|
||||
" )\n" +
|
||||
"\n" +
|
||||
" SELECT tmp_lisv.cod_mart,\n" +
|
||||
" ISNULL(maa.cod_mart_anag, tmp_lisv.cod_mart) AS cod_mart_anag,\n" +
|
||||
" cod_vlis,\n" +
|
||||
" data_iniz,\n" +
|
||||
" data_fine,\n" +
|
||||
" da,\n" +
|
||||
" a,\n" +
|
||||
" prz_vend,\n" +
|
||||
" prz_vend_netto,\n" +
|
||||
" perc_sco1,\n" +
|
||||
" perc_sco2,\n" +
|
||||
" perc_sco3,\n" +
|
||||
" perc_sco4,\n" +
|
||||
" perc_prov,\n" +
|
||||
" qta_residua,\n" +
|
||||
" id_contratto,\n" +
|
||||
" rap_conv,\n" +
|
||||
" ISNULL(maa.note, tmp_lisv.note) AS note,\n" +
|
||||
" cod_tcol_ul,\n" +
|
||||
" unt_mis_ven,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN maa.colli_pedana IS NULL OR maa.colli_pedana = 0 THEN tmp_lisv.colli_pedana\n" +
|
||||
" ELSE maa.colli_pedana END AS colli_pedana,\n" +
|
||||
" tipo_variazione,\n" +
|
||||
" tipo_promo,\n" +
|
||||
" cod_paga,\n" +
|
||||
" descr_paga,\n" +
|
||||
" porto,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" CAST(CASE WHEN tmp_lisv.data_iniz IS NULL THEN 0 ELSE 1 END AS BIT) AS art_lisv,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" note_incoterms,\n" +
|
||||
" data_rif_scad,\n" +
|
||||
" note_carico,\n" +
|
||||
" term_cons,\n" +
|
||||
" cod_banc,\n" +
|
||||
" descr_banc,\n" +
|
||||
" flag_primario\n" +
|
||||
" FROM tmp_lisv\n" +
|
||||
" LEFT OUTER JOIN mtb_aart_anag maa\n" +
|
||||
" ON tmp_lisv.cod_mart = maa.cod_mart AND maa.cod_anag = @codAnag)"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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_20251107132252 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("PICKING", "ACCETTAZIONE", "FLAG_VIEW_LOTTO", "N",
|
||||
"In inserimento articolo propone il lotto presente nella riga dell'ordine", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251107150055 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("update ctb_rit_acc set num_cmov_fat = null\n" +
|
||||
"where num_cmov_fat is not null and num_cmov_fat not in (select num_cmov from ctb_movt )\n",
|
||||
"update ctb_rit_acc set num_cmov_paga = null\n" +
|
||||
"where num_cmov_paga is not null and num_cmov_paga not in (select num_cmov from ctb_movt )\n" ,
|
||||
"update ctb_beni set num_cmov_acq = null\n" +
|
||||
"where num_cmov_acq is not null and num_cmov_acq not in (select num_cmov from ctb_movt )\n",
|
||||
"alter table ctb_rit_acc add constraint fk_ctb_rit_acc_ctb_movt_fat foreign key ( num_cmov_fat ) references ctb_movt ( num_cmov )\n" ,
|
||||
"alter table ctb_rit_acc add constraint fk_ctb_rit_acc_ctb_movt_paga foreign key ( num_cmov_paga ) references ctb_movt ( num_cmov )\n" ,
|
||||
"alter table ctb_beni add constraint fk_ctb_beni_ctb_movt foreign key ( num_cmov_acq ) references ctb_movt ( num_cmov )\n" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -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_20251110095557 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("PVM","MRP", "COD_MDEP_PREF", null, "Inserire la lista dei depositi preselezionati per utente",
|
||||
"COD_MDEP", true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
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.utility.UtilityQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20251110100959 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact))
|
||||
return;
|
||||
|
||||
final List<String> duplicatedBarcodes = executeQueryOnlyFirstColumn("SELECT cod_barre\n" +
|
||||
"FROM mtb_aart_bar_code\n" +
|
||||
"GROUP BY cod_barre\n" +
|
||||
"HAVING COUNT(cod_barre) > 1");
|
||||
|
||||
executeStatement("DELETE FROM dbo.mtb_aart_bar_code\n" +
|
||||
"WHERE cod_barre IN (" + UtilityQuery.concatStringFieldsWithSeparator(duplicatedBarcodes, ",") + ")");
|
||||
|
||||
|
||||
executeStatement("ALTER TABLE dbo.mtb_aart_bar_code\n" +
|
||||
" ALTER COLUMN cod_mart VARCHAR(15) NOT NULL",
|
||||
"ALTER TABLE dbo.mtb_aart_bar_code\n" +
|
||||
" ALTER COLUMN cod_barre VARCHAR(40) NOT NULL",
|
||||
"ALTER TABLE dbo.mtb_aart_bar_code\n" +
|
||||
" ADD CONSTRAINT pk_mtb_aart_bar_code\n" +
|
||||
" PRIMARY KEY (cod_mart, cod_barre)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251110104131 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"ALTER TABLE dbo.vtb_viaggi\n" +
|
||||
" ALTER COLUMN note_incoterms VARCHAR(40) NULL;"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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_20251110111625 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createSetupQuery(null, null, "SELECT '1|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa)' UNION SELECT '2|Prezzo netto d''acquisto e ricalcola ricarica (Prezzo di vendita fisso)' UNION SELECT '3|Prezzo netto d''acquisto e prezzo di vendita da prezzo lordo d''acquisto (Ricalcola ricarica)' UNION SELECT '4|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa da Testata listino)' UNION SELECT '5|Prezzo netto d''acquisto, prezzo di vendita e ricarica fissa (Non ricalcolare prezzo)' UNION SELECT '6|Prezzo netto d''acquisto, prezzo di vendita = Prezzo Vendita Suggerito' UNION SELECT '7|Non ricalcolare il prezzo' ");
|
||||
createSetup("VTB_LIST", "LISV4LISA", "CALC_PRZ_BASE", null,
|
||||
"SELEZIONARE IL CRITERIO DI CALCOLO DEL PREZZO BASE", false, null, false, false,
|
||||
false, false, false, null, false, "SELECT '1|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa)' UNION SELECT '2|Prezzo netto d''acquisto e ricalcola ricarica (Prezzo di vendita fisso)' UNION SELECT '3|Prezzo netto d''acquisto e prezzo di vendita da prezzo lordo d''acquisto (Ricalcola ricarica)' UNION SELECT '4|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa da Testata listino)' UNION SELECT '5|Prezzo netto d''acquisto, prezzo di vendita e ricarica fissa (Non ricalcolare prezzo)' UNION SELECT '6|Prezzo netto d''acquisto, prezzo di vendita = Prezzo Vendita Suggerito' UNION SELECT '7|Non ricalcolare il prezzo' ");
|
||||
if (isCustomer(IntegryCustomer.Carelli))
|
||||
updateSetupValue("VTB_LIST", "LISV4LISA", "CALC_PRZ_BASE","1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251110175256 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement("alter table vtb_list add tipo_um tinyint");
|
||||
createOrUpdateFunction("getListinoVendita","CREATE FUNCTION [dbo].[getListinoVendita](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" SELECT vtb_list.cod_vlis,\n" +
|
||||
" vtb_list.descrizione,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tmp_list.max_lisv IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(DATETIME, LEFT(tmp_list.max_lisv, 10)) END AS data_iniz,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN tmp_list.max_lisv IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(INT, RIGHT(tmp_list.max_lisv, 4)) END AS versione,\n" +
|
||||
" vtb_list.cod_divi,\n" +
|
||||
" vtb_list.cambio,\n" +
|
||||
" vtb_list.flag_arr_prz_iva,\n" +
|
||||
" vtb_list.arr_ric,\n" +
|
||||
" vtb_list.flag_list_iva_inclusa,\n" +
|
||||
" vtb_list.flag_lisv_margine,\n" +
|
||||
" vtb_list.flag_add_trasp,\n" +
|
||||
" tmp_list.cod_mart AS 'cod_mart',\n" +
|
||||
" mtb_lisv_data.unt_mis_ven AS unt_mis_ven,\n" +
|
||||
" ISNULL(mtb_lisv_data.rap_conv, 1) AS rap_conv,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_base, 0) AS prz_base,\n" +
|
||||
" ISNULL(mtb_lisv_data.ricarica, 0) AS ricarico,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_vend IS NOT NULL AND mtb_lisv_data.prz_vend <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend, 0) * 100, 2)\n" +
|
||||
" ELSE 0 END AS margine_eff,\n" +
|
||||
" --dbo.f_calcMargineEffettivo(IsNull(mtb_lisv_data.prz_base, 0), IsNull(mtb_lisv_data.prz_vend, 0), mtb_aart.perc_sfrido) as margine_eff,\n" +
|
||||
" --dbo.f_calcRicaricoEffettivo(IsNull(mtb_lisv_data.prz_base, 0), IsNull(mtb_lisv_data.prz_vend, 0), mtb_aart.perc_sfrido) ricarico_eff, \n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_base IS NOT NULL AND mtb_lisv_data.prz_base <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100)) * 100, 2)\n" +
|
||||
" ELSE 0 END AS ricarico_eff,\n" +
|
||||
"\n" +
|
||||
" ISNULL(mtb_lisv_data.magg_prz_vend, 0) AS magg_prz_vend,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend, 0) AS prz_vend,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend_iva, 0) AS prz_vend_iva,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco1, 0) AS perc_sco1,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco2, 0) AS perc_sco2,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco3, 0) AS perc_sco3,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_sco4, 0) AS perc_sco4,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_prov, 0) AS perc_prov,\n" +
|
||||
" ISNULL(mtb_lisv_data.fisso_prov, 0) AS fisso_prov,\n" +
|
||||
" ISNULL(mtb_lisv_data.posizione, '') AS posizione,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_gest, 0) AS perc_gest,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_gest, 0) AS val_gest,\n" +
|
||||
" mtb_lisv_data.data_agg_prz AS data_agg_prz,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_ispe, 0) AS perc_ispe,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_ispe, 0) AS val_ispe,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_promo, 0) AS perc_promo,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_promo, 0) AS val_promo,\n" +
|
||||
" ISNULL(mtb_lisv_data.perc_oneri, 0) AS perc_oneri,\n" +
|
||||
" ISNULL(mtb_lisv_data.val_oneri, 0) AS val_oneri,\n" +
|
||||
" mtb_lisv_data.tipo_variazione AS tipo_variazione,\n" +
|
||||
" mtb_lisv_data.note AS note,\n" +
|
||||
" mtb_lisv_data.aggiornato_da AS aggiornato_da,\n" +
|
||||
" mtb_lisv_data.prz_vend * (1 - mtb_lisv_data.perc_sco1 / 100) * (1 - mtb_lisv_data.perc_sco2 / 100) *\n" +
|
||||
" (1 - mtb_lisv_data.perc_sco3 / 100) *\n" +
|
||||
" (1 - mtb_lisv_data.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ISNULL(mtb_lisv_data.colli_pedana, 0) <> 0 THEN mtb_lisv_data.colli_pedana\n" +
|
||||
" ELSE mtb_aart.colli_pedana END AS colli_pedana,\n" +
|
||||
" mtb_lisv_data.cod_tcol_ul AS cod_tcol_ul,\n" +
|
||||
" mtb_lisv_data.cod_tcol_ui AS cod_tcol_ui,\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend_sug, 0) AS prz_vend_sug,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ISNULL(mtb_lisv_data.qta_cnf, 0) <> 0\n" +
|
||||
" AND dbo.getGestSetup('VTB_LIST', 'SETUP', 'QTA_CNF_LISTINO') = 'S' \n" +
|
||||
" THEN mtb_lisv_data.qta_cnf\n" +
|
||||
" ELSE mtb_aart.qta_cnf / ISNULL(mtb_lisv_data.rap_conv, 1) END AS qta_cnf,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN ISNULL(mtb_lisv_data.colli_strato, 0) <> 0 THEN mtb_lisv_data.colli_strato\n" +
|
||||
" ELSE mtb_aart.colli_strato END AS colli_strato,\n" +
|
||||
" mtb_lisv_data.descrizione_html AS descrizione_html,\n" +
|
||||
" mtb_lisv_data.colli_pedana AS colli_pedana_lisv,\n" +
|
||||
" mtb_lisv_data.qta_cnf AS qta_cnf_lisv,\n" +
|
||||
" mtb_lisv_data.colli_strato AS colli_strato_lisv,\n" +
|
||||
" mtb_lisv_data.sconto_cartoni,\n" +
|
||||
" mtb_lisv_data.sconto_strato,\n" +
|
||||
" mtb_lisv_data.sconto_pedane,\n" +
|
||||
" vtb_list.flag_attivo,\n" +
|
||||
" vtb_list_data.note AS note_testata,\n" +
|
||||
" ISNULL(mtb_lisv_data.flag_prz_bloccato, 'N') AS flag_prz_bloccato,\n" +
|
||||
" vtb_list_data.porto AS porto,\n" +
|
||||
" mtb_lisv_data.system_note,\n" +
|
||||
" mtb_lisv.add_val_spese,\n" +
|
||||
" mtb_lisv.add_ric_spese,\n" +
|
||||
" mtb_lisv.add_sco_spese,\n" +
|
||||
"\t\t\t mtb_aart.flag_incl_listino,\n" +
|
||||
"\t\t\t mtb_lisv.flag_primario,\n" +
|
||||
"\t\t\t mtb_aart.id_art_equi,\n" +
|
||||
"\t\t\t vtb_list.tipo_um\n" +
|
||||
" FROM (SELECT vtb_list.cod_vlis AS cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart,\n" +
|
||||
" MAX(CASE\n" +
|
||||
" WHEN vtb_list_data.versione IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(VARCHAR(10), vtb_list_data.data_iniz, 111) + ' ' +\n" +
|
||||
" REPLICATE('0', 5 - LEN(vtb_list_data.versione)) +\n" +
|
||||
" CONVERT(VARCHAR(5), vtb_list_data.versione) END) AS max_lisv,\n" +
|
||||
" vtb_list.cod_vlis AS 'cod_vlis_rif'\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" INNER JOIN mtb_lisv_data ON vtb_list.cod_vlis = mtb_lisv_data.cod_vlis\n" +
|
||||
" LEFT OUTER JOIN vtb_list_data ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
|
||||
" vtb_list_data.cod_promo IS NULL AND\n" +
|
||||
" vtb_list_data.data_iniz <= ISNULL(@datavalidita, GETDATE())\n" +
|
||||
" WHERE vtb_list.cod_vlis_rif IS NULL\n" +
|
||||
" GROUP BY vtb_list.cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart\n" +
|
||||
" UNION\n" +
|
||||
" SELECT vtb_list.cod_vlis AS cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart,\n" +
|
||||
" MAX(CASE\n" +
|
||||
" WHEN vtb_list_data.versione IS NULL THEN NULL\n" +
|
||||
" ELSE CONVERT(VARCHAR(10), vtb_list_data.data_iniz, 111) + ' ' +\n" +
|
||||
" REPLICATE('0', 5 - LEN(vtb_list_data.versione_rif)) +\n" +
|
||||
" CONVERT(VARCHAR(5), vtb_list_data.versione_rif) END) AS max_lisv,\n" +
|
||||
" vtb_list.cod_vlis_rif AS 'cod_vlis_rif'\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" INNER JOIN vtb_list_data ON vtb_list.cod_vlis = vtb_list_data.cod_vlis\n" +
|
||||
" INNER JOIN vtb_list_data vtb_list_data_rif\n" +
|
||||
" ON vtb_list_data.versione_rif = vtb_list_data_rif.versione AND\n" +
|
||||
" vtb_list_data.cod_vlis_rif = vtb_list_data_rif.cod_vlis\n" +
|
||||
" INNER JOIN mtb_lisv_data ON vtb_list_data_rif.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" vtb_list_data_rif.versione = mtb_lisv_data.versione\n" +
|
||||
"\n" +
|
||||
" WHERE vtb_list_data.data_iniz <= ISNULL(@datavalidita, GETDATE())\n" +
|
||||
" AND vtb_list.cod_vlis_rif IS NOT NULL\n" +
|
||||
" GROUP BY vtb_list.cod_vlis,\n" +
|
||||
" mtb_lisv_data.cod_mart,\n" +
|
||||
" vtb_list.cod_vlis_rif) tmp_list\n" +
|
||||
" INNER JOIN vtb_list ON vtb_list.cod_vlis = tmp_list.cod_vlis\n" +
|
||||
" INNER JOIN mtb_lisv\n" +
|
||||
" ON tmp_list.cod_vlis_rif = mtb_lisv.cod_vlis AND tmp_list.cod_mart = mtb_lisv.cod_mart\n" +
|
||||
" INNER JOIN mtb_aart ON tmp_list.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_lisv_data ON tmp_list.cod_vlis_rif = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" tmp_list.cod_mart = mtb_lisv_data.cod_mart AND\n" +
|
||||
" CONVERT(INT, RIGHT(tmp_list.max_lisv, 5)) = mtb_lisv_data.versione\n" +
|
||||
" LEFT OUTER JOIN vtb_list_data ON tmp_list.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||
" CONVERT(INT, RIGHT(tmp_list.max_lisv, 5)) = vtb_list_data.versione\n" +
|
||||
"\n" +
|
||||
" WHERE (@codmart IS NULL OR tmp_list.cod_mart = @codmart)\n" +
|
||||
" AND (@codvlis IS NULL OR tmp_list.cod_vlis = @codvlis)\n");
|
||||
|
||||
createOrUpdateFunction("getListinoVenditaPedane","CREATE FUNCTION [dbo].[getListinoVenditaPedane](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15), @pedane INT)\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" WITH trasp AS (SELECT mtb_lisv_data_spese.cod_vlis,\n" +
|
||||
" mtb_lisv_data_spese.versione,\n" +
|
||||
" mtb_lisv_data_spese.cod_spes,\n" +
|
||||
" mtb_lisv_data_spese.perc_ricarico,\n" +
|
||||
" mtb_lisv_data_spese.val_ricarico,\n" +
|
||||
" mtb_lisv_data_spese.perc_sconto,\n" +
|
||||
" mtb_lisv_data_spese.da,\n" +
|
||||
" mtb_lisv_data_spese.a\n" +
|
||||
" FROM vtb_list_data\n" +
|
||||
" --riga Sotto Aggiunta da Massimo 08/01/25 per non fare uscire i range pedane quando il prezzo non deve essere addizionato del costo dei trasporti\n" +
|
||||
" --inner join vtb_list on vtb_list_data.cod_vlis = vtb_list.cod_vlis and vtb_list.flag_add_trasp = 1\n" +
|
||||
" INNER JOIN mtb_lisv_data_spese\n" +
|
||||
" ON vtb_list_data.cod_vlis = mtb_lisv_data_spese.cod_vlis AND\n" +
|
||||
" vtb_list_data.versione = mtb_lisv_data_spese.versione\n" +
|
||||
" CROSS APPLY (SELECT MAX(id_listino) AS max_id_listino\n" +
|
||||
" FROM vtb_list_data t\n" +
|
||||
" WHERE t.data_iniz <= ISNULL(@datavalidita, CAST(GETDATE() AS DATE))\n" +
|
||||
" AND vtb_list_data.cod_vlis = t.cod_vlis) max_lisv\n" +
|
||||
" WHERE vtb_list_data.id_listino = max_lisv.max_id_listino)\n" +
|
||||
"\n" +
|
||||
" SELECT list.cod_vlis,\n" +
|
||||
" list.descrizione,\n" +
|
||||
" list.data_iniz,\n" +
|
||||
" list.versione,\n" +
|
||||
" list.cod_divi,\n" +
|
||||
" list.cambio,\n" +
|
||||
" list.flag_arr_prz_iva,\n" +
|
||||
" list.arr_ric,\n" +
|
||||
" list.flag_list_iva_inclusa,\n" +
|
||||
" list.flag_lisv_margine,\n" +
|
||||
" list.flag_add_trasp,\n" +
|
||||
" list.cod_mart,\n" +
|
||||
" list.unt_mis_ven,\n" +
|
||||
" list.rap_conv,\n" +
|
||||
" list.prz_base,\n" +
|
||||
" list.ricarico,\n" +
|
||||
" list.margine_eff,\n" +
|
||||
" list.ricarico_eff,\n" +
|
||||
" list.magg_prz_vend,\n" +
|
||||
" list.prz_vend,\n" +
|
||||
" list.prz_vend_iva,\n" +
|
||||
" list.perc_sco1,\n" +
|
||||
" list.perc_sco2,\n" +
|
||||
" list.perc_sco3,\n" +
|
||||
" list.perc_sco4,\n" +
|
||||
" list.perc_prov,\n" +
|
||||
" list.fisso_prov,\n" +
|
||||
" list.posizione,\n" +
|
||||
" list.perc_gest,\n" +
|
||||
" list.val_gest,\n" +
|
||||
" list.data_agg_prz,\n" +
|
||||
" list.perc_ispe,\n" +
|
||||
" list.val_ispe,\n" +
|
||||
" list.perc_promo,\n" +
|
||||
" list.val_promo,\n" +
|
||||
" list.perc_oneri,\n" +
|
||||
" list.val_oneri,\n" +
|
||||
" list.tipo_variazione,\n" +
|
||||
" list.note,\n" +
|
||||
" list.aggiornato_da,\n" +
|
||||
" list.prz_vend_netto,\n" +
|
||||
" list.colli_pedana,\n" +
|
||||
" list.cod_tcol_ul,\n" +
|
||||
" list.cod_tcol_ui,\n" +
|
||||
" list.prz_vend_sug,\n" +
|
||||
" list.qta_cnf,\n" +
|
||||
" list.colli_strato,\n" +
|
||||
" list.descrizione_html,\n" +
|
||||
" list.colli_pedana_lisv,\n" +
|
||||
" list.qta_cnf_lisv,\n" +
|
||||
" list.colli_strato_lisv,\n" +
|
||||
" list.sconto_cartoni,\n" +
|
||||
" list.sconto_strato,\n" +
|
||||
" list.sconto_pedane,\n" +
|
||||
" list.flag_attivo,\n" +
|
||||
" list.note_testata,\n" +
|
||||
" list.flag_prz_bloccato,\n" +
|
||||
" list.porto,\n" +
|
||||
" list.system_note,\n" +
|
||||
" list.add_val_spese,\n" +
|
||||
" list.add_ric_spese,\n" +
|
||||
" list.add_sco_spese,\n" +
|
||||
" list.flag_incl_listino,\n" +
|
||||
" list.flag_primario,\n" +
|
||||
" list.id_art_equi,\n" +
|
||||
" trasp.cod_spes,\n" +
|
||||
" trasp.perc_ricarico,\n" +
|
||||
" trasp.val_ricarico,\n" +
|
||||
" trasp.perc_sconto,\n" +
|
||||
" trasp.da,\n" +
|
||||
" trasp.a,\n" +
|
||||
" (list.prz_vend +\n" +
|
||||
" IIF(list.flag_add_trasp = 1, --Questa condizione si potrebbe togliere per la modifica fatta l'8/01/25\n" +
|
||||
" ((ISNULL(val_ricarico, 0)) * list.add_val_spese) /\n" +
|
||||
" IIF(ISNULL(list.colli_pedana, 1) = 0, 1, list.colli_pedana), 0)) +\n" +
|
||||
" ((ISNULL(perc_ricarico, 0) * list.add_ric_spese * list.prz_vend) / 100) *\n" +
|
||||
" (1 - (ISNULL(perc_sconto, 0) * list.add_sco_spese) / 100) prz_vend_trasp,\n" +
|
||||
" ((list.prz_vend +\n" +
|
||||
" IIF(list.flag_add_trasp = 1, --Questa condizione si potrebbe togliere per la modifica fatta l'8/01/25\n" +
|
||||
" ((ISNULL(val_ricarico, 0)) * list.add_val_spese) /\n" +
|
||||
" IIF(ISNULL(list.colli_pedana, 1) = 0, 1, list.colli_pedana), 0)) +\n" +
|
||||
" ((ISNULL(perc_ricarico, 0) * list.add_ric_spese * list.prz_vend) / 100) *\n" +
|
||||
" (1 - (ISNULL(perc_sconto, 0) * list.add_sco_spese) / 100)) * (1 - list.perc_sco1 / 100) *\n" +
|
||||
" (1 - list.perc_sco2 / 100) *\n" +
|
||||
" (1 - list.perc_sco3 / 100) *\n" +
|
||||
" (1 - list.perc_sco4 / 100) AS prz_vend_trasp_netto,\n" +
|
||||
"\t\t\t list.tipo_um\n" +
|
||||
" FROM getlistinovendita(@datavalidita, @codvlis, @codmart) list\n" +
|
||||
" LEFT OUTER JOIN trasp ON list.cod_vlis = trasp.cod_vlis AND\n" +
|
||||
" (@pedane IS NULL OR @pedane BETWEEN da AND a OR\n" +
|
||||
" (@pedane IS NOT NULL AND da = 0 AND a = 0))");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.StbGestSetup;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Migration_20251110184508 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
String sql = "SELECT DISTINCT wgsu.gest_name, wgsu.section, wgsu.key_section, 'S' AS flag_setup_user_web\n" +
|
||||
"FROM wtb_gest_setup_user wgsu\n" +
|
||||
"WHERE NOT EXISTS(SELECT sgs.gest_name, sgs.section, sgs.key_section\n" +
|
||||
" FROM stb_gest_setup sgs\n" +
|
||||
" WHERE wgsu.gest_name = sgs.gest_name\n" +
|
||||
" AND wgsu.section = sgs.section\n" +
|
||||
" AND wgsu.key_section = sgs.key_section)";
|
||||
|
||||
List<StbGestSetup> stbGestSetupsToCreate = UtilityDB.executeSimpleQueryDTO(connection, sql, StbGestSetup.class);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(stbGestSetupsToCreate)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (StbGestSetup stbGestSetup : stbGestSetupsToCreate) {
|
||||
stbGestSetup.setOperation(OperationType.INSERT);
|
||||
|
||||
stbGestSetup.manageWithParentConnection(connection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251111110443 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Salpar)){
|
||||
executeStatement("INSERT INTO stb_tipi_indirizzi\n" +
|
||||
"VALUES ('PUNTO VENDITA', 'ABRW'),\n" +
|
||||
" ('PUNTO VENDITA', 'ABTW'),\n" +
|
||||
" ('PUNTO VENDITA', 'BAMW'),\n" +
|
||||
" ('PUNTO VENDITA', 'BATW')");
|
||||
|
||||
executeStatement("UPDATE vtb_clie_pers_rif\n" +
|
||||
"SET tipo_indirizzo = 'PUNTO VENDITA'\n" +
|
||||
"WHERE tipo_indirizzo = 'UFFICIO ACQUISTI'");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251111120322 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction(
|
||||
"pvm_getassortimentoCliente",
|
||||
"CREATE FUNCTION [dbo].[pvm_getassortimentoCliente](\n" +
|
||||
" @codAnag VARCHAR(5), @codVlis VARCHAR(5), @codVdes VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT\n" +
|
||||
")\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN(SELECT cod_mart,\n" +
|
||||
" cod_mart_anag,\n" +
|
||||
" cod_vlis,\n" +
|
||||
" data_iniz,\n" +
|
||||
" data_fine,\n" +
|
||||
" da,\n" +
|
||||
" a,\n" +
|
||||
" prz_vend,\n" +
|
||||
" prz_vend_netto,\n" +
|
||||
" perc_sco1,\n" +
|
||||
" perc_sco2,\n" +
|
||||
" perc_sco3,\n" +
|
||||
" perc_sco4,\n" +
|
||||
" perc_prov,\n" +
|
||||
" qta_residua,\n" +
|
||||
" id_contratto,\n" +
|
||||
" rap_conv,\n" +
|
||||
" note,\n" +
|
||||
" cod_tcol_ul,\n" +
|
||||
" unt_mis_ven,\n" +
|
||||
" colli_pedana,\n" +
|
||||
" tipo_variazione,\n" +
|
||||
" tipo_promo,\n" +
|
||||
" cod_paga,\n" +
|
||||
" descr_paga,\n" +
|
||||
" porto,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" art_lisv,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" note_incoterms,\n" +
|
||||
" data_rif_scad,\n" +
|
||||
" note_carico,\n" +
|
||||
" term_cons,\n" +
|
||||
" cod_banc,\n" +
|
||||
" descr_banc,\n" +
|
||||
" flag_primario\n" +
|
||||
" FROM [dbo].pvm_getassortimentoClientePedane(\n" +
|
||||
" @codAnag, @codVlis, @codVdes, @dataValidita, @viewPromo,\n" +
|
||||
" DEFAULT))"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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_20251111151102 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
|
||||
return;
|
||||
|
||||
createSetup("W_VEDI_DESADV_DLG", "SETUP", "VERSIONE_C2835", "20",
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("W_VEDI_DESADV_DLG", "SETUP", "DTM_C2835", "137",
|
||||
"Qualificatore data ora riferimento (Data documento), per default è impostato a 2", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
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.JtbCiclCq;
|
||||
import it.integry.ems_model.entity._enum.TipoValore;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityInteger;
|
||||
import it.integry.ems_model.utility.UtilityList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20251111170814 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
|
||||
return;
|
||||
|
||||
|
||||
String sql = "select distinct jtb_cicl.cod_prod,MAX(jtb_cicl_cq.num_fase) as num_fase,max(jtb_cicl_cq.id_riga) as id_riga\n" +
|
||||
"from jtb_dist_clav_dir dir\n" +
|
||||
" inner join jtb_cicl on dir.cod_prod = jtb_cicl.cod_prod\n" +
|
||||
" left outer join jtb_cicl_cq on jtb_cicl.cod_prod = jtb_cicl_cq.cod_prod\n" +
|
||||
"where dir.cod_jfas like 'SC%'\n" +
|
||||
" and jtb_cicl.flag_attiva = 'S'\n" +
|
||||
"group by jtb_cicl.cod_prod";
|
||||
|
||||
List<JtbCiclCq> distinteDaAggiornare = UtilityDB.executeSimpleQueryDTO(connection, sql, JtbCiclCq.class);
|
||||
if (UtilityList.isNullOrEmpty(distinteDaAggiornare))
|
||||
return;
|
||||
|
||||
for (JtbCiclCq jtbCiclCq : distinteDaAggiornare) {
|
||||
jtbCiclCq.setIdRiga(UtilityInteger.isNull(jtbCiclCq.getIdRiga(),0) + 1)
|
||||
.setNumFase(UtilityInteger.isNull(jtbCiclCq.getNumFase(),0))
|
||||
.setControllo("Check Etichetta Cartone")
|
||||
.setTipoValore(TipoValore.BOOLEAN)
|
||||
.setValoreRif("S")
|
||||
.setNumRip(0)
|
||||
.setTipologia("DETAILED_CQ")
|
||||
.setOperation(OperationType.INSERT);
|
||||
|
||||
jtbCiclCq.manageWithParentConnection(connection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251111171747 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("lisv_getTipoUm", "CREATE FUNCTION dbo.lisv_getTipoUm\n" +
|
||||
"( \n" +
|
||||
" @codMart varchar(15), @tipoUmLisv tinyint\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE \n" +
|
||||
"AS\n" +
|
||||
"RETURN \n" +
|
||||
"(\n" +
|
||||
" with um as (\n" +
|
||||
"select cod_mart, unt_mis, rap_conv\n" +
|
||||
"from dbo.getUntMisArticolo(@codMart, null ) um\n" +
|
||||
"where @tipoUmLisv is not null\n" +
|
||||
"and ( (@tipoUmLisv = 1 and um.tipo_um = 'UI' ) or \n" +
|
||||
"(@tipoUmLisv = 2 and flag_unita_kg = 'S'))\n" +
|
||||
")\n" +
|
||||
"\n" +
|
||||
"select mtb_aart.cod_mart, \n" +
|
||||
"case \n" +
|
||||
"when @tipoUmLisv IS null then mtb_aart.unt_mis\n" +
|
||||
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf not in (0, 1) then mtb_aart.unt_mis\n" +
|
||||
"when @tipoUmLisv = 2 and mtb_aart.peso_kg not in (0, 1) then mtb_aart.unt_mis\n" +
|
||||
" else ISNULL(um.unt_mis, mtb_aart.unt_mis) end as unt_mis_ven, \n" +
|
||||
"case \n" +
|
||||
"when @tipoUmLisv IS null then 1\n" +
|
||||
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf not in (0, 1) then 1\n" +
|
||||
"when @tipoUmLisv = 2 and mtb_aart.peso_kg not in (0, 1) then 1\n" +
|
||||
" else ISNULL(um.rap_conv, 1) end as rap_conv_vend\n" +
|
||||
"from mtb_aart left outer join um on mtb_aart.cod_mart = um.cod_mart\n" +
|
||||
"where (@codMart is null or mtb_aart.cod_mart = @codMart )\n" +
|
||||
")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251113102040 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE vtb_list_data ADD promo_chiusa bit DEFAULT 0 NOT NULL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251113105159 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("exec sp_rename 'vtb_list_data.promo_chiusa', 'chiusura_immediata'");
|
||||
|
||||
|
||||
createOrUpdateFunction("getPromozioneVendita", "CREATE FUNCTION [dbo].[getPromozioneVendita](@dataIniz DATETIME, @dataFine DATETIME, @codVlis VARCHAR(5),\n" +
|
||||
" @codPromo VARCHAR(10), @codMart VARCHAR(15))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" SELECT vtb_list.cod_vlis,\n" +
|
||||
" vtb_list.descrizione,\n" +
|
||||
" vtb_list_data.data_iniz,\n" +
|
||||
" vtb_list_data.data_fine,\n" +
|
||||
" vtb_list_data.cod_promo,\n" +
|
||||
" vtb_list_data.versione,\n" +
|
||||
" vtb_list.cod_divi,\n" +
|
||||
" vtb_list.flag_arr_prz_iva,\n" +
|
||||
" vtb_list.arr_ric,\n" +
|
||||
" vtb_list.flag_list_iva_inclusa,\n" +
|
||||
" vtb_list.flag_lisv_margine,\n" +
|
||||
" mtb_lisv_data.cod_mart AS cod_mart,\n" +
|
||||
" mtb_lisv_data.unt_mis_ven AS unt_mis_ven,\n" +
|
||||
" mtb_lisv_data.rap_conv AS rap_conv,\n" +
|
||||
" mtb_lisv_data.prz_base AS prz_base,\n" +
|
||||
" mtb_lisv_data.ricarica AS ricarico,\n" +
|
||||
" --dbo.f_calcMargineEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as margine_eff,\n" +
|
||||
" --dbo.f_calcRicaricoEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as ricarico_eff, \n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_vend IS NOT NULL AND mtb_lisv_data.prz_vend <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend, 0) * 100, 2)\n" +
|
||||
" ELSE 0 END AS margine_eff,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_base IS NOT NULL AND mtb_lisv_data.prz_base <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100)) * 100, 2)\n" +
|
||||
" ELSE 0 END AS ricarico_eff,\n" +
|
||||
" mtb_lisv_data.prz_vend AS prz_vend,\n" +
|
||||
" mtb_lisv_data.prz_vend_iva AS prz_vend_iva,\n" +
|
||||
" mtb_lisv_data.perc_sco1 AS perc_sco1,\n" +
|
||||
" mtb_lisv_data.perc_sco2 AS perc_sco2,\n" +
|
||||
" mtb_lisv_data.perc_sco3 AS perc_sco3,\n" +
|
||||
" mtb_lisv_data.perc_sco4 AS perc_sco4,\n" +
|
||||
" mtb_lisv_data.perc_prov AS perc_prov,\n" +
|
||||
" mtb_lisv_data.fisso_prov AS fisso_prov,\n" +
|
||||
" mtb_lisv_data.posizione AS posizione,\n" +
|
||||
" mtb_lisv_data.perc_gest AS perc_gest,\n" +
|
||||
" mtb_lisv_data.val_gest AS val_gest,\n" +
|
||||
" mtb_lisv_data.data_agg_prz AS data_agg_prz,\n" +
|
||||
" mtb_lisv_data.perc_ispe AS perc_ispe,\n" +
|
||||
" mtb_lisv_data.val_ispe AS val_ispe,\n" +
|
||||
" mtb_lisv_data.perc_promo AS perc_promo,\n" +
|
||||
" mtb_lisv_data.val_promo AS val_promo,\n" +
|
||||
" mtb_lisv_data.perc_oneri AS perc_oneri,\n" +
|
||||
" mtb_lisv_data.val_oneri AS val_oneri,\n" +
|
||||
" mtb_lisv_data.tipo_variazione AS tipo_variazione,\n" +
|
||||
" mtb_lisv_data.note AS note,\n" +
|
||||
" mtb_lisv_data.aggiornato_da AS aggiornato_da,\n" +
|
||||
" mtb_lisv_data.prz_vend * (1 - mtb_lisv_data.perc_sco1 / 100) * (1 - mtb_lisv_data.perc_sco2 / 100) *\n" +
|
||||
" (1 - mtb_lisv_data.perc_sco3 / 100) * (1 - mtb_lisv_data.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||
" vtb_promo.descrizione AS 'descr_promo',\n" +
|
||||
" vtb_promo.data_iniz_sell_out,\n" +
|
||||
" vtb_promo.data_fine_sell_out,\n" +
|
||||
" vtb_promo.flag_tipo_promo,\n" +
|
||||
" mtb_lisv_data.sconto_cartoni,\n" +
|
||||
" mtb_lisv_data.sconto_strato,\n" +
|
||||
" mtb_lisv_data.sconto_pedane,\n" +
|
||||
" mtb_lisv_data.giacenza,\n" +
|
||||
" mtb_lisv_data.magg_prz_vend,\n" +
|
||||
" vtb_promo.flag_sconto_contrattuale,\n" +
|
||||
" vtb_promo.intercode_xml_variazioni,\n" +
|
||||
" vtb_list_data.note AS note_testata,\n" +
|
||||
" vtb_promo.flag_tipologia,\n" +
|
||||
" vtb_promo.flag_volantino,\n" +
|
||||
" mtb_lisv_data.inserito_da,\n" +
|
||||
" vtb_list_data.chiusura_immediata\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" INNER JOIN vtb_list_data ON vtb_list.cod_vlis = vtb_list_data.cod_vlis\n" +
|
||||
" INNER JOIN mtb_lisv_data ON vtb_list_data.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" vtb_list_data.versione = mtb_lisv_data.versione\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_lisv_data.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN vtb_promo ON vtb_list_data.cod_promo = vtb_promo.cod_promo\n" +
|
||||
" OUTER APPLY (SELECT COUNT(*) AS conta\n" +
|
||||
" FROM vtb_list_data rif\n" +
|
||||
" WHERE vtb_list_data.cod_vlis = rif.cod_vlis_rif\n" +
|
||||
" AND vtb_list_data.versione = rif.versione) list_rif\n" +
|
||||
" WHERE (@codMart IS NULL OR mtb_lisv_data.cod_mart = @codMart)\n" +
|
||||
" AND (@codvlis IS NULL OR vtb_list_data.cod_vlis = @codVlis)\n" +
|
||||
" AND vtb_list.cod_vlis_rif IS NULL\n" +
|
||||
" AND (@codPromo IS NULL OR vtb_list_data.cod_promo = @codPromo)\n" +
|
||||
" AND (((@dataFine IS NULL OR ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) = @dataFine) AND\n" +
|
||||
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine) OR\n" +
|
||||
" (@dataFine IS NOT NULL AND ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) <> @dataFine AND\n" +
|
||||
" (vtb_list_data.data_iniz BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||
" vtb_list_data.data_fine BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine OR\n" +
|
||||
" @dataFine BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine)))\n" +
|
||||
" AND (vtb_promo.flag_sconto_contrattuale = 'N' OR\n" +
|
||||
" (vtb_promo.flag_sconto_contrattuale = 'S' AND list_rif.conta = 0))\n" +
|
||||
" UNION\n" +
|
||||
" SELECT vtb_list.cod_vlis,\n" +
|
||||
" vtb_list.descrizione,\n" +
|
||||
" vtb_list_data.data_iniz,\n" +
|
||||
" vtb_list_data.data_fine,\n" +
|
||||
" vtb_list_data.cod_promo,\n" +
|
||||
" vtb_list_data.versione,\n" +
|
||||
" vtb_list.cod_divi,\n" +
|
||||
" vtb_list.flag_arr_prz_iva,\n" +
|
||||
" vtb_list.arr_ric,\n" +
|
||||
" vtb_list.flag_list_iva_inclusa,\n" +
|
||||
" vtb_list.flag_lisv_margine,\n" +
|
||||
" mtb_lisv_data.cod_mart AS cod_mart,\n" +
|
||||
" mtb_lisv_data.unt_mis_ven AS unt_mis_ven,\n" +
|
||||
" mtb_lisv_data.rap_conv AS rap_conv,\n" +
|
||||
" mtb_lisv_data.prz_base AS prz_base,\n" +
|
||||
" mtb_lisv_data.ricarica AS ricarico,\n" +
|
||||
" --dbo.f_calcMargineEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as margine_eff,\n" +
|
||||
" --dbo.f_calcRicaricoEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as ricarico_eff, \n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_vend IS NOT NULL AND mtb_lisv_data.prz_vend <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" ISNULL(mtb_lisv_data.prz_vend, 0) * 100, 2)\n" +
|
||||
" ELSE 0 END AS margine_eff,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_lisv_data.prz_base IS NOT NULL AND mtb_lisv_data.prz_base <> 0 THEN\n" +
|
||||
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100)) * 100, 2)\n" +
|
||||
" ELSE 0 END AS ricarico_eff,\n" +
|
||||
" mtb_lisv_data.prz_vend AS prz_vend,\n" +
|
||||
" mtb_lisv_data.prz_vend_iva AS prz_vend_iva,\n" +
|
||||
" mtb_lisv_data.perc_sco1 AS perc_sco1,\n" +
|
||||
" mtb_lisv_data.perc_sco2 AS perc_sco2,\n" +
|
||||
" mtb_lisv_data.perc_sco3 AS perc_sco3,\n" +
|
||||
" mtb_lisv_data.perc_sco4 AS perc_sco4,\n" +
|
||||
" mtb_lisv_data.perc_prov AS perc_prov,\n" +
|
||||
" mtb_lisv_data.fisso_prov AS fisso_prov,\n" +
|
||||
" mtb_lisv_data.posizione AS posizione,\n" +
|
||||
" mtb_lisv_data.perc_gest AS perc_gest,\n" +
|
||||
" mtb_lisv_data.val_gest AS val_gest,\n" +
|
||||
" mtb_lisv_data.data_agg_prz AS data_agg_prz,\n" +
|
||||
" mtb_lisv_data.perc_ispe AS perc_ispe,\n" +
|
||||
" mtb_lisv_data.val_ispe AS val_ispe,\n" +
|
||||
" mtb_lisv_data.perc_promo AS perc_promo,\n" +
|
||||
" mtb_lisv_data.val_promo AS val_promo,\n" +
|
||||
" mtb_lisv_data.perc_oneri AS perc_oneri,\n" +
|
||||
" mtb_lisv_data.val_oneri AS val_oneri,\n" +
|
||||
" mtb_lisv_data.tipo_variazione AS tipo_variazione,\n" +
|
||||
" mtb_lisv_data.note AS note,\n" +
|
||||
" mtb_lisv_data.aggiornato_da AS aggiornato_da,\n" +
|
||||
" mtb_lisv_data.prz_vend * (1 - mtb_lisv_data.perc_sco1 / 100) * (1 - mtb_lisv_data.perc_sco2 / 100) *\n" +
|
||||
" (1 - mtb_lisv_data.perc_sco3 / 100) * (1 - mtb_lisv_data.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||
" vtb_promo.descrizione AS 'descr_promo',\n" +
|
||||
" vtb_promo.data_iniz_sell_out,\n" +
|
||||
" vtb_promo.data_fine_sell_out,\n" +
|
||||
" vtb_promo.flag_tipo_promo,\n" +
|
||||
" mtb_lisv_data.sconto_cartoni,\n" +
|
||||
" mtb_lisv_data.sconto_strato,\n" +
|
||||
" mtb_lisv_data.sconto_pedane,\n" +
|
||||
" mtb_lisv_data.giacenza,\n" +
|
||||
" mtb_lisv_data.magg_prz_vend,\n" +
|
||||
" vtb_promo.flag_sconto_contrattuale,\n" +
|
||||
" vtb_promo.intercode_xml_variazioni,\n" +
|
||||
" vtb_list_data.note AS note_testata,\n" +
|
||||
" vtb_promo.flag_tipologia,\n" +
|
||||
" vtb_promo.flag_volantino,\n" +
|
||||
" mtb_lisv_data.inserito_da,\n" +
|
||||
" vtb_list_data_rif.chiusura_immediata\n" +
|
||||
" FROM vtb_list\n" +
|
||||
" INNER JOIN vtb_list_data ON vtb_list.cod_vlis = vtb_list_data.cod_vlis\n" +
|
||||
" INNER JOIN vtb_list_data vtb_list_data_rif\n" +
|
||||
" ON vtb_list_data.cod_vlis_rif = vtb_list_data_rif.cod_vlis AND\n" +
|
||||
" vtb_list_data.versione_rif = vtb_list_data_rif.versione\n" +
|
||||
" INNER JOIN mtb_lisv_data ON vtb_list_data_rif.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||
" vtb_list_data_rif.versione = mtb_lisv_data.versione\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_lisv_data.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN vtb_promo ON vtb_list_data_rif.cod_promo = vtb_promo.cod_promo\n" +
|
||||
" WHERE (@codMart IS NULL OR mtb_lisv_data.cod_mart = @codMart)\n" +
|
||||
" AND (@codvlis IS NULL OR vtb_list_data.cod_vlis = @codVlis)\n" +
|
||||
" AND (@codPromo IS NULL OR vtb_list_data.cod_promo = @codPromo)\n" +
|
||||
" AND (((@dataFine IS NULL OR ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) = @dataFine) AND\n" +
|
||||
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine) OR\n" +
|
||||
" (@dataFine IS NOT NULL AND ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) <> @dataFine AND\n" +
|
||||
" (vtb_list_data.data_iniz BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||
" vtb_list_data.data_fine BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine OR\n" +
|
||||
" @dataFine BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine)))");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251113122313 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("lisv_getTipoUm", "CREATE FUNCTION [dbo].[lisv_getTipoUm]\n" +
|
||||
"(\t\n" +
|
||||
"\t@codMart varchar(15), @tipoUmLisv tinyint\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE \n" +
|
||||
"AS\n" +
|
||||
"RETURN \n" +
|
||||
"(\n" +
|
||||
"\twith um as (\n" +
|
||||
"select cod_mart, unt_mis, rap_conv\n" +
|
||||
"from dbo.getUntMisArticolo(@codMart, null ) um\n" +
|
||||
"where @tipoUmLisv is not null\n" +
|
||||
"and ( (@tipoUmLisv = 1 and um.tipo_um = 'UI' ) or \n" +
|
||||
"(@tipoUmLisv = 2 and flag_unita_kg = 'S'))\n" +
|
||||
")\n" +
|
||||
"\n" +
|
||||
"select mtb_aart.cod_mart, \n" +
|
||||
"case \n" +
|
||||
"when @tipoUmLisv IS null then mtb_aart.unt_mis\n" +
|
||||
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf in (0, 1) then mtb_aart.unt_mis\n" +
|
||||
"when @tipoUmLisv = 2 and mtb_aart.peso_kg in (0, 1) then mtb_aart.unt_mis\n" +
|
||||
"\telse ISNULL(um.unt_mis, mtb_aart.unt_mis) end as unt_mis_ven, \n" +
|
||||
"case \n" +
|
||||
"when @tipoUmLisv IS null then 1\n" +
|
||||
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf in (0, 1) then 1\n" +
|
||||
"when @tipoUmLisv = 2 and mtb_aart.peso_kg in (0, 1) then 1\n" +
|
||||
"\telse ISNULL(um.rap_conv, 1) end as rap_conv_vend\n" +
|
||||
"from mtb_aart left outer join um on mtb_aart.cod_mart = um.cod_mart\n" +
|
||||
"where (@codMart is null or mtb_aart.cod_mart = @codMart )\n" +
|
||||
")");
|
||||
|
||||
executeStatement("alter table mtb_var_lisv_log alter column versione int null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251113170159 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE wdtb_doct ADD merce_ricevuta BIT DEFAULT 0 NOT NULL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -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_20251114114334 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
executeStatement("ALTER TABLE ctb_amac DROP COLUMN cod_mdep;");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251114150912 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE jtb_comt ADD data_mod DATETIME");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -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_20251114163222 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE vtb_dest ADD data_mod DATETIME");
|
||||
executeStatement("ALTER TABLE ptb_pros ADD data_mod DATETIME");
|
||||
executeStatement("ALTER TABLE ptb_pros_rif ADD data_mod DATETIME");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251117142928 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("W_jriep_presenze_dip_disp", "SETUP", "SET_DATA_FINE", "N",
|
||||
"imposta data fine = fine mese", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||
|
||||
if (isCustomer(IntegryCustomer.Integry))
|
||||
updateSetupValue("W_jriep_presenze_dip_disp", "SETUP", "SET_DATA_FINE", "S");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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_20251117170957 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
|
||||
return;
|
||||
|
||||
executeStatement("update stb_gest_setup set value = 'S' where gest_name = 'DTB_ORDT' and key_section in ('NUOVA_PROCEDURA','DISABLE_TRIGGER_ORDL')");
|
||||
executeStatement("update stb_gest_sync set syncronize = 'R' where gest_name like 'lord%'");
|
||||
executeStatement("update stb_gest_sync set syncronize = 'R' where gest_name like 'pord%'");
|
||||
executeStatement("insert into stb_abil \n" +
|
||||
"select case when gest_name = 'lordi' then 'LG081' else 'AG031' end , user_name, 'S', case when gest_name = 'lordi' then 'lordi_tab' else 'pordi_tab' end from stb_abil \n" +
|
||||
"where gest_name in ('lordi','pordi') and case when gest_name = 'lordi' then 'LG081' else 'AG031' end + user_name not in (select cod_opz + user_name from stb_abil where cod_opz in ('LG081','AG031'))");
|
||||
executeStatement("update stb_abil set flag_abil = 'N' where gest_name in ('lordi','pordi')");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration.dto.MigrationStatusDTO;
|
||||
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.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -46,14 +46,14 @@ public class MigrationSetupService {
|
||||
|
||||
final List<MigrationStatusDTO> migrationStatuses = new ArrayList<>();
|
||||
|
||||
final List<AvailableConnectionsModel> databases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
final List<AvailableConnectionModel> databases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
for (AvailableConnectionsModel availableConnectionsModel : databases) {
|
||||
if (IntegryCustomer.getFromDB(IntegryCustomerDB.parse(availableConnectionsModel.getDbName())) == IntegryCustomer.Integry &&
|
||||
for (AvailableConnectionModel availableConnectionModel : databases) {
|
||||
if (IntegryCustomer.getFromDB(IntegryCustomerDB.parse(availableConnectionModel.getDbName())) == IntegryCustomer.Integry &&
|
||||
UtilityDebug.isDebugExecution())
|
||||
continue;
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(availableConnectionsModel)) {
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(availableConnectionModel)) {
|
||||
List<StbMigrationStatus> stbMigrationStatuses = retrieveStatuses(multiDBTransactionManager);
|
||||
|
||||
if (stbMigrationStatuses == null) {
|
||||
@@ -88,7 +88,7 @@ public class MigrationSetupService {
|
||||
migrationStatuses.add(new MigrationStatusDTO()
|
||||
.setStatus(status)
|
||||
.setMigrationCode(migrationCode)
|
||||
.setProfileDb(availableConnectionsModel.getProfileName())
|
||||
.setProfileDb(availableConnectionModel.getProfileName())
|
||||
.setErrorMessage(errorMessage));
|
||||
|
||||
}
|
||||
@@ -132,11 +132,11 @@ public class MigrationSetupService {
|
||||
|
||||
|
||||
public void executeAll() throws Exception {
|
||||
for (AvailableConnectionsModel availableConnectionsModel : settingsModel.getAvailableConnections(true)) {
|
||||
for (AvailableConnectionModel availableConnectionModel : settingsModel.getAvailableConnections(true)) {
|
||||
if (multiDBTransactionManager.getActiveConnections().stream()
|
||||
.noneMatch(connection ->
|
||||
connection.getDbName().equalsIgnoreCase(availableConnectionsModel.getDbName()))) {
|
||||
multiDBTransactionManager.addConnection(availableConnectionsModel);
|
||||
connection.getDbName().equalsIgnoreCase(availableConnectionModel.getDbName()))) {
|
||||
multiDBTransactionManager.addConnection(availableConnectionModel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AccountingBusinessLogic {
|
||||
.setCodAnag(ctbMovt.getCodAnag())
|
||||
.setCodVage(ctbMovt.getCodVage())
|
||||
.setAnnoPart(annoPart)
|
||||
.setDataDoc(ctbMovt.getDataDoc())
|
||||
.setDataDoc(UtilityLocalDate.localDateFromDate(ctbMovt.getDataDoc()))
|
||||
.setSerDoc(ctbMovt.getSerDoc())
|
||||
.setNumDoc(ctbMovt.getNumDoc())
|
||||
.setCodDiviCont(ctbMovt.getCodDiviCont())
|
||||
@@ -120,7 +120,7 @@ public class AccountingBusinessLogic {
|
||||
"Convert(numeric(20,5), importo_enasarco * cambio_divi_cont) as importo_enasarco " +
|
||||
" FROM ctb_rit_acc " +
|
||||
" WHERE num_cmov_fat = " + UtilityDB.valueToString(testata.getNumCmov()) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueDateToString(testata.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" data_doc = " + UtilityDB.valueToString(testata.getDataDoc()) + " AND " +
|
||||
" ser_doc = " + UtilityDB.valueToString(testata.getSerDoc()) + " AND " +
|
||||
" num_doc = " + UtilityDB.valueToString(testata.getNumDoc());
|
||||
|
||||
@@ -142,7 +142,7 @@ public class AccountingBusinessLogic {
|
||||
.setAnnoPart(annoPart)
|
||||
.setSerDoc(testata.getSerDoc())
|
||||
.setNumDoc(testata.getNumDoc())
|
||||
.setDataScad(testata.getDataDoc());
|
||||
.setDataScad(UtilityLocalDate.localDateFromDate(testata.getDataDoc()));
|
||||
if (testata.getTipoPartitaEnum() == TipoPartita.ATTIVA) {
|
||||
ctbScad.setImpDare(ritenuta);
|
||||
ctbScad.setImpAvere(BigDecimal.ZERO);
|
||||
@@ -166,7 +166,7 @@ public class AccountingBusinessLogic {
|
||||
.setAnnoPart(annoPart)
|
||||
.setSerDoc(testata.getSerDoc())
|
||||
.setNumDoc(testata.getNumDoc())
|
||||
.setDataScad(testata.getDataDoc());
|
||||
.setDataScad(UtilityLocalDate.localDateFromDate(testata.getDataDoc()));
|
||||
if (testata.getTipoPartitaEnum() == TipoPartita.ATTIVA) {
|
||||
ctbScad.setImpDare(enasarco);
|
||||
ctbScad.setImpAvere(BigDecimal.ZERO);
|
||||
@@ -413,10 +413,17 @@ public class AccountingBusinessLogic {
|
||||
}
|
||||
|
||||
public static BigDecimal pagaScadenze(Date dataCmov, BigDecimal residuo, List<CtbScad> elencoScadenze) {
|
||||
return pagaScadenze(dataCmov, residuo, elencoScadenze, null);
|
||||
return pagaScadenze(UtilityLocalDate.localDateFromDate(dataCmov), residuo, elencoScadenze, null);
|
||||
}
|
||||
|
||||
public static BigDecimal pagaScadenze(Date dataCmov, BigDecimal residuo, List<CtbScad> elencoScadenze, Integer idRigaMov) {
|
||||
return pagaScadenze(UtilityLocalDate.localDateFromDate(dataCmov), residuo, elencoScadenze, idRigaMov);
|
||||
}
|
||||
|
||||
public static BigDecimal pagaScadenze(LocalDate dataCmov, BigDecimal residuo, List<CtbScad> elencoScadenze) {
|
||||
return pagaScadenze(dataCmov, residuo, elencoScadenze, null);
|
||||
}
|
||||
public static BigDecimal pagaScadenze(LocalDate dataCmov, BigDecimal residuo, List<CtbScad> elencoScadenze, Integer idRigaMov) {
|
||||
long countScad =
|
||||
Stream.of(elencoScadenze)
|
||||
.distinctBy(x ->
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class AccountingRules extends QueryRules {
|
||||
@@ -182,7 +183,7 @@ public class AccountingRules extends QueryRules {
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codBiva)) {
|
||||
for (CtbMovi ctbMovi : ctbMovt.getCtbMovi()) {
|
||||
if (UtilityString.isNullOrEmpty(ctbMovi.getCodBiva())) {
|
||||
if (UtilityString.isNullOrEmpty(ctbMovi.getCodBiva()) && !ctbMovi.getCodBiva().equalsIgnoreCase(EmsRestConstants.NULL)) {
|
||||
ctbMovi.setCodBiva(codBiva);
|
||||
}
|
||||
movi.add(ctbMovi);
|
||||
@@ -390,7 +391,7 @@ public class AccountingRules extends QueryRules {
|
||||
.setCodAnag(ctbMovt.getCodAnag())
|
||||
.setCodVage(ctbMovt.getCodVage())
|
||||
.setAnnoPart(annoPart)
|
||||
.setDataDoc(ctbMovt.getDataDoc())
|
||||
.setDataDoc(UtilityLocalDate.localDateFromDate(ctbMovt.getDataDoc()))
|
||||
.setSerDoc(ctbMovt.getSerDoc())
|
||||
.setNumDoc(ctbMovt.getNumDoc())
|
||||
.setCodDiviCont(ctbMovt.getCodDiviCont())
|
||||
@@ -605,19 +606,6 @@ public class AccountingRules extends QueryRules {
|
||||
BigDecimal impDare = BigDecimal.ZERO;
|
||||
BigDecimal impAvere = BigDecimal.ZERO;
|
||||
|
||||
// if (UtilityBigDecimal.greaterThan(ctbMovr.getImpDare(), BigDecimal.ZERO)) {
|
||||
// if (ctbScad.getImpDare() == null)
|
||||
// impDare = ctbMovr.getImpDare();
|
||||
// else
|
||||
// impDare = ctbScad.getImpDare().divide(cambioScad, 5, RoundingMode.HALF_UP);
|
||||
// }
|
||||
// if (UtilityBigDecimal.greaterThan(ctbMovr.getImpAvere(), BigDecimal.ZERO)) {
|
||||
// if (ctbScad.getImpAvere() == null)
|
||||
// impAvere = ctbMovr.getImpAvere();
|
||||
// else
|
||||
// impAvere = ctbScad.getImpAvere().divide(cambioScad).setScale(5, RoundingMode.HALF_UP);
|
||||
// }
|
||||
|
||||
Boolean riperta = ctbScad.getRiaperta() == null ? false : ctbScad.getRiaperta();
|
||||
if (tipoPartita == 0 || (riperta && tipoPartita == 1)) {
|
||||
if (ctbScad.getImpDare() == null)
|
||||
@@ -671,7 +659,7 @@ public class AccountingRules extends QueryRules {
|
||||
.setAnnoPart(ctbScad.getAnnoPart())
|
||||
.setSerDoc(ctbScad.getSerDoc())
|
||||
.setNumDoc(ctbScad.getNumDoc())
|
||||
.setDataCmov(ctbMovr.getDataCmov())
|
||||
.setDataCmov(UtilityLocalDate.localDateFromDate(ctbMovr.getDataCmov()))
|
||||
.setIdRiga(ctbMovr.getIdRiga())
|
||||
.setImpDare(impDare)
|
||||
.setImpAvere(impAvere)
|
||||
@@ -749,7 +737,7 @@ public class AccountingRules extends QueryRules {
|
||||
.setAnnoPart(ctbMovr.getAnnoPart())
|
||||
.setSerDoc(ctbMovr.getSerDoc())
|
||||
.setNumDoc(ctbMovr.getNumDoc())
|
||||
.setDataCmov(ctbMovr.getDataCmov())
|
||||
.setDataCmov(UtilityLocalDate.localDateFromDate(ctbMovr.getDataCmov()))
|
||||
.setIdRiga(ctbMovr.getIdRiga())
|
||||
.setImpDare(ctbMovr.getImpDare())
|
||||
.setImpAvere(ctbMovr.getImpAvere())
|
||||
@@ -976,18 +964,16 @@ public class AccountingRules extends QueryRules {
|
||||
public static CtbMovt completeScadRitAcc(Connection conn, CtbRitAcc ctbRitAcc) throws Exception {
|
||||
String sql =
|
||||
"SELECT count(*) as count_partita " +
|
||||
" FROM ctb_part inner join ctb_parr on ctb_part.tipo_anag = ctb_parr.tipo_anag and " +
|
||||
"ctb_part.cod_anag = ctb_parr.cod_anag and " +
|
||||
"ctb_part.anno_part = ctb_parr.anno_part and " +
|
||||
"ctb_part.ser_doc = ctb_parr.ser_doc and " +
|
||||
"ctb_part.num_doc = ctb_parr.num_doc " +
|
||||
" WHERE ctb_parr.num_cmov = " + UtilityDB.valueToString(ctbRitAcc.getNumCmovFat()) + " AND " +
|
||||
" ( ctb_part.dare_part = 0 or ctb_part.avere_part = 0 ) ";
|
||||
" FROM ctb_part inner join ctb_parr on ctb_part.tipo_anag = ctb_parr.tipo_anag and " +
|
||||
"ctb_part.cod_anag = ctb_parr.cod_anag and " +
|
||||
"ctb_part.anno_part = ctb_parr.anno_part and " +
|
||||
"ctb_part.ser_doc = ctb_parr.ser_doc and " +
|
||||
"ctb_part.num_doc = ctb_parr.num_doc " +
|
||||
" WHERE ctb_parr.num_cmov = " + UtilityDB.valueToString(ctbRitAcc.getNumCmovFat());
|
||||
|
||||
Integer countPart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
if (countPart > 0) {
|
||||
|
||||
if (countPart <= 1) {
|
||||
CtbMovt ctbMovt = new CtbMovt();
|
||||
ctbMovt.setNumCmov(ctbRitAcc.getNumCmovFat());
|
||||
ctbMovt.setGeneraScad(ctbRitAcc.getGeneraScadenze());
|
||||
@@ -1003,7 +989,7 @@ public class AccountingRules extends QueryRules {
|
||||
for (CtbScad ctbScad : ctbMovt.getCtbScad()) {
|
||||
ctbScad.setTipoAnag(UtilityString.isNullOrEmpty(ctbScad.getTipoAnag()) ? ctbMovt.getTipoAnag() : ctbScad.getTipoAnag());
|
||||
ctbScad.setCodAnag(UtilityString.isNullOrEmpty(ctbScad.getCodAnag()) ? ctbMovt.getCodAnag() : ctbScad.getCodAnag());
|
||||
ctbScad.setDataDoc(UtilityString.isNullOrEmpty(ctbScad.getDataDoc()) ? ctbMovt.getDataDoc() : ctbScad.getDataDoc());
|
||||
ctbScad.setDataDoc(UtilityLocalDate.isNull(ctbScad.getDataDoc(), UtilityLocalDate.localDateFromDate(ctbMovt.getDataDoc())));
|
||||
ctbScad.setSerDoc(UtilityString.isNullOrEmpty(ctbScad.getSerDoc()) ? ctbMovt.getSerDoc() : ctbScad.getSerDoc());
|
||||
ctbScad.setNumDoc(UtilityString.isNullOrEmpty(ctbScad.getNumDoc()) ? ctbMovt.getNumDoc() : ctbScad.getNumDoc());
|
||||
Integer annoPart = Integer.parseInt(new SimpleDateFormat("yyyy").format(ctbMovt.getDataDoc()));
|
||||
@@ -1140,5 +1126,16 @@ public class AccountingRules extends QueryRules {
|
||||
}
|
||||
return ventilazione;
|
||||
}
|
||||
|
||||
public static void checkRigaMovCtbParr( CtbMovt ctbMovt) {
|
||||
List<CtbMovr> row = ctbMovt.getCtbMovr().stream()
|
||||
.filter(x -> x.getCtbScad() != null && x.getCtbScad().size() > 0)
|
||||
.collect(Collectors.toList());
|
||||
for(CtbMovr r : row) {
|
||||
r.getCtbScad()
|
||||
.forEach(scad -> {scad.getCrlScadParr()
|
||||
.stream()
|
||||
.filter(x->x.getIdRigaMov() != r.getIdRiga())
|
||||
.forEach(x->x.setIdRigaMov(r.getIdRiga()));});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@ import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity._enum.ListinoEnum;
|
||||
import it.integry.ems_model.entity.common.DtbBaseDocR;
|
||||
import it.integry.ems_model.entity.common.DtbDocOrdR;
|
||||
import it.integry.ems_model.entity.common.DtbDocOrdT;
|
||||
@@ -674,7 +675,11 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
if ("A".equals(gestione)) {
|
||||
costo = DocumentRules.completeCostoUntDocA(conn, ((DtbDocr) row));
|
||||
} else if ("L".equals(gestione)) {
|
||||
costo = DocumentRules.completeCostoUntDocL(conn, ((DtbDocr) row), flagValCosto);
|
||||
if (testata.getListino().equalsIgnoreCase(ListinoEnum.COSTO_ULTIMO.getValue()) && !UtilityBigDecimal.isNullOrZero(row.getValUnt())) {
|
||||
costo = row.getValUnt();
|
||||
} else {
|
||||
costo = DocumentRules.completeCostoUntDocL(conn, ((DtbDocr) row), flagValCosto);
|
||||
}
|
||||
}
|
||||
((DtbDocr) row).setCostoUnt(costo);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package it.integry.ems.rules.completing;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
import it.integry.ems_model.entity.MtbCols;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.entity.MtbPartitaMag;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
|
||||
@@ -255,7 +255,7 @@ public class PackagesRules extends QueryRules {
|
||||
int cifreDec;
|
||||
if (UtilityString.isNullOrEmpty(flagQtaCnfFissa)) {
|
||||
throw new Exception(String.format("Articolo %s non trovato", mtbColr.getCodMart()));
|
||||
}else if (flagQtaCnfFissa.equalsIgnoreCase("S")) {
|
||||
} else if (flagQtaCnfFissa.equalsIgnoreCase("S")) {
|
||||
cifreDec = EmsRestConstants.cifreDecMax;
|
||||
} else {
|
||||
cifreDec = 0;
|
||||
@@ -331,23 +331,28 @@ public class PackagesRules extends QueryRules {
|
||||
return datiOrd;
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> calcPeso(Connection conn, MtbColr entity) throws Exception {
|
||||
String sql = "select cifre_dec from mtb_unt_mis where flag_unita_kg = 'S'";
|
||||
BigDecimal cifreDec = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
public static HashMap<String, Object> calcPeso(IntegryCustomerDB customerDB, Connection conn, MtbColr entity) throws Exception {
|
||||
|
||||
if ( cifreDec == null ) { cifreDec = BigDecimal.valueOf(5); }
|
||||
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||
|
||||
sql =
|
||||
"SELECT mtb_aart.unt_mis, " +
|
||||
" mtb_aart.tara_kg, " +
|
||||
" mtb_aart.peso_kg, " +
|
||||
" case when mtb_aart.flag_peso_egalizzato = 1 THEN mtb_aart.qta_cnf ELSE 1 END * mtb_aart.peso_kg as 'peso_egalizzato', " +
|
||||
" mtb_unt_mis.flag_unita_kg, " +
|
||||
" mtb_aart.flag_peso_egalizzato " +
|
||||
" FROM mtb_aart INNER JOIN mtb_unt_mis ON mtb_aart.unt_mis = mtb_unt_mis.unt_mis " +
|
||||
" WHERE mtb_aart.cod_mart = " + UtilityDB.valueToString(entity.getCodMart());
|
||||
BigDecimal cifreDec = entityCacheComponent.<MtbUntMis>getCachedEntitiesStream(customerDB, MtbUntMis.ENTITY,
|
||||
x -> x.getFlagUnitaKg().equalsIgnoreCase("S"))
|
||||
.map(MtbUntMis::getCifreDec)
|
||||
.findFirst()
|
||||
.orElse(BigDecimal.valueOf(5));
|
||||
|
||||
HashMap<String, Object> anagArt = entityCacheComponent.<MtbAart>getCachedEntitiesStream(customerDB, MtbAart.ENTITY,
|
||||
x -> x.getCodMart().equalsIgnoreCase(entity.getCodMart()))
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("unt_mis", x.getUntMis());
|
||||
put("tara_kg", x.getTaraKg());
|
||||
put("peso_kg", x.getPesoKg());
|
||||
put("flag_peso_egalizzato", x.getFlagPesoEgalizzato());
|
||||
put("peso_egalizzato", x.getFlagPesoEgalizzato() ? x.getQtaCnf().multiply(x.getPesoKg()) : null);
|
||||
}})
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
HashMap<String, Object> queryResults = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
|
||||
|
||||
MtbColr originalEntity = ((MtbColr) entity.getOriginalEntity());
|
||||
if (originalEntity != null && originalEntity.getPesoNettoKg() != null && originalEntity.getPesoLordoKg() != null) {
|
||||
@@ -359,12 +364,17 @@ public class PackagesRules extends QueryRules {
|
||||
}
|
||||
|
||||
BigDecimal pesoNetto = BigDecimal.ZERO, pesoLordo = BigDecimal.ZERO;
|
||||
if (queryResults != null) {
|
||||
BigDecimal taraKg = (BigDecimal) queryResults.get("tara_kg");
|
||||
BigDecimal pesoKg = (BigDecimal) queryResults.get("peso_kg");
|
||||
String flagUnitaKg = (String) queryResults.get("flag_unita_kg");
|
||||
BigDecimal pesoKGEgalizzato = (BigDecimal) queryResults.get("peso_egalizzato");
|
||||
Boolean pesoEgalizzato = (Boolean) queryResults.get("flag_peso_egalizzato");
|
||||
if (anagArt != null) {
|
||||
String flagUnitaKg = entityCacheComponent.<MtbUntMis>getCachedEntitiesStream(customerDB, MtbUntMis.ENTITY,
|
||||
x -> x.getUntMis().equalsIgnoreCase(String.valueOf(anagArt.get("unt_mis"))))
|
||||
.map(MtbUntMis::getFlagUnitaKg)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
BigDecimal taraKg = (BigDecimal) anagArt.get("tara_kg");
|
||||
BigDecimal pesoKg = (BigDecimal) anagArt.get("peso_kg");
|
||||
BigDecimal pesoKGEgalizzato = (BigDecimal) anagArt.get("peso_egalizzato");
|
||||
Boolean pesoEgalizzato = (Boolean) anagArt.get("flag_peso_egalizzato");
|
||||
|
||||
if ("S".equalsIgnoreCase(flagUnitaKg)) {
|
||||
pesoNetto = entity.getQtaCol();
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -72,8 +73,8 @@ public class SalesRules extends QueryRules {
|
||||
|
||||
if (dataFine != null) {
|
||||
|
||||
if (dataFine.equals(UtilityLocalDate.localDateFromDate(vtbListData.getDataFine())) &&
|
||||
vtbListData.getDataIniz().before((UtilityDate.getTodayWithoutTime())) &&
|
||||
if (dataFine.equals(vtbListData.getDataFine()) &&
|
||||
vtbListData.getDataIniz().isBefore(LocalDate.now()) &&
|
||||
!vtbListData.getMtbLisvData().isEmpty()) {
|
||||
throw new Exception("Impossibile modificare gli articoli di una promozione con data inizio antecedente a oggi");
|
||||
|
||||
@@ -84,7 +85,7 @@ public class SalesRules extends QueryRules {
|
||||
|
||||
}
|
||||
|
||||
if (vtbListData.getDataIniz().before((UtilityDate.getTodayWithoutTime())))
|
||||
if (vtbListData.getDataIniz().isBefore(LocalDate.now()))
|
||||
throw new Exception(String.format("Impossibile inserire una %s data inizio antecedente a oggi",
|
||||
(vtbListData.getDataFine() != null ? "promozione" : "variazione")));
|
||||
|
||||
@@ -94,13 +95,13 @@ public class SalesRules extends QueryRules {
|
||||
|
||||
|
||||
public static boolean checkDataFine(Connection conn, VtbListData vtbListData) throws Exception {
|
||||
LocalDate dataIniz = UtilityLocalDate.localDateFromDate(vtbListData.getDataIniz());
|
||||
LocalDate dataFine = UtilityLocalDate.localDateFromDate(vtbListData.getDataFine());
|
||||
LocalDate dataIniz = vtbListData.getDataIniz();
|
||||
LocalDate dataFine = vtbListData.getDataFine();
|
||||
|
||||
if (dataFine.isBefore(dataIniz))
|
||||
throw new Exception(String.format("Impossibile inserire//modificare una promozione con data fine (%s) antecedente a data inizio ( %s )",
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(vtbListData.getDataFine()),
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(vtbListData.getDataIniz())));
|
||||
UtilityLocalDate.formatDate(vtbListData.getDataFine(), CommonConstants.DATE_FORMAT_DMY),
|
||||
UtilityLocalDate.formatDate(vtbListData.getDataIniz(), CommonConstants.DATE_FORMAT_DMY)));
|
||||
|
||||
String promoEscluse = setupGest.getSetup(conn, "VTB_LIST", "CHECK_DATA_FINE", "PROMO_ESCLUSE");
|
||||
if (!UtilityString.isNullOrEmpty(promoEscluse)) {
|
||||
@@ -112,7 +113,7 @@ public class SalesRules extends QueryRules {
|
||||
if (vtbListData.getCheckDataFine() != null && vtbListData.getCheckDataFine()) {
|
||||
if (UtilityLocalDate.isBeforeToday(dataFine))
|
||||
throw new Exception(String.format("Impossibile inserire//modificare una promozione con data fine (%s) antecedente ad oggi",
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(vtbListData.getDataFine())));
|
||||
UtilityLocalDate.formatDate(vtbListData.getDataFine(), CommonConstants.DATE_FORMAT_DMY)));
|
||||
}
|
||||
|
||||
if (vtbListData.getCheckDataFine() != null && vtbListData.getCheckDataFine()) {
|
||||
@@ -254,8 +255,8 @@ public class SalesRules extends QueryRules {
|
||||
public static String completeCodPromo(Connection connection, VtbListData vtbListData) throws Exception {
|
||||
String partialCode =
|
||||
vtbListData.getCodVlis() + ";" +
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_YMD).format(vtbListData.getDataIniz()) + ";" +
|
||||
new SimpleDateFormat(CommonConstants.DATE_FORMAT_YMD).format(vtbListData.getDataFine());
|
||||
UtilityLocalDate.formatDate(vtbListData.getDataIniz(), CommonConstants.DATE_FORMAT_YMD) + ";" +
|
||||
UtilityLocalDate.formatDate(vtbListData.getDataFine(), CommonConstants.DATE_FORMAT_YMD);
|
||||
|
||||
String sql = "SELECT dbo.f_suggestCodeCodPromoVend( " + UtilityDB.valueToString(partialCode) + " ) ";
|
||||
String codPromo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
@@ -277,7 +278,7 @@ public class SalesRules extends QueryRules {
|
||||
"vtb_list_data.versione = mtb_lisv_data.versione " +
|
||||
"where mtb_lisv_data.cod_mart = " + UtilityDB.valueToString(mtbLisvData.getCodMart()) + " and " +
|
||||
"vtb_list_data.cod_vlis = " + UtilityDB.valueToString(mtbLisvData.getCodVlis()) + " and " +
|
||||
"vtb_list_data.data_iniz <= " + UtilityDB.valueDateToString(mtbLisvData.getDataIniz(), CommonConstants.DATE_FORMAT_YMD) +
|
||||
"vtb_list_data.data_iniz <= " + UtilityDB.valueToString(mtbLisvData.getDataIniz()) +
|
||||
(mtbLisvData.getVersione() != null ? " AND vtb_list_data.versione <> " + UtilityDB.valueToString(mtbLisvData.getVersione()) : "") +
|
||||
" ORDER BY vtb_list_data.data_iniz desc";
|
||||
|
||||
@@ -346,9 +347,9 @@ public class SalesRules extends QueryRules {
|
||||
|
||||
public static void setDataUltVar(Connection connection, VtbListData testata) throws Exception {
|
||||
if (testata.getOperation() == OperationType.INSERT || testata.getOperation() == OperationType.UPDATE || testata.getOperation() == OperationType.INSERT_OR_UPDATE) {
|
||||
testata.setDataUltVar(new Date());
|
||||
testata.setDataUltVar(LocalDateTime.now());
|
||||
} else if ( testata.getMtbLisvData() != null && testata.getMtbLisvData().stream().anyMatch(x-> x.getOperation() == OperationType.INSERT || x.getOperation() == OperationType.UPDATE || x.getOperation() == OperationType.INSERT_OR_UPDATE )){
|
||||
testata.setDataUltVar(new Date());
|
||||
testata.setDataUltVar(LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +372,7 @@ public class SalesRules extends QueryRules {
|
||||
" FROM vtb_list_data " +
|
||||
" WHERE cod_vlis = " + UtilityDB.valueToString(vtbListData.getCodVlis()) + " AND " +
|
||||
"versione = " + UtilityDB.valueToString(vtbListData.getVersione()) + " AND " +
|
||||
"data_iniz = " + UtilityDB.valueDateToString(vtbListData.getDataIniz(), CommonConstants.DATE_FORMAT_YMD);
|
||||
"data_iniz = " + UtilityDB.valueToString(vtbListData.getDataIniz());
|
||||
|
||||
boolean existLisv = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
|
||||
@@ -388,7 +389,7 @@ public class SalesRules extends QueryRules {
|
||||
+ " WHERE cod_vlis = "
|
||||
+ UtilityDB.valueToString(vtbListData.getCodVlis())
|
||||
+ " AND data_iniz = "
|
||||
+ UtilityDB.valueDateToString(vtbListData.getDataIniz(), CommonConstants.DATE_FORMAT_YMD)
|
||||
+ UtilityDB.valueToString(vtbListData.getDataIniz())
|
||||
+ " AND cod_promo IS NULL"
|
||||
+ " AND isNull(note, '') = IsNull(" + UtilityDB.valueToString(vtbListData.getNote()) + ", '') ";
|
||||
versioneNew = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
@@ -399,9 +400,9 @@ public class SalesRules extends QueryRules {
|
||||
+ " WHERE cod_vlis = "
|
||||
+ UtilityDB.valueToString(vtbListData.getCodVlis())
|
||||
+ " AND data_iniz = "
|
||||
+ UtilityDB.valueDateToString(vtbListData.getDataIniz(), CommonConstants.DATE_FORMAT_YMD)
|
||||
+ UtilityDB.valueToString(vtbListData.getDataIniz())
|
||||
+ " AND data_fine = "
|
||||
+ UtilityDB.valueDateToString(vtbListData.getDataFine(), CommonConstants.DATE_FORMAT_YMD) + " AND "
|
||||
+ UtilityDB.valueToString(vtbListData.getDataFine()) + " AND "
|
||||
+ " cod_promo = " + UtilityDB.valueToString(vtbListData.getCodPromo()) + " AND "
|
||||
+ " ( note = " + UtilityDB.valueToString(vtbListData.getNote()) + " OR "
|
||||
+ UtilityDB.valueToString(vtbListData.getNote()) + " is null ) ";
|
||||
@@ -413,17 +414,6 @@ public class SalesRules extends QueryRules {
|
||||
if (versioneNew == null || versioneNew == 0) {
|
||||
if (vtbListData.getOperation() == OperationType.INSERT_OR_UPDATE)
|
||||
vtbListData.setOperation(OperationType.INSERT);
|
||||
// query = " SELECT max(versione) versione"
|
||||
// + " FROM vtb_list_data "
|
||||
// + " WHERE cod_vlis = "
|
||||
// + UtilityDB.valueToString(vtbListData.getCodVlis());
|
||||
// versioneNew = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
//
|
||||
// if (versioneNew == null) {
|
||||
// versioneNew = 1;
|
||||
// } else {
|
||||
// versioneNew = versioneNew + 1;
|
||||
// }
|
||||
} else {
|
||||
vtbListData.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
@@ -432,12 +422,11 @@ public class SalesRules extends QueryRules {
|
||||
return versioneNew;
|
||||
}
|
||||
|
||||
public static BigDecimal completeRicaricaRow(Connection connection, String codVlis, String codMart, Date dataIniz) throws Exception {
|
||||
public static BigDecimal completeRicaricaRow(Connection connection, String codVlis, String codMart, LocalDate dataIniz) throws Exception {
|
||||
|
||||
String sql = "SELECT distinct ricarico FROM dbo.ftx_getListinoVendita(" + UtilityDB.valueDateToString(dataIniz, CommonConstants.DATE_FORMAT_YMD) + ","
|
||||
String sql = "SELECT distinct ricarico FROM dbo.ftx_getListinoVendita(" + UtilityDB.valueToString(dataIniz) + ","
|
||||
+ UtilityDB.valueToString(codVlis) + "," + UtilityDB.valueToString(codMart) + ", 'N')";
|
||||
|
||||
|
||||
BigDecimal ricarico = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
return ricarico;
|
||||
@@ -447,7 +436,7 @@ public class SalesRules extends QueryRules {
|
||||
if (entity.getListData() == null) {
|
||||
String codVlis = entity.getCodVlis();
|
||||
String codMart = entity.getCodMart();
|
||||
Date dataIniz = entity.getDataIniz();
|
||||
LocalDate dataIniz = entity.getDataIniz();
|
||||
|
||||
String sql =
|
||||
"SELECT Cast(count(*) as bit) as existLisv " +
|
||||
@@ -489,7 +478,7 @@ public class SalesRules extends QueryRules {
|
||||
+ "sconto_strato, "
|
||||
+ "sconto_pedane, "
|
||||
+ "flag_prz_bloccato "
|
||||
+ " FROM dbo.getListinoVendita(" + UtilityDB.valueDateToString(dataIniz, CommonConstants.DATE_FORMAT_YMD) + ","
|
||||
+ " FROM dbo.getListinoVendita(" + UtilityDB.valueToString(dataIniz) + ","
|
||||
+ UtilityDB.valueToString(codVlis) + ","
|
||||
+ UtilityDB.valueToString(codMart) + ") ";
|
||||
|
||||
@@ -947,15 +936,16 @@ public class SalesRules extends QueryRules {
|
||||
public static Boolean checkChangeRicarico(Connection conn, MtbLisvData entity) throws Exception {
|
||||
Boolean ret = false;
|
||||
String query =
|
||||
"SELECT user_name " +
|
||||
"SELECT Cast(count(*) as bit) " +
|
||||
" FROM stb_user " +
|
||||
" WHERE stb_user.user_name = " + UtilityDB.valueToString(entity.getUsername()) + " AND " +
|
||||
"stb_user.flag_dba = 'N' AND " +
|
||||
"stb_user.user_name not in (select user_name from stb_gest_setup_user WHERE section = 'W_VLIST_RC' AND key_section = 'DISABLE_CHK_RICARICO' and value = 'S') ";
|
||||
|
||||
PreparedStatement ps = conn.prepareStatement(query);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
Boolean checkRicarico = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
if (checkRicarico == null) checkRicarico = false;
|
||||
|
||||
if (checkRicarico) {
|
||||
query =
|
||||
"SELECT ricarico_min, " +
|
||||
"ricarico_max, " +
|
||||
@@ -966,15 +956,12 @@ public class SalesRules extends QueryRules {
|
||||
" vtb_range_ricarico.cod_msgr = mtb_aart.cod_msgr " +
|
||||
" WHERE mtb_aart.cod_mart = " + UtilityDB.valueToString(entity.getCodMart()) + "AND " +
|
||||
"( vtb_range_ricarico.ricarico_min <> 0 OR vtb_range_ricarico.ricarico_max <> 0 )";
|
||||
ps = conn.prepareStatement(query);
|
||||
rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
BigDecimal ricaricoMin = rs.getBigDecimal(1);
|
||||
BigDecimal ricaricoMax = rs.getBigDecimal(2);
|
||||
String descrizioneArt = rs.getString(3);
|
||||
String flagTipoRicarico = rs.getString(4);
|
||||
rs.close();
|
||||
ps.close();
|
||||
HashMap<String, Object> dati = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, query);
|
||||
if (UtilityHashMap.isPresent(dati)) {
|
||||
BigDecimal ricaricoMin = UtilityHashMap.getValueIfExists(dati, "ricarico_min");
|
||||
BigDecimal ricaricoMax = UtilityHashMap.getValueIfExists(dati, "ricarico_max");
|
||||
String descrizioneArt = UtilityHashMap.getValueIfExists(dati, "descrizione");
|
||||
String flagTipoRicarico = UtilityHashMap.getValueIfExists(dati, "flag_tipo_ricarico");
|
||||
|
||||
BigDecimal ricaricoCalc = BigDecimal.ZERO;
|
||||
if ("P".equals(flagTipoRicarico)) {
|
||||
@@ -984,14 +971,8 @@ public class SalesRules extends QueryRules {
|
||||
" mtb_aart.perc_sfrido)" +
|
||||
" FROM mtb_aart " +
|
||||
" WHERE mtb_aart.cod_mart = " + UtilityDB.valueToString(entity.getCodMart());
|
||||
ps = conn.prepareStatement(query);
|
||||
rs = ps.executeQuery();
|
||||
|
||||
if (rs.next()) {
|
||||
ricaricoCalc = rs.getBigDecimal(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
ricaricoCalc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
} else {
|
||||
ricaricoCalc = entity.getPrzVend().subtract(entity.getPrzBase());
|
||||
}
|
||||
@@ -1003,8 +984,6 @@ public class SalesRules extends QueryRules {
|
||||
}
|
||||
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1017,7 +996,7 @@ public class SalesRules extends QueryRules {
|
||||
String flagPrzBloccato = "N";
|
||||
if (chkPrzBloccato) {
|
||||
query = "SELECT flag_prz_bloccato " +
|
||||
"FROM dbo.GetListinoVendita(" + UtilityDB.valueDateToString(entity.getDataIniz(), CommonConstants.DATE_FORMAT_YMD) + ", " +
|
||||
"FROM dbo.GetListinoVendita(" + UtilityDB.valueToString(entity.getDataIniz()) + ", " +
|
||||
UtilityDB.valueToString(entity.getCodVlis()) + ", " +
|
||||
UtilityDB.valueToString(entity.getCodMart()) + ") lisv ";
|
||||
flagPrzBloccato = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, query);
|
||||
@@ -1357,7 +1336,7 @@ public class SalesRules extends QueryRules {
|
||||
public static Long completeIdMtbLisvDataSpese(Connection connection, MtbLisvDataSpese mtbLisvDataSpese) throws SQLException {
|
||||
VtbListData vtbListData = (VtbListData) mtbLisvDataSpese.getParent();
|
||||
|
||||
Date dataIniz = vtbListData.getDataIniz();
|
||||
LocalDate dataIniz = vtbListData.getDataIniz();
|
||||
|
||||
String sql = Query.format(
|
||||
"SELECT id\n" +
|
||||
@@ -1371,4 +1350,19 @@ public class SalesRules extends QueryRules {
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
public static boolean checkMtbLisvDelete(Connection conn, MtbLisv mtbLisv) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT Cast(count(*) As BIT)\n" +
|
||||
"FROM mtb_lisv_data " +
|
||||
"WHERE cod_vlis = %s AND cod_mart = %s",
|
||||
mtbLisv.getCodVlis(),
|
||||
mtbLisv.getCodMart()
|
||||
);
|
||||
|
||||
Boolean exist = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
if (exist == null) exist = false;
|
||||
|
||||
return exist;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.OperationField;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.OperationFieldDTO;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -46,7 +46,7 @@ public class AutomatedOperationService {
|
||||
|
||||
if (x.getName().equalsIgnoreCase("profiledb")) {
|
||||
List<String> profiles = Stream.of(settingsModel.getAvailableConnections())
|
||||
.map(AvailableConnectionsModel::getProfileName)
|
||||
.map(AvailableConnectionModel::getProfileName)
|
||||
.sorted()
|
||||
.toList();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -272,7 +272,7 @@ public class DefaultAutomatedOperationHandlerComponent {
|
||||
|
||||
settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> x.getInternalDb() && x.getProfileName().equalsIgnoreCase(x.getDbName()))
|
||||
.map(AvailableConnectionsModel::getProfileName)
|
||||
.map(AvailableConnectionModel::getProfileName)
|
||||
.forEach(profileDb -> {
|
||||
try {
|
||||
final String operationName = "Remove FPX invio files (" + profileDb + ")";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package it.integry.ems.service;
|
||||
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
@@ -34,10 +34,10 @@ public class CleanDirectoryComponent {
|
||||
public void cleanDirectory() throws Exception {
|
||||
if (!UtilityDebug.isDebugExecution()) {
|
||||
|
||||
List<AvailableConnectionsModel> databases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
List<AvailableConnectionModel> databases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
|
||||
for (AvailableConnectionsModel connectionModel : databases) {
|
||||
for (AvailableConnectionModel connectionModel : databases) {
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionModel, false)) {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import it.integry.ems.dynamic_cache.DynamicCacheService;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.service.dto.EntityToLogDTO;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -66,7 +66,7 @@ public class EntityLoggerNewService {
|
||||
private void initSetup() {
|
||||
List<String> dbNames = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)
|
||||
.stream()
|
||||
.map(AvailableConnectionsModel::getDbName)
|
||||
.map(AvailableConnectionModel::getDbName)
|
||||
.collect(Collectors.toList());;
|
||||
|
||||
dynamicCacheService.addEntity(DynamicCacheService.Keys.ENTITY_LOGGER_SETUP, 5, StbLogEntitySetup.class, dbNames);
|
||||
|
||||
@@ -2,7 +2,7 @@ package it.integry.ems.service.production;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems.service.dto.production.MRPDailyConsumiDTO;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
@@ -41,9 +41,9 @@ public class MrpConsumiHandlerService {
|
||||
|
||||
@Scheduled(fixedDelay = 1, timeUnit = TimeUnit.MINUTES, initialDelay = 60, zone = "Europe/Rome")
|
||||
private void updateData() {
|
||||
final List<AvailableConnectionsModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
final List<AvailableConnectionModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
for (AvailableConnectionsModel connectionModel : availableConnections) {
|
||||
for (AvailableConnectionModel connectionModel : availableConnections) {
|
||||
boolean isEnabled = mrpSetupHandlerService.isGestioneAbilitata(connectionModel.getDbName());
|
||||
if (!isEnabled) continue;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package it.integry.ems.service.production;
|
||||
|
||||
import it.integry.ems.service.dto.production.MRPDailySetupGruppiDTO;
|
||||
import it.integry.ems.service.dto.production.MRPDailySetupSottogruppiDTO;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -52,9 +52,9 @@ public class MrpSetupHandlerService {
|
||||
"WHERE cod_opz = 'WG125'\n" +
|
||||
" AND flag_abil <> 'N'";
|
||||
|
||||
final List<AvailableConnectionsModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
final List<AvailableConnectionModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
for (AvailableConnectionsModel connectionsModel : availableConnections) {
|
||||
for (AvailableConnectionModel connectionsModel : availableConnections) {
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionsModel, false)) {
|
||||
|
||||
boolean isEnabled = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
@@ -78,9 +78,9 @@ public class MrpSetupHandlerService {
|
||||
private void updateData() {
|
||||
if (!canBeExecuted) return;
|
||||
|
||||
final List<AvailableConnectionsModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
final List<AvailableConnectionModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
for (AvailableConnectionsModel connectionModel : availableConnections) {
|
||||
for (AvailableConnectionModel connectionModel : availableConnections) {
|
||||
boolean isEnabled = isGestioneAbilitata(connectionModel.getDbName());
|
||||
if (!isEnabled) continue;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.annimon.stream.Stream;
|
||||
import it.integry.ems.service.dto.production.AvailableClassMercDTO;
|
||||
import it.integry.ems.service.dto.production.OrdineInevasoGroupMercDTO;
|
||||
import it.integry.ems.service.dto.production.OrdineLavorazioneDTO;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
@@ -54,9 +54,9 @@ public class ProductionOrderDataHandlerService {
|
||||
"WHERE cod_opz IN ('WG069', 'WG135')\n" +
|
||||
" AND flag_abil <> 'N'";
|
||||
|
||||
final List<AvailableConnectionsModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
final List<AvailableConnectionModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
for (AvailableConnectionsModel connectionsModel : availableConnections) {
|
||||
for (AvailableConnectionModel connectionsModel : availableConnections) {
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionsModel, false)) {
|
||||
boolean isEnabled = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
executionPermission.remove(connectionsModel.getDbName());
|
||||
@@ -75,9 +75,9 @@ public class ProductionOrderDataHandlerService {
|
||||
public void updateInternalCache() throws Exception {
|
||||
boolean onlyInevasi = true;
|
||||
|
||||
final List<AvailableConnectionsModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
final List<AvailableConnectionModel> availableConnections = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
for (AvailableConnectionsModel connectionModel : availableConnections) {
|
||||
for (AvailableConnectionModel connectionModel : availableConnections) {
|
||||
boolean isEnabled = executionPermission.getOrDefault(connectionModel.getDbName(), false);
|
||||
if (!isEnabled) continue;
|
||||
|
||||
@@ -222,7 +222,8 @@ public class ProductionOrderDataHandlerService {
|
||||
" isNull(colli.data_scad,mtb_partita_mag.data_scad) AS data_scad,\n" +
|
||||
" jtb_comt.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione as descrizione_commessa,\n" +
|
||||
" jl.id_lotto\n" +
|
||||
" jl.id_lotto,\n" +
|
||||
" dtb_ordt.qta_prod as qta_ord \n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordt ordl ON dtb_ordt.gestione = ordl.gestione_rif\n" +
|
||||
" AND dtb_ordt.data_ord = ordl.data_ord_rif\n" +
|
||||
|
||||
@@ -8,7 +8,7 @@ import it.integry.security.utility.CryptoUtils;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AvailableConnectionsModel {
|
||||
public class AvailableConnectionModel {
|
||||
|
||||
|
||||
private String profileName;
|
||||
@@ -24,7 +24,7 @@ public class AvailableConnectionsModel {
|
||||
return profileName;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setProfileName(String profileName) {
|
||||
public AvailableConnectionModel setProfileName(String profileName) {
|
||||
this.profileName = profileName;
|
||||
return this;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class AvailableConnectionsModel {
|
||||
return connectionType;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setConnectionType(EmsRestConstants.DB_TYPE connectionType) {
|
||||
public AvailableConnectionModel setConnectionType(EmsRestConstants.DB_TYPE connectionType) {
|
||||
this.connectionType = connectionType;
|
||||
return this;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class AvailableConnectionsModel {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setDbName(String dbName) {
|
||||
public AvailableConnectionModel setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
return this;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class AvailableConnectionsModel {
|
||||
return username;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setUsername(String username) {
|
||||
public AvailableConnectionModel setUsername(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class AvailableConnectionsModel {
|
||||
return password;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setPassword(String password) {
|
||||
public AvailableConnectionModel setPassword(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class AvailableConnectionsModel {
|
||||
return host;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setHost(String host) {
|
||||
public AvailableConnectionModel setHost(String host) {
|
||||
this.host = host;
|
||||
return this;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class AvailableConnectionsModel {
|
||||
return encryptedDbPsw != null ? encryptedDbPsw : true;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setEncryptedDbPsw(Boolean encryptedDbPsw) {
|
||||
public AvailableConnectionModel setEncryptedDbPsw(Boolean encryptedDbPsw) {
|
||||
this.encryptedDbPsw = encryptedDbPsw;
|
||||
return this;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class AvailableConnectionsModel {
|
||||
return isInternalDb;
|
||||
}
|
||||
|
||||
public AvailableConnectionsModel setInternalDb(Boolean internalDb) {
|
||||
public AvailableConnectionModel setInternalDb(Boolean internalDb) {
|
||||
isInternalDb = internalDb;
|
||||
return this;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class AvailableConnectionsModel {
|
||||
public boolean equals(Object o) {
|
||||
//if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AvailableConnectionsModel that = (AvailableConnectionsModel) o;
|
||||
AvailableConnectionModel that = (AvailableConnectionModel) o;
|
||||
return Objects.equals(getProfileName(), that.getProfileName()) &&
|
||||
getConnectionType() == that.getConnectionType() &&
|
||||
Objects.equals(getDbName(), that.getDbName()) &&
|
||||
@@ -41,7 +41,7 @@ public class SettingsModel implements InitializingBean {
|
||||
|
||||
private final ObservableField<String> systemPassword = new ObservableField<>("?MF!jbI+&OkA");
|
||||
|
||||
private final ObservableArrayList<AvailableConnectionsModel> availableConnections = new ObservableArrayList<>();
|
||||
private final ObservableArrayList<AvailableConnectionModel> availableConnections = new ObservableArrayList<>();
|
||||
|
||||
private MailConfigurationModel defaultMailConfiguration = new MailConfigurationModel();
|
||||
|
||||
@@ -109,31 +109,31 @@ public class SettingsModel implements InitializingBean {
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<AvailableConnectionsModel> getAvailableConnections() {
|
||||
public List<AvailableConnectionModel> getAvailableConnections() {
|
||||
return getAvailableConnections(false);
|
||||
}
|
||||
|
||||
public List<AvailableConnectionsModel> getAvailableConnections(boolean onlyInternal) {
|
||||
public List<AvailableConnectionModel> getAvailableConnections(boolean onlyInternal) {
|
||||
return availableConnections.get().stream()
|
||||
.filter(x -> !onlyInternal || x.getInternalDb())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<AvailableConnectionsModel> getAvailableConnectionsWithoutDuplicatedProfiles(boolean onlyInternal) {
|
||||
Map<String, List<AvailableConnectionsModel>> databases = getAvailableConnections(onlyInternal)
|
||||
public List<AvailableConnectionModel> getAvailableConnectionsWithoutDuplicatedProfiles(boolean onlyInternal) {
|
||||
Map<String, List<AvailableConnectionModel>> databases = getAvailableConnections(onlyInternal)
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||
|
||||
return databases.keySet().stream()
|
||||
.map(key -> databases.get(key).get(0))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void addAvailableConnection(AvailableConnectionsModel availableConnectionsModel) {
|
||||
availableConnections.add(availableConnectionsModel);
|
||||
public void addAvailableConnection(AvailableConnectionModel availableConnectionModel) {
|
||||
availableConnections.add(availableConnectionModel);
|
||||
}
|
||||
|
||||
public void setAvailableConnections(ArrayList<AvailableConnectionsModel> availableConnections) {
|
||||
public void setAvailableConnections(ArrayList<AvailableConnectionModel> availableConnections) {
|
||||
this.availableConnections.set(availableConnections);
|
||||
}
|
||||
|
||||
@@ -182,12 +182,12 @@ public class SettingsModel implements InitializingBean {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public AvailableConnectionsModel getDefaultConnectionModel() {
|
||||
public AvailableConnectionModel getDefaultConnectionModel() {
|
||||
if (this.getAvailableConnections() == null || this.getAvailableConnections().isEmpty() || UtilityString.isNullOrEmpty(this.getDefaultProfile()))
|
||||
return null;
|
||||
|
||||
|
||||
Optional<AvailableConnectionsModel> optConn = this.getAvailableConnections().stream()
|
||||
Optional<AvailableConnectionModel> optConn = this.getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(this.getDefaultProfile()))
|
||||
.findFirst();
|
||||
|
||||
@@ -197,7 +197,7 @@ public class SettingsModel implements InitializingBean {
|
||||
public String getProfileDbFromDbName(String dbName) {
|
||||
String profileDb = this.getAvailableConnections().stream()
|
||||
.filter(x -> x.getDbName().equalsIgnoreCase(dbName))
|
||||
.map(AvailableConnectionsModel::getProfileName)
|
||||
.map(AvailableConnectionModel::getProfileName)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
@@ -207,7 +207,7 @@ public class SettingsModel implements InitializingBean {
|
||||
public String getDbNameFromProfileDb(String profileDb) {
|
||||
String dbName = this.getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileDb))
|
||||
.map(AvailableConnectionsModel::getDbName)
|
||||
.map(AvailableConnectionModel::getDbName)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
@@ -215,7 +215,7 @@ public class SettingsModel implements InitializingBean {
|
||||
}
|
||||
|
||||
|
||||
public AvailableConnectionsModel findConnectionModel(String profileName) {
|
||||
public AvailableConnectionModel findConnectionModel(String profileName) {
|
||||
return getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileName))
|
||||
.findFirst()
|
||||
@@ -262,13 +262,13 @@ public class SettingsModel implements InitializingBean {
|
||||
availableConnections.add(this.getDefaultProfile());
|
||||
}
|
||||
|
||||
List<AvailableConnectionsModel> availableConnectionsModels = this.getAvailableConnections()
|
||||
List<AvailableConnectionModel> availableConnectionModels = this.getAvailableConnections()
|
||||
.stream()
|
||||
.filter(availableConnectionsModel ->
|
||||
availableConnections.stream().anyMatch(s -> s.equalsIgnoreCase(availableConnectionsModel.getProfileName())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
this.setAvailableConnections(new ArrayList<>(availableConnectionsModels));
|
||||
this.setAvailableConnections(new ArrayList<>(availableConnectionModels));
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import it.integry.ems.expansion.ObservableArrayList;
|
||||
import it.integry.ems.expansion.ObservableField;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.watching.FileWatcher;
|
||||
@@ -152,7 +152,7 @@ public class SettingsController implements IFileWatcherEvents {
|
||||
}
|
||||
|
||||
public String getHistoryProfileDb() throws Exception {
|
||||
AvailableConnectionsModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
AvailableConnectionModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
|
||||
if (connectionsModel == null) {
|
||||
throw new Exception("Impossibile ricavare la default connection");
|
||||
@@ -168,8 +168,8 @@ public class SettingsController implements IFileWatcherEvents {
|
||||
}
|
||||
|
||||
|
||||
public AvailableConnectionsModel getHistoryDbConnectionModel() {
|
||||
AvailableConnectionsModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
public AvailableConnectionModel getHistoryDbConnectionModel() {
|
||||
AvailableConnectionModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
|
||||
if (connectionsModel == null) {
|
||||
return null;
|
||||
@@ -177,7 +177,7 @@ public class SettingsController implements IFileWatcherEvents {
|
||||
|
||||
String profileName = connectionsModel.getDbName() + "_history";
|
||||
|
||||
Optional<AvailableConnectionsModel> opt = settingsModel.getAvailableConnections().stream()
|
||||
Optional<AvailableConnectionModel> opt = settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileName))
|
||||
.findFirst();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.settings;
|
||||
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.LoggerConfigurationModel;
|
||||
import it.integry.ems.settings.Model.MailConfigurationModel;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
@@ -39,9 +39,9 @@ class SettingsConverter {
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<AvailableConnectionsModel> getConvertedAvailableConnections() throws Exception {
|
||||
public ArrayList<AvailableConnectionModel> getConvertedAvailableConnections() throws Exception {
|
||||
|
||||
ArrayList<AvailableConnectionsModel> connectionList = new ArrayList<AvailableConnectionsModel>();
|
||||
ArrayList<AvailableConnectionModel> connectionList = new ArrayList<AvailableConnectionModel>();
|
||||
|
||||
File connectionFile = new File(emsProperties.getGlobalConnectionIniPath());
|
||||
|
||||
@@ -53,7 +53,7 @@ class SettingsConverter {
|
||||
// Print the content on the console
|
||||
|
||||
if (strLine.startsWith("CONNECT_STRING")) {
|
||||
AvailableConnectionsModel model = new AvailableConnectionsModel();
|
||||
AvailableConnectionModel model = new AvailableConnectionModel();
|
||||
|
||||
String[] splittedLine = strLine.split("=");
|
||||
|
||||
@@ -82,7 +82,7 @@ class SettingsConverter {
|
||||
String dbType = typeDBFullString.split("=")[1];
|
||||
|
||||
|
||||
for (AvailableConnectionsModel model : connectionList) {
|
||||
for (AvailableConnectionModel model : connectionList) {
|
||||
if (model.getProfileName().equalsIgnoreCase(dbName)) {
|
||||
model.setConnectionType(EmsRestConstants.DB_TYPE.fromString(dbType));
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class SettingsConverter {
|
||||
String dbEncryptedPsw = typeDBFullString.split("=")[1];
|
||||
|
||||
|
||||
for (AvailableConnectionsModel model : connectionList) {
|
||||
for (AvailableConnectionModel model : connectionList) {
|
||||
if (model.getProfileName().equalsIgnoreCase(dbName)) {
|
||||
model.setEncryptedDbPsw(dbEncryptedPsw.equalsIgnoreCase("S"));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package it.integry.ems.sync;
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
@@ -27,6 +27,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -63,11 +64,11 @@ public class AsyncManager {
|
||||
}
|
||||
|
||||
String finalHistoryProfileDb = historyProfileDb;
|
||||
List<AvailableConnectionsModel> databases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
List<AvailableConnectionModel> databases = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
cachedSetup.clear();
|
||||
|
||||
for (AvailableConnectionsModel connectionModel : databases) {
|
||||
for (AvailableConnectionModel connectionModel : databases) {
|
||||
try {
|
||||
cacheSetup(connectionModel);
|
||||
} catch (Exception ex) {
|
||||
@@ -76,7 +77,7 @@ public class AsyncManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheSetup(AvailableConnectionsModel connectionsModel) throws Exception {
|
||||
private void cacheSetup(AvailableConnectionModel connectionsModel) throws Exception {
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionsModel, false)) {
|
||||
String sql = "SELECT * FROM " + StbPublicationsDetail.ENTITY + " WHERE active = 1";
|
||||
@@ -168,7 +169,7 @@ public class AsyncManager {
|
||||
|
||||
List<String> dbNamesToConnect = toBeSavedQueue.stream().map(Map.Entry::getKey).distinct().collect(Collectors.toList());
|
||||
|
||||
final List<AvailableConnectionsModel> databaseConnections = settingsModel.getAvailableConnections().stream()
|
||||
final List<AvailableConnectionModel> databaseConnections = settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> dbNamesToConnect.stream().anyMatch(y -> x.getDbName().equalsIgnoreCase(y)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -180,14 +181,13 @@ public class AsyncManager {
|
||||
final Map.Entry<String, StbTransactionLog> finalItemToSave = itemToSave;
|
||||
final StbTransactionLog stbTransactionLog = finalItemToSave.getValue();
|
||||
|
||||
AvailableConnectionsModel connectionModel = databaseConnections.stream()
|
||||
AvailableConnectionModel connectionModel = databaseConnections.stream()
|
||||
.filter(x -> x.getDbName().equalsIgnoreCase(finalItemToSave.getKey()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionModel);
|
||||
SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) multiDBTransactionManager.prepareStatement(insertSQL)) {
|
||||
|
||||
PreparedStatement insertBulkPs = multiDBTransactionManager.prepareStatement(insertSQL)) {
|
||||
insertBulkPs.setLong(1, stbTransactionLog.getPublicationGroupId());
|
||||
insertBulkPs.setObject(2, stbTransactionLog.getCreatedAt());
|
||||
insertBulkPs.setString(3, stbTransactionLog.getUserName());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.sync.MultiDBTransaction;
|
||||
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -21,7 +21,7 @@ public class BasicConnectionPool {
|
||||
@Autowired
|
||||
private SettingsModel settingsModel;
|
||||
|
||||
private final ConcurrentHashMap<String, DataSource> registeredDatasources = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<AvailableConnectionModel, DataSource> registeredDatasources = new ConcurrentHashMap<>();
|
||||
|
||||
private volatile boolean initialized = false;
|
||||
private final Object initLock = new Object(); // Lock più leggero solo per inizializzazione
|
||||
@@ -62,10 +62,10 @@ public class BasicConnectionPool {
|
||||
}
|
||||
|
||||
private void initializeConnections() {
|
||||
final List<AvailableConnectionsModel> availableConnections =
|
||||
settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(false);
|
||||
final List<AvailableConnectionModel> availableConnections =
|
||||
settingsModel.getAvailableConnections(false);
|
||||
|
||||
for (AvailableConnectionsModel model : availableConnections) {
|
||||
for (AvailableConnectionModel model : availableConnections) {
|
||||
try {
|
||||
registerDataSourceIfNotExists(model);
|
||||
|
||||
@@ -75,13 +75,13 @@ public class BasicConnectionPool {
|
||||
}
|
||||
}
|
||||
|
||||
private DataSource createNewDataSource(AvailableConnectionsModel connectionModel) throws Exception {
|
||||
private DataSource createNewDataSource(AvailableConnectionModel connectionModel) throws Exception {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(connectionModel);
|
||||
return ds;
|
||||
}
|
||||
|
||||
public Connection getConnection(AvailableConnectionsModel connectionsModel) throws SQLException {
|
||||
public Connection getConnection(AvailableConnectionModel connectionsModel) throws SQLException {
|
||||
if (connectionsModel == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -89,14 +89,15 @@ public class BasicConnectionPool {
|
||||
try {
|
||||
registerDataSourceIfNotExists(connectionsModel);
|
||||
|
||||
String dbName = connectionsModel.getDbName();
|
||||
DataSource ds = registeredDatasources.get(dbName);
|
||||
DataSource ds = registeredDatasources.get(connectionsModel);
|
||||
|
||||
if (ds == null) {
|
||||
throw new IllegalArgumentException("No datasource registered for profile: " + connectionsModel.getProfileName());
|
||||
}
|
||||
|
||||
String dbName = connectionsModel.getDbName();
|
||||
Connection connection = ds.getConnection();
|
||||
|
||||
if (!connection.getCatalog().equalsIgnoreCase(dbName)) {
|
||||
throw new IllegalArgumentException("Connection for profile " + connectionsModel.getProfileName() + " is not for database " + dbName);
|
||||
}
|
||||
@@ -109,10 +110,9 @@ public class BasicConnectionPool {
|
||||
}
|
||||
|
||||
|
||||
private void registerDataSourceIfNotExists(AvailableConnectionsModel connectionModel) throws Exception {
|
||||
String dbName = connectionModel.getDbName();
|
||||
if (!registeredDatasources.containsKey(dbName)) {
|
||||
registeredDatasources.put(dbName, createNewDataSource(connectionModel));
|
||||
private void registerDataSourceIfNotExists(AvailableConnectionModel connectionModel) throws Exception {
|
||||
if (!registeredDatasources.containsKey(connectionModel)) {
|
||||
registeredDatasources.put(connectionModel, createNewDataSource(connectionModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -74,11 +74,11 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
this.setPrimaryDB(profileDb);
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(AvailableConnectionsModel connectionsModel) throws Exception {
|
||||
public MultiDBTransactionManager(AvailableConnectionModel connectionsModel) throws Exception {
|
||||
this(connectionsModel, true);
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(AvailableConnectionsModel connectionsModel, boolean enableLog) throws Exception {
|
||||
public MultiDBTransactionManager(AvailableConnectionModel connectionsModel, boolean enableLog) throws Exception {
|
||||
this();
|
||||
this.enableLog = enableLog;
|
||||
this.setPrimaryDB(connectionsModel);
|
||||
@@ -113,12 +113,12 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
|
||||
|
||||
public void addConnection(String profileName) throws SQLException {
|
||||
AvailableConnectionsModel availableConnectionsModel = settingsModel.findConnectionModel(profileName);
|
||||
this.addConnection(availableConnectionsModel);
|
||||
AvailableConnectionModel availableConnectionModel = settingsModel.findConnectionModel(profileName);
|
||||
this.addConnection(availableConnectionModel);
|
||||
}
|
||||
|
||||
public void addConnection(AvailableConnectionsModel availableConnectionsModel) throws SQLException {
|
||||
Connection connection = connectionPool.getConnection(availableConnectionsModel);
|
||||
public void addConnection(AvailableConnectionModel availableConnectionModel) throws SQLException {
|
||||
Connection connection = connectionPool.getConnection(availableConnectionModel);
|
||||
this.addConnection(connection);
|
||||
}
|
||||
|
||||
@@ -285,11 +285,11 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
throw new Exception(String.format("Configurazione DB non trovata o dati mancanti (%s)", profileDb));
|
||||
}
|
||||
|
||||
AvailableConnectionsModel connectionModel = settingsModel.findConnectionModel(profileDb);
|
||||
AvailableConnectionModel connectionModel = settingsModel.findConnectionModel(profileDb);
|
||||
setPrimaryDB(connectionModel);
|
||||
}
|
||||
|
||||
public void setPrimaryDB(AvailableConnectionsModel connectionModel) throws Exception {
|
||||
public void setPrimaryDB(AvailableConnectionModel connectionModel) throws Exception {
|
||||
this.close();
|
||||
|
||||
if (connectionModel == null) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import it.integry.ems.dynamic_cache.DynamicCacheService;
|
||||
import it.integry.ems.exception.SyncException;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -57,8 +57,8 @@ public class SyncManager {
|
||||
@PostContextConstruct
|
||||
public void init() {
|
||||
List<String> dbNames = settingsModel.getAvailableConnections().stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.map(AvailableConnectionsModel::getDbName)
|
||||
.filter(AvailableConnectionModel::getInternalDb)
|
||||
.map(AvailableConnectionModel::getDbName)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import it.integry.common.var.EmsDBConst;
|
||||
import it.integry.ems._context.EmsCoreContext;
|
||||
import it.integry.ems.exception.SystemNotInitializedException;
|
||||
import it.integry.ems.migration.MigrationComponent;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
@@ -67,7 +67,7 @@ public class SystemRequisiteCheckInterceptor extends HandlerInterceptorAdapter {
|
||||
String[] foundProfile = UtilityHashMap.getValueIfExists(request.getParameterMap(), CommonConstants.PROFILE_DB);
|
||||
if (foundProfile != null && foundProfile.length > 0 && !UtilityString.isNullOrEmpty(foundProfile[0])) {
|
||||
|
||||
Optional<AvailableConnectionsModel> optConn = Stream.of(settingsModel.getAvailableConnections())
|
||||
Optional<AvailableConnectionModel> optConn = Stream.of(settingsModel.getAvailableConnections())
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(foundProfile[0]))
|
||||
.findFirst();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
public class UserDTO {
|
||||
public class UserDTO implements Cloneable{
|
||||
|
||||
@SqlField("user_name")
|
||||
private String username;
|
||||
@@ -288,4 +288,14 @@ public class UserDTO {
|
||||
this.availableProfiles = availableProfiles;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDTO clone() {
|
||||
try {
|
||||
UserDTO clone = (UserDTO) super.clone();
|
||||
return clone;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package it.integry.ems.user.service;
|
||||
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.model.IntegryApplicationEnum;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -54,11 +54,11 @@ public class UserCacheService {
|
||||
private void internalCacheUpdate(boolean forceStart) {
|
||||
if (!forceStart && !canStart) return;
|
||||
|
||||
List<AvailableConnectionsModel> availableConnectionsModels =
|
||||
List<AvailableConnectionModel> availableConnectionModels =
|
||||
settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager()) {
|
||||
for (AvailableConnectionsModel model : availableConnectionsModels) {
|
||||
for (AvailableConnectionModel model : availableConnectionModels) {
|
||||
try {
|
||||
multiDBTransactionManager.addConnection(model);
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -9,6 +9,4 @@ public interface EquatableEntityInterface<T> extends EntityInterface {
|
||||
boolean equalsKey(T other);
|
||||
|
||||
boolean equals(Object other);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1476,48 +1476,51 @@ public class GeneraOrdLav {
|
||||
activityID = (String) datiOrdL.get("activity_id");
|
||||
}
|
||||
|
||||
Integer ggDiff = Math.toIntExact(UtilityLocalDate.daysAfterDate(dataInizProdOld, dataInizNew));
|
||||
if (ggDiff != 0) {
|
||||
sql = "SELECT * FROM dtb_ordr";
|
||||
sql = UtilityDB.addwhereCond(sql, ordT.getPkWhereCond(), true);
|
||||
List<DtbOrdr> dtbOrdrL = UtilityDB.executeSimpleQueryDTO(conn, sql, DtbOrdr.class);
|
||||
|
||||
if (dtbOrdrL != null && !dtbOrdrL.isEmpty()) {
|
||||
dtbOrdrL.stream().forEach(x -> {
|
||||
x.setDataCons(UtilityDate.dateAdd(x.getDataCons(), ggDiff));
|
||||
if (dataInizProdOld != null && dataInizNew != null && dataInizProdOld != EmsRestConstants.LOCAL_DATE_NULL && dataInizNew != EmsRestConstants.LOCAL_DATE_NULL){
|
||||
Integer ggDiff = Math.toIntExact(UtilityLocalDate.daysAfterDate(dataInizProdOld, dataInizNew));
|
||||
if (ggDiff != 0) {
|
||||
sql = "SELECT * FROM dtb_ordr";
|
||||
sql = UtilityDB.addwhereCond(sql, ordT.getPkWhereCond(), true);
|
||||
List<DtbOrdr> dtbOrdrL = UtilityDB.executeSimpleQueryDTO(conn, sql, DtbOrdr.class);
|
||||
|
||||
if (dtbOrdrL != null && !dtbOrdrL.isEmpty()) {
|
||||
dtbOrdrL.stream().forEach(x -> {
|
||||
x.setDataCons(UtilityDate.dateAdd(x.getDataCons(), ggDiff));
|
||||
x.setOperation(OperationType.UPDATE);
|
||||
});
|
||||
|
||||
ordT.setDtbOrdr(dtbOrdrL);
|
||||
}
|
||||
|
||||
sql = "SELECT * FROM dtb_ord_steps";
|
||||
sql = UtilityDB.addwhereCond(sql, ordT.getPkWhereCond(), true);
|
||||
List<DtbOrdSteps> dtbOrdSteps = UtilityDB.executeSimpleQueryDTO(conn, sql, DtbOrdSteps.class);
|
||||
|
||||
dtbOrdSteps.stream().forEach(x -> {
|
||||
x.setDataIniz(x.getDataIniz() != null ? UtilityDate.dateAdd(x.getDataIniz(), ggDiff) : null);
|
||||
x.setDataFine(x.getDataFine() != null ? UtilityDate.dateAdd(x.getDataFine(), ggDiff) : null);
|
||||
x.setOperation(OperationType.UPDATE);
|
||||
});
|
||||
|
||||
ordT.setDtbOrdr(dtbOrdrL);
|
||||
}
|
||||
ordT.setDtbOrdSteps(dtbOrdSteps);
|
||||
|
||||
sql = "SELECT * FROM dtb_ord_steps";
|
||||
sql = UtilityDB.addwhereCond(sql, ordT.getPkWhereCond(), true);
|
||||
List<DtbOrdSteps> dtbOrdSteps = UtilityDB.executeSimpleQueryDTO(conn, sql, DtbOrdSteps.class);
|
||||
// FABIO: DA CAPIRE COME VALORIZZATA LE ATTIVITA MODIFICATE
|
||||
if (assegnaAttivita) {
|
||||
sql = "SELECT stb_activity.* " +
|
||||
" FROM stb_activity " +
|
||||
" where (activity_id = " + UtilityDB.valueToString(activityID) + " or " +
|
||||
" parent_activity_id = " + UtilityDB.valueToString(activityID) + ")";
|
||||
List<StbActivity> stbActivity = UtilityDB.executeSimpleQueryDTO(conn, sql, StbActivity.class);
|
||||
|
||||
dtbOrdSteps.stream().forEach(x -> {
|
||||
x.setDataIniz(x.getDataIniz() != null ? UtilityDate.dateAdd(x.getDataIniz(), ggDiff) : null);
|
||||
x.setDataFine(x.getDataFine() != null ? UtilityDate.dateAdd(x.getDataFine(), ggDiff) : null);
|
||||
x.setOperation(OperationType.UPDATE);
|
||||
});
|
||||
stbActivity.stream().forEach(x -> {
|
||||
x.setEstimatedTime(x.getEstimatedTime().plusDays(ggDiff));
|
||||
x.setEstimatedEndtime(x.getEstimatedEndtime().plusDays(ggDiff));
|
||||
x.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
});
|
||||
|
||||
ordT.setDtbOrdSteps(dtbOrdSteps);
|
||||
|
||||
// FABIO: DA CAPIRE COME VALORIZZATA LE ATTIVITA MODIFICATE
|
||||
if (assegnaAttivita) {
|
||||
sql = "SELECT stb_activity.* " +
|
||||
" FROM stb_activity " +
|
||||
" where (activity_id = " + UtilityDB.valueToString(activityID) + " or " +
|
||||
" parent_activity_id = " + UtilityDB.valueToString(activityID) + ")";
|
||||
List<StbActivity> stbActivity = UtilityDB.executeSimpleQueryDTO(conn, sql, StbActivity.class);
|
||||
|
||||
stbActivity.stream().forEach(x -> {
|
||||
x.setEstimatedTime(x.getEstimatedTime().plusDays(ggDiff));
|
||||
x.setEstimatedEndtime(x.getEstimatedEndtime().plusDays(ggDiff));
|
||||
x.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
});
|
||||
|
||||
row.setStbActivityList(stbActivity);
|
||||
row.setStbActivityList(stbActivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,35 +864,37 @@ public class ProductionBusinessLogic {
|
||||
|
||||
List<JtbCiclCq> jtbCiclCqList = UtilityDB.executeSimpleQueryDTO(conn, sql, JtbCiclCq.class);
|
||||
|
||||
for (JtbCiclCq cq : jtbCiclCqList) {
|
||||
int numFase = cq.getNumFase();
|
||||
String controllo = cq.getControllo();
|
||||
String valoreRif = cq.getValoreRif();
|
||||
int numRip = cq.getNumRip();
|
||||
String tipologia = cq.getTipologia();
|
||||
datiDist.setIdRigaContrCQ(datiDist.getIdRigaContrCQ() + 1);
|
||||
if (!UtilityList.isNullOrEmpty(jtbCiclCqList)) {
|
||||
for (JtbCiclCq cq : jtbCiclCqList) {
|
||||
int numFase = cq.getNumFase();
|
||||
String controllo = cq.getControllo();
|
||||
String valoreRif = cq.getValoreRif();
|
||||
int numRip = cq.getNumRip();
|
||||
String tipologia = cq.getTipologia();
|
||||
datiDist.setIdRigaContrCQ(datiDist.getIdRigaContrCQ() + 1);
|
||||
|
||||
// Inserimento controllo di qualità nell'ordine di lavorazione
|
||||
DtbOrdCq ordCQ = new DtbOrdCq();
|
||||
ordCQ.setOperation(OperationType.INSERT);
|
||||
ordCQ.setIdRiga(datiDist.getIdRigaContrCQ());
|
||||
ordCQ.setControllo(controllo);
|
||||
ordCQ.setValoreRif(valoreRif);
|
||||
ordCQ.setNumRip(numRip);
|
||||
ordCQ.setNumFase(numFase);
|
||||
ordCQ.setTipologia(tipologia);
|
||||
ordCQ.setTipoValore(cq.getTipoValore());
|
||||
ordCQ.setIdValori(cq.getIdValori());
|
||||
if (isRoot) {
|
||||
ordCQ.setNumFase(numFase + datiDist.getNumFase());
|
||||
} else {
|
||||
// Inserimento controllo di qualità nell'ordine di lavorazione
|
||||
DtbOrdCq ordCQ = new DtbOrdCq();
|
||||
ordCQ.setOperation(OperationType.INSERT);
|
||||
ordCQ.setIdRiga(datiDist.getIdRigaContrCQ());
|
||||
ordCQ.setControllo(controllo);
|
||||
ordCQ.setValoreRif(valoreRif);
|
||||
ordCQ.setNumRip(numRip);
|
||||
ordCQ.setNumFase(numFase);
|
||||
ordCQ.setTipologia(tipologia);
|
||||
ordCQ.setTipoValore(cq.getTipoValore());
|
||||
ordCQ.setIdValori(cq.getIdValori());
|
||||
if (isRoot) {
|
||||
ordCQ.setNumFase(numFase + datiDist.getNumFase());
|
||||
} else {
|
||||
ordCQ.setNumFase(numFase);
|
||||
}
|
||||
if (numFase == 0) {
|
||||
ordCQ.setNumFase(numFase);
|
||||
}
|
||||
ordT.getDtbOrdCq().add(ordCQ);
|
||||
//((DtbOrdr) dtbOrdr).getOrdLav().getDtbOrdCq().add(ordCQ);
|
||||
}
|
||||
if (numFase == 0) {
|
||||
ordCQ.setNumFase(numFase);
|
||||
}
|
||||
ordT.getDtbOrdCq().add(ordCQ);
|
||||
//((DtbOrdr) dtbOrdr).getOrdLav().getDtbOrdCq().add(ordCQ);
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
@@ -1846,11 +1848,11 @@ public class ProductionBusinessLogic {
|
||||
Stream.of(dtbOrdtTrasf.getDtbOrdr()).forEach(
|
||||
x -> {
|
||||
DtbOrdr row = null;
|
||||
BigDecimal qtaEvasa= BigDecimal.ZERO;
|
||||
BigDecimal qtaEvasa = BigDecimal.ZERO;
|
||||
FlagEvaso flagEvaso = FlagEvaso.INEVASO;
|
||||
if (!UtilityList.isNullOrEmpty(rowsDataToMantain)) {
|
||||
row = rowsDataToMantain.stream().filter(c -> Objects.equals(c.getRigaOrd(), x.getRigaOrd())).findFirst().orElse(null);
|
||||
if (row != null){
|
||||
if (row != null) {
|
||||
qtaEvasa = row.getQtaEvasa();
|
||||
flagEvaso = row.getFlagEvaso();
|
||||
}
|
||||
|
||||
@@ -449,6 +449,7 @@ public class AtbForn extends EntityBase implements EquatableEntityInterface<AtbF
|
||||
return Objects.equals(getCodAnag(), other.getCodAnag());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -65,9 +65,6 @@ public class CtbAmac extends EntityBase {
|
||||
@SqlField(value = "flag_attivo", nullable = false, defaultObjectValue = "1")
|
||||
private Boolean flagAttivo;
|
||||
|
||||
@SqlField(value = "cod_mdep")
|
||||
private String codMdep;
|
||||
|
||||
@SqlField(value = "posizione")
|
||||
@FK(tableName = MtbDepoPosizioni.ENTITY)
|
||||
private String posizione;
|
||||
@@ -241,15 +238,6 @@ public class CtbAmac extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public CtbAmac setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPosizione() {
|
||||
return posizione;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class CtbBeni extends EntityBase {
|
||||
@SqlField(value = "perc_costo_deduc", nullable = false)
|
||||
private BigDecimal percCostoDeduc;
|
||||
|
||||
@FK(tableName = CtbMovt.ENTITY, columnName = "num_cmov")
|
||||
@SqlField(value = "num_cmov_acq")
|
||||
private Integer numCmovAcq;
|
||||
|
||||
|
||||
@@ -775,6 +775,20 @@ public class CtbMovt extends EntityBase {
|
||||
ctbMovr.deleteAllEntities(connection, this.getPkWhereCond());
|
||||
CtbMovi ctbMovi = new CtbMovi();
|
||||
ctbMovi.deleteAllEntities(connection, this.getPkWhereCond());
|
||||
CtbRitAcc ctbRitAcc = new CtbRitAcc();
|
||||
String whereCond = "num_cmov_fat = " + this.getNumCmov();
|
||||
ctbRitAcc.deleteAllEntities(connection, whereCond);
|
||||
String sql = "SELECT * FROM ctb_beni WHERE num_cmov_acq = " + this.getNumCmov();
|
||||
List<CtbBeni> ctbBeni = UtilityDB.executeSimpleQueryDTO(connection, sql, CtbBeni.class);
|
||||
if (ctbBeni != null && ctbBeni.size() > 0) {
|
||||
for (CtbBeni c : ctbBeni) {
|
||||
c.setOperation(OperationType.DELETE);
|
||||
c.manageWithParentConnection(connection, c.getOperation(), dataCompleting, entityHolder);
|
||||
}
|
||||
}
|
||||
|
||||
CtbVarbeni ctbVarbeni = new CtbVarbeni();
|
||||
ctbVarbeni.deleteAllEntities(connection, this.getPkWhereCond());
|
||||
CrlMovAttached crlMovAttached = new CrlMovAttached();
|
||||
crlMovAttached.deleteAllEntities(connection, this.getPkWhereCond());
|
||||
if (numCmovRc == null || numCmovRc == 0) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@PropertyReactive
|
||||
@@ -61,7 +61,7 @@ public class CtbParr extends EntityBase {
|
||||
|
||||
@ImportFromParent
|
||||
@SqlField(value = "data_cmov", nullable = false)
|
||||
private Date dataCmov;
|
||||
private LocalDate dataCmov;
|
||||
|
||||
@SqlField(value = "imp_dare", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal impDare;
|
||||
@@ -86,7 +86,7 @@ public class CtbParr extends EntityBase {
|
||||
private BigDecimal cambioDiviCont;
|
||||
|
||||
@ImportFromParent
|
||||
private Date dataDoc;
|
||||
private LocalDate dataDoc;
|
||||
|
||||
@ImportFromParent
|
||||
private String chiudiScad;
|
||||
@@ -174,11 +174,11 @@ public class CtbParr extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataCmov() {
|
||||
public LocalDate getDataCmov() {
|
||||
return dataCmov;
|
||||
}
|
||||
|
||||
public CtbParr setDataCmov(Date dataCmov) {
|
||||
public CtbParr setDataCmov(LocalDate dataCmov) {
|
||||
this.dataCmov = dataCmov;
|
||||
return this;
|
||||
}
|
||||
@@ -237,11 +237,11 @@ public class CtbParr extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataDoc() {
|
||||
public LocalDate getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public CtbParr setDataDoc(Date dataDoc) {
|
||||
public CtbParr setDataDoc(LocalDate dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -46,7 +46,7 @@ public class CtbPart extends EntityBase {
|
||||
|
||||
@ImportFromParent (value = "data_doc")
|
||||
@SqlField(value = "data_doc")
|
||||
private Date dataDoc;
|
||||
private LocalDate dataDoc;
|
||||
|
||||
@SqlField(value = "tot_imponib", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal totImponib;
|
||||
@@ -185,11 +185,11 @@ public class CtbPart extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataDoc() {
|
||||
public LocalDate getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public CtbPart setDataDoc(Date dataDoc) {
|
||||
public CtbPart setDataDoc(LocalDate dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -114,9 +114,11 @@ public class CtbRitAcc extends EntityBase {
|
||||
@SqlField(value = "modello", maxLength = 5)
|
||||
private String modello;
|
||||
|
||||
@FK(tableName = CtbMovt.ENTITY, columnName = "num_cmov")
|
||||
@SqlField(value = "num_cmov_fat")
|
||||
private Integer numCmovFat;
|
||||
|
||||
@FK(tableName = CtbMovt.ENTITY, columnName = "num_cmov")
|
||||
@SqlField(value = "num_cmov_paga")
|
||||
private Integer numCmovPaga;
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@PropertyReactive
|
||||
@@ -58,11 +58,11 @@ public class CtbScad extends EntityBase {
|
||||
private String codPaga;
|
||||
|
||||
@ImportFromParent( value = "data_doc")
|
||||
@SqlField(value = "data_doc", nullable = false, format = CommonConstants.SYSDATE)
|
||||
private Date dataDoc;
|
||||
@SqlField(value = "data_doc", nullable = false)
|
||||
private LocalDate dataDoc;
|
||||
|
||||
@SqlField(value = "data_scad", nullable = false, format = CommonConstants.SYSDATE)
|
||||
private Date dataScad;
|
||||
@SqlField(value = "data_scad", nullable = false)
|
||||
private LocalDate dataScad;
|
||||
|
||||
@SqlField(value = "imp_dare", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal impDare;
|
||||
@@ -70,14 +70,14 @@ public class CtbScad extends EntityBase {
|
||||
@SqlField(value = "imp_avere", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal impAvere;
|
||||
|
||||
@SqlField(value = "data_pag", format = CommonConstants.SYSDATE)
|
||||
private Date dataPag;
|
||||
@SqlField(value = "data_pag")
|
||||
private LocalDate dataPag;
|
||||
|
||||
@SqlField(value = "descriz_pag", maxLength = 40)
|
||||
private String descrizPag;
|
||||
|
||||
@SqlField(value = "data_ult_soll")
|
||||
private Date dataUltSoll;
|
||||
private LocalDate dataUltSoll;
|
||||
|
||||
@SqlField(value = "ult_soll")
|
||||
private Integer ultSoll;
|
||||
@@ -85,17 +85,17 @@ public class CtbScad extends EntityBase {
|
||||
@SqlField(value = "note", maxLength = 40)
|
||||
private String note;
|
||||
|
||||
@SqlField(value = "data_ant_provv", format = CommonConstants.SYSDATE)
|
||||
private Date dataAntProvv;
|
||||
@SqlField(value = "data_ant_provv")
|
||||
private LocalDate dataAntProvv;
|
||||
|
||||
@SqlField(value = "data_titolo", format = CommonConstants.SYSDATE)
|
||||
private Date dataTitolo;
|
||||
@SqlField(value = "data_titolo")
|
||||
private LocalDate dataTitolo;
|
||||
|
||||
@SqlField(value = "gestione", maxLength = 1)
|
||||
private String gestione;
|
||||
|
||||
@SqlField(value = "data_ord", format = CommonConstants.SYSDATE)
|
||||
private Date dataOrd;
|
||||
private LocalDate dataOrd;
|
||||
|
||||
@SqlField(value = "num_ord")
|
||||
private Integer numOrd;
|
||||
@@ -203,24 +203,44 @@ public class CtbScad extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataDoc() {
|
||||
public LocalDate getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public CtbScad setDataDoc(Date dataDoc) {
|
||||
public CtbScad setDataDoc(LocalDate dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataScad() {
|
||||
public LocalDate getDataScad() {
|
||||
return dataScad;
|
||||
}
|
||||
|
||||
public CtbScad setDataScad(Date dataScad) {
|
||||
public CtbScad setDataScad(LocalDate dataScad) {
|
||||
this.dataScad = dataScad;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CtbScad setDataUltSoll(LocalDate dataUltSoll) {
|
||||
this.dataUltSoll = dataUltSoll;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CtbScad setDataAntProvv(LocalDate dataAntProvv) {
|
||||
this.dataAntProvv = dataAntProvv;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CtbScad setDataTitolo(LocalDate dataTitolo) {
|
||||
this.dataTitolo = dataTitolo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CtbScad setDataOrd(LocalDate dataOrd) {
|
||||
this.dataOrd = dataOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getImpDare() {
|
||||
return impDare;
|
||||
}
|
||||
@@ -239,11 +259,11 @@ public class CtbScad extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataPag() {
|
||||
public LocalDate getDataPag() {
|
||||
return dataPag;
|
||||
}
|
||||
|
||||
public CtbScad setDataPag(Date dataPag) {
|
||||
public CtbScad setDataPag(LocalDate dataPag) {
|
||||
this.dataPag = dataPag;
|
||||
return this;
|
||||
}
|
||||
@@ -257,15 +277,6 @@ public class CtbScad extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataUltSoll() {
|
||||
return dataUltSoll;
|
||||
}
|
||||
|
||||
public CtbScad setDataUltSoll(Date dataUltSoll) {
|
||||
this.dataUltSoll = dataUltSoll;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUltSoll() {
|
||||
return ultSoll;
|
||||
}
|
||||
@@ -284,21 +295,28 @@ public class CtbScad extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataAntProvv() {
|
||||
public LocalDate getDataUltSoll() {
|
||||
return dataUltSoll;
|
||||
}
|
||||
|
||||
public LocalDate getDataAntProvv() {
|
||||
return dataAntProvv;
|
||||
}
|
||||
|
||||
public CtbScad setDataAntProvv(Date dataAntProvv) {
|
||||
this.dataAntProvv = dataAntProvv;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataTitolo() {
|
||||
public LocalDate getDataTitolo() {
|
||||
return dataTitolo;
|
||||
}
|
||||
|
||||
public CtbScad setDataTitolo(Date dataTitolo) {
|
||||
this.dataTitolo = dataTitolo;
|
||||
public LocalDate getDataOrd() {
|
||||
return dataOrd;
|
||||
}
|
||||
|
||||
public Boolean getInsoluto() {
|
||||
return isInsoluto;
|
||||
}
|
||||
|
||||
public CtbScad setInsoluto(Boolean insoluto) {
|
||||
isInsoluto = insoluto;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -311,15 +329,6 @@ public class CtbScad extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataOrd() {
|
||||
return dataOrd;
|
||||
}
|
||||
|
||||
public CtbScad setDataOrd(Date dataOrd) {
|
||||
this.dataOrd = dataOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNumOrd() {
|
||||
return numOrd;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ public class CtbVarbeni extends EntityBase {
|
||||
@SqlField(value = "residuo_vend_var")
|
||||
private BigDecimal residuoVendVar;
|
||||
|
||||
@FK(tableName = CtbMovt.ENTITY, columnName = "num_cmov")
|
||||
@SqlField(value = "num_cmov")
|
||||
private Integer numCmov;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
@@ -132,6 +133,9 @@ public class JtbComt extends EntityBase {
|
||||
@SqlField(value = "rif_comm", maxLength = 255)
|
||||
private String rifComm;
|
||||
|
||||
@SqlField(value = "data_mod", defaultObjectValue = CommonConstants.TIMESTAMP)
|
||||
private LocalDateTime dataMod;
|
||||
|
||||
@EntityChild
|
||||
private List<JrlDisOrd> jrlDisOrd = new ArrayList<>();
|
||||
|
||||
@@ -468,6 +472,15 @@ public class JtbComt extends EntityBase {
|
||||
this.rifComm = rifComm;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataMod() {
|
||||
return dataMod;
|
||||
}
|
||||
|
||||
public JtbComt setDataMod(LocalDateTime dataMod) {
|
||||
this.dataMod = dataMod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<JrlDisOrd> getJrlDisOrd() {
|
||||
return jrlDisOrd;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -46,39 +46,44 @@ public class MtbAartBarCode extends EntityBase {
|
||||
return codBarre;
|
||||
}
|
||||
|
||||
public void setCodBarre(String codBarre) {
|
||||
public MtbAartBarCode setCodBarre(String codBarre) {
|
||||
this.codBarre = codBarre;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public void setCodMart(String codMart) {
|
||||
public MtbAartBarCode setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaCnf() {
|
||||
return qtaCnf;
|
||||
}
|
||||
|
||||
public void setQtaCnf(BigDecimal qtaCnf) {
|
||||
public MtbAartBarCode setQtaCnf(BigDecimal qtaCnf) {
|
||||
this.qtaCnf = qtaCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagPrimario() {
|
||||
return flagPrimario;
|
||||
}
|
||||
|
||||
public void setFlagPrimario(String flagPrimario) {
|
||||
public MtbAartBarCode setFlagPrimario(String flagPrimario) {
|
||||
this.flagPrimario = flagPrimario;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTipoCodBarre() {
|
||||
return tipoCodBarre;
|
||||
}
|
||||
|
||||
public void setTipoCodBarre(String tipoCodBarre) {
|
||||
public MtbAartBarCode setTipoCodBarre(String tipoCodBarre) {
|
||||
this.tipoCodBarre = tipoCodBarre;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.Master;
|
||||
import it.integry.ems_model.annotation.PK;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.annotation.Table;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -26,6 +23,11 @@ public class MtbAartMarchio extends EntityBase implements EquatableEntityInterfa
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@PK
|
||||
@Identity
|
||||
@SqlField(value = "id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@Unique
|
||||
@SqlField(value = "marchio", maxLength = 255, nullable = false)
|
||||
private String marchio;
|
||||
|
||||
@@ -59,17 +61,14 @@ public class MtbAartMarchio extends EntityBase implements EquatableEntityInterfa
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object)
|
||||
return true;
|
||||
if (!(object instanceof MtbAartMarchio))
|
||||
return false;
|
||||
MtbAartMarchio that = (MtbAartMarchio) object;
|
||||
return Objects.equals(getMarchio(), that.getMarchio());
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof MtbAartMarchio)) return false;
|
||||
MtbAartMarchio that = (MtbAartMarchio) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(getMarchio(), that.getMarchio());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getMarchio());
|
||||
return Objects.hash(id, getMarchio());
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user