Compare commits
296 Commits
feature/Fe
...
feature-re
| Author | SHA1 | Date | |
|---|---|---|---|
| 73aed3e9d6 | |||
| 1ae0ee3567 | |||
| 49f6664874 | |||
| 03fe0c7279 | |||
| 49b4fca63c | |||
| 36c425941a | |||
| 5fa3dc538f | |||
| 280474d038 | |||
| 518263d955 | |||
| 0f298bcd05 | |||
| c8200f3690 | |||
| 08ff9e1940 | |||
| 165e81938c | |||
| c87404a4ee | |||
| 92a9abf978 | |||
| 71e99ed943 | |||
| b1c337a238 | |||
| 21fa20e94f | |||
| bf1b78ccc0 | |||
| 5325f3124a | |||
| fce976b2df | |||
| 8caa0c924b | |||
| 4af7155db9 | |||
| ab682181ce | |||
| d6cda98855 | |||
| 38c1c80abb | |||
| fed416de15 | |||
| d5bf6aef92 | |||
| 5a0cfd160f | |||
| bea182eea9 | |||
| ce6a102f45 | |||
| 9e1a600087 | |||
| 89a6a8c2f4 | |||
| 9fca434612 | |||
| d675ce0e82 | |||
| ef2f2a91b3 | |||
| 49ff0c839b | |||
| bd5eb9c535 | |||
| 0851fe8915 | |||
| fa7e3a55ca | |||
| 52d34fa810 | |||
| 59624c8c17 | |||
| cd53eca2e8 | |||
| a486b6102b | |||
| becfdab1a1 | |||
| e6605c2feb | |||
| 305c79a558 | |||
| edcc08c9da | |||
| 89d0f95834 | |||
| 112dc51ac7 | |||
| a93979c546 | |||
| 6b536b20c6 | |||
| 17c832745f | |||
| fcb62e3689 | |||
| bc88453914 | |||
| a85173bc45 | |||
| ed0c117bac | |||
| 557159cf7f | |||
| 46dcdd7745 | |||
| c30c7ec369 | |||
| 8e99c0898d | |||
| b4ce3f8d27 | |||
| 9549583c86 | |||
| 5b88fa632c | |||
| 64425c2c4a | |||
| e6d5df31dd | |||
| f9be1f4463 | |||
| 1cfc7558ac | |||
| 140c443030 | |||
| 0bfa110d6c | |||
| 374d143090 | |||
| 32dc0b4f4c | |||
| 75edd98223 | |||
| d89ddb447c | |||
| a2b668ed96 | |||
| d7aef97ae0 | |||
| 4f6eed564e | |||
| e3cf9aa115 | |||
| 766e6a18cc | |||
| 45c507cfcc | |||
| ebaee14167 | |||
| 0a56b9dd25 | |||
| 51210cd8df | |||
| e80d8ee151 | |||
| 3b461350d5 | |||
| 5724dc53c9 | |||
| 84ff15687e | |||
| 422e09b072 | |||
| 3dd1cd60cb | |||
| 14cf0d60b5 | |||
| 7a0cbebdfb | |||
| f5e208a973 | |||
| f4189b71e0 | |||
| 0d8101ec05 | |||
| 7f42ee47ce | |||
| 0b1310646c | |||
| ebde200a73 | |||
| 502dc5e7a9 | |||
| 4fca7a604b | |||
| 2b781e795a | |||
| cbfa2482da | |||
| ef9bbe6198 | |||
| 4e78712c2f | |||
| bcb23e8a42 | |||
| 4e9d2615b1 | |||
| f8da37203c | |||
| 29e67b3680 | |||
| 9a7508d05e | |||
| 88da287d33 | |||
| b924e018ab | |||
| b9f2ed0509 | |||
| cecf45cc8f | |||
| 2f6c642ef0 | |||
| c38608d92b | |||
| 08b91b91ef | |||
| 25d266b0f8 | |||
| d9287659d2 | |||
| 9542465064 | |||
| 4901067c3f | |||
| 35727ef0af | |||
| 9aa60b6464 | |||
| c2d9ccf1b1 | |||
| 56764f5918 | |||
| c11ead2b49 | |||
| 219fd1989a | |||
| 78137519ec | |||
| 2010782da4 | |||
| a9718b5fbe | |||
| c995d2334f | |||
| c0340b9863 | |||
| e8d8f7db1a | |||
| e22c467a15 | |||
| 7ba89d3cfa | |||
| fbc13719db | |||
| 5cbc6cce2e | |||
| c3871083b1 | |||
| 33c85e3a18 | |||
| e3863f5992 | |||
| 218f6b9306 | |||
| cf215fae02 | |||
| 358064102e | |||
| 998b63301d | |||
| 3055139b83 | |||
| cf766e190e | |||
| d61cf134fb | |||
| 68238f0d6e | |||
| c3dd5fb59b | |||
| 96a4ab4b39 | |||
| e9411988d2 | |||
| db6319ad6c | |||
| 8a61bc87bc | |||
| e580a12b0e | |||
| 5576834083 | |||
| 715e1fc6c3 | |||
| 090828aa8a | |||
| 7c65f3a8f9 | |||
| 778141da66 | |||
| ceb7deb79f | |||
| 0724f6ab83 | |||
| f910e6855f | |||
| acbd3e8ac2 | |||
| 5e7209f060 | |||
| 5201b5b25d | |||
| 7126f9bf71 | |||
| 5a2ad13068 | |||
| c0dc46935b | |||
| f1c5d7cd2e | |||
| 08c675b662 | |||
| 7d9ca973f5 | |||
| 1b2a3c1203 | |||
| ef7369c2a3 | |||
| 1520d45609 | |||
| 820ae30ab4 | |||
| 60683c0383 | |||
| 90b955f6a4 | |||
| e0d63d5c44 | |||
| d54401cd9e | |||
| 6f6232be13 | |||
| 872503afb5 | |||
| edd50bed65 | |||
| aac8b151dc | |||
| 76785b22fe | |||
| bebf48f6c5 | |||
| 79d0ea1967 | |||
| 069b652035 | |||
| 6b3d579803 | |||
| 5acb744618 | |||
| 0ee6c261e5 | |||
| 0b6ad5d5dc | |||
| 19c8d1eee7 | |||
| 201996e4b5 | |||
| 2bf4edeffe | |||
| 799c3be92d | |||
| 96102328c1 | |||
| 2d458e1836 | |||
| 3f2ad37ff9 | |||
| c343ec70ad | |||
| 4bb59eee38 | |||
| 585771cb2e | |||
| 51ad617bd3 | |||
| 4c71015588 | |||
| 065fb956d3 | |||
| f096f72942 | |||
| f61f8283f0 | |||
| 0682af0dee | |||
| fb09e637ee | |||
| aa4619e323 | |||
| 5e30e340a2 | |||
| ca8fba8d6f | |||
| 7012dca4a6 | |||
| 8256c1e0ce | |||
| f92de927ff | |||
| fe5dc1f55b | |||
| 557ada2363 | |||
| 6b30fea7b8 | |||
| 71df21c003 | |||
| d73f607e21 | |||
| 960f74e7cd | |||
| e1e9a3cbfc | |||
| 48d5190586 | |||
| 36c6ec6c64 | |||
| 7f3c43f263 | |||
| 4d0dfc5341 | |||
| b08e1ef6bb | |||
| 09b8d47c76 | |||
| 43f59ccf3b | |||
| fee5320c37 | |||
| 3a55dcdb58 | |||
| f5ea90a0d0 | |||
| b833fc79e8 | |||
| f52aa4d837 | |||
| fff5faf3be | |||
| 978b42d18a | |||
| c7c8b1be24 | |||
| 6034120f1f | |||
| c2b6d4ba69 | |||
| bc97f9a573 | |||
| ce1f68deb2 | |||
| 45bf3d67d1 | |||
| bf38dfe0d8 | |||
| af68b892f3 | |||
| af29eeba58 | |||
| 5698329cc8 | |||
| d70efd3af2 | |||
| f99957eb41 | |||
| 40104bcce7 | |||
| edda81733d | |||
| ceb11d3261 | |||
| a13671c51a | |||
| b94d9b1177 | |||
| d027f3ff20 | |||
| 8601f4fd90 | |||
| 73ade8691d | |||
| df2a7d6e36 | |||
| c7c6affe3e | |||
| 54fc28eb74 | |||
| ab1200ff84 | |||
| 22f65037f4 | |||
| ec2b83657a | |||
| 2511aabbdb | |||
| 313fa6a8df | |||
| 9bb8751e21 | |||
| 24c4935dad | |||
| 61d76b03c4 | |||
| 0f973c962a | |||
| cffe9082db | |||
| 6c88b7b288 | |||
| ea2121e111 | |||
| 1191f98485 | |||
| 6c0e2d5259 | |||
| 894da40182 | |||
| 749a7e9750 | |||
| e5a66bfd15 | |||
| 9761d05a8e | |||
| 050e8bd19e | |||
| a0c3d3a6b3 | |||
| f06117d5ef | |||
| 75262b5940 | |||
| 0b3f1ee9fc | |||
| 7c19c93814 | |||
| 532c12dd22 | |||
| e81c2ac6b9 | |||
| 161ea5e5dd | |||
| 260019d79f | |||
| 08b68781e9 | |||
| 760be03b18 | |||
| 148a4359b6 | |||
| b65d35cfd6 | |||
| 54eb75a420 | |||
| e9d28c6f63 | |||
| 212f14db36 | |||
| b50e25a0ee | |||
| 0a49695d7c | |||
| 9e5a2e8400 | |||
| f0fb85e6db | |||
| 86081ec113 |
1
.idea/runConfigurations/MenuStaticCreator.xml
generated
1
.idea/runConfigurations/MenuStaticCreator.xml
generated
@@ -2,6 +2,7 @@
|
||||
<configuration default="false" name="MenuStaticCreator" type="Application" factoryName="Application" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="it.integry.ems.menu.MenuStaticCreator" />
|
||||
<module name="ems-core" />
|
||||
<shortenClasspath name="MANIFEST" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="it.integry.ems.menu.*" />
|
||||
|
||||
@@ -6,15 +6,6 @@
|
||||
"enableTokenCaching" : false,
|
||||
"systemPassword" : "?MF!jbI+&OkA",
|
||||
"availableConnections" : [{
|
||||
"profileName" : "MAGGIOSRL",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "MaggioSRL",
|
||||
"username" : "sa",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.214",
|
||||
"encryptedDbPsw" : true,
|
||||
"internalDb" : true
|
||||
}, {
|
||||
"profileName" : "AGRICOPER",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "agricoper",
|
||||
@@ -33,18 +24,18 @@
|
||||
"encryptedDbPsw" : true,
|
||||
"internalDb" : true
|
||||
}, {
|
||||
"profileName" : "COAP",
|
||||
"profileName" : "RESINA_COLOR",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "COAP",
|
||||
"dbName" : "RESINACOLOR",
|
||||
"username" : "sa",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.214",
|
||||
"encryptedDbPsw" : true,
|
||||
"internalDb" : true
|
||||
}, {
|
||||
"profileName" : "RESINA_COLOR",
|
||||
"profileName" : "RESINA_COLOR_PASQUALE",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "RESINACOLOR",
|
||||
"dbName" : "RESINACOLOR_PASQUALE",
|
||||
"username" : "sa",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.214",
|
||||
@@ -242,12 +233,21 @@
|
||||
}, {
|
||||
"profileName" : "GRAMM",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "gramm",
|
||||
"dbName" : "gramm_peppe",
|
||||
"username" : "SA",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.220",
|
||||
"encryptedDbPsw" : true,
|
||||
"internalDb" : true
|
||||
}, {
|
||||
"profileName" : "MAGGIOSRL",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "MaggioSRL",
|
||||
"username" : "sa",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.214",
|
||||
"encryptedDbPsw" : true,
|
||||
"internalDb" : true
|
||||
}, {
|
||||
"profileName" : "IDROTECNICA",
|
||||
"connectionType" : "MSSQL",
|
||||
@@ -278,7 +278,7 @@
|
||||
}, {
|
||||
"profileName" : "IME_TE",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "IME_TE",
|
||||
"dbName" : "IME_TE_peppe",
|
||||
"username" : "SA",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.214",
|
||||
@@ -692,7 +692,7 @@
|
||||
}, {
|
||||
"profileName" : "BIOLEVANTE",
|
||||
"connectionType" : "MSSQL",
|
||||
"dbName" : "biolevante",
|
||||
"dbName" : "biolevante_peppe",
|
||||
"username" : "SA",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.220",
|
||||
|
||||
@@ -90,7 +90,7 @@ public class EmsCoreDBLoader {
|
||||
|
||||
futureTasks.add(() -> {
|
||||
try {
|
||||
Connection connection = connectionPool.getConnection(modelAtomicReference.get().getProfileName());
|
||||
Connection connection = connectionPool.getConnection(modelAtomicReference.get());
|
||||
String sql = "SELECT db_distributore FROM azienda";
|
||||
String dbDistributore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
package it.integry.ems.anonymizer;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Generatore di nomi e cognomi italiani per l'anonimizzazione dei dati.
|
||||
* Mantiene la coerenza del sesso tra nome e genere.
|
||||
*/
|
||||
public class ItalianNameGenerator {
|
||||
|
||||
private final Random random;
|
||||
|
||||
// Nomi maschili italiani (200+ nomi)
|
||||
public static final List<String> MALE_NAMES = Arrays.asList(
|
||||
"Alessandro", "Andrea", "Antonio", "Francesco", "Marco", "Matteo", "Giuseppe", "Luca",
|
||||
"Giovanni", "Roberto", "Stefano", "Paolo", "Davide", "Michele", "Simone", "Federico",
|
||||
"Riccardo", "Fabio", "Daniele", "Massimo", "Claudio", "Nicola", "Gabriele", "Vincenzo",
|
||||
"Lorenzo", "Salvatore", "Emanuele", "Alberto", "Diego", "Tommaso", "Alessio", "Filippo",
|
||||
"Giorgio", "Mattia", "Franco", "Bruno", "Enrico", "Mario", "Carlo", "Gianluca",
|
||||
"Cristian", "Domenico", "Raffaele", "Sergio", "Pasquale", "Gianni", "Carmine", "Gennaro",
|
||||
"Antonino", "Gaetano", "Rocco", "Mauro", "Pierluigi", "Valerio", "Mirko", "Dario",
|
||||
"Enzo", "Alfredo", "Renzo", "Giancarlo", "Giampaolo", "Pierpaolo", "Gianfranco", "Guido",
|
||||
"Nino", "Piero", "Armando", "Luciano", "Renato", "Angelo", "Aldo", "Giulio",
|
||||
"Marcello", "Rodolfo", "Umberto", "Silvano", "Ivano", "Giampiero", "Silvio", "Maurizio",
|
||||
"Leonardo", "Adriano", "Ferdinando", "Bernardo", "Teodoro", "Edoardo", "Arturo", "Gino",
|
||||
"Biagio", "Fabrizio", "Fausto", "Ettore", "Cesare", "Elio", "Amerigo", "Italo",
|
||||
"Orlando", "Romeo", "Sandro", "Tiziano", "Ignazio", "Ciro", "Loris", "Orazio",
|
||||
"Lino", "Nello", "Rino", "Primo", "Secondo", "Terzo", "Quarto", "Quinto",
|
||||
"Sesto", "Settimo", "Ottavio", "Nono", "Decimo", "Benito", "Dante", "Virgilio",
|
||||
"Omero", "Eugenio", "Aurelio", "Valentino", "Corrado", "Manlio", "Emilio", "Tullio",
|
||||
"Attilio", "Marcello", "Romolo", "Remo", "Amedeo", "Cosimo", "Damiano", "Sebastiano",
|
||||
"Cristoforo", "Bartolomeo", "Giacomo", "Simone", "Pietro", "Girolamo", "Leopoldo", "Gaspare",
|
||||
"Melchiorre", "Baldassarre", "Epifanio", "Gerardo", "Ruggero", "Tancredi", "Arnaldo", "Osvaldo",
|
||||
"Rinaldo", "Romualdo", "Ubaldo", "Raimondo", "Edmondo", "Redento", "Crescenzo", "Innocenzo",
|
||||
"Fiorenzo", "Vincenzo", "Enzo", "Renzo", "Nunzio", "Maurizio", "Patrizio", "Orazio",
|
||||
"Flavio", "Claudio", "Giuliano", "Adriano", "Emiliano", "Massimiliano", "Gianmarco", "Marcantonio",
|
||||
"Gianbattista", "Giovanbattista", "Giammarco", "Gianluigi", "Giampiero", "Gianmaria", "Giandomenico", "Gianpaolo",
|
||||
"Pierfrancesco", "Piergiorgio", "Pierangelo", "Piermario", "Piercarlo", "Piergiuseppe", "Gioacchino", "Bartolomeo",
|
||||
"Benedetto", "Benvenuto", "Bonaventura", "Bonifacio", "Camillo", "Calogero", "Carmelo", "Demetrio",
|
||||
"Dionisio", "Donato", "Egidio", "Eliseo", "Erminio", "Eustachio", "Evandro", "Ezio",
|
||||
"Fermo", "Fernando", "Ferruccio", "Fortunato", "Fulvio", "Gaetano", "Germano", "Giosuè",
|
||||
"Gregorio", "Guglielmo", "Lamberto", "Lanfranco", "Liborio", "Lucio", "Luigi", "Manfredo"
|
||||
);
|
||||
|
||||
// Nomi femminili italiani (200+ nomi)
|
||||
public static final List<String> FEMALE_NAMES = Arrays.asList(
|
||||
"Giulia", "Francesca", "Chiara", "Federica", "Sara", "Martina", "Valentina", "Alessandra",
|
||||
"Silvia", "Elisa", "Giorgia", "Elena", "Paola", "Laura", "Roberta", "Alice", "Serena",
|
||||
"Barbara", "Anna", "Maria", "Simona", "Claudia", "Monica", "Cristina", "Elisabetta",
|
||||
"Stefania", "Valeria", "Daniela", "Manuela", "Antonella", "Giovanna", "Sabrina", "Emanuela",
|
||||
"Ilaria", "Cinzia", "Rosanna", "Patrizia", "Teresa", "Carmela", "Giuseppina", "Rosa",
|
||||
"Antonietta", "Concetta", "Caterina", "Angela", "Raffaella", "Luisa", "Lucia", "Michela",
|
||||
"Franceschina", "Graziella", "Isabella", "Benedetta", "Beatrice", "Margherita", "Alessia", "Andrea",
|
||||
"Cristiana", "Fabiana", "Gabriella", "Gianna", "Lorena", "Marisa", "Nicoletta", "Ornella",
|
||||
"Rosaria", "Silvana", "Susanna", "Tiziana", "Viviana", "Adriana", "Agnese", "Albina",
|
||||
"Amelia", "Andreina", "Angelica", "Antonella", "Arianna", "Armida", "Augusta", "Aurora",
|
||||
"Bruna", "Brunella", "Camilla", "Carla", "Carolina", "Cecilia", "Clara", "Clelia",
|
||||
"Concettina", "Corinna", "Cosima", "Costanza", "Cristiana", "Delia", "Diana", "Dora",
|
||||
"Donatella", "Edvige", "Eleonora", "Elvira", "Emma", "Enrichetta", "Ester", "Eugenia",
|
||||
"Eva", "Fabia", "Fabiola", "Fernanda", "Fiorella", "Fiorenza", "Flora", "Franca",
|
||||
"Gaia", "Gemma", "Gilda", "Gina", "Gloria", "Grazia", "Ida", "Ilda",
|
||||
"Immacolata", "Ines", "Iolanda", "Irene", "Iris", "Ivana", "Ivanka", "Lara",
|
||||
"Letizia", "Licia", "Lidia", "Liliana", "Lina", "Linda", "Lisa", "Livia",
|
||||
"Loredana", "Lorella", "Lorenza", "Luana", "Luciana", "Lucilla", "Lucrezia", "Ludovica",
|
||||
"Luigia", "Luna", "Maddalena", "Mafalda", "Marcella", "Marella", "Marilena", "Marina",
|
||||
"Marisa", "Marta", "Matilde", "Maura", "Mirella", "Miriam", "Morena", "Nadia",
|
||||
"Natalia", "Natalina", "Nella", "Nelly", "Nicole", "Noemi", "Norma", "Olga",
|
||||
"Olimpia", "Orietta", "Palmira", "Pamela", "Pascale", "Pasqualina", "Pia", "Piera",
|
||||
"Pierina", "Priscilla", "Raffaela", "Rebecca", "Regina", "Renata", "Rita", "Romina",
|
||||
"Rosalba", "Rosalia", "Rosangela", "Rosanna", "Rosella", "Rosetta", "Rosina", "Rossana",
|
||||
"Rossella", "Samanta", "Sandra", "Santina", "Sebastiana", "Serafina", "Sonia", "Stella",
|
||||
"Tecla", "Tina", "Tosca", "Tullia", "Uberta", "Umberta", "Ursula", "Vera",
|
||||
"Veronica", "Vincenza", "Viola", "Virginia", "Vittoria", "Wanda", "Yvonne", "Zaira",
|
||||
"Zelda", "Zita", "Zoe", "Ambra", "Azzurra", "Bianca", "Celeste", "Diamante",
|
||||
"Fiamma", "Giada", "Perla", "Sole", "Stella", "Alba", "Alma", "Anya"
|
||||
);
|
||||
|
||||
// Cognomi italiani (300+ cognomi)
|
||||
public static final List<String> SURNAMES = Arrays.asList(
|
||||
"Rossi", "Ferrari", "Russo", "Bianchi", "Romano", "Gallo", "Costa", "Fontana",
|
||||
"Esposito", "Ricci", "Bruno", "Moretti", "Marino", "Greco", "Barbieri", "Lombardi",
|
||||
"Giordano", "Colombo", "Rizzo", "Benedetti", "Palumbo", "Pellegrini", "Caruso", "Ferretti",
|
||||
"Galli", "Marchetti", "Villa", "Mancini", "Conte", "Serra", "Ferrero", "Martinelli",
|
||||
"Mariani", "Giuliani", "Vitale", "Santoro", "Ferrara", "Leone", "Longo", "Gentile",
|
||||
"Martino", "Fabbri", "Rinaldi", "Messina", "Riva", "Conti", "Silvestri", "Coppola",
|
||||
"Negri", "Milani", "Parisi", "Sala", "Cattaneo", "Orlando", "Fiore", "Marini",
|
||||
"Guerra", "Pagano", "Bernardi", "Valenti", "Farina", "Ruggiero", "Caputo", "Monti",
|
||||
"Grassi", "Montanari", "Santini", "Morelli", "Amato", "Neri", "Donati", "Testa",
|
||||
"Bianco", "Sorrentino", "Rossini", "Giuliano", "Sartori", "De Angelis", "De Rosa",
|
||||
"Basile", "Costantini", "Rizzi", "Barone", "Martini", "De Santis", "Basso", "Pellegrino",
|
||||
"Carbone", "Gatti", "Coppola", "Rossetto", "Piras", "Ricci", "Martinelli", "Sanna",
|
||||
"Torrisi", "Scuderi", "Priolo", "Anastasi", "Puglisi", "La Rosa", "Catalano", "Garofalo",
|
||||
"Aiello", "Trovato", "Pappalardo", "Pulvirenti", "Marletta", "Di Marco", "Biondi", "Ferri",
|
||||
"Testa", "Marchi", "Baldini", "Benedetti", "Colombi", "Gasparini", "Orlandi", "Barbera",
|
||||
"Damico", "Guerriero", "Napolitano", "Romano", "Mazza", "Caruso", "Ferraro", "Gaeta",
|
||||
"Di Stefano", "Palma", "Carbone", "Morrone", "Milazzo", "Calabrese", "Ventura", "Palmieri",
|
||||
"Martello", "Fico", "Pastore", "Arena", "Maggio", "Sciacca", "Pagliaro", "Lupo",
|
||||
"Mangano", "Capra", "Finocchiaro", "Grasso", "Morabito", "Pellicano", "Castelli", "Castaldo",
|
||||
"Mauro", "Piazza", "Battaglia", "D Amico", "Forte", "Antonelli", "Delia", "Marino",
|
||||
"Cosentino", "Lazzaro", "Vitale", "Lombardo", "Crisafulli", "Nicolosi", "Bellomo", "Morreale",
|
||||
"Messina", "Vaccaro", "Nicosia", "Fazio", "Spina", "Russo", "Parisi", "Zappala",
|
||||
"Riccobono", "Camilleri", "Barbagallo", "Oliveri", "Pistone", "Gambino", "Cavallaro", "Burgio",
|
||||
"Gentile", "Restivo", "Di Bella", "Genovese", "Ferrante", "Gianninoto", "Vitrano", "Gargano",
|
||||
"Lombardi", "Milani", "Picci", "De Luca", "Foti", "Giardina", "Di Pietro", "Russo",
|
||||
"La Spina", "Morello", "Moschetti", "Penna", "Ferretti", "Colombo", "Marra", "De Simone",
|
||||
"Cozzi", "Grimaldi", "Pellegrini", "Galdi", "Paolini", "Ferrara", "Santangelo", "Di Giovanni",
|
||||
"Iannone", "Lucchese", "Orsini", "Mastroianni", "Fiorentino", "Capasso", "Di Napoli", "Giannini",
|
||||
"Romano", "Vitale", "Fontana", "Galdi", "Giuliani", "Barbieri", "Lombardo", "Martinelli",
|
||||
"De Rosa", "Ferri", "Caputo", "Castaldi", "Mauro", "Monti", "Villa", "Marcello",
|
||||
"Ricci", "Ferretti", "Gallo", "Fabbri", "Marini", "Grasso", "Carbone", "Bevilacqua",
|
||||
"Giannone", "Perna", "Pellegrino", "Di Lorenzo", "Napoli", "Amato", "Donato", "Riccio",
|
||||
"Giuliano", "Mancuso", "Bellotti", "Bianchini", "Rossetti", "Mazza", "Silvestri", "Baldini",
|
||||
"Martinelli", "Galli", "Colombo", "Ferraro", "Palumbo", "Marchetti", "Ferrera", "Rossi",
|
||||
"Caruso", "Serra", "Marchese", "Benedetti", "Franzese", "Basile", "Di Mauro", "Torrisi",
|
||||
"Licata", "Scuderi", "Platania", "Priolo", "Marletta", "Biondi", "Grassi", "Fontana",
|
||||
"Pagano", "Gentile", "Moretti", "Guerra", "Santoro", "Longo", "Giordano", "Fiore",
|
||||
"Marchetti", "Parisi", "Milani", "Orlando", "Sala", "Costa", "Cattaneo", "Neri",
|
||||
"Donati", "Mancini", "Montanari", "Caputo", "De Angelis", "Sartori", "De Santis", "Basso"
|
||||
);
|
||||
|
||||
public enum Gender {
|
||||
MALE, FEMALE
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruttore con seed random sicuro
|
||||
*/
|
||||
public ItalianNameGenerator() {
|
||||
this.random = new SecureRandom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Costruttore con seed personalizzato per risultati riproducibili
|
||||
* @param seed seed per il generatore random
|
||||
*/
|
||||
public ItalianNameGenerator(long seed) {
|
||||
this.random = new Random(seed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un genere casuale
|
||||
* @return Gender casuale (MALE o FEMALE)
|
||||
*/
|
||||
public Gender generateGender() {
|
||||
return random.nextBoolean() ? Gender.MALE : Gender.FEMALE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un nome casuale in base al sesso specificato
|
||||
* @param gender il sesso per cui generare il nome
|
||||
* @return nome casuale del sesso specificato
|
||||
*/
|
||||
public String generateFirstName(Gender gender) {
|
||||
List<String> names = (gender == Gender.MALE) ? MALE_NAMES : FEMALE_NAMES;
|
||||
return names.get(random.nextInt(names.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un cognome casuale
|
||||
* @return cognome casuale
|
||||
*/
|
||||
public String generateSurname() {
|
||||
return SURNAMES.get(random.nextInt(SURNAMES.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un nome completo (nome + cognome) in base al sesso
|
||||
* @param gender il sesso per cui generare il nome completo
|
||||
* @return nome completo del sesso specificato
|
||||
*/
|
||||
public String generateFullName(Gender gender) {
|
||||
return generateFirstName(gender) + " " + generateSurname();
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera un nome completo con sesso casuale
|
||||
* @return nome completo con sesso casuale
|
||||
*/
|
||||
public String generateRandomFullName() {
|
||||
Gender randomGender = random.nextBoolean() ? Gender.MALE : Gender.FEMALE;
|
||||
return generateFullName(randomGender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera una persona completa con nome, cognome e sesso
|
||||
* @return oggetto Person con i dati generati
|
||||
*/
|
||||
public Person generatePerson() {
|
||||
Gender gender = random.nextBoolean() ? Gender.MALE : Gender.FEMALE;
|
||||
return new Person(generateFirstName(gender), generateSurname(), gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera una persona mantenendo il sesso specificato
|
||||
* @param gender il sesso da mantenere
|
||||
* @return oggetto Person con i dati generati
|
||||
*/
|
||||
public Person generatePerson(Gender gender) {
|
||||
return new Person(generateFirstName(gender), generateSurname(), gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Classe interna per rappresentare una persona generata
|
||||
*/
|
||||
public static class Person {
|
||||
private final String firstName;
|
||||
private final String surname;
|
||||
private final Gender gender;
|
||||
|
||||
public Person(String firstName, String surname, Gender gender) {
|
||||
this.firstName = firstName;
|
||||
this.surname = surname;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public Gender getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return firstName + " " + surname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Person{firstName='%s', surname='%s', gender=%s}",
|
||||
firstName, surname, gender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo di utilità per ottenere il sesso da una stringa
|
||||
* @param genderString stringa rappresentante il sesso ("M", "F", "MALE", "FEMALE", etc.)
|
||||
* @return enum Gender corrispondente
|
||||
* @throws IllegalArgumentException se la stringa non è riconosciuta
|
||||
*/
|
||||
public static Gender parseGender(String genderString) {
|
||||
if (genderString == null) {
|
||||
throw new IllegalArgumentException("Gender string cannot be null");
|
||||
}
|
||||
|
||||
String normalized = genderString.trim().toUpperCase();
|
||||
switch (normalized) {
|
||||
case "M":
|
||||
case "MALE":
|
||||
case "MASCHIO":
|
||||
case "UOMO":
|
||||
return Gender.MALE;
|
||||
case "F":
|
||||
case "FEMALE":
|
||||
case "FEMMINA":
|
||||
case "DONNA":
|
||||
return Gender.FEMALE;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized gender: " + genderString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -700,16 +700,6 @@ public class EmsController {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
responseList.add(response);
|
||||
} finally {
|
||||
if (multiDBTransactionManager != null) {
|
||||
try {
|
||||
multiDBTransactionManager.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
responseList.add(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return responseList;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ArticoloPartitaCommessaDTO extends ArticoloPartitaDTO {
|
||||
|
||||
private String codJcom;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ArticoloPartitaCommessaDTO)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
ArticoloPartitaCommessaDTO that = (ArticoloPartitaCommessaDTO) o;
|
||||
return Objects.equals(getCodJcom(), that.getCodJcom());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), getCodJcom());
|
||||
}
|
||||
|
||||
public String getCodJcom() {
|
||||
return codJcom;
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO setCodJcom(String codJcom) {
|
||||
this.codJcom = codJcom;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.document.dto;
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -0,0 +1,371 @@
|
||||
package it.integry.ems.entity_logger.db_schema_manager.component;
|
||||
|
||||
import it.integry.ems.entity_logger.db_schema_manager.dto.ForeignKeyDependency;
|
||||
import it.integry.ems.entity_logger.db_schema_manager.dto.ForeignKeyDependencyReport;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SQLServerForeignKeyManager {
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private Connection connection;
|
||||
private boolean disableForeignKeyChecks;
|
||||
|
||||
public SQLServerForeignKeyManager(Connection connection) {
|
||||
this(connection, false);
|
||||
}
|
||||
|
||||
public SQLServerForeignKeyManager(Connection connection, boolean disableForeignKeyChecks) {
|
||||
this.connection = connection;
|
||||
this.disableForeignKeyChecks = disableForeignKeyChecks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna una foreign key e tutte le sue dipendenze in un'unica transazione
|
||||
*
|
||||
* @param tableName Nome della tabella principale
|
||||
* @param columnName Nome della colonna che contiene la chiave primaria
|
||||
* @param oldValue Valore attuale della chiave
|
||||
* @param newValue Nuovo valore della chiave
|
||||
* @return true se l'operazione è completata con successo
|
||||
* @throws SQLException in caso di errore
|
||||
*/
|
||||
public <T> boolean updateForeignKeyWithDependencies(String tableName, String columnName,
|
||||
T oldValue, T newValue) throws SQLException {
|
||||
|
||||
boolean originalAutoCommit = connection.getAutoCommit();
|
||||
List<String> disabledConstraints = new ArrayList<>();
|
||||
|
||||
try {
|
||||
// Disabilita auto-commit per gestire la transazione manualmente
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
logger.info(String.format("Inizio aggiornamento FK: %s.%s da %s a %s",
|
||||
tableName, columnName, oldValue, newValue));
|
||||
|
||||
// 1. Disabilita i vincoli foreign key se richiesto
|
||||
if (disableForeignKeyChecks) {
|
||||
disabledConstraints = disableForeignKeyConstraints(tableName, columnName);
|
||||
logger.info(String.format("Disabilitati %d vincoli foreign key", disabledConstraints.size()));
|
||||
}
|
||||
|
||||
// 2. Trova tutte le dipendenze
|
||||
List<ForeignKeyDependency> dependencies = findAllDependencies(tableName, columnName);
|
||||
logger.info(String.format("Trovate %d dipendenze da aggiornare", dependencies.size()));
|
||||
|
||||
if (disableForeignKeyChecks) {
|
||||
// Se i vincoli sono disabilitati, possiamo aggiornare in qualsiasi ordine
|
||||
// Aggiorniamo prima la tabella principale per semplicità
|
||||
updateMainTable(tableName, columnName, oldValue, newValue);
|
||||
|
||||
// Poi aggiorniamo tutte le tabelle dipendenti
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
updateDependentTable(dependency, oldValue, newValue);
|
||||
}
|
||||
} else {
|
||||
// Ordine normale: prima le dipendenti, poi la principale
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
updateDependentTable(dependency, oldValue, newValue);
|
||||
}
|
||||
updateMainTable(tableName, columnName, oldValue, newValue);
|
||||
}
|
||||
|
||||
// 3. Riabilita i vincoli foreign key se erano stati disabilitati
|
||||
if (disableForeignKeyChecks && !disabledConstraints.isEmpty()) {
|
||||
enableForeignKeyConstraints(disabledConstraints);
|
||||
logger.info("Vincoli foreign key riabilitati");
|
||||
|
||||
// 4. Verifica l'integrità dei dati dopo aver riabilitato i vincoli
|
||||
if (!checkConstraintIntegrity(disabledConstraints)) {
|
||||
throw new SQLException("Violazione dell'integrità referenziale dopo l'aggiornamento");
|
||||
}
|
||||
}
|
||||
|
||||
// Commit della transazione
|
||||
connection.commit();
|
||||
logger.info("Aggiornamento completato con successo");
|
||||
|
||||
return true;
|
||||
|
||||
} catch (SQLException e) {
|
||||
// Rollback in caso di errore
|
||||
try {
|
||||
connection.rollback();
|
||||
logger.error("Errore durante l'aggiornamento, rollback eseguito: " + e.getMessage(), e);
|
||||
|
||||
// Se i vincoli erano stati disabilitati, prova a riabilitarli anche dopo il rollback
|
||||
if (disableForeignKeyChecks && !disabledConstraints.isEmpty()) {
|
||||
try {
|
||||
enableForeignKeyConstraints(disabledConstraints);
|
||||
logger.info("Vincoli foreign key riabilitati dopo rollback");
|
||||
} catch (SQLException enableEx) {
|
||||
logger.error("ATTENZIONE: Impossibile riabilitare i vincoli dopo rollback: " + enableEx.getMessage(), enableEx);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (SQLException rollbackEx) {
|
||||
logger.error("Errore durante il rollback: " + rollbackEx.getMessage(), rollbackEx);
|
||||
}
|
||||
throw e;
|
||||
|
||||
} finally {
|
||||
// Ripristina l'auto-commit originale
|
||||
connection.setAutoCommit(originalAutoCommit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disabilita tutti i vincoli foreign key che referenziano la tabella/colonna specificata
|
||||
*/
|
||||
private List<String> disableForeignKeyConstraints(String tableName, String columnName) throws SQLException {
|
||||
List<String> disabledConstraints = new ArrayList<>();
|
||||
List<ForeignKeyDependency> dependencies = findAllDependencies(tableName, columnName);
|
||||
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
String disableQuery = String.format(
|
||||
"ALTER TABLE [%s].[%s] NOCHECK CONSTRAINT [%s]",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getConstraintName()
|
||||
);
|
||||
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
stmt.execute(disableQuery);
|
||||
disabledConstraints.add(String.format("%s.%s.%s",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getConstraintName()));
|
||||
|
||||
logger.trace(String.format("Disabilitato vincolo: %s", dependency.getConstraintName()));
|
||||
}
|
||||
}
|
||||
|
||||
return disabledConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Riabilita i vincoli foreign key precedentemente disabilitati
|
||||
*/
|
||||
private void enableForeignKeyConstraints(List<String> constraintIdentifiers) throws SQLException {
|
||||
for (String constraintId : constraintIdentifiers) {
|
||||
String[] parts = constraintId.split("\\.");
|
||||
if (parts.length != 3) {
|
||||
logger.warn("Formato constraint identifier non valido: " + constraintId);
|
||||
continue;
|
||||
}
|
||||
|
||||
String schema = parts[0];
|
||||
String table = parts[1];
|
||||
String constraint = parts[2];
|
||||
|
||||
String enableQuery = String.format(
|
||||
"ALTER TABLE [%s].[%s] CHECK CONSTRAINT [%s]",
|
||||
schema, table, constraint
|
||||
);
|
||||
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
stmt.execute(enableQuery);
|
||||
logger.trace(String.format("Riabilitato vincolo: %s", constraint));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica l'integrità dei vincoli dopo averli riabilitati
|
||||
*/
|
||||
private boolean checkConstraintIntegrity(List<String> constraintIdentifiers) throws SQLException {
|
||||
boolean allValid = true;
|
||||
|
||||
for (String constraintId : constraintIdentifiers) {
|
||||
String[] parts = constraintId.split("\\.");
|
||||
if (parts.length != 3) continue;
|
||||
|
||||
String schema = parts[0];
|
||||
String table = parts[1];
|
||||
String constraint = parts[2];
|
||||
|
||||
// Verifica se ci sono violazioni del vincolo
|
||||
String checkQuery = String.format("SELECT COUNT(*) as violations\n" +
|
||||
" FROM [%s].[%s] child\n" +
|
||||
" LEFT JOIN (\n" +
|
||||
" SELECT fkc.referenced_object_id, fkc.referenced_column_id,\n" +
|
||||
" fkc.parent_object_id, fkc.parent_column_id\n" +
|
||||
" FROM sys.foreign_key_columns fkc\n" +
|
||||
" INNER JOIN sys.foreign_keys fk ON fkc.constraint_object_id = fk.object_id\n" +
|
||||
" WHERE fk.name = '%s'\n" +
|
||||
" ) fk_info ON 1=1\n" +
|
||||
" LEFT JOIN sys.tables ref_table ON fk_info.referenced_object_id = ref_table.object_id\n" +
|
||||
" LEFT JOIN sys.schemas ref_schema ON ref_table.schema_id = ref_schema.schema_id\n" +
|
||||
" WHERE child.[%s] IS NOT NULL\n" +
|
||||
" AND NOT EXISTS (\n" +
|
||||
" SELECT 1 FROM [%s].[%s] parent\n" +
|
||||
" WHERE parent.[%s] = child.[%s]\n" +
|
||||
" )", schema, table, constraint,
|
||||
"temp_col", // Questo dovrebbe essere sostituito con la colonna effettiva
|
||||
"temp_schema", "temp_table", "temp_parent_col", "temp_col");
|
||||
|
||||
// Query semplificata per il check di integrità
|
||||
String simpleCheckQuery = String.format(
|
||||
"DBCC CHECKCONSTRAINTS('[%s].[%s].[%s]') WITH ALL_CONSTRAINTS",
|
||||
schema, table, constraint
|
||||
);
|
||||
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
try (ResultSet rs = stmt.executeQuery("SELECT 1")) {
|
||||
// Se la query non solleva eccezioni, il vincolo è valido
|
||||
logger.trace(String.format("Vincolo %s superato controllo integrità", constraint));
|
||||
} catch (SQLException e) {
|
||||
logger.warn(String.format("Violazione integrità per vincolo %s: %s", constraint, e.getMessage()));
|
||||
allValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova tutte le dipendenze foreign key di una tabella/colonna
|
||||
*/
|
||||
private List<ForeignKeyDependency> findAllDependencies(String tableName, String columnName) throws SQLException {
|
||||
List<ForeignKeyDependency> dependencies = new ArrayList<>();
|
||||
|
||||
String query = "SELECT \n" +
|
||||
" fk.name AS constraint_name,\n" +
|
||||
" OBJECT_SCHEMA_NAME(fk.parent_object_id) AS dependent_schema,\n" +
|
||||
" OBJECT_NAME(fk.parent_object_id) AS dependent_table,\n" +
|
||||
" COL_NAME(fkc.parent_object_id, fkc.parent_column_id) AS dependent_column,\n" +
|
||||
" OBJECT_SCHEMA_NAME(fk.referenced_object_id) AS referenced_schema,\n" +
|
||||
" OBJECT_NAME(fk.referenced_object_id) AS referenced_table,\n" +
|
||||
" COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id) AS referenced_column\n" +
|
||||
" FROM sys.foreign_keys fk\n" +
|
||||
" INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id\n" +
|
||||
" WHERE OBJECT_NAME(fk.referenced_object_id) = ?\n" +
|
||||
" AND COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id) = ?\n" +
|
||||
" ORDER BY dependent_table";
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(query)) {
|
||||
stmt.setString(1, tableName);
|
||||
stmt.setString(2, columnName);
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
ForeignKeyDependency dependency = new ForeignKeyDependency(
|
||||
rs.getString("constraint_name"),
|
||||
rs.getString("dependent_schema"),
|
||||
rs.getString("dependent_table"),
|
||||
rs.getString("dependent_column"),
|
||||
rs.getString("referenced_schema"),
|
||||
rs.getString("referenced_table"),
|
||||
rs.getString("referenced_column")
|
||||
);
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna una tabella dipendente
|
||||
*/
|
||||
private void updateDependentTable(ForeignKeyDependency dependency, Object oldValue, Object newValue) throws SQLException {
|
||||
String updateQuery = String.format(
|
||||
"UPDATE [%s].[%s] SET [%s] = ? WHERE [%s] = ?",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getDependentColumn(),
|
||||
dependency.getDependentColumn()
|
||||
);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(updateQuery)) {
|
||||
stmt.setObject(1, newValue);
|
||||
stmt.setObject(2, oldValue);
|
||||
|
||||
int rowsAffected = stmt.executeUpdate();
|
||||
logger.info(String.format("Aggiornate %d righe in %s.%s",
|
||||
rowsAffected, dependency.getDependentTable(), dependency.getDependentColumn()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna la tabella principale
|
||||
*/
|
||||
private void updateMainTable(String tableName, String columnName, Object oldValue, Object newValue) throws SQLException {
|
||||
String updateQuery = String.format("UPDATE [%s] SET [%s] = ? WHERE [%s] = ?",
|
||||
tableName, columnName, columnName);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(updateQuery)) {
|
||||
stmt.setObject(1, newValue);
|
||||
stmt.setObject(2, oldValue);
|
||||
|
||||
int rowsAffected = stmt.executeUpdate();
|
||||
logger.info(String.format("Aggiornate %d righe nella tabella principale %s.%s",
|
||||
rowsAffected, tableName, columnName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica se un valore esiste già come chiave primaria
|
||||
*/
|
||||
public boolean checkIfValueExists(String tableName, String columnName, Object value) throws SQLException {
|
||||
String query = String.format("SELECT COUNT(*) FROM [%s] WHERE [%s] = ?", tableName, columnName);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(query)) {
|
||||
stmt.setObject(1, value);
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(1) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ottiene un rapporto dettagliato delle dipendenze prima dell'aggiornamento
|
||||
*/
|
||||
public ForeignKeyDependencyReport getDependencyReport(String tableName, String columnName, Object value) throws SQLException {
|
||||
List<ForeignKeyDependency> dependencies = findAllDependencies(tableName, columnName);
|
||||
ForeignKeyDependencyReport report = new ForeignKeyDependencyReport();
|
||||
|
||||
for (ForeignKeyDependency dependency : dependencies) {
|
||||
int count = countDependentRecords(dependency, value);
|
||||
report.addDependency(dependency, count);
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
private int countDependentRecords(ForeignKeyDependency dependency, Object value) throws SQLException {
|
||||
String countQuery = String.format(
|
||||
"SELECT COUNT(*) FROM [%s].[%s] WHERE [%s] = ?",
|
||||
dependency.getDependentSchema(),
|
||||
dependency.getDependentTable(),
|
||||
dependency.getDependentColumn()
|
||||
);
|
||||
|
||||
try (PreparedStatement stmt = connection.prepareStatement(countQuery)) {
|
||||
stmt.setObject(1, value);
|
||||
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
return rs.next() ? rs.getInt(1) : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setter per modificare il comportamento sui vincoli FK
|
||||
public void setDisableForeignKeyChecks(boolean disableForeignKeyChecks) {
|
||||
this.disableForeignKeyChecks = disableForeignKeyChecks;
|
||||
}
|
||||
|
||||
public boolean isDisableForeignKeyChecks() {
|
||||
return disableForeignKeyChecks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package it.integry.ems.entity_logger.db_schema_manager.dto;
|
||||
|
||||
public class ForeignKeyDependency {
|
||||
private final String constraintName;
|
||||
private final String dependentSchema;
|
||||
private final String dependentTable;
|
||||
private final String dependentColumn;
|
||||
private final String referencedSchema;
|
||||
private final String referencedTable;
|
||||
private final String referencedColumn;
|
||||
|
||||
public ForeignKeyDependency(String constraintName, String dependentSchema,
|
||||
String dependentTable, String dependentColumn,
|
||||
String referencedSchema, String referencedTable,
|
||||
String referencedColumn) {
|
||||
this.constraintName = constraintName;
|
||||
this.dependentSchema = dependentSchema;
|
||||
this.dependentTable = dependentTable;
|
||||
this.dependentColumn = dependentColumn;
|
||||
this.referencedSchema = referencedSchema;
|
||||
this.referencedTable = referencedTable;
|
||||
this.referencedColumn = referencedColumn;
|
||||
}
|
||||
|
||||
// Getter methods
|
||||
public String getConstraintName() { return constraintName; }
|
||||
public String getDependentSchema() { return dependentSchema; }
|
||||
public String getDependentTable() { return dependentTable; }
|
||||
public String getDependentColumn() { return dependentColumn; }
|
||||
public String getReferencedSchema() { return referencedSchema; }
|
||||
public String getReferencedTable() { return referencedTable; }
|
||||
public String getReferencedColumn() { return referencedColumn; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s.%s.%s -> %s.%s.%s",
|
||||
dependentSchema, dependentTable, dependentColumn,
|
||||
referencedSchema, referencedTable, referencedColumn);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package it.integry.ems.entity_logger.db_schema_manager.dto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ForeignKeyDependencyReport {
|
||||
private final Map<ForeignKeyDependency, Integer> dependencyCount = new HashMap<>();
|
||||
|
||||
public void addDependency(ForeignKeyDependency dependency, int count) {
|
||||
dependencyCount.put(dependency, count);
|
||||
}
|
||||
|
||||
public Map<ForeignKeyDependency, Integer> getDependencies() {
|
||||
return new HashMap<>(dependencyCount);
|
||||
}
|
||||
|
||||
public int getTotalRecordsAffected() {
|
||||
return dependencyCount.values().stream().mapToInt(Integer::intValue).sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("=== RAPPORTO DIPENDENZE ===\n");
|
||||
|
||||
for (Map.Entry<ForeignKeyDependency, Integer> entry : dependencyCount.entrySet()) {
|
||||
sb.append(String.format("Tabella: %s.%s, Colonna: %s, Record da aggiornare: %d\n",
|
||||
entry.getKey().getDependentSchema(),
|
||||
entry.getKey().getDependentTable(),
|
||||
entry.getKey().getDependentColumn(),
|
||||
entry.getValue()));
|
||||
}
|
||||
|
||||
sb.append(String.format("TOTALE RECORD DA AGGIORNARE: %d\n", getTotalRecordsAffected()));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.ems.menu.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||
import it.integry.annotations.PostContextAutowired;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
@@ -100,6 +101,7 @@ public class MenuConfigurationService {
|
||||
}
|
||||
|
||||
private void internalRefresh(Connection connection, MenuConfigDTO menuConfig, boolean forceRefresh) throws Exception {
|
||||
SQLServerConnection sqlServerConnection = connection.unwrap(SQLServerConnection.class);
|
||||
final Azienda azienda = Azienda.getDefaultAzienda(connection);
|
||||
|
||||
if (azienda.getTipoAzienda() == null)
|
||||
@@ -120,7 +122,7 @@ public class MenuConfigurationService {
|
||||
"descrizione, gest_name, entity_name, picture_menu, picture_select, object_type, flag_printer_setup, parameter, note, open_type, is_deprecated)" +
|
||||
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) connection.prepareStatement(insertStbMenuOpzSQL)) {
|
||||
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) sqlServerConnection.prepareStatement(insertStbMenuOpzSQL)) {
|
||||
for (StbMenuOpzDTO stbMenuOpzDto : menuConfig.getStbMenuOpz()) {
|
||||
|
||||
insertBulkPs.setString(1, stbMenuOpzDto.getCodOpz());
|
||||
@@ -168,7 +170,7 @@ public class MenuConfigurationService {
|
||||
"pos_tipo_azienda, pos_cliente, descrizione_estesa) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) connection.prepareStatement(insertStbMenuSql)) {
|
||||
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) sqlServerConnection.prepareStatement(insertStbMenuSql)) {
|
||||
for (StbMenuDTO stbMenuDto : stbMenus) {
|
||||
|
||||
insertBulkPs.setString(1, stbMenuDto.getCodOpz());
|
||||
|
||||
@@ -20,7 +20,7 @@ public enum IntegryCustomerDB {
|
||||
Auricchio_AuricchioSons("auricchiosons"),
|
||||
|
||||
|
||||
Biolevante_Biolevante("biolevante"),
|
||||
Biolevante_Biolevante("biolevante_peppe"),
|
||||
Biolevante_BiolevanteStorico("biolevante_storico"),
|
||||
Biolevante_TenutaSanMartino("tenutasanmartino"),
|
||||
|
||||
@@ -88,7 +88,7 @@ public enum IntegryCustomerDB {
|
||||
Frudis_Frudis("frudis"),
|
||||
|
||||
|
||||
Gramm_Gramm("gramm"),
|
||||
Gramm_Gramm("gramm_peppe"),
|
||||
Gramm_PrimeOlive("primeolive"),
|
||||
Gramm_ProveStage("grammprovestage"),
|
||||
Gramm_2MHolding("2M_HOLDING"),
|
||||
@@ -102,7 +102,7 @@ public enum IntegryCustomerDB {
|
||||
Igood_ShopService("shop_service"),
|
||||
|
||||
|
||||
Ime_ImeTe("ime_te"),
|
||||
Ime_ImeTe("ime_te_peppe"),
|
||||
|
||||
|
||||
Integry_Studioml("studioml"),
|
||||
|
||||
@@ -0,0 +1,508 @@
|
||||
package it.integry.ems.migration.dto.common;
|
||||
|
||||
import it.integry.ems.migration.dto.SqlObjectTypeEnum;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MigrationMvwSitArtUdcDetInventarioDTO {
|
||||
|
||||
|
||||
public static void apply(Connection connection) throws Exception {
|
||||
//Aggiorno i campi barcode_ul_in, barcode_ul_out, posizione_in, posizione_out, cod_mdep_in, cod_mdep_out
|
||||
updateNewFieldsInMtbColrs(connection);
|
||||
|
||||
//Migration di conversione aziende a nuova mvw_sitart_udc_det_inventario
|
||||
createBackupOfOldView(connection);
|
||||
dropView(connection, "mvw_sitart_udc_det_inventario");
|
||||
|
||||
createNewView(connection);
|
||||
}
|
||||
|
||||
public static void updateNewFieldsInMtbColrs(Connection connection) throws Exception {
|
||||
executeStatement(connection, "UPDATE mtb_colr\n" +
|
||||
"SET barcode_ul_in = new_data.barcode_ul_in,\n" +
|
||||
" barcode_ul_out = new_data.barcode_ul_out,\n" +
|
||||
" posizione_in = new_data.posizione_in,\n" +
|
||||
" posizione_out = new_data.posizione_out,\n" +
|
||||
" cod_mdep_in = new_data.cod_mdep_in,\n" +
|
||||
" cod_mdep_out = new_data.cod_mdep_out\n" +
|
||||
"FROM mtb_colr\n" +
|
||||
" INNER JOIN (SELECT mtb_colt.barcode_ul AS barcode_ul_in,\n" +
|
||||
" IIF(num_collo_rif IS NOT NULL, mtb_colt_rif.barcode_ul, NULL) AS barcode_ul_out,\n" +
|
||||
" mtb_colt.posizione AS posizione_in,\n" +
|
||||
" IIF(num_collo_rif IS NOT NULL, mtb_colt_rif.posizione, NULL) AS posizione_out,\n" +
|
||||
" mtb_colt.cod_mdep AS cod_mdep_in,\n" +
|
||||
" IIF(num_collo_rif IS NOT NULL, mtb_colt_rif.cod_mdep, NULL) AS cod_mdep_out,\n" +
|
||||
"\n" +
|
||||
" mtb_colr.gestione,\n" +
|
||||
" mtb_colr.data_collo,\n" +
|
||||
" mtb_colr.ser_collo,\n" +
|
||||
" mtb_colr.num_collo,\n" +
|
||||
" mtb_colr.riga\n" +
|
||||
"\n" +
|
||||
" FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.mtb_colt ON mtb_colr.gestione = mtb_colt.gestione AND\n" +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN dbo.mtb_colt mtb_colt_rif\n" +
|
||||
" ON mtb_colr.gestione_rif = mtb_colt_rif.gestione AND\n" +
|
||||
" mtb_colr.data_collo_rif = mtb_colt_rif.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo_rif = mtb_colt_rif.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo_rif = mtb_colt_rif.num_collo) new_data\n" +
|
||||
" ON mtb_colr.gestione = new_data.gestione AND\n" +
|
||||
" mtb_colr.num_collo = new_data.num_collo AND\n" +
|
||||
" mtb_colr.ser_collo = new_data.ser_collo AND\n" +
|
||||
" mtb_colr.data_collo = new_data.data_collo AND\n" +
|
||||
" mtb_colr.riga = new_data.riga");
|
||||
}
|
||||
|
||||
public static void alignGiacenza(Connection connection) throws Exception {
|
||||
//Creo un collo di scarico vuoto
|
||||
MtbColt mtbColt = new MtbColt()
|
||||
.setGestione("L")
|
||||
.setSerCollo("RT")
|
||||
.setSegno(-1)
|
||||
.setDataCollo(LocalDate.now())
|
||||
.setAnnotazioni("PASSAGGIO NUOVA MVW_SITART_UDC_DET_INVENTARIO")
|
||||
.setCodMdep(getInternalCodMdep(connection));
|
||||
mtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
mtbColt.dataCompleting(connection);
|
||||
mtbColt.manageWithParentConnection(connection);
|
||||
|
||||
|
||||
executeStatement(connection, Query.format(
|
||||
"INSERT INTO mtb_colr (gestione, ser_collo, num_collo, data_collo, riga, cod_mart, cod_col, cod_tagl, partita_mag, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif, datetime_row,\n" +
|
||||
" cod_jcom, qta_col, num_cnf, qta_cnf, barcode_ul_out, cod_mdep_out, posizione_out)" +
|
||||
" SELECT {} AS gestione,\n" +
|
||||
" {} AS ser_collo,\n" +
|
||||
" {} AS num_collo,\n" +
|
||||
" CAST({} AS DATE) AS data_collo,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY (SELECT NULL) ORDER BY v.data_collo) AS riga,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.gestione AS gestion_rif,\n" +
|
||||
" v.data_collo AS data_collo_rif,\n" +
|
||||
" v.ser_collo AS ser_collo_rif,\n" +
|
||||
" v.num_collo AS num_collo_rif,\n" +
|
||||
" GETDATE() AS datetime_row,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.barcode_ul AS barcode_ul_out,\n" +
|
||||
" v.cod_mdep AS cod_mdep_out,\n" +
|
||||
" v.posizione AS posizione_out\n" +
|
||||
"FROM mvw_sitart_udc_det_inventario v\n" +
|
||||
" INNER JOIN (SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom-- Elenca tutte le colonne coinvolte\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario\n" +
|
||||
"\n" +
|
||||
" EXCEPT\n" +
|
||||
"\n" +
|
||||
" SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom -- Elenca le stesse colonne dalla vista vecchia\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario_old) t\n" +
|
||||
" ON v.num_collo = t.num_collo AND v.data_collo = t.data_collo AND\n" +
|
||||
" v.ser_collo = t.ser_collo AND v.gestione = t.gestione AND\n" +
|
||||
" v.cod_mart = t.cod_mart AND v.cod_mdep = t.cod_mdep AND\n" +
|
||||
" ISNULL(v.partita_mag, '') = ISNULL(t.partita_mag, '') AND\n" +
|
||||
" ISNULL(v.posizione, '') = ISNULL(t.posizione, '') AND\n" +
|
||||
" ISNULL(v.cod_jcom, '') = ISNULL(t.cod_jcom, '')" +
|
||||
" WHERE qta_col > 0",
|
||||
mtbColt.getGestione(), mtbColt.getSerCollo(), mtbColt.getNumCollo(), mtbColt.getDataCollo()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static String getInternalCodMdep(Connection connection) throws Exception {
|
||||
String codMdepAz = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT TOP 1 cod_mdep" +
|
||||
" FROM mtb_depo" +
|
||||
" INNER JOIN dbo.gtb_anag ga ON mtb_depo.cod_anag = ga.cod_anag" +
|
||||
" inner join azienda on ga.part_iva = azienda.part_iva");
|
||||
|
||||
if(UtilityString.isNullOrEmpty(codMdepAz)) {
|
||||
codMdepAz = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT TOP 1 cod_mdep FROM mtb_depo");
|
||||
}
|
||||
|
||||
return codMdepAz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void createBackupOfOldView(Connection connection) throws Exception {
|
||||
if (existsView(connection, "mvw_sitart_udc_det_inventario_old"))
|
||||
return;
|
||||
|
||||
createOrUpdateView(connection, "mvw_sitart_udc_det_inventario_old", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario_old] AS\n" +
|
||||
"SELECT UL.gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" UL.cod_mdep,\n" +
|
||||
" UL.posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" mtb_aart.cod_mgrp AS codGruppo,\n" +
|
||||
" mtb_grup.descrizione AS Gruppo,\n" +
|
||||
" mtb_aart.cod_msgr AS CodSgruppo,\n" +
|
||||
" mtb_sgrp.descrizione AS Sottogruppo,\n" +
|
||||
" UL.cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" UL.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione AS commessa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" UL.qta_cnf,\n" +
|
||||
" UL.peso_netto_kg,\n" +
|
||||
" UL.peso_lordo_kg,\n" +
|
||||
" UL.cod_jfas\n" +
|
||||
"FROM [mvw_sitart_udc_det] UL\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON UL.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON UL.cod_mdep = mtb_depo_posizioni.cod_mdep AND UL.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" mtb_aart,\n" +
|
||||
" mtb_grup,\n" +
|
||||
" mtb_sgrp\n" +
|
||||
"WHERE UL.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" AND qta_col <> 0");
|
||||
}
|
||||
|
||||
private static void createNewView(Connection connection) throws Exception {
|
||||
|
||||
if (!existsTable(connection, "stb_multiplier")) {
|
||||
executeStatement(connection, "CREATE TABLE stb_multiplier\n" +
|
||||
"(\n" +
|
||||
" moltiplicatore INT NOT NULL\n" +
|
||||
")",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (1)",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (-1)");
|
||||
}
|
||||
|
||||
|
||||
createOrUpdateView(connection, "mvw_mtb_colr_with_giacenza", "CREATE VIEW dbo.mvw_mtb_colr_with_giacenza\n" +
|
||||
" WITH SCHEMABINDING\n" +
|
||||
" AS\n" +
|
||||
"SELECT COUNT_BIG(*) AS c,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.barcode_ul_out,\n" +
|
||||
" mtb_colr.barcode_ul_in) AS barcode_ul,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.cod_mdep_out,\n" +
|
||||
" mtb_colr.cod_mdep_in) AS cod_mdep,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.posizione_out,\n" +
|
||||
" mtb_colr.posizione_in) AS posizione,\n" +
|
||||
" SUM(mtb_colr.qta_col * moltiplicatore) AS qta_col,\n" +
|
||||
" SUM(IIF(mtb_aart.flag_qta_cnf_fissa = 'S', mtb_colr.qta_col / mtb_aart.qta_cnf, mtb_colr.num_cnf) *\n" +
|
||||
" moltiplicatore) AS num_cnf,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" SUM(mtb_colr.peso_netto_kg * moltiplicatore) AS peso_netto_kg,\n" +
|
||||
" SUM(mtb_colr.peso_lordo_kg * moltiplicatore) AS peso_lordo_kg,\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom) AS cod_jcom,\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf AS qta_cnf_anag\n" +
|
||||
"FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.stb_multiplier ON (moltiplicatore = 1 AND mtb_colr.barcode_ul_in IS NOT NULL) OR\n" +
|
||||
" (moltiplicatore = -1 AND mtb_colr.barcode_ul_out IS NOT NULL)\n" +
|
||||
" INNER JOIN dbo.mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"GROUP BY mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.barcode_ul_out,\n" +
|
||||
" mtb_colr.barcode_ul_in),\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.cod_mdep_out,\n" +
|
||||
" mtb_colr.cod_mdep_in),\n" +
|
||||
" IIF(moltiplicatore = -1, mtb_colr.posizione_out,\n" +
|
||||
" mtb_colr.posizione_in),\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom),\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf");
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_CLUSTERED_mvw_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_CLUSTERED_mvw_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setUnique(true)
|
||||
.setClustered(true)
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("barcode_ul"));
|
||||
add(new IndexTableDTO.ColumnIndex("posizione"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mdep"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_jcom"));
|
||||
}}));
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_mvw_qta_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_qta_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("qta_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_cnf"));
|
||||
}}));
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}}));
|
||||
|
||||
dropIndex(connection, "mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_giac_mtb_colr_with_giacenza");
|
||||
createIndex(connection, new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_giac_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}})
|
||||
.setColumnsInclude("qta_col", "num_cnf"));
|
||||
|
||||
executeStatement(connection, "UPDATE STATISTICS dbo.mvw_mtb_colr_with_giacenza");
|
||||
|
||||
|
||||
createOrUpdateView(connection, "mvw_sitart_udc_det_inventario", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
" WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))\n" +
|
||||
" ),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
" SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul\n" +
|
||||
" FROM final_stock");
|
||||
}
|
||||
|
||||
|
||||
private static boolean existsView(Connection connection, String objectName) throws SQLException {
|
||||
return UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT COUNT(*) FROM SYSOBJECTS WHERE id = object_id('" + objectName + "')") > 0;
|
||||
}
|
||||
|
||||
|
||||
private static void dropView(Connection connection, String objectName) throws SQLException, IOException {
|
||||
UtilityDB.executeStatement(connection, "IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||
"\tDROP " + SqlObjectTypeEnum.VIEW.toString() + " " + objectName);
|
||||
}
|
||||
|
||||
private static boolean existsTable(Connection connection, String tableName) throws SQLException, IOException {
|
||||
String schema = null;
|
||||
if (tableName.contains(".")) {
|
||||
schema = tableName.substring(0, tableName.indexOf("."));
|
||||
tableName = tableName.replace(schema + ".", "");
|
||||
}
|
||||
|
||||
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM INFORMATION_SCHEMA.TABLES " +
|
||||
"WHERE TABLE_NAME = N%s ", tableName);
|
||||
|
||||
if (schema != null)
|
||||
sql += Query.format("AND TABLE_SCHEMA = N%s", schema);
|
||||
|
||||
return UtilityDB.<Boolean>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void createIndex(Connection connection, IndexTableDTO indexTableDTO) throws Exception {
|
||||
UtilityDB.createIndex(connection, indexTableDTO);
|
||||
}
|
||||
|
||||
private static void dropIndex(Connection connection, String tableName, String indexName) throws Exception {
|
||||
UtilityDB.dropIndex(connection, tableName, indexName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void executeStatement(Connection connection, String... sqls) throws SQLException {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
for (String sql : sqls) {
|
||||
statement.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void createOrUpdateView(Connection connection, String objectName, String createViewSql) throws SQLException, IOException {
|
||||
alterObject(connection, SqlObjectTypeEnum.VIEW, objectName, createViewSql);
|
||||
}
|
||||
|
||||
private static void alterObject(Connection connection, SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
||||
executeStatement(connection, "IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||
"\tDROP " + sqlObject.toString() + " " + objectName,
|
||||
sql);
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,7 @@ public class Migration_20220413102657 extends BaseMigration implements Migration
|
||||
.setCreationDatetime(wtbUser.getCreationDatetime())
|
||||
.setPasswordExpiresDays(wtbUser.getPasswordExpiresDays())
|
||||
.setLastPasswords(wtbUser.getLastPasswords())
|
||||
.setFlagPasswordExpiring(wtbUser.getFlagPasswordExpiring())
|
||||
.setDestructionDatetime(wtbUser.getDestructionDatetime());;
|
||||
.setFlagPasswordExpiring(wtbUser.getFlagPasswordExpiring());
|
||||
|
||||
stbUser.setOperation(OperationType.INSERT);
|
||||
stbUser.manageWithParentConnection(connection, droolsDataCompleting);
|
||||
|
||||
@@ -3,14 +3,7 @@ package it.integry.ems.migration.model;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import it.integry.ems.migration.dto.common.MigrationMvwSitArtUdcDetInventarioDTO;
|
||||
|
||||
public class Migration_20241213163759 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@@ -22,381 +15,8 @@ public class Migration_20241213163759 extends BaseMigration implements Migration
|
||||
if (!isCustomer(IntegryCustomer.RossoGargano))
|
||||
return;
|
||||
|
||||
//Migration di conversione aziende a nuova mvw_sitart_udc_det_inventario
|
||||
createBackupOfOldView();
|
||||
dropView("mvw_sitart_udc_det_inventario");
|
||||
|
||||
createNewView();
|
||||
|
||||
alignGiacenza();
|
||||
|
||||
}
|
||||
|
||||
private void createBackupOfOldView() throws Exception {
|
||||
if (existsView("mvw_sitart_udc_det_inventario_old"))
|
||||
return;
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario_old", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario_old] AS\n" +
|
||||
"SELECT UL.gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" UL.cod_mdep,\n" +
|
||||
" UL.posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" mtb_aart.cod_mgrp AS codGruppo,\n" +
|
||||
" mtb_grup.descrizione AS Gruppo,\n" +
|
||||
" mtb_aart.cod_msgr AS CodSgruppo,\n" +
|
||||
" mtb_sgrp.descrizione AS Sottogruppo,\n" +
|
||||
" UL.cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" UL.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione AS commessa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" UL.qta_cnf,\n" +
|
||||
" UL.peso_netto_kg,\n" +
|
||||
" UL.peso_lordo_kg,\n" +
|
||||
" UL.cod_jfas\n" +
|
||||
"FROM [mvw_sitart_udc_det] UL\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON UL.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON UL.cod_mdep = mtb_depo_posizioni.cod_mdep AND UL.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" mtb_aart,\n" +
|
||||
" mtb_grup,\n" +
|
||||
" mtb_sgrp\n" +
|
||||
"WHERE UL.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" AND qta_col <> 0");
|
||||
}
|
||||
|
||||
private void createNewView() throws Exception {
|
||||
|
||||
if (!existsTable("stb_multiplier")) {
|
||||
executeStatement("CREATE TABLE stb_multiplier\n" +
|
||||
"(\n" +
|
||||
" moltiplicatore INT NOT NULL\n" +
|
||||
")",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (1)",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (-1)");
|
||||
}
|
||||
|
||||
|
||||
createOrUpdateView("mvw_mtb_colr_with_giacenza", "CREATE VIEW dbo.mvw_mtb_colr_with_giacenza\n" +
|
||||
" WITH SCHEMABINDING\n" +
|
||||
"AS\n" +
|
||||
"SELECT COUNT_BIG(*) AS c,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif,\n" +
|
||||
" mtb_colr.gestione) AS gestione,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo) AS data_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo) AS ser_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo) AS num_collo,\n" +
|
||||
" SUM(mtb_colr.qta_col * moltiplicatore) AS qta_col,\n" +
|
||||
"\n" +
|
||||
" SUM(IIF(mtb_aart.flag_qta_cnf_fissa = 'S', mtb_colr.qta_col / mtb_aart.qta_cnf, mtb_colr.num_cnf) *\n" +
|
||||
" moltiplicatore) AS num_cnf,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" SUM(mtb_colr.peso_netto_kg * moltiplicatore) AS peso_netto_kg,\n" +
|
||||
" SUM(mtb_colr.peso_lordo_kg * moltiplicatore) AS peso_lordo_kg,\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom) AS cod_jcom,\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf AS qta_cnf_anag\n" +
|
||||
"FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.stb_multiplier ON moltiplicatore = 1 OR mtb_colr.num_collo_rif IS NOT NULL\n" +
|
||||
" INNER JOIN dbo.mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"GROUP BY mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif, mtb_colr.gestione),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo),\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom),\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf");
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_CLUSTERED_mvw_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_CLUSTERED_mvw_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setUnique(true)
|
||||
.setClustered(true)
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("gestione"));
|
||||
add(new IndexTableDTO.ColumnIndex("data_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("ser_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_jcom"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_qta_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_qta_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("qta_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_cnf"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_giac_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_giac_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}})
|
||||
.setColumnsInclude("qta_col", "num_cnf"));
|
||||
|
||||
executeStatement("UPDATE STATISTICS dbo.mvw_mtb_colr_with_giacenza");
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW mvw_sitart_udc_det_inventario AS\n" +
|
||||
" WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colt.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" mtb_colt.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.num_collo = mtb_colt.num_collo AND v.gestione = mtb_colt.gestione AND\n" +
|
||||
" v.ser_collo = mtb_colt.ser_collo AND v.data_collo = mtb_colt.data_collo\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND v.gestione = 'V'))),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
" SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul\n" +
|
||||
" FROM final_stock");
|
||||
}
|
||||
|
||||
private void alignGiacenza() throws Exception {
|
||||
//Creo un collo di scarico vuoto
|
||||
MtbColt mtbColt = new MtbColt()
|
||||
.setGestione("L")
|
||||
.setSerCollo("RT")
|
||||
.setSegno(-1)
|
||||
.setDataCollo(LocalDate.now())
|
||||
.setAnnotazioni("PASSAGGIO NUOVA MVW_SITART_UDC_DET_INVENTARIO")
|
||||
.setCodMdep(getInternalCodMdep());
|
||||
mtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
mtbColt.dataCompleting(connection);
|
||||
mtbColt.manageWithParentConnection(connection);
|
||||
|
||||
|
||||
executeStatement(Query.format(
|
||||
"INSERT INTO mtb_colr (gestione, ser_collo, num_collo, data_collo, riga, cod_mart, cod_col, cod_tagl, partita_mag, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif, datetime_row,\n" +
|
||||
" cod_jcom, qta_col, num_cnf, qta_cnf)" +
|
||||
" SELECT {} AS gestione,\n" +
|
||||
" {} AS ser_collo,\n" +
|
||||
" {} AS num_collo,\n" +
|
||||
" CAST({} AS DATE) AS data_collo,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY (SELECT NULL) ORDER BY v.data_collo) AS riga,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.gestione AS gestion_rif,\n" +
|
||||
" v.data_collo AS data_collo_rif,\n" +
|
||||
" v.ser_collo AS ser_collo_rif,\n" +
|
||||
" v.num_collo AS num_collo_rif,\n" +
|
||||
" GETDATE() AS datetime_row,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf\n" +
|
||||
"FROM mvw_sitart_udc_det_inventario v\n" +
|
||||
" INNER JOIN (SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom-- Elenca tutte le colonne coinvolte\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario\n" +
|
||||
"\n" +
|
||||
" EXCEPT\n" +
|
||||
"\n" +
|
||||
" SELECT ser_collo,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_jcom -- Elenca le stesse colonne dalla vista vecchia\n" +
|
||||
" FROM mvw_sitart_udc_det_inventario_old) t\n" +
|
||||
" ON v.num_collo = t.num_collo AND v.data_collo = t.data_collo AND\n" +
|
||||
" v.ser_collo = t.ser_collo AND v.gestione = t.gestione AND\n" +
|
||||
" v.cod_mart = t.cod_mart AND v.cod_mdep = t.cod_mdep AND\n" +
|
||||
" ISNULL(v.partita_mag, '') = ISNULL(t.partita_mag, '') AND\n" +
|
||||
" ISNULL(v.posizione, '') = ISNULL(t.posizione, '') AND\n" +
|
||||
" ISNULL(v.cod_jcom, '') = ISNULL(t.cod_jcom, '')" +
|
||||
" WHERE qta_col > 0",
|
||||
mtbColt.getGestione(), mtbColt.getSerCollo(), mtbColt.getNumCollo(), mtbColt.getDataCollo()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String getInternalCodMdep() throws Exception {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT TOP 1 cod_mdep" +
|
||||
" FROM mtb_depo" +
|
||||
" INNER JOIN dbo.gtb_anag ga ON mtb_depo.cod_anag = ga.cod_anag" +
|
||||
" inner join azienda on ga.part_iva = azienda.part_iva");
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,323 +0,0 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Migration_20250320121611 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Tosca))
|
||||
return;
|
||||
|
||||
//Migration di conversione aziende a nuova mvw_sitart_udc_det_inventario
|
||||
createBackupOfOldView();
|
||||
dropView("mvw_sitart_udc_det_inventario");
|
||||
|
||||
createNewView();
|
||||
|
||||
}
|
||||
|
||||
private void createBackupOfOldView() throws Exception {
|
||||
if (existsView("mvw_sitart_udc_det_inventario_old"))
|
||||
return;
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario_old", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario_old] AS\n" +
|
||||
"SELECT UL.gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" segno,\n" +
|
||||
" UL.cod_mdep,\n" +
|
||||
" UL.posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" mtb_aart.cod_mgrp AS codGruppo,\n" +
|
||||
" mtb_grup.descrizione AS Gruppo,\n" +
|
||||
" mtb_aart.cod_msgr AS CodSgruppo,\n" +
|
||||
" mtb_sgrp.descrizione AS Sottogruppo,\n" +
|
||||
" UL.cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" UL.cod_jcom,\n" +
|
||||
" jtb_comt.descrizione AS commessa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" UL.qta_cnf,\n" +
|
||||
" UL.peso_netto_kg,\n" +
|
||||
" UL.peso_lordo_kg,\n" +
|
||||
" UL.cod_jfas\n" +
|
||||
"FROM [mvw_sitart_udc_det] UL\n" +
|
||||
" LEFT OUTER JOIN jtb_comt ON UL.cod_jcom = jtb_comt.cod_jcom\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON UL.cod_mdep = mtb_depo_posizioni.cod_mdep AND UL.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" mtb_aart,\n" +
|
||||
" mtb_grup,\n" +
|
||||
" mtb_sgrp\n" +
|
||||
"WHERE UL.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" AND qta_col <> 0");
|
||||
}
|
||||
|
||||
private void createNewView() throws Exception {
|
||||
|
||||
if (!existsTable("stb_multiplier")) {
|
||||
executeStatement("CREATE TABLE stb_multiplier\n" +
|
||||
"(\n" +
|
||||
" moltiplicatore INT NOT NULL\n" +
|
||||
")",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (1)",
|
||||
"INSERT INTO stb_multiplier (moltiplicatore) VALUES (-1)");
|
||||
}
|
||||
|
||||
|
||||
createOrUpdateView("mvw_mtb_colr_with_giacenza", "CREATE VIEW dbo.mvw_mtb_colr_with_giacenza\n" +
|
||||
" WITH SCHEMABINDING\n" +
|
||||
"AS\n" +
|
||||
"SELECT COUNT_BIG(*) AS c,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif,\n" +
|
||||
" mtb_colr.gestione) AS gestione,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo) AS data_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo) AS ser_collo,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo) AS num_collo,\n" +
|
||||
" SUM(mtb_colr.qta_col * moltiplicatore) AS qta_col,\n" +
|
||||
"\n" +
|
||||
" SUM(IIF(mtb_aart.flag_qta_cnf_fissa = 'S', mtb_colr.qta_col / mtb_aart.qta_cnf, mtb_colr.num_cnf) *\n" +
|
||||
" moltiplicatore) AS num_cnf,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" SUM(mtb_colr.peso_netto_kg * moltiplicatore) AS peso_netto_kg,\n" +
|
||||
" SUM(mtb_colr.peso_lordo_kg * moltiplicatore) AS peso_lordo_kg,\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom) AS cod_jcom,\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf AS qta_cnf_anag\n" +
|
||||
"FROM dbo.mtb_colr\n" +
|
||||
" INNER JOIN dbo.stb_multiplier ON moltiplicatore = 1 OR mtb_colr.num_collo_rif IS NOT NULL\n" +
|
||||
" INNER JOIN dbo.mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"GROUP BY mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.gestione_rif, mtb_colr.gestione),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.data_collo_rif,\n" +
|
||||
" mtb_colr.data_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.ser_collo_rif,\n" +
|
||||
" mtb_colr.ser_collo),\n" +
|
||||
" IIF(moltiplicatore = -1 AND num_collo_rif IS NOT NULL, mtb_colr.num_collo_rif,\n" +
|
||||
" mtb_colr.num_collo),\n" +
|
||||
" IIF(mtb_colr.cod_jcom = 'MAG', NULL, mtb_colr.cod_jcom),\n" +
|
||||
" mtb_aart.flag_qta_cnf_fissa,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" mtb_aart.diacod,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_aart.cod_mgrp,\n" +
|
||||
" mtb_aart.cod_msgr,\n" +
|
||||
" mtb_aart.cod_mtip,\n" +
|
||||
" mtb_aart.cod_mstp,\n" +
|
||||
" mtb_aart.cod_msfa,\n" +
|
||||
" mtb_aart.qta_cnf");
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_CLUSTERED_mvw_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_CLUSTERED_mvw_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setUnique(true)
|
||||
.setClustered(true)
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("gestione"));
|
||||
add(new IndexTableDTO.ColumnIndex("data_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("ser_collo"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_jcom"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_qta_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_qta_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("qta_col"));
|
||||
add(new IndexTableDTO.ColumnIndex("num_cnf"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}}));
|
||||
|
||||
dropIndex("mvw_mtb_colr_with_giacenza", "IDX_mvw_articolo_giac_mtb_colr_with_giacenza");
|
||||
createIndex(new IndexTableDTO()
|
||||
.setIndexName("IDX_mvw_articolo_giac_mtb_colr_with_giacenza")
|
||||
.setTableName("mvw_mtb_colr_with_giacenza")
|
||||
.setMaxDop(1)
|
||||
.setSortInTempDb(true)
|
||||
.setColumnsIndex(new ArrayList<IndexTableDTO.ColumnIndex>() {{
|
||||
add(new IndexTableDTO.ColumnIndex("cod_mart"));
|
||||
add(new IndexTableDTO.ColumnIndex("partita_mag"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_tagl"));
|
||||
add(new IndexTableDTO.ColumnIndex("cod_col"));
|
||||
}})
|
||||
.setColumnsInclude("qta_col", "num_cnf"));
|
||||
|
||||
executeStatement("UPDATE STATISTICS dbo.mvw_mtb_colr_with_giacenza");
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW mvw_sitart_udc_det_inventario AS\n" +
|
||||
" WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colt.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" mtb_colt.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.num_collo = mtb_colt.num_collo AND v.gestione = mtb_colt.gestione AND\n" +
|
||||
" v.ser_collo = mtb_colt.ser_collo AND v.data_collo = mtb_colt.data_collo\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND v.gestione = 'V'))),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
" SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul\n" +
|
||||
" FROM final_stock");
|
||||
}
|
||||
|
||||
@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_20250402112610 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
// //Gia aggiornato
|
||||
// if (isCustomer(IntegryCustomer.RossoGargano) ||
|
||||
// isCustomer(IntegryCustomer.Tosca))
|
||||
// return;
|
||||
//
|
||||
// //Azienda da aggiornare
|
||||
// if (!isCustomer(IntegryCustomer.Gramm))
|
||||
// return;
|
||||
//
|
||||
// MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
// MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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.migration.dto.common.MigrationMvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20250403174531 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Gramm) &&
|
||||
!isCustomer(IntegryCustomer.RossoGargano))
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
//Rigenero barcodeUl testate con barcode duplicato
|
||||
regenerateDuplicatedBarcodeUlTestate();
|
||||
}
|
||||
|
||||
//Aggiorno la view mvw_mtb_colr_with_giacenza
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
private void regenerateDuplicatedBarcodeUlTestate() throws Exception {
|
||||
String retrieveDuplicatedSql = "SELECT barcode_ul\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"GROUP BY barcode_ul, ser_collo\n" +
|
||||
"HAVING COUNT(barcode_ul) > 1";
|
||||
|
||||
|
||||
final List<String> duplicatedBarcodes = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, retrieveDuplicatedSql);
|
||||
|
||||
for (String barcode : duplicatedBarcodes) {
|
||||
String sql = Query.format("SELECT * FROM mtb_colt WHERE barcode_ul = {}", barcode);
|
||||
List<MtbColt> loadedMtbColts = executeQueryDTO(sql, MtbColt.class);
|
||||
|
||||
for (MtbColt colt : loadedMtbColts) {
|
||||
if (colt.getSerCollo().equalsIgnoreCase("T")) {
|
||||
String newBarcodeUl = PackagesRules.completeBarcodeUl(connection,
|
||||
colt.getGestione(),
|
||||
colt.getDataCollo(),
|
||||
colt.getSerCollo(),
|
||||
colt.getNumCollo(),
|
||||
null);
|
||||
|
||||
colt.setBarcodeUl(newBarcodeUl);
|
||||
colt.setOperation(OperationType.UPDATE);
|
||||
colt.manageWithParentConnection(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
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_20250403174532 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
if (isCustomer(IntegryCustomer.Gramm) ||
|
||||
isCustomer(IntegryCustomer.RossoGargano) ||
|
||||
isCustomer(IntegryCustomer.Carelli) ||
|
||||
isDMS())
|
||||
return;
|
||||
|
||||
//Cancello tutti i barcode UL dalle testate degli scarichi a lavorazione
|
||||
executeStatement("UPDATE mtb_colt SET barcode_ul = NULL\n" +
|
||||
"WHERE gestione = 'L' AND segno = -1\n" +
|
||||
"AND barcode_ul IS NOT NULL");
|
||||
|
||||
|
||||
executeStatement("UPDATE mtb_colt\n" +
|
||||
"SET barcode_ul = EAN128.AI_00\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" CROSS APPLY (SELECT TOP 1 * FROM (SELECT DISTINCT AI_00\n" +
|
||||
" FROM f_getEAN128UL(mtb_colt.gestione, mtb_colt.data_collo, mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" NULL)" +
|
||||
" WHERE mtb_colt.ser_collo <> 'UL'\n" +
|
||||
" UNION\n" +
|
||||
" SELECT CONCAT('U', RIGHT(YEAR(mtb_colt.data_collo), 2), FORMAT(mtb_colt.num_collo, '0000000')) AS AI_00\n" +
|
||||
" WHERE mtb_colt.ser_collo = 'UL') tmp) EAN128");
|
||||
|
||||
createOrUpdateFunction("f_getEAN128UL", "CREATE FUNCTION [dbo].[f_getEAN128UL](@gestione VARCHAR(1), @dataCollo DATETIME, @serCollo VARCHAR(2), @numCollo INT,\n" +
|
||||
" @customPrefissoEan VARCHAR(7))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" -- DECLARE @gestione AS VARCHAR(1) = 'L'\n" +
|
||||
"-- DECLARE @serCollo AS VARCHAR(10) = 'GG'\n" +
|
||||
"-- DECLARE @numCollo AS INT = 7837\n" +
|
||||
"-- DECLARE @dataCollo AS DATETIME = '2025-03-10';\n" +
|
||||
"-- DECLARE @customPrefissoEan AS VARCHAR(7);-- = '8017596';\n" +
|
||||
"\n" +
|
||||
" WITH barcodes AS (SELECT mtb_colt.barcode_ul AS AI_00,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.cod_barre_imb IS NOT NULL AND LEN(mtb_aart.cod_barre_imb) < 14 THEN\n" +
|
||||
" FORMAT(CONVERT(NUMERIC, ISNULL(NULLIF(mtb_aart.cod_barre_imb, ''), '0')),\n" +
|
||||
" REPLICATE('0', 14))\n" +
|
||||
" ELSE mtb_aart.cod_barre_imb\n" +
|
||||
" END AS AI_01,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_aart.bar_code IS NOT NULL AND LEN(mtb_aart.bar_code) < 14\n" +
|
||||
" THEN\n" +
|
||||
" FORMAT(CONVERT(BIGINT, mtb_aart.bar_code), REPLICATE('0', 14))\n" +
|
||||
" ELSE mtb_aart.bar_code\n" +
|
||||
" END AS AI_02,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_colr.partita_mag IS NOT NULL THEN\n" +
|
||||
" mtb_colr.partita_mag + CHAR(29)\n" +
|
||||
" END AS AI_10,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN mtb_partita_mag.data_scad IS NOT NULL THEN\n" +
|
||||
" REPLACE(CONVERT(VARCHAR(10), mtb_partita_mag.data_scad, 2), '.', '')\n" +
|
||||
" END AS AI_15,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 6 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000000'), '.', '')\n" +
|
||||
" END AS AI_3100,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 5 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00000.0'), '.', '')\n" +
|
||||
" END AS AI_3101,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 4 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0000.00'), '.', '')\n" +
|
||||
" END AS AI_3102,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 3 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000.000'), '.', '')\n" +
|
||||
" END AS AI_3103,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 2 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00.0000'), '.', '')\n" +
|
||||
" END AS AI_3104,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 1 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0.00000'), '.', '')\n" +
|
||||
" END AS AI_3105,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 6 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '000000'), '.', '')\n" +
|
||||
" END AS AI_3300,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 5 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '00000.0'), '.', '')\n" +
|
||||
" END AS AI_3301,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 4 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '0000.00'), '.', '')\n" +
|
||||
" END AS AI_3302,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 3 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '000.000'), '.', '')\n" +
|
||||
" END AS AI_3303,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 2 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '00.0000'), '.', '')\n" +
|
||||
" END AS AI_3304,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 1 THEN\n" +
|
||||
" REPLACE(FORMAT(mtb_colt.peso_kg, '0.00000'), '.', '')\n" +
|
||||
" END AS AI_3305,\n" +
|
||||
" CONVERT(VARCHAR, CONVERT(INTEGER, SUM(mtb_colr.qta_col / mtb_colr.qta_cnf))) AS AI_37\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr\n" +
|
||||
" ON mtb_colt.gestione = mtb_colr.gestione AND\n" +
|
||||
" mtb_colt.data_collo = mtb_colr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo AND\n" +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_partita_mag ON mtb_colr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||
" mtb_colr.partita_mag =\n" +
|
||||
" mtb_partita_mag.partita_mag,\n" +
|
||||
" azienda\n" +
|
||||
" WHERE mtb_colt.gestione = @gestione\n" +
|
||||
" AND mtb_colt.data_collo = @dataCollo\n" +
|
||||
" AND mtb_colt.ser_collo = @serCollo\n" +
|
||||
" AND mtb_colt.num_collo = @numCollo\n" +
|
||||
" GROUP BY mtb_colr.qta_cnf,\n" +
|
||||
" mtb_colt.data_vers,\n" +
|
||||
" nome_ditta,\n" +
|
||||
" azienda.indirizzo,\n" +
|
||||
" azienda.cap,\n" +
|
||||
" azienda.citta,\n" +
|
||||
" azienda.prov,\n" +
|
||||
" prefisso_ean,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" mtb_aart.cod_barre_imb,\n" +
|
||||
" mtb_aart.bar_code,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" mtb_partita_mag.data_scad,\n" +
|
||||
" mtb_colt.peso_netto_kg,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.peso_kg,\n" +
|
||||
" mtb_aart.peso_kg, \n" +
|
||||
" mtb_colt.barcode_ul)\n" +
|
||||
" SELECT AI_00,\n" +
|
||||
" IIF(AI_01 IS NOT NULL AND LEN(AI_01) = 13,\n" +
|
||||
" CONCAT(AI_01, dbo.getCheckDigitITF14(AI_01)), AI_01) AS AI_01,\n" +
|
||||
" AI_02,\n" +
|
||||
" AI_10,\n" +
|
||||
" AI_15,\n" +
|
||||
" AI_3100,\n" +
|
||||
" AI_3101,\n" +
|
||||
" AI_3102,\n" +
|
||||
" AI_3103,\n" +
|
||||
" AI_3104,\n" +
|
||||
" AI_3105,\n" +
|
||||
" AI_3300,\n" +
|
||||
" AI_3301,\n" +
|
||||
" AI_3302,\n" +
|
||||
" AI_3303,\n" +
|
||||
" AI_3304,\n" +
|
||||
" AI_3305,\n" +
|
||||
" AI_37\n" +
|
||||
" FROM barcodes\n" +
|
||||
"GO");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
import it.integry.ems.migration.dto.common.MigrationMvwSitArtUdcDetInventarioDTO;
|
||||
|
||||
public class Migration_20250417110238 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
//Migration per aggiornare la view mvw_sitart_udc_det_inventario
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Maggio) &&
|
||||
!isCustomerDb(IntegryCustomerDB.Biolevante_Biolevante) &&
|
||||
!isCustomerDb(IntegryCustomerDB.Ime_ImeTe))
|
||||
return;
|
||||
|
||||
//Aggiorno la view mvw_mtb_colr_with_giacenza
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.apply(connection);
|
||||
|
||||
MigrationMvwSitArtUdcDetInventarioDTO.alignGiacenza(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250604172635 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("WMS_OrdPrelievo", "CREATE VIEW [dbo].[WMS_OrdPrelievo] AS\n" +
|
||||
"WITH elencoFornitoriInterni AS (SELECT value_string AS fornitore\n" +
|
||||
" FROM dbo.ParseStringIntoArray((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'PICKING'\n" +
|
||||
" AND section = 'SPEDIZIONE'\n" +
|
||||
" AND key_section = 'ELENCO_FORNITORI_INTERNI'),\n" +
|
||||
" '|')),\n" +
|
||||
" riservatoPerOrd AS (\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"SELECT mtb_colt.gestione,\n" +
|
||||
" mtb_colr.data_ord,\n" +
|
||||
" mtb_colr.num_ord,\n" +
|
||||
" mtb_colr.riga_ord,\n" +
|
||||
" SUM(mtb_colr.qta_col) AS qtaCollo,\n" +
|
||||
" SUM(mtb_colr.num_cnf) AS numCnfCollo,\n" +
|
||||
" COUNT(DISTINCT mtb_colr.num_ord) AS ColliRiservati\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" INNER JOIN mtb_colt ON mtb_colr.gestione = mtb_colt.gestione AND\n" +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND\n" +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
" WHERE segno = - 1\n" +
|
||||
" AND mtb_colr.gestione IN ('L', 'V')\n" +
|
||||
" AND mtb_colr.data_ord IS NOT NULL\n" +
|
||||
" GROUP BY mtb_colt.gestione, mtb_colr.data_ord, mtb_colr.num_ord, mtb_colr.riga_ord\n" +
|
||||
"\n" +
|
||||
" ), OrdVr AS (\n" +
|
||||
" SELECT dtb_ordr.gestione,\n" +
|
||||
" dtb_ordr.data_ord,\n" +
|
||||
" dtb_ordr.num_ord,\n" +
|
||||
" dtb_ordt.cod_vdes,\n" +
|
||||
" IIF(dtb_ordr.gestione = 'V', LEFT(ISNULL(vtb_dest.citta + ' - ', '') + vtb_dest.indirizzo, 40),\n" +
|
||||
" dtb_ordt.rif_ord) AS rif_ord,\n" +
|
||||
" dtb_ordt.cod_anag,\n" +
|
||||
" dtb_ordt.cod_prod,\n" +
|
||||
" CASE dtb_ordr.gestione WHEN 'L' THEN '2' WHEN 'V' THEN '3' END +\n" +
|
||||
" REPLACE(CONVERT(VARCHAR(10), dtb_ordr.data_ord, 105), '-', '') +\n" +
|
||||
" REPLICATE('0', 5 - LEN(dtb_ordr.num_ord)) +\n" +
|
||||
" CONVERT(VARCHAR(6), dtb_ordr.num_ord) AS chiave_ordine,\n" +
|
||||
" dtb_ordr.cod_jcom,\n" +
|
||||
" dtb_ordr.cod_mart,\n" +
|
||||
" SUM(ROUND(dtb_ordr.qta_ord - dtb_ordr.qta_evasa, mtb_unt_mis.cifre_dec)) *\n" +
|
||||
" dtb_ordr.rap_conv AS qta_inevasa,\n" +
|
||||
" dtb_ordt.listino,\n" +
|
||||
" dtb_ordt.term_cons,\n" +
|
||||
" dtb_ordt.cod_auto,\n" +
|
||||
" dtb_ordt.cod_vvet,\n" +
|
||||
" dtb_ordt.data_iniz_trasp,\n" +
|
||||
" dtb_ordt.cod_mdep,\n" +
|
||||
" dtb_ordr.data_cons AS data_cons,\n" +
|
||||
" dtb_ordr.id_viaggio,\n" +
|
||||
" dtb_ordt.cod_vage,\n" +
|
||||
" SUM(colli.qtaCollo) AS qtaCollo,\n" +
|
||||
" SUM(ROUND((dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * dtb_ordr.rap_conv -\n" +
|
||||
" ISNULL(colli.qtaCollo, 0),\n" +
|
||||
" mtb_unt_mis.cifre_dec)) AS qtaInevasaColli,\n" +
|
||||
" SUM(colli.numCnfCollo) AS numCnfCollo,\n" +
|
||||
" SUM(dtb_ordr.num_cnf - dtb_ordr.num_cnf_evasa -\n" +
|
||||
" ISNULL(colli.numCnfCollo, 0)) AS numCnfInevasaColli,\n" +
|
||||
" IIF((dtb_ordr.gestione = 'L' AND dtb_ordt.gestione_rif = 'T') OR\n" +
|
||||
" elencoFornitoriInterni.fornitore IS NOT NULL, 'S', 'N') AS ord_trasf\n" +
|
||||
" FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione AND\n" +
|
||||
" dtb_ordt.data_ord = dtb_ordr.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" INNER JOIN mtb_unt_mis ON mtb_unt_mis.unt_mis = dtb_ordr.unt_ord\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON dtb_ordt.cod_anag = vtb_dest.cod_anag AND\n" +
|
||||
" dtb_ordt.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" LEFT OUTER JOIN riservatoPerOrd colli\n" +
|
||||
" ON dtb_ordt.gestione = colli.gestione AND\n" +
|
||||
" dtb_ordt.data_ord = colli.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = colli.num_ord\n" +
|
||||
" LEFT OUTER JOIN elencoFornitoriInterni ON fornitore = dtb_ordt.cod_anag\n" +
|
||||
" WHERE dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND dtb_ordt.flag_sospeso = 'N'\n" +
|
||||
" AND dtb_ordr.flag_evaso = 'I'\n" +
|
||||
" AND dtb_ordt.flag_evaso_forzato = 'N'\n" +
|
||||
" AND dtb_ordt.gestione IN ('L', 'V')\n" +
|
||||
" AND ((mtb_aart.flag_qta_cnf_fissa = 'S' AND qta_ord > qta_evasa) OR\n" +
|
||||
" (mtb_aart.flag_qta_cnf_fissa <> 'S' AND num_cnf > num_cnf_evasa))\n" +
|
||||
" GROUP BY dtb_ordr.gestione, dtb_ordr.data_ord, dtb_ordr.num_ord, dtb_ordt.cod_vdes,\n" +
|
||||
" vtb_dest.indirizzo,\n" +
|
||||
" vtb_dest.citta, dtb_ordt.rif_ord, dtb_ordt.cod_anag, dtb_ordr.cod_jcom, dtb_ordr.cod_mart,\n" +
|
||||
" dtb_ordt.cod_prod, dtb_ordt.listino, dtb_ordt.term_cons, dtb_ordt.cod_auto,\n" +
|
||||
" dtb_ordt.cod_vvet, fornitore,\n" +
|
||||
" dtb_ordt.data_iniz_trasp, dtb_ordt.cod_mdep, dtb_ordt.cod_vage, dtb_ordr.id_viaggio,\n" +
|
||||
" colli.num_ord, dtb_ordr.data_cons, dtb_ordt.gestione_rif, dtb_ordr.rap_conv\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" ), OrdV AS (\n" +
|
||||
" SELECT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" rif_ord,\n" +
|
||||
" cod_anag,\n" +
|
||||
" chiave_ordine,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" cod_prod,\n" +
|
||||
" listino,\n" +
|
||||
" term_cons,\n" +
|
||||
" cod_auto,\n" +
|
||||
" cod_vvet,\n" +
|
||||
" data_iniz_trasp,\n" +
|
||||
" data_cons,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" COUNT(DISTINCT cod_mart) AS arts_da_evadere,\n" +
|
||||
" SUM(qtaInevasaColli) AS qtaInevasa,\n" +
|
||||
" SUM(numCnfInevasaColli) AS numCnfInevasa,\n" +
|
||||
" id_viaggio,\n" +
|
||||
" cod_vage,\n" +
|
||||
" COUNT(DISTINCT qtaCollo) AS colliRiservati,\n" +
|
||||
" ord_trasf\n" +
|
||||
" FROM OrdVr\n" +
|
||||
" GROUP BY gestione, data_ord, num_ord, rif_ord, cod_anag, chiave_ordine, cod_jcom, cod_prod, listino,\n" +
|
||||
" term_cons, cod_auto, cod_vvet, data_iniz_trasp, data_cons, cod_vdes, cod_mdep, cod_vage,\n" +
|
||||
" id_viaggio, ord_trasf\n" +
|
||||
"\n" +
|
||||
" ),\n" +
|
||||
" OrdV2 AS (SELECT OrdV.gestione,\n" +
|
||||
" OrdV.data_ord,\n" +
|
||||
" OrdV.num_ord,\n" +
|
||||
" rif_ord,\n" +
|
||||
" OrdV.cod_anag,\n" +
|
||||
" chiave_ordine,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" cod_prod,\n" +
|
||||
" listino,\n" +
|
||||
" term_cons,\n" +
|
||||
" OrdV.cod_auto,\n" +
|
||||
" ISNULL(vtb_viaggi.cod_vvet, OrdV.cod_vvet) AS cod_vvet,\n" +
|
||||
" data_iniz_trasp,\n" +
|
||||
" ISNULL(CONVERT(DATETIME, CONVERT(VARCHAR(10), vtb_viaggi.data_ora_iniz_trasp, 121)),\n" +
|
||||
" data_cons) AS data_cons,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" arts_da_evadere AS ArtDaEvadere,\n" +
|
||||
" OrdV.id_viaggio,\n" +
|
||||
" cod_vage,\n" +
|
||||
" ISNULL(ordV.ColliRiservati, 0) AS colli_riservati,\n" +
|
||||
" qtaInevasa,\n" +
|
||||
" numCnfInevasa,\n" +
|
||||
" CAST(IIF(ISNULL(ordV.ColliRiservati, 0) > 0, 1, 0) AS BIT) exist_collo,\n" +
|
||||
" CAST(IIF(ISNULL(qtaInevasa, 0) > 0,\n" +
|
||||
" IIF(ISNULL(numCnfInevasa, 0) > 0, 0, IIF(ordV.colliRiservati > 0, 1, 0)), 1) AS BIT) AS flag_evaso,\n" +
|
||||
" ord_trasf,\n" +
|
||||
" IIF((SELECT azienda.part_iva\n" +
|
||||
" FROM azienda\n" +
|
||||
" WHERE azienda.part_iva = gtb_anag.part_iva) IS NULL, 'N', 'S') AS ord_aziendale\n" +
|
||||
" FROM Ordv\n" +
|
||||
" INNER JOIN gtb_anag ON OrdV.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" LEFT OUTER JOIN vtb_viaggi ON OrdV.id_viaggio = vtb_viaggi.id_viaggio\n" +
|
||||
" WHERE (arts_da_evadere > 0 OR ISNULL(ColliRiservati, 0) > 0))\n" +
|
||||
"SELECT gestione,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" rif_ord,\n" +
|
||||
" cod_anag,\n" +
|
||||
" chiave_ordine,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" cod_prod,\n" +
|
||||
" listino,\n" +
|
||||
" term_cons,\n" +
|
||||
" cod_auto,\n" +
|
||||
" cod_vvet,\n" +
|
||||
" data_iniz_trasp,\n" +
|
||||
" data_cons,\n" +
|
||||
" cod_vdes,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" SUM(ArtDaEvadere) AS ArtDaEvadere,\n" +
|
||||
" id_viaggio,\n" +
|
||||
" cod_vage,\n" +
|
||||
" SUM(colli_riservati) AS colli_riservati,\n" +
|
||||
" SUM(qtaInevasa) AS qtaInevasa,\n" +
|
||||
" SUM(numCnfInevasa) AS numCnfInevasa,\n" +
|
||||
" exist_collo,\n" +
|
||||
" flag_evaso,\n" +
|
||||
" ord_trasf,\n" +
|
||||
" ord_aziendale\n" +
|
||||
"FROM OrdV2\n" +
|
||||
"GROUP BY gestione, data_ord, num_ord, rif_ord, cod_anag, chiave_ordine, cod_jcom, cod_prod, listino, term_cons,\n" +
|
||||
" cod_auto, cod_vvet, data_iniz_trasp, data_cons, cod_vdes, cod_mdep, id_viaggio, cod_vage, exist_collo,\n" +
|
||||
" flag_evaso, ord_trasf, ord_aziendale");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250618195259 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("dvw_situazione_qta_docs", "CREATE VIEW dvw_situazione_qta_docs AS\n" +
|
||||
"SELECT dtb_docr.[cod_anag],\n" +
|
||||
" dtb_docr.[cod_dtip],\n" +
|
||||
" dtb_docr.[data_doc],\n" +
|
||||
" dtb_docr.[ser_doc],\n" +
|
||||
" dtb_docr.[num_doc],\n" +
|
||||
" dtb_docr.[id_riga],\n" +
|
||||
" dtb_docr.[cod_mart],\n" +
|
||||
" dtb_docr.[descrizione],\n" +
|
||||
" dtb_docr.[unt_doc],\n" +
|
||||
" (dtb_docr.[rap_conv] / dtb_docr.[rap_conv]) AS rap_conv,\n" +
|
||||
" (dtb_docr.[qta_doc] * dtb_docr.[rap_conv]) - ISNULL(mtb_colr.qta_col, 0) AS qta_doc,\n" +
|
||||
" dtb_docr.[val_unt],\n" +
|
||||
" dtb_docr.[sconto5],\n" +
|
||||
" dtb_docr.[sconto6],\n" +
|
||||
" dtb_docr.[sconto7],\n" +
|
||||
" dtb_docr.[sconto8],\n" +
|
||||
" dtb_docr.[cod_aliq],\n" +
|
||||
" dtb_docr.[perc_prov],\n" +
|
||||
" dtb_docr.[val_prov],\n" +
|
||||
" dtb_docr.[data_ord],\n" +
|
||||
" dtb_docr.[num_ord],\n" +
|
||||
" dtb_docr.[riga_ord],\n" +
|
||||
" dtb_docr.[importo_riga],\n" +
|
||||
" dtb_docr.[cod_col],\n" +
|
||||
" dtb_docr.[cod_tagl],\n" +
|
||||
" dtb_docr.[cod_jcom],\n" +
|
||||
" dtb_docr.[cod_mdep],\n" +
|
||||
" dtb_docr.[perc_gest],\n" +
|
||||
" dtb_docr.[val_gest],\n" +
|
||||
" dtb_docr.[partita_mag],\n" +
|
||||
" dtb_docr.[val_unt_iva],\n" +
|
||||
" (dtb_docr.[qta_cnf] * dtb_docr.[rap_conv]) AS qta_cnf,\n" +
|
||||
" dtb_docr.[descrizione_estesa],\n" +
|
||||
" dtb_docr.[costo_unt],\n" +
|
||||
" dtb_docr.[perc_ispe],\n" +
|
||||
" dtb_docr.[val_ispe],\n" +
|
||||
" dtb_docr.[perc_promo],\n" +
|
||||
" dtb_docr.[val_promo],\n" +
|
||||
" dtb_docr.[perc_oneri],\n" +
|
||||
" dtb_docr.[val_oneri],\n" +
|
||||
" dtb_docr.[flag_evaso_forzato],\n" +
|
||||
" dtb_docr.[cod_dtip_comp],\n" +
|
||||
" dtb_docr.[data_doc_comp],\n" +
|
||||
" dtb_docr.[ser_doc_comp],\n" +
|
||||
" dtb_docr.[num_doc_comp],\n" +
|
||||
" dtb_docr.[cod_promo],\n" +
|
||||
" dtb_docr.[perc_prov2],\n" +
|
||||
" dtb_docr.[val_prov2],\n" +
|
||||
" dtb_docr.[cod_art_for],\n" +
|
||||
" dtb_docr.[unt_doc2],\n" +
|
||||
" dtb_docr.[qta_doc2],\n" +
|
||||
" dtb_docr.[unt_doc3],\n" +
|
||||
" dtb_docr.[qta_doc3],\n" +
|
||||
" dtb_docr.[num_cnf] - ISNULL(mtb_colr.num_cnf, 0) AS num_cnf,\n" +
|
||||
" dtb_docr.[peso_lordo],\n" +
|
||||
" dtb_docr.[posizione],\n" +
|
||||
" dtb_docr.[cod_anag_comp],\n" +
|
||||
" dtb_docr.[cod_mtip],\n" +
|
||||
" dtb_docr.[matricola],\n" +
|
||||
" dtb_docr.[data_iniz_comp],\n" +
|
||||
" dtb_docr.[data_fine_comp],\n" +
|
||||
" dtb_docr.[cod_kit],\n" +
|
||||
" dtb_docr.[cod_alis],\n" +
|
||||
" dtb_docr.[data_ins_row],\n" +
|
||||
" dtb_docr.[note],\n" +
|
||||
" dtb_doct.[gestione],\n" +
|
||||
" mtb_partita_mag.[data_scad] AS data_scad_partita_mag\n" +
|
||||
"FROM dtb_docr\n" +
|
||||
" INNER JOIN dtb_doct ON dtb_docr.num_doc = dtb_doct.num_doc AND dtb_docr.data_doc = dtb_doct.data_doc AND\n" +
|
||||
" dtb_docr.cod_anag = dtb_doct.cod_anag AND dtb_docr.cod_dtip = dtb_doct.cod_dtip AND\n" +
|
||||
" dtb_docr.ser_doc = dtb_doct.ser_doc\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_docr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_partita_mag ON dtb_docr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||
" dtb_docr.partita_mag = mtb_partita_mag.partita_mag\n" +
|
||||
" LEFT OUTER JOIN ctb_cont ON mtb_aart.cod_ccon_ricavi = ctb_cont.cod_ccon\n" +
|
||||
" LEFT OUTER JOIN ctb_grup ON ctb_cont.cod_cgrp = ctb_grup.cod_cgrp\n" +
|
||||
" LEFT OUTER JOIN (SELECT gestione,\n" +
|
||||
" cod_mart,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" SUM(qta_col) AS qta_col,\n" +
|
||||
" data_ord,\n" +
|
||||
" num_ord,\n" +
|
||||
" riga_ord,\n" +
|
||||
" partita_mag,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione_rif,\n" +
|
||||
" data_collo_rif,\n" +
|
||||
" ser_collo_rif,\n" +
|
||||
" num_collo_rif,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" SUM(num_cnf) AS num_cnf,\n" +
|
||||
" cod_anag_doc,\n" +
|
||||
" cod_dtip_doc,\n" +
|
||||
" data_doc,\n" +
|
||||
" ser_doc,\n" +
|
||||
" num_doc,\n" +
|
||||
" id_riga_doc\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" GROUP BY gestione, cod_barre, cod_mart, cod_col, cod_tagl, data_ord, num_ord, riga_ord,\n" +
|
||||
" partita_mag, qta_cnf, gestione_rif, data_collo_rif, ser_collo_rif, num_collo_rif,\n" +
|
||||
" cod_jcom, cod_anag_doc, cod_dtip_doc, data_doc, ser_doc, num_doc,\n" +
|
||||
" id_riga_doc) mtb_colr\n" +
|
||||
" ON dtb_docr.cod_anag = mtb_colr.cod_anag_doc AND dtb_docr.cod_dtip = mtb_colr.cod_dtip_doc AND\n" +
|
||||
" dtb_docr.ser_doc = mtb_colr.ser_doc AND dtb_docr.data_doc = mtb_colr.data_doc AND\n" +
|
||||
" dtb_docr.num_doc = mtb_colr.num_doc AND dtb_docr.id_riga = mtb_colr.id_riga_doc\n" +
|
||||
"WHERE (ctb_grup.sezione <> 1 OR ctb_grup.sezione IS NULL)\n" +
|
||||
" AND (dtb_docr.[qta_doc] * dtb_docr.[rap_conv]) - ISNULL(mtb_colr.qta_col, 0) > 0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250625155432 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
"WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" mtb_colr.datetime_row AS datetime_posizionamento\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" LEFT OUTER JOIN mtb_colr ON\n" +
|
||||
" v.barcode_ul = mtb_colr.barcode_ul_in AND\n" +
|
||||
" v.cod_mart = mtb_colr.cod_mart AND\n" +
|
||||
" ISNULL(v.partita_mag, '') = ISNULL(mtb_colr.partita_mag, '') AND\n" +
|
||||
" ISNULL(v.cod_col, '') = ISNULL(mtb_colr.cod_col, '') AND\n" +
|
||||
" ISNULL(v.cod_tagl, '') = ISNULL(mtb_colr.cod_tagl, '') AND\n" +
|
||||
" ISNULL(v.cod_jcom, '') = ISNULL(mtb_colr.cod_jcom, '') AND\n" +
|
||||
" ISNULL(v.posizione, '') = ISNULL(mtb_colr.posizione_in, '') AND\n" +
|
||||
" ISNULL(v.cod_mdep, '') = ISNULL(mtb_colr.cod_mdep_in, '') AND\n" +
|
||||
" ISNULL(mtb_colr.posizione_in, '') <> ISNULL(mtb_colr.posizione_out, '')\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE v.qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.datetime_posizionamento\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
"SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul,\n" +
|
||||
" datetime_posizionamento\n" +
|
||||
"FROM final_stock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250626142053 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
String reportNamePackingList = null;
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
reportNamePackingList = "PackingListScarico";
|
||||
}
|
||||
createSetup("PVM", "CONTROLLO_GIACENZE", "REPORT_NAME_PACKING_LIST", reportNamePackingList, "Nome report per stampa packing list post trasferimento", "REPORT_NAME");
|
||||
|
||||
}
|
||||
|
||||
@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.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250627184608 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
String value = null;
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)){
|
||||
value = "ControlloGiacenzeSintetico";
|
||||
}
|
||||
createSetup("PVM","CONTROLLO_GIACENZE","REPORT_NAME_ELENCO_SINTETICO",value,"Report name per report giacenze sintetico da portale web","REPORT_NAME");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250630164505 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateView("mvw_sitart_udc_det_inventario", "CREATE VIEW [dbo].[mvw_sitart_udc_det_inventario] AS\n" +
|
||||
"WITH baseMtbColr AS (SELECT c,\n" +
|
||||
"\n" +
|
||||
" ROUND(v.qta_col, cifre_dec) AS qta_col,\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec) AS num_cnf,\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)) AS qta_cnf,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione AS descrizione_gruppo,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione AS descrizione_sottogruppo,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag,\n" +
|
||||
" MAX(mtb_colr.datetime_row) AS datetime_posizionamento\n" +
|
||||
" FROM mvw_mtb_colr_with_giacenza v WITH (NOEXPAND)\n" +
|
||||
" INNER JOIN mtb_colt\n" +
|
||||
" ON v.barcode_ul = mtb_colt.barcode_ul\n" +
|
||||
" LEFT OUTER JOIN mtb_colr ON\n" +
|
||||
" v.barcode_ul = mtb_colr.barcode_ul_in AND\n" +
|
||||
" v.cod_mart = mtb_colr.cod_mart AND\n" +
|
||||
" ((v.partita_mag IS NULL AND mtb_colr.partita_mag IS NULL) OR\n" +
|
||||
" (v.partita_mag = mtb_colr.partita_mag)) AND\n" +
|
||||
" ((v.cod_col IS NULL AND mtb_colr.cod_col IS NULL) OR (v.cod_col = mtb_colr.cod_col)) AND\n" +
|
||||
" ((v.cod_tagl IS NULL AND mtb_colr.cod_tagl IS NULL) OR (v.cod_tagl = mtb_colr.cod_tagl)) AND\n" +
|
||||
" ((v.cod_jcom IS NULL AND mtb_colr.cod_jcom IS NULL) OR (v.cod_jcom = mtb_colr.cod_jcom)) AND\n" +
|
||||
" ((v.posizione IS NULL AND mtb_colr.posizione_in IS NULL) OR (v.posizione = mtb_colr.posizione_in)) AND\n" +
|
||||
" ((v.cod_mdep IS NULL AND mtb_colr.cod_mdep_in IS NULL) OR (v.cod_mdep = mtb_colr.cod_mdep_in)) AND\n" +
|
||||
" ISNULL(mtb_colr.posizione_in, '') <> ISNULL(mtb_colr.posizione_out, '')\n" +
|
||||
" INNER JOIN dbo.mtb_unt_mis ON v.unt_mis = mtb_unt_mis.unt_mis\n" +
|
||||
"\n" +
|
||||
" INNER JOIN dbo.mtb_grup ON v.cod_mgrp = mtb_grup.cod_mgrp\n" +
|
||||
" INNER JOIN dbo.mtb_sgrp ON v.cod_mgrp = mtb_sgrp.cod_mgrp\n" +
|
||||
" AND v.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
" WHERE v.qta_col > 0\n" +
|
||||
" AND (segno = 1 OR (segno = -1 AND cod_dtip IS NULL AND mtb_colt.gestione = 'V'))\n" +
|
||||
" GROUP BY c,\n" +
|
||||
" ROUND(v.qta_col, cifre_dec),\n" +
|
||||
" ROUND(v.num_cnf, cifre_dec),\n" +
|
||||
" IIF(flag_qta_cnf_fissa = 'S',\n" +
|
||||
" v.qta_cnf_anag, v.qta_col / IIF(v.num_cnf = 0, 1, v.num_cnf)),\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.cod_mgrp,\n" +
|
||||
" mtb_grup.descrizione,\n" +
|
||||
" v.cod_msgr,\n" +
|
||||
" mtb_sgrp.descrizione,\n" +
|
||||
" mtb_unt_mis.flag_dig,\n" +
|
||||
" mtb_unt_mis.cifre_dec,\n" +
|
||||
" mtb_colt.segno,\n" +
|
||||
" v.cod_mdep,\n" +
|
||||
" v.posizione,\n" +
|
||||
" mtb_colt.cod_dtip,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.qta_cnf_anag),\n" +
|
||||
" final_stock AS (SELECT v.qta_col,\n" +
|
||||
" v.num_cnf,\n" +
|
||||
" v.qta_cnf,\n" +
|
||||
" v.gestione,\n" +
|
||||
" v.data_collo,\n" +
|
||||
" v.ser_collo,\n" +
|
||||
" v.num_collo,\n" +
|
||||
" v.cod_mdep AS cod_mdep,\n" +
|
||||
" v.posizione AS posizione,\n" +
|
||||
" mtb_depo_posizioni.priorita,\n" +
|
||||
" v.cod_mgrp AS codGruppo,\n" +
|
||||
" v.descrizione_gruppo AS Gruppo,\n" +
|
||||
" v.cod_msgr AS CodSgruppo,\n" +
|
||||
" v.descrizione_sottogruppo AS Sottogruppo,\n" +
|
||||
" v.cod_mart,\n" +
|
||||
" v.diacod,\n" +
|
||||
" v.descrizione_estesa,\n" +
|
||||
" v.partita_mag,\n" +
|
||||
" v.cod_col,\n" +
|
||||
" v.cod_tagl,\n" +
|
||||
" v.cod_jcom,\n" +
|
||||
" v.peso_netto_kg,\n" +
|
||||
" v.peso_lordo_kg,\n" +
|
||||
" v.cod_jfas,\n" +
|
||||
" v.flag_qta_cnf_fissa,\n" +
|
||||
" v.unt_mis,\n" +
|
||||
" v.segno,\n" +
|
||||
" v.barcode_ul,\n" +
|
||||
" v.datetime_posizionamento\n" +
|
||||
" FROM baseMtbColr v\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_depo_posizioni\n" +
|
||||
" ON v.cod_mdep = mtb_depo_posizioni.cod_mdep\n" +
|
||||
" AND v.posizione = mtb_depo_posizioni.posizione)\n" +
|
||||
"\n" +
|
||||
"SELECT qta_col,\n" +
|
||||
" num_cnf,\n" +
|
||||
" qta_cnf,\n" +
|
||||
" gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" posizione,\n" +
|
||||
" priorita,\n" +
|
||||
" codGruppo,\n" +
|
||||
" Gruppo,\n" +
|
||||
" CodSgruppo,\n" +
|
||||
" Sottogruppo,\n" +
|
||||
" cod_mart,\n" +
|
||||
" diacod,\n" +
|
||||
" descrizione_estesa,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_col,\n" +
|
||||
" cod_tagl,\n" +
|
||||
" cod_jcom,\n" +
|
||||
" peso_netto_kg,\n" +
|
||||
" peso_lordo_kg,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" flag_qta_cnf_fissa,\n" +
|
||||
" unt_mis,\n" +
|
||||
" segno,\n" +
|
||||
" barcode_ul,\n" +
|
||||
" datetime_posizionamento\n" +
|
||||
"FROM final_stock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250714164813 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("WMS_GetUltimeConsegneClienti", "CREATE FUNCTION [dbo].[WMS_GetUltimeConsegneClienti](@numConsegnePerClie INT, @codAnag VARCHAR(5), @codMart VARCHAR(15),\n" +
|
||||
" @codMdep VARCHAR(5), @daysDiff INT)\n" +
|
||||
"/*Funzione che restituisce le ultime consegne effettuate per conto di un cliente con possibilitàdi filtrare per articolo/deposito.\n" +
|
||||
"Se il cliente non viene passato allora la funzione restituiràle ultime consegne di tutti i clienti. */\n" +
|
||||
" RETURNS TABLE AS RETURN\n" +
|
||||
" SELECT DISTINCT *\n" +
|
||||
" FROM (SELECT dtb_doct.cod_anag,\n" +
|
||||
" DENSE_RANK() OVER (PARTITION BY dtb_doct.cod_anag ORDER BY dtb_doct.cod_anag ASC, dtb_doct.data_doc DESC, dtb_doct.num_doc) AS counter_consegna,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.compilato_da,\n" +
|
||||
" dtb_doct.rif_ord,\n" +
|
||||
" dtb_doct.data_ord,\n" +
|
||||
" vtb_dest.destinatario,\n" +
|
||||
" vtb_dest.indirizzo,\n" +
|
||||
" dtb_doct.data_iniz_trasp\n" +
|
||||
" FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.cod_anag = dtb_docr.cod_anag AND\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" LEFT OUTER JOIN vtb_dest\n" +
|
||||
" ON dtb_doct.cod_anag = vtb_dest.cod_anag\n" +
|
||||
" AND dtb_doct.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
"\n" +
|
||||
" WHERE dtb_doct.gestione = 'V'\n" +
|
||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND dtb_tipi.segno_qta_scar = 1\n" +
|
||||
" AND DATEDIFF(DAY, dtb_doct.data_doc, GETDATE()) <= @daysDiff\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" AND (@codMdep IS NULL\n" +
|
||||
" OR dtb_doct.cod_mdep = @codMdep)\n" +
|
||||
" AND (@codMart IS NULL\n" +
|
||||
" OR dtb_docr.cod_mart = @codMart)\n" +
|
||||
" AND (@codAnag IS NULL\n" +
|
||||
" OR dtb_doct.cod_anag = @codAnag)) grouped_consegne\n" +
|
||||
" WHERE @numConsegnePerClie IS NULL\n" +
|
||||
" OR grouped_consegne.counter_consegna <= @numConsegnePerClie");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250715110408 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("WMS_GetUltimeConsegneClienti", "CREATE FUNCTION [dbo].[WMS_GetUltimeConsegneClienti](@numConsegnePerClie INT, @codAnag VARCHAR(5), @codVdes VARCHAR(5), @codMart VARCHAR(15),\n" +
|
||||
" @codMdep VARCHAR(5), @daysDiff INT)\n" +
|
||||
"/*Funzione che restituisce le ultime consegne effettuate per conto di un cliente con possibilitàdi filtrare per articolo/deposito.\n" +
|
||||
"Se il cliente non viene passato allora la funzione restituiràle ultime consegne di tutti i clienti. */\n" +
|
||||
" RETURNS TABLE AS RETURN\n" +
|
||||
" SELECT DISTINCT *\n" +
|
||||
" FROM (SELECT dtb_doct.cod_anag,\n" +
|
||||
" DENSE_RANK() OVER (PARTITION BY dtb_doct.cod_anag ORDER BY dtb_doct.cod_anag ASC, dtb_doct.data_doc DESC, dtb_doct.num_doc) AS counter_consegna,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.compilato_da,\n" +
|
||||
" dtb_doct.rif_ord,\n" +
|
||||
" dtb_doct.data_ord,\n" +
|
||||
" vtb_dest.destinatario,\n" +
|
||||
" vtb_dest.indirizzo,\n" +
|
||||
" dtb_doct.data_iniz_trasp\n" +
|
||||
" FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.cod_anag = dtb_docr.cod_anag AND\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" LEFT OUTER JOIN vtb_dest\n" +
|
||||
" ON dtb_doct.cod_anag = vtb_dest.cod_anag\n" +
|
||||
" AND dtb_doct.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
"\n" +
|
||||
" WHERE dtb_doct.gestione = 'V'\n" +
|
||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND dtb_tipi.segno_qta_scar = 1\n" +
|
||||
" AND DATEDIFF(DAY, dtb_doct.data_doc, GETDATE()) <= @daysDiff\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" AND (@codMdep IS NULL\n" +
|
||||
" OR dtb_doct.cod_mdep = @codMdep)\n" +
|
||||
" AND (@codMart IS NULL\n" +
|
||||
" OR dtb_docr.cod_mart = @codMart)\n" +
|
||||
" AND (@codAnag IS NULL\n" +
|
||||
" OR dtb_doct.cod_anag = @codAnag)\n" +
|
||||
" AND (@codVdes IS NULL\n" +
|
||||
" OR dtb_doct.cod_vdes = @codVdes)) grouped_consegne\n" +
|
||||
" WHERE @numConsegnePerClie IS NULL\n" +
|
||||
" OR grouped_consegne.counter_consegna <= @numConsegnePerClie");
|
||||
}
|
||||
|
||||
@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.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250728095637 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("alter table dbo.atb_tipi add socio_aziendale BIT default 0 not null");
|
||||
|
||||
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
executeStatement("UPDATE dbo.atb_tipi SET socio_aziendale = 1 where cod_atip in (N'C1050', N'C1055')");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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_20250728125101 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
String reportNameScar = null;
|
||||
String reportNameLav = null;
|
||||
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)) {
|
||||
reportNameScar = "ReportScaricoProdotto";
|
||||
reportNameLav = "RiepilogoLavorazioniMateriaPrimaGrezza";
|
||||
}
|
||||
|
||||
createSetup("PVM","PIAN_ACC_ROSSG","REPORT_NAME_RIEP_SCARICO_PRODOTTO",reportNameScar,"Nome report stampa riepilogo scarico prodotti (da tab omonima in pagina accettazione da campo)","REPORT_NAME");
|
||||
createSetup("PVM","PIAN_ACC_ROSSG","REPORT_NAME_RIEP_LAV_MATERIALE",reportNameLav,"Nome report stampa riepilogo lavorazioni del giorno (da tab Laborazioni in pagina accettazione da campo)","REPORT_NAME");
|
||||
}
|
||||
|
||||
@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.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250807105039 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateView(
|
||||
"wtb_users",
|
||||
"CREATE VIEW [dbo].[Wtb_users] AS\n" +
|
||||
" SELECT [User_name],\n" +
|
||||
" [Full_name],\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_user.key_group = 1 OR stb_user.flag_dba = 'S' THEN NULL\n" +
|
||||
" ELSE dbo.sys_dcd_pss([Password]) END AS [Password],\n" +
|
||||
" [key_group],\n" +
|
||||
" [User_code],\n" +
|
||||
" [Details],\n" +
|
||||
" [Last_access_datetime],\n" +
|
||||
" [flag_attivo] AS ctrl_state,\n" +
|
||||
" [password_endtime],\n" +
|
||||
" [url_css],\n" +
|
||||
" [cod_lang],\n" +
|
||||
" [creation_datetime],\n" +
|
||||
" [e_mail],\n" +
|
||||
" [password_expires_days],\n" +
|
||||
" [last_passwords],\n" +
|
||||
" [flag_password_expiring],\n" +
|
||||
" password_endtime AS [destruction_datetime]\n" +
|
||||
" FROM [dbo].stb_user\n" +
|
||||
" WHERE flag_extra_user = 'S'\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250807112659 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
dropColumn("stb_user", "destruction_datetime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@ import it.integry.ems.rules.businessLogic.enums.FlagSezione;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity.key.MtbColtKey;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
@@ -24,6 +24,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
|
||||
|
||||
@@ -55,12 +56,24 @@ public class LoadColliService {
|
||||
|
||||
this.currentAzienda = Azienda.getDefaultAzienda(multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
String whereCond = "";
|
||||
|
||||
for (MtbColt mtbColt : loadColli.getColli()) {
|
||||
mtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
mtbColt.getMtbColr().forEach(mtbColr -> mtbColr.setOperation(OperationType.SELECT_OBJECT));
|
||||
mtbColt.getMtbCols().forEach(mtbCols -> mtbCols.setOperation(OperationType.SELECT_OBJECT));
|
||||
|
||||
if(loadDatiFromDB){
|
||||
entityProcessor.processEntity(mtbColt, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
if (mtbColt.getNumCollo() == null && mtbColt.getDataCollo() == null) {
|
||||
mtbColt.setDataCollo(UtilityLocalDate.getNow());
|
||||
int numCollo = PackagesRules.completeNumCollo(multiDBTransactionManager.getPrimaryConnection(),
|
||||
mtbColt.getSerCollo(),
|
||||
mtbColt.getDataCollo(),
|
||||
mtbColt.getGestione());
|
||||
mtbColt.setNumCollo(numCollo);
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(loadColli.getGestione()) && !UtilityString.isNullOrEmpty(loadColli.getCodDtip())) {
|
||||
@@ -74,35 +87,31 @@ public class LoadColliService {
|
||||
}
|
||||
|
||||
|
||||
if (loadDatiFromDB) {
|
||||
for (EntityBase entity : loadColli.getColli()) {
|
||||
entityProcessor.processEntity(entity, false, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
// String whereCond = "";
|
||||
// for (MtbColt collo : loadColli.getColli()) {
|
||||
// if (!UtilityString.isNullOrEmpty(whereCond)) {
|
||||
// whereCond += " OR ";
|
||||
// }
|
||||
//
|
||||
// whereCond += "( mtb_colt.gestione = " + UtilityDB.valueToString(collo.getGestione()) + " AND " +
|
||||
// " mtb_colt.data_collo = " + UtilityDB.valueToString(collo.getDataCollo()) + " AND " +
|
||||
// " mtb_colt.ser_collo = " + UtilityDB.valueToString(collo.getSerCollo()) + " AND " +
|
||||
// " mtb_colt.num_collo = " + UtilityDB.valueToString(collo.getNumCollo()) + ") ";
|
||||
// }
|
||||
checkColli(loadColli.getColli().stream()
|
||||
.map(MtbColt::getKey)
|
||||
.collect(Collectors.toList()), loadColli);
|
||||
|
||||
for (MtbColt mtbColt : loadColli.getColli()) {
|
||||
if (mtbColt.getNumCollo() == null && mtbColt.getDataCollo() == null) {
|
||||
mtbColt.setDataCollo(UtilityLocalDate.getNow());
|
||||
int numCollo = PackagesRules.completeNumCollo(multiDBTransactionManager.getPrimaryConnection(),
|
||||
mtbColt.getSerCollo(),
|
||||
mtbColt.getDataCollo(),
|
||||
mtbColt.getGestione());
|
||||
mtbColt.setNumCollo(numCollo);
|
||||
}
|
||||
}
|
||||
String whereCondColli = UtilityQuery.concatFieldListInWhereCond(loadColli.getColli().stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("mtb_colt.gestione", x.getGestione());
|
||||
put("mtb_colt.num_collo", x.getNumCollo());
|
||||
put("mtb_colt.data_collo", x.getDataCollo());
|
||||
put("mtb_colt.ser_collo", x.getSerCollo());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
for (MtbColt collo : loadColli.getColli()) {
|
||||
if (!UtilityString.isNullOrEmpty(whereCond)) {
|
||||
whereCond += " OR ";
|
||||
}
|
||||
|
||||
whereCond += "( mtb_colt.gestione = " + UtilityDB.valueToString(collo.getGestione()) + " AND " +
|
||||
" mtb_colt.data_collo = " + UtilityDB.valueToString(collo.getDataCollo()) + " AND " +
|
||||
" mtb_colt.ser_collo = " + UtilityDB.valueToString(collo.getSerCollo()) + " AND " +
|
||||
" mtb_colt.num_collo = " + UtilityDB.valueToString(collo.getNumCollo()) + ") ";
|
||||
}
|
||||
|
||||
checkColli(whereCond, loadColli);
|
||||
|
||||
DtbDoct dtbDoct;
|
||||
String query;
|
||||
@@ -185,15 +194,17 @@ public class LoadColliService {
|
||||
throw new Exception("Codice Deposito obbligatorio");
|
||||
}
|
||||
|
||||
|
||||
if (loadDatiFromDB) {
|
||||
query = "SELECT DISTINCT mtb_colt.cod_vlis AS listino, " +
|
||||
" mtb_colt.cod_vdes " +
|
||||
" FROM mtb_colt, mtb_colr " +
|
||||
"WHERE mtb_colr.gestione = mtb_colt.gestione AND " +
|
||||
" FROM mtb_colt " +
|
||||
" INNER JOIN mtb_colr ON mtb_colr.gestione = mtb_colt.gestione AND " +
|
||||
" mtb_colr.data_collo = mtb_colt.data_collo AND " +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND " +
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo ";
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
" mtb_colr.num_collo = mtb_colt.num_collo " +
|
||||
" WHERE " + whereCondColli;
|
||||
|
||||
dtbDoct = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), query, DtbDoct.class);
|
||||
} else {
|
||||
dtbDoct = new DtbDoct();
|
||||
@@ -229,7 +240,7 @@ public class LoadColliService {
|
||||
" vtb_list.descrizione ";
|
||||
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
if (!results.isEmpty()) {
|
||||
dtbDoct.setCodDivi(UtilityHashMap.<String>getValueIfExists(results.get(0), "cod_divi"));
|
||||
@@ -242,7 +253,7 @@ public class LoadColliService {
|
||||
if (loadColli.getColli().isEmpty() && loadDatiFromDB) {
|
||||
query = "SELECT gestione, data_collo, ser_collo, num_collo " +
|
||||
" FROM mtb_colt ";
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
PreparedStatement ps = multiDBTransactionManager.prepareStatement(query);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
@@ -256,7 +267,7 @@ public class LoadColliService {
|
||||
// Acquisizione ID_LOTTO del primo collo da agganciare
|
||||
if (loadDatiFromDB) {
|
||||
query = "SELECT TOP 1 id_lotto FROM mtb_colt ";
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
Integer idLotto = (Integer) getSingleValue(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
if (idLotto != null) {
|
||||
dtbDoct.setIdLotto(idLotto);
|
||||
@@ -300,7 +311,7 @@ public class LoadColliService {
|
||||
|
||||
|
||||
//VERIFICARE CHE USERNAME VENGA PASSATO
|
||||
List<DtbDocr> dtbDocr = loadRigheCollo(whereCond, loadColli);
|
||||
List<DtbDocr> dtbDocr = loadRigheCollo(whereCondColli, loadColli);
|
||||
|
||||
if (!dtbDocr.isEmpty()) {
|
||||
dtbDocr.stream()
|
||||
@@ -321,9 +332,19 @@ public class LoadColliService {
|
||||
|
||||
}
|
||||
|
||||
private void checkColli(String whereCond, final LoadColliDTO loadColliDTO) throws Exception {
|
||||
private void checkColli(final List<MtbColtKey> mtbColtKeys, final LoadColliDTO loadColliDTO) throws Exception {
|
||||
String query;
|
||||
|
||||
|
||||
String whereCondColli = UtilityQuery.concatFieldListInWhereCond(mtbColtKeys.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("mtb_colt.gestione", x.getGestione());
|
||||
put("mtb_colt.num_collo", x.getNumCollo());
|
||||
put("mtb_colt.data_collo", x.getDataCollo());
|
||||
put("mtb_colt.ser_collo", x.getSerCollo());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
//CONTROLLO COLLI AGGANCIATI A DOCUMENTI
|
||||
if (loadDatiFromDB) {
|
||||
query =
|
||||
@@ -341,7 +362,7 @@ public class LoadColliService {
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo and " +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo ";
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
for (HashMap<String, Object> result : results) {
|
||||
@@ -359,14 +380,15 @@ public class LoadColliService {
|
||||
" n. " + numDoc);
|
||||
}
|
||||
} else {
|
||||
List<MtbColt> mtbColtWithDocAlready = Stream.of(loadColliDTO.getColli())
|
||||
.filter(mtbColt -> !UtilityString.isNullOrEmpty(mtbColt.getCodDtip())).toList();
|
||||
List<MtbColt> mtbColtWithDocAlready = loadColliDTO.getColli().stream()
|
||||
.filter(mtbColt -> !UtilityString.isNullOrEmpty(mtbColt.getCodDtip()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (mtbColtWithDocAlready != null && !mtbColtWithDocAlready.isEmpty()) {
|
||||
if (!mtbColtWithDocAlready.isEmpty()) {
|
||||
throw new Exception("Il collo n° " + mtbColtWithDocAlready.get(0).getNumCollo() +
|
||||
" del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(mtbColtWithDocAlready.get(0).getDataCollo()) +
|
||||
" del " + CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(mtbColtWithDocAlready.get(0).getDataCollo()) +
|
||||
" già agganciato al documento " + mtbColtWithDocAlready.get(0).getCodDtip() +
|
||||
" del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(mtbColtWithDocAlready.get(0).getDataDoc()) +
|
||||
" del " + CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(mtbColtWithDocAlready.get(0).getDataDoc()) +
|
||||
" n. " + mtbColtWithDocAlready.get(0).getNumDoc());
|
||||
}
|
||||
}
|
||||
@@ -381,7 +403,7 @@ public class LoadColliService {
|
||||
"FROM mtb_colt " +
|
||||
"WHERE mtb_colt.cod_mdep <> " + UtilityDB.valueToString(loadColliDTO.getCodMdep());
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
if (!results.isEmpty()) {
|
||||
@@ -407,7 +429,7 @@ public class LoadColliService {
|
||||
" mtb_colr.data_ord = dtb_ordt.data_ord AND " +
|
||||
" mtb_colr.num_ord = dtb_ordt.num_ord ";
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
if (!results.isEmpty()) {
|
||||
@@ -431,7 +453,7 @@ public class LoadColliService {
|
||||
" mtb_colr.num_ord = dtb_ordt.num_ord " +
|
||||
"WHERE dtb_ordt.flag_sospeso = 'S'";
|
||||
|
||||
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||
query = UtilityDB.addwhereCond(query, whereCondColli, false);
|
||||
|
||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||
|
||||
@@ -682,7 +704,7 @@ public class LoadColliService {
|
||||
mtbTcol.setOperation(OperationType.SELECT_OBJECT);
|
||||
mtbTcol.setCodTcol(mtbColt.getCodTcol());
|
||||
|
||||
entityProcessor.processEntity(mtbTcol, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(mtbTcol,true, multiDBTransactionManager);
|
||||
|
||||
if (mtbColt.getPesoKg() == null) mtbColt.setPesoKg(BigDecimal.ZERO);
|
||||
|
||||
@@ -704,7 +726,7 @@ public class LoadColliService {
|
||||
MtbAart mtbAart = new MtbAart();
|
||||
mtbAart.setCodMart(mtbColr.getCodMart());
|
||||
mtbAart.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(mtbAart, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(mtbAart,true, multiDBTransactionManager);
|
||||
|
||||
//Retrieve della riga ordine
|
||||
DtbOrdr dtbOrdr = null;
|
||||
@@ -715,7 +737,7 @@ public class LoadColliService {
|
||||
dtbOrdr.setRigaOrd(mtbColr.getRigaOrd());
|
||||
dtbOrdr.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(dtbOrdr, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(dtbOrdr,true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
DtbDocr dtbDocr = new DtbDocr();
|
||||
|
||||
@@ -1264,12 +1264,23 @@ public class CommonRules extends QueryRules {
|
||||
return maxProgressivoUl + 1;
|
||||
}
|
||||
|
||||
public static int retrieveNextProgressivoUlRG(Connection conn, String gestione, LocalDate dataOrd, int numOrd, int segno) throws SQLException {
|
||||
public static int retrieveNextProgressivoUlRG(Connection conn, String gestione, LocalDate dataOrd, int numOrd, int segno, String codJfas) throws Exception {
|
||||
return CommonRules.retrieveNextProgressivoUlRG(conn, gestione, dataOrd, numOrd, segno, codJfas, null);
|
||||
}
|
||||
|
||||
public static int retrieveNextProgressivoUlRG(Connection conn, String gestione, LocalDate dataOrd, int numOrd, int segno, String codJfas, String partitaMag) throws Exception {
|
||||
// boolean isScadenzaMultipla = setupGest.getSetupDetBoolean(conn, "MES", "SETUP", "CONTROLLO_SCADENZA_MULTIPLA", codJfas);
|
||||
// if (!isScadenzaMultipla) {
|
||||
// return retrieveNextProgressivoUl(conn, gestione, dataOrd, numOrd, segno);
|
||||
// }
|
||||
|
||||
partitaMag = UtilityString.isNull(partitaMag, "dot.partita_mag");
|
||||
|
||||
String sql = Query.format(
|
||||
"WITH partite AS (SELECT dot.cod_prod AS cod_mart, mpm.partita_mag_prod, dot.cod_jfas\n" +
|
||||
" FROM dtb_ordt dot\n" +
|
||||
" INNER JOIN mtb_partita_mag mpm\n" +
|
||||
" ON dot.cod_prod = mpm.cod_mart AND dot.partita_mag = mpm.partita_mag\n" +
|
||||
" ON dot.cod_prod = mpm.cod_mart AND [partitaMag] = mpm.partita_mag\n" +
|
||||
" WHERE dot.data_ord = %s\n" +
|
||||
" AND dot.num_ord = %s\n" +
|
||||
" AND dot.gestione = [gestione])\n" +
|
||||
@@ -1285,7 +1296,9 @@ public class CommonRules extends QueryRules {
|
||||
dataOrd,
|
||||
numOrd,
|
||||
segno
|
||||
).replace("[gestione]", UtilityDB.valueToString(gestione));
|
||||
)
|
||||
.replace("[partitaMag]", partitaMag.equalsIgnoreCase("dot.partita_mag") ? partitaMag : UtilityDB.valueToString(partitaMag))
|
||||
.replace("[gestione]", UtilityDB.valueToString(gestione));
|
||||
|
||||
int maxProgressivoUl = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
return maxProgressivoUl + 1;
|
||||
|
||||
@@ -18,8 +18,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DocumentRules extends QueryRules {
|
||||
@@ -586,7 +586,7 @@ public class DocumentRules extends QueryRules {
|
||||
mtbColt
|
||||
.setCodAnag(cancellaRifDoc && colloAnonimo ? EmsRestConstants.NULL : testata.getCodAnag())
|
||||
.setCodDtip(cancellaRifDoc ? EmsRestConstants.NULL : testata.getCodDtip())
|
||||
.setDataDoc(cancellaRifDoc ? EmsRestConstants.DATE_NULL : testata.getDataDoc())
|
||||
.setDataDoc(cancellaRifDoc ? EmsRestConstants.LOCAL_DATE_NULL : UtilityLocalDate.localDateFromDate(testata.getDataDoc()))
|
||||
.setSerDoc(cancellaRifDoc ? EmsRestConstants.NULL : testata.getSerDoc())
|
||||
.setNumDoc(cancellaRifDoc ? EmsRestConstants.INTEGER_NULL : testata.getNumDoc());
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
|
||||
@@ -16,8 +16,8 @@ import java.sql.*;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -505,9 +505,9 @@ public class OrderRules extends QueryRules {
|
||||
}
|
||||
|
||||
public static void setRifOrd(Connection conn, DtbOrdt dtbOrdt) throws Exception {
|
||||
Boolean completeRifOrd = setupGest.getSetupBoolean("w_vordi_rc", "SETUP", "RIF_ORD_AUTOCOMP");
|
||||
Boolean completeRifOrd = setupGest.getSetupBoolean(conn, "w_vordi_rc", "SETUP", "RIF_ORD_AUTOCOMP");
|
||||
if (UtilityString.isNullOrEmpty(dtbOrdt.getRifOrd()) && completeRifOrd) {
|
||||
String setupRifOrd = setupGest.getSetup("w_vordi_rc", "SETUP", "RIF_ORD_FORMATO");
|
||||
String setupRifOrd = setupGest.getSetup(conn, "w_vordi_rc", "SETUP", "RIF_ORD_FORMATO");
|
||||
if (!UtilityString.isNullOrEmpty(setupRifOrd) &&
|
||||
dtbOrdt.getRifDataOrd() != null && !dtbOrdt.getRifDataOrd().equals(EmsRestConstants.DATE_NULL) &&
|
||||
dtbOrdt.getRifNumOrd() != null && dtbOrdt.getRifNumOrd() != EmsRestConstants.NULL) {
|
||||
|
||||
@@ -12,7 +12,8 @@ import it.integry.ems.Import.base.IEntityImporter;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.Import.enums.EntityImportType;
|
||||
import it.integry.ems.dto.*;
|
||||
import it.integry.ems.dto.CreateZipDTO;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.dto.info.ApplicationInfoDTO;
|
||||
import it.integry.ems.dto.info.DatabaseEngineInfoDTO;
|
||||
import it.integry.ems.dto.info.DatabaseInfoDTO;
|
||||
@@ -853,7 +854,7 @@ public class EmsServices {
|
||||
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||
throw new Exception("Cannot export server info in DEBUG mode");
|
||||
|
||||
multiDBTransactionManager.setPrimaryDs(settingsModel.getDefaultProfile());
|
||||
multiDBTransactionManager.setPrimaryDB(settingsModel.getDefaultProfile());
|
||||
|
||||
HashMap<String, Object> arguments = new HashMap<>();
|
||||
|
||||
@@ -1106,7 +1107,7 @@ public class EmsServices {
|
||||
}
|
||||
|
||||
private void importClientieOrdiniQuore() throws Exception {
|
||||
try (Connection connection = basicConnectionPool.getConnection(settingsModel.getDefaultProfile())) {
|
||||
try (Connection connection = basicConnectionPool.getConnection(settingsModel.findConnectionModel(settingsModel.getDefaultProfile()))) {
|
||||
boolean enabled = Boolean.parseBoolean(setupGest.getSetup(connection,
|
||||
"IMPORT_ORDINI WEB", "CONQUIST", "ENABLED"));
|
||||
String folder = setupGest.getSetup(connection, "IMPORT_ORDINI WEB", "CONQUIST", "FOLDER");
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package it.integry.ems.service.dto;
|
||||
|
||||
public class UpdatePvmEndpointRequestDTO {
|
||||
|
||||
private String endpoint;
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public UpdatePvmEndpointRequestDTO setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ public class InsertPartitaMagRequestDTO {
|
||||
|
||||
private Integer numOrd;
|
||||
|
||||
private LocalDate dataProd;
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
@@ -101,4 +103,13 @@ public class InsertPartitaMagRequestDTO {
|
||||
this.numOrd = numOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataProd() {
|
||||
return dataProd;
|
||||
}
|
||||
|
||||
public InsertPartitaMagRequestDTO setDataProd(LocalDate dataProd) {
|
||||
this.dataProd = dataProd;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,14 @@ public class SettingsModel implements InitializingBean {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
|
||||
public AvailableConnectionsModel findConnectionModel(String profileName) {
|
||||
return getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
instance = this;
|
||||
|
||||
@@ -94,17 +94,17 @@ public class BasicConnectionPool {
|
||||
return ds;
|
||||
}
|
||||
|
||||
public Connection getConnection(String profileName) throws Exception {
|
||||
String dbName = settingsModel.getDbNameFromProfileDb(profileName);
|
||||
|
||||
if (dbName == null) {
|
||||
public Connection getConnection(AvailableConnectionsModel connectionsModel) throws Exception {
|
||||
if (connectionsModel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String dbName = connectionsModel.getDbName();
|
||||
|
||||
poolLock.lock();
|
||||
try {
|
||||
if (!registeredDatasources.containsKey(dbName)) {
|
||||
throw new IllegalArgumentException("No datasource registered for profile: " + profileName);
|
||||
throw new IllegalArgumentException("No datasource registered for profile: " + connectionsModel.getProfileName());
|
||||
}
|
||||
|
||||
DataSource ds = registeredDatasources.get(dbName);
|
||||
@@ -114,12 +114,4 @@ public class BasicConnectionPool {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private AvailableConnectionsModel findConnectionModel(String profileName) {
|
||||
return settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,10 +47,12 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
|
||||
public MultiDBTransactionManager() {
|
||||
connectionPool = ApplicationContextProvider.getApplicationContext().getBean(BasicConnectionPool.class);
|
||||
settingsModel = ApplicationContextProvider.getApplicationContext().getBean(SettingsModel.class);
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(BasicConnectionPool connectionPool) throws Exception {
|
||||
this.connectionPool = connectionPool;
|
||||
settingsModel = ApplicationContextProvider.getApplicationContext().getBean(SettingsModel.class);
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(AvailableConnectionsModel connectionsModel) throws Exception {
|
||||
@@ -68,7 +70,7 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
public MultiDBTransactionManager(String profileDb, boolean enableLog) throws Exception {
|
||||
this();
|
||||
this.enableLog = enableLog;
|
||||
this.setPrimaryDs(profileDb);
|
||||
this.setPrimaryDB(profileDb);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +84,7 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
if (requestData != null && requestData.isValidProfileDB()) {
|
||||
profileDb = requestData.getProfileDB();
|
||||
}
|
||||
this.setPrimaryDs(profileDb);
|
||||
this.setPrimaryDB(profileDb);
|
||||
} catch (Exception ex) {
|
||||
logger.error("Errore durante la connessione al DB.", ex);
|
||||
}
|
||||
@@ -98,7 +100,8 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
}
|
||||
|
||||
public void addConnection(String profileName, boolean isDistributore) throws Exception {
|
||||
Connection connection = connectionPool.getConnection(profileName);
|
||||
AvailableConnectionsModel availableConnectionsModel = settingsModel.findConnectionModel(profileName);
|
||||
Connection connection = connectionPool.getConnection(availableConnectionsModel);
|
||||
this.addConnection(connection, isDistributore);
|
||||
}
|
||||
|
||||
@@ -159,18 +162,17 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
public Connection getDistributoreConnection() throws Exception {
|
||||
Connection dsToReturn = null;
|
||||
|
||||
public String getDistributoreProfileName() throws PrimaryDatabaseNotPresentException {
|
||||
for (Connection connection : allConnections) {
|
||||
if (connection.isDistributore()) {
|
||||
dsToReturn = connection;
|
||||
return connection.getProfileName();
|
||||
}
|
||||
}
|
||||
return getPrimaryConnection().getProfileName();
|
||||
}
|
||||
|
||||
if (dsToReturn == null) dsToReturn = getPrimaryConnection();
|
||||
|
||||
return dsToReturn;
|
||||
public Connection getDistributoreConnection() throws Exception {
|
||||
return connectionPool.getConnection(settingsModel.findConnectionModel(getDistributoreProfileName()));
|
||||
}
|
||||
|
||||
|
||||
@@ -179,11 +181,6 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
return connection.prepareStatement(sql);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatementOnDistributore(String sql) throws Exception {
|
||||
Connection connection = getDistributoreConnection();
|
||||
return connection.prepareStatement(sql);
|
||||
}
|
||||
|
||||
public List<Connection> getActiveConnections() throws SQLException {
|
||||
return allConnections;
|
||||
}
|
||||
@@ -279,14 +276,23 @@ public class MultiDBTransactionManager implements AutoCloseable {
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public void setPrimaryDs(String profileDb) throws Exception {
|
||||
public void setPrimaryDB(String profileDb) throws Exception {
|
||||
if (!SettingsModel.getInstance().isValidConnection(profileDb)) {
|
||||
throw new Exception(String.format("Configurazione DB non trovata o dati mancanti (%s)", profileDb));
|
||||
}
|
||||
|
||||
AvailableConnectionsModel connectionModel = settingsModel.findConnectionModel(profileDb);
|
||||
setPrimaryDB(connectionModel);
|
||||
}
|
||||
|
||||
public void setPrimaryDB(AvailableConnectionsModel connectionModel) throws Exception {
|
||||
this.close();
|
||||
|
||||
primaryConnection = connectionPool.getConnection(profileDb);
|
||||
if (connectionModel == null) {
|
||||
throw new IllegalArgumentException("Connection model cannot be null");
|
||||
}
|
||||
|
||||
primaryConnection = connectionPool.getConnection(connectionModel);
|
||||
|
||||
this.allConnections = new ArrayList<>();
|
||||
this.addConnection(primaryConnection, false);
|
||||
|
||||
@@ -81,6 +81,7 @@ public class SyncManager {
|
||||
|
||||
proceedSyncronization(entitySource, entityCloned, lastProfileUsed, multiDBTransactionManager);
|
||||
|
||||
distributoreConnection.commit();
|
||||
} catch (Exception e) {
|
||||
|
||||
String subscriptor = null;
|
||||
@@ -104,6 +105,9 @@ public class SyncManager {
|
||||
|
||||
e = new SyncException(e, profileDb);
|
||||
}
|
||||
|
||||
distributoreConnection.rollback();
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -135,9 +139,8 @@ public class SyncManager {
|
||||
|
||||
private void proceedSyncronization(EntityInterface entitySource, EntityInterface entityCloned, StringBuffer[] lastProfileUsed, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
|
||||
Connection distributoreDatasource = multiDBTransactionManager.getDistributoreConnection();
|
||||
String profileDbDistributore = distributoreDatasource.getProfileName();
|
||||
List<StbSubscription> subscriptions = dynamicCacheService.getEntity(DynamicCacheService.Keys.ENTITY_SYNC_KEY, distributoreDatasource.getDbName());
|
||||
String profileDbDistributore = multiDBTransactionManager.getDistributoreProfileName();
|
||||
List<StbSubscription> subscriptions = dynamicCacheService.getEntity(DynamicCacheService.Keys.ENTITY_SYNC_KEY, profileDbDistributore);
|
||||
|
||||
if (subscriptions == null)
|
||||
return;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class UserSession {
|
||||
|
||||
if(currentUser != null) currentUserDepo = UtilityUser.getDefaultUserDepo(multiDBTransactionManager, currentUser);
|
||||
} catch (Exception ex) {
|
||||
logger.trace(UserSession.class.getName() + ": errore durante l'inizializzazione", ex);
|
||||
//logger.trace(UserSession.class.getName() + ": errore durante l'inizializzazione", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,22 @@ public class UserSession {
|
||||
public MtbDepo getDefaultDepo() {
|
||||
return currentUserDepo;
|
||||
}
|
||||
|
||||
public void checkUser() throws Exception {
|
||||
if (currentUser == null) {
|
||||
throw new Exception("Utente non trovato");
|
||||
}
|
||||
|
||||
if (!isAttivo()) {
|
||||
throw new Exception("Utente " + getUsername() + " non riconoscuto!");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkUserDepo() throws Exception {
|
||||
checkUser();
|
||||
|
||||
if (currentUserDepo == null) {
|
||||
throw new Exception("Deposito non trovato per l'utente " + getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ public class UserCacheService {
|
||||
" su.password_endtime,\n" +
|
||||
" su.cod_lang,\n" +
|
||||
" su.flag_password_expiring,\n" +
|
||||
" CAST(IIF(su.destruction_datetime IS NOT NULL AND\n" +
|
||||
" DATEDIFF(DAY, su.destruction_datetime, GETDATE()) > 0 AND su.flag_password_expiring = 'S', 1,\n" +
|
||||
" CAST(IIF(su.password_endtime IS NOT NULL AND\n" +
|
||||
" DATEDIFF(DAY, su.password_endtime, GETDATE()) > 0 AND su.flag_password_expiring = 'S', 1,\n" +
|
||||
" 0) AS BIT) AS is_password_expired,\n" +
|
||||
" IIF(su.key_group = '3' AND su.user_code IS NULL, wc.cod_anag, su.user_code) AS user_code,\n" +
|
||||
" wd.cod_mdep,\n" +
|
||||
|
||||
@@ -10,6 +10,7 @@ public class EmsRestConstants {
|
||||
|
||||
public static final String NIL = "NIL#";
|
||||
public static final String NULL = "[NULL]";
|
||||
public static final String NOT_NULL = "[NOT_NULL]";
|
||||
public static final Date DATE_NULL = new Date(-2208992400000L); // 1/1/1900
|
||||
public static final LocalDate LOCAL_DATE_NULL = LocalDate.of(1900, 1, 1); // 1/1/1900
|
||||
public static final LocalTime LOCAL_TIME_NULL = LocalTime.MAX; // 23:59:59.99999
|
||||
@@ -115,6 +116,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_USERS = PATH + "getUser";
|
||||
public static final String PATH_EXPORT_ORDINI_ACQ = PATH + "exportOrdiniAcquisto";
|
||||
public static final String PATH_PROCESS_REPORT = PATH + "processReport";
|
||||
public static final String PATH_DOWNLOAD_REPORT_LIST = PATH + "downloadReportList";
|
||||
public static final String PATH_DOWNLOAD_REPORT = PATH + "downloadReport";
|
||||
public static final String PATH_PROCESS_REPORT_TYPE = PATH + "processReportType";
|
||||
public static final String PATH_PRINT_REPORT_TYPE = PATH + "printReportType";
|
||||
@@ -179,6 +181,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_SAVE_PROPOSTA_ORDINE = PATH + "savePropostaOrdine";
|
||||
public static final String PATH_GET_COSTO_PRODOTTO = PATH + "getCostoProdotto";
|
||||
public static final String PATH_GET_COSTO_PRODOTTO_CC = PATH + "getCostoProdottoCC";
|
||||
public static final String PATH_GET_COLLI_BY_BARCODES = PATH + "getColliByBarcodes";
|
||||
public static final String PATH_GET_COLLO_BY_BARCODE = PATH + "getColloByBarcode";
|
||||
public static final String PATH_GET_COLLO_IN_GIAC = PATH + "getColloInGiac";
|
||||
public static final String PATH_GET_COLLI_IN_BASKET = PATH + "getColliInBasket";
|
||||
@@ -523,7 +526,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_WOO_SYNC_IMMAGINI = PATH + "syncImmagini";
|
||||
// PRODUCTION WAREHOUSE SERVICES
|
||||
public static final String PATH_WAREHOUSE_PRODUCTION_RETTIFICA = PATH + "rettificaMagazzinoProduzione";
|
||||
public static final String PATH_WAREHOUSE_PRODUCTION_DELETE_COLLO = PATH + "cancellaColloDaProduzione";
|
||||
public static final String PATH_WAREHOUSE_PRODUCTION_DELETE_CARICO = PATH + "cancellaCaricoDaProduzione";
|
||||
|
||||
// NOTIFICATION SERVICES
|
||||
public static final String GROUP_NOTIF = PATH + "notification";
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
|
||||
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
|
||||
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.ImportExport.Interfaces.IExportFormat;
|
||||
import it.integry.ems_model.ImportExport.Interfaces.IImportFormat;
|
||||
@@ -25,10 +26,10 @@ import org.apache.logging.log4j.Logger;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -112,6 +113,11 @@ public class ResultSetMapper {
|
||||
fields = outputClass.getDeclaredFields();
|
||||
}
|
||||
|
||||
if(outputClass.getSuperclass() != null && !outputClass.getSuperclass().isPrimitive() && !EntityBase.class.isAssignableFrom(outputClass)) {
|
||||
Field[] superFields = outputClass.getSuperclass().getDeclaredFields();
|
||||
fields = java.util.stream.Stream.concat(Arrays.stream(fields), Arrays.stream(superFields)).toArray(Field[]::new);
|
||||
}
|
||||
|
||||
outputList = internalMappingList(rs, outputClass, fields);
|
||||
|
||||
if (outputList != null && !outputList.isEmpty() && EntityBase.class.isAssignableFrom(outputClass)) {
|
||||
|
||||
@@ -29,6 +29,9 @@ public class AtbTipi extends EntityBase {
|
||||
@SqlField(value = "descrizione", maxLength = 40, nullable = false)
|
||||
private String descrizione;
|
||||
|
||||
@SqlField(value = "socio_aziendale", nullable = false)
|
||||
private Boolean socioAziendale = false;
|
||||
|
||||
public AtbTipi() {
|
||||
super(logger);
|
||||
}
|
||||
@@ -48,4 +51,13 @@ public class AtbTipi extends EntityBase {
|
||||
public void setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
}
|
||||
|
||||
public Boolean getSocioAziendale() {
|
||||
return socioAziendale;
|
||||
}
|
||||
|
||||
public AtbTipi setSocioAziendale(Boolean socioAziendale) {
|
||||
this.socioAziendale = socioAziendale;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.entity.common.DtbBaseDocT;
|
||||
import it.integry.ems_model.entity.common.DtbDocOrdR;
|
||||
import it.integry.ems_model.entity.key.DtbDoctKey;
|
||||
import it.integry.ems_model.rules.completing.DocumentExtEntityRules;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -21,8 +23,8 @@ import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@@ -426,6 +428,17 @@ public class DtbDoct extends DtbBaseDocT implements EquatableEntityInterface<Dtb
|
||||
this.serDoc = serDoc;
|
||||
}
|
||||
|
||||
|
||||
public DtbDoctKey getKey() {
|
||||
return UtilityString.isNullOrEmpty(gestione) ||
|
||||
UtilityString.isNullOrEmpty(codDtip) ||
|
||||
UtilityString.isNullOrEmpty(codAnag) ||
|
||||
dataDoc == null ||
|
||||
numDoc == null ?
|
||||
null :
|
||||
new DtbDoctKey(codAnag, codDtip, UtilityLocalDate.localDateFromDate(dataDoc), numDoc, serDoc);
|
||||
}
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||
import it.integry.ems_model.entity.key.MtbColrKey;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -204,6 +205,12 @@ public class MtbColr extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
super(logger);
|
||||
}
|
||||
|
||||
|
||||
public MtbColrKey getKey() {
|
||||
return new MtbColrKey(gestione, serCollo, dataCollo, numCollo, riga);
|
||||
}
|
||||
|
||||
|
||||
public LocalDate getDataCollo() {
|
||||
return dataCollo;
|
||||
}
|
||||
@@ -707,12 +714,83 @@ public class MtbColr extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MtbColr)) return false;
|
||||
MtbColr mtbColr = (MtbColr) o;
|
||||
return Objects.equals(getDataCollo(), mtbColr.getDataCollo()) && Objects.equals(getGestione(), mtbColr.getGestione()) && Objects.equals(getSerCollo(), mtbColr.getSerCollo()) && Objects.equals(getNumCollo(), mtbColr.getNumCollo()) && Objects.equals(getRiga(), mtbColr.getRiga()) && Objects.equals(getRigaOrd(), mtbColr.getRigaOrd()) && Objects.equals(getCodMart(), mtbColr.getCodMart()) && Objects.equals(getCodBarre(), mtbColr.getCodBarre()) && Objects.equals(getCodCol(), mtbColr.getCodCol()) && Objects.equals(getCodTagl(), mtbColr.getCodTagl()) && Objects.equals(getPartitaMag(), mtbColr.getPartitaMag()) && Objects.equals(getGestioneRif(), mtbColr.getGestioneRif()) && Objects.equals(getSerColloRif(), mtbColr.getSerColloRif()) && Objects.equals(getNote(), mtbColr.getNote()) && Objects.equals(getDataOrd(), mtbColr.getDataOrd()) && Objects.equals(getDataColloRif(), mtbColr.getDataColloRif()) && Objects.equals(getQtaCnf(), mtbColr.getQtaCnf()) && Objects.equals(getQtaCol(), mtbColr.getQtaCol()) && Objects.equals(getNumOrd(), mtbColr.getNumOrd()) && Objects.equals(getNumEtich(), mtbColr.getNumEtich()) && Objects.equals(getNumColloRif(), mtbColr.getNumColloRif()) && Objects.equals(getDatetimeRow(), mtbColr.getDatetimeRow()) && Objects.equals(getCodJcom(), mtbColr.getCodJcom()) && Objects.equals(getNumCnf(), mtbColr.getNumCnf()) && getCausale() == mtbColr.getCausale() && Objects.equals(getUtente(), mtbColr.getUtente()) && Objects.equals(getCodAnagDoc(), mtbColr.getCodAnagDoc()) && Objects.equals(getCodDtipDoc(), mtbColr.getCodDtipDoc()) && Objects.equals(getDataDoc(), mtbColr.getDataDoc()) && Objects.equals(getSerDoc(), mtbColr.getSerDoc()) && Objects.equals(getNumDoc(), mtbColr.getNumDoc()) && Objects.equals(getIdRigaDoc(), mtbColr.getIdRigaDoc()) && Objects.equals(getPesoNettoKg(), mtbColr.getPesoNettoKg()) && Objects.equals(getPesoLordoKg(), mtbColr.getPesoLordoKg()) && Objects.equals(getInsPartitaMag(), mtbColr.getInsPartitaMag()) && Objects.equals(getMtbPartitaMag_descrizione(), mtbColr.getMtbPartitaMag_descrizione()) && Objects.equals(getDataScadPartita(), mtbColr.getDataScadPartita()) && Objects.equals(getDescrizione(), mtbColr.getDescrizione()) && Objects.equals(getFlagQtaCnfFissa(), mtbColr.getFlagQtaCnfFissa()) && Objects.equals(getArtAPeso(), mtbColr.getArtAPeso());
|
||||
return Objects.equals(getDataCollo(), mtbColr.getDataCollo()) &&
|
||||
Objects.equals(getGestione(), mtbColr.getGestione()) &&
|
||||
Objects.equals(getSerCollo(), mtbColr.getSerCollo()) &&
|
||||
Objects.equals(getNumCollo(), mtbColr.getNumCollo()) &&
|
||||
Objects.equals(getRiga(), mtbColr.getRiga()) &&
|
||||
Objects.equals(getRigaOrd(), mtbColr.getRigaOrd()) &&
|
||||
Objects.equals(getCodMart(), mtbColr.getCodMart()) &&
|
||||
Objects.equals(getCodBarre(), mtbColr.getCodBarre()) &&
|
||||
Objects.equals(getCodCol(), mtbColr.getCodCol()) &&
|
||||
Objects.equals(getCodTagl(), mtbColr.getCodTagl()) &&
|
||||
Objects.equals(getPartitaMag(), mtbColr.getPartitaMag()) &&
|
||||
Objects.equals(getGestioneRif(), mtbColr.getGestioneRif()) &&
|
||||
Objects.equals(getSerColloRif(), mtbColr.getSerColloRif()) &&
|
||||
Objects.equals(getNote(), mtbColr.getNote()) &&
|
||||
Objects.equals(getDataOrd(), mtbColr.getDataOrd()) &&
|
||||
Objects.equals(getDataColloRif(), mtbColr.getDataColloRif()) &&
|
||||
Objects.equals(getQtaCnf(), mtbColr.getQtaCnf()) &&
|
||||
Objects.equals(getQtaCol(), mtbColr.getQtaCol()) &&
|
||||
Objects.equals(getNumOrd(), mtbColr.getNumOrd()) &&
|
||||
Objects.equals(getNumEtich(), mtbColr.getNumEtich()) &&
|
||||
Objects.equals(getNumColloRif(), mtbColr.getNumColloRif()) &&
|
||||
Objects.equals(getDatetimeRow(), mtbColr.getDatetimeRow()) &&
|
||||
Objects.equals(getCodJcom(), mtbColr.getCodJcom()) &&
|
||||
Objects.equals(getNumCnf(), mtbColr.getNumCnf()) &&
|
||||
getCausale() == mtbColr.getCausale() &&
|
||||
Objects.equals(getUtente(), mtbColr.getUtente()) &&
|
||||
Objects.equals(getCodAnagDoc(), mtbColr.getCodAnagDoc()) &&
|
||||
Objects.equals(getCodDtipDoc(), mtbColr.getCodDtipDoc()) &&
|
||||
Objects.equals(getDataDoc(), mtbColr.getDataDoc()) &&
|
||||
Objects.equals(getSerDoc(), mtbColr.getSerDoc()) &&
|
||||
Objects.equals(getNumDoc(), mtbColr.getNumDoc()) &&
|
||||
Objects.equals(getIdRigaDoc(), mtbColr.getIdRigaDoc()) &&
|
||||
Objects.equals(getPesoNettoKg(), mtbColr.getPesoNettoKg()) &&
|
||||
Objects.equals(getPesoLordoKg(), mtbColr.getPesoLordoKg()) &&
|
||||
Objects.equals(getInsPartitaMag(), mtbColr.getInsPartitaMag()) &&
|
||||
Objects.equals(getMtbPartitaMag_descrizione(), mtbColr.getMtbPartitaMag_descrizione()) &&
|
||||
Objects.equals(getDataScadPartita(), mtbColr.getDataScadPartita()) &&
|
||||
Objects.equals(getDescrizione(), mtbColr.getDescrizione()) &&
|
||||
Objects.equals(getFlagQtaCnfFissa(), mtbColr.getFlagQtaCnfFissa()) &&
|
||||
Objects.equals(getArtAPeso(), mtbColr.getArtAPeso()) &&
|
||||
Objects.equals(getBarcodeUlIn(), mtbColr.getBarcodeUlIn()) &&
|
||||
Objects.equals(getCodMdepIn(), mtbColr.getCodMdepIn()) &&
|
||||
Objects.equals(getPosizioneIn(), mtbColr.getPosizioneIn()) &&
|
||||
Objects.equals(getBarcodeUlOut(), mtbColr.getBarcodeUlOut()) &&
|
||||
Objects.equals(getCodMdepOut(), mtbColr.getCodMdepOut()) &&
|
||||
Objects.equals(getPosizioneOut(), mtbColr.getPosizioneOut());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getDataCollo(), getGestione(), getSerCollo(), getNumCollo(), getRiga(), getRigaOrd(), getCodMart(), getCodBarre(), getCodCol(), getCodTagl(), getPartitaMag(), getGestioneRif(), getSerColloRif(), getNote(), getDataOrd(), getDataColloRif(), getQtaCnf(), getQtaCol(), getNumOrd(), getNumEtich(), getNumColloRif(), getDatetimeRow(), getCodJcom(), getNumCnf(), getCausale(), getUtente(), getCodAnagDoc(), getCodDtipDoc(), getDataDoc(), getSerDoc(), getNumDoc(), getIdRigaDoc(), getPesoNettoKg(), getPesoLordoKg(), getInsPartitaMag(), getMtbPartitaMag_descrizione(), getDataScadPartita(), getDescrizione(), getFlagQtaCnfFissa(), getArtAPeso());
|
||||
return Objects.hash(getDataCollo(),
|
||||
getGestione(), getSerCollo(),
|
||||
getNumCollo(), getRiga(),
|
||||
getRigaOrd(), getCodMart(),
|
||||
getCodBarre(), getCodCol(),
|
||||
getCodTagl(), getPartitaMag(),
|
||||
getGestioneRif(), getSerColloRif(),
|
||||
getNote(), getDataOrd(),
|
||||
getDataColloRif(), getQtaCnf(),
|
||||
getQtaCol(), getNumOrd(),
|
||||
getNumEtich(), getNumColloRif(),
|
||||
getDatetimeRow(), getCodJcom(),
|
||||
getNumCnf(), getCausale(),
|
||||
getUtente(), getCodAnagDoc(),
|
||||
getCodDtipDoc(), getDataDoc(),
|
||||
getSerDoc(), getNumDoc(),
|
||||
getIdRigaDoc(), getPesoNettoKg(),
|
||||
getPesoLordoKg(), getInsPartitaMag(),
|
||||
getMtbPartitaMag_descrizione(), getDataScadPartita(),
|
||||
getDescrizione(), getFlagQtaCnfFissa(),
|
||||
getArtAPeso(),
|
||||
getBarcodeUlIn(),
|
||||
getCodMdepIn(),
|
||||
getPosizioneIn(),
|
||||
getBarcodeUlOut(),
|
||||
getCodMdepOut(),
|
||||
getPosizioneOut());
|
||||
}
|
||||
|
||||
public enum Causale implements IBaseEnum<Causale> {
|
||||
|
||||
@@ -6,9 +6,10 @@ import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.entity.key.MtbColtKey;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -19,7 +20,10 @@ import java.sql.CallableStatement;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@@ -99,7 +103,7 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
private LocalDate dataOrd;
|
||||
|
||||
@SqlField(value = "data_doc")
|
||||
private Date dataDoc;
|
||||
private LocalDate dataDoc;
|
||||
|
||||
@SqlField(value = "ora_iniz_prep")
|
||||
private Date oraInizPrep;
|
||||
@@ -197,6 +201,14 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
super(logger);
|
||||
}
|
||||
|
||||
public MtbColt(MtbColtKey mtbColtKey) {
|
||||
this();
|
||||
this.dataCollo = mtbColtKey.getDataCollo();
|
||||
this.gestione = mtbColtKey.getGestione();
|
||||
this.serCollo = mtbColtKey.getSerCollo();
|
||||
this.numCollo = mtbColtKey.getNumCollo();
|
||||
}
|
||||
|
||||
public MtbColt(String gestione, LocalDate dataCollo, Integer numCollo, String serCollo) {
|
||||
this();
|
||||
this.dataCollo = dataCollo;
|
||||
@@ -205,6 +217,16 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
this.numCollo = numCollo;
|
||||
}
|
||||
|
||||
|
||||
public MtbColtKey getKey() {
|
||||
return UtilityString.isNullOrEmpty(gestione) ||
|
||||
UtilityString.isNullOrEmpty(dataCollo) ||
|
||||
dataCollo == null ||
|
||||
numCollo == null ?
|
||||
null :
|
||||
new MtbColtKey(gestione, serCollo, getDataCollo(), numCollo);
|
||||
}
|
||||
|
||||
public String getGestione() {
|
||||
return gestione;
|
||||
}
|
||||
@@ -385,11 +407,11 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataDoc() {
|
||||
public LocalDate getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public MtbColt setDataDoc(Date dataDoc) {
|
||||
public MtbColt setDataDoc(LocalDate dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
return this;
|
||||
}
|
||||
@@ -693,17 +715,35 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
|
||||
@Override
|
||||
public void execStoredProcedure() throws Exception {
|
||||
if (this.getOperation() != OperationType.DELETE && dataCollo != null) {
|
||||
if (this.getOperation() != OperationType.DELETE &&
|
||||
getOperation() != OperationType.SELECT_OBJECT &&
|
||||
getOperation() != OperationType.SELECT &&
|
||||
getKey() != null) {
|
||||
if (this.getCalcPeso()) {
|
||||
String whereCond = "mtb_colt.gestione = " + UtilityDB.valueToString(this.getGestione()) + " AND " + "mtb_colt.data_collo = " + UtilityDB.valueToString(this.getDataCollo()) + " AND " + "mtb_colt.ser_collo = " + UtilityDB.valueToString(this.getSerCollo()) + " AND " + "mtb_colt.num_collo = " + UtilityDB.valueToString(this.getNumCollo());
|
||||
String sql = "SELECT ISNULL(SUM(mtb_colr.peso_netto_kg), 0) AS peso_netto_kg, " + "ISNULL(SUM(mtb_colr.peso_lordo_kg), 0) AS peso_lordo_kg\n" + "FROM mtb_colt\n" + " INNER JOIN mtb_colr ON mtb_colt.gestione = mtb_colr.gestione AND mtb_colt.data_collo = mtb_colr.data_collo AND\n" + " mtb_colt.ser_collo = mtb_colr.ser_collo AND mtb_colt.num_collo = mtb_colr.num_collo\n";
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, false);
|
||||
HashMap<String, Object> peso = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
||||
BigDecimal pesoNettoKg = UtilityHashMap.getValueIfExists(peso, "peso_netto_kg", BigDecimal.ZERO);
|
||||
BigDecimal pesoLordoKg = UtilityHashMap.getValueIfExists(peso, "peso_lordo_kg", BigDecimal.ZERO);
|
||||
sql = "UPDATE mtb_colt\n" + " SET peso_kg = " + UtilityDB.valueToString(pesoLordoKg) + ",\n" + " peso_netto_kg = " + UtilityDB.valueToString(pesoNettoKg);
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, false);
|
||||
UtilityDB.executeSimpleUpdate(connection, sql);
|
||||
|
||||
String updateSql = Query.format("UPDATE mtb_colt\n" +
|
||||
"SET peso_kg = ISNULL(mtb_colr.peso_lordo_kg, 0),\n" +
|
||||
" peso_netto_kg = ISNULL(mtb_colr.peso_netto_kg, 0)\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" INNER JOIN (SELECT gestione,\n" +
|
||||
" data_collo,\n" +
|
||||
" ser_collo,\n" +
|
||||
" num_collo,\n" +
|
||||
" SUM(mtb_colr.peso_lordo_kg) AS peso_lordo_kg,\n" +
|
||||
" SUM(mtb_colr.peso_netto_kg) AS peso_netto_kg\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" GROUP BY gestione, data_collo, ser_collo, num_collo) mtb_colr ON\n" +
|
||||
" mtb_colt.gestione = mtb_colr.gestione AND\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo AND\n" +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo AND\n" +
|
||||
" mtb_colt.data_collo = mtb_colr.data_collo\n" +
|
||||
" WHERE mtb_colt.gestione = %s\n" +
|
||||
" AND mtb_colt.data_collo = %s\n" +
|
||||
" AND mtb_colt.ser_collo = %s\n" +
|
||||
" AND mtb_colt.num_collo = %s",
|
||||
getGestione(), getDataCollo(), getSerCollo(), getNumCollo());
|
||||
|
||||
UtilityDB.executeSimpleUpdate(connection, updateSql);
|
||||
}
|
||||
CallableStatement StoredProcedure = connection.prepareCall("{call dbo.mtbColt_storedProcedurePers(?,?,?,?)}");
|
||||
StoredProcedure.setString(1, gestione);
|
||||
|
||||
@@ -10,6 +10,7 @@ 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;
|
||||
@@ -102,7 +103,7 @@ public class MtbPartitaMag extends EntityBase implements EquatableEntityInterfac
|
||||
private String partitaMagProd;
|
||||
|
||||
@SqlField(value = "data_prod")
|
||||
private Date dataProd;
|
||||
private LocalDate dataProd;
|
||||
|
||||
@EntityChild
|
||||
private List<MtbPartitaMagCarat> mtbPartitaMagCarat = new ArrayList<>();
|
||||
@@ -336,11 +337,11 @@ public class MtbPartitaMag extends EntityBase implements EquatableEntityInterfac
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataProd() {
|
||||
public LocalDate getDataProd() {
|
||||
return dataProd;
|
||||
}
|
||||
|
||||
public MtbPartitaMag setDataProd(Date dataProd) {
|
||||
public MtbPartitaMag setDataProd(LocalDate dataProd) {
|
||||
this.dataProd = dataProd;
|
||||
return this;
|
||||
}
|
||||
@@ -386,11 +387,59 @@ public class MtbPartitaMag extends EntityBase implements EquatableEntityInterfac
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MtbPartitaMag)) return false;
|
||||
MtbPartitaMag that = (MtbPartitaMag) o;
|
||||
return Objects.equals(getCodMart(), that.getCodMart()) && Objects.equals(getPartitaMag(), that.getPartitaMag()) && Objects.equals(getDescrizione(), that.getDescrizione()) && Objects.equals(getDataIns(), that.getDataIns()) && Objects.equals(getDataScad(), that.getDataScad()) && Objects.equals(getScelta(), that.getScelta()) && Objects.equals(getCostoUntUmMag(), that.getCostoUntUmMag()) && Objects.equals(getValUntUmMag(), that.getValUntUmMag()) && Objects.equals(getTaraCnfKg(), that.getTaraCnfKg()) && Objects.equals(getQtaCnf(), that.getQtaCnf()) && Objects.equals(getFlagImballoArendere(), that.getFlagImballoArendere()) && Objects.equals(getFlagStato(), that.getFlagStato()) && Objects.equals(getCodDiviCont(), that.getCodDiviCont()) && Objects.equals(getCambioDiviCont(), that.getCambioDiviCont()) && Objects.equals(getBarcode(), that.getBarcode()) && Objects.equals(getNote(), that.getNote()) && Objects.equals(getRapConv2(), that.getRapConv2()) && Objects.equals(getRapConv3(), that.getRapConv3()) && Objects.equals(getPosizione(), that.getPosizione()) && Objects.equals(getDataAggPrz(), that.getDataAggPrz()) && Objects.equals(getPartitaMagSec(), that.getPartitaMagSec()) && Objects.equals(getQtaAttesa(), that.getQtaAttesa()) && Objects.equals(getNazioneProv(), that.getNazioneProv());
|
||||
return Objects.equals(getCodMart(), that.getCodMart()) &&
|
||||
Objects.equals(getPartitaMag(), that.getPartitaMag()) &&
|
||||
Objects.equals(getDescrizione(), that.getDescrizione()) &&
|
||||
Objects.equals(getDataIns(), that.getDataIns()) &&
|
||||
Objects.equals(getDataScad(), that.getDataScad()) &&
|
||||
Objects.equals(getScelta(), that.getScelta()) &&
|
||||
Objects.equals(getCostoUntUmMag(), that.getCostoUntUmMag()) &&
|
||||
Objects.equals(getValUntUmMag(), that.getValUntUmMag()) &&
|
||||
Objects.equals(getTaraCnfKg(), that.getTaraCnfKg()) &&
|
||||
Objects.equals(getQtaCnf(), that.getQtaCnf()) &&
|
||||
Objects.equals(getFlagImballoArendere(), that.getFlagImballoArendere()) &&
|
||||
Objects.equals(getFlagStato(), that.getFlagStato()) &&
|
||||
Objects.equals(getCodDiviCont(), that.getCodDiviCont()) &&
|
||||
Objects.equals(getCambioDiviCont(), that.getCambioDiviCont()) &&
|
||||
Objects.equals(getBarcode(), that.getBarcode()) &&
|
||||
Objects.equals(getNote(), that.getNote()) &&
|
||||
Objects.equals(getRapConv2(), that.getRapConv2()) &&
|
||||
Objects.equals(getRapConv3(), that.getRapConv3()) &&
|
||||
Objects.equals(getPosizione(), that.getPosizione()) &&
|
||||
Objects.equals(getDataAggPrz(), that.getDataAggPrz()) &&
|
||||
Objects.equals(getPartitaMagSec(), that.getPartitaMagSec()) &&
|
||||
Objects.equals(getQtaAttesa(), that.getQtaAttesa()) &&
|
||||
Objects.equals(getNazioneProv(), that.getNazioneProv()) &&
|
||||
Objects.equals(getPartitaMagProd(), that.getPartitaMagProd()) &&
|
||||
Objects.equals(getDataProd(), that.getDataProd());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getCodMart(), getPartitaMag(), getDescrizione(), getDataIns(), getDataScad(), getScelta(), getCostoUntUmMag(), getValUntUmMag(), getTaraCnfKg(), getQtaCnf(), getFlagImballoArendere(), getFlagStato(), getCodDiviCont(), getCambioDiviCont(), getBarcode(), getNote(), getRapConv2(), getRapConv3(), getPosizione(), getDataAggPrz(), getPartitaMagSec(), getQtaAttesa(), getNazioneProv());
|
||||
return Objects.hash(getCodMart(),
|
||||
getPartitaMag(),
|
||||
getDescrizione(),
|
||||
getDataIns(),
|
||||
getDataScad(),
|
||||
getScelta(),
|
||||
getCostoUntUmMag(),
|
||||
getValUntUmMag(),
|
||||
getTaraCnfKg(),
|
||||
getQtaCnf(),
|
||||
getFlagImballoArendere(),
|
||||
getFlagStato(),
|
||||
getCodDiviCont(),
|
||||
getCambioDiviCont(),
|
||||
getBarcode(),
|
||||
getNote(),
|
||||
getRapConv2(),
|
||||
getRapConv3(),
|
||||
getPosizione(),
|
||||
getDataAggPrz(),
|
||||
getPartitaMagSec(),
|
||||
getQtaAttesa(),
|
||||
getNazioneProv(),
|
||||
getPartitaMagProd(),
|
||||
getDataProd());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,6 @@ public class StbUser extends EntityBase {
|
||||
@SqlField(value = "flag_password_expiring", maxLength = 1, defaultObjectValue = "N")
|
||||
private String flagPasswordExpiring;
|
||||
|
||||
@SqlField(value = "destruction_datetime")
|
||||
private Date destructionDatetime;
|
||||
|
||||
@SqlField(value = "cod_lang", maxLength = 5, defaultObjectValue = "IT")
|
||||
private String codLang;
|
||||
|
||||
@@ -461,15 +458,6 @@ public class StbUser extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDestructionDatetime() {
|
||||
return destructionDatetime;
|
||||
}
|
||||
|
||||
public StbUser setDestructionDatetime(Date destructionDatetime) {
|
||||
this.destructionDatetime = destructionDatetime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodLang() {
|
||||
return codLang;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.annotation.Table;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
@PropertyReactive
|
||||
@Table(WtbJreptSetup.ENTITY)
|
||||
@@ -155,13 +155,15 @@ public class WtbJreptSetup extends EntityBase {
|
||||
ETICHETTA_SSCC_ACCETTAZIONE((short) 0),
|
||||
ETICHETTA_SSCC_LAVORAZIONE((short) 1),
|
||||
ETICHETTA_SSCC_SPEDIZIONE((short) 2),
|
||||
WMS_SPEDIZIONE_PACKING_LIST_ORD((short) 4),
|
||||
PACKING_LIST_ORD_SPEDIZIONE((short) 4),
|
||||
STAMPA_LISTINI_VENDITA((short) 5),
|
||||
STAMPA_LISTINI_VENDITA_RANGE_PEDANE((short) 6),
|
||||
STAMPA_ORDINE_LAVORAZIONE((short) 7),
|
||||
STAMPA_DOCUMENTI_VENDITA((short) 8),
|
||||
STAMPA_DOCUMENTI_LAVORAZIONE((short) 9),
|
||||
STAMPA_DOCUMENTI_ACQUISTO((short) 10);
|
||||
STAMPA_DOCUMENTI_ACQUISTO((short) 10),
|
||||
PACKING_LIST_DOC_SPEDIZIONE((short) 11),
|
||||
PACKING_LIST_DOC_ACCETTAZIONE((short) 12);
|
||||
|
||||
private final short value;
|
||||
|
||||
@@ -171,7 +173,7 @@ public class WtbJreptSetup extends EntityBase {
|
||||
|
||||
@JsonCreator
|
||||
public static Tipo from(Object value) {
|
||||
int castValue = (int) value;
|
||||
int castValue = value instanceof String ? Integer.parseInt((String) value) : (int) value;
|
||||
for (Tipo b : Tipo.values()) {
|
||||
if (b.value == castValue)
|
||||
return b;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package it.integry.ems_model.entity.key;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DtbDocrKey extends DtbDoctKey {
|
||||
|
||||
@SqlField("id_riga")
|
||||
private int idRiga;
|
||||
|
||||
public DtbDocrKey() {
|
||||
}
|
||||
|
||||
public DtbDocrKey(String codAnag, String codDtip, LocalDate dataDoc, Integer numDoc, String serDoc, int idRiga) {
|
||||
super(codAnag, codDtip, dataDoc, numDoc, serDoc);
|
||||
this.idRiga = idRiga;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof DtbDocrKey)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
DtbDocrKey that = (DtbDocrKey) o;
|
||||
return getIdRiga() == that.getIdRiga();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), getIdRiga());
|
||||
}
|
||||
|
||||
public int getIdRiga() {
|
||||
return idRiga;
|
||||
}
|
||||
|
||||
public DtbDocrKey setIdRiga(int idRiga) {
|
||||
this.idRiga = idRiga;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,17 +1,31 @@
|
||||
package it.integry.ems_model.entity.key;
|
||||
|
||||
import java.util.Date;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DtbDoctKey {
|
||||
|
||||
private final String codAnag;
|
||||
private final String codDtip;
|
||||
private final Date dataDoc;
|
||||
private final Integer numDoc;
|
||||
private final String serDoc;
|
||||
@SqlField("cod_anag")
|
||||
private String codAnag;
|
||||
|
||||
public DtbDoctKey(String codAnag, String codDtip, Date dataDoc, Integer numDoc, String serDoc) {
|
||||
@SqlField("cod_dtip")
|
||||
private String codDtip;
|
||||
|
||||
@SqlField("data_doc")
|
||||
private LocalDate dataDoc;
|
||||
|
||||
@SqlField("num_doc")
|
||||
private Integer numDoc;
|
||||
|
||||
@SqlField("ser_doc")
|
||||
private String serDoc;
|
||||
|
||||
public DtbDoctKey() {
|
||||
}
|
||||
|
||||
public DtbDoctKey(String codAnag, String codDtip, LocalDate dataDoc, Integer numDoc, String serDoc) {
|
||||
this.codAnag = codAnag;
|
||||
this.codDtip = codDtip;
|
||||
this.dataDoc = dataDoc;
|
||||
@@ -22,7 +36,7 @@ public class DtbDoctKey {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (o == null || (getClass() != o.getClass() && !getClass().isAssignableFrom(o.getClass()))) return false;
|
||||
DtbDoctKey that = (DtbDoctKey) o;
|
||||
return Objects.equals(codAnag, that.codAnag) &&
|
||||
Objects.equals(codDtip, that.codDtip) &&
|
||||
@@ -35,4 +49,49 @@ public class DtbDoctKey {
|
||||
public int hashCode() {
|
||||
return Objects.hash(codAnag, codDtip, dataDoc, numDoc, serDoc);
|
||||
}
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public DtbDoctKey setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodDtip() {
|
||||
return codDtip;
|
||||
}
|
||||
|
||||
public DtbDoctKey setCodDtip(String codDtip) {
|
||||
this.codDtip = codDtip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public DtbDoctKey setDataDoc(LocalDate dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNumDoc() {
|
||||
return numDoc;
|
||||
}
|
||||
|
||||
public DtbDoctKey setNumDoc(Integer numDoc) {
|
||||
this.numDoc = numDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSerDoc() {
|
||||
return serDoc;
|
||||
}
|
||||
|
||||
public DtbDoctKey setSerDoc(String serDoc) {
|
||||
this.serDoc = serDoc;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package it.integry.ems_model.entity.key;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class MtbColrKey extends MtbColtKey {
|
||||
|
||||
@SqlField("riga")
|
||||
private int riga;
|
||||
|
||||
public MtbColrKey() {
|
||||
}
|
||||
|
||||
public MtbColrKey(String gestione, String serCollo, LocalDate dataCollo, int numCollo, int riga) {
|
||||
super(gestione, serCollo, dataCollo, numCollo);
|
||||
this.riga = riga;
|
||||
}
|
||||
|
||||
public Integer getRiga() {
|
||||
return riga;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
MtbColrKey that = (MtbColrKey) o;
|
||||
return getRiga().equals(that.getRiga());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + getRiga().hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,14 @@ import java.util.Objects;
|
||||
|
||||
public class MtbColtKey {
|
||||
|
||||
private final String gestione;
|
||||
private final String serCollo;
|
||||
private final LocalDate dataCollo;
|
||||
private final Integer numCollo;
|
||||
private String gestione;
|
||||
private String serCollo;
|
||||
private LocalDate dataCollo;
|
||||
private Integer numCollo;
|
||||
|
||||
public MtbColtKey() {
|
||||
// Default constructor for JPA
|
||||
}
|
||||
|
||||
public MtbColtKey(String gestione, String serCollo, LocalDate dataCollo, Integer numCollo) {
|
||||
this.gestione = gestione;
|
||||
@@ -17,10 +21,26 @@ public class MtbColtKey {
|
||||
this.numCollo = numCollo;
|
||||
}
|
||||
|
||||
public String getGestione() {
|
||||
return gestione;
|
||||
}
|
||||
|
||||
public String getSerCollo() {
|
||||
return serCollo;
|
||||
}
|
||||
|
||||
public LocalDate getDataCollo() {
|
||||
return dataCollo;
|
||||
}
|
||||
|
||||
public Integer getNumCollo() {
|
||||
return numCollo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (o == null || (getClass() != o.getClass() && !getClass().isAssignableFrom(o.getClass()))) return false;
|
||||
MtbColtKey that = (MtbColtKey) o;
|
||||
return Objects.equals(dataCollo, that.dataCollo) &&
|
||||
Objects.equals(gestione, that.gestione) &&
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DocumentExtEntityRules {
|
||||
if (first.get().getOperation() != OperationType.DELETE) {
|
||||
first.get().setCodDtip(EmsRestConstants.NULL)
|
||||
.setCodAnag(EmsRestConstants.NULL)
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||
.setDataDoc(EmsRestConstants.LOCAL_DATE_NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
||||
.setCodAnag(mtbColt.getFlagColloAnonimo().equalsIgnoreCase("S") ? EmsRestConstants.NULL : mtbColt.getCodAnag())
|
||||
@@ -44,7 +44,7 @@ public class DocumentExtEntityRules {
|
||||
} else {
|
||||
mtbColt.setCodDtip(EmsRestConstants.NULL)
|
||||
.setCodAnag(EmsRestConstants.NULL)
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||
.setDataDoc(EmsRestConstants.LOCAL_DATE_NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
||||
.setCodAnag(mtbColt.getFlagColloAnonimo().equalsIgnoreCase("S")?EmsRestConstants.NULL:mtbColt.getCodAnag())
|
||||
|
||||
@@ -405,4 +405,8 @@ public class SetupGest {
|
||||
public boolean getSetupDetBoolean(String gestName, String section, String keySection, String colRif) throws Exception {
|
||||
return "S".equalsIgnoreCase(getSetupDet(gestName, section, keySection, colRif));
|
||||
}
|
||||
|
||||
public boolean getSetupDetBoolean(Connection conn, String gestName, String section, String keySection, String colRif) throws Exception {
|
||||
return "S".equalsIgnoreCase(getSetupDet(conn, gestName, section, keySection, colRif));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ public class UtilityBarcodeEan128 {
|
||||
|
||||
switch (aiModel.AI) {
|
||||
case SSCC:
|
||||
if (!aiValue.isEmpty() && (aiValue.charAt(0) == '0' || aiValue.charAt(0) == '9')) {
|
||||
aiValue = aiValue.substring(1);
|
||||
}
|
||||
// if (!aiValue.isEmpty() && (aiValue.charAt(0) == '0' || aiValue.charAt(0) == '9')) {
|
||||
// aiValue = aiValue.substring(1);
|
||||
// }
|
||||
model.Sscc = aiValue;
|
||||
break;
|
||||
case GTIN:
|
||||
|
||||
@@ -15,9 +15,14 @@ public class UtilityException {
|
||||
if(e.getStackTrace().length > 0)
|
||||
errorMessage = "Null value at " + e.getStackTrace()[0].toString();
|
||||
else errorMessage = "Empty stacktrace\n" + e;
|
||||
|
||||
} else if (e instanceof BaseSystemException) {
|
||||
errorCode = ((BaseSystemException) e).getCode();
|
||||
errorMessage = ((BaseSystemException) e).getCustomMessage();
|
||||
|
||||
} else if (e instanceof IllegalArgumentException) {
|
||||
errorMessage = e.getMessage();
|
||||
|
||||
} else if (e instanceof EntityException) {
|
||||
EntityException entityException = (EntityException) e;
|
||||
|
||||
@@ -49,6 +54,7 @@ public class UtilityException {
|
||||
}
|
||||
|
||||
errorMessage = message;
|
||||
|
||||
} else if (e instanceof RuntimeException || e instanceof JRException) {
|
||||
String message = e.getCause() != null && e.getCause().getMessage() != null ? e.getCause().getMessage() : e.toString();
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package it.integry.ems_model.utility;
|
||||
|
||||
import it.integry.ems_model.base.EntityInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class UtilityList {
|
||||
@@ -15,4 +18,20 @@ public class UtilityList {
|
||||
return defaultValue;
|
||||
return listToCheck;
|
||||
}
|
||||
|
||||
|
||||
public static <T extends EntityInterface> List<T> clone(List<T> listToClone) {
|
||||
if (listToClone == null) {
|
||||
return null;
|
||||
}
|
||||
return new ArrayList<>(listToClone.stream()
|
||||
.map(x -> {
|
||||
try {
|
||||
return (T) x.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
@@ -158,6 +158,11 @@ public class UtilityLocalDate {
|
||||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
public static LocalDate isNull(LocalDate dateToCheck, LocalDate fallbackValue) {
|
||||
if (dateToCheck == null) return fallbackValue;
|
||||
return dateToCheck;
|
||||
}
|
||||
|
||||
public static LocalDateTime isNull(LocalDateTime dateToCheck, LocalDateTime fallbackValue) {
|
||||
if (dateToCheck == null) return fallbackValue;
|
||||
return dateToCheck;
|
||||
|
||||
@@ -5,6 +5,7 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.utility.dto.PageableRequestDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -96,7 +97,14 @@ public class UtilityQuery {
|
||||
for (int k = 0; k < keys.length; k++) {
|
||||
Object value = singleInputData.get(keys[k]);
|
||||
|
||||
sbWhereCond.append(keys[k] + (value == null ? " IS NULL" : " = " + UtilityDB.valueToString(value)));
|
||||
sbWhereCond.append(keys[k]);
|
||||
if(value == null || value.equals(EmsRestConstants.NULL)) {
|
||||
sbWhereCond.append(" IS NULL");
|
||||
} else if(value.equals(EmsRestConstants.NOT_NULL)) {
|
||||
sbWhereCond.append(" IS NOT NULL");
|
||||
} else {
|
||||
sbWhereCond.append(" = ").append(UtilityDB.valueToString(value));
|
||||
}
|
||||
|
||||
if (k < keys.length - 1) sbWhereCond.append(" AND ");
|
||||
}
|
||||
|
||||
@@ -22,12 +22,13 @@ global IntegryCustomerDB customerDb
|
||||
global IntegryCustomer customer
|
||||
|
||||
rule "completeMtbColtProgressivoUlRG"
|
||||
salience 10
|
||||
no-loop
|
||||
when
|
||||
eval(postRulesEnabled && customer == IntegryCustomer.RossoGargano)
|
||||
$mtbColt: MtbColt(operation != OperationType.DELETE && progressivoUl == null && gestione != null && gestione == 'L' && dataOrd != null && numOrd != null)
|
||||
then
|
||||
int progressivoToSave = CommonRules.retrieveNextProgressivoUlRG(conn, $mtbColt.getGestione(), $mtbColt.getDataOrd(), $mtbColt.getNumOrd(), $mtbColt.getSegno());
|
||||
int progressivoToSave = CommonRules.retrieveNextProgressivoUlRG(conn, $mtbColt.getGestione(), $mtbColt.getDataOrd(), $mtbColt.getNumOrd(), $mtbColt.getSegno(), $mtbColt.getCodJfas());
|
||||
|
||||
modify($mtbColt){
|
||||
setProgressivoUl(progressivoToSave);
|
||||
|
||||
@@ -67,15 +67,14 @@ then
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
||||
rule "deleteDatiDocValV"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$docT : DtbDoct(previstaFat == "S" && serDoc.equalsIgnoreCase(serDocVal) &&
|
||||
numDoc.equals(numDocVal) && dataDoc.equals(dataDocVal) &&
|
||||
codDtip.equalsIgnoreCase(codDtipVal))
|
||||
$docT : DtbDoct(previstaFat == "S" && serDocVal != null && numDoc != null && codDtipVal != null &&
|
||||
serDoc == serDocVal &&
|
||||
numDoc == numDocVal && dataDoc == dataDocVal &&
|
||||
codDtip == codDtipVal)
|
||||
then
|
||||
modify ( $docT ) {
|
||||
setDataDocVal(EmsRestConstants.DATE_NULL),
|
||||
|
||||
@@ -165,5 +165,11 @@
|
||||
<artifactId>fixedformat4j</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.datafaker</groupId>
|
||||
<artifactId>datafaker</artifactId>
|
||||
<version>1.9.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -14,6 +14,7 @@ import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.PrinterService;
|
||||
import it.integry.ems.service.ReportProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityPdf;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||
import it.integry.ems_model.entity.JtbDisegniFiles;
|
||||
@@ -84,6 +85,7 @@ public class EmsEngineController {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse downloadReport(HttpServletRequest request,
|
||||
@@ -96,6 +98,27 @@ public class EmsEngineController {
|
||||
return ServiceRestResponse.createNegativeResponse("Nessun report generato!");
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT_LIST, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse downloadReportList(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody JasperDTO[] jasperDTOList)throws Exception {
|
||||
|
||||
FileItem fi = new FileItem();
|
||||
List<byte[]> pdfList = new ArrayList<>();
|
||||
for (JasperDTO jasperDTO : jasperDTOList) {
|
||||
pdfList.add(emsEngineService.processReport(jasperDTO));
|
||||
}
|
||||
byte[] bytes = UtilityPdf.merge(pdfList);
|
||||
|
||||
if (bytes != null) {
|
||||
return ServiceRestResponse.createPositiveResponse(downloadFileHandlerService.generateDownloadItem(new Date().getTime() + ".pdf", bytes));
|
||||
} else {
|
||||
return ServiceRestResponse.createNegativeResponse("Nessun report generato!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_PROCESS_REPORT_TYPE, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse processReportTypeList(HttpServletRequest request,
|
||||
@@ -118,14 +141,9 @@ public class EmsEngineController {
|
||||
public @ResponseBody
|
||||
ServiceRestResponse printReportTypeList(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody ReportTypeDTO reportTypeDTO) {
|
||||
try {
|
||||
@RequestBody ReportTypeDTO reportTypeDTO) throws Exception {
|
||||
printerService.printReportType(reportTypeDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(configuration, e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_SETUP_REPORT_TYPE, method = RequestMethod.POST)
|
||||
|
||||
@@ -1634,7 +1634,7 @@ public class ActivityService {
|
||||
|
||||
try {
|
||||
m.addConnection(historyProfileDb);
|
||||
m.setPrimaryDs(historyProfileDb);
|
||||
m.setPrimaryDB(historyProfileDb);
|
||||
|
||||
String sql = "select stb_activity.activity_id,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
|
||||
@@ -141,7 +141,7 @@ public class SteUPService {
|
||||
toReturn.put("user", userData);
|
||||
|
||||
profileDb = userData.get("profile_db").toString();
|
||||
multiDBTransactionManager.setPrimaryDs(profileDb);
|
||||
multiDBTransactionManager.setPrimaryDB(profileDb);
|
||||
|
||||
String sql = "SELECT mtb_depo.cod_mdep, mtb_depo.descrizione, mtb_depo.indirizzo, mtb_depo.citta, mtb_depo.cap, mtb_depo.prov " +
|
||||
"FROM mtb_depo INNER JOIN wtb_depo ON wtb_depo.cod_mdep = mtb_depo.cod_mdep " +
|
||||
@@ -952,7 +952,7 @@ public class SteUPService {
|
||||
|
||||
public void uploadAttachmentTmp() throws Exception {
|
||||
|
||||
try (Connection connection = basicConnectionPool.getConnection("WINACT")) {
|
||||
try (Connection connection = basicConnectionPool.getConnection(settingsModel.findConnectionModel("WINACT"))) {
|
||||
|
||||
String sql =
|
||||
"select a.activity_id, t.activity_id_new, f.file_name, f.last_upd " +
|
||||
|
||||
@@ -52,7 +52,7 @@ public class RegCorrispettivoService {
|
||||
if (!UtilityString.isNullOrEmpty(profileDBFromSetupGest) && !profileDBFromSetupGest.equalsIgnoreCase(multiDBTransactionManager.getPrimaryConnection().getProfileName())) {
|
||||
multiDBTransactionManager.close();
|
||||
|
||||
multiDBTransactionManager.setPrimaryDs(profileDBFromSetupGest);
|
||||
multiDBTransactionManager.setPrimaryDB(profileDBFromSetupGest);
|
||||
}
|
||||
|
||||
String campoTipoIncasso = (raggruppaPerConto ? "cod_ccon" : "tipo_inca");
|
||||
|
||||
@@ -2,7 +2,9 @@ package it.integry.ems.customizations.production.controller;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.customizations.constant.EmsCustomRestConstants;
|
||||
import it.integry.ems.customizations.production.dto.ROSSOGARGANO.SaveCqPomodoriRGDTO;
|
||||
import it.integry.ems.customizations.production.service.RossoGarganoProductionService;
|
||||
import it.integry.ems.production.dto.ortofrutta.AccettazioneOrtoFruttaDTO;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -13,6 +15,7 @@ import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Scope(value = "request")
|
||||
@@ -28,14 +31,11 @@ public class RossoGarganoProductionController {
|
||||
public MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = EmsCustomRestConstants.PATH_ROSSO_GARGANO_SYNC_CERTIFICATI_VALORIZZATI, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse syncCertificati(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam("externalProfileDb") String externalProfileDB)
|
||||
|
||||
{
|
||||
@RequestParam("externalProfileDb") String externalProfileDB) {
|
||||
try {
|
||||
rossoGarganoProductionService.syncCertificati(externalProfileDB);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
@@ -51,4 +51,26 @@ public class RossoGarganoProductionController {
|
||||
return new ServiceRestResponse(EsitoType.KO, profileDB, e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cq/pomodori", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse saveCqPomodori(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestBody List<SaveCqPomodoriRGDTO> dtoList) throws Exception {
|
||||
|
||||
try {
|
||||
rossoGarganoProductionService.saveCqPomodori(dtoList);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
} catch (Exception ex) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
}
|
||||
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return new ServiceRestResponse(EsitoType.KO, profileDB, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package it.integry.ems.customizations.production.dto.ROSSOGARGANO;
|
||||
|
||||
import it.integry.ems_model.entity.MtbPartitaMag;
|
||||
import it.integry.ems_model.entity.MtbPartitaMagCarat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SaveCqPomodoriRGDTO {
|
||||
|
||||
private String barcodeUl;
|
||||
private String posizione;
|
||||
private String codJfas;
|
||||
private MtbPartitaMag partitaMag;
|
||||
private String annotazioni;
|
||||
|
||||
public String getBarcodeUl() {
|
||||
return barcodeUl;
|
||||
}
|
||||
|
||||
public SaveCqPomodoriRGDTO setBarcodeUl(String barcodeUl) {
|
||||
this.barcodeUl = barcodeUl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPosizione() {
|
||||
return posizione;
|
||||
}
|
||||
|
||||
public SaveCqPomodoriRGDTO setPosizione(String posizione) {
|
||||
this.posizione = posizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJfas() {
|
||||
return codJfas;
|
||||
}
|
||||
|
||||
public SaveCqPomodoriRGDTO setCodJfas(String codJfas) {
|
||||
this.codJfas = codJfas;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MtbPartitaMag getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public SaveCqPomodoriRGDTO setPartitaMag(MtbPartitaMag partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAnnotazioni() {
|
||||
return annotazioni;
|
||||
}
|
||||
|
||||
public SaveCqPomodoriRGDTO setAnnotazioni(String annotazioni) {
|
||||
this.annotazioni = annotazioni;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class LicorProductionService {
|
||||
.setPartitaMag(scarico.getPartitaMag())
|
||||
.setTargetMtbColt(scaricoMaterialiAgg)
|
||||
.setQtaCnf(scarico.getQtaCnf())
|
||||
.setDataOrd(chiusuraLavorazioneDTO.getOrdine().getDataOrd())
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(chiusuraLavorazioneDTO.getOrdine().getDataOrd()))
|
||||
.setRigaOrd(rigaOrd)
|
||||
.setNumOrd(chiusuraLavorazioneDTO.getOrdine().getNumOrd());
|
||||
wmsLavorazioneService.insertUDSRow(insertRequestDto);
|
||||
@@ -419,7 +419,7 @@ public class LicorProductionService {
|
||||
requestDTO.setQtaCnf(rigaOrdine.getQtaCnf());
|
||||
requestDTO.setNumCnf(UtilityBigDecimal.divide(inventarioDTO.getQtaCol(), rigaOrdine.getQtaCnf()));
|
||||
|
||||
requestDTO.setDataOrd(rigaOrdine.getDataOrd());
|
||||
requestDTO.setDataOrd(UtilityLocalDate.localDateFromDate(rigaOrdine.getDataOrd()));
|
||||
requestDTO.setNumOrd(rigaOrdine.getNumOrd());
|
||||
requestDTO.setRigaOrd(rigaOrdine.getRigaOrd());
|
||||
|
||||
@@ -443,7 +443,7 @@ public class LicorProductionService {
|
||||
requestDTO.setQtaCnf(rigaOrdine.getQtaCnf());
|
||||
requestDTO.setNumCnf(UtilityBigDecimal.divide(disp.getQta(), rigaOrdine.getQtaCnf()));
|
||||
|
||||
requestDTO.setDataOrd(rigaOrdine.getDataOrd());
|
||||
requestDTO.setDataOrd(UtilityLocalDate.localDateFromDate(rigaOrdine.getDataOrd()));
|
||||
requestDTO.setNumOrd(rigaOrdine.getNumOrd());
|
||||
requestDTO.setRigaOrd(rigaOrdine.getRigaOrd());
|
||||
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
package it.integry.ems.customizations.production.service;
|
||||
|
||||
import it.integry.ems.customizations.production.dto.ROSSOGARGANO.SaveCqPomodoriRGDTO;
|
||||
import it.integry.ems.production.dto.ortofrutta.AccettazioneOrtoFruttaDTO;
|
||||
import it.integry.ems.production.service.MesProductionServiceV2;
|
||||
import it.integry.ems.production.service.OrtoFruttaProductionService;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.dto.UpdatePosizioneULRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SpostaUlRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGenericService;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.exchange.dto.CertificatiValorizzatiDTO;
|
||||
import it.integry.ems.system.exchange.service.structure.ExchangeImportDataManagerService;
|
||||
import it.integry.ems.system.exchange.service.structure.ExchangeImportSchemaManagerService;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.entity.MtbPartitaMag;
|
||||
import it.integry.ems_model.entity.MtbPartitaMagCarat;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,6 +32,7 @@ import org.springframework.stereotype.Service;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -45,9 +56,16 @@ public class RossoGarganoProductionService {
|
||||
|
||||
@Autowired
|
||||
private ExchangeImportDataManagerService exchangeImportDataManagerService;
|
||||
|
||||
@Autowired
|
||||
private OrtoFruttaProductionService ortoFruttaProductionService;
|
||||
|
||||
@Autowired
|
||||
private WMSGiacenzaULService wmsGiacenzaULService;
|
||||
|
||||
@Autowired
|
||||
private WMSGenericService wmsGenericService;
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public void syncCertificati(String externalProfileDb) throws Exception {
|
||||
@@ -379,4 +397,43 @@ public class RossoGarganoProductionService {
|
||||
valorizzazioneCertificatiTableName, Query.format("cod_mart is not null AND data_doc > {}", minDate), retrieveAlreadyImported);
|
||||
}
|
||||
|
||||
public void saveCqPomodori(List<SaveCqPomodoriRGDTO> dtoList) throws Exception {
|
||||
|
||||
if (UtilityList.isNullOrEmpty(dtoList))
|
||||
return;
|
||||
|
||||
List<EntityBase> entityList = new ArrayList<>();
|
||||
|
||||
for (SaveCqPomodoriRGDTO dto : dtoList) {
|
||||
if (!UtilityString.hasContent(dto.getBarcodeUl()))
|
||||
throw new Exception("Impossibile identificare il carico selezionato!");
|
||||
|
||||
MtbColt mtbColt = WMSUtility.retrieveBarcodeUlAnag(multiDBTransactionManager.getPrimaryConnection(), dto.getBarcodeUl());
|
||||
if (mtbColt == null)
|
||||
throw new Exception("Impossibile identificare il carico selezionato!");
|
||||
boolean movementEdited = false;
|
||||
if (UtilityString.hasContent(dto.getCodJfas())) {
|
||||
mtbColt.setCodJfas(dto.getCodJfas());
|
||||
movementEdited = true;
|
||||
}
|
||||
if (!UtilityString.equalsIgnoreCase(dto.getAnnotazioni(), mtbColt.getAnnotazioni())) {
|
||||
mtbColt.setAnnotazioni(dto.getAnnotazioni());
|
||||
movementEdited = true;
|
||||
}
|
||||
if (movementEdited) {
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
entityList.add(mtbColt);
|
||||
}
|
||||
|
||||
if (dto.getPartitaMag() != null) {
|
||||
dto.getPartitaMag().setOperation(OperationType.UPDATE);
|
||||
entityList.add(dto.getPartitaMag());
|
||||
}
|
||||
|
||||
}
|
||||
entityProcessor.processEntityList(entityList, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(entityList);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1191,7 +1191,7 @@ public class DocumentiAcquistoImportService {
|
||||
|
||||
MultiDBTransactionManager m = new MultiDBTransactionManager();
|
||||
try {
|
||||
m.setPrimaryDs(connection.getProfileName());
|
||||
m.setPrimaryDB(connection.getProfileName());
|
||||
|
||||
if (!isWdtb) {
|
||||
UpdProgOrdini(m, (DtbDoct) dtbBaseDoct, -1);
|
||||
|
||||
@@ -200,7 +200,7 @@ public class DocumentiConsortileService {
|
||||
|
||||
// Connessione al database dell'azienda agricola
|
||||
if (j == 0) {
|
||||
multiDBTransactionManagerAzAgr.setPrimaryDs(profileDB);
|
||||
multiDBTransactionManagerAzAgr.setPrimaryDB(profileDB);
|
||||
}
|
||||
|
||||
// Creazione documento vendita per azienda agricola
|
||||
@@ -373,7 +373,7 @@ public class DocumentiConsortileService {
|
||||
if (j == 0) {
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDB);
|
||||
multiDBTransactionManagerAzAgr.setPrimaryDs(profileDB);
|
||||
multiDBTransactionManagerAzAgr.setPrimaryDB(profileDB);
|
||||
}
|
||||
|
||||
// Creazione documento vendita per azienda agricola
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ImportResiDaClienteService {
|
||||
String userNameWeb = (String) dati.get("user_name");
|
||||
if (!UtilityString.isNullOrEmpty(profileDBCliente)) {
|
||||
mdbCliente = new MultiDBTransactionManager();
|
||||
mdbCliente.setPrimaryDs(profileDBCliente);
|
||||
mdbCliente.setPrimaryDB(profileDBCliente);
|
||||
MDBClientiList.add(mdbCliente);
|
||||
entityListDocClie = createEntityDocResoDelete(mdbCliente, doc, datiReso, partIva, type, format, userNameWeb);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.document.dto.CreateULFromDocumentsDTO;
|
||||
import it.integry.ems.document.service.DocumentiDirettiService;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.DtbDoct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -15,16 +16,25 @@ import javax.servlet.http.HttpServletRequest;
|
||||
@Scope("request")
|
||||
@RequestMapping("documenti-diretti")
|
||||
public class DocumentiDirettiController {
|
||||
|
||||
@Autowired
|
||||
private DocumentiDirettiService documentiDirettiService;
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@RequestMapping(value = "insert", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse insert(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody DtbDoct dtbDoct) throws Exception {
|
||||
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.save(dtbDoct, true));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "update", method = RequestMethod.POST)
|
||||
@@ -33,7 +43,12 @@ public class DocumentiDirettiController {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody DtbDoct dtbDoct) throws Exception {
|
||||
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.save(dtbDoct, false));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "delete", method = RequestMethod.POST)
|
||||
@@ -42,7 +57,12 @@ public class DocumentiDirettiController {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody DtbDoct dtbDoct) throws Exception {
|
||||
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.delete(dtbDoct));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "createULFromDocument", method = RequestMethod.POST)
|
||||
|
||||
@@ -8,9 +8,8 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ProduzioneOrdineDTO {
|
||||
public class ArticoloProdottoDTO {
|
||||
@SqlField("cod_mart")
|
||||
private String codMart;
|
||||
@SqlField("partita_mag")
|
||||
@@ -32,8 +31,8 @@ public class ProduzioneOrdineDTO {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public ProduzioneOrdineDTO() {}
|
||||
public ProduzioneOrdineDTO(String codMart, String partitaMag, BigDecimal quantita, DtbOrdt ordine) {
|
||||
public ArticoloProdottoDTO() {}
|
||||
public ArticoloProdottoDTO(String codMart, String partitaMag, BigDecimal quantita, DtbOrdt ordine) {
|
||||
this.codMart = codMart;
|
||||
this.partitaMag = partitaMag;
|
||||
this.quantita = quantita;
|
||||
@@ -41,7 +40,7 @@ public class ProduzioneOrdineDTO {
|
||||
}
|
||||
|
||||
|
||||
public ProduzioneOrdineDTO setCodMart(String codMart) {
|
||||
public ArticoloProdottoDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
@@ -50,7 +49,7 @@ public class ProduzioneOrdineDTO {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public ProduzioneOrdineDTO setPartitaMag(String partitaMag) {
|
||||
public ArticoloProdottoDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
@@ -59,7 +58,7 @@ public class ProduzioneOrdineDTO {
|
||||
return dataProd;
|
||||
}
|
||||
|
||||
public ProduzioneOrdineDTO setDataProd(LocalDate dataProd) {
|
||||
public ArticoloProdottoDTO setDataProd(LocalDate dataProd) {
|
||||
this.dataProd = dataProd;
|
||||
return this;
|
||||
}
|
||||
@@ -68,7 +67,7 @@ public class ProduzioneOrdineDTO {
|
||||
return quantita;
|
||||
}
|
||||
|
||||
public ProduzioneOrdineDTO setQuantita(BigDecimal quantita) {
|
||||
public ArticoloProdottoDTO setQuantita(BigDecimal quantita) {
|
||||
this.quantita = quantita;
|
||||
return this;
|
||||
}
|
||||
@@ -77,7 +76,7 @@ public class ProduzioneOrdineDTO {
|
||||
return pesoProduzione;
|
||||
}
|
||||
|
||||
public ProduzioneOrdineDTO setPesoProduzione(BigDecimal pesoProduzione) {
|
||||
public ArticoloProdottoDTO setPesoProduzione(BigDecimal pesoProduzione) {
|
||||
this.pesoProduzione = pesoProduzione;
|
||||
return this;
|
||||
}
|
||||
@@ -86,7 +85,7 @@ public class ProduzioneOrdineDTO {
|
||||
return scarichiProduzione;
|
||||
}
|
||||
|
||||
public ProduzioneOrdineDTO setScarichiProduzione(List<MtbColt> scarichiProduzione) {
|
||||
public ArticoloProdottoDTO setScarichiProduzione(List<MtbColt> scarichiProduzione) {
|
||||
this.scarichiProduzione = scarichiProduzione;
|
||||
return this;
|
||||
}
|
||||
@@ -95,7 +94,7 @@ public class ProduzioneOrdineDTO {
|
||||
return ordine;
|
||||
}
|
||||
|
||||
public ProduzioneOrdineDTO setOrdine(DtbOrdt ordine) {
|
||||
public ArticoloProdottoDTO setOrdine(DtbOrdt ordine) {
|
||||
this.ordine = ordine;
|
||||
return this;
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package it.integry.ems.document.dto;
|
||||
import it.integry.ems_model.entity.DtbOrdt;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -35,7 +34,7 @@ public class ChiusuraLavorazioneDTO {
|
||||
private boolean terminaLavorazioneLinea = false;
|
||||
private boolean salvaDocumenti = true;
|
||||
|
||||
private List<ProduzioneOrdineDTO> produzioniOrdine = new ArrayList<>();
|
||||
private List<ArticoloProdottoDTO> produzioniOrdine = new ArrayList<>();
|
||||
|
||||
public DtbOrdt getOrdine() {
|
||||
return ordine;
|
||||
@@ -200,11 +199,11 @@ public class ChiusuraLavorazioneDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ProduzioneOrdineDTO> getProduzioniOrdine() {
|
||||
public List<ArticoloProdottoDTO> getProduzioniOrdine() {
|
||||
return produzioniOrdine;
|
||||
}
|
||||
|
||||
public ChiusuraLavorazioneDTO setProduzioniOrdine(List<ProduzioneOrdineDTO> produzioniOrdine) {
|
||||
public ChiusuraLavorazioneDTO setProduzioniOrdine(List<ArticoloProdottoDTO> produzioniOrdine) {
|
||||
this.produzioniOrdine = produzioniOrdine;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package it.integry.ems.document.dto;
|
||||
|
||||
import it.integry.ems.logistic.dto.sm2.FiltroDistribuzioneColloDTO;
|
||||
import it.integry.ems_model.entity.DtbOrdt;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,6 +18,9 @@ public class CreateULFromDocumentsDTO {
|
||||
|
||||
private List<ULRowDTO> ulRows;
|
||||
|
||||
private List<DtbOrdt> ordini;
|
||||
private FiltroDistribuzioneColloDTO.CriterioDistribuzioneEnum criterioDistribuzione = FiltroDistribuzioneColloDTO.CriterioDistribuzioneEnum.U;
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
@@ -86,4 +92,22 @@ public class CreateULFromDocumentsDTO {
|
||||
this.segnoDoc = segnoDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<DtbOrdt> getOrdini() {
|
||||
return ordini;
|
||||
}
|
||||
|
||||
public CreateULFromDocumentsDTO setOrdini(List<DtbOrdt> ordini) {
|
||||
this.ordini = ordini;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FiltroDistribuzioneColloDTO.CriterioDistribuzioneEnum getCriterioDistribuzione() {
|
||||
return criterioDistribuzione;
|
||||
}
|
||||
|
||||
public CreateULFromDocumentsDTO setCriterioDistribuzione(FiltroDistribuzioneColloDTO.CriterioDistribuzioneEnum criterioDistribuzione) {
|
||||
this.criterioDistribuzione = criterioDistribuzione;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import it.integry.ems_model.entity.MtbColr;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public class ScarichiArticoloDTO {
|
||||
public class ScarichiMateriaPrimaDTO {
|
||||
private String codMart;
|
||||
private BigDecimal qtaScaricata;
|
||||
private List<MtbColr> scarichi;
|
||||
@@ -14,7 +14,7 @@ public class ScarichiArticoloDTO {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public ScarichiArticoloDTO setCodMart(String codMart) {
|
||||
public ScarichiMateriaPrimaDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class ScarichiArticoloDTO {
|
||||
return qtaScaricata;
|
||||
}
|
||||
|
||||
public ScarichiArticoloDTO setQtaScaricata(BigDecimal qtaScaricata) {
|
||||
public ScarichiMateriaPrimaDTO setQtaScaricata(BigDecimal qtaScaricata) {
|
||||
this.qtaScaricata = qtaScaricata;
|
||||
return this;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class ScarichiArticoloDTO {
|
||||
return scarichi;
|
||||
}
|
||||
|
||||
public ScarichiArticoloDTO setScarichi(List<MtbColr> scarichi) {
|
||||
public ScarichiMateriaPrimaDTO setScarichi(List<MtbColr> scarichi) {
|
||||
this.scarichi = scarichi;
|
||||
return this;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.document.dto;
|
||||
|
||||
import it.integry.ems.dto.ArticoloPartitaDTO;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class DocumentiMilkonExportService {
|
||||
documentPs.close();
|
||||
|
||||
MultiDBTransactionManager mdb = new MultiDBTransactionManager();
|
||||
mdb.setPrimaryDs(profileDb);
|
||||
mdb.setPrimaryDB(profileDb);
|
||||
Connection targetConnection = mdb.getPrimaryConnection();
|
||||
|
||||
DtbDoct exportedDocument = null;
|
||||
|
||||
@@ -517,6 +517,7 @@ public class DigitalInvoiceBodyFactory {
|
||||
" dtb_doct.num_doc = " + UtilityDB.valueToString(bodyFattura.getNumeroDocumento());
|
||||
String termCons = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (!UtilityString.isNullOrEmpty(termCons)) {
|
||||
termCons = termCons.replaceAll("\n", " ").replaceAll("\r", "");
|
||||
datiGeneraliDocumento.getCausale().add(termCons);
|
||||
}
|
||||
}
|
||||
@@ -544,6 +545,7 @@ public class DigitalInvoiceBodyFactory {
|
||||
sql = "SELECT note FROM gtb_anag_note WHERE flag_stampa_doc ='S' and cod_anag = " + UtilityDB.valueToString(request.getCodAnag()) + " ORDER BY riga_note";
|
||||
List<String> notes = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
for (String note : notes) {
|
||||
note = note.replaceAll("\n", " ").replaceAll("\r", "");
|
||||
datiGeneraliDocumento.getCausale().add(note);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2885,7 +2885,7 @@ public class DocumentProdService {
|
||||
//<editor-fold desc="Genera scarico materiali: se c'è stato uno scarico da collo di versamento allora scarica solo
|
||||
// eventuali materiali restanti Se la data del documento non viene passata da fuori allora vuole dire che la generazione
|
||||
// dei carichi/scarichi deve essere fatta utilizzando la data dei colli di versamento o carico">
|
||||
for (ProduzioneOrdineDTO produzione : dto.getProduzioniOrdine()) {
|
||||
for (ArticoloProdottoDTO produzione : dto.getProduzioniOrdine()) {
|
||||
List<DtbDoct> scarichi = generaDocumentiScaricoMateriali(dto, produzione);
|
||||
if (dto.isSalvaDocumenti()) {
|
||||
entityProcessor.processEntityList(scarichi, multiDBTransactionManager, true);
|
||||
@@ -2904,14 +2904,13 @@ public class DocumentProdService {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ordine ordine da controllare
|
||||
* @param separaPerData separa le produzioni per data collo
|
||||
* @return Recupera tutte le produzioni senza documento dell'ordine suddivise per articolo, partita e (se necessario) data di produzione
|
||||
* @throws Exception
|
||||
*/
|
||||
private List<ProduzioneOrdineDTO> getProduzioniOrdine(DtbOrdt ordine, boolean separaPerData) throws Exception {
|
||||
List<ProduzioneOrdineDTO> produzioni = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||
private List<ArticoloProdottoDTO> getProduzioniOrdine(DtbOrdt ordine, boolean separaPerData) throws Exception {
|
||||
List<ArticoloProdottoDTO> produzioni = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||
it.integry.ems_model.utility.Query.format("SELECT mtb_colr.cod_mart, mtb_colr.partita_mag," + (separaPerData ? "mtb_colr.data_collo as data_prod," : "") + "SUM(mtb_colr.qta_col) as quantita\n" +
|
||||
"from mtb_colr\n" +
|
||||
" inner join mtb_colt on mtb_colr.gestione = mtb_colt.gestione and mtb_colr.data_collo = mtb_colt.data_collo and\n" +
|
||||
@@ -2924,18 +2923,16 @@ public class DocumentProdService {
|
||||
"and dtb_ordt.data_ord = {}\n" +
|
||||
"and dtb_ordt.num_ord = {}\n" +
|
||||
"group by mtb_colr.cod_mart, mtb_colr.partita_mag" + (separaPerData ? ",mtb_colr.data_collo" : ""), ordine.getDataOrd(), ordine.getNumOrd()),
|
||||
ProduzioneOrdineDTO.class);
|
||||
ArticoloProdottoDTO.class);
|
||||
if (UtilityList.isNullOrEmpty(produzioni)) {
|
||||
return produzioni;
|
||||
}
|
||||
|
||||
BigDecimal qtaProdotta = produzioni.stream().map(ProduzioneOrdineDTO::getQuantita).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
produzioni.forEach(x ->
|
||||
{
|
||||
BigDecimal qtaProdotta = produzioni.stream().map(ArticoloProdottoDTO::getQuantita).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
produzioni.forEach(x -> {
|
||||
x.setPesoProduzione(BigDecimal.valueOf(100).multiply(x.getQuantita()).divide(qtaProdotta, 3, RoundingMode.HALF_EVEN));
|
||||
x.setOrdine(ordine);
|
||||
}
|
||||
);
|
||||
});
|
||||
return produzioni;
|
||||
}
|
||||
|
||||
@@ -3158,7 +3155,7 @@ public class DocumentProdService {
|
||||
|
||||
if (UtilityList.isNullOrEmpty(chiusuraLavorazioneDTO.getProduzioniOrdine())) {
|
||||
//se la lista delle produzioni è vuota (non ci sono colli di produzione agganciati ne aggiungo uno preso dall'ordine )
|
||||
chiusuraLavorazioneDTO.setProduzioniOrdine(Collections.singletonList(new ProduzioneOrdineDTO(ordine.getCodProd(), ordine.getPartitaMag(), chiusuraLavorazioneDTO.getScaricoLavorazioneDTO().getQtaProd(), ordine)));
|
||||
chiusuraLavorazioneDTO.setProduzioniOrdine(Collections.singletonList(new ArticoloProdottoDTO(ordine.getCodProd(), ordine.getPartitaMag(), chiusuraLavorazioneDTO.getScaricoLavorazioneDTO().getQtaProd(), ordine)));
|
||||
chiusuraLavorazioneDTO.setOrdine(ordine);
|
||||
}
|
||||
//</editor-fold>
|
||||
@@ -3168,7 +3165,8 @@ public class DocumentProdService {
|
||||
"SELECT DISTINCT mtb_colt.gestione, " +
|
||||
" mtb_colt.data_collo, " +
|
||||
" mtb_colt.ser_collo, " +
|
||||
" mtb_colt.num_collo " +
|
||||
" mtb_colt.num_collo, " +
|
||||
" mtb_colt.segno " +
|
||||
" FROM mtb_colt, " +
|
||||
" mtb_colr " +
|
||||
" WHERE mtb_colr.gestione = " + UtilityDB.valueToString(ordine.getGestione()) + " AND " +
|
||||
@@ -3184,9 +3182,10 @@ public class DocumentProdService {
|
||||
|
||||
sql = UtilityDB.addwhereCond(sql, condFase, false);
|
||||
List<MtbColt> scarichi = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
List<ProduzioneOrdineDTO> produzioni = wmsLavorazioneService.riproporzionaScarichiLavorazione(chiusuraLavorazioneDTO.getProduzioniOrdine(), scarichi);
|
||||
List<ArticoloProdottoDTO> articoloProdotto = chiusuraLavorazioneDTO.getProduzioniOrdine();
|
||||
wmsLavorazioneService.riproporzionaScarichiLavorazione(articoloProdotto, scarichi);
|
||||
//</editor-fold>
|
||||
for (ProduzioneOrdineDTO produzione : produzioni) {
|
||||
for (ArticoloProdottoDTO produzione : articoloProdotto) {
|
||||
if (UtilityList.isNullOrEmpty(produzione.getScarichiProduzione()))
|
||||
continue;
|
||||
Date dataDoc = UtilityDate.isNull(UtilityLocalDate.localDateToDate(produzione.getDataProd()), chiusuraLavorazioneDTO.getDataDoc());
|
||||
@@ -3283,14 +3282,14 @@ public class DocumentProdService {
|
||||
return docsList;
|
||||
}
|
||||
|
||||
private List<DtbDoct> generaDocumentiScaricoMateriali(@NotNull ChiusuraLavorazioneDTO chiusuraLavorazioneDTO, ProduzioneOrdineDTO produzioneOrdine) throws Exception {
|
||||
private List<DtbDoct> generaDocumentiScaricoMateriali(@NotNull ChiusuraLavorazioneDTO chiusuraLavorazioneDTO, ArticoloProdottoDTO produzioneOrdine) throws Exception {
|
||||
List<DtbDoct> docsList = new ArrayList<>();
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
boolean scaricoUnico = "S".equalsIgnoreCase(setupGest.getSetup(conn, "CARICO_SCARICO_PF", "SETUP", "SCARICO_UNICO"));
|
||||
DtbOrdt ordine = chiusuraLavorazioneDTO.getOrdine();
|
||||
ScaricoLavorazioneDTO datiScarico = chiusuraLavorazioneDTO.getScaricoLavorazioneDTO();
|
||||
|
||||
// Acquisizione dati prodotto finito per riproporzionare i materiali
|
||||
//<editor-fold desc="Acquisizione dati prodotto finito per riproporzionare i materiali">
|
||||
String sql =
|
||||
" SELECT DISTINCT ordL.cod_prod, " +
|
||||
" ordL.unt_mis_prod, " +
|
||||
@@ -3321,10 +3320,12 @@ public class DocumentProdService {
|
||||
if (dettaglioScaricoDTO == null) {
|
||||
throw new Exception("L'ordine di lavorazione n." + UtilityDB.valueToString(ordine.getNumOrd()) + " del " + UtilityDB.valueToString(ordine.getDataOrd()) + " e/o la distinta corrispondente presentano delle anomalie.");
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
// Acquisizione dati prodotto dall'esterno
|
||||
//<editor-fold desc="Acquisizione dati prodotto dall'esterno">
|
||||
BigDecimal qtaProdUMMag = produzioneOrdine.getQuantita();
|
||||
BigDecimal qtaProd = qtaProdUMMag.divide(ordine.getRapConvProd(), 5, RoundingMode.HALF_UP);
|
||||
//</editor-fold>
|
||||
|
||||
|
||||
// Verifica esistenza partita magazzino
|
||||
@@ -4383,7 +4384,7 @@ public class DocumentProdService {
|
||||
DtbDoct docLav = new DtbDoct();
|
||||
docLav
|
||||
.setCodDtip(mtbColt.getCodDtip())
|
||||
.setDataDoc(mtbColt.getDataDoc())
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(mtbColt.getDataDoc()))
|
||||
.setNumDoc(mtbColt.getNumDoc())
|
||||
.setSerDoc(mtbColt.getSerDoc())
|
||||
.setCodAnag(mtbColt.getCodAnag())
|
||||
@@ -4394,11 +4395,16 @@ public class DocumentProdService {
|
||||
DtbDocr rows = new DtbDocr();
|
||||
rows.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(), docLav);
|
||||
mtbColt.setCodDtip(EmsRestConstants.NULL)
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||
.setDataDoc(EmsRestConstants.LOCAL_DATE_NULL)
|
||||
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL);
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
entityProcessor.processEntity(mtbColt, true, multiDBTransactionManager);
|
||||
mtbColt.setCodDtip(null)
|
||||
.setDataDoc(null)
|
||||
.setNumDoc(null)
|
||||
.setSerDoc(null);
|
||||
|
||||
return docLav;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package it.integry.ems.document.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.document.dto.ArticoloPartitaDTO;
|
||||
import it.integry.ems.document.dto.CreateULFromDocumentsDTO;
|
||||
import it.integry.ems.document.dto.ULRowDTO;
|
||||
import it.integry.ems.document.dto.UlVenditaDTO;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.accettazione.service.WMSAccettazioneService;
|
||||
import it.integry.ems.retail.wms.dto.*;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.RetrieveArtsInGiacenzaByArtRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SpostaUlRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGenericService;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
||||
import it.integry.ems.retail.wms.lavorazione.service.WMSLavorazioneService;
|
||||
import it.integry.ems.retail.wms.vendita.service.WMSSpedizioneService;
|
||||
import it.integry.ems.rules.businessLogic.enums.TipoEmissione;
|
||||
import it.integry.ems.rules.completing.ConfigActivityRules;
|
||||
@@ -19,13 +21,14 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity.key.MtbColtKey;
|
||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -42,30 +45,43 @@ import static java.util.stream.Collectors.groupingBy;
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class DocumentiDirettiService {
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
@Autowired
|
||||
private DocumentService documentService;
|
||||
|
||||
@Autowired
|
||||
private WMSAccettazioneService wmsAccettazioneService;
|
||||
|
||||
@Autowired
|
||||
private WMSSpedizioneService wmsSpedizioneService;
|
||||
|
||||
@Autowired
|
||||
private WMSLavorazioneService wmsLavorazioneService;
|
||||
|
||||
@Autowired
|
||||
private WMSGiacenzaULService wmsGiacenzaULService;
|
||||
|
||||
@Autowired
|
||||
private WMSGenericService wmsGenericService;
|
||||
|
||||
public List<EntityBase> save(DtbDoct dtbDoct, boolean isInsert) throws Exception {
|
||||
List<EntityBase> entityList = new ArrayList<>();
|
||||
if (!isInsert) {
|
||||
dtbDoct.setOperation(OperationType.DELETE_THEN_INSERT);
|
||||
dtbDoct.getDtbDocr().stream().forEach(dtbDoc -> {
|
||||
dtbDoc.setIdRiga(null);
|
||||
});
|
||||
dtbDoct.getDtbDocr().forEach(dtbDoc ->
|
||||
dtbDoc.setIdRiga(null));
|
||||
}
|
||||
entityList.add(dtbDoct);
|
||||
|
||||
@@ -86,6 +102,8 @@ public class DocumentiDirettiService {
|
||||
checkUDSForTransfer(dtbDoct, entityList, isInsert);
|
||||
}
|
||||
|
||||
//TODO: Aggiungere versamento in nuova UDC per pedane mezze
|
||||
|
||||
if (UtilityString.equalsIgnoreCase((String) datiTipoDoc.get("gestione"), "A")) {
|
||||
if (!isInsert && dtbDoct.getOldPk() != null) {
|
||||
HashMap<String, Object> oldPkDoc = getOldPkDoc(dtbDoct);
|
||||
@@ -135,176 +153,406 @@ public class DocumentiDirettiService {
|
||||
|
||||
}
|
||||
|
||||
private DtbDoct checkUDSForTransfer(DtbDoct dtbDoct, List<EntityBase> entityList, boolean isNewDoc) throws Exception {
|
||||
private List<MtbColt> checkUDSForTransfer(DtbDoct dtbDoct, List<EntityBase> entityList, boolean isNewDoc) throws Exception {
|
||||
if (dtbDoct.getMtbColt().isEmpty() && isNewDoc)
|
||||
return null;
|
||||
String codDtipTrasf = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "LOGISTICA", "COD_DTIP_DOC_TRASF_INTERNI", dtbDoct.getCodMdep());
|
||||
if (UtilityString.isNullOrEmpty(codDtipTrasf))
|
||||
return null;
|
||||
//<editor-fold desc="Prendo tutti i colli, con le quantità associate che devono essere trasferite">
|
||||
String whereCondColli = StringUtils.join(dtbDoct.getMtbColt().stream().filter(x -> x.getOperation() == null || !x.getOperation().equals(OperationType.DELETE)).map(ul -> {
|
||||
try {
|
||||
return String.format("(%s)", ul.getPkWhereCond());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(dtbDoct.getMtbColt())) return null;
|
||||
|
||||
List<MtbColt> ulsToAddToTransfer = dtbDoct.getMtbColt().stream()
|
||||
.filter(x -> (x.getOperation() == null || x.getOperation() != OperationType.DELETE))
|
||||
.map(x -> (MtbColt) x.clone())
|
||||
.peek(x -> x.setOperation(OperationType.SELECT_OBJECT))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(ulsToAddToTransfer)) {
|
||||
String selectMtbColrs = "SELECT * FROM " + MtbColr.ENTITY + " " +
|
||||
"WHERE " + UtilityQuery.concatFieldListInWhereCond(ulsToAddToTransfer.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("gestione", x.getGestione());
|
||||
put("ser_collo", x.getSerCollo());
|
||||
put("data_collo", x.getDataCollo());
|
||||
put("num_collo", x.getNumCollo());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
final List<MtbColr> mtbColrsToTransfer = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), selectMtbColrs, MtbColr.class);
|
||||
|
||||
ulsToAddToTransfer.forEach(mtbColt -> {
|
||||
mtbColt.setMtbColr(mtbColrsToTransfer.stream()
|
||||
.filter(mtbColr -> mtbColt.getKey().equals(mtbColr.getKey()))
|
||||
.collect(Collectors.toList()));
|
||||
});
|
||||
addUlIntoTransfer(multiDBTransactionManager, ulsToAddToTransfer, dtbDoct.getCodMdep());
|
||||
}
|
||||
}).collect(Collectors.toList()), " OR ");
|
||||
List<UlVenditaDTO> artsToTransfer;
|
||||
if (UtilityString.isNullOrEmpty(whereCondColli)) {
|
||||
artsToTransfer = new ArrayList<>();
|
||||
|
||||
|
||||
List<MtbColt> ulsToEditTransfer = dtbDoct.getMtbColt().stream()
|
||||
.filter(x -> x.getOperation() == OperationType.DELETE || x.getMtbColr().stream().anyMatch(y -> y.getOperation() == OperationType.UPDATE))
|
||||
.map(x -> (MtbColt) x.clone())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(ulsToEditTransfer)) {
|
||||
removeOrUpdateUlFromTransfer(multiDBTransactionManager, ulsToEditTransfer, dtbDoct.getCodMdep());
|
||||
}
|
||||
|
||||
// throw new RuntimeException("TEST");
|
||||
return dtbDoct.getMtbColt();
|
||||
}
|
||||
|
||||
private void addUlIntoTransfer(MultiDBTransactionManager multiDBTransactionManager, List<MtbColt> ulsToTransfer, String documentCodMdep) throws Exception {
|
||||
|
||||
List<MtbColr> mtbColrsToTransfer = ulsToTransfer.stream()
|
||||
.flatMap(x -> x.getMtbColr().stream())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
List<String> depositiPartenza = mtbColrsToTransfer.stream()
|
||||
.map(MtbColr::getCodMdepOut)
|
||||
.filter(x -> !x.equalsIgnoreCase(documentCodMdep))
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (String codMdepPartenza : depositiPartenza) {
|
||||
|
||||
List<MtbColr> mtbColrsGroupedByDepoToTransfer = mtbColrsToTransfer.stream()
|
||||
.filter(x -> x.getCodMdepOut().equals(codMdepPartenza))
|
||||
.map(x -> (MtbColr) x.clone())
|
||||
.peek(x -> x.setNumCollo(null)
|
||||
.setDataCollo(null)
|
||||
.setSerCollo(null)
|
||||
.setGestione(null)
|
||||
.setRiga(null)
|
||||
.setBarcodeUlIn(x.getBarcodeUlOut())
|
||||
.setPosizioneIn(null)
|
||||
.setCodMdepIn(documentCodMdep)
|
||||
.setGestioneRif(null)
|
||||
.setDataColloRif(null)
|
||||
.setNumColloRif(null)
|
||||
.setSerColloRif(null)
|
||||
.setNumOrd(null)
|
||||
.setDataOrd(null)
|
||||
.setRigaOrd(null)
|
||||
.setOperation(OperationType.INSERT))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
String codMdepArrivo = documentCodMdep;
|
||||
String codDtipToUse = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "LOGISTICA", "COD_DTIP_DOC_TRASF_INTERNI", codMdepArrivo);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codDtipToUse))
|
||||
throw new Exception("La configurazione della setup gest non è completa per gestire gli spostamenti tra depositi");
|
||||
|
||||
String sql = Query.format(
|
||||
"SELECT segno_qta_car - segno_qta_scar FROM dtb_tipi WHERE cod_dtip = %s",
|
||||
codDtipToUse
|
||||
);
|
||||
|
||||
short segno = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
String codMdepDoc;
|
||||
String codAnag;
|
||||
String codVdes;
|
||||
|
||||
if (segno > 0) {
|
||||
codMdepDoc = codMdepArrivo;
|
||||
|
||||
MtbDepo mtbDepoPartenza = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||
Query.format("SELECT * FROM mtb_depo WHERE cod_mdep = {}", codMdepPartenza), MtbDepo.class);
|
||||
|
||||
codAnag = mtbDepoPartenza.getCodAnag();
|
||||
codVdes = mtbDepoPartenza.getCodVdes();
|
||||
|
||||
} else {
|
||||
artsToTransfer = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("WITH uds AS (SELECT *\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" WHERE cod_mdep <> {}\n" +
|
||||
" AND (" + whereCondColli + "))\n" +
|
||||
"\n" +
|
||||
"SELECT mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" mtb_colt.cod_tcol,\n" +
|
||||
" SUM(qta_col) AS qta_col,\n" +
|
||||
" SUM(num_cnf) AS num_cnf\n" +
|
||||
"FROM uds mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr ON mtb_colt.gestione = mtb_colr.gestione AND mtb_colt.data_collo = mtb_colr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
"GROUP BY mtb_colt.data_collo, mtb_colt.ser_collo, mtb_colt.gestione, mtb_colt.num_collo, cod_mdep, partita_mag,cod_mart, mtb_colt.cod_tcol\n", dtbDoct.getCodMdep(), whereCondColli)
|
||||
, UlVenditaDTO.class);
|
||||
if (artsToTransfer == null) artsToTransfer = new ArrayList<>();
|
||||
codMdepDoc = codMdepPartenza;
|
||||
|
||||
MtbDepo mtbDepoArrivo = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||
Query.format("SELECT * FROM mtb_depo WHERE cod_mdep = {}", codMdepArrivo), MtbDepo.class);
|
||||
|
||||
codAnag = mtbDepoArrivo.getCodAnag();
|
||||
codVdes = mtbDepoArrivo.getCodVdes();
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="raccolgo le info basi del nuovo documento">
|
||||
MtbDepo mtbDepo = new MtbDepo();
|
||||
mtbDepo.setCodMdep(dtbDoct.getCodMdep())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(mtbDepo, multiDBTransactionManager);
|
||||
final String gestName = "DTB_DOCT";
|
||||
final String sectionVendita = "VENDITA";
|
||||
final String keySectionTipoAttivita = "TIPO_ATTIVITA";
|
||||
String activityTypeId = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), gestName, sectionVendita, keySectionTipoAttivita);
|
||||
if (UtilityString.isNullOrEmpty(activityTypeId))
|
||||
throw new Exception(String.format("Tipo attività non configurato %s -> %s -> %s", gestName, sectionVendita, keySectionTipoAttivita));
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="controllo se esiste già una attività con la quale raggruppare i documenti generati">
|
||||
String activityId = dtbDoct.getActivityId();
|
||||
if (!isNewDoc) {
|
||||
if (UtilityString.isNullOrEmpty(activityId)) {
|
||||
String sql = Query.format("SELECT activity_id FROM dtb_doct WHERE cod_anag = %s AND cod_dtip = %s AND data_doc = %s AND ser_doc = %s AND num_doc = %s",
|
||||
dtbDoct.getCodAnag(),
|
||||
dtbDoct.getCodDtip(),
|
||||
dtbDoct.getDataDoc(),
|
||||
dtbDoct.getSerDoc(),
|
||||
dtbDoct.getNumDoc());
|
||||
activityId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(activityId)) {
|
||||
StbActivity activity = createStbActivity(activityTypeId);
|
||||
entityList.add(0, activity);
|
||||
activityId = activity.getActivityId();
|
||||
dtbDoct.setActivityId(activityId);
|
||||
}
|
||||
//</editor-fold>
|
||||
MtbColt internalMovement = WMSUtility.createInternalMovement(multiDBTransactionManager.getPrimaryConnection(), codMdepDoc, requestDataDTO.getUsername());
|
||||
internalMovement.setCodAnag(codAnag);
|
||||
internalMovement.setCodVdes(codVdes);
|
||||
internalMovement.setBarcodeUl(EmsRestConstants.NULL);
|
||||
internalMovement.setMtbColr(mtbColrsGroupedByDepoToTransfer);
|
||||
|
||||
List<DtbDoct> docTrasfList = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("SELECT cod_anag,data_doc,ser_doc,num_doc,cod_dtip,cod_mdep from dtb_doct where activity_id = {} and cod_dtip = {} ", activityId, codDtipTrasf), DtbDoct.class);
|
||||
if (docTrasfList == null) docTrasfList = new ArrayList<>();
|
||||
docTrasfList = docTrasfList.stream().peek(x -> x.setOperation(OperationType.DELETE)).collect(Collectors.toList());
|
||||
entityProcessor.processEntity(internalMovement, true, multiDBTransactionManager);
|
||||
|
||||
List<String> depositiPartenza = artsToTransfer.stream().map(UlVenditaDTO::getCodMdep).distinct().collect(Collectors.toList());
|
||||
for (String codMdep : depositiPartenza) {
|
||||
//<editor-fold desc="Controllo se esiste già un documento di trasferimento">
|
||||
DtbDoct docTrasf = null;
|
||||
|
||||
if (!isNewDoc) {
|
||||
docTrasf = docTrasfList.stream().filter(x -> x.getCodMdep().equals(codMdep)).findFirst().orElse(null);
|
||||
if (docTrasf != null) {
|
||||
docTrasf.setOperation(OperationType.UPDATE);
|
||||
List<DtbDocr> oldDocRows = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), "SELECT * from dtb_docr where " + docTrasf.getPkWhereCond(), DtbDocr.class);
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(oldDocRows)) {
|
||||
docTrasf.getDtbDocr().addAll(oldDocRows.stream().peek(row -> row.setQtaDoc(BigDecimal.ZERO).setOperation(OperationType.UPDATE)).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (docTrasf == null) {
|
||||
docTrasf = new DtbDoct();
|
||||
docTrasf
|
||||
.setCodMdep(codMdep)
|
||||
.setCodVdes(mtbDepo.getCodVdes())
|
||||
.setCodAnag(mtbDepo.getCodAnag())
|
||||
.setCodDtip(codDtipTrasf)
|
||||
.setActivityId(activityId);
|
||||
docTrasf.setOperation(OperationType.INSERT);
|
||||
docTrasfList.add(docTrasf);
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Raggruppo le quantità da trasferire per deposito/articolo/partita">
|
||||
Map<ArticoloPartitaDTO, List<UlVenditaDTO>> ulToTransf = artsToTransfer.stream()
|
||||
.filter(ul -> ul.getCodMdep().equalsIgnoreCase(codMdep))
|
||||
.collect(groupingBy(UlVenditaDTO::getArticoloPartita));
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="per ogni coppia di articolo / partita sommo le quantità e aggiungo al documento">
|
||||
|
||||
for (ArticoloPartitaDTO articoloPartitaDTO : ulToTransf.keySet()) {
|
||||
DtbDocr row = docTrasf.getDtbDocr().stream().filter(docR -> docR.getCodMart().equalsIgnoreCase(articoloPartitaDTO.getCodMart()) && docR.getPartitaMag().equalsIgnoreCase(articoloPartitaDTO.getPartitaMag())).findFirst().orElse(null);
|
||||
if (row == null) {
|
||||
row = new DtbDocr();
|
||||
row.setCodMart(articoloPartitaDTO.getCodMart())
|
||||
.setPartitaMag(articoloPartitaDTO.getPartitaMag())
|
||||
.setQtaDoc(BigDecimal.ZERO)
|
||||
.setNumCnf(BigDecimal.ZERO)
|
||||
.setOperation(OperationType.INSERT);
|
||||
docTrasf.getDtbDocr().add(row);
|
||||
}
|
||||
|
||||
row
|
||||
.setQtaDoc(ulToTransf.get(articoloPartitaDTO).stream().map(UlVenditaDTO::getQtaCol).reduce(BigDecimal.ZERO, BigDecimal::add))
|
||||
.setNumCnf(ulToTransf.get(articoloPartitaDTO).stream().map(UlVenditaDTO::getNumCnf).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
|
||||
//<editor-fold desc="Aggiungo pedane da trasferire al documento">
|
||||
Map<String, List<UlVenditaDTO>> ulForCodTcol = artsToTransfer.stream().filter(x -> !UtilityString.isNullOrEmpty(x.getCodTcol())).collect(groupingBy(UlVenditaDTO::getCodTcol));
|
||||
for (String codTcol : ulForCodTcol.keySet()) {
|
||||
MtbAart mtbAart = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("SELECT * from mtb_tcol where cod_tcol = {}", codTcol), MtbAart.class);
|
||||
if (mtbAart == null || UtilityString.isNullOrEmpty(mtbAart.getCodMart()))
|
||||
continue;
|
||||
DtbDocr row = docTrasf.getDtbDocr().stream().filter(docR -> docR.getCodMart().equalsIgnoreCase(mtbAart.getCodMart())).findFirst().orElse(null);
|
||||
if (row == null) {
|
||||
row = new DtbDocr();
|
||||
row.setCodMart(mtbAart.getCodMart())
|
||||
.setQtaDoc(BigDecimal.ZERO)
|
||||
.setQtaCnf(mtbAart.getQtaCnf())
|
||||
.setOperation(OperationType.INSERT);
|
||||
docTrasf.getDtbDocr().add(row);
|
||||
}
|
||||
row.setQtaDoc(BigDecimal.valueOf(ulForCodTcol.get(codTcol).size()));
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
DtbDoct transferDocument =
|
||||
WMSUtility.createTransferDocumentAndAttachToMovement(multiDBTransactionManager, setupGest,
|
||||
internalMovement, null, documentCodMdep, null,
|
||||
requestDataDTO.getUsername(), false, SpostaUlRequestDTO.TransferGroupPolicy.NONE);
|
||||
|
||||
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Se qualche riga del documento resta con qta = 0 vuol dire che è una coppia di articolo/partita non più necessaria e se le righe sono tutte a 0 elimino il documento">
|
||||
for (DtbDocr docR : docTrasf.getDtbDocr()) {
|
||||
if (UtilityBigDecimal.equalsTo(docR.getQtaDoc(), BigDecimal.ZERO))
|
||||
docR.setOperation(OperationType.DELETE);
|
||||
}
|
||||
if (docTrasf.getDtbDocr().stream().allMatch(row -> row.getOperation().equals(OperationType.DELETE)))
|
||||
docTrasf.setOperation(OperationType.DELETE);
|
||||
//</editor-fold>
|
||||
entityProcessor.processEntity(transferDocument, true, multiDBTransactionManager);
|
||||
|
||||
mtbColrsToTransfer.stream()
|
||||
.filter(x -> x.getCodMdepOut().equals(codMdepPartenza))
|
||||
.forEach(x -> {
|
||||
x.setOperation(OperationType.UPDATE);
|
||||
x
|
||||
.setCodMdepIn(documentCodMdep)
|
||||
.setCodMdepOut(documentCodMdep)
|
||||
.setPosizioneOut(EmsRestConstants.NULL)
|
||||
.setGestioneRif(null)
|
||||
.setDataColloRif(null)
|
||||
.setNumColloRif(null)
|
||||
.setSerColloRif(null);
|
||||
});
|
||||
}
|
||||
entityList.addAll(docTrasfList);
|
||||
|
||||
ulsToTransfer.forEach(x -> x.setOperation(OperationType.UPDATE));
|
||||
entityProcessor.processEntityList(ulsToTransfer, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(ulsToTransfer);
|
||||
}
|
||||
|
||||
private void removeOrUpdateUlFromTransfer(MultiDBTransactionManager multiDBTransactionManager, List<MtbColt> ulsToRemoveTransfer, String documentCodMdep) throws Exception {
|
||||
//Carico i dati delle testate dei colli da eliminare o aggiornare
|
||||
|
||||
for (MtbColt ul : ulsToRemoveTransfer) {
|
||||
final OperationType originalOperation = ul.getOperation();
|
||||
|
||||
ul.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(ul, true, multiDBTransactionManager);
|
||||
ul.setOperation(originalOperation);
|
||||
|
||||
|
||||
return dtbDoct;
|
||||
ul.getMtbColr().forEach(mtbColr -> {
|
||||
mtbColr.setNumCollo(ul.getNumCollo())
|
||||
.setDataCollo(ul.getDataCollo())
|
||||
.setSerCollo(ul.getSerCollo())
|
||||
.setGestione(ul.getGestione());
|
||||
});
|
||||
}
|
||||
|
||||
entityProcessor.processEntityList(ulsToRemoveTransfer, multiDBTransactionManager, true);
|
||||
|
||||
String selectMtbColrs = "SELECT * FROM " + MtbColr.ENTITY + " " +
|
||||
"WHERE " + UtilityQuery.concatFieldListInWhereCond(ulsToRemoveTransfer.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("gestione", x.getGestione());
|
||||
put("ser_collo", x.getSerCollo());
|
||||
put("data_collo", x.getDataCollo());
|
||||
put("num_collo", x.getNumCollo());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
final List<MtbColr> mtbColrsToTransfer = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), selectMtbColrs, MtbColr.class);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(mtbColrsToTransfer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mtbColrsToTransfer.forEach(mtbColr -> {
|
||||
final MtbColr matchedRow = ulsToRemoveTransfer.stream()
|
||||
.filter(x -> !UtilityList.isNullOrEmpty(x.getMtbColr()))
|
||||
.flatMap(x -> x.getMtbColr().stream())
|
||||
.filter(x -> x.getKey().equals(mtbColr.getKey()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (matchedRow != null)
|
||||
mtbColr.setQtaCol(matchedRow.getQtaCol())
|
||||
.setNumCnf(matchedRow.getNumCnf())
|
||||
.setQtaCnf(matchedRow.getQtaCnf());
|
||||
});
|
||||
|
||||
ulsToRemoveTransfer.forEach(mtbColt -> {
|
||||
mtbColt.setMtbColr(mtbColrsToTransfer.stream()
|
||||
.filter(mtbColr -> mtbColt.getKey().equals(mtbColr.getKey()))
|
||||
.map(x -> (MtbColr) x.clone())
|
||||
.collect(Collectors.toList()));
|
||||
});
|
||||
|
||||
//Cerco i trasferimenti L generati in automatico precedentemente.
|
||||
//Si riconoscono perchè hanno:
|
||||
// - barcode_ul_in = barcode_ul_out
|
||||
// - cod_mdep_in = deposito del documento
|
||||
// - cod_mdep_out <> cod_mdep_in
|
||||
// - datetime_row del collo L = datetime_row del collo V
|
||||
// - cod_mart del collo L = cod_mart del collo V
|
||||
// - partita_mag del collo L = partita_mag del collo V
|
||||
// - cod_jcom del collo L = cod_jcom del collo V
|
||||
// - qta_col del collo L = qta_col del collo V
|
||||
// - num_cnf del collo L = num_cnf del collo V
|
||||
|
||||
String selectTransferMtbColrs = "SELECT * FROM " + MtbColr.ENTITY + " " +
|
||||
"WHERE barcode_ul_in = barcode_ul_out AND " +
|
||||
" cod_mdep_in <> cod_mdep_out AND " +
|
||||
UtilityQuery.concatFieldListInWhereCond(mtbColrsToTransfer.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("gestione", "L");
|
||||
put("barcode_ul_in", x.getBarcodeUlOut());
|
||||
put("cod_mdep_in", documentCodMdep);
|
||||
put("datetime_row", x.getDatetimeRow());
|
||||
put("cod_mart", x.getCodMart());
|
||||
put("partita_mag", x.getPartitaMag());
|
||||
put("cod_jcom", x.getCodJcom());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
final List<MtbColr> transferMtbColrs = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), selectTransferMtbColrs, MtbColr.class);
|
||||
|
||||
if (transferMtbColrs == null) return;
|
||||
|
||||
transferMtbColrs.forEach(transferMtbColr -> {
|
||||
|
||||
MtbColr mtbColrUscita = mtbColrsToTransfer.stream().filter(x -> x.getBarcodeUlOut().equals(transferMtbColr.getBarcodeUlIn()) &&
|
||||
x.getCodMart().equals(transferMtbColr.getCodMart()) &&
|
||||
x.getPartitaMag().equals(transferMtbColr.getPartitaMag()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbColrUscita != null) {
|
||||
transferMtbColr.setQtaCol(mtbColrUscita.getQtaCol())
|
||||
.setNumCnf(mtbColrUscita.getNumCnf())
|
||||
.setOperation(transferMtbColr.getOperation());
|
||||
}
|
||||
|
||||
// transferMtbColr.setOperation(OperationType.DELETE);
|
||||
});
|
||||
|
||||
final List<MtbColt> transferMtbColtToUpdate = transferMtbColrs.stream()
|
||||
.map(x -> new MtbColtKey(x.getGestione(), x.getSerCollo(), x.getDataCollo(), x.getNumCollo()))
|
||||
.distinct()
|
||||
.map(x -> {
|
||||
MtbColt mtbColt = new MtbColt(x);
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
mtbColt.setMtbColr(transferMtbColrs.stream()
|
||||
.filter(y -> x.equals(y.getKey()))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return mtbColt;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
//Carico i documenti di trasferimento da eliminare
|
||||
String sqlSelectDocuments = "SELECT cod_anag, cod_dtip, data_doc, ser_doc, num_doc FROM " + MtbColt.ENTITY + " " +
|
||||
"WHERE " + UtilityQuery.concatFieldListInWhereCond(transferMtbColtToUpdate.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("data_collo", x.getDataCollo());
|
||||
put("ser_collo", x.getSerCollo());
|
||||
put("num_collo", x.getNumCollo());
|
||||
put("gestione", x.getGestione());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
List<DtbDoct> documentsToDelete = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sqlSelectDocuments, DtbDoct.class);
|
||||
|
||||
//Carico i colli da riagganciare al trasferimento (poiché i documenti attuali verranno cancellati)
|
||||
String selectMtbColtsToReAttach = "SELECT * FROM " + MtbColt.ENTITY + " " +
|
||||
"WHERE " + UtilityQuery.concatFieldListInWhereCond(documentsToDelete.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("cod_dtip", x.getCodDtip());
|
||||
put("cod_anag", x.getCodAnag());
|
||||
put("ser_doc", x.getSerDoc());
|
||||
put("num_doc", x.getNumDoc());
|
||||
put("data_doc", x.getDataDoc());
|
||||
}})
|
||||
.collect(Collectors.toList()));
|
||||
List<MtbColt> mtbColtsToReattach = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), selectMtbColtsToReAttach, MtbColt.class);
|
||||
|
||||
if (mtbColtsToReattach == null || mtbColtsToReattach.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Cancello i documenti di trasferimento
|
||||
documentsToDelete.forEach(doc -> {
|
||||
doc.setOperation(OperationType.DELETE);
|
||||
});
|
||||
entityProcessor.processEntityList(documentsToDelete, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(documentsToDelete);
|
||||
mtbColtsToReattach.forEach(x -> x.setDataDoc(null)
|
||||
.setNumDoc(null)
|
||||
.setSerDoc(null)
|
||||
.setCodDtip(null));
|
||||
|
||||
//Aggiorno le righe di trasferimento
|
||||
entityProcessor.processEntityList(transferMtbColtToUpdate, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(transferMtbColtToUpdate);
|
||||
|
||||
//Ricarico i colli da riagganciare al trasferimento (nel caso in cui la cancellazione precedente abbia rimosso alcuni colli)
|
||||
selectMtbColtsToReAttach = "SELECT colt.gestione, colt.ser_collo, colt.num_collo, colt.data_collo, COUNT(colr.riga) AS count_righe " +
|
||||
"FROM " + MtbColt.ENTITY + " colt " +
|
||||
" LEFT OUTER JOIN " + MtbColr.ENTITY + " colr ON" +
|
||||
" colr.data_collo = colt.data_collo AND " +
|
||||
" colr.ser_collo = colt.ser_collo AND " +
|
||||
" colr.num_collo = colt.num_collo AND " +
|
||||
" colr.gestione = colt.gestione " +
|
||||
"WHERE " + UtilityQuery.concatFieldListInWhereCond(mtbColtsToReattach.stream()
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("colt.data_collo", x.getDataCollo());
|
||||
put("colt.ser_collo", x.getSerCollo());
|
||||
put("colt.num_collo", x.getNumCollo());
|
||||
put("colt.gestione", x.getGestione());
|
||||
}})
|
||||
.collect(Collectors.toList())) +
|
||||
" GROUP BY colt.gestione, colt.ser_collo, colt.num_collo, colt.data_collo ";
|
||||
final List<HashMap<String, Object>> definitiveMtbColtsToReattach = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), selectMtbColtsToReAttach);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(definitiveMtbColtsToReattach)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Cancello le testate che hanno 0 righe
|
||||
List<MtbColt> mtbColtResidueToBeDeleted = definitiveMtbColtsToReattach.stream()
|
||||
.filter(x -> UtilityHashMap.<Integer>getValueIfExists(x, "count_righe") == 0)
|
||||
.map(x -> {
|
||||
final MtbColt mtbColt = new MtbColt(
|
||||
UtilityHashMap.getValueIfExists(x, "gestione"),
|
||||
UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(x, "data_collo")),
|
||||
UtilityHashMap.getValueIfExists(x, "num_collo"),
|
||||
UtilityHashMap.getValueIfExists(x, "ser_collo")
|
||||
);
|
||||
mtbColt.setOperation(OperationType.DELETE);
|
||||
return mtbColt;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!mtbColtResidueToBeDeleted.isEmpty()) {
|
||||
entityProcessor.processEntityList(mtbColtResidueToBeDeleted, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(mtbColtResidueToBeDeleted);
|
||||
definitiveMtbColtsToReattach.removeIf(x -> UtilityHashMap.<Integer>getValueIfExists(x, "count_righe") == 0);
|
||||
}
|
||||
|
||||
//Riaggancio i colli residui al trasferimento
|
||||
List<DtbDoct> documentsToSave = new ArrayList<>();
|
||||
for (HashMap<String, Object> mtbColtToReattach : definitiveMtbColtsToReattach) {
|
||||
MtbColt internalMovement = mtbColtsToReattach.stream()
|
||||
.filter(x -> x.getKey().equals(new MtbColtKey(
|
||||
UtilityHashMap.getValueIfExists(mtbColtToReattach, "gestione"),
|
||||
UtilityHashMap.getValueIfExists(mtbColtToReattach, "ser_collo"),
|
||||
UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(mtbColtToReattach, "data_collo")),
|
||||
UtilityHashMap.getValueIfExists(mtbColtToReattach, "num_collo"))))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// internalMovement.setOperation(OperationType.SELECT_OBJECT);
|
||||
// entityProcessor.processEntity(internalMovement, true, multiDBTransactionManager);
|
||||
internalMovement.setOperation(OperationType.UPDATE);
|
||||
|
||||
String mtbColrsToReattach = "SELECT * FROM " + MtbColr.ENTITY + " WHERE " + UtilityQuery.concatFieldsInWhereCond(new HashMap<String, Object>() {{
|
||||
put("gestione", internalMovement.getGestione());
|
||||
put("ser_collo", internalMovement.getSerCollo());
|
||||
put("data_collo", internalMovement.getDataCollo());
|
||||
put("num_collo", internalMovement.getNumCollo());
|
||||
}});
|
||||
internalMovement.setMtbColr(UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), mtbColrsToReattach, MtbColr.class));
|
||||
|
||||
DtbDoct transferDocument =
|
||||
WMSUtility.createTransferDocumentAndAttachToMovement(multiDBTransactionManager, setupGest,
|
||||
internalMovement, null, documentCodMdep, null,
|
||||
requestDataDTO.getUsername(), false, SpostaUlRequestDTO.TransferGroupPolicy.NONE);
|
||||
documentsToSave.add(transferDocument);
|
||||
}
|
||||
entityProcessor.processEntityList(documentsToSave, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(documentsToSave);
|
||||
}
|
||||
|
||||
|
||||
private HashMap<String, Object> getOldPkDoc(DtbDoct dtbDoct) throws IOException {
|
||||
String codAnag = dtbDoct.getCodAnag();
|
||||
String codDtip = dtbDoct.getCodDtip();
|
||||
@@ -585,7 +833,7 @@ public class DocumentiDirettiService {
|
||||
|
||||
}
|
||||
|
||||
private void getDtbDoctImballi(DtbDoct dtbDoct, List<EntityBase> entityList, String codDtipPed, String codAnagPed, String codMdep, String listino, String codMart, int qtaDoc, String descrizioneArticolo, String idAttivita) throws DataConverterNotFoundException, SQLException, InstantiationException, IllegalAccessException, PrimaryDatabaseNotPresentException, IOException {
|
||||
private void getDtbDoctImballi(DtbDoct dtbDoct, List<EntityBase> entityList, String codDtipPed, String codAnagPed, String codMdep, String listino, String codMart, int qtaDoc, String descrizioneArticolo, String idAttivita) throws SQLException, InstantiationException, IllegalAccessException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException {
|
||||
String sql;
|
||||
DtbDoct dtbDoctPed = (DtbDoct) entityList
|
||||
.stream()
|
||||
@@ -684,7 +932,7 @@ public class DocumentiDirettiService {
|
||||
|
||||
public List<MtbColt> createULFromDocument(CreateULFromDocumentsDTO createULFromDocument) throws Exception {
|
||||
boolean isTrasferimento = false;
|
||||
String codMdepTrasf;
|
||||
String codMdepTrasf = "";
|
||||
if (createULFromDocument.getGestione().equalsIgnoreCase("L")) {
|
||||
String sql =
|
||||
Query.format(
|
||||
@@ -697,12 +945,27 @@ public class DocumentiDirettiService {
|
||||
createULFromDocument.getCodAnag(),
|
||||
createULFromDocument.getCodVdes());
|
||||
codMdepTrasf = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (!UtilityString.isNullOrEmpty(codMdepTrasf)) isTrasferimento = true;
|
||||
if (!UtilityString.isNullOrEmpty(codMdepTrasf) && !UtilityString.equalsIgnoreCase(createULFromDocument.getCodMdep(), codMdepTrasf))
|
||||
isTrasferimento = true;
|
||||
}
|
||||
|
||||
if (isTrasferimento) {
|
||||
throw new Exception("Trasferimento non supportato");
|
||||
|
||||
List<String> barcodeUlListToMove = new ArrayList<>();
|
||||
for (ULRowDTO ulRowDTO : createULFromDocument.getUlRows()) {
|
||||
MvwSitArtUdcDetInventarioDTO datiCollo = getDatiCollo(ulRowDTO.getBarcodeUl(), ulRowDTO.getCodMart(), ulRowDTO.getPartitaMag());
|
||||
barcodeUlListToMove.add(ulRowDTO.getBarcodeUl());
|
||||
}
|
||||
if (createULFromDocument.getSegnoDoc() > 0) {
|
||||
codMdepTrasf = createULFromDocument.getCodMdep();
|
||||
}
|
||||
SpostaUlRequestDTO requestDTO = new SpostaUlRequestDTO()
|
||||
.setCodMdep(codMdepTrasf)
|
||||
.setCreateDocAutomatically(false)
|
||||
.setBarcodeUlList(barcodeUlListToMove);
|
||||
MtbColt mtbColt = wmsGenericService.spostaUL(requestDTO);
|
||||
List<MtbColt> colliRet = new ArrayList<>();
|
||||
colliRet.add(mtbColt);
|
||||
return colliRet;
|
||||
} else if (createULFromDocument.getSegnoDoc() > 0) {
|
||||
return createUDCFromDocument(createULFromDocument);
|
||||
} else {
|
||||
@@ -713,6 +976,7 @@ public class DocumentiDirettiService {
|
||||
|
||||
private List<MtbColt> createUDCFromDocument(CreateULFromDocumentsDTO createUDCFromDocuments) throws Exception {
|
||||
List<MtbColt> generatedMtbColt = new ArrayList<>();
|
||||
boolean isLavorazione = createUDCFromDocuments.getGestione().equalsIgnoreCase("L");
|
||||
|
||||
List<ULRowDTO> udcRows = createUDCFromDocuments.getUlRows();
|
||||
Map<String, List<ULRowDTO>> groupedByBarcode = udcRows.stream()
|
||||
@@ -722,7 +986,9 @@ public class DocumentiDirettiService {
|
||||
String barcodeUl = entry.getKey();
|
||||
List<ULRowDTO> groupedRequests = entry.getValue();
|
||||
|
||||
MtbColt udc = wmsAccettazioneService.createUDC(
|
||||
MtbColt udc;
|
||||
if (isLavorazione) {
|
||||
udc = wmsLavorazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodAnag(createUDCFromDocuments.getCodAnag())
|
||||
.setCodMdep(createUDCFromDocuments.getCodMdep())
|
||||
@@ -730,6 +996,16 @@ public class DocumentiDirettiService {
|
||||
.setCodVdes(createUDCFromDocuments.getCodVdes())
|
||||
.setBarcodeUl(barcodeUl)
|
||||
);
|
||||
} else {
|
||||
udc = wmsAccettazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodAnag(createUDCFromDocuments.getCodAnag())
|
||||
.setCodMdep(createUDCFromDocuments.getCodMdep())
|
||||
.setDataCollo(createUDCFromDocuments.getDataCollo())
|
||||
.setCodVdes(createUDCFromDocuments.getCodVdes())
|
||||
.setBarcodeUl(barcodeUl)
|
||||
);
|
||||
}
|
||||
|
||||
udc.getMtbCols().forEach(x -> x.setOperation(OperationType.NO_OP));
|
||||
|
||||
@@ -745,9 +1021,16 @@ public class DocumentiDirettiService {
|
||||
.setRigaOrd(request.getRigaOrd())
|
||||
.setTargetMtbColt(udc)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if (isLavorazione) {
|
||||
CloseUDCLavorazioneRequestDTO closeUDCLavorazioneRequestDTO = new CloseUDCLavorazioneRequestDTO();
|
||||
closeUDCLavorazioneRequestDTO.setMtbColt(udc);
|
||||
wmsLavorazioneService.closeUDC(closeUDCLavorazioneRequestDTO);
|
||||
} else {
|
||||
wmsAccettazioneService.closeUDC(new CloseUDCRequestDTO().setMtbColt(udc));
|
||||
}
|
||||
|
||||
generatedMtbColt.add(udc);
|
||||
}
|
||||
@@ -759,18 +1042,18 @@ public class DocumentiDirettiService {
|
||||
List<MtbColt> generatedMtbColt = new ArrayList<>();
|
||||
MtbColt uds = null;
|
||||
|
||||
boolean isLavorazione = createUDSFromDocuments.getGestione().equalsIgnoreCase("L");
|
||||
|
||||
List<CreateUDSRequestOrderDTO> createUDSRequestOrderDTO = Collections.emptyList();
|
||||
|
||||
if (createUDSFromDocuments.isMonoUl()) {
|
||||
createUDSRequestOrderDTO = createUDSFromDocuments.getUlRows().stream()
|
||||
.filter(x -> x.getNumOrd() != null && x.getDataOrd() != null)
|
||||
.map(
|
||||
x -> {
|
||||
CreateUDSRequestOrderDTO ord = new CreateUDSRequestOrderDTO()
|
||||
x -> new CreateUDSRequestOrderDTO()
|
||||
.setDataOrd(x.getDataOrd())
|
||||
.setNumOrd(x.getNumOrd())
|
||||
.setGestione(createUDSFromDocuments.getGestione());
|
||||
return ord;
|
||||
}
|
||||
.setGestione(createUDSFromDocuments.getGestione())
|
||||
).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
@@ -780,57 +1063,91 @@ public class DocumentiDirettiService {
|
||||
for (Map.Entry<String, List<ULRowDTO>> entry : ulGroup.entrySet()) {
|
||||
String codMdep = entry.getKey();
|
||||
for (ULRowDTO ulRowDTO : entry.getValue()) {
|
||||
if ((createUDSFromDocuments.isMonoUl() && uds == null) || !createUDSFromDocuments.isMonoUl()) {
|
||||
if (!createUDSFromDocuments.isMonoUl()) {
|
||||
CreateUDSRequestOrderDTO ord = new CreateUDSRequestOrderDTO()
|
||||
if (!createUDSFromDocuments.isMonoUl() || uds == null) {
|
||||
if (!UtilityList.isNullOrEmpty(createUDSFromDocuments.getOrdini())) {
|
||||
createUDSRequestOrderDTO = createUDSFromDocuments.getOrdini().stream().map(x -> new CreateUDSRequestOrderDTO()
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(x.getDataOrd()))
|
||||
.setNumOrd(x.getNumOrd())
|
||||
.setGestione(x.getGestione())).collect(Collectors.toList());
|
||||
} else if (!createUDSFromDocuments.isMonoUl()) {
|
||||
createUDSRequestOrderDTO = Collections.singletonList(new CreateUDSRequestOrderDTO()
|
||||
.setDataOrd(ulRowDTO.getDataOrd())
|
||||
.setNumOrd(ulRowDTO.getNumOrd())
|
||||
.setGestione(createUDSFromDocuments.getGestione());
|
||||
createUDSRequestOrderDTO = new ArrayList<>();
|
||||
createUDSRequestOrderDTO.add(ord);
|
||||
.setGestione(createUDSFromDocuments.getGestione()));
|
||||
|
||||
}
|
||||
uds = wmsSpedizioneService.createUDS(
|
||||
|
||||
if (isLavorazione) {
|
||||
uds = wmsLavorazioneService.createUDSMovement(
|
||||
new CreateUDSRequestDTO()
|
||||
.setCodAnag(createUDSFromDocuments.getCodAnag())
|
||||
.setCodMdep(createUDSFromDocuments.getCodMdep())
|
||||
.setCodVdes(createUDSFromDocuments.getCodVdes())
|
||||
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||
.setOrders(createUDSRequestOrderDTO));
|
||||
} else {
|
||||
uds = wmsSpedizioneService.createUDSMovement(
|
||||
new CreateUDSRequestDTO()
|
||||
.setCodAnag(createUDSFromDocuments.getCodAnag())
|
||||
.setCodMdep(codMdep)
|
||||
.setCodVdes(createUDSFromDocuments.getCodVdes())
|
||||
.setOrders(createUDSRequestOrderDTO));
|
||||
}
|
||||
uds.getMtbCols().forEach(x -> x.setOperation(OperationType.NO_OP));
|
||||
}
|
||||
|
||||
List<MvwSitArtUdcDetInventarioDTO> mvwSitArtUdcDetInventarioDTOS = wmsGiacenzaULService.retrieveArtsInGiacenzaByBarcodeUl(multiDBTransactionManager.getPrimaryConnection(), ulRowDTO.getBarcodeUl());
|
||||
List<MvwSitArtUdcDetInventarioDTO> mvwSitArtUdcDetInventarioDTOS =
|
||||
wmsGiacenzaULService.retrieveArtsInGiacenzaByArticolo(multiDBTransactionManager.getPrimaryConnection(), new RetrieveArtsInGiacenzaByArtRequestDTO()
|
||||
.setBarcodeUl(ulRowDTO.getBarcodeUl())
|
||||
.setCodMart(ulRowDTO.getCodMart())
|
||||
.setPartitaMag(ulRowDTO.getPartitaMag()));
|
||||
|
||||
MtbColr sourceMtbColr = null;
|
||||
if (mvwSitArtUdcDetInventarioDTOS != null) {
|
||||
MvwSitArtUdcDetInventarioDTO mvwSitArtUdcDetInventarioDTO = mvwSitArtUdcDetInventarioDTOS.stream()
|
||||
.filter(x ->
|
||||
x.getCodMart().equalsIgnoreCase(ulRowDTO.getCodMart()) &&
|
||||
UtilityString.equalsIgnoreCase(x.getPartitaMag(), ulRowDTO.getPartitaMag()))
|
||||
.findFirst().orElse(null);
|
||||
if (mvwSitArtUdcDetInventarioDTO != null) {
|
||||
sourceMtbColr =
|
||||
new MtbColr()
|
||||
.setGestione(mvwSitArtUdcDetInventarioDTO.getGestione())
|
||||
.setDataCollo(mvwSitArtUdcDetInventarioDTO.getDataCollo())
|
||||
.setSerCollo(mvwSitArtUdcDetInventarioDTO.getSerCollo())
|
||||
.setNumCollo(mvwSitArtUdcDetInventarioDTO.getNumCollo());
|
||||
}
|
||||
if (!UtilityList.isNullOrEmpty(mvwSitArtUdcDetInventarioDTOS)) {
|
||||
MvwSitArtUdcDetInventarioDTO mvwSitArtUdcDetInventarioDTO = mvwSitArtUdcDetInventarioDTOS.get(0);
|
||||
sourceMtbColr = WMSUtility.convertMvwItemToMtbColr(mvwSitArtUdcDetInventarioDTO);
|
||||
}
|
||||
|
||||
wmsSpedizioneService.insertUDSRow(
|
||||
if (isLavorazione) {
|
||||
wmsLavorazioneService.insertUDSRowMovement(
|
||||
new InsertUDSRowRequestDTO()
|
||||
.setCodMart(ulRowDTO.getCodMart())
|
||||
.setPartitaMag(ulRowDTO.getPartitaMag())
|
||||
.setQtaTot(ulRowDTO.getQtaCol())
|
||||
.setDataOrd(ulRowDTO.getDataOrd() != null ? UtilityLocalDate.localDateToDate(ulRowDTO.getDataOrd()) : null)
|
||||
.setDataOrd(ulRowDTO.getDataOrd())
|
||||
.setNumOrd(ulRowDTO.getNumOrd())
|
||||
.setRigaOrd(ulRowDTO.getRigaOrd())
|
||||
.setTargetMtbColt(uds)
|
||||
.setSourceMtbColr(sourceMtbColr)
|
||||
);
|
||||
.setSourceMtbColr(sourceMtbColr));
|
||||
|
||||
} else {
|
||||
wmsSpedizioneService.insertUDSRowMovement(
|
||||
new InsertUDSRowRequestDTO()
|
||||
.setCodMart(ulRowDTO.getCodMart())
|
||||
.setPartitaMag(ulRowDTO.getPartitaMag())
|
||||
.setQtaTot(ulRowDTO.getQtaCol())
|
||||
.setDataOrd(ulRowDTO.getDataOrd())
|
||||
.setNumOrd(ulRowDTO.getNumOrd())
|
||||
.setRigaOrd(ulRowDTO.getRigaOrd())
|
||||
.setTargetMtbColt(uds)
|
||||
.setSourceMtbColr(sourceMtbColr));
|
||||
}
|
||||
|
||||
if (!createUDSFromDocuments.isMonoUl()) {
|
||||
wmsSpedizioneService.closeUDS(new CloseUDSRequestDTO().setMtbColt(uds));
|
||||
entityProcessor.processEntity(uds, true, multiDBTransactionManager);
|
||||
|
||||
if (isLavorazione) {
|
||||
CloseUDSLavorazioneRequestDTO closeUDSLavorazioneRequestDTO =
|
||||
new CloseUDSLavorazioneRequestDTO();
|
||||
closeUDSLavorazioneRequestDTO.setMtbColt(uds);
|
||||
if (createUDSFromDocuments.getCriterioDistribuzione() != null)
|
||||
closeUDSLavorazioneRequestDTO.setCriterioDistribuzione(createUDSFromDocuments.getCriterioDistribuzione());
|
||||
wmsLavorazioneService.closeUDS(closeUDSLavorazioneRequestDTO);
|
||||
} else {
|
||||
CloseUDSRequestDTO closeUDSRequestDTO = new CloseUDSRequestDTO().setMtbColt(uds);
|
||||
if (createUDSFromDocuments.getCriterioDistribuzione() != null)
|
||||
closeUDSRequestDTO.setCriterioDistribuzione(createUDSFromDocuments.getCriterioDistribuzione());
|
||||
wmsSpedizioneService.closeUDS(closeUDSRequestDTO);
|
||||
}
|
||||
|
||||
generatedMtbColt.add(uds);
|
||||
}
|
||||
@@ -838,11 +1155,39 @@ public class DocumentiDirettiService {
|
||||
}
|
||||
|
||||
if (createUDSFromDocuments.isMonoUl()) {
|
||||
wmsSpedizioneService.closeUDS(new CloseUDSRequestDTO().setMtbColt(uds));
|
||||
entityProcessor.processEntity(uds, true, multiDBTransactionManager);
|
||||
|
||||
if (isLavorazione) {
|
||||
CloseUDSLavorazioneRequestDTO closeUDSLavorazioneRequestDTO =
|
||||
new CloseUDSLavorazioneRequestDTO();
|
||||
closeUDSLavorazioneRequestDTO.setMtbColt(uds);
|
||||
if (createUDSFromDocuments.getCriterioDistribuzione() != null)
|
||||
closeUDSLavorazioneRequestDTO.setCriterioDistribuzione(createUDSFromDocuments.getCriterioDistribuzione());
|
||||
wmsLavorazioneService.closeUDS(closeUDSLavorazioneRequestDTO);
|
||||
} else {
|
||||
CloseUDSRequestDTO closeUDSRequestDTO = new CloseUDSRequestDTO().setMtbColt(uds);
|
||||
if (createUDSFromDocuments.getCriterioDistribuzione() != null)
|
||||
closeUDSRequestDTO.setCriterioDistribuzione(createUDSFromDocuments.getCriterioDistribuzione());
|
||||
wmsSpedizioneService.closeUDS(closeUDSRequestDTO);
|
||||
}
|
||||
|
||||
generatedMtbColt.add(uds);
|
||||
}
|
||||
|
||||
return generatedMtbColt;
|
||||
}
|
||||
|
||||
private MvwSitArtUdcDetInventarioDTO getDatiCollo(String barcodeUl, String codMart, String partitaMag) throws Exception {
|
||||
List<MvwSitArtUdcDetInventarioDTO> mvwSitArtUdcDetInventarioDTOS = wmsGiacenzaULService.retrieveArtsInGiacenzaByBarcodeUl(multiDBTransactionManager.getPrimaryConnection(), barcodeUl);
|
||||
|
||||
if (mvwSitArtUdcDetInventarioDTOS != null) {
|
||||
MvwSitArtUdcDetInventarioDTO mvwSitArtUdcDetInventarioDTO = mvwSitArtUdcDetInventarioDTOS.stream()
|
||||
.filter(x ->
|
||||
x.getCodMart().equalsIgnoreCase(codMart) &&
|
||||
UtilityString.equalsIgnoreCase(x.getPartitaMag(), partitaMag))
|
||||
.findFirst().orElse(null);
|
||||
return mvwSitArtUdcDetInventarioDTO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class EuritmoImportService {
|
||||
SimpleDateFormat dateFormatFile = new SimpleDateFormat(CommonConstants.DATE_FORMAT_YMD);
|
||||
|
||||
multiDBTransactionManager.close(); /*Chiusura connessione al DB di partenza*/
|
||||
multiDBTransactionManager.setPrimaryDs(profileDBDest); /*Connessione al database di destinazione per stampare l'etichetta*/
|
||||
multiDBTransactionManager.setPrimaryDB(profileDBDest); /*Connessione al database di destinazione per stampare l'etichetta*/
|
||||
for (int a = 0; a < rifColloImported.size(); a++) {
|
||||
HashMap<String, String> params = new HashMap<String, String>();
|
||||
params.put("rif_ord", rifColloImported.get(a));
|
||||
|
||||
@@ -10,13 +10,13 @@ import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -31,6 +31,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -196,7 +197,7 @@ public class ICONImportService {
|
||||
public List<MtbColt> returnMissionePicking(String type, String format, List<AnomalieDTO> anomalies) throws Exception {
|
||||
String serColloMagAuto = null, gestioneMagMaga = null, filtroOrdini = null, codAnag = null, codVdes = null, codVlis = null, codMdep = null;
|
||||
LocalDate dataColloMagAuto = null;
|
||||
Date dataOrd = null;
|
||||
LocalDate dataOrd = null;
|
||||
Integer numColloMagAuto = null, numOrd = null;
|
||||
List<ServiceRestResponse> respList = new ArrayList<ServiceRestResponse>();
|
||||
List<MtbColt> colTDistributed = new ArrayList<MtbColt>();
|
||||
@@ -224,16 +225,13 @@ public class ICONImportService {
|
||||
" from mtb_colt " +
|
||||
" where posizione = " + UtilityDB.valueToString(posizione) + " and " +
|
||||
" segno = 1 ";
|
||||
PreparedStatement psInfo = conn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ResultSet resInfo = psInfo.executeQuery();
|
||||
while (resInfo.next()) {
|
||||
dataColloMagAuto = UtilityLocalDate.localDateFromDate(resInfo.getDate(1));
|
||||
serColloMagAuto = resInfo.getString(2);
|
||||
numColloMagAuto = resInfo.getInt(3);
|
||||
gestioneMagMaga = resInfo.getString(4);
|
||||
}
|
||||
resInfo.close();
|
||||
psInfo.close();
|
||||
|
||||
final HashMap<String, Object> result = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, query);
|
||||
dataColloMagAuto = UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(result, "data_collo"));
|
||||
serColloMagAuto = UtilityHashMap.getValueIfExists(result, "ser_collo");
|
||||
numColloMagAuto = UtilityHashMap.getValueIfExists(result, "num_collo");
|
||||
gestioneMagMaga = UtilityHashMap.getValueIfExists(result, "gestione");
|
||||
|
||||
|
||||
// Acquisizione liste importare da ICON con successo
|
||||
query = "SELECT tmkeymov, " +
|
||||
@@ -248,12 +246,13 @@ public class ICONImportService {
|
||||
" tmdirflu = " + UtilityDB.valueToString(dirFlu) + " and " +
|
||||
" left(tmparmte, 2) = 'P|' ";
|
||||
|
||||
PreparedStatement ps = conICON.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ResultSet res = ps.executeQuery();
|
||||
while (res.next()) {
|
||||
Integer keyMov = res.getInt(1);
|
||||
String tmparmte = res.getString(2);
|
||||
String nomeLista = res.getString(4);
|
||||
final List<HashMap<String, Object>> iconImportedLists = UtilityDB.executeSimpleQuery(conICON, query);
|
||||
|
||||
for (HashMap<String, Object> iconImportedRow : iconImportedLists) {
|
||||
|
||||
Integer keyMov = UtilityHashMap.getValueIfExists(iconImportedRow, "tmkeymov");
|
||||
String tmparmte = UtilityHashMap.getValueIfExists(iconImportedRow, "tmparmte");
|
||||
String nomeLista = UtilityHashMap.getValueIfExists(iconImportedRow, "tmname");
|
||||
|
||||
// Acquisizione estremi ordini di vendita
|
||||
String[] keyApprov = tmparmte.split("\\|");
|
||||
@@ -266,13 +265,13 @@ public class ICONImportService {
|
||||
// Se il collo esiste e ci sono già delle righe all'interno allora vuol dire che la missione è stata chiusa parzialmente e ripresa successivamente
|
||||
// quindi è necessario creare un nuovo collo (testata uguale al precedente in modo da acquisre il filtro ordine)
|
||||
boolean existCollo = false, isPickingLibero = false;
|
||||
;
|
||||
|
||||
int isPartialPicking = 0;
|
||||
query = "select mtb_colt.filtro_ordini, " +
|
||||
" mtb_colt.cod_mdep, " +
|
||||
" mtb_colt.data_ord, " +
|
||||
" mtb_colt.num_ord, " +
|
||||
" sum(case when mtb_colr.cod_mart is null then 0 else 1 end ) as existRow " +
|
||||
query = "select mtb_colt.filtro_ordini AS filtro_ordini, " +
|
||||
" mtb_colt.cod_mdep AS cod_mdep, " +
|
||||
" mtb_colt.data_ord AS data_ord, " +
|
||||
" mtb_colt.num_ord AS num_ord, " +
|
||||
" sum(case when mtb_colr.cod_mart is null then 0 else 1 end ) AS existRow " +
|
||||
" from mtb_colt LEFT OUTER JOIN mtb_colr ON mtb_colt.gestione = mtb_colr.gestione and " +
|
||||
" mtb_colt.data_collo = mtb_colr.data_collo and " +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo and " +
|
||||
@@ -285,28 +284,28 @@ public class ICONImportService {
|
||||
" mtb_colt.cod_mdep, " +
|
||||
" mtb_colt.data_ord, " +
|
||||
" mtb_colt.num_ord";
|
||||
psInfo = conn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
resInfo = psInfo.executeQuery();
|
||||
while (resInfo.next()) {
|
||||
existCollo = true;
|
||||
filtroOrdini = resInfo.getString(1);
|
||||
codMdep = resInfo.getString(2);
|
||||
dataOrd = resInfo.getDate(3);
|
||||
numOrd = resInfo.getInt(4);
|
||||
isPartialPicking = resInfo.getInt(5);
|
||||
|
||||
final HashMap<String, Object> openedPickingResult = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, query);
|
||||
existCollo = openedPickingResult != null;
|
||||
|
||||
if(existCollo) {
|
||||
filtroOrdini = UtilityHashMap.getValueIfExists(openedPickingResult, "filtro_ordini");
|
||||
codMdep = UtilityHashMap.getValueIfExists(openedPickingResult, "cod_mdep");
|
||||
dataOrd = UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(openedPickingResult, "data_ord"));
|
||||
numOrd = UtilityHashMap.getValueIfExists(openedPickingResult, "num_ord");
|
||||
isPartialPicking = UtilityHashMap.getValueIfExists(openedPickingResult, "existRow");
|
||||
|
||||
if (dataOrd == null) {
|
||||
isPickingLibero = true;
|
||||
}
|
||||
}
|
||||
resInfo.close();
|
||||
psInfo.close();
|
||||
|
||||
|
||||
// Se il collo di partenza non esiste allora viene saltata la missione ed inviato un messaggio di
|
||||
// alert impostando come importata la lista in modo da non creare intasamento nelle mail di notifica
|
||||
if (existCollo) {
|
||||
List<MtbColt> listImported = new ArrayList<MtbColt>();
|
||||
Integer index = 0;
|
||||
int index = 0;
|
||||
query = "SELECT rmcodart, " +
|
||||
" sum(rmqtamov) as qta_mov " +
|
||||
" FROM [dbo].[mvrig01l]" +
|
||||
@@ -335,7 +334,7 @@ public class ICONImportService {
|
||||
colT.setRifOrd("PICKING LIBERO");
|
||||
}
|
||||
colT.setSegno(-1);
|
||||
colT.setDataOrd(UtilityLocalDate.localDateFromDate(dataOrd));
|
||||
colT.setDataOrd(dataOrd);
|
||||
colT.setNumOrd(numOrd);
|
||||
colT.setCodMdep(codMdep);
|
||||
colT.setAnnotazioni(nomeLista);
|
||||
@@ -365,7 +364,6 @@ public class ICONImportService {
|
||||
// Se non vi è il filtro ordini allora vuol dire che si tratta di un picking libero e quindi veiene solo registrato il collo di partenza
|
||||
if (filtroOrdini != null) {
|
||||
// Distribuzione collo vendita
|
||||
List<MtbColt> colTDistr = new ArrayList<>();
|
||||
DistribuzioneColliService distrCollo = new DistribuzioneColliService();
|
||||
FiltroDistribuzioneColloDTO filtro = new FiltroDistribuzioneColloDTO();
|
||||
filtro.setGestione(collo.getGestione());
|
||||
@@ -373,7 +371,7 @@ public class ICONImportService {
|
||||
filtro.setSerCollo(collo.getSerCollo());
|
||||
filtro.setNumCollo(collo.getNumCollo());
|
||||
filtro.setCriterioDistribuzione("U");
|
||||
colTDistr = distrCollo.distribuzioneRigheColloNew(filtro, true);
|
||||
List<MtbColt> colTDistr = distrCollo.distribuzioneRigheColloNew(filtro, true);
|
||||
colTDistributed.addAll(colTDistr);
|
||||
|
||||
entityProcessor.processEntityList(colTDistr, multiDBTransactionManager, true);
|
||||
@@ -391,25 +389,21 @@ public class ICONImportService {
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo and " +
|
||||
" mtb_colr.riga_ord is null ";
|
||||
|
||||
psInfo = multiDBTransactionManager.prepareStatement(query);
|
||||
resInfo = psInfo.executeQuery();
|
||||
MtbColt colloDistribuito = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), query, MtbColt.class);
|
||||
|
||||
ResultSetMapper mapper = new ResultSetMapper();
|
||||
List<MtbColt> colloDistribuito = mapper.mapResultSetToList(resInfo, MtbColt.class);
|
||||
|
||||
if (colloDistribuito != null && !colloDistribuito.isEmpty()) {
|
||||
if (colloDistribuito != null) {
|
||||
String errorText = "(PICKING) Referenze non distribuite su collo N. " + collo.getNumCollo() + " relativa alla lista " + nomeLista + ". Alcune referenze potrebbero essere cambiate nell'ordine dopo avere effettuata la lista di movimentazione articoli";
|
||||
anomalies.add(AnomalieDTO.error(errorText));
|
||||
|
||||
// Se ci sono righe che non sono state distribuite allora bisognerà assegnare il primo codice commessa utile presente negli ordini e il codice del cliente
|
||||
colloDistribuito.get(0).setOperation(OperationType.UPDATE);
|
||||
colloDistribuito.get(0).setGestione(gestione);
|
||||
colloDistribuito.get(0).setDataCollo(dataCollo);
|
||||
colloDistribuito.get(0).setSerCollo(serCollo);
|
||||
colloDistribuito.get(0).setNumCollo(collo.getNumCollo());
|
||||
colloDistribuito.get(0).setCodAnag(colTDistr.get(0).getCodAnag());
|
||||
colloDistribuito.get(0).setCodVdes(colTDistr.get(0).getCodVdes());
|
||||
colloDistribuito.get(0).setMtbColr(new ArrayList<MtbColr>());
|
||||
colloDistribuito.setOperation(OperationType.UPDATE);
|
||||
colloDistribuito.setGestione(gestione);
|
||||
colloDistribuito.setDataCollo(dataCollo);
|
||||
colloDistribuito.setSerCollo(serCollo);
|
||||
colloDistribuito.setNumCollo(collo.getNumCollo());
|
||||
colloDistribuito.setCodAnag(colTDistr.get(0).getCodAnag());
|
||||
colloDistribuito.setCodVdes(colTDistr.get(0).getCodVdes());
|
||||
colloDistribuito.setMtbColr(new ArrayList<>());
|
||||
|
||||
query =
|
||||
"SELECT riga FROM mtb_colr " +
|
||||
@@ -418,19 +412,18 @@ public class ICONImportService {
|
||||
" ser_collo = " + UtilityDB.valueToString(serCollo) + " and " +
|
||||
" num_collo = " + UtilityDB.valueToString(collo.getNumCollo());
|
||||
|
||||
psInfo = conn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
resInfo = psInfo.executeQuery();
|
||||
while (resInfo.next()) {
|
||||
final HashMap<String, Object> resultMtbColr = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, query);
|
||||
|
||||
if(resultMtbColr != null){
|
||||
MtbColr colR = new MtbColr();
|
||||
colR.setOperation(OperationType.UPDATE);
|
||||
colR.setRiga(resInfo.getInt(1));
|
||||
colR.setRiga(UtilityHashMap.getValueIfExists(resultMtbColr, "riga"));
|
||||
colR.setCodJcom(colTDistr.get(0).getMtbColr().get(0).getCodJcom());
|
||||
colloDistribuito.get(0).getMtbColr().add(colR);
|
||||
colloDistribuito.getMtbColr().add(colR);
|
||||
}
|
||||
psInfo.close();
|
||||
resInfo.close();
|
||||
|
||||
entityProcessor.processEntityList(colloDistribuito, multiDBTransactionManager, true);
|
||||
|
||||
entityProcessor.processEntity(colloDistribuito, multiDBTransactionManager, true);
|
||||
multiDBTransactionManager.commitAll();
|
||||
}
|
||||
}
|
||||
@@ -447,8 +440,6 @@ public class ICONImportService {
|
||||
conICON.commit();
|
||||
multiDBTransactionManager.commitAll();
|
||||
}
|
||||
res.close();
|
||||
ps.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("(RETURN PICKING) " + e.getLocalizedMessage());
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Slim2kLogisticController {
|
||||
@RequestParam(value = "listcode", required = false) String listCode) {
|
||||
List<ServiceRestResponse> list = new ArrayList<ServiceRestResponse>();
|
||||
try {
|
||||
multiDBTransactionManager.setPrimaryDs(configuration);
|
||||
multiDBTransactionManager.setPrimaryDB(configuration);
|
||||
logger.debug(requestDataDTO.getUsername() + " " + requestDataDTO.getPassword() + " " + requestDataDTO.getProfileDB());
|
||||
list = slim2kLogisticService.importListeDiScarico(listType, listCode);
|
||||
} catch (Exception e) {
|
||||
@@ -63,7 +63,7 @@ public class Slim2kLogisticController {
|
||||
@RequestParam(value = "doctype", required = false) String doctype) {
|
||||
List<ServiceRestResponse> list = new ArrayList<ServiceRestResponse>();
|
||||
try {
|
||||
multiDBTransactionManager.setPrimaryDs(configuration);
|
||||
multiDBTransactionManager.setPrimaryDB(configuration);
|
||||
logger.debug(requestDataDTO.getUsername() + " " + requestDataDTO.getPassword() + " " + requestDataDTO.getProfileDB());
|
||||
list = slim2kLogisticService.importListeDiCarico(scode, dcode, docdate, docnum, refdoc);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.DtbOrdr;
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
@@ -128,6 +129,21 @@ public class ColliEviosysImportService {
|
||||
throw new Exception("Nessun deposito trovato per l'ordine: " + dtbOrdr.getNumOrd() + " del cliente: " + codAnag);
|
||||
}
|
||||
|
||||
sql = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE barcode_ul = %s\n" +
|
||||
" AND data_ord IS NULL\n" +
|
||||
" AND num_ord IS NULL\n" +
|
||||
" AND num_doc IS NULL\n" +
|
||||
" AND ser_doc IS NULL\n" +
|
||||
" AND data_doc IS NULL",
|
||||
barcodeUl
|
||||
);
|
||||
|
||||
MtbColt mtbColt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColt.class);
|
||||
|
||||
if (mtbColt == null) {
|
||||
MtbColt udc = wmsAccettazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodMdep(dtbOrdr.getCodMdep())
|
||||
@@ -152,6 +168,37 @@ public class ColliEviosysImportService {
|
||||
wmsAccettazioneService.closeUDC(new CloseUDCRequestDTO().setMtbColt(udc));
|
||||
|
||||
entityBases.add(udc);
|
||||
} else {
|
||||
sql = Query.format(
|
||||
"SELECT r.*\n" +
|
||||
"FROM mtb_colt t\n" +
|
||||
" INNER JOIN mtb_colr r\n" +
|
||||
" ON t.gestione = r.gestione AND t.num_collo = r.num_collo AND\n" +
|
||||
" t.ser_collo = r.ser_collo AND t.data_collo = r.data_collo\n" +
|
||||
"WHERE t.data_collo = %s\n" +
|
||||
" AND t.num_collo = %s\n" +
|
||||
" AND t.ser_collo = %s\n" +
|
||||
" AND t.gestione = %s",
|
||||
mtbColt.getDataCollo(), mtbColt.getNumCollo(), mtbColt.getSerCollo(), mtbColt.getGestione()
|
||||
);
|
||||
|
||||
MtbColr mtbColr = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColr.class);
|
||||
|
||||
mtbColt.setCodAnag(codAnag)
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd());
|
||||
|
||||
mtbColr.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd());
|
||||
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
entityProcessor.processEntity(mtbColt, multiDBTransactionManager);
|
||||
|
||||
entityBases.add(mtbColt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,7 +256,11 @@ public class ColliEviosysImportService {
|
||||
if (codArtFor != null) {
|
||||
String sql = Query.format("SELECT cod_mart FROM mtb_lisa WHERE cod_art_for = %s", codArtFor);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
String codMart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (codMart == null) throw new Exception("Codice articolo fornitore: " + codArtFor + " non trovato");
|
||||
|
||||
return codMart;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
import static it.integry.ems_model.types.SetupGestKeySection.*;
|
||||
@@ -289,7 +288,7 @@ public class ColliImportService {
|
||||
if (UtilityString.isNullOrEmpty(codMdep)) throw new Exception("Codice Deposito dei default non configurato");
|
||||
|
||||
MultiDBTransactionManager mdbSteup = new MultiDBTransactionManager();
|
||||
mdbSteup.setPrimaryDs(profileDb);
|
||||
mdbSteup.setPrimaryDB(profileDb);
|
||||
|
||||
String sql =
|
||||
"select mtb_colt.gestione, " +
|
||||
@@ -519,6 +518,21 @@ public class ColliImportService {
|
||||
);
|
||||
DtbOrdr dtbOrdr = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, DtbOrdr.class);
|
||||
|
||||
sql = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE barcode_ul = %s\n" +
|
||||
" AND data_ord IS NULL\n" +
|
||||
" AND num_ord IS NULL\n" +
|
||||
" AND num_doc IS NULL\n" +
|
||||
" AND ser_doc IS NULL\n" +
|
||||
" AND data_doc IS NULL",
|
||||
dettagliLotti.getCodSscc()
|
||||
);
|
||||
|
||||
MtbColt mtbColt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColt.class);
|
||||
|
||||
if (mtbColt == null){
|
||||
MtbColt udc = wmsAccettazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodMdep(dtbOrdr.getCodMdep())
|
||||
@@ -545,6 +559,37 @@ public class ColliImportService {
|
||||
wmsAccettazioneService.closeUDC(new CloseUDCRequestDTO().setMtbColt(udc));
|
||||
|
||||
entityBases.add(udc);
|
||||
} else {
|
||||
sql = Query.format(
|
||||
"SELECT r.*\n" +
|
||||
"FROM mtb_colt t\n" +
|
||||
" INNER JOIN mtb_colr r\n" +
|
||||
" ON t.gestione = r.gestione AND t.num_collo = r.num_collo AND\n" +
|
||||
" t.ser_collo = r.ser_collo AND t.data_collo = r.data_collo\n" +
|
||||
"WHERE t.data_collo = %s\n" +
|
||||
" AND t.num_collo = %s\n" +
|
||||
" AND t.ser_collo = %s\n" +
|
||||
" AND t.gestione = %s",
|
||||
mtbColt.getDataCollo(), mtbColt.getNumCollo(), mtbColt.getSerCollo(), mtbColt.getGestione()
|
||||
);
|
||||
|
||||
MtbColr mtbColr = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColr.class);
|
||||
|
||||
mtbColt.setCodAnag(codAnag)
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd());
|
||||
|
||||
mtbColr.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd());
|
||||
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
entityProcessor.processEntity(mtbColt, multiDBTransactionManager);
|
||||
|
||||
entityBases.add(mtbColt);
|
||||
}
|
||||
}
|
||||
|
||||
return entityBases;
|
||||
|
||||
@@ -115,6 +115,7 @@ public class DistribuzioneColliService {
|
||||
List<String> codMarts = sourceMtbColrs.stream()
|
||||
.filter(mtbColr -> mtbColr != null && !UtilityString.isNullOrEmpty(mtbColr.getCodMart()))
|
||||
.map(MtbColr::getCodMart)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<MtbAart> mtbAarts = WMSUtility.getArticoliByCodMarts(codMarts, multiDBTransactionManager.getPrimaryConnection());
|
||||
@@ -295,6 +296,13 @@ public class DistribuzioneColliService {
|
||||
newMtbColr.setNumColloRif(sourceMtbColr.getNumColloRif());
|
||||
newMtbColr.setGestioneRif(sourceMtbColr.getGestioneRif());
|
||||
|
||||
newMtbColr.setBarcodeUlIn(sourceMtbColr.getBarcodeUlIn());
|
||||
newMtbColr.setBarcodeUlOut(sourceMtbColr.getBarcodeUlOut());
|
||||
newMtbColr.setCodMdepIn(sourceMtbColr.getCodMdepIn());
|
||||
newMtbColr.setCodMdepOut(sourceMtbColr.getCodMdepOut());
|
||||
newMtbColr.setPosizioneIn(sourceMtbColr.getPosizioneIn());
|
||||
newMtbColr.setPosizioneOut(sourceMtbColr.getPosizioneOut());
|
||||
|
||||
newMtbColr.setDatetimeRow(sourceMtbColr.getDatetimeRow());
|
||||
newMtbColr.setQueryTimeoutSeconds(30);
|
||||
|
||||
@@ -662,7 +670,10 @@ public class DistribuzioneColliService {
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getCodCol(), groupedMtbColr.getCodCol()) &&
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getCodTagl(), groupedMtbColr.getCodTagl()) &&
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getPartitaMag(), groupedMtbColr.getPartitaMag()) &&
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getCodJcom(), groupedMtbColr.getCodJcom()))
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getCodJcom(), groupedMtbColr.getCodJcom()) &&
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getBarcodeUlOut(), groupedMtbColr.getBarcodeUlOut()) &&
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getPosizioneOut(), groupedMtbColr.getPosizioneOut()) &&
|
||||
UtilityString.equalsIgnoreCase(mtbColr.getCodMdepOut(), groupedMtbColr.getCodMdepOut()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (match != null && !match.isEmpty()) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package it.integry.ems.logistic.service;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.logistic.dto.ImportColliDaProduzioneDTO;
|
||||
import it.integry.ems.retail.wms.accettazione.service.WMSAccettazioneService;
|
||||
import it.integry.ems.retail.wms.dto.*;
|
||||
import it.integry.ems.retail.wms.lavorazione.service.WMSLavorazioneService;
|
||||
import it.integry.ems.retail.wms.vendita.service.WMSSpedizioneService;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -44,6 +47,15 @@ public class PackagesImportService {
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
@Autowired
|
||||
private WMSAccettazioneService wmsAccettazioneService;
|
||||
|
||||
@Autowired
|
||||
private WMSSpedizioneService wmsSpedizioneService;
|
||||
|
||||
@Autowired
|
||||
private WMSLavorazioneService wmsLavorazioneService;
|
||||
|
||||
public Map<String, Object> resultSetToHashMap(ResultSet rs, String... keyValues) throws Exception {
|
||||
|
||||
if (keyValues.length < 2)
|
||||
@@ -355,88 +367,79 @@ public class PackagesImportService {
|
||||
String codVdes = UtilityHashMap.getValueIfExists(result, "cod_vdes");
|
||||
|
||||
|
||||
MtbColt mtbColt = new MtbColt()
|
||||
.setMtbColr(new ArrayList<>());
|
||||
mtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
if (importColliProd.getGestione().equalsIgnoreCase("A")) {
|
||||
mtbColt
|
||||
.setCodAnag(codAnag)
|
||||
.setCodVdes(codVdes);
|
||||
}
|
||||
mtbColt.setCodMdep(codMdep)
|
||||
.setPreparatoDa(requestDataDTO.getUsername())
|
||||
CreateUDCRequestDTO createUDCRequest = new CreateUDCRequestDTO()
|
||||
.setCodMdep(codMdep)
|
||||
.setDataCollo(importColliProd.getDataCollo())
|
||||
.setSerCollo(serCollo)
|
||||
.setCodTcol(importColliProd.getCodTcol())
|
||||
.setPesoKg(importColliProd.getPesoLordo())
|
||||
.setPesoNettoKg(importColliProd.getPesoNetto())
|
||||
.setOrders(Collections.singletonList(new CreateUDCRequestOrderDTO()
|
||||
.setDataOrd(importColliProd.getDataOrd())
|
||||
.setNumOrd(importColliProd.getNumOrd())
|
||||
.setGestione(importColliProd.getGestione())
|
||||
.setSegno(1)
|
||||
.setDataVers(dataVers)
|
||||
.setGestione(importColliProd.getGestione())))
|
||||
.setCodJfas(importColliProd.getCodJfas())
|
||||
.setAnnotazioni(importColliProd.getAnnotazioni());
|
||||
|
||||
if (importColliProd.getGestione().equalsIgnoreCase("A")) {
|
||||
createUDCRequest
|
||||
.setCodAnag(codAnag)
|
||||
.setCodVdes(codVdes);
|
||||
}
|
||||
|
||||
MtbColt udc = wmsLavorazioneService.createUDC(createUDCRequest);
|
||||
|
||||
udc
|
||||
.setPesoKg(importColliProd.getPesoLordo())
|
||||
.setPesoNettoKg(importColliProd.getPesoNetto())
|
||||
.setDataVers(dataVers)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
|
||||
BigDecimal qtaCnf = importColliProd.getQtaCnf() == null ?
|
||||
importColliProd.getQtaCol().divide(new BigDecimal(importColliProd.getColliBancale()), EmsRestConstants.cifreDecMax, RoundingMode.HALF_UP) :
|
||||
importColliProd.getQtaCnf();
|
||||
|
||||
MtbColr mtbColr = new MtbColr()
|
||||
InsertUDCRowRequestDTO insertUDCRowRequestDTO = new InsertUDCRowRequestDTO()
|
||||
.setTargetMtbColt(udc)
|
||||
.setCodMart(importColliProd.getCodMart())
|
||||
.setQtaCnf(qtaCnf)
|
||||
.setQtaCol(importColliProd.getQtaCol())
|
||||
.setQtaTot(importColliProd.getQtaCol())
|
||||
.setNumCnf(new BigDecimal(importColliProd.getColliBancale()))
|
||||
.setPartitaMag(importColliProd.getPartitaMag())
|
||||
.setDataOrd(importColliProd.getDataOrd())
|
||||
.setNumOrd(importColliProd.getNumOrd())
|
||||
.setPesoLordoKg(importColliProd.getPesoLordo())
|
||||
.setPesoNettoKg(importColliProd.getPesoNetto())
|
||||
.setCodJcom(importColliProd.getCodJcom());
|
||||
|
||||
|
||||
if (importColliProd.getGestione().equalsIgnoreCase("A")) {
|
||||
mtbColr.setRigaOrd(importColliProd.getRigaOrd());
|
||||
insertUDCRowRequestDTO.setRigaOrd(importColliProd.getRigaOrd());
|
||||
} else {
|
||||
mtbColr.setRigaOrd(0);
|
||||
insertUDCRowRequestDTO.setRigaOrd(0);
|
||||
}
|
||||
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
entityProcessor.processEntity(mtbColt, true, multiDBTransactionManager);
|
||||
final MtbColr savedMtbColr = wmsAccettazioneService.insertUDCRow(insertUDCRowRequestDTO)
|
||||
.getSavedMtbColr();
|
||||
|
||||
savedMtbColr
|
||||
.setPesoLordoKg(importColliProd.getPesoLordo())
|
||||
.setPesoNettoKg(importColliProd.getPesoNetto())
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
udc.setMtbColr(new ArrayList<MtbColr>(1) {{
|
||||
add(savedMtbColr);
|
||||
}});
|
||||
|
||||
entityProcessor.processEntity(udc, true, multiDBTransactionManager);
|
||||
|
||||
|
||||
List<MtbColt> colliRet = new ArrayList<>();
|
||||
colliRet.add(mtbColt);
|
||||
colliRet.add(udc);
|
||||
|
||||
List<EntityBase> entityBases = new ArrayList<>();
|
||||
if (!UtilityString.isNullOrEmpty(importColliProd.getCodJcom()) && importColliProd.isAutoGeneraVendita()) {
|
||||
MtbColt mtbColtV = new MtbColt()
|
||||
.setGestione("V")
|
||||
.setCodMdep(codMdep)
|
||||
.setDataCollo(importColliProd.getDataCollo())
|
||||
.setSerCollo(serCollo)
|
||||
.setSegno(-1)
|
||||
.setPesoKg(importColliProd.getPesoLordo())
|
||||
.setPesoNettoKg(importColliProd.getPesoNetto())
|
||||
.setCodTcol(importColliProd.getCodTcol())
|
||||
.setPreparatoDa(requestDataDTO.getUsername())
|
||||
.setAnnotazioni(importColliProd.getFornitore())
|
||||
.setDataVers(dataVers)
|
||||
.setMtbColr(new ArrayList<>());
|
||||
mtbColtV.setOperation(OperationType.INSERT);
|
||||
entityBases.add(mtbColtV);
|
||||
|
||||
MtbColr mtbColrV = new MtbColr()
|
||||
.setCodMart(importColliProd.getCodMart())
|
||||
.setQtaCnf(qtaCnf)
|
||||
.setQtaCol(importColliProd.getQtaCol())
|
||||
.setNumCnf(new BigDecimal(importColliProd.getColliBancale()))
|
||||
.setPartitaMag(importColliProd.getPartitaMag())
|
||||
.setGestioneRif(mtbColt.getGestione())
|
||||
.setNumColloRif(mtbColt.getNumCollo())
|
||||
.setDataColloRif(mtbColt.getDataCollo())
|
||||
.setSerColloRif(mtbColt.getSerCollo());
|
||||
mtbColtV.getMtbColr().add(mtbColrV);
|
||||
|
||||
query = "SELECT dtb_ordt.cod_anag," +
|
||||
" dtb_ordt.gestione," +
|
||||
" dtb_ordt.data_ord," +
|
||||
" dtb_ordt.num_ord, " +
|
||||
" dtb_ordt.cod_vdes, " +
|
||||
@@ -452,13 +455,34 @@ public class PackagesImportService {
|
||||
|
||||
result = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, query);
|
||||
|
||||
|
||||
CreateUDSRequestDTO createUDSRequest = new CreateUDSRequestDTO()
|
||||
.setCodMdep(codMdep)
|
||||
.setDataCollo(importColliProd.getDataCollo())
|
||||
.setSerCollo(serCollo)
|
||||
.setCodTcol(importColliProd.getCodTcol())
|
||||
.setAnnotazioni(importColliProd.getFornitore());
|
||||
|
||||
|
||||
InsertUDSRowRequestDTO insertUDSRowRequest = new InsertUDSRowRequestDTO()
|
||||
.setCodMart(importColliProd.getCodMart())
|
||||
.setQtaCnf(qtaCnf)
|
||||
.setQtaTot(importColliProd.getQtaCol())
|
||||
.setNumCnf(new BigDecimal(importColliProd.getColliBancale()))
|
||||
.setPartitaMag(importColliProd.getPartitaMag())
|
||||
.setSourceMtbColr(savedMtbColr);
|
||||
|
||||
if (result != null) {
|
||||
mtbColtV.setCodAnag(UtilityHashMap.getValueIfExists(result, "cod_anag"))
|
||||
createUDSRequest.setCodAnag(UtilityHashMap.getValueIfExists(result, "cod_anag"))
|
||||
.setOrders(Collections.singletonList(new CreateUDSRequestOrderDTO()
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(result, "data_ord")))
|
||||
.setNumOrd(UtilityHashMap.getValueIfExists(result, "num_ord"))
|
||||
.setGestione(UtilityHashMap.getValueIfExists(result, "gestione"))
|
||||
))
|
||||
.setCodVdes(UtilityHashMap.getValueIfExists(result, "cod_vdes"))
|
||||
.setRifOrd(UtilityHashMap.getValueIfExists(result, "rif_ord"));
|
||||
mtbColrV.setDataOrd(UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(result, "data_ord")))
|
||||
|
||||
insertUDSRowRequest.setDataOrd(UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(result, "data_ord")))
|
||||
.setNumOrd(UtilityHashMap.getValueIfExists(result, "num_ord"))
|
||||
.setRigaOrd(UtilityHashMap.getValueIfExists(result, "riga_ord"));
|
||||
|
||||
@@ -467,8 +491,23 @@ public class PackagesImportService {
|
||||
"FROM jtb_comt WHERE cod_jcom = " + UtilityDB.valueToString(importColliProd.getCodJcom());
|
||||
|
||||
String codAnagV = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, query);
|
||||
mtbColtV.setCodAnag(codAnagV);
|
||||
createUDSRequest.setCodAnag(codAnagV);
|
||||
}
|
||||
|
||||
final MtbColt uds = wmsSpedizioneService.createUDS(createUDSRequest);
|
||||
|
||||
uds
|
||||
.setPesoKg(importColliProd.getPesoLordo())
|
||||
.setPesoNettoKg(importColliProd.getPesoNetto())
|
||||
.setDataVers(dataVers)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
entityProcessor.processEntity(uds, true, multiDBTransactionManager);
|
||||
|
||||
|
||||
insertUDSRowRequest
|
||||
.setTargetMtbColt(uds);
|
||||
wmsSpedizioneService.insertUDSRow(insertUDSRowRequest);
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(importColliProd.getCodJfas()) && flagStart.equalsIgnoreCase("S")) {
|
||||
@@ -579,17 +618,14 @@ public class PackagesImportService {
|
||||
}*/
|
||||
}
|
||||
|
||||
List<EntityBase> entityRet = entityProcessor.processEntityList(entityBases, true);
|
||||
entityProcessor.processEntityList(entityBases, true);
|
||||
|
||||
List<MtbColt> mtbColtRet =
|
||||
Stream.of(entityRet)
|
||||
.filter(x -> x instanceof MtbColt)
|
||||
.map(x -> (MtbColt) x)
|
||||
.toList();
|
||||
colliRet.forEach(x -> {
|
||||
x.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
x.getMtbColr().forEach(y -> y.setOperation(OperationType.SELECT_OBJECT));
|
||||
});
|
||||
|
||||
if (mtbColtRet != null && !mtbColtRet.isEmpty()) {
|
||||
colliRet.addAll(mtbColtRet);
|
||||
}
|
||||
return colliRet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class OrdiniConsortileService {
|
||||
// Connessione al database della consortile
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBDest);
|
||||
multiDBTransactionManagerDBDest.setPrimaryDs(profileDBDest);
|
||||
multiDBTransactionManagerDBDest.setPrimaryDB(profileDBDest);
|
||||
Connection connDBDest = multiDBTransactionManagerDBDest.getDatabaseConnection(profileDBDest);
|
||||
|
||||
// Acquisizione elenco ordini da trasferire
|
||||
|
||||
@@ -649,7 +649,7 @@ public class PuddyService {
|
||||
MultiDBTransactionManager multiDBTransactionManagerVG = new MultiDBTransactionManager();
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBVG);
|
||||
multiDBTransactionManagerVG.setPrimaryDs(profileDBVG);
|
||||
multiDBTransactionManagerVG.setPrimaryDB(profileDBVG);
|
||||
|
||||
// Acquisizione dati agente VG
|
||||
sql =
|
||||
@@ -1138,7 +1138,7 @@ public class PuddyService {
|
||||
if (!UtilityString.isNullOrEmpty(profileDBVG)){
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDBVG);
|
||||
multiDBTransactionManagerVG.setPrimaryDs(profileDBVG);
|
||||
multiDBTransactionManagerVG.setPrimaryDB(profileDBVG);
|
||||
columnTipoAzienda = "case when ser_doc like 'V%' then 'ASS_VG' else 'ASS_SEVEN' end";
|
||||
|
||||
/*Acquisizione dati agente/data incasso*/
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AgribookUserService {
|
||||
" password_expires_days,\n" +
|
||||
" last_passwords,\n" +
|
||||
" flag_password_expiring,\n" +
|
||||
" destruction_datetime\n" +
|
||||
" password_endtime as destruction_datetime\n" +
|
||||
"FROM Wtb_users\n" +
|
||||
"WHERE key_group IN (" + String.join("','", listKeyGroupAgronomi) + ")";
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import it.integry.ems.service.dto.production.OrdineLavorazioneDTO;
|
||||
import it.integry.ems.service.production.ProductionOrderDataHandlerService;
|
||||
import it.integry.ems.status.ServiceChecker;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.business_logic.GeneraOrdLav;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
@@ -478,6 +477,7 @@ public class MesProductionControllerV2 {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PostMapping(value = "ordine/ripianifica")
|
||||
public @ResponseBody
|
||||
ServiceRestResponse ripianifica(@RequestBody RipianificaOrdineLavRequestDTO dto) throws Exception {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user