Compare commits
633 Commits
master-202
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 635ac0a1c7 | |||
| 8abf441a8a | |||
| 8781b406ff | |||
| c9325674d9 | |||
| 99ca1731b1 | |||
| af6f465c0e | |||
| d981e59a7d | |||
| 6d7212ce97 | |||
| 5103830369 | |||
| 5056d7e0c8 | |||
| 4b5e46de7b | |||
| 4d686ee145 | |||
| e842326f5b | |||
| 63ad11086f | |||
| 21f6fc6717 | |||
| 8c2789b5f3 | |||
| 8f3ef405cf | |||
| 76e76dfcf4 | |||
| 1df5ad7137 | |||
| a43ca46395 | |||
| a63eba544b | |||
| ce912bf103 | |||
| ababbf6142 | |||
| e97fd0aacb | |||
| 51c1ed1d23 | |||
| a9be8f7003 | |||
| 7522092a12 | |||
| 4dc0174800 | |||
| a04b2fa4a1 | |||
| 04317470c6 | |||
| 187216dd9f | |||
| e11172a90f | |||
| 51d5b05bd3 | |||
| 3a2ceaf217 | |||
| c783f69a49 | |||
| 1c8695095b | |||
| fc28af761c | |||
| fd4db5ab3b | |||
| f7e1d1f6ca | |||
| 0b8f82f041 | |||
| 99680dccd8 | |||
| e948855fc0 | |||
| 0854acacfb | |||
| 1aba141c9f | |||
| 741cb960d4 | |||
| 82d7efc00c | |||
| c6c2739525 | |||
| 313bfc21ff | |||
| 36f50ad846 | |||
| 798e5b532e | |||
| c27c96c3d9 | |||
| 4e3d15ebd8 | |||
| 0ba9297f39 | |||
| 7c036172d8 | |||
| 8afa01d8ef | |||
| db1949b5b6 | |||
| bb47dd458e | |||
| 530b6af4ef | |||
| 92cd4b1af5 | |||
| 6b71d6b784 | |||
| de4d8d225f | |||
| 671c2e99d0 | |||
| 755e7394b4 | |||
| ce06683722 | |||
| e8a1a8ca0b | |||
| 7a5c024005 | |||
| c82f2a57d8 | |||
| 78dbf9f7e3 | |||
| b9e863a563 | |||
| 60e4429c3f | |||
| d7012d4e1f | |||
| 1d52f79337 | |||
| 0e1adccb7c | |||
| fa76a8e92d | |||
| 9b34a51bd9 | |||
| b75f7e3810 | |||
| 4aeccdfa76 | |||
| 39db8e6e1b | |||
| 1b87cacca2 | |||
| 326bd4294e | |||
| 6a237ce4d9 | |||
| a64932d918 | |||
| e887aceaaf | |||
| a15d009f76 | |||
| a62f37d930 | |||
| 55f23b2dfc | |||
| a4a2b34379 | |||
| 1ef49b87e8 | |||
| f2d67ea89d | |||
| fda162d867 | |||
| 2008ef0e8f | |||
| 6d8e0e747f | |||
| 5417e28630 | |||
| 4ac4686645 | |||
| 1594154639 | |||
| 3a4a954b91 | |||
| 744f92c881 | |||
| 6e5f099fc2 | |||
| 697cd58e39 | |||
| 4bf1f6021f | |||
| 118d2d83d5 | |||
| 149bdc36b3 | |||
| 89c69bc0d2 | |||
| 240f18d19d | |||
| 9a8a144705 | |||
| 2f412f1ad6 | |||
| 8e8b03889a | |||
| dd4ace59bd | |||
| 52c0e0ca61 | |||
| e2f2b9bde9 | |||
| 4ea9be84db | |||
| 11e4b1cf20 | |||
| a66cfa16d8 | |||
| 9f628973e9 | |||
| 9fa7f9628c | |||
| 1a5156d53c | |||
| ba667fd28e | |||
| cddc7f8979 | |||
| 60c436256e | |||
| 46449c47b9 | |||
| f8b6d3ebe0 | |||
| b3d29219ee | |||
| 2c81a6566b | |||
| f697a122b6 | |||
| 3f4ed16f20 | |||
| cbbfbb16b8 | |||
| 585a04ffba | |||
| b025be1bd9 | |||
| 5453826156 | |||
| 8312d48970 | |||
| b50c348528 | |||
| 64aeff7bf6 | |||
| 2a8cf16ce0 | |||
| 3539e82849 | |||
| f4faa20652 | |||
| e7f5959e27 | |||
| 1d897f1461 | |||
| f3e48b9a3e | |||
| f0e41c6554 | |||
| 3d76dec03a | |||
| 754b58fd37 | |||
| 0627fd59c9 | |||
| 31480b8fbe | |||
| c1efdf48a6 | |||
| e1de9f4db9 | |||
| ce2ec669ba | |||
| c9658954aa | |||
| 5011aa271d | |||
| af4a5511a3 | |||
| fa996c210c | |||
| c5b5fb62a1 | |||
| 3b007c061e | |||
| 8ee9e2fe57 | |||
| 4ddcc6228e | |||
| 7cf9df3549 | |||
| 8e8d6cf2c3 | |||
| 2a5314fd1e | |||
| 9363e674b5 | |||
| e7252f7fea | |||
| b5e1d2e1ce | |||
| 53ef2539f5 | |||
| 6136d9b848 | |||
| fe2be9b926 | |||
| 1b113999b2 | |||
| 4ebcae77ca | |||
| 8d35f9284a | |||
| b953349afc | |||
| 6c2eaaa37a | |||
| 9b8824e681 | |||
| fb03aa1ea7 | |||
| c16e23d3bf | |||
| 27055f8e5e | |||
| b8ac769ffd | |||
| 0216bc5d53 | |||
| db3973637d | |||
| 7dab29e8c2 | |||
| 809ffe73b9 | |||
| 4d13d17095 | |||
| f749356735 | |||
| b2d24ab6b4 | |||
| 6bb7b55618 | |||
| 920257812c | |||
| 00efbe6fcf | |||
| cacb24a563 | |||
| 5da098e058 | |||
| 3e0c443ce3 | |||
| b4442bc251 | |||
| eec353c6a5 | |||
| 8b50f54881 | |||
| 42f50e0d80 | |||
| cbeae87d23 | |||
| 71cb1db5ef | |||
| bb642d92db | |||
| ddd3b95d17 | |||
| ff5428f8bd | |||
| d3b39ad878 | |||
| 99a366d875 | |||
| abc4f1c966 | |||
| fc1c2f192e | |||
| ac4afa9a2b | |||
| c5a315e070 | |||
| 1d0fd3341d | |||
| b44685335a | |||
| e5689da13d | |||
| f57710cb32 | |||
| ceb5dc817c | |||
| 3a934813d8 | |||
| d56fe38e2c | |||
| 5555a40731 | |||
| acf5daf673 | |||
| 939c4ab236 | |||
| 49237b9585 | |||
| abbf298b4f | |||
| 34985c9fd3 | |||
| 401f0330de | |||
| 7815fb72f1 | |||
| 0e8cc5b2de | |||
| 9a18dd6ebd | |||
| 3f0b9315a2 | |||
| 32a15a4f3e | |||
| 932f99c147 | |||
| 1fc7d01b9c | |||
| 46e47a9549 | |||
| ba1bbbafe0 | |||
| fa54de3d76 | |||
| 1550de37e6 | |||
| 450f9f4dd4 | |||
| f1da5057d6 | |||
| a3d15aeb32 | |||
| c933c02727 | |||
| 28b94b228a | |||
| c291db3e34 | |||
| 3f9a451a70 | |||
| 9f39c5bc2d | |||
| 6a455db664 | |||
| c33c1da199 | |||
| d0769ea1bd | |||
| f3f768380a | |||
| cb2cf06200 | |||
| a81fc6813c | |||
| 5c03b928b6 | |||
| 16b478a511 | |||
| c2ef09a604 | |||
| f2de64de75 | |||
| b877347a77 | |||
| 2d43952d96 | |||
| ee171374c8 | |||
| f0d1cdc81a | |||
| 1758dcabbb | |||
| 8231716e97 | |||
| 2603cda317 | |||
| 77c79c6247 | |||
| 532a9cc3f4 | |||
| c26f7feb35 | |||
| 15a63cff14 | |||
| b53d76358b | |||
| f9ded1153a | |||
| 81ddb42e5c | |||
| 5ac4d4be63 | |||
| 0b432960ec | |||
| 159436247d | |||
| 2a2435f64d | |||
| fba5e331b5 | |||
| 21cc88f295 | |||
| de21ce7cb8 | |||
| 33f24290a9 | |||
| dc83e89392 | |||
| d525048bb3 | |||
| f5d46be57d | |||
| ca4c3c3412 | |||
| e5c16c6e4e | |||
| 42bef35d5f | |||
| 44e3de6a0f | |||
| 9942f92440 | |||
| e34bb01aea | |||
| 6f11e08807 | |||
| aa9529f551 | |||
| bcb8f4475d | |||
| 8a83213384 | |||
| 2433c98ab1 | |||
| 595fe77472 | |||
| 29f9335876 | |||
| e975964f53 | |||
| 9d82cbc610 | |||
| 0a12dc23f2 | |||
| 1719f2ba37 | |||
| ddd9c73f49 | |||
| 1b0f5d5d29 | |||
| 6991e60ec5 | |||
| 8a87d428ae | |||
| 0058373710 | |||
| d9f93b14e1 | |||
| dea6b14323 | |||
| d01b4aef8f | |||
| b2c3008464 | |||
| d02f44237e | |||
| 675e919652 | |||
| 9d9d4e3d87 | |||
| 19e17f76d4 | |||
| df18330a01 | |||
| da61cb5439 | |||
| 975e4f2be4 | |||
| e31b0bc1a0 | |||
| 84ccdafd90 | |||
| 97de2f0e71 | |||
| 1ee321b253 | |||
| 7912d29f00 | |||
| ecd8bca2aa | |||
| 1a64179099 | |||
| 54588d20bd | |||
| 84f3823597 | |||
| 0022e620da | |||
| 62a1f5a85f | |||
| cd389dc83f | |||
| 974b5f61af | |||
| a10876effc | |||
| 4385520480 | |||
| a1b892a75e | |||
| 92dcc45638 | |||
| a178ec5017 | |||
| 1456e094a2 | |||
| 58b89777bb | |||
| f4da09eacc | |||
| 6f47434d6f | |||
| 8fb8e4c05a | |||
| d18ac96cc4 | |||
| 9b26849cb6 | |||
| fcbee627b0 | |||
| b17d807ca3 | |||
| 5b017fdad1 | |||
| 4957cba34b | |||
| 85e59e577f | |||
| 5c60cd2558 | |||
| 5a824d0b3a | |||
| f60c3337b1 | |||
| 4ee64127b1 | |||
| b587e38cc8 | |||
| be4c2d149e | |||
| ccb8b81597 | |||
| 68a45a9eea | |||
| d419c38220 | |||
| 8fe752e595 | |||
| 71ffc5b4cf | |||
| f00f0cf975 | |||
| 19e8949d86 | |||
| cc189f4761 | |||
| bd3bf9a8dc | |||
| bee29e357e | |||
| 461b949581 | |||
| 7fd4b6236c | |||
| 5075e17078 | |||
| c6e2230052 | |||
| f9794850c4 | |||
| ee18ecb15e | |||
| 656f2018a2 | |||
| 2b4cea4ada | |||
| 2aa6384f69 | |||
| 72ebb39b22 | |||
| 8e01509e99 | |||
| e4de8e4287 | |||
| 18da8c2763 | |||
| a770e150a4 | |||
| 96993755da | |||
| 30db0f9182 | |||
| 8064e87017 | |||
| ef399668c4 | |||
| 72059e4623 | |||
| db5ee20a39 | |||
| ee4bf3d501 | |||
| 7b40578ea4 | |||
| 9685bff5ef | |||
| 3bff9a6fdc | |||
| bfa48cbbb1 | |||
| 4f2b251d20 | |||
| a1f1ffba95 | |||
| 1ab59fa9a6 | |||
| 800407ebd7 | |||
| 3dad6790fc | |||
| d073a8fd17 | |||
| a9068c45cd | |||
| ca78b09ad8 | |||
| 3e17a7239a | |||
| d78597cba4 | |||
| 91f28a8c82 | |||
| 03a7877899 | |||
| 46e8a19c53 | |||
| 81a42fc1d9 | |||
| fdbcc0c539 | |||
| 7d51ddb868 | |||
| 9f25bd2bf6 | |||
| a9ce0d82b6 | |||
| 83d2f329ce | |||
| 7e06512598 | |||
| b5776e82c9 | |||
| 05dd42b0bf | |||
| 636774ed86 | |||
| 6649af6e92 | |||
| acfff8e8d6 | |||
| 44c1bd7cee | |||
| c712e729cc | |||
| b684129f39 | |||
| 1b339289c1 | |||
| b246991600 | |||
| dc578d1f17 | |||
| 6c6f6d4d7e | |||
| 50dcb999f1 | |||
| c656cc95de | |||
| 0b0b5bbf33 | |||
| c2310327d2 | |||
| 9962471f71 | |||
| 8ad86f71d3 | |||
| 3a42baab00 | |||
| a1bfd0150c | |||
| 2e420fc540 | |||
| f591246ae3 | |||
| d4c02cf504 | |||
| e15878a9eb | |||
| 39f43b3361 | |||
| 18a6756860 | |||
| 3640b08041 | |||
| 928d47f772 | |||
| 28478cb11d | |||
| 0c48df7895 | |||
| 327f5af3dd | |||
| 62234f2edf | |||
| 2fcba55965 | |||
| d29768776a | |||
| 3dcf6d3ee0 | |||
| 7c2aa55eb8 | |||
| e92d64a05e | |||
| 0fa021be3e | |||
| 086bd574d5 | |||
| b46f26790d | |||
| c364d57e86 | |||
| 6d89e4d09b | |||
| 3391051bb8 | |||
| acba051357 | |||
| 785ae254ee | |||
| 21a189ea66 | |||
| 3a4a11d9e8 | |||
| 6d5d021884 | |||
| 185d403d7a | |||
| 349d983b7f | |||
| 85ed6b54f9 | |||
| 9b6b0c87aa | |||
| fd68a9b73a | |||
| 433ab4b0ec | |||
| df9fbc7f65 | |||
| a8253614b4 | |||
| 9977cae821 | |||
| 344010ed90 | |||
| 1c51fb717a | |||
| 81827a8368 | |||
| 21222a25e9 | |||
| 838f32e04c | |||
| d24a033e01 | |||
| bdaf4a5ac6 | |||
| 5e76d8db2a | |||
| bae92e626b | |||
| 0d471db37d | |||
| c4c6875e16 | |||
| 3515e5c976 | |||
| 84a6f4c4f1 | |||
| ee9ec1a8a7 | |||
| 1884a9184e | |||
| caa62588b6 | |||
| 8bb9803f5b | |||
| ea27c26597 | |||
| 80aaa94036 | |||
| a82c0de415 | |||
| 762ae4827f | |||
| 68b12b0cba | |||
| f61577ee64 | |||
| 87e4d8704c | |||
| a5f22e68d2 | |||
| cf261ab427 | |||
| 5bd3b02ff0 | |||
| 10f62b669c | |||
| 565aec0739 | |||
| 7112cf15da | |||
| 03a061ae1f | |||
| 1e21e37e3c | |||
| 9da3fe3daa | |||
| b127ca2222 | |||
| be688efd2c | |||
| 94b1318a56 | |||
| 2e9e120cdb | |||
| 1000b1abbe | |||
| 0f2246f033 | |||
| 9dfee9d605 | |||
| 3ecd9e365e | |||
| 78a13ae89b | |||
| 6f8ddf6aa5 | |||
| 03f9de19b3 | |||
| a74e9aeb92 | |||
| 709422856b | |||
| 034a3cb2b5 | |||
| a9caf10897 | |||
| 659908ecf7 | |||
| 7ebecd94cd | |||
| 5bcb9000a9 | |||
| fe622dd742 | |||
| ab5d7e74a2 | |||
| 68e6dd246f | |||
| 8fe2b50d5c | |||
| ebc8401989 | |||
| 67765fc7d2 | |||
| a303459b7d | |||
| 2b68967ce0 | |||
| b0194e569a | |||
| 164516166f | |||
| 3339cf1c9d | |||
| d635079e50 | |||
| 069ee22499 | |||
| e7082aef49 | |||
| ebf3a750a2 | |||
| a25dc83d30 | |||
| 7d0bc83b67 | |||
| 38a5b2510a | |||
| fe2d868ca6 | |||
| aca7cc07e6 | |||
| a1618ad2ad | |||
| 67756553f3 | |||
| 473c2e05b5 | |||
| 84560a94ea | |||
| 9a35af5b20 | |||
| ba899f3309 | |||
| 8b9454a684 | |||
| 612bc1e3de | |||
| 6f198e7d5a | |||
| 0c6f7f769b | |||
| 19e709fc3d | |||
| fd4636e6a6 | |||
| 62458a0640 | |||
| 43efca4045 | |||
| 5106ff9f12 | |||
| 3516a8c8de | |||
| 62857a9bb0 | |||
|
|
e1b85b8879 | ||
| 3f4a8b38eb | |||
| 99047236fc | |||
| 0f3c828c1f | |||
| 6d950cee38 | |||
| 2b426103cd | |||
| 876daa7df4 | |||
| cca26eb472 | |||
| a1c7f63976 | |||
| e83e7f03c8 | |||
| e4b08b9a61 | |||
| b4f8fa49da | |||
| 5842cf0048 | |||
| d75dd5ead7 | |||
| b6eed691d0 | |||
| 49626f4371 | |||
| 6e1d889eb8 | |||
| 0cf5dbd24b | |||
| 19d4c6b929 | |||
| a040670c5b | |||
| b9fd701098 | |||
| d39134c47e | |||
| fa0b2e338b | |||
| 0efc991231 | |||
| 965e9ee3b4 | |||
| 59aabd6a43 | |||
| 40f5649a5f | |||
| 45d067673c | |||
| 9634306d01 | |||
| d8e24764dc | |||
| 5cd2151f6c | |||
| 449aa664ab | |||
| 91f7269af4 | |||
| 29a8f6efc6 | |||
| be3b57b1c5 | |||
| cd5cfa88bc | |||
| d28e3578e4 | |||
| af6b053215 | |||
| cd3468fd50 | |||
| ac5361b9a8 | |||
| e7b3d65628 | |||
| 164f105878 | |||
| 605ec9a910 | |||
| 8d83789356 | |||
| 623d9d316a | |||
| bba6ae5d9b | |||
| db32ba0e15 | |||
| 02e2e73259 | |||
| 1bc1caa528 | |||
| 3637ba0048 | |||
| 7409d15cce | |||
| 563902d29e | |||
| c2994b8767 | |||
| 7a9b1fba4d | |||
| 88743f65c6 | |||
| 61cf7b8601 | |||
| 2663f039a0 | |||
| 0bac28fc98 | |||
| 9f696ec2cd | |||
| 8983748314 | |||
| bcb39b8829 | |||
| 3abf35028f | |||
| 58c7d31fea | |||
| 68db2d9591 | |||
| d6d342ba42 | |||
| 9b7ba6e6f4 | |||
| fc3fcaf80c | |||
| 8a2029f396 | |||
| 3b4d29d1c4 | |||
| 952e1b22f2 | |||
| 3151755a1f | |||
| 2659bbdc83 | |||
| d60ffea913 | |||
| 0144d6d7ef | |||
| 755132a1b9 | |||
| 0b1292ec55 | |||
| 4b4ba7bc10 | |||
| 8f365e77be | |||
| 5052f6dc2d | |||
| 42a9756d94 | |||
| 41fbeb333f | |||
| 279257a35d | |||
| 5d7d2cb99f | |||
| 9676b65be3 | |||
| 27f28abb9b | |||
| b3e390a634 | |||
| 2ae58205d8 | |||
| ea025c1f31 | |||
| 0a03b1d489 | |||
| 9d14673771 | |||
| ee9f4b08ff | |||
| cdc81c58e7 | |||
| 4c4b364177 | |||
| 0a46eda642 | |||
| 53fb1cb58e |
18
.idea/copilotDiffState.xml
generated
Normal file
18
.idea/copilotDiffState.xml
generated
Normal file
File diff suppressed because one or more lines are too long
33
.idea/dataSources.xml
generated
33
.idea/dataSources.xml
generated
@@ -1,11 +1,40 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
<data-source source="LOCAL" name="@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
|
<data-source source="LOCAL" name="Biolevante@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
|
||||||
<driver-ref>sqlserver.ms</driver-ref>
|
<driver-ref>sqlserver.ms</driver-ref>
|
||||||
<synchronize>true</synchronize>
|
<synchronize>true</synchronize>
|
||||||
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||||
<jdbc-url>jdbc:sqlserver://SERVERDB2019</jdbc-url>
|
<jdbc-url>jdbc:sqlserver://SERVERDB2019\MSSQLSERVER;database=Biolevante</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="Gramm@SERVERDB2019" uuid="02282d62-6d2a-4b83-bdcf-b558fa6db140">
|
||||||
|
<driver-ref>sqlserver.ms</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlserver://SERVERDB2019\MSSQLSERVER;database=Gramm</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="vgalimenti@SERVERDB" uuid="eaf0bcaf-4620-478b-b63c-42e77902813f">
|
||||||
|
<driver-ref>sqlserver.ms</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlserver://SERVERDB\MSSQLSERVER;database=vgalimenti</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
8
.idea/data_source_mapping.xml
generated
Normal file
8
.idea/data_source_mapping.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourcePerFileMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query.sql" value="ff4f0bad-7271-429e-a4e1-bae28629efc8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_1.sql" value="02282d62-6d2a-4b83-bdcf-b558fa6db140" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" value="eaf0bcaf-4620-478b-b63c-42e77902813f" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/db-forest-config.xml
generated
Normal file
6
.idea/db-forest-config.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="db-tree-configuration">
|
||||||
|
<option name="data" value="---------------------------------------- 1:0:ff4f0bad-7271-429e-a4e1-bae28629efc8 2:0:02282d62-6d2a-4b83-bdcf-b558fa6db140 3:0:eaf0bcaf-4620-478b-b63c-42e77902813f " />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
1822
.idea/inspectionProfiles/LocalDate_Checks.xml
generated
Normal file
1822
.idea/inspectionProfiles/LocalDate_Checks.xml
generated
Normal file
File diff suppressed because it is too large
Load Diff
2485
.idea/inspectionProfiles/Project_Default.xml
generated
2485
.idea/inspectionProfiles/Project_Default.xml
generated
File diff suppressed because it is too large
Load Diff
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="PROJECT_PROFILE" value="LocalDate Checks" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -1,6 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="central" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
|
|||||||
8
.idea/sqldialects.xml
generated
Normal file
8
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query.sql" dialect="TSQL" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_1.sql" dialect="TSQL" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" dialect="TSQL" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
30
.idea/structuralSearch.xml
generated
Normal file
30
.idea/structuralSearch.xml
generated
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="StructuralSearch">
|
||||||
|
<searchConfiguration name="LocalDate passato a SimpleDateFormat" text="$formatter$.format($date$)" recursive="true" caseInsensitive="true" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="formatter" nameOfExprType="java\.text\.SimpleDateFormat" within="" contains="" />
|
||||||
|
<constraint name="date" nameOfExprType="java\.time\.LocalDate" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="LocalDate equals java.util.Date inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.time\.LocalDate" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="java.util.Date equals LocalDate inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.time\.LocalDate" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="java.util.Date equals LocalDateTime inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.time\.LocalDateTime" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="LocalDateTime equals java.util.Date inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.time\.LocalDateTime" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM tomcat:9-jre8-alpine
|
|
||||||
|
|
||||||
RUN apk add --no-cache fontconfig ttf-dejavu
|
|
||||||
|
|
||||||
ENV TZ="Europe/Rome"
|
|
||||||
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx1G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
|
|
||||||
ENV USERDOMAIN="STUDIO-ML"
|
|
||||||
|
|
||||||
COPY docker/tomcat/conf/integry/ems.properties /usr/local/tomcat/conf/integry/
|
|
||||||
COPY docker/tomcat/conf/integry/ems_automated_operations.json /usr/local/tomcat/conf/integry/
|
|
||||||
COPY docker/tomcat/conf/integry/ems_settings.json /usr/local/tomcat/conf/integry/
|
|
||||||
COPY ems-engine/target/ems-api.war /usr/local/tomcat/webapps/
|
|
||||||
|
|
||||||
#COPY docker/FontTest.class .
|
|
||||||
#ENTRYPOINT ["java","FontTest"]
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
EXPOSE 5005
|
|
||||||
42
Dockerfile
42
Dockerfile
@@ -1,11 +1,45 @@
|
|||||||
FROM tomcat:9-jre8-alpine
|
FROM tomcat:9-jre8
|
||||||
|
|
||||||
RUN apk add --no-cache fontconfig ttf-dejavu
|
|
||||||
|
|
||||||
ENV TZ="Europe/Rome"
|
ENV TZ="Europe/Rome"
|
||||||
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx1G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
|
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx2G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
|
||||||
ENV USERDOMAIN="STUDIO-ML"
|
ENV USERDOMAIN="STUDIO-ML"
|
||||||
|
|
||||||
|
# Install Samba
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y samba samba-common-bin && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Ensure log directory exists and is readable
|
||||||
|
RUN mkdir -p /usr/local/tomcat/logs && \
|
||||||
|
chmod -R 755 /usr/local/tomcat/logs
|
||||||
|
|
||||||
|
# Create samba user (no login) and add to root group
|
||||||
|
RUN useradd -M -s /usr/sbin/nologin sambauser && \
|
||||||
|
printf "sambapass\nsambapass\n" | smbpasswd -a -s sambauser && \
|
||||||
|
usermod -aG root sambauser
|
||||||
|
|
||||||
|
# Samba configuration
|
||||||
|
RUN printf "\
|
||||||
|
[global]\n\
|
||||||
|
workgroup = STUDIO-ML\n\
|
||||||
|
security = user\n\
|
||||||
|
map to guest = never\n\
|
||||||
|
server role = standalone server\n\
|
||||||
|
unix extensions = no\n\
|
||||||
|
client min protocol = NT1\n\
|
||||||
|
\n\
|
||||||
|
[tomcat-logs]\n\
|
||||||
|
comment = Tomcat logs (read-only)\n\
|
||||||
|
path = /usr/local/tomcat/logs\n\
|
||||||
|
browseable = yes\n\
|
||||||
|
read only = yes\n\
|
||||||
|
guest ok = no\n\
|
||||||
|
valid users = sambauser\n\
|
||||||
|
force user = root\n\
|
||||||
|
create mask = 0644\n\
|
||||||
|
directory mask = 0755\n\
|
||||||
|
" > /etc/samba/smb.conf
|
||||||
|
|
||||||
COPY docker/tomcat/conf/integry/ems.properties /usr/local/tomcat/conf/integry/
|
COPY docker/tomcat/conf/integry/ems.properties /usr/local/tomcat/conf/integry/
|
||||||
COPY docker/tomcat/conf/integry/ems_automated_operations.json /usr/local/tomcat/conf/integry/
|
COPY docker/tomcat/conf/integry/ems_automated_operations.json /usr/local/tomcat/conf/integry/
|
||||||
COPY docker/tomcat/conf/integry/ems_settings.json /usr/local/tomcat/conf/integry/
|
COPY docker/tomcat/conf/integry/ems_settings.json /usr/local/tomcat/conf/integry/
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pipeline {
|
|||||||
bat(script: 'mvn clean install -t toolchains-jenkins.xml', returnStdout: true)
|
bat(script: 'mvn clean install -t toolchains-jenkins.xml', returnStdout: true)
|
||||||
archiveArtifacts(artifacts: 'ems-engine/target/ems-api.war', onlyIfSuccessful: true)
|
archiveArtifacts(artifacts: 'ems-engine/target/ems-api.war', onlyIfSuccessful: true)
|
||||||
}
|
}
|
||||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Containerfile', name: 'container-files'
|
stash includes: 'ems-engine/target/ems-api.war,docker/**,Dockerfile', name: 'container-files'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
|||||||
}
|
}
|
||||||
|
|
||||||
// bat "docker buildx build --platform linux/amd64,linux/arm64 --push -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
// bat "docker buildx build --platform linux/amd64,linux/arm64 --push -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||||
bat "podman build -f .\\Containerfile -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
bat "podman build -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||||
bat "podman push \"git.studioml.it/integry/ems-api${branchVersion}:latest\""
|
bat "podman push \"git.studioml.it/integry/ems-api${branchVersion}:latest\""
|
||||||
|
|
||||||
//containerImageLink "git.studioml.it/integry/ems-api-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}:latest}"
|
//containerImageLink "git.studioml.it/integry/ems-api-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}:latest}"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -229,6 +229,11 @@
|
|||||||
<artifactId>arial-rounded</artifactId>
|
<artifactId>arial-rounded</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.integry.font</groupId>
|
||||||
|
<artifactId>NotoSerif</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.groovy</groupId>
|
<groupId>org.apache.groovy</groupId>
|
||||||
@@ -399,6 +404,17 @@
|
|||||||
<artifactId>spring-orm</artifactId>
|
<artifactId>spring-orm</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-jpa</artifactId>
|
||||||
|
<version>2.7.18</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
<version>5.6.15.Final</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context-support</artifactId>
|
<artifactId>spring-context-support</artifactId>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public class CommonConstants {
|
|||||||
|
|
||||||
public static final String INTEGRY = "integry";
|
public static final String INTEGRY = "integry";
|
||||||
public static final String PROFILE_DB = "profileDb";
|
public static final String PROFILE_DB = "profileDb";
|
||||||
|
public static final String COD_MDEP = "codMdep";
|
||||||
public static final String WHERE_COND = "whereCond";
|
public static final String WHERE_COND = "whereCond";
|
||||||
public static final String EMPTY_STRING = "";
|
public static final String EMPTY_STRING = "";
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ public class CommonConstants {
|
|||||||
public static final String TIMESTAMP = "timestamp";
|
public static final String TIMESTAMP = "timestamp";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String DATE_FORMAT_YMD_SLASHED = "yyyy/MM/dd";
|
||||||
public static final String DATE_FORMAT_YMD = "yyyy-MM-dd";
|
public static final String DATE_FORMAT_YMD = "yyyy-MM-dd";
|
||||||
public static final String DATE_FORMAT_DMY = "dd/MM/yyyy";
|
public static final String DATE_FORMAT_DMY = "dd/MM/yyyy";
|
||||||
public static final String DATE_FORMAT_DMY_DASHED = "dd-MM-yyyy";
|
public static final String DATE_FORMAT_DMY_DASHED = "dd-MM-yyyy";
|
||||||
@@ -27,7 +29,7 @@ public class CommonConstants {
|
|||||||
|
|
||||||
public static final String TIME_FORMAT = "HH:mm:ss";
|
public static final String TIME_FORMAT = "HH:mm:ss";
|
||||||
|
|
||||||
public static final String DATETIME_FORMAT_YMD = String.format("%s %s", DATE_FORMAT_YMD, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_YMD = String.format("%s %s", DATE_FORMAT_YMD_SLASHED, TIME_FORMAT);
|
||||||
public static final String DATETIME_FORMAT_DMY = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_DMY = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
||||||
public static final String DATETIME_FORMAT_DMY_SLASHED = String.format("%s %s", DATE_FORMAT_DMY, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_DMY_SLASHED = String.format("%s %s", DATE_FORMAT_DMY, TIME_FORMAT);
|
||||||
public static final String DATETIME_FORMAT_DMY_DASHED = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_DMY_DASHED = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
||||||
@@ -46,6 +48,10 @@ public class CommonConstants {
|
|||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
|
||||||
|
public static final DateTimeFormatter DATE_YMD_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD_SLASHED)
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
|
public static final DateTimeFormatter DATETIME_YMD_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD)
|
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATETIME_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
public static final DateTimeFormatter DATETIME_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
||||||
@@ -53,6 +59,8 @@ public class CommonConstants {
|
|||||||
|
|
||||||
public static final DateTimeFormatter DATE_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY)
|
public static final DateTimeFormatter DATE_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
public static final DateTimeFormatter DATE_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY_DASHED)
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATETIME_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_SLASHED)
|
public static final DateTimeFormatter DATETIME_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_SLASHED)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATETIME_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_DASHED)
|
public static final DateTimeFormatter DATETIME_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_DASHED)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package it.integry.ems._context;
|
|||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
import it.integry.common.var.EmsDBConst;
|
import it.integry.common.var.EmsDBConst;
|
||||||
import it.integry.ems.expansion.RunnableArgsThrowable;
|
import it.integry.ems.expansion.RunnableArgsThrowable;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||||
@@ -69,7 +69,6 @@ public class EmsCoreDBLoader {
|
|||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionPool)){
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionPool)){
|
||||||
discoverAllConnections(multiDBTransactionManager);
|
discoverAllConnections(multiDBTransactionManager);
|
||||||
setupAzienda(multiDBTransactionManager);
|
setupAzienda(multiDBTransactionManager);
|
||||||
userCacheService.discoverAllUsers(multiDBTransactionManager);
|
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run(multiDBTransactionManager);
|
if (onComplete != null) onComplete.run(multiDBTransactionManager);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -83,9 +82,9 @@ public class EmsCoreDBLoader {
|
|||||||
private void discoverAllConnections(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
private void discoverAllConnections(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||||
|
|
||||||
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
||||||
for (AvailableConnectionsModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
for (AvailableConnectionModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
||||||
|
|
||||||
AtomicReference<AvailableConnectionsModel> modelAtomicReference = new AtomicReference<>(model);
|
AtomicReference<AvailableConnectionModel> modelAtomicReference = new AtomicReference<>(model);
|
||||||
|
|
||||||
futureTasks.add(() -> {
|
futureTasks.add(() -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.adapter;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class LongDeserializer extends JsonDeserializer<Long> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long deserialize(JsonParser parser, DeserializationContext context)
|
||||||
|
throws IOException {
|
||||||
|
String string = parser.getText();
|
||||||
|
|
||||||
|
if (!UtilityString.isNullOrEmpty(string)) {
|
||||||
|
if (string.equalsIgnoreCase("null")) {
|
||||||
|
return EmsRestConstants.LONG_NULL;
|
||||||
|
}
|
||||||
|
return new Long(string);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ public class ExecutorServiceConfig {
|
|||||||
|
|
||||||
private final int corePoolSize = Runtime.getRuntime().availableProcessors();
|
private final int corePoolSize = Runtime.getRuntime().availableProcessors();
|
||||||
private final int maxPoolSize = (int) (corePoolSize * 1.5f);
|
private final int maxPoolSize = (int) (corePoolSize * 1.5f);
|
||||||
private final int queueSize = 500;
|
private final int queueSize = 1_000_000;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ExecutorService taskExecutor() {
|
public ExecutorService taskExecutor() {
|
||||||
|
|||||||
@@ -793,9 +793,8 @@ public class EmsController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_EMAIL_CONTENT, method = RequestMethod.GET)
|
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_EMAIL_CONTENT, method = RequestMethod.GET)
|
||||||
public byte[] downloadStbEmailContent(HttpServletRequest request, HttpServletResponse response,
|
public ResponseEntity<byte[]> downloadStbEmailContent(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
@RequestParam Integer idEmail) throws Exception {
|
||||||
@RequestParam Integer idEmail) throws Exception {
|
|
||||||
StbEmailContent stbEmailContent = new StbEmailContent();
|
StbEmailContent stbEmailContent = new StbEmailContent();
|
||||||
stbEmailContent.setIdEmail(idEmail);
|
stbEmailContent.setIdEmail(idEmail);
|
||||||
stbEmailContent.setOperation(OperationType.SELECT_OBJECT);
|
stbEmailContent.setOperation(OperationType.SELECT_OBJECT);
|
||||||
@@ -803,11 +802,7 @@ public class EmsController {
|
|||||||
stbEmailContent = entityProcessor.processEntity(stbEmailContent, multiDBTransactionManager);
|
stbEmailContent = entityProcessor.processEntity(stbEmailContent, multiDBTransactionManager);
|
||||||
|
|
||||||
if (stbEmailContent != null) {
|
if (stbEmailContent != null) {
|
||||||
response.setContentType("application/octet-stream");
|
byte[] byteArr;
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
|
||||||
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment().filename("email.eml").build().toString());
|
|
||||||
|
|
||||||
byte[] byteArr = null;
|
|
||||||
|
|
||||||
String pattern = "[^\\x00-\\x7F]";
|
String pattern = "[^\\x00-\\x7F]";
|
||||||
Pattern pat = Pattern.compile(pattern);
|
Pattern pat = Pattern.compile(pattern);
|
||||||
@@ -819,13 +814,18 @@ public class EmsController {
|
|||||||
byteArr = Base64.decodeBase64(stbEmailContent.getEmailContent());
|
byteArr = Base64.decodeBase64(stbEmailContent.getEmailContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setContentLength(byteArr != null ? byteArr.length : 0);
|
return ResponseEntity.ok()
|
||||||
return byteArr;
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
.contentLength(byteArr != null ? byteArr.length : 0)
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||||
|
.builder("attachment")
|
||||||
|
.filename("email.eml")
|
||||||
|
.build()
|
||||||
|
.toString())
|
||||||
|
.body(byteArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.sendError(404, "Allegato non trovato");
|
return ResponseEntity.notFound().build();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_DOC_PDF, method = RequestMethod.GET)
|
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_DOC_PDF, method = RequestMethod.GET)
|
||||||
@@ -884,12 +884,13 @@ public class EmsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_ORD_PDF, method = RequestMethod.GET)
|
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_ORD_PDF, method = RequestMethod.GET)
|
||||||
public byte[] downloadDtbOrdPdf(HttpServletRequest request, HttpServletResponse response,
|
public ResponseEntity<byte[]> downloadDtbOrdPdf(
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
@RequestParam String gestione,
|
@RequestParam String gestione,
|
||||||
@RequestParam String dataOrd,
|
@RequestParam String dataOrd,
|
||||||
@RequestParam Integer numOrd,
|
@RequestParam Integer numOrd,
|
||||||
@RequestParam Integer versione) throws Exception {
|
@RequestParam Integer versione) throws Exception {
|
||||||
|
|
||||||
DtbOrdPdf dtbOrdPdf = new DtbOrdPdf();
|
DtbOrdPdf dtbOrdPdf = new DtbOrdPdf();
|
||||||
dtbOrdPdf.setGestione(gestione);
|
dtbOrdPdf.setGestione(gestione);
|
||||||
dtbOrdPdf.setDataOrd(UtilityDate.RecognizeDate(dataOrd));
|
dtbOrdPdf.setDataOrd(UtilityDate.RecognizeDate(dataOrd));
|
||||||
@@ -900,17 +901,20 @@ public class EmsController {
|
|||||||
dtbOrdPdf = entityProcessor.processEntity(dtbOrdPdf, multiDBTransactionManager);
|
dtbOrdPdf = entityProcessor.processEntity(dtbOrdPdf, multiDBTransactionManager);
|
||||||
|
|
||||||
if (dtbOrdPdf != null) {
|
if (dtbOrdPdf != null) {
|
||||||
response.setContentType("application/octet-stream");
|
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
|
||||||
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment().filename(dtbOrdPdf.getFilename()).build().toString());
|
|
||||||
|
|
||||||
byte[] byteArr = dtbOrdPdf.getFilecontentByteArr(true);
|
byte[] byteArr = dtbOrdPdf.getFilecontentByteArr(true);
|
||||||
response.setContentLength(byteArr != null ? byteArr.length : 0);
|
|
||||||
return byteArr;
|
return ResponseEntity.ok()
|
||||||
|
.contentType(MediaType.APPLICATION_PDF)
|
||||||
|
.contentLength(byteArr != null ? byteArr.length : 0)
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||||
|
.builder("attachment")
|
||||||
|
.filename(ContentDisposition.attachment().filename(dtbOrdPdf.getFilename()).build().toString())
|
||||||
|
.build()
|
||||||
|
.toString())
|
||||||
|
.body(byteArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.sendError(404, "Allegato non trovato");
|
return ResponseEntity.notFound().build();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.POST)
|
@RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.POST)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package it.integry.ems.datasource;
|
package it.integry.ems.datasource;
|
||||||
|
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityHashMap;
|
import it.integry.ems_model.utility.UtilityHashMap;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -13,17 +14,26 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
public class DataSource extends BasicDataSource {
|
public class DataSource extends BasicDataSource {
|
||||||
|
|
||||||
private AvailableConnectionsModel connectionModel;
|
private final int POOL_SIZE;
|
||||||
|
|
||||||
|
private AvailableConnectionModel connectionModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instanzia un nuovo datasource.
|
* Instanzia un nuovo datasource.
|
||||||
*
|
*
|
||||||
* @deprecated Il datasource non deve essere istanziato direttamente ma bisogna utilizzare il metodo
|
* @deprecated Il datasource non deve essere istanziato direttamente ma bisogna utilizzare il metodo
|
||||||
* {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(AvailableConnectionsModel)} per ottenere una connessione.
|
* {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(AvailableConnectionModel)} per ottenere una connessione.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public DataSource() {
|
public DataSource() {
|
||||||
super();
|
super();
|
||||||
|
POOL_SIZE = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public DataSource(int poolSize) {
|
||||||
|
super();
|
||||||
|
POOL_SIZE = poolSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmsRestConstants.DB_TYPE getTypeDB() {
|
public EmsRestConstants.DB_TYPE getTypeDB() {
|
||||||
@@ -62,12 +72,20 @@ public class DataSource extends BasicDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initialize(String profileDB) throws Exception {
|
public synchronized void initialize(String profileDB) throws Exception {
|
||||||
AvailableConnectionsModel connectionsModel = SettingsModel.getInstance().findConnectionModel(profileDB);
|
initialize(profileDB, null);
|
||||||
|
|
||||||
initialize(connectionsModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initialize(AvailableConnectionsModel connectionModel) throws Exception {
|
public synchronized void initialize(String profileDB, String customAppName) throws Exception {
|
||||||
|
AvailableConnectionModel connectionsModel = SettingsModel.getInstance().findConnectionModel(profileDB);
|
||||||
|
|
||||||
|
initialize(connectionsModel, customAppName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void initialize(AvailableConnectionModel connectionModel) throws Exception {
|
||||||
|
initialize(connectionModel, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void initialize(AvailableConnectionModel connectionModel, String customAppName) throws Exception {
|
||||||
if (connectionModel == null) {
|
if (connectionModel == null) {
|
||||||
throw new Exception("Configurazione DB non trovata");
|
throw new Exception("Configurazione DB non trovata");
|
||||||
}
|
}
|
||||||
@@ -76,7 +94,7 @@ public class DataSource extends BasicDataSource {
|
|||||||
|
|
||||||
this.setDriverClassName(connectionModel.getDriverClassName());
|
this.setDriverClassName(connectionModel.getDriverClassName());
|
||||||
|
|
||||||
this.setUrl(connectionModel.getDbConnectionString("EMS Connection"));
|
this.setUrl(connectionModel.getDbConnectionString(UtilityString.isNull(customAppName, "EMS Connection")));
|
||||||
this.setUsername(connectionModel.getUsername());
|
this.setUsername(connectionModel.getUsername());
|
||||||
this.setPassword(connectionModel.getPasswordDecrypted());
|
this.setPassword(connectionModel.getPasswordDecrypted());
|
||||||
this.setDefaultCatalog(connectionModel.getDbName());
|
this.setDefaultCatalog(connectionModel.getDbName());
|
||||||
@@ -87,9 +105,9 @@ public class DataSource extends BasicDataSource {
|
|||||||
// ===== OTTIMIZZAZIONI CRITICHE =====
|
// ===== OTTIMIZZAZIONI CRITICHE =====
|
||||||
|
|
||||||
// Pool sizing ottimizzato per READ_UNCOMMITTED (meno locking = più connessioni possibili)
|
// Pool sizing ottimizzato per READ_UNCOMMITTED (meno locking = più connessioni possibili)
|
||||||
this.setInitialSize(5); // Inizia con più connessioni
|
this.setInitialSize(POOL_SIZE); // Inizia con più connessioni
|
||||||
this.setMaxTotal(-1); // Aumentato il massimo
|
this.setMaxTotal(-1); // Aumentato il massimo
|
||||||
this.setMinIdle(5); // Non scendere sotto 5
|
this.setMinIdle(POOL_SIZE); // Non scendere sotto 5
|
||||||
this.setMaxIdle(-1); // Mantieni più connessioni idle
|
this.setMaxIdle(-1); // Mantieni più connessioni idle
|
||||||
|
|
||||||
// Timeout ottimizzati per performance massime
|
// Timeout ottimizzati per performance massime
|
||||||
@@ -97,8 +115,8 @@ public class DataSource extends BasicDataSource {
|
|||||||
|
|
||||||
// Validazione veloce ed efficiente
|
// Validazione veloce ed efficiente
|
||||||
this.setValidationQuery("SELECT 1");
|
this.setValidationQuery("SELECT 1");
|
||||||
// this.setValidationQueryTimeout(60); // Ridotto a 1 secondo
|
this.setValidationQueryTimeout(30); // Ridotto a 1 secondo
|
||||||
// this.setTestWhileIdle(true); // Testa connessioni idle
|
this.setTestWhileIdle(true); // Testa connessioni idle
|
||||||
|
|
||||||
// Eviction ottimizzata per READ_UNCOMMITTED
|
// Eviction ottimizzata per READ_UNCOMMITTED
|
||||||
// this.setTimeBetweenEvictionRunsMillis(1 * 1000); // Ogni 30 secondi
|
// this.setTimeBetweenEvictionRunsMillis(1 * 1000); // Ogni 30 secondi
|
||||||
|
|||||||
@@ -0,0 +1,302 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.component;
|
||||||
|
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
|
||||||
|
import it.integry.ems.datasource.DataSource;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.ChangeTrackingConfigDTO;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.DetectedChangeDataDTO;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityHashMap;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class DbmsChangeTracker {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
private final int CHANGE_RETENTION_HOURS = 1;
|
||||||
|
private final boolean AUTO_CLEANUP = true;
|
||||||
|
|
||||||
|
private Connection integryConnection;
|
||||||
|
private boolean trackerEnabled = false;
|
||||||
|
private long currentVersion;
|
||||||
|
|
||||||
|
|
||||||
|
private Listener eventListener;
|
||||||
|
|
||||||
|
public DbmsChangeTracker(String profileDb) throws Exception {
|
||||||
|
createDataSource(profileDb);
|
||||||
|
createConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createDataSource(String profileDb) throws Exception {
|
||||||
|
DataSource ds = new DataSource(1);
|
||||||
|
ds.initialize(profileDb, "Integry Changes Tracker");
|
||||||
|
this.dataSource = ds;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createConnection() throws SQLException {
|
||||||
|
integryConnection = dataSource.getConnection();
|
||||||
|
if (!(integryConnection.isWrapperFor(SQLServerConnection.class))) {
|
||||||
|
integryConnection.close();
|
||||||
|
|
||||||
|
throw new SQLException("Connection is not a SQL Server connection");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkConnection() {
|
||||||
|
try {
|
||||||
|
UtilityDB.executeSimpleQuery(integryConnection, "SELECT 1");
|
||||||
|
if (integryConnection.isClosed())
|
||||||
|
createConnection();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
integryConnection.close();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
createConnection();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
logger.error("Unable to reestablish DB connection for Change Tracker", ex);
|
||||||
|
throw new RuntimeException("Unable to reestablish DB connection for Change Tracker");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableTrackerInDbms() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
final ChangeTrackingConfigDTO currentConfig = retrieveTrackerCurrentConfig();
|
||||||
|
if (currentConfig != null) {
|
||||||
|
logInfo("Changes Tracker is already enabled (with " + currentConfig.getRetentionPeriod() + " " + currentConfig.getRetentionPeriodUnit().toLowerCase() + " retention and auto cleanup " + (currentConfig.isAutoCleanupOn() ? "ON" : "OFF") + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String enableSql = "ALTER DATABASE [" + integryConnection.getDbName() + "] \n" +
|
||||||
|
"SET CHANGE_TRACKING = ON (" +
|
||||||
|
"CHANGE_RETENTION = " + CHANGE_RETENTION_HOURS + " HOURS, " +
|
||||||
|
"AUTO_CLEANUP = " + (AUTO_CLEANUP ? "ON" : "OFF") +
|
||||||
|
");\n";
|
||||||
|
|
||||||
|
//COMMIT necessario perché ALTER DATABASE richiede che non ci siano altre transazioni attive
|
||||||
|
UtilityDB.executeStatement(integryConnection, "COMMIT", enableSql);
|
||||||
|
|
||||||
|
logInfo("Changes Tracker is now enabled (with " + CHANGE_RETENTION_HOURS + " hours retention and auto cleanup " + (AUTO_CLEANUP ? "ON" : "OFF") + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void enableTrackerOnTable(String tableName) throws SQLException {
|
||||||
|
if (isTableTrackingEnabled(tableName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilityDB.executeStatement(integryConnection, "ALTER TABLE dbo." + tableName + "\n" +
|
||||||
|
"ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON);", "COMMIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void disableTrackerOnNotUsedTables(List<String> usedTables) throws SQLException {
|
||||||
|
final List<String> trackedTables = retrieveTrackedTables();
|
||||||
|
|
||||||
|
trackedTables.removeAll(usedTables);
|
||||||
|
|
||||||
|
for (String tableName : trackedTables) {
|
||||||
|
disableTrackerOnTable(tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableTrackerOnTable(String tableName) throws SQLException {
|
||||||
|
if (!isTableTrackingEnabled(tableName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilityDB.executeStatement(integryConnection, "ALTER TABLE dbo." + tableName + "\n" +
|
||||||
|
"DISABLE CHANGE_TRACKING;", "COMMIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void startTracking() throws SQLException {
|
||||||
|
currentVersion = retrieveCurrentVersion();
|
||||||
|
trackerEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkForChanges() throws Exception {
|
||||||
|
if (!trackerEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
checkConnection();
|
||||||
|
|
||||||
|
final List<String> trackedTables = retrieveTrackedTables();
|
||||||
|
|
||||||
|
HashMap<Long, List<DetectedChangeDataDTO>> changesByVersion = new HashMap<>();
|
||||||
|
|
||||||
|
for (String trackedTable : trackedTables) {
|
||||||
|
long minValidVersion = getMinValidVersion(trackedTable);
|
||||||
|
|
||||||
|
if (currentVersion < minValidVersion) {
|
||||||
|
if (eventListener != null) {
|
||||||
|
eventListener.onTrackingResetted();
|
||||||
|
currentVersion = retrieveCurrentVersion();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<DetectedChangeDataDTO> detectedChanges = retrieveChangeList(trackedTable);
|
||||||
|
|
||||||
|
detectedChanges.forEach(detectedChangeDataDTO -> {
|
||||||
|
changesByVersion.putIfAbsent(detectedChangeDataDTO.getSysChangeVersion(), new ArrayList<>());
|
||||||
|
changesByVersion.get(detectedChangeDataDTO.getSysChangeVersion()).add(detectedChangeDataDTO);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
logTrace("Detected " + changesByVersion.size() + " changes since version " + currentVersion);
|
||||||
|
|
||||||
|
dispatchChanges(changesByVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchChanges(HashMap<Long, List<DetectedChangeDataDTO>> changesByVersion) throws Exception {
|
||||||
|
final List<Long> sortedChanges = changesByVersion.keySet().stream()
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
for (Long changeId : sortedChanges) {
|
||||||
|
final List<DetectedChangeDataDTO> detectedChanges = changesByVersion.get(changeId);
|
||||||
|
|
||||||
|
for (DetectedChangeDataDTO detectedChange : detectedChanges) {
|
||||||
|
switch (detectedChange.getSysChangeOperation()) {
|
||||||
|
case INSERT:
|
||||||
|
if (eventListener != null)
|
||||||
|
eventListener.onInsertDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UPDATE:
|
||||||
|
if (eventListener != null)
|
||||||
|
eventListener.onUpdateDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DELETE:
|
||||||
|
if (eventListener != null)
|
||||||
|
eventListener.onDeleteDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentVersion = changeId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<DetectedChangeDataDTO> retrieveChangeList(String tableName) throws SQLException {
|
||||||
|
String sql = "SELECT *\n" +
|
||||||
|
"FROM CHANGETABLE(CHANGES dbo." + tableName + ", " + currentVersion + ") AS c";
|
||||||
|
final List<HashMap<String, Object>> result = UtilityDB.executeSimpleQuery(integryConnection, sql);
|
||||||
|
|
||||||
|
return result.stream()
|
||||||
|
.map(x -> {
|
||||||
|
DetectedChangeDataDTO detectedChangeDataDTO = new DetectedChangeDataDTO()
|
||||||
|
.setTableName(tableName);
|
||||||
|
|
||||||
|
Long sysChangeVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_VERSION");
|
||||||
|
detectedChangeDataDTO.setSysChangeVersion(sysChangeVersion);
|
||||||
|
|
||||||
|
|
||||||
|
Long sysChangeCreationVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_CREATION_VERSION");
|
||||||
|
detectedChangeDataDTO.setSysChangeCreationVersion(sysChangeCreationVersion);
|
||||||
|
|
||||||
|
detectedChangeDataDTO.setSysChangeOperation(DetectedChangeDataDTO.Operation.from(UtilityHashMap.<String>getValueIfExists(x, "SYS_CHANGE_OPERATION")));
|
||||||
|
|
||||||
|
List<String> keysToRemove = new ArrayList<>();
|
||||||
|
for (String colName : x.keySet()) {
|
||||||
|
if (colName.startsWith("SYS_"))
|
||||||
|
keysToRemove.add(colName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String colName : keysToRemove) {
|
||||||
|
x.remove(colName);
|
||||||
|
}
|
||||||
|
|
||||||
|
detectedChangeDataDTO.setPrimaryKey(x);
|
||||||
|
|
||||||
|
return detectedChangeDataDTO;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private long retrieveCurrentVersion() throws SQLException {
|
||||||
|
String sql = "SELECT CHANGE_TRACKING_CURRENT_VERSION() AS current_version";
|
||||||
|
|
||||||
|
long currentVersion = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||||
|
return currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getMinValidVersion(String table) throws SQLException {
|
||||||
|
String sql = "SELECT CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID(" + UtilityDB.valueToString(table) + "))";
|
||||||
|
|
||||||
|
long minValidVersion = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||||
|
return minValidVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> retrieveTrackedTables() throws SQLException {
|
||||||
|
String sql = "SELECT OBJECT_NAME(object_id) AS table_name\n" +
|
||||||
|
" FROM sys.change_tracking_tables";
|
||||||
|
|
||||||
|
List<String> trackedTables = UtilityDB.executeSimpleQueryOnlyFirstColumn(integryConnection, sql);
|
||||||
|
return trackedTables;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTableTrackingEnabled(String tableName) throws SQLException {
|
||||||
|
String sql = "SELECT CAST(COUNT(is_track_columns_updated_on) AS BIT) AS enabled\n" +
|
||||||
|
" FROM sys.change_tracking_tables \n" +
|
||||||
|
" WHERE object_id = OBJECT_ID('dbo." + tableName + "')";
|
||||||
|
|
||||||
|
boolean enabled = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChangeTrackingConfigDTO retrieveTrackerCurrentConfig() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String checkSql = "SELECT DB_NAME(database_id) as database_name,\n" +
|
||||||
|
"CAST(is_auto_cleanup_on AS BIT) AS is_auto_cleanup_on,\n" +
|
||||||
|
"retention_period,\n" +
|
||||||
|
"retention_period_units_desc,\n" +
|
||||||
|
"max_cleanup_version\n" +
|
||||||
|
"FROM sys.change_tracking_databases \n" +
|
||||||
|
"WHERE DB_NAME(database_id)=DB_NAME()";
|
||||||
|
|
||||||
|
final ChangeTrackingConfigDTO currentConfig = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(integryConnection, checkSql, ChangeTrackingConfigDTO.class);
|
||||||
|
|
||||||
|
return currentConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void logInfo(String message) {
|
||||||
|
logger.info("[" + integryConnection.getProfileName() + "] " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logTrace(String message) {
|
||||||
|
logger.trace("[" + integryConnection.getProfileName() + "] " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public DbmsChangeTracker setEventListener(Listener eventListener) {
|
||||||
|
this.eventListener = eventListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Listener {
|
||||||
|
void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||||
|
|
||||||
|
void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||||
|
|
||||||
|
void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||||
|
|
||||||
|
void onTrackingResetted() throws Exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.component;
|
||||||
|
|
||||||
|
import it.integry.annotations.PostContextAutowired;
|
||||||
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordDeletedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordInsertedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordUpdatedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableTrackingResettedEvent;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems_model.entity.*;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DbmsChangeTrackerComponent {
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
private final HashMap<IntegryCustomerDB, DbmsChangeTracker> activeChangeTrackers = new HashMap<>();
|
||||||
|
|
||||||
|
private final ArrayList<String> trackedTables = new ArrayList<String>() {{
|
||||||
|
add(MtbDepo.ENTITY);
|
||||||
|
add(MtbDepoPosizioni.ENTITY);
|
||||||
|
add(StbEditLimit.ENTITY);
|
||||||
|
add(StbGestSetup.ENTITY);
|
||||||
|
add(StbGestSetupDepo.ENTITY);
|
||||||
|
add(StbUser.ENTITY);
|
||||||
|
add(WtbClie.ENTITY);
|
||||||
|
add(WtbDepo.ENTITY);
|
||||||
|
add(WtbGestSetupUser.ENTITY);
|
||||||
|
}};
|
||||||
|
|
||||||
|
|
||||||
|
private final ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
|
@PostContextAutowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
public DbmsChangeTrackerComponent(ApplicationEventPublisher applicationEventPublisher) {
|
||||||
|
this.applicationEventPublisher = applicationEventPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostContextConstruct(priority = 10)
|
||||||
|
public void init() throws Exception {
|
||||||
|
for (Connection conn : multiDBTransactionManager.getActiveConnections()) {
|
||||||
|
IntegryCustomerDB customerDB = IntegryCustomerDB.parse(conn.getDbName());
|
||||||
|
activeChangeTrackers.put(customerDB, new DbmsChangeTracker(conn.getProfileName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
enableAllChangeTracking();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void enableAllChangeTracking() throws Exception {
|
||||||
|
for (Map.Entry<IntegryCustomerDB, DbmsChangeTracker> entrySet : activeChangeTrackers.entrySet()) {
|
||||||
|
final IntegryCustomerDB customerDB = entrySet.getKey();
|
||||||
|
final DbmsChangeTracker dbmsChangeTracker = entrySet.getValue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
dbmsChangeTracker.enableTrackerInDbms();
|
||||||
|
|
||||||
|
for (String tableName : trackedTables) {
|
||||||
|
dbmsChangeTracker.enableTrackerOnTable(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbmsChangeTracker.disableTrackerOnNotUsedTables(trackedTables);
|
||||||
|
|
||||||
|
dbmsChangeTracker.setEventListener(new DbmsChangeTracker.Listener() {
|
||||||
|
@Override
|
||||||
|
public void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
onItemInserted(customerDB, tableName, primaryKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
onItemUpdated(customerDB, tableName, primaryKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
onItemDeleted(customerDB, tableName, primaryKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrackingResetted() throws Exception {
|
||||||
|
requestGlobalReset(customerDB);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dbmsChangeTracker.startTracking();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new Exception("Errore durante l'abilitazione del DbmsChangeTracker per il customer: " + customerDB.getValue(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS)
|
||||||
|
private void checkAllChanges() throws Exception {
|
||||||
|
for (DbmsChangeTracker dbmsChangeTracker : activeChangeTrackers.values()) {
|
||||||
|
try {
|
||||||
|
dbmsChangeTracker.checkForChanges();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Errore durante il controllo delle modifiche nel DbmsChangeTracker.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void onItemInserted(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
logger.trace("Item inserted in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||||
|
applicationEventPublisher.publishEvent(new TableRecordInsertedEvent(this, customerDB, tableName, primaryKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onItemUpdated(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
logger.trace("Item updated in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||||
|
applicationEventPublisher.publishEvent(new TableRecordUpdatedEvent(this, customerDB, tableName, primaryKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onItemDeleted(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
logger.trace("Item deleted in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||||
|
applicationEventPublisher.publishEvent(new TableRecordDeletedEvent(this, customerDB, tableName, primaryKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestGlobalReset(IntegryCustomerDB customerDB) {
|
||||||
|
logger.warn("Table tracking resetted in profileDb {} ", customerDB.getValue());
|
||||||
|
applicationEventPublisher.publishEvent(new TableTrackingResettedEvent(this, customerDB));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.component.exception;
|
||||||
|
|
||||||
|
public class DbmsChangeTrackerInvalidMinVersionException extends Exception {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final long currentVersion;
|
||||||
|
private final long minValidVersion;
|
||||||
|
|
||||||
|
public DbmsChangeTrackerInvalidMinVersionException(String tableName, long currentVersion, long minValidVersion) {
|
||||||
|
super("Change Tracking on table " + tableName + " has been reset. Current version: " + currentVersion + ", Min valid version: " + minValidVersion);
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.minValidVersion = minValidVersion;
|
||||||
|
this.currentVersion = currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCurrentVersion() {
|
||||||
|
return currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMinValidVersion() {
|
||||||
|
return minValidVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
|
||||||
|
public class ChangeTrackingConfigDTO {
|
||||||
|
|
||||||
|
@SqlField("database_name")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
@SqlField("is_auto_cleanup_on")
|
||||||
|
private boolean autoCleanupOn;
|
||||||
|
|
||||||
|
@SqlField("retention_period")
|
||||||
|
private int retentionPeriod;
|
||||||
|
|
||||||
|
@SqlField("retention_period_units_desc")
|
||||||
|
private String retentionPeriodUnit;
|
||||||
|
|
||||||
|
// @SqlField("max_cleanup_version")
|
||||||
|
private Object maxCleanupVersion;
|
||||||
|
|
||||||
|
|
||||||
|
public String getDatabaseName() {
|
||||||
|
return databaseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setDatabaseName(String databaseName) {
|
||||||
|
this.databaseName = databaseName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutoCleanupOn() {
|
||||||
|
return autoCleanupOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setAutoCleanupOn(boolean autoCleanupOn) {
|
||||||
|
this.autoCleanupOn = autoCleanupOn;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRetentionPeriod() {
|
||||||
|
return retentionPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setRetentionPeriod(int retentionPeriod) {
|
||||||
|
this.retentionPeriod = retentionPeriod;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRetentionPeriodUnit() {
|
||||||
|
return retentionPeriodUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setRetentionPeriodUnit(String retentionPeriodUnit) {
|
||||||
|
this.retentionPeriodUnit = retentionPeriodUnit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getMaxCleanupVersion() {
|
||||||
|
return maxCleanupVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setMaxCleanupVersion(Object maxCleanupVersion) {
|
||||||
|
this.maxCleanupVersion = maxCleanupVersion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class DetectedChangeDataDTO {
|
||||||
|
|
||||||
|
private long sysChangeVersion;
|
||||||
|
private Long sysChangeCreationVersion;
|
||||||
|
private Operation sysChangeOperation;
|
||||||
|
|
||||||
|
private String tableName;
|
||||||
|
private HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
|
||||||
|
public long getSysChangeVersion() {
|
||||||
|
return sysChangeVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setSysChangeVersion(long sysChangeVersion) {
|
||||||
|
this.sysChangeVersion = sysChangeVersion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSysChangeCreationVersion() {
|
||||||
|
return sysChangeCreationVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setSysChangeCreationVersion(Long sysChangeCreationVersion) {
|
||||||
|
this.sysChangeCreationVersion = sysChangeCreationVersion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operation getSysChangeOperation() {
|
||||||
|
return sysChangeOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setSysChangeOperation(Operation sysChangeOperation) {
|
||||||
|
this.sysChangeOperation = sysChangeOperation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setTableName(String tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setPrimaryKey(HashMap<String, Object> primaryKey) {
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum Operation implements IBaseEnum<Operation> {
|
||||||
|
INSERT('I'),
|
||||||
|
UPDATE('U'),
|
||||||
|
DELETE('D');
|
||||||
|
|
||||||
|
private final char value;
|
||||||
|
|
||||||
|
Operation(char value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Operation from(Object value) {
|
||||||
|
if (value instanceof String && ((String) value).length() == 1) {
|
||||||
|
value = ((String) value).charAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char castValue = (char) value;
|
||||||
|
for (Operation b : Operation.values()) {
|
||||||
|
if (b.value == castValue)
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public char getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Operation fromInternal(Object val) {
|
||||||
|
return from(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class TableRecordDeletedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
public TableRecordDeletedEvent(Object source, IntegryCustomerDB integryCustomerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
super(source, integryCustomerDB);
|
||||||
|
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class TableRecordInsertedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
public TableRecordInsertedEvent(Object source, IntegryCustomerDB integryCustomerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
super(source, integryCustomerDB);
|
||||||
|
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class TableRecordUpdatedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
public TableRecordUpdatedEvent(Object source, IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
super(source, customerDB);
|
||||||
|
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
public class TableTrackingResettedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
public TableTrackingResettedEvent(Object source, IntegryCustomerDB customerDB) {
|
||||||
|
super(source, customerDB);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@ public class DevicesRequestInterceptor implements HandlerInterceptor {
|
|||||||
RequestDataDTO requestDataDTO = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
RequestDataDTO requestDataDTO = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
||||||
|
|
||||||
if (requestDataDTO.isValidProfileDB() && requestDataDTO.isValidDeviceId()) {
|
if (requestDataDTO.isValidProfileDB() && requestDataDTO.isValidDeviceId()) {
|
||||||
deviceService.updateUsage(requestDataDTO.getApplication(), requestDataDTO.getDeviceId());
|
deviceService.updateUsage(requestDataDTO.getDeviceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.http.ContentDisposition;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@@ -28,26 +32,26 @@ public class DownloadController {
|
|||||||
private MimeTypesHandler mimetypesFileTypeMap;
|
private MimeTypesHandler mimetypesFileTypeMap;
|
||||||
|
|
||||||
@RequestMapping(value = "download/{uuid}/{fileName}", method = RequestMethod.GET)
|
@RequestMapping(value = "download/{uuid}/{fileName}", method = RequestMethod.GET)
|
||||||
public byte[] download(HttpServletResponse response,
|
public ResponseEntity<byte[]> download(@PathVariable String uuid,
|
||||||
@PathVariable String uuid,
|
@PathVariable String fileName) throws Exception {
|
||||||
@PathVariable String fileName) throws Exception {
|
|
||||||
|
|
||||||
byte[] fileContent = downloadFileHandlerService.getDownloadFileContent(uuid);
|
byte[] fileContent = downloadFileHandlerService.getDownloadFileContent(uuid);
|
||||||
|
|
||||||
if (fileContent != null) {
|
if (fileContent != null) {
|
||||||
String filename = downloadFileHandlerService.getDownloadFileName(uuid);
|
String filename = downloadFileHandlerService.getDownloadFileName(uuid);
|
||||||
|
|
||||||
String mimeType = Files.probeContentType(Paths.get(fileName));
|
MediaType mediaType = mimetypesFileTypeMap.getContentType(fileName);
|
||||||
|
|
||||||
response.setContentType(mimeType);
|
return ResponseEntity.ok()
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
.contentType(mediaType)
|
||||||
response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
|
.contentLength(fileContent.length)
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||||
response.setContentLength(fileContent.length);
|
.builder("attachment")
|
||||||
return fileContent;
|
.filename(filename)
|
||||||
|
.build()
|
||||||
|
.toString())
|
||||||
|
.body(fileContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.sendError(404, "File non trovato");
|
return ResponseEntity.notFound().build();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package it.integry.ems.dynamic_cache;
|
|||||||
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
||||||
import it.integry.ems.expansion.RunnableWithReturn;
|
import it.integry.ems.expansion.RunnableWithReturn;
|
||||||
import it.integry.ems.looper.service.LooperService;
|
import it.integry.ems.looper.service.LooperService;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -37,8 +37,7 @@ public class DynamicCacheService {
|
|||||||
DATI_AZIENDA_KEY,
|
DATI_AZIENDA_KEY,
|
||||||
ENTITY_LOGGER_SETUP,
|
ENTITY_LOGGER_SETUP,
|
||||||
GRIGLIA_ACQUISTO_KEY,
|
GRIGLIA_ACQUISTO_KEY,
|
||||||
ENTITY_SYNC_KEY,
|
ENTITY_SYNC_KEY
|
||||||
STB_GEST_SETUP_KEY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
||||||
@@ -51,11 +50,11 @@ public class DynamicCacheService {
|
|||||||
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
||||||
RunnableWithReturn<Object> internalRefreshAction = () -> {
|
RunnableWithReturn<Object> internalRefreshAction = () -> {
|
||||||
|
|
||||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
.filter(AvailableConnectionModel::getInternalDb)
|
||||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||||
|
|
||||||
final HashMap<String, T> cachedDataByDB = new HashMap<>();
|
final HashMap<String, T> cachedDataByDB = new HashMap<>();
|
||||||
|
|
||||||
@@ -83,11 +82,11 @@ public class DynamicCacheService {
|
|||||||
|
|
||||||
RunnableWithReturn<Object> refreshAction = () -> {
|
RunnableWithReturn<Object> refreshAction = () -> {
|
||||||
|
|
||||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
.filter(AvailableConnectionModel::getInternalDb)
|
||||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||||
|
|
||||||
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = new HashMap<>();
|
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = new HashMap<>();
|
||||||
|
|
||||||
@@ -138,11 +137,11 @@ public class DynamicCacheService {
|
|||||||
|
|
||||||
RunnableWithReturn<Object> refreshAction = () -> {
|
RunnableWithReturn<Object> refreshAction = () -> {
|
||||||
|
|
||||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
.filter(AvailableConnectionModel::getInternalDb)
|
||||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||||
|
|
||||||
final HashMap<String, List<?>> cacheQueryByDB = new HashMap<>();
|
final HashMap<String, List<?>> cacheQueryByDB = new HashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,322 @@
|
|||||||
|
package it.integry.ems.dynamic_cache;
|
||||||
|
|
||||||
|
import it.integry.annotations.PostContextAutowired;
|
||||||
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.dbms_change_tracker.component.DbmsChangeTrackerComponent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordDeletedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordInsertedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordUpdatedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableTrackingResettedEvent;
|
||||||
|
import it.integry.ems.dto.EntityHierarchy;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
|
import it.integry.ems_model.entity.*;
|
||||||
|
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityQuery;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EntityCacheComponent implements ApplicationListener {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
private final DbmsChangeTrackerComponent dbmsChangeTrackerComponent;
|
||||||
|
private final EntityPropertyHolder entityPropertyHolder;
|
||||||
|
|
||||||
|
private final HashMap<IntegryCustomerDB, ConcurrentHashMap<String, ConcurrentHashMap<HashMap<String, Object>, EntityBase>>> entityCache = new HashMap<>();
|
||||||
|
|
||||||
|
// Lock per IntegryCustomerDB per garantire accessi sincronizzati alla cache di quel customer
|
||||||
|
private final ConcurrentHashMap<IntegryCustomerDB, Object> cacheLocks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private Object getCacheLock(IntegryCustomerDB customerDB) {
|
||||||
|
cacheLocks.putIfAbsent(customerDB, new Object());
|
||||||
|
return cacheLocks.get(customerDB);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final HashMap<String, Class<? extends EntityBase>> enabledEntities = new HashMap<String, Class<? extends EntityBase>>() {{
|
||||||
|
put(MtbDepo.ENTITY, MtbDepo.class);
|
||||||
|
put(MtbDepoPosizioni.ENTITY, MtbDepoPosizioni.class);
|
||||||
|
put(StbEditLimit.ENTITY, StbEditLimit.class);
|
||||||
|
put(StbGestSetup.ENTITY, StbGestSetup.class);
|
||||||
|
put(StbGestSetupDepo.ENTITY, StbGestSetupDepo.class);
|
||||||
|
put(StbUser.ENTITY, StbUser.class);
|
||||||
|
put(WtbDepo.ENTITY, WtbDepo.class);
|
||||||
|
put(WtbGestSetupUser.ENTITY, WtbGestSetupUser.class);
|
||||||
|
put(WtbClie.ENTITY, WtbClie.class);
|
||||||
|
}};
|
||||||
|
|
||||||
|
public EntityCacheComponent(DbmsChangeTrackerComponent dbmsChangeTrackerComponent, EntityPropertyHolder entityPropertyHolder) {
|
||||||
|
this.dbmsChangeTrackerComponent = dbmsChangeTrackerComponent;
|
||||||
|
this.entityPropertyHolder = entityPropertyHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostContextAutowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@PostContextConstruct
|
||||||
|
private void init() throws Exception {
|
||||||
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Connection conn : multiDBTransactionManager.getActiveConnections()) {
|
||||||
|
IntegryCustomerDB customerDB = IntegryCustomerDB.parse(conn.getDbName());
|
||||||
|
|
||||||
|
if (customerDB == null)
|
||||||
|
throw new RuntimeException("Impossibile inizializzare IntegryCustomerDB per il database: " + conn.getDbName());
|
||||||
|
|
||||||
|
|
||||||
|
for (Map.Entry<String, Class<? extends EntityBase>> enabledEntity : enabledEntities.entrySet()) {
|
||||||
|
String tableName = enabledEntity.getKey();
|
||||||
|
|
||||||
|
refreshCacheForEntity(conn, customerDB, tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshCacheGlobal(IntegryCustomerDB customerDB) throws Exception {
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(customerDB)) {
|
||||||
|
Connection conn = mdb.getPrimaryConnection();
|
||||||
|
for (Map.Entry<String, Class<? extends EntityBase>> enabledEntity : enabledEntities.entrySet()) {
|
||||||
|
String tableName = enabledEntity.getKey();
|
||||||
|
refreshCacheForEntity(conn, customerDB, tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshCacheForEntity(IntegryCustomerDB customerDB, String tableName) throws Exception {
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(customerDB)) {
|
||||||
|
Connection conn = mdb.getPrimaryConnection();
|
||||||
|
refreshCacheForEntity(conn, customerDB, tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshCacheForEntity(Connection connection, IntegryCustomerDB customerDB, String tableName) throws Exception {
|
||||||
|
// Sincronizziamo l'intera operazione di refresh per il customerDB per evitare accessi concorrenti
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
Class<? extends EntityBase> clazz = enabledEntities.get(tableName);
|
||||||
|
// if (clazz == null)
|
||||||
|
// throw new RuntimeException("Entity cache is not enabled for table " + tableName);
|
||||||
|
|
||||||
|
entityCache.putIfAbsent(customerDB, new ConcurrentHashMap<>());
|
||||||
|
entityCache.get(customerDB).remove(tableName);
|
||||||
|
|
||||||
|
ConcurrentHashMap<HashMap<String, Object>, EntityBase> entities = retrieveEntityList(connection, tableName, clazz);
|
||||||
|
entityCache.get(customerDB).put(tableName, entities);
|
||||||
|
|
||||||
|
logger.trace(String.format("[%s] Cached %d records for entity %s",
|
||||||
|
customerDB.getValue(),
|
||||||
|
entities.size(),
|
||||||
|
clazz.getSimpleName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityBase> List<T> getCachedEntitiesList(IntegryCustomerDB customerDB, String tableName, Predicate<T> filterPredicate) {
|
||||||
|
return getCachedEntitiesStream(customerDB, tableName, filterPredicate)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityBase> Stream<T> getCachedEntitiesStream(IntegryCustomerDB customerDB, String tableName, Predicate<T> filterPredicate) {
|
||||||
|
// Per evitare accessi concorrenti leggiamo/snapshottiamo la cache sotto lock per quel customerDB
|
||||||
|
Stream<T> snapshot;
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
if (!isCacheEnabled(customerDB, tableName)) {
|
||||||
|
try {
|
||||||
|
refreshCacheForEntity(customerDB, tableName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// prendo un'istantanea degli oggetti clonati per poter lavorare fuori dal lock
|
||||||
|
snapshot = entityCache.get(customerDB)
|
||||||
|
.get(tableName)
|
||||||
|
.values()
|
||||||
|
.parallelStream()
|
||||||
|
.map(x -> (T) x.clone());
|
||||||
|
|
||||||
|
if (filterPredicate != null)
|
||||||
|
snapshot = snapshot.filter(filterPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(ApplicationEvent event) {
|
||||||
|
if (event instanceof TableRecordInsertedEvent) {
|
||||||
|
handleRecordInserted((TableRecordInsertedEvent) event);
|
||||||
|
|
||||||
|
} else if (event instanceof TableRecordUpdatedEvent) {
|
||||||
|
handleRecordUpdated((TableRecordUpdatedEvent) event);
|
||||||
|
|
||||||
|
} else if (event instanceof TableRecordDeletedEvent) {
|
||||||
|
handleRecordDeleted((TableRecordDeletedEvent) event);
|
||||||
|
|
||||||
|
} else if (event instanceof TableTrackingResettedEvent) {
|
||||||
|
try {
|
||||||
|
handleTableTrackingResetted((TableTrackingResettedEvent) event);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void handleRecordInserted(TableRecordInsertedEvent event) {
|
||||||
|
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(event.getCustomerDB())) {
|
||||||
|
EntityBase newItem = retrieveEntityItem(mdb.getPrimaryConnection(), event.getTableName(),
|
||||||
|
enabledEntities.get(event.getTableName()),
|
||||||
|
event.getPrimaryKey());
|
||||||
|
|
||||||
|
|
||||||
|
// sincronizziamo la modifica per il customerDB
|
||||||
|
synchronized (getCacheLock(event.getCustomerDB())) {
|
||||||
|
entityCache.get(event.getCustomerDB())
|
||||||
|
.get(event.getTableName())
|
||||||
|
.put(entityPrimaryKey, newItem);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRecordUpdated(TableRecordUpdatedEvent event) {
|
||||||
|
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(event.getCustomerDB())) {
|
||||||
|
EntityBase newItem = retrieveEntityItem(mdb.getPrimaryConnection(), event.getTableName(),
|
||||||
|
enabledEntities.get(event.getTableName()),
|
||||||
|
event.getPrimaryKey());
|
||||||
|
|
||||||
|
|
||||||
|
// sincronizziamo la modifica per il customerDB
|
||||||
|
synchronized (getCacheLock(event.getCustomerDB())) {
|
||||||
|
entityCache.get(event.getCustomerDB())
|
||||||
|
.get(event.getTableName())
|
||||||
|
.put(entityPrimaryKey, newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRecordDeleted(TableRecordDeletedEvent event) {
|
||||||
|
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||||
|
|
||||||
|
// sincronizziamo la rimozione per il customerDB
|
||||||
|
final EntityBase removedItem;
|
||||||
|
synchronized (getCacheLock(event.getCustomerDB())) {
|
||||||
|
removedItem = entityCache.get(event.getCustomerDB())
|
||||||
|
.get(event.getTableName())
|
||||||
|
.remove(entityPrimaryKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleTableTrackingResetted(TableTrackingResettedEvent event) throws Exception {
|
||||||
|
// reset e refresh sono eseguiti in modo sincronizzato per quel customer
|
||||||
|
resetTablesCache(event.getCustomerDB());
|
||||||
|
refreshCacheGlobal(event.getCustomerDB());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ConcurrentHashMap<HashMap<String, Object>, EntityBase> retrieveEntityList(Connection connection, String tableName, Class<? extends EntityBase> clazz) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String sql = "SELECT * FROM " + tableName;
|
||||||
|
|
||||||
|
List<? extends EntityBase> objects = UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
||||||
|
if (objects == null)
|
||||||
|
objects = new ArrayList<>();
|
||||||
|
final List<EntityHierarchy.Field> pkFields = entityPropertyHolder.getEntityFields(clazz, EntityHierarchy.Field::isPrimaryKey);
|
||||||
|
|
||||||
|
|
||||||
|
ConcurrentHashMap<HashMap<String, Object>, EntityBase> objectsMap = new ConcurrentHashMap<>();
|
||||||
|
for (EntityBase object : objects) {
|
||||||
|
HashMap<String, Object> pkMap = new HashMap<>();
|
||||||
|
for (EntityHierarchy.Field pkField : pkFields) {
|
||||||
|
Object pkValue = pkField.getField().get(object);
|
||||||
|
pkMap.put(pkField.getFieldName(), pkValue);
|
||||||
|
}
|
||||||
|
objectsMap.put(pkMap, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return objectsMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityBase retrieveEntityItem(Connection connection, String tableName, Class<?> clazz, HashMap<String, Object> primaryKey) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String sql = "SELECT * FROM " + tableName + "\n" +
|
||||||
|
" WHERE " + UtilityQuery.concatFieldsInWhereCond(primaryKey);
|
||||||
|
|
||||||
|
final EntityBase object = (EntityBase) UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, clazz);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private HashMap<String, Object> convertSqlMapToEntityMap(HashMap<String, Object> sqlMap, Class<? extends EntityBase> clazz) {
|
||||||
|
HashMap<String, Object> entityMap = new HashMap<>();
|
||||||
|
for (Map.Entry<String, Object> entry : sqlMap.entrySet()) {
|
||||||
|
String fieldName = entityPropertyHolder.getEntityFields(clazz, f -> f.isSqlField() && f.getSqlField().value().equals(entry.getKey()))
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.map(EntityHierarchy.Field::getFieldName)
|
||||||
|
.orElse(entry.getKey());
|
||||||
|
entityMap.put(fieldName, entry.getValue());
|
||||||
|
}
|
||||||
|
return entityMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void resetTableCache(IntegryCustomerDB customerDB, String tableName) {
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
if (entityCache.containsKey(customerDB) && entityCache.get(customerDB).containsKey(tableName)) {
|
||||||
|
entityCache.get(customerDB).remove(tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void resetTablesCache(IntegryCustomerDB customerDB) {
|
||||||
|
// sincronizziamo la rimozione dell'intera cache per il customer
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
entityCache.remove(customerDB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isCacheEnabled(IntegryCustomerDB customerDB, String tableName) {
|
||||||
|
return (entityCache.containsKey(customerDB) && entityCache.get(customerDB).containsKey(tableName)) ||
|
||||||
|
!(UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import it.integry.annotations.PostContextConstruct;
|
|||||||
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.*;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.*;
|
||||||
import it.integry.ems.looper.service.LooperService;
|
import it.integry.ems.looper.service.LooperService;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -57,7 +57,7 @@ public class EntityLoggerComponent {
|
|||||||
|
|
||||||
private void syncDBScheme() throws Exception {
|
private void syncDBScheme() throws Exception {
|
||||||
|
|
||||||
AvailableConnectionsModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
AvailableConnectionModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||||
|
|
||||||
if (connectionsModel == null) {
|
if (connectionsModel == null) {
|
||||||
throw new Exception("Impossibile ricavare la default connection");
|
throw new Exception("Impossibile ricavare la default connection");
|
||||||
@@ -107,7 +107,7 @@ public class EntityLoggerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settingsModel.getAvailableConnections().stream().noneMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
if (settingsModel.getAvailableConnections().stream().noneMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
||||||
settingsModel.addAvailableConnection(new AvailableConnectionsModel()
|
settingsModel.addAvailableConnection(new AvailableConnectionModel()
|
||||||
.setInternalDb(false)
|
.setInternalDb(false)
|
||||||
.setHost(dbHost)
|
.setHost(dbHost)
|
||||||
.setUsername(dbUsername)
|
.setUsername(dbUsername)
|
||||||
@@ -210,12 +210,12 @@ public class EntityLoggerComponent {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<AvailableConnectionsModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
List<AvailableConnectionModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||||
String historyProfileDB = settingsController.getHistoryProfileDb();
|
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||||
|
|
||||||
try (MultiDBTransactionManager historyMultiDB = new MultiDBTransactionManager(historyProfileDB)) {
|
try (MultiDBTransactionManager historyMultiDB = new MultiDBTransactionManager(historyProfileDB)) {
|
||||||
|
|
||||||
for (AvailableConnectionsModel sourceConnectionModel : connectionsModels) {
|
for (AvailableConnectionModel sourceConnectionModel : connectionsModels) {
|
||||||
String sql = "SELECT * FROM stb_log_entity_setup" +
|
String sql = "SELECT * FROM stb_log_entity_setup" +
|
||||||
" WHERE entity_name <> " + UtilityDB.valueToString(StbLogEntitySetup.ENTITY);
|
" WHERE entity_name <> " + UtilityDB.valueToString(StbLogEntitySetup.ENTITY);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class InvalidCustomerDbException extends RuntimeException {
|
||||||
|
public InvalidCustomerDbException(String dbName) {
|
||||||
|
super("Invalid customer database name: " + dbName + ". Please check your ems_settings.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class InvalidDbNameException extends RuntimeException {
|
||||||
|
public InvalidDbNameException(String dbName) {
|
||||||
|
super("Invalid database name: " + dbName + ". Please check your ems_settings.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class InvalidProfileDbException extends RuntimeException {
|
||||||
|
public InvalidProfileDbException(String profileDb) {
|
||||||
|
super("Invalid profile db: " + profileDb + ". Please check your ems_settings.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package it.integry.ems.file_formatter.txt;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.ems_model.annotation.DtoField;
|
import it.integry.ems_model.annotation.DtoField;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -10,6 +11,7 @@ import java.lang.reflect.Field;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -76,8 +78,16 @@ public class TxtMapper<T> {
|
|||||||
|
|
||||||
if (ignorePosition)
|
if (ignorePosition)
|
||||||
stringBuilder.append(value).append(fieldsSplitChar);
|
stringBuilder.append(value).append(fieldsSplitChar);
|
||||||
else
|
else {
|
||||||
|
if ( stringBuilder.length() > 0 && stringBuilder.length() < dtoField.startPosition() ) {
|
||||||
|
int numChar = dtoField.startPosition() - stringBuilder.length();
|
||||||
|
for (int i = 0; i < numChar; i++) {
|
||||||
|
stringBuilder.append(fieldsSplitChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
stringBuilder.insert(dtoField.startPosition(), value).append(fieldsSplitChar);
|
stringBuilder.insert(dtoField.startPosition(), value).append(fieldsSplitChar);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
@@ -208,6 +218,8 @@ public class TxtMapper<T> {
|
|||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof Date) {
|
if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof Date) {
|
||||||
value = new SimpleDateFormat(dtoField.format()).format(value);
|
value = new SimpleDateFormat(dtoField.format()).format(value);
|
||||||
|
} else if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof LocalDate) {
|
||||||
|
value = UtilityLocalDate.formatDate((LocalDate) value, dtoField.format() );
|
||||||
} else if (!UtilityString.isNullOrEmpty(dtoField.formula()) && value instanceof BigDecimal) {
|
} else if (!UtilityString.isNullOrEmpty(dtoField.formula()) && value instanceof BigDecimal) {
|
||||||
value = ((BigDecimal) value).setScale(dtoField.scale(), RoundingMode.HALF_DOWN);
|
value = ((BigDecimal) value).setScale(dtoField.scale(), RoundingMode.HALF_DOWN);
|
||||||
String formula = dtoField.formula().replaceAll("this", value.toString());
|
String formula = dtoField.formula().replaceAll("this", value.toString());
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package it.integry.ems.javabeans;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems._context.ApplicationContextProvider;
|
||||||
|
import it.integry.ems.jpa.TenantContext;
|
||||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
import it.integry.ems.model.IntegryApplicationEnum;
|
import it.integry.ems.model.IntegryApplicationEnum;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.user.dto.UserDTO;
|
import it.integry.ems.user.dto.UserDTO;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
@@ -16,13 +20,15 @@ import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.PreDestroy;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("request")
|
@Scope(WebApplicationContext.SCOPE_REQUEST)
|
||||||
public class RequestDataDTO {
|
public class RequestDataDTO {
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
@@ -37,6 +43,10 @@ public class RequestDataDTO {
|
|||||||
private String requestClientIP;
|
private String requestClientIP;
|
||||||
|
|
||||||
private String profileDB;
|
private String profileDB;
|
||||||
|
|
||||||
|
//Indica il codice deposito reale dell'utente che effettua la richiesta, ovvero la posizione fisica dell'utente
|
||||||
|
private String codMdep;
|
||||||
|
|
||||||
private Long deviceId;
|
private Long deviceId;
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
@@ -55,6 +65,10 @@ public class RequestDataDTO {
|
|||||||
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
|
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request != null && request.getHeader(CommonConstants.COD_MDEP) != null) {
|
||||||
|
codMdep = request.getHeader(CommonConstants.COD_MDEP);
|
||||||
|
}
|
||||||
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
|
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
|
||||||
readAuthenticationClaims(authentication);
|
readAuthenticationClaims(authentication);
|
||||||
@@ -89,6 +103,24 @@ public class RequestDataDTO {
|
|||||||
} else {
|
} else {
|
||||||
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logica di fallback o recupero tenant da sessione/utente
|
||||||
|
if (profileDB == null || profileDB.isEmpty()) {
|
||||||
|
// Esempio: recupero da sessione se presente
|
||||||
|
// tenantId = (String) request.getSession().getAttribute("TENANT_ID");
|
||||||
|
|
||||||
|
// Fallback temporaneo per test
|
||||||
|
// tenantId = DEFAULT_TENANT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profileDB != null) {
|
||||||
|
TenantContext.setCurrentTenant(profileDB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreDestroy
|
||||||
|
public void destroy() throws Exception {
|
||||||
|
TenantContext.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,6 +140,10 @@ public class RequestDataDTO {
|
|||||||
return !UtilityString.isNullOrEmpty(profileDB);
|
return !UtilityString.isNullOrEmpty(profileDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValidCodMdep() {
|
||||||
|
return !UtilityString.isNullOrEmpty(codMdep);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValidDeviceId() {
|
public boolean isValidDeviceId() {
|
||||||
return deviceId != null;
|
return deviceId != null;
|
||||||
}
|
}
|
||||||
@@ -138,6 +174,20 @@ public class RequestDataDTO {
|
|||||||
return profileDB;
|
return profileDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCodMdep() {
|
||||||
|
return codMdep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegryCustomerDB getCustomerDB() {
|
||||||
|
if (UtilityString.isNullOrEmpty(profileDB))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
final SettingsModel settingsModel = ApplicationContextProvider.getApplicationContext().getBean(SettingsModel.class);
|
||||||
|
final String dbName = settingsModel.getDbNameFromProfileDb(profileDB);
|
||||||
|
|
||||||
|
return IntegryCustomerDB.parse(dbName);
|
||||||
|
}
|
||||||
|
|
||||||
public Long getDeviceId() {
|
public Long getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package it.integry.ems.jpa;
|
||||||
|
|
||||||
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||||
|
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MultiTenantDataSource extends AbstractRoutingDataSource {
|
||||||
|
|
||||||
|
private final BasicConnectionPool basicConnectionPool;
|
||||||
|
private final SettingsModel settingsModel;
|
||||||
|
|
||||||
|
public MultiTenantDataSource(BasicConnectionPool basicConnectionPool, SettingsModel settingsModel) {
|
||||||
|
this.basicConnectionPool = basicConnectionPool;
|
||||||
|
this.settingsModel = settingsModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object determineCurrentLookupKey() {
|
||||||
|
return TenantContext.getCurrentTenant();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() {
|
||||||
|
Map<Object, Object> targetDataSources = new HashMap<>();
|
||||||
|
List<AvailableConnectionModel> connections = settingsModel.getAvailableConnections(false);
|
||||||
|
|
||||||
|
// Imposta il primo come default se necessario, o gestisci il caso null
|
||||||
|
DataSource defaultDataSource = null;
|
||||||
|
|
||||||
|
for (AvailableConnectionModel model : connections) {
|
||||||
|
DataSource ds = basicConnectionPool.getDataSource(model.getProfileName());
|
||||||
|
if (ds != null) {
|
||||||
|
targetDataSources.put(model.getProfileName(), ds);
|
||||||
|
if (defaultDataSource == null) {
|
||||||
|
defaultDataSource = ds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setTargetDataSources(targetDataSources);
|
||||||
|
this.setDefaultTargetDataSource(defaultDataSource);
|
||||||
|
super.afterPropertiesSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metodo per ricaricare i datasource se vengono aggiunti nuovi tenant a runtime
|
||||||
|
public void refreshDataSources() {
|
||||||
|
this.afterPropertiesSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
18
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal file
18
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package it.integry.ems.jpa;
|
||||||
|
|
||||||
|
public class TenantContext {
|
||||||
|
private static final ThreadLocal<String> currentTenant = new ThreadLocal<>();
|
||||||
|
|
||||||
|
public static void setCurrentTenant(String tenant) {
|
||||||
|
currentTenant.set(tenant);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCurrentTenant() {
|
||||||
|
return currentTenant.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
currentTenant.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package it.integry.ems.jpa.entity;
|
||||||
|
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
public abstract class BaseEntity implements Serializable {
|
||||||
|
// Classe base per le entity JPA
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package it.integry.ems.jpa.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.repository.NoRepositoryBean;
|
||||||
|
|
||||||
|
@NoRepositoryBean
|
||||||
|
public interface BaseRepository<T, ID> extends JpaRepository<T, ID> {
|
||||||
|
// Interfaccia base per i repository
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package it.integry.ems.jpa.repository;
|
||||||
|
|
||||||
|
import it.integry.ems_model.entity.MtbAart;
|
||||||
|
import org.springframework.data.jpa.repository.EntityGraph;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface MtbAartRepository extends BaseRepository<MtbAart, String> {
|
||||||
|
|
||||||
|
Optional<MtbAart> findByCodMart(String codMart);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbUntMis"})
|
||||||
|
Optional<MtbAart> findWithUntMisByCodMart(String codMart);
|
||||||
|
|
||||||
|
List<MtbAart> findByCodMartIn(List<String> codMarts);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbUntMis"})
|
||||||
|
List<MtbAart> findWithUntMisByCodMartIn(List<String> codMarts);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbUntMis", "mtbAartBarCode"})
|
||||||
|
List<MtbAart> findWithBarcodeWithUntMisByCodMartIn(List<String> codMarts);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbAartBarCode"})
|
||||||
|
Optional<MtbAart> findWithBarcodeByCodMart(String codMart);
|
||||||
|
|
||||||
|
@Query("SELECT m FROM MtbAart m WHERE m.untMis = 'KG'")
|
||||||
|
List<MtbAart> findByUntMisKG();
|
||||||
|
|
||||||
|
@Query("SELECT m.flagQtaCnfFissa FROM MtbAart m WHERE m.codMart = :codMart")
|
||||||
|
Optional<String> findFlagQtaCnfFissaByCodMart(@Param("codMart") String codMart);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.jpa.repository;
|
||||||
|
|
||||||
|
import it.integry.ems_model.entity.MtbUntMis;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface MtbUntMisRepository extends BaseRepository<MtbUntMis, String> {
|
||||||
|
|
||||||
|
Optional<MtbUntMis> findByUntMis(String untMis);
|
||||||
|
|
||||||
|
List<MtbUntMis> findByUntMisIn(List<String> untMis);
|
||||||
|
|
||||||
|
@Query("SELECT a.mtbUntMis FROM MtbAart a WHERE a.codMart = :codMart")
|
||||||
|
Optional<MtbUntMis> findByCodMart(@Param("codMart") String codMart);
|
||||||
|
|
||||||
|
int countByUntMis(String untMis);
|
||||||
|
|
||||||
|
@Query("SELECT u.cifreDec FROM MtbUntMis u WHERE u.flagUnitaKg = :flagUnitaKg")
|
||||||
|
List<BigDecimal> findCifreDecByFlagUnitaKg(@Param("flagUnitaKg") String flagUnitaKg);
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ public class JsonObjectMapperConfig {
|
|||||||
|
|
||||||
module.addDeserializer(BigDecimal.class, new BigDecimalDeserialize());
|
module.addDeserializer(BigDecimal.class, new BigDecimalDeserialize());
|
||||||
module.addDeserializer(Integer.class, new IntegerDeserializer());
|
module.addDeserializer(Integer.class, new IntegerDeserializer());
|
||||||
|
module.addDeserializer(Long.class, new LongDeserializer());
|
||||||
|
|
||||||
module.addDeserializer(String.class, new StringUnicodeDeserialize());
|
module.addDeserializer(String.class, new StringUnicodeDeserialize());
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import it.integry.ems.json.ResponseJSONObjectMapper;
|
|||||||
import it.integry.ems.response.EsitoType;
|
import it.integry.ems.response.EsitoType;
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
import it.integry.ems.service.HttpRestWrapper;
|
import it.integry.ems.service.HttpRestWrapper;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -60,11 +60,11 @@ public class LicenseComponent {
|
|||||||
if (!canStart)
|
if (!canStart)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<AvailableConnectionsModel> availableConnectionsModels = settingsModel.getAvailableConnections(true);
|
List<AvailableConnectionModel> availableConnectionModels = settingsModel.getAvailableConnections(true);
|
||||||
|
|
||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager()) {
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager()) {
|
||||||
|
|
||||||
for (AvailableConnectionsModel model : availableConnectionsModels) {
|
for (AvailableConnectionModel model : availableConnectionModels) {
|
||||||
multiDBTransactionManager.addConnection(model);
|
multiDBTransactionManager.addConnection(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import it.integry.ems_model.utility.Query;
|
|||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||||
|
import it.integry.ems_model.utility.dto.PkTableDTO;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.web.context.ContextLoader;
|
import org.springframework.web.context.ContextLoader;
|
||||||
@@ -75,6 +76,18 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
return UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
return UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected @NotNull <T> List<T> executeQueryOnlyFirstColumn(String sql) throws SQLException {
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @NotNull HashMap<String, Object> executeQueryOnlyFirstRow(String sql) throws SQLException {
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @NotNull <T> T executeQueryOnlyFirstRowFirstColumn(String sql) throws SQLException {
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
protected void executeStatement(String... sqls) throws SQLException {
|
protected void executeStatement(String... sqls) throws SQLException {
|
||||||
executeStatement(connection, sqls);
|
executeStatement(connection, sqls);
|
||||||
}
|
}
|
||||||
@@ -141,6 +154,10 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void alterObject(SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
private void alterObject(SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
||||||
|
if (UtilityString.isNullOrEmpty(objectName)) {
|
||||||
|
throw new IllegalArgumentException("ObjectName in createOrUpdateFunction(), createOrUpdateView(), createOrUpdateTrigger(), createOrUpdateProcedure() cannot be null or empty");
|
||||||
|
}
|
||||||
|
|
||||||
executeStatement("IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
executeStatement("IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||||
"\tDROP " + sqlObject.toString() + " " + objectName,
|
"\tDROP " + sqlObject.toString() + " " + objectName,
|
||||||
sql);
|
sql);
|
||||||
@@ -155,12 +172,20 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
UtilityDB.createIndex(connection, indexTableDTO);
|
UtilityDB.createIndex(connection, indexTableDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void createPrimaryKey(PkTableDTO pkTableDTO) throws Exception {
|
||||||
|
UtilityDB.createPK(connection, pkTableDTO);
|
||||||
|
}
|
||||||
|
|
||||||
protected void cloneTable(String sourceTable, String newTable,boolean fillNewTable, boolean dropOldTable, boolean renameNewTable) throws Exception {
|
|
||||||
|
protected void cloneTable(String sourceTable, String newTable, boolean fillNewTable, boolean dropOldTable, boolean renameNewTable) throws Exception {
|
||||||
UtilityDB.cloneTable(connection, sourceTable, newTable, fillNewTable, dropOldTable, renameNewTable);
|
UtilityDB.cloneTable(connection, sourceTable, newTable, fillNewTable, dropOldTable, renameNewTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dropIndex(String tableName, String indexName) throws Exception {
|
protected boolean existIndex(String tableName, String indexName) throws SQLException {
|
||||||
|
return UtilityDB.existIndex(connection, tableName, indexName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dropIndex(String tableName, String indexName) throws SQLException {
|
||||||
UtilityDB.dropIndex(connection, tableName, indexName);
|
UtilityDB.dropIndex(connection, tableName, indexName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,6 +423,25 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getSetupValue(String gestName, String section, String keySection) throws SQLException {
|
||||||
|
String sql = Query.format("SELECT value FROM " + StbGestSetup.ENTITY +
|
||||||
|
" WHERE gest_name = %s AND" +
|
||||||
|
" section = %s AND" +
|
||||||
|
" key_section = %s", gestName, section, keySection);
|
||||||
|
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a getStbGestSetup method to return the entire StbGestSetup object
|
||||||
|
protected StbGestSetup getStbGestSetup(String gestName, String section, String keySection) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String sql = Query.format("SELECT * FROM stb_gest_setup " +
|
||||||
|
" WHERE gest_name = %s AND" +
|
||||||
|
" section = %s AND" +
|
||||||
|
" key_section = %s", gestName, section, keySection);
|
||||||
|
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, StbGestSetup.class);
|
||||||
|
}
|
||||||
|
|
||||||
protected void deleteSetup(String gestName, String section, String keySection) throws Exception {
|
protected void deleteSetup(String gestName, String section, String keySection) throws Exception {
|
||||||
StbGestSetup stbGestSetup = new StbGestSetup()
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
.setGestName(gestName)
|
.setGestName(gestName)
|
||||||
@@ -480,6 +524,16 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
stbGestSetup.manageWithParentConnection(connection);
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void dropSetup(String gestName, String section, String keySection) throws Exception {
|
||||||
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
|
.setGestName(gestName)
|
||||||
|
.setSection(section)
|
||||||
|
.setKeySection(keySection);
|
||||||
|
|
||||||
|
stbGestSetup.setOperation(OperationType.DELETE);
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
|
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public enum IntegryCustomer {
|
|||||||
IntegryCustomerDB.Agricoper_IlVisone,
|
IntegryCustomerDB.Agricoper_IlVisone,
|
||||||
IntegryCustomerDB.Agricoper_Luva),
|
IntegryCustomerDB.Agricoper_Luva),
|
||||||
|
|
||||||
ATI(IntegryCustomerDB.ATI_Finpart),
|
ATI(IntegryCustomerDB.ATI, IntegryCustomerDB.ATI_Finpart),
|
||||||
Auricchio(IntegryCustomerDB.Auricchio_Auricchio,
|
Auricchio(IntegryCustomerDB.Auricchio_Auricchio,
|
||||||
IntegryCustomerDB.Auricchio_AuricchioMiki,
|
IntegryCustomerDB.Auricchio_AuricchioMiki,
|
||||||
IntegryCustomerDB.Auricchio_AuricchioSrl,
|
IntegryCustomerDB.Auricchio_AuricchioSrl,
|
||||||
@@ -20,6 +20,7 @@ public enum IntegryCustomer {
|
|||||||
Biolevante(IntegryCustomerDB.Biolevante_Biolevante,
|
Biolevante(IntegryCustomerDB.Biolevante_Biolevante,
|
||||||
IntegryCustomerDB.Biolevante_BiolevanteStorico,
|
IntegryCustomerDB.Biolevante_BiolevanteStorico,
|
||||||
IntegryCustomerDB.Biolevante_TenutaSanMartino),
|
IntegryCustomerDB.Biolevante_TenutaSanMartino),
|
||||||
|
CapelliMonelli(IntegryCustomerDB.CapelliMonelli_CapelliMonelli),
|
||||||
Carelli(IntegryCustomerDB.Carelli_Carelli,
|
Carelli(IntegryCustomerDB.Carelli_Carelli,
|
||||||
IntegryCustomerDB.Carelli_GestFood,
|
IntegryCustomerDB.Carelli_GestFood,
|
||||||
IntegryCustomerDB.Carelli_Chiuso,
|
IntegryCustomerDB.Carelli_Chiuso,
|
||||||
@@ -70,7 +71,8 @@ public enum IntegryCustomer {
|
|||||||
Gramm(IntegryCustomerDB.Gramm_Gramm,
|
Gramm(IntegryCustomerDB.Gramm_Gramm,
|
||||||
IntegryCustomerDB.Gramm_PrimeOlive,
|
IntegryCustomerDB.Gramm_PrimeOlive,
|
||||||
IntegryCustomerDB.Gramm_ProveStage,
|
IntegryCustomerDB.Gramm_ProveStage,
|
||||||
IntegryCustomerDB.Gramm_2MHolding),
|
IntegryCustomerDB.Gramm_2MHolding,
|
||||||
|
IntegryCustomerDB.Gramm_GrammUsa),
|
||||||
Idrotecnica(IntegryCustomerDB.Idrotecnica_Idrotecnica),
|
Idrotecnica(IntegryCustomerDB.Idrotecnica_Idrotecnica),
|
||||||
Igood(IntegryCustomerDB.Igood_Aida,
|
Igood(IntegryCustomerDB.Igood_Aida,
|
||||||
IntegryCustomerDB.Igood_Igood,
|
IntegryCustomerDB.Igood_Igood,
|
||||||
@@ -117,7 +119,10 @@ public enum IntegryCustomer {
|
|||||||
IntegryCustomerDB.Suit_TenutaArianna,
|
IntegryCustomerDB.Suit_TenutaArianna,
|
||||||
IntegryCustomerDB.Suit_Valpietro),
|
IntegryCustomerDB.Suit_Valpietro),
|
||||||
Tempesta(IntegryCustomerDB.Tempesta_Tempesta,
|
Tempesta(IntegryCustomerDB.Tempesta_Tempesta,
|
||||||
IntegryCustomerDB.Tempesta_VivaiTempesta),
|
IntegryCustomerDB.Tempesta_DI,
|
||||||
|
IntegryCustomerDB.Tempesta_VivaiTempesta,
|
||||||
|
IntegryCustomerDB.Tempesta_VivaiTempesta_DI
|
||||||
|
),
|
||||||
Tosca(IntegryCustomerDB.Tosca_Ba,
|
Tosca(IntegryCustomerDB.Tosca_Ba,
|
||||||
IntegryCustomerDB.Tosca_Ce,
|
IntegryCustomerDB.Tosca_Ce,
|
||||||
IntegryCustomerDB.Tosca_Cz,
|
IntegryCustomerDB.Tosca_Cz,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems.migration._base;
|
package it.integry.ems.migration._base;
|
||||||
|
|
||||||
|
import it.integry.ems.exception.InvalidCustomerDbException;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -9,7 +10,9 @@ public enum IntegryCustomerDB {
|
|||||||
Agricoper_IlVisone("ilvisone"),
|
Agricoper_IlVisone("ilvisone"),
|
||||||
Agricoper_Luva("luva"),
|
Agricoper_Luva("luva"),
|
||||||
|
|
||||||
|
ATI("atisrl"),
|
||||||
ATI_Finpart("Finpart"),
|
ATI_Finpart("Finpart"),
|
||||||
|
|
||||||
Auricchio_Auricchio("auricchio"),
|
Auricchio_Auricchio("auricchio"),
|
||||||
Auricchio_AuricchioMiki("auricchio_miki"),
|
Auricchio_AuricchioMiki("auricchio_miki"),
|
||||||
Auricchio_AuricchioSrl("auricchiosrl"),
|
Auricchio_AuricchioSrl("auricchiosrl"),
|
||||||
@@ -24,12 +27,14 @@ public enum IntegryCustomerDB {
|
|||||||
Biolevante_BiolevanteStorico("biolevante_storico"),
|
Biolevante_BiolevanteStorico("biolevante_storico"),
|
||||||
Biolevante_TenutaSanMartino("tenutasanmartino"),
|
Biolevante_TenutaSanMartino("tenutasanmartino"),
|
||||||
|
|
||||||
|
CapelliMonelli_CapelliMonelli("capelli_monelli"),
|
||||||
|
|
||||||
Carelli_Carelli("carelli"),
|
Carelli_Carelli("carelli"),
|
||||||
Carelli_GestFood("gestfood"),
|
Carelli_GestFood("gestfood"),
|
||||||
Carelli_Chiuso("chiuso"),
|
Carelli_Chiuso("chiuso"),
|
||||||
Carelli_Format("format"),
|
Carelli_Format("format"),
|
||||||
Carelli_Murgia("murgia"),
|
Carelli_Murgia("murgia"),
|
||||||
|
Carelli_MurgiaTest("murgia_test"),
|
||||||
Carelli_Panimal("panimal"),
|
Carelli_Panimal("panimal"),
|
||||||
Carelli_Winact("winact"),
|
Carelli_Winact("winact"),
|
||||||
Carelli_Csgr("csgr"),
|
Carelli_Csgr("csgr"),
|
||||||
@@ -91,7 +96,8 @@ public enum IntegryCustomerDB {
|
|||||||
Gramm_Gramm("gramm"),
|
Gramm_Gramm("gramm"),
|
||||||
Gramm_PrimeOlive("primeolive"),
|
Gramm_PrimeOlive("primeolive"),
|
||||||
Gramm_ProveStage("grammprovestage"),
|
Gramm_ProveStage("grammprovestage"),
|
||||||
Gramm_2MHolding("2M_HOLDING"),
|
Gramm_2MHolding("dueemme"),
|
||||||
|
Gramm_GrammUsa("gramm_usa"),
|
||||||
|
|
||||||
|
|
||||||
Idrotecnica_Idrotecnica("idrotecnica"),
|
Idrotecnica_Idrotecnica("idrotecnica"),
|
||||||
@@ -122,6 +128,7 @@ public enum IntegryCustomerDB {
|
|||||||
Levanplast_Perilflor("perilflor"),
|
Levanplast_Perilflor("perilflor"),
|
||||||
Levanplast_PerilflorSrl("perilflorsrl"),
|
Levanplast_PerilflorSrl("perilflorsrl"),
|
||||||
Levanplast_Levanplast("levanplast"),
|
Levanplast_Levanplast("levanplast"),
|
||||||
|
Levanplast_Levanplastsrl("levanplastsrl"),
|
||||||
|
|
||||||
Maggio_MaggioSrl("maggiosrl"),
|
Maggio_MaggioSrl("maggiosrl"),
|
||||||
Maggio_GiovMaggio("giovmaggio"),
|
Maggio_GiovMaggio("giovmaggio"),
|
||||||
@@ -191,7 +198,9 @@ public enum IntegryCustomerDB {
|
|||||||
|
|
||||||
|
|
||||||
Tempesta_Tempesta("tempesta"),
|
Tempesta_Tempesta("tempesta"),
|
||||||
|
Tempesta_DI("tempestadi"),
|
||||||
Tempesta_VivaiTempesta("vivaitempesta"),
|
Tempesta_VivaiTempesta("vivaitempesta"),
|
||||||
|
Tempesta_VivaiTempesta_DI("vivaitempestadi"),
|
||||||
|
|
||||||
|
|
||||||
Tosca_Ba("tosca_ba"),
|
Tosca_Ba("tosca_ba"),
|
||||||
@@ -229,6 +238,6 @@ public enum IntegryCustomerDB {
|
|||||||
|
|
||||||
return Arrays.stream(values()).filter(x -> x.getValue().equalsIgnoreCase(value))
|
return Arrays.stream(values()).filter(x -> x.getValue().equalsIgnoreCase(value))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElseThrow(() -> new InvalidCustomerDbException(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package it.integry.ems.migration.model;
|
|||||||
|
|
||||||
import it.integry.ems.migration._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ public class Migration_20210721093948 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void up() throws Exception {
|
public void up() throws Exception {
|
||||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||||
|
|
||||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package it.integry.ems.migration.model;
|
|||||||
|
|
||||||
import it.integry.ems.migration._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ public class Migration_20210924152555 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void up() throws Exception {
|
public void up() throws Exception {
|
||||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||||
|
|
||||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import it.integry.ems_model.entity.StbUser;
|
|||||||
import it.integry.ems_model.entity.WtbUsers;
|
import it.integry.ems_model.entity.WtbUsers;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import it.integry.security.utility.CryptoUtils;
|
import it.integry.security.utility.CryptoUtils;
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ public class Migration_20220413102657 extends BaseMigration implements Migration
|
|||||||
.setUserCode(wtbUser.getUserCode())
|
.setUserCode(wtbUser.getUserCode())
|
||||||
.setDetails(wtbUser.getDetails())
|
.setDetails(wtbUser.getDetails())
|
||||||
.setLastAccessDatetime(wtbUser.getLastAccessDatetime())
|
.setLastAccessDatetime(wtbUser.getLastAccessDatetime())
|
||||||
.setPasswordEndtime(wtbUser.getPasswordEndtime())
|
.setPasswordEndtime(UtilityLocalDate.localDateTimeFromDate(wtbUser.getPasswordEndtime()))
|
||||||
.setUrlCss(wtbUser.getUrlCss())
|
.setUrlCss(wtbUser.getUrlCss())
|
||||||
.setCodLang(wtbUser.getCodLang())
|
.setCodLang(wtbUser.getCodLang())
|
||||||
.setCreationDatetime(wtbUser.getCreationDatetime())
|
.setCreationDatetime(wtbUser.getCreationDatetime())
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public class Migration_20251022125946 extends BaseMigration implements Migration
|
|||||||
if (isHistoryDB())
|
if (isHistoryDB())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
createOrUpdateFunction("getListinoVendita", "CREATE FUNCTION [dbo].[getListinoVendita](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15))\n" +
|
createOrUpdateFunction("getListinoVendita", "CREATE FUNCTION [dbo].[getListinoVendita](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15))\n" +
|
||||||
" RETURNS TABLE AS\n" +
|
" RETURNS TABLE AS\n" +
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ public class Migration_20251024175524 extends BaseMigration implements Migration
|
|||||||
if (isHistoryDB())
|
if (isHistoryDB())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
executeStatement(
|
executeStatement(
|
||||||
"exec DropForeignKey 'ctb_amac', 'mtb_depo_posizioni'",
|
"exec DropForeignKey 'ctb_amac', 'mtb_depo_posizioni'",
|
||||||
"exec DropForeignKey 'jrl_fase_posizioni', 'mtb_depo_posizioni'",
|
"exec DropForeignKey 'jrl_fase_posizioni', 'mtb_depo_posizioni'",
|
||||||
|
|||||||
@@ -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_20251027125018 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup("MTB_AART", "SETUP", "CHK_EXIST_BARCODE", "N",
|
||||||
|
"Se abilitata blocca se codice a barre già assegnato ad altra referenza", false, null, false, false,
|
||||||
|
false, false, false, null, false, null);
|
||||||
|
|
||||||
|
if(isCustomer(IntegryCustomer.Carelli)){
|
||||||
|
updateSetupValue("MTB_AART", "SETUP", "CHK_EXIST_BARCODE", "S");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Migration_20251027172319 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(
|
||||||
|
"CREATE TABLE [dbo].[mtb_ssfam]("
|
||||||
|
+ " [cod_mgrp] varchar(5) NOT NULL, "
|
||||||
|
+ " [cod_msgr] varchar(5) NOT NULL, "
|
||||||
|
+ " [cod_msfa] varchar(6) NOT NULL, "
|
||||||
|
+ " [cod_mssfa] varchar(6) NOT NULL, "
|
||||||
|
+ " [descrizione] varchar(40) NOT NULL);",
|
||||||
|
|
||||||
|
"ALTER TABLE mtb_ssfam ADD CONSTRAINT pk_mtb_ssfam PRIMARY KEY ("
|
||||||
|
+ " cod_mgrp ASC, cod_msgr ASC, cod_msfa ASC, cod_mssfa ASC );",
|
||||||
|
|
||||||
|
"ALTER TABLE [dbo].[mtb_ssfam] WITH CHECK ADD CONSTRAINT fk_mtb_ssfam_mtb_grup "
|
||||||
|
+ "FOREIGN KEY(cod_mgrp) REFERENCES [dbo].[mtb_grup](cod_mgrp);",
|
||||||
|
|
||||||
|
"ALTER TABLE [dbo].[mtb_ssfam] WITH CHECK ADD CONSTRAINT fk_mtb_ssfam_mtb_sgrp "
|
||||||
|
+ "FOREIGN KEY(cod_mgrp, cod_msgr) REFERENCES [dbo].[mtb_sgrp](cod_mgrp, cod_msgr);",
|
||||||
|
|
||||||
|
"ALTER TABLE [dbo].[mtb_ssfam] WITH CHECK ADD CONSTRAINT fk_mtb_ssfam_mtb_sfam "
|
||||||
|
+ "FOREIGN KEY(cod_mgrp, cod_msgr, cod_msfa) REFERENCES [dbo].[mtb_sfam](cod_mgrp, cod_msgr, cod_msfa);",
|
||||||
|
"exec DropForeignKey 'mtb_aart', 'mtb_aart_marchio';",
|
||||||
|
"exec DropPrimaryKey 'mtb_aart_marchio';",
|
||||||
|
"ALTER TABLE mtb_aart_marchio ADD id bigint identity NOT NULL;",
|
||||||
|
"ALTER TABLE mtb_aart_marchio ADD CONSTRAINT pk_mtb_aart_marchio PRIMARY KEY (id);",
|
||||||
|
"CREATE TABLE mtb_marchio_linea ("
|
||||||
|
+ " id_marchio bigint NOT NULL, "
|
||||||
|
+ " cod_linea varchar(6) NOT NULL, "
|
||||||
|
+ " descrizione varchar(255) NOT NULL );",
|
||||||
|
"ALTER TABLE mtb_marchio_linea ADD CONSTRAINT pk_mtb_marchio_linea PRIMARY KEY (cod_linea);",
|
||||||
|
"ALTER TABLE mtb_marchio_linea ADD CONSTRAINT fk_mtb_marchio_linea_mtb_aart_marchio "
|
||||||
|
+ "FOREIGN KEY (id_marchio) REFERENCES mtb_aart_marchio(id);",
|
||||||
|
|
||||||
|
"ALTER TABLE mtb_aart ADD id_marchio bigint;",
|
||||||
|
"UPDATE mtb_aart SET id_marchio = mtb_aart_marchio.id "
|
||||||
|
+ "FROM mtb_aart INNER JOIN mtb_aart_marchio ON mtb_aart.marchio = mtb_aart_marchio.marchio;",
|
||||||
|
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_aart_marchio "
|
||||||
|
+ "FOREIGN KEY (id_marchio) REFERENCES mtb_aart_marchio(id);",
|
||||||
|
|
||||||
|
"ALTER TABLE mtb_aart ADD cod_mssfa varchar(6);",
|
||||||
|
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_ssfam "
|
||||||
|
+ "FOREIGN KEY (cod_mgrp, cod_msgr, cod_msfa, cod_mssfa) "
|
||||||
|
+ "REFERENCES mtb_ssfam (cod_mgrp, cod_msgr, cod_msfa, cod_mssfa);",
|
||||||
|
|
||||||
|
"ALTER TABLE mtb_aart ADD cod_linea varchar(6);",
|
||||||
|
"ALTER TABLE mtb_aart ADD cod_slinea varchar(6);",
|
||||||
|
"ALTER TABLE mtb_aart ADD cod_sslinea varchar(6);",
|
||||||
|
"CREATE TABLE mtb_marchio_slinea ("
|
||||||
|
+ " cod_linea varchar(6) NOT NULL, "
|
||||||
|
+ " cod_slinea varchar(6) NOT NULL, "
|
||||||
|
+ " descrizione varchar(255) NOT NULL );",
|
||||||
|
"ALTER TABLE mtb_marchio_slinea ADD CONSTRAINT pk_mtb_marchio_slinea PRIMARY KEY (cod_slinea);",
|
||||||
|
"ALTER TABLE mtb_marchio_slinea ADD CONSTRAINT fk_mtb_marchio_slinea_mtb_marchio_linea "
|
||||||
|
+ "FOREIGN KEY (cod_linea) REFERENCES mtb_marchio_linea (cod_linea);",
|
||||||
|
|
||||||
|
"CREATE TABLE mtb_marchio_sslinea ("
|
||||||
|
+ " cod_slinea varchar(6) NOT NULL, "
|
||||||
|
+ " cod_sslinea varchar(6) NOT NULL, "
|
||||||
|
+ " descrizione varchar(255) NOT NULL );",
|
||||||
|
"ALTER TABLE mtb_marchio_sslinea ADD CONSTRAINT pk_mtb_marchio_sslinea PRIMARY KEY (cod_sslinea);",
|
||||||
|
"ALTER TABLE mtb_marchio_sslinea ADD CONSTRAINT fk_mtb_marchio_sslinea_mtb_marchio_slinea "
|
||||||
|
+ "FOREIGN KEY (cod_slinea) REFERENCES mtb_marchio_slinea (cod_slinea);",
|
||||||
|
|
||||||
|
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_marchio_linea "
|
||||||
|
+ "FOREIGN KEY (cod_linea) REFERENCES mtb_marchio_linea(cod_linea);",
|
||||||
|
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_marchio_slinea "
|
||||||
|
+ "FOREIGN KEY (cod_slinea) REFERENCES mtb_marchio_slinea(cod_slinea);",
|
||||||
|
"ALTER TABLE mtb_aart ADD CONSTRAINT fk_mtb_aart_mtb_marchio_sslinea "
|
||||||
|
+ "FOREIGN KEY (cod_sslinea) REFERENCES mtb_marchio_sslinea(cod_sslinea);"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Migration_20251027173518 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
IndexTableDTO indexTableDTO =
|
||||||
|
new IndexTableDTO()
|
||||||
|
.setTableName("mtb_aart_marchio")
|
||||||
|
.setIndexName("ix_mtb_aart_marchio_unique")
|
||||||
|
.setUnique(true)
|
||||||
|
.setColumnsIndex(Arrays.asList(
|
||||||
|
new IndexTableDTO.ColumnIndex("marchio")
|
||||||
|
));
|
||||||
|
createIndex(indexTableDTO);
|
||||||
|
|
||||||
|
if (!existsColumn("ctb_movt", "rif_import")){
|
||||||
|
executeStatement("ALTER TABLE ctb_movt ADD rif_import varchar(40)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existsColumn("ctb_varbeni", "num_cmov")) {
|
||||||
|
executeStatement("ALTER TABLE ctb_varbeni add num_cmov int",
|
||||||
|
"ALTER TABLE ctb_varbeni ADD CONSTRAINT fk_ctb_varbeni_ctb_movt FOREIGN KEY (num_cmov) REFERENCES ctb_movt (num_cmov)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251028153054 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
createSetup("PICKING", "PRODUZIONE", "FLAG_SKIP_ASK_VERSAMENTO_AUTOMATICO", "N",
|
||||||
|
"Permette di saltare la domanda relativa all''effettuazione del versamento automatico, eseguendolo direttamente.", false, "SI_NO", false, false,
|
||||||
|
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251029153203 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateView("[vw_tracciabUDCVend]", "CREATE VIEW [dbo].[vw_tracciabUDCVend] AS\n" +
|
||||||
|
"SELECT mtb_colt.cod_anag AS codAnag,\n" +
|
||||||
|
" gtb_anag.rag_soc AS ragSoc,\n" +
|
||||||
|
" ISNULL(vtb_dest.destinatario, '') AS destinazione,\n" +
|
||||||
|
" ISNULL(vtb_dest.citta, gtb_anag.citta) AS citta,\n" +
|
||||||
|
" ISNULL(vtb_dest.prov, gtb_anag.prov) AS provincia,\n" +
|
||||||
|
" ISNULL(vtb_dest.nazione, gtb_anag.nazione) AS nazione,\n" +
|
||||||
|
" mtb_colt.cod_dtip AS codDtip,\n" +
|
||||||
|
" mtb_colt.data_doc AS dataDoc,\n" +
|
||||||
|
" mtb_colt.ser_doc AS serDoc,\n" +
|
||||||
|
" mtb_colt.num_doc AS numDoc,\n" +
|
||||||
|
" mtb_colr.cod_mart AS codMart,\n" +
|
||||||
|
" mtb_aart.descrizione_estesa AS descrizioneEstesa,\n" +
|
||||||
|
" ISNULL(mtb_partita_mag.partita_mag_prod, mtb_colr.partita_mag) AS lotto,\n" +
|
||||||
|
" mtb_partita_mag.data_prod AS dataLotto,\n" +
|
||||||
|
" IIF(dtb_tipi.segno_qta_scar = -1, mtb_colr.barcode_ul_in, mtb_colr.barcode_ul_out) AS UDCVenduta,\n" +
|
||||||
|
" UDC.data_vers AS dataOraProd,\n" +
|
||||||
|
" UDC.cod_jfas AS LineaProd,\n" +
|
||||||
|
" UDC.num_ord AS numOrdProd,\n" +
|
||||||
|
" UDC.data_ord AS DataOrdProd,\n" +
|
||||||
|
" mtb_aart.unt_mis AS untMis,\n" +
|
||||||
|
" SUM(mtb_colr.qta_col) AS qtaVenduta,\n" +
|
||||||
|
" SUM(mtb_colr.num_cnf) AS colliVenduti,\n" +
|
||||||
|
" vtb_vett.rag_soc AS vettore,\n" +
|
||||||
|
" vtb_viaggi.targa AS Targa,\n" +
|
||||||
|
" vtb_viaggi.num_prenotazione AS num_prenotazione,\n" +
|
||||||
|
" vtb_viaggi.container AS container,\n" +
|
||||||
|
" vtb_viaggi.sigillo AS sigillo,\n" +
|
||||||
|
" vtb_viaggi.nave AS nave,\n" +
|
||||||
|
" vtb_viaggi.id_viaggio AS id_viaggio\n" +
|
||||||
|
" FROM mtb_colt\n" +
|
||||||
|
" INNER JOIN mtb_colr 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 dtb_tipi ON mtb_colt.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||||
|
" INNER JOIN gtb_anag ON mtb_colt.cod_anag = gtb_anag.cod_anag\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_dest ON mtb_colt.cod_anag = vtb_dest.cod_anag AND\n" +
|
||||||
|
" mtb_colt.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||||
|
" INNER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" INNER JOIN mtb_partita_mag ON mtb_colr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||||
|
" mtb_colr.partita_mag = mtb_partita_mag.partita_mag\n" +
|
||||||
|
" INNER JOIN mtb_colt UDC ON IIF(dtb_tipi.segno_qta_scar = -1, mtb_colr.barcode_ul_in, mtb_colr.barcode_ul_out) =\n" +
|
||||||
|
" UDC.barcode_ul\n" +
|
||||||
|
" LEFT OUTER JOIN dtb_doct on mtb_colt.cod_dtip =dtb_doct.cod_dtip and mtb_colt.data_doc =dtb_doct.data_doc and mtb_colt.ser_doc= dtb_doct.ser_doc and mtb_colt.num_doc= dtb_doct.num_doc\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_viaggi on dtb_doct.id_viaggio=vtb_viaggi.id_viaggio\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_vett on vtb_viaggi.cod_vvet=vtb_vett.cod_vvet\n" +
|
||||||
|
"\n" +
|
||||||
|
"WHERE mtb_colt.gestione = 'V'\n" +
|
||||||
|
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||||
|
"GROUP BY mtb_colt.cod_anag, gtb_anag.rag_soc, ISNULL(vtb_dest.destinatario, ''),\n" +
|
||||||
|
" ISNULL(vtb_dest.citta, gtb_anag.citta),\n" +
|
||||||
|
" ISNULL(vtb_dest.prov, gtb_anag.prov),\n" +
|
||||||
|
" ISNULL(vtb_dest.nazione, gtb_anag.nazione),\n" +
|
||||||
|
" mtb_colt.cod_dtip, mtb_colt.data_doc, mtb_colt.ser_doc, mtb_colt.num_doc,\n" +
|
||||||
|
" mtb_colr.cod_mart, mtb_aart.descrizione_estesa,\n" +
|
||||||
|
" ISNULL(mtb_partita_mag.partita_mag_prod, mtb_colr.partita_mag),\n" +
|
||||||
|
" mtb_partita_mag.data_prod,\n" +
|
||||||
|
" mtb_aart.unt_mis,\n" +
|
||||||
|
" IIF(dtb_tipi.segno_qta_scar = -1, mtb_colr.barcode_ul_in, mtb_colr.barcode_ul_out),\n" +
|
||||||
|
" UDC.data_vers,\n" +
|
||||||
|
" UDC.cod_jfas,\n" +
|
||||||
|
" UDC.data_ord,\n" +
|
||||||
|
" UDC.num_ord,\n" +
|
||||||
|
" vtb_vett.rag_soc, \n" +
|
||||||
|
" vtb_viaggi.targa, \n" +
|
||||||
|
" vtb_viaggi.num_prenotazione, \n" +
|
||||||
|
" vtb_viaggi.container, \n" +
|
||||||
|
" vtb_viaggi.sigillo, \n" +
|
||||||
|
" vtb_viaggi.nave, \n" +
|
||||||
|
" vtb_viaggi.id_viaggio");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251029170931 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateFunction("getDettMatricoleDaOrdine", "CREATE Function [dbo].[getDettMatricoleDaOrdine] (@codJcom varchar(10)) \n" +
|
||||||
|
"RETURNS @dettMatricole TABLE( cod_prod varchar(15),\n" +
|
||||||
|
" descrizione_prod varchar(255), \n" +
|
||||||
|
" unt_mis_prod varchar(3),\n" +
|
||||||
|
" qta_inevasa numeric(20,5),\n" +
|
||||||
|
" qta_da_prod numeric(20,5),\n" +
|
||||||
|
" data_ord datetime, \n" +
|
||||||
|
" num_ord integer, \n" +
|
||||||
|
"matricola varchar(20)) AS\n" +
|
||||||
|
"Begin\n" +
|
||||||
|
" declare @codProd varchar(15),\n" +
|
||||||
|
" @descrizioneProd varchar(255), \n" +
|
||||||
|
" @untMisProd varchar(3), \n" +
|
||||||
|
" @qtaInevasa numeric(20,5), \n" +
|
||||||
|
" @qtaProd numeric(20,5), \n" +
|
||||||
|
" @dataOrd datetime, \n" +
|
||||||
|
" @numOrd integer,\n" +
|
||||||
|
" @existMatricola integer,\n" +
|
||||||
|
" @matricola varchar(20),\n" +
|
||||||
|
" @termCons varchar(1024);\n" +
|
||||||
|
"\n" +
|
||||||
|
" Declare crs_prod Cursor LOCAL SCROLL FOR\n" +
|
||||||
|
" select dtb_ordt.cod_prod, \n" +
|
||||||
|
" dtb_ordt.descrizione_prod, \n" +
|
||||||
|
" dtb_ordt.unt_mis_prod, \n" +
|
||||||
|
" dtb_ordt.qta_prod - dtb_ordt.qta_evasa_prod as qta_inevasa, \n" +
|
||||||
|
" convert(numeric(20,5), 0) as qta_da_prod, \n" +
|
||||||
|
" dtb_ordt.data_ord, \n" +
|
||||||
|
" dtb_ordt.num_ord,\n" +
|
||||||
|
" dtb_ordt.term_cons\n" +
|
||||||
|
" from dtb_ordt \n" +
|
||||||
|
" where gestione = 'L' and \n" +
|
||||||
|
" livello = 1 and\n" +
|
||||||
|
" /*flag_evaso_forzato = 'N' and\n" +
|
||||||
|
" flag_evaso_prod = 'I' and */\n" +
|
||||||
|
" dtb_ordt.cod_jcom = @codJcom\n" +
|
||||||
|
"\n" +
|
||||||
|
" OPEN crs_prod \n" +
|
||||||
|
" FETCH NEXT FROM crs_prod INTO @codProd, @descrizioneProd, @untMisProd, @qtaInevasa, @qtaProd, @dataOrd, @numOrd, @termCons\n" +
|
||||||
|
" WHILE @@FETCH_STATUS = 0\n" +
|
||||||
|
" Begin \n" +
|
||||||
|
" IF @termCons IS NOT NULL\n" +
|
||||||
|
" BEGIN\n" +
|
||||||
|
" Declare crs_matricole Cursor LOCAL SCROLL FOR\n" +
|
||||||
|
" select value_string\n" +
|
||||||
|
" from parseStringIntoArray(@termcons, '|') \n" +
|
||||||
|
"\n" +
|
||||||
|
" OPEN crs_matricole \n" +
|
||||||
|
" FETCH NEXT FROM crs_matricole INTO @matricola\n" +
|
||||||
|
" WHILE @@FETCH_STATUS = 0\n" +
|
||||||
|
" Begin\n" +
|
||||||
|
" select @existMatricola = 0\n" +
|
||||||
|
" select @existMatricola = COUNT(*)\n" +
|
||||||
|
" from dtb_ordt, \n" +
|
||||||
|
" dtb_docr inner join (select cod_prod, \n" +
|
||||||
|
" partita_mag \n" +
|
||||||
|
" from dtb_doct \n" +
|
||||||
|
" where cod_dtip = dbo.getGestSetup('IMPORT_DOCUMENTI', 'CARICO_SCARICO_DA_FABB', 'COD_DTIP_SCAR_GIROC'))giroc on giroc.cod_prod = dtb_docr.cod_mart and\n" +
|
||||||
|
" giroc.partita_mag = dtb_docr.matricola, \n" +
|
||||||
|
" dtb_tipi\n" +
|
||||||
|
" where dtb_docr.data_ord = dtb_ordt.data_ord and\n" +
|
||||||
|
" dtb_docr.num_ord = dtb_ordt.num_ord and\n" +
|
||||||
|
" dtb_ordt.gestione = 'L' and \n" +
|
||||||
|
" dtb_docr.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||||
|
" dtb_tipi.tipo_emissione = 'DIRETTA' and\n" +
|
||||||
|
" dtb_tipi.segno_qta_car = 1 and\n" +
|
||||||
|
" dtb_ordt.livello = 1 and\n" +
|
||||||
|
" dtb_ordt.data_ord = @dataOrd and\n" +
|
||||||
|
" dtb_ordt.num_ord = @numOrd and\n" +
|
||||||
|
" dtb_docr.matricola = @matricola;\n" +
|
||||||
|
" \n" +
|
||||||
|
"\n" +
|
||||||
|
" IF @existMatricola = 0\n" +
|
||||||
|
" insert into @dettMatricole \n" +
|
||||||
|
" select @codProd, @descrizioneProd, @untMisProd, @qtaInevasa, @qtaProd, @dataOrd, @numOrd, @matricola\n" +
|
||||||
|
"\n" +
|
||||||
|
" FETCH NEXT FROM crs_matricole INTO @matricola\n" +
|
||||||
|
" end \n" +
|
||||||
|
" close crs_matricole\n" +
|
||||||
|
" deallocate crs_matricole \n" +
|
||||||
|
" END\n" +
|
||||||
|
" ELSE\n" +
|
||||||
|
" insert into @dettMatricole \n" +
|
||||||
|
" select @codProd, @descrizioneProd, @untMisProd, @qtaInevasa, @qtaProd, @dataOrd, @numOrd, null\n" +
|
||||||
|
"\n" +
|
||||||
|
" FETCH NEXT FROM crs_prod INTO @codProd, @descrizioneProd, @untMisProd, @qtaInevasa, @qtaProd, @dataOrd, @numOrd, @termCons\n" +
|
||||||
|
" end \n" +
|
||||||
|
" close crs_prod\n" +
|
||||||
|
" deallocate crs_prod \n" +
|
||||||
|
"\n" +
|
||||||
|
" return\n" +
|
||||||
|
"end");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.entity.JtbCiclCq;
|
||||||
|
import it.integry.ems_model.entity.JtbCiclCqValori;
|
||||||
|
import it.integry.ems_model.entity._enum.TipoValore;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityList;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20251029181607 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(
|
||||||
|
"EXEC sp_updateextendedproperty 'MS_Description',\n" +
|
||||||
|
" 'Valori possibili: 0 -> Testo, 1 -> Boolean, 2 -> Intero, 3 -> Decimale, 4 -> Date, 5 -> Datetime, 6 -> Time, 7 -> DropdownList',\n" +
|
||||||
|
" 'SCHEMA', 'dbo', 'TABLE', 'jtb_cicl_cq', 'COLUMN', 'tipo_valore';",
|
||||||
|
"EXEC sp_updateextendedproperty 'MS_Description',\n" +
|
||||||
|
" 'Valori possibili: 0 -> Testo, 1 -> Boolean, 2 -> Intero, 3 -> Decimale, 4 -> Date, 5 -> Datetime, 6 -> Time, 7 -> DropdownList',\n" +
|
||||||
|
" 'SCHEMA', 'dbo', 'TABLE', 'dtb_ord_cq', 'COLUMN', 'tipo_valore';"
|
||||||
|
);
|
||||||
|
|
||||||
|
dropChecks("jtb_cicl_cq", "tipo_valore");
|
||||||
|
dropChecks("dtb_ord_cq", "tipo_valore");
|
||||||
|
|
||||||
|
executeStatement(
|
||||||
|
"ALTER TABLE jtb_cicl_cq\n" +
|
||||||
|
" ADD CHECK ([tipo_valore] = 0 OR [tipo_valore] = 1 OR [tipo_valore] = 2 OR [tipo_valore] = 3 OR [tipo_valore] = 4 OR\n" +
|
||||||
|
" [tipo_valore] = 5 OR [tipo_valore] = 6 OR [tipo_valore] = 7);",
|
||||||
|
"ALTER TABLE dtb_ord_cq\n" +
|
||||||
|
" ADD CHECK ([tipo_valore] = 0 OR [tipo_valore] = 1 OR [tipo_valore] = 2 OR [tipo_valore] = 3 OR [tipo_valore] = 4 OR\n" +
|
||||||
|
" [tipo_valore] = 5 OR [tipo_valore] = 6 OR [tipo_valore] = 7);",
|
||||||
|
"CREATE TABLE jtb_cicl_cq_valori\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY\n" +
|
||||||
|
" CONSTRAINT jtb_cicl_cq_valori_pk\n" +
|
||||||
|
" PRIMARY KEY,\n" +
|
||||||
|
" descrizione VARCHAR(255) NOT NULL,\n" +
|
||||||
|
" valori VARCHAR(MAX) NOT NULL\n" +
|
||||||
|
");",
|
||||||
|
"ALTER TABLE jtb_cicl_cq\n" +
|
||||||
|
" ADD id_valori BIGINT\n" +
|
||||||
|
" CONSTRAINT jtb_cicl_cq_jtb_cicl_cq_valori_id_fk\n" +
|
||||||
|
" REFERENCES dbo.jtb_cicl_cq_valori;",
|
||||||
|
"ALTER TABLE dtb_ord_cq\n" +
|
||||||
|
" ADD id_valori BIGINT\n" +
|
||||||
|
" CONSTRAINT dtb_ord_cq_jtb_cicl_cq_valori_id_fk\n" +
|
||||||
|
" REFERENCES dbo.jtb_cicl_cq_valori;"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.entity.JtbCiclCq;
|
||||||
|
import it.integry.ems_model.entity.JtbCiclCqValori;
|
||||||
|
import it.integry.ems_model.entity._enum.TipoValore;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20251030093449 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JtbCiclCqValori jtbCiclCqValori = new JtbCiclCqValori()
|
||||||
|
.setDescrizione("Tipologia Fermi Macchina")
|
||||||
|
.setValori("FERMO MACCHINA|CAMBIO FORMATO|CAMBIO COLORE|PULIZIA|ATTESA PRODOTTO");
|
||||||
|
|
||||||
|
jtbCiclCqValori.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
jtbCiclCqValori.manageWithParentConnection(connection);
|
||||||
|
|
||||||
|
String sql =
|
||||||
|
"SELECT DISTINCT cod_prod, num_fase, MAX(id_riga) + 1 AS id_riga\n" +
|
||||||
|
"FROM jtb_cicl_cq\n" +
|
||||||
|
"WHERE tipologia = 'FERMI_MACCHINA'\n" +
|
||||||
|
"GROUP BY cod_prod, num_fase";
|
||||||
|
|
||||||
|
List<JtbCiclCq> jtbCiclCqList = UtilityDB.executeSimpleQueryDTO(connection, sql, JtbCiclCq.class);
|
||||||
|
|
||||||
|
if (UtilityList.isNullOrEmpty(jtbCiclCqList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (JtbCiclCq jtbCiclCq : jtbCiclCqList) {
|
||||||
|
jtbCiclCq
|
||||||
|
.setControllo("Tipologia")
|
||||||
|
.setNumRip(0)
|
||||||
|
.setTipologia("FERMI_MACCHINA")
|
||||||
|
.setTipoValore(TipoValore.DROPDOWNLIST)
|
||||||
|
.setIdValori(jtbCiclCqValori.getId());
|
||||||
|
|
||||||
|
jtbCiclCq.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
jtbCiclCq.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251031092657 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("alter table dtb_tipi add flag_delete_plk bit not null default 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
@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_20251031094727 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(isCustomer(IntegryCustomer.RossoGargano)) {
|
||||||
|
executeStatement("insert into stb_abil\n" +
|
||||||
|
"select stb_menu_opz.cod_opz, user_name, flag_abil, stb_menu_opz.gest_name\n" +
|
||||||
|
"from ( select * from stb_abil where stb_abil.cod_opz = 'VR011' ) stb_abil\n" +
|
||||||
|
"cross apply ( select * from stb_menu_opz where stb_menu_opz.cod_opz ='VR131' ) stb_menu_opz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251031100008 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("exec sp_rename 'dtb_tipi.flag_delete_plk', 'flag_delete_pkl'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251031120553 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateFunction("f_suggestEAN13","CREATE FUNCTION [dbo].[f_suggestEAN13](@precode VARCHAR(12))\n" +
|
||||||
|
" RETURNS VARCHAR(13)\n" +
|
||||||
|
" AS\n" +
|
||||||
|
" BEGIN\n" +
|
||||||
|
"\n" +
|
||||||
|
" DECLARE @ean13 VARCHAR(13);\n" +
|
||||||
|
"\n" +
|
||||||
|
" IF LEN(@precode) = 12\n" +
|
||||||
|
" BEGIN\n" +
|
||||||
|
" SELECT @ean13 = CONCAT(@precode, dbo.getCheckDigitEan13(@precode))\n" +
|
||||||
|
" END;\n" +
|
||||||
|
" ELSE\n" +
|
||||||
|
" BEGIN\n" +
|
||||||
|
" WITH ean AS (SELECT MAX(CAST((RIGHT(\n" +
|
||||||
|
" LEFT(cod_barre, LEN(cod_barre) - 1),\n" +
|
||||||
|
" (LEN(cod_barre) - LEN(@precode) - 1))) AS NUMERIC)) AS maxValue\n" +
|
||||||
|
"\n" +
|
||||||
|
" FROM mvw_barcode\n" +
|
||||||
|
" WHERE cod_barre LIKE @precode + '%'\n" +
|
||||||
|
" AND LEN(cod_barre) = 13\n" +
|
||||||
|
" AND ISNUMERIC(RIGHT(cod_barre, LEN(cod_barre) - LEN(@precode))) = 1)\n" +
|
||||||
|
" SELECT @ean13 = CONCAT(@precode,\n" +
|
||||||
|
" RIGHT(FORMAT((ISNULL(maxValue, 0) + 1), REPLICATE('0', 12)), 12 - LEN(@precode)))\n" +
|
||||||
|
" FROM ean;\n" +
|
||||||
|
"\n" +
|
||||||
|
" SELECT @ean13 = CONCAT(@ean13, dbo.getCheckDigitEan13(@ean13))\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
" END\n" +
|
||||||
|
" RETURN @ean13;\n" +
|
||||||
|
" END\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@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_20251031122121 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup("W_CSITUAZ_CNTECONCOMM_DISP", "DATAWINDOW", "D_CSIT_CNTECONCOMM_REP", null,
|
||||||
|
null, false, null, false, false,
|
||||||
|
false, false, false, null, false, null);
|
||||||
|
|
||||||
|
if(isCustomer(IntegryCustomer.Smetar)){
|
||||||
|
updateSetupValue("W_CSITUAZ_CNTECONCOMM_DISP", "DATAWINDOW", "D_CSIT_CNTECONCOMM_REP", "d_csit_cnteconcomm_smetar_rep");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
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_20251031125910 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(isCustomer(IntegryCustomer.Gramm)) {
|
||||||
|
createOrUpdateView("[OlapFermiMacchina]", "CREATE view [dbo].[OlapFermiMacchina] as \n" +
|
||||||
|
"\n" +
|
||||||
|
" \n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
" WITH controlli_qualita AS (SELECT [Data Inizio],[Data Fine], [Operatore], [Tipologia], [Descrizione del Fermo] as Note, gestione, data_ord, num_ord, num_rip\n" +
|
||||||
|
" FROM (\n" +
|
||||||
|
" select controllo, valore_ril, DTB_ORDT.gestione, dtb_ordt.data_ord, dtb_ordt.num_ord, dtb_ord_cqr.num_rip\n" +
|
||||||
|
" \n" +
|
||||||
|
"from dtb_ord_cqr inner join dtb_ord_cq on dtb_ord_cqr.gestione=dtb_ord_cq.gestione and \n" +
|
||||||
|
" dtb_ord_cqr.data_ord=dtb_ord_cq.data_ord and dtb_ord_cqr.num_ord=dtb_ord_cq.num_ord \n" +
|
||||||
|
" and dtb_ord_cqr.id_riga=dtb_ord_cq.id_riga\n" +
|
||||||
|
" inner join dtb_ordt on dtb_ord_cqr.gestione=dtb_ordt.gestione and \n" +
|
||||||
|
" dtb_ord_cqr.data_ord=dtb_ordt.data_ord and \n" +
|
||||||
|
" dtb_ord_cqr.num_ord=dtb_ordt.num_ord\n" +
|
||||||
|
" \n" +
|
||||||
|
"where dtb_ord_cqr.gestione='L' and dtb_ord_cqr.data_ord >'2024/10/01' and dtb_ordt.cod_mdep in('34','01','33')\n" +
|
||||||
|
" ) cq\n" +
|
||||||
|
" PIVOT\n" +
|
||||||
|
" (max(valore_ril)\n" +
|
||||||
|
" FOR controllo IN ([Data Inizio],[Data Fine], [Operatore],[Tipologia],[Descrizione del Fermo])\n" +
|
||||||
|
" ) AS pivottable)\n" +
|
||||||
|
"\n" +
|
||||||
|
"select dtb_ordt.cod_mdep,\n" +
|
||||||
|
" dtb_ord_steps.cod_jfas,\n" +
|
||||||
|
" dtb_ordt.data_ord, \n" +
|
||||||
|
" dtb_ordt.num_ord,\n" +
|
||||||
|
" dtb_ordt.cod_prod,\n" +
|
||||||
|
" mtb_aart.descrizione,\n" +
|
||||||
|
" mtb_aart.marchio,\n" +
|
||||||
|
" dtb_ordt.partita_mag,\n" +
|
||||||
|
" dtb_ordt.unt_mis_prod,\n" +
|
||||||
|
" dtb_ordt.qta_evasa_prod,\n" +
|
||||||
|
" try_convert(datetime, controlli_qualita.[Data Inizio], 103) as Data_inz_fermo,\n" +
|
||||||
|
" try_convert(datetime, controlli_qualita.[Data Fine], 103) as Data_fine_fermo,\n" +
|
||||||
|
" controlli_qualita.Operatore,\n" +
|
||||||
|
" controlli_qualita.Note,\n" +
|
||||||
|
" SUM(\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN TRY_CONVERT(datetime, controlli_qualita.[Data Inizio], 103) IS NOT NULL\n" +
|
||||||
|
" AND TRY_CONVERT(datetime, controlli_qualita.[Data Fine], 103) IS NOT NULL\n" +
|
||||||
|
" THEN DATEDIFF(\n" +
|
||||||
|
" MINUTE,\n" +
|
||||||
|
" TRY_CONVERT(datetime, controlli_qualita.[Data Inizio], 103),\n" +
|
||||||
|
" TRY_CONVERT(datetime, controlli_qualita.[Data Fine], 103)\n" +
|
||||||
|
" )\n" +
|
||||||
|
" ELSE 0\n" +
|
||||||
|
" END\n" +
|
||||||
|
") AS min_lav, -- min_fermo (non è stato cambiato il nome del campo perchè ci sono diversi report che leggono da questa vista)\n" +
|
||||||
|
"\n" +
|
||||||
|
"0 AS h_lav,\n" +
|
||||||
|
"\n" +
|
||||||
|
"SUM(\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN TRY_CONVERT(datetime, controlli_qualita.[Data Inizio], 103) IS NOT NULL\n" +
|
||||||
|
" AND TRY_CONVERT(datetime, controlli_qualita.[Data Fine], 103) IS NOT NULL\n" +
|
||||||
|
" THEN DATEDIFF(\n" +
|
||||||
|
" HOUR,\n" +
|
||||||
|
" TRY_CONVERT(datetime, controlli_qualita.[Data Inizio], 103),\n" +
|
||||||
|
" TRY_CONVERT(datetime, controlli_qualita.[Data Fine], 103)\n" +
|
||||||
|
" )\n" +
|
||||||
|
" ELSE 0\n" +
|
||||||
|
" END\n" +
|
||||||
|
") OVER (PARTITION BY dtb_ordt.gestione, dtb_ordt.data_ord, dtb_ordt.num_ord) AS h_fermo,\n" +
|
||||||
|
"\n" +
|
||||||
|
"controlli_qualita.Tipologia\n" +
|
||||||
|
"\n" +
|
||||||
|
" \n" +
|
||||||
|
"from controlli_qualita inner join dtb_ordt on controlli_qualita.gestione=dtb_ordt.gestione and \n" +
|
||||||
|
" controlli_qualita.data_ord=dtb_ordt.data_ord and \n" +
|
||||||
|
" controlli_qualita.num_ord=dtb_ordt.num_ord\n" +
|
||||||
|
" \n" +
|
||||||
|
" inner join mtb_aart on dtb_ordt.cod_prod=mtb_aart.cod_mart\n" +
|
||||||
|
" left outer join ( select num_ord, data_ord, gestione, cod_jfas\n" +
|
||||||
|
" from \n" +
|
||||||
|
" (select num_ord, data_ord, gestione, data_iniz, cod_jfas,\n" +
|
||||||
|
" ROW_NUMBER() OVER (PARTITION BY gestione, data_ord, num_ord ORDER BY data_iniz ASC) AS num\n" +
|
||||||
|
" from dtb_ord_steps\n" +
|
||||||
|
" where data_iniz IS NOT NULL) step\n" +
|
||||||
|
" where num='1') dtb_ord_steps ON dtb_ordt.gestione = dtb_ord_steps.gestione\n" +
|
||||||
|
" AND dtb_ordt.data_ord = dtb_ord_steps.data_ord\n" +
|
||||||
|
" AND dtb_ordt.num_ord = dtb_ord_steps.num_ord\n" +
|
||||||
|
"where dtb_ordt.gestione='L' and dtb_ordt.data_ord>'2024/10/01' and dtb_ordt.cod_mdep in('34','01','33') \n" +
|
||||||
|
"\n" +
|
||||||
|
"group by dtb_ordt.cod_mdep,\n" +
|
||||||
|
" dtb_ord_steps.cod_jfas,\n" +
|
||||||
|
" dtb_ordt.data_ord, \n" +
|
||||||
|
" dtb_ordt.num_ord,\n" +
|
||||||
|
" dtb_ordt.cod_prod,\n" +
|
||||||
|
" mtb_aart.descrizione,\n" +
|
||||||
|
" mtb_aart.marchio,\n" +
|
||||||
|
" dtb_ordt.partita_mag,\n" +
|
||||||
|
" dtb_ordt.unt_mis_prod,\n" +
|
||||||
|
" dtb_ordt.qta_prod,\n" +
|
||||||
|
" dtb_ordt.qta_evasa_prod,\n" +
|
||||||
|
" controlli_qualita.[Data Inizio],\n" +
|
||||||
|
" controlli_qualita.[Data Fine],\n" +
|
||||||
|
" controlli_qualita.Operatore,\n" +
|
||||||
|
" controlli_qualita.Note,\n" +
|
||||||
|
" dtb_ordt.gestione,\n" +
|
||||||
|
" controlli_qualita.Tipologia");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251031162801 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!isCustomerDb(IntegryCustomerDB.Levanplast_Levanplast))
|
||||||
|
return;
|
||||||
|
|
||||||
|
updateSetupValue("W_ARICEZIONE_MERCE_INS_NEW_COLLO_DLG", "SETUP", "AGGIORNA_DATA_SCAD_PARTITA_MAG", "S",
|
||||||
|
"Se impostata a S in fase di ricezione merce la data di scadenza della partita verrà aggiornata a data ricezione + gg_scad ove presente", false, null, false, false, false,
|
||||||
|
false, false, null, false, null);
|
||||||
|
|
||||||
|
executeStatement("DELETE\n" +
|
||||||
|
"FROM stb_gest_setup_depo\n" +
|
||||||
|
"WHERE gest_name = 'W_ARICEZIONE_MERCE_INS_NEW_COLLO_DLG'\n" +
|
||||||
|
" AND section = 'SETUP'\n" +
|
||||||
|
" AND key_section = 'AGGIORNA_DATA_SCAD_PARTITA_MAG'"
|
||||||
|
);
|
||||||
|
|
||||||
|
executeStatement("DELETE\n" +
|
||||||
|
"FROM wtb_gest_setup_user\n" +
|
||||||
|
"WHERE gest_name = 'W_ARICEZIONE_MERCE_INS_NEW_COLLO_DLG'\n" +
|
||||||
|
" AND section = 'SETUP'\n" +
|
||||||
|
" AND key_section = 'AGGIORNA_DATA_SCAD_PARTITA_MAG'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251031163348 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("INSERT INTO stb_gest_setup VALUES (\n" +
|
||||||
|
"\t'W_ARICEZIONE_MERCE_INS_NEW_COLLO_DLG',\n" +
|
||||||
|
"\t'SETUP',\n" +
|
||||||
|
"\t'AGGIORNA_DATA_SCAD_PARTITA_MAG',\n" +
|
||||||
|
"\t'S',\n" +
|
||||||
|
"\t'Se impostata a S in fase di ricezione merce la data di scadenza della partita verrà aggiornata a data ricezione + gg_scad ove presente',\n" +
|
||||||
|
"\t'N',\n" +
|
||||||
|
"\tNULL,\n" +
|
||||||
|
"\t'N',\n" +
|
||||||
|
"\t'2025-10-31 16:28:03.000',\n" +
|
||||||
|
"\t'Database Administrator',\n" +
|
||||||
|
"\t'N',\n" +
|
||||||
|
"\t'N',\n" +
|
||||||
|
"\t'N',\n" +
|
||||||
|
"\t'N',\n" +
|
||||||
|
"\tNULL,\n" +
|
||||||
|
"\t0);\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251103103545 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("CREATE TABLE [dbo].[srl_activity_art](\n" +
|
||||||
|
"\tid bigint identity,\n" +
|
||||||
|
"\t[activity_id] [varchar](15) NOT NULL,\n" +
|
||||||
|
"\t[cod_mart] [varchar](15) not NULL\n" +
|
||||||
|
")\n"
|
||||||
|
,
|
||||||
|
"alter table srl_activity_art add constraint pk_srl_activity_art primary key(id);\n");
|
||||||
|
|
||||||
|
if (isCustomerDb(IntegryCustomerDB.Carelli_Winact)) {
|
||||||
|
executeStatement("insert into srl_activity_art\n" +
|
||||||
|
"select activity_id, cod_mart\n" +
|
||||||
|
"from stb_activity\n" +
|
||||||
|
"where cod_jcom = 'MODEL'\n" +
|
||||||
|
"and activity_type_id = 'SEGNALAZIONE'\n" +
|
||||||
|
"and cod_mart is not null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251103175252 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(
|
||||||
|
"CREATE TABLE mtb_colori ("
|
||||||
|
+ " cod_col varchar(6) NOT NULL, "
|
||||||
|
+ " descrizione varchar(255) NOT NULL );",
|
||||||
|
"ALTER TABLE mtb_colori ADD CONSTRAINT pk_mtb_colori PRIMARY KEY (cod_col);",
|
||||||
|
"CREATE TABLE mtb_aart_colori ("
|
||||||
|
+ " cod_mart varchar(15) NOT NULL, "
|
||||||
|
+ " cod_col varchar(6) NOT NULL, "
|
||||||
|
+ " cod_barre varchar(25) NULL);",
|
||||||
|
"ALTER TABLE mtb_aart_colori ADD CONSTRAINT pk_mtb_aart_colori PRIMARY KEY (cod_mart, cod_col);",
|
||||||
|
"ALTER TABLE mtb_aart_colori ADD CONSTRAINT fk_mtb_aart_colori_mtb_aart "
|
||||||
|
+ "FOREIGN KEY (cod_mart) REFERENCES mtb_aart (cod_mart);",
|
||||||
|
"ALTER TABLE mtb_aart_colori ADD CONSTRAINT fk_mtb_aart_colori_mtb_colori "
|
||||||
|
+ "FOREIGN KEY (cod_col) REFERENCES mtb_colori (cod_col);"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,384 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251104122721 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(
|
||||||
|
"ALTER TABLE dbo.vtb_offt\n" +
|
||||||
|
" ADD cod_banc VARCHAR(5)\n" +
|
||||||
|
" CONSTRAINT vtb_offt_gtb_banc_cod_banc_fk\n" +
|
||||||
|
" REFERENCES dbo.gtb_banc;",
|
||||||
|
"ALTER TABLE dbo.vtb_offt\n" +
|
||||||
|
" ADD cod_banc_azi VARCHAR(5)\n" +
|
||||||
|
" CONSTRAINT vtb_offt_gtb_banc_azi_cod_banc_fk\n" +
|
||||||
|
" REFERENCES dbo.gtb_banc_azi;"
|
||||||
|
);
|
||||||
|
|
||||||
|
createOrUpdateView(
|
||||||
|
"vvw_contratti_vendita",
|
||||||
|
"CREATE VIEW [dbo].[vvw_contratti_vendita] AS\n" +
|
||||||
|
"WITH depo AS (SELECT TOP 1 cod_mdep\n" +
|
||||||
|
" FROM mtb_depo\n" +
|
||||||
|
" WHERE mtb_depo.flag_movimentabile = 'S'\n" +
|
||||||
|
" AND (cod_anag IS NULL OR cod_anag IN (SELECT gtb_anag.cod_anag\n" +
|
||||||
|
" FROM gtb_anag,\n" +
|
||||||
|
" azienda\n" +
|
||||||
|
" WHERE gtb_anag.part_iva = azienda.part_iva))),\n" +
|
||||||
|
" contratto AS (SELECT vtb_offt.cod_anag,\n" +
|
||||||
|
" vtb_offt.cod_vdes,\n" +
|
||||||
|
" vtb_offt.note,\n" +
|
||||||
|
" vtb_offr.id_offerta,\n" +
|
||||||
|
" vtb_offr.cod_mart,\n" +
|
||||||
|
" vtb_offr.unt_mis,\n" +
|
||||||
|
" vtb_offr.descrizione,\n" +
|
||||||
|
" vtb_offr.descrizione_html,\n" +
|
||||||
|
" vtb_offr.json_costi,\n" +
|
||||||
|
" vtb_offr.costo_unt,\n" +
|
||||||
|
" vtb_offr.unt_mis_vend,\n" +
|
||||||
|
" vtb_offr.prz_unt,\n" +
|
||||||
|
" vtb_offr.qta_off,\n" +
|
||||||
|
" vtb_offr.data_iniz_contr,\n" +
|
||||||
|
" vtb_offr.data_fine_contr,\n" +
|
||||||
|
" vtb_offt.cod_paga,\n" +
|
||||||
|
" vtb_offt.descrizione_paga,\n" +
|
||||||
|
" vtb_offr.perc_sco1,\n" +
|
||||||
|
" vtb_offr.perc_sco2,\n" +
|
||||||
|
" vtb_offr.perc_sco3,\n" +
|
||||||
|
" vtb_offr.perc_sco4,\n" +
|
||||||
|
" vtb_offr.rap_conv_vend,\n" +
|
||||||
|
" vtb_offr.qta_ord,\n" +
|
||||||
|
" vtb_offr.qta_doc,\n" +
|
||||||
|
" vtb_offr.qta_fatt,\n" +
|
||||||
|
" vtb_offr.note AS note_riga,\n" +
|
||||||
|
" vtb_offt.condizioni_commerciali,\n" +
|
||||||
|
" vtb_offt.incoterms,\n" +
|
||||||
|
" vtb_offt.note_incoterms,\n" +
|
||||||
|
" vtb_offt.data_rif_scad,\n" +
|
||||||
|
" vtb_offt.perc_prov,\n" +
|
||||||
|
" vtb_offt.note_carico,\n" +
|
||||||
|
" vtb_offt.term_cons,\n" +
|
||||||
|
" vtb_offt.cod_banc,\n" +
|
||||||
|
" vtb_offt.cod_banc_azi\n" +
|
||||||
|
" FROM vtb_offt\n" +
|
||||||
|
" INNER JOIN vtb_offr ON vtb_offt.id_offerta = vtb_offr.id_offerta\n" +
|
||||||
|
" CROSS APPLY [dbo].[getUntMisArticolo](vtb_offr.cod_mart, vtb_offr.unt_mis_vend) um\n" +
|
||||||
|
" WHERE stato_offerta = 3)\n" +
|
||||||
|
"\n" +
|
||||||
|
"SELECT contratto.data_iniz_contr AS data_iniz,\n" +
|
||||||
|
" contratto.data_fine_contr AS data_fine,\n" +
|
||||||
|
" contratto.id_offerta AS id_contratto,\n" +
|
||||||
|
" contratto.note,\n" +
|
||||||
|
" contratto.cod_mart,\n" +
|
||||||
|
" contratto.descrizione AS descrizione_articolo,\n" +
|
||||||
|
" contratto.unt_mis_vend AS unt_mis_ven,\n" +
|
||||||
|
" contratto.qta_off AS qta_vend_contratto,\n" +
|
||||||
|
" contratto.prz_unt AS prz_vend,\n" +
|
||||||
|
" contratto.perc_sco1,\n" +
|
||||||
|
" contratto.perc_sco2,\n" +
|
||||||
|
" contratto.perc_sco3,\n" +
|
||||||
|
" contratto.perc_sco4,\n" +
|
||||||
|
" ISNULL(contratto.qta_ord, 0) AS qta_ord,\n" +
|
||||||
|
" ISNULL(contratto.qta_doc, 0) AS qta_doc,\n" +
|
||||||
|
" gtb_anag.cod_anag,\n" +
|
||||||
|
" gtb_anag.rag_soc,\n" +
|
||||||
|
" gtb_anag.indirizzo,\n" +
|
||||||
|
" gtb_anag.cap,\n" +
|
||||||
|
" gtb_anag.citta,\n" +
|
||||||
|
" gtb_anag.prov,\n" +
|
||||||
|
" gtb_anag.nazione,\n" +
|
||||||
|
" gtb_anag.e_mail,\n" +
|
||||||
|
" gtb_anag.telefono,\n" +
|
||||||
|
" gtb_anag.part_iva,\n" +
|
||||||
|
" ISNULL(giacenza.qta_disp * rap_conv_vend, 0) AS qta_disp,\n" +
|
||||||
|
" (SELECT cod_mdep FROM depo) AS cod_mdep,\n" +
|
||||||
|
" contratto.prz_unt * (1 - contratto.perc_sco1 / 100) * (1 - contratto.perc_sco2 / 100) -\n" +
|
||||||
|
" (1 * contratto.perc_sco3 / 100) *\n" +
|
||||||
|
" (1 - contratto.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||||
|
" contratto.cod_paga,\n" +
|
||||||
|
" ISNULL(contratto.descrizione_paga, gtb_paga.descrizione) AS descrizione_paga,\n" +
|
||||||
|
" contratto.qta_off -\n" +
|
||||||
|
" ISNULL(contratto.qta_ord, 0) -\n" +
|
||||||
|
" ISNULL(contratto.qta_doc, 0) AS qta_residua,\n" +
|
||||||
|
" ISNULL(contratto.qta_ord + contratto.qta_doc, 0) AS qta_usata,\n" +
|
||||||
|
" contratto.rap_conv_vend AS rap_conv,\n" +
|
||||||
|
" contratto.cod_vdes,\n" +
|
||||||
|
" vd.destinatario,\n" +
|
||||||
|
" vd.indirizzo AS indirizzo_dest,\n" +
|
||||||
|
" vc.cod_vlis,\n" +
|
||||||
|
" contratto.qta_fatt,\n" +
|
||||||
|
" contratto.note_riga,\n" +
|
||||||
|
" contratto.condizioni_commerciali,\n" +
|
||||||
|
" contratto.incoterms,\n" +
|
||||||
|
" gp.descrizione AS desc_incoterms,\n" +
|
||||||
|
" contratto.note_incoterms,\n" +
|
||||||
|
" contratto.data_rif_scad,\n" +
|
||||||
|
" contratto.perc_prov,\n" +
|
||||||
|
" contratto.note_carico,\n" +
|
||||||
|
" contratto.term_cons,\n" +
|
||||||
|
" gtb_tipi_paga.flag_banca_ven,\n" +
|
||||||
|
" IIF(gtb_tipi_paga.flag_banca_ven = 'C', gb.cod_banc, gba.cod_banc_azi) AS cod_banc,\n" +
|
||||||
|
" IIF(gtb_tipi_paga.flag_banca_ven = 'C', gb.descrizione, gba.descrizione) AS descr_banc\n" +
|
||||||
|
"FROM contratto\n" +
|
||||||
|
" INNER JOIN gtb_anag ON contratto.cod_anag = gtb_anag.cod_anag\n" +
|
||||||
|
" INNER JOIN vtb_clie vc ON contratto.cod_anag = vc.cod_anag\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_dest vd ON contratto.cod_anag = vd.cod_anag AND contratto.cod_vdes = vd.cod_vdes\n" +
|
||||||
|
" LEFT OUTER JOIN gtb_paga ON contratto.cod_paga = gtb_paga.cod_paga\n" +
|
||||||
|
" LEFT OUTER JOIN gtb_tipi_paga ON gtb_paga.tipo_paga = gtb_tipi_paga.tipo_paga\n" +
|
||||||
|
" LEFT OUTER JOIN gtb_porto gp ON contratto.incoterms = gp.porto\n" +
|
||||||
|
" LEFT OUTER JOIN gtb_banc gb ON contratto.cod_banc = gb.cod_banc\n" +
|
||||||
|
" LEFT OUTER JOIN gtb_banc_azi gba ON contratto.cod_banc_azi = gba.cod_banc_azi\n" +
|
||||||
|
" OUTER APPLY (SELECT SUM(mtb_part.qta_esistente + mtb_part.qta_imp_lav - mtb_part.qta_imp_cli) AS qta_disp\n" +
|
||||||
|
" FROM mtb_part\n" +
|
||||||
|
" INNER JOIN mtb_depo ON mtb_part.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||||
|
" WHERE mtb_depo.flag_movimentabile = 'S'\n" +
|
||||||
|
" AND mtb_part.cod_mart = contratto.cod_mart) giacenza");
|
||||||
|
|
||||||
|
createOrUpdateFunction(
|
||||||
|
"pvm_getassortimentoClientePedane",
|
||||||
|
"CREATE FUNCTION [dbo].[pvm_getassortimentoClientePedane](\n" +
|
||||||
|
" @codAnag VARCHAR(5), @codVlis VARCHAR(5), @codVdes VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT,\n" +
|
||||||
|
" @pedane INT = 0\n" +
|
||||||
|
")\n" +
|
||||||
|
" RETURNS TABLE\n" +
|
||||||
|
" AS\n" +
|
||||||
|
" RETURN( /*\n" +
|
||||||
|
"\n" +
|
||||||
|
" declare @codAnag VARCHAR(5), @codVlis VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT\n" +
|
||||||
|
" set @codAnag = 'C3355'\n" +
|
||||||
|
" set @codVlis = 'C3355'\n" +
|
||||||
|
" set @dataValidita = '2023/04/04'\n" +
|
||||||
|
" set @viewPromo = 1;\n" +
|
||||||
|
" */\n" +
|
||||||
|
" WITH assortimento AS (SELECT vtb_griglia_art.cod_mart\n" +
|
||||||
|
" FROM vtb_clie\n" +
|
||||||
|
" INNER JOIN vtb_griglia ON vtb_clie.cod_griglia = vtb_griglia.cod_griglia\n" +
|
||||||
|
" INNER JOIN vtb_griglia_art\n" +
|
||||||
|
" ON vtb_griglia.cod_griglia = vtb_griglia_art.cod_griglia AND\n" +
|
||||||
|
" vtb_griglia.data_validita = vtb_griglia_art.data_validita\n" +
|
||||||
|
" WHERE vtb_clie.cod_anag = @codAnag\n" +
|
||||||
|
" AND vtb_griglia.data_validita = (SELECT MAX(g.data_validita)\n" +
|
||||||
|
" FROM vtb_griglia g\n" +
|
||||||
|
" WHERE g.cod_griglia = vtb_clie.cod_griglia\n" +
|
||||||
|
" AND g.data_validita <= ISNULL(@dataValidita, CAST(GETDATE() AS DATE)))),\n" +
|
||||||
|
" lisv AS (SELECT cod_vlis, cod_vlis AS cod_vlis_rif\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" WHERE cod_vlis_rif IS NULL\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT cod_vlis, cod_vlis_rif\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" WHERE cod_vlis_rif IS NOT NULL),\n" +
|
||||||
|
" listino AS (SELECT DISTINCT cod_mart, tipo_variazione\n" +
|
||||||
|
" FROM (SELECT lisv.cod_vlis,\n" +
|
||||||
|
" mtb_lisv.cod_mart,\n" +
|
||||||
|
" LAST_VALUE(CASE\n" +
|
||||||
|
" WHEN vtb_list_data.data_iniz IS NULL THEN NULL\n" +
|
||||||
|
" ELSE mtb_lisv_data.tipo_variazione END)\n" +
|
||||||
|
" OVER (PARTITION BY lisv.cod_vlis, mtb_lisv.cod_mart\n" +
|
||||||
|
" ORDER BY vtb_list_data.data_iniz, CASE WHEN vtb_list_data.cod_promo IS NULL THEN 0 ELSE 1 END, vtb_list_data.versione\n" +
|
||||||
|
" RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS tipo_variazione\n" +
|
||||||
|
" FROM lisv\n" +
|
||||||
|
" INNER JOIN mtb_lisv ON lisv.cod_vlis_rif = mtb_lisv.cod_vlis\n" +
|
||||||
|
" INNER JOIN mtb_lisv_data ON mtb_lisv.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||||
|
" mtb_lisv.cod_mart = mtb_lisv_data.cod_mart\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_list_data\n" +
|
||||||
|
" ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||||
|
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
|
||||||
|
" vtb_list_data.data_iniz <=\n" +
|
||||||
|
" ISNULL(@dataValidita, CAST(GETDATE() AS DATE))\n" +
|
||||||
|
" WHERE lisv.cod_vlis = @codVlis\n" +
|
||||||
|
" AND NOT EXISTS(SELECT cod_mart FROM assortimento)) t\n" +
|
||||||
|
" WHERE (t.tipo_variazione IS NULL OR t.tipo_variazione <> 'D')),\n" +
|
||||||
|
" tmp_lisv AS (SELECT l.cod_mart,\n" +
|
||||||
|
" l.cod_vlis,\n" +
|
||||||
|
" ISNULL(p.data_iniz, l.data_iniz) AS data_iniz,\n" +
|
||||||
|
" p.data_fine,\n" +
|
||||||
|
" l.da,\n" +
|
||||||
|
" l.a,\n" +
|
||||||
|
" ISNULL(p.prz_vend, l.prz_vend_trasp) AS prz_vend,\n" +
|
||||||
|
" ISNULL(p.prz_vend_netto, l.prz_vend_trasp_netto) AS prz_vend_netto,\n" +
|
||||||
|
" ISNULL(p.perc_sco1, l.perc_sco1) AS perc_sco1,\n" +
|
||||||
|
" ISNULL(p.perc_sco2, l.perc_sco2) AS perc_sco2,\n" +
|
||||||
|
" ISNULL(p.perc_sco3, l.perc_sco3) AS perc_sco3,\n" +
|
||||||
|
" ISNULL(p.perc_sco4, l.perc_sco4) AS perc_sco4,\n" +
|
||||||
|
" p.perc_prov,\n" +
|
||||||
|
" CONVERT(NUMERIC(20, 5), 0) AS qta_residua,\n" +
|
||||||
|
" CONVERT(BIGINT, NULL) AS id_contratto,\n" +
|
||||||
|
" ISNULL(p.rap_conv, l.rap_conv) AS rap_conv,\n" +
|
||||||
|
" ISNULL(p.note, l.note) AS note,\n" +
|
||||||
|
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||||
|
" l.cod_tcol_ul AS cod_tcol_ul,\n" +
|
||||||
|
" ISNULL(p.unt_mis_ven, l.unt_mis_ven) AS unt_mis_ven,\n" +
|
||||||
|
" l.colli_pedana AS colli_pedana,\n" +
|
||||||
|
" ISNULL(p.tipo_variazione, l.tipo_variazione) AS tipo_variazione,\n" +
|
||||||
|
" CONVERT(VARCHAR(1), CASE\n" +
|
||||||
|
" WHEN p.cod_promo IS NULL THEN NULL\n" +
|
||||||
|
" ELSE 'P' END) AS tipo_promo,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||||
|
" l.porto,\n" +
|
||||||
|
" l.qta_cnf,\n" +
|
||||||
|
" NULL AS note_incoterms,\n" +
|
||||||
|
" NULL AS data_rif_scad,\n" +
|
||||||
|
" NULL AS note_carico,\n" +
|
||||||
|
" NULL AS term_cons,\n" +
|
||||||
|
" NULL AS cod_banc,\n" +
|
||||||
|
" NULL AS descr_banc\n" +
|
||||||
|
" FROM dbo.getListinoVenditaPedane(@dataValidita, @codVlis, NULL, @pedane) l\n" +
|
||||||
|
" LEFT OUTER JOIN dbo.getPromozioneVendita(@dataValidita, @dataValidita,\n" +
|
||||||
|
" @codVlis, NULL, NULL) p\n" +
|
||||||
|
" ON l.cod_vlis = p.cod_vlis AND l.cod_mart = p.cod_mart AND\n" +
|
||||||
|
" ISNULL(@viewPromo, 0) = 1\n" +
|
||||||
|
" WHERE l.cod_vlis = @codVlis\n" +
|
||||||
|
" AND l.cod_mart IN (SELECT cod_mart\n" +
|
||||||
|
" FROM assortimento\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT cod_mart\n" +
|
||||||
|
" FROM listino)\n" +
|
||||||
|
" AND l.tipo_variazione <> 'D'\n" +
|
||||||
|
" AND l.tipo_variazione IS NOT NULL\n" +
|
||||||
|
" AND l.flag_attivo = 'S'\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT l.cod_mart,\n" +
|
||||||
|
" l.cod_vlis,\n" +
|
||||||
|
" NULL AS data_iniz,\n" +
|
||||||
|
" NULL AS data_fine,\n" +
|
||||||
|
" NULL AS da,\n" +
|
||||||
|
" NULL AS a,\n" +
|
||||||
|
" NULL AS prz_vend,\n" +
|
||||||
|
" NULL AS prz_vend_netto,\n" +
|
||||||
|
" NULL AS perc_sco1,\n" +
|
||||||
|
" NULL AS perc_sco2,\n" +
|
||||||
|
" NULL AS perc_sco3,\n" +
|
||||||
|
" NULL AS perc_sco4,\n" +
|
||||||
|
" NULL AS perc_prov,\n" +
|
||||||
|
" NULL AS qta_residua,\n" +
|
||||||
|
" NULL AS id_contratto,\n" +
|
||||||
|
" um.rap_conv AS rap_conv,\n" +
|
||||||
|
" NULL AS note,\n" +
|
||||||
|
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||||
|
" NULL AS cod_tcol_ul,\n" +
|
||||||
|
" l.unt_mis_ven AS unt_mis_ven,\n" +
|
||||||
|
" NULL AS colli_pedana,\n" +
|
||||||
|
" NULL AS tipo_variazione,\n" +
|
||||||
|
" NULL AS tipo_promo,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||||
|
" NULL porto,\n" +
|
||||||
|
" mtb_aart.qta_cnf,\n" +
|
||||||
|
" NULL AS note_incoterms,\n" +
|
||||||
|
" NULL AS data_rif_scad,\n" +
|
||||||
|
" NULL AS note_carico,\n" +
|
||||||
|
" NULL AS term_cons,\n" +
|
||||||
|
" NULL AS cod_banc,\n" +
|
||||||
|
" NULL AS descr_banc\n" +
|
||||||
|
" FROM mtb_lisv l\n" +
|
||||||
|
" INNER JOIN listino ON l.cod_mart = listino.cod_mart\n" +
|
||||||
|
" INNER JOIN mtb_aart ON l.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" CROSS APPLY dbo.getUntMisArticolo(l.cod_mart, l.unt_mis_ven) um\n" +
|
||||||
|
" WHERE l.cod_vlis = @codVlis\n" +
|
||||||
|
" AND listino.tipo_variazione IS NULL\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT vvw_contratti_vendita.cod_mart,\n" +
|
||||||
|
" NULL AS cod_vlis,\n" +
|
||||||
|
" vvw_contratti_vendita.data_iniz,\n" +
|
||||||
|
" vvw_contratti_vendita.data_fine,\n" +
|
||||||
|
" NULL AS da,\n" +
|
||||||
|
" NULL AS a,\n" +
|
||||||
|
" vvw_contratti_vendita.prz_vend,\n" +
|
||||||
|
" ROUND(vvw_contratti_vendita.prz_vend *\n" +
|
||||||
|
" (1 - ISNULL(vvw_contratti_vendita.perc_sco1, 0))\n" +
|
||||||
|
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco2, 0))\n" +
|
||||||
|
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco3, 0))\n" +
|
||||||
|
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco4, 0)),\n" +
|
||||||
|
" 5) AS prz_vend_netto,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco1,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco2,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco3,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco4,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_prov,\n" +
|
||||||
|
" vvw_contratti_vendita.qta_residua,\n" +
|
||||||
|
" vvw_contratti_vendita.id_contratto,\n" +
|
||||||
|
" vvw_contratti_vendita.rap_conv,\n" +
|
||||||
|
" vvw_contratti_vendita.note,\n" +
|
||||||
|
" vvw_contratti_vendita.cod_vdes,\n" +
|
||||||
|
" NULL,\n" +
|
||||||
|
" vvw_contratti_vendita.unt_mis_ven,\n" +
|
||||||
|
" NULL,\n" +
|
||||||
|
" NULL,\n" +
|
||||||
|
" 'C' AS tipo_promo,\n" +
|
||||||
|
" vvw_contratti_vendita.cod_paga,\n" +
|
||||||
|
" vvw_contratti_vendita.descrizione_paga AS descr_paga,\n" +
|
||||||
|
" vvw_contratti_vendita.incoterms AS porto,\n" +
|
||||||
|
" mtb_aart.qta_cnf,\n" +
|
||||||
|
" vvw_contratti_vendita.note_incoterms,\n" +
|
||||||
|
" vvw_contratti_vendita.data_rif_scad,\n" +
|
||||||
|
" vvw_contratti_vendita.note_carico,\n" +
|
||||||
|
" vvw_contratti_vendita.term_cons,\n" +
|
||||||
|
" vvw_contratti_vendita.cod_banc,\n" +
|
||||||
|
" vvw_contratti_vendita.descr_banc\n" +
|
||||||
|
" FROM vvw_contratti_vendita\n" +
|
||||||
|
" INNER JOIN mtb_aart ON vvw_contratti_vendita.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" WHERE vvw_contratti_vendita.cod_anag = @codAnag\n" +
|
||||||
|
" AND (@codVdes IS NULL OR vvw_contratti_vendita.cod_vdes IS NULL OR\n" +
|
||||||
|
" vvw_contratti_vendita.cod_vdes = @codVdes)\n" +
|
||||||
|
" AND (ISNULL(@dataValidita, CAST(GETDATE() AS DATE)) BETWEEN\n" +
|
||||||
|
" vvw_contratti_vendita.data_iniz AND vvw_contratti_vendita.data_fine)\n" +
|
||||||
|
"-- AND vvw_contratti_vendita.qta_residua >= 0\n" +
|
||||||
|
" )\n" +
|
||||||
|
"\n" +
|
||||||
|
" SELECT tmp_lisv.cod_mart,\n" +
|
||||||
|
" ISNULL(maa.cod_mart_anag, tmp_lisv.cod_mart) AS cod_mart_anag,\n" +
|
||||||
|
" cod_vlis,\n" +
|
||||||
|
" data_iniz,\n" +
|
||||||
|
" data_fine,\n" +
|
||||||
|
" da,\n" +
|
||||||
|
" a,\n" +
|
||||||
|
" prz_vend,\n" +
|
||||||
|
" prz_vend_netto,\n" +
|
||||||
|
" perc_sco1,\n" +
|
||||||
|
" perc_sco2,\n" +
|
||||||
|
" perc_sco3,\n" +
|
||||||
|
" perc_sco4,\n" +
|
||||||
|
" perc_prov,\n" +
|
||||||
|
" qta_residua,\n" +
|
||||||
|
" id_contratto,\n" +
|
||||||
|
" rap_conv,\n" +
|
||||||
|
" ISNULL(maa.note, tmp_lisv.note) AS note,\n" +
|
||||||
|
" cod_tcol_ul,\n" +
|
||||||
|
" unt_mis_ven,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN maa.colli_pedana IS NULL OR maa.colli_pedana = 0 THEN tmp_lisv.colli_pedana\n" +
|
||||||
|
" ELSE maa.colli_pedana END AS colli_pedana,\n" +
|
||||||
|
" tipo_variazione,\n" +
|
||||||
|
" tipo_promo,\n" +
|
||||||
|
" cod_paga,\n" +
|
||||||
|
" descr_paga,\n" +
|
||||||
|
" porto,\n" +
|
||||||
|
" qta_cnf,\n" +
|
||||||
|
" CAST(CASE WHEN tmp_lisv.data_iniz IS NULL THEN 0 ELSE 1 END AS BIT) AS art_lisv,\n" +
|
||||||
|
" cod_vdes,\n" +
|
||||||
|
" note_incoterms,\n" +
|
||||||
|
" data_rif_scad,\n" +
|
||||||
|
" note_carico,\n" +
|
||||||
|
" term_cons,\n" +
|
||||||
|
" cod_banc,\n" +
|
||||||
|
" descr_banc\n" +
|
||||||
|
" FROM tmp_lisv\n" +
|
||||||
|
" LEFT OUTER JOIN mtb_aart_anag maa\n" +
|
||||||
|
" ON tmp_lisv.cod_mart = maa.cod_mart AND maa.cod_anag = @codAnag)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251105171403 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("delete dtb_ordr\n" +
|
||||||
|
"from dtb_ordr \n" +
|
||||||
|
"where not exists (select *\n" +
|
||||||
|
"from dtb_ordt \n" +
|
||||||
|
"where dtb_ordt.gestione = dtb_ordr.gestione\n" +
|
||||||
|
" AND dtb_ordt.data_ord = dtb_ordr.data_ord\n" +
|
||||||
|
" AND dtb_ordt.num_ord = dtb_ordr.num_ord )\n" +
|
||||||
|
"\n",
|
||||||
|
"alter table dtb_ordr add constraint fk_dtb_ordr_dtb_ordt foreign key (gestione, data_ord, num_ord) references dbo.dtb_ordt (gestione, data_ord, num_ord)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251106104752 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
dropDefault("mtb_lisv", "flag_primario");
|
||||||
|
|
||||||
|
addDefault("mtb_lisv", "flag_primario", 1);
|
||||||
|
|
||||||
|
if (!isCustomer(IntegryCustomer.RossoGargano)) {
|
||||||
|
executeStatement(
|
||||||
|
"UPDATE mtb_lisv\n" +
|
||||||
|
"SET flag_primario = DEFAULT\n" +
|
||||||
|
"WHERE flag_primario = 0"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251106113104 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateFunction(
|
||||||
|
"pvm_getassortimentoClientePedane",
|
||||||
|
"CREATE FUNCTION [dbo].[pvm_getassortimentoClientePedane](\n" +
|
||||||
|
" @codAnag VARCHAR(5), @codVlis VARCHAR(5), @codVdes VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT,\n" +
|
||||||
|
" @pedane INT = 0\n" +
|
||||||
|
")\n" +
|
||||||
|
" RETURNS TABLE\n" +
|
||||||
|
" AS\n" +
|
||||||
|
" RETURN( /*\n" +
|
||||||
|
"\n" +
|
||||||
|
" declare @codAnag VARCHAR(5), @codVlis VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT\n" +
|
||||||
|
" set @codAnag = 'C3355'\n" +
|
||||||
|
" set @codVlis = 'C3355'\n" +
|
||||||
|
" set @dataValidita = '2023/04/04'\n" +
|
||||||
|
" set @viewPromo = 1;\n" +
|
||||||
|
" */\n" +
|
||||||
|
" WITH assortimento AS (SELECT vtb_griglia_art.cod_mart\n" +
|
||||||
|
" FROM vtb_clie\n" +
|
||||||
|
" INNER JOIN vtb_griglia ON vtb_clie.cod_griglia = vtb_griglia.cod_griglia\n" +
|
||||||
|
" INNER JOIN vtb_griglia_art\n" +
|
||||||
|
" ON vtb_griglia.cod_griglia = vtb_griglia_art.cod_griglia AND\n" +
|
||||||
|
" vtb_griglia.data_validita = vtb_griglia_art.data_validita\n" +
|
||||||
|
" WHERE vtb_clie.cod_anag = @codAnag\n" +
|
||||||
|
" AND vtb_griglia.data_validita = (SELECT MAX(g.data_validita)\n" +
|
||||||
|
" FROM vtb_griglia g\n" +
|
||||||
|
" WHERE g.cod_griglia = vtb_clie.cod_griglia\n" +
|
||||||
|
" AND g.data_validita <= ISNULL(@dataValidita, CAST(GETDATE() AS DATE)))),\n" +
|
||||||
|
" lisv AS (SELECT cod_vlis, cod_vlis AS cod_vlis_rif\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" WHERE cod_vlis_rif IS NULL\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT cod_vlis, cod_vlis_rif\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" WHERE cod_vlis_rif IS NOT NULL),\n" +
|
||||||
|
" listino AS (SELECT DISTINCT cod_mart, tipo_variazione\n" +
|
||||||
|
" FROM (SELECT lisv.cod_vlis,\n" +
|
||||||
|
" mtb_lisv.cod_mart,\n" +
|
||||||
|
" LAST_VALUE(CASE\n" +
|
||||||
|
" WHEN vtb_list_data.data_iniz IS NULL THEN NULL\n" +
|
||||||
|
" ELSE mtb_lisv_data.tipo_variazione END)\n" +
|
||||||
|
" OVER (PARTITION BY lisv.cod_vlis, mtb_lisv.cod_mart\n" +
|
||||||
|
" ORDER BY vtb_list_data.data_iniz, CASE WHEN vtb_list_data.cod_promo IS NULL THEN 0 ELSE 1 END, vtb_list_data.versione\n" +
|
||||||
|
" RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS tipo_variazione\n" +
|
||||||
|
" FROM lisv\n" +
|
||||||
|
" INNER JOIN mtb_lisv ON lisv.cod_vlis_rif = mtb_lisv.cod_vlis\n" +
|
||||||
|
" INNER JOIN mtb_lisv_data ON mtb_lisv.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||||
|
" mtb_lisv.cod_mart = mtb_lisv_data.cod_mart\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_list_data\n" +
|
||||||
|
" ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||||
|
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
|
||||||
|
" vtb_list_data.data_iniz <=\n" +
|
||||||
|
" ISNULL(@dataValidita, CAST(GETDATE() AS DATE))\n" +
|
||||||
|
" WHERE lisv.cod_vlis = @codVlis\n" +
|
||||||
|
" AND NOT EXISTS(SELECT cod_mart FROM assortimento)) t\n" +
|
||||||
|
" WHERE (t.tipo_variazione IS NULL OR t.tipo_variazione <> 'D')),\n" +
|
||||||
|
" tmp_lisv AS (SELECT l.cod_mart,\n" +
|
||||||
|
" l.cod_vlis,\n" +
|
||||||
|
" ISNULL(p.data_iniz, l.data_iniz) AS data_iniz,\n" +
|
||||||
|
" p.data_fine,\n" +
|
||||||
|
" l.da,\n" +
|
||||||
|
" l.a,\n" +
|
||||||
|
" ISNULL(p.prz_vend, l.prz_vend_trasp) AS prz_vend,\n" +
|
||||||
|
" ISNULL(p.prz_vend_netto, l.prz_vend_trasp_netto) AS prz_vend_netto,\n" +
|
||||||
|
" ISNULL(p.perc_sco1, l.perc_sco1) AS perc_sco1,\n" +
|
||||||
|
" ISNULL(p.perc_sco2, l.perc_sco2) AS perc_sco2,\n" +
|
||||||
|
" ISNULL(p.perc_sco3, l.perc_sco3) AS perc_sco3,\n" +
|
||||||
|
" ISNULL(p.perc_sco4, l.perc_sco4) AS perc_sco4,\n" +
|
||||||
|
" p.perc_prov,\n" +
|
||||||
|
" CONVERT(NUMERIC(20, 5), 0) AS qta_residua,\n" +
|
||||||
|
" CONVERT(BIGINT, NULL) AS id_contratto,\n" +
|
||||||
|
" ISNULL(p.rap_conv, l.rap_conv) AS rap_conv,\n" +
|
||||||
|
" ISNULL(p.note, l.note) AS note,\n" +
|
||||||
|
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||||
|
" l.cod_tcol_ul AS cod_tcol_ul,\n" +
|
||||||
|
" ISNULL(p.unt_mis_ven, l.unt_mis_ven) AS unt_mis_ven,\n" +
|
||||||
|
" l.colli_pedana AS colli_pedana,\n" +
|
||||||
|
" ISNULL(p.tipo_variazione, l.tipo_variazione) AS tipo_variazione,\n" +
|
||||||
|
" CONVERT(VARCHAR(1), CASE\n" +
|
||||||
|
" WHEN p.cod_promo IS NULL THEN NULL\n" +
|
||||||
|
" ELSE 'P' END) AS tipo_promo,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||||
|
" l.porto,\n" +
|
||||||
|
" l.qta_cnf,\n" +
|
||||||
|
" NULL AS note_incoterms,\n" +
|
||||||
|
" NULL AS data_rif_scad,\n" +
|
||||||
|
" NULL AS note_carico,\n" +
|
||||||
|
" NULL AS term_cons,\n" +
|
||||||
|
" NULL AS cod_banc,\n" +
|
||||||
|
" NULL AS descr_banc,\n" +
|
||||||
|
" l.flag_primario\n" +
|
||||||
|
" FROM dbo.getListinoVenditaPedane(@dataValidita, @codVlis, NULL, @pedane) l\n" +
|
||||||
|
" LEFT OUTER JOIN dbo.getPromozioneVendita(@dataValidita, @dataValidita,\n" +
|
||||||
|
" @codVlis, NULL, NULL) p\n" +
|
||||||
|
" ON l.cod_vlis = p.cod_vlis AND l.cod_mart = p.cod_mart AND\n" +
|
||||||
|
" ISNULL(@viewPromo, 0) = 1\n" +
|
||||||
|
" WHERE l.cod_vlis = @codVlis\n" +
|
||||||
|
" AND l.cod_mart IN (SELECT cod_mart\n" +
|
||||||
|
" FROM assortimento\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT cod_mart\n" +
|
||||||
|
" FROM listino)\n" +
|
||||||
|
" AND l.tipo_variazione <> 'D'\n" +
|
||||||
|
" AND l.tipo_variazione IS NOT NULL\n" +
|
||||||
|
" AND l.flag_attivo = 'S'\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT l.cod_mart,\n" +
|
||||||
|
" l.cod_vlis,\n" +
|
||||||
|
" NULL AS data_iniz,\n" +
|
||||||
|
" NULL AS data_fine,\n" +
|
||||||
|
" NULL AS da,\n" +
|
||||||
|
" NULL AS a,\n" +
|
||||||
|
" NULL AS prz_vend,\n" +
|
||||||
|
" NULL AS prz_vend_netto,\n" +
|
||||||
|
" NULL AS perc_sco1,\n" +
|
||||||
|
" NULL AS perc_sco2,\n" +
|
||||||
|
" NULL AS perc_sco3,\n" +
|
||||||
|
" NULL AS perc_sco4,\n" +
|
||||||
|
" NULL AS perc_prov,\n" +
|
||||||
|
" NULL AS qta_residua,\n" +
|
||||||
|
" NULL AS id_contratto,\n" +
|
||||||
|
" um.rap_conv AS rap_conv,\n" +
|
||||||
|
" NULL AS note,\n" +
|
||||||
|
" CAST(NULL AS VARCHAR(5)) AS cod_vdes,\n" +
|
||||||
|
" NULL AS cod_tcol_ul,\n" +
|
||||||
|
" l.unt_mis_ven AS unt_mis_ven,\n" +
|
||||||
|
" NULL AS colli_pedana,\n" +
|
||||||
|
" NULL AS tipo_variazione,\n" +
|
||||||
|
" NULL AS tipo_promo,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS cod_paga,\n" +
|
||||||
|
" CONVERT(VARCHAR(5), NULL) AS descr_paga,\n" +
|
||||||
|
" NULL porto,\n" +
|
||||||
|
" mtb_aart.qta_cnf,\n" +
|
||||||
|
" NULL AS note_incoterms,\n" +
|
||||||
|
" NULL AS data_rif_scad,\n" +
|
||||||
|
" NULL AS note_carico,\n" +
|
||||||
|
" NULL AS term_cons,\n" +
|
||||||
|
" NULL AS cod_banc,\n" +
|
||||||
|
" NULL AS descr_banc,\n" +
|
||||||
|
" 1 AS flag_primario\n" +
|
||||||
|
" FROM mtb_lisv l\n" +
|
||||||
|
" INNER JOIN listino ON l.cod_mart = listino.cod_mart\n" +
|
||||||
|
" INNER JOIN mtb_aart ON l.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" CROSS APPLY dbo.getUntMisArticolo(l.cod_mart, l.unt_mis_ven) um\n" +
|
||||||
|
" WHERE l.cod_vlis = @codVlis\n" +
|
||||||
|
" AND listino.tipo_variazione IS NULL\n" +
|
||||||
|
" UNION ALL\n" +
|
||||||
|
" SELECT vvw_contratti_vendita.cod_mart,\n" +
|
||||||
|
" NULL AS cod_vlis,\n" +
|
||||||
|
" vvw_contratti_vendita.data_iniz,\n" +
|
||||||
|
" vvw_contratti_vendita.data_fine,\n" +
|
||||||
|
" NULL AS da,\n" +
|
||||||
|
" NULL AS a,\n" +
|
||||||
|
" vvw_contratti_vendita.prz_vend,\n" +
|
||||||
|
" ROUND(vvw_contratti_vendita.prz_vend *\n" +
|
||||||
|
" (1 - ISNULL(vvw_contratti_vendita.perc_sco1, 0))\n" +
|
||||||
|
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco2, 0))\n" +
|
||||||
|
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco3, 0))\n" +
|
||||||
|
" * (1 - ISNULL(vvw_contratti_vendita.perc_sco4, 0)),\n" +
|
||||||
|
" 5) AS prz_vend_netto,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco1,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco2,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco3,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_sco4,\n" +
|
||||||
|
" vvw_contratti_vendita.perc_prov,\n" +
|
||||||
|
" vvw_contratti_vendita.qta_residua,\n" +
|
||||||
|
" vvw_contratti_vendita.id_contratto,\n" +
|
||||||
|
" vvw_contratti_vendita.rap_conv,\n" +
|
||||||
|
" vvw_contratti_vendita.note,\n" +
|
||||||
|
" vvw_contratti_vendita.cod_vdes,\n" +
|
||||||
|
" NULL,\n" +
|
||||||
|
" vvw_contratti_vendita.unt_mis_ven,\n" +
|
||||||
|
" NULL,\n" +
|
||||||
|
" NULL,\n" +
|
||||||
|
" 'C' AS tipo_promo,\n" +
|
||||||
|
" vvw_contratti_vendita.cod_paga,\n" +
|
||||||
|
" vvw_contratti_vendita.descrizione_paga AS descr_paga,\n" +
|
||||||
|
" vvw_contratti_vendita.incoterms AS porto,\n" +
|
||||||
|
" mtb_aart.qta_cnf,\n" +
|
||||||
|
" vvw_contratti_vendita.note_incoterms,\n" +
|
||||||
|
" vvw_contratti_vendita.data_rif_scad,\n" +
|
||||||
|
" vvw_contratti_vendita.note_carico,\n" +
|
||||||
|
" vvw_contratti_vendita.term_cons,\n" +
|
||||||
|
" vvw_contratti_vendita.cod_banc,\n" +
|
||||||
|
" vvw_contratti_vendita.descr_banc,\n" +
|
||||||
|
" 1 AS flag_primario\n" +
|
||||||
|
" FROM vvw_contratti_vendita\n" +
|
||||||
|
" INNER JOIN mtb_aart ON vvw_contratti_vendita.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" WHERE vvw_contratti_vendita.cod_anag = @codAnag\n" +
|
||||||
|
" AND (@codVdes IS NULL OR vvw_contratti_vendita.cod_vdes IS NULL OR\n" +
|
||||||
|
" vvw_contratti_vendita.cod_vdes = @codVdes)\n" +
|
||||||
|
" AND (ISNULL(@dataValidita, CAST(GETDATE() AS DATE)) BETWEEN\n" +
|
||||||
|
" vvw_contratti_vendita.data_iniz AND vvw_contratti_vendita.data_fine)\n" +
|
||||||
|
"-- AND vvw_contratti_vendita.qta_residua >= 0\n" +
|
||||||
|
" )\n" +
|
||||||
|
"\n" +
|
||||||
|
" SELECT tmp_lisv.cod_mart,\n" +
|
||||||
|
" ISNULL(maa.cod_mart_anag, tmp_lisv.cod_mart) AS cod_mart_anag,\n" +
|
||||||
|
" cod_vlis,\n" +
|
||||||
|
" data_iniz,\n" +
|
||||||
|
" data_fine,\n" +
|
||||||
|
" da,\n" +
|
||||||
|
" a,\n" +
|
||||||
|
" prz_vend,\n" +
|
||||||
|
" prz_vend_netto,\n" +
|
||||||
|
" perc_sco1,\n" +
|
||||||
|
" perc_sco2,\n" +
|
||||||
|
" perc_sco3,\n" +
|
||||||
|
" perc_sco4,\n" +
|
||||||
|
" perc_prov,\n" +
|
||||||
|
" qta_residua,\n" +
|
||||||
|
" id_contratto,\n" +
|
||||||
|
" rap_conv,\n" +
|
||||||
|
" ISNULL(maa.note, tmp_lisv.note) AS note,\n" +
|
||||||
|
" cod_tcol_ul,\n" +
|
||||||
|
" unt_mis_ven,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN maa.colli_pedana IS NULL OR maa.colli_pedana = 0 THEN tmp_lisv.colli_pedana\n" +
|
||||||
|
" ELSE maa.colli_pedana END AS colli_pedana,\n" +
|
||||||
|
" tipo_variazione,\n" +
|
||||||
|
" tipo_promo,\n" +
|
||||||
|
" cod_paga,\n" +
|
||||||
|
" descr_paga,\n" +
|
||||||
|
" porto,\n" +
|
||||||
|
" qta_cnf,\n" +
|
||||||
|
" CAST(CASE WHEN tmp_lisv.data_iniz IS NULL THEN 0 ELSE 1 END AS BIT) AS art_lisv,\n" +
|
||||||
|
" cod_vdes,\n" +
|
||||||
|
" note_incoterms,\n" +
|
||||||
|
" data_rif_scad,\n" +
|
||||||
|
" note_carico,\n" +
|
||||||
|
" term_cons,\n" +
|
||||||
|
" cod_banc,\n" +
|
||||||
|
" descr_banc,\n" +
|
||||||
|
" flag_primario\n" +
|
||||||
|
" FROM tmp_lisv\n" +
|
||||||
|
" LEFT OUTER JOIN mtb_aart_anag maa\n" +
|
||||||
|
" ON tmp_lisv.cod_mart = maa.cod_mart AND maa.cod_anag = @codAnag)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251107132252 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
createSetup("PICKING", "ACCETTAZIONE", "FLAG_VIEW_LOTTO", "N",
|
||||||
|
"In inserimento articolo propone il lotto presente nella riga dell'ordine", false, "SI_NO", false, false,
|
||||||
|
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251107150055 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("update ctb_rit_acc set num_cmov_fat = null\n" +
|
||||||
|
"where num_cmov_fat is not null and num_cmov_fat not in (select num_cmov from ctb_movt )\n",
|
||||||
|
"update ctb_rit_acc set num_cmov_paga = null\n" +
|
||||||
|
"where num_cmov_paga is not null and num_cmov_paga not in (select num_cmov from ctb_movt )\n" ,
|
||||||
|
"update ctb_beni set num_cmov_acq = null\n" +
|
||||||
|
"where num_cmov_acq is not null and num_cmov_acq not in (select num_cmov from ctb_movt )\n",
|
||||||
|
"alter table ctb_rit_acc add constraint fk_ctb_rit_acc_ctb_movt_fat foreign key ( num_cmov_fat ) references ctb_movt ( num_cmov )\n" ,
|
||||||
|
"alter table ctb_rit_acc add constraint fk_ctb_rit_acc_ctb_movt_paga foreign key ( num_cmov_paga ) references ctb_movt ( num_cmov )\n" ,
|
||||||
|
"alter table ctb_beni add constraint fk_ctb_beni_ctb_movt foreign key ( num_cmov_acq ) references ctb_movt ( num_cmov )\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251110095557 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup("PVM","MRP", "COD_MDEP_PREF", null, "Inserire la lista dei depositi preselezionati per utente",
|
||||||
|
"COD_MDEP", true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.utility.UtilityQuery;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20251110100959 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (!isCustomerDb(IntegryCustomerDB.Carelli_Winact))
|
||||||
|
return;
|
||||||
|
|
||||||
|
final List<String> duplicatedBarcodes = executeQueryOnlyFirstColumn("SELECT cod_barre\n" +
|
||||||
|
"FROM mtb_aart_bar_code\n" +
|
||||||
|
"GROUP BY cod_barre\n" +
|
||||||
|
"HAVING COUNT(cod_barre) > 1");
|
||||||
|
|
||||||
|
executeStatement("DELETE FROM dbo.mtb_aart_bar_code\n" +
|
||||||
|
"WHERE cod_barre IN (" + UtilityQuery.concatStringFieldsWithSeparator(duplicatedBarcodes, ",") + ")");
|
||||||
|
|
||||||
|
|
||||||
|
executeStatement("ALTER TABLE dbo.mtb_aart_bar_code\n" +
|
||||||
|
" ALTER COLUMN cod_mart VARCHAR(15) NOT NULL",
|
||||||
|
"ALTER TABLE dbo.mtb_aart_bar_code\n" +
|
||||||
|
" ALTER COLUMN cod_barre VARCHAR(40) NOT NULL",
|
||||||
|
"ALTER TABLE dbo.mtb_aart_bar_code\n" +
|
||||||
|
" ADD CONSTRAINT pk_mtb_aart_bar_code\n" +
|
||||||
|
" PRIMARY KEY (cod_mart, cod_barre)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251110104131 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(
|
||||||
|
"ALTER TABLE dbo.vtb_viaggi\n" +
|
||||||
|
" ALTER COLUMN note_incoterms VARCHAR(40) NULL;"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251110111625 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetupQuery(null, null, "SELECT '1|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa)' UNION SELECT '2|Prezzo netto d''acquisto e ricalcola ricarica (Prezzo di vendita fisso)' UNION SELECT '3|Prezzo netto d''acquisto e prezzo di vendita da prezzo lordo d''acquisto (Ricalcola ricarica)' UNION SELECT '4|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa da Testata listino)' UNION SELECT '5|Prezzo netto d''acquisto, prezzo di vendita e ricarica fissa (Non ricalcolare prezzo)' UNION SELECT '6|Prezzo netto d''acquisto, prezzo di vendita = Prezzo Vendita Suggerito' UNION SELECT '7|Non ricalcolare il prezzo' ");
|
||||||
|
createSetup("VTB_LIST", "LISV4LISA", "CALC_PRZ_BASE", null,
|
||||||
|
"SELEZIONARE IL CRITERIO DI CALCOLO DEL PREZZO BASE", false, null, false, false,
|
||||||
|
false, false, false, null, false, "SELECT '1|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa)' UNION SELECT '2|Prezzo netto d''acquisto e ricalcola ricarica (Prezzo di vendita fisso)' UNION SELECT '3|Prezzo netto d''acquisto e prezzo di vendita da prezzo lordo d''acquisto (Ricalcola ricarica)' UNION SELECT '4|Prezzo netto d''acquisto e ricalcola il prezzo di vendita (Ricarica fissa da Testata listino)' UNION SELECT '5|Prezzo netto d''acquisto, prezzo di vendita e ricarica fissa (Non ricalcolare prezzo)' UNION SELECT '6|Prezzo netto d''acquisto, prezzo di vendita = Prezzo Vendita Suggerito' UNION SELECT '7|Non ricalcolare il prezzo' ");
|
||||||
|
if (isCustomer(IntegryCustomer.Carelli))
|
||||||
|
updateSetupValue("VTB_LIST", "LISV4LISA", "CALC_PRZ_BASE","1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251110175256 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("alter table vtb_list add tipo_um tinyint");
|
||||||
|
createOrUpdateFunction("getListinoVendita","CREATE FUNCTION [dbo].[getListinoVendita](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15))\n" +
|
||||||
|
" RETURNS TABLE AS\n" +
|
||||||
|
" RETURN\n" +
|
||||||
|
" SELECT vtb_list.cod_vlis,\n" +
|
||||||
|
" vtb_list.descrizione,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN tmp_list.max_lisv IS NULL THEN NULL\n" +
|
||||||
|
" ELSE CONVERT(DATETIME, LEFT(tmp_list.max_lisv, 10)) END AS data_iniz,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN tmp_list.max_lisv IS NULL THEN NULL\n" +
|
||||||
|
" ELSE CONVERT(INT, RIGHT(tmp_list.max_lisv, 4)) END AS versione,\n" +
|
||||||
|
" vtb_list.cod_divi,\n" +
|
||||||
|
" vtb_list.cambio,\n" +
|
||||||
|
" vtb_list.flag_arr_prz_iva,\n" +
|
||||||
|
" vtb_list.arr_ric,\n" +
|
||||||
|
" vtb_list.flag_list_iva_inclusa,\n" +
|
||||||
|
" vtb_list.flag_lisv_margine,\n" +
|
||||||
|
" vtb_list.flag_add_trasp,\n" +
|
||||||
|
" tmp_list.cod_mart AS 'cod_mart',\n" +
|
||||||
|
" mtb_lisv_data.unt_mis_ven AS unt_mis_ven,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.rap_conv, 1) AS rap_conv,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.prz_base, 0) AS prz_base,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.ricarica, 0) AS ricarico,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_lisv_data.prz_vend IS NOT NULL AND mtb_lisv_data.prz_vend <> 0 THEN\n" +
|
||||||
|
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.prz_vend, 0) * 100, 2)\n" +
|
||||||
|
" ELSE 0 END AS margine_eff,\n" +
|
||||||
|
" --dbo.f_calcMargineEffettivo(IsNull(mtb_lisv_data.prz_base, 0), IsNull(mtb_lisv_data.prz_vend, 0), mtb_aart.perc_sfrido) as margine_eff,\n" +
|
||||||
|
" --dbo.f_calcRicaricoEffettivo(IsNull(mtb_lisv_data.prz_base, 0), IsNull(mtb_lisv_data.prz_vend, 0), mtb_aart.perc_sfrido) ricarico_eff, \n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_lisv_data.prz_base IS NOT NULL AND mtb_lisv_data.prz_base <> 0 THEN\n" +
|
||||||
|
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100)) * 100, 2)\n" +
|
||||||
|
" ELSE 0 END AS ricarico_eff,\n" +
|
||||||
|
"\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.magg_prz_vend, 0) AS magg_prz_vend,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.prz_vend, 0) AS prz_vend,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.prz_vend_iva, 0) AS prz_vend_iva,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_sco1, 0) AS perc_sco1,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_sco2, 0) AS perc_sco2,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_sco3, 0) AS perc_sco3,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_sco4, 0) AS perc_sco4,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_prov, 0) AS perc_prov,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.fisso_prov, 0) AS fisso_prov,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.posizione, '') AS posizione,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_gest, 0) AS perc_gest,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.val_gest, 0) AS val_gest,\n" +
|
||||||
|
" mtb_lisv_data.data_agg_prz AS data_agg_prz,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_ispe, 0) AS perc_ispe,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.val_ispe, 0) AS val_ispe,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_promo, 0) AS perc_promo,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.val_promo, 0) AS val_promo,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.perc_oneri, 0) AS perc_oneri,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.val_oneri, 0) AS val_oneri,\n" +
|
||||||
|
" mtb_lisv_data.tipo_variazione AS tipo_variazione,\n" +
|
||||||
|
" mtb_lisv_data.note AS note,\n" +
|
||||||
|
" mtb_lisv_data.aggiornato_da AS aggiornato_da,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend * (1 - mtb_lisv_data.perc_sco1 / 100) * (1 - mtb_lisv_data.perc_sco2 / 100) *\n" +
|
||||||
|
" (1 - mtb_lisv_data.perc_sco3 / 100) *\n" +
|
||||||
|
" (1 - mtb_lisv_data.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN ISNULL(mtb_lisv_data.colli_pedana, 0) <> 0 THEN mtb_lisv_data.colli_pedana\n" +
|
||||||
|
" ELSE mtb_aart.colli_pedana END AS colli_pedana,\n" +
|
||||||
|
" mtb_lisv_data.cod_tcol_ul AS cod_tcol_ul,\n" +
|
||||||
|
" mtb_lisv_data.cod_tcol_ui AS cod_tcol_ui,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.prz_vend_sug, 0) AS prz_vend_sug,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN ISNULL(mtb_lisv_data.qta_cnf, 0) <> 0\n" +
|
||||||
|
" AND dbo.getGestSetup('VTB_LIST', 'SETUP', 'QTA_CNF_LISTINO') = 'S' \n" +
|
||||||
|
" THEN mtb_lisv_data.qta_cnf\n" +
|
||||||
|
" ELSE mtb_aart.qta_cnf / ISNULL(mtb_lisv_data.rap_conv, 1) END AS qta_cnf,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN ISNULL(mtb_lisv_data.colli_strato, 0) <> 0 THEN mtb_lisv_data.colli_strato\n" +
|
||||||
|
" ELSE mtb_aart.colli_strato END AS colli_strato,\n" +
|
||||||
|
" mtb_lisv_data.descrizione_html AS descrizione_html,\n" +
|
||||||
|
" mtb_lisv_data.colli_pedana AS colli_pedana_lisv,\n" +
|
||||||
|
" mtb_lisv_data.qta_cnf AS qta_cnf_lisv,\n" +
|
||||||
|
" mtb_lisv_data.colli_strato AS colli_strato_lisv,\n" +
|
||||||
|
" mtb_lisv_data.sconto_cartoni,\n" +
|
||||||
|
" mtb_lisv_data.sconto_strato,\n" +
|
||||||
|
" mtb_lisv_data.sconto_pedane,\n" +
|
||||||
|
" vtb_list.flag_attivo,\n" +
|
||||||
|
" vtb_list_data.note AS note_testata,\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.flag_prz_bloccato, 'N') AS flag_prz_bloccato,\n" +
|
||||||
|
" vtb_list_data.porto AS porto,\n" +
|
||||||
|
" mtb_lisv_data.system_note,\n" +
|
||||||
|
" mtb_lisv.add_val_spese,\n" +
|
||||||
|
" mtb_lisv.add_ric_spese,\n" +
|
||||||
|
" mtb_lisv.add_sco_spese,\n" +
|
||||||
|
"\t\t\t mtb_aart.flag_incl_listino,\n" +
|
||||||
|
"\t\t\t mtb_lisv.flag_primario,\n" +
|
||||||
|
"\t\t\t mtb_aart.id_art_equi,\n" +
|
||||||
|
"\t\t\t vtb_list.tipo_um\n" +
|
||||||
|
" FROM (SELECT vtb_list.cod_vlis AS cod_vlis,\n" +
|
||||||
|
" mtb_lisv_data.cod_mart,\n" +
|
||||||
|
" MAX(CASE\n" +
|
||||||
|
" WHEN vtb_list_data.versione IS NULL THEN NULL\n" +
|
||||||
|
" ELSE CONVERT(VARCHAR(10), vtb_list_data.data_iniz, 111) + ' ' +\n" +
|
||||||
|
" REPLICATE('0', 5 - LEN(vtb_list_data.versione)) +\n" +
|
||||||
|
" CONVERT(VARCHAR(5), vtb_list_data.versione) END) AS max_lisv,\n" +
|
||||||
|
" vtb_list.cod_vlis AS 'cod_vlis_rif'\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" INNER JOIN mtb_lisv_data ON vtb_list.cod_vlis = mtb_lisv_data.cod_vlis\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_list_data ON mtb_lisv_data.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||||
|
" mtb_lisv_data.versione = vtb_list_data.versione AND\n" +
|
||||||
|
" vtb_list_data.cod_promo IS NULL AND\n" +
|
||||||
|
" vtb_list_data.data_iniz <= ISNULL(@datavalidita, GETDATE())\n" +
|
||||||
|
" WHERE vtb_list.cod_vlis_rif IS NULL\n" +
|
||||||
|
" GROUP BY vtb_list.cod_vlis,\n" +
|
||||||
|
" mtb_lisv_data.cod_mart\n" +
|
||||||
|
" UNION\n" +
|
||||||
|
" SELECT vtb_list.cod_vlis AS cod_vlis,\n" +
|
||||||
|
" mtb_lisv_data.cod_mart,\n" +
|
||||||
|
" MAX(CASE\n" +
|
||||||
|
" WHEN vtb_list_data.versione IS NULL THEN NULL\n" +
|
||||||
|
" ELSE CONVERT(VARCHAR(10), vtb_list_data.data_iniz, 111) + ' ' +\n" +
|
||||||
|
" REPLICATE('0', 5 - LEN(vtb_list_data.versione_rif)) +\n" +
|
||||||
|
" CONVERT(VARCHAR(5), vtb_list_data.versione_rif) END) AS max_lisv,\n" +
|
||||||
|
" vtb_list.cod_vlis_rif AS 'cod_vlis_rif'\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" INNER JOIN vtb_list_data ON vtb_list.cod_vlis = vtb_list_data.cod_vlis\n" +
|
||||||
|
" INNER JOIN vtb_list_data vtb_list_data_rif\n" +
|
||||||
|
" ON vtb_list_data.versione_rif = vtb_list_data_rif.versione AND\n" +
|
||||||
|
" vtb_list_data.cod_vlis_rif = vtb_list_data_rif.cod_vlis\n" +
|
||||||
|
" INNER JOIN mtb_lisv_data ON vtb_list_data_rif.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||||
|
" vtb_list_data_rif.versione = mtb_lisv_data.versione\n" +
|
||||||
|
"\n" +
|
||||||
|
" WHERE vtb_list_data.data_iniz <= ISNULL(@datavalidita, GETDATE())\n" +
|
||||||
|
" AND vtb_list.cod_vlis_rif IS NOT NULL\n" +
|
||||||
|
" GROUP BY vtb_list.cod_vlis,\n" +
|
||||||
|
" mtb_lisv_data.cod_mart,\n" +
|
||||||
|
" vtb_list.cod_vlis_rif) tmp_list\n" +
|
||||||
|
" INNER JOIN vtb_list ON vtb_list.cod_vlis = tmp_list.cod_vlis\n" +
|
||||||
|
" INNER JOIN mtb_lisv\n" +
|
||||||
|
" ON tmp_list.cod_vlis_rif = mtb_lisv.cod_vlis AND tmp_list.cod_mart = mtb_lisv.cod_mart\n" +
|
||||||
|
" INNER JOIN mtb_aart ON tmp_list.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" LEFT OUTER JOIN mtb_lisv_data ON tmp_list.cod_vlis_rif = mtb_lisv_data.cod_vlis AND\n" +
|
||||||
|
" tmp_list.cod_mart = mtb_lisv_data.cod_mart AND\n" +
|
||||||
|
" CONVERT(INT, RIGHT(tmp_list.max_lisv, 5)) = mtb_lisv_data.versione\n" +
|
||||||
|
" LEFT OUTER JOIN vtb_list_data ON tmp_list.cod_vlis = vtb_list_data.cod_vlis AND\n" +
|
||||||
|
" CONVERT(INT, RIGHT(tmp_list.max_lisv, 5)) = vtb_list_data.versione\n" +
|
||||||
|
"\n" +
|
||||||
|
" WHERE (@codmart IS NULL OR tmp_list.cod_mart = @codmart)\n" +
|
||||||
|
" AND (@codvlis IS NULL OR tmp_list.cod_vlis = @codvlis)\n");
|
||||||
|
|
||||||
|
createOrUpdateFunction("getListinoVenditaPedane","CREATE FUNCTION [dbo].[getListinoVenditaPedane](@datavalidita DATETIME, @codvlis VARCHAR(5), @codmart VARCHAR(15), @pedane INT)\n" +
|
||||||
|
" RETURNS TABLE AS\n" +
|
||||||
|
" RETURN\n" +
|
||||||
|
" WITH trasp AS (SELECT mtb_lisv_data_spese.cod_vlis,\n" +
|
||||||
|
" mtb_lisv_data_spese.versione,\n" +
|
||||||
|
" mtb_lisv_data_spese.cod_spes,\n" +
|
||||||
|
" mtb_lisv_data_spese.perc_ricarico,\n" +
|
||||||
|
" mtb_lisv_data_spese.val_ricarico,\n" +
|
||||||
|
" mtb_lisv_data_spese.perc_sconto,\n" +
|
||||||
|
" mtb_lisv_data_spese.da,\n" +
|
||||||
|
" mtb_lisv_data_spese.a\n" +
|
||||||
|
" FROM vtb_list_data\n" +
|
||||||
|
" --riga Sotto Aggiunta da Massimo 08/01/25 per non fare uscire i range pedane quando il prezzo non deve essere addizionato del costo dei trasporti\n" +
|
||||||
|
" --inner join vtb_list on vtb_list_data.cod_vlis = vtb_list.cod_vlis and vtb_list.flag_add_trasp = 1\n" +
|
||||||
|
" INNER JOIN mtb_lisv_data_spese\n" +
|
||||||
|
" ON vtb_list_data.cod_vlis = mtb_lisv_data_spese.cod_vlis AND\n" +
|
||||||
|
" vtb_list_data.versione = mtb_lisv_data_spese.versione\n" +
|
||||||
|
" CROSS APPLY (SELECT MAX(id_listino) AS max_id_listino\n" +
|
||||||
|
" FROM vtb_list_data t\n" +
|
||||||
|
" WHERE t.data_iniz <= ISNULL(@datavalidita, CAST(GETDATE() AS DATE))\n" +
|
||||||
|
" AND vtb_list_data.cod_vlis = t.cod_vlis) max_lisv\n" +
|
||||||
|
" WHERE vtb_list_data.id_listino = max_lisv.max_id_listino)\n" +
|
||||||
|
"\n" +
|
||||||
|
" SELECT list.cod_vlis,\n" +
|
||||||
|
" list.descrizione,\n" +
|
||||||
|
" list.data_iniz,\n" +
|
||||||
|
" list.versione,\n" +
|
||||||
|
" list.cod_divi,\n" +
|
||||||
|
" list.cambio,\n" +
|
||||||
|
" list.flag_arr_prz_iva,\n" +
|
||||||
|
" list.arr_ric,\n" +
|
||||||
|
" list.flag_list_iva_inclusa,\n" +
|
||||||
|
" list.flag_lisv_margine,\n" +
|
||||||
|
" list.flag_add_trasp,\n" +
|
||||||
|
" list.cod_mart,\n" +
|
||||||
|
" list.unt_mis_ven,\n" +
|
||||||
|
" list.rap_conv,\n" +
|
||||||
|
" list.prz_base,\n" +
|
||||||
|
" list.ricarico,\n" +
|
||||||
|
" list.margine_eff,\n" +
|
||||||
|
" list.ricarico_eff,\n" +
|
||||||
|
" list.magg_prz_vend,\n" +
|
||||||
|
" list.prz_vend,\n" +
|
||||||
|
" list.prz_vend_iva,\n" +
|
||||||
|
" list.perc_sco1,\n" +
|
||||||
|
" list.perc_sco2,\n" +
|
||||||
|
" list.perc_sco3,\n" +
|
||||||
|
" list.perc_sco4,\n" +
|
||||||
|
" list.perc_prov,\n" +
|
||||||
|
" list.fisso_prov,\n" +
|
||||||
|
" list.posizione,\n" +
|
||||||
|
" list.perc_gest,\n" +
|
||||||
|
" list.val_gest,\n" +
|
||||||
|
" list.data_agg_prz,\n" +
|
||||||
|
" list.perc_ispe,\n" +
|
||||||
|
" list.val_ispe,\n" +
|
||||||
|
" list.perc_promo,\n" +
|
||||||
|
" list.val_promo,\n" +
|
||||||
|
" list.perc_oneri,\n" +
|
||||||
|
" list.val_oneri,\n" +
|
||||||
|
" list.tipo_variazione,\n" +
|
||||||
|
" list.note,\n" +
|
||||||
|
" list.aggiornato_da,\n" +
|
||||||
|
" list.prz_vend_netto,\n" +
|
||||||
|
" list.colli_pedana,\n" +
|
||||||
|
" list.cod_tcol_ul,\n" +
|
||||||
|
" list.cod_tcol_ui,\n" +
|
||||||
|
" list.prz_vend_sug,\n" +
|
||||||
|
" list.qta_cnf,\n" +
|
||||||
|
" list.colli_strato,\n" +
|
||||||
|
" list.descrizione_html,\n" +
|
||||||
|
" list.colli_pedana_lisv,\n" +
|
||||||
|
" list.qta_cnf_lisv,\n" +
|
||||||
|
" list.colli_strato_lisv,\n" +
|
||||||
|
" list.sconto_cartoni,\n" +
|
||||||
|
" list.sconto_strato,\n" +
|
||||||
|
" list.sconto_pedane,\n" +
|
||||||
|
" list.flag_attivo,\n" +
|
||||||
|
" list.note_testata,\n" +
|
||||||
|
" list.flag_prz_bloccato,\n" +
|
||||||
|
" list.porto,\n" +
|
||||||
|
" list.system_note,\n" +
|
||||||
|
" list.add_val_spese,\n" +
|
||||||
|
" list.add_ric_spese,\n" +
|
||||||
|
" list.add_sco_spese,\n" +
|
||||||
|
" list.flag_incl_listino,\n" +
|
||||||
|
" list.flag_primario,\n" +
|
||||||
|
" list.id_art_equi,\n" +
|
||||||
|
" trasp.cod_spes,\n" +
|
||||||
|
" trasp.perc_ricarico,\n" +
|
||||||
|
" trasp.val_ricarico,\n" +
|
||||||
|
" trasp.perc_sconto,\n" +
|
||||||
|
" trasp.da,\n" +
|
||||||
|
" trasp.a,\n" +
|
||||||
|
" (list.prz_vend +\n" +
|
||||||
|
" IIF(list.flag_add_trasp = 1, --Questa condizione si potrebbe togliere per la modifica fatta l'8/01/25\n" +
|
||||||
|
" ((ISNULL(val_ricarico, 0)) * list.add_val_spese) /\n" +
|
||||||
|
" IIF(ISNULL(list.colli_pedana, 1) = 0, 1, list.colli_pedana), 0)) +\n" +
|
||||||
|
" ((ISNULL(perc_ricarico, 0) * list.add_ric_spese * list.prz_vend) / 100) *\n" +
|
||||||
|
" (1 - (ISNULL(perc_sconto, 0) * list.add_sco_spese) / 100) prz_vend_trasp,\n" +
|
||||||
|
" ((list.prz_vend +\n" +
|
||||||
|
" IIF(list.flag_add_trasp = 1, --Questa condizione si potrebbe togliere per la modifica fatta l'8/01/25\n" +
|
||||||
|
" ((ISNULL(val_ricarico, 0)) * list.add_val_spese) /\n" +
|
||||||
|
" IIF(ISNULL(list.colli_pedana, 1) = 0, 1, list.colli_pedana), 0)) +\n" +
|
||||||
|
" ((ISNULL(perc_ricarico, 0) * list.add_ric_spese * list.prz_vend) / 100) *\n" +
|
||||||
|
" (1 - (ISNULL(perc_sconto, 0) * list.add_sco_spese) / 100)) * (1 - list.perc_sco1 / 100) *\n" +
|
||||||
|
" (1 - list.perc_sco2 / 100) *\n" +
|
||||||
|
" (1 - list.perc_sco3 / 100) *\n" +
|
||||||
|
" (1 - list.perc_sco4 / 100) AS prz_vend_trasp_netto,\n" +
|
||||||
|
"\t\t\t list.tipo_um\n" +
|
||||||
|
" FROM getlistinovendita(@datavalidita, @codvlis, @codmart) list\n" +
|
||||||
|
" LEFT OUTER JOIN trasp ON list.cod_vlis = trasp.cod_vlis AND\n" +
|
||||||
|
" (@pedane IS NULL OR @pedane BETWEEN da AND a OR\n" +
|
||||||
|
" (@pedane IS NOT NULL AND da = 0 AND a = 0))");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.entity.StbGestSetup;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityList;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class Migration_20251110184508 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql = "SELECT DISTINCT wgsu.gest_name, wgsu.section, wgsu.key_section, 'S' AS flag_setup_user_web\n" +
|
||||||
|
"FROM wtb_gest_setup_user wgsu\n" +
|
||||||
|
"WHERE NOT EXISTS(SELECT sgs.gest_name, sgs.section, sgs.key_section\n" +
|
||||||
|
" FROM stb_gest_setup sgs\n" +
|
||||||
|
" WHERE wgsu.gest_name = sgs.gest_name\n" +
|
||||||
|
" AND wgsu.section = sgs.section\n" +
|
||||||
|
" AND wgsu.key_section = sgs.key_section)";
|
||||||
|
|
||||||
|
List<StbGestSetup> stbGestSetupsToCreate = UtilityDB.executeSimpleQueryDTO(connection, sql, StbGestSetup.class);
|
||||||
|
|
||||||
|
if (UtilityList.isNullOrEmpty(stbGestSetupsToCreate)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (StbGestSetup stbGestSetup : stbGestSetupsToCreate) {
|
||||||
|
stbGestSetup.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251111110443 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isCustomer(IntegryCustomer.Salpar)){
|
||||||
|
executeStatement("INSERT INTO stb_tipi_indirizzi\n" +
|
||||||
|
"VALUES ('PUNTO VENDITA', 'ABRW'),\n" +
|
||||||
|
" ('PUNTO VENDITA', 'ABTW'),\n" +
|
||||||
|
" ('PUNTO VENDITA', 'BAMW'),\n" +
|
||||||
|
" ('PUNTO VENDITA', 'BATW')");
|
||||||
|
|
||||||
|
executeStatement("UPDATE vtb_clie_pers_rif\n" +
|
||||||
|
"SET tipo_indirizzo = 'PUNTO VENDITA'\n" +
|
||||||
|
"WHERE tipo_indirizzo = 'UFFICIO ACQUISTI'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251111120322 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateFunction(
|
||||||
|
"pvm_getassortimentoCliente",
|
||||||
|
"CREATE FUNCTION [dbo].[pvm_getassortimentoCliente](\n" +
|
||||||
|
" @codAnag VARCHAR(5), @codVlis VARCHAR(5), @codVdes VARCHAR(5), @dataValidita DATETIME, @viewPromo BIT\n" +
|
||||||
|
")\n" +
|
||||||
|
" RETURNS TABLE AS\n" +
|
||||||
|
" RETURN(SELECT cod_mart,\n" +
|
||||||
|
" cod_mart_anag,\n" +
|
||||||
|
" cod_vlis,\n" +
|
||||||
|
" data_iniz,\n" +
|
||||||
|
" data_fine,\n" +
|
||||||
|
" da,\n" +
|
||||||
|
" a,\n" +
|
||||||
|
" prz_vend,\n" +
|
||||||
|
" prz_vend_netto,\n" +
|
||||||
|
" perc_sco1,\n" +
|
||||||
|
" perc_sco2,\n" +
|
||||||
|
" perc_sco3,\n" +
|
||||||
|
" perc_sco4,\n" +
|
||||||
|
" perc_prov,\n" +
|
||||||
|
" qta_residua,\n" +
|
||||||
|
" id_contratto,\n" +
|
||||||
|
" rap_conv,\n" +
|
||||||
|
" note,\n" +
|
||||||
|
" cod_tcol_ul,\n" +
|
||||||
|
" unt_mis_ven,\n" +
|
||||||
|
" colli_pedana,\n" +
|
||||||
|
" tipo_variazione,\n" +
|
||||||
|
" tipo_promo,\n" +
|
||||||
|
" cod_paga,\n" +
|
||||||
|
" descr_paga,\n" +
|
||||||
|
" porto,\n" +
|
||||||
|
" qta_cnf,\n" +
|
||||||
|
" art_lisv,\n" +
|
||||||
|
" cod_vdes,\n" +
|
||||||
|
" note_incoterms,\n" +
|
||||||
|
" data_rif_scad,\n" +
|
||||||
|
" note_carico,\n" +
|
||||||
|
" term_cons,\n" +
|
||||||
|
" cod_banc,\n" +
|
||||||
|
" descr_banc,\n" +
|
||||||
|
" flag_primario\n" +
|
||||||
|
" FROM [dbo].pvm_getassortimentoClientePedane(\n" +
|
||||||
|
" @codAnag, @codVlis, @codVdes, @dataValidita, @viewPromo,\n" +
|
||||||
|
" DEFAULT))"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251111151102 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup("W_VEDI_DESADV_DLG", "SETUP", "VERSIONE_C2835", "20",
|
||||||
|
null, false, null, false, false,
|
||||||
|
false, false, false, null, false, null);
|
||||||
|
createSetup("W_VEDI_DESADV_DLG", "SETUP", "DTM_C2835", "137",
|
||||||
|
"Qualificatore data ora riferimento (Data documento), per default è impostato a 2", false, null, false, false,
|
||||||
|
false, false, false, null, false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.entity.JtbCiclCq;
|
||||||
|
import it.integry.ems_model.entity._enum.TipoValore;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityInteger;
|
||||||
|
import it.integry.ems_model.utility.UtilityList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20251111170814 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!isCustomerDb(IntegryCustomerDB.Gramm_Gramm))
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
String sql = "select distinct jtb_cicl.cod_prod,MAX(jtb_cicl_cq.num_fase) as num_fase,max(jtb_cicl_cq.id_riga) as id_riga\n" +
|
||||||
|
"from jtb_dist_clav_dir dir\n" +
|
||||||
|
" inner join jtb_cicl on dir.cod_prod = jtb_cicl.cod_prod\n" +
|
||||||
|
" left outer join jtb_cicl_cq on jtb_cicl.cod_prod = jtb_cicl_cq.cod_prod\n" +
|
||||||
|
"where dir.cod_jfas like 'SC%'\n" +
|
||||||
|
" and jtb_cicl.flag_attiva = 'S'\n" +
|
||||||
|
"group by jtb_cicl.cod_prod";
|
||||||
|
|
||||||
|
List<JtbCiclCq> distinteDaAggiornare = UtilityDB.executeSimpleQueryDTO(connection, sql, JtbCiclCq.class);
|
||||||
|
if (UtilityList.isNullOrEmpty(distinteDaAggiornare))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (JtbCiclCq jtbCiclCq : distinteDaAggiornare) {
|
||||||
|
jtbCiclCq.setIdRiga(UtilityInteger.isNull(jtbCiclCq.getIdRiga(),0) + 1)
|
||||||
|
.setNumFase(UtilityInteger.isNull(jtbCiclCq.getNumFase(),0))
|
||||||
|
.setControllo("Check Etichetta Cartone")
|
||||||
|
.setTipoValore(TipoValore.BOOLEAN)
|
||||||
|
.setValoreRif("S")
|
||||||
|
.setNumRip(0)
|
||||||
|
.setTipologia("DETAILED_CQ")
|
||||||
|
.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
jtbCiclCq.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251111171747 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateFunction("lisv_getTipoUm", "CREATE FUNCTION dbo.lisv_getTipoUm\n" +
|
||||||
|
"( \n" +
|
||||||
|
" @codMart varchar(15), @tipoUmLisv tinyint\n" +
|
||||||
|
")\n" +
|
||||||
|
"RETURNS TABLE \n" +
|
||||||
|
"AS\n" +
|
||||||
|
"RETURN \n" +
|
||||||
|
"(\n" +
|
||||||
|
" with um as (\n" +
|
||||||
|
"select cod_mart, unt_mis, rap_conv\n" +
|
||||||
|
"from dbo.getUntMisArticolo(@codMart, null ) um\n" +
|
||||||
|
"where @tipoUmLisv is not null\n" +
|
||||||
|
"and ( (@tipoUmLisv = 1 and um.tipo_um = 'UI' ) or \n" +
|
||||||
|
"(@tipoUmLisv = 2 and flag_unita_kg = 'S'))\n" +
|
||||||
|
")\n" +
|
||||||
|
"\n" +
|
||||||
|
"select mtb_aart.cod_mart, \n" +
|
||||||
|
"case \n" +
|
||||||
|
"when @tipoUmLisv IS null then mtb_aart.unt_mis\n" +
|
||||||
|
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf not in (0, 1) then mtb_aart.unt_mis\n" +
|
||||||
|
"when @tipoUmLisv = 2 and mtb_aart.peso_kg not in (0, 1) then mtb_aart.unt_mis\n" +
|
||||||
|
" else ISNULL(um.unt_mis, mtb_aart.unt_mis) end as unt_mis_ven, \n" +
|
||||||
|
"case \n" +
|
||||||
|
"when @tipoUmLisv IS null then 1\n" +
|
||||||
|
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf not in (0, 1) then 1\n" +
|
||||||
|
"when @tipoUmLisv = 2 and mtb_aart.peso_kg not in (0, 1) then 1\n" +
|
||||||
|
" else ISNULL(um.rap_conv, 1) end as rap_conv_vend\n" +
|
||||||
|
"from mtb_aart left outer join um on mtb_aart.cod_mart = um.cod_mart\n" +
|
||||||
|
"where (@codMart is null or mtb_aart.cod_mart = @codMart )\n" +
|
||||||
|
")");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251113102040 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("ALTER TABLE vtb_list_data ADD promo_chiusa bit DEFAULT 0 NOT NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251113105159 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("exec sp_rename 'vtb_list_data.promo_chiusa', 'chiusura_immediata'");
|
||||||
|
|
||||||
|
|
||||||
|
createOrUpdateFunction("getPromozioneVendita", "CREATE FUNCTION [dbo].[getPromozioneVendita](@dataIniz DATETIME, @dataFine DATETIME, @codVlis VARCHAR(5),\n" +
|
||||||
|
" @codPromo VARCHAR(10), @codMart VARCHAR(15))\n" +
|
||||||
|
" RETURNS TABLE AS\n" +
|
||||||
|
" RETURN\n" +
|
||||||
|
" SELECT vtb_list.cod_vlis,\n" +
|
||||||
|
" vtb_list.descrizione,\n" +
|
||||||
|
" vtb_list_data.data_iniz,\n" +
|
||||||
|
" vtb_list_data.data_fine,\n" +
|
||||||
|
" vtb_list_data.cod_promo,\n" +
|
||||||
|
" vtb_list_data.versione,\n" +
|
||||||
|
" vtb_list.cod_divi,\n" +
|
||||||
|
" vtb_list.flag_arr_prz_iva,\n" +
|
||||||
|
" vtb_list.arr_ric,\n" +
|
||||||
|
" vtb_list.flag_list_iva_inclusa,\n" +
|
||||||
|
" vtb_list.flag_lisv_margine,\n" +
|
||||||
|
" mtb_lisv_data.cod_mart AS cod_mart,\n" +
|
||||||
|
" mtb_lisv_data.unt_mis_ven AS unt_mis_ven,\n" +
|
||||||
|
" mtb_lisv_data.rap_conv AS rap_conv,\n" +
|
||||||
|
" mtb_lisv_data.prz_base AS prz_base,\n" +
|
||||||
|
" mtb_lisv_data.ricarica AS ricarico,\n" +
|
||||||
|
" --dbo.f_calcMargineEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as margine_eff,\n" +
|
||||||
|
" --dbo.f_calcRicaricoEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as ricarico_eff, \n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_lisv_data.prz_vend IS NOT NULL AND mtb_lisv_data.prz_vend <> 0 THEN\n" +
|
||||||
|
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.prz_vend, 0) * 100, 2)\n" +
|
||||||
|
" ELSE 0 END AS margine_eff,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_lisv_data.prz_base IS NOT NULL AND mtb_lisv_data.prz_base <> 0 THEN\n" +
|
||||||
|
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100)) * 100, 2)\n" +
|
||||||
|
" ELSE 0 END AS ricarico_eff,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend AS prz_vend,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend_iva AS prz_vend_iva,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco1 AS perc_sco1,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco2 AS perc_sco2,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco3 AS perc_sco3,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco4 AS perc_sco4,\n" +
|
||||||
|
" mtb_lisv_data.perc_prov AS perc_prov,\n" +
|
||||||
|
" mtb_lisv_data.fisso_prov AS fisso_prov,\n" +
|
||||||
|
" mtb_lisv_data.posizione AS posizione,\n" +
|
||||||
|
" mtb_lisv_data.perc_gest AS perc_gest,\n" +
|
||||||
|
" mtb_lisv_data.val_gest AS val_gest,\n" +
|
||||||
|
" mtb_lisv_data.data_agg_prz AS data_agg_prz,\n" +
|
||||||
|
" mtb_lisv_data.perc_ispe AS perc_ispe,\n" +
|
||||||
|
" mtb_lisv_data.val_ispe AS val_ispe,\n" +
|
||||||
|
" mtb_lisv_data.perc_promo AS perc_promo,\n" +
|
||||||
|
" mtb_lisv_data.val_promo AS val_promo,\n" +
|
||||||
|
" mtb_lisv_data.perc_oneri AS perc_oneri,\n" +
|
||||||
|
" mtb_lisv_data.val_oneri AS val_oneri,\n" +
|
||||||
|
" mtb_lisv_data.tipo_variazione AS tipo_variazione,\n" +
|
||||||
|
" mtb_lisv_data.note AS note,\n" +
|
||||||
|
" mtb_lisv_data.aggiornato_da AS aggiornato_da,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend * (1 - mtb_lisv_data.perc_sco1 / 100) * (1 - mtb_lisv_data.perc_sco2 / 100) *\n" +
|
||||||
|
" (1 - mtb_lisv_data.perc_sco3 / 100) * (1 - mtb_lisv_data.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||||
|
" vtb_promo.descrizione AS 'descr_promo',\n" +
|
||||||
|
" vtb_promo.data_iniz_sell_out,\n" +
|
||||||
|
" vtb_promo.data_fine_sell_out,\n" +
|
||||||
|
" vtb_promo.flag_tipo_promo,\n" +
|
||||||
|
" mtb_lisv_data.sconto_cartoni,\n" +
|
||||||
|
" mtb_lisv_data.sconto_strato,\n" +
|
||||||
|
" mtb_lisv_data.sconto_pedane,\n" +
|
||||||
|
" mtb_lisv_data.giacenza,\n" +
|
||||||
|
" mtb_lisv_data.magg_prz_vend,\n" +
|
||||||
|
" vtb_promo.flag_sconto_contrattuale,\n" +
|
||||||
|
" vtb_promo.intercode_xml_variazioni,\n" +
|
||||||
|
" vtb_list_data.note AS note_testata,\n" +
|
||||||
|
" vtb_promo.flag_tipologia,\n" +
|
||||||
|
" vtb_promo.flag_volantino,\n" +
|
||||||
|
" mtb_lisv_data.inserito_da,\n" +
|
||||||
|
" vtb_list_data.chiusura_immediata\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" INNER JOIN vtb_list_data ON vtb_list.cod_vlis = vtb_list_data.cod_vlis\n" +
|
||||||
|
" INNER JOIN mtb_lisv_data ON vtb_list_data.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||||
|
" vtb_list_data.versione = mtb_lisv_data.versione\n" +
|
||||||
|
" INNER JOIN mtb_aart ON mtb_lisv_data.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" INNER JOIN vtb_promo ON vtb_list_data.cod_promo = vtb_promo.cod_promo\n" +
|
||||||
|
" OUTER APPLY (SELECT COUNT(*) AS conta\n" +
|
||||||
|
" FROM vtb_list_data rif\n" +
|
||||||
|
" WHERE vtb_list_data.cod_vlis = rif.cod_vlis_rif\n" +
|
||||||
|
" AND vtb_list_data.versione = rif.versione) list_rif\n" +
|
||||||
|
" WHERE (@codMart IS NULL OR mtb_lisv_data.cod_mart = @codMart)\n" +
|
||||||
|
" AND (@codvlis IS NULL OR vtb_list_data.cod_vlis = @codVlis)\n" +
|
||||||
|
" AND vtb_list.cod_vlis_rif IS NULL\n" +
|
||||||
|
" AND (@codPromo IS NULL OR vtb_list_data.cod_promo = @codPromo)\n" +
|
||||||
|
" AND (((@dataFine IS NULL OR ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) = @dataFine) AND\n" +
|
||||||
|
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine) OR\n" +
|
||||||
|
" (@dataFine IS NOT NULL AND ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) <> @dataFine AND\n" +
|
||||||
|
" (vtb_list_data.data_iniz BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||||
|
" vtb_list_data.data_fine BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||||
|
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine OR\n" +
|
||||||
|
" @dataFine BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine)))\n" +
|
||||||
|
" AND (vtb_promo.flag_sconto_contrattuale = 'N' OR\n" +
|
||||||
|
" (vtb_promo.flag_sconto_contrattuale = 'S' AND list_rif.conta = 0))\n" +
|
||||||
|
" UNION\n" +
|
||||||
|
" SELECT vtb_list.cod_vlis,\n" +
|
||||||
|
" vtb_list.descrizione,\n" +
|
||||||
|
" vtb_list_data.data_iniz,\n" +
|
||||||
|
" vtb_list_data.data_fine,\n" +
|
||||||
|
" vtb_list_data.cod_promo,\n" +
|
||||||
|
" vtb_list_data.versione,\n" +
|
||||||
|
" vtb_list.cod_divi,\n" +
|
||||||
|
" vtb_list.flag_arr_prz_iva,\n" +
|
||||||
|
" vtb_list.arr_ric,\n" +
|
||||||
|
" vtb_list.flag_list_iva_inclusa,\n" +
|
||||||
|
" vtb_list.flag_lisv_margine,\n" +
|
||||||
|
" mtb_lisv_data.cod_mart AS cod_mart,\n" +
|
||||||
|
" mtb_lisv_data.unt_mis_ven AS unt_mis_ven,\n" +
|
||||||
|
" mtb_lisv_data.rap_conv AS rap_conv,\n" +
|
||||||
|
" mtb_lisv_data.prz_base AS prz_base,\n" +
|
||||||
|
" mtb_lisv_data.ricarica AS ricarico,\n" +
|
||||||
|
" --dbo.f_calcMargineEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as margine_eff,\n" +
|
||||||
|
" --dbo.f_calcRicaricoEffettivo(mtb_lisv_data.prz_base, mtb_lisv_data.prz_vend, mtb_aart.perc_sfrido) as ricarico_eff, \n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_lisv_data.prz_vend IS NOT NULL AND mtb_lisv_data.prz_vend <> 0 THEN\n" +
|
||||||
|
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||||
|
" ISNULL(mtb_lisv_data.prz_vend, 0) * 100, 2)\n" +
|
||||||
|
" ELSE 0 END AS margine_eff,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_lisv_data.prz_base IS NOT NULL AND mtb_lisv_data.prz_base <> 0 THEN\n" +
|
||||||
|
" ROUND((ISNULL(mtb_lisv_data.prz_vend, 0) -\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100))) /\n" +
|
||||||
|
" (ISNULL(mtb_lisv_data.prz_base, 0) / (1 - mtb_aart.perc_sfrido / 100)) * 100, 2)\n" +
|
||||||
|
" ELSE 0 END AS ricarico_eff,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend AS prz_vend,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend_iva AS prz_vend_iva,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco1 AS perc_sco1,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco2 AS perc_sco2,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco3 AS perc_sco3,\n" +
|
||||||
|
" mtb_lisv_data.perc_sco4 AS perc_sco4,\n" +
|
||||||
|
" mtb_lisv_data.perc_prov AS perc_prov,\n" +
|
||||||
|
" mtb_lisv_data.fisso_prov AS fisso_prov,\n" +
|
||||||
|
" mtb_lisv_data.posizione AS posizione,\n" +
|
||||||
|
" mtb_lisv_data.perc_gest AS perc_gest,\n" +
|
||||||
|
" mtb_lisv_data.val_gest AS val_gest,\n" +
|
||||||
|
" mtb_lisv_data.data_agg_prz AS data_agg_prz,\n" +
|
||||||
|
" mtb_lisv_data.perc_ispe AS perc_ispe,\n" +
|
||||||
|
" mtb_lisv_data.val_ispe AS val_ispe,\n" +
|
||||||
|
" mtb_lisv_data.perc_promo AS perc_promo,\n" +
|
||||||
|
" mtb_lisv_data.val_promo AS val_promo,\n" +
|
||||||
|
" mtb_lisv_data.perc_oneri AS perc_oneri,\n" +
|
||||||
|
" mtb_lisv_data.val_oneri AS val_oneri,\n" +
|
||||||
|
" mtb_lisv_data.tipo_variazione AS tipo_variazione,\n" +
|
||||||
|
" mtb_lisv_data.note AS note,\n" +
|
||||||
|
" mtb_lisv_data.aggiornato_da AS aggiornato_da,\n" +
|
||||||
|
" mtb_lisv_data.prz_vend * (1 - mtb_lisv_data.perc_sco1 / 100) * (1 - mtb_lisv_data.perc_sco2 / 100) *\n" +
|
||||||
|
" (1 - mtb_lisv_data.perc_sco3 / 100) * (1 - mtb_lisv_data.perc_sco4 / 100) AS prz_vend_netto,\n" +
|
||||||
|
" vtb_promo.descrizione AS 'descr_promo',\n" +
|
||||||
|
" vtb_promo.data_iniz_sell_out,\n" +
|
||||||
|
" vtb_promo.data_fine_sell_out,\n" +
|
||||||
|
" vtb_promo.flag_tipo_promo,\n" +
|
||||||
|
" mtb_lisv_data.sconto_cartoni,\n" +
|
||||||
|
" mtb_lisv_data.sconto_strato,\n" +
|
||||||
|
" mtb_lisv_data.sconto_pedane,\n" +
|
||||||
|
" mtb_lisv_data.giacenza,\n" +
|
||||||
|
" mtb_lisv_data.magg_prz_vend,\n" +
|
||||||
|
" vtb_promo.flag_sconto_contrattuale,\n" +
|
||||||
|
" vtb_promo.intercode_xml_variazioni,\n" +
|
||||||
|
" vtb_list_data.note AS note_testata,\n" +
|
||||||
|
" vtb_promo.flag_tipologia,\n" +
|
||||||
|
" vtb_promo.flag_volantino,\n" +
|
||||||
|
" mtb_lisv_data.inserito_da,\n" +
|
||||||
|
" vtb_list_data_rif.chiusura_immediata\n" +
|
||||||
|
" FROM vtb_list\n" +
|
||||||
|
" INNER JOIN vtb_list_data ON vtb_list.cod_vlis = vtb_list_data.cod_vlis\n" +
|
||||||
|
" INNER JOIN vtb_list_data vtb_list_data_rif\n" +
|
||||||
|
" ON vtb_list_data.cod_vlis_rif = vtb_list_data_rif.cod_vlis AND\n" +
|
||||||
|
" vtb_list_data.versione_rif = vtb_list_data_rif.versione\n" +
|
||||||
|
" INNER JOIN mtb_lisv_data ON vtb_list_data_rif.cod_vlis = mtb_lisv_data.cod_vlis AND\n" +
|
||||||
|
" vtb_list_data_rif.versione = mtb_lisv_data.versione\n" +
|
||||||
|
" INNER JOIN mtb_aart ON mtb_lisv_data.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" INNER JOIN vtb_promo ON vtb_list_data_rif.cod_promo = vtb_promo.cod_promo\n" +
|
||||||
|
" WHERE (@codMart IS NULL OR mtb_lisv_data.cod_mart = @codMart)\n" +
|
||||||
|
" AND (@codvlis IS NULL OR vtb_list_data.cod_vlis = @codVlis)\n" +
|
||||||
|
" AND (@codPromo IS NULL OR vtb_list_data.cod_promo = @codPromo)\n" +
|
||||||
|
" AND (((@dataFine IS NULL OR ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) = @dataFine) AND\n" +
|
||||||
|
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine) OR\n" +
|
||||||
|
" (@dataFine IS NOT NULL AND ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) <> @dataFine AND\n" +
|
||||||
|
" (vtb_list_data.data_iniz BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||||
|
" vtb_list_data.data_fine BETWEEN ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) AND @dataFine OR\n" +
|
||||||
|
" ISNULL(@dataIniz, CAST(GETDATE() AS DATE)) BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine OR\n" +
|
||||||
|
" @dataFine BETWEEN vtb_list_data.data_iniz AND vtb_list_data.data_fine)))");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251113122313 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateFunction("lisv_getTipoUm", "CREATE FUNCTION [dbo].[lisv_getTipoUm]\n" +
|
||||||
|
"(\t\n" +
|
||||||
|
"\t@codMart varchar(15), @tipoUmLisv tinyint\n" +
|
||||||
|
")\n" +
|
||||||
|
"RETURNS TABLE \n" +
|
||||||
|
"AS\n" +
|
||||||
|
"RETURN \n" +
|
||||||
|
"(\n" +
|
||||||
|
"\twith um as (\n" +
|
||||||
|
"select cod_mart, unt_mis, rap_conv\n" +
|
||||||
|
"from dbo.getUntMisArticolo(@codMart, null ) um\n" +
|
||||||
|
"where @tipoUmLisv is not null\n" +
|
||||||
|
"and ( (@tipoUmLisv = 1 and um.tipo_um = 'UI' ) or \n" +
|
||||||
|
"(@tipoUmLisv = 2 and flag_unita_kg = 'S'))\n" +
|
||||||
|
")\n" +
|
||||||
|
"\n" +
|
||||||
|
"select mtb_aart.cod_mart, \n" +
|
||||||
|
"case \n" +
|
||||||
|
"when @tipoUmLisv IS null then mtb_aart.unt_mis\n" +
|
||||||
|
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf in (0, 1) then mtb_aart.unt_mis\n" +
|
||||||
|
"when @tipoUmLisv = 2 and mtb_aart.peso_kg in (0, 1) then mtb_aart.unt_mis\n" +
|
||||||
|
"\telse ISNULL(um.unt_mis, mtb_aart.unt_mis) end as unt_mis_ven, \n" +
|
||||||
|
"case \n" +
|
||||||
|
"when @tipoUmLisv IS null then 1\n" +
|
||||||
|
"when @tipoUmLisv = 1 and mtb_aart.qta_cnf in (0, 1) then 1\n" +
|
||||||
|
"when @tipoUmLisv = 2 and mtb_aart.peso_kg in (0, 1) then 1\n" +
|
||||||
|
"\telse ISNULL(um.rap_conv, 1) end as rap_conv_vend\n" +
|
||||||
|
"from mtb_aart left outer join um on mtb_aart.cod_mart = um.cod_mart\n" +
|
||||||
|
"where (@codMart is null or mtb_aart.cod_mart = @codMart )\n" +
|
||||||
|
")");
|
||||||
|
|
||||||
|
executeStatement("alter table mtb_var_lisv_log alter column versione int null");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251113170159 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("ALTER TABLE wdtb_doct ADD merce_ricevuta BIT DEFAULT 0 NOT NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251114114334 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("ALTER TABLE ctb_amac DROP COLUMN cod_mdep;");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251114150912 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("ALTER TABLE jtb_comt ADD data_mod DATETIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251114163222 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement("ALTER TABLE vtb_dest ADD data_mod DATETIME");
|
||||||
|
executeStatement("ALTER TABLE ptb_pros ADD data_mod DATETIME");
|
||||||
|
executeStatement("ALTER TABLE ptb_pros_rif ADD data_mod DATETIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251117100418 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createOrUpdateProcedure("sp_moveTableToFileGroup", "CREATE PROCEDURE [dbo].[sp_moveTableToFileGroup] (@tableName varchar(max), @fileGroup varchar(max), @fileName varchar(max), @createFile varchar(1) = 'N')\n" +
|
||||||
|
"AS\n" +
|
||||||
|
"BEGIN\n" +
|
||||||
|
" /*la variabile @fileGroup deve contenere solo il prefisso poi la procedura aggiunge _DATA e _INDEX*/\n" +
|
||||||
|
"\n" +
|
||||||
|
" declare @fileGroupIndex varchar(max), @fileGroupData varchar(max), @sqlText varchar(max),\n" +
|
||||||
|
" @countFile int, @pathDB varchar(max), @fileGroupDataName varchar(max),\n" +
|
||||||
|
" @fileGroupIndexName varchar(max)\n" +
|
||||||
|
"\n" +
|
||||||
|
" SELECT @pathDB = reverse(substring(reverse(physical_name), charindex('\', reverse(physical_name)), LEN(physical_name) -charindex('', reverse(physical_name) ) + 1)) \n" +
|
||||||
|
" FROM sys.master_files inner join sys.databases on sys.master_files.database_id = sys.databases.database_id WHERE sys.databases.name = DB_NAME()and data_space_id = 1\n" +
|
||||||
|
"\n" +
|
||||||
|
" select @fileGroup = case when IsNull(@fileGroup, '') <> '' and RIGHT(@fileGroup, 5) = '_DATA' THEN LEFT(@fileGroup, LEN(@fileGroup) - 5 ) ELSE @fileGroup END\n" +
|
||||||
|
" \n" +
|
||||||
|
" SELECT @fileGroupData = CASE WHEN @fileGroup = 'PRIMARY' OR IsNull(@fileGroup, '') = '' THEN '' ELSE @fileGroup + '_DATA' END,\n" +
|
||||||
|
" @fileGroupIndex = CASE WHEN @fileGroup = 'PRIMARY' OR IsNull(@fileGroup, '') = '' THEN '' ELSE @fileGroup + '_INDEX ' END\n" +
|
||||||
|
"\n" +
|
||||||
|
" if @fileGroup <> 'PRIMARY' \n" +
|
||||||
|
" BEGIN\n" +
|
||||||
|
" select @countFile = COUNT(*) from sys.filegroups f WHERE name like @fileGroup + '%'\n" +
|
||||||
|
" \n" +
|
||||||
|
" IF @countFile = 0 AND @createFile = 'S'\n" +
|
||||||
|
" BEGIN\n" +
|
||||||
|
" select @fileGroupDataName = Lower(db_name()) + '_' + \n" +
|
||||||
|
" (SELECT UPPER(LEFT(value_string,1)) + LOWER(SUBSTRING(value_string,2,LEN(value_string))) \n" +
|
||||||
|
" FROM dbo.ParseStringIntoArray(@fileGroupData, '_') FOR XML PATH('') ),\n" +
|
||||||
|
" @fileGroupIndexName = Lower(db_name()) + '_' + \n" +
|
||||||
|
" (SELECT UPPER(LEFT(value_string,1)) + LOWER(SUBSTRING(value_string,2,LEN(value_string))) \n" +
|
||||||
|
" FROM dbo.ParseStringIntoArray(@fileGroupIndex, '_') FOR XML PATH('') )\n" +
|
||||||
|
"\n" +
|
||||||
|
" \n" +
|
||||||
|
" SELECT @sqlText =\n" +
|
||||||
|
" 'ALTER DATABASE ' + Upper(db_name()) + ' ADD FILEGROUP ' + @fileGroupData + '; '+ CHAR(13) + CHAR(10) + ' GO' + CHAR(13) + CHAR(10) + \n" +
|
||||||
|
" 'ALTER DATABASE ' + Upper(db_name()) + ' ADD FILE (NAME = ' + @fileGroupDataName + ',' +\n" +
|
||||||
|
" 'FILENAME = ''' + @pathDB + @fileGroupDataName + '.ndf'' ' +\n" +
|
||||||
|
" ') TO FILEGROUP ' + @fileGroupData + ';'+ CHAR(13) + CHAR(10) + ' GO' + CHAR(13) + CHAR(10) + \n" +
|
||||||
|
" 'ALTER DATABASE ' + Upper(db_name()) + ' ADD FILEGROUP ' + @fileGroupIndex + '; '+ CHAR(13) + CHAR(10) + ' GO' + CHAR(13) + CHAR(10) + \n" +
|
||||||
|
" 'ALTER DATABASE ' + Upper(db_name()) + ' ADD FILE (NAME = ' +@fileGroupIndexName + ',' + \n" +
|
||||||
|
" 'FILENAME = ''' + @pathDB + @fileGroupIndexName + '.ndf'' ' +\n" +
|
||||||
|
" ') TO FILEGROUP ' + @fileGroupIndex + ';' + CHAR(13) + CHAR(10) + ' GO' + CHAR(13) + CHAR(10) ;\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
" if @fileName <> '' \n" +
|
||||||
|
" exec sp_writeFile @fileName, @sqlText, 'S' \n" +
|
||||||
|
" else \n" +
|
||||||
|
" select @sqlText\n" +
|
||||||
|
" \n" +
|
||||||
|
" END\n" +
|
||||||
|
"\n" +
|
||||||
|
" SELECT @fileGroupData = ' ON ' + @fileGroupData, \n" +
|
||||||
|
" @fileGroupIndex = ' ON ' + @fileGroupIndex\n" +
|
||||||
|
"\n" +
|
||||||
|
" END\n" +
|
||||||
|
" \n" +
|
||||||
|
" \n" +
|
||||||
|
" DECLARE crs_query CURSOR FOR\n" +
|
||||||
|
" SELECT 'DROP INDEX '+ schema_name(t.schema_id) + '.' + t.name + '.' +i.name + CHAR(13) + CHAR(10) + ' GO' as script\n" +
|
||||||
|
" FROM sys.indexes i\n" +
|
||||||
|
" INNER JOIN sys.tables t ON t.object_id= i.object_id\n" +
|
||||||
|
" WHERE i.type>0 and \n" +
|
||||||
|
" t.is_ms_shipped=0 and \n" +
|
||||||
|
" t.name<>'sysdiagrams' and \n" +
|
||||||
|
" (is_primary_key=0 and is_unique_constraint=0) and\n" +
|
||||||
|
" t.name = @tableName\n" +
|
||||||
|
" union all\n" +
|
||||||
|
" SELECT 'CREATE ' +\n" +
|
||||||
|
" CASE \n" +
|
||||||
|
" WHEN I.is_unique = 1 THEN ' UNIQUE '\n" +
|
||||||
|
" ELSE ''\n" +
|
||||||
|
" END +\n" +
|
||||||
|
" I.type_desc COLLATE DATABASE_DEFAULT + ' INDEX ' +\n" +
|
||||||
|
" I.name + ' ON ' +\n" +
|
||||||
|
" SCHEMA_NAME(T.schema_id) + '.' + T.name + ' ( ' +\n" +
|
||||||
|
" KeyColumns + ' ) ' +\n" +
|
||||||
|
" ISNULL(' INCLUDE (' + IncludedColumns + ' ) ', '') +\n" +
|
||||||
|
" ISNULL(' WHERE ' + I.filter_definition, '') + ' WITH ( ' +\n" +
|
||||||
|
" CASE \n" +
|
||||||
|
" WHEN I.is_padded = 1 THEN ' PAD_INDEX = ON '\n" +
|
||||||
|
" ELSE ' PAD_INDEX = OFF '\n" +
|
||||||
|
" END + ',' +\n" +
|
||||||
|
" 'FILLFACTOR = ' + CONVERT(\n" +
|
||||||
|
" CHAR(5),\n" +
|
||||||
|
" CASE \n" +
|
||||||
|
" WHEN I.fill_factor = 0 THEN 100\n" +
|
||||||
|
" ELSE I.fill_factor\n" +
|
||||||
|
" END\n" +
|
||||||
|
" ) + ',' +\n" +
|
||||||
|
" -- default value \n" +
|
||||||
|
" 'SORT_IN_TEMPDB = OFF ' + ',' +\n" +
|
||||||
|
" CASE \n" +
|
||||||
|
" WHEN I.ignore_dup_key = 1 THEN ' IGNORE_DUP_KEY = ON '\n" +
|
||||||
|
" ELSE ' IGNORE_DUP_KEY = OFF '\n" +
|
||||||
|
" END + ',' +\n" +
|
||||||
|
" CASE \n" +
|
||||||
|
" WHEN ST.no_recompute = 0 THEN ' STATISTICS_NORECOMPUTE = OFF '\n" +
|
||||||
|
" ELSE ' STATISTICS_NORECOMPUTE = ON '\n" +
|
||||||
|
" END + ',' +\n" +
|
||||||
|
" ' ONLINE = OFF ' + ',' +\n" +
|
||||||
|
" CASE \n" +
|
||||||
|
" WHEN I.allow_row_locks = 1 THEN ' ALLOW_ROW_LOCKS = ON '\n" +
|
||||||
|
" ELSE ' ALLOW_ROW_LOCKS = OFF '\n" +
|
||||||
|
" END + ',' +\n" +
|
||||||
|
" CASE \n" +
|
||||||
|
" WHEN I.allow_page_locks = 1 THEN ' ALLOW_PAGE_LOCKS = ON '\n" +
|
||||||
|
" ELSE ' ALLOW_PAGE_LOCKS = OFF '\n" +
|
||||||
|
" END + ' ) ' + @fileGroupIndex + CHAR(13) + CHAR(10) + ' GO' [CreateIndexScript]\n" +
|
||||||
|
" FROM sys.indexes I\n" +
|
||||||
|
" JOIN sys.tables T\n" +
|
||||||
|
" ON T.object_id = I.object_id\n" +
|
||||||
|
" JOIN sys.sysindexes SI\n" +
|
||||||
|
" ON I.object_id = SI.id\n" +
|
||||||
|
" AND I.index_id = SI.indid\n" +
|
||||||
|
" JOIN (\n" +
|
||||||
|
" SELECT *\n" +
|
||||||
|
" FROM (\n" +
|
||||||
|
" SELECT IC2.object_id,\n" +
|
||||||
|
" IC2.index_id,\n" +
|
||||||
|
" STUFF(\n" +
|
||||||
|
" (\n" +
|
||||||
|
" SELECT ' , ' + C.name + CASE \n" +
|
||||||
|
" WHEN MAX(CONVERT(INT, IC1.is_descending_key)) \n" +
|
||||||
|
" = 1 THEN \n" +
|
||||||
|
" ' DESC '\n" +
|
||||||
|
" ELSE \n" +
|
||||||
|
" ' ASC '\n" +
|
||||||
|
" END\n" +
|
||||||
|
" FROM sys.index_columns IC1\n" +
|
||||||
|
" JOIN sys.columns C\n" +
|
||||||
|
" ON C.object_id = IC1.object_id\n" +
|
||||||
|
" AND C.column_id = IC1.column_id\n" +
|
||||||
|
" AND IC1.is_included_column = \n" +
|
||||||
|
" 0\n" +
|
||||||
|
" WHERE IC1.object_id = IC2.object_id\n" +
|
||||||
|
" AND IC1.index_id = IC2.index_id\n" +
|
||||||
|
" GROUP BY\n" +
|
||||||
|
" IC1.object_id,\n" +
|
||||||
|
" C.name,\n" +
|
||||||
|
" index_id\n" +
|
||||||
|
" ORDER BY\n" +
|
||||||
|
" MAX(IC1.key_ordinal) \n" +
|
||||||
|
" FOR XML PATH('')\n" +
|
||||||
|
" ),\n" +
|
||||||
|
" 1,\n" +
|
||||||
|
" 2,\n" +
|
||||||
|
" ''\n" +
|
||||||
|
" ) KeyColumns\n" +
|
||||||
|
" FROM sys.index_columns IC2 \n" +
|
||||||
|
" --WHERE IC2.Object_id = object_id('Person.Address') --Comment for all tables\n" +
|
||||||
|
" GROUP BY\n" +
|
||||||
|
" IC2.object_id,\n" +
|
||||||
|
" IC2.index_id\n" +
|
||||||
|
" ) tmp3\n" +
|
||||||
|
" )tmp4\n" +
|
||||||
|
" ON I.object_id = tmp4.object_id\n" +
|
||||||
|
" AND I.Index_id = tmp4.index_id\n" +
|
||||||
|
" JOIN sys.stats ST\n" +
|
||||||
|
" ON ST.object_id = I.object_id\n" +
|
||||||
|
" AND ST.stats_id = I.index_id\n" +
|
||||||
|
" JOIN sys.data_spaces DS\n" +
|
||||||
|
" ON I.data_space_id = DS.data_space_id\n" +
|
||||||
|
" JOIN sys.filegroups FG\n" +
|
||||||
|
" ON I.data_space_id = FG.data_space_id\n" +
|
||||||
|
" LEFT JOIN (\n" +
|
||||||
|
" SELECT *\n" +
|
||||||
|
" FROM (\n" +
|
||||||
|
" SELECT IC2.object_id,\n" +
|
||||||
|
" IC2.index_id,\n" +
|
||||||
|
" STUFF(\n" +
|
||||||
|
" (\n" +
|
||||||
|
" SELECT ' , ' + C.name\n" +
|
||||||
|
" FROM sys.index_columns IC1\n" +
|
||||||
|
" JOIN sys.columns C\n" +
|
||||||
|
" ON C.object_id = IC1.object_id\n" +
|
||||||
|
" AND C.column_id = IC1.column_id\n" +
|
||||||
|
" AND IC1.is_included_column = \n" +
|
||||||
|
" 1\n" +
|
||||||
|
" WHERE IC1.object_id = IC2.object_id\n" +
|
||||||
|
" AND IC1.index_id = IC2.index_id\n" +
|
||||||
|
" GROUP BY\n" +
|
||||||
|
" IC1.object_id,\n" +
|
||||||
|
" C.name,\n" +
|
||||||
|
" index_id \n" +
|
||||||
|
" FOR XML PATH('')\n" +
|
||||||
|
" ),\n" +
|
||||||
|
" 1,\n" +
|
||||||
|
" 2,\n" +
|
||||||
|
" ''\n" +
|
||||||
|
" ) IncludedColumns\n" +
|
||||||
|
" FROM sys.index_columns IC2 \n" +
|
||||||
|
" --WHERE IC2.Object_id = object_id('Person.Address') --Comment for all tables\n" +
|
||||||
|
" GROUP BY\n" +
|
||||||
|
" IC2.object_id,\n" +
|
||||||
|
" IC2.index_id\n" +
|
||||||
|
" ) tmp1\n" +
|
||||||
|
" WHERE IncludedColumns IS NOT NULL\n" +
|
||||||
|
" ) tmp2\n" +
|
||||||
|
" ON tmp2.object_id = I.object_id\n" +
|
||||||
|
" AND tmp2.index_id = I.index_id\n" +
|
||||||
|
" WHERE I.is_primary_key = 0\n" +
|
||||||
|
" AND I.is_unique_constraint = 0 and\n" +
|
||||||
|
" t.name = @tableName\n" +
|
||||||
|
" --AND I.Object_id = object_id('Person.Address') --Comment for all tables\n" +
|
||||||
|
" --AND I.name = 'IX_Address_PostalCode' --comment for all indexes \n" +
|
||||||
|
" union all\n" +
|
||||||
|
" SELECT 'ALTER TABLE ' + schema_name(fk.schema_id) + '.' + object_name(fk.parent_object_id)+ ' DROP CONSTRAINT ' + name + CHAR(13) + CHAR(10) + ' GO'\n" +
|
||||||
|
" from sys.foreign_keys fk\n" +
|
||||||
|
" where (object_name(fk.referenced_object_id) = @tableName)\n" +
|
||||||
|
" union all\n" +
|
||||||
|
" SELECT 'EXEC dbo.DropPrimaryKey '''+@tableName+''''+ CHAR(13) + CHAR(10) + ' GO' \n" +
|
||||||
|
" FROM sysobjects sysobjects_a, \n" +
|
||||||
|
" sysobjects sysobjects_b\n" +
|
||||||
|
" WHERE ( sysobjects_a.parent_obj = sysobjects_b.id) and \n" +
|
||||||
|
" ( sysobjects_a.xtype = 'PK' ) and \n" +
|
||||||
|
" ( sysobjects_b.name = @tableName )\n" +
|
||||||
|
" union all\n" +
|
||||||
|
" SELECT 'ALTER TABLE ' + schema_name(tb.schema_id) + '.' + tb. name + ' ADD CONSTRAINT pk_' + tb.name + ' primary key (' + \n" +
|
||||||
|
" ( select STUFF(( select ',' + col.name\n" +
|
||||||
|
" from sys.indexes ix \n" +
|
||||||
|
" inner join sys.index_columns ixc on ix.object_id=ixc.object_id and ix.index_id= ixc.index_id\n" +
|
||||||
|
" inner join sys.columns col on ixc.object_id =col.object_id and ixc.column_id=col.column_id\n" +
|
||||||
|
" where ix.type>0 and (ix.is_primary_key=1 or ix.is_unique_constraint=1)\n" +
|
||||||
|
" and object_name(ix.object_id) = tb.name\n" +
|
||||||
|
" ORDER BY ixc.key_ordinal\n" +
|
||||||
|
" FOR XML PATH('')), 1, 1, '' ) ) + ') ' + @fileGroupData + CHAR(13) + CHAR(10) + ' GO'\n" +
|
||||||
|
" from sys.tables tb\n" +
|
||||||
|
" where tb.name = @tableName and\n" +
|
||||||
|
" object_id in ( select object_id from sys.indexes ix where ix.is_primary_key=1 ) \n" +
|
||||||
|
" union all\n" +
|
||||||
|
" SELECT 'ALTER TABLE ' + schema_name(fk.schema_id) + '.' + object_name(fk.parent_object_id) + \n" +
|
||||||
|
" ' ADD CONSTRAINT ' + FK.NAME + ' FOREIGN KEY (' + \n" +
|
||||||
|
" (SELECT STUFF(( select ',' + c1.NAME \n" +
|
||||||
|
" from sys.foreign_key_columns fkc \n" +
|
||||||
|
" inner join sys.columns c1 on c1.object_id=fkc.parent_object_id and c1.column_id=fkc.parent_column_id \n" +
|
||||||
|
" where fkc.constraint_object_id = fk.OBJECT_ID \n" +
|
||||||
|
" ORDER by fkc.constraint_column_id\n" +
|
||||||
|
" FOR XML PATH('')), 1, 1, '' )) + \n" +
|
||||||
|
" ') REFERENCES ' + OBJECT_NAME(fk.referenced_object_id) + CHAR(13) + CHAR(10) + ' GO'\n" +
|
||||||
|
" from sys.foreign_keys fk\n" +
|
||||||
|
" where ( object_name(fk.referenced_object_id) = @tableName)\n" +
|
||||||
|
" union all\n" +
|
||||||
|
" select 'ALTER TABLE ' + + schema_name(tb.schema_id) + '.' + tb. name + ' ADD ID_PK_TEMP INT IDENTITY; ' + + CHAR(13) + CHAR(10) + 'GO' + CHAR(13) + CHAR(10) + \n" +
|
||||||
|
" 'ALTER TABLE ' + schema_name(tb.schema_id) + '.' + tb. name + ' ADD CONSTRAINT PK_' + tb. name + ' PRIMARY KEY(ID_PK_TEMP) ' + @fileGroupData + '; ' +\n" +
|
||||||
|
"CHAR(13) + CHAR(10) + 'GO' + CHAR(13) + CHAR(10) + \n" +
|
||||||
|
" 'ALTER TABLE ' + schema_name(tb.schema_id) + '.' + tb. name + ' DROP CONSTRAINT PK_' + tb. name + ' ;' + CHAR(13) + CHAR(10) + 'GO'\n" +
|
||||||
|
" from sys.tables tb\n" +
|
||||||
|
" where object_id not in (\n" +
|
||||||
|
" select object_id\n" +
|
||||||
|
" from sys.indexes ix \n" +
|
||||||
|
" where ix.is_primary_key=1 ) and tb.name = @tableName\n" +
|
||||||
|
"\n" +
|
||||||
|
"\n" +
|
||||||
|
" OPEN crs_query \n" +
|
||||||
|
" FETCH NEXT FROM crs_query INTO @sqlText\n" +
|
||||||
|
" WHILE @@FETCH_STATUS = 0\n" +
|
||||||
|
" BEGIN\n" +
|
||||||
|
" if @fileName <> '' \n" +
|
||||||
|
" exec sp_writeFile @fileName, @sqlText, 'S' \n" +
|
||||||
|
" else \n" +
|
||||||
|
" select @sqlText\n" +
|
||||||
|
" \n" +
|
||||||
|
"\n" +
|
||||||
|
" FETCH NEXT FROM crs_query INTO @sqlText\n" +
|
||||||
|
" END\n" +
|
||||||
|
" CLOSE crs_query\n" +
|
||||||
|
" DEALLOCATE crs_query \n" +
|
||||||
|
"END");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20251117142928 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetupQuery("SI_NO", "SI_NO", "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
createSetup("W_jriep_presenze_dip_disp", "SETUP", "SET_DATA_FINE", "N",
|
||||||
|
"imposta data fine = fine mese", false, "SI_NO", false, false,
|
||||||
|
false, false, false, null, false, "SELECT 'S' UNION ALL SELECT 'N'");
|
||||||
|
|
||||||
|
if (isCustomer(IntegryCustomer.Integry))
|
||||||
|
updateSetupValue("W_jriep_presenze_dip_disp", "SETUP", "SET_DATA_FINE", "S");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user