Compare commits
340 Commits
bb47dd458e
...
feature-re
| Author | SHA1 | Date | |
|---|---|---|---|
| d048ea1f9c | |||
| 6f2d485de7 | |||
| 9f46505136 | |||
| e189aa4f6c | |||
| 4d2fbf610d | |||
| 3ec8d6d0e1 | |||
| a3df8d0822 | |||
| 255de9a955 | |||
| 622c4c903c | |||
| e51fa4fa6b | |||
| febe8be89e | |||
| 3ad15c8457 | |||
| 3ae1d499c2 | |||
| b10c6e837c | |||
| 1d07f15169 | |||
| 18e69f0195 | |||
| 3f4735f953 | |||
| edcd6ecf6b | |||
| b2ac734b5e | |||
| 481e8e35cc | |||
| 725b93be81 | |||
| 7eac47b3b7 | |||
| 8abb7c2842 | |||
| 55e55bd64a | |||
| 7de563abf3 | |||
| 12154ed089 | |||
| 98e518e295 | |||
| 498ce2880e | |||
| b828e5bfae | |||
| 637fdca7ed | |||
| 8778aecbeb | |||
| 724bc750cf | |||
| 4c78c0cf37 | |||
| c8c476f98c | |||
| 0c3cf9095f | |||
| f90688e969 | |||
| c76417b917 | |||
| 332b4fddd8 | |||
| fa2bca9c99 | |||
| 565cbc9f30 | |||
| febd5d7e7f | |||
| 057d7961f2 | |||
| 8ead6d9fdb | |||
| 08215fab9d | |||
| 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.*" />
|
||||
|
||||
@@ -5,16 +5,7 @@
|
||||
"primaryInstance" : true,
|
||||
"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
|
||||
}, {
|
||||
"availableConnections" : [{
|
||||
"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",
|
||||
"username" : "SA",
|
||||
"password" : "sZ",
|
||||
"host" : "192.168.2.220",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
@Component
|
||||
public class LooperService {
|
||||
public class LooperService {
|
||||
private final ArrayList<LoopDTO> mLoopsHandler = new ArrayList<>();
|
||||
private final ArrayList<TaskModel> mLoopsTask = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -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,28 +1264,41 @@ 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" +
|
||||
" WHERE dot.data_ord = %s\n" +
|
||||
" AND dot.num_ord = %s\n" +
|
||||
" AND dot.gestione = [gestione])\n" +
|
||||
"SELECT ISNULL(MAX(progressivo_ul), 0) AS progressivo_ul\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr mcr ON mtb_colt.gestione = mcr.gestione AND mtb_colt.data_collo = mcr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mcr.ser_collo AND mtb_colt.num_collo = mcr.num_collo\n" +
|
||||
" INNER JOIN mtb_partita_mag mpm ON mcr.cod_mart = mpm.cod_mart AND mcr.partita_mag = mpm.partita_mag\n" +
|
||||
" INNER JOIN partite ON mcr.cod_mart = partite.cod_mart AND mpm.partita_mag_prod = partite.partita_mag_prod\n" +
|
||||
" AND mtb_colt.cod_jfas = partite.cod_jfas\n" +
|
||||
"WHERE mtb_colt.gestione = [gestione]\n" +
|
||||
" AND segno = %s",
|
||||
dataOrd,
|
||||
numOrd,
|
||||
segno
|
||||
).replace("[gestione]", UtilityDB.valueToString(gestione));
|
||||
"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 [partitaMag] = mpm.partita_mag\n" +
|
||||
" WHERE dot.data_ord = %s\n" +
|
||||
" AND dot.num_ord = %s\n" +
|
||||
" AND dot.gestione = [gestione])\n" +
|
||||
"SELECT ISNULL(MAX(progressivo_ul), 0) AS progressivo_ul\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr mcr ON mtb_colt.gestione = mcr.gestione AND mtb_colt.data_collo = mcr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mcr.ser_collo AND mtb_colt.num_collo = mcr.num_collo\n" +
|
||||
" INNER JOIN mtb_partita_mag mpm ON mcr.cod_mart = mpm.cod_mart AND mcr.partita_mag = mpm.partita_mag\n" +
|
||||
" INNER JOIN partite ON mcr.cod_mart = partite.cod_mart AND mpm.partita_mag_prod = partite.partita_mag_prod\n" +
|
||||
" AND mtb_colt.cod_jfas = partite.cod_jfas\n" +
|
||||
"WHERE mtb_colt.gestione = [gestione]\n" +
|
||||
" AND segno = %s",
|
||||
dataOrd,
|
||||
numOrd,
|
||||
segno
|
||||
)
|
||||
.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;
|
||||
@@ -1331,12 +1344,12 @@ public class CommonRules extends QueryRules {
|
||||
public static boolean getChkCompatibilitaCarat(Connection connection, String codMart, String carat) throws SQLException {
|
||||
String sql =
|
||||
Query.format("SELECT chk_compatibilita\n" +
|
||||
"FROM mtb_aart\n" +
|
||||
" INNER JOIN mtb_tipi_carat ON mtb_aart.cod_mtip = mtb_tipi_carat.cod_mtip AND\n" +
|
||||
" mtb_aart.cod_mstp = mtb_tipi_carat.cod_mstp\n" +
|
||||
"WHERE mtb_aart.cod_mart = %s\n" +
|
||||
" AND mtb_tipi_carat.carat = %s\n" ,
|
||||
codMart, carat);
|
||||
"FROM mtb_aart\n" +
|
||||
" INNER JOIN mtb_tipi_carat ON mtb_aart.cod_mtip = mtb_tipi_carat.cod_mtip AND\n" +
|
||||
" mtb_aart.cod_mstp = mtb_tipi_carat.cod_mstp\n" +
|
||||
"WHERE mtb_aart.cod_mart = %s\n" +
|
||||
" AND mtb_tipi_carat.carat = %s\n",
|
||||
codMart, carat);
|
||||
|
||||
Boolean chkCompatibilita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
if (chkCompatibilita == null) chkCompatibilita = false;
|
||||
|
||||
@@ -2,7 +2,6 @@ package it.integry.ems.rules.completing;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.rules.businessLogic.enums.TipoEmissione;
|
||||
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
@@ -11,7 +10,6 @@ import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity.common.DtbBaseDocT;
|
||||
import it.integry.ems_model.entity.common.DtbDocOrdT;
|
||||
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;
|
||||
@@ -20,8 +18,8 @@ import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DocumentRules extends QueryRules {
|
||||
@@ -588,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;
|
||||
|
||||
|
||||
@@ -509,9 +509,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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
@@ -517,7 +520,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";
|
||||
|
||||
@@ -113,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,10 +6,9 @@ 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.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
@@ -19,7 +18,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 +101,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 +199,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 +215,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 +405,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;
|
||||
}
|
||||
@@ -665,7 +685,10 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
}
|
||||
|
||||
public boolean hasDocument() {
|
||||
return !(UtilityString.isNullOrEmpty(getCodDtip()) && UtilityString.isNullOrEmpty(getSerDoc()) && getNumDoc() == null && getDataDoc() == null);
|
||||
return !(UtilityString.isNullOrEmpty(getCodDtip()) &&
|
||||
UtilityString.isNullOrEmpty(getSerDoc()) &&
|
||||
UtilityInteger.isNull(getNumDoc()) &&
|
||||
UtilityLocalDate.isNull(getDataDoc()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -693,17 +716,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);
|
||||
@@ -738,7 +779,7 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
if (this == other)
|
||||
return true;
|
||||
|
||||
if(hashCodeKey() != other.hashCodeKey())
|
||||
if (hashCodeKey() != other.hashCodeKey())
|
||||
return false;
|
||||
|
||||
return Objects.equals(getGestione(), other.getGestione()) && Objects.equals(getDataCollo(), other.getDataCollo()) && Objects.equals(getSerCollo(), other.getSerCollo()) && Objects.equals(getNumCollo(), other.getNumCollo());
|
||||
@@ -762,15 +803,15 @@ public class MtbColt extends EntityBase implements EquatableEntityInterface<MtbC
|
||||
return Objects.hash(getGestione(), getDataCollo(), getSerCollo(), getNumCollo(), getRifOrd(), getCodAnag(), getCodVdes(), getCodMdep(), getCodVlis(), getCodDtip(), getCodTcol(), getSerDoc(), getFiltroOrdini(), getPreparatoDa(), getAnnotazioni(), getPosizione(), getCodDtipProvv(), getSerDocProvv(), getCodJfas(), getDataOrd(), getDataDoc(), getOraInizPrep(), getOraFinePrep(), getDataDocProvv(), getDataVers(), getSegno(), getNumOrd(), getNumDoc(), getNumDocProvv(), getPesoKg(), getLunghezzaCm(), getLarghezzaCm(), getAltezzaCm(), getPesoNettoKg(), getDataDistribuzione(), getFlagColloAnonimo(), getFlagStampato(), getActivityId(), getTrackNumber(), getDataIns(), getModificatoDa(), getDataUltMod(), getIdLotto(), getBarcodeUl(), getIdPesata(), getInsPartitaMag(), getStpPrz(), getCalcPeso());
|
||||
}
|
||||
|
||||
public static MtbColt fromMtbColr(MtbColr mtbColr){
|
||||
return new MtbColt(mtbColr.getGestione(),mtbColr.getDataCollo(),mtbColr.getNumCollo(),mtbColr.getSerCollo());
|
||||
public static MtbColt fromMtbColr(MtbColr mtbColr) {
|
||||
return new MtbColt(mtbColr.getGestione(), mtbColr.getDataCollo(), mtbColr.getNumCollo(), mtbColr.getSerCollo());
|
||||
}
|
||||
|
||||
public DtbOrdt getOrdine(){
|
||||
if (UtilityEntity.anyNull(this.getGestione(),this.getDataOrd(),this.getNumOrd())){
|
||||
public DtbOrdt getOrdine() {
|
||||
if (UtilityEntity.anyNull(this.getGestione(), this.getDataOrd(), this.getNumOrd())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DtbOrdt(this.getGestione(),this.getDataOrd(),this.getNumOrd());
|
||||
return new DtbOrdt(this.getGestione(), this.getDataOrd(), this.getNumOrd());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,17 +1,33 @@
|
||||
package it.integry.ems_model.utility;
|
||||
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
|
||||
public class UtilityInteger {
|
||||
|
||||
public static boolean isNull(Integer nullableValue) {
|
||||
return nullableValue == null || nullableValue.equals(EmsRestConstants.INTEGER_NULL);
|
||||
}
|
||||
|
||||
public static Integer isNull(Integer valOrig, Integer valDef) {
|
||||
return valOrig==null?valDef:valOrig;
|
||||
return isNull(valOrig) ? valDef : valOrig;
|
||||
}
|
||||
|
||||
public static boolean isNullOrZero(Integer numCollo) {
|
||||
return numCollo == null || numCollo == 0;
|
||||
return isNull(numCollo) || numCollo == 0;
|
||||
}
|
||||
|
||||
public static Integer stringToInteger(String str) {
|
||||
if (!UtilityString.isNullOrEmpty(str)) { return Integer.parseInt(str); }
|
||||
if (!UtilityString.isNullOrEmpty(str)) {
|
||||
return Integer.parseInt(str);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int lowerBetween(Integer value, Integer compare) {
|
||||
if (value == null && compare == null) return 0;
|
||||
if (value == null) return compare;
|
||||
if (compare == null) return value;
|
||||
return Math.min(value, compare);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.ems_model.utility;
|
||||
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -159,6 +161,15 @@ public class UtilityLocalDate {
|
||||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
public static boolean isNull(LocalDate dateToCheck) {
|
||||
return dateToCheck == null || dateToCheck.equals(EmsRestConstants.LOCAL_DATE_NULL) ;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -71,10 +71,10 @@ rule "deleteDatiDocValV"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$docT : DtbDoct(previstaFat == "S" && serDocVal != null && numDoc != null && codDtipVal != null &&
|
||||
serDoc == serDocVal &&
|
||||
numDoc == numDocVal && dataDoc == dataDocVal &&
|
||||
codDtip == 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),
|
||||
|
||||
@@ -146,5 +146,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 {
|
||||
printerService.printReportType(reportTypeDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(configuration, e);
|
||||
}
|
||||
@RequestBody ReportTypeDTO reportTypeDTO) throws Exception {
|
||||
printerService.printReportType(reportTypeDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_SETUP_REPORT_TYPE, method = RequestMethod.POST)
|
||||
|
||||
@@ -56,7 +56,7 @@ public class RossoGarganoSyncService {
|
||||
public void sync() throws Exception {
|
||||
int timingId = UtilityTiming.startNewTiming("Sync RossoGargano");
|
||||
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager("ROSSOGARGANOEXCHANGE")) {
|
||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager("ROSSOGARGANO_EXCHANGE")) {
|
||||
saveCtbCaus(mdb.getPrimaryConnection());
|
||||
UtilityTiming.intervalTiming(timingId, "Importazione causali");
|
||||
|
||||
|
||||
@@ -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(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam("externalProfileDb") String externalProfileDB) {
|
||||
try {
|
||||
rossoGarganoProductionService.syncCertificati(externalProfileDB);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
@@ -51,4 +51,50 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/fix_versamenti_ribaltatori", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse fixVersamentiRibaltatori(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam Long batchSize
|
||||
) throws Exception {
|
||||
|
||||
try {
|
||||
rossoGarganoProductionService.fixVersamentiRibaltatori(batchSize);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package it.integry.ems.customizations.production.dto.ROSSOGARGANO;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class VersamentoPomodoroDTO {
|
||||
|
||||
@SqlField("data_collo")
|
||||
private LocalDate dataCollo;
|
||||
|
||||
@SqlField("ser_Collo")
|
||||
private String serCollo;
|
||||
|
||||
@SqlField("gestione")
|
||||
private String gestione;
|
||||
|
||||
@SqlField("num_collo")
|
||||
private Integer numCollo;
|
||||
|
||||
@SqlField("cod_mdep")
|
||||
private String codMdep;
|
||||
|
||||
@SqlField("cod_jfas")
|
||||
private String codJfas;
|
||||
|
||||
@SqlField("posizione")
|
||||
private String posizione;
|
||||
|
||||
@SqlField("cod_mart")
|
||||
private String codMart;
|
||||
|
||||
@SqlField("ora_iniz_prep")
|
||||
private LocalDateTime oraInizPrep;
|
||||
|
||||
@SqlField("ora_fine_prep")
|
||||
private LocalDateTime oraFinePrep;
|
||||
|
||||
@SqlField("qta_vers")
|
||||
private BigDecimal qtaVers;
|
||||
|
||||
@SqlField("num_cnf_vers")
|
||||
private BigDecimal numCnfVers;
|
||||
|
||||
@SqlField("barcode_ul")
|
||||
private String barcodeUl;
|
||||
|
||||
@SqlField("partita_mag")
|
||||
private String partitaMag;
|
||||
|
||||
@SqlField("qta_cnf")
|
||||
private BigDecimal qtaCnf;
|
||||
|
||||
public LocalDate getDataCollo() {
|
||||
return dataCollo;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setDataCollo(LocalDate dataCollo) {
|
||||
this.dataCollo = dataCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSerCollo() {
|
||||
return serCollo;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setSerCollo(String serCollo) {
|
||||
this.serCollo = serCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGestione() {
|
||||
return gestione;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setGestione(String gestione) {
|
||||
this.gestione = gestione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNumCollo() {
|
||||
return numCollo;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setNumCollo(Integer numCollo) {
|
||||
this.numCollo = numCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJfas() {
|
||||
return codJfas;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setCodJfas(String codJfas) {
|
||||
this.codJfas = codJfas;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPosizione() {
|
||||
return posizione;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setPosizione(String posizione) {
|
||||
this.posizione = posizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getOraInizPrep() {
|
||||
return oraInizPrep;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setOraInizPrep(LocalDateTime oraInizPrep) {
|
||||
this.oraInizPrep = oraInizPrep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getOraFinePrep() {
|
||||
return oraFinePrep;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setOraFinePrep(LocalDateTime oraFinePrep) {
|
||||
this.oraFinePrep = oraFinePrep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaVers() {
|
||||
return qtaVers;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setQtaVers(BigDecimal qtaVers) {
|
||||
this.qtaVers = qtaVers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getNumCnfVers() {
|
||||
return numCnfVers;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setNumCnfVers(BigDecimal numCnfVers) {
|
||||
this.numCnfVers = numCnfVers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcodeUl() {
|
||||
return barcodeUl;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setBarcodeUl(String barcodeUl) {
|
||||
this.barcodeUl = barcodeUl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaCnf() {
|
||||
return qtaCnf;
|
||||
}
|
||||
|
||||
public VersamentoPomodoroDTO setQtaCnf(BigDecimal qtaCnf) {
|
||||
this.qtaCnf = qtaCnf;
|
||||
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,32 @@
|
||||
package it.integry.ems.customizations.production.service;
|
||||
|
||||
import it.integry.ems.customizations.production.dto.ROSSOGARGANO.SaveCqPomodoriRGDTO;
|
||||
import it.integry.ems.customizations.production.dto.ROSSOGARGANO.VersamentoPomodoroDTO;
|
||||
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.MagazzinoBufferVersamentoMaterialeEditRequestDTO;
|
||||
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.retail.wms.generic.service.WMSMagazzinoBufferService;
|
||||
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.service.SetupGest;
|
||||
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 +36,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,10 +60,22 @@ 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();
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
@Autowired
|
||||
private WMSMagazzinoBufferService wmsMagazzinoBufferService;
|
||||
|
||||
public void syncCertificati(String externalProfileDb) throws Exception {
|
||||
try (MultiDBTransactionManager externalTransactionManager = new MultiDBTransactionManager(externalProfileDb)) {
|
||||
@@ -379,4 +406,127 @@ 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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void fixVersamentiRibaltatori(Long batchSize) throws Exception {
|
||||
if (batchSize == null)
|
||||
batchSize = 10L;
|
||||
|
||||
String sqlColliDaCorreggere = "select mvw_sitart_udc_det_inventario.*\n" +
|
||||
"from mvw_sitart_udc_det_inventario\n" +
|
||||
" inner join mtb_colt on mtb_colt.data_collo = mvw_sitart_udc_det_inventario.data_collo and\n" +
|
||||
" mtb_colt.ser_collo = mvw_sitart_udc_det_inventario.ser_collo and\n" +
|
||||
" mtb_colt.gestione = mvw_sitart_udc_det_inventario.gestione and\n" +
|
||||
" mtb_colt.num_collo = mvw_sitart_udc_det_inventario.num_collo\n" +
|
||||
" inner join dtb_ordt on dtb_ordt.data_ord = mtb_colt.data_ord and dtb_ordt.num_ord = mtb_colt.num_ord and\n" +
|
||||
" dtb_ordt.gestione = mtb_colt.gestione\n" +
|
||||
"\n" +
|
||||
"where mtb_colt.gestione = 'L' and mtb_colt.segno = 1\n" +
|
||||
" and mvw_sitart_udc_det_inventario.qta_col > 0\n" +
|
||||
"and mvw_sitart_udc_det_inventario.num_cnf < 1\n" +
|
||||
"and dtb_ordt.cod_jfas = (select top 1 value from stb_gest_setup where gest_name = 'w_lpianoprod_rc' and section = 'SETUP' and key_section = 'FASE_RACC')\n" +
|
||||
"and mtb_colt.data_collo > '2025-07-01'";
|
||||
|
||||
|
||||
List<MvwSitArtUdcDetInventarioDTO> ulsToFix = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sqlColliDaCorreggere, MvwSitArtUdcDetInventarioDTO.class);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(ulsToFix)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ulsToFix = ulsToFix.subList(0, Math.min(ulsToFix.size(), batchSize.intValue()));
|
||||
|
||||
for (MvwSitArtUdcDetInventarioDTO ul : ulsToFix) {
|
||||
String sqlVersamenti = "SELECT mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_Collo,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colt.cod_jfas,\n" +
|
||||
" ISNULL(mtb_colt.posizione, mtb_colt.cod_jfas) AS posizione,\n" +
|
||||
" mtb_colr.cod_mart,\n" +
|
||||
" mtb_Colt.ora_iniz_prep,\n" +
|
||||
" mtb_Colt.ora_fine_prep,\n" +
|
||||
" SUM(qta_col) AS qta_vers,\n" +
|
||||
" SUM(num_cnf) AS num_cnf_vers,\n" +
|
||||
" mtb_colr.barcode_ul_out as barcode_ul,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" mtb_colr.qta_cnf\n" +
|
||||
"\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr\n" +
|
||||
" ON mtb_colr.data_collo = mtb_colt.data_collo AND mtb_Colt.ser_collo = mtb_colr.ser_collo AND\n" +
|
||||
" mtb_colr.gestione = mtb_colt.gestione AND mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
"WHERE mtb_colr.gestione = 'L'\n" +
|
||||
" AND segno = -1\n" +
|
||||
" AND mtb_colr.barcode_ul_out = {barcode}\n" +
|
||||
" AND ISNULL(mtb_colr.barcode_ul_in,'') <> {barcode}\n" +
|
||||
"GROUP BY mtb_Colt.ora_fine_prep, mtb_Colt.ora_iniz_prep, mtb_colr.cod_mart, mtb_colt.cod_jfas, mtb_colt.num_collo,\n" +
|
||||
" mtb_colt.gestione, mtb_colt.ser_Collo, mtb_colt.data_collo, mtb_colt.cod_mdep,\n" +
|
||||
" mtb_colr.barcode_ul_out,\n" +
|
||||
" mtb_colr.partita_mag, mtb_colr.qta_cnf, mtb_colt.posizione";
|
||||
|
||||
|
||||
List<VersamentoPomodoroDTO> versamentoPomodoroDTOList = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sqlVersamenti.replaceAll("\\{barcode\\}", UtilityDB.valueToString(ul.getBarcodeUl())), VersamentoPomodoroDTO.class);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(versamentoPomodoroDTOList)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wmsMagazzinoBufferService.editVersamentoMateriale(versamentoPomodoroDTOList.stream().map(x -> new MagazzinoBufferVersamentoMaterialeEditRequestDTO()
|
||||
.setBarcodeUl(ul.getBarcodeUl())
|
||||
.setCodMart(ul.getCodMart())
|
||||
.setNumCnfVers(x.getNumCnfVers())
|
||||
.setPartitaMag(ul.getPartitaMag())
|
||||
.setDataCollo(x.getDataCollo())
|
||||
.setSerCollo(x.getSerCollo())
|
||||
.setGestione(x.getGestione())
|
||||
.setNumCollo(x.getNumCollo())
|
||||
.setCodJfas(x.getCodJfas())
|
||||
.setPosizione(x.getPosizione())
|
||||
.setCodMdep(x.getCodMdep())
|
||||
.setOraFinePrep(x.getOraFinePrep())
|
||||
.setOraInizPrep(x.getOraInizPrep())).collect(Collectors.toList()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.save(dtbDoct, true));
|
||||
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 {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.save(dtbDoct, false));
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.save(dtbDoct, false));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "delete", method = RequestMethod.POST)
|
||||
@@ -42,15 +57,24 @@ public class DocumentiDirettiController {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody DtbDoct dtbDoct) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.delete(dtbDoct));
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.delete(dtbDoct));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "createULFromDocument", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse createULFromDocument(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody CreateULFromDocumentsDTO CreateULFromDocuments) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.createULFromDocument(CreateULFromDocuments));
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody CreateULFromDocumentsDTO CreateULFromDocuments) throws Exception {
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(documentiDirettiService.createULFromDocument(CreateULFromDocuments));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 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 ->
|
||||
{
|
||||
x.setPesoProduzione(BigDecimal.valueOf(100).multiply(x.getQuantita()).divide(qtaProdotta, 3, RoundingMode.HALF_EVEN));
|
||||
x.setOrdine(ordine);
|
||||
}
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -58,10 +58,10 @@ public class ColliImporter extends BaseEntityImporter implements IEntityImporter
|
||||
entities = context.getBean(ColliBaioneImportService.class).importColli(type, format, requestDto, anomalie);
|
||||
break;
|
||||
case EVIOSYS:
|
||||
entities = context.getBean(ColliEviosysImportService.class).importColliEviosys(type, format, requestDto);
|
||||
entities = context.getBean(ColliEviosysImportService.class).importColliEviosys(type, format, requestDto, anomalie);
|
||||
break;
|
||||
case SONOCO:
|
||||
entities = context.getBean(ColliEviosysImportService.class).importColliSonoco(type, format, requestDto);
|
||||
entities = context.getBean(ColliEviosysImportService.class).importColliSonoco(type, format, requestDto, anomalie);
|
||||
break;
|
||||
case DESADV:
|
||||
entities = context.getBean(ColliImportService.class).importColliFromDesadv(type, format, requestDto, anomalie);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -6,10 +6,12 @@ import it.integry.ems.retail.wms.accettazione.service.WMSAccettazioneService;
|
||||
import it.integry.ems.retail.wms.dto.CloseUDCRequestDTO;
|
||||
import it.integry.ems.retail.wms.dto.CreateUDCRequestDTO;
|
||||
import it.integry.ems.retail.wms.dto.InsertUDCRowRequestDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.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;
|
||||
@@ -30,6 +32,9 @@ import static java.util.stream.StreamSupport.stream;
|
||||
@Scope(value = "request")
|
||||
public class ColliEviosysImportService {
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@@ -39,7 +44,7 @@ public class ColliEviosysImportService {
|
||||
@Autowired
|
||||
private WMSAccettazioneService wmsAccettazioneService;
|
||||
|
||||
public List<EntityBase> importColliEviosys(String type, String format, ImportRequestDTO requestDTO) throws Exception {
|
||||
public List<EntityBase> importColliEviosys(String type, String format, ImportRequestDTO requestDTO, List<AnomalieDTO> anomalie) throws Exception {
|
||||
List<EntityBase> entityBases = new ArrayList<>();
|
||||
Map<String, String> setup = setupGest.getImportSetupSection(multiDBTransactionManager.getPrimaryConnection(), type, format);
|
||||
|
||||
@@ -82,7 +87,8 @@ public class ColliEviosysImportService {
|
||||
.replace(".", "")
|
||||
);
|
||||
|
||||
entityBases.add(ImportCore(barcodeUl, codAnag, codMart, lotto, qta));
|
||||
EntityBase entityBase = ImportCore(barcodeUl, codAnag, codMart, lotto, qta, anomalie);
|
||||
if (entityBase != null) entityBases.add(entityBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +97,7 @@ public class ColliEviosysImportService {
|
||||
return entityBases;
|
||||
}
|
||||
|
||||
public List<EntityBase> importColliSonoco(String type, String format, ImportRequestDTO requestDTO) throws Exception {
|
||||
public List<EntityBase> importColliSonoco(String type, String format, ImportRequestDTO requestDTO, List<AnomalieDTO> anomalie) throws Exception {
|
||||
List<EntityBase> entityBases = new ArrayList<>();
|
||||
Map<String, String> setup = setupGest.getImportSetupSection(multiDBTransactionManager.getPrimaryConnection(), type, format);
|
||||
String codAnag = setup.get("COD_ANAG");
|
||||
@@ -100,21 +106,23 @@ public class ColliEviosysImportService {
|
||||
while (rowIterator.hasNext()) {
|
||||
Row row = rowIterator.next();
|
||||
|
||||
entityBases.add(
|
||||
ImportCore(
|
||||
UtilityExcel.getCellAsString(row, 0, true), // barcodeUl
|
||||
codAnag,
|
||||
UtilityExcel.getCellAsString(row, 1, true), // codMart
|
||||
UtilityExcel.getCellAsString(row, 7, true), // lotto
|
||||
UtilityString.stringToBigDecimal(UtilityExcel.getCellAsString(row, 3, true)) // qta
|
||||
)
|
||||
EntityBase entityBase = ImportCore(
|
||||
UtilityExcel.getCellAsString(row, 0, true), // barcodeUl
|
||||
codAnag,
|
||||
decodeCodArtFor(UtilityExcel.getCellAsString(row, 1, true)), // codMart
|
||||
UtilityExcel.getCellAsString(row, 7, true), // lotto
|
||||
UtilityString.stringToBigDecimal(UtilityExcel.getCellAsString(row, 3, true)), // qta
|
||||
anomalie
|
||||
);
|
||||
|
||||
if (entityBase != null) entityBases.add(entityBase);
|
||||
}
|
||||
|
||||
return entityBases;
|
||||
return entityBases;
|
||||
}
|
||||
|
||||
private EntityBase ImportCore(String barcodeUl, String codAnag, String codMart, String lotto, BigDecimal qta) throws Exception {
|
||||
private EntityBase ImportCore(String barcodeUl, String codAnag, String codMart, String lotto, BigDecimal qta, List<AnomalieDTO> anomalie) throws Exception {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
barcodeUl = barcodeUl.replace("*", "");
|
||||
|
||||
if (barcodeUl.length() > 18)
|
||||
@@ -141,36 +149,88 @@ public class ColliEviosysImportService {
|
||||
"WHERE dr = 1",
|
||||
codAnag, codMart, new Date()
|
||||
);
|
||||
DtbOrdr dtbOrdr = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbOrdr.class);
|
||||
DtbOrdr dtbOrdr = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, DtbOrdr.class);
|
||||
|
||||
if (dtbOrdr == null)
|
||||
throw new Exception("Nessun ordine trovato per il codice anagrafica: " + codAnag + " e codice articolo: " + codMart);
|
||||
else if (dtbOrdr.getCodMdep() == null)
|
||||
throw new Exception("Nessun deposito trovato per l'ordine: " + dtbOrdr.getNumOrd() + " del cliente: " + codAnag);
|
||||
|
||||
MtbColt udc = wmsAccettazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodMdep(dtbOrdr.getCodMdep())
|
||||
.setCodAnag(codAnag)
|
||||
.setBarcodeUl(barcodeUl)
|
||||
.setDataCollo(LocalDate.now())
|
||||
sql = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE barcode_ul = %s",
|
||||
barcodeUl
|
||||
);
|
||||
MtbColt mtbColt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColt.class);
|
||||
MtbColr mtbColr = null;
|
||||
|
||||
udc.getMtbCols().forEach(x -> x.setOperation(OperationType.NO_OP));
|
||||
if (mtbColt != null) {
|
||||
mtbColt.setOperation(OperationType.NO_OP);
|
||||
|
||||
wmsAccettazioneService.insertUDCRow(
|
||||
new InsertUDCRowRequestDTO()
|
||||
.setTargetMtbColt(udc)
|
||||
.setCodMart(codMart)
|
||||
.setPartitaMag(lotto)
|
||||
.setQtaTot(qta)
|
||||
if (mtbColt.getNumDoc() != null && mtbColt.getSerDoc() != null && mtbColt.getDataDoc() != null){
|
||||
anomalie.add(AnomalieDTO.warning("Il barcode " + barcodeUl + " è già stato dichiarato in un collo"));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mtbColt.getDataOrd() != null && mtbColt.getNumOrd() != null) {
|
||||
anomalie.add(AnomalieDTO.warning("Il barcode " + barcodeUl + " è già stato dichiarato in un collo"));
|
||||
return null;
|
||||
} else {
|
||||
mtbColt.setCodAnag(codAnag)
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd())
|
||||
);
|
||||
wmsAccettazioneService.closeUDC(new CloseUDCRequestDTO().setMtbColt(udc));
|
||||
.setNumOrd(dtbOrdr.getNumOrd());
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
return udc;
|
||||
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 = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColr.class);
|
||||
} else {
|
||||
mtbColt = wmsAccettazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodMdep(dtbOrdr.getCodMdep())
|
||||
.setCodAnag(codAnag)
|
||||
.setBarcodeUl(barcodeUl)
|
||||
.setDataCollo(LocalDate.now())
|
||||
);
|
||||
mtbColt.getMtbCols().forEach(x -> x.setOperation(OperationType.NO_OP));
|
||||
}
|
||||
|
||||
if (mtbColr != null) {
|
||||
mtbColr.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd());
|
||||
mtbColr.setOperation(OperationType.UPDATE);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
entityProcessor.processEntity(mtbColt, multiDBTransactionManager);
|
||||
} else {
|
||||
wmsAccettazioneService.insertUDCRow(
|
||||
new InsertUDCRowRequestDTO()
|
||||
.setTargetMtbColt(mtbColt)
|
||||
.setCodMart(codMart)
|
||||
.setPartitaMag(lotto)
|
||||
.setQtaTot(qta)
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
wmsAccettazioneService.closeUDC(new CloseUDCRequestDTO().setMtbColt(mtbColt));
|
||||
return mtbColt;
|
||||
}
|
||||
|
||||
private Object cellToString(Cell cell) {
|
||||
@@ -219,10 +279,16 @@ public class ColliEviosysImportService {
|
||||
return state;
|
||||
}, (s1, s2) -> s1)[1];
|
||||
|
||||
return decodeCodArtFor(codArtFor);
|
||||
}
|
||||
|
||||
private String decodeCodArtFor(String codArtFor) throws Exception {
|
||||
if (codArtFor != null) {
|
||||
String sql = Query.format("SELECT cod_mart FROM mtb_lisa WHERE cod_art_for = %s", codArtFor);
|
||||
String codMart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (codMart == null) throw new Exception("Codice articolo fornitore: " + codArtFor + " non trovato");
|
||||
return codMart;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -518,32 +518,83 @@ public class ColliImportService {
|
||||
);
|
||||
DtbOrdr dtbOrdr = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, DtbOrdr.class);
|
||||
|
||||
MtbColt udc = wmsAccettazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodMdep(dtbOrdr.getCodMdep())
|
||||
.setCodAnag(codAnag)
|
||||
.setBarcodeUl(dettagliLotti.getCodSscc())
|
||||
.setDataCollo(UtilityString.parseLocalDate(vebadDesadv.testataDoc.getDataDDT()))
|
||||
sql = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE barcode_ul = %s",
|
||||
dettagliLotti.getCodSscc()
|
||||
);
|
||||
MtbColt mtbColt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColt.class);
|
||||
MtbColr mtbColr = null;
|
||||
|
||||
udc.getMtbCols().forEach(x -> x.setOperation(OperationType.NO_OP));
|
||||
if (mtbColt != null) {
|
||||
mtbColt.setOperation(OperationType.NO_OP);
|
||||
|
||||
wmsAccettazioneService.insertUDCRow(
|
||||
new InsertUDCRowRequestDTO()
|
||||
.setTargetMtbColt(udc)
|
||||
.setDataScad(UtilityLocalDate.localDateFromDate(dettagliLotti.getDataScad()))
|
||||
.setPartitaMag(dettagliLotti.getLotto())
|
||||
.setBarcode(dettagliLotti.getGtin())
|
||||
.setCodMart(codMart)
|
||||
.setNumCnf(new BigDecimal(dettagliLotti.getQtaSscc()))
|
||||
if (mtbColt.getNumDoc() != null && mtbColt.getSerDoc() != null && mtbColt.getDataDoc() != null) {
|
||||
anomalie.add(AnomalieDTO.warning("Il barcode " + dettagliLotti.getCodSscc() + " è già stato dichiarato in un collo"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mtbColt.getDataOrd() != null && mtbColt.getNumOrd() != null) {
|
||||
anomalie.add(AnomalieDTO.warning("Il barcode " + dettagliLotti.getCodSscc() + " è già stato dichiarato in un collo"));
|
||||
continue;
|
||||
} else {
|
||||
mtbColt.setCodAnag(codAnag)
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd())
|
||||
);
|
||||
.setNumOrd(dtbOrdr.getNumOrd());
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
wmsAccettazioneService.closeUDC(new CloseUDCRequestDTO().setMtbColt(udc));
|
||||
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 = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, sql, MtbColr.class);
|
||||
} else {
|
||||
mtbColt = wmsAccettazioneService.createUDC(
|
||||
new CreateUDCRequestDTO()
|
||||
.setCodMdep(dtbOrdr.getCodMdep())
|
||||
.setCodAnag(codAnag)
|
||||
.setBarcodeUl(dettagliLotti.getCodSscc())
|
||||
.setDataCollo(UtilityString.parseLocalDate(vebadDesadv.testataDoc.getDataDDT()))
|
||||
);
|
||||
|
||||
entityBases.add(udc);
|
||||
mtbColt.getMtbCols().forEach(x -> x.setOperation(OperationType.NO_OP));
|
||||
}
|
||||
|
||||
if (mtbColr != null) {
|
||||
mtbColr.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd());
|
||||
mtbColr.setOperation(OperationType.UPDATE);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
entityProcessor.processEntity(mtbColt, multiDBTransactionManager);
|
||||
} else {
|
||||
wmsAccettazioneService.insertUDCRow(
|
||||
new InsertUDCRowRequestDTO()
|
||||
.setTargetMtbColt(mtbColt)
|
||||
.setDataScad(UtilityLocalDate.localDateFromDate(dettagliLotti.getDataScad()))
|
||||
.setPartitaMag(dettagliLotti.getLotto())
|
||||
.setBarcode(dettagliLotti.getGtin())
|
||||
.setCodMart(codMart)
|
||||
.setNumCnf(new BigDecimal(dettagliLotti.getQtaSscc()))
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(dtbOrdr.getDataOrd()))
|
||||
.setNumOrd(dtbOrdr.getNumOrd())
|
||||
.setRigaOrd(dtbOrdr.getRigaOrd())
|
||||
);
|
||||
}
|
||||
|
||||
wmsAccettazioneService.closeUDC(new CloseUDCRequestDTO().setMtbColt(mtbColt));
|
||||
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())
|
||||
.setDataOrd(importColliProd.getDataOrd())
|
||||
.setNumOrd(importColliProd.getNumOrd())
|
||||
.setGestione(importColliProd.getGestione())
|
||||
.setSegno(1)
|
||||
.setDataVers(dataVers)
|
||||
.setOrders(Collections.singletonList(new CreateUDCRequestOrderDTO()
|
||||
.setDataOrd(importColliProd.getDataOrd())
|
||||
.setNumOrd(importColliProd.getNumOrd())
|
||||
.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"))
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(result, "data_ord")))
|
||||
.setNumOrd(UtilityHashMap.getValueIfExists(result, "num_ord"))
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -99,8 +98,8 @@ public class MesProductionControllerV2 {
|
||||
@RequestParam(required = false) String flagEvaso,
|
||||
@RequestParam(required = false) String codJfas,
|
||||
@RequestParam(required = false) String codAnag,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = "yyyy/MM/dd") LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = "yyyy/MM/dd") LocalDate endDate) throws Exception {
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd", fallbackPatterns = "yyyy/MM/dd") LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd", fallbackPatterns = "yyyy/MM/dd") LocalDate endDate) throws Exception {
|
||||
|
||||
ServiceRestResponse response = new ServiceRestResponse(EsitoType.OK);
|
||||
|
||||
@@ -115,7 +114,7 @@ public class MesProductionControllerV2 {
|
||||
ServiceRestResponse getOrdineLavorazione(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam int numOrd,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = "yyyy/MM/dd") LocalDate dataOrd,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd", fallbackPatterns = "yyyy/MM/dd") LocalDate dataOrd,
|
||||
@RequestParam String gestione,
|
||||
@RequestParam String codJfas
|
||||
) throws Exception {
|
||||
@@ -180,7 +179,7 @@ public class MesProductionControllerV2 {
|
||||
ServiceRestResponse openOrderSteps(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam(required = false, defaultValue = "") String codJfas,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = "yyyy/MM/dd") LocalDate dataOrd,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd", fallbackPatterns = "yyyy/MM/dd") LocalDate dataOrd,
|
||||
@RequestParam Integer numOrd,
|
||||
@RequestParam String gestioneOrd,
|
||||
@RequestParam(required = false, defaultValue = "0") int hrNum,
|
||||
@@ -194,7 +193,7 @@ public class MesProductionControllerV2 {
|
||||
ServiceRestResponse closeOrderSteps(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam(required = false, defaultValue = "") String codJfas,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd",fallbackPatterns = "yyyy/MM/dd") LocalDate dataOrd,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd", fallbackPatterns = "yyyy/MM/dd") LocalDate dataOrd,
|
||||
@RequestParam Integer numOrd,
|
||||
@RequestParam String gestioneOrd,
|
||||
@RequestParam(required = false) Integer idStep,
|
||||
@@ -478,6 +477,7 @@ public class MesProductionControllerV2 {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PostMapping(value = "ordine/ripianifica")
|
||||
public @ResponseBody
|
||||
ServiceRestResponse ripianifica(@RequestBody RipianificaOrdineLavRequestDTO dto) throws Exception {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package it.integry.ems.production.controller;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.production.dto.DeleteCaricoDaProduzioneRequestDTO;
|
||||
import it.integry.ems.production.dto.RettificaProdDTO;
|
||||
import it.integry.ems.production.service.ProductionWarehouseService;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -51,19 +51,13 @@ public class ProductionWarehouseController {
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_WAREHOUSE_PRODUCTION_DELETE_COLLO, method = RequestMethod.POST)
|
||||
@RequestMapping(value = EmsRestConstants.PATH_WAREHOUSE_PRODUCTION_DELETE_CARICO, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse deleteColloDaProduzione(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestBody MtbColt mtbColtToDelete) {
|
||||
|
||||
try {
|
||||
warehouseService.deleteColloDaProduzione(mtbColtToDelete);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(profileDB, e);
|
||||
}
|
||||
@RequestBody DeleteCaricoDaProduzioneRequestDTO caricoToDelete) throws Exception {
|
||||
warehouseService.deleteCaricoDaProduzione(caricoToDelete);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package it.integry.ems.production.dto;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ArticoloPartitaCommessaDTO {
|
||||
public class ArticoloPartitaCommessaOrdineDTO {
|
||||
|
||||
private String codMart;
|
||||
private String codJcom;
|
||||
@@ -11,10 +11,10 @@ public class ArticoloPartitaCommessaDTO {
|
||||
private Date dataOrd;
|
||||
private Integer numOrd;
|
||||
|
||||
public ArticoloPartitaCommessaDTO() {
|
||||
public ArticoloPartitaCommessaOrdineDTO() {
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO(String codMart, String codJcom, String partitaMag, Date dataOrd, Integer numOrd) {
|
||||
public ArticoloPartitaCommessaOrdineDTO(String codMart, String codJcom, String partitaMag, Date dataOrd, Integer numOrd) {
|
||||
this.codMart = codMart;
|
||||
this.codJcom = codJcom;
|
||||
this.partitaMag = partitaMag;
|
||||
@@ -26,7 +26,7 @@ public class ArticoloPartitaCommessaDTO {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO setCodMart(String codMart) {
|
||||
public ArticoloPartitaCommessaOrdineDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class ArticoloPartitaCommessaDTO {
|
||||
return codJcom;
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO setCodJcom(String codJcom) {
|
||||
public ArticoloPartitaCommessaOrdineDTO setCodJcom(String codJcom) {
|
||||
this.codJcom = codJcom;
|
||||
return this;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class ArticoloPartitaCommessaDTO {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO setPartitaMag(String partitaMag) {
|
||||
public ArticoloPartitaCommessaOrdineDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class ArticoloPartitaCommessaDTO {
|
||||
return dataOrd;
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO setDataOrd(Date dataOrd) {
|
||||
public ArticoloPartitaCommessaOrdineDTO setDataOrd(Date dataOrd) {
|
||||
this.dataOrd = dataOrd;
|
||||
return this;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class ArticoloPartitaCommessaDTO {
|
||||
return numOrd;
|
||||
}
|
||||
|
||||
public ArticoloPartitaCommessaDTO setNumOrd(Integer numOrd) {
|
||||
public ArticoloPartitaCommessaOrdineDTO setNumOrd(Integer numOrd) {
|
||||
this.numOrd = numOrd;
|
||||
return this;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class ArticoloPartitaCommessaDTO {
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ArticoloPartitaCommessaDTO that = (ArticoloPartitaCommessaDTO) o;
|
||||
ArticoloPartitaCommessaOrdineDTO that = (ArticoloPartitaCommessaOrdineDTO) o;
|
||||
return Objects.equals(getCodMart(), that.getCodMart()) && Objects.equals(getCodJcom(), that.getCodJcom()) && Objects.equals(getPartitaMag(), that.getPartitaMag()) && Objects.equals(getDataOrd(), that.getDataOrd()) && Objects.equals(getNumOrd(), that.getNumOrd());
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ package it.integry.ems.production.dto;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
public class CaricoProdottoFinitoDTO {
|
||||
private String codMart;
|
||||
private BigDecimal qtaCollo;
|
||||
private LocalDate dataOrd;
|
||||
private Date dataCollo;
|
||||
private LocalDate dataCollo;
|
||||
private String gestione;
|
||||
private int numOrd;
|
||||
private int rigaOrd;
|
||||
@@ -28,7 +27,8 @@ public class CaricoProdottoFinitoDTO {
|
||||
private boolean accodaAdEsistenti = true;
|
||||
private boolean segnaQuarantena = false;
|
||||
private LocalDateTime dataVers;
|
||||
|
||||
private String barcodeUl;
|
||||
private String partitaMag;
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
@@ -202,11 +202,11 @@ public class CaricoProdottoFinitoDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataCollo() {
|
||||
public LocalDate getDataCollo() {
|
||||
return dataCollo;
|
||||
}
|
||||
|
||||
public CaricoProdottoFinitoDTO setDataCollo(Date dataCollo) {
|
||||
public CaricoProdottoFinitoDTO setDataCollo(LocalDate dataCollo) {
|
||||
this.dataCollo = dataCollo;
|
||||
return this;
|
||||
}
|
||||
@@ -228,4 +228,22 @@ public class CaricoProdottoFinitoDTO {
|
||||
this.dataVers = dataVers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcodeUl() {
|
||||
return barcodeUl;
|
||||
}
|
||||
|
||||
public CaricoProdottoFinitoDTO setBarcodeUl(String barcodeUl) {
|
||||
this.barcodeUl = barcodeUl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public CaricoProdottoFinitoDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ public class CheckMaterialeBarcodeInOrdineDTO {
|
||||
private String barcode;
|
||||
private String codJfas;
|
||||
private DtbOrdt ordine;
|
||||
private boolean versamentoEnabled = true;
|
||||
|
||||
public String getBarcode() {
|
||||
return barcode;
|
||||
@@ -34,4 +35,13 @@ public class CheckMaterialeBarcodeInOrdineDTO {
|
||||
this.ordine = ordine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isVersamentoEnabled() {
|
||||
return versamentoEnabled;
|
||||
}
|
||||
|
||||
public CheckMaterialeBarcodeInOrdineDTO setVersamentoEnabled(boolean versamentoEnabled) {
|
||||
this.versamentoEnabled = versamentoEnabled;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package it.integry.ems.production.dto;
|
||||
|
||||
public class DeleteCaricoDaProduzioneRequestDTO {
|
||||
|
||||
private String barcodeUl;
|
||||
private String codMart;
|
||||
private String partitaMag;
|
||||
private String codJcom;
|
||||
private String codCol;
|
||||
private String codTagl;
|
||||
|
||||
public String getBarcodeUl() {
|
||||
return barcodeUl;
|
||||
}
|
||||
|
||||
public DeleteCaricoDaProduzioneRequestDTO setBarcodeUl(String barcodeUl) {
|
||||
this.barcodeUl = barcodeUl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public DeleteCaricoDaProduzioneRequestDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public DeleteCaricoDaProduzioneRequestDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJcom() {
|
||||
return codJcom;
|
||||
}
|
||||
|
||||
public DeleteCaricoDaProduzioneRequestDTO setCodJcom(String codJcom) {
|
||||
this.codJcom = codJcom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodCol() {
|
||||
return codCol;
|
||||
}
|
||||
|
||||
public DeleteCaricoDaProduzioneRequestDTO setCodCol(String codCol) {
|
||||
this.codCol = codCol;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodTagl() {
|
||||
return codTagl;
|
||||
}
|
||||
|
||||
public DeleteCaricoDaProduzioneRequestDTO setCodTagl(String codTagl) {
|
||||
this.codTagl = codTagl;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -6,39 +6,61 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class MaterialeVersatoSuOrdineDTO {
|
||||
|
||||
@SqlField("gestione")
|
||||
private String gestione;
|
||||
|
||||
@SqlField("data_collo")
|
||||
private LocalDate dataCollo;
|
||||
|
||||
@SqlField("ser_collo")
|
||||
private String serCollo;
|
||||
|
||||
@SqlField("num_collo")
|
||||
private Integer numCollo;
|
||||
|
||||
@SqlField("num_ord")
|
||||
private Integer numOrd;
|
||||
|
||||
@SqlField("data_ord")
|
||||
private LocalDate dataOrd;
|
||||
|
||||
@SqlField("qta_versata")
|
||||
private BigDecimal qtaVersata;
|
||||
|
||||
@SqlField("partita_mag")
|
||||
private String partitaMag;
|
||||
|
||||
@SqlField("unt_mis")
|
||||
private String untMis;
|
||||
|
||||
@SqlField("cod_mart")
|
||||
private String codMart;
|
||||
|
||||
@SqlField("qta_cnf")
|
||||
private BigDecimal qtaCnf;
|
||||
|
||||
@SqlField("qta_cnf_art")
|
||||
private BigDecimal qtaCnfArt;
|
||||
|
||||
@SqlField("num_Cnf")
|
||||
private BigDecimal numCnf;
|
||||
|
||||
@SqlField("rap_conv2")
|
||||
private BigDecimal rapConv2;
|
||||
|
||||
@SqlField("unt_mis2")
|
||||
private String untMis2;
|
||||
|
||||
@SqlField("descrizione")
|
||||
private String descrizione;
|
||||
|
||||
@SqlField("barcode_ul_in")
|
||||
private String barcodeUlIn;
|
||||
|
||||
@SqlField("barcode_ul_out")
|
||||
private String barcodeUlOut;
|
||||
|
||||
public String getGestione() {
|
||||
return gestione;
|
||||
}
|
||||
@@ -182,4 +204,22 @@ public class MaterialeVersatoSuOrdineDTO {
|
||||
this.qtaCnfArt = qtaCnfArt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcodeUlIn() {
|
||||
return barcodeUlIn;
|
||||
}
|
||||
|
||||
public MaterialeVersatoSuOrdineDTO setBarcodeUlIn(String barcodeUlIn) {
|
||||
this.barcodeUlIn = barcodeUlIn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBarcodeUlOut() {
|
||||
return barcodeUlOut;
|
||||
}
|
||||
|
||||
public MaterialeVersatoSuOrdineDTO setBarcodeUlOut(String barcodeUlOut) {
|
||||
this.barcodeUlOut = barcodeUlOut;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
package it.integry.ems.production.dto;
|
||||
|
||||
import it.integry.ems_model.entity.JtbDistMate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NuovaLavorazioneDTO {
|
||||
private LocalDate dataOrd;
|
||||
private Integer numOrd;
|
||||
private String codJfas;
|
||||
private List<String> codJfasAggiuntivi;
|
||||
private String codAnag;
|
||||
private String codVdes;
|
||||
private String codVzon;
|
||||
private String codTcolUl;
|
||||
private String codMdep;
|
||||
private String codMart;
|
||||
private String partitaMag;
|
||||
private LocalDate dataScadPartitaMag;
|
||||
private LocalDate dataProdPartita;
|
||||
private BigDecimal numCnf;
|
||||
private BigDecimal valUnt;
|
||||
private BigDecimal colliPedana;
|
||||
private BigDecimal qtaOrd;
|
||||
private String untOrd;
|
||||
private List<JtbDistMate> listaMateriali = new ArrayList<>();
|
||||
private String descrizionePartita;
|
||||
private String annotazioni;
|
||||
private String notePartita;
|
||||
|
||||
public LocalDate getDataOrd() {
|
||||
return dataOrd;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setDataOrd(LocalDate dataOrd) {
|
||||
this.dataOrd = dataOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNumOrd() {
|
||||
return numOrd;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setNumOrd(Integer numOrd) {
|
||||
this.numOrd = numOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVdes() {
|
||||
return codVdes;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodVdes(String codVdes) {
|
||||
this.codVdes = codVdes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getNumCnf() {
|
||||
return numCnf;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setNumCnf(BigDecimal numCnf) {
|
||||
this.numCnf = numCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getColliPedana() {
|
||||
return colliPedana;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setColliPedana(BigDecimal colliPedana) {
|
||||
this.colliPedana = colliPedana;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntOrd() {
|
||||
return untOrd;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setUntOrd(String untOrd) {
|
||||
this.untOrd = untOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getValUnt() {
|
||||
return valUnt;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setValUnt(BigDecimal valUnt) {
|
||||
this.valUnt = valUnt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodJfas() {
|
||||
return codJfas;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodJfas(String codJfas) {
|
||||
this.codJfas = codJfas;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getCodJfasAggiuntivi() {
|
||||
return codJfasAggiuntivi;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodJfasAggiuntivi(List<String> codJfasAggiuntivi) {
|
||||
this.codJfasAggiuntivi = codJfasAggiuntivi;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataProdPartita() {
|
||||
return dataProdPartita;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setDataProdPartita(LocalDate dataProdPartita) {
|
||||
this.dataProdPartita = dataProdPartita;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<JtbDistMate> getListaMateriali() {
|
||||
return listaMateriali;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setListaMateriali(List<JtbDistMate> listaMateriali) {
|
||||
this.listaMateriali = listaMateriali;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAnnotazioni() {
|
||||
return annotazioni;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setAnnotazioni(String annotazioni) {
|
||||
this.annotazioni = annotazioni;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizionePartita() {
|
||||
return descrizionePartita;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setDescrizionePartita(String descrizionePartita) {
|
||||
this.descrizionePartita = descrizionePartita;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaOrd() {
|
||||
return qtaOrd;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setQtaOrd(BigDecimal qtaOrd) {
|
||||
this.qtaOrd = qtaOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVzon() {
|
||||
return codVzon;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodVzon(String codVzon) {
|
||||
this.codVzon = codVzon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodTcolUl() {
|
||||
return codTcolUl;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setCodTcolUl(String codTcolUl) {
|
||||
this.codTcolUl = codTcolUl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataScadPartitaMag() {
|
||||
return dataScadPartitaMag;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setDataScadPartitaMag(LocalDate dataScadPartitaMag) {
|
||||
this.dataScadPartitaMag = dataScadPartitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNotePartita() {
|
||||
return notePartita;
|
||||
}
|
||||
|
||||
public NuovaLavorazioneDTO setNotePartita(String notePartita) {
|
||||
this.notePartita = notePartita;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import it.integry.ems.production.dto.*;
|
||||
import it.integry.ems.report.dto.JasperDTO;
|
||||
import it.integry.ems.report.dto.PairsDTO;
|
||||
import it.integry.ems.retail.pvmRetail.service.PvmService;
|
||||
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;
|
||||
@@ -25,6 +26,7 @@ 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.rules.completing.CommonRules;
|
||||
import it.integry.ems.rules.completing.DocumentRules;
|
||||
import it.integry.ems.rules.completing.PartitaMagRules;
|
||||
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
||||
@@ -48,7 +50,6 @@ import it.integry.ems_model.utility.BarcodeEan128.Ean128Model;
|
||||
import it.integry.ems_model.utility.BarcodeEan128.UtilityBarcodeEan128;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -489,7 +490,7 @@ public class MesProductionServiceV2 {
|
||||
&& !UtilityString.isNullOrEmpty(mtbPartitaMagToUpdate.getPartitaMag())) {
|
||||
mtbPartitaMagToUpdate.setOperation(OperationType.UPDATE);
|
||||
|
||||
mtbPartitaMagToUpdate.setDataProd(new Date());
|
||||
mtbPartitaMagToUpdate.setDataProd(LocalDate.now());
|
||||
|
||||
entityProcessor.processEntity(mtbPartitaMagToUpdate, skipCommit, multiDBTransactionManager);
|
||||
}
|
||||
@@ -717,7 +718,7 @@ public class MesProductionServiceV2 {
|
||||
throw new Exception("Non è stato configurato un indirizzo ip per il pannello supervisore ");
|
||||
|
||||
|
||||
if (printerServicePort <= 0 )
|
||||
if (printerServicePort <= 0)
|
||||
throw new Exception("Non è stato configurato una porta per il pannello supervisore ");
|
||||
|
||||
return hmiData;
|
||||
@@ -867,12 +868,12 @@ public class MesProductionServiceV2 {
|
||||
if (UtilityString.isNullOrEmpty(reportName)) {
|
||||
if (firstChildCodMart != null) {
|
||||
|
||||
reportName = wmsLavorazioneService.getEtichettaSSCCArticolo(firstChildCodMart);
|
||||
if (UtilityString.hasContent(reportName)) {
|
||||
logger.debug("Eseguita stampa SSCC del report " + reportName);
|
||||
}else {
|
||||
logger.error("Nessun disegno trovato con il cod_prod " + firstChildCodMart);
|
||||
}
|
||||
reportName = wmsLavorazioneService.getEtichettaSSCCArticolo(firstChildCodMart);
|
||||
if (UtilityString.hasContent(reportName)) {
|
||||
logger.debug("Eseguita stampa SSCC del report " + reportName);
|
||||
} else {
|
||||
logger.error("Nessun disegno trovato con il cod_prod " + firstChildCodMart);
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.error("Il collo " + mtbColtToPrint.getNumCollo() + " del " + CommonConstants.DATETIME_DMY_SLASHED_FORMATTER.format(mtbColtToPrint.getDataCollo()) + " non ha una riga prodotto al suo interno");
|
||||
@@ -922,8 +923,8 @@ public class MesProductionServiceV2 {
|
||||
orientation = Orientation.LANDSCAPE;
|
||||
|
||||
break;
|
||||
default:
|
||||
case AUTO:
|
||||
default:
|
||||
orientation = Orientation.AUTO;
|
||||
|
||||
break;
|
||||
@@ -1079,104 +1080,126 @@ public class MesProductionServiceV2 {
|
||||
dto.setQtaCollo(dto.getColliPedana().multiply(qtaCnf));
|
||||
}
|
||||
|
||||
MtbColt udc = null;
|
||||
MtbColr udcRow;
|
||||
|
||||
DtbOrdSteps stepAttivo = getOrderOpenStepOnFase(ordineLav, dto.getCodJfas());
|
||||
if (stepAttivo != null) {
|
||||
try {
|
||||
DtbOrdSteps stepAttivo = getOrderOpenStepOnFase(ordineLav, dto.getCodJfas());
|
||||
|
||||
int finalStep = getMaxFaseOrdine(ordineLav);
|
||||
ordineLav.setOperation(OperationType.NO_OP);
|
||||
ordineLav.getDtbOrdSteps().add(stepAttivo);
|
||||
stepAttivo.setQtaLav((UtilityBigDecimal.isNull(stepAttivo.getQtaLav(), BigDecimal.ZERO)).add(dto.getQtaCollo().divide(UtilityBigDecimal.isNull(stepAttivo.getRapConvLav(), BigDecimal.ONE), 2, RoundingMode.HALF_UP)));
|
||||
stepAttivo.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(ordineLav, true, multiDBTransactionManager);
|
||||
if (stepAttivo.getNumFase() != finalStep) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MtbColt mtbColtToInsert = null;
|
||||
if (dto.isAccodaAdEsistenti()) {
|
||||
|
||||
String queryMtbColt = "SELECT mtb_colr.datetime_row, mtb_colr.* " +
|
||||
"FROM mtb_colr " +
|
||||
" INNER JOIN mtb_colt mc on mtb_colr.gestione = mc.gestione and mtb_colr.data_collo = mc.data_collo and " +
|
||||
" mtb_colr.ser_collo = mc.ser_collo and mtb_colr.num_collo = mc.num_collo " +
|
||||
"WHERE cod_mdep = " + UtilityDB.valueToString(ordineLav.getCodMdep()) + " " +
|
||||
"AND mc.data_ord = " + UtilityDB.valueToString(ordineLav.getDataOrd()) + " " +
|
||||
"AND mc.num_ord = " + UtilityDB.valueToString(ordineLav.getNumOrd()) + " " +
|
||||
"AND mc.gestione = " + UtilityDB.valueToString(ordineLav.getGestione()) + " " +
|
||||
"AND mc.segno = 1 " +
|
||||
"AND mc.cod_jfas = " + UtilityDB.valueToString(UtilityString.isNull(dto.getCodJfas(), ordineLav.getCodJfas())) + " " +
|
||||
"AND mc.posizione = " + UtilityDB.valueToString(UtilityString.isNull(dto.getPosizione(), ordineLav.getCodJfas())) + " " +
|
||||
"AND mc.data_collo = " + UtilityDB.valueToString(new Date()) + " " +
|
||||
"AND cod_mart = " + UtilityDB.valueToString(ordineLav.getCodProd()) + " " +
|
||||
"ORDER BY mtb_colr.datetime_row DESC";
|
||||
|
||||
List<MtbColt> alreadyPresentMtbColts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), queryMtbColt, MtbColt.class);
|
||||
if (alreadyPresentMtbColts != null && !alreadyPresentMtbColts.isEmpty()) {
|
||||
mtbColtToInsert = alreadyPresentMtbColts.get(0);
|
||||
mtbColtToInsert.setOperation(OperationType.NO_OP);
|
||||
}
|
||||
}
|
||||
|
||||
if (mtbColtToInsert == null) {
|
||||
mtbColtToInsert = new MtbColt()
|
||||
.setMtbColr(new ArrayList<>())
|
||||
.setGestione("L")
|
||||
.setSegno(1)
|
||||
.setCodMdep(UtilityString.isNull(dto.getCodMdep(), ordineLav.getCodMdep()))
|
||||
.setCodJfas(UtilityString.isNull(dto.getCodJfas(), ordineLav.getCodJfas()))
|
||||
.setCodVdes(UtilityString.isNull(dto.getCodVdes(), ordineLav.getCodVdes()))
|
||||
.setCodAnag(ordineLav.getCodAnag())
|
||||
.setPosizione(dto.getCodJfas())
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setCodTcol(ordineLav.getCodTcolUl())
|
||||
.setRifOrd(ordineLav.getRifOrd())
|
||||
.setCodVdes(ordineLav.getCodVdes())
|
||||
.setPreparatoDa(dto.getPreparatoDa())
|
||||
.setNumOrd(dto.getNumOrd());
|
||||
|
||||
if (dto.getDataCollo() != null) {
|
||||
mtbColtToInsert.setDataCollo(UtilityLocalDate.localDateFromDate(dto.getDataCollo()));
|
||||
}
|
||||
if (dto.getDataVers() != null) {
|
||||
mtbColtToInsert.setDataVers(dto.getDataVers());
|
||||
if (stepAttivo != null) {
|
||||
int finalStep = getMaxFaseOrdine(ordineLav);
|
||||
ordineLav.setOperation(OperationType.NO_OP);
|
||||
ordineLav.getDtbOrdSteps().add(stepAttivo);
|
||||
stepAttivo.setQtaLav((UtilityBigDecimal.isNull(stepAttivo.getQtaLav(), BigDecimal.ZERO)).add(dto.getQtaCollo().divide(UtilityBigDecimal.isNull(stepAttivo.getRapConvLav(), BigDecimal.ONE), 2, RoundingMode.HALF_UP)));
|
||||
stepAttivo.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(ordineLav, true, multiDBTransactionManager);
|
||||
if (stepAttivo.getNumFase() != finalStep) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (dto.isSegnaQuarantena()) {
|
||||
String codDtipProvv = setupGest.getSetup("MES", "SETUP", "COD_DTIP_PROVV");
|
||||
LocalDate dataCollo = UtilityLocalDate.isNull(dto.getDataCollo(), UtilityLocalDate.getNow());
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codDtipProvv)) {
|
||||
throw new GestSetupNotFoundException("MES", "SETUP", "COD_DTIP_PROVV");
|
||||
if (dto.isAccodaAdEsistenti()) {
|
||||
String queryMtbColt = "SELECT mtb_colr.* " +
|
||||
"FROM mtb_colr " +
|
||||
" INNER JOIN mtb_colt mc on mtb_colr.gestione = mc.gestione and mtb_colr.data_collo = mc.data_collo and " +
|
||||
" mtb_colr.ser_collo = mc.ser_collo and mtb_colr.num_collo = mc.num_collo " +
|
||||
"WHERE cod_mdep = " + UtilityDB.valueToString(ordineLav.getCodMdep()) + " " +
|
||||
"AND mc.data_ord = " + UtilityDB.valueToString(ordineLav.getDataOrd()) + " " +
|
||||
"AND mc.num_ord = " + UtilityDB.valueToString(ordineLav.getNumOrd()) + " " +
|
||||
"AND mc.gestione = " + UtilityDB.valueToString(ordineLav.getGestione()) + " " +
|
||||
"AND mc.segno = 1 " +
|
||||
"AND mc.cod_jfas = " + UtilityDB.valueToString(UtilityString.isNull(dto.getCodJfas(), ordineLav.getCodJfas())) + " " +
|
||||
"AND mc.posizione = " + UtilityDB.valueToString(UtilityString.isNull(dto.getPosizione(), ordineLav.getCodJfas())) + " " +
|
||||
"AND mc.data_collo = " + UtilityDB.valueToString(dataCollo) + " " +
|
||||
"AND cod_mart = " + UtilityDB.valueToString(ordineLav.getCodProd()) + " " +
|
||||
"ORDER BY mtb_colr.datetime_row DESC";
|
||||
|
||||
List<MtbColt> alreadyPresentMtbColts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), queryMtbColt, MtbColt.class);
|
||||
if (alreadyPresentMtbColts != null && !alreadyPresentMtbColts.isEmpty()) {
|
||||
udc = alreadyPresentMtbColts.get(0);
|
||||
udc.setOperation(OperationType.NO_OP);
|
||||
}
|
||||
}
|
||||
|
||||
if (udc == null) {
|
||||
CreateUDCRequestDTO createUDCRequest = new CreateUDCRequestDTO()
|
||||
.setDataCollo(dataCollo)
|
||||
.setCodMdep(UtilityString.isNull(dto.getCodMdep(), ordineLav.getCodMdep()))
|
||||
.setCodJfas(UtilityString.isNull(dto.getCodJfas(), ordineLav.getCodJfas()))
|
||||
.setCodVdes(UtilityString.isNull(dto.getCodVdes(), ordineLav.getCodVdes()))
|
||||
.setCodAnag(ordineLav.getCodAnag())
|
||||
.setPosizione(dto.getCodJfas())
|
||||
.setBarcodeUl(dto.getBarcodeUl())
|
||||
.setCodTcol(ordineLav.getCodTcolUl())
|
||||
.setOrders(Collections.singletonList(new CreateUDCRequestOrderDTO()
|
||||
.setGestione(dto.getGestione())
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setDataOrd(dto.getDataOrd())));
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(dto.getPartitaMag()) && !dto.getPartitaMag().equalsIgnoreCase(ordineLav.getPartitaMag())) {
|
||||
int progressivoUl = CommonRules.retrieveNextProgressivoUlRG(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
dto.getGestione(),
|
||||
dto.getDataOrd(),
|
||||
dto.getNumOrd(),
|
||||
1,
|
||||
dto.getCodJfas(),
|
||||
dto.getPartitaMag()
|
||||
);
|
||||
|
||||
createUDCRequest.setProgressivoUl(progressivoUl);
|
||||
}
|
||||
|
||||
mtbColtToInsert.setCodDtipProvv(codDtipProvv);
|
||||
udc = wmsLavorazioneService.createUDC(createUDCRequest);
|
||||
|
||||
if (dto.getDataVers() != null) {
|
||||
udc.setDataVers(dto.getDataVers());
|
||||
}
|
||||
|
||||
if (dto.isSegnaQuarantena()) {
|
||||
String codDtipProvv = setupGest.getSetup("MES", "SETUP", "COD_DTIP_PROVV");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codDtipProvv)) {
|
||||
throw new GestSetupNotFoundException("MES", "SETUP", "COD_DTIP_PROVV");
|
||||
}
|
||||
|
||||
udc.setCodDtipProvv(codDtipProvv);
|
||||
}
|
||||
|
||||
udc.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
mtbColtToInsert.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
InsertUDCRowRequestDTO insertUDCRow = new InsertUDCRowRequestDTO()
|
||||
.setTargetMtbColt(udc)
|
||||
.setCodMart(ordineLav.getCodProd())
|
||||
.setPartitaMag(UtilityString.isNull(dto.getPartitaMag(), ordineLav.getPartitaMag()))
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setRigaOrd(UtilityInteger.isNull(dto.getRigaOrd(), 0))
|
||||
.setCodJcom(ordineLav.getCodJcom())
|
||||
.setQtaTot(dto.getQtaCollo());
|
||||
|
||||
final InsertUDCRowResponseDTO insertRowResponse = wmsAccettazioneService.insertUDCRow(insertUDCRow);
|
||||
|
||||
udcRow = insertRowResponse.getSavedMtbColr()
|
||||
.setNumEtich(dto.getNumEtich())
|
||||
.setNote(dto.getNote());
|
||||
|
||||
udcRow.setOperation(OperationType.UPDATE);
|
||||
|
||||
if (dto.getDataVers() != null) {
|
||||
udcRow.setDatetimeRow(dto.getDataVers());
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(udc, true, multiDBTransactionManager);
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
MtbColr mtbColrToInsert = new MtbColr()
|
||||
.setCodJcom(ordineLav.getCodJcom())
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setCodMart(ordineLav.getCodProd())
|
||||
.setPartitaMag(ordineLav.getPartitaMag())
|
||||
.setRigaOrd(UtilityInteger.isNull(dto.getRigaOrd(), 0))
|
||||
.setNumEtich(dto.getNumEtich())
|
||||
.setNote(dto.getNote())
|
||||
.setQtaCol(dto.getQtaCollo());
|
||||
if (dto.getDataVers() != null) {
|
||||
mtbColrToInsert.setDatetimeRow(dto.getDataVers());
|
||||
}
|
||||
|
||||
mtbColrToInsert.setOperation(OperationType.INSERT);
|
||||
mtbColtToInsert.getMtbColr().add(mtbColrToInsert);
|
||||
|
||||
entityProcessor.processEntity(mtbColtToInsert, true, multiDBTransactionManager);
|
||||
|
||||
if (dto.isSegnaQuarantena()) {
|
||||
String indirizziQuarantena = setupGest.getSetup("MES", "MAIL", "INDIRIZZI_QUARANTENA");
|
||||
|
||||
@@ -1188,14 +1211,14 @@ public class MesProductionServiceV2 {
|
||||
}
|
||||
|
||||
testoMailQuarantena = testoMailQuarantena
|
||||
.replace("[codMdep]", mtbColtToInsert.getCodMdep())
|
||||
.replace("[dataCollo]", UtilityLocalDate.formatDate(mtbColtToInsert.getDataCollo(), CommonConstants.DATE_FORMAT_DMY))
|
||||
.replace("[numCollo]", String.valueOf(mtbColtToInsert.getNumCollo()))
|
||||
.replace("[codMdep]", udc.getCodMdep())
|
||||
.replace("[dataCollo]", UtilityLocalDate.formatDate(udc.getDataCollo(), CommonConstants.DATE_FORMAT_DMY))
|
||||
.replace("[numCollo]", String.valueOf(udc.getNumCollo()))
|
||||
.replace("[articolo]", String.format("%s - %s", mtbAart.getCodMart(), mtbAart.getDescrizione()))
|
||||
.replace("[partitaMag]", mtbColrToInsert.getPartitaMag())
|
||||
.replace("[qtaCol]", UtilityString.bigDecimalToString(mtbColrToInsert.getQtaCol(), "#,###"))
|
||||
.replace("[numCnf]", UtilityString.bigDecimalToString(mtbColrToInsert.getNumCnf(), "#,###"))
|
||||
.replace("[posizione]", mtbColtToInsert.getPosizione());
|
||||
.replace("[partitaMag]", udcRow.getPartitaMag())
|
||||
.replace("[qtaCol]", UtilityString.bigDecimalToString(udcRow.getQtaCol(), "#,###"))
|
||||
.replace("[numCnf]", UtilityString.bigDecimalToString(udcRow.getNumCnf(), "#,###"))
|
||||
.replace("[posizione]", udc.getPosizione());
|
||||
|
||||
String subject = "Pedane in Quarantena";
|
||||
|
||||
@@ -1212,7 +1235,7 @@ public class MesProductionServiceV2 {
|
||||
}
|
||||
}
|
||||
|
||||
return mtbColtToInsert;
|
||||
return udc;
|
||||
}
|
||||
|
||||
private int getMaxFaseOrdine(DtbOrdt ordineLav) throws SQLException, IOException, PrimaryDatabaseNotPresentException {
|
||||
@@ -1394,16 +1417,17 @@ public class MesProductionServiceV2 {
|
||||
}
|
||||
|
||||
if (collo == null) {
|
||||
boolean canCreateUlFromEan128 = setupGest.getSetupBoolean(multiDBTransactionManager.getPrimaryConnection(), "PVM", "MONITORAGGIO_LINEE_V2", "CAN_CREATE_UL_FROM_EAN");
|
||||
if (canCreateUlFromEan128) {
|
||||
response.getAnomalie().add(
|
||||
AnomalieDTO.warning("Il barcode richiesto non ha fornito alcun risultato!")
|
||||
);
|
||||
response.setCanCreateNewUl(true);
|
||||
return response;
|
||||
} else {
|
||||
throw new Exception("Il barcode richiesto non ha fornito alcun risultato!");
|
||||
if (dto.isVersamentoEnabled()) {
|
||||
boolean canCreateUlFromEan128 = setupGest.getSetupBoolean(multiDBTransactionManager.getPrimaryConnection(), "PVM", "MONITORAGGIO_LINEE_V2", "CAN_CREATE_UL_FROM_EAN");
|
||||
if (canCreateUlFromEan128) {
|
||||
response.getAnomalie().add(
|
||||
AnomalieDTO.warning("Il barcode richiesto non ha fornito alcun risultato!")
|
||||
);
|
||||
response.setCanCreateNewUl(true);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
throw new Exception("Il barcode richiesto non ha fornito alcun risultato!");
|
||||
}
|
||||
response.setSourceMtbColt(collo);
|
||||
JtbFasi jtbFasi = new JtbFasi();
|
||||
@@ -1425,7 +1449,7 @@ public class MesProductionServiceV2 {
|
||||
|
||||
List<MtbColr> rows = collo.getMtbColr();
|
||||
if (UtilityList.isNullOrEmpty(rows)) {
|
||||
MaterialeVersatoSuOrdineDTO versamentoSuOrdine = getVersamentoBarcodeSuOrdine(dto.getOrdine(), dto.getBarcode());
|
||||
MaterialeVersatoSuOrdineDTO versamentoSuOrdine = getPreviousVersamentoBarcodeSuOrdine(dto.getOrdine(), dto.getBarcode());
|
||||
if (versamentoSuOrdine != null && UtilityBigDecimal.greaterThan(versamentoSuOrdine.getQtaVersata(), BigDecimal.ZERO)) {
|
||||
response.setVersamento(versamentoSuOrdine);
|
||||
return response;
|
||||
@@ -1434,6 +1458,10 @@ public class MesProductionServiceV2 {
|
||||
}
|
||||
}
|
||||
|
||||
if (!dto.isVersamentoEnabled()) {
|
||||
throw new Exception("Nessun versamento disponibile per il recupero");
|
||||
}
|
||||
|
||||
|
||||
DtbOrdt ordineLav = completeDatiOrdine(dto.getOrdine());
|
||||
|
||||
@@ -1449,20 +1477,26 @@ public class MesProductionServiceV2 {
|
||||
entityProcessor.processEntity(partitaMagOrdine, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
String codMgrpSL = setupGest.getSetup("w_lpianoprod_rc", "SETUP", "GRUPPO_SL");
|
||||
boolean matchLottoSlToOrdine = setupGest.getSetupDetBoolean("MES", "SETUP", "VINCOLA_LOTTO_ORDINE_A_SL", dto.getCodJfas());
|
||||
|
||||
List<MtbAart> arts = rows.stream().map(MtbColr::getCodMart).map(MtbAart::fromCodMart).distinct().collect(java.util.stream.Collectors.toList());
|
||||
List<String> codMarts = rows.stream()
|
||||
.map(MtbColr::getCodMart)
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
|
||||
if (arts.size() > 1)
|
||||
|
||||
if (codMarts.size() > 1)
|
||||
throw new Exception("Impossibile versare a produzione una pedana mista!");
|
||||
|
||||
final MtbAart rowArt = entityProcessor.processEntity(arts.get(0), true, multiDBTransactionManager);
|
||||
|
||||
MtbAart rowArt = WMSUtility.getArticoloByCodMart(codMarts.get(0), multiDBTransactionManager.getPrimaryConnection());
|
||||
GiacenzaArtInBarcodeDTO invDto = new GiacenzaArtInBarcodeDTO();
|
||||
|
||||
MtbGrup mtbGrup = new MtbGrup();
|
||||
mtbGrup.setCodMgrp(rowArt.getCodMgrp());
|
||||
mtbGrup.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(mtbGrup, true, multiDBTransactionManager);
|
||||
|
||||
invDto
|
||||
.setBarcodeUl(dto.getBarcode())
|
||||
.setBarcodeUl(collo.getBarcodeUl())
|
||||
.setCodMart(rowArt.getCodMart())
|
||||
.setDescrizione(rowArt.getDescrizioneEstesa())
|
||||
.setUntMis(rowArt.getUntMis())
|
||||
@@ -1472,10 +1506,13 @@ public class MesProductionServiceV2 {
|
||||
.setQtaCnfArt(rowArt.getQtaCnf())
|
||||
.setNumCnf(BigDecimal.ZERO);
|
||||
|
||||
entityProcessor.processEntityList(arts, true);
|
||||
|
||||
for (MtbColr row : rows) {
|
||||
DtbOrdr rowOrdine = ordineLav.getDtbOrdr().stream().filter(ordRow -> ordRow.getCodMart().equalsIgnoreCase(rowArt.getCodMart())).findFirst().orElse(null);
|
||||
|
||||
DtbOrdr rowOrdine = UtilityList.isNullOrEmpty(ordineLav.getDtbOrdr()) ? null : ordineLav.getDtbOrdr().stream()
|
||||
.filter(ordRow -> ordRow.getCodMart().equalsIgnoreCase(rowArt.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (rowOrdine == null) {
|
||||
throw new Exception(String.format("L'articolo '%s' non è presente nell'ordine selezionato!", rowArt.getCodMart()));
|
||||
// anomalie.add(AnomalieDTO.error(String.format("L'articolo '%s' non è presente nell'ordine selezionato!", rowArt.getCodMart())));
|
||||
@@ -1491,23 +1528,22 @@ public class MesProductionServiceV2 {
|
||||
|
||||
entityProcessor.processEntity(partitaMagRow, true, multiDBTransactionManager);
|
||||
|
||||
if (rowArt.getCodMgrp().equalsIgnoreCase(codMgrpSL)
|
||||
if (Arrays.asList(MtbGrup.TipoGruppo.SEMILAVORATI, MtbGrup.TipoGruppo.PRODOTTI_FINITI).contains(mtbGrup.getTipoMgrp())
|
||||
&& matchLottoSlToOrdine
|
||||
&& !UtilityString.isNullOrEmpty(ordineLav.getPartitaMag())
|
||||
&& (!partitaMagRow.getPartitaMagProd().equalsIgnoreCase(partitaMagOrdine.getPartitaMagProd())
|
||||
|| !DateUtils.isSameDay(partitaMagRow.getDataScad(), partitaMagOrdine.getDataScad()))) {
|
||||
if (!partitaMagRow.getPartitaMagProd().equalsIgnoreCase(partitaMagOrdine.getPartitaMagProd())) {
|
||||
response.getAnomalie().add(AnomalieDTO.warning(String.format(
|
||||
"Lotto di produzione (%s) diverso da quello in lavorazione (%s).\nVuoi creare un nuovo ordine?",
|
||||
partitaMagRow.getPartitaMag(),
|
||||
partitaMagOrdine.getPartitaMagProd())));
|
||||
} else {
|
||||
response.getAnomalie().add(AnomalieDTO.warning(String.format(
|
||||
"La data di scadenza del lotto versato (%s) è diversa da quella del lotto di lavorazione (%s).\nVuoi creare un nuovo ordine?",
|
||||
UtilityDate.formatDate(partitaMagRow.getDataScad(), CommonConstants.DATE_FORMAT_DMY),
|
||||
UtilityDate.formatDate(partitaMagOrdine.getDataScad(), CommonConstants.DATE_FORMAT_DMY)
|
||||
)));
|
||||
}
|
||||
&& !partitaMagRow.getPartitaMagProd().equalsIgnoreCase(partitaMagOrdine.getPartitaMagProd())) {
|
||||
// if (!partitaMagRow.getPartitaMagProd().equalsIgnoreCase(partitaMagOrdine.getPartitaMagProd())) {
|
||||
response.getAnomalie().add(AnomalieDTO.warning(String.format(
|
||||
"Lotto di produzione (%s) diverso da quello in lavorazione (%s).\nVuoi creare un nuovo ordine?",
|
||||
partitaMagRow.getPartitaMag(),
|
||||
partitaMagOrdine.getPartitaMagProd())));
|
||||
// } else {
|
||||
// response.getAnomalie().add(AnomalieDTO.warning(String.format(
|
||||
// "La data di scadenza del lotto versato (%s) è diversa da quella del lotto di lavorazione (%s).\nVuoi creare un nuovo ordine?",
|
||||
// UtilityDate.formatDate(partitaMagRow.getDataScad(), CommonConstants.DATE_FORMAT_DMY),
|
||||
// UtilityDate.formatDate(partitaMagOrdine.getDataScad(), CommonConstants.DATE_FORMAT_DMY)
|
||||
// )));
|
||||
// }
|
||||
|
||||
response.setNewOrderRequired(true);
|
||||
}
|
||||
@@ -1524,7 +1560,8 @@ public class MesProductionServiceV2 {
|
||||
|
||||
}
|
||||
|
||||
private MaterialeVersatoSuOrdineDTO getVersamentoBarcodeSuOrdine(DtbOrdt ordine, String barcode) throws Exception {
|
||||
private MaterialeVersatoSuOrdineDTO getPreviousVersamentoBarcodeSuOrdine(DtbOrdt ordine, String barcode) throws
|
||||
Exception {
|
||||
|
||||
Ean128Model model;
|
||||
try {
|
||||
@@ -1543,29 +1580,27 @@ public class MesProductionServiceV2 {
|
||||
" mtb_aart.unt_mis2,\n" +
|
||||
" mtb_aart.rap_conv2,\n" +
|
||||
" mtb_aart.qta_cnf as qta_cnf_art,\n" +
|
||||
" mtb_colr.qta_cnf,\n" +
|
||||
" IIF(mtb_aart.flag_qta_cnf_fissa = 'S', mtb_aart.qta_cnf, SUM(qta_col) / SUM(num_cnf)) AS qta_cnf,\n" +
|
||||
" SUM(num_cnf) AS num_cnf,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" mtb_aart.descrizione,\n" +
|
||||
" mtb_colr.partita_mag,\n" +
|
||||
" SUM(qta_col) AS qta_versata,\n" +
|
||||
" mtb_colr.data_ord,\n" +
|
||||
" mtb_colr.num_ord\n" +
|
||||
" mtb_colr.num_ord,\n" +
|
||||
" mtb_colr.barcode_ul_out\n" +
|
||||
" FROM mtb_colr\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_aart.cod_mart = mtb_colr.cod_mart\n" +
|
||||
" INNER JOIN mtb_colt ON mtb_colr.gestione = mtb_colt.gestione AND mtb_colr.data_collo = mtb_colt.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo = mtb_colt.ser_collo AND mtb_colr.num_collo = mtb_colt.num_collo\n" +
|
||||
" INNER JOIN mtb_colt rif\n" +
|
||||
" ON mtb_colr.gestione_rif = rif.gestione AND mtb_colr.data_collo_rif = rif.data_collo AND\n" +
|
||||
" mtb_colr.ser_collo_rif = rif.ser_collo AND mtb_colr.num_collo_rif = rif.num_collo\n" +
|
||||
"WHERE mtb_colt.gestione = 'L'\n" +
|
||||
" AND mtb_colt.segno = -1\n" +
|
||||
" AND mtb_colr.data_ord = {}\n" +
|
||||
" AND mtb_colr.num_ord = {}\n" +
|
||||
" AND (rif.barcode_ul = {} or rif.barcode_ul ={})\n" +
|
||||
"GROUP BY mtb_colt.data_collo, mtb_colt.num_collo, mtb_colt.ser_collo, mtb_colt.gestione, mtb_colr.cod_mart,\n" +
|
||||
" mtb_aart.unt_mis, mtb_colr.partita_mag, mtb_colr.data_ord, mtb_colr.num_ord,mtb_colr.qta_cnf, mtb_aart.unt_mis2,\n" +
|
||||
" mtb_aart.rap_conv2, mtb_aart.descrizione, mtb_aart.qta_cnf", ordine.getDataOrd(), ordine.getNumOrd(), barcode, sscc);
|
||||
" AND mtb_colr.barcode_ul_out = {}\n" +
|
||||
"GROUP BY mtb_aart.flag_qta_cnf_fissa, " +
|
||||
" mtb_colt.data_collo, mtb_colt.num_collo, mtb_colt.ser_collo, mtb_colt.gestione, mtb_colr.cod_mart,\n" +
|
||||
" mtb_aart.unt_mis, mtb_colr.partita_mag, mtb_colr.data_ord, mtb_colr.num_ord, mtb_aart.unt_mis2,\n" +
|
||||
" mtb_aart.rap_conv2, mtb_aart.descrizione, mtb_aart.qta_cnf, mtb_colr.barcode_ul_in, mtb_colr.barcode_ul_out", ordine.getDataOrd(), ordine.getNumOrd(), sscc);
|
||||
|
||||
MaterialeVersatoSuOrdineDTO rowVersamento = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MaterialeVersatoSuOrdineDTO.class);
|
||||
|
||||
@@ -1588,14 +1623,19 @@ public class MesProductionServiceV2 {
|
||||
ordine.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(ordine, multiDBTransactionManager);
|
||||
|
||||
|
||||
//<editor-fold desc="Se la pedana non è sul deposito dove si effettua la lavorazione procediamo con il trasferimento">
|
||||
if (dto.isTransferRequired()) {
|
||||
SpostaUlRequestDTO trasferimentoRequest = new SpostaUlRequestDTO();
|
||||
trasferimentoRequest
|
||||
.setCodMdep(dto.getOrdine().getCodMdep())
|
||||
.setCreateDocAutomatically(true)
|
||||
.setMtbColtsToMove(Collections.singletonList(dto.getMtbColt()));
|
||||
.setGroupDailyTransfers(true)
|
||||
.setGroupingPolicy(SpostaUlRequestDTO.TransferGroupPolicy.BY_USER)
|
||||
.setBarcodeUlList(Collections.singletonList(dto.getMtbColt().getBarcodeUl()));
|
||||
wmsGenericService.spostaUL(trasferimentoRequest);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
List<MvwSitArtUdcDetInventarioDTO> contenuto =
|
||||
wmsGiacenzaULService.retrieveArtsInGiacenzaByBarcodeUl(multiDBTransactionManager.getPrimaryConnection(), sourceBarcodeUl);
|
||||
@@ -1607,33 +1647,69 @@ public class MesProductionServiceV2 {
|
||||
MtbColt uds;
|
||||
|
||||
try {
|
||||
boolean matchLottoSlToOrdine = setupGest.getSetupDetBoolean("MES", "SETUP", "VINCOLA_LOTTO_ORDINE_A_SL", dto.getCodJfas());
|
||||
|
||||
MtbPartitaMag partitaSL = new MtbPartitaMag();
|
||||
MvwSitArtUdcDetInventarioDTO infoScarichi = contenuto.get(0);
|
||||
partitaSL.setCodMart(infoScarichi.getCodMart())
|
||||
.setPartitaMag(infoScarichi.getPartitaMag())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(partitaSL, true, multiDBTransactionManager);
|
||||
MtbGrup mtbGrup = new MtbGrup();
|
||||
mtbGrup.setCodMgrp(infoScarichi.getCodGruppo());
|
||||
mtbGrup.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(mtbGrup, true, multiDBTransactionManager);
|
||||
|
||||
//
|
||||
//<editor-fold desc="Assegna una nuova partita se l'ordine non ha nessuna partita o se il semilavorato ha diversa partitaMagProd">
|
||||
if (matchLottoSlToOrdine
|
||||
&& Arrays.asList(MtbGrup.TipoGruppo.SEMILAVORATI, MtbGrup.TipoGruppo.PRODOTTI_FINITI).contains(mtbGrup.getTipoMgrp())
|
||||
) {
|
||||
|
||||
MtbPartitaMag partitaOrdine = null;
|
||||
|
||||
if (UtilityString.hasContent(ordine.getPartitaMag())) {
|
||||
partitaOrdine = new MtbPartitaMag();
|
||||
|
||||
partitaOrdine
|
||||
.setCodMart(ordine.getCodProd())
|
||||
.setPartitaMag(ordine.getPartitaMag())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(partitaOrdine, true, multiDBTransactionManager);
|
||||
}
|
||||
if (dto.isCloneOrdine() || partitaOrdine == null || !partitaOrdine.getPartitaMagProd().equalsIgnoreCase(partitaSL.getPartitaMagProd())) {
|
||||
//<editor-fold desc="Se l'ordine non ha partita o è una partita diversa dal SL o se devo clonarlo creo una nuova partita e al assegno all'ordine">
|
||||
List<EntityBase> listPartitaMagPf = productionService.insertPartitaMag(new InsertPartitaMagRequestDTO()
|
||||
.setCodMart(ordine.getCodProd())
|
||||
.setPartitaMag(partitaSL.getPartitaMag())
|
||||
.setPartitaMagProd(partitaSL.getPartitaMagProd())
|
||||
.setDataScad(UtilityLocalDate.localDateFromDate(partitaSL.getDataScad()))
|
||||
.setDataProd(partitaSL.getDataProd())
|
||||
.setNote(partitaSL.getNote()), false);
|
||||
|
||||
if (!listPartitaMagPf.isEmpty()) {
|
||||
MtbPartitaMag mtbPartitaMag = (MtbPartitaMag) listPartitaMagPf.get(0);
|
||||
mtbPartitaMag.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(mtbPartitaMag, true, multiDBTransactionManager);
|
||||
ordine.setPartitaMag(mtbPartitaMag.getPartitaMag());
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
if (dto.isCloneOrdine()) {
|
||||
String sql = Query.format("SELECT dtb_ordr.* from dtb_ordr\n" +
|
||||
" inner join dtb_ordt on dtb_ordr.data_ord = dtb_ordt.data_ord_rif and dtb_ordr.gestione = gestione_rif and dtb_ordr.num_ord = num_ord_rif\n" +
|
||||
" where dtb_ordt.gestione = {} and dtb_ordt.data_ord = {} and dtb_ordt.num_ord = {} and dtb_ordr.cod_mart = {}", ordine.getGestione(), ordine.getDataOrd(), ordine.getNumOrd(), ordine.getCodProd());
|
||||
DtbOrdr oldRow = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbOrdr.class);
|
||||
|
||||
CreaOrdineProdDTO newOrdDTO = new CreaOrdineProdDTO();
|
||||
newOrdDTO.setCodAnag(ordine.getCodAnag())
|
||||
.setDataOrd(LocalDate.now())
|
||||
.setUntOrd(oldRow.getUntOrd())
|
||||
.setCodMart(oldRow.getCodMart())
|
||||
.setCodMdep(ordine.getCodMdep())
|
||||
.setNumCnf(oldRow.getNumCnf())
|
||||
.setQtaOrd(ordine.getQtaProd())
|
||||
.setCodJfas(ordine.getCodJfas())
|
||||
.setColliPedana(oldRow.getColliPedana());
|
||||
|
||||
ordine = productionService.saveOrdineProd(newOrdDTO);
|
||||
|
||||
ordine.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(ordine, multiDBTransactionManager);
|
||||
ordine = cloneOrdineLav(ordine, LocalDate.now());
|
||||
} else {
|
||||
ordine.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(ordine, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
List<CreateUDSRequestOrderDTO> ordini = new ArrayList<>();
|
||||
|
||||
MaterialeVersatoSuOrdineDTO versamentoEsistente = getVersamentoBarcodeSuOrdine(dto.getOrdine(), sourceBarcodeUl);
|
||||
|
||||
MaterialeVersatoSuOrdineDTO versamentoEsistente = getPreviousVersamentoBarcodeSuOrdine(dto.getOrdine(), sourceBarcodeUl);
|
||||
if (versamentoEsistente == null) {
|
||||
CreateUDSRequestOrderDTO orderDTO = new CreateUDSRequestOrderDTO()
|
||||
.setNumOrd(ordine.getNumOrd())
|
||||
@@ -1652,7 +1728,8 @@ public class MesProductionServiceV2 {
|
||||
|
||||
uds = wmsLavorazioneService.createUDS(requestDTO);
|
||||
} else {
|
||||
uds = new MtbColt(versamentoEsistente.getGestione(), versamentoEsistente.getDataCollo(), versamentoEsistente.getNumCollo(), versamentoEsistente.getSerCollo());
|
||||
uds = new MtbColt(versamentoEsistente.getGestione(), versamentoEsistente.getDataCollo(), versamentoEsistente.getNumCollo(), versamentoEsistente.getSerCollo())
|
||||
.setBarcodeUl(versamentoEsistente.getBarcodeUlIn());
|
||||
}
|
||||
|
||||
for (MvwSitArtUdcDetInventarioDTO scarico : contenuto) {
|
||||
@@ -1667,6 +1744,9 @@ public class MesProductionServiceV2 {
|
||||
MtbColr sourceMtbColr = new MtbColr();
|
||||
|
||||
sourceMtbColr
|
||||
.setBarcodeUlIn(scarico.getBarcodeUl())
|
||||
.setPosizioneIn(scarico.getPosizione())
|
||||
.setCodMdepIn(scarico.getCodMdep())
|
||||
.setNumCollo(scarico.getNumCollo())
|
||||
.setSerCollo(scarico.getSerCollo())
|
||||
.setDataCollo(scarico.getDataCollo())
|
||||
@@ -1683,79 +1763,10 @@ public class MesProductionServiceV2 {
|
||||
.setSourceMtbColr(sourceMtbColr)
|
||||
.setTargetMtbColt(uds)
|
||||
.setQtaCnf(scarico.getQtaCnf())
|
||||
.setDataOrd(ordine.getDataOrd())
|
||||
.setDataOrd(UtilityLocalDate.localDateFromDate(ordine.getDataOrd()))
|
||||
.setRigaOrd(rigaOrd)
|
||||
.setNumOrd(ordine.getNumOrd());
|
||||
wmsLavorazioneService.insertUDSRow(insertRequestDto);
|
||||
|
||||
String codMgrpSL = setupGest.getSetup("w_lpianoprod_rc", "SETUP", "GRUPPO_SL");
|
||||
boolean matchLottoSlToOrdine = setupGest.getSetupDetBoolean("MES", "SETUP", "VINCOLA_LOTTO_ORDINE_A_SL", dto.getCodJfas());
|
||||
|
||||
MtbPartitaMag partitaSL = new MtbPartitaMag();
|
||||
|
||||
partitaSL.setCodMart(scarico.getCodMart())
|
||||
.setPartitaMag(scarico.getPartitaMag())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(partitaSL, true, multiDBTransactionManager);
|
||||
|
||||
MtbPartitaMag partitaOrdine = null;
|
||||
|
||||
// Controllo se esiste partita con stesso lotto e scadenza
|
||||
if (!UtilityString.isNullOrEmpty(ordine.getPartitaMag())) {
|
||||
partitaOrdine = new MtbPartitaMag();
|
||||
|
||||
partitaOrdine
|
||||
.setCodMart(ordine.getCodProd())
|
||||
.setPartitaMag(ordine.getPartitaMag())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
entityProcessor.processEntity(partitaOrdine, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
// Assegna una nuova partita se l'ordine non ha nessuna partita o se il semilavorato ha diversa partitaMagProd o data scadenza
|
||||
if (matchLottoSlToOrdine
|
||||
&& scarico.getCodGruppo().equalsIgnoreCase(codMgrpSL)
|
||||
&& (UtilityString.isNullOrEmpty(ordine.getPartitaMag())
|
||||
|| !partitaOrdine.getPartitaMagProd().equalsIgnoreCase(partitaSL.getPartitaMagProd())
|
||||
|| !DateUtils.isSameDay(partitaOrdine.getDataScad(), partitaSL.getDataScad()))) {
|
||||
String partitaMagProd = UtilityString.isNull(partitaSL.getPartitaMagProd(), partitaSL.getPartitaMag());
|
||||
|
||||
sql = Query.format(
|
||||
"WITH datiPartita\n" +
|
||||
" AS (SELECT MAX(ASCII(RIGHT(partita_mag, LEN(partita_mag) - LEN(%s)))) + 1 AS nextProgressivo\n" +
|
||||
" FROM mtb_partita_mag\n" +
|
||||
" WHERE cod_mart = %s\n" +
|
||||
" AND partita_mag_prod = %s)\n" +
|
||||
"SELECT CONCAT(%s, ISNULL(CHAR(nextProgressivo), 'A'))\n" +
|
||||
"FROM datiPartita",
|
||||
partitaMagProd,
|
||||
ordine.getCodProd(),
|
||||
partitaMagProd,
|
||||
partitaMagProd
|
||||
);
|
||||
|
||||
String partitaMagPf = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
partitaMagPf = UtilityString.isNull(partitaMagPf, partitaMagProd);
|
||||
|
||||
MtbPartitaMag partitaPf = new MtbPartitaMag();
|
||||
|
||||
partitaPf
|
||||
.setCodMart(ordine.getCodProd())
|
||||
.setPartitaMag(partitaMagPf)
|
||||
.setPartitaMagProd(partitaMagProd)
|
||||
.setDataProd(partitaSL.getDataProd())
|
||||
.setDataScad(partitaSL.getDataScad())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
entityProcessor.processEntity(partitaPf, true, multiDBTransactionManager);
|
||||
|
||||
ordine.setPartitaMag(partitaMagPf)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
entityProcessor.processEntity(ordine, true, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
|
||||
if (dto.isStartOrdine() || dto.isCloneOrdine()) {
|
||||
@@ -1771,6 +1782,11 @@ public class MesProductionServiceV2 {
|
||||
return uds;
|
||||
}
|
||||
|
||||
private DtbOrdt getOrdineProd(String codJfas, LocalDate dataOrd) throws Exception {
|
||||
String queryOrdProd = Query.format("SELECT * from dtb_ordt where gestione = 'A' and gestione_rif = 'A' and cod_jfas = {} and data_ord = {}", codJfas, dataOrd);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), queryOrdProd, DtbOrdt.class);
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
OPEN,
|
||||
CLOSE,
|
||||
@@ -2397,4 +2413,124 @@ public class MesProductionServiceV2 {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public DtbOrdt creaNuovaLavorazione(NuovaLavorazioneDTO dto) throws Exception {
|
||||
LocalDate dataProd = UtilityLocalDate.isNull(dto.getDataOrd(), LocalDate.now());
|
||||
|
||||
//<editor-fold desc="Controllo se esiste un ordine di produzione sulla linea selezionata (altrimenti lo creo)">
|
||||
DtbOrdt ordProd = getOrdineProd(dto.getCodJfas(), dataProd);
|
||||
if (ordProd == null) {
|
||||
|
||||
ordProd = new DtbOrdt()
|
||||
.setGestione("A")
|
||||
.setGestioneRif("A")
|
||||
.setDataOrd(UtilityLocalDate.localDateToDate(dataProd))
|
||||
.setOrdTrasf(Boolean.FALSE)
|
||||
.setCodAnag(dto.getCodAnag())
|
||||
.setCodVdes(dto.getCodVdes())
|
||||
.setCodMdep(dto.getCodMdep())
|
||||
.setCodVzon(dto.getCodVzon())
|
||||
;
|
||||
|
||||
ordProd.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
|
||||
DtbOrdr ordLav = new DtbOrdr()
|
||||
.setCodMart(dto.getCodMart())
|
||||
.setCodJfas(dto.getCodJfas())
|
||||
.setQtaOrd(dto.getQtaOrd())
|
||||
.setUntOrd(dto.getUntOrd())
|
||||
.setDataCons(UtilityLocalDate.localDateToDate(dataProd))
|
||||
.setPartitaMag(dto.getPartitaMag())
|
||||
.setColliPedana(dto.getColliPedana())
|
||||
.setDataInizProd(dataProd)
|
||||
.setCodTcolUl(dto.getCodTcolUl())
|
||||
.setNote(dto.getAnnotazioni())
|
||||
.setDistinta(dto.getListaMateriali());
|
||||
|
||||
ordLav.setOperation(OperationType.INSERT);
|
||||
|
||||
ordProd.addDtbOrdr(ordLav);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(dto.getPartitaMag())) {
|
||||
String partitaMag = PartitaMagRules.suggestCodePartitaMag(multiDBTransactionManager.getPrimaryConnection(),
|
||||
new DatiPartitaMagDTO()
|
||||
.setCodMart(ordLav.getCodMart())
|
||||
.setDataOrd(UtilityLocalDate.localDateToDate(dataProd))
|
||||
.setGestione("L")
|
||||
.setCodJfas(ordLav.getCodJfas()));
|
||||
|
||||
List<EntityBase> listPartitaMag = productionService.insertPartitaMag(new InsertPartitaMagRequestDTO()
|
||||
.setCodMart(dto.getCodMart())
|
||||
.setPartitaMag(partitaMag)
|
||||
.setDataScad(dto.getDataScadPartitaMag())
|
||||
.setDataProd(dto.getDataProdPartita())
|
||||
.setNote(dto.getNotePartita()), false);
|
||||
if (!listPartitaMag.isEmpty()) {
|
||||
MtbPartitaMag mtbPartitaMag = (MtbPartitaMag) listPartitaMag.get(0);
|
||||
|
||||
mtbPartitaMag.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
entityProcessor.processEntity(mtbPartitaMag, true, multiDBTransactionManager);
|
||||
|
||||
ordLav.setPartitaMag(mtbPartitaMag.getPartitaMag());
|
||||
}
|
||||
}
|
||||
|
||||
ordProd.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(ordProd, true, multiDBTransactionManager);
|
||||
|
||||
DtbOrdt newOrd = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||
Query.format("SELECT * from dtb_ordt where gestione_rif ={} and data_ord_rif = {} and num_ord_rif = {} and riga_ord_rif = {}",
|
||||
ordLav.getGestione(),
|
||||
ordLav.getDataOrd(),
|
||||
ordLav.getNumOrd(),
|
||||
ordLav.getRigaOrd()
|
||||
),
|
||||
DtbOrdt.class);
|
||||
return newOrd;
|
||||
}
|
||||
|
||||
public DtbOrdt cloneOrdineLav(DtbOrdt ordine, LocalDate dataProd) throws Exception {
|
||||
List<DtbOrdr> righeOrdLav = UtilityDB.executeSimpleQueryDTO(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
Query.format(
|
||||
"SELECT * from dtb_ordr where data_ord = {} and num_ord ={} and gestione = {}", ordine.getDataOrd(), ordine.getNumOrd(), ordine.getGestione()
|
||||
), DtbOrdr.class);
|
||||
NuovaLavorazioneDTO dto = new NuovaLavorazioneDTO()
|
||||
.setCodAnag(ordine.getCodAnag())
|
||||
.setDataOrd(LocalDate.now())
|
||||
.setUntOrd(ordine.getUntMisProd())
|
||||
.setCodMart(ordine.getCodProd())
|
||||
.setCodMdep(ordine.getCodMdep())
|
||||
.setNumCnf(ordine.getNumCnfProd())
|
||||
.setQtaOrd(ordine.getQtaProd())
|
||||
.setCodJfas(ordine.getCodJfas())
|
||||
.setAnnotazioni(ordine.getNote())
|
||||
.setPartitaMag(ordine.getPartitaMag());
|
||||
|
||||
if (!UtilityList.isNullOrEmpty(righeOrdLav)) {
|
||||
List<JtbDistMate> listaMateriali = new ArrayList<>();
|
||||
for (DtbOrdr rigaOrdine : righeOrdLav) {
|
||||
JtbDistMate jtbDistMate = new JtbDistMate()
|
||||
.setCodProd(ordine.getCodProd())
|
||||
.setCodMart(rigaOrdine.getCodMart())
|
||||
.setQtaStd(rigaOrdine.getQtaOrd())
|
||||
.setNumFase(rigaOrdine.getNumFase());
|
||||
|
||||
jtbDistMate.setOperation(OperationType.INSERT);
|
||||
|
||||
listaMateriali
|
||||
.add(jtbDistMate);
|
||||
}
|
||||
dto.setListaMateriali(listaMateriali);
|
||||
}
|
||||
|
||||
|
||||
return creaNuovaLavorazione(dto);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import it.integry.ems.retail.wms.generic.service.WMSGenericService;
|
||||
import it.integry.ems.retail.wms.lavorazione.service.WMSLavorazioneService;
|
||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||
import it.integry.ems.rules.businessLogic.dto.LoadColliDTO;
|
||||
import it.integry.ems.rules.completing.DocumentRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
@@ -29,12 +30,9 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -67,366 +65,391 @@ public class OrtoFruttaProductionService {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public EntityBase accettazioneDaRaccolta(AccettazioneOrtoFruttaDTO dto) throws Exception {
|
||||
public MtbColt accettazioneDaRaccolta(AccettazioneOrtoFruttaDTO dto) throws Exception {
|
||||
|
||||
try {
|
||||
|
||||
//<editor-fold desc="Acquisizione Dati">
|
||||
if (dto.getUntMis().equalsIgnoreCase("KG") && UtilityBigDecimal.isNullOrZero(dto.getPesoLordoCamion()))
|
||||
throw new Exception("Peso lordo non configurato!");
|
||||
|
||||
if (dto.getDataOrd() == null || dto.getNumOrd() == null)
|
||||
throw new Exception("Ordine di raccolta non selezionato!");
|
||||
|
||||
String codDtipAcqCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"COD_DTIP_ACCETTAZIONE");
|
||||
String serDocAcqCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"SER_DOC_ACCETTAZIONE");
|
||||
|
||||
String codJfas = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "w_lpianoprod_rc",
|
||||
"SETUP",
|
||||
"FASE_RACC");
|
||||
|
||||
String codDtipLavCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"COD_DTIP_CAR");
|
||||
String serDocLavCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"SER_DOC_CAR");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(dto.getSerDocProvv()))
|
||||
dto.setSerDocProvv(serDocAcqCar);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(dto.getCodDtipProvv()))
|
||||
dto.setCodDtipProvv(codDtipAcqCar);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(dto.getCodJfas())) {
|
||||
dto.setCodJfas(codJfas);
|
||||
}
|
||||
|
||||
if (UtilityInteger.isNullOrZero(dto.getNumDoc())) {
|
||||
DtbTipi tipoDocCertc = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("select * from dtb_tipi where cod_dtip = {}", codDtipLavCar), DtbTipi.class);
|
||||
Integer numDoc = DocumentRules.nextNumDoc(multiDBTransactionManager.getPrimaryConnection(),
|
||||
UtilityLocalDate.localDateToDate(dto.getDataDoc()),
|
||||
tipoDocCertc.getCodIreg(),
|
||||
serDocLavCar,
|
||||
tipoDocCertc.getNumIreg(),
|
||||
0);
|
||||
dto.setNumDoc(numDoc);
|
||||
}
|
||||
//<editor-fold desc=" controllo se il Certificato richiesto è già occupato nell'anno">
|
||||
|
||||
String sql = "SELECT data_collo,ser_collo,num_collo,gestione\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE YEAR(data_doc) = YEAR(" + UtilityDB.valueDateToString(UtilityLocalDate.localDateToDate(dto.getDataDoc()), CommonConstants.DATE_FORMAT_YMD) + ")\n" +
|
||||
" AND num_doc = " + UtilityDB.valueToString(dto.getNumDoc()) + "\n" +
|
||||
" AND cod_anag = " + UtilityDB.valueToString(dto.getCodAnag()) + "\n" +
|
||||
"AND cod_dtip = " + UtilityDB.valueToString(codDtipLavCar) + "\n" +
|
||||
"and ser_doc = " + UtilityDB.valueToString(serDocLavCar) + "\n";
|
||||
MtbColt mtbcolt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
if (mtbcolt != null && (UtilityInteger.isNullOrZero(dto.getNumCollo()) || !mtbcolt.equalsKey(new MtbColt(dto.getGestione(), dto.getDataCollo(), dto.getNumCollo(), dto.getSerCollo())))) {
|
||||
throw new Exception(String.format("Il certificato n. %d per l'anno %s è già stato registrato!", dto.getNumDoc(), UtilityLocalDate.formatDate(dto.getDataDoc(), "yyyy")));
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc=" controllo se il DDT richiesto è già occupato da un altro certificato">
|
||||
|
||||
sql = "SELECT data_collo,ser_collo,num_collo,gestione\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE data_doc_provv = " + UtilityDB.valueDateToString(UtilityLocalDate.localDateToDate(dto.getDataDocProvv()), CommonConstants.DATE_FORMAT_YMD) + "\n" +
|
||||
" AND num_doc_provv = " + UtilityDB.valueToString(dto.getNumDocProvv()) + "\n" +
|
||||
" AND cod_anag = " + UtilityDB.valueToString(dto.getCodAnag()) + "\n" +
|
||||
"AND cod_dtip_provv = " + UtilityDB.valueToString(dto.getCodDtipProvv()) + "\n" +
|
||||
"and ser_doc_provv = " + UtilityDB.valueToString(dto.getSerDocProvv()) + "\n";
|
||||
mtbcolt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
if (mtbcolt != null && (UtilityInteger.isNullOrZero(dto.getNumCollo()) || mtbcolt.getNumCollo().compareTo(dto.getNumCollo()) != 0)) {
|
||||
throw new Exception("Il documento di trasporto inserito è già esistente!");
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
String barcodeUl = null;
|
||||
if (setupGest.getSetupBoolean("PVM", "PIAN_ACC_ROSSG", "NUM_DOC_AS_BARCODE")) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy");
|
||||
barcodeUl = formatter.format(UtilityLocalDate.isNull(dto.getDataCollo().atStartOfDay(), LocalDateTime.now())) + String.format("%06d", dto.getNumDoc());
|
||||
}
|
||||
|
||||
//<editor-fold desc="Salvataggio dati base collo e Activity">
|
||||
MtbColt collo;
|
||||
//creo collo base se non esiste
|
||||
if (UtilityInteger.isNullOrZero(dto.getNumCollo())) {
|
||||
CaricoProdottoFinitoDTO createColloDto = new CaricoProdottoFinitoDTO();
|
||||
createColloDto
|
||||
.setCodMdep(dto.getCodMdepProd())
|
||||
.setCodJfas(dto.getCodJfas())
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setDataCollo(dto.getDataCollo())
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setGestione(dto.getGestione())
|
||||
.setQtaCollo(dto.getQtaCol())
|
||||
.setBarcodeUl(barcodeUl);
|
||||
collo = mesProductionServiceV2.createColloCaricoProdottoFinito(createColloDto);
|
||||
collo.setMtbCols(new ArrayList<>());
|
||||
} else {
|
||||
collo = new MtbColt(dto.getGestione(), dto.getDataCollo(), dto.getNumCollo(), dto.getSerCollo());
|
||||
completeDatiCollo(collo);
|
||||
}
|
||||
|
||||
String activityId = collo.getActivityId();
|
||||
|
||||
|
||||
//<editor-fold desc="Acquisizione Dati">
|
||||
if (dto.getUntMis().equalsIgnoreCase("KG") && UtilityBigDecimal.isNullOrZero(dto.getPesoLordoCamion()))
|
||||
throw new Exception("Peso lordo non configurato!");
|
||||
//Genero l'id attività se non esiste
|
||||
if (UtilityString.isNullOrEmpty(activityId)) {
|
||||
StbActivity activity = new StbActivity()
|
||||
.setFlagTipologia("A")
|
||||
.setActivityTypeId("ACCETTAZIONE_DA_RACCOLTA")
|
||||
.setUserName(requestDataDTO.getUsername());
|
||||
|
||||
if (dto.getDataOrd() == null || dto.getNumOrd() == null)
|
||||
throw new Exception("Ordine di raccolta non selezionato!");
|
||||
activity.setOperation(OperationType.INSERT);
|
||||
entityProcessor.processEntity(activity, true, multiDBTransactionManager);
|
||||
activityId = activity.getActivityId();
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
String codDtipAcqCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"COD_DTIP_ACCETTAZIONE");
|
||||
String serDocAcqCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"SER_DOC_ACCETTAZIONE");
|
||||
//<editor-fold desc="Salvataggio dati partita">
|
||||
List<MtbPartitaMagCarat> datiPartita;
|
||||
MtbPartitaMagCarat lottoProd = new MtbPartitaMagCarat();
|
||||
MtbPartitaMagCarat modalitaRaccolta = new MtbPartitaMagCarat();
|
||||
MtbPartitaMagCarat rifAnalisi = new MtbPartitaMagCarat();
|
||||
MtbPartitaMagCarat varietaRaccolta = new MtbPartitaMagCarat();
|
||||
String caratLottoProd = "Lotto Produttore";
|
||||
String caratModalitaRaccolta = "Modalita Raccolta";
|
||||
String caratVarietaRaccolta = "Varieta";
|
||||
String caratRifAnalisi = "RifAnalisi";
|
||||
if (dto.getOriginal() != null) {
|
||||
datiPartita = UtilityDB.executeSimpleQueryDTO(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
Query.format("SELECT * from mtb_partita_mag_carat where cod_mart = {} and partita_mag = {} and carat in ({},{},{},{}) and activity_id = {}",
|
||||
dto.getCodMart(),
|
||||
dto.getPartitaRaccolta(),
|
||||
caratLottoProd,
|
||||
caratModalitaRaccolta,
|
||||
caratVarietaRaccolta,
|
||||
caratRifAnalisi,
|
||||
activityId),
|
||||
MtbPartitaMagCarat.class);
|
||||
if (!UtilityList.isNullOrEmpty(datiPartita)) {
|
||||
lottoProd = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratLottoProd)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
modalitaRaccolta = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratModalitaRaccolta)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
varietaRaccolta = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratVarietaRaccolta)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
rifAnalisi = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratRifAnalisi)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
}
|
||||
}
|
||||
lottoProd
|
||||
.setCarat(caratLottoProd)
|
||||
.setValCarat(dto.getLottoProduttore())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
String codJfas = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "w_lpianoprod_rc",
|
||||
"SETUP",
|
||||
"FASE_RACC");
|
||||
modalitaRaccolta
|
||||
.setCarat(caratModalitaRaccolta)
|
||||
.setValCarat(dto.getModalitaRaccolta())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
rifAnalisi
|
||||
.setCarat(caratRifAnalisi)
|
||||
.setValCarat(dto.getRifAnalisi())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
varietaRaccolta
|
||||
.setCarat(caratVarietaRaccolta)
|
||||
.setValCarat(dto.getVarieta())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
datiPartita = new ArrayList<>();
|
||||
datiPartita.add(lottoProd);
|
||||
datiPartita.add(modalitaRaccolta);
|
||||
datiPartita.add(varietaRaccolta);
|
||||
datiPartita.add(rifAnalisi);
|
||||
|
||||
String codDtipLavCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"COD_DTIP_CAR");
|
||||
String serDocLavCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
"SER_DOC_CAR");
|
||||
MtbPartitaMag part = new MtbPartitaMag();
|
||||
part
|
||||
.setCodMart(dto.getCodMart())
|
||||
.setPartitaMag(dto.getPartitaRaccolta())
|
||||
.setDescrizione(dto.getRagSocProduttore() + " - " + dto.getVarieta())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
part.setMtbPartitaMagCarat(datiPartita);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(dto.getSerDocProvv()))
|
||||
dto.setSerDocProvv(serDocAcqCar);
|
||||
entityProcessor.processEntity(part, true, multiDBTransactionManager);
|
||||
//</editor-fold>
|
||||
|
||||
if (UtilityString.isNullOrEmpty(dto.getCodDtipProvv()))
|
||||
dto.setCodDtipProvv(codDtipAcqCar);
|
||||
//<editor-fold desc="Generazione Certificato">
|
||||
//Genero testata certificato di lavoro
|
||||
//se esiste un certificato per il carico in salvataggio con un numero diverso da quello selezionato lo vado a cancellare
|
||||
deleteOldCertificatoIfExists(activityId, codDtipLavCar, dto);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(dto.getCodJfas())) {
|
||||
dto.setCodJfas(codJfas);
|
||||
}
|
||||
//<editor-fold desc=" controllo se il Certificato richiesto è già occupato nell'anno">
|
||||
|
||||
String sql = "SELECT data_collo,ser_collo,num_collo,gestione\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE YEAR(data_doc) = YEAR(" + UtilityDB.valueDateToString(UtilityLocalDate.localDateToDate(dto.getDataDoc()), CommonConstants.DATE_FORMAT_YMD) + ")\n" +
|
||||
" AND num_doc = " + UtilityDB.valueToString(dto.getNumDoc()) + "\n" +
|
||||
" AND cod_anag = " + UtilityDB.valueToString(dto.getCodAnag()) + "\n" +
|
||||
"AND cod_dtip = " + UtilityDB.valueToString(codDtipLavCar) + "\n" +
|
||||
"and ser_doc = " + UtilityDB.valueToString(serDocLavCar) + "\n";
|
||||
MtbColt mtbcolt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
if (mtbcolt != null && (UtilityInteger.isNullOrZero(dto.getNumCollo()) || !mtbcolt.equalsKey(new MtbColt(dto.getGestione(),dto.getDataCollo(),dto.getNumCollo(),dto.getSerCollo())))) {
|
||||
throw new Exception(String.format("Il certificato n. %d per l'anno %s è già stato registrato!",dto.getNumDoc(),UtilityLocalDate.formatDate(dto.getDataDoc(),"yyyy")));
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc=" controllo se il DDT richiesto è già occupato da un altro certificato">
|
||||
|
||||
sql = "SELECT data_collo,ser_collo,num_collo,gestione\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
"WHERE data_doc_provv = " + UtilityDB.valueDateToString(UtilityLocalDate.localDateToDate(dto.getDataDocProvv()), CommonConstants.DATE_FORMAT_YMD) + "\n" +
|
||||
" AND num_doc_provv = " + UtilityDB.valueToString(dto.getNumDocProvv()) + "\n" +
|
||||
" AND cod_anag = " + UtilityDB.valueToString(dto.getCodAnag()) + "\n" +
|
||||
"AND cod_dtip_provv = " + UtilityDB.valueToString(dto.getCodDtipProvv()) + "\n" +
|
||||
"and ser_doc_provv = " + UtilityDB.valueToString(dto.getSerDocProvv()) + "\n";
|
||||
mtbcolt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
if (mtbcolt != null && (UtilityInteger.isNullOrZero(dto.getNumCollo()) || mtbcolt.getNumCollo().compareTo(dto.getNumCollo()) != 0)) {
|
||||
throw new Exception("Il documento di trasporto inserito è già esistente!");
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Salvataggio dati base collo e Activity">
|
||||
MtbColt collo;
|
||||
//creo collo base se non esiste
|
||||
if (UtilityInteger.isNullOrZero(dto.getNumCollo())) {
|
||||
CaricoProdottoFinitoDTO createColloDto = new CaricoProdottoFinitoDTO();
|
||||
createColloDto
|
||||
DtbDoct docLav = new DtbDoct();
|
||||
docLav
|
||||
.setCodDtip(UtilityString.isNull(dto.getCodDtip(), codDtipLavCar))
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(dto.getDataDoc()))
|
||||
.setNumDoc(dto.getNumDoc())
|
||||
.setCodAnag(dto.getCodAnag())
|
||||
.setSerDoc(serDocLavCar)
|
||||
.setTarga(dto.getTarga())
|
||||
.setCodMdep(dto.getCodMdepProd())
|
||||
.setCodJfas(dto.getCodJfas())
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setDataCollo(UtilityLocalDate.localDateToDate(dto.getDataCollo()))
|
||||
.setDataCons(UtilityLocalDate.localDateTimeToDate(dto.getDataVers()))
|
||||
.setCodProd(dto.getCodMart())
|
||||
.setPartitaMag(dto.getPartitaRaccolta())
|
||||
.setDataOrd(UtilityLocalDate.localDateToDate(dto.getDataOrd()))
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setGestione(dto.getGestione())
|
||||
.setQtaCollo(dto.getQtaCol());
|
||||
collo = mesProductionServiceV2.createColloCaricoProdottoFinito(createColloDto);
|
||||
collo.setMtbCols(new ArrayList<>());
|
||||
} else {
|
||||
collo = new MtbColt(dto.getGestione(), dto.getDataCollo(), dto.getNumCollo(), dto.getSerCollo());
|
||||
completeDatiCollo(collo);
|
||||
}
|
||||
.setTargaRim(dto.getTargaRim())
|
||||
.setActivityId(activityId)
|
||||
.setCodVvet(dto.getCodVvet())
|
||||
.setCodVzon(dto.getCodVzon())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
String activityId = collo.getActivityId();
|
||||
entityProcessor.processEntity(docLav, true, multiDBTransactionManager);
|
||||
|
||||
DtbDocr rowsDocLav = new DtbDocr();
|
||||
rowsDocLav.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(), docLav);
|
||||
|
||||
|
||||
//Genero l'id attività se non esiste
|
||||
if (UtilityString.isNullOrEmpty(activityId)) {
|
||||
StbActivity activity = new StbActivity()
|
||||
.setFlagTipologia("A")
|
||||
.setActivityTypeId("ACCETTAZIONE_DA_RACCOLTA")
|
||||
.setUserName(requestDataDTO.getUsername());
|
||||
collo
|
||||
.setActivityId(activityId)
|
||||
.setIdPesata(dto.getIdPesata())
|
||||
.setDataDoc(EmsRestConstants.LOCAL_DATE_NULL)
|
||||
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setCodDtip(EmsRestConstants.NULL)
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setCodMdep(dto.getCodMdepProd())
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setDataDocProvv(UtilityLocalDate.localDateToDate(dto.getDataDocProvv()))
|
||||
.setNumDocProvv(dto.getNumDocProvv())
|
||||
.setCodDtipProvv(dto.getCodDtipProvv())
|
||||
.setSerDocProvv(dto.getSerDocProvv())
|
||||
.setPesoKg(BigDecimal.ZERO)
|
||||
.setPesoNettoKg(BigDecimal.ZERO)
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
activity.setOperation(OperationType.INSERT);
|
||||
entityProcessor.processEntity(activity, true, multiDBTransactionManager);
|
||||
activityId = activity.getActivityId();
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Salvataggio dati partita">
|
||||
List<MtbPartitaMagCarat> datiPartita;
|
||||
MtbPartitaMagCarat lottoProd = new MtbPartitaMagCarat();
|
||||
MtbPartitaMagCarat modalitaRaccolta = new MtbPartitaMagCarat();
|
||||
MtbPartitaMagCarat rifAnalisi = new MtbPartitaMagCarat();
|
||||
MtbPartitaMagCarat varietaRaccolta = new MtbPartitaMagCarat();
|
||||
String caratLottoProd = "Lotto Produttore";
|
||||
String caratModalitaRaccolta = "Modalita Raccolta";
|
||||
String caratVarietaRaccolta = "Varieta";
|
||||
String caratRifAnalisi = "RifAnalisi";
|
||||
if (dto.getOriginal() != null) {
|
||||
datiPartita = UtilityDB.executeSimpleQueryDTO(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
Query.format("SELECT * from mtb_partita_mag_carat where cod_mart = {} and partita_mag = {} and carat in ({},{},{},{}) and activity_id = {}",
|
||||
dto.getCodMart(),
|
||||
dto.getPartitaRaccolta(),
|
||||
caratLottoProd,
|
||||
caratModalitaRaccolta,
|
||||
caratVarietaRaccolta,
|
||||
caratRifAnalisi,
|
||||
activityId),
|
||||
MtbPartitaMagCarat.class);
|
||||
if (!UtilityList.isNullOrEmpty(datiPartita)) {
|
||||
lottoProd = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratLottoProd)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
modalitaRaccolta = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratModalitaRaccolta)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
varietaRaccolta = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratVarietaRaccolta)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
rifAnalisi = datiPartita.stream().filter(x -> x.getCarat().equalsIgnoreCase(caratRifAnalisi)).findFirst().orElse(new MtbPartitaMagCarat());
|
||||
collo.setDataVers(dto.getDataVers());
|
||||
MtbColr rowToEmpty = new MtbColr();
|
||||
rowToEmpty.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(), collo);
|
||||
MtbColr row = collo.getMtbColr().stream().filter(x -> x.getCodMart().equalsIgnoreCase(dto.getCodMart())).findFirst().orElse(new MtbColr());
|
||||
if (row.getNumOrd() == null) {
|
||||
collo.getMtbColr().add(row);
|
||||
}
|
||||
}
|
||||
lottoProd
|
||||
.setCarat(caratLottoProd)
|
||||
.setValCarat(dto.getLottoProduttore())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
row
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setQtaCol(dto.getQtaCol())
|
||||
.setPartitaMag(dto.getPartitaRaccolta())
|
||||
.setPesoNettoKg(dto.getPesoNettoPedane())
|
||||
.setPesoLordoKg(dto.getPesoLordoCamion())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
if (!UtilityBigDecimal.isNullOrZero(dto.getNumCnf()))
|
||||
row.setNumCnf(dto.getNumCnf())
|
||||
.setQtaCnf(dto.getQtaCol().divide(dto.getNumCnf(), 2, RoundingMode.HALF_UP));
|
||||
sql = "SELECT art_tcol.* from mtb_aart " +
|
||||
" inner join mtb_tcol on mtb_tcol.cod_tcol = mtb_aart.cod_tcol_UI " +
|
||||
" inner join mtb_aart art_tcol on art_tcol.cod_mart = mtb_tcol.cod_mart " +
|
||||
" where mtb_aart.cod_mart = " + UtilityDB.valueToString(dto.getCodMart());
|
||||
MtbAart articoloBins = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbAart.class);
|
||||
|
||||
modalitaRaccolta
|
||||
.setCarat(caratModalitaRaccolta)
|
||||
.setValCarat(dto.getModalitaRaccolta())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
rifAnalisi
|
||||
.setCarat(caratRifAnalisi)
|
||||
.setValCarat(dto.getRifAnalisi())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
varietaRaccolta
|
||||
.setCarat(caratVarietaRaccolta)
|
||||
.setValCarat(dto.getVarieta())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
datiPartita = new ArrayList<>();
|
||||
datiPartita.add(lottoProd);
|
||||
datiPartita.add(modalitaRaccolta);
|
||||
datiPartita.add(varietaRaccolta);
|
||||
datiPartita.add(rifAnalisi);
|
||||
|
||||
MtbPartitaMag part = new MtbPartitaMag();
|
||||
part
|
||||
.setCodMart(dto.getCodMart())
|
||||
.setPartitaMag(dto.getPartitaRaccolta())
|
||||
.setDescrizione(dto.getRagSocProduttore() + " - " + dto.getVarieta())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
part.setMtbPartitaMagCarat(datiPartita);
|
||||
|
||||
entityProcessor.processEntity(part, true, multiDBTransactionManager);
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Generazione Certificato">
|
||||
//Genero testata certificato di lavoro
|
||||
//se esiste un certificato per il carico in salvataggio con un numero diverso da quello selezionato lo vado a cancellare
|
||||
deleteOldCertificatoIfExists(activityId, codDtipLavCar, dto);
|
||||
|
||||
DtbDoct docLav = new DtbDoct();
|
||||
docLav
|
||||
.setCodDtip(UtilityString.isNull(dto.getCodDtip(), codDtipLavCar))
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(dto.getDataDoc()))
|
||||
.setNumDoc(dto.getNumDoc())
|
||||
.setCodAnag(dto.getCodAnag())
|
||||
.setSerDoc(serDocLavCar)
|
||||
.setTarga(dto.getTarga())
|
||||
.setCodMdep(dto.getCodMdepProd())
|
||||
.setCodJfas(dto.getCodJfas())
|
||||
.setDataCons(UtilityLocalDate.localDateTimeToDate(dto.getDataVers()))
|
||||
.setCodProd(dto.getCodMart())
|
||||
.setPartitaMag(dto.getPartitaRaccolta())
|
||||
.setDataOrd(UtilityLocalDate.localDateToDate(dto.getDataOrd()))
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setTargaRim(dto.getTargaRim())
|
||||
.setActivityId(activityId)
|
||||
.setCodVvet(dto.getCodVvet())
|
||||
.setCodVzon(dto.getCodVzon())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
entityProcessor.processEntity(docLav, true, multiDBTransactionManager);
|
||||
|
||||
DtbDocr rowsDocLav = new DtbDocr();
|
||||
rowsDocLav.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(), docLav);
|
||||
|
||||
|
||||
collo
|
||||
.setActivityId(activityId)
|
||||
.setIdPesata(dto.getIdPesata())
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setCodDtip(EmsRestConstants.NULL)
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setCodMdep(dto.getCodMdepProd())
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setDataDocProvv(UtilityLocalDate.localDateToDate(dto.getDataDocProvv()))
|
||||
.setNumDocProvv(dto.getNumDocProvv())
|
||||
.setCodDtipProvv(dto.getCodDtipProvv())
|
||||
.setSerDocProvv(dto.getSerDocProvv())
|
||||
.setPesoKg(BigDecimal.ZERO)
|
||||
.setPesoNettoKg(BigDecimal.ZERO)
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
if (setupGest.getSetupBoolean("PVM", "PIAN_ACC_ROSSG", "NUM_DOC_AS_BARCODE")) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yy");
|
||||
collo.setBarcodeUl(dateFormat.format(UtilityLocalDate.localDateToDate(collo.getDataCollo())) + String.format("%06d", docLav.getNumDoc()));
|
||||
}
|
||||
|
||||
collo.setDataVers(dto.getDataVers());
|
||||
MtbColr rowToEmpty = new MtbColr();
|
||||
rowToEmpty.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(), collo);
|
||||
MtbColr row = collo.getMtbColr().stream().filter(x -> x.getCodMart().equalsIgnoreCase(dto.getCodMart())).findFirst().orElse(new MtbColr());
|
||||
if (row.getNumOrd() == null) {
|
||||
collo.getMtbColr().add(row);
|
||||
}
|
||||
row
|
||||
.setNumOrd(dto.getNumOrd())
|
||||
.setDataOrd(dto.getDataOrd())
|
||||
.setQtaCol(dto.getQtaCol())
|
||||
.setPartitaMag(dto.getPartitaRaccolta())
|
||||
.setPesoNettoKg(dto.getPesoNettoPedane())
|
||||
.setPesoLordoKg(dto.getPesoLordoCamion())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
if (!UtilityBigDecimal.isNullOrZero(dto.getNumCnf()))
|
||||
row.setNumCnf(dto.getNumCnf())
|
||||
.setQtaCnf(dto.getQtaCol().divide(dto.getNumCnf(), 2, RoundingMode.HALF_UP));
|
||||
sql = "SELECT art_tcol.* from mtb_aart " +
|
||||
" inner join mtb_tcol on mtb_tcol.cod_tcol = mtb_aart.cod_tcol_UI " +
|
||||
" inner join mtb_aart art_tcol on art_tcol.cod_mart = mtb_tcol.cod_mart " +
|
||||
" where mtb_aart.cod_mart = " + UtilityDB.valueToString(dto.getCodMart());
|
||||
MtbAart articoloBins = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbAart.class);
|
||||
|
||||
if (articoloBins != null) {
|
||||
DtbDocr docRowCar = new DtbDocr();
|
||||
docRowCar
|
||||
.setCodMart(articoloBins.getCodMart())
|
||||
.setNote("Casse scaricate")
|
||||
.setQtaDoc(dto.getNumCnf());
|
||||
docRowCar.setOperation(OperationType.INSERT);
|
||||
docLav.getDtbDocr().add(docRowCar);
|
||||
if (!UtilityBigDecimal.isNullOrZero(dto.getCnfRese())) {
|
||||
DtbDocr docRowSCar = new DtbDocr();
|
||||
docRowSCar
|
||||
if (articoloBins != null) {
|
||||
DtbDocr docRowCar = new DtbDocr();
|
||||
docRowCar
|
||||
.setCodMart(articoloBins.getCodMart())
|
||||
.setNote("Casse rese")
|
||||
.setQtaDoc(dto.getCnfRese().multiply(BigDecimal.valueOf(-1)));
|
||||
docRowSCar.setOperation(OperationType.INSERT);
|
||||
docLav.getDtbDocr().add(docRowSCar);
|
||||
.setNote("Casse scaricate")
|
||||
.setQtaDoc(dto.getNumCnf());
|
||||
docRowCar.setOperation(OperationType.INSERT);
|
||||
docLav.getDtbDocr().add(docRowCar);
|
||||
if (!UtilityBigDecimal.isNullOrZero(dto.getCnfRese())) {
|
||||
DtbDocr docRowSCar = new DtbDocr();
|
||||
docRowSCar
|
||||
.setCodMart(articoloBins.getCodMart())
|
||||
.setNote("Casse rese")
|
||||
.setQtaDoc(dto.getCnfRese().multiply(BigDecimal.valueOf(-1)));
|
||||
docRowSCar.setOperation(OperationType.INSERT);
|
||||
docLav.getDtbDocr().add(docRowSCar);
|
||||
}
|
||||
docLav.setOperation(OperationType.NO_OP);
|
||||
entityProcessor.processEntity(docLav, true, multiDBTransactionManager);
|
||||
UtilityEntity.throwEntityException(docLav);
|
||||
}
|
||||
docLav.setOperation(OperationType.NO_OP);
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Posizionamento merce">
|
||||
MtbAart articolo = new MtbAart();
|
||||
articolo.setCodMart(dto.getCodMart())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(articolo, multiDBTransactionManager);
|
||||
String valColRif = articolo.getCodMgrp() + "~" + articolo.getCodMsgr();
|
||||
String queryTipoPos =
|
||||
" SELECT ISNULL(stb_gest_setup_det.value,stb_gest_setup.value)\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" LEFT OUTER JOIN stb_gest_setup_det ON stb_gest_setup.gest_name = stb_gest_setup_det.gest_name AND\n" +
|
||||
" stb_gest_setup.section = stb_gest_setup_det.section AND\n" +
|
||||
" stb_gest_setup.key_section = stb_gest_setup_det.key_section AND\n" +
|
||||
" stb_gest_setup.tipo_setup = stb_gest_setup_det.tipo_setup AND\n" +
|
||||
" stb_gest_setup_det.val_col_rif = " + UtilityDB.valueToString(valColRif) + "\n" +
|
||||
" WHERE stb_gest_setup.gest_name = 'PVM'\n" +
|
||||
" AND stb_gest_setup.section = 'PIAN_ACC_ROSSG'\n" +
|
||||
" AND stb_gest_setup.key_section = 'TIPO_POSIZIONAMENTO_ACCETTAZIONE'\n";
|
||||
String tipoPosizionamento = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), queryTipoPos);
|
||||
String queryPos =
|
||||
" SELECT ISNULL(stb_gest_setup_det.value,stb_gest_setup.value)\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" LEFT OUTER JOIN stb_gest_setup_det ON stb_gest_setup.gest_name = stb_gest_setup_det.gest_name AND\n" +
|
||||
" stb_gest_setup.section = stb_gest_setup_det.section AND\n" +
|
||||
" stb_gest_setup.key_section = stb_gest_setup_det.key_section AND\n" +
|
||||
" stb_gest_setup.tipo_setup = stb_gest_setup_det.tipo_setup AND\n" +
|
||||
" stb_gest_setup_det.val_col_rif = " + UtilityDB.valueToString(valColRif) + "\n" +
|
||||
" WHERE stb_gest_setup.gest_name = 'PVM'\n" +
|
||||
" AND stb_gest_setup.section = 'PIAN_ACC_ROSSG'\n" +
|
||||
" AND stb_gest_setup.key_section = 'POSIZIONE_DEFAULT_ARTICOLO'\n";
|
||||
String posizioneDef = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), queryPos);
|
||||
MtbDepoPosizioni posizione = new MtbDepoPosizioni();
|
||||
posizione.setCodMdep(collo.getCodMdep())
|
||||
.setPosizione(posizioneDef)
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(posizione, multiDBTransactionManager);
|
||||
if (tipoPosizionamento.equalsIgnoreCase("POSIZIONAMENTO") && !posizione.isFlagMonoCollo()) {
|
||||
collo.setPosizione(posizioneDef);
|
||||
}
|
||||
|
||||
|
||||
entityProcessor.processEntity(collo, true, multiDBTransactionManager);
|
||||
UtilityEntity.throwEntityException(collo);
|
||||
if (tipoPosizionamento.equalsIgnoreCase("POSIZIONAMENTO") && posizione.isFlagMonoCollo()) {
|
||||
String ssccDest = null;
|
||||
if (posizione.isFlagMonoCollo()) {
|
||||
final List<String> barcodes = WMSUtility.retrieveBarcodesInPosizione(multiDBTransactionManager.getPrimaryConnection(), posizione.getPosizione());
|
||||
|
||||
if (barcodes.size() > 1) {
|
||||
throw new Exception("Ci sono " + barcodes.size() + " UL in posizione " + posizione.getPosizione() + " (MONO-UL)");
|
||||
} else if (!barcodes.isEmpty())
|
||||
ssccDest = barcodes.get(0);
|
||||
|
||||
}
|
||||
if (ssccDest == null) {
|
||||
MtbColt colloDest = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO()
|
||||
.setCodMdep(posizione.getCodMdep())
|
||||
.setPosizione(posizione.getPosizione()));
|
||||
ssccDest = colloDest.getBarcodeUl();
|
||||
}
|
||||
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(), collo, ssccDest, false, entityProcessor, requestDataDTO);
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
LoadColliDTO loadColliDTO = new LoadColliDTO();
|
||||
loadColliDTO
|
||||
.setCodDtip(docLav.getCodDtip())
|
||||
.setCodAnag(docLav.getCodAnag())
|
||||
.setSerDoc(docLav.getSerDoc())
|
||||
.setDataDoc(docLav.getDataDoc())
|
||||
.setNumDoc(docLav.getNumDoc())
|
||||
.setCodMdep(docLav.getCodMdep())
|
||||
.setColli(Collections.singletonList(collo));
|
||||
docLav = loadColliService.createDocFromColli(multiDBTransactionManager, loadColliDTO);
|
||||
entityProcessor.processEntity(docLav, true, multiDBTransactionManager);
|
||||
UtilityEntity.throwEntityException(docLav);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Posizionamento merce">
|
||||
MtbAart articolo = new MtbAart();
|
||||
articolo.setCodMart(dto.getCodMart())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(articolo, multiDBTransactionManager);
|
||||
String valColRif = articolo.getCodMgrp() + "~" + articolo.getCodMsgr();
|
||||
String queryTipoPos =
|
||||
" SELECT ISNULL(stb_gest_setup_det.value,stb_gest_setup.value)\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" LEFT OUTER JOIN stb_gest_setup_det ON stb_gest_setup.gest_name = stb_gest_setup_det.gest_name AND\n" +
|
||||
" stb_gest_setup.section = stb_gest_setup_det.section AND\n" +
|
||||
" stb_gest_setup.key_section = stb_gest_setup_det.key_section AND\n" +
|
||||
" stb_gest_setup.tipo_setup = stb_gest_setup_det.tipo_setup AND\n" +
|
||||
" stb_gest_setup_det.val_col_rif = " + UtilityDB.valueToString(valColRif) + "\n" +
|
||||
" WHERE stb_gest_setup.gest_name = 'PVM'\n" +
|
||||
" AND stb_gest_setup.section = 'PIAN_ACC_ROSSG'\n" +
|
||||
" AND stb_gest_setup.key_section = 'TIPO_POSIZIONAMENTO_ACCETTAZIONE'\n";
|
||||
String tipoPosizionamento = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), queryTipoPos);
|
||||
String queryPos =
|
||||
" SELECT ISNULL(stb_gest_setup_det.value,stb_gest_setup.value)\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" LEFT OUTER JOIN stb_gest_setup_det ON stb_gest_setup.gest_name = stb_gest_setup_det.gest_name AND\n" +
|
||||
" stb_gest_setup.section = stb_gest_setup_det.section AND\n" +
|
||||
" stb_gest_setup.key_section = stb_gest_setup_det.key_section AND\n" +
|
||||
" stb_gest_setup.tipo_setup = stb_gest_setup_det.tipo_setup AND\n" +
|
||||
" stb_gest_setup_det.val_col_rif = " + UtilityDB.valueToString(valColRif) + "\n" +
|
||||
" WHERE stb_gest_setup.gest_name = 'PVM'\n" +
|
||||
" AND stb_gest_setup.section = 'PIAN_ACC_ROSSG'\n" +
|
||||
" AND stb_gest_setup.key_section = 'POSIZIONE_DEFAULT_ARTICOLO'\n";
|
||||
String posizioneDef = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), queryPos);
|
||||
MtbDepoPosizioni posizione = new MtbDepoPosizioni();
|
||||
posizione.setCodMdep(collo.getCodMdep())
|
||||
.setPosizione(posizioneDef)
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(posizione, multiDBTransactionManager);
|
||||
if (tipoPosizionamento.equalsIgnoreCase("POSIZIONAMENTO") && !posizione.isFlagMonoCollo()) {
|
||||
collo.setPosizione(posizioneDef);
|
||||
}
|
||||
|
||||
|
||||
entityProcessor.processEntity(collo, true, multiDBTransactionManager);
|
||||
UtilityEntity.throwEntityException(collo);
|
||||
if (tipoPosizionamento.equalsIgnoreCase("POSIZIONAMENTO") && posizione.isFlagMonoCollo()) {
|
||||
MtbColt colloDest = null;
|
||||
if (posizione.isFlagMonoCollo()) {
|
||||
colloDest = getMonoColloPosizione(posizione);
|
||||
//alla creazione della bolla (DDT) creare documento di acquisto e scarico di materiale alla pianta
|
||||
if (!UtilityBigDecimal.isNullOrZero(dto.getQtaCol()) && !UtilityBigDecimal.isNullOrZero(dto.getPrezzoFinale())) {
|
||||
DtbOrdt ordAcq = getOrdineAcquistoCollegato(dto.getGestione(), UtilityLocalDate.localDateToDate(dto.getDataOrd()), dto.getNumOrd());
|
||||
DtbDoct ddt = generaDdtAcq(dto, ordAcq, activityId);
|
||||
DtbDoct slav = generaScaricoLav(dto, ordAcq, activityId);
|
||||
}
|
||||
if (colloDest == null) {
|
||||
colloDest = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO().setCodMdep(posizione.getCodMdep()).setPosizione(posizione.getPosizione()));
|
||||
}
|
||||
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(), collo, colloDest, false, entityProcessor, requestDataDTO);
|
||||
return collo;
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
List<MtbColt> lista = new ArrayList<>();
|
||||
lista.add(collo);
|
||||
LoadColliDTO loadColliDTO = new LoadColliDTO();
|
||||
loadColliDTO
|
||||
.setCodDtip(docLav.getCodDtip())
|
||||
.setCodAnag(docLav.getCodAnag())
|
||||
.setSerDoc(docLav.getSerDoc())
|
||||
.setDataDoc(docLav.getDataDoc())
|
||||
.setNumDoc(docLav.getNumDoc())
|
||||
.setCodMdep(docLav.getCodMdep())
|
||||
.setColli(lista);
|
||||
docLav = loadColliService.createDocFromColli(multiDBTransactionManager, loadColliDTO);
|
||||
entityProcessor.processEntity(docLav, true, multiDBTransactionManager);
|
||||
UtilityEntity.throwEntityException(docLav);
|
||||
|
||||
|
||||
//alla creazione della bolla (DDT) creare documento di acquisto e scarico di materiale alla pianta
|
||||
if (!UtilityBigDecimal.isNullOrZero(dto.getQtaCol()) && !UtilityBigDecimal.isNullOrZero(dto.getPrezzoFinale())) {
|
||||
DtbOrdt ordAcq = getOrdineAcquistoCollegato(dto.getGestione(), UtilityLocalDate.localDateToDate(dto.getDataOrd()), dto.getNumOrd());
|
||||
DtbDoct ddt = generaDdtAcq(dto, ordAcq, activityId);
|
||||
DtbDoct slav = generaScaricoLav(dto, ordAcq, activityId);
|
||||
}
|
||||
|
||||
return collo;
|
||||
}
|
||||
|
||||
private boolean deleteOldCertificatoIfExists(String activityId, String codDtipLavCar, AccettazioneOrtoFruttaDTO dto) throws Exception {
|
||||
|
||||
@@ -612,7 +612,7 @@ public class ProductionService {
|
||||
if (mtbColts != null && !mtbColts.isEmpty()) {
|
||||
for (MtbColt mtbColt : mtbColts) {
|
||||
mtbColt.setCodDtip(setupCruscotto.get("COD_DTIP_SCAR"))
|
||||
.setDataDoc(dataProd);
|
||||
.setDataDoc(UtilityLocalDate.localDateFromDate(dataProd));
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
entitiesToSave.addAll(mtbColts);
|
||||
@@ -1652,13 +1652,13 @@ public class ProductionService {
|
||||
return;
|
||||
|
||||
// raggruppo per articolo/commessa/partita/ordine
|
||||
List<ArticoloPartitaCommessaDTO> listToCheck = documentiLav
|
||||
List<ArticoloPartitaCommessaOrdineDTO> listToCheck = documentiLav
|
||||
.stream()
|
||||
.map(x -> new ArticoloPartitaCommessaDTO(x.getCodMart(), x.getCodJcom(), x.getPartitaMag(), x.getDataOrd(), x.getNumOrd()))
|
||||
.map(x -> new ArticoloPartitaCommessaOrdineDTO(x.getCodMart(), x.getCodJcom(), x.getPartitaMag(), x.getDataOrd(), x.getNumOrd()))
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (ArticoloPartitaCommessaDTO dataToCheck : listToCheck) {
|
||||
for (ArticoloPartitaCommessaOrdineDTO dataToCheck : listToCheck) {
|
||||
//prendo dettaglio costi per articolo commessa partita
|
||||
List<DettaglioCostiDTO> dettaglioCosti = getDettaglioCostiProd(dataToCheck.getCodMart(), dataToCheck.getPartitaMag(), dataToCheck.getCodJcom(), null, null);
|
||||
if (UtilityList.isNullOrEmpty(dettaglioCosti))
|
||||
@@ -1677,7 +1677,7 @@ public class ProductionService {
|
||||
|
||||
//aggiorno le righe dei vari documenti (mantenendo lo stesso filtro ovviamente)
|
||||
List<DtbDocr> righeDaAggiornare = documentiLav.stream()
|
||||
.filter(x -> new ArticoloPartitaCommessaDTO(x.getCodMart(), x.getCodJcom(), x.getPartitaMag(), x.getDataOrd(), x.getNumOrd()).equals(dataToCheck))
|
||||
.filter(x -> new ArticoloPartitaCommessaOrdineDTO(x.getCodMart(), x.getCodJcom(), x.getPartitaMag(), x.getDataOrd(), x.getNumOrd()).equals(dataToCheck))
|
||||
.peek(r -> {
|
||||
r.setValUnt(costoProdUnt)
|
||||
.setCostoUnt(costoProdUnt)
|
||||
@@ -1764,6 +1764,7 @@ public class ProductionService {
|
||||
.setPartitaMag(partitaMag)
|
||||
.setPartitaMagProd(partitaMagProd)
|
||||
.setCodMart(codMart)
|
||||
.setDataProd(dto.getDataProd())
|
||||
.setDataScad(UtilityLocalDate.localDateToDate(dataScad));
|
||||
|
||||
boolean setDescrizione = setupGest.getSetupBoolean("MTB_PARTITA_MAG", "SETUP", "SET_DESCRIZIONE_FROM_NOTE_ORDINE");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package it.integry.ems.production.service;
|
||||
|
||||
import it.integry.ems.production.dto.DeleteCaricoDaProduzioneRequestDTO;
|
||||
import it.integry.ems.production.dto.RettificaProdDTO;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.generic.dto.RettificaULDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGenericService;
|
||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||
@@ -9,12 +11,15 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.PrinterService;
|
||||
import it.integry.ems.service.ReportProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.entity.DtbDoct;
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
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.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,6 +29,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
@@ -93,31 +99,53 @@ public class ProductionWarehouseService {
|
||||
}
|
||||
|
||||
|
||||
public void deleteColloDaProduzione(MtbColt mtbColt) throws Exception {
|
||||
public void deleteCaricoDaProduzione(DeleteCaricoDaProduzioneRequestDTO caricoToDelete) throws Exception {
|
||||
|
||||
List<MtbColt> mtbColtsToDelete = new ArrayList<>();
|
||||
if (UtilityString.isNullOrEmpty(caricoToDelete.getBarcodeUl()) || UtilityString.isNullOrEmpty(caricoToDelete.getCodMart()))
|
||||
throw new IllegalArgumentException("Il barcode_ul_out e il cod_mart sono obbligatori per la cancellazione del carico da produzione");
|
||||
|
||||
String query = "SELECT num_collo, data_collo, ser_collo, gestione " +
|
||||
"FROM " + MtbColr.ENTITY + " " +
|
||||
"WHERE num_collo_rif = " + UtilityDB.valueToString(mtbColt.getNumCollo()) + " " +
|
||||
" AND data_collo_rif = " + UtilityDB.valueToString(mtbColt.getDataCollo()) + " " +
|
||||
" AND ser_collo_rif = " + UtilityDB.valueToString(mtbColt.getSerCollo()) + " " +
|
||||
" AND gestione_rif = " + UtilityDB.valueToString(mtbColt.getGestione());
|
||||
|
||||
List<MtbColt> mtbColtsRefs = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), query, MtbColt.class);
|
||||
String sql = "SELECT * \n" +
|
||||
"FROM " + MtbColr.ENTITY + "\n " +
|
||||
"WHERE (barcode_ul_out = " + UtilityDB.valueToString(caricoToDelete.getBarcodeUl()) + " OR barcode_ul_in = " + UtilityDB.valueToString(caricoToDelete.getBarcodeUl()) + ") \n " +
|
||||
" AND cod_mart = " + UtilityDB.valueToString(caricoToDelete.getCodMart()) + "\n " +
|
||||
(!UtilityString.isNullOrEmpty(caricoToDelete.getPartitaMag()) ? " AND partita_mag = " + UtilityDB.valueToString(caricoToDelete.getPartitaMag()) : "") + "\n " +
|
||||
(!UtilityString.isNullOrEmpty(caricoToDelete.getCodJcom()) ? " AND cod_jcom = " + UtilityDB.valueToString(caricoToDelete.getCodJcom()) : "") + "\n " +
|
||||
(!UtilityString.isNullOrEmpty(caricoToDelete.getCodCol()) ? " AND cod_col = " + UtilityDB.valueToString(caricoToDelete.getCodCol()) : "") + "\n " +
|
||||
(!UtilityString.isNullOrEmpty(caricoToDelete.getCodTagl()) ? " AND cod_tagl = " + UtilityDB.valueToString(caricoToDelete.getCodTagl()) : "");
|
||||
|
||||
if (mtbColtsRefs != null && !mtbColtsRefs.isEmpty()) {
|
||||
for (MtbColt mtbColtRef :
|
||||
mtbColtsRefs) {
|
||||
mtbColtRef.setOperation(OperationType.DELETE);
|
||||
List<MtbColr> mtbColrsToBeDeleted = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColr.class);
|
||||
|
||||
|
||||
if(mtbColrsToBeDeleted != null && !mtbColrsToBeDeleted.isEmpty()) {
|
||||
mtbColrsToBeDeleted.forEach(x -> x.setOperation(OperationType.DELETE));
|
||||
|
||||
final List<MtbColt> mtbColtsToDelete = mtbColrsToBeDeleted.stream()
|
||||
.map(mtbColr -> (MtbColtKey) mtbColr.getKey())
|
||||
.distinct()
|
||||
.map(x -> {
|
||||
MtbColt mtbColt = new MtbColt(x);
|
||||
mtbColt.setMtbColr(mtbColrsToBeDeleted.stream()
|
||||
.filter(y -> y.getKey().equals(x))
|
||||
.collect(Collectors.toList()));
|
||||
mtbColt.setOperation(OperationType.UPDATE);
|
||||
return mtbColt;
|
||||
}
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
entityProcessor.processEntityList(mtbColtsToDelete, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(mtbColtsToDelete);
|
||||
|
||||
for (MtbColt mtbColt : mtbColtsToDelete) {
|
||||
if (WMSUtility.canULBeDeleted(mtbColt, multiDBTransactionManager)) {
|
||||
WMSUtility.deleteUL(mtbColt, entityProcessor, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
|
||||
mtbColtsToDelete.addAll(mtbColtsRefs);
|
||||
}
|
||||
|
||||
mtbColt.setOperation(OperationType.DELETE);
|
||||
mtbColtsToDelete.add(mtbColt);
|
||||
|
||||
entityProcessor.processEntityList(mtbColtsToDelete, true);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +525,21 @@ public class PvmController {
|
||||
return ServiceRestResponse.createPositiveResponse(pvmService.getCostoProdottoDatiCommerciali(codProd, dataValidita.toInstant(), codVlis));
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_COLLO_BY_BARCODE, method = RequestMethod.POST)
|
||||
@PostMapping(value = EmsRestConstants.PATH_GET_COLLI_BY_BARCODES)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse getColliByBarcodes(
|
||||
@RequestBody GetColliByBarcodesRequestDTO requestData,
|
||||
@RequestParam(required = false, defaultValue = "true") boolean throwExcIfNull) throws Exception {
|
||||
|
||||
List<MtbColt> foundColli = pvmService.getColliByBarcodes(requestData.getBarcodes(), requestData.isOnlyResiduo());
|
||||
|
||||
if ((foundColli == null || foundColli.isEmpty()) && throwExcIfNull)
|
||||
throw new Exception("Nessun bancale trovato");
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(foundColli);
|
||||
}
|
||||
|
||||
@PostMapping(value = EmsRestConstants.PATH_GET_COLLO_BY_BARCODE)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse getColloByBarcode(
|
||||
HttpServletRequest request,
|
||||
@@ -548,7 +562,7 @@ public class PvmController {
|
||||
@RequestParam(required = false, defaultValue = "true") boolean throwExcIfNull,
|
||||
@RequestBody MtbColt mtbColt) throws Exception {
|
||||
|
||||
MtbColt collo = pvmService.getColloInGiac(mtbColt, onlyResiduo);
|
||||
MtbColt collo = pvmService.getColloInGiac(mtbColt.getBarcodeUl(), onlyResiduo);
|
||||
if (collo == null && throwExcIfNull) throw new Exception("Nessun bancale trovato");
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(collo);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.retail.pvmRetail.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GetColliByBarcodesRequestDTO {
|
||||
|
||||
private List<String> barcodes;
|
||||
private boolean onlyResiduo;
|
||||
|
||||
|
||||
public List<String> getBarcodes() {
|
||||
return barcodes;
|
||||
}
|
||||
|
||||
public GetColliByBarcodesRequestDTO setBarcodes(List<String> barcodes) {
|
||||
this.barcodes = barcodes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isOnlyResiduo() {
|
||||
return onlyResiduo;
|
||||
}
|
||||
|
||||
public GetColliByBarcodesRequestDTO setOnlyResiduo(boolean onlyResiduo) {
|
||||
this.onlyResiduo = onlyResiduo;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -203,13 +203,7 @@ public class OrdineInevasoDTO {
|
||||
@SqlField(value = "exist_collo")
|
||||
@JsonProperty("existCollo")
|
||||
@JsonSerialize
|
||||
private String existCollo;
|
||||
|
||||
|
||||
@SqlField(value = "exist_collo_boolean")
|
||||
@JsonProperty("existColloBoolean")
|
||||
@JsonSerialize
|
||||
private boolean existColloBoolean;
|
||||
private boolean existCollo;
|
||||
|
||||
|
||||
@SqlField(value = "flag_evaso")
|
||||
@@ -561,24 +555,15 @@ public class OrdineInevasoDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getExistCollo() {
|
||||
public boolean isExistCollo() {
|
||||
return existCollo;
|
||||
}
|
||||
|
||||
public OrdineInevasoDTO setExistCollo(String existCollo) {
|
||||
public OrdineInevasoDTO setExistCollo(boolean existCollo) {
|
||||
this.existCollo = existCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isExistColloBoolean() {
|
||||
return existColloBoolean;
|
||||
}
|
||||
|
||||
public OrdineInevasoDTO setExistColloBoolean(boolean existColloBoolean) {
|
||||
this.existColloBoolean = existColloBoolean;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagEvaso() {
|
||||
return flagEvaso;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import it.integry.ems.retail.dto.AnomalieResiDTO;
|
||||
import it.integry.ems.retail.dto.OrdChkConsDTO;
|
||||
import it.integry.ems.retail.pvmRetail.dto.*;
|
||||
import it.integry.ems.retail.pvmRetail.dto.save.DocFromPickingDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||
import it.integry.ems.rules.completing.OrderRules;
|
||||
import it.integry.ems.service.EmsServices;
|
||||
@@ -117,6 +119,9 @@ public class PvmService {
|
||||
@Autowired
|
||||
private UserSession userSession;
|
||||
|
||||
@Autowired
|
||||
private WMSGiacenzaULService wmsGiacenzaULService;
|
||||
|
||||
public List<OrdChkConsDTO> chkDisponibilitaCons(Date dataCons, String citta) throws Exception {
|
||||
String profileDb = null;
|
||||
UserDTO userData = systemService.login(requestDataDTO.getUsername(), requestDataDTO.getPassword(), "", profileDb);
|
||||
@@ -1508,89 +1513,28 @@ public class PvmService {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Spostare servizion in WmsGenericService (?)
|
||||
public MtbColt getColloByBarcode(String codBarreCollo, boolean onlyResiduo) throws Exception {
|
||||
public List<MtbColt> getColliByBarcodes(List<String> barcodes, boolean onlyResiduo) throws Exception {
|
||||
if (barcodes == null || barcodes.isEmpty()) return Collections.emptyList();
|
||||
|
||||
MtbColt mtbColt = getColloByExternalBarcode(codBarreCollo);
|
||||
List<MtbColt> colli = new ArrayList<>();
|
||||
|
||||
if (mtbColt == null) {
|
||||
|
||||
HashMap<String, Object> datiCollo = new HashMap<>();
|
||||
if (codBarreCollo.startsWith("U")) {
|
||||
datiCollo.put("gestione", null);
|
||||
datiCollo.put("anno", Integer.parseInt(codBarreCollo.substring(1, 3)));
|
||||
datiCollo.put("num", Integer.parseInt(codBarreCollo.substring(3, 10)));
|
||||
|
||||
if (codBarreCollo.length() > 10) {
|
||||
datiCollo.put("serie", codBarreCollo.substring(10));
|
||||
} else {
|
||||
datiCollo.put("serie", "UL");
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
datiCollo = new HashMap<>();
|
||||
|
||||
codBarreCollo = codBarreCollo.substring(0, codBarreCollo.length() - 1); //Rimuovo il check digit finale
|
||||
|
||||
datiCollo.put("num", Integer.parseInt(codBarreCollo.substring(codBarreCollo.length() - 5)));
|
||||
datiCollo.put("anno", Integer.parseInt(codBarreCollo.substring(codBarreCollo.length() - 7, codBarreCollo.length() - 5)));
|
||||
int gestioneInt = Integer.parseInt("" + codBarreCollo.charAt(codBarreCollo.length() - 8));
|
||||
|
||||
int numMultiplier = 0;
|
||||
if (codBarreCollo.length() >= 9) {
|
||||
numMultiplier = Integer.parseInt("" + codBarreCollo.charAt(codBarreCollo.length() - 9)) * 100000;
|
||||
}
|
||||
|
||||
|
||||
datiCollo.put("num", ((Integer) datiCollo.get("num")) + numMultiplier);
|
||||
|
||||
String gestione;
|
||||
|
||||
try {
|
||||
switch (gestioneInt) {
|
||||
case 1:
|
||||
gestione = "A";
|
||||
break;
|
||||
case 2:
|
||||
gestione = "L";
|
||||
break;
|
||||
case 3:
|
||||
gestione = "V";
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Il collo letto ha un errore nella gestione");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new Exception("Il collo letto ha un errore nella gestione");
|
||||
}
|
||||
|
||||
datiCollo.put("gestione", gestione);
|
||||
datiCollo.put("serie", "/");
|
||||
for (String barcode : barcodes) {
|
||||
MtbColt mtbColt = getColloByBarcode(barcode, onlyResiduo);
|
||||
if (mtbColt != null) {
|
||||
colli.add(mtbColt);
|
||||
}
|
||||
|
||||
String query;
|
||||
|
||||
String whereCondGestione = "";
|
||||
|
||||
if (datiCollo.containsKey("gestione") && datiCollo.get("gestione") != null) {
|
||||
whereCondGestione = " gestione = " + UtilityDB.valueToString(datiCollo.get("gestione")) + " AND ";
|
||||
}
|
||||
|
||||
query = "SELECT * "
|
||||
+ "FROM mtb_colt "
|
||||
+ "WHERE "
|
||||
+ whereCondGestione
|
||||
+ " num_collo = " + UtilityDB.valueToString(datiCollo.get("num")) + " AND "
|
||||
+ " RIGHT(YEAR(data_collo), 2) = " + UtilityDB.valueToString(datiCollo.get("anno")) + " AND "
|
||||
+ " ser_collo = " + UtilityDB.valueToString(datiCollo.get("serie"));
|
||||
|
||||
|
||||
mtbColt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), query, MtbColt.class);
|
||||
}
|
||||
|
||||
return colli;
|
||||
}
|
||||
|
||||
|
||||
//TODO: Spostare servizio in WmsGenericService (?)
|
||||
public MtbColt getColloByBarcode(String codBarreCollo, boolean onlyResiduo) throws Exception {
|
||||
MtbColt mtbColt = getColloByExternalBarcode(codBarreCollo);
|
||||
|
||||
if (mtbColt == null) return null;
|
||||
else return getColloInGiac(mtbColt, onlyResiduo);
|
||||
else return getColloInGiac(mtbColt.getBarcodeUl(), onlyResiduo);
|
||||
}
|
||||
|
||||
private MtbColt getColloByExternalBarcode(String barcode) throws Exception {
|
||||
@@ -1601,54 +1545,42 @@ public class PvmService {
|
||||
model = new Ean128Model();
|
||||
}
|
||||
String sql = Query.format("SELECT * FROM " + MtbColt.ENTITY +
|
||||
" WHERE barcode_ul = %s", barcode);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(model.Sscc) && !model.Sscc.equalsIgnoreCase(barcode)) {
|
||||
sql += " OR barcode_ul = " + UtilityDB.valueToString(model.Sscc);
|
||||
}
|
||||
" WHERE barcode_ul = %s", UtilityString.isNull(model.Sscc, barcode));
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
}
|
||||
|
||||
public MtbColt getColloInGiac(MtbColt mtbColt, boolean onlyResiduo) throws Exception {
|
||||
|
||||
HashMap<String, Object> datiCollo = new HashMap<>();
|
||||
|
||||
datiCollo.put("gestione", mtbColt.getGestione());
|
||||
datiCollo.put("serie", mtbColt.getSerCollo());
|
||||
datiCollo.put("num", mtbColt.getNumCollo());
|
||||
datiCollo.put("anno", mtbColt.getDataCollo().getYear() - 2000);
|
||||
|
||||
String whereCondGestione = "";
|
||||
|
||||
if (datiCollo.containsKey("gestione") && datiCollo.get("gestione") != null) {
|
||||
whereCondGestione = " gestione = " + UtilityDB.valueToString(datiCollo.get("gestione")) + " AND ";
|
||||
}
|
||||
public MtbColt getColloInGiac(String barcodeUl, boolean onlyResiduo) throws Exception {
|
||||
|
||||
if (UtilityString.isNullOrEmpty(barcodeUl))
|
||||
return null;
|
||||
|
||||
String query;
|
||||
MtbColt mtbColtToReturn;
|
||||
|
||||
String mtbColtQuery = Query.format("SELECT * " +
|
||||
"FROM " + MtbColt.ENTITY + " " +
|
||||
"WHERE barcode_ul = {}", barcodeUl);
|
||||
|
||||
mtbColtToReturn = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), mtbColtQuery, MtbColt.class);
|
||||
|
||||
if (!onlyResiduo) {
|
||||
String mtbColrsSql = Query.format("SELECT mtb_colr.*, " +
|
||||
"mtb_aart.descrizione AS descrizione, mtb_partita_mag.flag_stato as flag_stato_partita " +
|
||||
"FROM mtb_colr " +
|
||||
"LEFT OUTER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart " +
|
||||
"LEFT OUTER JOIN mtb_partita_mag ON mtb_colr.cod_mart = mtb_partita_mag.cod_mart AND mtb_colr.partita_mag = mtb_partita_mag.partita_mag " +
|
||||
"WHERE mtb_colr.gestione = {} AND mtb_colr.ser_collo = {} AND mtb_colr.data_collo = {} AND mtb_colr.num_collo = {}",
|
||||
mtbColtToReturn.getGestione(),
|
||||
mtbColtToReturn.getSerCollo(),
|
||||
mtbColtToReturn.getDataCollo(),
|
||||
mtbColtToReturn.getNumCollo());
|
||||
|
||||
|
||||
String queryrows = "SELECT mtb_colr.*, mtb_aart.descrizione AS descrizione, mtb_partita_mag.flag_stato as flag_stato_partita "
|
||||
+ "FROM mtb_colr "
|
||||
+ "LEFT OUTER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart "
|
||||
+ "LEFT OUTER JOIN mtb_partita_mag ON mtb_colr.cod_mart = mtb_partita_mag.cod_mart AND mtb_colr.partita_mag = mtb_partita_mag.partita_mag "
|
||||
+ "WHERE "
|
||||
+ whereCondGestione
|
||||
+ " num_collo = " + UtilityDB.valueToString(datiCollo.get("num")) + " AND "
|
||||
+ " RIGHT(YEAR(data_collo), 2) = " + UtilityDB.valueToString(datiCollo.get("anno")) + " AND "
|
||||
+ " ser_collo = " + UtilityDB.valueToString(datiCollo.get("serie"));
|
||||
|
||||
PreparedStatement psRows = multiDBTransactionManager.prepareStatement(queryrows);
|
||||
ResultSet rsRows = psRows.executeQuery();
|
||||
|
||||
List<HashMap<String, Object>> mapList = ResultSetMapper.mapResultSetToHashMap(rsRows);
|
||||
final List<HashMap<String, Object>> mtbColrValues = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), mtbColrsSql);
|
||||
|
||||
List<MtbColr> rows = new ArrayList<MtbColr>();
|
||||
|
||||
for (HashMap<String, Object> mapRow : mapList) {
|
||||
for (HashMap<String, Object> mapRow : mtbColrValues) {
|
||||
MtbColr row = new MtbColr();
|
||||
|
||||
row.setGestione(UtilityHashMap.getValueIfExists(mapRow, "gestione"));
|
||||
@@ -1672,62 +1604,60 @@ public class PvmService {
|
||||
row.setDataColloRif(UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(mapRow, "data_collo_rif")));
|
||||
row.setNumColloRif(UtilityHashMap.getValueIfExists(mapRow, "num_collo_rif"));
|
||||
row.setSerColloRif(UtilityHashMap.getValueIfExists(mapRow, "ser_collo_rif"));
|
||||
row.setBarcodeUlIn(UtilityHashMap.getValueIfExists(mapRow, "barcode_ul_in"));
|
||||
row.setCodMdepIn(UtilityHashMap.getValueIfExists(mapRow, "cod_mdep_in"));
|
||||
row.setPosizioneIn(UtilityHashMap.getValueIfExists(mapRow, "posizione_in"));
|
||||
row.setOperation(OperationType.SELECT_OBJECT);
|
||||
row.setOnlyPkMaster(false);
|
||||
|
||||
rows.add(row);
|
||||
}
|
||||
rsRows.close();
|
||||
psRows.close();
|
||||
|
||||
mtbColt.setMtbColr(rows);
|
||||
mtbColtToReturn.setMtbColr(rows);
|
||||
} else {
|
||||
query = "SELECT mvw_sitart_udc_det_inventario.*, mtb_partita_mag.data_scad " +
|
||||
" FROM mvw_sitart_udc_det_inventario " +
|
||||
" LEFT OUTER JOIN mtb_partita_mag " +
|
||||
" ON mvw_sitart_udc_det_inventario.cod_mart = mtb_partita_mag.cod_mart " +
|
||||
" AND mvw_sitart_udc_det_inventario.partita_mag = mtb_partita_mag.partita_mag " +
|
||||
"WHERE " +
|
||||
whereCondGestione +
|
||||
" num_collo = " + UtilityDB.valueToString(datiCollo.get("num")) + " AND " +
|
||||
" RIGHT(YEAR(data_collo), 2) = " + UtilityDB.valueToString(datiCollo.get("anno")) + " AND " +
|
||||
" ser_collo = " + UtilityDB.valueToString(datiCollo.get("serie"));
|
||||
|
||||
PreparedStatement ps = multiDBTransactionManager.getPrimaryConnection().prepareStatement(query);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
final List<MvwSitArtUdcDetInventarioDTO> giacenzaList = wmsGiacenzaULService.retrieveArtsInGiacenzaByBarcodeUl(multiDBTransactionManager.getPrimaryConnection(), barcodeUl);
|
||||
|
||||
List<HashMap<String, Object>> mapList = ResultSetMapper.mapResultSetToHashMap(rs);
|
||||
|
||||
if (!mapList.isEmpty()) {
|
||||
if (giacenzaList != null && !giacenzaList.isEmpty()) {
|
||||
List<MtbColr> rows = new ArrayList<MtbColr>();
|
||||
|
||||
for (HashMap<String, Object> mapRow : mapList) {
|
||||
for (MvwSitArtUdcDetInventarioDTO item : giacenzaList) {
|
||||
MtbColr row = new MtbColr();
|
||||
|
||||
row.setDataScadPartita(UtilityHashMap.getValueIfExists(mapRow, "data_scad"));
|
||||
row.setCodMart(UtilityHashMap.getValueIfExists(mapRow, "cod_mart"));
|
||||
row.setCodJcom(UtilityHashMap.getValueIfExists(mapRow, "cod_jcom"));
|
||||
row.setPartitaMag(UtilityHashMap.getValueIfExists(mapRow, "partita_mag"));
|
||||
row.setQtaCol(UtilityHashMap.getValueIfExists(mapRow, "qta_col"));
|
||||
row.setQtaCnf(UtilityHashMap.getValueIfExists(mapRow, "qta_cnf"));
|
||||
row.setNumCnf(UtilityHashMap.getValueIfExists(mapRow, "num_cnf"));
|
||||
row.setDescrizione(UtilityHashMap.getValueIfExists(mapRow, "descrizione_estesa"));
|
||||
row.setPesoNettoKg(UtilityHashMap.getValueIfExists(mapRow, "peso_netto_kg"));
|
||||
row.setPesoLordoKg(UtilityHashMap.getValueIfExists(mapRow, "peso_lordo_kg"));
|
||||
row.setDataScadPartita(item.getDataScad());
|
||||
row.setCodMart(item.getCodMart());
|
||||
row.setCodJcom(item.getCodJcom());
|
||||
row.setPartitaMag(item.getPartitaMag());
|
||||
row.setQtaCol(item.getQtaCol());
|
||||
row.setQtaCnf(item.getQtaCnf());
|
||||
row.setNumCnf(item.getNumCnf());
|
||||
row.setDescrizione(item.getDescrizioneEstesa());
|
||||
row.setPesoNettoKg(item.getPesoNettoKG());
|
||||
row.setPesoLordoKg(item.getPesoLordoKG());
|
||||
row.setOperation(OperationType.SELECT_OBJECT);
|
||||
row.setOnlyPkMaster(false);
|
||||
row.setBarcodeUlIn(item.getBarcodeUl());
|
||||
row.setCodMdepIn(item.getCodMdep());
|
||||
row.setPosizioneIn(item.getPosizione());
|
||||
|
||||
rows.add(row);
|
||||
}
|
||||
mtbColt.setMtbColr(rows);
|
||||
mtbColtToReturn.setMtbColr(rows);
|
||||
|
||||
if (!giacenzaList.isEmpty()) {
|
||||
MvwSitArtUdcDetInventarioDTO firstRow = giacenzaList.get(0);
|
||||
|
||||
mtbColtToReturn.setCodMdep(firstRow.getCodMdep())
|
||||
.setPosizione(firstRow.getPosizione());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (mtbColt != null) {
|
||||
if (mtbColtToReturn != null && mtbColtToReturn.getMtbColr() != null) {
|
||||
|
||||
List<HashMap<String, Object>> mtbPartitaMagListHashMap = Stream.of(mtbColt.getMtbColr())
|
||||
List<HashMap<String, Object>> mtbPartitaMagListHashMap = mtbColtToReturn.getMtbColr().stream()
|
||||
.filter(x -> !UtilityString.isNullOrEmpty(x.getPartitaMag()))
|
||||
.map(mtbColr -> {
|
||||
MtbPartitaMag mtbPartitaMag = new MtbPartitaMag();
|
||||
@@ -1744,26 +1674,20 @@ public class PvmService {
|
||||
|
||||
return item;
|
||||
})
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (mtbPartitaMagListHashMap != null && !mtbPartitaMagListHashMap.isEmpty()) {
|
||||
if (!mtbPartitaMagListHashMap.isEmpty()) {
|
||||
String partitaMagQuery = "SELECT * FROM mtb_partita_mag WHERE " + UtilityQuery.concatFieldListInWhereCond(mtbPartitaMagListHashMap);
|
||||
ps = multiDBTransactionManager.getPrimaryConnection().prepareStatement(partitaMagQuery);
|
||||
rs = ps.executeQuery();
|
||||
|
||||
ResultSetMapper rsPartMapper = new ResultSetMapper();
|
||||
List<MtbPartitaMag> listPartite = rsPartMapper.mapResultSetToList(rs, MtbPartitaMag.class, OperationType.SELECT_OBJECT);
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
List<MtbPartitaMag> listPartite = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), partitaMagQuery, MtbPartitaMag.class);
|
||||
|
||||
if (listPartite != null) {
|
||||
for (final MtbColr mtbColr : mtbColt.getMtbColr()) {
|
||||
List<MtbPartitaMag> selectedPartite = Stream.of(listPartite)
|
||||
for (final MtbColr mtbColr : mtbColtToReturn.getMtbColr()) {
|
||||
List<MtbPartitaMag> selectedPartite = listPartite.stream()
|
||||
.filter(mtbPartitaMag -> mtbPartitaMag.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()) &&
|
||||
(Objects.equals(mtbPartitaMag.getPartitaMag(), mtbColr.getPartitaMag()) || mtbPartitaMag.getPartitaMag().equalsIgnoreCase(mtbColr.getPartitaMag()))).toList();
|
||||
(Objects.equals(mtbPartitaMag.getPartitaMag(), mtbColr.getPartitaMag()) || mtbPartitaMag.getPartitaMag().equalsIgnoreCase(mtbColr.getPartitaMag())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (selectedPartite != null && selectedPartite.size() == 1) {
|
||||
if (selectedPartite.size() == 1) {
|
||||
mtbColr.setMtbPartitaMag(selectedPartite.get(0));
|
||||
}
|
||||
}
|
||||
@@ -1772,11 +1696,11 @@ public class PvmService {
|
||||
}
|
||||
}
|
||||
|
||||
if (mtbColt != null) {
|
||||
mtbColt.setOnlyPkMaster(false);
|
||||
mtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
if (mtbColtToReturn != null) {
|
||||
mtbColtToReturn.setOnlyPkMaster(false);
|
||||
mtbColtToReturn.setOperation(OperationType.SELECT_OBJECT);
|
||||
}
|
||||
return mtbColt;
|
||||
return mtbColtToReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -485,7 +485,7 @@ public class GiacenzaService {
|
||||
for (MtbColt collo : mtbColts) {
|
||||
collo
|
||||
.setCodDtip(codDtipRett)
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(collo.getDataCollo()))
|
||||
.setDataDoc(collo.getDataCollo())
|
||||
.setDataDistribuzione(new Date());
|
||||
collo.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(collo, false, false, "", multiDBTransactionManager, RequestDataDTO.systemMockupData(), false, false);
|
||||
|
||||
@@ -2,13 +2,19 @@ package it.integry.ems.retail.wms.Utility;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import groovy.lang.Tuple2;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.retail.wms.dto.InsertUDCRowRequestDTO;
|
||||
import it.integry.ems.retail.wms.dto.InsertUDCRowResponseDTO;
|
||||
import it.integry.ems.retail.wms.exceptions.InvalidArticoloException;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SpostaArtsTraULResponseDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SpostaUlRequestDTO;
|
||||
import it.integry.ems.retail.wms.generic.service.WMSGiacenzaULService;
|
||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||
import it.integry.ems.rules.businessLogic.dto.LoadColliDTO;
|
||||
import it.integry.ems.rules.businessLogic.enums.FlagSezione;
|
||||
import it.integry.ems.rules.completing.PackagesRules;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
@@ -16,9 +22,14 @@ import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.ConverterNotConfiguredException;
|
||||
import it.integry.ems_model.exception.RulesNotCompiledException;
|
||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
@@ -32,15 +43,14 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class WMSUtility {
|
||||
|
||||
public static boolean isGestisciColli(MtbDepo mtbDepo,
|
||||
EntityProcessor entityProcessor,
|
||||
MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
public static boolean isGestisciColli(String codMdep,
|
||||
Connection connection) throws Exception {
|
||||
|
||||
MtbDepoTipi mtbDepoTipi = new MtbDepoTipi();
|
||||
mtbDepoTipi.setCodTipoDepo(mtbDepo.getFlagTipoNegozio())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
String selectSql = Query.format("SELECT " + MtbDepoTipi.ENTITY + ".* FROM mtb_depo " +
|
||||
" INNER JOIN " + MtbDepoTipi.ENTITY + " ON mtb_depo.flag_tipo_negozio = mtb_depo_tipi.cod_tipo_depo " +
|
||||
"WHERE cod_mdep = {}", codMdep);
|
||||
|
||||
entityProcessor.processEntity(mtbDepoTipi, true, multiDBTransactionManager);
|
||||
final MtbDepoTipi mtbDepoTipi = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, selectSql, MtbDepoTipi.class);
|
||||
|
||||
return mtbDepoTipi.getGestisciColli() == null || mtbDepoTipi.getGestisciColli();
|
||||
}
|
||||
@@ -74,45 +84,108 @@ public class WMSUtility {
|
||||
.setNumCnf(docr.getNumCnf().add(mtbColr.getNumCnf()));
|
||||
}
|
||||
|
||||
public static void trasferisciPedane(MtbColt mtbColt, List<MtbTcol> listaPedane, DtbDoct dtbDoct) throws Exception {
|
||||
//<editor-fold desc="Trasferisco le pedane agganciate al collo se presenti e gestite a magazzino">
|
||||
if (!UtilityString.isNullOrEmpty(mtbColt.getCodTcol()) && !UtilityList.isNullOrEmpty(listaPedane)) {
|
||||
MtbTcol pedana = listaPedane.stream().filter(x -> x.getCodTcol().equalsIgnoreCase(mtbColt.getCodTcol())).findFirst().orElse(null);
|
||||
if (!UtilityString.isNullOrEmpty(pedana)) {
|
||||
DtbDocr docr = dtbDoct.getDtbDocr().stream()
|
||||
.filter(row -> row.getCodMart().equalsIgnoreCase(pedana.getCodMart()))
|
||||
.findFirst().orElse(null);
|
||||
public static void trasferisciImballi(MtbTcol imballaggio, DtbDoct dtbDoct) {
|
||||
|
||||
if (docr == null) {
|
||||
docr = new DtbDocr();
|
||||
docr.setCodMart(pedana.getCodMart())
|
||||
.setQtaDoc(BigDecimal.ZERO)
|
||||
.setOperation(OperationType.INSERT);
|
||||
//<editor-fold desc="Trasferisco gli imballaggi (pedane/casse/interfalde) agganciati al collo se presenti e gestite a magazzino">
|
||||
if (!UtilityString.isNullOrEmpty(imballaggio)) {
|
||||
DtbDocr docr = dtbDoct.getDtbDocr().stream()
|
||||
.filter(row -> row.getCodMart().equalsIgnoreCase(imballaggio.getCodMart()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
dtbDoct.getDtbDocr().add(docr);
|
||||
}
|
||||
if (docr == null) {
|
||||
docr = new DtbDocr();
|
||||
docr.setCodMart(imballaggio.getCodMart())
|
||||
.setQtaDoc(BigDecimal.ZERO)
|
||||
.setOperation(OperationType.INSERT);
|
||||
|
||||
docr.setQtaDoc(docr.getQtaDoc().add(BigDecimal.ONE));
|
||||
dtbDoct.getDtbDocr().add(docr);
|
||||
}
|
||||
|
||||
docr.setQtaDoc(docr.getQtaDoc().add(UtilityBigDecimal.isNull(imballaggio.getNumPezzi(), BigDecimal.ONE)));
|
||||
}
|
||||
//</editor-fold>
|
||||
}
|
||||
|
||||
public static List<MtbTcol> getListaPedane(List<MtbColt> mtbCotlList, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
List<String> codTcolList = mtbCotlList.stream()
|
||||
.filter(x -> !UtilityString.isNullOrEmpty(x.getCodTcol()))
|
||||
.map(x -> UtilityDB.valueToString(x.getCodTcol()))
|
||||
.distinct().collect(Collectors.toList());
|
||||
public static HashMap<String, MtbTcol> getListaTipiColloByBarcodeUls(List<String> barcodeUls, Connection connection) throws Exception {
|
||||
if(barcodeUls == null || barcodeUls.isEmpty()) return new HashMap<>();
|
||||
|
||||
List<MtbTcol> listaPedane = new ArrayList<>();
|
||||
if (!codTcolList.isEmpty()) {
|
||||
listaPedane = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), String.format(
|
||||
"SELECT cod_tcol,cod_mart from mtb_tcol where cod_tcol in (%s)",
|
||||
StringUtils.join(codTcolList, ",")
|
||||
), MtbTcol.class);
|
||||
@NotNull List<HashMap<String, Object>> barcodesWithCodTcol = UtilityDB.executeSimpleQuery(connection,
|
||||
"SELECT DISTINCT barcode_ul, cod_tcol FROM mtb_colt WHERE barcode_ul IN (" + UtilityQuery.concatStringFieldsWithSeparator(barcodeUls, ",") + ")");
|
||||
|
||||
if (UtilityList.isNullOrEmpty(barcodesWithCodTcol)) return new HashMap<>();
|
||||
|
||||
List<String> codTcolList = barcodesWithCodTcol.stream()
|
||||
.map(x -> UtilityHashMap.<String>getValueIfExists(x, "cod_tcol"))
|
||||
.filter(x -> !UtilityString.isNullOrEmpty(x))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (codTcolList.isEmpty()) return new HashMap<>();
|
||||
|
||||
final List<MtbTcol> mtbTcolList = UtilityDB.executeSimpleQueryDTO(connection, String.format(
|
||||
"SELECT cod_tcol, " +
|
||||
"cod_mart " +
|
||||
"FROM mtb_tcol " +
|
||||
"WHERE cod_tcol in (%s) AND cod_mart IS NOT NULL",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(codTcolList, ",")
|
||||
), MtbTcol.class);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(mtbTcolList)) return new HashMap<>();
|
||||
|
||||
HashMap<String, MtbTcol> mtbColtMap = new HashMap<>();
|
||||
|
||||
for (HashMap<String, Object> barcodeWithCodTcol : barcodesWithCodTcol) {
|
||||
String barcodeUl = UtilityHashMap.getValueIfExists(barcodeWithCodTcol, "barcode_ul");
|
||||
String codTcol = UtilityHashMap.getValueIfExists(barcodeWithCodTcol, "cod_tcol");
|
||||
|
||||
MtbTcol mtbTcol = null;
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codTcol)) {
|
||||
mtbTcol = mtbTcolList.stream()
|
||||
.filter(x -> x.getCodTcol().equalsIgnoreCase(codTcol))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
mtbColtMap.put(barcodeUl, mtbTcol);
|
||||
}
|
||||
|
||||
return listaPedane;
|
||||
return mtbColtMap;
|
||||
}
|
||||
|
||||
public static List<MtbColr> createCambiaPosizioneUlMovement(Connection connection, String sscc, boolean changeCodMdep, String newCodMdep, String newPosizione) throws Exception {
|
||||
return createCambiaPosizioneUlMovements(connection, Collections.singletonList(sscc), changeCodMdep, newCodMdep, newPosizione);
|
||||
}
|
||||
|
||||
public static List<MtbColr> createCambiaPosizioneUlMovements(Connection connection, List<String> ssccList, boolean changeCodMdep, String newCodMdep, String newPosizione) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(ssccList))
|
||||
throw new MissingDataException("UL da aggiornare");
|
||||
|
||||
WMSGiacenzaULService wmsGiacenzaULService = ApplicationContextProvider.getApplicationContext().getBean(WMSGiacenzaULService.class);
|
||||
|
||||
final List<MvwSitArtUdcDetInventarioDTO> mvwSitArtUdcDetInventarioDTOS =
|
||||
wmsGiacenzaULService.retrieveArtsInGiacenzaByBarcodeUls(connection, ssccList, true);
|
||||
|
||||
if (mvwSitArtUdcDetInventarioDTOS.isEmpty())
|
||||
throw new Exception("Nessun articolo trovato per il barcode: " + ssccList);
|
||||
|
||||
|
||||
final List<MtbColr> movementRows = mvwSitArtUdcDetInventarioDTOS.stream()
|
||||
.map(x -> {
|
||||
final MtbColr mtbColr = WMSUtility.convertMvwItemToMtbColr(x);
|
||||
mtbColr.setPosizioneIn(newPosizione);
|
||||
if (changeCodMdep) mtbColr.setCodMdepIn(newCodMdep);
|
||||
mtbColr.setDataColloRif(x.getDataCollo())
|
||||
.setSerColloRif(x.getSerCollo())
|
||||
.setNumColloRif(x.getNumCollo())
|
||||
.setGestioneRif(x.getGestione());
|
||||
|
||||
mtbColr.setOperation(OperationType.INSERT);
|
||||
|
||||
return mtbColr;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return movementRows;
|
||||
}
|
||||
|
||||
public static boolean canULBeDeleted(MtbColt mtbColt, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
@@ -170,13 +243,24 @@ public class WMSUtility {
|
||||
}
|
||||
|
||||
public static void deleteUL(MtbColt mtbColt, EntityProcessor entityProcessor, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
deleteUL(mtbColt, entityProcessor, multiDBTransactionManager, true);
|
||||
}
|
||||
|
||||
public static void deleteUL(MtbColt mtbColt, EntityProcessor entityProcessor, MultiDBTransactionManager multiDBTransactionManager, boolean completeEntity) throws Exception {
|
||||
mtbColt.setOperation(OperationType.DELETE);
|
||||
entityProcessor.processEntity(mtbColt, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
public static SpostaArtsTraULResponseDTO spostaArtsTraUL(Connection connection, MtbColt sourceMtbColt, MtbColt destinationMtbColt, boolean flagForceUseRefs, EntityProcessor entityProcessor, RequestDataDTO requestDataDTO) throws Exception {
|
||||
public static Tuple2<ArrayList<MtbColr>, ArrayList<MtbColr>> generateSpostaArtsTraUlMovements(
|
||||
MtbColt sourceMtbColt, String destinationBarcodeUl, String destinationCodMdep, String destinationPosizione, String destinationGestione,
|
||||
boolean flagForceUseRefs, RequestDataDTO requestDataDTO, boolean useRequestUsername) throws Exception {
|
||||
|
||||
if (UtilityString.isNullOrEmpty(destinationBarcodeUl))
|
||||
throw new MissingDataException("SSCC di destinazione non presente");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(destinationGestione))
|
||||
throw new MissingDataException("Gestione UL di destinazione non presente");
|
||||
|
||||
SpostaArtsTraULResponseDTO response = new SpostaArtsTraULResponseDTO();
|
||||
List<MtbColr> mtbColrsToMove = sourceMtbColt.getMtbColr();
|
||||
|
||||
if (mtbColrsToMove != null && !mtbColrsToMove.isEmpty()) {
|
||||
@@ -189,9 +273,9 @@ public class WMSUtility {
|
||||
|
||||
boolean destroyMtbColrReferences = false;
|
||||
|
||||
//Se le gestioni sono uguali faccio uno storno sulla sorgente e non lavoro con i riferimenti (solo se non volontariamente forzata)
|
||||
if (!flagForceUseRefs && (UtilityString.equalsIgnoreCase(sourceMtbColt.getGestione(), "V") && UtilityString.equalsIgnoreCase(destinationMtbColt.getGestione(), "V")) ||
|
||||
(UtilityString.equalsIgnoreCase(sourceMtbColt.getGestione(), "V") && sourceMtbColt.getSegno() == -1 && UtilityString.equalsIgnoreCase(destinationMtbColt.getGestione(), "L"))) {
|
||||
//Se la sorgente è un collo di scarico allora faccio lo storno sulla sorgente e aggiungo le qta a quella di destinazione
|
||||
if (!flagForceUseRefs &&
|
||||
(sourceMtbColt.getSegno() == -1 && UtilityString.equalsIgnoreCase(destinationGestione, "L"))) {
|
||||
destroyMtbColrReferences = true;
|
||||
|
||||
MtbColr stornoSourceMtbColr = (MtbColr) mtbColr.clone();
|
||||
@@ -201,15 +285,30 @@ public class WMSUtility {
|
||||
.setNumCollo(null)
|
||||
.setSerCollo(null)
|
||||
.setDataCollo(null)
|
||||
.setRiga(null)
|
||||
.setGestioneRif(cloneMtbColr.getGestioneRif())
|
||||
.setNumColloRif(cloneMtbColr.getNumColloRif())
|
||||
.setSerColloRif(cloneMtbColr.getSerColloRif())
|
||||
.setDataColloRif(cloneMtbColr.getDataColloRif())
|
||||
.setCausale(MtbColr.Causale.VERSAMENTO)
|
||||
.setUtente(requestDataDTO.getUsername())
|
||||
|
||||
.setQtaCol(stornoSourceMtbColr.getQtaCol().multiply(new BigDecimal(-1)))
|
||||
.setNumCnf(stornoSourceMtbColr.getNumCnf().multiply(new BigDecimal(-1)));
|
||||
.setNumCnf(stornoSourceMtbColr.getNumCnf().multiply(new BigDecimal(-1)))
|
||||
|
||||
//Lavoro al contrario per compatibilità
|
||||
.setBarcodeUlOut(cloneMtbColr.getBarcodeUlIn())
|
||||
.setCodMdepOut(cloneMtbColr.getCodMdepOut())
|
||||
.setPosizioneOut(cloneMtbColr.getPosizioneOut())
|
||||
|
||||
.setBarcodeUlIn(destinationBarcodeUl)
|
||||
.setCodMdepIn(destinationCodMdep)
|
||||
.setPosizioneIn(destinationPosizione)
|
||||
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
if(useRequestUsername)
|
||||
stornoSourceMtbColr
|
||||
.setUtente(requestDataDTO.getUsername());
|
||||
|
||||
mtbColrSourceList.add(stornoSourceMtbColr);
|
||||
}
|
||||
@@ -221,6 +320,14 @@ public class WMSUtility {
|
||||
.setSerColloRif(cloneMtbColr.getSerCollo())
|
||||
.setNumColloRif(cloneMtbColr.getNumCollo())
|
||||
.setDataColloRif(cloneMtbColr.getDataCollo());
|
||||
|
||||
cloneMtbColr
|
||||
.setBarcodeUlOut(cloneMtbColr.getBarcodeUlIn())
|
||||
.setBarcodeUlIn(destinationBarcodeUl)
|
||||
.setPosizioneOut(cloneMtbColr.getPosizioneIn())
|
||||
.setPosizioneIn(destinationPosizione)
|
||||
.setCodMdepOut(cloneMtbColr.getCodMdepIn())
|
||||
.setCodMdepOut(destinationCodMdep);
|
||||
}
|
||||
|
||||
if (sourceMtbColt.getGestione().equalsIgnoreCase("V") && sourceMtbColt.getSegno() == +1) {
|
||||
@@ -233,9 +340,16 @@ public class WMSUtility {
|
||||
.setNumCollo(null)
|
||||
.setDataCollo(null)
|
||||
.setRiga(null)
|
||||
.setUtente(requestDataDTO.getUsername());
|
||||
.setBarcodeUlIn(destinationBarcodeUl)
|
||||
.setCodMdepIn(destinationCodMdep)
|
||||
.setPosizioneIn(destinationPosizione)
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
if (!StringUtils.equalsIgnoreCase(destinationMtbColt.getGestione(), "V")) {
|
||||
if(useRequestUsername)
|
||||
cloneMtbColr
|
||||
.setUtente(requestDataDTO.getUsername());
|
||||
|
||||
if (!StringUtils.equalsIgnoreCase(destinationGestione, "V")) {
|
||||
cloneMtbColr
|
||||
.setCausale(MtbColr.Causale.VERSAMENTO);
|
||||
}
|
||||
@@ -243,38 +357,65 @@ public class WMSUtility {
|
||||
mtbColrDestList.add(cloneMtbColr);
|
||||
}
|
||||
|
||||
sourceMtbColt.setMtbColr(mtbColrSourceList);
|
||||
destinationMtbColt.setMtbColr(mtbColrDestList);
|
||||
|
||||
destinationMtbColt.setMtbCols(new ArrayList<>());
|
||||
PackagesRules.insertMtbCols(destinationMtbColt, MtbCols.Causale.VERSAMENTO);
|
||||
|
||||
|
||||
ArrayList<MtbColt> mtbColts = new ArrayList<>();
|
||||
mtbColts.add(sourceMtbColt);
|
||||
mtbColts.add(destinationMtbColt);
|
||||
|
||||
for (MtbColt mtbColt : mtbColts) {
|
||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
for (int i = 0; i < mtbColt.getMtbColr().size(); i++) {
|
||||
mtbColt.getMtbColr().get(i)
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
entityProcessor.processEntityList(mtbColts, true);
|
||||
UtilityEntity.throwEntitiesException(mtbColts);
|
||||
|
||||
response.setGeneratedMtbColr(destinationMtbColt.getMtbColr());
|
||||
|
||||
// if (destinationMtbColt.getMtbCols().stream().noneMatch(x -> x.getOperation() == OperationType.INSERT || x.getOperation() == OperationType.INSERT_OR_UPDATE)) {
|
||||
// destinationMtbColt.setMtbCols(new ArrayList<>());
|
||||
// PackagesRules.insertMtbCols(destinationMtbColt, MtbCols.Causale.VERSAMENTO);
|
||||
// }
|
||||
return new Tuple2<>(mtbColrSourceList, mtbColrDestList);
|
||||
}
|
||||
return response;
|
||||
|
||||
return new Tuple2<>(new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
|
||||
public static SpostaArtsTraULResponseDTO spostaArtsTraUL(Connection connection, MtbColt sourceMtbColt,
|
||||
String destinationBarcodeUl,
|
||||
boolean flagForceUseRefs, EntityProcessor entityProcessor, RequestDataDTO requestDataDTO) throws Exception {
|
||||
|
||||
String destinationMtbColtQuery = Query.format("SELECT * " +
|
||||
"FROM " + MtbColt.ENTITY + " " +
|
||||
"WHERE barcode_ul = {}", destinationBarcodeUl);
|
||||
|
||||
MtbColt destinationMtbColt = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, destinationMtbColtQuery, MtbColt.class);
|
||||
|
||||
final Tuple2<ArrayList<MtbColr>, ArrayList<MtbColr>> spostaArtsTraUlMovements =
|
||||
generateSpostaArtsTraUlMovements(sourceMtbColt, destinationBarcodeUl, destinationMtbColt.getCodMdep(),
|
||||
destinationMtbColt.getPosizione(), destinationMtbColt.getGestione(), flagForceUseRefs, requestDataDTO, false);
|
||||
|
||||
|
||||
sourceMtbColt.setMtbColr(spostaArtsTraUlMovements.getV1());
|
||||
destinationMtbColt.setMtbColr(spostaArtsTraUlMovements.getV2());
|
||||
|
||||
destinationMtbColt.setMtbCols(new ArrayList<>());
|
||||
PackagesRules.insertMtbCols(destinationMtbColt, MtbCols.Causale.VERSAMENTO);
|
||||
|
||||
|
||||
ArrayList<MtbColt> mtbColts = new ArrayList<>();
|
||||
mtbColts.add(sourceMtbColt);
|
||||
mtbColts.add(destinationMtbColt);
|
||||
|
||||
for (MtbColt mtbColt : mtbColts) {
|
||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
for (int i = 0; i < mtbColt.getMtbColr().size(); i++) {
|
||||
mtbColt.getMtbColr().get(i)
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
entityProcessor.processEntityList(mtbColts, true);
|
||||
UtilityEntity.throwEntitiesException(mtbColts);
|
||||
|
||||
return new SpostaArtsTraULResponseDTO()
|
||||
.setGeneratedMtbColr(destinationMtbColt.getMtbColr());
|
||||
}
|
||||
|
||||
public static InsertUDCRowResponseDTO insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, EntityProcessor entityProcessor, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
|
||||
MtbColt targetMtbColt = insertUDCRowRequestDTO.getTargetMtbColt();
|
||||
|
||||
if (targetMtbColt == null)
|
||||
throw new MissingDataException("UL di destinazione non presente");
|
||||
|
||||
targetMtbColt.setOperation(OperationType.SELECT_OBJECT);
|
||||
entityProcessor.processEntity(targetMtbColt, true, multiDBTransactionManager);
|
||||
|
||||
@@ -289,11 +430,11 @@ public class WMSUtility {
|
||||
.setCodJcom(insertUDCRowRequestDTO.getCodJcom())
|
||||
.setGestioneRif(insertUDCRowRequestDTO.getGestioneRif())
|
||||
.setUtente(insertUDCRowRequestDTO.getFullName())
|
||||
.setNumEtich(insertUDCRowRequestDTO.getNumEtich())
|
||||
|
||||
.setDataOrd(insertUDCRowRequestDTO.getDataOrd())
|
||||
.setNumOrd(insertUDCRowRequestDTO.getNumOrd())
|
||||
.setRigaOrd(insertUDCRowRequestDTO.getRigaOrd())
|
||||
|
||||
.setDataDoc(UtilityDate.toDate(insertUDCRowRequestDTO.getDataDoc()))
|
||||
.setNumDoc(insertUDCRowRequestDTO.getNumDoc())
|
||||
.setCodDtipDoc(insertUDCRowRequestDTO.getCodDtip())
|
||||
@@ -301,6 +442,14 @@ public class WMSUtility {
|
||||
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime());
|
||||
|
||||
if (insertUDCRowRequestDTO.getCodDtip() != null){
|
||||
targetMtbColr.setCodAnagDoc(insertUDCRowRequestDTO.getTargetMtbColt().getCodAnag());
|
||||
}
|
||||
|
||||
targetMtbColr.setBarcodeUlIn(UtilityString.isNull(insertUDCRowRequestDTO.getCustomBarcodeUlIn(), targetMtbColt.getBarcodeUl()))
|
||||
.setCodMdepIn(UtilityString.isNull(insertUDCRowRequestDTO.getCustomCodMdepIn(), targetMtbColt.getCodMdep()))
|
||||
.setPosizioneIn(UtilityString.isNull(insertUDCRowRequestDTO.getCustomPosizioneIn(), targetMtbColt.getPosizione()));
|
||||
|
||||
|
||||
if (insertUDCRowRequestDTO.getCodMart() != null) {
|
||||
MtbAart mtbAart = getArticoloByCodMart(insertUDCRowRequestDTO.getCodMart(), multiDBTransactionManager.getPrimaryConnection());
|
||||
@@ -321,6 +470,15 @@ public class WMSUtility {
|
||||
.setNote(insertUDCRowRequestDTO.getDescrizione());
|
||||
}
|
||||
|
||||
if (insertUDCRowRequestDTO.getDocumentReso() != null) {
|
||||
targetMtbColr.setCodAnagDoc(insertUDCRowRequestDTO.getDocumentReso().getCodAnag())
|
||||
.setCodDtipDoc(insertUDCRowRequestDTO.getDocumentReso().getCodDtip())
|
||||
.setSerDoc(insertUDCRowRequestDTO.getDocumentReso().getSerDoc())
|
||||
.setNumDoc(insertUDCRowRequestDTO.getDocumentReso().getNumDoc())
|
||||
.setDataDoc(UtilityDate.toDate(insertUDCRowRequestDTO.getDocumentReso().getDataDoc()))
|
||||
.setIdRigaDoc(insertUDCRowRequestDTO.getDocumentReso().getIdRiga());
|
||||
}
|
||||
|
||||
targetMtbColr.setOperation(OperationType.INSERT);
|
||||
targetMtbColt.getMtbColr().add(targetMtbColr);
|
||||
|
||||
@@ -354,7 +512,7 @@ public class WMSUtility {
|
||||
|
||||
List<MtbAart> listMtbAart = UtilityDB.executeSimpleQueryDTO(connection, query, MtbAart.class);
|
||||
|
||||
List<MtbAartBarCode> barCodeFromCod = getBarCodeFromCod(codMarts, connection);
|
||||
List<MtbAartBarCode> barCodeFromCod = getAlternativeMtbAartBarCodes(codMarts, connection);
|
||||
|
||||
if (listMtbAart != null && !listMtbAart.isEmpty()) {
|
||||
List<String> untMisStrings = listMtbAart.stream()
|
||||
@@ -386,6 +544,14 @@ public class WMSUtility {
|
||||
return listMtbAart;
|
||||
}
|
||||
|
||||
public static HashMap<String, MtbAart> getArticoliByCodMartsAsMap(List<String> codMarts, Connection connection) throws Exception {
|
||||
List<MtbAart> mtbAarts = getArticoliByCodMarts(codMarts, connection);
|
||||
if (mtbAarts == null || mtbAarts.isEmpty()) return new HashMap<>();
|
||||
|
||||
return mtbAarts.stream()
|
||||
.collect(Collectors.toMap(MtbAart::getCodMart, a -> a, (a, b) -> a, HashMap::new));
|
||||
}
|
||||
|
||||
public static List<MtbUntMis> getUntMisFromCod(List<String> untMisCods, Connection connection) throws Exception {
|
||||
List<String> untMisStrings = Stream.of(untMisCods)
|
||||
.withoutNulls()
|
||||
@@ -397,22 +563,130 @@ public class WMSUtility {
|
||||
return mtbUntMis != null ? mtbUntMis : new ArrayList<>();
|
||||
}
|
||||
|
||||
public static List<MtbAartBarCode> getBarCodeFromCod(List<String> codMart, Connection conn) throws Exception {
|
||||
String sql = "SELECT * FROM mtb_aart_bar_code WHERE cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMart, ",") + ")";
|
||||
public static boolean checkIfBarcodeUlIsAlreadyDeclared(Connection connection, String barcodeUl) throws SQLException {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||
"SELECT CAST(IIF(COUNT(*) > 0, 1, 0) AS BIT) AS exist " +
|
||||
" FROM mtb_colt WHERE barcode_ul = " + UtilityDB.valueToString(barcodeUl));
|
||||
}
|
||||
|
||||
public static List<MtbAartBarCode> getAlternativeMtbAartBarCodes(List<String> codMarts, Connection conn) throws Exception {
|
||||
codMarts = codMarts.stream()
|
||||
.distinct().collect(Collectors.toList());
|
||||
|
||||
String sql = "SELECT * FROM mtb_aart_bar_code WHERE cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
||||
final List<MtbAartBarCode> barCodeList = UtilityDB.executeSimpleQueryDTO(conn, sql, MtbAartBarCode.class);
|
||||
return barCodeList != null ? barCodeList : new ArrayList<>();
|
||||
}
|
||||
|
||||
public static MtbColt createInternalMovement(String codMdep) {
|
||||
|
||||
public static DtbDoct createTransferDocumentAndAttachToMovement(MultiDBTransactionManager multiDBTransactionManager, SetupGest setupGest, MtbColt movementToAttach,
|
||||
LocalDate dataTrasf, String codMdepArrivo,
|
||||
String annotazioni, String username,
|
||||
boolean groupDailyTransfer, SpostaUlRequestDTO.TransferGroupPolicy groupingPolicy) throws Exception {
|
||||
|
||||
Connection connection = multiDBTransactionManager.getPrimaryConnection();
|
||||
String codDtipToUse = setupGest.getSetupDepo(connection, "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");
|
||||
|
||||
LocalDate dataDoc = UtilityLocalDate.isNull(dataTrasf, UtilityLocalDate.getNow());
|
||||
|
||||
LoadColliDTO docTrasfRequest = new LoadColliDTO();
|
||||
docTrasfRequest
|
||||
.setDataDoc(UtilityLocalDate.localDateToDate(dataDoc))
|
||||
.setCodDtip(codDtipToUse)
|
||||
.setCodMdep(movementToAttach.getCodMdep())
|
||||
.setCodAnag(movementToAttach.getCodAnag())
|
||||
.setCodVdes(movementToAttach.getCodVdes())
|
||||
.setNote(annotazioni);
|
||||
|
||||
if (groupDailyTransfer) {
|
||||
String queryDoc = Query.format("select cod_dtip, cod_anag, data_doc, ser_doc, num_doc\n" +
|
||||
"from dtb_doct\n" +
|
||||
"where cod_dtip = {}\n" +
|
||||
" and data_doc = {}\n" +
|
||||
" and cod_mdep = {}\n" +
|
||||
" and cod_anag = {}\n" +
|
||||
" and cod_vdes = {}", codDtipToUse, dataDoc, movementToAttach.getCodMdep(), movementToAttach.getCodAnag(), movementToAttach.getCodVdes());
|
||||
switch (groupingPolicy) {
|
||||
case BY_USER:
|
||||
queryDoc = UtilityDB.addwhereCond(queryDoc, Query.format("user_name = {}", username), true);
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DtbDoct existingDoc = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, queryDoc, DtbDoct.class);
|
||||
if (existingDoc != null) {
|
||||
docTrasfRequest
|
||||
.setDataDoc(existingDoc.getDataDoc())
|
||||
.setSerDoc(existingDoc.getSerDoc())
|
||||
.setNumDoc(existingDoc.getNumDoc())
|
||||
.setCodDtip(existingDoc.getCodDtip())
|
||||
.setCodAnag(existingDoc.getCodAnag());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
docTrasfRequest.setColli(Collections.singletonList(movementToAttach));
|
||||
|
||||
LoadColliService loadColliService = ApplicationContextProvider.getApplicationContext().getBean(LoadColliService.class);
|
||||
|
||||
DtbDoct docTrasf = loadColliService.createDocFromColli(multiDBTransactionManager, docTrasfRequest, false);
|
||||
docTrasf.getDtbDocr().forEach(docr -> docr.setOperation(OperationType.INSERT_OR_UPDATE));
|
||||
|
||||
List<String> barcodeUlsOut = movementToAttach.getMtbColr().stream()
|
||||
.map(MtbColr::getBarcodeUlOut)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
HashMap<String, MtbTcol> listaPedane = WMSUtility.getListaTipiColloByBarcodeUls(barcodeUlsOut, connection);
|
||||
HashMap<String, MtbTcol> listaImballi = WMSUtility.getListaTipiImballoByBarcodeUls(barcodeUlsOut, connection);
|
||||
|
||||
|
||||
//<editor-fold desc="Trasferimento pallet">
|
||||
for (MtbColr rowMovimento : movementToAttach.getMtbColr()) {
|
||||
if (listaPedane.getOrDefault(rowMovimento.getBarcodeUlOut(), null) != null) {
|
||||
WMSUtility.trasferisciImballi(listaPedane.get(rowMovimento.getBarcodeUlOut()), docTrasf);
|
||||
//rimuovo il barcode dalla lista di pallet da spostare per evitare che righe di moviemento create in più mtbColr moltiplichino il numero di pallet spostati
|
||||
listaPedane.remove(rowMovimento.getBarcodeUlOut());
|
||||
}
|
||||
if (listaImballi.getOrDefault(rowMovimento.getBarcodeUlOut(), null) != null) {
|
||||
WMSUtility.trasferisciImballi(listaImballi.get(rowMovimento.getBarcodeUlOut()), docTrasf);
|
||||
//rimuovo il barcode dalla lista di pallet da spostare per evitare che righe di moviemento create in più mtbColr moltiplichino il numero di pallet spostati
|
||||
listaImballi.remove(rowMovimento.getBarcodeUlOut());
|
||||
}
|
||||
}
|
||||
//</editor-fold>
|
||||
if (!UtilityString.isNullOrEmpty(annotazioni)) {
|
||||
DtbDocr dtbDocr = new DtbDocr()
|
||||
.setDescrizione(UtilityString.substring(annotazioni, 0, 40))
|
||||
.setDescrizioneEstesa(annotazioni);
|
||||
dtbDocr.setOperation(OperationType.INSERT);
|
||||
|
||||
docTrasf.getDtbDocr().add(dtbDocr);
|
||||
}
|
||||
|
||||
return docTrasf;
|
||||
}
|
||||
|
||||
public static MtbColt createInternalMovement(Connection connection, String codMdep, String username) throws RulesNotCompiledException, SQLException, IOException, IllegalAccessException, ConverterNotConfiguredException {
|
||||
return createInternalMovement(connection, codMdep, null, username);
|
||||
}
|
||||
|
||||
public static MtbColt createInternalMovement(Connection connection, String codMdep, LocalDate dataCollo, String username) throws RulesNotCompiledException, SQLException, IOException, IllegalAccessException, ConverterNotConfiguredException {
|
||||
MtbColt mtbColt = new MtbColt()
|
||||
.setGestione("L")
|
||||
.setSegno(1)
|
||||
.setDataCollo(LocalDate.now())
|
||||
.setDataCollo(UtilityLocalDate.isNull(dataCollo, LocalDate.now()))
|
||||
.setCodMdep(codMdep);
|
||||
|
||||
mtbColt.setOperation(OperationType.INSERT);
|
||||
|
||||
final DroolsDataCompleting dataCompleting = ApplicationContextProvider.getApplicationContext().getBean(DroolsDataCompleting.class);
|
||||
dataCompleting.complete(mtbColt, connection, username);
|
||||
|
||||
return mtbColt;
|
||||
}
|
||||
|
||||
@@ -424,8 +698,8 @@ public class WMSUtility {
|
||||
return new MtbColr()
|
||||
.setCodMart(inputData.getCodMart())
|
||||
.setPartitaMag(inputData.getPartitaMag())
|
||||
// .setCodCol(inputData.getCodCol())
|
||||
// .setCodTagl(inputData.getCodTagl())
|
||||
.setCodCol(inputData.getCodCol())
|
||||
.setCodTagl(inputData.getCodTagl())
|
||||
.setQtaCol(inputData.getQtaCol())
|
||||
.setNumCnf(inputData.getNumCnf())
|
||||
.setQtaCnf(inputData.getQtaCnf())
|
||||
@@ -436,7 +710,11 @@ public class WMSUtility {
|
||||
.setCodMdepOut(inputData.getCodMdep())
|
||||
.setPosizioneIn(inputData.getPosizione())
|
||||
.setPosizioneOut(inputData.getPosizione())
|
||||
.setCodJcom(inputData.getCodJcom());
|
||||
.setCodJcom(inputData.getCodJcom())
|
||||
.setGestione(inputData.getGestione())
|
||||
.setDataCollo(inputData.getDataCollo())
|
||||
.setSerCollo(inputData.getSerCollo())
|
||||
.setNumCollo(inputData.getNumCollo());
|
||||
}
|
||||
|
||||
public static List<MtbColr> convertMvwItemsToMtbColrs(List<MvwSitArtUdcDetInventarioDTO> inputData) {
|
||||
@@ -449,7 +727,7 @@ public class WMSUtility {
|
||||
}
|
||||
|
||||
|
||||
public static List<String> retrieveBarcodesInPosizione(Connection connection, String posizione) throws SQLException, IOException, PrimaryDatabaseNotPresentException {
|
||||
public static List<String> retrieveBarcodesInPosizione(Connection connection, String posizione) throws SQLException {
|
||||
String sql = "SELECT * FROM (" +
|
||||
"SELECT barcode_ul FROM mtb_colt WHERE posizione = " + UtilityDB.valueToString(posizione) +
|
||||
" UNION " +
|
||||
@@ -459,4 +737,76 @@ public class WMSUtility {
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
public static MtbColt retrieveBarcodeUlAnag(Connection connection, String barcodeUl) throws Exception {
|
||||
if (UtilityString.isNullOrEmpty(barcodeUl))
|
||||
return null;
|
||||
|
||||
String sql = "SELECT * FROM mtb_colt WHERE barcode_ul = " + UtilityDB.valueToString(barcodeUl);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, MtbColt.class);
|
||||
}
|
||||
|
||||
public static List<MtbColr> retrieveRowsForMovement(Connection connection, MtbColt mtbColt) throws Exception {
|
||||
return UtilityDB.executeSimpleQueryDTO(connection, Query.format("SELECT * from mtb_colr where data_collo = {} AND ser_collo = {} and num_collo = {} and gestione = {}"
|
||||
, mtbColt.getDataCollo(), mtbColt.getSerCollo(), mtbColt.getNumCollo(), mtbColt.getGestione()), MtbColr.class);
|
||||
}
|
||||
|
||||
|
||||
public static MtbDepoPosizioni getPosizioneFromName(Connection conn, String posizione) throws Exception {
|
||||
MtbDepoPosizioni mtbDepoPosizioni = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(conn, Query.format("SELECT * from " + MtbDepoPosizioni.ENTITY + " where posizione = {}", posizione), MtbDepoPosizioni.class);
|
||||
return mtbDepoPosizioni;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, MtbTcol> getListaTipiImballoByBarcodeUls(List<String> barcodeUls, Connection connection) throws Exception {
|
||||
if (UtilityList.isNullOrEmpty(barcodeUls)) return new HashMap<>();
|
||||
|
||||
@NotNull List<HashMap<String, Object>> barcodesWithCodTcol = UtilityDB.executeSimpleQuery(connection,
|
||||
"select barcode_ul, mtb_aart.cod_tcol_UI as cod_tcol\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" +
|
||||
" inner join mtb_aart on mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
"\n" +
|
||||
"where barcode_ul IN (" + UtilityQuery.concatStringFieldsWithSeparator(barcodeUls, ",") + ")");
|
||||
|
||||
if (barcodesWithCodTcol.isEmpty()) return new HashMap<>();
|
||||
|
||||
List<String> codTcolList = barcodesWithCodTcol.stream()
|
||||
.map(x -> UtilityHashMap.<String>getValueIfExists(x, "cod_tcol"))
|
||||
.filter(x -> !UtilityString.isNullOrEmpty(x))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (codTcolList.isEmpty()) return new HashMap<>();
|
||||
|
||||
final List<MtbTcol> mtbTcolList = UtilityDB.executeSimpleQueryDTO(connection, String.format(
|
||||
"SELECT cod_tcol, " +
|
||||
"cod_mart " +
|
||||
"FROM mtb_tcol " +
|
||||
"WHERE cod_tcol in (%s) and cod_mart is not null",
|
||||
UtilityQuery.concatStringFieldsWithSeparator(codTcolList, ",")
|
||||
), MtbTcol.class);
|
||||
|
||||
if (UtilityList.isNullOrEmpty(mtbTcolList)) return new HashMap<>();
|
||||
|
||||
HashMap<String, MtbTcol> mtbColtMap = new HashMap<>();
|
||||
|
||||
for (HashMap<String, Object> barcodeWithCodTcol : barcodesWithCodTcol) {
|
||||
String barcodeUl = UtilityHashMap.getValueIfExists(barcodeWithCodTcol, "barcode_ul");
|
||||
String codTcol = UtilityHashMap.getValueIfExists(barcodeWithCodTcol, "cod_tcol");
|
||||
|
||||
MtbTcol mtbTcol = null;
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codTcol)) {
|
||||
mtbTcol = mtbTcolList.stream()
|
||||
.filter(x -> x.getCodTcol().equalsIgnoreCase(codTcol))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
mtbColtMap.put(barcodeUl, mtbTcol);
|
||||
}
|
||||
|
||||
return mtbColtMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ public class WMSAccettazioneController {
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACCETTAZIONE_MERCE_SILOS, method = RequestMethod.POST)
|
||||
public @ResponseBody ServiceRestResponse accettazioneMerceSilos(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestBody MtbColt colloCarico
|
||||
) throws Exception {
|
||||
@RequestBody MtbColt colloCarico) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(wmsAccettazioneService.accettazioneMerceSilos(colloCarico));
|
||||
}
|
||||
|
||||
@@ -94,8 +94,16 @@ public class WMSAccettazioneController {
|
||||
@RequestMapping(value = "checkIfBarcodeUlAlreadyRegistered", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse checkBarcodeUl(@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestParam String barcodeUl ) throws Exception {
|
||||
@RequestParam String barcodeUl) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(wmsAccettazioneService.checkIfBarcodeUlAlreadyRegistered(barcodeUl));
|
||||
}
|
||||
|
||||
@PostMapping(value = "createUDCWithRows")
|
||||
public @ResponseBody
|
||||
ServiceRestResponse createUDCWithRows(@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@RequestBody CreateUDCWithRowsRequestDTO createUDCWithRows) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(wmsAccettazioneService.createUDCWithRows(createUDCWithRows));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class WMSAccettazioneBollaService {
|
||||
.map(SitBollaAccettazioneDTO::getCodMart)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList()),multiDBTransactionManager.getPrimaryConnection());
|
||||
.collect(Collectors.toList()), multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
final Map<String, BigDecimal> qtaCnfsByArt = articoliByCodMarts.stream()
|
||||
.collect(Collectors.toMap(MtbAart::getCodMart, MtbAart::getQtaCnf));
|
||||
|
||||
@@ -9,7 +9,6 @@ import it.integry.ems.retail.wms.accettazione.dto.AlreadyRegisteredUlDTO;
|
||||
import it.integry.ems.retail.wms.dto.*;
|
||||
import it.integry.ems.retail.wms.exceptions.InvalidArticoloException;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.retail.wms.generic.dto.SpostaArtsTraULRequestDTO;
|
||||
import it.integry.ems.retail.wms.lavorazione.service.WMSLavorazioneService;
|
||||
import it.integry.ems.rules.businessLogic.LoadColliService;
|
||||
import it.integry.ems.rules.businessLogic.dto.LoadColliDTO;
|
||||
@@ -74,20 +73,25 @@ public class WMSAccettazioneService {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconoscuto!");
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(createUDCRequestDTO.getBarcodeUl()) &&
|
||||
WMSUtility.checkIfBarcodeUlIsAlreadyDeclared(multiDBTransactionManager.getPrimaryConnection(), createUDCRequestDTO.getBarcodeUl())) {
|
||||
throw new Exception("Il barcode " + createUDCRequestDTO.getBarcodeUl() + " è già stato dichiarato in un collo di carico");
|
||||
}
|
||||
|
||||
String defaultPosizioneColliAccettazione = setupGest.getSetup("PICKING", "SETUP", "DEFAULT_POSIZIONE_COLLI_ACCETTAZIONE");
|
||||
|
||||
|
||||
MtbColt udcMtbColt = new MtbColt()
|
||||
.setGestione(GestioneEnum.ACQUISTO.getText())
|
||||
.setGestione(createUDCRequestDTO.isReso() ? GestioneEnum.VENDITA.getText() : GestioneEnum.ACQUISTO.getText())
|
||||
.setNumCollo(createUDCRequestDTO.getNumCollo())
|
||||
.setSerCollo(createUDCRequestDTO.getSerCollo())
|
||||
.setCodMdep(createUDCRequestDTO.getCodMdep())
|
||||
.setCodVdes(createUDCRequestDTO.getCodVdes())
|
||||
.setDataCollo(createUDCRequestDTO.getDataCollo())
|
||||
.setOraInizPrep(new Date())
|
||||
.setPreparatoDa(requestDataDTO.getUsername())
|
||||
.setPreparatoDa(userSession.getUsername())
|
||||
.setPosizione(UtilityString.isNullOrEmpty(createUDCRequestDTO.getPosizione()) ? defaultPosizioneColliAccettazione : createUDCRequestDTO.getPosizione())
|
||||
.setCodTcol(createUDCRequestDTO.getCodTcol())
|
||||
.setCodJfas(createUDCRequestDTO.getCodJfas())
|
||||
.setAnnotazioni(createUDCRequestDTO.getAnnotazioni())
|
||||
.setBarcodeUl(createUDCRequestDTO.getBarcodeUl())
|
||||
.setSegno(1);
|
||||
@@ -157,7 +161,9 @@ public class WMSAccettazioneService {
|
||||
udcMtbColt.setOperation(OperationType.INSERT);
|
||||
entityProcessor.processEntity(udcMtbColt, multiDBTransactionManager);
|
||||
|
||||
udcMtbColt.setOnlyPkMaster(false);
|
||||
udcMtbColt
|
||||
.setMtbCols(new ArrayList<>())
|
||||
.setOnlyPkMaster(false);
|
||||
return udcMtbColt;
|
||||
}
|
||||
|
||||
@@ -263,12 +269,10 @@ public class WMSAccettazioneService {
|
||||
|
||||
|
||||
public InsertUDCRowResponseDTO insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO) throws Exception {
|
||||
if (!userSession.isAttivo()) {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconoscuto!");
|
||||
}
|
||||
userSession.checkUser();
|
||||
|
||||
if (UtilityString.isNullOrEmpty(insertUDCRowRequestDTO.getFullName())) {
|
||||
insertUDCRowRequestDTO.setFullName(userSession.getFullname());
|
||||
insertUDCRowRequestDTO.setFullName(userSession.getUsername());
|
||||
}
|
||||
|
||||
return WMSUtility.insertUDCRow(insertUDCRowRequestDTO, entityProcessor, multiDBTransactionManager);
|
||||
@@ -301,7 +305,7 @@ public class WMSAccettazioneService {
|
||||
.setNumCnf(insertUDCRowRequestDTO.getNumCnf())
|
||||
.setCodJcom(insertUDCRowRequestDTO.getCodJcom())
|
||||
.setGestioneRif(insertUDCRowRequestDTO.getGestioneRif())
|
||||
.setUtente(userSession.getFullname())
|
||||
.setUtente(userSession.getUsername())
|
||||
|
||||
.setDataOrd(insertUDCRowRequestDTO.getDataOrd())
|
||||
.setNumOrd(insertUDCRowRequestDTO.getNumOrd())
|
||||
@@ -368,7 +372,7 @@ public class WMSAccettazioneService {
|
||||
.setQtaCol(editUDCRowRequestDTO.getNewQtaTot())
|
||||
.setPartitaMag(editUDCRowRequestDTO.getNewPartitaMag())
|
||||
.setDataScadPartita(editUDCRowRequestDTO.getNewDataScad())
|
||||
.setUtente(userSession.getFullname())
|
||||
.setUtente(userSession.getUsername())
|
||||
.setDatetimeRow(UtilityLocalDate.getNowTime());
|
||||
|
||||
MtbColt targetMtbColt = new MtbColt()
|
||||
@@ -460,7 +464,8 @@ public class WMSAccettazioneService {
|
||||
" num_doc_provv,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" data_vers,\n" +
|
||||
" mtb_colt.peso_netto_kg\n" +
|
||||
" mtb_colt.peso_netto_kg,\n" +
|
||||
" mtb_colt.barcode_ul\n" +
|
||||
"FROM mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr ON\n" +
|
||||
" mtb_colt.gestione = mtb_colr.gestione AND\n" +
|
||||
@@ -506,7 +511,8 @@ public class WMSAccettazioneService {
|
||||
" num_doc_provv,\n" +
|
||||
" cod_jfas,\n" +
|
||||
" data_vers,\n" +
|
||||
" mtb_colt.peso_netto_kg";
|
||||
" mtb_colt.peso_netto_kg,\n" +
|
||||
" mtb_colt.barcode_ul";
|
||||
|
||||
final List<AlreadyRegisteredUlDTO> alreadyRegisteredUdcList = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, AlreadyRegisteredUlDTO.class);
|
||||
|
||||
@@ -550,12 +556,22 @@ public class WMSAccettazioneService {
|
||||
colloCarico.setDataVers(null);
|
||||
|
||||
//se la posizione è monocollo recupero il collo di destinazione (o lo creo se non esiste)
|
||||
MtbColt colloDest = null;
|
||||
|
||||
String ssccDest = null;
|
||||
|
||||
if (posizione.isFlagMonoCollo()) {
|
||||
colloDest = getMonoColloPosizione(posizione);
|
||||
final List<String> barcodes = WMSUtility.retrieveBarcodesInPosizione(multiDBTransactionManager.getPrimaryConnection(), posizione.getPosizione());
|
||||
|
||||
if (barcodes.size() > 1) {
|
||||
throw new Exception("Ci sono " + barcodes.size() + " UL in posizione " + posizione.getPosizione() + " (MONO-UL)");
|
||||
} else if (!barcodes.isEmpty())
|
||||
ssccDest = barcodes.get(0);
|
||||
}
|
||||
if (colloDest == null) {
|
||||
colloDest = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO().setCodMdep(posizione.getCodMdep()).setPosizione(posizione.getPosizione()));
|
||||
if (ssccDest == null) {
|
||||
MtbColt colloDest = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO()
|
||||
.setCodMdep(posizione.getCodMdep())
|
||||
.setPosizione(posizione.getPosizione()));
|
||||
ssccDest = colloDest.getBarcodeUl();
|
||||
}
|
||||
|
||||
//eseguo gli scarichi e il carico della nuova partita
|
||||
@@ -576,9 +592,13 @@ public class WMSAccettazioneService {
|
||||
articoloAccettato.setQtaCol(articoloAccettato.getQtaCol().subtract(qtaScarAccettazione));
|
||||
|
||||
LocalDateTime dataVers = UtilityLocalDate.getNowTime().plusSeconds(10);
|
||||
MtbColt uds = wmsLavorazioneService.createUDS(new CreateUDSRequestDTO().setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO).setCodMdep(posizione.getCodMdep()));
|
||||
MtbColt uds = wmsLavorazioneService.createUDS(new CreateUDSRequestDTO()
|
||||
.setCausaleCollo(CreateUDSRequestDTO.Causale.SCARICO)
|
||||
.setCodMdep(posizione.getCodMdep()));
|
||||
|
||||
MtbColt udc = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO().setCodMdep(posizione.getCodMdep()));
|
||||
udc.setDataVers(dataVers);
|
||||
|
||||
String partitaMagNew = suggestPartitaMix(articoloAccettato.getCodMart(), articoloAccettato.getPartitaMag(), colloMix.getPartitaMag(), posizione.getPosizione());
|
||||
MtbPartitaMag nuovaPartita = new MtbPartitaMag()
|
||||
.setPartitaMag(partitaMagNew)
|
||||
@@ -641,10 +661,6 @@ public class WMSAccettazioneService {
|
||||
entityProcessor.processEntity(udc, true, multiDBTransactionManager);
|
||||
|
||||
//sposto le quantità della nuova partita nella udc creata nel silos
|
||||
SpostaArtsTraULRequestDTO richiestaSpostamento = new SpostaArtsTraULRequestDTO();
|
||||
richiestaSpostamento.setSourceMtbColt(udc)
|
||||
.setDestinationMtbColt(colloDest);
|
||||
udc.setMtbCols(new ArrayList<>());
|
||||
|
||||
List<MtbColt> listaCarichi = new ArrayList<>();
|
||||
listaCarichi.add(udc);
|
||||
@@ -664,20 +680,15 @@ public class WMSAccettazioneService {
|
||||
UtilityEntity.throwEntitiesException(docGenerati);
|
||||
|
||||
|
||||
colloDest.setMtbCols(new ArrayList<>());
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(), udc, colloDest, false, entityProcessor, requestDataDTO);
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(), udc, ssccDest, false, entityProcessor, requestDataDTO);
|
||||
}
|
||||
|
||||
|
||||
//sposto le quantità del collo di accettazione nel silos
|
||||
SpostaArtsTraULRequestDTO richiestaSpostamento = new SpostaArtsTraULRequestDTO();
|
||||
richiestaSpostamento.setSourceMtbColt(colloCarico)
|
||||
.setDestinationMtbColt(colloDest);
|
||||
colloCarico.setMtbCols(new ArrayList<>());
|
||||
colloDest.setMtbCols(new ArrayList<>());
|
||||
colloDest.setMtbColr(new ArrayList<>());
|
||||
colloCarico.getMtbColr().get(0).setDatetimeRow(UtilityLocalDate.getNowTime().plusMinutes(5));
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(), colloCarico, colloDest, false, entityProcessor, requestDataDTO);
|
||||
WMSUtility.spostaArtsTraUL(multiDBTransactionManager.getPrimaryConnection(),
|
||||
colloCarico, ssccDest, false, entityProcessor, requestDataDTO);
|
||||
|
||||
return colloCarico;
|
||||
}
|
||||
@@ -687,14 +698,6 @@ public class WMSAccettazioneService {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
|
||||
private MtbColt getMonoColloPosizione(MtbDepoPosizioni posizione) throws Exception {
|
||||
String sql = "Select data_collo, gestione, num_collo, ser_collo from mvw_sitart_udc_det_inventario " +
|
||||
" where posizione = " + UtilityDB.valueToString(posizione.getPosizione()) +
|
||||
" AND cod_mdep = " + UtilityDB.valueToString(posizione.getCodMdep());
|
||||
MtbColt monoCollo = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
return monoCollo;
|
||||
}
|
||||
|
||||
|
||||
private MvwSitArtUdcDetInventarioDTO getUltimoVersamentoArticoloPosizione(MtbDepoPosizioni silos, String codMart) throws Exception {
|
||||
|
||||
@@ -750,4 +753,19 @@ public class WMSAccettazioneService {
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
}
|
||||
|
||||
public CreateUDCResponseDTO createUDCWithRows(CreateUDCWithRowsRequestDTO dto) throws Exception {
|
||||
if (!userSession.isAttivo()) {
|
||||
throw new UsernameNotFoundException("Utente " + userSession.getUsername() + " non riconosciuto!");
|
||||
}
|
||||
|
||||
MtbColt udc = this.createUDC(dto);
|
||||
|
||||
for (InsertUDCRowRequestDTO row : dto.getUdcRows()){
|
||||
row.setTargetMtbColt(udc);
|
||||
WMSUtility.insertUDCRow(row, entityProcessor, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
return new CreateUDCResponseDTO().setMtbColt(udc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class WMSDocumentService {
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final List<MtbUntMis> untMisFromCod = WMSUtility.getUntMisFromCod(untMiss,multiDBTransactionManager.getPrimaryConnection());
|
||||
final List<MtbUntMis> untMisFromCod = WMSUtility.getUntMisFromCod(untMiss, multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
for (DocumentArtDTO art : arts) {
|
||||
final MtbUntMis mtbUntMis = untMisFromCod.stream().filter(x -> x.getUntMis().equalsIgnoreCase(art.getUntMis()))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user