Compare commits
976 Commits
feature-re
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| 74dcedeba9 | |||
| 5848f82e4a | |||
| 797c5c7736 | |||
| b666064d15 | |||
| 532aa91b23 | |||
| 7f2c83ea69 | |||
| 307840c236 | |||
| 25321a9941 | |||
| dcbf627840 | |||
| 3e069d1c39 | |||
| 988712b234 | |||
| 123c7835d6 | |||
| d9d2b5bef7 | |||
| 99740104b9 | |||
| 3606aa99d9 | |||
| 673de9d9b1 | |||
| 0bebf87fa4 | |||
| 87cb0f8302 | |||
| 6b80520d8d | |||
| ab956b4a6e | |||
| 2831137dac | |||
| dabf6a0a54 | |||
| 7a6ddde702 | |||
| 17f4e1ad49 | |||
| 74227e6bf1 | |||
| fc2eee29a6 | |||
| 8cf75f9497 | |||
| 5b40bd4780 | |||
| 9899944a04 | |||
| 58335a5102 | |||
| 3507bc531c | |||
| 4bb4a6b34b | |||
| fe0927c0eb | |||
| 0d93dd2b1c | |||
| dad53637e8 | |||
| 853470701b | |||
| b1ee861a5c | |||
| 05857e2b11 | |||
| 60fb37ad8b | |||
| dae03dc91f | |||
| 5c81248472 | |||
| 7184c24f16 | |||
| a2be331295 | |||
| 18403554e7 | |||
| b1e189321c | |||
| e61b2532b1 | |||
| db56575b8f | |||
| 7832095b86 | |||
| 2bd8b6392c | |||
| 442af631aa | |||
| 2666e9a7ef | |||
| 7b3395dec8 | |||
| 7a15a94b38 | |||
| da8884dcdc | |||
| 54a09c2300 | |||
| 8818a42457 | |||
| d4a035fc0e | |||
| 3c5a0ba1f1 | |||
| c49f135e49 | |||
| a4d7d09c0b | |||
| 73b26249eb | |||
| 2581f537b1 | |||
| 8c14cd1937 | |||
| 597c2fe2a2 | |||
| 785b03455e | |||
| e7a581f326 | |||
| db85805afd | |||
| 3350677b23 | |||
| 8413be30a0 | |||
| 9033da0bf2 | |||
| 6dfd56c58e | |||
| 98e251478c | |||
| d31a28d3b5 | |||
| fd5867e5f1 | |||
| 13311f191e | |||
| 1f2ace8258 | |||
| 0aaba82e57 | |||
| 3888c1ce25 | |||
| 954eb96a2a | |||
| 057e3ac3c1 | |||
| 49cad4a71a | |||
| 8b593a3b21 | |||
| 6072ab57c9 | |||
| 120d85c1d3 | |||
| 13e2b1b3a4 | |||
| 6c705ab96b | |||
| 28e0c448f4 | |||
| 0b22aa9764 | |||
| a1b813f051 | |||
| 516874a6e5 | |||
| 5b31befcec | |||
| 19335be66b | |||
| 9ac451693b | |||
| 399f712024 | |||
| db38f84fca | |||
| fa94de4135 | |||
| 81b01dd5a8 | |||
| 085d6af657 | |||
| 5421cb12d2 | |||
| cd98c3884f | |||
| 92e60c95e3 | |||
| 227025b526 | |||
| 4647125b61 | |||
| 1217922b90 | |||
| 731c28f382 | |||
| 2c5deeceb6 | |||
| 8e727aeb73 | |||
| 273b76715a | |||
| 7aa8c71b3f | |||
| ac235c2b56 | |||
| b78ab2e308 | |||
| a44a307dd1 | |||
| c25d08c9ac | |||
| 695e784c73 | |||
| 0c3415b7d6 | |||
| b412860f1f | |||
| 85f5129057 | |||
| 74bfc38cd5 | |||
| 3ec6deaec6 | |||
| e2113d0660 | |||
| 8199b354d8 | |||
| 4e795f6a0a | |||
| 5f8732299a | |||
| 8babc6acfb | |||
| f193d21ffa | |||
| 6361e790b2 | |||
| 206927622a | |||
| b1ee82f0dc | |||
| 2529660f3b | |||
| 5c784a3f90 | |||
| d493749445 | |||
| 7e9c36ab77 | |||
| 904f5115b9 | |||
| 4387c4d1c3 | |||
| 9c481c5380 | |||
| 8eda08d060 | |||
|
|
ea493b3fa2 | ||
| e8bd3c0c99 | |||
| ac7bb55874 | |||
| 626a728529 | |||
| 9f9e1ef12d | |||
| c6526f6574 | |||
| a919c323ae | |||
| 00cb459c66 | |||
| e1bee4b70f | |||
| cd81b92bfe | |||
| 4120f20c5a | |||
| d43345c5fc | |||
| c0ad1f0770 | |||
| a2bd7bc9aa | |||
| 02eb94fdef | |||
| c6380a9e05 | |||
| 08b2cb3289 | |||
| 65009a6693 | |||
| cb0f18eb0b | |||
| 30108563a0 | |||
| bec0430942 | |||
| ed9952d37d | |||
| a656c81373 | |||
| d6c0271129 | |||
| d3ba9aae5f | |||
| 809a31ea87 | |||
| 63cf1920a9 | |||
| 3c79fb6745 | |||
| 4a86118707 | |||
| 9dfd8623a7 | |||
| 7e8b8a8bc4 | |||
| 554a78e40f | |||
| 32022652b3 | |||
| 3560f2a661 | |||
| 63265571ac | |||
| 73049f32eb | |||
| 1e9b48811c | |||
| 2312323649 | |||
| 9c634059ab | |||
| 57892e22ee | |||
| 9d6dd2ff5f | |||
| 2d1d15da98 | |||
| 08af6fddb2 | |||
| 1a97940826 | |||
| b2e6b0bd87 | |||
| c161857422 | |||
| 69343830a9 | |||
| f3644dcc3f | |||
| b8782a14c1 | |||
| 4825d59616 | |||
| e10f2d3a0c | |||
| 18f4f2770a | |||
|
|
fbf26157c1 | ||
| ee2e5c5938 | |||
| 8602bbf09d | |||
| 38ef2b297d | |||
| 452a2d2555 | |||
| d6794a904f | |||
| 18c2ae047e | |||
| 5581055f07 | |||
| fc0ac2ec4b | |||
| b64cd203eb | |||
| e436b9773e | |||
| 37cb5d90f4 | |||
| 15e598df7e | |||
| b43b6be4ac | |||
| 4036d2a04f | |||
| 90bc764e61 | |||
| 37fcfba74e | |||
| 9e5bfc6655 | |||
| 295fd59729 | |||
| 8c2cf7d9fe | |||
| efb786ed0d | |||
| 514500de0b | |||
| 304f0a53db | |||
| 645b269fc8 | |||
| 94ceff0753 | |||
| 7f16ca80f4 | |||
| 14c57d6ab5 | |||
| ce56820405 | |||
| 4e46f89440 | |||
| fa337ffb16 | |||
| bd3b915963 | |||
| 032a4e3aca | |||
| 3c4d62cde2 | |||
| d1a7a166a8 | |||
| e0a3dbcea2 | |||
| 112f083c9a | |||
| adccf68c45 | |||
| f84a18b9b6 | |||
| d7ef52f164 | |||
| 5a91589ac6 | |||
| 942dbeef5e | |||
| a18156014b | |||
| c5cbfd406f | |||
| abc2a0bb1e | |||
| 3568b6b17e | |||
| 93261bdb87 | |||
| 202261afc1 | |||
| 75d42d04ee | |||
| 6898cfc92c | |||
| e85b00c457 | |||
| ba1e8bb41c | |||
| 32ad423fc2 | |||
| 1661d60b94 | |||
| 438d62a362 | |||
| 0bb2cf76bf | |||
| 987a576bfd | |||
| 91ea98d9f2 | |||
| b64c01e7ce | |||
| be1ee50f32 | |||
| d2955085c5 | |||
| 10ed26c023 | |||
| 98cf6d5192 | |||
| 7e0ee7192e | |||
| f68690a01b | |||
| fcdbe8ab94 | |||
| 19568d1394 | |||
| 425b4b544f | |||
| 5dc8949215 | |||
| 1497a55607 | |||
| 6f94a290ee | |||
| 911271a6b1 | |||
| d955609d93 | |||
| eddd9ff8e7 | |||
| dcd3b0aace | |||
| 77a2fef606 | |||
| d54da02dc0 | |||
| 7e4c36a785 | |||
| 1bee7e59ab | |||
| d629f0a21d | |||
| eecadba27d | |||
| ab764a9a50 | |||
| 6027df9ee5 | |||
| 7d831c59e7 | |||
| eaf8e4779e | |||
| 84669f3929 | |||
| 9b3184281c | |||
| 7dff05df5c | |||
| b88a5bface | |||
| 48b87b7b48 | |||
| bc512ab8f2 | |||
| b73d2e9bac | |||
| bc18dc3231 | |||
| d660bb592b | |||
| a5478ef619 | |||
| c8034042aa | |||
| bff520b2ab | |||
| 71eeba9091 | |||
| f30284a30b | |||
| 8932e3ac98 | |||
| 856b759acc | |||
| c6271341b8 | |||
| b68a7aebd4 | |||
| c682331a22 | |||
| af6bc8ebe9 | |||
| 685fa64f46 | |||
| 1456749587 | |||
| dac957e5b0 | |||
| f8fd7820bc | |||
| db35c3d914 | |||
| fde32f2314 | |||
| dee4485a89 | |||
| ef58f2e65c | |||
| d5763c1d03 | |||
| 26d83ddabf | |||
| d0369d85c5 | |||
| dbba2e3fb3 | |||
| 11431e37c9 | |||
| 827fc6836c | |||
| 262d6d0f08 | |||
| ea5c880b0a | |||
| 182bd07d6c | |||
| 66a514468f | |||
| ff41b7e0dd | |||
| de6e0865ac | |||
| 6b8a2fb4c0 | |||
| 86e0750f03 | |||
| d0bb5e9342 | |||
| 9712d81a7d | |||
| 8f6ce309a2 | |||
| d551f029a8 | |||
| 839942ea40 | |||
| 44a9d7dbd2 | |||
| 74d3dc0a67 | |||
| acc35b8cc8 | |||
| b9b756a811 | |||
| c1e979391d | |||
| 5fd28fddd1 | |||
| 9c85f5da3c | |||
| 8357a33df8 | |||
| c0b67577a7 | |||
| 56d7876eb5 | |||
| af0f1e14b0 | |||
| aaac5bebb7 | |||
| 8068110cf3 | |||
| 3ee2272886 | |||
| 2d11f53330 | |||
| cb7a45d83e | |||
| 6c95492412 | |||
| 8723751f78 | |||
| 0f91128b8e | |||
| d5eb4c62f6 | |||
| c9ee41a1b1 | |||
| eaf10604ef | |||
| 4a0382cafc | |||
| 0b0942b995 | |||
| 63a891d061 | |||
| 044540ff10 | |||
| 90f3a636db | |||
| 048c639e72 | |||
| 5b1b5c5cde | |||
| d94bd75770 | |||
| 32c38b85aa | |||
| c7a96834a2 |
6
.idea/copilot.data.migration.edit.xml
generated
Normal file
6
.idea/copilot.data.migration.edit.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EditMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
12
.idea/dataSources.xml
generated
Normal file
12
.idea/dataSources.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
|
||||
<driver-ref>sqlserver.ms</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlserver://SERVERDB2019</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</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>
|
||||
@@ -1,10 +1,10 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Tomcat 9 (RistoCash)" type="Remote">
|
||||
<configuration default="false" name="Tomcat 9 (AnydeskTunnel)" type="Remote">
|
||||
<module name="ems-engine" />
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" />
|
||||
<option name="HOST" value="127.0.0.1" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="8001" />
|
||||
<option name="AUTO_RESTART" value="false" />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
16
.idea/runConfigurations/Tomcat__AnydeskTunnel_.xml
generated
16
.idea/runConfigurations/Tomcat__AnydeskTunnel_.xml
generated
@@ -1,16 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Tomcat (AnydeskTunnel)" type="Remote">
|
||||
<module name="ems-engine" />
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" />
|
||||
<option name="HOST" value="servertomcat" />
|
||||
<option name="PORT" value="8001" />
|
||||
<option name="AUTO_RESTART" value="false" />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="8001" />
|
||||
<option name="LOCAL" value="false" />
|
||||
</RunnerSettings>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
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>
|
||||
18
Containerfile
Normal file
18
Containerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
@@ -3,7 +3,7 @@ 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 JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx2G -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/
|
||||
|
||||
@@ -42,7 +42,7 @@ pipeline {
|
||||
bat(script: 'mvn clean install -t toolchains-jenkins.xml', returnStdout: true)
|
||||
archiveArtifacts(artifacts: 'ems-engine/target/ems-api.war', onlyIfSuccessful: true)
|
||||
}
|
||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Dockerfile', name: 'docker-files'
|
||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Containerfile', name: 'container-files'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
||||
steps {
|
||||
node('server-build') {
|
||||
echo "Building Docker image"
|
||||
unstash 'docker-files'
|
||||
unstash 'container-files'
|
||||
|
||||
script {
|
||||
def branchVersion = ""
|
||||
@@ -127,7 +127,9 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
||||
branchVersion = "-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}"
|
||||
}
|
||||
|
||||
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 push \"git.studioml.it/integry/ems-api${branchVersion}: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>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.integry.font</groupId>
|
||||
<artifactId>NotoSerif</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
@@ -363,6 +368,11 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.20</version> <!-- Versione scritta a mano perché qui non hanno usato lo 0 finale -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package it.integry.annotations;
|
||||
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import org.springframework.stereotype.Indexed;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Indexed
|
||||
public @interface CustomerComponent {
|
||||
IntegryCustomer value();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.annotations;
|
||||
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@CustomerComponent(IntegryCustomer.Integry) // Valore di default, verrà sovrascritto
|
||||
public @interface CustomerService {
|
||||
@AliasFor(
|
||||
annotation = CustomerComponent.class
|
||||
)
|
||||
IntegryCustomer value();
|
||||
}
|
||||
@@ -11,6 +11,7 @@ public class CommonConstants {
|
||||
|
||||
public static final String INTEGRY = "integry";
|
||||
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 EMPTY_STRING = "";
|
||||
|
||||
@@ -20,6 +21,7 @@ public class CommonConstants {
|
||||
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_DMY = "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 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_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);
|
||||
@@ -46,6 +48,10 @@ public class CommonConstants {
|
||||
.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)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
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)
|
||||
.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)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
public static final DateTimeFormatter DATETIME_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_DASHED)
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.json.JsonObjectMapperConfig;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
@@ -24,6 +25,7 @@ public abstract class BaseEntityImporter<T> implements IEntityImporter<T> {
|
||||
protected String format;
|
||||
protected boolean headless;
|
||||
protected ImportRequestDTO requestDto;
|
||||
protected RequestDataDTO requestDataDTO;
|
||||
protected MultiDBTransactionManager multiDBTransactionManager;
|
||||
protected List<AnomalieDTO> anomalie = new ArrayList<AnomalieDTO>();
|
||||
|
||||
@@ -77,6 +79,12 @@ public abstract class BaseEntityImporter<T> implements IEntityImporter<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityImporter<T> setRequestDataDTO(RequestDataDTO requestDataDTO) {
|
||||
this.requestDataDTO = requestDataDTO;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<AnomalieDTO> getAnomalie() {
|
||||
return anomalie;
|
||||
}
|
||||
@@ -100,4 +108,6 @@ public abstract class BaseEntityImporter<T> implements IEntityImporter<T> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.integry.ems.Import.base;
|
||||
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
@@ -26,10 +27,14 @@ public interface IEntityImporter<T> {
|
||||
|
||||
IEntityImporter<T> setRequestDTO(ImportRequestDTO requestDto);
|
||||
|
||||
IEntityImporter<T> setRequestDataDTO(RequestDataDTO requestDataDTO);
|
||||
|
||||
List<AnomalieDTO> getAnomalie();
|
||||
|
||||
T doImport() throws Exception;
|
||||
|
||||
String renameFile(String orginalFileName, List<EntityBase> entities) throws Exception;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package it.integry.ems._context;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.common.var.EmsDBConst;
|
||||
import it.integry.ems.expansion.RunnableArgsThrowable;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||
@@ -69,7 +69,6 @@ public class EmsCoreDBLoader {
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionPool)){
|
||||
discoverAllConnections(multiDBTransactionManager);
|
||||
setupAzienda(multiDBTransactionManager);
|
||||
userCacheService.discoverAllUsers(multiDBTransactionManager);
|
||||
|
||||
if (onComplete != null) onComplete.run(multiDBTransactionManager);
|
||||
} catch (Exception ex) {
|
||||
@@ -83,9 +82,9 @@ public class EmsCoreDBLoader {
|
||||
private void discoverAllConnections(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||
|
||||
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
||||
for (AvailableConnectionsModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
||||
for (AvailableConnectionModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
||||
|
||||
AtomicReference<AvailableConnectionsModel> modelAtomicReference = new AtomicReference<>(model);
|
||||
AtomicReference<AvailableConnectionModel> modelAtomicReference = new AtomicReference<>(model);
|
||||
|
||||
futureTasks.add(() -> {
|
||||
try {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package it.integry.ems.adapter;
|
||||
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class XmlLocalDateAdapter extends XmlAdapter<String, LocalDate> {
|
||||
|
||||
private DateTimeFormatter sdf;
|
||||
|
||||
public XmlLocalDateAdapter() {
|
||||
sdf = DateTimeFormatter.ofPattern("dd-MM-yyyy");
|
||||
}
|
||||
|
||||
public XmlLocalDateAdapter(String format) {
|
||||
sdf = DateTimeFormatter.ofPattern(format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(LocalDate arg0) throws Exception {
|
||||
return arg0.format(sdf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate unmarshal(String arg0) throws Exception {
|
||||
String format = UtilityString.determineDateFormat(arg0);
|
||||
if (format != null && !"dd-MM-yyyy".equals(format))
|
||||
sdf = DateTimeFormatter.ofPattern(format);
|
||||
return LocalDate.parse(arg0,sdf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package it.integry.ems.adapter;
|
||||
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class XmlLocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime> {
|
||||
|
||||
private DateTimeFormatter sdf;
|
||||
|
||||
public XmlLocalDateTimeAdapter() {
|
||||
sdf = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
|
||||
}
|
||||
|
||||
public XmlLocalDateTimeAdapter(String format) {
|
||||
sdf = DateTimeFormatter.ofPattern(format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(LocalDateTime arg0) throws Exception {
|
||||
return arg0.format(sdf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime unmarshal(String arg0) throws Exception {
|
||||
String format = UtilityString.determineDateFormat(arg0);
|
||||
if (format != null && !"dd-MM-yyyy HH:mm:ss".equals(format))
|
||||
sdf = DateTimeFormatter.ofPattern(format);
|
||||
return LocalDateTime.parse(arg0,sdf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
package it.integry.ems.configuration;
|
||||
|
||||
import it.integry.annotations.CustomerComponent;
|
||||
import it.integry.annotations.CustomerService;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
|
||||
/**
|
||||
* Configurazione per registrare gli scope personalizzati per customer specifici
|
||||
*/
|
||||
@Configuration
|
||||
public class CustomerServicesConfig implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private SettingsModel settingsModel;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
// Assicuriamoci che sia il context principale e non un sub-context
|
||||
if (event.getApplicationContext() == applicationContext) {
|
||||
registerCustomerBeans();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerCustomerBeans() {
|
||||
ClassPathScanningCandidateComponentProvider scanner =
|
||||
new ClassPathScanningCandidateComponentProvider(false);
|
||||
|
||||
// Aggiungo filtri per le annotazioni custom
|
||||
scanner.addIncludeFilter(new AnnotationTypeFilter(CustomerService.class));
|
||||
scanner.addIncludeFilter(new AnnotationTypeFilter(CustomerComponent.class));
|
||||
|
||||
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) applicationContext.getAutowireCapableBeanFactory();
|
||||
|
||||
// Scansiono tutti i package del progetto
|
||||
for (BeanDefinition bd : scanner.findCandidateComponents("it.integry")) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(bd.getBeanClassName());
|
||||
String beanName = generateBeanName(clazz);
|
||||
|
||||
IntegryCustomer customer = extractCustomer(clazz);
|
||||
|
||||
// Ora SettingsModel è completamente inizializzato con @PostConstruct chiamato
|
||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(customer.toString())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Evito duplicati controllando se il bean esiste già
|
||||
if (!registry.containsBeanDefinition(beanName)) {
|
||||
logger.trace("Registering custom bean for customer: " + customer + " - Class: " + clazz.getSimpleName());
|
||||
|
||||
// Creo la definizione del bean
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(clazz);
|
||||
|
||||
// Registro il bean nel registry di Spring
|
||||
registry.registerBeanDefinition(beanName, builder.getBeanDefinition());
|
||||
|
||||
// Determino lo scope del bean per decidere se istanziarlo immediatamente
|
||||
String beanScope = determineBeanScope(clazz);
|
||||
|
||||
if (shouldInstantiateImmediately(beanScope)) {
|
||||
// Forzo l'istanziazione immediata solo per bean con scope appropriati
|
||||
try {
|
||||
Object beanInstance = applicationContext.getBean(beanName);
|
||||
logger.info("Bean customer {} istanziato con successo: {} (scope: {})",
|
||||
customer, beanInstance.getClass().getSimpleName(), beanScope);
|
||||
} catch (Exception e) {
|
||||
logger.error("Errore durante l'istanziazione del bean {} (scope: {}): {}",
|
||||
beanName, beanScope, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
logger.info("Bean customer {} registrato ma non istanziato (scope: {}). " +
|
||||
"Verrà istanziato quando richiesto", customer, beanScope);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("Impossibile caricare la classe: " + bd.getBeanClassName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera il nome del bean basato sul nome della classe
|
||||
*/
|
||||
private String generateBeanName(Class<?> clazz) {
|
||||
String simpleName = clazz.getSimpleName();
|
||||
return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
|
||||
}
|
||||
|
||||
private IntegryCustomer extractCustomer(Class<?> clazz) {
|
||||
if (clazz.isAnnotationPresent(CustomerService.class)) {
|
||||
CustomerService cs = clazz.getAnnotation(CustomerService.class);
|
||||
return cs.value();
|
||||
} else if (clazz.isAnnotationPresent(CustomerComponent.class)) {
|
||||
CustomerComponent cc = clazz.getAnnotation(CustomerComponent.class);
|
||||
return cc.value();
|
||||
}
|
||||
return IntegryCustomer.Integry; // Valore di default
|
||||
}
|
||||
|
||||
/**
|
||||
* Determina lo scope del bean analizzando le annotazioni della classe
|
||||
*/
|
||||
private String determineBeanScope(Class<?> clazz) {
|
||||
// Controllo per @Scope
|
||||
if (clazz.isAnnotationPresent(org.springframework.context.annotation.Scope.class)) {
|
||||
org.springframework.context.annotation.Scope scopeAnnotation =
|
||||
clazz.getAnnotation(org.springframework.context.annotation.Scope.class);
|
||||
return scopeAnnotation.value();
|
||||
}
|
||||
|
||||
// Controllo per @RequestScope
|
||||
if (clazz.isAnnotationPresent(org.springframework.web.context.annotation.RequestScope.class)) {
|
||||
return "request";
|
||||
}
|
||||
|
||||
// Controllo per @SessionScope
|
||||
if (clazz.isAnnotationPresent(org.springframework.web.context.annotation.SessionScope.class)) {
|
||||
return "session";
|
||||
}
|
||||
|
||||
// Controllo per @ApplicationScope
|
||||
if (clazz.isAnnotationPresent(org.springframework.web.context.annotation.ApplicationScope.class)) {
|
||||
return "application";
|
||||
}
|
||||
|
||||
// Default è singleton
|
||||
return "singleton";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determina se il bean può essere istanziato immediatamente in base al suo scope
|
||||
*/
|
||||
private boolean shouldInstantiateImmediately(String scope) {
|
||||
switch (scope.toLowerCase()) {
|
||||
case "request":
|
||||
case "session":
|
||||
// I bean con scope request/session non possono essere istanziati
|
||||
// al di fuori del contesto web
|
||||
return false;
|
||||
case "prototype":
|
||||
// I bean prototype non vengono istanziati automaticamente
|
||||
return false;
|
||||
case "singleton":
|
||||
case "application":
|
||||
default:
|
||||
// Singleton e application possono essere istanziati immediatamente
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class ExecutorServiceConfig {
|
||||
|
||||
private final int corePoolSize = Runtime.getRuntime().availableProcessors();
|
||||
private final int maxPoolSize = (int) (corePoolSize * 1.5f);
|
||||
private final int queueSize = 500;
|
||||
private final int queueSize = 1_000_000;
|
||||
|
||||
@Bean
|
||||
public ExecutorService taskExecutor() {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package it.integry.ems.configuration;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
@Configuration
|
||||
@EnableScheduling // Equivale a <task:annotation-driven/>
|
||||
public class SchedulerConfig {
|
||||
|
||||
@Bean
|
||||
public ThreadPoolTaskScheduler taskScheduler() {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setPoolSize(5); // Equivale a pool-size="5"
|
||||
scheduler.setThreadNamePrefix("taskScheduler-");
|
||||
scheduler.initialize();
|
||||
return scheduler;
|
||||
}
|
||||
}
|
||||
@@ -552,7 +552,7 @@ public class EmsController {
|
||||
@RequestParam(required = false, defaultValue = "true") boolean headless,
|
||||
@RequestBody(required = false) JsonNode body) throws Exception {
|
||||
|
||||
EntityExportResponse<?> entityExportResponse = emsServices.export(typeExport, formatExport, body, headless);
|
||||
EntityExportResponse<?> entityExportResponse = emsServices.export(multiDBTransactionManager, requestDataDTO, typeExport, formatExport, body, headless);
|
||||
List<AnomalieDTO> anomalie = new ArrayList<>();
|
||||
|
||||
if (entityExportResponse != null && entityExportResponse.getAnomalie() != null && !entityExportResponse.getAnomalie().isEmpty())
|
||||
@@ -608,7 +608,7 @@ public class EmsController {
|
||||
@RequestParam(required = false, defaultValue = "true") boolean headless,
|
||||
@RequestBody(required = false) ImportRequestDTO requestBody) throws Exception {
|
||||
|
||||
EntityImportResponse<List<EntityBase>> importResponse = emsServices.importEntity(importType, importFormat, requestBody, headless);
|
||||
EntityImportResponse<List<EntityBase>> importResponse = emsServices.importEntity(multiDBTransactionManager, requestDataDTO, importType, importFormat, requestBody, headless);
|
||||
List<EntityBase> entities = importResponse.getResponse();
|
||||
|
||||
|
||||
@@ -733,7 +733,7 @@ public class EmsController {
|
||||
@PathVariable String filename,
|
||||
@RequestParam(name = "contentDisposition", defaultValue = "attachment") String contentDispositionType,
|
||||
@RequestParam(defaultValue = "false") boolean requestThumbnail) throws Exception {
|
||||
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(idAttach, requestThumbnail);
|
||||
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(multiDBTransactionManager, idAttach, requestThumbnail);
|
||||
|
||||
if (attachmentDTO != null) {
|
||||
return ResponseEntity.ok()
|
||||
@@ -754,7 +754,7 @@ public class EmsController {
|
||||
public ResponseEntity<byte[]> downloadFileFromRefUuid(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam() String refUuid,
|
||||
@RequestParam() String fileName) throws Exception {
|
||||
AttachmentDTO attached = emsServices.downloadFileFromRefUuid(refUuid, fileName);
|
||||
AttachmentDTO attached = emsServices.downloadFileFromRefUuid(multiDBTransactionManager, refUuid, fileName);
|
||||
|
||||
if (attached == null) return ResponseEntity.notFound().build();
|
||||
|
||||
@@ -774,7 +774,7 @@ public class EmsController {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam String idAttach,
|
||||
@RequestParam(defaultValue = "false") boolean requestThumbnail) throws Exception {
|
||||
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(idAttach, requestThumbnail);
|
||||
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(multiDBTransactionManager, idAttach, requestThumbnail);
|
||||
|
||||
if (attachmentDTO != null) {
|
||||
return ResponseEntity.ok()
|
||||
@@ -793,9 +793,8 @@ public class EmsController {
|
||||
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_EMAIL_CONTENT, method = RequestMethod.GET)
|
||||
public byte[] downloadStbEmailContent(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam Integer idEmail) throws Exception {
|
||||
public ResponseEntity<byte[]> downloadStbEmailContent(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam Integer idEmail) throws Exception {
|
||||
StbEmailContent stbEmailContent = new StbEmailContent();
|
||||
stbEmailContent.setIdEmail(idEmail);
|
||||
stbEmailContent.setOperation(OperationType.SELECT_OBJECT);
|
||||
@@ -803,11 +802,7 @@ public class EmsController {
|
||||
stbEmailContent = entityProcessor.processEntity(stbEmailContent, multiDBTransactionManager);
|
||||
|
||||
if (stbEmailContent != null) {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment().filename("email.eml").build().toString());
|
||||
|
||||
byte[] byteArr = null;
|
||||
byte[] byteArr;
|
||||
|
||||
String pattern = "[^\\x00-\\x7F]";
|
||||
Pattern pat = Pattern.compile(pattern);
|
||||
@@ -819,13 +814,18 @@ public class EmsController {
|
||||
byteArr = Base64.decodeBase64(stbEmailContent.getEmailContent());
|
||||
}
|
||||
|
||||
response.setContentLength(byteArr != null ? byteArr.length : 0);
|
||||
return byteArr;
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.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 null;
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
@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)
|
||||
public byte[] downloadDtbOrdPdf(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam String gestione,
|
||||
@RequestParam String dataOrd,
|
||||
@RequestParam Integer numOrd,
|
||||
@RequestParam Integer versione) throws Exception {
|
||||
public ResponseEntity<byte[]> downloadDtbOrdPdf(
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam String gestione,
|
||||
@RequestParam String dataOrd,
|
||||
@RequestParam Integer numOrd,
|
||||
@RequestParam Integer versione) throws Exception {
|
||||
|
||||
DtbOrdPdf dtbOrdPdf = new DtbOrdPdf();
|
||||
dtbOrdPdf.setGestione(gestione);
|
||||
dtbOrdPdf.setDataOrd(UtilityDate.RecognizeDate(dataOrd));
|
||||
@@ -900,17 +901,20 @@ public class EmsController {
|
||||
dtbOrdPdf = entityProcessor.processEntity(dtbOrdPdf, multiDBTransactionManager);
|
||||
|
||||
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);
|
||||
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 null;
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.POST)
|
||||
@@ -927,7 +931,7 @@ public class EmsController {
|
||||
throw new Exception("Sono stati inviati più file del previsto");
|
||||
}
|
||||
|
||||
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(idAttach,
|
||||
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(multiDBTransactionManager, idAttach,
|
||||
files[0].getOriginalFilename(),
|
||||
files[0].getBytes(),
|
||||
descrizione,
|
||||
@@ -1106,7 +1110,7 @@ public class EmsController {
|
||||
.setCodDtip(codDtip);
|
||||
drlDocAttached.setOperation(OperationType.INSERT);
|
||||
|
||||
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(idAttach,
|
||||
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(multiDBTransactionManager, idAttach,
|
||||
files[0].getOriginalFilename(),
|
||||
files[0].getBytes(),
|
||||
descrizione,
|
||||
@@ -1125,7 +1129,7 @@ public class EmsController {
|
||||
@RequestMapping(value = "createZipFromFiles", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse createZipFromFiles(@RequestBody CreateZipDTO createZipDTO) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(emsServices.createZipFromFiles(createZipDTO));
|
||||
return ServiceRestResponse.createPositiveResponse(emsServices.createZipFromFiles(multiDBTransactionManager, createZipDTO));
|
||||
}
|
||||
|
||||
// @RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_EMAIL_CONTENT, method = RequestMethod.POST)
|
||||
@@ -1171,22 +1175,10 @@ public class EmsController {
|
||||
// }
|
||||
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_CLEAN_DIRECTORIES, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse cleanDirectories(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
||||
try {
|
||||
emsServices.cleanDirectories();
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_EXPORT_SERVER_INFO_ISCC, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse exportServerInfoISCC(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
||||
emsServices.checkServerVariables();
|
||||
emsServices.checkServerVariables(multiDBTransactionManager);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package it.integry.ems.datasource;
|
||||
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
import java.sql.SQLException;
|
||||
@@ -13,17 +14,26 @@ import java.util.HashMap;
|
||||
|
||||
public class DataSource extends BasicDataSource {
|
||||
|
||||
private AvailableConnectionsModel connectionModel;
|
||||
private final int POOL_SIZE;
|
||||
|
||||
private AvailableConnectionModel connectionModel;
|
||||
|
||||
/**
|
||||
* Instanzia un nuovo datasource.
|
||||
*
|
||||
* @deprecated Il datasource non deve essere istanziato direttamente ma bisogna utilizzare il metodo
|
||||
* {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(AvailableConnectionsModel)} per ottenere una connessione.
|
||||
* {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(AvailableConnectionModel)} per ottenere una connessione.
|
||||
*/
|
||||
@Deprecated
|
||||
public DataSource() {
|
||||
super();
|
||||
POOL_SIZE = 5;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DataSource(int poolSize) {
|
||||
super();
|
||||
POOL_SIZE = poolSize;
|
||||
}
|
||||
|
||||
public EmsRestConstants.DB_TYPE getTypeDB() {
|
||||
@@ -62,12 +72,20 @@ public class DataSource extends BasicDataSource {
|
||||
}
|
||||
|
||||
public synchronized void initialize(String profileDB) throws Exception {
|
||||
AvailableConnectionsModel connectionsModel = SettingsModel.getInstance().findConnectionModel(profileDB);
|
||||
|
||||
initialize(connectionsModel);
|
||||
initialize(profileDB, null);
|
||||
}
|
||||
|
||||
public synchronized void initialize(AvailableConnectionsModel connectionModel) throws Exception {
|
||||
public synchronized void initialize(String profileDB, String customAppName) throws Exception {
|
||||
AvailableConnectionModel connectionsModel = SettingsModel.getInstance().findConnectionModel(profileDB);
|
||||
|
||||
initialize(connectionsModel, customAppName);
|
||||
}
|
||||
|
||||
public synchronized void initialize(AvailableConnectionModel connectionModel) throws Exception {
|
||||
initialize(connectionModel, null);
|
||||
}
|
||||
|
||||
public synchronized void initialize(AvailableConnectionModel connectionModel, String customAppName) throws Exception {
|
||||
if (connectionModel == null) {
|
||||
throw new Exception("Configurazione DB non trovata");
|
||||
}
|
||||
@@ -76,7 +94,7 @@ public class DataSource extends BasicDataSource {
|
||||
|
||||
this.setDriverClassName(connectionModel.getDriverClassName());
|
||||
|
||||
this.setUrl(connectionModel.getDbConnectionString("EMS Connection"));
|
||||
this.setUrl(connectionModel.getDbConnectionString(UtilityString.isNull(customAppName, "EMS Connection")));
|
||||
this.setUsername(connectionModel.getUsername());
|
||||
this.setPassword(connectionModel.getPasswordDecrypted());
|
||||
this.setDefaultCatalog(connectionModel.getDbName());
|
||||
@@ -87,9 +105,9 @@ public class DataSource extends BasicDataSource {
|
||||
// ===== OTTIMIZZAZIONI CRITICHE =====
|
||||
|
||||
// Pool sizing ottimizzato per READ_UNCOMMITTED (meno locking = più connessioni possibili)
|
||||
this.setInitialSize(5); // Inizia con più connessioni
|
||||
this.setInitialSize(POOL_SIZE); // Inizia con più connessioni
|
||||
this.setMaxTotal(-1); // Aumentato il massimo
|
||||
this.setMinIdle(5); // Non scendere sotto 5
|
||||
this.setMinIdle(POOL_SIZE); // Non scendere sotto 5
|
||||
this.setMaxIdle(-1); // Mantieni più connessioni idle
|
||||
|
||||
// Timeout ottimizzati per performance massime
|
||||
@@ -97,8 +115,8 @@ public class DataSource extends BasicDataSource {
|
||||
|
||||
// Validazione veloce ed efficiente
|
||||
this.setValidationQuery("SELECT 1");
|
||||
// this.setValidationQueryTimeout(60); // Ridotto a 1 secondo
|
||||
// this.setTestWhileIdle(true); // Testa connessioni idle
|
||||
this.setValidationQueryTimeout(30); // Ridotto a 1 secondo
|
||||
this.setTestWhileIdle(true); // Testa connessioni idle
|
||||
|
||||
// Eviction ottimizzata per READ_UNCOMMITTED
|
||||
// this.setTimeBetweenEvictionRunsMillis(1 * 1000); // Ogni 30 secondi
|
||||
|
||||
@@ -0,0 +1,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,144 @@
|
||||
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(MtbAart.ENTITY);
|
||||
add(MtbAartBarCode.ENTITY);
|
||||
add(MtbUntMis.ENTITY);
|
||||
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);
|
||||
|
||||
if (requestDataDTO.isValidProfileDB() && requestDataDTO.isValidDeviceId()) {
|
||||
deviceService.updateUsage(requestDataDTO.getApplication(), requestDataDTO.getDeviceId());
|
||||
deviceService.updateUsage(requestDataDTO.getDeviceId());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -5,6 +5,10 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -28,26 +32,26 @@ public class DownloadController {
|
||||
private MimeTypesHandler mimetypesFileTypeMap;
|
||||
|
||||
@RequestMapping(value = "download/{uuid}/{fileName}", method = RequestMethod.GET)
|
||||
public byte[] download(HttpServletResponse response,
|
||||
@PathVariable String uuid,
|
||||
@PathVariable String fileName) throws Exception {
|
||||
|
||||
public ResponseEntity<byte[]> download(@PathVariable String uuid,
|
||||
@PathVariable String fileName) throws Exception {
|
||||
byte[] fileContent = downloadFileHandlerService.getDownloadFileContent(uuid);
|
||||
|
||||
if (fileContent != null) {
|
||||
String filename = downloadFileHandlerService.getDownloadFileName(uuid);
|
||||
|
||||
String mimeType = Files.probeContentType(Paths.get(fileName));
|
||||
MediaType mediaType = mimetypesFileTypeMap.getContentType(fileName);
|
||||
|
||||
response.setContentType(mimeType);
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
|
||||
|
||||
response.setContentLength(fileContent.length);
|
||||
return fileContent;
|
||||
return ResponseEntity.ok()
|
||||
.contentType(mediaType)
|
||||
.contentLength(fileContent.length)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||
.builder("attachment")
|
||||
.filename(filename)
|
||||
.build()
|
||||
.toString())
|
||||
.body(fileContent);
|
||||
}
|
||||
|
||||
response.sendError(404, "File non trovato");
|
||||
return null;
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import it.integry.ems.utility.UtilityFile;
|
||||
import it.integry.ems_model.entity.StbFilesAttached;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
@@ -16,7 +15,6 @@ import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class DownloadFileHandlerService {
|
||||
@@ -26,12 +24,6 @@ public class DownloadFileHandlerService {
|
||||
|
||||
private final HashMap<String, CachedFileDto> mFileMap = new HashMap<>();
|
||||
|
||||
@Scheduled(fixedDelay = 1, timeUnit = TimeUnit.HOURS, zone = "Europe/Rome")
|
||||
public void clean() {
|
||||
UtilityFile.cleanDirectory(getTempPath(), 1, "");
|
||||
}
|
||||
|
||||
|
||||
public DownloadFileDto generateDownloadItem(File file) throws IOException {
|
||||
return generateDownloadItem(file.getName(), FileUtils.readFileToByteArray(file), false);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
public class ExtendedStbActivity {
|
||||
@@ -14,11 +15,9 @@ public class ExtendedStbActivity {
|
||||
private String userCreator;
|
||||
private String note;
|
||||
private String activityDescription;
|
||||
private Date dataInsAct;
|
||||
private int priorita;
|
||||
private Date alarmDate;
|
||||
private Date alarmTime;
|
||||
private Date oraInsAct;
|
||||
private LocalDateTime alarmTime;
|
||||
private LocalDateTime oraInsAct;
|
||||
private String activityTypeId;
|
||||
private String parentActivityId;
|
||||
private StbActivityEmailObject emailObject;
|
||||
@@ -116,15 +115,6 @@ public class ExtendedStbActivity {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataInsAct() {
|
||||
return dataInsAct;
|
||||
}
|
||||
|
||||
public ExtendedStbActivity setDataInsAct(Date dataInsAct) {
|
||||
this.dataInsAct = dataInsAct;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPriorita() {
|
||||
return priorita;
|
||||
}
|
||||
@@ -134,29 +124,20 @@ public class ExtendedStbActivity {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getAlarmDate() {
|
||||
return alarmDate;
|
||||
}
|
||||
|
||||
public ExtendedStbActivity setAlarmDate(Date alarmDate) {
|
||||
this.alarmDate = alarmDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getAlarmTime() {
|
||||
public LocalDateTime getAlarmTime() {
|
||||
return alarmTime;
|
||||
}
|
||||
|
||||
public ExtendedStbActivity setAlarmTime(Date alarmTime) {
|
||||
public ExtendedStbActivity setAlarmTime(LocalDateTime alarmTime) {
|
||||
this.alarmTime = alarmTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getOraInsAct() {
|
||||
public LocalDateTime getOraInsAct() {
|
||||
return oraInsAct;
|
||||
}
|
||||
|
||||
public ExtendedStbActivity setOraInsAct(Date oraInsAct) {
|
||||
public ExtendedStbActivity setOraInsAct(LocalDateTime oraInsAct) {
|
||||
this.oraInsAct = oraInsAct;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package it.integry.ems.dynamic_cache;
|
||||
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
||||
import it.integry.ems.expansion.RunnableWithReturn;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -37,8 +37,7 @@ public class DynamicCacheService {
|
||||
DATI_AZIENDA_KEY,
|
||||
ENTITY_LOGGER_SETUP,
|
||||
GRIGLIA_ACQUISTO_KEY,
|
||||
ENTITY_SYNC_KEY,
|
||||
STB_GEST_SETUP_KEY
|
||||
ENTITY_SYNC_KEY
|
||||
}
|
||||
|
||||
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
||||
@@ -51,11 +50,11 @@ public class DynamicCacheService {
|
||||
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
||||
RunnableWithReturn<Object> internalRefreshAction = () -> {
|
||||
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||
.stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.filter(AvailableConnectionModel::getInternalDb)
|
||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||
|
||||
final HashMap<String, T> cachedDataByDB = new HashMap<>();
|
||||
|
||||
@@ -83,11 +82,11 @@ public class DynamicCacheService {
|
||||
|
||||
RunnableWithReturn<Object> refreshAction = () -> {
|
||||
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||
.stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.filter(AvailableConnectionModel::getInternalDb)
|
||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||
|
||||
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = new HashMap<>();
|
||||
|
||||
@@ -138,11 +137,11 @@ public class DynamicCacheService {
|
||||
|
||||
RunnableWithReturn<Object> refreshAction = () -> {
|
||||
|
||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||
.stream()
|
||||
.filter(AvailableConnectionsModel::getInternalDb)
|
||||
.filter(AvailableConnectionModel::getInternalDb)
|
||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||
|
||||
final HashMap<String, List<?>> cacheQueryByDB = new HashMap<>();
|
||||
|
||||
|
||||
@@ -0,0 +1,325 @@
|
||||
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(MtbAart.ENTITY, MtbAart.class);
|
||||
put(MtbAartBarCode.ENTITY, MtbAartBarCode.class);
|
||||
put(MtbUntMis.ENTITY, MtbUntMis.class);
|
||||
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.dto.*;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -57,7 +57,7 @@ public class EntityLoggerComponent {
|
||||
|
||||
private void syncDBScheme() throws Exception {
|
||||
|
||||
AvailableConnectionsModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
AvailableConnectionModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
|
||||
if (connectionsModel == null) {
|
||||
throw new Exception("Impossibile ricavare la default connection");
|
||||
@@ -107,7 +107,7 @@ public class EntityLoggerComponent {
|
||||
}
|
||||
|
||||
if (settingsModel.getAvailableConnections().stream().noneMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
||||
settingsModel.addAvailableConnection(new AvailableConnectionsModel()
|
||||
settingsModel.addAvailableConnection(new AvailableConnectionModel()
|
||||
.setInternalDb(false)
|
||||
.setHost(dbHost)
|
||||
.setUsername(dbUsername)
|
||||
@@ -210,12 +210,12 @@ public class EntityLoggerComponent {
|
||||
return;
|
||||
|
||||
try {
|
||||
List<AvailableConnectionsModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
List<AvailableConnectionModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||
|
||||
try (MultiDBTransactionManager historyMultiDB = new MultiDBTransactionManager(historyProfileDB)) {
|
||||
|
||||
for (AvailableConnectionsModel sourceConnectionModel : connectionsModels) {
|
||||
for (AvailableConnectionModel sourceConnectionModel : connectionsModels) {
|
||||
String sql = "SELECT * FROM stb_log_entity_setup" +
|
||||
" WHERE entity_name <> " + UtilityDB.valueToString(StbLogEntitySetup.ENTITY);
|
||||
|
||||
|
||||
@@ -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 it.integry.ems_model.annotation.DtoField;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -10,6 +11,7 @@ import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -76,8 +78,16 @@ public class TxtMapper<T> {
|
||||
|
||||
if (ignorePosition)
|
||||
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);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
@@ -208,6 +218,8 @@ public class TxtMapper<T> {
|
||||
if (value != null) {
|
||||
if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof Date) {
|
||||
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) {
|
||||
value = ((BigDecimal) value).setScale(dtoField.scale(), RoundingMode.HALF_DOWN);
|
||||
String formula = dtoField.formula().replaceAll("this", value.toString());
|
||||
|
||||
@@ -2,8 +2,11 @@ package it.integry.ems.javabeans;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.model.IntegryApplicationEnum;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
@@ -37,12 +40,16 @@ public class RequestDataDTO {
|
||||
private String requestClientIP;
|
||||
|
||||
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 String username;
|
||||
private String password;
|
||||
private boolean includeNulls = false;
|
||||
|
||||
private IntegryApplicationEnum integryApplication = IntegryApplicationEnum.PVM;
|
||||
private IntegryApplicationEnum integryApplication;
|
||||
|
||||
private UserDTO userDTO;
|
||||
|
||||
@@ -55,6 +62,10 @@ public class RequestDataDTO {
|
||||
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();
|
||||
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
|
||||
readAuthenticationClaims(authentication);
|
||||
@@ -98,10 +109,20 @@ public class RequestDataDTO {
|
||||
.setPassword("sql");
|
||||
}
|
||||
|
||||
public static RequestDataDTO scheduledOperationsMockupData() {
|
||||
return new RequestDataDTO()
|
||||
.setUsername("INTEGRY")
|
||||
.setPassword("INTEGRY");
|
||||
}
|
||||
|
||||
public boolean isValidProfileDB() {
|
||||
return !UtilityString.isNullOrEmpty(profileDB);
|
||||
}
|
||||
|
||||
public boolean isValidCodMdep() {
|
||||
return !UtilityString.isNullOrEmpty(codMdep);
|
||||
}
|
||||
|
||||
public boolean isValidDeviceId() {
|
||||
return deviceId != null;
|
||||
}
|
||||
@@ -132,6 +153,20 @@ public class RequestDataDTO {
|
||||
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() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class JsonObjectMapperConfig {
|
||||
|
||||
module.addDeserializer(BigDecimal.class, new BigDecimalDeserialize());
|
||||
module.addDeserializer(Integer.class, new IntegerDeserializer());
|
||||
module.addDeserializer(Long.class, new LongDeserializer());
|
||||
|
||||
module.addDeserializer(String.class, new StringUnicodeDeserialize());
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package it.integry.ems.license;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -11,7 +12,6 @@ import java.util.Random;
|
||||
|
||||
public class LicenseCheckInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
|
||||
@Autowired
|
||||
private LicenseComponent licenseComponent;
|
||||
|
||||
@@ -19,13 +19,9 @@ public class LicenseCheckInterceptor extends HandlerInterceptorAdapter {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler) {
|
||||
|
||||
RequestDataDTO requestData = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
||||
|
||||
String profileDB = null;
|
||||
if (request != null && request.getQueryString() != null && request.getQueryString().contains(CommonConstants.PROFILE_DB)) {
|
||||
profileDB = request.getParameter(CommonConstants.PROFILE_DB);
|
||||
} else if (request != null && request.getHeader(CommonConstants.PROFILE_DB) != null) {
|
||||
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
|
||||
}
|
||||
String profileDB = requestData.getProfileDB();
|
||||
|
||||
LicenseStatusDTO licenseStatusDTO = null;
|
||||
if (profileDB != null) licenseStatusDTO = licenseComponent.getLicenseStatus(profileDB);
|
||||
|
||||
@@ -8,7 +8,7 @@ import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.HttpRestWrapper;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@@ -59,11 +60,11 @@ public class LicenseComponent {
|
||||
if (!canStart)
|
||||
return;
|
||||
|
||||
List<AvailableConnectionsModel> availableConnectionsModels = settingsModel.getAvailableConnections(true);
|
||||
List<AvailableConnectionModel> availableConnectionModels = settingsModel.getAvailableConnections(true);
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager()) {
|
||||
|
||||
for (AvailableConnectionsModel model : availableConnectionsModels) {
|
||||
for (AvailableConnectionModel model : availableConnectionModels) {
|
||||
multiDBTransactionManager.addConnection(model);
|
||||
}
|
||||
|
||||
@@ -105,14 +106,19 @@ public class LicenseComponent {
|
||||
} else {
|
||||
List<LicenseStatusDTO> licenses = response.getDTO(new TypeReference<List<LicenseStatusDTO>>() {
|
||||
});
|
||||
if (licenses == null) return;
|
||||
if (licenses == null || licenses.isEmpty()) return;
|
||||
|
||||
listAziende.forEach((key, value) -> {
|
||||
cachedLicenseStatus.remove(key);
|
||||
|
||||
licenses.stream().filter(x -> x.getPartIva().equalsIgnoreCase(value))
|
||||
.findFirst()
|
||||
.ifPresent(license -> cachedLicenseStatus.put(key, license));
|
||||
final Optional<LicenseStatusDTO> licenseSearch = licenses.stream().filter(x -> x.getPartIva().equalsIgnoreCase(value))
|
||||
.findFirst();
|
||||
|
||||
if (licenseSearch.isPresent()) {
|
||||
cachedLicenseStatus.put(key, licenseSearch.get());
|
||||
} else {
|
||||
cachedLicenseStatus.put(key, licenses.get(0));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,10 +10,13 @@ import java.util.Date;
|
||||
public class LicenseStatusDTO {
|
||||
@SqlField("part_iva")
|
||||
private String partIva;
|
||||
|
||||
@SqlField("classe_merito")
|
||||
private Quality quality;
|
||||
|
||||
@SqlField
|
||||
private Status status;
|
||||
|
||||
@SqlField("data_scad_license")
|
||||
private Date expiringDate;
|
||||
|
||||
|
||||
@@ -17,10 +17,12 @@ import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||
import it.integry.ems_model.types.ApplicationName;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.types.TypeDbObject;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
import it.integry.ems_model.utility.dto.PkTableDTO;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
@@ -74,6 +76,18 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
return UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
||||
}
|
||||
|
||||
protected @NotNull <T> List<T> executeQueryOnlyFirstColumn(String sql) throws SQLException {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
|
||||
}
|
||||
|
||||
protected @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 {
|
||||
executeStatement(connection, sqls);
|
||||
}
|
||||
@@ -140,6 +154,10 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
}
|
||||
|
||||
private void alterObject(SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
||||
if (UtilityString.isNullOrEmpty(objectName)) {
|
||||
throw new IllegalArgumentException("ObjectName in createOrUpdateFunction(), createOrUpdateView(), createOrUpdateTrigger(), createOrUpdateProcedure() cannot be null or empty");
|
||||
}
|
||||
|
||||
executeStatement("IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||
"\tDROP " + sqlObject.toString() + " " + objectName,
|
||||
sql);
|
||||
@@ -154,7 +172,20 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
UtilityDB.createIndex(connection, indexTableDTO);
|
||||
}
|
||||
|
||||
protected void dropIndex(String tableName, String indexName) throws Exception {
|
||||
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 {
|
||||
UtilityDB.cloneTable(connection, sourceTable, newTable, fillNewTable, dropOldTable, renameNewTable);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -392,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 {
|
||||
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||
.setGestName(gestName)
|
||||
@@ -474,6 +524,16 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
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) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
@@ -594,4 +654,38 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
protected boolean isSqlServer2022() throws Exception {
|
||||
return getSqlCompatibilityLevel() == DatabaseVersionEnum.SQLServer2022;
|
||||
}
|
||||
|
||||
protected void addDescriptionTable(String tableName, String description) throws SQLException {
|
||||
if (existsTable(tableName)) {
|
||||
addDescriptionObject(tableName, TypeDbObject.TABLE, description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void addDescriptionView(String viewName, String description) throws SQLException {
|
||||
if (existsView(viewName)) {
|
||||
addDescriptionObject(viewName, TypeDbObject.VIEW, description);
|
||||
}
|
||||
}
|
||||
|
||||
private void addDescriptionObject(String objectName, TypeDbObject type, String description) throws SQLException {
|
||||
String typeString = "TABLE";
|
||||
|
||||
if (type == TypeDbObject.VIEW) {
|
||||
typeString = "VIEW";
|
||||
}
|
||||
executeStatement(
|
||||
Query.format("EXEC sp_addextendedproperty " +
|
||||
"@name = N'MS_Description', " +
|
||||
"@value = %s, " +
|
||||
"@level0type = N'SCHEMA', @level0name = 'dbo', " +
|
||||
"@level1type = %s, @level1name = %s;", description, typeString, objectName));
|
||||
}
|
||||
|
||||
private void addDescriptionColumn(String tableName, String columnName, String description) throws SQLException {
|
||||
executeStatement(Query.format("EXEC sp_addextendedproperty 'MS_Description', %s, 'SCHEMA', 'dbo', 'TABLE',%s, 'COLUMN', %s)",
|
||||
description, tableName, columnName));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public enum IntegryCustomer {
|
||||
IntegryCustomerDB.Agricoper_IlVisone,
|
||||
IntegryCustomerDB.Agricoper_Luva),
|
||||
|
||||
ATI(IntegryCustomerDB.ATI_Finpart),
|
||||
ATI(IntegryCustomerDB.ATI, IntegryCustomerDB.ATI_Finpart),
|
||||
Auricchio(IntegryCustomerDB.Auricchio_Auricchio,
|
||||
IntegryCustomerDB.Auricchio_AuricchioMiki,
|
||||
IntegryCustomerDB.Auricchio_AuricchioSrl,
|
||||
@@ -20,6 +20,7 @@ public enum IntegryCustomer {
|
||||
Biolevante(IntegryCustomerDB.Biolevante_Biolevante,
|
||||
IntegryCustomerDB.Biolevante_BiolevanteStorico,
|
||||
IntegryCustomerDB.Biolevante_TenutaSanMartino),
|
||||
CapelliMonelli(IntegryCustomerDB.CapelliMonelli_CapelliMonelli),
|
||||
Carelli(IntegryCustomerDB.Carelli_Carelli,
|
||||
IntegryCustomerDB.Carelli_GestFood,
|
||||
IntegryCustomerDB.Carelli_Chiuso,
|
||||
@@ -70,7 +71,8 @@ public enum IntegryCustomer {
|
||||
Gramm(IntegryCustomerDB.Gramm_Gramm,
|
||||
IntegryCustomerDB.Gramm_PrimeOlive,
|
||||
IntegryCustomerDB.Gramm_ProveStage,
|
||||
IntegryCustomerDB.Gramm_2MHolding),
|
||||
IntegryCustomerDB.Gramm_2MHolding,
|
||||
IntegryCustomerDB.Gramm_GrammUsa),
|
||||
Idrotecnica(IntegryCustomerDB.Idrotecnica_Idrotecnica),
|
||||
Igood(IntegryCustomerDB.Igood_Aida,
|
||||
IntegryCustomerDB.Igood_Igood,
|
||||
@@ -117,7 +119,10 @@ public enum IntegryCustomer {
|
||||
IntegryCustomerDB.Suit_TenutaArianna,
|
||||
IntegryCustomerDB.Suit_Valpietro),
|
||||
Tempesta(IntegryCustomerDB.Tempesta_Tempesta,
|
||||
IntegryCustomerDB.Tempesta_VivaiTempesta),
|
||||
IntegryCustomerDB.Tempesta_DI,
|
||||
IntegryCustomerDB.Tempesta_VivaiTempesta,
|
||||
IntegryCustomerDB.Tempesta_VivaiTempesta_DI
|
||||
),
|
||||
Tosca(IntegryCustomerDB.Tosca_Ba,
|
||||
IntegryCustomerDB.Tosca_Ce,
|
||||
IntegryCustomerDB.Tosca_Cz,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.migration._base;
|
||||
|
||||
import it.integry.ems.exception.InvalidCustomerDbException;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -9,7 +10,9 @@ public enum IntegryCustomerDB {
|
||||
Agricoper_IlVisone("ilvisone"),
|
||||
Agricoper_Luva("luva"),
|
||||
|
||||
ATI("atisrl"),
|
||||
ATI_Finpart("Finpart"),
|
||||
|
||||
Auricchio_Auricchio("auricchio"),
|
||||
Auricchio_AuricchioMiki("auricchio_miki"),
|
||||
Auricchio_AuricchioSrl("auricchiosrl"),
|
||||
@@ -24,12 +27,14 @@ public enum IntegryCustomerDB {
|
||||
Biolevante_BiolevanteStorico("biolevante_storico"),
|
||||
Biolevante_TenutaSanMartino("tenutasanmartino"),
|
||||
|
||||
CapelliMonelli_CapelliMonelli("capelli_monelli"),
|
||||
|
||||
Carelli_Carelli("carelli"),
|
||||
Carelli_GestFood("gestfood"),
|
||||
Carelli_Chiuso("chiuso"),
|
||||
Carelli_Format("format"),
|
||||
Carelli_Murgia("murgia"),
|
||||
Carelli_MurgiaTest("murgia_test"),
|
||||
Carelli_Panimal("panimal"),
|
||||
Carelli_Winact("winact"),
|
||||
Carelli_Csgr("csgr"),
|
||||
@@ -91,7 +96,8 @@ public enum IntegryCustomerDB {
|
||||
Gramm_Gramm("gramm"),
|
||||
Gramm_PrimeOlive("primeolive"),
|
||||
Gramm_ProveStage("grammprovestage"),
|
||||
Gramm_2MHolding("2M_HOLDING"),
|
||||
Gramm_2MHolding("dueemme"),
|
||||
Gramm_GrammUsa("gramm_usa"),
|
||||
|
||||
|
||||
Idrotecnica_Idrotecnica("idrotecnica"),
|
||||
@@ -122,6 +128,7 @@ public enum IntegryCustomerDB {
|
||||
Levanplast_Perilflor("perilflor"),
|
||||
Levanplast_PerilflorSrl("perilflorsrl"),
|
||||
Levanplast_Levanplast("levanplast"),
|
||||
Levanplast_Levanplastsrl("levanplastsrl"),
|
||||
|
||||
Maggio_MaggioSrl("maggiosrl"),
|
||||
Maggio_GiovMaggio("giovmaggio"),
|
||||
@@ -191,7 +198,9 @@ public enum IntegryCustomerDB {
|
||||
|
||||
|
||||
Tempesta_Tempesta("tempesta"),
|
||||
Tempesta_DI("tempestadi"),
|
||||
Tempesta_VivaiTempesta("vivaitempesta"),
|
||||
Tempesta_VivaiTempesta_DI("vivaitempestadi"),
|
||||
|
||||
|
||||
Tosca_Ba("tosca_ba"),
|
||||
@@ -229,6 +238,6 @@ public enum IntegryCustomerDB {
|
||||
|
||||
return Arrays.stream(values()).filter(x -> x.getValue().equalsIgnoreCase(value))
|
||||
.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.MigrationModelInterface;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Migration_20210721093948 extends BaseMigration implements Migration
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
|
||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,7 @@ package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Migration_20210924152555 extends BaseMigration implements Migration
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||
|
||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.integry.ems_model.entity.StbUser;
|
||||
import it.integry.ems_model.entity.WtbUsers;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.CryptoUtils;
|
||||
|
||||
@@ -57,7 +58,7 @@ public class Migration_20220413102657 extends BaseMigration implements Migration
|
||||
.setUserCode(wtbUser.getUserCode())
|
||||
.setDetails(wtbUser.getDetails())
|
||||
.setLastAccessDatetime(wtbUser.getLastAccessDatetime())
|
||||
.setPasswordEndtime(wtbUser.getPasswordEndtime())
|
||||
.setPasswordEndtime(UtilityLocalDate.localDateTimeFromDate(wtbUser.getPasswordEndtime()))
|
||||
.setUrlCss(wtbUser.getUrlCss())
|
||||
.setCodLang(wtbUser.getCodLang())
|
||||
.setCreationDatetime(wtbUser.getCreationDatetime())
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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_20250827114912 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Ime_ImeTe) || isCustomerDb(IntegryCustomerDB.Materica_ImeBa)) {
|
||||
updateSetupValue("W_PORDI_RC", "SETUP", "CHECK_DEP_TERZISTA", "S");
|
||||
updateSetupValue("DTB_ORDT", "SETUP", "DISABLE_TRIGGER_ORDL", "S");
|
||||
}
|
||||
}
|
||||
|
||||
@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_20250827151739 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (existsColumn("dtb_ord_log_import", "id")) return;
|
||||
|
||||
executeStatement(
|
||||
"exec dropPrimaryKey 'dtb_ord_log_import'",
|
||||
"alter table dtb_ord_log_import add id bigint identity",
|
||||
"alter table dtb_ord_log_import add constraint pk_dtb_ord_log_import primary key (id)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250828100041 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement(
|
||||
"alter table ntb_docr add val_sco_art numeric(20,5);",
|
||||
"alter table mtb_depo_casse add last_idx int;",
|
||||
"Create table ntb_docs ( " +
|
||||
" id bigint identity not null, " +
|
||||
" cod_mdep varchar(5) not null, " +
|
||||
" cod_cassa varchar(5) not null, " +
|
||||
" data_doc datetime not null, " +
|
||||
" id_riga int not null, " +
|
||||
" promozione varchar(40) not null , " +
|
||||
" val_sco numeric(20,5) not null default 0); ",
|
||||
"alter table ntb_docs add constraint pk_ntb_docs primary key (id)",
|
||||
"alter table ntb_docs add constraint fk_ntb_docs_ntb_docr foreign key (cod_mdep, cod_cassa, data_doc, id_riga) references ntb_docr (cod_mdep, cod_cassa, data_doc, id_riga);"
|
||||
);
|
||||
}
|
||||
|
||||
@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_20250828145642 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS_SERVICES", "PROFILE_DB", null,
|
||||
"Inserire il profile del db a cui collegarsi", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Carelli_Carelli) && isCustomerDb(IntegryCustomerDB.Carelli_GestFood) ) {
|
||||
updateSetupValue("IMPORT_SCONTRINI", "MMPOS_SERVICES", "PROFILE_DB", "MMPOS");
|
||||
}else if (isCustomerDb(IntegryCustomerDB.Carelli_Murgia) && isCustomerDb(IntegryCustomerDB.Carelli_GestFood) ) {
|
||||
updateSetupValue("IMPORT_SCONTRINI", "MMPOS_SERVICES", "PROFILE_DB", "MMPOS_FORNO");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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_20250909112137 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "ATTIVO", null, "Flag che abilita l'utilizzo delle API di UVE2K", "SI_NO");
|
||||
createSetup("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_JWT_ACCESS_TOKEN", null, "Access token utile per autenticarsi sulle API di UVE2K", null);
|
||||
createSetup("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_URL_BASE_PATH", null, "URL base delle API di UVE2K", null);
|
||||
createSetup("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_COMPANY_ID", null, "Company ID di UVE2K", null);
|
||||
createSetup("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_APP_CLIENT_ID", null, "App Client ID di UVE2K", null);
|
||||
createSetup("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_USERNAME", null, "Username di accesso a UVE2K", null);
|
||||
createSetup("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_PASSWORD", null, "Password di accesso a UVE2K", null);
|
||||
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Lamonarca_Lamonarca)) {
|
||||
updateSetupValue("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "ATTIVO", "S");
|
||||
updateSetupValue("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_URL_BASE_PATH", "https://bluetech02.maxidata.net/uve2k.blue.srv1/");
|
||||
updateSetupValue("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_COMPANY_ID", "MAXI.MAXI.LAMON.00001");
|
||||
updateSetupValue("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_APP_CLIENT_ID", "uve2k.Blue");
|
||||
updateSetupValue("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_USERNAME", "Integry.Lamonarca");
|
||||
updateSetupValue("IMPORT_ORDINI LAVORAZIONE", "MAXIDATA", "UVE2K_PASSWORD", "Bt02Mes#2025");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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_20250922095154 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
dropColumn("ntb_docr", "val_sco_art");
|
||||
executeStatement("alter table ntb_docr add val_voucher numeric(20,5);");
|
||||
}
|
||||
|
||||
@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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250922140309 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS_SERVICES", "IMPOSTA_DATI_ORDINE", "N",
|
||||
"Imposta sulla riga dello scontrino i dati dell'ordine", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS_SERVICES", "IMPOSTA_KIT", "N",
|
||||
"Imposta sulla riga dello scontrino il codice del kit ( menu ) ", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if ( isCustomerDb(IntegryCustomerDB.Carelli_Murgia)) {
|
||||
updateSetupValue("IMPORT_SCONTRINI", "MMPOS_SERVICES", "IMPOSTA_DATI_ORDINE", "S");
|
||||
updateSetupValue("IMPORT_SCONTRINI", "MMPOS_SERVICES", "IMPOSTA_KIT", "S");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
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_20250922143404 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Biolevante)) return;
|
||||
|
||||
createOrUpdateView("olvw_miscele_olio", "CREATE view [dbo].[olvw_miscele_olio] as \n" +
|
||||
"select mtb_aart.cod_mart\n" +
|
||||
"from dbo.mtb_sgrp inner join dbo.mtb_aart on mtb_aart.cod_mgrp = mtb_sgrp.cod_mgrp and mtb_aart.cod_msgr = mtb_sgrp.cod_msgr\n" +
|
||||
"where flag_miscela = 1 and mtb_aart.flag_stato = 'A'");
|
||||
createOrUpdateFunction("lol_getMovimentazioneOlioDett", "CREATE FUNCTION [dbo].[lol_getMovimentazioneOlioDett]\n" +
|
||||
"( \n" +
|
||||
" @codAnag varchar(5), @codDtip varchar(5), @dataDoc datetime, @serDoc varchar(3), @numDoc int, @filtraMiscela bit\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE as\n" +
|
||||
"return \n" +
|
||||
"(\n" +
|
||||
"SELECT \n" +
|
||||
" doc_r.id_riga, \n" +
|
||||
" doc_r.posizione, \n" +
|
||||
" doc_r.cod_mart, \n" +
|
||||
" doc_r.descrizione_estesa, \n" +
|
||||
" doc_r.unt_doc, \n" +
|
||||
" doc_r.qta_doc, \n" +
|
||||
" doc_r.partita_mag,\n" +
|
||||
" doc_r.cod_art_for as 'cod_art_for',\n" +
|
||||
" dtb_doct.cod_prod,\n" +
|
||||
" dtb_doct.unt_mis_prod,\n" +
|
||||
" dtb_doct.qta_prod,\n" +
|
||||
" dtb_doct.partita_mag as partita_mag_prod,\n" +
|
||||
" mtb_partita_mag.posizione as posizione_prod,\n" +
|
||||
" doc_r.is_olioSfuso\n" +
|
||||
"FROM dtb_doct inner join dtb_docr on dtb_doct.cod_anag = dtb_docr.cod_anag AND\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" inner join mtb_partita_mag on dtb_doct.cod_prod = mtb_partita_mag.cod_mart AND\n" +
|
||||
" dtb_doct.partita_mag = mtb_partita_mag.partita_mag\n" +
|
||||
"LEFT OUTER JOIN (\n" +
|
||||
"SELECT doc_t.activity_id, doc_r.id_riga, doc_r.cod_mart, doc_r.descrizione_estesa, doc_r.unt_doc, doc_r.qta_doc, doc_r.partita_mag, doc_r.posizione, doc_r.cod_art_for,\n" +
|
||||
"case when IsNull(carat.confezionato, 'S') = 'N' THEN 1 ELSE 0 END as is_olioSfuso\n" +
|
||||
"FROM dtb_doct doc_t inner join dtb_docr doc_r on doc_t.cod_anag = doc_r.cod_anag AND \n" +
|
||||
" doc_t.cod_dtip = doc_r.cod_dtip AND \n" +
|
||||
" doc_t.data_doc = doc_r.data_doc AND\n" +
|
||||
" doc_t.ser_doc = doc_r.ser_doc AND\n" +
|
||||
" doc_t.num_doc = doc_r.num_doc\n" +
|
||||
" inner join dtb_tipi on doc_t.cod_dtip = dtb_tipi.cod_dtip \n" +
|
||||
" left outer join olvw_caratteristiche carat on doc_r.cod_mart = carat.cod_mart\n" +
|
||||
"WHERE dtb_tipi.segno_qta_car - dtb_tipi.segno_qta_scar < 0 AND\n" +
|
||||
"(@filtraMiscela = 0 OR (@filtraMiscela = 1 AND doc_t.cod_prod IN (select cod_mart from olvw_miscele_olio )))\n" +
|
||||
") doc_r on dtb_docr.activity_id_row = doc_r.activity_id \n" +
|
||||
" where dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" (@filtraMiscela = 0 OR (@filtraMiscela = 1 AND dtb_docr.cod_mart IN (select cod_mart from olvw_miscele_olio )))\n" +
|
||||
")");
|
||||
createOrUpdateView("lvw_MovimentiPosture", "CREATE view [dbo].[lvw_MovimentiPosture] as\n" +
|
||||
"With MovimentiMixPosture as\n" +
|
||||
" ( \n" +
|
||||
" select CarT.cod_prod CarCodProd,\n" +
|
||||
" CarT.partita_mag CartPartitaMag,\n" +
|
||||
" MixT.cod_prod MixTCodProd,\n" +
|
||||
" MixT.partita_mag as MixTPartita,\n" +
|
||||
" CarR.cod_mart CarRCodMart,\n" +
|
||||
" CarR.posizione CarRPos,\n" +
|
||||
" MixR.cod_mart MixRCodMart,\n" +
|
||||
" MixR.posizione MixRPos,\n" +
|
||||
"\n" +
|
||||
" MixT.data_reg,\n" +
|
||||
" MixT.data_ins,\n" +
|
||||
" MixT.cod_mdep,\n" +
|
||||
" carT.gestione,\n" +
|
||||
" CarT.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" CarT.cod_dtip,\n" +
|
||||
" dtb_tipi.descrizione as causale,\n" +
|
||||
" CarT.data_doc,\n" +
|
||||
" CarT.ser_doc,\n" +
|
||||
" CarT.num_doc,\n" +
|
||||
" Cart.cod_prod as cod_prod_fine,\n" +
|
||||
" Cart.partita_mag as partita_mag_fine,\n" +
|
||||
" MixT.cod_prod as Cod_prod_mix,\n" +
|
||||
" MixT.partita_mag as partita_mag_mix,\n" +
|
||||
" case\n" +
|
||||
" when (MixT.cod_prod <> CarT.cod_prod and MixT.cod_prod not in (select cod_mart from olvw_miscele_olio))\n" +
|
||||
" then\n" +
|
||||
" mtb_partita_mag.posizione --Avvinamento\n" +
|
||||
" else\n" +
|
||||
" Case\n" +
|
||||
" when MixR.cod_mart in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" then null --La miscela termina nel confezionato quindi postura null\n" +
|
||||
" else\n" +
|
||||
" Case\n" +
|
||||
" when MixT.cod_prod in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" and CarR.posizione = MixR.posizione\n" +
|
||||
" then null --Rigo di scarico a confezionamento di un olio senza serbatoio polomone\n" +
|
||||
"\n" +
|
||||
" else\n" +
|
||||
" CarR.posizione end end end as Posizione_a,\n" +
|
||||
" MixR.cod_dtip as cod_dtip_mix,\n" +
|
||||
" MixR.cod_mart,\n" +
|
||||
" mtb_aart.descrizione_estesa as descrizione_Articolo, \n" +
|
||||
" MixR.partita_mag,\n" +
|
||||
" CASE WHEN Isnull(carat_CarR.Confezionato, 'N') = 'S' -- Scarico olio confezionato\n" +
|
||||
" THEN null else MixR.posizione end as Posizione_da,\n" +
|
||||
"\n" +
|
||||
" MAX(Case\n" +
|
||||
" when MixR.cod_mart in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" then null\n" +
|
||||
" else MixR.posizione end)\n" +
|
||||
" over (PARTITION by CarT.cod_anag, CarT.cod_Dtip, CarT.data_doc, CarT.ser_doc, CarT.num_doc) as MaxPosizioneA,\n" +
|
||||
" MAX(MixR.posizione)\n" +
|
||||
" over (PARTITION by CarT.cod_anag, CarT.cod_Dtip, CarT.data_doc, CarT.ser_doc, CarT.num_doc) as MaxPosizioneDa, \n" +
|
||||
" Case\n" +
|
||||
" when isnull(carat_CarR.Confezionato , 'N') = 'S' THEN\n" +
|
||||
" case when tipoMix.segno_qta_car - tipoMix.segno_qta_scar > 0 THEN MixT.qta_prod eLSE 0 END --Sconfezionamento \n" +
|
||||
" when MAX(Case\n" +
|
||||
" when MixR.cod_mart in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" then Null\n" +
|
||||
" else MixR.posizione end)\n" +
|
||||
" over (PARTITION by CarT.cod_anag, CarT.cod_Dtip, CarT.data_doc, CarT.ser_doc, CarT.num_doc) =\n" +
|
||||
" MAX(MixR.posizione)\n" +
|
||||
" over (PARTITION by CarT.cod_anag, CarT.cod_Dtip, CarT.data_doc, CarT.ser_doc, CarT.num_doc)\n" +
|
||||
" and\n" +
|
||||
" MixR.posizione = MAX(Case\n" +
|
||||
" when MixR.cod_mart in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" then null\n" +
|
||||
" else MixR.posizione end)\n" +
|
||||
" over (PARTITION by CarT.cod_anag, CarT.cod_Dtip, CarT.data_doc, CarT.ser_doc, CarT.num_doc)\n" +
|
||||
" and MixR.cod_mart in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" then 0 --Esclusione dei movimenti di M00 nei confezionamenti senza serbatoio polmone\n" +
|
||||
" else \n" +
|
||||
" MixR.qta_doc \n" +
|
||||
" end as qta_doc\n" +
|
||||
" from dtb_doct CarT \n" +
|
||||
" INNER JOIN dtb_tipi on CarT.cod_dtip = dtb_tipi.cod_dtip \n" +
|
||||
" INNER JOIN gtb_anag ON CarT.cod_anag = gtb_anag.cod_anag \n" +
|
||||
" INNER JOIN dtb_docr CarR ON CarT.cod_anag = CarR.cod_anag\n" +
|
||||
" and CarT.cod_dtip = CarR.cod_dtip\n" +
|
||||
" and CarT.data_doc = CarR.data_doc\n" +
|
||||
" and CarT.ser_doc = CarR.ser_doc\n" +
|
||||
" and CarT.num_doc = CarR.num_doc \n" +
|
||||
" INNER JOIn dtb_doct MixT ON CarR.activity_id_row = MixT.activity_id \n" +
|
||||
" INNER JOIN dtb_tipi tipoMix on MixT.cod_dtip = tipoMix.cod_dtip\n" +
|
||||
" INNER JOIN dtb_docr MixR ON MixT.cod_anag = MixR.cod_anag\n" +
|
||||
" and MixT.cod_dtip = MixR.cod_dtip\n" +
|
||||
" and MixT.data_doc = MixR.data_doc\n" +
|
||||
" and MixT.ser_doc = MixR.ser_doc\n" +
|
||||
" and MixT.num_doc = MixR.num_doc \n" +
|
||||
" INNER JOIN mtb_partita_mag ON MixT.cod_prod = mtb_partita_mag.cod_mart and \n" +
|
||||
" MixT.partita_mag = mtb_partita_mag.partita_mag \n" +
|
||||
" INNER JOIN mtb_aart ON MixR.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN olvw_caratteristiche carat_CarR on CarR.cod_mart = carat_CarR.cod_mart\n" +
|
||||
" where dtb_tipi.tipo_emissione = 'DIRETTA' \n" +
|
||||
" and Carr.posizione is not null \n" +
|
||||
" And (\n" +
|
||||
" isNUll(mtb_partita_mag.posizione, '') <> isNull(MixR.posizione, '')\n" +
|
||||
" and CarR.posizione <> isNull(MixR.posizione, '') --esclusione dei giroconti dovuti agli avvinamenti\n" +
|
||||
"\n" +
|
||||
" OR MixT.cod_prod in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" and\n" +
|
||||
" CarR.posizione = isNull(MixR.posizione, '') --Serve ad includere la riga dell'olio dei confezionamenti senza serbatoio polmone\n" +
|
||||
" \n" +
|
||||
" OR MixT.cod_prod not in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
" and ( MixT.cod_prod <> MixR.cod_mart \n" +
|
||||
" OR (MixT.cod_prod = MixR.cod_mart AND IsNull(carat_CarR.Confezionato, 'N') = 'S' )\n" +
|
||||
" )\n" +
|
||||
" and CarR.posizione = isNull(MixR.posizione, '') --Serve ad includere la riga di riqualificazione dell'olio\n" +
|
||||
" ) \n" +
|
||||
" )\n" +
|
||||
"\n" +
|
||||
", movi as (\n" +
|
||||
" --Carichi da Mix per movimento speciale \n" +
|
||||
" Select data_reg,\n" +
|
||||
" data_ins,\n" +
|
||||
" MovimentiMixPosture.cod_mdep,\n" +
|
||||
" gestione,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc,\n" +
|
||||
" cod_dtip,\n" +
|
||||
" causale,\n" +
|
||||
" data_doc,\n" +
|
||||
" ser_doc,\n" +
|
||||
" num_doc,\n" +
|
||||
" posizione_a as Posizione,\n" +
|
||||
" mtb_depo_posizioni.descrizione as descrizione_posizione,\n" +
|
||||
" mtb_depo_posizioni.capacita,\n" +
|
||||
" cod_mart,\n" +
|
||||
" descrizione_Articolo,\n" +
|
||||
" partita_mag,\n" +
|
||||
" qta_doc as qta_Car,\n" +
|
||||
" 0 as qta_Scar,\n" +
|
||||
" ISNULL(cod_prod_fine, cod_prod_mix) as cod_prod,\n" +
|
||||
" ISNULL(partita_mag_fine, partita_mag_mix) as partita_mag_prod\n" +
|
||||
" from MovimentiMixPosture,\n" +
|
||||
" mtb_depo_posizioni\n" +
|
||||
" Where Posizione_a is not null\n" +
|
||||
" and qta_doc <> 0\n" +
|
||||
" /*and MovimentiMixPosture.cod_mdep = mtb_depo_posizioni.cod_mdep*/\n" +
|
||||
" and MovimentiMixPosture.Posizione_a = mtb_depo_posizioni.posizione\n" +
|
||||
" \n" +
|
||||
" Union all\n" +
|
||||
"\n" +
|
||||
" --Scarichi da Mix per movimento speciale\n" +
|
||||
" Select data_reg,\n" +
|
||||
" data_ins,\n" +
|
||||
" MovimentiMixPosture.cod_mdep,\n" +
|
||||
" gestione,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc,\n" +
|
||||
" cod_dtip,\n" +
|
||||
" causale,\n" +
|
||||
" data_doc,\n" +
|
||||
" ser_doc,\n" +
|
||||
" num_doc,\n" +
|
||||
" posizione_da as Posizione,\n" +
|
||||
" mtb_depo_posizioni.descrizione as descrizione_posizione,\n" +
|
||||
" mtb_depo_posizioni.capacita,\n" +
|
||||
" cod_mart,\n" +
|
||||
" descrizione_Articolo,\n" +
|
||||
" partita_mag,\n" +
|
||||
" 0 as qta_Car,\n" +
|
||||
" qta_doc as qta_Scar,\n" +
|
||||
" ISNULL(cod_prod_fine, cod_prod_mix) as cod_prod,\n" +
|
||||
" ISNULL(partita_mag_fine, partita_mag_mix) as partita_mag_prod\n" +
|
||||
" from MovimentiMixPosture,\n" +
|
||||
" mtb_depo_posizioni\n" +
|
||||
" Where Posizione_da is not null\n" +
|
||||
" and qta_doc <> 0\n" +
|
||||
" /*and MovimentiMixPosture.cod_mdep = mtb_depo_posizioni.cod_mdep*/\n" +
|
||||
" and MovimentiMixPosture.Posizione_da = mtb_depo_posizioni.posizione\n" +
|
||||
" \n" +
|
||||
" union all\n" +
|
||||
"\n" +
|
||||
" --Carichi e scarichi da movimenti normali (inventari, ddt di vendita, etc)\n" +
|
||||
" Select dtb_doct.data_reg,\n" +
|
||||
" dtb_doct.data_ins,\n" +
|
||||
" dtb_doct.cod_mdep,\n" +
|
||||
" dtb_doct.gestione,\n" +
|
||||
" dtb_doct.cod_anag,\n" +
|
||||
" gtb_anag.rag_soc,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_tipi.descrizione as causale,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_docr.posizione,\n" +
|
||||
" mtb_depo_posizioni.descrizione as descrizione_posizione,\n" +
|
||||
" mtb_depo_posizioni.capacita,\n" +
|
||||
" dtb_docr.cod_mart,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" dtb_docr.partita_mag,\n" +
|
||||
" dtb_docr.qta_doc * dtb_docr.rap_conv * (segno_qta_car) as qta_Car,\n" +
|
||||
" dtb_docr.qta_doc * dtb_docr.rap_conv * (segno_qta_scar) as qta_sCar,\n" +
|
||||
" dtb_doct.cod_prod,\n" +
|
||||
" dtb_doct.partita_mag as partita_mag_prod\n" +
|
||||
" from dtb_doct,\n" +
|
||||
" dtb_docr\n" +
|
||||
" left outer join mtb_depo_posizioni on dtb_docr.posizione = mtb_depo_posizioni.posizione,\n" +
|
||||
" dtb_tipi,\n" +
|
||||
" gtb_anag,\n" +
|
||||
" mtb_aart\n" +
|
||||
" Where dtb_doct.cod_anag = dtb_docr.cod_anag\n" +
|
||||
" and dtb_doct.cod_dtip = dtb_docr.cod_dtip\n" +
|
||||
" and dtb_doct.data_doc = dtb_docr.data_doc\n" +
|
||||
" and dtb_doct.ser_doc = dtb_docr.ser_doc\n" +
|
||||
" and dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" and dtb_doct.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" and dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" and dtb_docr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" and dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" and dtb_docr.posizione is not null\n" +
|
||||
" and dtb_doct.activity_id is null\n" +
|
||||
" and dtb_docr.cod_mart not in (select cod_mart from olvw_miscele_olio)\n" +
|
||||
")\n" +
|
||||
"\n" +
|
||||
"select data_reg,\n" +
|
||||
" data_ins,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" gestione,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc,\n" +
|
||||
" cod_dtip,\n" +
|
||||
" causale,\n" +
|
||||
" data_doc,\n" +
|
||||
" ser_doc,\n" +
|
||||
" num_doc,\n" +
|
||||
" Posizione,\n" +
|
||||
" descrizione_posizione,\n" +
|
||||
" capacita,\n" +
|
||||
" cod_mart,\n" +
|
||||
" descrizione_Articolo,\n" +
|
||||
" partita_mag,\n" +
|
||||
" sum(qta_Car) as qta_car,\n" +
|
||||
" sum(qta_Scar) as qta_scar,\n" +
|
||||
" cod_prod,\n" +
|
||||
" partita_mag_prod\n" +
|
||||
"from movi\n" +
|
||||
"group by data_reg,\n" +
|
||||
" data_ins,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" gestione,\n" +
|
||||
" cod_anag,\n" +
|
||||
" rag_soc,\n" +
|
||||
" cod_dtip,\n" +
|
||||
" causale,\n" +
|
||||
" data_doc,\n" +
|
||||
" ser_doc,\n" +
|
||||
" num_doc,\n" +
|
||||
" Posizione,\n" +
|
||||
" descrizione_posizione,\n" +
|
||||
" capacita,\n" +
|
||||
" cod_mart,\n" +
|
||||
" descrizione_Articolo,\n" +
|
||||
" partita_mag,\n" +
|
||||
" cod_prod,\n" +
|
||||
" partita_mag_prod");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,187 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250923113155 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isTextiles())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("ftx_getDisponibilitaArticoli", "CREATE FUNCTION [dbo].[ftx_getDisponibilitaArticoli](@datavalidita DATETIME,\n" +
|
||||
" @codmdep VARCHAR(8000),\n" +
|
||||
" @annostag VARCHAR(10),\n" +
|
||||
" @codmart VARCHAR(15),\n" +
|
||||
" @codtagl VARCHAR(15),\n" +
|
||||
" @codcol VARCHAR(15),\n" +
|
||||
" @barcode VARCHAR(15))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN\n" +
|
||||
" WITH setup AS (SELECT mtb_depo.cod_mdep,\n" +
|
||||
" MAX(IIF(stb_gest_setup.key_section = 'INCLUDI_QTA_ORD_FOR',\n" +
|
||||
" ISNULL(stb_gest_setup_depo.value, stb_gest_setup.value),\n" +
|
||||
" NULL)) AS includi_qta_ord_for,\n" +
|
||||
" MAX(IIF(stb_gest_setup.key_section = 'ESCLUDI_QTA_COLLI',\n" +
|
||||
" ISNULL(stb_gest_setup_depo.value, 'S'), NULL)) AS ESCLUDI_QTA_COLLI\n" +
|
||||
" FROM mtb_depo\n" +
|
||||
" CROSS APPLY stb_gest_setup\n" +
|
||||
" LEFT OUTER JOIN stb_gest_setup_depo\n" +
|
||||
" ON mtb_depo.cod_mdep = stb_gest_setup_depo.cod_mdep AND\n" +
|
||||
" stb_gest_setup.gest_name = stb_gest_setup_depo.gest_name AND\n" +
|
||||
" stb_gest_setup.section = stb_gest_setup_depo.section AND\n" +
|
||||
" stb_gest_setup.key_section = stb_gest_setup_depo.key_section\n" +
|
||||
" WHERE stb_gest_setup.gest_name = 'DATI_AZIENDA'\n" +
|
||||
" AND stb_gest_setup.section = 'CALCOLO_DISPONIBILITA'\n" +
|
||||
" AND stb_gest_setup.key_section IN ('INCLUDI_QTA_ORD_FOR', 'ESCLUDI_QTA_COLLI')\n" +
|
||||
" GROUP BY mtb_depo.cod_mdep),\n" +
|
||||
" articoli AS (SELECT ttb_style.anno_stag,\n" +
|
||||
" ttb_style.cod_style,\n" +
|
||||
" ttb_style_colori.cod_col,\n" +
|
||||
" ttb_style_taglie.cod_tagl,\n" +
|
||||
" mtb_part_dt.qta_ord_for,\n" +
|
||||
" mtb_part_dt.cod_mdep\n" +
|
||||
" FROM ttb_style,\n" +
|
||||
" ttb_style_colori,\n" +
|
||||
" ttb_style_taglie,\n" +
|
||||
" mtb_part_dt\n" +
|
||||
" WHERE (@codmdep IS NULL OR mtb_part_dt.cod_mdep IN (SELECT value_string AS cod_mdep\n" +
|
||||
" FROM parsestringintoarray(@codmdep, ',')))\n" +
|
||||
" AND (@codmart IS NULL OR ttb_style.cod_style = @codmart)\n" +
|
||||
" AND (@codcol IS NULL OR ttb_style_colori.cod_col = @codcol)\n" +
|
||||
" AND (@codtagl IS NULL OR ttb_style_taglie.cod_tagl = @codtagl)\n" +
|
||||
" AND (@annostag IS NULL OR ttb_style.anno_stag = @annostag)\n" +
|
||||
" AND ttb_style.cod_style = mtb_part_dt.cod_mart\n" +
|
||||
" AND ttb_style_colori.cod_col = mtb_part_dt.cod_col\n" +
|
||||
" AND ttb_style_taglie.cod_tagl = mtb_part_dt.cod_tagl\n" +
|
||||
" AND ttb_style.cod_style = ttb_style_colori.cod_style\n" +
|
||||
" AND ttb_style.cod_style = ttb_style_taglie.cod_style),\n" +
|
||||
" colli AS (SELECT mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" SUM(mtb_colr.qta_col) AS qta,\n" +
|
||||
" mtb_colt.cod_mdep\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" LEFT OUTER JOIN dtb_tipi ON mtb_colt.cod_dtip = dtb_tipi.cod_dtip,\n" +
|
||||
" mtb_colr\n" +
|
||||
" WHERE mtb_colt.gestione = mtb_colr.gestione\n" +
|
||||
" AND mtb_colt.data_collo = mtb_colr.data_collo\n" +
|
||||
" AND mtb_colt.ser_collo = mtb_colr.ser_collo\n" +
|
||||
" AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
" AND mtb_colt.gestione = 'V'\n" +
|
||||
" AND (@codmdep IS NULL OR mtb_colt.cod_mdep IN (SELECT value_string AS cod_mdep\n" +
|
||||
" FROM parsestringintoarray(@codmdep, ',')))\n" +
|
||||
" AND (mtb_colt.cod_dtip IS NULL OR (dtb_tipi.segno_qta_car = 0 AND dtb_tipi.segno_qta_scar = 0))\n" +
|
||||
" AND (@codmart IS NULL OR mtb_colr.cod_mart = @codmart)\n" +
|
||||
" AND (@codcol IS NULL OR mtb_colr.cod_col = @codcol)\n" +
|
||||
" AND (@codtagl IS NULL OR mtb_colr.cod_tagl = @codtagl)\n" +
|
||||
" GROUP BY mtb_colr.cod_mart,\n" +
|
||||
" mtb_colr.cod_col,\n" +
|
||||
" mtb_colr.cod_tagl,\n" +
|
||||
" mtb_colt.cod_mdep),\n" +
|
||||
" prenotazione AS (SELECT wdtb_ordr.cod_mart,\n" +
|
||||
" wdtb_ordr.cod_col,\n" +
|
||||
" wdtb_ordr.cod_tagl,\n" +
|
||||
" SUM(wdtb_ordr.qta_ord) AS qta,\n" +
|
||||
" wdtb_ordt.cod_mdep\n" +
|
||||
" FROM wdtb_ordt,\n" +
|
||||
" wdtb_ordr\n" +
|
||||
" WHERE wdtb_ordt.gestione = wdtb_ordr.gestione\n" +
|
||||
" AND wdtb_ordt.data_ord = wdtb_ordr.data_ord\n" +
|
||||
" AND wdtb_ordt.num_ord = wdtb_ordr.num_ord\n" +
|
||||
" AND wdtb_ordt.gestione = 'V'\n" +
|
||||
" AND (@codmdep IS NULL OR wdtb_ordt.cod_mdep IN (SELECT value_string AS cod_mdep\n" +
|
||||
" FROM parsestringintoarray(@codmdep, ',')))\n" +
|
||||
" AND wdtb_ordt.flag_elaborato = 'N'\n" +
|
||||
" AND (@codmart IS NULL OR wdtb_ordr.cod_mart = @codmart)\n" +
|
||||
" AND (@codcol IS NULL OR wdtb_ordr.cod_col = @codcol)\n" +
|
||||
" AND (@codtagl IS NULL OR wdtb_ordr.cod_tagl = @codtagl)\n" +
|
||||
" GROUP BY wdtb_ordr.cod_mart,\n" +
|
||||
" wdtb_ordr.cod_col,\n" +
|
||||
" wdtb_ordr.cod_tagl,\n" +
|
||||
" wdtb_ordt.cod_mdep),\n" +
|
||||
" ordine AS (SELECT dtb_ordr.cod_mart,\n" +
|
||||
" dtb_ordr.cod_col,\n" +
|
||||
" dtb_ordr.cod_tagl,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN SUM(CASE\n" +
|
||||
" WHEN dtb_ordr.flag_evaso = 'I' OR\n" +
|
||||
" (dtb_ordr.flag_evaso = 'A' AND dtb_ordr.qta_acc > 0)\n" +
|
||||
" THEN dtb_ordr.qta_ord - dtb_ordr.qta_evasa - dtb_ordr.qta_col\n" +
|
||||
" ELSE 0 END) > 0 THEN\n" +
|
||||
" SUM(CASE\n" +
|
||||
" WHEN dtb_ordr.flag_evaso = 'I' OR\n" +
|
||||
" (dtb_ordr.flag_evaso = 'A' AND dtb_ordr.qta_acc > 0)\n" +
|
||||
" THEN dtb_ordr.qta_ord - dtb_ordr.qta_evasa - dtb_ordr.qta_col\n" +
|
||||
" ELSE 0 END)\n" +
|
||||
" ELSE 0 END AS qta,\n" +
|
||||
" SUM(dtb_ordr.qta_acc) AS qta_acc,\n" +
|
||||
" /*sum(dtb_ordr.qta_acc - dtb_ordr.qta_col) as qta_acc,*/\n" +
|
||||
" dtb_ordt.cod_mdep\n" +
|
||||
" FROM dtb_ordt,\n" +
|
||||
" dtb_ordr\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" +
|
||||
" AND dtb_ordt.gestione = 'V'\n" +
|
||||
" AND (@codmdep IS NULL OR dtb_ordt.cod_mdep IN (SELECT value_string AS cod_mdep\n" +
|
||||
" FROM parsestringintoarray(@codmdep, ',')))\n" +
|
||||
" /* AND dtb_ordr.flag_evaso = 'I'*/\n" +
|
||||
" AND dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND (@codmart IS NULL OR dtb_ordr.cod_mart = @codmart)\n" +
|
||||
" AND (@codcol IS NULL OR dtb_ordr.cod_col = @codcol)\n" +
|
||||
" AND (@codtagl IS NULL OR dtb_ordr.cod_tagl = @codtagl)\n" +
|
||||
" GROUP BY dtb_ordr.cod_mart,\n" +
|
||||
" dtb_ordr.cod_col,\n" +
|
||||
" dtb_ordr.cod_tagl,\n" +
|
||||
" dtb_ordt.cod_mdep)\n" +
|
||||
"\n" +
|
||||
" SELECT articoli.anno_stag,\n" +
|
||||
" articoli.cod_style,\n" +
|
||||
" articoli.cod_col,\n" +
|
||||
" articoli.cod_tagl,\n" +
|
||||
" ttb_bar_code.cod_barre,\n" +
|
||||
" articoli.cod_mdep,\n" +
|
||||
" ISNULL(giacenza.qta_fine, 0) AS giacenza,\n" +
|
||||
" ISNULL(articoli.qta_ord_for, 0) AS ord_forn,\n" +
|
||||
" ISNULL(ordine.qta, 0) AS ordini,\n" +
|
||||
" ISNULL(prenotazione.qta, 0) AS ordini_web,\n" +
|
||||
" ISNULL(ordine.qta_acc, 0) AS accant_su_ordine,\n" +
|
||||
" ISNULL(colli.qta, 0) AS colli,\n" +
|
||||
" ISNULL(giacenza.qta_fine, 0) - ISNULL(ordine.qta, 0) - ISNULL(prenotazione.qta, 0) +\n" +
|
||||
" IIF(setup.includi_qta_ord_for = 'S', ISNULL(articoli.qta_ord_for, 0), 0) -\n" +
|
||||
" IIF(setup.ESCLUDI_QTA_COLLI = 'S', ISNULL(colli.qta, 0), 0) AS qta_disp,\n" +
|
||||
" ISNULL(giacenza.qta_fine, 0) - ISNULL(ordine.qta_acc, 0) - ISNULL(colli.qta, 0) AS qta_distrib_su_ordini\n" +
|
||||
" FROM articoli\n" +
|
||||
" LEFT OUTER JOIN ttb_bar_code ON articoli.cod_style = ttb_bar_code.cod_style AND\n" +
|
||||
" articoli.cod_col = ttb_bar_code.cod_col AND\n" +
|
||||
" articoli.cod_tagl = ttb_bar_code.cod_tagl\n" +
|
||||
" LEFT OUTER JOIN getsitartadatadett(@datavalidita, @codmdep) giacenza\n" +
|
||||
" ON articoli.cod_style = giacenza.cod_mart AND articoli.cod_col = giacenza.cod_col AND\n" +
|
||||
" articoli.cod_tagl = giacenza.cod_tagl AND articoli.cod_mdep = giacenza.cod_mdep\n" +
|
||||
" LEFT OUTER JOIN ordine\n" +
|
||||
" ON articoli.cod_style = ordine.cod_mart AND articoli.cod_col = ordine.cod_col AND\n" +
|
||||
" articoli.cod_tagl = ordine.cod_tagl AND articoli.cod_mdep = ordine.cod_mdep\n" +
|
||||
" LEFT OUTER JOIN prenotazione ON articoli.cod_style = prenotazione.cod_mart AND\n" +
|
||||
" articoli.cod_col = prenotazione.cod_col AND\n" +
|
||||
" articoli.cod_tagl = prenotazione.cod_tagl AND\n" +
|
||||
" articoli.cod_mdep = prenotazione.cod_mdep\n" +
|
||||
" LEFT OUTER JOIN colli ON articoli.cod_style = colli.cod_mart AND articoli.cod_col = colli.cod_col AND\n" +
|
||||
" articoli.cod_tagl = colli.cod_tagl AND articoli.cod_mdep = colli.cod_mdep\n" +
|
||||
" left outer join setup on setup.cod_mdep = articoli.cod_mdep\n" +
|
||||
" WHERE (@barcode IS NULL OR ttb_bar_code.cod_barre = @barcode)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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_20250923115203 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.FolliesGroup)) {
|
||||
|
||||
updateSetupValue("DATI_AZIENDA", "SETUP", "DELIMITED_IDENTIFIER", "1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250923132435 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("f_getCodEsenz", "CREATE FUNCTION [dbo].[f_getCodEsenz](@gestione varchar(1), @codAnag varchar(5), @codVdes varchar(5))\n" +
|
||||
"RETURNS varchar(5) \n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
" DECLARE @ls_codAliqCli VARCHAR(5),\n" +
|
||||
" @ls_codAliqForn VARCHAR(5),\n" +
|
||||
" @ls_codAliqIn VARCHAR(5),\n" +
|
||||
" @ls_codAliqOut VARCHAR(5),\n" +
|
||||
" @ls_codesenz VARCHAR(5),\n" +
|
||||
" @existCodAnag INTEGER;\n" +
|
||||
" \n" +
|
||||
" SELECT @existCodAnag = 0\n" +
|
||||
" SELECT @ls_codAliqCli = vtb_clie.cod_aliq,\n" +
|
||||
" @ls_codAliqForn = atb_forn.cod_aliq,\n" +
|
||||
" @ls_codAliqIn = vtb_dest.cod_aliq_in,\n" +
|
||||
" @ls_codAliqOut = vtb_dest.cod_aliq_out,\n" +
|
||||
" @existCodAnag = 1\n" +
|
||||
" FROM gtb_anag LEFT OUTER JOIN vtb_clie ON vtb_clie.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" LEFT OUTER JOIN atb_forn ON atb_forn.cod_anag = @codAnag\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON vtb_dest.cod_vdes = @codVdes AND\n" +
|
||||
" vtb_dest.cod_anag = @codAnag\n" +
|
||||
" WHERE gtb_anag.cod_anag = @codAnag;\n" +
|
||||
"\n" +
|
||||
" IF @gestione = 'V' and @existCodAnag = 0\n" +
|
||||
" begin\n" +
|
||||
" select @ls_codAliqIn = ptb_dest.cod_aliq_in,\n" +
|
||||
" @ls_codAliqOut = ptb_dest.cod_aliq_out\n" +
|
||||
" from ptb_dest \n" +
|
||||
" where cod_ppro = @codAnag AND\n" +
|
||||
" cod_pdes = @codVdes;\n" +
|
||||
" end\n" +
|
||||
" \n" +
|
||||
" if @ls_codAliqIn is null and @ls_codAliqOut is not null\n" +
|
||||
" SELECT @ls_codesenz = @ls_codAliqOut\n" +
|
||||
" \n" +
|
||||
" if @gestione <>'V'\n" +
|
||||
" SELECT @ls_codAliqCli = @ls_codAliqForn\n" +
|
||||
" \n" +
|
||||
" if @ls_codesenz is null and @ls_codAliqCli is not null \n" +
|
||||
" SELECT @ls_codEsenz = @ls_codAliqCli\n" +
|
||||
" \n" +
|
||||
" RETURN @ls_codEsenz;\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@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.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250923171606 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("alter table dbo.wtb_depo add default_depo tinyint not null default 0",
|
||||
"create unique index ux_wtb_depo_depo_default_utente\n" +
|
||||
" on dbo.wtb_depo (user_name)\n" +
|
||||
" where default_depo = 1");
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Biolevante_Biolevante)){
|
||||
executeStatement("update wtb_depo set default_depo = 1 where cod_mdep = '01'");
|
||||
}
|
||||
}
|
||||
|
||||
@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_20250924151610 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetupQuery("COD_PROMO_TAGLI", "Query per selezionare i tagli prezzo", "SELECT COD_PROMO FROM VTB_PROMO WHERE flag_tipo_promo = 'T'");
|
||||
executeStatement("update stb_gest_setup\n" +
|
||||
"set query_default = 'c' where gest_name = 'pvm' and section = 'CHIUSURA_TAGLI_PREZZO'\n" +
|
||||
"and key_section ='COD_PROMO_TAGLI' ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250925130833 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Carelli))
|
||||
return;
|
||||
|
||||
|
||||
updateSetupValue("DATI_AZIENDA", "SETUP", "LOGIN_OVER_WEBSERVICES", "S");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250925133902 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isTextiles()) return;
|
||||
|
||||
|
||||
executeStatement(
|
||||
"alter table ttb_grtg_el add range_taglie tinyint DEFAULT 1; ",
|
||||
"update ttb_grtg_el set range_taglie = 1; ",
|
||||
"alter table ttb_grtg_el alter column range_taglie tinyint NOT NULL; ",
|
||||
"create table ttb_qta_min_ord ( " +
|
||||
" cod_style varchar(15) not null, " +
|
||||
" cod_grtg varchar(5) not null, " +
|
||||
" range_taglie tinyint not null, " +
|
||||
" qta_min_ord numeric(20,5) not null default 0) ",
|
||||
"alter table ttb_qta_min_ord ADD constraint pk_ttb_qta_min_ord primary key (cod_style, cod_grtg, range_taglie, qta_min_ord); ",
|
||||
"ALTER TABLE dbo.ttb_qta_min_ord WITH CHECK ADD CONSTRAINT fk_ttb_qta_min_ord_ttb_style FOREIGN KEY(cod_style) REFERENCES dbo.ttb_style ( cod_style )",
|
||||
"ALTER TABLE dbo.ttb_qta_min_ord WITH CHECK ADD CONSTRAINT fk_ttb_qta_min_ord_ttb_grtg FOREIGN KEY(cod_grtg) REFERENCES dbo.ttb_grtg ( cod_grtg )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250925145607 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("f_GetCostoUltArt_depo", "CREATE FUNCTION [dbo].[f_GetCostoUltArt_depo](@dataReg datetime, @codMdep varchar(5), @codMart varchar(15))\n" +
|
||||
"RETURNS numeric(20,5) AS\n" +
|
||||
"BEGIN\n" +
|
||||
" /* UFFICIALE DEL 20-06-2016 */\n" +
|
||||
" DECLARE @lc_costoUltUnt numeric(20,5),\n" +
|
||||
" @lc_costoComp numeric(20,5),\n" +
|
||||
" @ls_codComp varchar(15),\n" +
|
||||
" @lc_qtaStd numeric(20,5),\n" +
|
||||
" @ls_flagCalcPrzAcq varchar(1),\n" +
|
||||
" @ls_isKit varchar(1),\n" +
|
||||
" @ls_idArtEqui varchar(40),\n" +
|
||||
" @ls_flagUltCostoEqui varchar(1),\n" +
|
||||
" @ls_flagArticoloMov varchar(1),\n" +
|
||||
" @ls_codMartEqui varchar(40),\n" +
|
||||
" @ldt_dataDocMax datetime,\n" +
|
||||
" @lc_qtaCarTot numeric(20,5),\n" +
|
||||
" @lc_valCarTot numeric(20,5);\n" +
|
||||
" \n" +
|
||||
" select @ls_isKit = 'N';\n" +
|
||||
" \n" +
|
||||
" select @codMdep = (case when value = 'S' AND @codMdep is not null then @codMdep else null end) \n" +
|
||||
" from stb_gest_setup where gest_name = 'dati_azienda' and section = 'COSTO_ULTIMO' AND key_section = 'COSTO_DA_DEPO' \n" +
|
||||
"\n" +
|
||||
" Declare csr_comp Cursor LOCAL SCROLL FOR\n" +
|
||||
" SELECT mtb_comp.cod_comp, \n" +
|
||||
" mtb_comp.qta_std,\n" +
|
||||
" mtb_aart.flag_calc_prz_acq \n" +
|
||||
" FROM mtb_comp,\n" +
|
||||
" mtb_aart\n" +
|
||||
" WHERE mtb_comp.cod_mart = @codMart and\n" +
|
||||
" mtb_aart.cod_mart = mtb_comp.cod_mart and\n" +
|
||||
" mtb_aart.articolo_composto = 'S' ;\n" +
|
||||
" OPEN csr_comp\n" +
|
||||
" FETCH NEXT FROM csr_comp INTO @ls_codComp, @lc_qtaStd, @ls_flagCalcPrzAcq\n" +
|
||||
" if @@CURSOR_ROWS > 0\n" +
|
||||
" begin\n" +
|
||||
"\n" +
|
||||
" select @ls_isKit = 'S'\n" +
|
||||
" SELECT @lc_costoUltUnt = 0 \n" +
|
||||
" if @ls_flagCalcPrzAcq = 'K' \n" +
|
||||
" begin\n" +
|
||||
" SELECT @lc_costoUltUnt = IsNull(Round(sum([dbo].[f_getPrzNettoAcqArt] (last_doc.data_doc,last_doc.listino,last_doc.cod_mart,last_doc.cod_art_for)) * last_doc.cambio / gtb_divi.cambio_euro , 5),0)\n" +
|
||||
" FROM dtb_docr, \n" +
|
||||
" gtb_anag,\n" +
|
||||
" (SELECT TOP 1 dtb_doct.cod_anag,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.cod_divi,\n" +
|
||||
" dtb_doct.cambio,\n" +
|
||||
" dtb_doct.listino,\n" +
|
||||
" dtb_docr.cod_mart,\n" +
|
||||
" dtb_docr.cod_art_for\n" +
|
||||
" FROM dtb_doct, \n" +
|
||||
" dtb_docr,\n" +
|
||||
" dtb_tipi\n" +
|
||||
" WHERE dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc and\n" +
|
||||
" dtb_doct.cod_dtip = dtb_tipi.cod_dtip and \n" +
|
||||
" dtb_tipi.segno_val_car = 1 and\n" +
|
||||
" dtb_tipi.gestione <> 'V' and\n" +
|
||||
" dtb_tipi.flag_costo = 'S' and\n" +
|
||||
" dtb_doct.data_doc <= @dataReg and\n" +
|
||||
" dtb_docr.cod_mart = @codMart and\n" +
|
||||
" dtb_doct.cod_mdep like IsNUll(@codMdep, '%')\n" +
|
||||
" ORDER BY dtb_doct.data_reg DESC ) last_doc, \n" +
|
||||
" mtb_aart,\n" +
|
||||
" gtb_divi\n" +
|
||||
" WHERE dtb_docr.cod_anag = last_doc.cod_anag and\n" +
|
||||
" dtb_docr.cod_dtip = last_doc.cod_dtip and\n" +
|
||||
" dtb_docr.data_doc = last_doc.data_doc and\n" +
|
||||
" dtb_docr.ser_doc = last_doc.ser_doc and\n" +
|
||||
" dtb_docr.num_doc = last_doc.num_doc and\n" +
|
||||
" dtb_docr.cod_mart = last_doc.cod_mart and\n" +
|
||||
" last_doc.cod_anag = gtb_anag.cod_anag and\n" +
|
||||
" dtb_docr.cod_mart = mtb_aart.cod_mart and\n" +
|
||||
" last_doc.cod_divi = gtb_divi.cod_divi and\n" +
|
||||
" mtb_aart.cod_mart = @codMart\n" +
|
||||
" group by last_doc.cambio , gtb_divi.cambio_euro \n" +
|
||||
" end\n" +
|
||||
" end\n" +
|
||||
" \n" +
|
||||
" if @lc_costoUltUnt = 0 or @ls_flagCalcPrzAcq = 'C'\n" +
|
||||
" begin\n" +
|
||||
" WHILE @@FETCH_STATUS = 0\n" +
|
||||
" Begin\n" +
|
||||
" select @lc_costoComp = dbo.f_GetCostoUltArt_depo(@dataReg, @codMdep, @ls_codComp)\n" +
|
||||
" select @lc_costoUltUnt = @lc_costoUltUnt + (@lc_costoComp * @lc_qtaStd)\n" +
|
||||
" FETCH NEXT FROM csr_comp INTO @ls_codComp, @lc_qtaStd, @ls_flagCalcPrzAcq\n" +
|
||||
" end\n" +
|
||||
" close csr_comp\n" +
|
||||
" deallocate csr_comp\n" +
|
||||
" end \n" +
|
||||
" select @ldt_dataDocMax = null;\n" +
|
||||
" if @ls_isKit = 'N' \n" +
|
||||
" begin\n" +
|
||||
" SELECT @ls_idArtEqui = mtb_aart.id_art_equi, \n" +
|
||||
" @ls_flagUltCostoEqui = mtb_aart_equi.flag_equi_costo, \n" +
|
||||
" @ls_flagArticoloMov = mtb_aart.flag_mov_art_mag \n" +
|
||||
" FROM mtb_aart_equi, mtb_aart \n" +
|
||||
" WHERE mtb_aart.id_art_equi = mtb_aart_equi.id_art_equi AND \n" +
|
||||
" mtb_aart.cod_mart = @codMart;\n" +
|
||||
" \n" +
|
||||
" if @ls_idArtEqui is not null and Len(@ls_idArtEqui) > 0 and (@ls_flagUltCostoEqui = 'S' )\n" +
|
||||
" begin\n" +
|
||||
" if @codMdep is null\n" +
|
||||
" begin\n" +
|
||||
" SELECT TOP 1 @ls_codMartEqui = mtb_movi.cod_mart, \n" +
|
||||
" @ldt_dataDocMax = Max(data_reg)\n" +
|
||||
" FROM mtb_movi, mtb_aart, dtb_tipi\n" +
|
||||
" WHERE mtb_aart.id_art_equi = @ls_idArtEqui and\n" +
|
||||
" mtb_movi.cod_mart = mtb_aart.cod_mart and\n" +
|
||||
" mtb_movi.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione <> 'V' and\n" +
|
||||
" dtb_tipi.flag_costo = 'S' and\n" +
|
||||
" qta_car > 0 AND val_car > 0 and\n" +
|
||||
" data_reg <= @dataReg\n" +
|
||||
" group by mtb_movi.cod_mart\n" +
|
||||
" order by 2 desc;\n" +
|
||||
" end \n" +
|
||||
" else\n" +
|
||||
" begin\n" +
|
||||
" SELECT TOP 1 @ls_codMartEqui = mtb_movi.cod_mart, \n" +
|
||||
" @ldt_dataDocMax = Max(data_reg) \n" +
|
||||
" FROM mtb_movi, mtb_aart, dtb_tipi\n" +
|
||||
" WHERE mtb_aart.id_art_equi = @ls_idArtEqui and\n" +
|
||||
" mtb_movi.cod_mart = mtb_aart.cod_mart and\n" +
|
||||
" mtb_movi.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione <> 'V' and\n" +
|
||||
" dtb_tipi.flag_costo = 'S' and\n" +
|
||||
" qta_car > 0 AND val_car > 0 and\n" +
|
||||
" cod_mdep = @codMdep and\n" +
|
||||
" data_reg <= @dataReg\n" +
|
||||
" group by mtb_movi.cod_mart\n" +
|
||||
" order by 2 desc;\n" +
|
||||
" end\n" +
|
||||
" select @codMart = @ls_codMartEqui; \n" +
|
||||
" end\n" +
|
||||
" else\n" +
|
||||
" begin\n" +
|
||||
" if @codMdep is null\n" +
|
||||
" SELECT @ldt_dataDocMax = Max(data_reg)\n" +
|
||||
" FROM mtb_movi, dtb_tipi\n" +
|
||||
" WHERE mtb_movi.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione <> 'V' and\n" +
|
||||
" dtb_tipi.flag_costo = 'S' and\n" +
|
||||
" cod_mart = @codMart AND data_reg <= @dataReg AND\n" +
|
||||
" qta_car > 0 AND val_car > 0 ;\n" +
|
||||
" else\n" +
|
||||
" SELECT @ldt_dataDocMax = Max(data_reg)\n" +
|
||||
" FROM mtb_movi, dtb_tipi\n" +
|
||||
" WHERE mtb_movi.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione <> 'V' and\n" +
|
||||
" dtb_tipi.flag_costo = 'S' and\n" +
|
||||
" cod_mart = @codMart AND data_reg <= @dataReg AND\n" +
|
||||
" qta_car > 0 AND val_car > 0 AND\n" +
|
||||
" cod_mdep = @codMdep;\n" +
|
||||
" end\n" +
|
||||
"\n" +
|
||||
" if @ldt_dataDocMax is null\n" +
|
||||
" begin\n" +
|
||||
" SELECT @lc_costoUltUnt = val_ult_car / cambio_divi_car\n" +
|
||||
" FROM mtb_aart\n" +
|
||||
" WHERE cod_mart = @codMart;\n" +
|
||||
" end \n" +
|
||||
" else\n" +
|
||||
" begin\n" +
|
||||
" IF @codMdep is null\n" +
|
||||
" SELECT @lc_qtaCarTot = sum(qta_car) , \n" +
|
||||
" @lc_valCarTot = sum(val_car_costo / cambio_divi_cont) \n" +
|
||||
" FROM mtb_movi, dtb_tipi\n" +
|
||||
" WHERE mtb_movi.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione <> 'V' and\n" +
|
||||
" dtb_tipi.flag_costo = 'S' and\n" +
|
||||
" cod_mart = @codMart AND \n" +
|
||||
" data_reg = @ldt_dataDocMax AND\n" +
|
||||
" (qta_car > 0 or (qta_car = 0 and val_car <> 0));\n" +
|
||||
" ELSE\n" +
|
||||
" SELECT @lc_qtaCarTot = sum(qta_car), \n" +
|
||||
" @lc_valCarTot = sum(val_car_costo /cambio_divi_cont)\n" +
|
||||
" FROM mtb_movi, \n" +
|
||||
" dtb_tipi\n" +
|
||||
" WHERE mtb_movi.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione <> 'V' and\n" +
|
||||
" dtb_tipi.flag_costo = 'S' and\n" +
|
||||
" cod_mart = @codMart AND \n" +
|
||||
" data_reg = @ldt_dataDocMax AND\n" +
|
||||
" (qta_car > 0 or (qta_car = 0 and val_car <> 0)) and\n" +
|
||||
" cod_mdep = @codMdep;\n" +
|
||||
" \n" +
|
||||
" select @lc_costoUltUnt =0\n" +
|
||||
" if @lc_qtaCarTot > 0 \n" +
|
||||
" select @lc_costoUltUnt = round(@lc_valCarTot / @lc_qtaCarTot, 5)\n" +
|
||||
" end\n" +
|
||||
" end\n" +
|
||||
" if @lc_costoUltUnt is null \n" +
|
||||
" SELECT @lc_costoUltUnt = 0\n" +
|
||||
" RETURN @lc_costoUltUnt\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@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.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250925151323 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (!isTextiles()) return;
|
||||
|
||||
executeStatement(
|
||||
"drop table ttb_qta_min_ord",
|
||||
"create table ttb_qta_min_ord (\n" +
|
||||
" id bigint identity,\n" +
|
||||
" cod_line varchar(5),\n" +
|
||||
" cod_style varchar(15),\n" +
|
||||
" cod_grtg varchar(5) not null,\n" +
|
||||
" range_taglie tinyint not null,\n" +
|
||||
" qta_min_ord numeric(20,5) not null default 0)",
|
||||
"alter table ttb_qta_min_ord ADD constraint pk_ttb_qta_min_ord primary key (id);",
|
||||
"create unique index ix_unique_ttb_qta_min_ord on ttb_qta_min_ord (cod_line, cod_style, cod_grtg);",
|
||||
"ALTER TABLE dbo.ttb_qta_min_ord WITH CHECK ADD CONSTRAINT fk_ttb_qta_min_ord_ttb_style FOREIGN KEY(cod_style) REFERENCES dbo.ttb_style ( cod_style )",
|
||||
"ALTER TABLE dbo.ttb_qta_min_ord WITH CHECK ADD CONSTRAINT fk_ttb_qta_min_ord_ttb_grtg FOREIGN KEY(cod_grtg) REFERENCES dbo.ttb_grtg ( cod_grtg )");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250926113139 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("w_mriassegna_costo_dlg", "LAVORAZIONE", "COSTO_DA_DISTINTA_SENZA_MDO", "N",
|
||||
"Se impostato a S e l'azienda non gestisce il costo sul deposito allora dal costo totale che viene dalla funzione di DB f_explode_dist verrà sottratto il cost della manodopera, sia il costo associato al servizio di MDO della distinta, sia l'eventuale costo MDO specificato nel ciclo di produzione della distinta", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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_20250926125635 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "ATTIVO", "N",
|
||||
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "EMAIL_FOR_LOG", null,
|
||||
"Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "FILE_FILTER", null,
|
||||
"Inserire il criterio di filtro dei file o il nome del file specifio (seguire la sintassi di java)", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "GG_CANC_FILE", null,
|
||||
"Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "IMPORT_REST", "S",
|
||||
"Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "LISTENING", "N",
|
||||
"Se LISTENIG = 'N' la procedura di importazione non si potrà mai mettere in ascolto sulla directory perchè nella procedura vengono prese in considerazione più file.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "PATH_FILE", null,
|
||||
"Directory contente i file da importare.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS", "PATH_FILE_IMPORTED", null,
|
||||
"Directory dove vengono spostati i file dopo l'importazione.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if (isCustomer(IntegryCustomer.Carelli))
|
||||
updateSetupValue("IMPORT_SCONTRINI", "MMPOS", "ATTIVO", "S");
|
||||
}
|
||||
|
||||
@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_20250926130028 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Maggio_MaggioSrl))
|
||||
return;
|
||||
|
||||
updateSetupValue("w_mriassegna_costo_dlg", "LAVORAZIONE", "COSTO_DA_DISTINTA_SENZA_MDO", "S",
|
||||
"Se impostato a S e l'azienda non gestisce il costo sul deposito allora dal costo totale che viene dalla funzione di DB f_explode_dist verrà sottratto il cost della manodopera, sia il costo associato al servizio di MDO della distinta, sia l'eventuale costo MDO specificato nel ciclo di produzione della distinta", false, null, false, false, false,
|
||||
false, false, null, false, null);
|
||||
|
||||
executeStatement("DELETE\n" +
|
||||
"FROM stb_gest_setup_depo\n" +
|
||||
"WHERE gest_name = 'w_mriassegna_costo_dlg'\n" +
|
||||
" AND section = 'LAVORAZIONE'\n" +
|
||||
" AND key_section = 'COSTO_DA_DISTINTA_SENZA_MDO'"
|
||||
);
|
||||
|
||||
executeStatement("DELETE\n" +
|
||||
"FROM wtb_gest_setup_user\n" +
|
||||
"WHERE gest_name = 'w_mriassegna_costo_dlg'\n" +
|
||||
" AND section = 'LAVORAZIONE'\n" +
|
||||
" AND key_section = 'COSTO_DA_DISTINTA_SENZA_MDO'"
|
||||
);
|
||||
}
|
||||
|
||||
@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_20250926131536 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_SCONTRINI", "MMPOS_SERVICES", "COD_VOUCHER", null,
|
||||
"elenco dei codici utilizzati per i voucher ( separati da |)", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if ( isCustomer(IntegryCustomer.Carelli))
|
||||
updateSetupValue("IMPORT_SCONTRINI", "MMPOS_SERVICES", "COD_VOUCHER", "655783_0-L");
|
||||
|
||||
}
|
||||
|
||||
@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_20250929103228 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("alter table jtb_rlavt add note_agg varchar(max)");
|
||||
}
|
||||
|
||||
@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_20250929103932 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("w_jriep_presenze_dip_disp", "CB_AGGNOTE", "VISIBLE", "N",
|
||||
null, false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if (isCustomer(IntegryCustomer.Integry)) {
|
||||
updateSetupValue("w_jriep_presenze_dip_disp", "CB_AGGNOTE", "VISIBLE", "S");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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_20250929111320 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
deleteSetup("w_jriep_presenze_dip_disp", "CB_AGGNOTE", "VISIBLE");
|
||||
|
||||
executeStatement("create table mtb_var_lisv_log (\n" +
|
||||
"id bigint identity,\n" +
|
||||
"datetime_var datetime not null,\n" +
|
||||
"user_name varchar(40),\n" +
|
||||
"cod_vlis varchar(5) not null, \n" +
|
||||
"versione int not null,\n" +
|
||||
"cod_promo varchar(10), \n" +
|
||||
"data_iniz datetime,\n" +
|
||||
"data_fine datetime,\n" +
|
||||
"cod_mart varchar(15),\n" +
|
||||
"note varchar(max))\n" ,
|
||||
"alter table mtb_var_lisv_log add constraint pk_mtb_var_lisv_log primary key ( id ) ");
|
||||
|
||||
if (isCustomer(IntegryCustomer.Carelli)) {
|
||||
executeStatement("update stb_abil set flag_abil = 'R'\n" +
|
||||
"where gest_name = 'vpromo'\n" +
|
||||
"and user_name not in ('Apapapicco', 'Gmezzapesa')\n" +
|
||||
"and flag_abil not in ('N', 'R')");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250929124316 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isDMS())
|
||||
return;
|
||||
|
||||
executeStatement("alter table vtb_dest alter column cod_affiliazione varchar(40)");
|
||||
|
||||
createOrUpdateFunction("getDocuPrint_generica", "CREATE FUNCTION [dbo].[getDocuPrint_generica]\n" +
|
||||
"( \n" +
|
||||
" @codAnag varchar(5), @codDtip varchar(5), @dataDoc datetime, @serDoc varchar(2), @numDoc int\n" +
|
||||
")\n" +
|
||||
"RETURNS TABLE \n" +
|
||||
"AS\n" +
|
||||
"RETURN \n" +
|
||||
"\n" +
|
||||
"WITH righe_doc as (\n" +
|
||||
" /*righe documento diretto */\n" +
|
||||
" select dtb_docr.cod_anag, dtb_docr.cod_dtip, dtb_docr.data_doc, dtb_docr.ser_doc, dtb_docr.num_doc, id_riga, null as tipo_cessione, \n" +
|
||||
" dtb_docr.cod_mart, mtb_aart.tipo_codice as tipo_codice_ean, mtb_aart.bar_code, \n" +
|
||||
" CASE WHEN len(dtb_docr.descrizione_estesa)>0 then dtb_docr.descrizione_estesa ELSE dtb_docr.descrizione END as descrizione, dtb_docr.descrizione as descrizione_breve, \n" +
|
||||
" convert(varchar(5), null) as cod_spes, dtb_docr.unt_doc, dtb_docr.qta_doc, dtb_docr.qta_cnf, dtb_docr.num_cnf, dtb_docr.val_unt, dtb_docr.val_unt_iva, \n" +
|
||||
" dtb_docr.sconto5, dtb_docr.sconto6, dtb_docr.sconto7, dtb_docr.sconto8, dtb_docr.importo_riga as importo_riga, \n" +
|
||||
" dtb_docr.cod_aliq, gtb_aliq.perc_aliq, CASE WHEN dtb_docr.cod_aliq is null THEN 'N2.2' ELSE gtb_aliq.natura END as natura, \n" +
|
||||
" dtb_docr.cod_kit, composto.descrizione as descr_kit, dtb_docr.partita_mag, dtb_docr.matricola, dtb_docr.data_iniz_comp, dtb_docr.data_fine_comp, dtb_docr.cod_jcom, \n" +
|
||||
" dtb_ordt.gestione, dtb_ordt.data_ord, dtb_ordt.num_ord, dtb_ordt.rif_ord, dtb_ordt.rif_data_ord, dtb_ordt.rif_num_ord, \n" +
|
||||
" dtb_doct.cod_dtip_val, dtb_doct.data_doc_val, dtb_doct.ser_doc_val, dtb_doct.num_doc_val, dtb_doct.num_doc_forn\n" +
|
||||
" from dtb_docr inner join dtb_doct \n" +
|
||||
" on dtb_docr.cod_anag = dtb_doct.cod_anag \n" +
|
||||
" and dtb_docr.cod_dtip = dtb_doct.cod_dtip\n" +
|
||||
" and dtb_docr.data_doc = dtb_doct.data_doc\n" +
|
||||
" and dtb_docr.ser_doc = dtb_doct.ser_doc\n" +
|
||||
" and dtb_docr.num_doc = dtb_doct.num_doc \n" +
|
||||
" left outer join dtb_ordt \n" +
|
||||
" on dtb_doct.gestione = dtb_ordt.gestione \n" +
|
||||
" and dtb_docr.data_ord = dtb_ordt.data_ord\n" +
|
||||
" and dtb_docr.num_ord = dtb_ordt.num_ord\n" +
|
||||
" left outer join gtb_aliq \n" +
|
||||
" on dtb_docr.cod_aliq = gtb_aliq.cod_aliq \n" +
|
||||
" left outer join (select cod_mart, descrizione, articolo_composto from mtb_aart) as composto \n" +
|
||||
" on composto.cod_mart = dtb_docr.cod_kit\n" +
|
||||
" left outer join mtb_aart on dtb_docr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" where dtb_doct.cod_anag = @codAnag and \n" +
|
||||
" dtb_doct.cod_dtip_val = @codDtip and \n" +
|
||||
" dtb_doct.data_doc_val = @dataDoc and \n" +
|
||||
" dtb_doct.ser_doc_val = @serDoc and \n" +
|
||||
" dtb_doct.num_doc_val = @numDoc and\n" +
|
||||
" /*esclusione degli articoli composti che vengono esplosi nel documento*/\n" +
|
||||
" not((composto.articolo_composto = 'S' and dtb_docr.cod_mart is null AND dtb_docr.qta_doc <> 0 and cod_kit is not null) OR \n" +
|
||||
" (composto.articolo_composto = 'N' and dtb_docr.cod_mart is NOT null AND dtb_docr.qta_doc <> 0 and cod_kit is not null and gtb_aliq.tipo_iva = 'IVA COMPOSTA') )\n" +
|
||||
" AND dtb_docr.descrizione NOT LIKE 'DDT N. %' \n" +
|
||||
" AND dtb_docr.descrizione NOT LIKE 'BOLLA N. %' \n" +
|
||||
" AND dtb_docr.descrizione NOT LIKE 'Rif.N.%' \n" +
|
||||
" UNION ALL \n" +
|
||||
" select dtb_docr.cod_anag, dtb_docr.cod_dtip, dtb_docr.data_doc, dtb_docr.ser_doc, dtb_docr.num_doc, id_riga, 'SC' as tipo_cessione, null as cod_mart, null as tipo_codice_ean, null as bar_code,\n" +
|
||||
" 'Omaggio con Rivalsa IVA -' + dtb_docr.descrizione, dtb_docr.descrizione as descrizione_breve, null as cod_spes,\n" +
|
||||
" null as unt_doc, 1 as qta_doc, null as qta_cnf, null as num_cnf, dtb_docr.qta_doc * dtb_docr.val_unt as val_unt, \n" +
|
||||
" dtb_docr.qta_doc * dtb_docr.val_unt_iva as val_unt_iva, 0 as sconto5, 0 as sconto6, 0 as sconto7, 0 as sconto8, dtb_docr.qta_doc * dtb_docr.val_unt as importo_riga, \n" +
|
||||
" dtb_docr.cod_aliq, gtb_aliq.perc_aliq, gtb_aliq.natura, \n" +
|
||||
" null as cod_kit, null as descr_kit, null as partita_mag, null as matricola, null as data_iniz_comp, null as data_fine_comp, null as cod_jcom,\n" +
|
||||
" dtb_ordt.gestione, dtb_ordt.data_ord, dtb_ordt.num_ord, dtb_ordt.rif_ord, dtb_ordt.rif_data_ord, dtb_ordt.rif_num_ord, \n" +
|
||||
" dtb_doct.cod_dtip_val, dtb_doct.data_doc_val, dtb_doct.ser_doc_val, dtb_doct.num_doc_val, dtb_doct.num_doc_forn\n" +
|
||||
" from dtb_docr inner join dtb_doct \n" +
|
||||
" on dtb_docr.cod_anag = dtb_doct.cod_anag \n" +
|
||||
" and dtb_docr.cod_dtip = dtb_doct.cod_dtip \n" +
|
||||
" and dtb_docr.data_doc = dtb_doct.data_doc \n" +
|
||||
" and dtb_docr.ser_doc = dtb_doct.ser_doc \n" +
|
||||
" and dtb_docr.num_doc = dtb_doct.num_doc \n" +
|
||||
" left outer join dtb_ordt \n" +
|
||||
" on dtb_doct.gestione = dtb_ordt.gestione \n" +
|
||||
" and dtb_docr.data_ord = dtb_ordt.data_ord \n" +
|
||||
" and dtb_docr.num_ord = dtb_ordt.num_ord \n" +
|
||||
" left outer join gtb_aliq \n" +
|
||||
" on dtb_docr.cod_aliq = gtb_aliq.cod_aliq \n" +
|
||||
" where dtb_doct.cod_anag = @codAnag \n" +
|
||||
" and dtb_doct.cod_dtip_val = @codDtip \n" +
|
||||
" and dtb_doct.data_doc_val = @dataDoc \n" +
|
||||
" and dtb_doct.ser_doc_val = @serDoc \n" +
|
||||
" and dtb_doct.num_doc_val = @numDoc \n" +
|
||||
" and (dtb_docr.sconto5 = 100 OR dtb_docr.sconto6 = 100 ) and gtb_aliq.perc_aliq >0\n" +
|
||||
" ) ,\n" +
|
||||
" \n" +
|
||||
" righe_doc_val as (\n" +
|
||||
" /*acquisizione dell'id_riga delle bolle in caso di documento differito per riportare lo stesso ordinamento */\n" +
|
||||
" select id_riga, dtb_docr.cod_anag, SUBSTRING(descrizione_estesa, 1, CHARINDEX( 'N.', descrizione_estesa, 1) - 2 ) as cod_dtip, \n" +
|
||||
" convert (datetime,\n" +
|
||||
" CASE WHEN CHARINDEX(' Rif.', descrizione_estesa) > 0 THEN \n" +
|
||||
" SUBSTRING(CASE WHEN CHARINDEX(' Dest.', descrizione_estesa) > 0 THEN \n" +
|
||||
" SUBSTRING(descrizione_estesa, CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') +1 , CHARINDEX(' Dest.', descrizione_estesa) - ( CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') ) -1 ) ELSE \n" +
|
||||
" SUBSTRING(descrizione_estesa, CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') +1 , len(descrizione_estesa) - ( CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') ))\n" +
|
||||
" END, 1, CHARINDEX(' Rif.', CASE WHEN CHARINDEX(' Dest.', descrizione_estesa) > 0 THEN \n" +
|
||||
" SUBSTRING(descrizione_estesa, CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') +1 , CHARINDEX(' Dest.', descrizione_estesa) - ( CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') ) -1 ) ELSE \n" +
|
||||
" SUBSTRING(descrizione_estesa, CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') +1 , len(descrizione_estesa) - ( CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') ))\n" +
|
||||
" END) - 1 )\n" +
|
||||
" ELSE \n" +
|
||||
" CASE WHEN CHARINDEX(' Dest.', descrizione_estesa) > 0 THEN \n" +
|
||||
" SUBSTRING(descrizione_estesa, CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') +1 , CHARINDEX(' Dest.', descrizione_estesa) - ( CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') ) -1 ) ELSE \n" +
|
||||
" SUBSTRING(descrizione_estesa, CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') +1 , len(descrizione_estesa) - ( CHARINDEX( ' DEL', descrizione_estesa, 1) + len (' DEL') ))\n" +
|
||||
" END\n" +
|
||||
" END , 103) as data_doc, \n" +
|
||||
" cast (SUBSTRING(SUBSTRING(descrizione_estesa, CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 , CHARINDEX(' DEL', descrizione_estesa) - ( CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 ) ), 1 , CHARINDEX( ' ', SUBSTRING(descrizione_estesa, CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 , CHARINDEX(' DEL', descrizione_estesa) - ( CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 ) )) -1 ) as int ) AS num_doc, \n" +
|
||||
" SUBSTRING(SUBSTRING(descrizione_estesa, CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 , CHARINDEX(' DEL', descrizione_estesa) - ( CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 ) ), CHARINDEX( ' ', SUBSTRING(descrizione_estesa, CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 , CHARINDEX(' DEL', descrizione_estesa) - ( CHARINDEX( 'N.', descrizione_estesa, 1) + len ('N.') + 1 ) ))+ 1 , 2 ) AS ser_doc \n" +
|
||||
" \n" +
|
||||
" from dtb_docr \n" +
|
||||
" where dtb_docr.descrizione LIKE 'BOLLA N. %'\n" +
|
||||
" AND descrizione_estesa is not null and CHARINDEX( 'N.', descrizione_estesa, 1) > 0\n" +
|
||||
" AND cod_anag = @codAnag and cod_dtip = @codDtip and data_doc = @dataDoc and ser_doc = @serDoc and num_doc = @numDoc \n" +
|
||||
" ) \n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"select dtb_docr_print.cod_anag,\n" +
|
||||
" dtb_docr_print.cod_dtip,\n" +
|
||||
" dtb_docr_print.data_doc,\n" +
|
||||
" dtb_docr_print.ser_doc,\n" +
|
||||
" dtb_docr_print.num_doc,\n" +
|
||||
" convert(varchar(2), null) as tipo_cessione, \n" +
|
||||
" dtb_docr_print.id_riga,\n" +
|
||||
" dtb_docr_print.cod_mart,\n" +
|
||||
" convert(varchar(4096), dtb_docr_print.descrizione) as descrizione,\n" +
|
||||
" convert(varchar(40), null) as descrizione_breve,\n" +
|
||||
" convert(varchar(5), null) as cod_spes,\n" +
|
||||
" convert(varchar(35), null) as tipo_codice_ean,\n" +
|
||||
" convert(varchar(40), null) as valore_codice_ean,\n" +
|
||||
" convert(varchar(35), null) as tipo_codice_forn,\n" +
|
||||
" convert(varchar(40), null) as valore_codice_forn,\n" +
|
||||
" convert(varchar(35), null) as tipo_codice_clie,\n" +
|
||||
" convert(varchar(40), null) as valore_codice_clie,\n" +
|
||||
" convert(varchar(10), null) as tipodato_ct_art,\n" +
|
||||
" convert(int, null) as rifNumero_ct_art,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_ct_art,\n" +
|
||||
" convert(varchar(10), null) as tipodato_pz_art,\n" +
|
||||
" convert(int, null) as rifNumero_pz_art,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_pz_art,\n" +
|
||||
" convert(varchar(40), null) as bar_code,\n" +
|
||||
" dtb_docr_print.unt_doc,\n" +
|
||||
" dtb_docr_print.qta_doc,\n" +
|
||||
" convert(numeric(15,5), null) as qta_cnf, \n" +
|
||||
" convert(numeric(20,5), null) as num_cnf,\n" +
|
||||
" convert(numeric(20,5), dtb_docr_print.val_unt) as val_unt,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto1,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto2,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto3,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto4,\n" +
|
||||
" dtb_docr_print.sconto5,\n" +
|
||||
" dtb_docr_print.sconto6,\n" +
|
||||
" dtb_docr_print.sconto7,\n" +
|
||||
" dtb_docr_print.sconto8,\n" +
|
||||
" dtb_docr_print.importo_riga,\n" +
|
||||
" dtb_docr_print.cod_aliq,\n" +
|
||||
" convert(numeric(5,2), gtb_aliq.perc_aliq) as perc_aliq, \n" +
|
||||
" convert(varchar(5), gtb_aliq.natura) as natura, \n" +
|
||||
" convert(datetime, null) as data_iniz_comp, \n" +
|
||||
" convert(datetime, null) as data_fine_comp,\n" +
|
||||
" convert(varchar(15), null) as cod_kit,\n" +
|
||||
" convert(varchar(40), null) as descr_kit,\n" +
|
||||
" convert(varchar(20), null ) as partita_mag, \n" +
|
||||
" convert(varchar(20), null ) as matricola,\n" +
|
||||
" convert(varchar(10), null) as tipodato_lotto,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_lotto,\n" +
|
||||
" convert(varchar(10), null) as tipodato_dest,\n" +
|
||||
" convert(varchar(40), null) as rifNumero_dest,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_dest, \n" +
|
||||
" convert(varchar(5), null) as cod_vdes,\n" +
|
||||
" convert(varchar(40), null) as cod_affiliazione,\n" +
|
||||
" convert(varchar(40), null) as cod_ean_dest,\n" +
|
||||
" convert(varchar(255), null ) as indirizzo_dest, \n" +
|
||||
" convert(varchar(5), null) as cod_dtip_ddt,\n" +
|
||||
" convert(int, null ) as num_doc_ddt,\n" +
|
||||
" convert(varchar(2), null) as ser_doc_ddt,\n" +
|
||||
" convert(datetime, null) as data_ddt, \n" +
|
||||
" convert(varchar(20), null) as num_ddt,\n" +
|
||||
" convert(varchar(1), null) as gestione_ord,\n" +
|
||||
" convert(datetime, null) as data_ord,\n" +
|
||||
" convert(int, null ) as num_ord,\n" +
|
||||
" convert(varchar(40), null ) as rif_ord, \n" +
|
||||
" dtb_docr_print.rif_data_ord, \n" +
|
||||
" dtb_docr_print.rif_num_ord, \n" +
|
||||
" convert(varchar(10), null) as cod_jcom, \n" +
|
||||
" dtb_docr_print.id_riga as id_riga_orig,\n" +
|
||||
" CONVERT(varchar(60), null) as rifTesto_numDocCli, \n" +
|
||||
" CONVERT(varchar(40), null) as tipoDato_numDocCli\n" +
|
||||
"from dtb_docr_print left outer join gtb_aliq on dtb_docr_print.cod_aliq = gtb_aliq.cod_aliq \n" +
|
||||
"where cod_anag = @codAnag and cod_Dtip = @codDtip and\n" +
|
||||
"data_doc = @dataDoc and ser_doc = @serDoc and num_doc = @numDoc\n" +
|
||||
"union all\n" +
|
||||
"SELECT docu_tab.cod_anag,\n" +
|
||||
" docu_tab.cod_dtip_val,\n" +
|
||||
" docu_tab.data_doc_val, \n" +
|
||||
" docu_tab.ser_doc_val,\n" +
|
||||
" docu_tab.num_doc_val,\n" +
|
||||
" docu_tab.tipo_cessione,\n" +
|
||||
" cast(ROW_NUMBER() over(order by docu_tab.cod_anag,\n" +
|
||||
" docu_tab.cod_dtip_val, \n" +
|
||||
" docu_tab.data_doc_val, \n" +
|
||||
" docu_tab.ser_doc_val,\n" +
|
||||
" docu_tab.num_doc_val, \n" +
|
||||
" --docu_tab.data_ddt, \n" +
|
||||
" --docu_tab.num_ddt,\n" +
|
||||
" docu_tab.id_riga_doc_val, \n" +
|
||||
" docu_tab.id_riga ) as integer) as id_riga,\n" +
|
||||
" docu_tab.cod_mart,\n" +
|
||||
" docu_tab.descrizione,\n" +
|
||||
" docu_tab.descrizione_breve,\n" +
|
||||
" docu_tab.cod_spes,\n" +
|
||||
" docu_tab.tipo_codice_ean,\n" +
|
||||
" docu_tab.valore_codice_ean,\n" +
|
||||
" docu_tab.tipo_codice_forn,\n" +
|
||||
" docu_tab.valore_codice_forn,\n" +
|
||||
" docu_tab.tipo_codice_clie,\n" +
|
||||
" docu_tab.valore_codice_clie,\n" +
|
||||
" docu_tab.tipodato_ct_art,\n" +
|
||||
" docu_tab.rifNumero_ct_art,\n" +
|
||||
" docu_tab.rifTesto_ct_art,\n" +
|
||||
" docu_tab.tipodato_pz_art,\n" +
|
||||
" docu_tab.rifNumero_pz_art,\n" +
|
||||
" docu_tab.rifTesto_pz_art,\n" +
|
||||
" docu_tab.bar_code,\n" +
|
||||
" docu_tab.unt_doc,\n" +
|
||||
" docu_tab.qta_doc,\n" +
|
||||
" docu_tab.qta_cnf, \n" +
|
||||
" docu_tab.num_cnf,\n" +
|
||||
" convert(numeric(20,5), isNull(docu_tab.val_unt, 0)) as val_unt,\n" +
|
||||
" docu_tab.sconto1,\n" +
|
||||
" docu_tab.sconto2,\n" +
|
||||
" docu_tab.sconto3,\n" +
|
||||
" docu_tab.sconto4,\n" +
|
||||
" docu_tab.sconto5,\n" +
|
||||
" docu_tab.sconto6,\n" +
|
||||
" docu_tab.sconto7,\n" +
|
||||
" docu_tab.sconto8,\n" +
|
||||
" convert(numeric(20,5), isNull(docu_tab.importo_riga, 0) ) as importo_riga,\n" +
|
||||
" docu_tab.cod_aliq,\n" +
|
||||
" docu_tab.perc_aliq, \n" +
|
||||
" docu_tab.natura, \n" +
|
||||
" docu_tab.data_iniz_comp, \n" +
|
||||
" docu_tab.data_fine_comp,\n" +
|
||||
" docu_tab.cod_kit,\n" +
|
||||
" docu_tab.descr_kit,\n" +
|
||||
" docu_tab.partita_mag,\n" +
|
||||
" docu_tab.matricola,\n" +
|
||||
" docu_tab.tipodato_lotto,\n" +
|
||||
" docu_tab.rifTesto_lotto,\n" +
|
||||
" docu_tab.tipodato_dest,\n" +
|
||||
" docu_tab.rifNumero_dest,\n" +
|
||||
" docu_tab.rifTesto_dest, \n" +
|
||||
" docu_tab.cod_vdes,\n" +
|
||||
" docu_tab.cod_affiliazione,\n" +
|
||||
" docu_tab.cod_ean_dest,\n" +
|
||||
" docu_tab.indirizzo_dest,\n" +
|
||||
" docu_tab.cod_dtip_ddt,\n" +
|
||||
" docu_tab.num_doc_ddt, \n" +
|
||||
" docu_tab.ser_doc_ddt, \n" +
|
||||
" docu_tab.data_ddt, \n" +
|
||||
" docu_tab.num_ddt,\n" +
|
||||
" docu_tab.gestione_ord, \n" +
|
||||
" docu_tab.data_ord, \n" +
|
||||
" docu_tab.num_ord, \n" +
|
||||
" docu_tab.rif_ord,\n" +
|
||||
" docu_tab.rif_data_ord, \n" +
|
||||
" docu_tab.rif_num_ord, \n" +
|
||||
" docu_tab.cod_jcom,\n" +
|
||||
" docu_tab.id_riga as id_riga_orig, \n" +
|
||||
" docu_tab.rifTesto_numDocCli, \n" +
|
||||
" docu_tab.tipodato_numDocCli\n" +
|
||||
"FROM \n" +
|
||||
"(\n" +
|
||||
" SELECT dtb_doct.cod_anag,\n" +
|
||||
" dtb_doct.cod_dtip_val, \n" +
|
||||
" dtb_doct.data_doc_val, \n" +
|
||||
" dtb_doct.ser_doc_val,\n" +
|
||||
" dtb_doct.num_doc_val,\n" +
|
||||
" righe_doc.tipo_cessione,\n" +
|
||||
" righe_doc_val.id_riga as id_riga_doc_val, \n" +
|
||||
" righe_doc.id_riga,\n" +
|
||||
" righe_doc.cod_mart,\n" +
|
||||
" righe_doc.descrizione, \n" +
|
||||
" righe_doc.descrizione_breve, \n" +
|
||||
" righe_doc.cod_spes,\n" +
|
||||
" CASE WHEN PATINDEX('%EAN%', righe_doc.tipo_codice_ean ) > 0 THEN 'EAN' ELSE NULL END as tipo_codice_ean,\n" +
|
||||
" CASE WHEN PATINDEX('%EAN%', righe_doc.tipo_codice_ean ) > 0 THEN righe_doc.bar_code ELSE NULL END as valore_codice_ean,\n" +
|
||||
" CASE WHEN righe_doc.cod_mart IS NOT NULL THEN 'COD.ART.FORNIT' ELSE null END as tipo_codice_forn,\n" +
|
||||
" righe_doc.cod_mart as valore_codice_forn,\n" +
|
||||
" convert(varchar(35), null) as tipo_codice_clie,\n" +
|
||||
" convert(varchar(40), null) as valore_codice_clie,\n" +
|
||||
" convert(varchar(10), null) as tipodato_ct_art,\n" +
|
||||
" convert(int, null) as rifNumero_ct_art,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_ct_art,\n" +
|
||||
" convert(varchar(10), null) as tipodato_pz_art,\n" +
|
||||
" convert(int, null) as rifNumero_pz_art,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_pz_art,\n" +
|
||||
" righe_doc.bar_code,\n" +
|
||||
" righe_doc.unt_doc,\n" +
|
||||
" righe_doc.qta_doc \n" +
|
||||
" * CASE WHEN (dtb_tipi.segno_val_scar * dtb_tipi_val.segno_val_scar) = 0 THEN 1 ELSE (dtb_tipi.segno_val_scar * dtb_tipi_val.segno_val_scar) END \n" +
|
||||
" as qta_doc,\n" +
|
||||
" righe_doc.qta_cnf, \n" +
|
||||
" righe_doc.num_cnf,\n" +
|
||||
" CASE WHEN dtb_tipi.flag_prz_iva = 'S' THEN Round( Round(righe_doc.qta_doc * righe_doc.val_unt_iva, 2) / (1 + perc_aliq /100) / CASE WHEN righe_doc.qta_doc = 0 THEN 1 ELSE righe_doc.qta_doc END, 5) ELSE righe_doc.val_unt END \n" +
|
||||
" * isNull(dvw_tipi_integrazioni.segno, 1) as val_unt, \n" +
|
||||
" CASE WHEN flag_prz_scontati = 'S' THEN 0 ELSE dtb_doct.sconto1 END as sconto1 , \n" +
|
||||
" CASE WHEN flag_prz_scontati = 'S' THEN 0 ELSE dtb_doct.sconto2 END as sconto2 , \n" +
|
||||
" CASE WHEN flag_prz_scontati = 'S' THEN 0 ELSE dtb_doct.sconto3 END as sconto3 ,\n" +
|
||||
" CASE WHEN flag_prz_scontati = 'S' THEN 0 ELSE dtb_doct.sconto4 END as sconto4 , \n" +
|
||||
" righe_doc.sconto5,\n" +
|
||||
" righe_doc.sconto6,\n" +
|
||||
" righe_doc.sconto7,\n" +
|
||||
" righe_doc.sconto8,\n" +
|
||||
" round(CASE WHEN dtb_tipi.flag_prz_iva = 'S' THEN Round( Round(righe_doc.qta_doc * righe_doc.val_unt_iva * (1 - righe_doc.sconto5 / 100) * (1 - righe_doc.sconto6 / 100) * (1 - righe_doc.sconto7 / 100) * (1 - righe_doc.sconto8 / 100), 2) / (1 + perc_aliq /100), 5) ELSE righe_doc.importo_riga END \n" +
|
||||
" * CASE WHEN flag_prz_scontati <> 'S' THEN (1 - dtb_doct.sconto1 / 100) * (1 - dtb_doct.sconto2 / 100) * (1 - dtb_doct.sconto3 / 100) * (1 - dtb_doct.sconto4 / 100) ELSE 1 END * CASE WHEN (dtb_tipi.segno_val_scar * dtb_tipi_val.segno_val_scar) = 0 THEN 1 ELSE (dtb_tipi.segno_val_scar * dtb_tipi_val.segno_val_scar) END\n" +
|
||||
" * isNull(dvw_tipi_integrazioni.segno, 1) \n" +
|
||||
" ,\n" +
|
||||
" CASE WHEN dtb_tipi.flag_prz_iva = 'S' THEN 5 ELSE 2 END ) as importo_riga,\n" +
|
||||
" righe_doc.cod_aliq,\n" +
|
||||
" isnull(righe_doc.perc_aliq, 0) as perc_aliq, \n" +
|
||||
" righe_doc.natura,\n" +
|
||||
" righe_doc.data_iniz_comp, \n" +
|
||||
" righe_doc.data_fine_comp,\n" +
|
||||
" righe_doc.cod_kit,\n" +
|
||||
" righe_doc.descr_kit, \n" +
|
||||
" righe_doc.partita_mag, \n" +
|
||||
" righe_doc.matricola, \n" +
|
||||
" CASE WHEN len(righe_doc.partita_mag ) > 0 THEN 'LOTTO' ELSE null END as tipodato_lotto,\n" +
|
||||
" CASE WHEN len(righe_doc.partita_mag ) > 0 THEN righe_doc.partita_mag ELSE null END as rifTesto_lotto,\n" +
|
||||
" CASE WHEN len(vtb_dest.cod_affiliazione) > 0 THEN 'PV' ELSE \n" +
|
||||
" CASE WHEN len(dtb_doct.cod_vdes) > 0 THEN 'PV.FORNIT' ELSE null END END as tipodato_dest,\n" +
|
||||
" CASE WHEN len(vtb_dest.cod_affiliazione) > 0 AND ISNUMERIC(vtb_dest.cod_affiliazione) = 1 THEN vtb_dest.cod_affiliazione ELSE null END as rifNumero_dest,\n" +
|
||||
" CASE WHEN len(vtb_dest.cod_affiliazione) > 0 THEN \n" +
|
||||
" CASE WHEN ISNUMERIC(vtb_dest.cod_affiliazione) = 1 THEN vtb_dest.indirizzo ELSE vtb_dest.cod_affiliazione END\n" +
|
||||
" ELSE \n" +
|
||||
" CASE WHEN len(dtb_doct.cod_vdes) > 0 THEN dtb_doct.cod_vdes + ' - '+ vtb_dest.indirizzo ELSE null END\n" +
|
||||
" END as rifTesto_dest,\n" +
|
||||
" dtb_doct.cod_vdes, \n" +
|
||||
" vtb_dest.cod_affiliazione,\n" +
|
||||
" vtb_dest.cod_ean as cod_ean_dest,\n" +
|
||||
" vtb_dest.indirizzo as indirizzo_dest,\n" +
|
||||
" CASE WHEN dtb_doct.cod_dtip_val <> dtb_doct.cod_dtip THEN dtb_doct.cod_dtip ELSE null END as cod_dtip_ddt, \n" +
|
||||
" CASE WHEN dtb_doct.cod_dtip_val <> dtb_doct.cod_dtip THEN dtb_doct.num_doc ELSE null END as num_doc_ddt,\n" +
|
||||
" CASE WHEN dtb_doct.cod_dtip_val <> dtb_doct.cod_dtip THEN dtb_doct.ser_doc ELSE null END as ser_doc_ddt,\n" +
|
||||
" CASE WHEN dtb_doct.cod_dtip_val <> dtb_doct.cod_dtip THEN dtb_doct.data_doc ELSE null END as data_ddt ,\n" +
|
||||
" CASE WHEN dtb_doct.cod_dtip_val <> dtb_doct.cod_dtip THEN cast(dtb_doct.num_doc as varchar) + ' '+ dtb_doct.ser_doc ELSE null END as num_ddt, \n" +
|
||||
" righe_doc.gestione as gestione_ord, righe_doc.data_ord, righe_doc.num_ord, \n" +
|
||||
" righe_doc.rif_ord, righe_doc.rif_data_ord, righe_doc.rif_num_ord, righe_doc.cod_jcom , righe_doc.num_doc_forn as rifTesto_numDocCli, 'N.DOC.CLI.' as tipodato_numDocCli\n" +
|
||||
" FROM dtb_doct inner join dtb_tipi \n" +
|
||||
" on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_tipi as dtb_tipi_val \n" +
|
||||
" on dtb_doct.cod_dtip_val = dtb_tipi_val.cod_dtip\n" +
|
||||
" inner join righe_doc \n" +
|
||||
" on dtb_doct.cod_anag = righe_doc.cod_anag \n" +
|
||||
" and dtb_doct.cod_dtip = righe_doc.cod_dtip \n" +
|
||||
" and dtb_doct.data_doc = righe_doc.data_doc \n" +
|
||||
" and dtb_doct.ser_doc = righe_doc.ser_doc \n" +
|
||||
" and dtb_doct.num_doc = righe_doc.num_doc \n" +
|
||||
" left outer join righe_doc_val \n" +
|
||||
" on righe_doc.cod_anag = righe_doc_val.cod_anag \n" +
|
||||
" and righe_doc.cod_dtip = righe_doc_val.cod_dtip \n" +
|
||||
" and righe_doc.data_doc = righe_doc_val.data_doc \n" +
|
||||
" and righe_doc.ser_doc = righe_doc_val.ser_doc \n" +
|
||||
" and righe_doc.num_doc =righe_doc_val.num_doc\n" +
|
||||
" left outer join vtb_dest \n" +
|
||||
" on dtb_doct.cod_anag = vtb_dest.cod_anag \n" +
|
||||
" and dtb_doct.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
" left outer join ctb_caus \n" +
|
||||
" on dtb_tipi_val.cod_ccau = ctb_caus.cod_ccau\n" +
|
||||
" left outer join dvw_tipi_integrazioni \n" +
|
||||
" on dtb_doct.cod_dtip = dvw_tipi_integrazioni.cod_dtip\n" +
|
||||
" WHERE dtb_tipi.tipo_emissione ='DIRETTA' and \n" +
|
||||
" dtb_doct.cod_anag = @codAnag and \n" +
|
||||
" dtb_doct.cod_dtip_val = @codDtip and \n" +
|
||||
" dtb_doct.data_doc_val = @dataDoc and \n" +
|
||||
" dtb_doct.ser_doc_val = @serDoc and \n" +
|
||||
" dtb_doct.num_doc_val = @numDoc \n" +
|
||||
"UNION ALL\n" +
|
||||
" SELECT dtb_doct.cod_anag,\n" +
|
||||
" dtb_doct.cod_dtip_val, \n" +
|
||||
" dtb_doct.data_doc_val, \n" +
|
||||
" dtb_doct.ser_doc_val,\n" +
|
||||
" dtb_doct.num_doc_val,\n" +
|
||||
" 'AC' as tipo_cessione, \n" +
|
||||
" (SELECT Max(id_riga) id FROM dtb_docr as docr\n" +
|
||||
" WHERE docr.cod_anag = dtb_doct.cod_anag AND docr.cod_dtip = dtb_doct.cod_dtip \n" +
|
||||
" AND docr.data_doc = dtb_doct.data_doc \n" +
|
||||
" AND docr.ser_doc = dtb_doct.ser_doc \n" +
|
||||
" AND docr.num_doc = dtb_doct.num_doc) as id_riga_doc_val ,\n" +
|
||||
" dtb_docs.riga as id_riga , \n" +
|
||||
" convert(varchar(15), null) as cod_mart,\n" +
|
||||
" convert(varchar(4096), dtb_docs.descrizione) as descrizione, \n" +
|
||||
" convert(varchar(40), dtb_docs.descrizione) as descrizione_breve, \n" +
|
||||
" dtb_docs.cod_spes ,\n" +
|
||||
" convert(varchar(35), null) as tipo_codice_ean,\n" +
|
||||
" convert(varchar(40), null) as valore_codice_ean,\n" +
|
||||
" convert(varchar(35), null) as tipo_codice_forn,\n" +
|
||||
" convert(varchar(40), null) as valore_codice_forn,\n" +
|
||||
" convert(varchar(35), null) as tipo_codice_clie,\n" +
|
||||
" convert(varchar(40), null) as valore_codice_clie,\n" +
|
||||
" convert(varchar(10), null) as tipodato_ct_art,\n" +
|
||||
" convert(int, null) as rifNumero_ct_art,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_ct_art,\n" +
|
||||
" convert(varchar(10), null) as tipodato_pz_art,\n" +
|
||||
" convert(int, null) as rifNumero_pz_art,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_pz_art,\n" +
|
||||
" convert(varchar(40), null) as bar_code,\n" +
|
||||
" dtb_docs.unt_mis as unt_doc,\n" +
|
||||
" 1 as qta_doc,\n" +
|
||||
" convert(numeric(15,5), null) as qta_cnf, \n" +
|
||||
" convert(numeric(20,5), null) as num_cnf,\n" +
|
||||
" convert(numeric(20,5), CASE WHEN flag_prz_iva = 'S' THEN Round( dtb_docs.importo / (1 + perc_aliq /100), 5) ELSE dtb_docs.importo END ) as val_unt,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto1,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto2,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto3,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto4,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto5,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto6,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto7,\n" +
|
||||
" convert(numeric(5,2), 0) as sconto8, \n" +
|
||||
" convert(numeric(20,5), CASE WHEN flag_prz_iva = 'S' THEN Round( dtb_docs.importo / (1 + perc_aliq /100), 5) ELSE dtb_docs.importo END) as importo_riga,\n" +
|
||||
" dtb_docs.cod_aliq,\n" +
|
||||
" isnull(gtb_aliq.perc_aliq, 0) as perc_aliq, \n" +
|
||||
" gtb_aliq.natura,\n" +
|
||||
" convert(datetime, null) as data_iniz_comp, \n" +
|
||||
" convert(datetime, null) as data_fine_comp,\n" +
|
||||
" convert(varchar(15), null) as cod_kit,\n" +
|
||||
" convert(varchar(40), null) as descr_kit,\n" +
|
||||
" convert(varchar(20), null ) as partita_mag, \n" +
|
||||
" convert(varchar(20), null ) as matricola, \n" +
|
||||
" convert(varchar(10), null) as tipodato_lotto,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_lotto,\n" +
|
||||
" convert(varchar(10), null) as tipodato_dest,\n" +
|
||||
" convert(varchar(40), null) as rifNumero_dest,\n" +
|
||||
" convert(varchar(60), null) as rifTesto_dest, \n" +
|
||||
" convert(varchar(5), null) as cod_vdes,\n" +
|
||||
" convert(varchar(10), null) as cod_affiliazione,\n" +
|
||||
" convert(varchar(40), null) as cod_ean_dest,\n" +
|
||||
" convert(varchar(255), null ) as indirizzo_dest, \n" +
|
||||
" convert(varchar(5), null) as cod_dtip_ddt,\n" +
|
||||
" convert(int, null ) as num_doc_ddt,\n" +
|
||||
" convert(varchar(2), null) as ser_doc_ddt,\n" +
|
||||
" convert(datetime, null) as data_ddt, \n" +
|
||||
" convert(varchar(20), null) as num_ddt,\n" +
|
||||
" convert(varchar(1), null) as gestione_ord,\n" +
|
||||
" convert(datetime, null) as data_ord,\n" +
|
||||
" convert(int, null ) as num_ord,\n" +
|
||||
" convert(varchar(40), null) as rif_ord,\n" +
|
||||
" convert(datetime, null) as rif_data_ord, \n" +
|
||||
" convert(varchar(20), null) as rif_num_ord,\n" +
|
||||
" convert(varchar(10), null) as cod_jcom,\n" +
|
||||
" CONVERT(varchar(60), null) as rifTesto_numDocCli, \n" +
|
||||
" CONVERT(varchar(40), null) as tipodato_numDocCli\n" +
|
||||
" FROM dtb_doct inner join dtb_docs on dtb_docs.cod_anag = dtb_doct.cod_anag and \n" +
|
||||
" dtb_docs.cod_dtip = dtb_doct.cod_dtip and \n" +
|
||||
" dtb_docs.data_doc = dtb_doct.data_doc and \n" +
|
||||
" dtb_docs.ser_doc = dtb_doct.ser_doc and \n" +
|
||||
" dtb_docs.num_doc = dtb_doct.num_doc \n" +
|
||||
" INNER JOIN dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" left outer join gtb_aliq on dtb_docs.cod_aliq = gtb_aliq.cod_aliq \n" +
|
||||
" WHERE dtb_doct.cod_anag = @codAnag and \n" +
|
||||
" dtb_doct.cod_dtip = @codDtip and \n" +
|
||||
" dtb_doct.data_doc = @dataDoc and \n" +
|
||||
" dtb_doct.ser_doc = @serDoc and \n" +
|
||||
" dtb_doct.num_doc = @numDoc ) as docu_tab left outer join dtb_docr_print on docu_tab.cod_anag = dtb_docr_print.cod_anag AND\n" +
|
||||
" docu_tab.cod_dtip_val = dtb_docr_print.cod_dtip AND\n" +
|
||||
" docu_tab.data_doc_val = dtb_docr_print.data_doc AND\n" +
|
||||
" docu_tab.ser_doc_val = dtb_docr_print.ser_doc AND\n" +
|
||||
" docu_tab.num_doc_val = dtb_docr_print.num_doc\n" +
|
||||
"WHERE dtb_docr_print.cod_anag is null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
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.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20250929172222 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Idrotecnica) || isCustomer(IntegryCustomer.Sabato) || isCustomer(IntegryCustomer.Ime) ||
|
||||
isCustomer(IntegryCustomer.Materica) || isCustomer(IntegryCustomer.Lippolis) || isCustomer(IntegryCustomer.Integry)){
|
||||
|
||||
//Creo uno script SQL per cancellare e ricreare le FK che punteranno a stb_activity_old
|
||||
String fixFkSqlScript = "SELECT fk.name AS FK_Name,\n" +
|
||||
" OBJECT_NAME(fk.parent_object_id) AS FK_Table,\n" +
|
||||
" c1.name AS FK_Column,\n" +
|
||||
" OBJECT_NAME(fk.referenced_object_id) AS Ref_Table,\n" +
|
||||
" c2.name AS Ref_Column,\n" +
|
||||
" 'ALTER TABLE [' + OBJECT_NAME(fk.parent_object_id) +\n" +
|
||||
" '] DROP CONSTRAINT [' + fk.name + ']; ' +\n" +
|
||||
" 'ALTER TABLE [' + OBJECT_NAME(fk.parent_object_id) +\n" +
|
||||
" '] WITH CHECK ADD CONSTRAINT [' + fk.name +\n" +
|
||||
" '] FOREIGN KEY([' + c1.name +\n" +
|
||||
" ']) REFERENCES [dbo].[stb_activity]([' + c2.name + ']);' AS FixScript\n" +
|
||||
"FROM sys.foreign_keys fk\n" +
|
||||
" INNER JOIN sys.foreign_key_columns fkc ON fkc.constraint_object_id = fk.object_id\n" +
|
||||
" INNER JOIN sys.columns c1 ON fkc.parent_object_id = c1.object_id AND fkc.parent_column_id = c1.column_id\n" +
|
||||
" INNER JOIN sys.columns c2\n" +
|
||||
" ON fkc.referenced_object_id = c2.object_id AND fkc.referenced_column_id = c2.column_id\n" +
|
||||
"WHERE fk.referenced_object_id = OBJECT_ID('dbo.stb_activity');";
|
||||
|
||||
final List<HashMap<String, Object>> fixScriptResult = executeQuery(fixFkSqlScript);
|
||||
|
||||
String[] fixScripts = new String[0];
|
||||
|
||||
if (fixScriptResult != null && !fixScriptResult.isEmpty()) {
|
||||
fixScripts = fixScriptResult.stream()
|
||||
.map(x -> (String) x.get("FixScript"))
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
|
||||
executeStatement("CREATE TABLE dbo.stb_activity_new\n" +
|
||||
"(\n" +
|
||||
" activity_id VARCHAR(15) NOT NULL\n" +
|
||||
" CONSTRAINT pk_stb_activity_new\n" +
|
||||
" PRIMARY KEY NONCLUSTERED\n" +
|
||||
" WITH (FILLFACTOR = 90),\n" +
|
||||
" data_ins_act DATETIME NOT NULL,\n" +
|
||||
" activity_type_id VARCHAR(40) NOT NULL,\n" +
|
||||
" activity_description VARCHAR(1024),\n" +
|
||||
" parent_activity_id VARCHAR(15),\n" +
|
||||
" user_name VARCHAR(40) NOT NULL\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_stb_user\n" +
|
||||
" REFERENCES dbo.stb_user,\n" +
|
||||
" tipo_anag VARCHAR,\n" +
|
||||
" cod_anag VARCHAR(15),\n" +
|
||||
" estimated_date DATETIME,\n" +
|
||||
" estimated_time DATETIME,\n" +
|
||||
" alarm_date DATETIME,\n" +
|
||||
" alarm_time DATETIME,\n" +
|
||||
" effective_date DATETIME,\n" +
|
||||
" effective_time DATETIME,\n" +
|
||||
" activity_result_id VARCHAR(15)\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_stb_activity_new_res\n" +
|
||||
" REFERENCES dbo.stb_activity_result,\n" +
|
||||
" result_description VARCHAR(1024),\n" +
|
||||
" estimated_enddate DATETIME,\n" +
|
||||
" estimated_endtime DATETIME,\n" +
|
||||
" effective_enddate DATETIME,\n" +
|
||||
" effective_endtime DATETIME,\n" +
|
||||
" cod_jcom VARCHAR(10)\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_jtb_comt\n" +
|
||||
" REFERENCES dbo.jtb_comt,\n" +
|
||||
" user_creator VARCHAR(40),\n" +
|
||||
" cod_jfas VARCHAR(5) DEFAULT NULL\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_jtb_fasi\n" +
|
||||
" REFERENCES dbo.jtb_fasi,\n" +
|
||||
" perc_comp NUMERIC(15, 5)\n" +
|
||||
" DEFAULT 0 NOT NULL,\n" +
|
||||
" estimated_hours NUMERIC(15, 5)\n" +
|
||||
" DEFAULT 0 NOT NULL,\n" +
|
||||
" cod_mart VARCHAR(15)\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_mtb_aart\n" +
|
||||
" REFERENCES dbo.mtb_aart,\n" +
|
||||
" matricola VARCHAR(20)\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_matricola\n" +
|
||||
" REFERENCES dbo.vtb_amac,\n" +
|
||||
" priorita INT,\n" +
|
||||
" activity_play_counter NUMERIC(20, 5) DEFAULT 0 NOT NULL,\n" +
|
||||
" flag_tipologia VARCHAR NOT NULL,\n" +
|
||||
" activity_event VARCHAR(1024),\n" +
|
||||
" guarantee VARCHAR,\n" +
|
||||
" note VARCHAR(1024),\n" +
|
||||
" rfid VARCHAR(40),\n" +
|
||||
" id_lotto INT,\n" +
|
||||
" persona_rif VARCHAR(40),\n" +
|
||||
" hr_num INT,\n" +
|
||||
" gestione VARCHAR,\n" +
|
||||
" data_ord DATETIME,\n" +
|
||||
" num_ord INT,\n" +
|
||||
" id_step INT,\n" +
|
||||
" id_riga INT,\n" +
|
||||
" ora_ins_act DATETIME,\n" +
|
||||
" indice_gradimento NUMERIC(20, 5) DEFAULT 0,\n" +
|
||||
" note_gradimento VARCHAR(8000),\n" +
|
||||
" flag_risolto VARCHAR DEFAULT 'N',\n" +
|
||||
" user_modifier VARCHAR(40),\n" +
|
||||
" ora_mod_act DATETIME,\n" +
|
||||
" ora_view_act DATETIME,\n" +
|
||||
" cod_vdes VARCHAR(5),\n" +
|
||||
" partita_mag VARCHAR(20),\n" +
|
||||
" cod_cmac VARCHAR(20),\n" +
|
||||
" wrike_id VARCHAR(8000),\n" +
|
||||
" cod_mgrp VARCHAR(5)\n" +
|
||||
" CONSTRAINT stb_activity_new_mtb_grup_cod_mgrp_fk\n" +
|
||||
" REFERENCES dbo.mtb_grup,\n" +
|
||||
" plan_id BIGINT\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_stb_activity_new_plan\n" +
|
||||
" REFERENCES dbo.stb_activity_plan,\n" +
|
||||
" id_posizione BIGINT\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_stb_posizioni\n" +
|
||||
" REFERENCES dbo.stb_posizioni,\n" +
|
||||
" CONSTRAINT fk_stb_activity_new_tipologia\n" +
|
||||
" FOREIGN KEY (activity_type_id, flag_tipologia) REFERENCES dbo.stb_activity_type\n" +
|
||||
")\n"
|
||||
,
|
||||
"CREATE INDEX ix_activity_effective\n" +
|
||||
" ON dbo.stb_activity_new (activity_id, effective_date, effective_time, effective_enddate, effective_endtime)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_activity_estimate\n" +
|
||||
" ON dbo.stb_activity_new (activity_id, estimated_date, estimated_time, estimated_enddate, estimated_endtime)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_activity_result_id\n" +
|
||||
" ON dbo.stb_activity_new (activity_result_id)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_activity_type_id\n" +
|
||||
" ON dbo.stb_activity_new (activity_type_id, flag_tipologia)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_stb_activity_new_cod_jcom\n" +
|
||||
" ON dbo.stb_activity_new (cod_jcom)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n",
|
||||
"CREATE INDEX ix_stb_activity_new_cod_jfas\n" +
|
||||
" ON dbo.stb_activity_new (cod_jfas)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_stb_activity_new_cod_mart\n" +
|
||||
" ON dbo.stb_activity_new (cod_mart)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n",
|
||||
"CREATE INDEX ix_stb_activity_new_parent_activity_id\n" +
|
||||
" ON dbo.stb_activity_new (parent_activity_id)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n",
|
||||
"CREATE INDEX ix_stb_activity_new_stb_activity_new\n" +
|
||||
" ON dbo.stb_activity_new (parent_activity_id)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_stb_activity_new_stb_activity_new_res\n" +
|
||||
" ON dbo.stb_activity_new (activity_result_id)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n",
|
||||
"CREATE INDEX ix_stb_activity_new_stb_user\n" +
|
||||
" ON dbo.stb_activity_new (user_name)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_stb_activity_new_user_name\n" +
|
||||
" ON dbo.stb_activity_new (user_name)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX ix_stb_activivty_priorita\n" +
|
||||
" ON dbo.stb_activity_new (priorita)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"CREATE INDEX stb_activity_new\n" +
|
||||
" ON dbo.stb_activity_new (activity_type_id)\n" +
|
||||
" WITH (FILLFACTOR = 90)\n" ,
|
||||
"insert into stb_activity_new " +
|
||||
"select * from stb_activity",
|
||||
"EXEC sp_rename 'dbo.stb_activity', 'stb_activity_old';",
|
||||
"EXEC sp_rename 'dbo.stb_activity_new', 'stb_activity';"
|
||||
);
|
||||
|
||||
executeStatement(fixScripts);
|
||||
}
|
||||
|
||||
dropIndex("stb_activity", "ix_stb_activity_raplav");
|
||||
dropIndex("stb_activity", "ix_stb_activity_effective_date");
|
||||
dropIndex("stb_activity", "ix_activity_effective");
|
||||
dropIndex("stb_activity", "ix_activity_estimate");
|
||||
dropIndex("stb_activity", "ix_stb_activity_alarm");
|
||||
|
||||
executeStatement(
|
||||
"UPDATE stb_activity\n" +
|
||||
"SET\n" +
|
||||
" estimated_time = ISNULL(estimated_time, estimated_date),\n" +
|
||||
" estimated_endtime = ISNULL(estimated_endtime, estimated_enddate),\n" +
|
||||
" effective_time = ISNULL(effective_time, effective_date),\n" +
|
||||
" effective_endtime = ISNULL(effective_endtime, effective_enddate),\n" +
|
||||
" alarm_time = ISNULL(alarm_time, alarm_date)\n" +
|
||||
"WHERE(\n" +
|
||||
" estimated_time IS NULL\n" +
|
||||
" OR estimated_endtime IS NULL\n" +
|
||||
" OR effective_time IS NULL\n" +
|
||||
" OR effective_endtime IS NULL\n" +
|
||||
" OR alarm_time IS NULL\n" +
|
||||
" );\n",
|
||||
"alter table stb_activity drop column data_ins_act ",
|
||||
"alter table stb_activity drop column estimated_date ",
|
||||
"alter table stb_activity drop column alarm_date ",
|
||||
"alter table stb_activity drop column effective_date ",
|
||||
"alter table stb_activity drop column estimated_enddate ",
|
||||
"alter table stb_activity drop column effective_enddate ",
|
||||
"alter table stb_activity add data_ins_act as cast(ora_ins_act as date) ",
|
||||
"alter table stb_activity add estimated_date as cast(estimated_time as date) ",
|
||||
"alter table stb_activity add alarm_date as cast(alarm_time as date) ",
|
||||
"alter table stb_activity add effective_date as cast(effective_time as date) ",
|
||||
"alter table stb_activity add estimated_enddate as cast(estimated_endtime as date) ",
|
||||
"alter table stb_activity add effective_enddate as cast(effective_endtime as date) ");
|
||||
|
||||
List<IndexTableDTO.ColumnIndex> columnsIndex = new ArrayList<>();
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("alarm_time"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("alarm_date"));
|
||||
createIndex(new IndexTableDTO()
|
||||
.setTableName("stb_activity")
|
||||
.setIndexName("ix_stb_activity_alarm")
|
||||
.setColumnsIndex(columnsIndex));
|
||||
|
||||
columnsIndex = new ArrayList<>();
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("activity_id"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("estimated_date"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("estimated_time"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("estimated_enddate"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("estimated_endtime"));
|
||||
|
||||
createIndex(new IndexTableDTO()
|
||||
.setTableName("stb_activity")
|
||||
.setIndexName("ix_activity_estimate")
|
||||
.setColumnsIndex(columnsIndex));
|
||||
|
||||
columnsIndex = new ArrayList<>();
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("activity_id"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("effective_date"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("effective_enddate"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("effective_time"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("effective_endtime"));
|
||||
|
||||
createIndex(new IndexTableDTO()
|
||||
.setTableName("stb_activity")
|
||||
.setIndexName("ix_activity_effective")
|
||||
.setColumnsIndex(columnsIndex));
|
||||
|
||||
|
||||
columnsIndex = new ArrayList<>();
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("data_ins_act"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("flag_tipologia"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("activity_type_id"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("cod_jcom"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("cod_jfas"));
|
||||
|
||||
createIndex(new IndexTableDTO()
|
||||
.setTableName("stb_activity")
|
||||
.setIndexName("ix_stb_activity_raplav")
|
||||
.setColumnsIndex(columnsIndex));
|
||||
|
||||
|
||||
columnsIndex = new ArrayList<>();
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex().setColumnName("effective_date"));
|
||||
|
||||
createIndex(new IndexTableDTO()
|
||||
.setTableName("stb_activity")
|
||||
.setIndexName("stb_activity_effective_date")
|
||||
.setColumnsIndex(columnsIndex));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250930121417 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if(isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateProcedure("UpdProgOrdini", "CREATE PROCEDURE [dbo].[UpdProgOrdini](\n" +
|
||||
" @codAnag varchar(5),\n" +
|
||||
" @codDtip varchar(5),\n" +
|
||||
" @dataDoc dateTime,\n" +
|
||||
" @serDoc varchar(2),\n" +
|
||||
" @numDoc integer,\n" +
|
||||
" @segno integer,\n" +
|
||||
" @Operation varchar(1))\n" +
|
||||
" /***DESCRIZIONE: Questa storedProcedure aggiorna la quantitàevasa degli ordini e anche il \n" +
|
||||
" numero di pezzi, non contiene una serie di logiche particolarti tipo la \n" +
|
||||
" sostuzione dell'articolo nell'ordine\n" +
|
||||
" \n" +
|
||||
" */\n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
" SET NOCOUNT ON;\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
" UPDATE dtb_ordr\n" +
|
||||
" SET dtb_ordr.qta_evasa = \n" +
|
||||
" CASE WHEN (SELECT application_name from azienda ) = 'WINGEST' THEN \n" +
|
||||
" dtb_ordr.qta_evasa + \n" +
|
||||
" (@segno * \n" +
|
||||
" (CASE dtb_ordr.unt_ord\n" +
|
||||
" when doc.unt_doc then doc.qta_doc\n" +
|
||||
" when doc.unt_doc2 then doc.qta_doc2\n" +
|
||||
" when doc.unt_doc3 then doc.qta_doc3\n" +
|
||||
" else \n" +
|
||||
" Round(((doc.qta_doc_no_um / dtb_ordr.rap_conv)),mtb_unt_mis.cifre_dec) \n" +
|
||||
" end ))\n" +
|
||||
" ELSE \n" +
|
||||
" dtb_ordr.qta_evasa \n" +
|
||||
" END, \n" +
|
||||
" dtb_ordr.num_cnf_evasa = dtb_ordr.num_cnf_evasa + (@segno * doc.num_cnf),\n" +
|
||||
" dtb_ordr.flag_evaso_forzato = CASE WHEN @Operation = 'D' THEN 'N' ELSE doc.flag_evaso_forzato END,\n" +
|
||||
" dtb_ordr.flag_evaso = CASE WHEN @Operation = 'D' THEN 'I'\n" +
|
||||
" WHEN doc.flag_evaso_forzato = 'S' THEN 'E' ELSE dtb_ordr.flag_evaso END \n" +
|
||||
" FROM dtb_ordr INNER JOIN mtb_unt_mis ON dtb_ordr.unt_ord = mtb_unt_mis.unt_mis\n" +
|
||||
" INNER JOIN \n" +
|
||||
" (SELECT dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord,\n" +
|
||||
" dtb_docr.riga_ord,\n" +
|
||||
" sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc_no_um,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc,\n" +
|
||||
" sum(dtb_docr.qta_doc) as qta_doc,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc2,\n" +
|
||||
" sum(dtb_docr.qta_doc2) as qta_doc2,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc3,\n" +
|
||||
" sum(dtb_docr.qta_doc3) as qta_doc3,\n" +
|
||||
" sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc \n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" ( dtb_doct.gestione <> 'L' AND (dtb_tipi.segno_qta_car = 1 OR dtb_tipi.segno_qta_scar = 1 ) OR \n" +
|
||||
" ( dtb_doct.gestione = 'L' AND dtb_tipi.segno_qta_scar = 1 ))\n" +
|
||||
" GROUP BY dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord,\n" +
|
||||
" dtb_docr.riga_ord, \n" +
|
||||
" dtb_docr.unt_doc, \n" +
|
||||
" dtb_docr.unt_doc2, \n" +
|
||||
" dtb_docr.unt_doc3 \n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT dtb_ordt.gestione_rif,\n" +
|
||||
" dtb_ordt.data_ord_rif, \n" +
|
||||
" dtb_ordt.num_ord_rif, \n" +
|
||||
" dtb_ordt.riga_ord_rif,\n" +
|
||||
" sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc_no_um,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc,\n" +
|
||||
" sum(dtb_docr.qta_doc) as qta_doc,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc2,\n" +
|
||||
" sum(dtb_docr.qta_doc2) as qta_doc2,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc3,\n" +
|
||||
" sum(dtb_docr.qta_doc3) as qta_doc3,\n" +
|
||||
" sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" left outer join dtb_ordt ON dtb_tipi.gestione = dtb_ordt.gestione and\n" +
|
||||
" dtb_docr.data_ord = dtb_ordt.data_ord and\n" +
|
||||
" dtb_docr.num_ord = dtb_ordt.num_ord\n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" dtb_doct.gestione = 'L' AND dtb_tipi.segno_qta_car = 1 AND\n" +
|
||||
" (SELECT application_name from azienda ) = 'WINGEST'\n" +
|
||||
" GROUP BY dtb_ordt.gestione_rif,\n" +
|
||||
" dtb_ordt.data_ord_rif,\n" +
|
||||
" dtb_ordt.num_ord_rif,\n" +
|
||||
" dtb_ordt.riga_ord_rif, \n" +
|
||||
" dtb_docr.unt_doc, \n" +
|
||||
" dtb_docr.unt_doc2, \n" +
|
||||
" dtb_docr.unt_doc3 ) doc ON\n" +
|
||||
" dtb_ordr.gestione = doc.gestione AND\n" +
|
||||
" dtb_ordr.data_ord = doc.data_ord AND\n" +
|
||||
" dtb_ordr.num_ord = doc.num_ord AND\n" +
|
||||
" dtb_ordr.riga_ord = doc.riga_ord;\n" +
|
||||
" \n" +
|
||||
" UPDATE dtb_ordt\n" +
|
||||
" SET dtb_ordt.qta_evasa_prod = dtb_ordt.qta_evasa_prod + (@segno * (doc.qta_doc / case when dtb_ordt.rap_conv_prod = 0 then 1 ELSE dtb_ordt.rap_conv_prod END)),\n" +
|
||||
" dtb_ordt.flag_evaso_prod = \n" +
|
||||
" CASE WHEN dtb_ordt.flag_evaso_prod = 'A' THEN dtb_ordt.flag_evaso_prod\n" +
|
||||
" WHEN @segno = -1 THEN CASE WHEN dtb_ordt.flag_evaso_forzato ='S' and dtb_ordt.flag_evaso_prod <> 'A' THEN 'E' ELSE 'I' END\n" +
|
||||
" WHEN @segno = 1 THEN \n" +
|
||||
" CASE WHEN doc.flag_evaso_forzato ='S' and dtb_ordt.flag_evaso_prod <> 'A' THEN 'E' \n" +
|
||||
" WHEN dtb_ordt.qta_evasa_prod + (@segno * (doc.qta_doc / case when dtb_ordt.rap_conv_prod = 0 then 1 ELSE dtb_ordt.rap_conv_prod END)) = dtb_ordt.qta_prod then 'E' \n" +
|
||||
" ELSE dtb_ordt.flag_evaso_prod END\n" +
|
||||
" END\n" +
|
||||
" FROM dtb_ordt INNER JOIN \n" +
|
||||
" (SELECT dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord,\n" +
|
||||
" Sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc,\n" +
|
||||
" Sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" dtb_doct.gestione = 'L' AND \n" +
|
||||
" dtb_tipi.segno_qta_car = 1 \n" +
|
||||
" GROUP BY dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT dtb_doct.gestione,\n" +
|
||||
" dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.num_ord,\n" +
|
||||
" Sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc,\n" +
|
||||
" Sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" case when (SELECT application_name from azienda ) = 'WINGEST' THEN min (CASE WHEN dtb_docr.qta_doc >= ord_prod.qta_ord OR (dtb_docr.qta_doc < ord_prod.qta_ord AND dtb_docr.flag_evaso_forzato = 'S' ) THEN 'S' ELSE 'N' END ) ELSE 'N' END as flag_evaso_forzato \n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" inner join dtb_ordr ord_prod on dtb_docr.data_ord = ord_prod.data_ord and\n" +
|
||||
" dtb_docr.num_ord = ord_prod.num_ord and\n" +
|
||||
" dtb_docr.riga_ord = ord_prod.riga_ord and\n" +
|
||||
" ord_prod.gestione = 'A'\n" +
|
||||
" inner join dtb_ordt on dtb_docr.data_ord = dtb_ordt.data_ord_rif and\n" +
|
||||
" dtb_docr.num_ord = dtb_ordt.num_ord_rif and\n" +
|
||||
" dtb_ordt.gestione = 'L' \n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" dtb_doct.gestione = 'L' AND (dtb_tipi.segno_qta_car = 0 AND dtb_tipi.segno_val_car = 1)\n" +
|
||||
" \n" +
|
||||
" GROUP BY dtb_doct.gestione,\n" +
|
||||
" dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.num_ord \n" +
|
||||
" ) doc ON\n" +
|
||||
" dtb_ordt.gestione = doc.gestione AND\n" +
|
||||
" dtb_ordt.data_ord = doc.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = doc.num_ord ;\n" +
|
||||
" \n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@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.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250930122122 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("w_ddocu_ord_rc", "SETUP", "CHK_DATA_DECORRENZA", "S",
|
||||
"Verifica che la data decorrenza sia precedente alla data del documento", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if(isCustomer(IntegryCustomer.RossoGargano))
|
||||
updateSetupValue("w_ddocu_ord_rc", "SETUP", "CHK_DATA_DECORRENZA", "N");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250930151328 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if(isDMS())
|
||||
return;
|
||||
|
||||
createOrUpdateFunction("[GetDatiProvv]", "CREATE FUNCTION [dbo].[GetDatiProvv](@codVlis varchar(5), \n" +
|
||||
" @dataValidita datetime, \n" +
|
||||
" @codAnag varchar(5), \n" +
|
||||
" @codVdes varchar(5), \n" +
|
||||
" @codVage varchar(5), \n" +
|
||||
" @codMart varchar(15), \n" +
|
||||
" @codDivi varchar(5), \n" +
|
||||
" @cambio numeric(20,5))\n" +
|
||||
" RETURNS TABLE AS\n" +
|
||||
" RETURN(\n" +
|
||||
"WITH lisv AS (SELECT lisv.cod_vlis,\n" +
|
||||
" lisv.cod_mart,\n" +
|
||||
" ISNULL(promo.perc_ispe, lisv.perc_ispe) AS perc_ispe,\n" +
|
||||
" ISNULL(promo.val_ispe, lisv.val_ispe) AS val_ispe,\n" +
|
||||
" ISNULL(promo.perc_prov, lisv.perc_prov) AS perc_prov,\n" +
|
||||
" ISNULL(promo.fisso_prov, lisv.fisso_prov) AS fisso_prov,\n" +
|
||||
" cambio\n" +
|
||||
" FROM dbo.getlistinovendita(@datavalidita, @codvlis, @codmart) lisv\n" +
|
||||
" LEFT OUTER JOIN dbo.getpromozionevendita(@datavalidita, @datavalidita, @codvlis, NULL,\n" +
|
||||
" @codmart) promo ON lisv.cod_vlis = promo.cod_vlis AND\n" +
|
||||
" lisv.cod_mart = promo.cod_mart)\n" +
|
||||
"\n" +
|
||||
" , scon AS (SELECT *\n" +
|
||||
" FROM vtb_scon\n" +
|
||||
" WHERE\n" +
|
||||
" vtb_scon.cod_sco_art = (SELECT mtb_aart.cod_sco_art FROM mtb_aart WHERE mtb_aart.cod_mart = @codmart)\n" +
|
||||
" AND vtb_scon.cod_sco_cli = (SELECT ISNULL(vtb_dest.cod_sco_cli, vtb_clie.cod_sco_cli)\n" +
|
||||
" FROM vtb_clie\n" +
|
||||
" LEFT OUTER JOIN vtb_dest\n" +
|
||||
" ON vtb_clie.cod_anag = vtb_dest.cod_anag AND\n" +
|
||||
" vtb_dest.cod_vdes = @codvdes\n" +
|
||||
" WHERE vtb_clie.cod_anag = @codanag))\n" +
|
||||
" , scon_age AS (SELECT *\n" +
|
||||
" FROM vtb_agen_prov\n" +
|
||||
" WHERE vtb_agen_prov.cod_sco_art =\n" +
|
||||
" (SELECT mtb_aart.cod_sco_art FROM mtb_aart WHERE mtb_aart.cod_mart = @codmart)\n" +
|
||||
" AND vtb_agen_prov.cod_sco_cli = (SELECT ISNULL(vtb_dest.cod_sco_cli, vtb_clie.cod_sco_cli)\n" +
|
||||
" FROM vtb_clie\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON vtb_clie.cod_anag =\n" +
|
||||
" vtb_dest.cod_anag AND\n" +
|
||||
" vtb_dest.cod_vdes = @codvdes\n" +
|
||||
" WHERE vtb_clie.cod_anag = @codanag)\n" +
|
||||
" AND vtb_agen_prov.cod_vage = @codvage)\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"/*Acquisizione provvigioni agente e ispettore */\n" +
|
||||
"/* @percProv = round(CASE WHEN vtb_agen_prov.cod_vage IS NULL THEN (CASE WHEN vtb_scon.cod_sco_cli IS NULL THEN (CASE WHEN mtb_lisv.cod_mart IS NULL THEN CASE WHEN vtb_clie.perc_prov = 0 THEN ISNULL(vtb_agen.perc_prov_age, 0) ELSE vtb_Clie.perc_prov END ELSE mtb_lisv.perc_prov END) ELSE vtb_scon.perc_prov END) ELSE vtb_agen_prov.perc_prov END, 5), */\n" +
|
||||
"/* 6.2.2018 (FABIO): implementata nuovamente la logica della provvigione da cliente e agente se presente in anagrafica, ma senza provviggioni */\n" +
|
||||
"/* 14/10/2021 (FABIO): abbiamo aggiunto il campo perc_prov_age nella VTB_AGEN in modo da non leggere da vtb_agen.perc_prov_age che invece è la provvigione dell'ispettore */\n" +
|
||||
"SELECT ROUND(IIF(vtb_agen_prov.cod_vage IS NULL, (IIF(vtb_scon.cod_sco_cli IS NULL, (IIF(mtb_lisv.cod_mart IS NULL, IIF(vtb_clie.perc_prov = 0, ISNULL(vtb_agen.perc_prov_age, 0), vtb_clie.perc_prov), IIF(mtb_lisv.perc_prov = 0 OR mtb_lisv.perc_prov IS NULL, IIF(vtb_clie.perc_prov <> 0, vtb_clie.perc_prov, ISNULL(vtb_agen.perc_prov_age, 0)), mtb_lisv.perc_prov))), vtb_scon.perc_prov)), vtb_agen_prov.perc_prov), 5) AS perc_prov,\n" +
|
||||
" ROUND(IIF(vtb_agen_prov.cod_vage IS NULL, (IIF(vtb_scon.cod_sco_cli IS NULL, (IIF(mtb_lisv.cod_mart IS NULL, 0, mtb_lisv.fisso_prov * @cambio / mtb_lisv.cambio)), vtb_scon.fisso_prov * @cambio / vtb_scon.cambio_divi_cont)), vtb_agen_prov.fisso_prov * @cambio / vtb_agen_prov.cambio_divi_cont), 5) AS val_prov,\n" +
|
||||
" ROUND(IIF(vtb_agen_prov.cod_vage IS NULL, (IIF(vtb_scon.cod_sco_cli IS NULL, (IIF(mtb_lisv.cod_mart IS NULL, 0, mtb_lisv.perc_ispe)), vtb_scon.perc_ispe)), vtb_agen_prov.perc_ispe), 5) AS perc_ispe,\n" +
|
||||
" ROUND(IIF(vtb_agen_prov.cod_vage IS NULL, (IIF(vtb_scon.cod_sco_cli IS NULL, (IIF(mtb_lisv.cod_mart IS NULL, 0, mtb_lisv.val_ispe * @cambio / mtb_lisv.cambio)), vtb_scon.val_ispe * @cambio / vtb_scon.cambio_divi_cont)), vtb_agen_prov.val_ispe * @cambio / vtb_agen_prov.cambio_divi_cont), 5) AS val_ispe,\n" +
|
||||
" ISNULL(vtb_clie.perc_prov2, 0) AS perc_prov2\n" +
|
||||
"\n" +
|
||||
"FROM vtb_clie\n" +
|
||||
" OUTER APPLY scon vtb_scon\n" +
|
||||
" OUTER APPLY scon_age vtb_agen_prov\n" +
|
||||
" OUTER APPLY (SELECT * FROM vtb_agen WHERE vtb_agen.cod_vage = @codvage) vtb_agen\n" +
|
||||
" OUTER APPLY lisv mtb_lisv\n" +
|
||||
"WHERE vtb_clie.cod_anag = @codanag\n" +
|
||||
" \n" +
|
||||
")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250930152326 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if(isDMS())
|
||||
return;
|
||||
createOrUpdateProcedure("UpdProgOrdini", "CREATE PROCEDURE [dbo].[UpdProgOrdini](\n" +
|
||||
" @codAnag varchar(5),\n" +
|
||||
" @codDtip varchar(5),\n" +
|
||||
" @dataDoc dateTime,\n" +
|
||||
" @serDoc varchar(2),\n" +
|
||||
" @numDoc integer,\n" +
|
||||
" @segno integer,\n" +
|
||||
" @Operation varchar(1))\n" +
|
||||
" /***DESCRIZIONE: Questa storedProcedure aggiorna la quantitàevasa degli ordini e anche il \n" +
|
||||
" numero di pezzi, non contiene una serie di logiche particolarti tipo la \n" +
|
||||
" sostuzione dell'articolo nell'ordine\n" +
|
||||
" \n" +
|
||||
" */\n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
" SET NOCOUNT ON;\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
" UPDATE dtb_ordr\n" +
|
||||
" SET dtb_ordr.qta_evasa = \n" +
|
||||
" CASE WHEN (SELECT application_name from azienda ) = 'WINGEST' THEN \n" +
|
||||
" dtb_ordr.qta_evasa + \n" +
|
||||
" (@segno * \n" +
|
||||
" (CASE dtb_ordr.unt_ord\n" +
|
||||
" when doc.unt_doc then doc.qta_doc\n" +
|
||||
" when doc.unt_doc2 then doc.qta_doc2\n" +
|
||||
" when doc.unt_doc3 then doc.qta_doc3\n" +
|
||||
" else \n" +
|
||||
" Round(((doc.qta_doc_no_um / dtb_ordr.rap_conv)),mtb_unt_mis.cifre_dec) \n" +
|
||||
" end ))\n" +
|
||||
" ELSE \n" +
|
||||
" dtb_ordr.qta_evasa \n" +
|
||||
" END, \n" +
|
||||
" dtb_ordr.num_cnf_evasa = dtb_ordr.num_cnf_evasa + (@segno * doc.num_cnf),\n" +
|
||||
" dtb_ordr.flag_evaso_forzato = CASE WHEN @Operation = 'D' THEN 'N' ELSE doc.flag_evaso_forzato END,\n" +
|
||||
" dtb_ordr.flag_evaso = CASE WHEN @Operation = 'D' THEN 'I'\n" +
|
||||
" WHEN doc.flag_evaso_forzato = 'S' THEN 'E' ELSE dtb_ordr.flag_evaso END \n" +
|
||||
" FROM dtb_ordr INNER JOIN mtb_unt_mis ON dtb_ordr.unt_ord = mtb_unt_mis.unt_mis\n" +
|
||||
" INNER JOIN \n" +
|
||||
" (SELECT dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord,\n" +
|
||||
" dtb_docr.riga_ord,\n" +
|
||||
" sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc_no_um,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc,\n" +
|
||||
" sum(dtb_docr.qta_doc) as qta_doc,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc2,\n" +
|
||||
" sum(dtb_docr.qta_doc2) as qta_doc2,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc3,\n" +
|
||||
" sum(dtb_docr.qta_doc3) as qta_doc3,\n" +
|
||||
" sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc \n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" ( dtb_doct.gestione <> 'L' AND (dtb_tipi.segno_qta_car = 1 OR dtb_tipi.segno_qta_scar = 1 ) OR \n" +
|
||||
" ( dtb_doct.gestione = 'L' AND dtb_tipi.segno_qta_scar = 1 ))\n" +
|
||||
" GROUP BY dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord,\n" +
|
||||
" dtb_docr.riga_ord, \n" +
|
||||
" dtb_docr.unt_doc, \n" +
|
||||
" dtb_docr.unt_doc2, \n" +
|
||||
" dtb_docr.unt_doc3 \n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT dtb_ordt.gestione_rif,\n" +
|
||||
" dtb_ordt.data_ord_rif, \n" +
|
||||
" dtb_ordt.num_ord_rif, \n" +
|
||||
" dtb_ordt.riga_ord_rif,\n" +
|
||||
" sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc_no_um,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc,\n" +
|
||||
" sum(dtb_docr.qta_doc) as qta_doc,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc2,\n" +
|
||||
" sum(dtb_docr.qta_doc2) as qta_doc2,\n" +
|
||||
" \n" +
|
||||
" dtb_docr.unt_doc3,\n" +
|
||||
" sum(dtb_docr.qta_doc3) as qta_doc3,\n" +
|
||||
" sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" left outer join dtb_ordt ON dtb_tipi.gestione = dtb_ordt.gestione and\n" +
|
||||
" dtb_docr.data_ord = dtb_ordt.data_ord and\n" +
|
||||
" dtb_docr.num_ord = dtb_ordt.num_ord\n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" dtb_doct.gestione = 'L' AND dtb_tipi.segno_qta_car = 1 AND\n" +
|
||||
" (SELECT application_name from azienda ) = 'WINGEST'\n" +
|
||||
" GROUP BY dtb_ordt.gestione_rif,\n" +
|
||||
" dtb_ordt.data_ord_rif,\n" +
|
||||
" dtb_ordt.num_ord_rif,\n" +
|
||||
" dtb_ordt.riga_ord_rif, \n" +
|
||||
" dtb_docr.unt_doc, \n" +
|
||||
" dtb_docr.unt_doc2, \n" +
|
||||
" dtb_docr.unt_doc3 ) doc ON\n" +
|
||||
" dtb_ordr.gestione = doc.gestione AND\n" +
|
||||
" dtb_ordr.data_ord = doc.data_ord AND\n" +
|
||||
" dtb_ordr.num_ord = doc.num_ord AND\n" +
|
||||
" dtb_ordr.riga_ord = doc.riga_ord;\n" +
|
||||
" \n" +
|
||||
" UPDATE dtb_ordt\n" +
|
||||
" SET dtb_ordt.qta_evasa_prod = dtb_ordt.qta_evasa_prod + (@segno * (doc.qta_doc / case when dtb_ordt.rap_conv_prod = 0 then 1 ELSE dtb_ordt.rap_conv_prod END)),\n" +
|
||||
" dtb_ordt.flag_evaso_prod = \n" +
|
||||
" CASE WHEN dtb_ordt.flag_evaso_prod = 'A' THEN dtb_ordt.flag_evaso_prod\n" +
|
||||
" WHEN @segno = -1 THEN CASE WHEN dtb_ordt.flag_evaso_forzato ='S' and dtb_ordt.flag_evaso_prod <> 'A' THEN 'E' ELSE 'I' END\n" +
|
||||
" WHEN @segno = 1 THEN \n" +
|
||||
" CASE WHEN doc.flag_evaso_forzato ='S' and dtb_ordt.flag_evaso_prod <> 'A' THEN 'E' \n" +
|
||||
" WHEN dtb_ordt.qta_evasa_prod + (@segno * (doc.qta_doc / case when dtb_ordt.rap_conv_prod = 0 then 1 ELSE dtb_ordt.rap_conv_prod END)) = dtb_ordt.qta_prod then 'E' \n" +
|
||||
" ELSE dtb_ordt.flag_evaso_prod END\n" +
|
||||
" END\n" +
|
||||
" FROM dtb_ordt INNER JOIN \n" +
|
||||
" (SELECT dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord,\n" +
|
||||
" Sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc,\n" +
|
||||
" Sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" max(dtb_docr.flag_evaso_forzato) as flag_evaso_forzato\n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" dtb_doct.gestione = 'L' AND \n" +
|
||||
" dtb_tipi.segno_qta_car = 1 \n" +
|
||||
" GROUP BY dtb_doct.gestione,\n" +
|
||||
" dtb_docr.data_ord,\n" +
|
||||
" dtb_docr.num_ord\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT dtb_doct.gestione,\n" +
|
||||
" dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.num_ord,\n" +
|
||||
" Sum(dtb_docr.qta_doc * dtb_docr.rap_conv) as qta_doc,\n" +
|
||||
" Sum(dtb_docr.num_cnf) as num_cnf,\n" +
|
||||
" case when (SELECT application_name from azienda ) = 'WINGEST' THEN min (CASE WHEN dtb_docr.qta_doc >= ord_prod.qta_ord OR (dtb_docr.qta_doc < ord_prod.qta_ord AND dtb_docr.flag_evaso_forzato = 'S' ) THEN 'S' ELSE 'N' END ) ELSE 'N' END as flag_evaso_forzato \n" +
|
||||
" FROM dtb_doct inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" inner join dtb_docr on dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" inner join dtb_ordr ord_prod on dtb_docr.data_ord = ord_prod.data_ord and\n" +
|
||||
" dtb_docr.num_ord = ord_prod.num_ord and\n" +
|
||||
" dtb_docr.riga_ord = ord_prod.riga_ord and\n" +
|
||||
" ord_prod.gestione = 'A'\n" +
|
||||
" inner join dtb_ordt on dtb_docr.data_ord = dtb_ordt.data_ord_rif and\n" +
|
||||
" dtb_docr.num_ord = dtb_ordt.num_ord_rif and\n" +
|
||||
" dtb_ordt.gestione = 'L' \n" +
|
||||
" WHERE dtb_doct.cod_dtip = @codDtip AND\n" +
|
||||
" dtb_doct.cod_anag = @codAnag AND\n" +
|
||||
" dtb_doct.data_doc = @dataDoc AND\n" +
|
||||
" dtb_doct.ser_doc = @serDoc AND\n" +
|
||||
" dtb_doct.num_doc = @numDoc AND\n" +
|
||||
" dtb_docr.data_ord is not null AND\n" +
|
||||
" dtb_doct.gestione = 'L' AND (dtb_tipi.segno_qta_car = 0 AND dtb_tipi.segno_val_car = 1)\n" +
|
||||
" \n" +
|
||||
" GROUP BY dtb_doct.gestione,\n" +
|
||||
" dtb_ordt.data_ord,\n" +
|
||||
" dtb_ordt.num_ord \n" +
|
||||
" ) doc ON\n" +
|
||||
" dtb_ordt.gestione = doc.gestione AND\n" +
|
||||
" dtb_ordt.data_ord = doc.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = doc.num_ord ;\n" +
|
||||
" \n" +
|
||||
"END");
|
||||
|
||||
}
|
||||
|
||||
@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_20250930182717 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", "CBX_VISUALIZZANOTEAGG", "VISIBLE", "N",
|
||||
"Inserire S/N se si vuole o meno visualizzare il flag", 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,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251001103200 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("update stb_gest_setup set key_section = 'FLAG_COSTO_DISTINTA_NO_MDO' where key_section = 'COSTO_DA_DISTINTA_SENZA_MDO' and gest_name = 'w_mriassegna_costo_dlg'");
|
||||
}
|
||||
|
||||
@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_20251001104616 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("update stb_gest_setup set section = 'SETUP' where key_section = 'FLAG_COSTO_DISTINTA_NO_MDO'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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 java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20251001151805 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
List<HashMap<String,Object>> constraints = executeQuery("SELECT dc.name AS ConstraintName,\n" +
|
||||
" OBJECT_NAME(dc.parent_object_id) AS TableName,\n" +
|
||||
" c.name AS ColumnName\n" +
|
||||
"FROM sys.default_constraints dc\n" +
|
||||
"INNER JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id\n" +
|
||||
"WHERE OBJECT_NAME(dc.parent_object_id) = 'wtb_depo'\n" +
|
||||
"AND c.name = 'default_depo';\n");
|
||||
if (constraints != null && !constraints.isEmpty()) {
|
||||
String constraint = constraints.get(0).get("ConstraintName").toString();
|
||||
executeStatement("alter table dbo.wtb_depo drop constraint " + constraint);
|
||||
}
|
||||
|
||||
executeStatement("drop index ux_wtb_depo_depo_default_utente on dbo.wtb_depo",
|
||||
"alter table dbo.wtb_depo ALTER column default_depo BIT NOT NULL",
|
||||
"alter table dbo.wtb_depo ADD constraint DF_wtb_depo_default DEFAULT 0 FOR default_depo",
|
||||
"create unique index ux_wtb_depo_depo_default_utente\n" +
|
||||
" on dbo.wtb_depo (user_name)\n" +
|
||||
" where default_depo = 1");
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Biolevante_Biolevante)){
|
||||
executeStatement("update wtb_depo set default_depo = 1 where cod_mdep = '01'");
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
import it.integry.ems_model.entity.JtbFasi;
|
||||
|
||||
public class Migration_20251002111947 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("MES", "SETUP", "VINCOLA_DATA_PROD_AL_LOTTO", "N", "Se true, sulle linee su cui è impostata la data produzione della partita verrà calcolata in base alla partita stessa (es. dal giorno giuliano selezionato)", false, "SI_NO", false, false, false, false, false, JtbFasi.ENTITY, false, null);
|
||||
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)){
|
||||
executeStatement("INSERT INTO stb_gest_setup_det (gest_name, section, key_section, tipo_setup, val_col_rif, value)\n" +
|
||||
"SELECT N'MES',\n" +
|
||||
" N'SETUP',\n" +
|
||||
" N'VINCOLA_DATA_PROD_AL_LOTTO',\n" +
|
||||
" N'" + JtbFasi.ENTITY + "',\n" +
|
||||
" cod_jfas,\n" +
|
||||
" 'S'\n" +
|
||||
"FROM jtb_fasi\n" +
|
||||
"WHERE cod_jfas IN ('E5')\n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
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_20251002112352 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("f_suggestDataProdPartitaMag","CREATE FUNCTION [dbo].[f_suggestDataProdPartitaMag](@codMart VARCHAR(15),@partitaMag VARCHAR(20), @codJfas varchar(5))\n" +
|
||||
" RETURNS DATE\n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
"\n" +
|
||||
"RETURN NULL\n" +
|
||||
"END\n"
|
||||
);
|
||||
|
||||
if (isCustomer(IntegryCustomer.RossoGargano)){
|
||||
createOrUpdateFunction("f_suggestDataProdPartitaMag","CREATE FUNCTION [dbo].[f_suggestDataProdPartitaMag](@codMart VARCHAR(15), @partitaMag VARCHAR(20), @codJfas varchar(5))\n" +
|
||||
" RETURNS DATE\n" +
|
||||
" AS\n" +
|
||||
" BEGIN\n" +
|
||||
"\n" +
|
||||
" DECLARE @idProduttore VARCHAR(10), @idProduttorePartita varchar(10);\n" +
|
||||
" DECLARE @idLottoLav VARCHAR(5);\n" +
|
||||
" DECLARE @codMdep VARCHAR(5);\n" +
|
||||
" DECLARE @annoLottoLav smallint;\n" +
|
||||
" DECLARE @ggGiuliano smallint;\n" +
|
||||
" DECLARE @dataProd date;\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" SELECT @codMdep = cod_mdep_lav from jtb_fasi where cod_jfas = @codJfas;\n" +
|
||||
"\n" +
|
||||
" SELECT @idProduttore = ISNULL(stb_gest_setup_depo.value, stb_gest_setup.value)\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" LEFT OUTER JOIN stb_gest_setup_depo ON stb_gest_setup.gest_name = stb_gest_setup_depo.gest_name AND\n" +
|
||||
" stb_gest_setup.section = stb_gest_setup_depo.section AND\n" +
|
||||
" stb_gest_setup.key_section = stb_gest_setup_depo.key_section\n" +
|
||||
" AND stb_gest_setup_depo.cod_mdep = @codMdep\n" +
|
||||
" WHERE stb_gest_setup.gest_name = 'DATI_AZIENDA'\n" +
|
||||
" AND stb_gest_setup.section = 'SETUP'\n" +
|
||||
" AND stb_gest_setup.key_section = 'COD_PRODUTTORE';\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" SELECT @idProduttorePartita = SUBSTRING(@partitaMag, 1, LEN(@idProduttore));\n" +
|
||||
"\n" +
|
||||
" if not @idProduttorePartita = @idProduttore\n" +
|
||||
" return null;\n" +
|
||||
"\n" +
|
||||
" select @partitaMag = REPLACE(@partitaMag, @idProduttore, '');\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" SELECT @idLottoLav = SUBSTRING(@partitaMag, 1, 1);\n" +
|
||||
" SELECT @annoLottoLav = anno from gtb_anni_divi where id_lotto_lav = @idLottoLav;\n" +
|
||||
"\n" +
|
||||
" if @annoLottoLav is null\n" +
|
||||
" return null;\n" +
|
||||
"\n" +
|
||||
" SELECT @ggGiuliano = SUBSTRING(@partitaMag, 2, 3);\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" SELECT @dataProd = DATEADD(DAY, @ggGiuliano - 1, DATEFROMPARTS(@annoLottoLav, 1, 1));\n" +
|
||||
" return @dataProd\n" +
|
||||
"\n" +
|
||||
" END\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_20251002113809 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isTextiles()) return;
|
||||
|
||||
dropIndex("ttb_qta_min_ord", "ix_unique_ttb_qta_min_ord");
|
||||
executeStatement("create unique index ix_unique_ttb_qta_min_ord on ttb_qta_min_ord (cod_line, cod_style, cod_grtg, range_taglie);");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
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_20251002114819 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (!isCustomer(IntegryCustomer.Biolevante)) return;
|
||||
|
||||
|
||||
createOrUpdateFunction("f_pp_consuntivo_prod_tracc", "CREATE function [dbo].[f_pp_consuntivo_prod_tracc] (@as_codProdParent varchar(15), @as_partitaMagParent varchar(20), @ac_qtaProdParent numeric(20,5), @as_codProd varchar(15), @as_partitaMag varchar(20), @ac_qtaProd numeric(20, 5), @ai_livello integer, @as_item_id varchar(255), @ai_idRiga integer) \n" +
|
||||
"RETURNS @dettCosti TABLE(livello integer, \n" +
|
||||
" item_id varchar(255),\n" +
|
||||
" cod_prod_parent varchar(15),\n" +
|
||||
" partita_mag_parent varchar(20), \n" +
|
||||
" qta_prod_parent numeric(20,5),\n" +
|
||||
" cod_prod varchar(15),\n" +
|
||||
" partita_mag varchar(20), \n" +
|
||||
" qta_prod numeric(20,5),\n" +
|
||||
" gruppo_conto varchar(40), \n" +
|
||||
" conto varchar(40), \n" +
|
||||
" descrizione_conto varchar(255), \n" +
|
||||
" dettaglio_conto varchar(40),\n" +
|
||||
" unt_mis varchar(5), \n" +
|
||||
" qta_consumata numeric(20, 5)) AS\n" +
|
||||
"Begin\n" +
|
||||
" DECLARE \n" +
|
||||
" @lc_qtaProd numeric(20,5), \n" +
|
||||
" @ls_gruppoConto varchar(40), \n" +
|
||||
" @ls_codMart varchar(15), \n" +
|
||||
" @ls_partitaMag varchar(20), \n" +
|
||||
" @ls_descrizione varchar(255), \n" +
|
||||
" @ls_untMis varchar(5), \n" +
|
||||
" @lc_qtaMP numeric(20,5), \n" +
|
||||
" @li_existDist integer, \n" +
|
||||
" @lc_rapporto numeric(20, 5),\n" +
|
||||
" @lc_qtaProdScaricata numeric(20,5),\n" +
|
||||
" @li_livello integer, \n" +
|
||||
" @ls_itemID varchar(255),\n" +
|
||||
" @li_idRiga integer,\n" +
|
||||
" @ls_codMiscela varchar(15),\n" +
|
||||
" @ls_posizione varchar(20),\n" +
|
||||
" @ls_posizione_da varchar(20),\n" +
|
||||
" @ls_posizione_a varchar(20)\n" +
|
||||
"\n" +
|
||||
" SELECT @ls_codMiscela = cod_mart FROM olvw_miscele_olio\n" +
|
||||
"\n" +
|
||||
" if @ai_idRiga is null\n" +
|
||||
" begin\n" +
|
||||
" SELECT @ai_livello = 1\n" +
|
||||
" SELECT @as_item_id = '00001';\n" +
|
||||
" end ;\n" +
|
||||
" IF @as_item_id = '' \n" +
|
||||
" begin\n" +
|
||||
" Select @ls_posizione = mtb_depo_posizioni.posizione from mtb_partita_mag, mtb_depo_posizioni \n" +
|
||||
" where mtb_depo_posizioni.posizione = mtb_partita_mag.posizione and\n" +
|
||||
" mtb_partita_mag.cod_mart = @as_codProdParent and partita_mag = @as_partitaMagParent and\n" +
|
||||
" mtb_depo_posizioni.flag_silos_liquidi = 1;\n" +
|
||||
" If @ls_posizione is not null Select @as_item_id = 'SILOS' --Serve ad identificare le miscele di olio\n" +
|
||||
" end\n" +
|
||||
"\n" +
|
||||
" /* Acquisizione quantita totale prodotta per prodotto-partita */\n" +
|
||||
" Select @lc_qtaProd = ISNULL(sum(dtb_docr.qta_doc * dtb_docr.rap_conv * dtb_tipi.segno_qta_car), 0)\n" +
|
||||
" from dtb_docr, \n" +
|
||||
" dtb_tipi, \n" +
|
||||
" mtb_aart, \n" +
|
||||
" mtb_grup\n" +
|
||||
" where dtb_docr.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_docr.cod_mart = mtb_aart.cod_mart and\n" +
|
||||
" mtb_aart.cod_mgrp = mtb_Grup.cod_mgrp and\n" +
|
||||
" dtb_docr.cod_mart = @as_codProd and\n" +
|
||||
" dtb_docr.partita_mag = @as_partitaMag and\n" +
|
||||
" dtb_tipi.gestione = 'L' and\n" +
|
||||
" dtb_tipi.tipo_emissione = 'DIRETTA' and\n" +
|
||||
" dtb_tipi.segno_qta_car <> 0\n" +
|
||||
"\n" +
|
||||
" /* Calcolo del rapporto della qta passata come parametro e di quella totale*/\n" +
|
||||
" if @ac_qtaProd is not null\n" +
|
||||
" if @lc_qtaProd = 0 select @lc_rapporto = 0 else select @lc_rapporto = @ac_qtaProd / @lc_qtaProd\n" +
|
||||
" else\n" +
|
||||
" begin \n" +
|
||||
" select @lc_rapporto = 1\n" +
|
||||
" select @ac_qtaProdParent = @lc_qtaProd\n" +
|
||||
" end\n" +
|
||||
" \n" +
|
||||
" /* Acquisizione totale quantita' prodotta per prododo-partita_mag dagli scarichi\n" +
|
||||
" E' necessario prendere la quantita dalla testata degli scarichi perche' ci \n" +
|
||||
" potrebbero essere delle perdite rispetto alla quantita' caricata.\n" +
|
||||
" N.B. al momento questa variabile viene acquisita solo per controllo in fase di debug\n" +
|
||||
" */\n" +
|
||||
" Select @lc_qtaProdScaricata = sum(dtb_doct.qta_prod*dtb_doct.rap_conv_prod * @lc_rapporto)\n" +
|
||||
" From dtb_doct, \n" +
|
||||
" dtb_tipi\n" +
|
||||
" Where dtb_doct.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione = 'L' and \n" +
|
||||
" dtb_tipi.segno_qta_scar = 1 and\n" +
|
||||
" dtb_doct.cod_prod = @as_codProd and\n" +
|
||||
" ISNULL(dtb_doct.partita_mag, '') = ISNULL(@as_partitaMag, '')\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
" /* Acquisizione scarichi per prodotto-partita_mag */\n" +
|
||||
" select @li_idRiga = 0;\n" +
|
||||
" IF @as_codProd = @ls_codMiscela\n" +
|
||||
" begin\n" +
|
||||
" Select @ai_livello = @ai_livello+1\n" +
|
||||
" end\n" +
|
||||
" Declare csr_scarichi Cursor LOCAL SCROLL FOR\n" +
|
||||
" Select PP_gruppiCostiMP.GruppoConto,\n" +
|
||||
" dtb_docr.cod_mart, \n" +
|
||||
" dtb_docr.partita_mag,\n" +
|
||||
" dtb_docr.descrizione_estesa as descrizione,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" sum(dtb_docr.qta_doc*dtb_docr.rap_conv*dtb_tipi.segno_qta_scar*@lc_rapporto) as Qta_mp\n" +
|
||||
" From dtb_doct, \n" +
|
||||
" dtb_docr, \n" +
|
||||
" dtb_tipi, \n" +
|
||||
" mtb_aart, \n" +
|
||||
" mtb_grup, \n" +
|
||||
" PP_gruppiCostiMP\n" +
|
||||
" Where dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc and\n" +
|
||||
" dtb_doct.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.gestione = 'L' and \n" +
|
||||
" dtb_tipi.segno_qta_scar = 1 and\n" +
|
||||
" dtb_docr.cod_mart = mtb_aart.cod_mart and\n" +
|
||||
" mtb_aart.cod_mgrp = mtb_grup.cod_mgrp and\n" +
|
||||
" dtb_docr.cod_mart = PP_gruppiCostiMP.cod_mart and\n" +
|
||||
" dtb_doct.cod_prod = @as_codProd and\n" +
|
||||
" ISNULL(dtb_doct.partita_mag, '') = ISNULL(@as_partitaMag, '')\n" +
|
||||
" and NOT (dtb_docr.cod_mart = @as_codProd and ISNULL(dtb_docr.partita_mag, '') = ISNULL(@as_partitaMag, ''))\n" +
|
||||
" group by PP_gruppiCostiMP.GruppoConto,\n" +
|
||||
" dtb_docr.cod_mart, \n" +
|
||||
" dtb_docr.partita_mag,\n" +
|
||||
" dtb_docr.descrizione_estesa,\n" +
|
||||
" mtb_aart.unt_mis\n" +
|
||||
" union all\n" +
|
||||
" \n" +
|
||||
" Select PP_gruppiCostiMP.GruppoConto,\n" +
|
||||
" car.cod_mart, \n" +
|
||||
" car.partita_mag,\n" +
|
||||
" car.descrizione_estesa as descrizione,\n" +
|
||||
" mtb_aart.unt_mis,\n" +
|
||||
" sum(car.qta_doc*car.rap_conv*dtb_tipi.segno_qta_scar*@lc_rapporto) as Qta_mp \n" +
|
||||
" from dtb_doct inner join dtb_docr on dtb_doct.cod_anag = dtb_docr.cod_anag and\n" +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip and\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and\n" +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc \n" +
|
||||
" inner join dtb_tipi on dtb_doct.cod_dtip = dtb_tipi.cod_dtip \n" +
|
||||
" inner join dtb_docr car on dtb_doct.activity_id = car.activity_id_row \n" +
|
||||
" inner join dtb_tipi tipo_car on car.cod_dtip = tipo_car.cod_dtip\n" +
|
||||
" inner join olvw_caratteristiche on car.cod_mart = olvw_caratteristiche.cod_mart\n" +
|
||||
" inner join PP_gruppiCostiMP on car.cod_mart = PP_gruppiCostiMP.cod_mart\n" +
|
||||
" inner join mtb_aart on car.cod_mart = mtb_aart.cod_mart \n" +
|
||||
" inner join mtb_grup on mtb_aart.cod_mgrp = mtb_grup.cod_mgrp \n" +
|
||||
" where tipo_car.gestione = 'L' and \n" +
|
||||
" tipo_car.segno_qta_car - tipo_car.segno_qta_scar < 0 and \n" +
|
||||
" olvw_caratteristiche.Confezionato = 'S' and \n" +
|
||||
" dtb_tipi.gestione = 'L' and \n" +
|
||||
" dtb_tipi.segno_qta_scar = 1 and\n" +
|
||||
" dtb_doct.cod_prod = @as_codProd and\n" +
|
||||
" ISNULL(dtb_doct.partita_mag, '') = ISNULL(@as_partitaMag, '')\n" +
|
||||
" and NOT (dtb_docr.cod_mart = @as_codProd and ISNULL(dtb_docr.partita_mag, '') = ISNULL(@as_partitaMag, '')) \n" +
|
||||
" group by PP_gruppiCostiMP.GruppoConto,\n" +
|
||||
" car.cod_mart, \n" +
|
||||
" car.partita_mag,\n" +
|
||||
" car.descrizione_estesa,\n" +
|
||||
" mtb_aart.unt_mis\n" +
|
||||
" Order by PP_gruppiCostiMP.GruppoConto desc \n" +
|
||||
" \n" +
|
||||
" OPEN csr_scarichi\n" +
|
||||
" FETCH NEXT FROM csr_scarichi INTO @ls_gruppoConto, @ls_codMart, @ls_partitaMag, @ls_descrizione, @ls_untMis, @lc_qtaMP\n" +
|
||||
" WHILE @@FETCH_STATUS = 0\n" +
|
||||
" begin\n" +
|
||||
" IF ABS(@lc_qtaMP) > 0.01\n" +
|
||||
" Begin\n" +
|
||||
" select @li_idRiga = @li_idRiga + 1;\n" +
|
||||
" SELECT @ls_itemID = @as_item_id + '_' + REPLICATE('0', 5 - len(CONVERT(varchar(15), @li_idRiga))) + CONVERT(varchar(15), @li_idRiga); \n" +
|
||||
"\n" +
|
||||
" /* verifica esistenza scarico, Indica che siamo in presenza di un semilavorato/lotto */\n" +
|
||||
" select @li_existDist = count(*)\n" +
|
||||
" from dtb_doct, dtb_tipi\n" +
|
||||
" where dtb_doct.cod_prod = @ls_codMart and partita_mag = @ls_partitaMag and \n" +
|
||||
" dtb_doct.cod_dtip = dtb_tipi.cod_dtip and\n" +
|
||||
" dtb_tipi.segno_qta_scar = 1 and \n" +
|
||||
" dtb_doct.gestione = 'L'\n" +
|
||||
" \n" +
|
||||
" \n" +
|
||||
" /* Materia prima */\n" +
|
||||
" if @li_existDist = 0 or @@NESTLEVEL >= 30\n" +
|
||||
" begin\n" +
|
||||
" insert into @dettCosti \n" +
|
||||
" select @ai_livello,\n" +
|
||||
" @ls_itemID,\n" +
|
||||
" @as_codProdParent, \n" +
|
||||
" @as_partitaMagParent, \n" +
|
||||
" @ac_qtaProdParent, \n" +
|
||||
" @as_codProd, \n" +
|
||||
" @as_partitaMag, \n" +
|
||||
" @lc_qtaProdScaricata, \n" +
|
||||
" @ls_gruppoConto, \n" +
|
||||
" @ls_codMart, \n" +
|
||||
" @ls_descrizione, \n" +
|
||||
" @ls_partitaMag, \n" +
|
||||
" @ls_untMis, \n" +
|
||||
" @lc_qtaMP\n" +
|
||||
" end\n" +
|
||||
" else\n" +
|
||||
" Begin\n" +
|
||||
" /* Semilavorato */\n" +
|
||||
" \n" +
|
||||
" Select @ls_posizione_a = mtb_depo_posizioni.posizione \n" +
|
||||
" from mtb_partita_mag, mtb_depo_posizioni \n" +
|
||||
" where mtb_depo_posizioni.posizione = mtb_partita_mag.posizione and\n" +
|
||||
" mtb_partita_mag.cod_mart = @as_codProd and partita_mag = @as_partitaMag and\n" +
|
||||
" mtb_depo_posizioni.flag_silos_liquidi = 1;\n" +
|
||||
" Select @ls_posizione_da = mtb_depo_posizioni.posizione \n" +
|
||||
" from mtb_partita_mag, mtb_depo_posizioni \n" +
|
||||
" where mtb_depo_posizioni.posizione = mtb_partita_mag.posizione and\n" +
|
||||
" mtb_partita_mag.cod_mart = @ls_codMart and partita_mag = @ls_partitaMag and\n" +
|
||||
" mtb_depo_posizioni.flag_silos_liquidi = 1;\n" +
|
||||
"\n" +
|
||||
" If @ls_posizione_da is not null and\n" +
|
||||
" (ISNULL(@ls_posizione_da,'') <> ISNULL(@ls_posizione_a,00) or \n" +
|
||||
" @ls_posizione_da is null or @ls_posizione_a is null or \n" +
|
||||
" (@ai_livello <1 and @as_codProd = @ls_codMiscela) or \n" +
|
||||
" (ISNULL(@ls_posizione_da,'') = ISNULL(@ls_posizione_a,00) and @as_codProd= @ls_codMiscela))\n" +
|
||||
" --Questa insert serve per trattare l'olio che proviene da altro serbatoio come una materia prima a partire dal 2° livello di ricorsione\n" +
|
||||
" Begin\n" +
|
||||
" insert into @dettCosti \n" +
|
||||
" select @ai_livello,\n" +
|
||||
" @ls_itemID,\n" +
|
||||
" @as_codProdParent, \n" +
|
||||
" @as_partitaMagParent, \n" +
|
||||
" @ac_qtaProdParent, \n" +
|
||||
" @as_codProd, \n" +
|
||||
" @as_partitaMag, \n" +
|
||||
" @lc_qtaProdScaricata, \n" +
|
||||
" @ls_gruppoConto, \n" +
|
||||
" @ls_codMart, \n" +
|
||||
" @ls_descrizione, \n" +
|
||||
" @ls_partitaMag, \n" +
|
||||
" @ls_untMis, \n" +
|
||||
" @lc_qtaMP;\n" +
|
||||
" End\n" +
|
||||
" \n" +
|
||||
" /*Ricorsione su semilavorato-partita_mag*/\n" +
|
||||
" If ISNULL(@ls_posizione_da,'') = ISNULL(@ls_posizione_a,00) and @as_codProd <> @ls_codMiscela or \n" +
|
||||
" @ls_posizione_da is null or @ls_posizione_a is null or \n" +
|
||||
" (@ai_livello <1 and @as_codProd = @ls_codMiscela)\n" +
|
||||
" --La ricorsione non avviene sugli olii provenienti da altro serbatoio e neanche nel caso di Miscele fittizie create nello stesso serbatoio dell'olio di provenienza in assenza di polmone\n" +
|
||||
" insert into @dettCosti \n" +
|
||||
" select costi.livello, \n" +
|
||||
" costi.item_id,\n" +
|
||||
" @as_codProdParent, \n" +
|
||||
" @as_partitaMagParent,\n" +
|
||||
" @ac_qtaProdParent,\n" +
|
||||
" costi.cod_prod, \n" +
|
||||
" costi.partita_mag, \n" +
|
||||
" costi.qta_prod,\n" +
|
||||
" costi.gruppo_conto, \n" +
|
||||
" costi.conto, \n" +
|
||||
" costi.descrizione_conto, \n" +
|
||||
" costi.dettaglio_conto,\n" +
|
||||
" costi.unt_mis, \n" +
|
||||
" costi.qta_consumata \n" +
|
||||
" from dbo.f_pp_consuntivo_prod_tracc(@as_codProdParent, @as_partitaMagParent, @ac_qtaProdParent, @ls_codMart, @ls_partitaMag, @lc_qtaMP, @ai_livello, @ls_itemID, @li_idRiga) costi\n" +
|
||||
" \n" +
|
||||
" \n" +
|
||||
" end\n" +
|
||||
" end\n" +
|
||||
" FETCH NEXT FROM csr_scarichi INTO @ls_gruppoConto, @ls_codMart, @ls_partitaMag, @ls_descrizione, @ls_untMis, @lc_qtaMP\n" +
|
||||
" end\n" +
|
||||
" close csr_scarichi\n" +
|
||||
" deallocate csr_scarichi\n" +
|
||||
" return\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251002130813 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("update stb_gest_setup set flag_setup_depo = 'S'\n" +
|
||||
"where gest_name = 'IMPORT_SCONTRINI'\n" +
|
||||
"and key_section = 'ATTIVO'\n" +
|
||||
"and section = 'MMPOS'");
|
||||
|
||||
enableSaveToRest("nvdoct");
|
||||
if (isCustomer(IntegryCustomer.Carelli)) {
|
||||
executeStatement("UPDATE stb_gest_setup SET value = 'N'\n" +
|
||||
"where gest_name = 'IMPORT_SCONTRINI'\n" +
|
||||
"and key_section = 'ATTIVO'\n" +
|
||||
"and section not in ('INTEGRETAIL', 'MMPOS_SERVICES', 'MMPOS')");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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