Compare commits
1876 commits
dev-schedu
...
10_01_2024
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c2ce48bd1 | ||
|
|
0fd9208e41 | ||
|
|
ab80d194a5 | ||
|
|
6590d63026 | ||
|
|
b96fcaae7d | ||
|
|
517dc8669a | ||
|
|
8df2442aa6 | ||
|
|
c959023094 | ||
|
|
54c3d7c235 | ||
|
|
892bdcb769 | ||
|
|
66ead14acb | ||
|
|
072a5dbcd9 | ||
|
|
730ae2aba4 | ||
|
|
5ad1b0d569 | ||
|
|
2a400e1a8a | ||
|
|
c8336ce8a4 | ||
|
|
08867e3cb9 | ||
|
|
999b0999de | ||
|
|
038f676eef | ||
|
|
c5a62a0bd4 | ||
|
|
ab34364a22 | ||
|
|
91b6f9efbc | ||
|
|
9a279eead8 | ||
|
|
c5f79afb50 | ||
|
|
de9619376b | ||
|
|
0dd5cec12e | ||
|
|
cd488b19d8 | ||
|
|
1ec2b25714 | ||
|
|
8fe43dee98 | ||
|
|
49b3191a63 | ||
|
|
2a81e33b78 | ||
|
|
313ff28cbd | ||
|
|
2656d6a78c | ||
|
|
dc21de68f2 | ||
|
|
2c2cc64595 | ||
|
|
17910bd224 | ||
|
|
02e2b3a3f2 | ||
|
|
fe48b00464 | ||
|
|
3f5fa0433f | ||
|
|
4e78439e54 | ||
|
|
673bb48938 | ||
|
|
0dc90cf828 | ||
|
|
afbe819255 | ||
|
|
9b8e68a94c | ||
|
|
d5e764131d | ||
|
|
793171b3da | ||
|
|
4bcc725c26 | ||
|
|
2da0ac042c | ||
|
|
99f4dbe292 | ||
|
|
4bd6dab4b1 | ||
|
|
e028aee516 | ||
|
|
7641b2691c | ||
|
|
970da463fc | ||
|
|
5639f9ff8b | ||
|
|
8e948bc27a | ||
|
|
0b2bef797e | ||
|
|
e04460b194 | ||
|
|
0c00c7fdb3 | ||
|
|
494bafbe18 | ||
|
|
4b1b6113f4 | ||
|
|
53198ca9f5 | ||
|
|
3e6b8911c9 | ||
|
|
1d4d831ea7 | ||
|
|
085b0cf4ce | ||
|
|
632bdf9e09 | ||
|
|
866c063b0d | ||
|
|
911c90bc45 | ||
|
|
8ae41b9d16 | ||
|
|
37a741e866 | ||
|
|
4a0df9bb48 | ||
|
|
939ea451a1 | ||
|
|
ee0f95fcde | ||
|
|
4581592380 | ||
|
|
4e431ee798 | ||
|
|
10d8803651 | ||
|
|
fac5dca462 | ||
|
|
06b38cc61f | ||
|
|
4dfb642e1b | ||
|
|
740c138ead | ||
|
|
0d134db9c6 | ||
|
|
deaa77a05c | ||
|
|
c86f1e907a | ||
|
|
04bc8e9edf | ||
|
|
e8cba0467a | ||
|
|
9f988d34c0 | ||
|
|
3fbb5931df | ||
|
|
15242a0a75 | ||
|
|
5cd8608584 | ||
|
|
943ec5f762 | ||
|
|
20f6c6a939 | ||
|
|
9e9a801bde | ||
|
|
a8386a9ed9 | ||
|
|
fd25105fe8 | ||
|
|
858e02084b | ||
|
|
eb3bed4a1d | ||
|
|
8079ec1fb3 | ||
|
|
cc2f20de3c | ||
|
|
145d3f4c74 | ||
|
|
e6ede79021 | ||
|
|
a2ebfd945b | ||
|
|
c7ad0a181c | ||
|
|
12ff85188f | ||
|
|
9c827763de | ||
|
|
59d0b000d1 | ||
|
|
60e7c6ac39 | ||
|
|
9b26fb2290 | ||
|
|
81c4c9fa99 | ||
|
|
9ac71532f7 | ||
|
|
79eaffbda6 | ||
|
|
8deebfafbb | ||
|
|
31de64e5bb | ||
|
|
afeede8baa | ||
|
|
286b3ace2c | ||
|
|
2f54dcaccf | ||
|
|
bcb4307acd | ||
|
|
0bc0f9461f | ||
|
|
681e612bbd | ||
|
|
b5b204bf5f | ||
|
|
a2dcd21867 | ||
|
|
9eff119ff2 | ||
|
|
2a61062eb9 | ||
|
|
fba4a07513 | ||
|
|
7b24b1d6ab | ||
|
|
e7c48f17e6 | ||
|
|
520233356b | ||
|
|
68a1a4d9d9 | ||
|
|
3437106728 | ||
|
|
a3d2726b23 | ||
|
|
269a74960b | ||
|
|
0befdfab92 | ||
|
|
90aba79ded | ||
|
|
02c768d273 | ||
|
|
657a3e79eb | ||
|
|
41ce70416c | ||
|
|
63d0a12f55 | ||
|
|
488f7f999b | ||
|
|
d0a359a97e | ||
|
|
5023e922cf | ||
|
|
205386d78a | ||
|
|
a048a46bf6 | ||
|
|
55c8486507 | ||
|
|
6887b627c7 | ||
|
|
1d36a64dd5 | ||
|
|
86a76a4488 | ||
|
|
039f1f8510 | ||
|
|
e8895ebd84 | ||
|
|
39b1b25c80 | ||
|
|
e7ac9a8784 | ||
|
|
f4f313a1ce | ||
|
|
e4c362db00 | ||
|
|
846a364164 | ||
|
|
6dece4c19f | ||
|
|
113d0e0d65 | ||
|
|
03eb67f82e | ||
|
|
7b422acc4a | ||
|
|
4006c1f233 | ||
|
|
789f18181a | ||
|
|
50ebdbacb9 | ||
|
|
ba438187e5 | ||
|
|
894408354b | ||
|
|
3eaa2a9ac6 | ||
|
|
dc3ea5d48a | ||
|
|
391384fab2 | ||
|
|
0b4c277ea0 | ||
|
|
98a2cf46d2 | ||
|
|
38dab80e99 | ||
|
|
aa1e5f7ac1 | ||
|
|
6f04b15527 | ||
|
|
0522b3a562 | ||
|
|
76a1b74c4b | ||
|
|
53810fd4f1 | ||
|
|
723f177c25 | ||
|
|
5fd85852bb | ||
|
|
1af852e09c | ||
|
|
7e2e9dcd51 | ||
|
|
7a359c1d98 | ||
|
|
ffe2134dfd | ||
|
|
f905772251 | ||
|
|
93951a3bf5 | ||
|
|
0744364924 | ||
|
|
64c174e806 | ||
|
|
a4c4fe8c71 | ||
|
|
98922dac8c | ||
|
|
815631d5d2 | ||
|
|
98523cf528 | ||
|
|
a9ef98f4da | ||
|
|
c10e41b29e | ||
|
|
1da3af6b7a | ||
|
|
9e009307f4 | ||
|
|
934b9babd3 | ||
|
|
b15334d8ac | ||
|
|
d78105c3b7 | ||
|
|
2b3571ec85 | ||
|
|
afdfa0d6d6 | ||
|
|
6d5e5fd00e | ||
|
|
d2cf49b7c8 | ||
|
|
e99311b582 | ||
|
|
4da67d145d | ||
|
|
5aca4dc82f | ||
|
|
49119bcabd | ||
|
|
e8bb442588 | ||
|
|
93080c76c9 | ||
|
|
553d829b4f | ||
|
|
f36286e14b | ||
|
|
4f2daf06d8 | ||
|
|
afc8fb0b54 | ||
|
|
9382c6bb2c | ||
|
|
dd4cd2a314 | ||
|
|
40978a0017 | ||
|
|
9ed6a75fe5 | ||
|
|
ef317a07a5 | ||
|
|
6ec042bd30 | ||
|
|
646c8c7e77 | ||
|
|
ef972a593d | ||
|
|
e278bc1bb8 | ||
|
|
36b0381294 | ||
|
|
5adeeec3f7 | ||
|
|
a743de0dd1 | ||
|
|
7fa35d108d | ||
|
|
11f6ea0b84 | ||
|
|
bd7f6ad460 | ||
|
|
caeece00f3 | ||
|
|
43911cbb58 | ||
|
|
252b89652d | ||
|
|
4b089a91ae | ||
|
|
c66df265d9 | ||
|
|
90a2b858bb | ||
|
|
c93e59c814 | ||
|
|
1be10820a3 | ||
|
|
2ee26a3d68 | ||
|
|
fae7a37424 | ||
|
|
96b5e90ebf | ||
|
|
8a2855e32b | ||
|
|
03aa29413c | ||
|
|
83ff343c92 | ||
|
|
bf3ba4e6aa | ||
|
|
4951559891 | ||
|
|
4df7131630 | ||
|
|
e16767c15a | ||
|
|
1c9de78f5e | ||
|
|
60cff01fe2 | ||
|
|
81456f3d2e | ||
|
|
f467b1062b | ||
|
|
b9b3013b2d | ||
|
|
b749839963 | ||
|
|
0761de4b7e | ||
|
|
f9c09aa792 | ||
|
|
9a074addcf | ||
|
|
c201e850ce | ||
|
|
0961748a2a | ||
|
|
c940316494 | ||
|
|
a80742af7d | ||
|
|
1a0601ba56 | ||
|
|
5cf9f6476e | ||
|
|
0000a31942 | ||
|
|
fa45f6335b | ||
|
|
e40a8dc724 | ||
|
|
155b899e5d | ||
|
|
80fcb32abe | ||
|
|
db00bb906f | ||
|
|
f595f0f251 | ||
|
|
be311962cb | ||
|
|
91cc82f154 | ||
|
|
5a4a1cbf56 | ||
|
|
248156c45d | ||
|
|
0f5feb3c7e | ||
|
|
633f34ee51 | ||
|
|
ea0b8a74dd | ||
|
|
53b71431ea | ||
|
|
57bbce07da | ||
|
|
bef57e096b | ||
|
|
0db32aac36 | ||
|
|
2d7a1f452e | ||
|
|
fa0b95ba5a | ||
|
|
5b85844e5e | ||
|
|
334e01d02d | ||
|
|
e366b647cc | ||
|
|
69aa7aa047 | ||
|
|
565eb70988 | ||
|
|
8c7c88c84f | ||
|
|
06efab761d | ||
|
|
3ba0611852 | ||
|
|
488adfa605 | ||
|
|
d9e2796185 | ||
|
|
091dc2dc1d | ||
|
|
7fe717be2b | ||
|
|
3756b73c34 | ||
|
|
2a82fcc4ae | ||
|
|
6a9867f477 | ||
|
|
6b7c41705c | ||
|
|
93ffe36ea6 | ||
|
|
b19912f430 | ||
|
|
a16fe442fa | ||
|
|
e19cb6876e | ||
|
|
f09b02b693 | ||
|
|
70e0c499ed | ||
|
|
195d6ac55b | ||
|
|
9a97006dcb | ||
|
|
eef8e8499a | ||
|
|
1deb4337cb | ||
|
|
5b82083596 | ||
|
|
2db5bbc7c0 | ||
|
|
45008556ab | ||
|
|
561ddd3b2d | ||
|
|
89b6567beb | ||
|
|
bb0f836d3c | ||
|
|
29ecbb8956 | ||
|
|
4d4e536154 | ||
|
|
425d5c4e13 | ||
|
|
38333d5b95 | ||
|
|
4c287bfed8 | ||
|
|
da22a11afe | ||
|
|
8b35c7d6c5 | ||
|
|
9fb5303754 | ||
|
|
eccfb27efe | ||
|
|
9dc45f2165 | ||
|
|
b7c7e8b358 | ||
|
|
161d16e749 | ||
|
|
8fb0dd63f6 | ||
|
|
9c559b5c80 | ||
|
|
41d66b9e96 | ||
|
|
2d08c7d589 | ||
|
|
e2740347ba | ||
|
|
c5398c7a1d | ||
|
|
9f32cd93a4 | ||
|
|
9507dc10be | ||
|
|
21ec74df69 | ||
|
|
08271d7e36 | ||
|
|
8cd1bda1ed | ||
|
|
d6e462f84f | ||
|
|
a3ac454cb3 | ||
|
|
b2d0d0c742 | ||
|
|
6aa252f801 | ||
|
|
71cb78b72c | ||
|
|
c4c2afe72c | ||
|
|
66ab0cad31 | ||
|
|
2da6edd976 | ||
|
|
d4b9ee6ec5 | ||
|
|
26f6c081f4 | ||
|
|
d95f22662d | ||
|
|
4226df3e5c | ||
|
|
14f6d5656b | ||
|
|
4ee335efd5 | ||
|
|
44880a2b4b | ||
|
|
f0a090b00c | ||
|
|
8e73a2eced | ||
|
|
d1b368d0b5 | ||
|
|
174ee519d3 | ||
|
|
c6df499058 | ||
|
|
7a7468b9f2 | ||
|
|
d06be93bc0 | ||
|
|
5c0c900f6b | ||
|
|
773e7133f3 | ||
|
|
065a1179ef | ||
|
|
ccdd38ad1a | ||
|
|
5135ddcd99 | ||
|
|
2a1dfad01b | ||
|
|
285f9b5188 | ||
|
|
99e98f6a28 | ||
|
|
0e19218728 | ||
|
|
db06a05eda | ||
|
|
b0dc6e6aa9 | ||
|
|
75233d560f | ||
|
|
13a45ff83a | ||
|
|
6ebc2dc2c6 | ||
|
|
54d2183b45 | ||
|
|
37885e9879 | ||
|
|
796f247fec | ||
|
|
1ee7c5a985 | ||
|
|
bb4fe2abe5 | ||
|
|
f86accfa44 | ||
|
|
e93baadd04 | ||
|
|
3ce2db798c | ||
|
|
e1df8110a7 | ||
|
|
b8df4ad882 | ||
|
|
b048c84bee | ||
|
|
d69bbc09b5 | ||
|
|
da5f351c54 | ||
|
|
7a520e49d6 | ||
|
|
4eb265d2f0 | ||
|
|
2954c33821 | ||
|
|
1ea2c551ee | ||
|
|
e24b580ca6 | ||
|
|
a8b4293225 | ||
|
|
b40d8a959a | ||
|
|
59496d97b0 | ||
|
|
f75b262c75 | ||
|
|
de16808e25 | ||
|
|
534e1d8cfe | ||
|
|
e4c8fc8278 | ||
|
|
21df705094 | ||
|
|
0eadc2f7e3 | ||
|
|
8840d89bb0 | ||
|
|
b92475b272 | ||
|
|
7ed3e267db | ||
|
|
d68220bf41 | ||
|
|
4b021a5bdf | ||
|
|
8fbee21a95 | ||
|
|
04f35dcdaa | ||
|
|
25d8915647 | ||
|
|
2b4e189a54 | ||
|
|
881c66dc1b | ||
|
|
4a08f72d40 | ||
|
|
67d851b5b6 | ||
|
|
b9f924aa8d | ||
|
|
ede6699a56 | ||
|
|
9564202df6 | ||
|
|
5d7772d45e | ||
|
|
afb21eb2ba | ||
|
|
199d9b3c58 | ||
|
|
ecb92d024f | ||
|
|
210b855cb2 | ||
|
|
ef217e8ff7 | ||
|
|
3ec26e9d91 | ||
|
|
76ba3463cf | ||
|
|
cd67d0b113 | ||
|
|
317b24748c | ||
|
|
f35e4bce23 | ||
|
|
27ed787013 | ||
|
|
835f9932d9 | ||
|
|
f5d5c8acfb | ||
|
|
47d0830e9e | ||
|
|
546359752b | ||
|
|
960ed3f0c8 | ||
|
|
228b290570 | ||
|
|
38916cdeb1 | ||
|
|
a448a78415 | ||
|
|
fe61ca6e02 | ||
|
|
75fe7a9593 | ||
|
|
5cdf12a323 | ||
|
|
6237f534f2 | ||
|
|
f720d2a945 | ||
|
|
99e83b8bf9 | ||
|
|
94831710e4 | ||
|
|
4dc73661d8 | ||
|
|
9f046ae383 | ||
|
|
cca5991bd6 | ||
|
|
b4397a25a8 | ||
|
|
e9de1c87a7 | ||
|
|
d81c4b7040 | ||
|
|
8b54b86ae9 | ||
|
|
adc20ee46b | ||
|
|
316a5bb6aa | ||
|
|
cfda9a6eba | ||
|
|
d6a790cec7 | ||
|
|
4763724315 | ||
|
|
f5831500c8 | ||
|
|
3c22c99e51 | ||
|
|
9a84b80c83 | ||
|
|
d7f0860726 | ||
|
|
e053ff652d | ||
|
|
49b920c6e9 | ||
|
|
1eb2b029e1 | ||
|
|
f95f1f241d | ||
|
|
f54efc6b2b | ||
|
|
622ea90e81 | ||
|
|
79a6cc846f | ||
|
|
d14b49ce85 | ||
|
|
d1082874cb | ||
|
|
f253caf3d2 | ||
|
|
523d5b4bc1 | ||
|
|
bdc4f3fb67 | ||
|
|
582472b951 | ||
|
|
7ee4e14126 | ||
|
|
dd272858f8 | ||
|
|
5c4b7adf31 | ||
|
|
54b209a5ab | ||
|
|
d41edf57ff | ||
|
|
2f0d91574c | ||
|
|
5c49e4e624 | ||
|
|
866849dc8f | ||
|
|
7164442752 | ||
|
|
0ad02d573b | ||
|
|
c4476c89a9 | ||
|
|
82e2b08df1 | ||
|
|
7e0eda6fe3 | ||
|
|
e9636e8723 | ||
|
|
0933657ea3 | ||
|
|
017f54a559 | ||
|
|
ce8c397fca | ||
|
|
8e57cd810e | ||
|
|
bc101f6cb4 | ||
|
|
91d31132be | ||
|
|
944d402c8d | ||
|
|
79d52d96ab | ||
|
|
ae3abdb638 | ||
|
|
bd65726668 | ||
|
|
8d864e8aca | ||
|
|
661c5916db | ||
|
|
2ea1c4332e | ||
|
|
63eab63c48 | ||
|
|
31fee0e8f3 | ||
|
|
334a91fb81 | ||
|
|
64e6f932bc | ||
|
|
e9e93ece7e | ||
|
|
50494d87c0 | ||
|
|
51ccc27090 | ||
|
|
d6cefd3902 | ||
|
|
745a13a8f8 | ||
|
|
848c26d69a | ||
|
|
25c2be5c52 | ||
|
|
1abbc5f734 | ||
|
|
fd22d89ecb | ||
|
|
19579ec0b0 | ||
|
|
0e2adf5807 | ||
|
|
af70ae6392 | ||
|
|
cef5460726 | ||
|
|
818fda3058 | ||
|
|
2900a17f7a | ||
|
|
4ad1ee7df7 | ||
|
|
bd253e7f4a | ||
|
|
8baedb31ea | ||
|
|
eeb8e4dc5f | ||
|
|
00090857a8 | ||
|
|
a98e791824 | ||
|
|
a3551bbc88 | ||
|
|
0b81edefbb | ||
|
|
38a0c7c0f8 | ||
|
|
7960e05d55 | ||
|
|
7c0b2d9215 | ||
|
|
6907d648d3 | ||
|
|
988344ee1a | ||
|
|
f06308bcad | ||
|
|
679a7ebd23 | ||
|
|
5863500e51 | ||
|
|
0e4e3c91a8 | ||
|
|
8681cb4db4 | ||
|
|
122e5f9d26 | ||
|
|
0c0bc7d910 | ||
|
|
6b3eaa1e24 | ||
|
|
c1516d207a | ||
|
|
d45b64b53f | ||
|
|
f1267387a3 | ||
|
|
c01cc429a0 | ||
|
|
c2a1f4a20a | ||
|
|
6769f5cd20 | ||
|
|
c1a519dc86 | ||
|
|
9aad5d1553 | ||
|
|
6daf7c0227 | ||
|
|
d0ca401ab1 | ||
|
|
6666c63fa5 | ||
|
|
b5a3e7289e | ||
|
|
51949a281a | ||
|
|
1c1b134edf | ||
|
|
06c809f48f | ||
|
|
5ed3f63e91 | ||
|
|
0e4acc54fa | ||
|
|
4463f9479f | ||
|
|
bcd0f1a85a | ||
|
|
807dffdc92 | ||
|
|
5ccf3ed734 | ||
|
|
d2539e5819 | ||
|
|
fbfe589ea3 | ||
|
|
3f3c59cc00 | ||
|
|
02ee4b461e | ||
|
|
2e25c733ba | ||
|
|
d4142e3b03 | ||
|
|
2c65f7ab92 | ||
|
|
a181c0981a | ||
|
|
6b3d68320e | ||
|
|
817166005f | ||
|
|
f39991a559 | ||
|
|
acb9b5a674 | ||
|
|
31e8a7af86 | ||
|
|
475c3f99ac | ||
|
|
f00cf0ee3b | ||
|
|
4316830043 | ||
|
|
e57ee9a72e | ||
|
|
39a3504c02 | ||
|
|
18b5e7232d | ||
|
|
08f498f774 | ||
|
|
835beb55cc | ||
|
|
add4335677 | ||
|
|
8c80c30958 | ||
|
|
0383068815 | ||
|
|
6740c4ed23 | ||
|
|
fb0b57bffc | ||
|
|
8fd329c129 | ||
|
|
34d860b749 | ||
|
|
33e75e6e81 | ||
|
|
68a7aec74c | ||
|
|
8ecb0b7c9e | ||
|
|
7279fdf743 | ||
|
|
92db7d5f1e | ||
|
|
7caa78edef | ||
|
|
55f66994b3 | ||
|
|
9f9b260a4f | ||
|
|
d71a7187fa | ||
|
|
98335c8b2e | ||
|
|
edb00e4608 | ||
|
|
1e713c1292 | ||
|
|
117e94ef2e | ||
|
|
8ea1ba2e79 | ||
|
|
b10d6bb0c3 | ||
|
|
9ba69c188f | ||
|
|
d8ad75dce9 | ||
|
|
7fa4b6aec5 | ||
|
|
5dd85d742f | ||
|
|
050c742313 | ||
|
|
b1db92425e | ||
|
|
7d51561c71 | ||
|
|
9208483045 | ||
|
|
4522aec93f | ||
|
|
aa755cbd89 | ||
|
|
c8fa6e052e | ||
|
|
7174024333 | ||
|
|
94af268598 | ||
|
|
06c37e11be | ||
|
|
6ea0cf3e38 | ||
|
|
b6e19b9f8d | ||
|
|
d0eef0b15f | ||
|
|
24eb6f9446 | ||
|
|
241f88199d | ||
|
|
89e8f2dae7 | ||
|
|
206ff77b97 | ||
|
|
63b72f0f67 | ||
|
|
67a80c7475 | ||
|
|
5343be3b58 | ||
|
|
e8232caf2b | ||
|
|
49c836cbde | ||
|
|
79b65e0023 | ||
|
|
a5bb906eea | ||
|
|
b58895da59 | ||
|
|
2c0ed58c2a | ||
|
|
626d8d3206 | ||
|
|
cec22d06f8 | ||
|
|
a9c9f1d47f | ||
|
|
6883496845 | ||
|
|
72d9896fca | ||
|
|
218c67bbf6 | ||
|
|
cb0d720ae0 | ||
|
|
2d559f9bf1 | ||
|
|
cf1db1b604 | ||
|
|
6fbf4efa1c | ||
|
|
e50abf16cd | ||
|
|
a6c2851bd2 | ||
|
|
c646bfe866 | ||
|
|
158a9db90c | ||
|
|
c92dc63fa8 | ||
|
|
9518c7130a | ||
|
|
98db18e687 | ||
|
|
f7cb4855aa | ||
|
|
dac9c80c6f | ||
|
|
87c114370c | ||
|
|
b36ea99b28 | ||
|
|
a0d5baef17 | ||
|
|
ccb669ca75 | ||
|
|
39e1d9dd65 | ||
|
|
39ccef91a5 | ||
|
|
b569062294 | ||
|
|
478b711dee | ||
|
|
26145a7587 | ||
|
|
168b50bdfc | ||
|
|
112fee67e4 | ||
|
|
6dc5133d10 | ||
|
|
79e1867e7f | ||
|
|
cb03a62265 | ||
|
|
62b847fcef | ||
|
|
e1d565522b | ||
|
|
cba1772bf6 | ||
|
|
a14ee21fd6 | ||
|
|
f5d7a7b127 | ||
|
|
828ba91ba0 | ||
|
|
7660f88387 | ||
|
|
5018e8a4be | ||
|
|
5c1bcc3b1b | ||
|
|
315d1e43ec | ||
|
|
2a109ed496 | ||
|
|
9382a8be8a | ||
|
|
4c69d38069 | ||
|
|
bfca0aadf5 | ||
|
|
aea33dcd13 | ||
|
|
c4416f2034 | ||
|
|
96c8441307 | ||
|
|
a8fb21f599 | ||
|
|
2399cfd8cc | ||
|
|
7cc1097c69 | ||
|
|
95ff52de20 | ||
|
|
07293ff3eb | ||
|
|
658810cc85 | ||
|
|
18a2c6705d | ||
|
|
aa49f28d69 | ||
|
|
fb45dda0f5 | ||
|
|
14b29edf84 | ||
|
|
60da507f71 | ||
|
|
da566c4c81 | ||
|
|
7f8e2dd027 | ||
|
|
56a89b7e6d | ||
|
|
2b1606c113 | ||
|
|
c01f499648 | ||
|
|
3b30b34a34 | ||
|
|
67149d08fe | ||
|
|
85a4cc95fe | ||
|
|
b3c58b0442 | ||
|
|
43c15d193b | ||
|
|
7f400066b9 | ||
|
|
d9e0a4ada2 | ||
|
|
7612126b9e | ||
|
|
997118ceb8 | ||
|
|
d5b083dcfe | ||
|
|
97322f6e0f | ||
|
|
343277caa3 | ||
|
|
2d37a2ec95 | ||
|
|
e184c68be2 | ||
|
|
8da9583854 | ||
|
|
656920e1ac | ||
|
|
c3b967dddc | ||
|
|
86469d6ff7 | ||
|
|
1dce1a2fe7 | ||
|
|
e9f3d9ba4a | ||
|
|
87349837f3 | ||
|
|
53e248b674 | ||
|
|
dde7c8eef2 | ||
|
|
5c7218e7f0 | ||
|
|
a63782a57b | ||
|
|
d805a1d462 | ||
|
|
7522a8f899 | ||
|
|
cdd4c4069c | ||
|
|
667ca04eeb | ||
|
|
7d30f24525 | ||
|
|
1d4e1b4a3e | ||
|
|
0668fa8b46 | ||
|
|
a82ab9b0ca | ||
|
|
c4c12ccad7 | ||
|
|
a4f2da37d4 | ||
|
|
705b24910d | ||
|
|
03e3188b39 | ||
|
|
abdc6d69b8 | ||
|
|
690ab4c35d | ||
|
|
ab46e96c28 | ||
|
|
28102d34af | ||
|
|
075591d2ea | ||
|
|
69c5e63158 | ||
|
|
d6de26963b | ||
|
|
7a0bbb9bce | ||
|
|
274e967888 | ||
|
|
cd920fbdf8 | ||
|
|
a0de1d0afc | ||
|
|
a998f75ed9 | ||
|
|
ac10bc4fb2 | ||
|
|
02b870f95b | ||
|
|
db8fd60495 | ||
|
|
d1378a4cf4 | ||
|
|
93a3df9bfb | ||
|
|
e59b718eab | ||
|
|
7179c09c29 | ||
|
|
6ff6d246a4 | ||
|
|
2bdfb10743 | ||
|
|
9f018d13c4 | ||
|
|
b469c162b2 | ||
|
|
73e93a4c46 | ||
|
|
6c1ec5380e | ||
|
|
30349030dd | ||
|
|
262166d470 | ||
|
|
810ebc3f58 | ||
|
|
c8dc5cdbcc | ||
|
|
05a42541de | ||
|
|
109240166e | ||
|
|
20f84b8311 | ||
|
|
d0d4c3a19f | ||
|
|
a3a749f587 | ||
|
|
a529135daf | ||
|
|
2ad79bb683 | ||
|
|
be55af4c5f | ||
|
|
5b3fedfc0c | ||
|
|
dfe3e271d7 | ||
|
|
e25b8c771f | ||
|
|
9b2d5dbf3a | ||
|
|
5944cf8208 | ||
|
|
132a3e7096 | ||
|
|
d253f9e1ff | ||
|
|
8548c6a8f7 | ||
|
|
716e70b10a | ||
|
|
df4802c856 | ||
|
|
ccc6538225 | ||
|
|
dc798c4d64 | ||
|
|
717e861fe0 | ||
|
|
7f9d8badec | ||
|
|
61332c5b73 | ||
|
|
d91383b4e5 | ||
|
|
679b5cc01b | ||
|
|
84ccc444b8 | ||
|
|
f90365a191 | ||
|
|
19184c3a4a | ||
|
|
ef94bdc2fe | ||
|
|
ad4e699bb6 | ||
|
|
23fbf503c9 | ||
|
|
6b036c8e91 | ||
|
|
9146fb67b0 | ||
|
|
0086bbf98b | ||
|
|
c85d82c2b7 | ||
|
|
ac5cd3b842 | ||
|
|
b221f4d76f | ||
|
|
afc4669cad | ||
|
|
d63d080023 | ||
|
|
27e9c75e78 | ||
|
|
fe0887b808 | ||
|
|
f5783dbdb6 | ||
|
|
c7f1b490ed | ||
|
|
5aa1de8b18 | ||
|
|
fa2cb814c8 | ||
|
|
55fa772b52 | ||
|
|
8004353f37 | ||
|
|
5e7e31066c | ||
|
|
db24212cc6 | ||
|
|
563e7f47c4 | ||
|
|
0c1a02ba7f | ||
|
|
33c9fd87e0 | ||
|
|
b59cd10acc | ||
|
|
fda13da0fd | ||
|
|
577a4cc42d | ||
|
|
6a91ce85e2 | ||
|
|
d388d5a39e | ||
|
|
e9661f8ec6 | ||
|
|
2155c02a75 | ||
|
|
92fcdb8bb4 | ||
|
|
b8cffb8f6a | ||
|
|
cd35d5ba9c | ||
|
|
82cf75ac2d | ||
|
|
d52e335174 | ||
|
|
864f64bba3 | ||
|
|
6219add3c9 | ||
|
|
7b6c6a4ad0 | ||
|
|
91f1c9a5df | ||
|
|
9ace5c276d | ||
|
|
524d59eece | ||
|
|
7a9b9b6eff | ||
|
|
4fe117236f | ||
|
|
da10e2bd0d | ||
|
|
4fa1cbf32a | ||
|
|
baa7492e99 | ||
|
|
5c69305e1f | ||
|
|
f27b313044 | ||
|
|
54cacc7e2e | ||
|
|
88fda6d2b9 | ||
|
|
2acf7a1e24 | ||
|
|
168d54a040 | ||
|
|
c18d9d41aa | ||
|
|
385992cdb1 | ||
|
|
d759e54f6d | ||
|
|
4ac51b04ef | ||
|
|
b18e047f84 | ||
|
|
aa9081ccf3 | ||
|
|
bf68d50b3e | ||
|
|
1d639b5b48 | ||
|
|
8467b8ef9d | ||
|
|
43dde65830 | ||
|
|
11fbb281a6 | ||
|
|
e3cbd73807 | ||
|
|
28006c3a33 | ||
|
|
fa17164d81 | ||
|
|
058c5ec1b4 | ||
|
|
b19ec97a5d | ||
|
|
8f7bd69f4e | ||
|
|
7a685c8f0c | ||
|
|
4382cc5572 | ||
|
|
8d4c38a9cb | ||
|
|
40c2bdc64a | ||
|
|
f5acd1e0e5 | ||
|
|
e935b3c366 | ||
|
|
34faab9220 | ||
|
|
ae7e03fda8 | ||
|
|
eae1e816da | ||
|
|
99d141bf41 | ||
|
|
142c534aa2 | ||
|
|
b81559002f | ||
|
|
c98087ccd6 | ||
|
|
699a40f157 | ||
|
|
4a4af8a442 | ||
|
|
54307516ad | ||
|
|
c676be8f0d | ||
|
|
0865c8b1d7 | ||
|
|
98964a3f3e | ||
|
|
2e7011921d | ||
|
|
a13b874b3e | ||
|
|
e5e7f774e5 | ||
|
|
26e8dd200a | ||
|
|
9690dd727e | ||
|
|
654b4f643c | ||
|
|
869315ce5a | ||
|
|
b399d238c3 | ||
|
|
fa76c1fb35 | ||
|
|
3f8b24319c | ||
|
|
33c40cfa66 | ||
|
|
b6f94a4069 | ||
|
|
c15f3fba9d | ||
|
|
2d2a89264d | ||
|
|
9e095a1825 | ||
|
|
8d0f1faae8 | ||
|
|
1c155e4804 | ||
|
|
e704b8d70c | ||
|
|
1cd52cd2c3 | ||
|
|
ea561b9a85 | ||
|
|
ef187881b2 | ||
|
|
ca05eb96c0 | ||
|
|
f7cd2307a5 | ||
|
|
18b0c66920 | ||
|
|
df5175b2a5 | ||
|
|
3f35a92afd | ||
|
|
abaf107700 | ||
|
|
acbd5c4b05 | ||
|
|
a8dd8d78ef | ||
|
|
9292206208 | ||
|
|
c211870d3f | ||
|
|
01db30a3bc | ||
|
|
b1af5cc68f | ||
|
|
75bf1db1ab | ||
|
|
2b4c5fef77 | ||
|
|
0e225d7804 | ||
|
|
4f8e13ca3c | ||
|
|
d087b1caa7 | ||
|
|
fe5ff2a422 | ||
|
|
f1cb711326 | ||
|
|
c94fe7d4db | ||
|
|
7d47af9e18 | ||
|
|
5dd546ae4f | ||
|
|
dd151e80d2 | ||
|
|
872b66984d | ||
|
|
ad09a31171 | ||
|
|
f9fa84ad64 | ||
|
|
5cffd47463 | ||
|
|
79c56c4571 | ||
|
|
8f7a64122c | ||
|
|
b3f5ac1026 | ||
|
|
4e795ee832 | ||
|
|
f21e7dea88 | ||
|
|
e6b32c4943 | ||
|
|
b85247dfaf | ||
|
|
66cf85a688 | ||
|
|
12f9d024aa | ||
|
|
c62e99fd7d | ||
|
|
754b915aed | ||
|
|
f759ce4d56 | ||
|
|
af2c9fac0e | ||
|
|
9a1a878513 | ||
|
|
fb77fb7603 | ||
|
|
5d4005a087 | ||
|
|
f45ed7fa1f | ||
|
|
7b6a74fd0a | ||
|
|
29ecf18e2e | ||
|
|
9d2be448ee | ||
|
|
2319f1a345 | ||
|
|
5ed749dbab | ||
|
|
768ba7c47f | ||
|
|
f5a7842ab1 | ||
|
|
4e283ff5e8 | ||
|
|
62c92ea4b3 | ||
|
|
621069c933 | ||
|
|
d8e519c838 | ||
|
|
e7d2b420d4 | ||
|
|
ef17c60c58 | ||
|
|
14c4dc58f2 | ||
|
|
420bfca7d1 | ||
|
|
04b5498542 | ||
|
|
7abf031246 | ||
|
|
d3fc4ae105 | ||
|
|
7bda8ea334 | ||
|
|
2f2d99e7ce | ||
|
|
e049752508 | ||
|
|
c99fa30bbd | ||
|
|
56719d4d37 | ||
|
|
9a3cb66037 | ||
|
|
c6d047a7ea | ||
|
|
7a01ffc6c0 | ||
|
|
865af17158 | ||
|
|
5129a05bb8 | ||
|
|
5c2c600d46 | ||
|
|
333d935a26 | ||
|
|
6bb00569d3 | ||
|
|
41c414497d | ||
|
|
c7a752120d | ||
|
|
e99d83fb4f | ||
|
|
3db1ef31b8 | ||
|
|
bff41c81f9 | ||
|
|
a036261319 | ||
|
|
2254f94de7 | ||
|
|
ae37e501f6 | ||
|
|
c10dd23a38 | ||
|
|
9c3e8737a0 | ||
|
|
415d5697d8 | ||
|
|
56e3507e26 | ||
|
|
c8f7f5212e | ||
|
|
e3352e6fdf | ||
|
|
989dcdec73 | ||
|
|
629b8c63aa | ||
|
|
0f7a017a8d | ||
|
|
d26ee55b55 | ||
|
|
46d87a046e | ||
|
|
89c8dc7434 | ||
|
|
501a160f14 | ||
|
|
46c6d73cd9 | ||
|
|
f046ffb3ab | ||
|
|
e2a0f33012 | ||
|
|
e5dc6d4487 | ||
|
|
3310559df6 | ||
|
|
21d959740f | ||
|
|
6536852791 | ||
|
|
a57907dc9d | ||
|
|
6139772966 | ||
|
|
2cab7c7b5a | ||
|
|
c564373382 | ||
|
|
b30f01e3eb | ||
|
|
d62829f3b1 | ||
|
|
c929b196b1 | ||
|
|
a7fd8dc0ab | ||
|
|
f4517b7736 | ||
|
|
bd8af7fc16 | ||
|
|
903fed53b3 | ||
|
|
0db6f75823 | ||
|
|
dab63ad8be | ||
|
|
5fa0bcd9be | ||
|
|
226c33faaf | ||
|
|
a8eaf758c4 | ||
|
|
42b26f4988 | ||
|
|
e9a1b245f1 | ||
|
|
36e8d5f096 | ||
|
|
0987180bd3 | ||
|
|
8955aafdb9 | ||
|
|
c040188512 | ||
|
|
fa09badd70 | ||
|
|
c5d8260b38 | ||
|
|
283e623f19 | ||
|
|
131c32978c | ||
|
|
d1a9462029 | ||
|
|
baa61228fa | ||
|
|
3a887732ac | ||
|
|
d734d02a14 | ||
|
|
f93525823a | ||
|
|
07ffb36104 | ||
|
|
5c3cc9265e | ||
|
|
86b9bd095f | ||
|
|
a622fccc71 | ||
|
|
6af1575053 | ||
|
|
7b7baf52d3 | ||
|
|
750d5c1e76 | ||
|
|
e1dea39b1f | ||
|
|
74697eb48f | ||
|
|
e224a4ffb7 | ||
|
|
2a873a22b3 | ||
|
|
53a574f34f | ||
|
|
14915bf450 | ||
|
|
15d950bee8 | ||
|
|
37bc4b72cd | ||
|
|
1621a3cfb9 | ||
|
|
50201be458 | ||
|
|
59d06cd0a8 | ||
|
|
329e2dda28 | ||
|
|
29b7bd7f38 | ||
|
|
e641510e7c | ||
|
|
8255f4a1eb | ||
|
|
e70cbc108d | ||
|
|
addf59853e | ||
|
|
93fb2eaa07 | ||
|
|
9360387bd0 | ||
|
|
0a2e7ca09a | ||
|
|
f52f5fe304 | ||
|
|
2527755afc | ||
|
|
7e8566cb14 | ||
|
|
d5c6123575 | ||
|
|
eebfd0b16a | ||
|
|
79c3c9bdad | ||
|
|
bfc487cfa5 | ||
|
|
24e9b4f548 | ||
|
|
587da25d0c | ||
|
|
14dc721cfd | ||
|
|
f99398ea12 | ||
|
|
5c3c287bf4 | ||
|
|
a934befc3d | ||
|
|
e2fc49c968 | ||
|
|
0ce767d78f | ||
|
|
29b3f3b188 | ||
|
|
e58c6fa899 | ||
|
|
2c2e0a699a | ||
|
|
88068659cf | ||
|
|
c0a88239a0 | ||
|
|
475d19f1d8 | ||
|
|
1e1c4f5526 | ||
|
|
0c8fec38dc | ||
|
|
143f7f9088 | ||
|
|
3135905dcc | ||
|
|
79f0650417 | ||
|
|
bc0f95e032 | ||
|
|
8991d915b3 | ||
|
|
49d13fba43 | ||
|
|
c5d74bd318 | ||
|
|
1710d25188 | ||
|
|
d7400624fa | ||
|
|
37b6b5d4e9 | ||
|
|
374ff0ca34 | ||
|
|
c505292247 | ||
|
|
23efed8caa | ||
|
|
5dfeeaff61 | ||
|
|
578283a999 | ||
|
|
6b34b26852 | ||
|
|
b29e6b7ab8 | ||
|
|
4249e486ba | ||
|
|
a0525260ed | ||
|
|
79637d1bd9 | ||
|
|
5daab77c0a | ||
|
|
cf62aa4586 | ||
|
|
30161a3291 | ||
|
|
a950dfcf33 | ||
|
|
c288a5669f | ||
|
|
be01162125 | ||
|
|
4b58259239 | ||
|
|
d8f79b85ee | ||
|
|
4218d95a49 | ||
|
|
e95e5bd677 | ||
|
|
b3a5565dc0 | ||
|
|
3bf9d651cd | ||
|
|
0390f3d20e | ||
|
|
1775ababa1 | ||
|
|
dc5c8d766f | ||
|
|
fdfdb12cd5 | ||
|
|
22ffb02971 | ||
|
|
8dc2cb0398 | ||
|
|
2e3233e17b | ||
|
|
e84a75016e | ||
|
|
e110b10cb9 | ||
|
|
eff05cb619 | ||
|
|
540562610d | ||
|
|
547c993c53 | ||
|
|
5f121a09b0 | ||
|
|
fe241653b5 | ||
|
|
537f8a3ff6 | ||
|
|
751da613a5 | ||
|
|
c6a7ab20c1 | ||
|
|
d07f2e491c | ||
|
|
0873f7a166 | ||
|
|
d57001d705 | ||
|
|
def4cd43c0 | ||
|
|
7c4fb50cff | ||
|
|
f36f1b5542 | ||
|
|
af0a234e9b | ||
|
|
bbd445b10f | ||
|
|
87ea31c507 | ||
|
|
0cba4f2dbb | ||
|
|
ad73909774 | ||
|
|
99004e0c47 | ||
|
|
873123cb9c | ||
|
|
644414447f | ||
|
|
234acc6577 | ||
|
|
a5bd6dd1cf | ||
|
|
7a8c5d704e | ||
|
|
e92cb8cc8e | ||
|
|
694a029554 | ||
|
|
6f4daca734 | ||
|
|
fbda04082a | ||
|
|
de3a2a6759 | ||
|
|
0feec2cfa2 | ||
|
|
a289ed3672 | ||
|
|
d18504377f | ||
|
|
f4b1f08eec | ||
|
|
ebe8bbb13f | ||
|
|
a0b8291e1d | ||
|
|
4b25a6d1e9 | ||
|
|
616df8d5e5 | ||
|
|
48f619fdc7 | ||
|
|
e68be9e8d3 | ||
|
|
8e3b49220a | ||
|
|
5e11208758 | ||
|
|
1c54744fdf | ||
|
|
58dcfe6061 | ||
|
|
5fee2ac276 | ||
|
|
602604aa81 | ||
|
|
5e5133b580 | ||
|
|
18f17923f9 | ||
|
|
d2da0e24c4 | ||
|
|
a60f550645 | ||
|
|
eafd571518 | ||
|
|
ee1f89e771 | ||
|
|
9b8c2d3e37 | ||
|
|
adc4d101f0 | ||
|
|
3c252ca3f6 | ||
|
|
b539db7664 | ||
|
|
515e68de67 | ||
|
|
25b64c3c09 | ||
|
|
786e4af3eb | ||
|
|
8d21e5a23e | ||
|
|
84bda2fa12 | ||
|
|
d51cbf809a | ||
|
|
ecbb5d1ed9 | ||
|
|
d60ed8a99b | ||
|
|
232d034126 | ||
|
|
67b60354bb | ||
|
|
acd14d0390 | ||
|
|
f3067be20d | ||
|
|
a4b70c6635 | ||
|
|
9fa165de2e | ||
|
|
56441c39cb | ||
|
|
83909eda50 | ||
|
|
8ea3397e16 | ||
|
|
7d971cd054 | ||
|
|
0881e1182b | ||
|
|
1f42a6badc | ||
|
|
bd33c77b47 | ||
|
|
08d17adb1a | ||
|
|
f04b094ac4 | ||
|
|
b8e563f913 | ||
|
|
0dbafe7972 | ||
|
|
2c917e0ddf | ||
|
|
5144b26a85 | ||
|
|
1e8ae0a47b | ||
|
|
53fab62830 | ||
|
|
64eb0bf654 | ||
|
|
75968bba76 | ||
|
|
c922351170 | ||
|
|
0379f82276 | ||
|
|
b80d21288d | ||
|
|
0a339688cd | ||
|
|
d0409a243e | ||
|
|
35e7cd2344 | ||
|
|
7ad62a3079 | ||
|
|
9a40d06eb9 | ||
|
|
8546affd94 | ||
|
|
b770d8431f | ||
|
|
a6cf844c74 | ||
|
|
70cb5b3da9 | ||
|
|
dce0a6d690 | ||
|
|
2b2e04bf84 | ||
|
|
ea62e75492 | ||
|
|
3af4b9e525 | ||
|
|
c0c8bd3056 | ||
|
|
94c2373dc9 | ||
|
|
2245e1313c | ||
|
|
381afbfc29 | ||
|
|
2c268d84fa | ||
|
|
afee32f2d5 | ||
|
|
3a36df08eb | ||
|
|
b4a330e713 | ||
|
|
03a8eecf91 | ||
|
|
7f542d6736 | ||
|
|
a342c01fd9 | ||
|
|
ac39aa5856 | ||
|
|
80c2b7a272 | ||
|
|
878ec0fcbb | ||
|
|
8e9f6143e4 | ||
|
|
a722c86907 | ||
|
|
6ad105d04a | ||
|
|
8e390eb272 | ||
|
|
5df646b6e9 | ||
|
|
5590fffc80 | ||
|
|
fafa894df8 | ||
|
|
fb85254c03 | ||
|
|
adcb2e7a91 | ||
|
|
062f6682c2 | ||
|
|
cd802139b0 | ||
|
|
fe18b289a3 | ||
|
|
ec55bd90cb | ||
|
|
125c50beb8 | ||
|
|
3e09c017c3 | ||
|
|
94ed38e0de | ||
|
|
c425431f4f | ||
|
|
f22dad9a20 | ||
|
|
a220b41443 | ||
|
|
46a3060ba9 | ||
|
|
61d7570b35 | ||
|
|
9410af7c15 | ||
|
|
d3a8aaff7a | ||
|
|
ca30893ed2 | ||
|
|
4749ae9592 | ||
|
|
c1d70b5990 | ||
|
|
389eb7d9fd | ||
|
|
338d8274ab | ||
|
|
6832899c2a | ||
|
|
cec531d04a | ||
|
|
11b0afdd4a | ||
|
|
14f7a814aa | ||
|
|
58b396c849 | ||
|
|
d1ae9e05c8 | ||
|
|
d10b79f05e | ||
|
|
e2e8fba2a1 | ||
|
|
d638615c2e | ||
|
|
a665e8e0d6 | ||
|
|
1379882a6a | ||
|
|
20ffcb6c8c | ||
|
|
81dbf7bf2c | ||
|
|
afd3d948fc | ||
|
|
cf2b937cff | ||
|
|
0597fe9136 | ||
|
|
45f51a1b27 | ||
|
|
d3a9c46234 | ||
|
|
53e10b7527 | ||
|
|
b5de68ae1e | ||
|
|
2d7bfae8a0 | ||
|
|
b6a48e49d7 | ||
|
|
be2d9aa234 | ||
|
|
93f2a6ecc9 | ||
|
|
a8e5bcc1ee | ||
|
|
8a9cb9f201 | ||
|
|
4aa53c223b | ||
|
|
a32849351f | ||
|
|
f13fba18fd | ||
|
|
dea2954ec3 | ||
|
|
d6c951f638 | ||
|
|
0bb9990a6e | ||
|
|
37335728cf | ||
|
|
fac24548fa | ||
|
|
f9044dcc1c | ||
|
|
3619329137 | ||
|
|
0fe495a1a2 | ||
|
|
f686361534 | ||
|
|
d9cc47aadf | ||
|
|
4bd05d4fb2 | ||
|
|
ddda96e150 | ||
|
|
f52cc62e08 | ||
|
|
01c3a8d1f7 | ||
|
|
25dc117c52 | ||
|
|
3e6f6121c4 | ||
|
|
bfcd79ab31 | ||
|
|
0daaea522e | ||
|
|
412d15ec3a | ||
|
|
699587c8d4 | ||
|
|
d3069db920 | ||
|
|
0d01940b42 | ||
|
|
4bcf820019 | ||
|
|
3dcb785ebb | ||
|
|
0e4b425645 | ||
|
|
28d7176a5c | ||
|
|
73c8cce9c2 | ||
|
|
cd863f209a | ||
|
|
0d0157fef2 | ||
|
|
e34d015c47 | ||
|
|
150945dbb1 | ||
|
|
8b2c7c120d | ||
|
|
4478644316 | ||
|
|
2e90eb7ca2 | ||
|
|
05abf6b132 | ||
|
|
d8db3048c1 | ||
|
|
af54945fde | ||
|
|
ec619899f6 | ||
|
|
3f8b8b8909 | ||
|
|
8a6ae8dcda | ||
|
|
67a1bcede0 | ||
|
|
eda01f2a15 | ||
|
|
3b33a57218 | ||
|
|
c2f463a1a7 | ||
|
|
4bbd7d09c1 | ||
|
|
41cdca1e3b | ||
|
|
32bcede266 | ||
|
|
10c0d8790c | ||
|
|
62da31b484 | ||
|
|
053a347e12 | ||
|
|
67b435889e | ||
|
|
2b2d178850 | ||
|
|
7d28912120 | ||
|
|
be35cf9c5f | ||
|
|
9f62b4fa76 | ||
|
|
aef5753a41 | ||
|
|
c537509c48 | ||
|
|
936e4613d8 | ||
|
|
7bdfda5b19 | ||
|
|
fa8cfe268d | ||
|
|
fc5d14db85 | ||
|
|
522f4f955d | ||
|
|
45a47dd76d | ||
|
|
fa98b9f7af | ||
|
|
a26978764b | ||
|
|
5c93f133dd | ||
|
|
63b1babed9 | ||
|
|
df4cecf59e | ||
|
|
ee8ef5c24c | ||
|
|
7918f78761 | ||
|
|
d39797a52b | ||
|
|
fd2b54d44b | ||
|
|
bea0c96d64 | ||
|
|
91b7b99f86 | ||
|
|
343497b556 | ||
|
|
627533f66c | ||
|
|
0eadc49ab6 | ||
|
|
dbec4604f9 | ||
|
|
bcbae31783 | ||
|
|
00a02ed7d2 | ||
|
|
363c4e4e88 | ||
|
|
2a8bda41e9 | ||
|
|
8c30280c1e | ||
|
|
db14e0f8e8 | ||
|
|
697017a8e8 | ||
|
|
6bdfb36c52 | ||
|
|
b80431f22e | ||
|
|
8755f3e1ca | ||
|
|
f7b129bf24 | ||
|
|
4b8c8fc2bb | ||
|
|
181291c42e | ||
|
|
de42098a8e | ||
|
|
8e5421900e | ||
|
|
e220d147bb | ||
|
|
df63b37e3c | ||
|
|
715328e4c9 | ||
|
|
0d296dac74 | ||
|
|
0d9ae577df | ||
|
|
02e927ab1b | ||
|
|
312c7c6294 | ||
|
|
c8725ae10f | ||
|
|
c7fefd481c | ||
|
|
2b038a3b04 | ||
|
|
bf5785d0d3 | ||
|
|
8d67330505 | ||
|
|
90b8d80ce8 | ||
|
|
e45b073290 | ||
|
|
d0a74989a4 | ||
|
|
ea4ef2f09c | ||
|
|
967877537d | ||
|
|
35a7a41091 | ||
|
|
15abb8cbfa | ||
|
|
4e37cf7757 | ||
|
|
6fdfcb041f | ||
|
|
94ab971af1 | ||
|
|
fe79868712 | ||
|
|
fc82c9817c | ||
|
|
e90e577f53 | ||
|
|
71d8454ad4 | ||
|
|
4790494d62 | ||
|
|
754df8edad | ||
|
|
c1519a2d7a | ||
|
|
f80c10ef04 | ||
|
|
64a28bc5a5 | ||
|
|
3172be7554 | ||
|
|
11c1e705f0 | ||
|
|
f4573b3dc5 | ||
|
|
5ba662b11a | ||
|
|
a7e2929cdb | ||
|
|
c002f39111 | ||
|
|
3fdc6b1dbc | ||
|
|
47fbbabb1b | ||
|
|
c76aee2428 | ||
|
|
a2873620a3 | ||
|
|
0e58782a4c | ||
|
|
b59597bc7b | ||
|
|
1551ad04c8 | ||
|
|
4bff19f9ba | ||
|
|
4d9185088a | ||
|
|
8d7c725a06 | ||
|
|
0dd8b6840c | ||
|
|
6c23cbca36 | ||
|
|
75e8a83aad | ||
|
|
ce84c28297 | ||
|
|
f05e93e14e | ||
|
|
c3a1cc41de | ||
|
|
5021443bb1 | ||
|
|
aa15b344b1 | ||
|
|
ee65d129f6 | ||
|
|
0147b88ba8 | ||
|
|
183babf1c2 | ||
|
|
f74937ab8e | ||
|
|
276252b2a1 | ||
|
|
97da625d64 | ||
|
|
9db47584ec | ||
|
|
44b8455ea6 | ||
|
|
32b63823fc | ||
|
|
ceb52616b0 | ||
|
|
008a3dbf36 | ||
|
|
39b476b917 | ||
|
|
e13968a148 | ||
|
|
d5c929f2a4 | ||
|
|
ee79336ce4 | ||
|
|
4968bce3a5 | ||
|
|
41faf64289 | ||
|
|
a28cf54bbd | ||
|
|
c46f4ebf07 | ||
|
|
7a858cf422 | ||
|
|
d6e31a84e5 | ||
|
|
f2756ac0e5 | ||
|
|
6c78081607 | ||
|
|
680d572385 | ||
|
|
457f051588 | ||
|
|
c752efceec | ||
|
|
59bfa7124e | ||
|
|
0022cb6b22 | ||
|
|
39167a2e8e | ||
|
|
b214aa8415 | ||
|
|
9bba734885 | ||
|
|
8eb1b69902 | ||
|
|
837485e96e | ||
|
|
3931d453da | ||
|
|
eed1e94f07 | ||
|
|
c427338121 | ||
|
|
61ed69c676 | ||
|
|
d9fa17b0c7 | ||
|
|
d0d59ba582 | ||
|
|
c6f0abfea3 | ||
|
|
907d76ed24 | ||
|
|
833e7b670d | ||
|
|
d023d289b0 | ||
|
|
518f5b774d | ||
|
|
05e879112a | ||
|
|
795075a4b6 | ||
|
|
70e73b68ae | ||
|
|
9d7bb36da8 | ||
|
|
a607262412 | ||
|
|
f001e551af | ||
|
|
a4d1a618cb | ||
|
|
84870fb64f | ||
|
|
18b8e6d81f | ||
|
|
3d56c0fc63 | ||
|
|
ba59d1cc80 | ||
|
|
a37fea5061 | ||
|
|
8d893d74ca | ||
|
|
65c235c01c | ||
|
|
654943ec36 | ||
|
|
e657e609bd | ||
|
|
8238757ca8 | ||
|
|
c5b80bd3c9 | ||
|
|
f5e2886ad6 | ||
|
|
05285cb12a | ||
|
|
e1b9076cd1 | ||
|
|
2829e50e7e | ||
|
|
5938786f84 | ||
|
|
3195081661 | ||
|
|
1b98981c9f | ||
|
|
cdd6a0996f | ||
|
|
9d1a378447 | ||
|
|
71203b08e7 | ||
|
|
a83f4f348f | ||
|
|
b6eb7a9d71 | ||
|
|
864bbcf125 | ||
|
|
f1a803aacf | ||
|
|
3ec2177641 | ||
|
|
c8d45cc872 | ||
|
|
f53d05ba6c | ||
|
|
2a6d4e38b9 | ||
|
|
be93eb1ded | ||
|
|
b60f046a8c | ||
|
|
e95b816f54 | ||
|
|
819a1afd22 | ||
|
|
29b47b8b96 | ||
|
|
ac3e325269 | ||
|
|
cd8118dad5 | ||
|
|
246dc403af | ||
|
|
2ad812d603 | ||
|
|
8ff70f65cf | ||
|
|
93d707961c | ||
|
|
ed47b5291b | ||
|
|
342db96a1e | ||
|
|
d901d9fca7 | ||
|
|
bf8454062e | ||
|
|
d2a48a22cf | ||
|
|
bca9879cc9 | ||
|
|
795b488629 | ||
|
|
8beb210e32 | ||
|
|
948b8187bc | ||
|
|
2f2835cc91 | ||
|
|
bb396b71d5 | ||
|
|
804b659227 | ||
|
|
2fc7c7e180 | ||
|
|
09b65585c4 | ||
|
|
b5592ad393 | ||
|
|
a42f767698 | ||
|
|
74238e1f23 | ||
|
|
32d95c175f | ||
|
|
7e4f7788e6 | ||
|
|
84e737083f | ||
|
|
0d35f74b1c | ||
|
|
a87f2ac0dc | ||
|
|
441546dd18 | ||
|
|
5cefa961b1 | ||
|
|
2dc844ba3f | ||
|
|
f542cc0441 | ||
|
|
fb7ff4711a | ||
|
|
9d1bb95169 | ||
|
|
ae1c39f8b4 | ||
|
|
202feebf0c | ||
|
|
2f369d6ea1 | ||
|
|
aa265afd86 | ||
|
|
6a1f2f7c20 | ||
|
|
d45878e1a2 | ||
|
|
fe3cc5f6f5 | ||
|
|
95fdcd2d92 | ||
|
|
ccb8afc679 | ||
|
|
67058ad32a | ||
|
|
ccddd98cd6 | ||
|
|
ff992e6812 | ||
|
|
7543e4b08f | ||
|
|
7026406168 | ||
|
|
7193d79256 | ||
|
|
0a20044d1e | ||
|
|
6e6d866445 | ||
|
|
510dfde848 | ||
|
|
f41aecf739 | ||
|
|
1d9d670c3a | ||
|
|
70433b7f85 | ||
|
|
2716196bf7 | ||
|
|
df9458b4ed | ||
|
|
c442dfb1fe | ||
|
|
bf82612485 | ||
|
|
54e828432d | ||
|
|
8528730e9c | ||
|
|
c1c5ec4c9c | ||
|
|
98df65ed49 | ||
|
|
8d643808c2 | ||
|
|
a325a7fd2e | ||
|
|
43ae4b26d8 | ||
|
|
849130f8b3 | ||
|
|
9bfc038111 | ||
|
|
45ca3d9b56 | ||
|
|
6b2acb66e7 | ||
|
|
eae197cef9 | ||
|
|
1fa4944ad1 | ||
|
|
41a0f2a4b7 | ||
|
|
5096a2eb73 | ||
|
|
02c5b2a176 | ||
|
|
24dccbf4b7 | ||
|
|
015171fc81 | ||
|
|
59e4a091ba | ||
|
|
026a6a8d09 | ||
|
|
e5239c7a24 | ||
|
|
384847168b | ||
|
|
670d21b13f | ||
|
|
7720f41699 | ||
|
|
07e4e946de | ||
|
|
a1a68d50b2 | ||
|
|
762ddeacc5 | ||
|
|
542b8c7e58 | ||
|
|
1c32803b60 | ||
|
|
dd41ada256 | ||
|
|
d7c74b25b1 | ||
|
|
32590c00f8 | ||
|
|
5d75c6f53d | ||
|
|
a213ca1872 | ||
|
|
0ea216fef2 | ||
|
|
44ee51994a | ||
|
|
e27d50f481 | ||
|
|
c01d1ba0c6 | ||
|
|
f71ae406a2 | ||
|
|
57b912dee1 | ||
|
|
7f58755bb8 | ||
|
|
0545a84229 | ||
|
|
f701b0db8c | ||
|
|
c00ea6be31 | ||
|
|
e3bc062346 | ||
|
|
6707e361d9 | ||
|
|
ce9ea6b1b2 | ||
|
|
8ce4158ce7 | ||
|
|
d44bea5228 | ||
|
|
6652cc7465 | ||
|
|
9b92dfdf93 | ||
|
|
02261a4c0c | ||
|
|
db8da95d32 | ||
|
|
700ecaf547 | ||
|
|
2573b559c5 | ||
|
|
e3fc42dda9 | ||
|
|
4294321613 | ||
|
|
e821423e68 | ||
|
|
83a513f629 | ||
|
|
5aea636e35 | ||
|
|
b0e7595d73 | ||
|
|
cb3b251ee5 | ||
|
|
2269f2c10e | ||
|
|
3280be88e2 | ||
|
|
cff4302c4a | ||
|
|
5366a7d79b | ||
|
|
4594540d40 | ||
|
|
3fcf40d94a | ||
|
|
28f47e8ebd | ||
|
|
17ca798fef | ||
|
|
0cbbe2a05b | ||
|
|
ade79ed6c6 | ||
|
|
c1b17eb6c5 | ||
|
|
cd2c49b9d9 | ||
|
|
d7680f6bdf | ||
|
|
1d173afccb | ||
|
|
466037cd22 | ||
|
|
cf22ea1074 | ||
|
|
c4b3c918c3 | ||
|
|
0b1dc8f98d | ||
|
|
34d1a8c444 | ||
|
|
167db4a815 | ||
|
|
7833e7c669 | ||
|
|
8288b4c988 | ||
|
|
0f3ef112a4 | ||
|
|
de137377bc | ||
|
|
61953777e6 | ||
|
|
398307b6b5 | ||
|
|
7a3c1ec22c | ||
|
|
e2452d33a7 | ||
|
|
21db7fb5bd | ||
|
|
bacbf1ceca | ||
|
|
09c0ab342b | ||
|
|
156e181d50 | ||
|
|
a45445340a | ||
|
|
0c4d747dde | ||
|
|
eb4e730bdf | ||
|
|
cd093c81eb | ||
|
|
8c43a6e4ae | ||
|
|
1adc5db487 | ||
|
|
edff45ebae | ||
|
|
15a477e8ce | ||
|
|
894f12591d | ||
|
|
15404dbec1 | ||
|
|
cd561d3302 | ||
|
|
a6926d1e46 | ||
|
|
c53374be1e | ||
|
|
dec7f44e48 | ||
|
|
2f01256a66 | ||
|
|
6ea7520b7b | ||
|
|
64e0dbbcf3 | ||
|
|
c8306a1f7f | ||
|
|
316e2fe042 | ||
|
|
1e5e4e393d | ||
|
|
9aeb6ca6ee | ||
|
|
3140ea911e | ||
|
|
30d600cdc8 | ||
|
|
ddc27dbb33 | ||
|
|
7fea5d46cd | ||
|
|
7ff3de2724 | ||
|
|
4ffbefbbe0 | ||
|
|
a2cc3945f6 | ||
|
|
77c4fe1bfd | ||
|
|
ffcba02af2 | ||
|
|
bfe2db7a72 | ||
|
|
e2ce49e3e5 | ||
|
|
d07674e2c6 | ||
|
|
ba4a7140d6 | ||
|
|
96dc0d0313 | ||
|
|
adf57e7b00 | ||
|
|
30485d7104 | ||
|
|
7d0da57d4a | ||
|
|
53a5d25cd9 | ||
|
|
93664b6ef5 | ||
|
|
dcb517d300 | ||
|
|
7eb629f158 | ||
|
|
f334a31b10 | ||
|
|
536df6a156 | ||
|
|
2032c156a8 | ||
|
|
ae1d52794a | ||
|
|
50e5d8d7bc | ||
|
|
5ed307f639 | ||
|
|
0b062fc97c | ||
|
|
9e4b4fd7df | ||
|
|
5560731a36 | ||
|
|
b6f516d81d | ||
|
|
a7875f2396 | ||
|
|
ee86ba8340 | ||
|
|
f99989145c | ||
|
|
73757a3bdb | ||
|
|
2570b82309 | ||
|
|
f7dcff2e87 | ||
|
|
2f17391664 | ||
|
|
ead30c2765 | ||
|
|
9abd6c818b | ||
|
|
d4d544a086 | ||
|
|
3ed83781f2 | ||
|
|
611801e965 | ||
|
|
de54b1c94a | ||
|
|
3c31fc9d02 | ||
|
|
e24cece994 | ||
|
|
729280e629 | ||
|
|
d8bed72ea2 | ||
|
|
a8a4d99113 | ||
|
|
18959e3beb | ||
|
|
e0b53a15d1 | ||
|
|
a1076c5026 | ||
|
|
3acebda42b | ||
|
|
4817f8644f | ||
|
|
7b50a49d5c | ||
|
|
ee334d285e | ||
|
|
24cba526f9 | ||
|
|
4345254674 | ||
|
|
71de170b00 | ||
|
|
daa2e880ff | ||
|
|
fde8174e86 | ||
|
|
0a1857ead8 | ||
|
|
a984876d84 | ||
|
|
b9ff994011 | ||
|
|
331710f288 | ||
|
|
8b119cc145 | ||
|
|
bfe9f42e04 | ||
|
|
4f3f78f4ba | ||
|
|
3520ac0392 | ||
|
|
1fe0168446 | ||
|
|
29a9261ee8 | ||
|
|
650583bd7e | ||
|
|
34d01f1a22 | ||
|
|
5b0184d60f | ||
|
|
535908f169 | ||
|
|
4d804f9644 | ||
|
|
bb18e4909b | ||
|
|
bfbd0a8da4 | ||
|
|
52543344d4 | ||
|
|
fa382190e3 | ||
|
|
2178135bc8 | ||
|
|
1c3e295a6b | ||
|
|
c2b11fea53 | ||
|
|
3d8e4a6913 | ||
|
|
70320834ae | ||
|
|
a6c6a7d733 | ||
|
|
fa5aa2ea27 | ||
|
|
a9cc2752d0 | ||
|
|
2d3808460e | ||
|
|
8ae1c18344 | ||
|
|
26696e73ba | ||
|
|
e6e7dd57c6 | ||
|
|
502a343c55 | ||
|
|
150468f823 | ||
|
|
13be0ab471 | ||
|
|
8a41f93e19 | ||
|
|
5c74626e76 | ||
|
|
553bf5b93c | ||
|
|
37e7ee1f2e | ||
|
|
dc0a214306 | ||
|
|
52d4c654a1 | ||
|
|
afb0e6c182 | ||
|
|
bb96118df0 | ||
|
|
687b50d970 | ||
|
|
722b6ff385 | ||
|
|
2ad1233863 | ||
|
|
c1f0923433 | ||
|
|
d22a4048aa | ||
|
|
54e7a99b77 | ||
|
|
15d836fade | ||
|
|
09605b610d | ||
|
|
0e8ea7b595 | ||
|
|
d1b9543d35 | ||
|
|
52b600dbbf | ||
|
|
f13bfbf9ac | ||
|
|
f60bfdd318 | ||
|
|
e960fb6cb4 | ||
|
|
1922203226 | ||
|
|
841ad76fe8 | ||
|
|
8415cfd243 | ||
|
|
520dcfe9be | ||
|
|
c5633916c6 | ||
|
|
c6600ada46 | ||
|
|
e105aad7eb | ||
|
|
ef0a4a09c7 | ||
|
|
0f2c8bf2dc | ||
|
|
c9676d3dfb | ||
|
|
12511a48e9 | ||
|
|
e924df5be2 | ||
|
|
da5d08e1d8 | ||
|
|
c38fa5c0bf | ||
|
|
af192d5a32 | ||
|
|
b448d6b208 | ||
|
|
01c22e449d | ||
|
|
894fdf7625 | ||
|
|
c77444c4df | ||
|
|
89059e8b46 | ||
|
|
2b11d25ac2 | ||
|
|
09a58a95ce | ||
|
|
89839b7da2 | ||
|
|
5a772d40a3 | ||
|
|
36ac6256d6 | ||
|
|
c59d010444 | ||
|
|
21d5fd0004 | ||
|
|
560ffc160a | ||
|
|
118ad70db0 | ||
|
|
68c74360d5 | ||
|
|
8e78759713 | ||
|
|
a27d4c3061 | ||
|
|
75c4e7aeae | ||
|
|
1debfd81da | ||
|
|
5f41508df3 | ||
|
|
43b69192e6 | ||
|
|
5c143ad47a | ||
|
|
6b43d3b238 | ||
|
|
8fb186f564 | ||
|
|
e016cc5528 | ||
|
|
efbc815717 | ||
|
|
0ffc0a6471 | ||
|
|
9e00b96e95 | ||
|
|
76bde6941a | ||
|
|
f47d3c0914 | ||
|
|
1f09042271 | ||
|
|
196ec996df | ||
|
|
fc56cbe360 | ||
|
|
2363c3362c | ||
|
|
503710f19b | ||
|
|
7dd06fcc51 | ||
|
|
2c7a9934fe | ||
|
|
06f53ad40d | ||
|
|
7647a0ff5b | ||
|
|
52ff312044 | ||
|
|
270a27187c | ||
|
|
10cf6bc3cb | ||
|
|
df04573792 | ||
|
|
11d38b3112 |
1747 changed files with 153538 additions and 30479 deletions
|
|
@ -32,6 +32,14 @@
|
|||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>classes</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>security-util</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
|
|
@ -41,6 +49,11 @@
|
|||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>test-clearing</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
|
|
@ -60,6 +73,11 @@
|
|||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package ru.spcex.clearing.account.config;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
import ru.spcex.clearing.util.services.RequestHelper;
|
||||
import ru.spcex.platform.enumeration.UserRole;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
@Configuration
|
||||
public class BeanConfiguration {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public RequestHelper requestHelper(IMessageResolver messageResolver) {
|
||||
return new RequestHelper(messageResolver, AccountError.GeneralError);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public UserRoleVerification userRoleVerification(ImdgProvider imdgProvider, IMessageResolver messageResolver) {
|
||||
return new UserRoleVerification(imdgProvider, messageResolver, UserRole.Admin, AccountError.UserVerifyDenial);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package ru.spcex.clearing.account.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.enumeration.SimpleMessageResolver;
|
||||
|
||||
@Configuration
|
||||
public class ErrorResolverConfig {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver() {
|
||||
return new SimpleMessageResolver();
|
||||
}
|
||||
}
|
||||
|
|
@ -7,10 +7,13 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.core.ProducerFactory;
|
||||
import ru.spcex.clearing.account.config.settings.AccountServiceSettings;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaConsumerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaProducerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
|
|
@ -33,13 +36,24 @@ public class KafkaConfig {
|
|||
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ProducerFactory<String, Object> pf(AccountServiceSettings settings) {
|
||||
KafkaProducerSettings kafkaSettings = settings.getKafkaProducer();
|
||||
return KafkaProducerFactory.producerFactory(kafkaSettings);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public KafkaTemplate<String, Object> kafkaTemplate(ProducerFactory<String, Object> pf) {
|
||||
return new KafkaTemplate<>(pf);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public KafkaSender kafkaSender(Producer<String, Object> kafkaProducer, ImdgProvider imdgProvider) {
|
||||
public KafkaSender kafkaSender(KafkaTemplate<String, Object> kafkaTemplate, ImdgProvider imdgProvider) {
|
||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||
return KafkaSender
|
||||
.setup()
|
||||
.producer(kafkaProducer)
|
||||
.setKafkaTemplate(kafkaTemplate)
|
||||
.idGenerator(imdgIdGenerator::nextId)
|
||||
.imdgProvider(s -> {
|
||||
Imdg<RequestInfo> imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
package ru.spcex.clearing.account.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.AccountBalance;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.spcex.clearing.account.validation.AccountValidationRule;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class ValidationConfig {
|
||||
private final Map<String, Imdg<? extends SpcexObjectBase>> imdgs;
|
||||
|
||||
public ValidationConfig(ImdgProvider imdgProvider) {
|
||||
this.imdgs = new HashMap<>();
|
||||
BiConsumer<String, Class<? extends SpcexObjectBase>> addImdg = (s, aClass) -> imdgs.put(s, imdgProvider.getImdg(s, aClass));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account, Account.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company, Company.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* чтобы во всех валидаторах был один экземпляр Imdg
|
||||
*/
|
||||
private Imdg<?> getImdg(String key) {
|
||||
return imdgs.get(key);
|
||||
}
|
||||
|
||||
@Bean("bankAccountNewRequestValidator")
|
||||
public Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator() {
|
||||
return bankAccountNewRequest -> {
|
||||
ImdgValidationContext<BankAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, getImdg(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountBalance);
|
||||
|
||||
return new ValidatorImpl<>(context,
|
||||
AccountValidationRule.RequiredFields,
|
||||
AccountValidationRule.RubRequiredFields,
|
||||
AccountValidationRule.AccountIsNew,
|
||||
AccountValidationRule.CompanyPresent
|
||||
);
|
||||
};
|
||||
//todo после слияния ветки CLR_51_57 переписать на использование DictionaryPresentRule, FieldRequiredRule
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.AccountSymbols;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountSymbolsNewRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldNotBlankRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class AccountSymbolsValidationConfig {
|
||||
|
||||
@Bean("accountSymbolsDepoNewRequest")
|
||||
public Function<AccountSymbolsNewRequest, IValidator> accountSymbolsDepoNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return accountSymbolsNewRequest -> {
|
||||
ImdgValidationContext<AccountSymbolsNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(accountSymbolsNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountSymbols);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("accountId",
|
||||
AccountSymbolsNewRequest::getAccountId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
true,
|
||||
(Account account) -> {
|
||||
if (AccountType.Depo.equalsByKey(account.getAccountType())) {
|
||||
return null;
|
||||
} else {
|
||||
return AccountError.AccountDepoTypeRequired;
|
||||
}
|
||||
}
|
||||
),
|
||||
FieldNotBlankRequiredRule.instance("accountSymbolValue",
|
||||
AccountSymbolsNewRequest::getAccountSymbolValue,
|
||||
AccountError.RequiredFieldEmpty, true),
|
||||
new DuplicateAccountSymbolsRule()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
static class DuplicateAccountSymbolsRule implements IValidationRule<ImdgValidationContext<AccountSymbolsNewRequest>> {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<AccountSymbolsNewRequest> context) {
|
||||
AccountSymbolsNewRequest validatedObject = context.getValidatedObject();
|
||||
Imdg<AccountSymbols> accountSymbolsImdg = context.obtainMap(IMDGDistributedNames.Map_AccountSymbols, AccountSymbols.class);
|
||||
|
||||
ImdgPredicateBuilder pb = accountSymbolsImdg.predicateBuilder();
|
||||
ImdgPredicate query = pb.or(
|
||||
pb.equals("accountId", validatedObject.getAccountId()),
|
||||
pb.equals("accountSymbolValue", validatedObject.getAccountSymbolValue())
|
||||
);
|
||||
Collection<AccountSymbols> existAccSymbols = accountSymbolsImdg.getCollectionObjectsByPredicate(query);
|
||||
|
||||
if (existAccSymbols.isEmpty()) {
|
||||
return empty();
|
||||
} else {
|
||||
AccountSymbols existAS = existAccSymbols.iterator().next();
|
||||
String duplicateMsg = "";
|
||||
if (validatedObject.getAccountId() != null && validatedObject.getAccountId().equals(existAS.getAccountId())) {
|
||||
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Account linkedAccount = accountImdg.getSingleObjectByID(existAS.getAccountId());
|
||||
if (linkedAccount != null) {
|
||||
duplicateMsg = linkedAccount.getAccount();
|
||||
} else {
|
||||
duplicateMsg = "" + existAS.getAccountId();
|
||||
}
|
||||
}
|
||||
if (validatedObject.getAccountSymbolValue() != null &&
|
||||
validatedObject.getAccountSymbolValue().equals(existAS.getAccountSymbolValue())) {
|
||||
if (!duplicateMsg.isEmpty())
|
||||
duplicateMsg += ", ";
|
||||
duplicateMsg += existAS.getAccountSymbolValue();
|
||||
}
|
||||
return of(AccountError.AccountAlreadyExist, duplicateMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.specific.FieldRequiredSpecificRule;
|
||||
import ru.spcex.clearing.validation.common.rules.specific.IdPresentSpecificRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class AccountValidationConfig {
|
||||
|
||||
@Bean("correspondentAccountNewRequestValidator")
|
||||
public Function<CorrespondentAccountNewRequest, IValidator> correspondentAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return correspondentAccountNewRequest -> {
|
||||
ImdgValidationContext<CorrespondentAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
CorrespondentAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound
|
||||
// company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive
|
||||
),
|
||||
FieldRequiredSpecificRule.instance("account",
|
||||
CorrespondentAccountNewRequest::getAccount,
|
||||
AccountError.AccountFieldNotSet,
|
||||
false,
|
||||
accountValue -> {
|
||||
if ((accountValue == null || accountValue.isBlank()) && AccountType.Info.equalsByKey(context.getValidatedObject().getAccountType())) {
|
||||
return null;
|
||||
}
|
||||
if (accountValue == null || accountValue.isBlank())
|
||||
return new EnumMessage(AccountError.AccountFieldNotSet, "account");
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", accountValue);
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", AccountStatus.ACTIVE.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate, accountStatusPredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return null;
|
||||
return new EnumMessage(AccountError.AccountAlreadyExist, accounts.stream().findFirst().get().getAccount());
|
||||
}),
|
||||
DictionaryPresentRule.instance("status",
|
||||
CorrespondentAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false
|
||||
// , statusValue -> {
|
||||
// if (ServiceStatus.Active.equalsByKey(statusValue.getCode())) return null;
|
||||
// return AccountError.WrongFieldValue;
|
||||
// }
|
||||
),
|
||||
DictionaryPresentRule.instance("accountType",
|
||||
CorrespondentAccountNewRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary,
|
||||
AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
accountType -> {
|
||||
if (IEnumKey.contains(accountType.getCode(), AccountType.Corr, AccountType.Info)) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
}).withMessageDecorator((causeEmpty, errorCode, fieldName, fieldValue) -> {
|
||||
if (errorCode == AccountError.WrongFieldValue)
|
||||
return DictionaryPresentRule.FIELD_NOT_FOUND_DECORATOR_1.decorator(causeEmpty, errorCode, fieldName, fieldValue);
|
||||
else
|
||||
return DictionaryPresentRule.DICTIONARY_NOT_FOUND_DECORATOR_2.decorator(causeEmpty, errorCode, fieldName, fieldValue);
|
||||
}
|
||||
),
|
||||
new SameAccountValidationRule<>(AccountType.Corr, CorrespondentAccountNewRequest::getAccount)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("correspondentAccountUpdateRequestValidator")
|
||||
public Function<CorrespondentAccountUpdateRequest, IValidator> correspondentAccountUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return correspondentAccountUpdateRequest -> {
|
||||
ImdgValidationContext<CorrespondentAccountUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
CorrespondentAccountUpdateRequest::getId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound),
|
||||
IdPresentRule.instance("companyId",
|
||||
CorrespondentAccountUpdateRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
false,
|
||||
company -> {
|
||||
if (Objects.equals(company.getId(), correspondentAccountUpdateRequest.getCompanyId()))
|
||||
return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
}),
|
||||
DictionaryPresentRule.instance("status",
|
||||
CorrespondentAccountUpdateRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false),
|
||||
DictionaryPresentRule.instance("accountType",
|
||||
CorrespondentAccountUpdateRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary,
|
||||
AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false
|
||||
// accountType -> {
|
||||
// if (AccountType.Corr.equalsByKey(accountType.getCode())) return null;
|
||||
// return AccountError.WrongFieldValue;
|
||||
// }
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("correspondentAccountBlockRequestValidator")
|
||||
public Function<CommonIdRequest, IValidator> correspondentAccountBlockRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return correspondentAccountBlockRequest -> {
|
||||
ImdgValidationContext<CommonIdRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountBlockRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentSpecificRule.instance("id",
|
||||
CommonIdRequest::getId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
account -> {
|
||||
if (AccountStatus.BLOCKED.equalsByKey(account.getStatus()))
|
||||
return new EnumMessage(AccountError.AccountNotActive, account.getAccount());
|
||||
return null;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldNotBlankRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.specific.FieldRequiredSpecificRule;
|
||||
import ru.spcex.clearing.validation.common.rules.specific.IdPresentSpecificRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class BankAccountValidationConfig {
|
||||
|
||||
@Bean("bankAccountNewRequestValidator")
|
||||
public Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return bankAccountNewRequest -> {
|
||||
ImdgValidationContext<BankAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CurrencyCodeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
BankAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
false),
|
||||
FieldNotBlankRequiredRule.instance("account",
|
||||
BankAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty
|
||||
),
|
||||
new SameAccountValidationRule<>(AccountType.Bank, BankAccountNewRequest::getAccount),
|
||||
DictionaryPresentRule.instance("currency",
|
||||
BankAccountNewRequest::getCurrency,
|
||||
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||
CurrencyCodeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound),
|
||||
FieldRequiredRule.instance("bankIdentificationCode",
|
||||
BankAccountNewRequest::getBankIdentificationCode,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
FieldRequiredRule.instance("bankName",
|
||||
BankAccountNewRequest::getBankName,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("status",
|
||||
BankAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("bankAccountUpdateRequestValidator")
|
||||
public Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return bankAccountUpdateRequest -> {
|
||||
ImdgValidationContext<BankAccountUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CurrencyCodeDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
BankAccountUpdateRequest::getId,
|
||||
IMDGDistributedNames.Map_BankAccount,
|
||||
BankAccount.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
bankAccount -> {
|
||||
Long accountId = bankAccount.getAccountId();
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
Account account = accountImdg.getSingleObjectByID(accountId);
|
||||
if (account == null) return AccountError.AccountNotFound;
|
||||
// if (!AccountStatus.ACTIVE.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
|
||||
return null;
|
||||
}),
|
||||
DictionaryPresentRule.instance("currency",
|
||||
BankAccountUpdateRequest::getCurrency,
|
||||
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||
CurrencyCodeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("bankAccountBlockRequestValidator")
|
||||
public Function<CommonIdRequest, IValidator> bankAccountBlockRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return bankAccountBlockRequest -> {
|
||||
ImdgValidationContext<CommonIdRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(bankAccountBlockRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentSpecificRule.instance("id",
|
||||
CommonIdRequest::getId,
|
||||
IMDGDistributedNames.Map_BankAccount,
|
||||
BankAccount.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
bankAccount -> {
|
||||
Long accountId = bankAccount.getAccountId();
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
Account account = accountImdg.getSingleObjectByID(accountId);
|
||||
if (account == null)
|
||||
return new EnumMessage(AccountError.AccountNotFound, accountId);
|
||||
if (AccountStatus.BLOCKED.equalsByKey(account.getStatus()))
|
||||
return new EnumMessage(AccountError.AccountNotActive, account.getAccount());
|
||||
return null;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.ClearingAccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldNotBlankRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.specific.FieldRequiredSpecificRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class ClearingAccountValidationConfig {
|
||||
|
||||
@Bean("clearingAccountNewRequestValidator")
|
||||
public Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return clearingAccountNewRequest -> {
|
||||
ImdgValidationContext<ClearingAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(clearingAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccountTypeDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
ClearingAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound
|
||||
// company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null
|
||||
),
|
||||
FieldNotBlankRequiredRule.instance("account",
|
||||
ClearingAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
new SameAccountValidationRule<>(AccountType.Clrn, ClearingAccountNewRequest::getAccount),
|
||||
DictionaryPresentRule.instance("clearingAccountType",
|
||||
ClearingAccountNewRequest::getClearingAccountType,
|
||||
IMDGDistributedNames.Map_ClearingAccountTypeDictionary,
|
||||
ClearingAccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound),
|
||||
DictionaryPresentRule.instance("status",
|
||||
ClearingAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Bean("clearingAccountUpdateRequestValidator")
|
||||
public Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return clearingAccountUpdateRequest -> {
|
||||
ImdgValidationContext<ClearingAccountUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(clearingAccountUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
FieldRequiredRule.instance("account",
|
||||
ClearingAccountUpdateRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
if (accountValue.isBlank())
|
||||
return AccountError.RequiredFieldEmpty;
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", accountValue);
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", ServiceStatus.Active.getKey());
|
||||
ImdgPredicate accountTypePredicate = pb.equals("accountType", AccountType.Clrn.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return AccountError.AccountNotFound;
|
||||
return null;
|
||||
}),
|
||||
FieldRequiredRule.instance("status",
|
||||
ClearingAccountUpdateRequest::getStatus,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
statusValue -> {
|
||||
if (statusValue == 0 || statusValue == 1 || statusValue == 2) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
}),
|
||||
FieldRequiredRule.instance("deal",
|
||||
ClearingAccountUpdateRequest::getDeal,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
dealValue -> {
|
||||
Imdg<Company> companyImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
Company company = companyImdg.getFirstObjectByFieldValues(Map.of("tradingCode", dealValue));
|
||||
if (company == null) return AccountError.WrongFieldValue;
|
||||
return null;
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClientCode;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class ClientCodeValidationConfig {
|
||||
|
||||
@Bean("clientCodeNewRequestValidator")
|
||||
public Function<ClientCodeNewRequest, IValidator> clientCodeNewRequestValidator(Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation) {
|
||||
return clientCodeUpdateRequest -> {
|
||||
ImdgValidationContext<ClientCodeNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(clientCodeUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
FieldRequiredRule.instance("companyId", ClientCodeNewRequest::getCompanyId, AccountError.RequiredFieldEmpty),
|
||||
IdPresentRule.instance("companyId",
|
||||
ClientCodeNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound),
|
||||
|
||||
IdPresentRule.instance("moneyAccountId",
|
||||
ClientCodeNewRequest::getMoneyAccountId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
false,
|
||||
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
|
||||
? null : AccountError.AccountNotFound
|
||||
),
|
||||
IdPresentRule.instance("depoAccountId",
|
||||
ClientCodeNewRequest::getDepoAccountId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
false,
|
||||
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
|
||||
? null : AccountError.AccountNotFound
|
||||
),
|
||||
|
||||
|
||||
DictionaryPresentRule.instance("stauts",
|
||||
ClientCodeNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("clientCodeUpdateRequestValidator")
|
||||
public Function<ClientCodeUpdateRequest, IValidator> clientCodeUpdateRequestValidator(Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation) {
|
||||
return clientCodeUpdateRequest -> {
|
||||
ImdgValidationContext<ClientCodeUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(clientCodeUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClientCode);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
return new ValidatorImpl<ImdgValidationContext<ClientCodeUpdateRequest>>(context,
|
||||
IdPresentRule.instance("id",
|
||||
ClientCodeUpdateRequest::getId,
|
||||
IMDGDistributedNames.Map_ClientCode,
|
||||
ClientCode.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.RecordNotFound
|
||||
),
|
||||
|
||||
FieldRequiredRule.instance("companyId", ClientCodeUpdateRequest::getCompanyId, AccountError.RequiredFieldEmpty),
|
||||
IdPresentRule.instance("companyId",
|
||||
ClientCodeUpdateRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound),
|
||||
|
||||
IdPresentRule.instance("moneyAccountId",
|
||||
ClientCodeUpdateRequest::getMoneyAccountId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
false,
|
||||
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
|
||||
? null : AccountError.AccountNotFound
|
||||
),
|
||||
IdPresentRule.instance("depoAccountId",
|
||||
ClientCodeUpdateRequest::getDepoAccountId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
false,
|
||||
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
|
||||
? null : AccountError.AccountNotFound
|
||||
),
|
||||
|
||||
DictionaryPresentRule.instance("stauts",
|
||||
ClientCodeUpdateRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("clientCodeDeleteRequestValidator")
|
||||
public Function<CommonDeleteRequest, IValidator> clientCodeDeleteRequestValidator(Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation) {
|
||||
return companyDeleteRequest -> {
|
||||
ImdgValidationContext<CommonDeleteRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(companyDeleteRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClientCode);
|
||||
return new ValidatorImpl<>(context,
|
||||
// FieldRequiredRule.instance("id", CommonDeleteRequest::getId, CompanyErrors.RequiredFieldEmpty),
|
||||
IdPresentRule.instance("id",
|
||||
CommonDeleteRequest::getId,
|
||||
IMDGDistributedNames.Map_ClientCode,
|
||||
ClientCode.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.RecordNotFound)
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.DepoAccountNewRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldNotBlankRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.specific.FieldRequiredSpecificRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class DepoAccountValidationConfig {
|
||||
|
||||
@Bean("depoAccountNewRequestValidator")
|
||||
public Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return depoAccountNewRequest -> {
|
||||
ImdgValidationContext<DepoAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(depoAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_DepoAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
DepoAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound
|
||||
// company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null
|
||||
),
|
||||
FieldNotBlankRequiredRule.instance("account",
|
||||
DepoAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
new SameAccountValidationRule<>(AccountType.Depo, DepoAccountNewRequest::getAccount),
|
||||
FieldRequiredRule.instance("depoAccountType",
|
||||
DepoAccountNewRequest::getDepoAccountType,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("status",
|
||||
DepoAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.InformationAccountNewRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldNotBlankRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class InformationAccountValidationConfig {
|
||||
|
||||
@Bean("informationAccountNewRequestValidator")
|
||||
public Function<InformationAccountNewRequest, IValidator> informationAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return informationAccountNewRequest -> {
|
||||
ImdgValidationContext<InformationAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(informationAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_InformationAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
InformationAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
company -> {
|
||||
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()))
|
||||
return AccountError.CompanyNotActive;
|
||||
return null;
|
||||
}),
|
||||
FieldNotBlankRequiredRule.instance("account", InformationAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("status", InformationAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary, ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty, AccountError.DictionaryNotFound, false),
|
||||
DictionaryPresentRule.instance("accountType", InformationAccountNewRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty, AccountError.DictionaryNotFound, false),
|
||||
new SameAccountValidationRule<>(AccountType.Info, InformationAccountNewRequest::getAccount)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
class SameAccountValidationRule<R> implements IValidationRule<ImdgValidationContext<R>> {
|
||||
final String accountType;
|
||||
final Function<R, String> accountGetter;
|
||||
|
||||
public SameAccountValidationRule(AccountType accountType, Function<R, String> accountGetter) {
|
||||
this.accountType = accountType.getKey(); // or req.getAccountType()
|
||||
this.accountGetter = accountGetter;
|
||||
Objects.requireNonNull(accountGetter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<R> context) {
|
||||
R req = context.getValidatedObject();
|
||||
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate query = pb.and(
|
||||
pb.equals("account", accountGetter.apply(req)), // req.getAccount()
|
||||
// pb.equals("accountType", accountType), имена всех счетов уникальны, вне зависимости от типа
|
||||
pb.in("status", ServiceStatus.Active.getKey(), ServiceStatus.Reopened.getKey(), ServiceStatus.Appl.getKey())
|
||||
);
|
||||
Account existAccount = accountImdg.getFirstObjectByPredicate(query);
|
||||
if (existAccount != null) {
|
||||
return of(AccountError.AccountAlreadyExist, existAccount.getAccount());
|
||||
}
|
||||
return empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryUpdateRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.FieldRequiredRule;
|
||||
import ru.spcex.clearing.validation.common.rules.IdPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.specific.IdPresentSpecificRule;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Configuration
|
||||
public class TradingClearingRegistryValidationConfig {
|
||||
|
||||
@Bean("tradingClearingRegistryNewRequest")
|
||||
public Function<TradingClearingRegistryNewRequest, IValidator> tradingClearingRegistryNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return tradingClearingRegistryNewRequest -> {
|
||||
ImdgValidationContext<TradingClearingRegistryNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(tradingClearingRegistryNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CompanySymbols);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_DepoAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_InformationAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentSpecificRule.instance("companyId",
|
||||
TradingClearingRegistryNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
true,
|
||||
company -> {
|
||||
Imdg<CompanySymbols> companySymbolsImdg = context.obtainMap(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||
CompanySymbols symbol = companySymbolsImdg.getFirstObjectByFieldValues(Map.of(
|
||||
"companyId", company.getId(),
|
||||
"companySymbol", CompanySymbol.CLRC.getKey()
|
||||
));
|
||||
if (symbol == null)
|
||||
return new EnumMessage(AccountError.ClearingCompanySymbolNotFound, company.getShortName());
|
||||
return null;
|
||||
}),
|
||||
FieldRequiredRule.instance("moneyAccountId",
|
||||
TradingClearingRegistryNewRequest::getMoneyAccountId,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
moneyAccountId -> {
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
Account account = accountImdg.getSingleObjectByID(moneyAccountId);
|
||||
if (account == null) {
|
||||
return AccountError.AccountNotFound;
|
||||
} else {
|
||||
if (AccountType.Clrn.equalsByKey(account.getAccountType()) || AccountType.Info.equalsByKey(account.getAccountType())) {
|
||||
// ok
|
||||
} else {
|
||||
// неправильный тип
|
||||
return AccountError.AccountNotFound;
|
||||
}
|
||||
}
|
||||
// Imdg<ClearingAccount> clearingAccountImdg = context.obtainMap(
|
||||
// IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class
|
||||
// );
|
||||
// ClearingAccount clearingAccount = clearingAccountImdg.getSingleObjectByFieldValues(
|
||||
// Map.of("accountId",moneyAccountId)
|
||||
// );
|
||||
// if (clearingAccount == null) {
|
||||
// Imdg<InformationAccount> informationAccountImdg = context.obtainMap(
|
||||
// IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
// );
|
||||
// InformationAccount infoAccount = informationAccountImdg.getSingleObjectByFieldValues(
|
||||
// Map.of("accountId",moneyAccountId));
|
||||
// if (infoAccount == null) return AccountError.AccountNotFound;
|
||||
// }
|
||||
return null;
|
||||
}),
|
||||
FieldRequiredRule.instance("depoAccountId",
|
||||
TradingClearingRegistryNewRequest::getDepoAccountId,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
false,
|
||||
depoAccountId -> {
|
||||
if (depoAccountId == null) return null;
|
||||
Imdg<DepoAccount> depoAccountImdg = context.obtainMap(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
DepoAccount depoAccount = depoAccountImdg.getFirstObjectByFieldValues(
|
||||
Map.of("accountId", depoAccountId)
|
||||
);
|
||||
if (depoAccount == null) return AccountError.AccountNotFound;
|
||||
return null;
|
||||
}),
|
||||
DictionaryPresentRule.instance("status",
|
||||
TradingClearingRegistryNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false),
|
||||
new newTCRDuplicateCheck()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
static class newTCRDuplicateCheck implements IValidationRule<ImdgValidationContext<TradingClearingRegistryNewRequest>> {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<TradingClearingRegistryNewRequest> context) {
|
||||
TradingClearingRegistryNewRequest validatedObject = context.getValidatedObject();
|
||||
Imdg<TradingClearingRegistry> tcrMap = context.obtainMap(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
|
||||
if (validatedObject.getMoneyAccountId() == null) {
|
||||
return of(AccountError.RequiredFieldEmpty, "MoneyAccountId");
|
||||
}
|
||||
//Map<String, Comparable<?>> query = new HashMap<>();
|
||||
// query.put("moneyAccountId", validatedObject.getMoneyAccountId());
|
||||
// if (validatedObject.getDepoAccountId() != null) {
|
||||
// query.put("depoAccountId", validatedObject.getDepoAccountId());
|
||||
// }
|
||||
ImdgPredicateBuilder pb = tcrMap.predicateBuilder();
|
||||
ImdgPredicate query = pb.equals("moneyAccountId", validatedObject.getMoneyAccountId());
|
||||
if (validatedObject.getDepoAccountId() != null) {
|
||||
query = pb.or(query, pb.equals("depoAccountId", validatedObject.getDepoAccountId()));
|
||||
}
|
||||
|
||||
Collection<TradingClearingRegistry> existTCR = tcrMap.getCollectionObjectsByPredicate(query);
|
||||
|
||||
if (existTCR.isEmpty()) {
|
||||
return empty();
|
||||
} else {
|
||||
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Account account = accountImdg.getSingleObjectByID(validatedObject.getMoneyAccountId());
|
||||
if (account == null && validatedObject.getDepoAccountId() != null) account = accountImdg.getSingleObjectByID(validatedObject.getDepoAccountId());
|
||||
return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, account.getAccount());
|
||||
// String tcrIds = existTCR.stream().map(tcr -> String.valueOf(tcr.getId())).collect(Collectors.joining(";"));
|
||||
// return of(AccountError.AccountForTradingClearingRegistryAlreadyUsed, tcrIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Bean("tradingClearingRegistryUpdateRequest")
|
||||
public Function<TradingClearingRegistryUpdateRequest, IValidator> tradingClearingRegistryUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return tradingClearingRegistryUpdateRequest -> {
|
||||
ImdgValidationContext<TradingClearingRegistryUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(tradingClearingRegistryUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
TradingClearingRegistryUpdateRequest::getId,
|
||||
IMDGDistributedNames.Map_TradingClearingRegistry,
|
||||
TradingClearingRegistry.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.TradingClearingRegistryNotFound),
|
||||
DictionaryPresentRule.instance("status",
|
||||
TradingClearingRegistryUpdateRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("tradingClearingRegistryBlockRequest")
|
||||
public Function<CommonIdRequest, IValidator> tradingClearingRegistryBlockRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return tradingClearingRegistryBlockRequest -> {
|
||||
ImdgValidationContext<CommonIdRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(tradingClearingRegistryBlockRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
CommonIdRequest::getId,
|
||||
IMDGDistributedNames.Map_TradingClearingRegistry,
|
||||
TradingClearingRegistry.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.TradingClearingRegistryNotFound)
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.*;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.platform.dictionary.*;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Configuration
|
||||
public class ValidationConfig {
|
||||
|
||||
@Bean("imdgForValidation")
|
||||
public Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation(ImdgProvider imdgProvider) {
|
||||
final Map<String, Imdg<? extends SpcexObjectBase>> imdg = new HashMap<>();
|
||||
BiConsumer<String, Class<? extends SpcexObjectBase>> addImdg = (s, aClass) -> imdg.put(s, imdgProvider.getImdg(s, aClass));
|
||||
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company, Company.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account, Account.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary, ServiceStatusDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountSymbols, AccountSymbols.class);
|
||||
|
||||
//for ClientCodeValidationConfig
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClientCode, ClientCode.class);
|
||||
|
||||
return imdg;
|
||||
}
|
||||
|
||||
@Bean("validationHelper")
|
||||
public ValidationHelper validationHelper(IMessageResolver messageResolver) {
|
||||
return new ValidationHelper(messageResolver);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,14 +1,31 @@
|
|||
package ru.spcex.clearing.account.errors;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IEnumId;
|
||||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||
|
||||
public enum AccountError implements IEnumId {
|
||||
public enum AccountError implements IErrorEnumId {
|
||||
GeneralError(5000L),
|
||||
UserVerifyDenial(5001L),
|
||||
RequiredFieldEmpty(5002L),
|
||||
DictionaryNotFound(5003L),
|
||||
WrongFieldValue(5004L),
|
||||
RecordNotFound(5006L),
|
||||
AccountAlreadyExist(5010L),
|
||||
AccountNotFound(5011L),
|
||||
AccountNotActive(5012L),
|
||||
CompanyNotFound(5013L),
|
||||
CompanyNotActive(5014L),
|
||||
|
||||
InfoAccountAlreadyExist(5015L),
|
||||
TradingClearingRegistryAlreadyExist(5016L),
|
||||
DepoAccountNotFound(5017L),
|
||||
MoneyAccountNotFound(5018L),
|
||||
ClearingCategoryNotFound(5019L),
|
||||
ClearingCompanySymbolNotFound(5022L), // Для компании %s отсутствует клиринговый код».
|
||||
AccountForTradingClearingRegistryAlreadyUsed(5023L),
|
||||
AccountFieldNotSet(5024L),
|
||||
AccountDepoTypeRequired(5025L),
|
||||
TradingClearingRegistryNotFound(3022L),
|
||||
;
|
||||
|
||||
private final Long id;
|
||||
|
||||
AccountError(Long id) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Service
|
||||
public class AccountHelper {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Imdg<ClearingMemberCategory> clearingMemberCategoryMap;
|
||||
private final Imdg<Relation> relationMap;
|
||||
private final IMessageResolver messageResolver;
|
||||
|
||||
@Autowired
|
||||
public AccountHelper(ImdgProvider imdgProvider,
|
||||
IMessageResolver messageResolver) {
|
||||
this.clearingMemberCategoryMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
this.relationMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
this.messageResolver = messageResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Заполняет поля relationId и companyId из соответствующей записи Relation
|
||||
*
|
||||
* @param requestId Идентификатор запроса для вывода лога
|
||||
*/
|
||||
public RequestInfoUpdate fillAccountFromRelation(Account account, Long requestId, boolean checkClearingMemberCategory) {
|
||||
Long companyId = account.getCompanyId();
|
||||
Collection<Relation> relations;
|
||||
ImdgPredicateBuilder relationPredicateBuilder = relationMap.predicateBuilder();
|
||||
ImdgPredicate finalRelationPredicate;
|
||||
if (checkClearingMemberCategory) {
|
||||
ImdgPredicateBuilder clearingMemberCategoryPredicateBuilder = clearingMemberCategoryMap.predicateBuilder();
|
||||
ImdgPredicate companyIdEquals = clearingMemberCategoryPredicateBuilder.equals("companyId", companyId);
|
||||
Collection<ClearingMemberCategory> clearingMemberCategories = clearingMemberCategoryMap.getCollectionObjectsByPredicate(companyIdEquals);
|
||||
|
||||
if (clearingMemberCategories.isEmpty())
|
||||
return makeError(requestId, AccountError.ClearingCategoryNotFound, companyId, "(any)");
|
||||
if (clearingMemberCategories.size() > 1)
|
||||
log.warn("ClearingMemberCategory for companyId {} contains multiply elements, use first", companyId);
|
||||
ClearingMemberCategory clearingMemberCategory = clearingMemberCategories.iterator().next();
|
||||
|
||||
ImdgPredicate consumerIdPredicate = relationPredicateBuilder.equals("consumerId", companyId);
|
||||
ImdgPredicate servicePredicate;
|
||||
String clearingCategoryValue = clearingMemberCategory.getClearingMemberCategory();
|
||||
if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.B, ClearingCategory.I, ClearingCategory.V)) {
|
||||
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.MKR.getKey());
|
||||
} else if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.F, ClearingCategory.C)) {
|
||||
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.FOND.getKey());
|
||||
} else {
|
||||
log.info("ClearingCategoryNotFound with clearingCategoryValue={} not implemented. Do not search Relation.", clearingCategoryValue);
|
||||
return null;
|
||||
//return makeError(requestId, AccountError.ClearingCategoryNotFound, companyId, clearingCategoryValue + " (case not implemented)");
|
||||
}
|
||||
finalRelationPredicate = relationPredicateBuilder.and(consumerIdPredicate, servicePredicate);
|
||||
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||
} else {
|
||||
finalRelationPredicate = relationPredicateBuilder.equals("consumerId", companyId);
|
||||
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||
}
|
||||
|
||||
if (relations.isEmpty()) {
|
||||
//return makeError(requestId, AccountError.WrongFieldValue, "companyId", finalRelationPredicate.toString());
|
||||
log.info("Relation not found: {}", finalRelationPredicate.toString());
|
||||
return null;
|
||||
}
|
||||
if (relations.size() > 1)
|
||||
log.warn("Relation for consumerId {} contains multiply elements, use first", companyId);
|
||||
Relation relation = relations.iterator().next();
|
||||
account.setRelationId(relation.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate makeError(Long reqId, AccountError accountError, Object... args) {
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(accountError, args));
|
||||
return new RequestInfoUpdate()
|
||||
.setId(reqId)
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,81 +1,334 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountTerminationRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class AccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Imdg<Account> accountMap;
|
||||
private final Imdg<ClearingMemberCategory> clearingMemberCategoryMap;
|
||||
private final Imdg<Relation> relationMap;
|
||||
private final KafkaSender kafkaSender;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final AccountHelper accountHelper;
|
||||
private final InformationAccountService informationAccountService;
|
||||
private final Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator;
|
||||
private final Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator;
|
||||
private final Function<CommonIdRequest, IValidator> accountBlockRequestValidator;
|
||||
|
||||
@Autowired
|
||||
public AccountService(Consumer<String, Object> kafkaQueue, ImdgProvider imdgProvider, KafkaSender kafkaSender) {
|
||||
super(kafkaQueue);
|
||||
this.accountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
public AccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
KafkaSender kafkaSender,
|
||||
IMessageResolver messageResolver,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper,
|
||||
AccountHelper accountHelper,
|
||||
InformationAccountService informationAccountService,
|
||||
@Qualifier("correspondentAccountNewRequestValidator")
|
||||
Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator,
|
||||
@Qualifier("correspondentAccountUpdateRequestValidator")
|
||||
Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator,
|
||||
@Qualifier("correspondentAccountBlockRequestValidator")
|
||||
Function<CommonIdRequest, IValidator> accountBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.accountHelper = accountHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
this.clearingMemberCategoryMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
this.relationMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.messageResolver = messageResolver;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.validationHelper = validationHelper;
|
||||
this.informationAccountService = informationAccountService;
|
||||
this.accountNewRequestValidator = accountNewRequestValidator;
|
||||
this.accountUpdateRequestValidator = accountUpdateRequestValidator;
|
||||
this.accountBlockRequestValidator = accountBlockRequestValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(AccountSdf01Request.class)
|
||||
.setConsumer(this::accountNew)
|
||||
.forDestination(Consts.ACCOUNT_NEW, callbacks::put);
|
||||
imdgProvider.waitAvailable();
|
||||
callback(CorrespondentAccountNewRequest.class)
|
||||
.setFunction(this::accountCorrespondentNew)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, callbacks::put);
|
||||
callback(CorrespondentAccountUpdateRequest.class)
|
||||
.setFunction(this::correspondentAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, callbacks::put);
|
||||
callback(CommonIdRequest.class)
|
||||
.setFunction(this::correspondentAccountBlock)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, callbacks::put);
|
||||
|
||||
callback(AccountTerminationRequest.class)
|
||||
.setFunction(this::accountTerminationForCompany)
|
||||
.forDestination(Consts.ACCOUNT_TERMINATION, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
private void accountNew(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||
log.debug("AccountSdf01Request received");
|
||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||
for (AccountSdfRequestPart accountReq : req.getAccounts()) {
|
||||
Account account = new Account();
|
||||
account.setAccount(accountReq.getAccount());
|
||||
account.setCompanyId(accountReq.getCompanyId());
|
||||
account.setAccountType(accountReq.getAccountType());
|
||||
accountMap.insert(account);
|
||||
AccountSdfToStatementRequestPart responsePart = responsePart(accountReq.getSdfId());
|
||||
accountToStatement.add(responsePart);
|
||||
|
||||
public RequestInfoUpdate accountCorrespondentNew(BaseRequest<CorrespondentAccountNewRequest> userRequest) {
|
||||
log.debug("CorrespondentAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CorrespondentAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setAccount(req.getAccount());
|
||||
if (AccountType.Info.equalsByKey(req.getAccountType())) {
|
||||
Long infoSequenceId = informationAccountService.accountNextId();
|
||||
String accountValue = informationAccountService.generateInfoAccount(infoSequenceId);
|
||||
log.trace("New info-account SequenceId={} account={}", infoSequenceId, accountValue);
|
||||
account.setAccount(accountValue);
|
||||
}
|
||||
sendStatementRequestBack(req.getGroupingSdf01Id(), accountToStatement);
|
||||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||
account.setAccountType(req.getAccountType());
|
||||
if (req.getStatus() == null) {
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
log.trace("Status not set in request. Use default: {}", account.getStatus());
|
||||
} else {
|
||||
account.setStatus(req.getStatus());
|
||||
}
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
|
||||
requestInfoUpdate = accountHelper.fillAccountFromRelation(account, userRequest.getId(), false);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long newId = null;
|
||||
if (AccountType.Corr.equalsByKey(account.getAccountType())) {
|
||||
// default, дополнительные таблицы не требуются
|
||||
newId = accountMap.insert(account);
|
||||
} else {
|
||||
// Транзакцией
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
imdgTransaction.beginTransaction();
|
||||
boolean txOk = false;
|
||||
try {
|
||||
Imdg<Account> accountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
newId = accountMap.insert(account);
|
||||
|
||||
if (AccountType.Corr.equalsByKey(account.getAccountType())) {
|
||||
// default, дополнительные таблицы не требуются
|
||||
} else if (AccountType.Info.equalsByKey(account.getAccountType()))
|
||||
makeInfoPart(imdgTransaction, account);
|
||||
else if (AccountType.Depo.equalsByKey(account.getAccountType()))
|
||||
makeDepoPart(imdgTransaction, account, req);
|
||||
else if (AccountType.Clrn.equalsByKey(account.getAccountType()))
|
||||
makeClrnPart(imdgTransaction, account);
|
||||
else {
|
||||
log.warn("Unexpected AccountType={}. Do not create additional record to other table's", account.getAccountType());
|
||||
}
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
} else {
|
||||
log.debug("failed insert, new account id {} rollback", newId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("successfully processed, new account id {}", newId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void accountUpdateWithBrake(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
|
||||
protected void makeInfoPart(ImdgTransaction imdgTransaction, Account account) {
|
||||
Imdg<InformationAccount> informationAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
|
||||
InformationAccount infoAcc = new InformationAccount();
|
||||
infoAcc.setAccountId(account.getId());
|
||||
Account firstAccountAntl = accountMap.getFirstObjectByFieldValues(Map.of(
|
||||
"companyId", Sender.One.getId(),
|
||||
"accountType", AccountType.Anlt.getKey()
|
||||
));
|
||||
if (firstAccountAntl == null) {
|
||||
log.warn("Can not find 1 ANTL account for fill information ClearingAccountId.");
|
||||
} else {
|
||||
infoAcc.setClearingAccountId(firstAccountAntl.getId());
|
||||
}
|
||||
infoAcc.setCompanyId(account.getCompanyId());
|
||||
Long infoId = informationAccountMap.insert(infoAcc);
|
||||
log.debug("For account id={} make InformationAccount id={}", account.getId(), infoId);
|
||||
}
|
||||
|
||||
private AccountSdfToStatementRequestPart responsePart(Long sdf01Id) {
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(sdf01Id);
|
||||
responsePart.setErrorCode(null);
|
||||
responsePart.setErrorText(null);
|
||||
return responsePart;
|
||||
protected void makeDepoPart(ImdgTransaction imdgTransaction, Account account, CorrespondentAccountNewRequest req) {
|
||||
Imdg<DepoAccount> depoAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
DepoAccount depoAcc = new DepoAccount();
|
||||
depoAcc.setAccountId(account.getId());
|
||||
depoAcc.setCompanyId(account.getCompanyId());
|
||||
if (account.getAccount() != null && account.getAccount().contains("BC")) {
|
||||
depoAcc.setDepoAccountType(DepoAccountType.C.getKey());
|
||||
} else {
|
||||
//todo в реквесте нет поля depoAcc.setDepoAccountType(req.getDepoAccountType());
|
||||
}
|
||||
Long depoId = depoAccountMap.insert(depoAcc);
|
||||
log.debug("For account id={} make DepoAccount id={}", account.getId(), depoId);
|
||||
}
|
||||
|
||||
private void sendStatementRequestBack(Long groupingSdf01Id, List<AccountSdfToStatementRequestPart> results) {
|
||||
StatementRequest request = new StatementRequest();
|
||||
request.setGroupId(groupingSdf01Id);
|
||||
request.setAccountCreationResults(results);
|
||||
kafkaSender.sendRequestToQueue(Consts.STATEMENT_PROCESS, request);
|
||||
protected void makeClrnPart(ImdgTransaction imdgTransaction, Account account) {
|
||||
Imdg<ClearingAccount> clearingAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
ClearingAccount clnrAcc = new ClearingAccount();
|
||||
clnrAcc.setAccountId(account.getId());
|
||||
clnrAcc.setCompanyId(account.getCompanyId());
|
||||
Long clrnId = clearingAccountMap.insert(clnrAcc);
|
||||
log.debug("For account id={} make ClearingAccount id={}", account.getId(), clrnId);
|
||||
}
|
||||
|
||||
public RequestInfoUpdate correspondentAccountUpdate(BaseRequest<CorrespondentAccountUpdateRequest> userRequest) {
|
||||
log.debug("CorrespondentAccountUpdateRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountUpdateRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CorrespondentAccountUpdateRequest request = userRequest.getRequestPayload();
|
||||
|
||||
Account account = accountMap.getSingleObjectByID(request.getId());
|
||||
if (request.getAccountType() != null && !request.getAccountType().equals(account.getAccountType())) {
|
||||
requestInfoUpdate = makeError(userRequest.getId(), AccountError.WrongFieldValue, "accountType");
|
||||
return requestInfoUpdate;
|
||||
}
|
||||
|
||||
if (request.getStatus() != null) account.setStatus(request.getStatus());
|
||||
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
|
||||
log.debug("successfully processed, update account id {}", account.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate correspondentAccountBlock(BaseRequest<CommonIdRequest> userRequest) {
|
||||
log.debug("AccountBlockRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountBlockRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CommonIdRequest request = userRequest.getRequestPayload();
|
||||
|
||||
Account account = accountMap.getSingleObjectByID(request.getId());
|
||||
account.setStatus(ServiceStatus.Blocked.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
|
||||
log.debug("successfully processed, block account id {}", account.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public RequestInfoUpdate accountTerminationForCompany(BaseRequest<AccountTerminationRequest> userRequest) {
|
||||
log.debug("AccountTerminationRequest received, id={}", userRequest.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate; // never - system
|
||||
|
||||
AccountTerminationRequest req = userRequest.getRequestPayload();
|
||||
final Long companyId = req.getCompanyId();
|
||||
Collection<Account> accounts = accountMap.getCollectionObjectsBySQL("companyId=" + companyId);
|
||||
log.trace("Found {} accounts (will be terminated) by company {}", accounts.size(), companyId);
|
||||
int blockCount = 0;
|
||||
ImdgTransaction tx = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
try {
|
||||
tx.beginTransaction();
|
||||
for (Account account : accounts) {
|
||||
//Account account = accountMap.getSingleObjectByID(request.getId());
|
||||
if (!ServiceStatus.Blocked.equalsByKey(account.getStatus())) {
|
||||
account.setStatus(ServiceStatus.Blocked.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
accountMap.update(account);
|
||||
blockCount++;
|
||||
}
|
||||
}
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk)
|
||||
tx.commitTransaction();
|
||||
else
|
||||
tx.beginTransaction();
|
||||
}
|
||||
log.debug("For company {} block {} account (of {} account)", companyId, blockCount, accounts.size());
|
||||
|
||||
Long reqId = kafkaSender.sendRequestToQueue(Consts.ACCOUNT_TERMINATION_STEP2, req);
|
||||
log.info("On termination request id={} send to next step {} new request id={}",
|
||||
userRequest.getId(), Consts.ACCOUNT_TERMINATION_STEP2, reqId);
|
||||
|
||||
log.debug("successfully processed, account termination");
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestInfoUpdate makeError(Long reqId, AccountError accountError, Object... args) {
|
||||
String errMsg = messageResolver.resolve(new EnumMessage(accountError, args));
|
||||
return new RequestInfoUpdate()
|
||||
.setId(reqId)
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.*;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountSymbolsNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.util.services.RequestHelper;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class AccountSymbolsService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final ValidationHelper validationHelper;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Imdg<AccountSymbols> accountSymbolsImdg;
|
||||
|
||||
private final RequestHelper requestHelper;
|
||||
private final Function<AccountSymbolsNewRequest, IValidator> accountSymbolsNewRequestValidator;
|
||||
|
||||
private final IMessageResolver messageResolver;
|
||||
private final Producer<String, Object> kafkaProducer;
|
||||
private final KafkaSender kafkaSender;
|
||||
|
||||
public AccountSymbolsService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
KafkaSender kafkaSender,
|
||||
ImdgProvider imdgProvider,
|
||||
ValidationHelper validationHelper,
|
||||
UserRoleVerification userRoleVerification,
|
||||
IMessageResolver messageResolver,
|
||||
RequestHelper requestHelper,
|
||||
@Qualifier("accountSymbolsDepoNewRequest")
|
||||
Function<AccountSymbolsNewRequest, IValidator> accountSymbolsNewRequestValidator
|
||||
) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.kafkaProducer = kafkaProducer;
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.validationHelper = validationHelper;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.requestHelper = requestHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountSymbolsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_AccountSymbols, AccountSymbols.class);
|
||||
this.accountSymbolsNewRequestValidator = accountSymbolsNewRequestValidator;
|
||||
this.messageResolver = messageResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
imdgProvider.waitAvailable();
|
||||
callback(AccountSymbolsNewRequest.class)
|
||||
.setFunction(this::accountSymbolsNew)
|
||||
.forDestination(Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_NEW, callbacks::put);
|
||||
callback(CommonIdRequest.class)
|
||||
.setFunction(this::accountSymbolsDelete)
|
||||
.forDestination(Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_DELETE, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
protected RequestInfoUpdate accountSymbolsNew(BaseRequest<AccountSymbolsNewRequest> userRequest) {
|
||||
log.debug("AccountSymbolsNewRequest received, id={}", userRequest.getId());
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountSymbolsNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
AccountSymbolsNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Long id = accountSymbolsImdg.nextIDSequenceFor();
|
||||
AccountSymbols accountSymbols = new AccountSymbols();
|
||||
accountSymbols.setId(id);
|
||||
accountSymbols.setAccountId(req.getAccountId());
|
||||
accountSymbols.setAccountSymbolValue(req.getAccountSymbolValue());
|
||||
|
||||
accountSymbolsImdg.insert(accountSymbols);
|
||||
|
||||
log.debug("successfully processed, id {}. New accountSymbols.id={} was created", id, accountSymbols.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
protected RequestInfoUpdate accountSymbolsDelete(BaseRequest<CommonIdRequest> userRequest) {
|
||||
log.debug("AccountSymbolsDeleteRequest(CommonIdRequest) received, id={}", userRequest.getId());
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CommonIdRequest req = userRequest.getRequestPayload();
|
||||
|
||||
AccountSymbols accountSymbols = accountSymbolsImdg.getSingleObjectByID(req.getId());
|
||||
if (accountSymbols == null) {
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.AccountNotFound, req.getId());
|
||||
}
|
||||
|
||||
accountSymbolsImdg.delete(accountSymbols);
|
||||
|
||||
log.debug("successfully processed, id {}. New accountSymbols.id={} was deleted", userRequest.getId(), accountSymbols.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,31 +6,29 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.Allowed;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
|
|
@ -38,29 +36,40 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Imdg<BankAccount> bankAccountMap;
|
||||
private final Imdg<Account> accountMap;
|
||||
private final Imdg<Relation> relationMap;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final ImdgProvider imdgProvider;
|
||||
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final ValidationHelper validationHelper;
|
||||
|
||||
private final AccountHelper accountService;
|
||||
|
||||
// private final Imdg<User> userImdg;
|
||||
// private final Imdg<UserRoleSession> userRoleSessionImdg;
|
||||
private final Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator;
|
||||
private final Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator;
|
||||
private final Function<CommonIdRequest, IValidator> bankAccountBlockRequestValidator;
|
||||
|
||||
@Autowired
|
||||
public BankAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
IMessageResolver messageResolver,
|
||||
|
||||
Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator) {
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper,
|
||||
AccountHelper accountService,
|
||||
@Qualifier("bankAccountNewRequestValidator")
|
||||
Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator,
|
||||
@Qualifier("bankAccountUpdateRequestValidator")
|
||||
Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator,
|
||||
@Qualifier("bankAccountBlockRequestValidator")
|
||||
Function<CommonIdRequest, IValidator> bankAccountBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.bankAccountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
this.accountMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.relationMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
||||
this.messageResolver = messageResolver;
|
||||
|
||||
// this.userImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_User, User.class);
|
||||
// this.userRoleSessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_UserRoleSession, UserRoleSession.class);
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.validationHelper = validationHelper;
|
||||
this.accountService = accountService;
|
||||
this.bankAccountNewRequestValidator = bankAccountNewRequestValidator;
|
||||
this.bankAccountUpdateRequestValidator = bankAccountUpdateRequestValidator;
|
||||
this.bankAccountBlockRequestValidator = bankAccountBlockRequestValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -71,83 +80,89 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
callback(BankAccountUpdateRequest.class)
|
||||
.setFunction(this::bankAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_BANK_ACCOUNT_UPDATE, callbacks::put);
|
||||
callback(CommonDeleteRequest.class)
|
||||
.setFunction(this::bankAccountDelete)
|
||||
.forDestination(Consts.DESTINATION_BANK_ACCOUNT_DELETE, callbacks::put);
|
||||
callback(CommonIdRequest.class)
|
||||
.setFunction(this::bankAccountBlock)
|
||||
.forDestination(Consts.DESTINATION_BANK_ACCOUNT_BLOCK, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
// protected Optional<EnumMessage> checkUserRole(Long userId) {
|
||||
// User user = userImdg.getSingleObjectByID(userId);
|
||||
// if (user == null) {
|
||||
// return Optional.of(new EnumMessage(AccountError.userNotFound(5007)));
|
||||
// }
|
||||
// UserRoleSession role=userRoleSessionImdg.getSingleObjectBySql("userId="+userId+" and userRoleSessions.userRole='ADMN'");
|
||||
// if (role == null) {
|
||||
// return Optional.of(new EnumMessage(AccountError.userNotFound(5001))); // Нет прав на проведение данной операции».
|
||||
// }
|
||||
// return Optional.empty();
|
||||
// }
|
||||
|
||||
private RequestInfoUpdate bankAccountNew(BaseRequest<BankAccountNewRequest> userRequest) {
|
||||
public RequestInfoUpdate bankAccountNew(BaseRequest<BankAccountNewRequest> userRequest) {
|
||||
log.debug("BankAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, bankAccountNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
BankAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
// // проверка прав
|
||||
// checkUserRole(req.getUserId());
|
||||
// валидация
|
||||
IValidator validator = bankAccountNewRequestValidator.apply(req);
|
||||
Optional<EnumMessage> error = validator.tillFirstError();
|
||||
if (error.isPresent()) {
|
||||
log.warn("BankAccountNewRequest[{}] validation error: {}", userRequest.getId(), error.get());
|
||||
String errorMsg = messageResolver.resolve(error.get());
|
||||
return new RequestInfoUpdate()
|
||||
.setId(userRequest.getId())
|
||||
.setStatus(Status.Error)
|
||||
.setMessage(errorMsg);
|
||||
}
|
||||
|
||||
log.debug("BankAccountNewRequest received");
|
||||
BankAccount bankAccount = new BankAccount();
|
||||
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
||||
bankAccount.setBankName(req.getBankName());
|
||||
bankAccount.setCorrespondentAccount(req.getCorrespondentAccount());
|
||||
bankAccount.setCorrespondentAccountName(req.getCorrespondentAccountName());
|
||||
bankAccount.setCurrency(req.getCurrency());
|
||||
bankAccount.setDestination(req.getDestination());
|
||||
bankAccount.setTaxpayerIdentificationNumber(req.getTaxpayerIdentificationNumber());
|
||||
bankAccount.setTaxRegistrationReasonCode(req.getTaxRegistrationReasonCode());
|
||||
bankAccount.setAccount(req.getAccount());
|
||||
bankAccount.setCompanyId(req.getCompanyId());
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(req.account);
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Bank.getKey());
|
||||
|
||||
String relationSqlCondition = String.format("consumerId = %s and service = %s", req.companyId,
|
||||
ru.spcex.platform.enumeration.Service.MKR.getKey());
|
||||
Relation relationByCompany = relationMap.getSingleObjectBySQL(relationSqlCondition);
|
||||
if (relationByCompany != null) {
|
||||
account.setRelationId(relationByCompany.getId());
|
||||
account.setCompanyId(relationByCompany.getConsumerId());
|
||||
if (req.getStatus() == null) {
|
||||
log.trace("Status not set in request. Use default: {}", account.getStatus());
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
} else {
|
||||
log.warn("Not found relation by condition: {}", relationSqlCondition);
|
||||
account.setStatus(req.getStatus());
|
||||
}
|
||||
account.setAccountStatus(AccountStatus.ACTIVE.getKey());
|
||||
account.setProcessingSign(Allowed.ALLOWED.getKey());
|
||||
account.setCreated(Instant.now());
|
||||
account.setUpdated(Instant.now());
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId(), false);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
accountMap.insert(account);
|
||||
Long bankAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
Imdg<BankAccount> bankAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
Imdg<Account> accountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
accountId = accountMap.insert(account);
|
||||
|
||||
bankAccount.setAccountId(account.getId());
|
||||
bankAccountMap.insert(bankAccount);
|
||||
log.debug("successfully processed, new id {}", bankAccount.getId());
|
||||
BankAccount bankAccount = new BankAccount();
|
||||
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
||||
bankAccount.setBankName(req.getBankName());
|
||||
bankAccount.setCorrespondentAccount(req.getCorrespondentAccount());
|
||||
bankAccount.setCorrespondentAccountName(req.getCorrespondentAccountName());
|
||||
bankAccount.setCurrency(req.getCurrency());
|
||||
bankAccount.setDestination(req.getDestination());
|
||||
bankAccount.setTaxpayerIdentificationNumber(req.getTaxpayerIdentificationNumber());
|
||||
bankAccount.setTaxRegistrationReasonCode(req.getTaxRegistrationReasonCode());
|
||||
bankAccount.setAccount(req.getAccount());
|
||||
bankAccount.setCompanyId(req.getCompanyId());
|
||||
bankAccount.setAccountId(accountId);
|
||||
bankAccountId = bankAccountMap.insert(bankAccount);
|
||||
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new bank account id {}, account id {}", bankAccountId, accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new bank account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
bankAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestInfoUpdate bankAccountUpdate(BaseRequest<BankAccountUpdateRequest> userRequest) {
|
||||
BankAccountUpdateRequest req = userRequest.getRequestPayload();
|
||||
log.debug("BankAccountUpdateRequest received id = {}", req.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, bankAccountUpdateRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
BankAccount bankAccount = bankAccountMap.getSingleObjectByID(req.getId());
|
||||
bankAccount.setBankIdentificationCode(req.getBankIdentificationCode());
|
||||
bankAccount.setBankName(req.getBankName());
|
||||
|
|
@ -163,24 +178,52 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
account.setAccount(req.account);
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
bankAccountMap.update(bankAccount);
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
Imdg<BankAccount> bankAccountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
Imdg<Account> accountMap = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
accountMap.update(account);
|
||||
bankAccountMap.update(bankAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new bank account id {}, account id {}",
|
||||
bankAccount.getId(),
|
||||
account.getId());
|
||||
} else {
|
||||
log.debug("failed update, bank account id {}, new account id {}",
|
||||
bankAccount.getId(),
|
||||
account.getId());
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
log.debug("successfully update, existing bankAccount with id {}", bankAccount.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestInfoUpdate bankAccountDelete(BaseRequest<CommonDeleteRequest> userRequest) {
|
||||
CommonDeleteRequest req = userRequest.getRequestPayload();
|
||||
log.debug("CommonDeleteRequest received id = {}", req.getId());
|
||||
private RequestInfoUpdate bankAccountBlock(BaseRequest<CommonIdRequest> userRequest) {
|
||||
CommonIdRequest req = userRequest.getRequestPayload();
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, bankAccountBlockRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
log.debug("CommonIdRequest received id = {}", req.getId());
|
||||
BankAccount bankAccount = bankAccountMap.getSingleObjectByID(req.getId());
|
||||
|
||||
Account account = accountMap.getSingleObjectByID(bankAccount.getAccountId());
|
||||
account.setAccountStatus(AccountStatus.BLOCKED.getKey());
|
||||
account.setStatus(ServiceStatus.Blocked.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountMap.update(account);
|
||||
bankAccountMap.delete(bankAccount);
|
||||
log.debug("successfully delete, existing bankAccount with id {}", bankAccount.getId());
|
||||
//без изменений bankAccountMap.update(bankAccount);
|
||||
|
||||
log.debug("successfully block, existing bankAccount with id {}", bankAccount.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,617 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutableTriple;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.classes.statics.data.misc.Notification;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf52;
|
||||
import ru.clearing.platform.dictionary.ClearingCategoryDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.NotificationFeedbackRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.NotificationNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.util.services.RequestHelper;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.collection.Pair;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
@Service
|
||||
public class ClearingAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final KafkaSender kafkaSender;
|
||||
private final AccountHelper accountService;
|
||||
private final SDFProcessService sdfProcessService;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final RequestHelper requestHelper;
|
||||
private final Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator;
|
||||
private final Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator;
|
||||
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private final Imdg<Company> companyImdg;
|
||||
private final Imdg<Relation> relationImdg;
|
||||
private final Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private final Imdg<ClearingCategoryDictionary> clearingCategoryImdg;
|
||||
private final Imdg<TradingClearingRegistry> tradingClearingRegistryImdg;
|
||||
private final Imdg<Notification> notificationImdg;
|
||||
|
||||
@Autowired
|
||||
public ClearingAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
KafkaSender kafkaSender,
|
||||
AccountHelper accountService,
|
||||
SDFProcessService sdfProcessService,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
IMessageResolver messageResolver,
|
||||
RequestHelper requestHelper,
|
||||
@Qualifier("clearingAccountNewRequestValidator")
|
||||
Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator,
|
||||
@Qualifier("clearingAccountUpdateRequestValidator")
|
||||
Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.accountService = accountService;
|
||||
this.sdfProcessService = sdfProcessService;
|
||||
this.validationHelper = validationHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.messageResolver = messageResolver;
|
||||
this.requestHelper = requestHelper;
|
||||
this.clearingAccountNewRequestValidator = clearingAccountNewRequestValidator;
|
||||
this.clearingAccountUpdateRequestValidator = clearingAccountUpdateRequestValidator;
|
||||
|
||||
this.accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.clearingAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
this.companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.relationImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
||||
this.clearingMemberCategoryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||
this.clearingCategoryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingCategoryDictionary, ClearingCategoryDictionary.class);
|
||||
this.tradingClearingRegistryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
this.notificationImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Notification, Notification.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
callback(ClearingAccountNewRequest.class)
|
||||
.setFunction(this::clearingAccountNew)
|
||||
.forDestination(Consts.DESTINATION_CLEARING_ACCOUNT_NEW, callbacks::put);
|
||||
callback(ClearingAccountUpdateRequest.class)
|
||||
.setFunction(this::clearingAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_CLEARING_ACCOUNT_UPDATE, callbacks::put);
|
||||
callback(AccountSdf01Request.class)
|
||||
.setFunction(this::accountNewSdf01)
|
||||
.forDestination(Consts.ACCOUNT_NEW_SDF01, callbacks::put);
|
||||
|
||||
callback(StatementRequest.class)
|
||||
.setFunction(this::accountUpdateSdf52)
|
||||
.forDestination(Consts.ACCOUNT_PROCESS_SDF52, callbacks::put);
|
||||
callback(NotificationFeedbackRequest.class)
|
||||
.setFunction(this::accountUpdateSdf52_part2Notification)
|
||||
.forDestination(Consts.ACCOUNT_NOTIFICATION_FEEDBACK, callbacks::put);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public RequestInfoUpdate clearingAccountNew(BaseRequest<ClearingAccountNewRequest> userRequest) {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(
|
||||
userRequest, clearingAccountNewRequestValidator
|
||||
);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ClearingAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
if (req.getStatus() == null) {
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
log.trace("Status not set in request. Use default: {}", account.getStatus());
|
||||
} else {
|
||||
account.setStatus(req.getStatus());
|
||||
}
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId(), true);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long clearingAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
ClearingAccount clearingAccount = null;
|
||||
try {
|
||||
Imdg<Account> accountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<ClearingAccount> clearingAccountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
clearingAccount = new ClearingAccount();
|
||||
clearingAccount.setCompanyId(req.getCompanyId());
|
||||
clearingAccount.setAccountId(accountId);
|
||||
clearingAccount.setClearingAccountType(req.getClearingAccountType());
|
||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new clearing account id {}, account id {}", clearingAccountId, accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new clearing account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
clearingAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate clearingAccountUpdate(BaseRequest<ClearingAccountUpdateRequest> userRequest) {
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(
|
||||
userRequest, clearingAccountUpdateRequestValidator
|
||||
);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ClearingAccountUpdateRequest req = userRequest.getRequestPayload();
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
Imdg<Account> accountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<ClearingAccount> clearingAccountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
ImdgPredicate accountValuePredicate = pb.equals("account", req.getAccount());
|
||||
ImdgPredicate accountStatusPredicate = pb.equals("status", ServiceStatus.Active.getKey());
|
||||
ImdgPredicate accountTypePredicate = pb.equals("accountType", AccountType.Clrn.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
|
||||
Account account = accountImdg.getCollectionObjectsByPredicate(finalPredicate).iterator().next();
|
||||
Long accountId = account.getId();
|
||||
|
||||
ClearingAccount clearingAccount = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", accountId));
|
||||
if (clearingAccount == null)
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.AccountNotFound, account.getAccount());
|
||||
|
||||
Integer statusValue = req.getStatus();
|
||||
if (statusValue == 0) account.setStatus(ServiceStatus.Blocked.getKey());
|
||||
else if (statusValue == 1) account.setStatus(ServiceStatus.Active.getKey());
|
||||
else if (statusValue == 2) account.setStatus(ServiceStatus.Closed.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
accountImdg.update(account);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) imdgTransaction.commitTransaction();
|
||||
else imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public RequestInfoUpdate accountNewSdf01(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
log.debug("AccountSdf01Request received, id={}", userRequest.getId());
|
||||
|
||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
Imdg<Account> accountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<ClearingAccount> clearingAccountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
|
||||
accountsLoop:
|
||||
for (AccountSdfRequestPart accountReq : req.getAccounts()) {
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountReq.getAccount());
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setCompanyId(accountReq.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
RequestInfoUpdate requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId(), true);
|
||||
if (requestInfoUpdate != null) {
|
||||
log.warn("Error fill new account from relation. {}", /*account.getId(),*/ requestInfoUpdate.getMessage());
|
||||
{
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(accountReq.getSdfId());
|
||||
responsePart.setErrorCode(AccountError.ClearingCategoryNotFound.getId()); // see accountService.fillAccountFromRelation
|
||||
responsePart.setErrorText(requestInfoUpdate.getMessage());
|
||||
accountToStatement.add(responsePart);
|
||||
continue accountsLoop;
|
||||
}
|
||||
}
|
||||
|
||||
if (accountImdg.getFirstObjectBySQL("account = '%s'".formatted(accountReq.getAccount())) != null) {
|
||||
log.debug("Account {} already exists", accountReq.getAccount());
|
||||
{
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(accountReq.getSdfId());
|
||||
responsePart.setErrorCode(null);
|
||||
responsePart.setErrorText(null);
|
||||
accountToStatement.add(responsePart);
|
||||
continue accountsLoop;
|
||||
}
|
||||
}
|
||||
|
||||
Long clearingAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ClearingAccount clearingAccount = null;
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
clearingAccount = new ClearingAccount();
|
||||
clearingAccount.setCompanyId(accountReq.getCompanyId());
|
||||
clearingAccount.setAccountId(accountId);
|
||||
clearingAccount.setClearingAccountType(accountReq.getAccountType());
|
||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||
log.debug("New account {}, clearingAccount {} was created.", accountId, clearingAccountId);
|
||||
|
||||
{
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(accountReq.getSdfId());
|
||||
responsePart.setErrorCode(null);
|
||||
responsePart.setErrorText(null);
|
||||
accountToStatement.add(responsePart);
|
||||
}
|
||||
}
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
} else {
|
||||
log.debug("failed insert, new clearing accounts. Request id={}", userRequest.getId());
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sendStatementRequestBack(req.getGroupingSdf01Id(), req.getGroupingSdf02Id(), accountToStatement);
|
||||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate accountUpdateSdf52(BaseRequest<StatementRequest> systemRequest) {
|
||||
log.debug("accountUpdateSdf52 StatementRequest received, id={}", systemRequest.getId());
|
||||
|
||||
StatementRequest req = systemRequest.getRequestPayload();
|
||||
Long groupId = req.getGroupId();
|
||||
if (SdfTable.SDF_52 != req.getTable()) {
|
||||
log.warn("Unsupported table {} received on accountUpdateSdf52. Expected only {}.",
|
||||
req.getTable(), SdfTable.SDF_52);
|
||||
}
|
||||
Collection<SDf52> sdfs = sdfProcessService.sdfsByGroupId(groupId);
|
||||
if (sdfs.isEmpty()) {
|
||||
log.info("Do not processing SDF52: S_DF52 not found by groupId={}", groupId);
|
||||
return null;
|
||||
}
|
||||
log.info("start processing {} SDF52: groupId={}", sdfs.size(), groupId);
|
||||
|
||||
List<Pair<SDf52, Account>> toUpdate = new ArrayList<>();
|
||||
List<Triple<SDf52, Account, String>> toProcessSDF53 = new ArrayList<>();
|
||||
{ // 1. Выборка данных
|
||||
for (SDf52 sDf52 : sdfs) {
|
||||
if (sdfProcessService.parseSdf52Status(sDf52.getStatus()) == null) {
|
||||
String msg = messageResolver.resolve(new EnumMessage(AccountError.WrongFieldValue, "status"));
|
||||
log.warn("By generationId={} s_df52[{}] error: {}", groupId, sDf52.getId(), msg);
|
||||
toProcessSDF53.add(new MutableTriple<>(sDf52, null,
|
||||
makeSdfErrorText(AccountError.WrongFieldValue, SDFProcessService.SDF_STATUS_ERROR)));
|
||||
continue;
|
||||
}
|
||||
Company company = sDf52.getDeal() == null ? null : companyImdg.getSingleObjectByFieldValues(Map.of("tradingCode", sDf52.getDeal()));
|
||||
if (company == null) {
|
||||
String msg = messageResolver.resolve(new EnumMessage(AccountError.CompanyNotFound, sDf52.getDeal()));
|
||||
log.warn("By generationId={} s_df52[{}] error: {}", groupId, sDf52.getId(), msg);
|
||||
toProcessSDF53.add(new MutableTriple<>(sDf52, null,
|
||||
makeSdfErrorText(AccountError.CompanyNotFound, SDFProcessService.SDF_STATUS_ERROR_COMPANY_NOT_FOUND)));
|
||||
continue;
|
||||
}
|
||||
Map<String, Comparable<?>> accountQuery = Map.of(
|
||||
"accountType", AccountType.Clrn.getKey(),
|
||||
"account", sDf52.getAccount(),
|
||||
"companyId", company.getId()
|
||||
);
|
||||
Account account = sDf52.getAccount() == null ? null : accountImdg.getFirstObjectByFieldValues(accountQuery);
|
||||
if (account == null) {
|
||||
if (SDFProcessService.SDF52_STATUS_3Open.equals(sDf52.getStatus())) {
|
||||
log.debug("By generationId={} s_df52[{}].status={}, but account not found (query: {}). COntinuse with result OK for status 3",
|
||||
groupId, sDf52.getId(), sDf52.getStatus(), accountQuery);
|
||||
} else {
|
||||
String msg = messageResolver.resolve(new EnumMessage(AccountError.AccountNotFound, sDf52.getAccount()));
|
||||
log.warn("By generationId={} s_df52[{}] (query: {}) error: {}", groupId, sDf52.getId(), accountQuery, msg);
|
||||
toProcessSDF53.add(new MutableTriple<>(sDf52, null,
|
||||
makeSdfErrorText(AccountError.AccountNotFound, SDFProcessService.SDF_STATUS_ERROR_COMPANY_NOT_FOUND)));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
toProcessSDF53.add(new MutableTriple<>(sDf52, account, SDFProcessService.SDF_STATUS_OK));
|
||||
toUpdate.add(new Pair<>(sDf52, account));
|
||||
}
|
||||
}
|
||||
log.debug("Selected to update {} account's", toUpdate.size());
|
||||
|
||||
// 4. to notification
|
||||
List<Long> notificationAccountIds = new ArrayList<>();
|
||||
for (Pair<SDf52, Account> item : toUpdate) {
|
||||
SDf52 sdf = item.getFirst();
|
||||
Account account = item.getSecond();
|
||||
AccountStatus newStatus = sdfProcessService.parseSdf52Status(sdf.getStatus());
|
||||
if (newStatus == null) { // never
|
||||
throw new IllegalArgumentException("Can not parse sdf status " + sdf.getStatus());
|
||||
}
|
||||
if (newStatus.equalsByKey(account.getStatus())) {
|
||||
// одинаковых обычно не бывает.
|
||||
continue;
|
||||
}
|
||||
if (AccountStatus.BLOCKED == newStatus || AccountStatus.CLOSE == newStatus) { // статус 0/2
|
||||
sendNotificationRequest(ObjectType.account_block, account, newStatus);
|
||||
notificationAccountIds.add(account.getId());
|
||||
putNotificationWaiting(systemRequest, item.getFirst(), item.getSecond());
|
||||
}
|
||||
if (AccountStatus.ACTIVE == newStatus) { // статус 1/3
|
||||
sendNotificationRequest(ObjectType.account_active, account, newStatus);
|
||||
notificationAccountIds.add(account.getId());
|
||||
putNotificationWaiting(systemRequest, item.getFirst(), item.getSecond());
|
||||
}
|
||||
}
|
||||
sdfProcessService.process(req, toProcessSDF53);
|
||||
|
||||
log.info("{} account's need wait accept over notification. GroupId={}", notificationAccountIds.size(), groupId);
|
||||
|
||||
log.debug("successfully processed, grouping id={} with {} accounts.",
|
||||
groupId, toUpdate.size());
|
||||
return null;
|
||||
}
|
||||
|
||||
protected RequestInfoUpdate accountUpdateSdf52_part2Notification(BaseRequest<NotificationFeedbackRequest> secondSystemRequest2) {
|
||||
log.debug("accountUpdateSdf52 NotificationFeedbackRequest received, id={}", secondSystemRequest2.getId());
|
||||
SDF52WaitingData trigger = onNotificationResponse(secondSystemRequest2.getRequestPayload());
|
||||
if (trigger == null) {
|
||||
log.trace("Not triggered, continue waiting");
|
||||
return null;
|
||||
} else {
|
||||
log.debug("Triggered, groupId={}, notification's status: {}, last notification user id={}",
|
||||
trigger.getGroupId(), trigger.globalStatus, secondSystemRequest2.getUserId());
|
||||
if (NotificationStatus.ACPT.equalsByKey(trigger.globalStatus)) {
|
||||
return accountUpdateSdf52_part2(trigger.systemRequest, trigger.sdf, trigger.account, secondSystemRequest2);
|
||||
} else if (NotificationStatus.CNCL.equalsByKey(trigger.globalStatus)) {
|
||||
log.debug("groupId={} rejected by user {}.", trigger.getGroupId(), secondSystemRequest2.getUserId());
|
||||
return null;
|
||||
} else {
|
||||
log.warn("Unknown waiting group status \"{}\"", trigger.globalStatus);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected RequestInfoUpdate accountUpdateSdf52_part2(BaseRequest<StatementRequest> systemRequest1,
|
||||
SDf52 sdf, Account account,
|
||||
BaseRequest<NotificationFeedbackRequest> secondSystemRequest2) {
|
||||
// 5. from notification:
|
||||
StatementRequest req = systemRequest1.getRequestPayload();
|
||||
Long groupId = req.getGroupId();
|
||||
log.info("Continue Sdf52 groupId={}, first request id={}, second request id={}",
|
||||
groupId, systemRequest1 == null ? null : systemRequest1.getId(), secondSystemRequest2 == null ? null : secondSystemRequest2.getId());
|
||||
|
||||
int countOfUpdated = 0;
|
||||
|
||||
// 2. обновление данных
|
||||
Instant now = Instant.now();
|
||||
AccountStatus newStatus = sdfProcessService.parseSdf52Status(sdf.getStatus());
|
||||
if (newStatus == null) {
|
||||
throw new IllegalArgumentException("Can not parse sdf status " + sdf.getStatus());
|
||||
}
|
||||
// За долгое время ожидания пользователя счёт мог быть обновлён, прочитать его ещё раз
|
||||
account = accountImdg.getSingleObjectByID(account.getId());
|
||||
if (!newStatus.equalsByKey(account.getStatus())) {
|
||||
// Обновление счёта
|
||||
String oldStatus = account.getStatus();
|
||||
account.setStatus(newStatus.getKey());
|
||||
account.setUpdated(now);
|
||||
accountImdg.update(account);
|
||||
log.trace("S_DF52[{}] do update status to {} for account[{}]",
|
||||
sdf.getId(), newStatus.getKey(), account.getId());
|
||||
if (AccountStatus.ACTIVE.equalsByKey(oldStatus) && AccountStatus.ACTIVE != newStatus) { // счёт заблокировали - значит блокируем ТКР, наоборот не надо.
|
||||
// Отправка в ТКР
|
||||
TradingClearingRegistryUpdateRequest tcrReq = new TradingClearingRegistryUpdateRequest();
|
||||
tcrReq.setMoneyAccountId(account.getId());
|
||||
tcrReq.setCompanyId(account.getCompanyId());
|
||||
tcrReq.setStatus(account.getStatus());
|
||||
Map<String, Long> queryTCR = new HashMap<>();
|
||||
queryTCR.put("moneyAccountId", tcrReq.getMoneyAccountId());
|
||||
if (tcrReq.getCompanyId() != null)
|
||||
queryTCR.put("companyId", tcrReq.getCompanyId());
|
||||
TradingClearingRegistry tcr = tradingClearingRegistryImdg.getFirstObjectByFieldValues(queryTCR);
|
||||
if (tcr == null) {
|
||||
log.warn("TradingClearingRegistry by {} not found, do not send update TCR.", queryTCR);
|
||||
} else {
|
||||
tcrReq.setId(tcr.getId());
|
||||
String destination = Consts.DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE;
|
||||
log.debug("Send message to kafka \"{}\": {}", destination, LogFormatter.toStringWrapper(tcrReq));
|
||||
kafkaSender.sendRequestToQueue(destination, tcrReq);
|
||||
}
|
||||
}
|
||||
countOfUpdated++;
|
||||
} else {
|
||||
log.info("Account[{}] \"{}\" do not updated - same status \"{}\"", account.getId(), account.getAccount(), newStatus);
|
||||
}
|
||||
|
||||
log.debug("successfully processed, grouping id={}. Updated {} accounts.",
|
||||
groupId, countOfUpdated);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String makeSdfErrorText(IErrorEnumId clrError, String sdfCode) {
|
||||
if (clrError == null) return sdfCode;
|
||||
sdfCode = clrError.getId().toString();
|
||||
if (sdfCode.length() > 3)
|
||||
sdfCode = sdfCode.substring(sdfCode.length() - 3);
|
||||
return sdfCode;
|
||||
}
|
||||
|
||||
public void sendStatementRequestBack(Long groupingSdf01Id, Long groupSdf02Id, List<AccountSdfToStatementRequestPart> results) {
|
||||
final String destination = Consts.STATEMENT_PROCESS;
|
||||
StatementRequest request = new StatementRequest();
|
||||
request.setGroupId(groupingSdf01Id);
|
||||
request.setChildGenerationId(groupSdf02Id);
|
||||
request.setAccountCreationResults(results);
|
||||
request.setContinueSdf(true);
|
||||
request.setTable(SdfTable.SDF_01); // по нему запрос получили
|
||||
log.debug("Send message to kafka \"{}\": {}", destination, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(destination, request);
|
||||
}
|
||||
|
||||
public Long sendNotificationRequest(ObjectType objectType, Account account, AccountStatus requestToStatus) {
|
||||
String statusText = AccountStatus.BLOCKED == requestToStatus ? "Заблокирован"
|
||||
: AccountStatus.CLOSE == requestToStatus ? "Закрыт"
|
||||
: AccountStatus.ACTIVE == requestToStatus ? "Разблокирован" :
|
||||
requestToStatus.getKey();
|
||||
String message = String.format("Для счета %s будет изменен статус на «%s»", account.getAccount(), statusText);
|
||||
final String destination = Consts.NOTIFICATION_NEW;
|
||||
NotificationNewRequest request = new NotificationNewRequest();
|
||||
request.setObjectType(objectType.getKey());
|
||||
request.setObjectId(account.getId());
|
||||
request.setPriority(Priority.HIGH.getKey());
|
||||
request.setComment(message);
|
||||
log.debug("Send message to kafka \"{}\": {}", destination, LogFormatter.toStringWrapper(request));
|
||||
Long rKey = kafkaSender.sendRequestToQueue(destination, request);
|
||||
log.trace("About account.id={} send notification request id={}", account.getId(), rKey);
|
||||
return rKey;
|
||||
}
|
||||
|
||||
|
||||
// --------- notification apply system -----------
|
||||
public static class SDF52WaitingData {
|
||||
public BaseRequest<StatementRequest> systemRequest;
|
||||
public SDf52 sdf;
|
||||
public Account account;
|
||||
public Long notAnsweredAccountId;
|
||||
public String globalStatus;
|
||||
|
||||
public SDF52WaitingData(BaseRequest<StatementRequest> systemRequest, SDf52 sdf, Account account) {
|
||||
this.systemRequest = systemRequest;
|
||||
this.sdf = sdf;
|
||||
this.account = account;
|
||||
this.notAnsweredAccountId = account.getId();
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
if (systemRequest != null && systemRequest.getRequestPayload() != null)
|
||||
return systemRequest.getRequestPayload().getGroupId();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected ConcurrentHashMap<Long, SDF52WaitingData> waitingList = new ConcurrentHashMap<>();
|
||||
|
||||
public boolean putNotificationWaiting(BaseRequest<StatementRequest> systemRequest, SDf52 sdf, Account account) {
|
||||
SDF52WaitingData data = new SDF52WaitingData(systemRequest, sdf, account);
|
||||
if (waitingList.contains(data.notAnsweredAccountId)) {
|
||||
log.warn("groupId={} accountId={} already waiting", data.getGroupId(), data.notAnsweredAccountId);
|
||||
}
|
||||
data.globalStatus = null;
|
||||
waitingList.put(data.notAnsweredAccountId, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return triggered SDF52WaitingData or null
|
||||
*/
|
||||
public SDF52WaitingData onNotificationResponse(NotificationFeedbackRequest onNotification) {
|
||||
if (onNotification.getNotificationId() == null) {
|
||||
log.trace("notificationId was empty");
|
||||
return null;
|
||||
}
|
||||
Notification notification = notificationImdg.getSingleObjectByID(onNotification.getNotificationId());
|
||||
if (notification == null) {
|
||||
log.warn("Notification with id={} not exist", onNotification.getNotificationId());
|
||||
return null;
|
||||
}
|
||||
if (!ObjectType.account_active.equalsByKey(notification.getObjectType()) && !ObjectType.account_block.equalsByKey(notification.getObjectType())) {
|
||||
log.warn("Notification[{}].objectType={} not supported", notification.getId(), notification.getObjectType());
|
||||
return null;
|
||||
}
|
||||
if (notification.getObjectId() == null) {
|
||||
log.warn("Notification[{}] with empty objectId", notification.getId());
|
||||
return null;
|
||||
}
|
||||
final Long accountId = notification.getObjectId();
|
||||
log.trace("Match accountId={} by notificationId={}", accountId, notification.getId());
|
||||
SDF52WaitingData inWaitingLst = waitingList.get(accountId);
|
||||
if (inWaitingLst == null) {
|
||||
log.debug("SDF52 waiting list (count {}) not found for accountId={}", waitingList.size(), accountId);
|
||||
return null;
|
||||
}
|
||||
boolean returnTrigger = false;
|
||||
if (NotificationStatus.ACPT.equalsByKey(onNotification.getNotificationStatus())) {
|
||||
log.trace("Triggered ACPT, by accountId={}", accountId);
|
||||
inWaitingLst.globalStatus = onNotification.getNotificationStatus();
|
||||
returnTrigger = true;
|
||||
} else if (NotificationStatus.CNCL.equalsByKey(onNotification.getNotificationStatus())) {
|
||||
log.trace("Triggered CNCL, by accountId={}", accountId);
|
||||
inWaitingLst.globalStatus = onNotification.getNotificationStatus();
|
||||
returnTrigger = true;
|
||||
} else {
|
||||
log.warn("Unknown notification[{}] status={}", onNotification.getNotificationId(), onNotification.getNotificationStatus());
|
||||
}
|
||||
if (returnTrigger) {
|
||||
log.debug("Remove from waiting list accountId={} (list groupId={})", accountId, inWaitingLst.getGroupId());
|
||||
waitingList.remove(inWaitingLst);
|
||||
}
|
||||
if (returnTrigger)
|
||||
return inWaitingLst;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,440 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.apache.kafka.clients.producer.RecordMetadata;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.ClientCode;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.util.services.RequestHelper;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.TradingClearingRegistryType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class ClientCodeService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Producer<String, Object> kafkaProducer;
|
||||
private final ImdgId idGenerator;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Imdg<ClientCode> clientCodeMap;
|
||||
private final Imdg<TradingClearingRegistry> tradingClearingRegistryMap;
|
||||
|
||||
|
||||
private final Function<ClientCodeNewRequest, IValidator> clientCodeNewRequestValidator;
|
||||
private final Function<ClientCodeUpdateRequest, IValidator> clientCodeUpdateRequestValidator;
|
||||
private final Function<CommonDeleteRequest, IValidator> clientCodeDeleteRequestValidator;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final RequestHelper requestHelper;
|
||||
|
||||
protected TradingClearingRegistryService tradingClearingRegistryService;
|
||||
|
||||
@Autowired
|
||||
public ClientCodeService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
ValidationHelper validationHelper,
|
||||
IMessageResolver messageResolver,
|
||||
RequestHelper requestHelper,
|
||||
TradingClearingRegistryService tradingClearingRegistryService,
|
||||
UserRoleVerification userRoleVerification,
|
||||
@Qualifier("clientCodeNewRequestValidator") Function<ClientCodeNewRequest, IValidator> clientCodeNewRequestValidator,
|
||||
@Qualifier("clientCodeUpdateRequestValidator") Function<ClientCodeUpdateRequest, IValidator> clientCodeUpdateRequestValidator,
|
||||
@Qualifier("clientCodeDeleteRequestValidator") Function<CommonDeleteRequest, IValidator> clientCodeDeleteRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.kafkaProducer = kafkaProducer;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.idGenerator = imdgProvider.getImdgIdGenerator();
|
||||
this.clientCodeMap = imdgProvider.getImdg(IMDGDistributedNames.Map_ClientCode, ClientCode.class);
|
||||
this.tradingClearingRegistryMap = imdgProvider.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
this.clientCodeNewRequestValidator = clientCodeNewRequestValidator;
|
||||
this.clientCodeUpdateRequestValidator = clientCodeUpdateRequestValidator;
|
||||
this.clientCodeDeleteRequestValidator = clientCodeDeleteRequestValidator;
|
||||
this.validationHelper = validationHelper;
|
||||
this.requestHelper = requestHelper;
|
||||
this.messageResolver = messageResolver;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.tradingClearingRegistryService = tradingClearingRegistryService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
imdgProvider.waitAvailable();
|
||||
|
||||
callback(ClientCodeNewRequest.class)
|
||||
.setFunction(this::clientCodeNew)
|
||||
.forDestination(Consts.DESTINATION_CLIENT_CODE_NEW, callbacks::put);
|
||||
callback(ClientCodeNewRequest.class)
|
||||
.setFunction(this::clientCodeNewFromApiUmCompany)
|
||||
.forDestination(Consts.DESTINATION_CLIENT_CODE_NEW_UM_COMPANY, callbacks::put);
|
||||
|
||||
callback(ClientCodeUpdateRequest.class)
|
||||
.setFunction(this::clientCodeUpdate)
|
||||
.forDestination(Consts.DESTINATION_CLIENT_CODE_UPDATE, callbacks::put);
|
||||
callback(CommonDeleteRequest.class)
|
||||
.setFunction(this::clientCodeDelete)
|
||||
.forDestination(Consts.DESTINATION_CLIENT_CODE_DELETE, callbacks::put);
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверки
|
||||
* 3.5.1 если не была найдена запись в tradingClearingRegistry по companyId, moneyAccountId, depoAccountId и tradingClearingRegistryType=B (п 3.5.1)
|
||||
* 3.5.2 если не заполнены поля moneyAccountId ИЛИ moneyAccountId и depoAccountId
|
||||
* @param userRequest
|
||||
* @param moneyAccountId req.getMoneyAccountId()
|
||||
* @param depoAccountId req.getDepoAccountId()
|
||||
* @param companyId req.getCompanyId()
|
||||
* @return
|
||||
*/
|
||||
RequestInfoUpdate crossValidate(BaseRequest<?> userRequest, Long moneyAccountId, Long depoAccountId, Long companyId) {
|
||||
if (moneyAccountId == null) { // Если не заполнены moneyAccountId ИЛИ moneyAccountId и depoAccountId
|
||||
EnumMessage error = null;
|
||||
if (companyId == null) {
|
||||
error = new EnumMessage(AccountError.RequiredFieldEmpty, "companyId");
|
||||
} else {
|
||||
TradingClearingRegistry tcr = tradingClearingRegistryMap.getFirstObjectByFieldValues(Map.of("companyId", companyId));
|
||||
if (tcr==null) {
|
||||
error=new EnumMessage(AccountError.TradingClearingRegistryNotFound, companyId);
|
||||
}
|
||||
}
|
||||
if (error != null) {
|
||||
return requestHelper.makeErrorResponse(userRequest, error);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected RequestInfoUpdate clientCodeNew(BaseRequest<ClientCodeNewRequest> userRequest) {
|
||||
log.debug("ClientCodeNewRequest received {}", userRequest.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, clientCodeNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ClientCodeNewRequest req = userRequest.getRequestPayload();
|
||||
// дополнительная проверка
|
||||
requestInfoUpdate = crossValidate(userRequest, req.getMoneyAccountId(), req.getDepoAccountId(), req.getCompanyId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (doCreateTCR) {
|
||||
try {
|
||||
requestInfoUpdate = createAndWaitTCR(userRequest.getId(), null,
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
} catch (Exception e) {
|
||||
log.error("Can not wait creation of TCR. request id={};CompanyId={}, MoneyAccountId={}, DepoAccountId={}; {}",
|
||||
userRequest.getId(), req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId(),
|
||||
e.toString());
|
||||
return makeErrorResponse(userRequest, AccountError.GeneralError, "Can not create TCR: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
ClientCode newClientCode = buildClientCode(req);
|
||||
clientCodeMap.insert(newClientCode);
|
||||
log.debug("successfully processed, new clientCode id {}", newClientCode.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected RequestInfoUpdate clientCodeNewFromApiUmCompany(BaseRequest<ClientCodeNewRequest> userRequest) {
|
||||
log.debug("ClientCodeNewRequest (UM_COMPANY) received {}", userRequest.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, clientCodeNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
|
||||
ClientCodeNewRequest req = userRequest.getRequestPayload();
|
||||
// дополнительная проверка
|
||||
requestInfoUpdate = crossValidate(userRequest, req.getMoneyAccountId(), req.getDepoAccountId(), req.getCompanyId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (doCreateTCR) {
|
||||
try {
|
||||
requestInfoUpdate = createAndWaitTCR(userRequest.getId(), null,
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
} catch (Exception e) {
|
||||
log.error("Can not wait creation of TCR. request id={};CompanyId={}, MoneyAccountId={}, DepoAccountId={}; {}",
|
||||
userRequest.getId(), req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId(),
|
||||
e.toString());
|
||||
return makeErrorResponse(userRequest, AccountError.GeneralError, "Can not create TCR at this moment" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
ClientCode newClientCode = buildClientCode(req);
|
||||
clientCodeMap.insert(newClientCode);
|
||||
log.debug("successfully processed, new clientCode id {}", newClientCode.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected RequestInfoUpdate clientCodeUpdate(BaseRequest<ClientCodeUpdateRequest> userRequest) {
|
||||
ClientCodeUpdateRequest req = userRequest.getRequestPayload();
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, clientCodeUpdateRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
// дополнительная проверка
|
||||
requestInfoUpdate = crossValidate(userRequest, req.getMoneyAccountId(), req.getDepoAccountId(), req.getCompanyId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
|
||||
log.debug("ClientCodeUpdateRequest received, id={}", req.getId());
|
||||
ClientCode clientCode = clientCodeMap.getSingleObjectByID(req.getId());
|
||||
if (clientCode == null) {
|
||||
return makeErrorResponse(userRequest, AccountError.RecordNotFound, req.getId());
|
||||
}
|
||||
|
||||
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (doCreateTCR) {
|
||||
try {
|
||||
requestInfoUpdate = createAndWaitTCR(userRequest.getId(), clientCode.getId(),
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
} catch (Exception e) {
|
||||
log.error("Can not wait creation of TCR. request id={};CompanyId={}, MoneyAccountId={}, DepoAccountId={}; {}",
|
||||
userRequest.getId(), req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId(),
|
||||
e.toString());
|
||||
return makeErrorResponse(userRequest, AccountError.GeneralError, "Can not create TCR: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
updateClientCode(clientCode, req);
|
||||
|
||||
clientCodeMap.update(clientCode);
|
||||
log.debug("successfully processed update, id {}", clientCode.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
private RequestInfoUpdate makeErrorResponse(BaseRequest<?> req, AccountError err, Object... arg) {
|
||||
return requestHelper.makeErrorResponse(req, err, arg);
|
||||
}
|
||||
|
||||
protected RequestInfoUpdate clientCodeDelete(BaseRequest<CommonDeleteRequest> userRequest) {
|
||||
log.debug("CommonDeleteRequest received id = {}", userRequest.getId());
|
||||
CommonDeleteRequest req = userRequest.getRequestPayload();
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, clientCodeDeleteRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ClientCode clientCode = clientCodeMap.getSingleObjectByID(req.getId());
|
||||
if (clientCode.getMoneyAccountId() != null) {
|
||||
log.debug("Blocking clientCode.id = {}: send message to account-service", clientCode.getId());
|
||||
sendBlockTCR(clientCode.getTradingClearingRegistryId(), clientCode.getMoneyAccountId());
|
||||
}
|
||||
log.debug("Blocking clientCode.id={}", clientCode.getId());
|
||||
clientCode.setUpdated(Instant.now());
|
||||
clientCode.setStatus(WorkflowStatus.Blocked.getKey());
|
||||
clientCodeMap.update(clientCode);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
TradingClearingRegistry selectTradingClearingRegistry(Long companyId, Long moneyAccountId, Long depoAccountId) {
|
||||
Map<String, Comparable<?>> query = new HashMap<>();
|
||||
query.put("companyId", companyId);
|
||||
query.put("moneyAccountId", moneyAccountId);
|
||||
query.put("tradingClearingRegistryType", TradingClearingRegistryType.Client_B.getKey());
|
||||
if (depoAccountId != null) {
|
||||
query.put("depoAccountId", depoAccountId);
|
||||
}
|
||||
TradingClearingRegistry result = tradingClearingRegistryMap.getFirstObjectByFieldValues(query);
|
||||
log.trace("TradingClearingRegistry by: {}; {}found", query, result == null ? "not " : "");
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean checkNeedCreateTCR(Long companyId, Long moneyAccountId, Long depoAccountId) {
|
||||
// moneyAccountId обязателен, depoAccountId опционален
|
||||
if (moneyAccountId == null) {
|
||||
return false;
|
||||
}
|
||||
TradingClearingRegistry result = selectTradingClearingRegistry(companyId, moneyAccountId, depoAccountId);
|
||||
if (result == null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected RequestInfoUpdate createAndWaitTCR(Long reqId, Long clientCode,
|
||||
Long companyId, Long moneyAccountId, Long depoAccountId) {
|
||||
log.debug("For request {}, clientCode={} need create TCR: companyId={}, moneyAccountId={}, depoAccountId={}",
|
||||
reqId, clientCode == null ? "new" : clientCode,
|
||||
companyId, moneyAccountId, depoAccountId);
|
||||
BaseRequest<TradingClearingRegistryNewRequest> request = new BaseRequest<>();
|
||||
request.setId(idGenerator.nextId());
|
||||
request.setActionType(ActionType.NEW);
|
||||
TradingClearingRegistryNewRequest requestPayload = new TradingClearingRegistryNewRequest();
|
||||
requestPayload.setCompanyId(companyId);
|
||||
requestPayload.setMoneyAccountId(moneyAccountId);
|
||||
requestPayload.setDepoAccountId(depoAccountId);
|
||||
// requestPayload.setStatus(WorkflowStatus.Active.getKey());
|
||||
requestPayload.setTradingClearingRegistryType(TradingClearingRegistryType.Client_B.getKey());
|
||||
request.setRequestPayload(requestPayload);
|
||||
|
||||
// Следующий вызываемый метод обязательно должен быть synchronized.
|
||||
RequestInfoUpdate reply = tradingClearingRegistryService.tradingClearingRegistryNew(request);
|
||||
if (reply != null && Status.Error.equals(reply.getStatus())) {
|
||||
log.warn("tradingClearingRegistryService return error: " + reply.getMessage());
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
protected void sendBlockTCR(Long tradingClearingRegistryId, Long moneyAccountId) {
|
||||
if (tradingClearingRegistryId == null) {
|
||||
throw new IllegalArgumentException("tradingClearingRegistryId was null");
|
||||
}
|
||||
BaseRequest<TradingClearingRegistryUpdateRequest> request = new BaseRequest<>();
|
||||
request.setId(idGenerator.nextId());
|
||||
request.setActionType(ActionType.UPDATE);
|
||||
TradingClearingRegistryUpdateRequest requestPayload = new TradingClearingRegistryUpdateRequest();
|
||||
requestPayload.setId(tradingClearingRegistryId);
|
||||
requestPayload.setStatus(WorkflowStatus.Blocked.getKey());
|
||||
request.setRequestPayload(requestPayload);
|
||||
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE, LogFormatter.toStringWrapper(request));
|
||||
try {
|
||||
sendMessage(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE, request);
|
||||
} catch (Exception e) {
|
||||
log.error("Can not send block TCR message, {}", e.toString());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param queue Consts.*
|
||||
* @param message BaseRequest
|
||||
* @return
|
||||
*/
|
||||
private Long sendMessage(String queue, BaseRequest<?> message) {
|
||||
Long sentRequestId = message.getId();
|
||||
if (sentRequestId == null) {
|
||||
throw new IllegalArgumentException("Message " + message.getClass().getSimpleName() + " required id.");
|
||||
}
|
||||
log.debug("Send to \"{}\" message {} id={}", queue, message.getActionType(), sentRequestId);
|
||||
try {
|
||||
Future<RecordMetadata> send = kafkaProducer.send(new ProducerRecord<>(queue, message));
|
||||
send.get();
|
||||
return sentRequestId;
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Interrupt when send message, {}", ExceptionUtils.getStackTrace(e));
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException("Thread interrupted when send message to " + queue, e);
|
||||
} catch (ExecutionException e) {
|
||||
log.error("Error at send message, {} cause: {}", e.toString(), ExceptionUtils.getStackTrace(e.getCause()));
|
||||
throw new RuntimeException("Send message error", e.getCause());
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected exception when send message: {}", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param req требуется заполнить tradingClearingRegistryId по tradingClearingRegistry.code
|
||||
* @return
|
||||
*/
|
||||
private ClientCode buildClientCode(ClientCodeNewRequest req) {
|
||||
ClientCode clientCode = new ClientCode();
|
||||
// clientCode.setId(idSequence.newId()); add in insert
|
||||
clientCode.setCreated(Instant.now());
|
||||
clientCode.setUpdated(clientCode.getCreated());
|
||||
|
||||
clientCode.setCompanyId(req.getCompanyId());
|
||||
clientCode.setCode(req.getCode());
|
||||
|
||||
if (req.getMoneyAccountId() != null) {
|
||||
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (tradingClearingRegistry == null) {
|
||||
log.warn("TCR not found: CompanyId {}, MoneyAccountId {}, DepoAccountId {}",
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
} else {
|
||||
clientCode.setTradingClearingRegistryId(tradingClearingRegistry.getId());
|
||||
}
|
||||
}
|
||||
|
||||
clientCode.setMoneyAccountId(req.getMoneyAccountId());
|
||||
clientCode.setDepoAccountId(req.getDepoAccountId());
|
||||
clientCode.setStatus(req.getStatus());
|
||||
|
||||
return clientCode;
|
||||
}
|
||||
|
||||
private void updateClientCode(ClientCode clientCode, ClientCodeUpdateRequest req) {
|
||||
assert clientCode.getId() != null && clientCode.getId().equals(req.getId());
|
||||
|
||||
clientCode.setCompanyId(req.getCompanyId());
|
||||
clientCode.setCode(req.getCode());
|
||||
|
||||
if (req.getMoneyAccountId() != null) {
|
||||
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (tradingClearingRegistry == null) {
|
||||
log.warn("TCR not found: CompanyId {}, MoneyAccountId {}, DepoAccountId {}",
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
} else {
|
||||
clientCode.setTradingClearingRegistryId(tradingClearingRegistry.getId());
|
||||
}
|
||||
}
|
||||
|
||||
clientCode.setTradingClearingRegistryId(req.getTradingClearingRegistryId());
|
||||
clientCode.setMoneyAccountId(req.getMoneyAccountId());
|
||||
clientCode.setDepoAccountId(req.getDepoAccountId());
|
||||
clientCode.setStatus(req.getStatus());
|
||||
|
||||
clientCode.setUpdated(Instant.now());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.DepoAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class DepoAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final KafkaSender kafkaSender;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final AccountHelper accountService;
|
||||
private final Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator;
|
||||
|
||||
public DepoAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
KafkaSender kafkaSender,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
AccountHelper accountService,
|
||||
@Qualifier("depoAccountNewRequestValidator")
|
||||
Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.validationHelper = validationHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountService = accountService;
|
||||
this.depoAccountNewRequestValidator = depoAccountNewRequestValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
callback(DepoAccountNewRequest.class)
|
||||
.setFunction(this::depoAccountNew)
|
||||
.forDestination(Consts.DESTINATION_DEPO_ACCOUNT_NEW, callbacks::put);
|
||||
callback(AccountSdf01Request.class)
|
||||
.setFunction(this::accountNewSdf08)
|
||||
.forDestination(Consts.ACCOUNT_NEW_SDF08, callbacks::put);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public RequestInfoUpdate depoAccountNew(BaseRequest<DepoAccountNewRequest> userRequest) {
|
||||
log.debug("DepoAccountNewRequest received");
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(
|
||||
userRequest, depoAccountNewRequestValidator
|
||||
);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
DepoAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Depo.getKey());
|
||||
if (req.getStatus() == null) {
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
log.trace("Status not set in request. Use default: {}", account.getStatus());
|
||||
} else {
|
||||
account.setStatus(req.getStatus());
|
||||
}
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId(), true);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long depoAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
DepoAccount depoAccount = null;
|
||||
try {
|
||||
Imdg<Account> accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<DepoAccount> depoAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
depoAccount = new DepoAccount();
|
||||
depoAccount.setCompanyId(req.getCompanyId());
|
||||
depoAccount.setAccountId(accountId);
|
||||
if (account.getAccount() != null && account.getAccount().contains("BC")) {
|
||||
depoAccount.setDepoAccountType(DepoAccountType.C.getKey());
|
||||
} else {
|
||||
depoAccount.setDepoAccountType(req.getDepoAccountType());
|
||||
}
|
||||
depoAccountId = depoAccountImdg.insert(depoAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new depo account id {}, account id {}", depoAccountId, accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new depo account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
depoAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate accountNewSdf08(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
log.debug("AccountSdf08Request received, id={}", userRequest.getId());
|
||||
|
||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||
List<AccountSdfToStatementRequestPart> accountToStatement = new ArrayList<>();
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
Imdg<Account> accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<DepoAccount> depoAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
accountsLoop:
|
||||
for (AccountSdfRequestPart accountReq : req.getAccounts()) {
|
||||
|
||||
// DepoAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountReq.getAccount());
|
||||
account.setAccountType(AccountType.Depo.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setCompanyId(accountReq.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
RequestInfoUpdate requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId(), true);
|
||||
if (requestInfoUpdate != null) {
|
||||
log.warn("Error fill new account from relation. {}", /*account.getId(),*/ requestInfoUpdate.getMessage());
|
||||
{
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(accountReq.getSdfId());
|
||||
responsePart.setErrorCode(AccountError.ClearingCategoryNotFound.getId()); // see accountService.fillAccountFromRelation
|
||||
responsePart.setErrorText(requestInfoUpdate.getMessage());
|
||||
accountToStatement.add(responsePart);
|
||||
continue accountsLoop;
|
||||
}
|
||||
}
|
||||
if (accountImdg.getFirstObjectBySQL("account = '%s'".formatted(accountReq.getAccount())) != null) {
|
||||
log.debug("Account {} already exists", accountReq.getAccount());
|
||||
{
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(accountReq.getSdfId());
|
||||
responsePart.setErrorCode(null);
|
||||
responsePart.setErrorText(null);
|
||||
accountToStatement.add(responsePart);
|
||||
continue accountsLoop;
|
||||
}
|
||||
}
|
||||
|
||||
Long depoAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
DepoAccount depoAccount = new DepoAccount();
|
||||
depoAccount.setCompanyId(accountReq.getCompanyId());
|
||||
depoAccount.setAccountId(accountId);
|
||||
if (account.getAccount() != null && account.getAccount().contains("BC")) {
|
||||
depoAccount.setDepoAccountType(DepoAccountType.C.getKey());
|
||||
} else {
|
||||
depoAccount.setDepoAccountType(accountReq.getAccountType());
|
||||
}
|
||||
depoAccountId = depoAccountImdg.insert(depoAccount);
|
||||
|
||||
|
||||
|
||||
log.debug("New account {}, depoAccount {} was created.", accountId, depoAccountId);
|
||||
|
||||
{
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(accountReq.getSdfId());
|
||||
responsePart.setErrorCode(null);
|
||||
responsePart.setErrorText(null);
|
||||
accountToStatement.add(responsePart);
|
||||
}
|
||||
}
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
} else {
|
||||
log.debug("failed insert, new clearing accounts. Request id={}", userRequest.getId());
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
sendStatementRequestBack(req.getGroupingSdf01Id(), req.getGroupingSdf02Id(), accountToStatement);
|
||||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void sendStatementRequestBack(Long groupingSdf01Id, Long groupingSdf02Id, List<AccountSdfToStatementRequestPart> results) {
|
||||
StatementRequest request = new StatementRequest();
|
||||
request.setGroupId(groupingSdf01Id);
|
||||
request.setChildGenerationId(groupingSdf02Id);
|
||||
request.setContinueSdf(true); //fixme????
|
||||
request.setAccountCreationResults(results);
|
||||
request.setTable(SdfTable.SDF_08); // по нему запрос получили
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.STATEMENT_PROCESS, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.STATEMENT_PROCESS, request);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,349 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.InformationAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.reports.NotificationRequest;
|
||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.util.services.RequestHelper;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
public class InformationAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final KafkaSender kafkaSender;
|
||||
private final IMessageResolver messageResolver;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final AccountHelper accountHelper;
|
||||
private final RequestHelper requestHelper;
|
||||
private final Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator;
|
||||
private final Imdg<InformationAccount> informationAccountImdg;
|
||||
private final Imdg<Account> accountImdg;
|
||||
/**
|
||||
* Кэш-счётчик сквозных номеров счетов.
|
||||
* См. accountNextId()
|
||||
*/
|
||||
protected AtomicLong infoCounter;
|
||||
|
||||
@Autowired
|
||||
public InformationAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
KafkaSender kafkaSender,
|
||||
IMessageResolver messageResolver,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ImdgProvider imdgProvider,
|
||||
ValidationHelper validationHelper,
|
||||
AccountHelper accountHelper,
|
||||
RequestHelper requestHelper,
|
||||
@Qualifier("informationAccountNewRequestValidator")
|
||||
Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.messageResolver = messageResolver;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.validationHelper = validationHelper;
|
||||
this.accountHelper = accountHelper;
|
||||
this.requestHelper = requestHelper;
|
||||
this.infoAccountNewRequestValidator = infoAccountNewRequestValidator;
|
||||
this.informationAccountImdg = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
this.accountImdg = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
callback(InformationAccountNewRequest.class)
|
||||
.setFunction(this::informationAccountNew)
|
||||
.forDestination(Consts.DESTINATION_INFORMATION_ACCOUNT_NEW, callbacks::put);
|
||||
callback(InformationAccountNewRequest.class)
|
||||
.setFunction(this::informationAccountSystemNew)
|
||||
.forDestination(Consts.INFORMATION_ACCOUNT_SYSTEM_NEW, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RequestInfoUpdate informationAccountNew(BaseRequest<InformationAccountNewRequest> userRequest) {
|
||||
log.debug("InformationAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, infoAccountNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
InformationAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Long newId = informationAccountImdg.nextIDSequenceFor();
|
||||
Long infoSequenceId = accountNextId();
|
||||
String accountValue = generateInfoAccount(infoSequenceId);
|
||||
log.trace("New info-account id={}, sequenceId={}, account={}", newId, infoSequenceId, accountValue);
|
||||
|
||||
ImdgPredicateBuilder accountPredicateBuilder = accountImdg.predicateBuilder();
|
||||
ImdgPredicate companyIdPredicate = accountPredicateBuilder.equals("companyId", 1L);
|
||||
ImdgPredicate accountTypePredicate = accountPredicateBuilder.equals("accountType", AccountType.Anlt.getKey());
|
||||
ImdgPredicate andPredicate = accountPredicateBuilder.and(companyIdPredicate, accountTypePredicate);
|
||||
Collection<Account> accountsAnlt = accountImdg.getCollectionObjectsByPredicate(andPredicate);
|
||||
if (accountsAnlt.isEmpty()) {
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "clearingAccountId");
|
||||
} else if (accountsAnlt.size() > 1) {
|
||||
log.warn("Account for companyId 1 and accountType=ANLT contains multiply elements, use first");
|
||||
}
|
||||
Account anltAccount = accountsAnlt.iterator().next();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Info.getKey());
|
||||
if (req.getStatus() == null) {
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
log.trace("Status not set in request. Use default: {}", account.getStatus());
|
||||
} else {
|
||||
account.setStatus(req.getStatus());
|
||||
}
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
|
||||
requestInfoUpdate = accountHelper.fillAccountFromRelation(account, userRequest.getId(), true);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
imdgTransaction.beginTransaction();
|
||||
boolean txOk = false;
|
||||
Long informationAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
InformationAccount informationAccount = null;
|
||||
try {
|
||||
Imdg<InformationAccount> informationAccountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
|
||||
Imdg<Account> accountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
informationAccount = new InformationAccount();
|
||||
informationAccount.setId(newId);
|
||||
informationAccount.setAccountId(accountId);
|
||||
informationAccount.setClearingAccountId(anltAccount.getId());
|
||||
informationAccount.setCompanyId(req.getCompanyId());
|
||||
informationAccountId = informationAccountImdg.insert(informationAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new information account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public RequestInfoUpdate informationAccountSystemNew(BaseRequest<InformationAccountNewRequest> userRequest) {
|
||||
log.debug("InformationAccountNewRequest received (system), request id={}", userRequest.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate;
|
||||
// RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, infoAccountNewRequestValidator);
|
||||
// if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
final Long forCompanyId = userRequest.getRequestPayload().getCompanyId();
|
||||
|
||||
ImdgPredicateBuilder pb = accountImdg.predicateBuilder();
|
||||
{ // Проверка существования счёта
|
||||
Collection<Account> accountsAnlt = accountImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
"companyId", forCompanyId,
|
||||
"accountType", AccountType.Info.getKey()
|
||||
));
|
||||
if (!accountsAnlt.isEmpty()) {
|
||||
String trueMessage = messageResolver.resolve(new EnumMessage(AccountError.InfoAccountAlreadyExist, forCompanyId));
|
||||
log.warn("{}", trueMessage);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Long newId = informationAccountImdg.nextIDSequenceFor();
|
||||
Long infoSequenceId = accountNextId(); // требуется последовательность n+1
|
||||
String accountValue = generateInfoAccount(infoSequenceId);
|
||||
log.trace("New info-account id={}, sequenceId={}, account={}", newId, infoSequenceId, accountValue);
|
||||
|
||||
Long anltAccountId = null;
|
||||
{
|
||||
ImdgPredicate andPredicate = pb.and(
|
||||
pb.equals("companyId", 1L),
|
||||
pb.equals("accountType", AccountType.Anlt.getKey())
|
||||
);
|
||||
Collection<Account> accountsAnlt = accountImdg.getCollectionObjectsByPredicate(andPredicate);
|
||||
if (accountsAnlt.isEmpty()) {
|
||||
log.error("Account with {} not exist.", andPredicate);
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "clearingAccountId");
|
||||
} else if (accountsAnlt.size() > 1) {
|
||||
log.warn("Account for companyId 1 and accountType=ANLT contains multiply elements, use first");
|
||||
}
|
||||
Account anltAccount = accountsAnlt.iterator().next();
|
||||
anltAccountId = anltAccount.getId();
|
||||
}
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountValue);
|
||||
account.setAccountType(AccountType.Info.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setCompanyId(forCompanyId);
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountHelper.fillAccountFromRelation(account, userRequest.getId(), false);
|
||||
if (requestInfoUpdate != null) {
|
||||
log.debug("Stop make new account, cause error: {}", requestInfoUpdate.getMessage());
|
||||
return requestInfoUpdate;
|
||||
}
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
imdgTransaction.beginTransaction();
|
||||
boolean txOk = false;
|
||||
Long informationAccountId = -1L;
|
||||
Long accountId = -1L;
|
||||
InformationAccount informationAccount = null;
|
||||
try {
|
||||
Imdg<InformationAccount> informationAccountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
|
||||
Imdg<Account> accountImdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
informationAccount = new InformationAccount();
|
||||
informationAccount.setId(newId);
|
||||
informationAccount.setAccountId(accountId);
|
||||
informationAccount.setClearingAccountId(anltAccountId);
|
||||
informationAccount.setCompanyId(userRequest.getRequestPayload().getCompanyId());
|
||||
informationAccountId = informationAccountImdg.insert(informationAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
} else {
|
||||
log.debug("failed insert, new information account id {}, new account id {} (if id = -1 then insert is failed)",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
// send to kafka
|
||||
sendNotificationToReport(informationAccount, account);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Формирование уведолмения о регистрации УК
|
||||
*/
|
||||
protected void sendNotificationToReport(InformationAccount informationAccount, Account account) {
|
||||
NotificationRequest request = new NotificationRequest();
|
||||
request.setConsumerId(account.getCompanyId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.CREATE_NOTIFICATION_NTCR, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.CREATE_NOTIFICATION_NCMP, request);
|
||||
}
|
||||
|
||||
public String generateInfoAccount(Long id) {
|
||||
return "%d%d%08d%d".formatted(39911, 810, id, 7000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Сквозной номер инфо-счетов
|
||||
*
|
||||
* @return infoCounter++
|
||||
*/
|
||||
public synchronized Long accountNextId() {
|
||||
if (infoCounter == null) synchronized (this) {
|
||||
if (infoCounter == null) {
|
||||
log.debug("Init account-information counter.");
|
||||
Collection<Account> allInfoAcc = accountImdg.getCollectionObjectsByFieldValues(Map.of("accountType", AccountType.Info.getKey()));
|
||||
if (allInfoAcc.isEmpty()) {
|
||||
infoCounter = new AtomicLong(1);
|
||||
log.debug("No account information on map. n={}", infoCounter.get());
|
||||
} else {
|
||||
Pattern accPattern = Pattern.compile("39911810([0-9]{8})7000");
|
||||
int maxN = 1;
|
||||
int parsedCount = 0;
|
||||
String lastAccount = null; // for debug
|
||||
for (Account acc : allInfoAcc) {
|
||||
try {
|
||||
String number = acc.getAccount();
|
||||
if (StringUtils.isEmpty(number)) continue;
|
||||
lastAccount = number;
|
||||
Matcher m = accPattern.matcher(number);
|
||||
if (m.find()) {
|
||||
String seqNumber = m.group(1);
|
||||
if (StringUtils.isNotEmpty(seqNumber)) {
|
||||
int accN = Integer.parseInt(seqNumber);
|
||||
if (accN > maxN) maxN = accN;
|
||||
}
|
||||
parsedCount++;
|
||||
}
|
||||
} catch (Exception errParse) {
|
||||
log.warn("Error parse account {}: {}", acc.getId(), ExceptionUtils.getStackTrace(errParse));
|
||||
}
|
||||
}
|
||||
infoCounter = new AtomicLong(maxN);
|
||||
log.debug("Parsed {} information accounts ({} pattern match) in map. n={}",
|
||||
allInfoAcc.size(), parsedCount, infoCounter.get());
|
||||
if (parsedCount == 0 && lastAccount != null)
|
||||
log.debug("Last unparseable account: {}", lastAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
return infoCounter.incrementAndGet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.misc.Notification;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf52;
|
||||
import ru.clearing.classes.statics.data.sdf.SDf53;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.ExportToFileRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.NotificationFeedbackRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.enumeration.NotificationStatus;
|
||||
import ru.spcex.platform.enumeration.ObjectType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.utils.collection.Pair;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@Service
|
||||
public class SDFProcessService {
|
||||
public static final String SDF_STATUS_OK = "OK"; // (Операция выполнена успешно) - если account обновлена по sDf52;
|
||||
public static final String SDF_STATUS_ERROR_REPEAT = "1"; // (Ошибка. Попытка повторно исполнить операцию)
|
||||
public static final String SDF_STATUS_ERROR_COMPANY_NOT_FOUND = "2"; // (Ошибка. Участник не найден) - если получена ошибка (5013) "Компания %s не найдена" (т.е. account НЕ обновлена по sDf52);
|
||||
public static final String SDF_STATUS_ERROR_LIMIT_SUMM = "3"; // (Ошибка. Сумма списания превышает сумму средств на торговом счете участника в ТС)
|
||||
public static final String SDF_STATUS_ERROR_NO_TRADE = "4"; // (Ошибка. Торги не идут)
|
||||
public static final String SDF_STATUS_ERROR = "9"; // (Другие ошибки, выявленные в КС) - если получены другие ошибки (т.е. account НЕ обновлена по sDf52).
|
||||
|
||||
protected static final Long SDF52_STATUS_0Blocked = 0L;
|
||||
protected static final Long SDF52_STATUS_1Unblocked = 1L;
|
||||
protected static final Long SDF52_STATUS_2Closed = 2L;
|
||||
protected static final Long SDF52_STATUS_3Open = 3L;
|
||||
|
||||
final protected Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected final Producer<String, Object> kafkaResponseQueue;
|
||||
protected final KafkaSender kafkaSender;
|
||||
|
||||
protected final ImdgProvider imdgProvider;
|
||||
protected final ImdgId idGenerator;
|
||||
|
||||
private final Imdg<SDf52> sdf52Imdg;
|
||||
|
||||
public SDFProcessService(
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
KafkaSender kafkaSender,
|
||||
ImdgProvider imdgProvider) {
|
||||
this.kafkaResponseQueue = kafkaResponseQueue;
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.idGenerator = imdgProvider.getImdgIdGenerator();
|
||||
|
||||
this.sdf52Imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf52, SDf52.class);
|
||||
}
|
||||
|
||||
public Collection<SDf52> sdfsByGroupId(Long generationId) {
|
||||
Collection<SDf52> sdfs = sdf52Imdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
"generationId", generationId
|
||||
));
|
||||
return sdfs;
|
||||
}
|
||||
|
||||
public void process(StatementRequest req, List<Triple<SDf52, Account, String>> toProcessSDF53) {
|
||||
final Long generationId = req.getGroupId();
|
||||
log.info("Create S_DF53 generationId={} by {} S_DF_52",
|
||||
generationId, toProcessSDF53.size());
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
HashSet<String> fileNames = new HashSet<>();
|
||||
try { // 2. обновление данных, в транзакции
|
||||
Imdg<SDf53> sdf53Imdg = imdgTransaction.getImdg(IMDGDistributedNames.Map_SDf53, SDf53.class);
|
||||
|
||||
Instant now = Instant.now();
|
||||
for (Triple<SDf52, Account, String> item : toProcessSDF53) {
|
||||
SDf53 sDf53 = createBy(item.getLeft(), item.getRight(), now, generationId);
|
||||
sdf53Imdg.insert(sDf53);
|
||||
fileNames.add(item.getLeft().getFileName());
|
||||
}
|
||||
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
} else {
|
||||
log.debug("failed create new SDF53, rollback transaction. sdf52 generationId={}", generationId);
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (fileNames.size() > 1)
|
||||
log.warn("generationId={}, too many different file names in S_DF52: {}", generationId, fileNames);
|
||||
String fileNameSingle = fileNames.stream().filter(Objects::nonNull).findAny().orElse(null);
|
||||
log.info("Send export command for SDF53 generationId={} with source file name {}",
|
||||
generationId, (fileNameSingle == null ? null : "\"" + fileNameSingle + "\""));
|
||||
messageStatementToExport53(generationId, fileNameSingle);
|
||||
}
|
||||
|
||||
SDf53 createBy(SDf52 sdf52, String result, Instant now, Long newGenerationId) {
|
||||
SDf53 newSdf = new SDf53();
|
||||
newSdf.setId(idGenerator.nextId());
|
||||
newSdf.setAccName(sdf52.getAcc_name());
|
||||
newSdf.setAccount(sdf52.getAccount());
|
||||
newSdf.setDeal(sdf52.getDeal());
|
||||
newSdf.setDate(sdf52.getDate());
|
||||
newSdf.setStatus(sdf52.getStatus());
|
||||
newSdf.setResult(result);
|
||||
newSdf.setGenerationTime(now);
|
||||
newSdf.setGenerationId(sdf52.getGenerationId());
|
||||
if (!Objects.equals(newGenerationId, newSdf.getGenerationId())) { // never
|
||||
log.warn("Different GenerationId={} for sdf53[{}] and GenerationId={} for group of sdf52",
|
||||
newSdf.getGenerationId(), newSdf.getId(), newGenerationId
|
||||
);
|
||||
}
|
||||
newSdf.setInSDfId(sdf52.getId());
|
||||
return newSdf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param status sdf.getStatus()
|
||||
* @return AccountStatus или null
|
||||
*/
|
||||
public AccountStatus parseSdf52Status(Long status) {
|
||||
if (SDF52_STATUS_1Unblocked.equals(status) || SDF52_STATUS_3Open.equals(status)) {
|
||||
return AccountStatus.ACTIVE;
|
||||
} else if (SDF52_STATUS_0Blocked.equals(status)) {
|
||||
return AccountStatus.BLOCKED;
|
||||
}
|
||||
if (SDF52_STATUS_2Closed.equals(status)) {
|
||||
return AccountStatus.CLOSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
void messageStatementToExport53(Long groupId, String fileName) {
|
||||
final String destination = Consts.EXPORT_PROCESS; // dbf-exporter
|
||||
ExportToFileRequest request = new ExportToFileRequest();
|
||||
request.setNameOfTable("DF-53"); // SdfTable.SDF_53
|
||||
request.setSdfGroupId(groupId);
|
||||
request.setFileName(fileName);
|
||||
Long msgId = kafkaSender.sendRequestToQueue(destination, request);
|
||||
log.debug("Send ExportToFileRequest({}, {}) message id={} to kafka \"{}\"",
|
||||
groupId, request.getNameOfTable(), msgId, destination);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,498 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.clearing.CreateRegistryRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.reports.NotificationRequest;
|
||||
import ru.spcex.clearing.platform.messaging.serialization.LogFormatter;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.util.services.RequestHelper;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.TradingClearingRegistryPurpose;
|
||||
import ru.spcex.platform.enumeration.TradingClearingRegistryType;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class TradingClearingRegistryService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final ValidationHelper validationHelper;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Imdg<TradingClearingRegistry> tradingClearingRegistryImdg;
|
||||
private final Imdg<DepoAccount> depoAccountImdg;
|
||||
private final Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private final Imdg<InformationAccount> informationAccountImdg;
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<Company> companyImdg;
|
||||
private final Imdg<Relation> relationImdg;
|
||||
|
||||
private final Function<TradingClearingRegistryUpdateRequest, IValidator> tradingClearingRegistryUpdateRequestValidator;
|
||||
private final RequestHelper requestHelper;
|
||||
private final Function<TradingClearingRegistryNewRequest, IValidator> tradingClearingRegistryNewRequestValidator;
|
||||
private final Function<TradingClearingRegistryNewRequest, IValidator> tradingClearingRegistryAutoNewRequestValidator;
|
||||
private final Function<CommonIdRequest, IValidator> tradingClearingRegistryBlockRequestValidator;
|
||||
|
||||
private final IMessageResolver messageResolver;
|
||||
private final Producer<String, Object> kafkaProducer;
|
||||
private final KafkaSender kafkaSender;
|
||||
|
||||
public TradingClearingRegistryService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
KafkaSender kafkaSender,
|
||||
ImdgProvider imdgProvider,
|
||||
ValidationHelper validationHelper,
|
||||
UserRoleVerification userRoleVerification,
|
||||
IMessageResolver messageResolver,
|
||||
RequestHelper requestHelper,
|
||||
@Qualifier("tradingClearingRegistryNewRequest")
|
||||
Function<TradingClearingRegistryNewRequest, IValidator> tradingClearingRegistryNewRequestValidator,
|
||||
@Qualifier("tradingClearingRegistryUpdateRequest")
|
||||
Function<TradingClearingRegistryUpdateRequest, IValidator> tradingClearingRegistryUpdateRequestValidator,
|
||||
@Qualifier("tradingClearingRegistryBlockRequest")
|
||||
Function<CommonIdRequest, IValidator> tradingClearingRegistryBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.kafkaProducer = kafkaProducer;
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.validationHelper = validationHelper;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.requestHelper = requestHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.tradingClearingRegistryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
this.depoAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
this.clearingAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
this.informationAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_InformationAccount, InformationAccount.class);
|
||||
this.companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.relationImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Relation, Relation.class);
|
||||
this.tradingClearingRegistryNewRequestValidator = tradingClearingRegistryNewRequestValidator;
|
||||
this.tradingClearingRegistryAutoNewRequestValidator = tradingClearingRegistryNewRequestValidator; // без relation.
|
||||
this.tradingClearingRegistryUpdateRequestValidator = tradingClearingRegistryUpdateRequestValidator;
|
||||
this.tradingClearingRegistryBlockRequestValidator = tradingClearingRegistryBlockRequestValidator;
|
||||
this.messageResolver = messageResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
imdgProvider.waitAvailable();
|
||||
callback(TradingClearingRegistryNewRequest.class) // todo deprecated - unused.
|
||||
.setFunction(this::tradingClearingRegistryAutoNew)
|
||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, callbacks::put);
|
||||
callback(TradingClearingRegistryNewRequest.class)
|
||||
.setFunction(this::tradingClearingRegistryNew)
|
||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_NEW, callbacks::put);
|
||||
callback(TradingClearingRegistryUpdateRequest.class)
|
||||
.setFunction(this::tradingClearingRegistryUpdate)
|
||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE, callbacks::put);
|
||||
callback(CommonIdRequest.class)
|
||||
.setFunction(this::tradingClearingRegistryBlock)
|
||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_BLOCK, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RequestInfoUpdate tradingClearingRegistryAutoNew(BaseRequest<TradingClearingRegistryNewRequest> userRequest) {
|
||||
log.debug("TradingClearingRegistryNewRequest received");
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, tradingClearingRegistryAutoNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
TradingClearingRegistryNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Long id = tradingClearingRegistryImdg.nextIDSequenceFor();
|
||||
TradingClearingRegistry tradingClearingRegistry = new TradingClearingRegistry();
|
||||
tradingClearingRegistry.setId(id);
|
||||
tradingClearingRegistry.setCompanyId(req.getCompanyId());
|
||||
tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
|
||||
tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
||||
|
||||
Account depoAccountMain = req.getDepoAccountId() != null ? accountImdg.getSingleObjectByID(req.getDepoAccountId()) : null;
|
||||
DepoAccount depoAccount = depoAccountMain != null ? depoAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
|
||||
|
||||
// InformationAccount infoAccount = null;
|
||||
ClearingAccount clearingAccount = null;
|
||||
Account accountMain = null;
|
||||
if (req.getMoneyAccountId() != null) {
|
||||
clearingAccount = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId()));
|
||||
// if (clearingAccount == null) infoAccount = informationAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId()));
|
||||
Long accountId = req.getMoneyAccountId(); //clearingAccount != null ? clearingAccount.getAccountId() : infoAccount.getAccountId();
|
||||
accountMain = accountImdg.getSingleObjectByID(accountId);
|
||||
}
|
||||
|
||||
// кроссвалидация
|
||||
if (req.getMoneyAccountId() == null && (req.getMoneyAccountId() == null || req.getDepoAccountId() == null)) {
|
||||
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (registryByCompany == null) {
|
||||
log.trace("Not found registry with companyId={}",
|
||||
req.getCompanyId());
|
||||
return requestHelper.makeErrorResponse(userRequest,
|
||||
AccountError.TradingClearingRegistryNotFound,
|
||||
req.getCompanyId());
|
||||
}
|
||||
}
|
||||
|
||||
if (tradingClearingRegistry.getMoneyAccountId() == null && tradingClearingRegistry.getDepoAccountId() != null) {
|
||||
Collection<TradingClearingRegistry> registriesByCompany = tradingClearingRegistryImdg.getCollectionObjectsByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
TradingClearingRegistry targetExistTradingClearingRegistry = null;
|
||||
for (TradingClearingRegistry existRegistry : registriesByCompany) {
|
||||
if (existRegistry.getMoneyAccountId() != null && existRegistry.getDepoAccountId() == null) {
|
||||
targetExistTradingClearingRegistry = existRegistry;
|
||||
}
|
||||
}
|
||||
if (targetExistTradingClearingRegistry == null) {
|
||||
log.warn("TradingClearingRegister with MoneyAccountId for companyId={} not found. Search exist accounts for company", req.getCompanyId());
|
||||
Long accountId;
|
||||
InformationAccount infoAccount = null;
|
||||
clearingAccount = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (clearingAccount == null) {
|
||||
infoAccount = informationAccountImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (infoAccount == null) {
|
||||
log.warn("ClearingAccount and InfoAccount not exist for company {}.", req.getCompanyId());
|
||||
accountId = null;
|
||||
} else {
|
||||
accountId = infoAccount.getAccountId();
|
||||
log.debug("Found account.id={} and infoaccount.id={} by companyId={}", accountId, infoAccount.getId(), req.getCompanyId());
|
||||
}
|
||||
} else {
|
||||
accountId = clearingAccount.getAccountId();
|
||||
log.debug("Found account.id={} and clearingAccount.id={} by companyId={}", accountId, clearingAccount.getId(), req.getCompanyId());
|
||||
}
|
||||
if (accountId != null) {
|
||||
accountMain = accountImdg.getSingleObjectByID(accountId);
|
||||
if (accountMain == null) { // never, только с инконсистентными данными
|
||||
log.warn("Account {} not exist.", accountId);
|
||||
} else {
|
||||
tradingClearingRegistry.setMoneyAccountId(accountId);
|
||||
log.debug("Set tradingClearingRegistry[{}].MoneyAccountId={}", tradingClearingRegistry.getId(), accountId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.debug("Update exist TCR.id={}, set DepoAccountId={}", targetExistTradingClearingRegistry, req.getDepoAccountId());
|
||||
targetExistTradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
||||
targetExistTradingClearingRegistry.setUpdated(Instant.now());
|
||||
tradingClearingRegistryImdg.update(targetExistTradingClearingRegistry);
|
||||
log.debug("successfully processed, id {}. Updated exist TradingClearingRegistry.id={}", id, targetExistTradingClearingRegistry.getId());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<String> activeStatuses = Arrays.asList(ServiceStatus.Active.getKey(), ServiceStatus.Reopened.getKey());
|
||||
String status = null;
|
||||
if (depoAccountMain != null && depoAccountMain.getStatus() != null) {
|
||||
if (activeStatuses.contains(depoAccountMain.getStatus()) && activeStatuses.contains(accountMain.getStatus()))
|
||||
status = ServiceStatus.Active.getKey();
|
||||
if (depoAccountMain.getStatus().equals(ServiceStatus.Blocked.getKey()) || accountMain.getStatus().equals(ServiceStatus.Blocked.getKey()))
|
||||
status = ServiceStatus.Blocked.getKey();
|
||||
if (depoAccountMain.getStatus().equals(ServiceStatus.Suspended.getKey()) || accountMain.getStatus().equals(ServiceStatus.Suspended.getKey()))
|
||||
status = ServiceStatus.Suspended.getKey();
|
||||
if (depoAccountMain.getStatus().equals(ServiceStatus.Closed.getKey()) || accountMain.getStatus().equals(ServiceStatus.Closed.getKey()))
|
||||
status = ServiceStatus.Closed.getKey();
|
||||
} else if (accountMain.getStatus() != null) {
|
||||
if (activeStatuses.contains(accountMain.getStatus()))
|
||||
status = ServiceStatus.Active.getKey();
|
||||
if (accountMain.getStatus().equals(ServiceStatus.Blocked.getKey()))
|
||||
status = ServiceStatus.Blocked.getKey();
|
||||
if (accountMain.getStatus().equals(ServiceStatus.Suspended.getKey()))
|
||||
status = ServiceStatus.Suspended.getKey();
|
||||
if (accountMain.getStatus().equals(ServiceStatus.Closed.getKey()))
|
||||
status = ServiceStatus.Closed.getKey();
|
||||
}
|
||||
if (status == null)
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, req.getMoneyAccountId());
|
||||
tradingClearingRegistry.setStatus(status);
|
||||
|
||||
String tradingRegistryType;
|
||||
if (depoAccount != null) {
|
||||
tradingRegistryType = depoAccount.getDepoAccountType();
|
||||
} else {
|
||||
if (clearingAccount != null) tradingRegistryType = clearingAccount.getClearingAccountType();
|
||||
else tradingRegistryType = TradingClearingRegistryType.Owner_A.getKey();
|
||||
}
|
||||
tradingClearingRegistry.setTradingClearingRegistryType(tradingRegistryType);
|
||||
|
||||
TradingClearingRegistryPurpose registryPurpose;
|
||||
if (req.getDepoAccountId() != null) registryPurpose = TradingClearingRegistryPurpose.C;
|
||||
else registryPurpose = TradingClearingRegistryPurpose.M;
|
||||
tradingClearingRegistry.setTradingClearingRegistryPurpose(registryPurpose.getKey());
|
||||
|
||||
Company company = companyImdg.getSingleObjectByID(req.getCompanyId());
|
||||
Long seqId = companySequenceNextId(req.getCompanyId(), registryPurpose, tradingRegistryType);
|
||||
String code = makeCode(company.getClearingCode(), registryPurpose, tradingRegistryType, seqId);
|
||||
log.debug("For new TCR.id={} of companyId={} next sequence={}; code={}", id, req.getCompanyId(), seqId, code);
|
||||
tradingClearingRegistry.setCode(code);
|
||||
|
||||
Instant now = Instant.now();
|
||||
tradingClearingRegistry.setCreated(now);
|
||||
tradingClearingRegistry.setUpdated(now);
|
||||
|
||||
tradingClearingRegistryImdg.insert(tradingClearingRegistry);
|
||||
log.debug("New TCR.id={} was created", tradingClearingRegistry.getId());
|
||||
|
||||
// sendNotificationToCompanySvc(tradingClearingRegistry); при автосоздании ТКР в company-service не отправлять.
|
||||
// sendNotificationToClearingSvc(tradingClearingRegistry);
|
||||
sendNotificationToReportSvc(tradingClearingRegistry);
|
||||
sendNotificationToClearingSvc(tradingClearingRegistry);
|
||||
|
||||
log.debug("successfully processed, id {}", id);
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized RequestInfoUpdate tradingClearingRegistryNew(BaseRequest<TradingClearingRegistryNewRequest> userRequest) {
|
||||
log.debug("TradingClearingRegistryNewRequest received");
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) {
|
||||
return requestInfoUpdate;
|
||||
}
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, tradingClearingRegistryNewRequestValidator);
|
||||
if (requestInfoUpdate != null) {
|
||||
return requestInfoUpdate;
|
||||
}
|
||||
|
||||
TradingClearingRegistryNewRequest req = userRequest.getRequestPayload();
|
||||
// Дополнительная проверка
|
||||
if (req.getMoneyAccountId() == null && (req.getMoneyAccountId() == null || req.getDepoAccountId() == null)) {
|
||||
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (registryByCompany == null) {
|
||||
return requestHelper.makeErrorResponse(userRequest,
|
||||
AccountError.TradingClearingRegistryNotFound,
|
||||
"companyId=" + req.getCompanyId());
|
||||
}
|
||||
}
|
||||
|
||||
Long id = tradingClearingRegistryImdg.nextIDSequenceFor();
|
||||
TradingClearingRegistry tradingClearingRegistry = new TradingClearingRegistry();
|
||||
tradingClearingRegistry.setId(id);
|
||||
tradingClearingRegistry.setCompanyId(req.getCompanyId());
|
||||
tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
|
||||
tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
||||
|
||||
DepoAccount depoAccount = req.getDepoAccountId() != null ? depoAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getDepoAccountId())) : null;
|
||||
ClearingAccount clearingAccount = req.getMoneyAccountId() != null ? clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", req.getMoneyAccountId())) : null;
|
||||
|
||||
if (req.getStatus() == null) {
|
||||
tradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
log.trace("TCR status in request not set. Use default: {}", tradingClearingRegistry.getStatus());
|
||||
} else {
|
||||
tradingClearingRegistry.setStatus(req.getStatus());
|
||||
log.trace("TCR status in request set: {}", tradingClearingRegistry.getStatus());
|
||||
}
|
||||
|
||||
String tradingRegistryType;
|
||||
if (req.getTradingClearingRegistryType() != null) {
|
||||
tradingRegistryType = req.getTradingClearingRegistryType();
|
||||
} else if (depoAccount != null) {
|
||||
tradingRegistryType = depoAccount.getDepoAccountType();
|
||||
} else {
|
||||
if (clearingAccount != null) tradingRegistryType = clearingAccount.getClearingAccountType();
|
||||
else tradingRegistryType = TradingClearingRegistryType.Owner_A.getKey();
|
||||
}
|
||||
tradingClearingRegistry.setTradingClearingRegistryType(tradingRegistryType);
|
||||
|
||||
TradingClearingRegistryPurpose registryPurpose;
|
||||
if (req.getDepoAccountId() != null) registryPurpose = TradingClearingRegistryPurpose.C;
|
||||
else registryPurpose = TradingClearingRegistryPurpose.M;
|
||||
tradingClearingRegistry.setTradingClearingRegistryPurpose(registryPurpose.getKey());
|
||||
|
||||
Company company = companyImdg.getSingleObjectByID(req.getCompanyId());
|
||||
Long seqId = companySequenceNextId(req.getCompanyId(), registryPurpose, tradingRegistryType);
|
||||
String code = makeCode(company.getClearingCode(), registryPurpose, tradingRegistryType, seqId);
|
||||
log.debug("For new TCR.id={} of companyId={} next sequence={}; code={}", id, req.getCompanyId(), seqId, code);
|
||||
tradingClearingRegistry.setCode(code);
|
||||
|
||||
Instant now = Instant.now();
|
||||
tradingClearingRegistry.setCreated(now);
|
||||
tradingClearingRegistry.setUpdated(now);
|
||||
|
||||
tradingClearingRegistryImdg.insert(tradingClearingRegistry);
|
||||
log.info("New TCR.id={} was created.", tradingClearingRegistry.getId());
|
||||
|
||||
sendNotificationToReportSvc(tradingClearingRegistry);
|
||||
sendNotificationToClearingSvc(tradingClearingRegistry);
|
||||
|
||||
log.debug("successfully processed, id {}", id);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Long companySequenceNextId(Long companyId, TradingClearingRegistryPurpose registryPurpose, String tradingRegistryType) {
|
||||
ImdgPredicateBuilder pb = tradingClearingRegistryImdg.predicateBuilder();
|
||||
Collection<TradingClearingRegistry> existTCR = tradingClearingRegistryImdg.getCollectionObjectsByPredicate(
|
||||
pb.and(
|
||||
pb.equals("companyId", companyId),
|
||||
pb.equals("tradingClearingRegistryPurpose", registryPurpose.getKey()),
|
||||
pb.equals("tradingClearingRegistryType", tradingRegistryType)
|
||||
)
|
||||
);
|
||||
if (existTCR.isEmpty()) {
|
||||
log.trace("For company id={} not found exist TCR.", companyId);
|
||||
return 1L;
|
||||
}
|
||||
log.trace("For company id={} found {} exist TCR.", companyId, existTCR.size());
|
||||
long maxN = 0;
|
||||
for (TradingClearingRegistry tcr : existTCR) {
|
||||
Long codeN = parseCodeSeqId(tcr.getCode());
|
||||
if (codeN != null) {
|
||||
if (maxN < codeN)
|
||||
maxN = codeN;
|
||||
}
|
||||
}
|
||||
return maxN + 1;
|
||||
}
|
||||
|
||||
protected Long parseCodeSeqId(String code) {
|
||||
if (code == null || code.isBlank())
|
||||
return null;
|
||||
try {
|
||||
String toParse = code.trim();
|
||||
if (toParse.length() > 5)
|
||||
toParse = toParse.substring(toParse.length() - 5);
|
||||
return Long.parseLong(toParse);
|
||||
} catch (NumberFormatException nan) {
|
||||
log.warn("Can not parse number from TCR code \"{}\": {}", code, nan.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String makeCode(String companyClearingCode, TradingClearingRegistryPurpose registryPurpose, String tradingRegistryType, Long id) {
|
||||
String code;
|
||||
code = companyClearingCode;
|
||||
if (code.length() > 4)
|
||||
code = code.substring(code.length() - 4);
|
||||
code = "%4s".formatted(code).replace(' ', '0');
|
||||
code += registryPurpose.getKey(); // C / M / ...
|
||||
String trType = tradingRegistryType + "T"; // 2 символа
|
||||
code += trType;
|
||||
String sId = "%5s".formatted(id).replace(' ', '0');
|
||||
if (sId.length() > 5)
|
||||
sId = sId.substring(sId.length() - 5);
|
||||
code += sId;
|
||||
return code; // 12 имволов
|
||||
}
|
||||
|
||||
public RequestInfoUpdate tradingClearingRegistryUpdate(BaseRequest<TradingClearingRegistryUpdateRequest> userRequest) {
|
||||
log.debug("TradingClearingRegistryUpdateRequest received");
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, tradingClearingRegistryUpdateRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
TradingClearingRegistryUpdateRequest req = userRequest.getRequestPayload();
|
||||
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryImdg.getSingleObjectByID(req.getId());
|
||||
|
||||
// кроссвалидация - нельзя менять эти поля:
|
||||
if (req.getMoneyAccountId() != null && !req.getMoneyAccountId().equals(tradingClearingRegistry.getMoneyAccountId())) {
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "MoneyAccountId", req.getMoneyAccountId());
|
||||
}
|
||||
if (req.getDepoAccountId() != null && !req.getDepoAccountId().equals(tradingClearingRegistry.getDepoAccountId())) {
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.WrongFieldValue, "DepoAccountId", req.getDepoAccountId());
|
||||
}
|
||||
// tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
|
||||
// tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
||||
|
||||
|
||||
if (req.getStatus() != null && !Objects.equals(req.getStatus(), tradingClearingRegistry.getStatus())) {
|
||||
Instant now = Instant.now();
|
||||
tradingClearingRegistry.setUpdated(now);
|
||||
tradingClearingRegistry.setStatus(req.getStatus());
|
||||
tradingClearingRegistryImdg.update(tradingClearingRegistry);
|
||||
log.debug("Update TCR.id={}.", tradingClearingRegistry.getId());
|
||||
} else {
|
||||
log.debug("Nothing to update TCR.id={}.", tradingClearingRegistry.getId());
|
||||
}
|
||||
|
||||
log.debug("successfully processed, id {}", tradingClearingRegistry.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate tradingClearingRegistryBlock(BaseRequest<CommonIdRequest> userRequest) {
|
||||
log.debug("TradingClearingRegistryBlockRequest received");
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, tradingClearingRegistryBlockRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
CommonIdRequest req = userRequest.getRequestPayload();
|
||||
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryImdg.getSingleObjectByID(req.getId());
|
||||
|
||||
tradingClearingRegistry.setStatus(ServiceStatus.Blocked.getKey());
|
||||
tradingClearingRegistry.setUpdated(Instant.now());
|
||||
|
||||
tradingClearingRegistryImdg.update(tradingClearingRegistry);
|
||||
|
||||
log.debug("successfully processed, id {}", tradingClearingRegistry.getId());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* company-service сообщение об успешном добавлении ТКР клиента с параметром tradingClearingRegistry.code
|
||||
*/
|
||||
protected void sendNotificationToCompanySvc(TradingClearingRegistry tradingClearingRegistry) {
|
||||
ClientCodeNewRequest request = new ClientCodeNewRequest();
|
||||
request.setTradingClearingRegistryId(tradingClearingRegistry.getId());
|
||||
request.setCompanyId(tradingClearingRegistry.getCompanyId());
|
||||
request.setCode(tradingClearingRegistry.getCode());
|
||||
request.setMoneyAccountId(tradingClearingRegistry.getMoneyAccountId());
|
||||
request.setDepoAccountId(tradingClearingRegistry.getDepoAccountId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_CLIENT_CODE_NEW_UM_COMPANY, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_CLIENT_CODE_NEW_UM_COMPANY, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* clearing-service сообщение на открытие клиринговых регистров;
|
||||
*/
|
||||
protected void sendNotificationToClearingSvc(TradingClearingRegistry tradingClearingRegistry) {
|
||||
CreateRegistryRequest request = new CreateRegistryRequest();
|
||||
request.setCompanyId(tradingClearingRegistry.getCompanyId());
|
||||
request.setTradingClearingRegistryId(tradingClearingRegistry.getId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.REGISTRY_NEW, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.REGISTRY_NEW, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* report-service сообщение на формирование уведомления о создании нового ТКР
|
||||
*/
|
||||
protected void sendNotificationToReportSvc(TradingClearingRegistry tradingClearingRegistry) {
|
||||
NotificationRequest request = new NotificationRequest();
|
||||
request.setConsumerId(tradingClearingRegistry.getCompanyId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.CREATE_NOTIFICATION_NTCR, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.CREATE_NOTIFICATION_NTCR, request);
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ public enum AccountValidationRule implements IValidationRule<ImdgValidationConte
|
|||
public Optional<EnumMessage> validate(ImdgValidationContext<BankAccountNewRequest> context) {
|
||||
BankAccountNewRequest bankAccountRequest = context.getValidatedObject();
|
||||
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Account account = accountImdg.getSingleObjectByFieldValues(Map.of("account", bankAccountRequest.getAccount(),
|
||||
Account account = accountImdg.getFirstObjectByFieldValues(Map.of("account", bankAccountRequest.getAccount(),
|
||||
"accountStatus", Status.Active.getKey()));
|
||||
if (account != null) {
|
||||
return of(AccountError.AccountAlreadyExist);
|
||||
|
|
@ -52,7 +52,7 @@ public enum AccountValidationRule implements IValidationRule<ImdgValidationConte
|
|||
public Optional<EnumMessage> validate(ImdgValidationContext<BankAccountNewRequest> context) {
|
||||
BankAccountNewRequest accountReq = context.getValidatedObject();
|
||||
if (StringUtils.isEmpty(accountReq.getCurrency())) {
|
||||
return of(AccountError.WrongFieldValue, "Currency");
|
||||
return of(AccountError.WrongFieldValue, "currency");
|
||||
}
|
||||
if (StringUtils.isEmpty(accountReq.getBankIdentificationCode())) {
|
||||
return of(AccountError.WrongFieldValue, "bankIdentificationCode");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,246 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.MockProducer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.InformationAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
AccountHelper.class,
|
||||
InformationAccountService.class,
|
||||
InformationAccountValidationConfig.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class AccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<RequestInfo> REQUEST_INFO_MATCHER_MATCHER = usingIgnoringFieldsComparator("created");
|
||||
private static final int PARTITION = 0;
|
||||
private static final String account = "123456789123";
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
@Autowired
|
||||
AccountService accountService;
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
private Imdg<ServiceStatusDictionary> serviceStatusDictionaryImdg;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
serviceStatusDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary, ServiceStatusDictionary.class
|
||||
);
|
||||
ServiceStatusDictionary serviceStatusDictionary = new ServiceStatusDictionary();
|
||||
serviceStatusDictionary.setCode(ServiceStatus.Active.getKey());
|
||||
serviceStatusDictionary.setName(ServiceStatus.Active.getKey());
|
||||
serviceStatusDictionaryImdg.insert(serviceStatusDictionary);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Corr.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Corr.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountCorrespondentNew() {
|
||||
String uniqueAccount = account + UUID.randomUUID();
|
||||
|
||||
CorrespondentAccountNewRequest correspondentAccountNewRequest = new CorrespondentAccountNewRequest();
|
||||
correspondentAccountNewRequest.setAccount(uniqueAccount);
|
||||
correspondentAccountNewRequest.setAccountType(AccountType.Corr.getKey());
|
||||
correspondentAccountNewRequest.setCompanyId(companyId);
|
||||
correspondentAccountNewRequest.setStatus(ServiceStatus.Active.getKey());
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(uniqueAccount);
|
||||
predictableAccount.setAccountType(AccountType.Corr.getKey());
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
predictableAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
|
||||
String jsonString = getJsonStringForNew(correspondentAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account resultNew = accountImdg.getCollectionObjectsByFieldValues(Map.of("account", uniqueAccount)).iterator().next();
|
||||
predictableAccount.setId(resultNew.getId());
|
||||
predictableAccount.setUpdated(resultNew.getUpdated());
|
||||
predictableAccount.setCreated(resultNew.getCreated());
|
||||
ACCOUNT_MATCHER.assertMatch(resultNew, predictableAccount);
|
||||
accountImdg.delete(resultNew);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountCorrespondentUpdate() {
|
||||
Account existAccount = new Account();
|
||||
existAccount.setAccount(account);
|
||||
existAccount.setAccountType(AccountType.Corr.getKey());
|
||||
existAccount.setStatus(ServiceStatus.Closed.getKey());
|
||||
existAccount.setCompanyId(companyId);
|
||||
Long accountId = accountImdg.insert(existAccount);
|
||||
|
||||
CorrespondentAccountUpdateRequest correspondentAccountUpdateRequest = new CorrespondentAccountUpdateRequest();
|
||||
correspondentAccountUpdateRequest.setAccount(account);
|
||||
correspondentAccountUpdateRequest.setAccountType(AccountType.Corr.getKey());
|
||||
correspondentAccountUpdateRequest.setStatus(ServiceStatus.Active.getKey());
|
||||
correspondentAccountUpdateRequest.setCompanyId(companyId);
|
||||
correspondentAccountUpdateRequest.setId(accountId);
|
||||
|
||||
|
||||
String jsonString = getJsonStringForUpdate(correspondentAccountUpdateRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account resultUpdating = accountImdg.getSingleObjectByID(accountId);
|
||||
Account expectAccount = new Account();
|
||||
expectAccount.setId(existAccount.getId());
|
||||
expectAccount.setAccount(account);
|
||||
expectAccount.setAccountType(AccountType.Corr.getKey());
|
||||
expectAccount.setStatus(ServiceStatus.Closed.getKey());
|
||||
expectAccount.setCompanyId(companyId);
|
||||
expectAccount.setCreated(existAccount.getCreated());
|
||||
expectAccount.setUpdated(resultUpdating.getUpdated());
|
||||
expectAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
ACCOUNT_MATCHER.assertMatch(resultUpdating, expectAccount);
|
||||
accountImdg.delete(resultUpdating);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountCorrespondentBlock() {
|
||||
Account existAccount = new Account();
|
||||
existAccount.setAccount(account);
|
||||
existAccount.setAccountType(AccountType.Corr.getKey());
|
||||
existAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
existAccount.setCompanyId(companyId);
|
||||
Long accountId = accountImdg.insert(existAccount);
|
||||
|
||||
CommonDeleteRequest commonDeleteRequest = new CommonDeleteRequest();
|
||||
commonDeleteRequest.setId(accountId);
|
||||
|
||||
String jsonString = getJsonStringForDelete(commonDeleteRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account resultBlock = accountImdg.getSingleObjectByID(accountId);
|
||||
existAccount.setStatus(ServiceStatus.Blocked.getKey());
|
||||
existAccount.setUpdated(resultBlock.getUpdated());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(existAccount, resultBlock);
|
||||
accountImdg.delete(resultBlock);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.*;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.AccountSymbolsValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountSymbolsNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
import static ru.spcex.clearing.test.config.KafkaTestConfig.setMockFuture;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
AccountSymbolsValidationConfig.class,
|
||||
AccountSymbolsService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class AccountSymbolsServiceTest {
|
||||
public static final MatcherFactory.Matcher<AccountSymbols> ACCOUNT_SYMBOL_MATCHER = usingIgnoringFieldsComparator();
|
||||
private static final int PARTITION = 0;
|
||||
|
||||
@Autowired
|
||||
AccountSymbolsService accountSymbolsService;
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("kafkaTestTemplate")
|
||||
protected KafkaTemplate<String, Object> kafkaTemplate;
|
||||
|
||||
private Imdg<AccountSymbols> accountSymbolsImdg;
|
||||
|
||||
private Imdg<Account> accountImdg;
|
||||
private Long accountId;
|
||||
private Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private Long clearingAccountId;
|
||||
|
||||
static int newRequestCnt = 0;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
accountSymbolsImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountSymbols, AccountSymbols.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
clearingAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class
|
||||
);
|
||||
|
||||
Account account = new Account();
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
ClearingAccount clearingAccount = new ClearingAccount();
|
||||
clearingAccount.setAccountId(accountId);
|
||||
clearingAccount.setClearingAccountType("CAT");
|
||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void destroyTest() {
|
||||
//clean test data
|
||||
Account account = accountImdg.getSingleObjectByID(accountId);
|
||||
if (account != null)
|
||||
accountImdg.delete(account);
|
||||
ClearingAccount clearingAccount = clearingAccountImdg.getSingleObjectByID(clearingAccountId);
|
||||
if (clearingAccount != null)
|
||||
clearingAccountImdg.delete(clearingAccount);
|
||||
}
|
||||
|
||||
@Test
|
||||
void tradingClearingRegistryNew_moneyAccount_clearingAccount() {
|
||||
setMockFuture(kafkaTemplate);
|
||||
AccountSymbolsNewRequest accountSymbolsNewRequest = new AccountSymbolsNewRequest();
|
||||
accountSymbolsNewRequest.setAccountId(accountId);
|
||||
accountSymbolsNewRequest.setAccountSymbolValue("SYMBOL1");
|
||||
|
||||
AccountSymbols predictableAccountSymbols = new AccountSymbols();
|
||||
predictableAccountSymbols.setAccountId(accountId);
|
||||
predictableAccountSymbols.setAccountSymbolValue("SYMBOL1");
|
||||
|
||||
String jsonString = getJsonStringForNew(accountSymbolsNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) accountSymbolsService.getConsumer(),
|
||||
Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_NEW,
|
||||
newRequestCnt,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
AccountSymbols resultNew = accountSymbolsImdg.getAllValues().iterator().next();
|
||||
predictableAccountSymbols.setId(resultNew.getId());
|
||||
|
||||
ACCOUNT_SYMBOL_MATCHER.assertMatch(resultNew, predictableAccountSymbols);
|
||||
accountSymbolsImdg.delete(resultNew); // cleanup test
|
||||
|
||||
newRequestCnt++;
|
||||
}
|
||||
|
||||
@Test
|
||||
void tradingClearingRegistryDelete() {
|
||||
AccountSymbols existAccountSymbols = new AccountSymbols();
|
||||
existAccountSymbols.setAccountId(accountId);
|
||||
existAccountSymbols.setAccountSymbolValue("SYMBOL 2");
|
||||
Long accountSymbolId = accountSymbolsImdg.insert(existAccountSymbols);
|
||||
|
||||
CommonDeleteRequest accountSymbolsDeleteRequest = new CommonDeleteRequest();
|
||||
accountSymbolsDeleteRequest.setId(accountSymbolId);
|
||||
|
||||
String jsonString = getJsonStringForDelete(accountSymbolsDeleteRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) accountSymbolsService.getConsumer(),
|
||||
Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_DELETE,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
AccountSymbols resultUpdating = accountSymbolsImdg.getSingleObjectByID(accountSymbolId);
|
||||
Assertions.assertNull(resultUpdating, "Должен был удалиться");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,26 +1,26 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.hazelcast.core.IMap;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.consumer.OffsetResetStrategy;
|
||||
import org.apache.kafka.clients.producer.MockProducer;
|
||||
import org.apache.kafka.common.TopicPartition;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
import ru.spcex.clearing.account.config.ErrorResolverConfig;
|
||||
import ru.spcex.clearing.account.config.HazelcastServiceTestConfiguration;
|
||||
import ru.spcex.clearing.account.config.ValidationConfig;
|
||||
import ru.spcex.clearing.account.utils.MatcherFactory.Matcher;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.BankAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
|
|
@ -28,43 +28,102 @@ import ru.spcex.clearing.platform.messaging.domain.Consts;
|
|||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.test.MatcherFactory.Matcher;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static ru.spcex.clearing.platform.messaging.service.Status.Error;
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
import static ru.spcex.clearing.test.config.KafkaTestConfig.getCaptor;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
HazelcastServiceTestConfiguration.class, ErrorResolverConfig.class,
|
||||
ValidationConfig.class})
|
||||
AccountHelper.class,
|
||||
BankAccountService.class,
|
||||
ValidationConfig.class,
|
||||
BankAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
BeanConfiguration.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
public class BankAccountServiceTest {
|
||||
public static final Matcher<BankAccount> BANK_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final Matcher<BaseRequest<Object>> BASE_REQUEST_MATCHER = usingIgnoringFieldsComparator();
|
||||
private static final int PARTITION = 0;
|
||||
private static final String TOPIC_ACCOUNT_NEW = Consts.DESTINATION_BANK_ACCOUNT_NEW;
|
||||
private static final String TOPIC_ACCOUNT_UPDATE = Consts.DESTINATION_BANK_ACCOUNT_UPDATE;
|
||||
private static final String TOPIC_ACCOUNT_DELETE = Consts.DESTINATION_BANK_ACCOUNT_DELETE;
|
||||
private static Long currentId = 0L;
|
||||
private static final String TOPIC_ACCOUNT_DELETE = Consts.DESTINATION_BANK_ACCOUNT_BLOCK;
|
||||
private static final Long ID = 0L;
|
||||
private static final AtomicInteger countRun = new AtomicInteger(1);
|
||||
private static final Long accountId = 12L;
|
||||
private static final String currency = "RUB";
|
||||
private static final String bankIdentificationCode = "99999";
|
||||
private static final String bankName = "ooo tinkoff";
|
||||
private static final String destination = "OOO ROGA I KOPITA";
|
||||
private static final String correspondentAccount = "9294189285498598598";
|
||||
private static final String correspondentAccountName = "BIK OF TINKOFF";
|
||||
private static final String taxpayerIdentificationNumber = "848484848484";
|
||||
private static final String taxRegistrationReasonCode = "886886";
|
||||
protected final Long addresseeIdNew = 2L;
|
||||
protected final String deal = "111111111";
|
||||
private final String acc = "0123456789";
|
||||
protected Imdg<Company> companyImdg;
|
||||
private Imdg<BankAccount> bankAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<CurrencyCodeDictionary> currencyCodeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
@Autowired
|
||||
private IMessageResolver messageResolver;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
@Autowired
|
||||
private IMessageResolver messageResolver;
|
||||
private MockConsumer<String, Object> mockConsumer;
|
||||
private MockProducer<String, Object> mockProducer;
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Autowired
|
||||
private Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator;
|
||||
private BankAccountService bankAccountService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mockConsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
|
||||
mockProducer = new MockProducer<>();
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
companyImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
bankAccountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
accountImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
currencyCodeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
CurrencyCodeDictionary currencyCodeDictionary = new CurrencyCodeDictionary();
|
||||
currencyCodeDictionary.setCode("RUB");
|
||||
currencyCodeDictionary.setName("RUB");
|
||||
currencyCodeDictionaryImdg.insert(currencyCodeDictionary);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,73 +140,143 @@ public class BankAccountServiceTest {
|
|||
* {@link BankAccountNewRequest#taxRegistrationReasonCode} - 886886<br>
|
||||
* {@link BankAccountNewRequest#account} - 123456789123<br>
|
||||
*/
|
||||
// @Test
|
||||
public void bankAccountNew() throws InterruptedException {
|
||||
//arrange
|
||||
BankAccountNewRequest bankAccountNewRequest = new BankAccountNewRequest();
|
||||
bankAccountNewRequest.setBankName("ooo tinkoff");
|
||||
bankAccountNewRequest.setBankIdentificationCode("99999");
|
||||
bankAccountNewRequest.setCorrespondentAccount("9294189285498598598");
|
||||
bankAccountNewRequest.setCorrespondentAccountName("BIK OF TINKOFF");
|
||||
bankAccountNewRequest.setCurrency("RUB");
|
||||
bankAccountNewRequest.setDestination("OOO ROGA I KOPITA");
|
||||
bankAccountNewRequest.setTaxpayerIdentificationNumber("848484848484");
|
||||
bankAccountNewRequest.setTaxRegistrationReasonCode("886886");
|
||||
bankAccountNewRequest.setAccount("123456789123");
|
||||
@Test
|
||||
public void bankAccountNew() {
|
||||
//ARRANGE
|
||||
BankAccount predictableBankAccount = getBankAccount();
|
||||
|
||||
BaseRequest<BankAccountNewRequest> baseNewRequest = new BaseRequest<>();
|
||||
baseNewRequest.setRequestPayload(bankAccountNewRequest);
|
||||
baseNewRequest.setId(currentId);
|
||||
baseNewRequest.setActionType(ActionType.NEW);
|
||||
String jsonBaseNewRequest;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
BankAccount predictableResult = new BankAccount();
|
||||
predictableResult.setBankName("ooo tinkoff");
|
||||
predictableResult.setBankIdentificationCode("99999");
|
||||
predictableResult.setCorrespondentAccount("9294189285498598598");
|
||||
predictableResult.setCorrespondentAccountName("BIK OF TINKOFF");
|
||||
predictableResult.setCurrency("RUB");
|
||||
predictableResult.setDestination("OOO ROGA I KOPITA");
|
||||
predictableResult.setTaxpayerIdentificationNumber("848484848484");
|
||||
predictableResult.setTaxRegistrationReasonCode("886886");
|
||||
predictableResult.setId(currentId);
|
||||
//KAFKA
|
||||
mockConsumer.schedulePollTask(() -> {
|
||||
mockConsumer.rebalance(Collections.singletonList(new TopicPartition(TOPIC_ACCOUNT_NEW, PARTITION)));
|
||||
mockConsumer.addRecord(new ConsumerRecord<>(TOPIC_ACCOUNT_NEW, PARTITION, 0, "key", jsonBaseNewRequest));
|
||||
});
|
||||
Company company = getTestCompany();
|
||||
Long companyId = companyImdg.insert(company);
|
||||
Long relationId = 777L;
|
||||
Account predictableAccount = getTestAccount(accountId, acc);
|
||||
predictableAccount.setProcessingSign(null);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
predictableAccount.setRelationId(relationId);
|
||||
clearImdg(accountImdg);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
HashMap<TopicPartition, Long> startOffsets = new HashMap<>();
|
||||
TopicPartition tp = new TopicPartition(TOPIC_ACCOUNT_NEW, PARTITION);
|
||||
startOffsets.put(tp, 0L);
|
||||
mockConsumer.updateBeginningOffsets(startOffsets);
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
BankAccountNewRequest bankAccountNewRequest = getBankAccountNewRequest(predictableBankAccount);
|
||||
String jsonString = getJsonStringForNew(bankAccountNewRequest, ID);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) bankAccountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, 0, jsonString);
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
|
||||
//service set up
|
||||
BankAccountService bankAccountService = new BankAccountService(mockConsumer, mockProducer,
|
||||
hazelcastServiceTest, messageResolver,
|
||||
bankAccountNewRequestValidator);
|
||||
Thread.sleep(10000);
|
||||
//callbacks set up
|
||||
bankAccountService.afterPropertiesSet();
|
||||
Thread.sleep(10000);
|
||||
Account accountResult = accountImdg.getFirstObjectBySQL(String.format("account = %s", acc));
|
||||
BankAccount bankAccountResult = bankAccountImdg.getFirstObjectBySQL(String.format("account = %s or companyId = %s", acc, addresseeIdNew));
|
||||
predictableBankAccount.setAccountId(accountResult.getId());
|
||||
predictableBankAccount.setId(bankAccountResult.getId());
|
||||
setSameValueToField(accountResult, predictableAccount);
|
||||
|
||||
//ASSERT
|
||||
IMap<Long, BankAccount> iMap = hazelcastServiceTest.getHazelcast().getMap(IMDGDistributedNames.Map_BankAccount);
|
||||
BankAccount result = iMap.get(currentId);
|
||||
BANK_ACCOUNT_MATCHER.assertMatch(bankAccountResult, predictableBankAccount);
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
}
|
||||
|
||||
BANK_ACCOUNT_MATCHER.assertMatch(result, predictableResult);
|
||||
/**
|
||||
* {@link BankAccountService#bankAccountNew(BaseRequest request)}<br>
|
||||
* Тест проверяет валидацию.<br>
|
||||
* Входной запрос {@link BankAccountNewRequest}:<br>
|
||||
* {@link BankAccountNewRequest#bankIdentificationCode} - 99999<br>
|
||||
* {@link BankAccountNewRequest#bankName} - ооо тинькофф<br>
|
||||
* {@link BankAccountNewRequest#correspondentAccount} - 9294189285498598598<br>
|
||||
* {@link BankAccountNewRequest#correspondentAccountName} - BIK OF<br>
|
||||
* {@link BankAccountNewRequest#currency} - RUB<br>
|
||||
* {@link BankAccountNewRequest#destination} - OOO ROGA I KOPITA<br>
|
||||
* {@link BankAccountNewRequest#taxpayerIdentificationNumber} - 848484848484<br>
|
||||
* {@link BankAccountNewRequest#taxRegistrationReasonCode} - 886886<br>
|
||||
* {@link BankAccountNewRequest#account} - 123456789123<br>
|
||||
*/
|
||||
@Test
|
||||
public void validatedBankAccountNew() {
|
||||
clearImdg(accountImdg);
|
||||
BankAccount predictableBankAccount = getBankAccount();
|
||||
Company company = getTestCompany();
|
||||
companyImdg.insert(company);
|
||||
BankAccountNewRequest bankAccountNewRequest = getBankAccountNewRequest(predictableBankAccount);
|
||||
|
||||
//reset hazelcastService for next test
|
||||
iMap.clear();
|
||||
currentId++;
|
||||
String errMsg;
|
||||
//AccountValidationRule.RequiredFields
|
||||
//WrongFieldValue
|
||||
bankAccountNewRequest.setCurrency(null);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "null, currency"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCurrency("TT0");
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.DictionaryNotFound, "TT0, CurrencyCodeDictionary"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCurrency(currency);
|
||||
bankAccountNewRequest.setBankIdentificationCode(null);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "bankIdentificationCode"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setBankIdentificationCode(bankIdentificationCode);
|
||||
bankAccountNewRequest.setBankName(null);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "bankName"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setBankName(bankName);
|
||||
bankAccountNewRequest.setAccount(null);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "account"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setAccount(acc);
|
||||
|
||||
//AccountValidationRule.CompanyPresent
|
||||
//CompanyNotFound
|
||||
bankAccountNewRequest.setCompanyId(999924535239L);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.CompanyNotFound, bankAccountNewRequest.getCompanyId()+", companyId"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCompanyId(company.getId());
|
||||
|
||||
//AccountValidationRule.AccountIsNew
|
||||
//AccountAlreadyExist
|
||||
Account existAccount = getTestAccount(accountId, acc);
|
||||
accountImdg.insert(existAccount);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.AccountAlreadyExist, existAccount.getAccount()));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
accountImdg.delete(existAccount);
|
||||
}
|
||||
|
||||
private void checkError(String errorMsg, BankAccountNewRequest bankAccountNewRequest) {
|
||||
//ARRANGE
|
||||
int currentTime = countRun.getAndIncrement();
|
||||
long currentOffset = currentTime;
|
||||
BaseRequest<Object> predictableBaseRequest = new BaseRequest<>();
|
||||
predictableBaseRequest.setId(ID);
|
||||
predictableBaseRequest.setActionType(ActionType.SYSTEM);
|
||||
RequestInfoUpdate requestInfoUpdate = new RequestInfoUpdate();
|
||||
requestInfoUpdate.setId(ID);
|
||||
requestInfoUpdate.setStatus(Error);
|
||||
requestInfoUpdate.setMessage(errorMsg);
|
||||
predictableBaseRequest.setRequestPayload(requestInfoUpdate);
|
||||
|
||||
String jsonString = getJsonStringForNew(bankAccountNewRequest, ID);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) bankAccountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, currentOffset, jsonString);
|
||||
|
||||
ArgumentCaptor<ProducerRecord> producerRecord = getCaptor(mockProducer);
|
||||
//waiting for kafka producer send message (finale event)
|
||||
verify(mockProducer, timeout(30_000L).times(currentTime))
|
||||
.send(producerRecord.capture());
|
||||
BaseRequest<Object> baseRequestResult = (BaseRequest<Object>) producerRecord.getValue().value();
|
||||
|
||||
//ASSERT
|
||||
assertEquals(Consts.REQUEST_INFO_UPDATE, producerRecord.getValue().topic());
|
||||
BASE_REQUEST_MATCHER.assertMatch(baseRequestResult, predictableBaseRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -164,187 +293,144 @@ public class BankAccountServiceTest {
|
|||
* {@link BankAccountUpdateRequest#taxRegistrationReasonCode} - 532137<br>
|
||||
* {@link BankAccountUpdateRequest#account} - 326984656514<br>
|
||||
*/
|
||||
// @Test
|
||||
void bankAccountUpdate() throws InterruptedException {
|
||||
//arrange
|
||||
BankAccountNewRequest bankAccountNewRequest = new BankAccountNewRequest();
|
||||
bankAccountNewRequest.setBankName("ooo tinkoff");
|
||||
bankAccountNewRequest.setBankIdentificationCode("99999");
|
||||
bankAccountNewRequest.setCorrespondentAccount("9294189285498598598");
|
||||
bankAccountNewRequest.setCorrespondentAccountName("BIK OF TINKOFF");
|
||||
bankAccountNewRequest.setCurrency("RUB");
|
||||
bankAccountNewRequest.setDestination("OOO ROGA I KOPITA");
|
||||
bankAccountNewRequest.setTaxpayerIdentificationNumber("848484848484");
|
||||
bankAccountNewRequest.setTaxRegistrationReasonCode("886886");
|
||||
bankAccountNewRequest.setAccount("123456789123");
|
||||
@Test
|
||||
void bankAccountUpdate() {
|
||||
clearImdg(accountImdg);
|
||||
//ARRANGE
|
||||
// Company company = getTestCompany();
|
||||
// companyImdg.insert(company);
|
||||
Account predictableAccount = getTestAccount(accountId, acc);
|
||||
accountImdg.insert(predictableAccount);
|
||||
|
||||
BankAccount bankAccountExists = getBankAccount();
|
||||
bankAccountImdg.insert(bankAccountExists);
|
||||
BankAccount predictableUpdateBankAccount = new BankAccount();
|
||||
predictableUpdateBankAccount.setBankName("NEW BUNK NAME");
|
||||
predictableUpdateBankAccount.setBankIdentificationCode("88888");
|
||||
predictableUpdateBankAccount.setCorrespondentAccount("894984646541316");
|
||||
predictableUpdateBankAccount.setCorrespondentAccountName("BIK OF NEW BUNK");
|
||||
predictableUpdateBankAccount.setCurrency("RUB");
|
||||
predictableUpdateBankAccount.setDestination("OOO NEW BUNK");
|
||||
predictableUpdateBankAccount.setTaxpayerIdentificationNumber("65468461321");
|
||||
predictableUpdateBankAccount.setTaxRegistrationReasonCode("532137");
|
||||
predictableUpdateBankAccount.setAccount(acc);
|
||||
predictableUpdateBankAccount.setId(ID);
|
||||
|
||||
BaseRequest<BankAccountNewRequest> baseNewRequest = new BaseRequest<>();
|
||||
baseNewRequest.setRequestPayload(bankAccountNewRequest);
|
||||
baseNewRequest.setId(currentId);
|
||||
baseNewRequest.setActionType(ActionType.NEW);
|
||||
String jsonBaseNewRequest;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
BankAccountUpdateRequest bankAccountUpdateRequest = new BankAccountUpdateRequest();
|
||||
bankAccountUpdateRequest.setId(currentId);
|
||||
bankAccountUpdateRequest.setBankName("NEW BUNK NAME");
|
||||
bankAccountUpdateRequest.setBankIdentificationCode("88888");
|
||||
bankAccountUpdateRequest.setCorrespondentAccount("894984646541316");
|
||||
bankAccountUpdateRequest.setCorrespondentAccountName("BIK OF NEW BUNK");
|
||||
bankAccountUpdateRequest.setCurrency("EU");
|
||||
bankAccountUpdateRequest.setDestination("OOO NEW BUNK");
|
||||
bankAccountUpdateRequest.setTaxpayerIdentificationNumber("65468461321");
|
||||
bankAccountUpdateRequest.setTaxRegistrationReasonCode("532137");
|
||||
bankAccountUpdateRequest.setAccount("326984656514");
|
||||
bankAccountUpdateRequest.setId(predictableUpdateBankAccount.getId());
|
||||
bankAccountUpdateRequest.setBankName(predictableUpdateBankAccount.getBankName());
|
||||
bankAccountUpdateRequest.setBankIdentificationCode(predictableUpdateBankAccount.getBankIdentificationCode());
|
||||
bankAccountUpdateRequest.setCorrespondentAccount(predictableUpdateBankAccount.getCorrespondentAccount());
|
||||
bankAccountUpdateRequest.setCorrespondentAccountName(predictableUpdateBankAccount.getCorrespondentAccountName());
|
||||
bankAccountUpdateRequest.setCurrency(predictableUpdateBankAccount.getCurrency());
|
||||
bankAccountUpdateRequest.setDestination(predictableUpdateBankAccount.getDestination());
|
||||
bankAccountUpdateRequest.setTaxpayerIdentificationNumber(predictableUpdateBankAccount.getTaxpayerIdentificationNumber());
|
||||
bankAccountUpdateRequest.setTaxRegistrationReasonCode(predictableUpdateBankAccount.getTaxRegistrationReasonCode());
|
||||
bankAccountUpdateRequest.setAccount(predictableUpdateBankAccount.getAccount());
|
||||
|
||||
BaseRequest<BankAccountUpdateRequest> baseUpdateRequest = new BaseRequest<>();
|
||||
baseUpdateRequest.setRequestPayload(bankAccountUpdateRequest);
|
||||
baseUpdateRequest.setId(currentId);
|
||||
baseUpdateRequest.setActionType(ActionType.UPDATE);
|
||||
String jsonBaseUpdateRequest;
|
||||
try {
|
||||
jsonBaseUpdateRequest = objectMapper.writeValueAsString(baseUpdateRequest);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
BankAccount predictableUpdateResult = new BankAccount();
|
||||
predictableUpdateResult.setBankName("NEW BUNK NAME");
|
||||
predictableUpdateResult.setBankIdentificationCode("88888");
|
||||
predictableUpdateResult.setCorrespondentAccount("894984646541316");
|
||||
predictableUpdateResult.setCorrespondentAccountName("BIK OF NEW BUNK");
|
||||
predictableUpdateResult.setCurrency("EU");
|
||||
predictableUpdateResult.setDestination("OOO NEW BUNK");
|
||||
predictableUpdateResult.setTaxpayerIdentificationNumber("65468461321");
|
||||
predictableUpdateResult.setTaxRegistrationReasonCode("532137");
|
||||
predictableUpdateResult.setId(currentId);
|
||||
|
||||
//KAFKA
|
||||
mockConsumer.schedulePollTask(() -> {
|
||||
mockConsumer.rebalance(Collections.singletonList(new TopicPartition(TOPIC_ACCOUNT_NEW, PARTITION)));
|
||||
mockConsumer.addRecord(new ConsumerRecord<>(TOPIC_ACCOUNT_NEW, PARTITION, 0, "key", jsonBaseNewRequest));
|
||||
});
|
||||
HashMap<TopicPartition, Long> startOffsets = new HashMap<>();
|
||||
TopicPartition tp = new TopicPartition(TOPIC_ACCOUNT_NEW, PARTITION);
|
||||
startOffsets.put(tp, 0L);
|
||||
mockConsumer.updateBeginningOffsets(startOffsets);
|
||||
String jsonString = getJsonStringForUpdate(bankAccountUpdateRequest, ID);
|
||||
|
||||
//ACT
|
||||
//service set up
|
||||
BankAccountService bankAccountService = new BankAccountService(mockConsumer, mockProducer,
|
||||
hazelcastServiceTest, messageResolver,
|
||||
bankAccountNewRequestValidator);
|
||||
Thread.sleep(10000);
|
||||
//callbacks set up
|
||||
bankAccountService.afterPropertiesSet();
|
||||
Thread.sleep(10000);
|
||||
|
||||
//KAFKA
|
||||
mockConsumer.schedulePollTask(() -> {
|
||||
mockConsumer.rebalance(Collections.singletonList(new TopicPartition(TOPIC_ACCOUNT_UPDATE, PARTITION)));
|
||||
mockConsumer.addRecord(new ConsumerRecord<>(TOPIC_ACCOUNT_UPDATE, PARTITION, 0, "key", jsonBaseUpdateRequest));
|
||||
});
|
||||
HashMap<TopicPartition, Long> startOffsetsUpdating = new HashMap<>();
|
||||
TopicPartition tpUpdating = new TopicPartition(TOPIC_ACCOUNT_UPDATE, PARTITION);
|
||||
startOffsetsUpdating.put(tpUpdating, 0L);
|
||||
mockConsumer.updateBeginningOffsets(startOffsetsUpdating);
|
||||
addRecordToKafka((MockConsumer) bankAccountService.getConsumer(), TOPIC_ACCOUNT_UPDATE, PARTITION, 0, jsonString);
|
||||
|
||||
//ASSERT
|
||||
Thread.sleep(10000);
|
||||
IMap<Long, BankAccount> iMap = hazelcastServiceTest.getHazelcast().getMap(IMDGDistributedNames.Map_BankAccount);
|
||||
BankAccount resultUpdating = iMap.get(currentId);
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
|
||||
BANK_ACCOUNT_MATCHER.assertMatch(resultUpdating, predictableUpdateResult);
|
||||
|
||||
//reset hazelcastService for next test
|
||||
iMap.clear();
|
||||
currentId++;
|
||||
Account accountResult = accountImdg.getSingleObjectByID(predictableAccount.getId());
|
||||
BankAccount resultUpdating = bankAccountImdg.getSingleObjectByID(predictableUpdateBankAccount.getId());
|
||||
predictableAccount.setUpdated(accountResult.getUpdated());
|
||||
predictableUpdateBankAccount.setAccountId(resultUpdating.getAccountId());
|
||||
predictableUpdateBankAccount.setCompanyId(resultUpdating.getCompanyId());
|
||||
BANK_ACCOUNT_MATCHER.assertMatch(resultUpdating, predictableUpdateBankAccount);
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link BankAccountService#bankAccountDelete(BaseRequest)}
|
||||
* {@link BankAccountService#bankAccountBlock(BaseRequest)}
|
||||
* Тест проверяет удаление сущности {@link BankAccount} в Hazelcast при передаче из Apache Kafka.
|
||||
* Входной запрос {@link CommonDeleteRequest}:
|
||||
* {@link CommonDeleteRequest#id} - Идентификатор записи
|
||||
*/
|
||||
@Test
|
||||
void bankAccountDelete() throws InterruptedException {
|
||||
//arrange
|
||||
BankAccountNewRequest bankAccountNewRequest = new BankAccountNewRequest();
|
||||
bankAccountNewRequest.setBankName("ooo tinkoff");
|
||||
bankAccountNewRequest.setBankIdentificationCode("99999");
|
||||
bankAccountNewRequest.setCorrespondentAccount("9294189285498598598");
|
||||
bankAccountNewRequest.setCorrespondentAccountName("BIK OF TINKOFF");
|
||||
bankAccountNewRequest.setCurrency("RUB");
|
||||
bankAccountNewRequest.setDestination("OOO ROGA I KOPITA");
|
||||
bankAccountNewRequest.setTaxpayerIdentificationNumber("848484848484");
|
||||
bankAccountNewRequest.setTaxRegistrationReasonCode("886886");
|
||||
bankAccountNewRequest.setAccount("123456789123");
|
||||
|
||||
BaseRequest<BankAccountNewRequest> baseNewRequest = new BaseRequest<>();
|
||||
baseNewRequest.setRequestPayload(bankAccountNewRequest);
|
||||
baseNewRequest.setId(currentId);
|
||||
baseNewRequest.setActionType(ActionType.NEW);
|
||||
String jsonBaseNewRequest;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
void bankAccountBlock() {
|
||||
//ARRANGE
|
||||
BankAccount bankAccountExists = getBankAccount();
|
||||
bankAccountImdg.insert(bankAccountExists);
|
||||
Account account = new Account();
|
||||
account.setId(accountId);
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
accountImdg.insert(account);
|
||||
|
||||
CommonDeleteRequest commonDeleteRequest = new CommonDeleteRequest();
|
||||
commonDeleteRequest.setId(currentId);
|
||||
BaseRequest<CommonDeleteRequest> baseDeleteRequest = new BaseRequest<>();
|
||||
baseDeleteRequest.setRequestPayload(commonDeleteRequest);
|
||||
baseDeleteRequest.setId(currentId);
|
||||
baseDeleteRequest.setActionType(ActionType.DELETE);
|
||||
String jsonDeleteNewRequest;
|
||||
try {
|
||||
jsonDeleteNewRequest = objectMapper.writeValueAsString(baseDeleteRequest);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//KAFKA
|
||||
mockConsumer.schedulePollTask(() -> {
|
||||
mockConsumer.rebalance(Collections.singletonList(new TopicPartition(TOPIC_ACCOUNT_NEW, PARTITION)));
|
||||
mockConsumer.addRecord(new ConsumerRecord<>(TOPIC_ACCOUNT_NEW, PARTITION, 0, "key", jsonBaseNewRequest));
|
||||
});
|
||||
HashMap<TopicPartition, Long> startOffsets = new HashMap<>();
|
||||
TopicPartition tp = new TopicPartition(TOPIC_ACCOUNT_NEW, PARTITION);
|
||||
startOffsets.put(tp, 0L);
|
||||
mockConsumer.updateBeginningOffsets(startOffsets);
|
||||
commonDeleteRequest.setId(ID);
|
||||
String jsonString = getJsonStringForDelete(commonDeleteRequest, ID);
|
||||
|
||||
//ACT
|
||||
//service set up
|
||||
BankAccountService bankAccountService = new BankAccountService(mockConsumer, mockProducer,
|
||||
hazelcastServiceTest, messageResolver,
|
||||
bankAccountNewRequestValidator);
|
||||
Thread.sleep(10000);
|
||||
//callbacks set up
|
||||
bankAccountService.afterPropertiesSet();
|
||||
Thread.sleep(10000);
|
||||
|
||||
//KAFKA
|
||||
mockConsumer.schedulePollTask(() -> {
|
||||
mockConsumer.rebalance(Collections.singletonList(new TopicPartition(TOPIC_ACCOUNT_DELETE, PARTITION)));
|
||||
mockConsumer.addRecord(new ConsumerRecord<>(TOPIC_ACCOUNT_DELETE, PARTITION, 0, "key", jsonDeleteNewRequest));
|
||||
});
|
||||
HashMap<TopicPartition, Long> startOffsetsDeleting = new HashMap<>();
|
||||
TopicPartition tpDeleting = new TopicPartition(TOPIC_ACCOUNT_DELETE, PARTITION);
|
||||
startOffsetsDeleting.put(tpDeleting, 0L);
|
||||
mockConsumer.updateBeginningOffsets(startOffsetsDeleting);
|
||||
addRecordToKafka((MockConsumer) bankAccountService.getConsumer(), TOPIC_ACCOUNT_DELETE, PARTITION, 0, jsonString);
|
||||
|
||||
//ASSERT
|
||||
Thread.sleep(10000);
|
||||
IMap<Long, BankAccount> iMap = hazelcastServiceTest.getHazelcast().getMap(IMDGDistributedNames.Map_BankAccount);
|
||||
Assertions.assertEquals(0, iMap.size());
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
|
||||
//reset hazelcastService for next test
|
||||
iMap.clear();
|
||||
currentId++;
|
||||
Account bankAccount = accountImdg.getSingleObjectByID(accountId);
|
||||
assertEquals(bankAccount.getStatus(), WorkflowStatus.Blocked.getKey());
|
||||
}
|
||||
|
||||
private Company getTestCompany() {
|
||||
Company company = new Company();
|
||||
company.setId(addresseeIdNew);
|
||||
company.setWorkflowStatus(Status.Active.getKey());
|
||||
company.setTradingCode(deal);
|
||||
company.setShortName("ShortName");
|
||||
company.setFullName("FullName");
|
||||
return company;
|
||||
}
|
||||
|
||||
private Account getTestAccount(Long id, String acc) {
|
||||
Account account = new Account();
|
||||
account.setId(id);
|
||||
account.setAccount(acc);
|
||||
account.setAccountType(AccountType.Bank.getKey());
|
||||
account.setStatus(Status.Active.getKey());
|
||||
account.setProcessingSign(Allowed.ALLOWED.getKey());
|
||||
return account;
|
||||
}
|
||||
|
||||
private void setSameValueToField(Account from, Account to) {
|
||||
to.setCreated(from.getCreated());
|
||||
to.setUpdated(from.getUpdated());
|
||||
to.setId(from.getId());
|
||||
}
|
||||
|
||||
private BankAccount getBankAccount() {
|
||||
BankAccount bankAccount = new BankAccount();
|
||||
bankAccount.setAccountId(accountId);
|
||||
bankAccount.setAccount(acc);
|
||||
bankAccount.setCompanyId(addresseeIdNew);
|
||||
bankAccount.setId(ID);
|
||||
bankAccount.setBankName(bankName);
|
||||
bankAccount.setBankIdentificationCode(bankIdentificationCode);
|
||||
bankAccount.setCorrespondentAccount(correspondentAccount);
|
||||
bankAccount.setCorrespondentAccountName(correspondentAccountName);
|
||||
bankAccount.setCurrency(currency);
|
||||
bankAccount.setDestination(destination);
|
||||
bankAccount.setTaxpayerIdentificationNumber(taxpayerIdentificationNumber);
|
||||
bankAccount.setTaxRegistrationReasonCode(taxRegistrationReasonCode);
|
||||
return bankAccount;
|
||||
}
|
||||
|
||||
private BankAccountNewRequest getBankAccountNewRequest(BankAccount bankAccount) {
|
||||
BankAccountNewRequest bankAccountNewRequest = new BankAccountNewRequest();
|
||||
bankAccountNewRequest.setBankName(bankAccount.getBankName());
|
||||
bankAccountNewRequest.setBankIdentificationCode(bankAccount.getBankIdentificationCode());
|
||||
bankAccountNewRequest.setCorrespondentAccount(bankAccount.getCorrespondentAccount());
|
||||
bankAccountNewRequest.setCorrespondentAccountName(bankAccount.getCorrespondentAccountName());
|
||||
bankAccountNewRequest.setCurrency(bankAccount.getCurrency());
|
||||
bankAccountNewRequest.setDestination(bankAccount.getDestination());
|
||||
bankAccountNewRequest.setTaxpayerIdentificationNumber(bankAccount.getTaxpayerIdentificationNumber());
|
||||
bankAccountNewRequest.setTaxRegistrationReasonCode(bankAccount.getTaxRegistrationReasonCode());
|
||||
bankAccountNewRequest.setAccount(bankAccount.getAccount());
|
||||
bankAccountNewRequest.setCompanyId(bankAccount.getCompanyId());
|
||||
return bankAccountNewRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,290 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ClearingAccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ClearingAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClearingAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.adapter.ImdgHazelcast;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
import static ru.spcex.clearing.test.config.ImdgTestConfig.currentID;
|
||||
import static ru.spcex.clearing.test.config.KafkaTestConfig.setMockFuture;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
ClearingAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountHelper.class,
|
||||
ClearingAccountService.class,
|
||||
SDFProcessService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class ClearingAccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<ClearingAccount> CLEARING_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator("created", "updated");
|
||||
private static final int PARTITION = 0;
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
private static final String CLEARING_ACCOUNT_TYPE_DICT = "A";
|
||||
private static final String ACCOUNT_VALUE = "account-value";
|
||||
private static final String TRADING_CODE = "trading-code";
|
||||
|
||||
@Autowired
|
||||
ClearingAccountService clearingAccountService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("kafkaTestTemplate")
|
||||
protected KafkaTemplate<String, Object> kafkaTemplate;
|
||||
|
||||
private Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<ClearingAccountTypeDictionary> clearingAccountTypeDictionaryImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
clearingAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
clearingAccountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
company.setTradingCode(TRADING_CODE);
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Clrn.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Clrn.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
ClearingAccountTypeDictionary clearingAccountTypeDictionary = new ClearingAccountTypeDictionary();
|
||||
clearingAccountTypeDictionary.setName(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
clearingAccountTypeDictionary.setCode(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
clearingAccountTypeDictionaryImdg.insert(clearingAccountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void clearingAccountNew() {
|
||||
ClearingAccountNewRequest clearingAccountNewRequest = new ClearingAccountNewRequest();
|
||||
clearingAccountNewRequest.setAccount(ACCOUNT_VALUE);
|
||||
clearingAccountNewRequest.setCompanyId(companyId);
|
||||
clearingAccountNewRequest.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
|
||||
String jsonString = getJsonStringForNew(clearingAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) clearingAccountService.getConsumer(),
|
||||
Consts.DESTINATION_CLEARING_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
predictableAccount.setAccountType(AccountType.Clrn.getKey());
|
||||
predictableAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
|
||||
ClearingAccount predictableClearingAccount = new ClearingAccount();
|
||||
predictableClearingAccount.setCompanyId(companyId);
|
||||
predictableClearingAccount.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
|
||||
Account resultAccountNew = accountImdg.getFirstObjectByFieldValues(Map.of("accountType", AccountType.Clrn.getKey()));
|
||||
ClearingAccount resultClearingAccountNew = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
|
||||
predictableAccount.setId(resultAccountNew.getId());
|
||||
predictableClearingAccount.setAccountId(resultAccountNew.getId());
|
||||
predictableClearingAccount.setId(resultClearingAccountNew.getId());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(resultAccountNew, predictableAccount);
|
||||
CLEARING_ACCOUNT_MATCHER.assertMatch(resultClearingAccountNew, predictableClearingAccount);
|
||||
|
||||
clearingAccountImdg.delete(resultClearingAccountNew);
|
||||
accountImdg.delete(resultAccountNew);
|
||||
}
|
||||
|
||||
@Test
|
||||
void clearingAccountUpdate() {
|
||||
Account existAccount = new Account();
|
||||
existAccount.setAccount(ACCOUNT_VALUE);
|
||||
existAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
existAccount.setAccountType(AccountType.Clrn.getKey());
|
||||
Long accountId = accountImdg.insert(existAccount);
|
||||
|
||||
ClearingAccount existClearingAccount = new ClearingAccount();
|
||||
existClearingAccount.setAccountId(accountId);
|
||||
existClearingAccount.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
existClearingAccount.setCompanyId(companyId);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
predictableAccount.setStatus(ServiceStatus.Blocked.getKey());
|
||||
predictableAccount.setAccountType(AccountType.Clrn.getKey());
|
||||
|
||||
clearingAccountImdg.insert(existClearingAccount);
|
||||
|
||||
ClearingAccountUpdateRequest clearingAccountUpdateRequest = new ClearingAccountUpdateRequest();
|
||||
clearingAccountUpdateRequest.setAccount(ACCOUNT_VALUE);
|
||||
clearingAccountUpdateRequest.setStatus(0);
|
||||
clearingAccountUpdateRequest.setDeal(TRADING_CODE);
|
||||
|
||||
String jsonString = getJsonStringForUpdate(clearingAccountUpdateRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) clearingAccountService.getConsumer(), Consts.DESTINATION_CLEARING_ACCOUNT_UPDATE, PARTITION, 0, jsonString);
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account accountResult = accountImdg.getSingleObjectByID(accountId);
|
||||
predictableAccount.setId(accountResult.getId());
|
||||
predictableAccount.setUpdated(accountResult.getUpdated());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
}
|
||||
|
||||
@Test
|
||||
void makeSdfErrorText() {
|
||||
Assertions.assertEquals("013", clearingAccountService.makeSdfErrorText(AccountError.CompanyNotFound, SDFProcessService.SDF_STATUS_ERROR_COMPANY_NOT_FOUND));
|
||||
Assertions.assertEquals("2", clearingAccountService.makeSdfErrorText(null, SDFProcessService.SDF_STATUS_ERROR_COMPANY_NOT_FOUND));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ClearingAccountService#accountNewSdf01(BaseRequest)}<br>
|
||||
* Тест проверяет создание сущности {@link BaseRequest} в Hazelcast при передаче из Apache Kafka.<br>
|
||||
* Входной запрос {@link AccountSdf01Request}:<br>
|
||||
* {@link AccountSdfRequestPart#setSdfId} - текущий Id<br>
|
||||
* {@link AccountSdfRequestPart#setAccount} - 123456789123<br>
|
||||
* {@link AccountSdfRequestPart#setCompanyId} - текущий Id<br>
|
||||
* {@link AccountSdf01Request#setGroupingSdf01Id} - текущий Id<br>
|
||||
* {@link AccountSdf01Request#setAccounts} - Collections.singletonList(AccountSdfRequestPart)<br>
|
||||
*/
|
||||
@Test
|
||||
void accountSdf01New() throws InterruptedException {
|
||||
//ARRANGE
|
||||
clearImdg(accountImdg);
|
||||
setMockFuture(kafkaTemplate);
|
||||
Long firstID = currentID.getAndIncrement();
|
||||
Long secondID = currentID.getAndIncrement();
|
||||
AccountSdfRequestPart accountSdfRequestPart = new AccountSdfRequestPart();
|
||||
accountSdfRequestPart.setSdfId(firstID);
|
||||
accountSdfRequestPart.setAccount(ACCOUNT_VALUE);
|
||||
accountSdfRequestPart.setCompanyId(firstID);
|
||||
AccountSdf01Request accountSdf01Request = new AccountSdf01Request();
|
||||
accountSdf01Request.setGroupingSdf01Id(firstID);
|
||||
accountSdf01Request.setAccounts(Collections.singletonList(accountSdfRequestPart));
|
||||
|
||||
String jsonString = getJsonStringForNew(accountSdf01Request, 0L);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
predictableAccount.setCompanyId(firstID);
|
||||
predictableAccount.setAccountType(AccountType.Clrn.getKey());
|
||||
predictableAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
ClearingAccount predictableClearingAccount = new ClearingAccount();
|
||||
predictableClearingAccount.setCompanyId(companyId);
|
||||
// predictableClearingAccount.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
|
||||
//KAFKA
|
||||
addRecordToKafka((MockConsumer) clearingAccountService.getConsumer(), Consts.ACCOUNT_NEW_SDF01, PARTITION, 0, jsonString);
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
ImdgHazelcast<Account> accountImdg = (ImdgHazelcast<Account>) hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
|
||||
//ASSERT
|
||||
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", ACCOUNT_VALUE));
|
||||
ClearingAccount resultClearingAccountNew = clearingAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", accountResult.getId()));
|
||||
predictableAccount.setId(accountResult.getId());
|
||||
predictableClearingAccount.setAccountId(accountResult.getId());
|
||||
predictableClearingAccount.setId(resultClearingAccountNew.getId());
|
||||
predictableAccount.setId(accountResult.getId());
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
CLEARING_ACCOUNT_MATCHER.assertMatch(resultClearingAccountNew, predictableClearingAccount);
|
||||
accountImdg.delete(accountResult);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,420 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.account.ClientCode;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.profile.CompanyInfo;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.platform.dictionary.*;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.ClientCodeValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.TradingClearingRegistryValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.TestUtils;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.TradingClearingRegistryType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static ru.spcex.clearing.test.TestUtils.waitingSendAndCheckRecord;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
ClientCodeService.class,
|
||||
ClientCodeValidationConfig.class,
|
||||
|
||||
TradingClearingRegistryService.class,
|
||||
TradingClearingRegistryValidationConfig.class,
|
||||
|
||||
ValidationConfig.class,
|
||||
BeanConfiguration.class,
|
||||
|
||||
KafkaTestConfig.class,
|
||||
ImdgTestConfig.class})
|
||||
class ClientCodeServiceTest {
|
||||
|
||||
private static final int PARTITION = 0;
|
||||
private static final Long ID = 4L;
|
||||
public static final MatcherFactory.Matcher<ClientCode> CLIENT_CODE_MATCHER = MatcherFactory.usingIgnoringFieldsComparator("created", "updated");
|
||||
|
||||
private static final Long TCR_ID = 41L;
|
||||
private static final Long COMPANY_ID = 42L;
|
||||
|
||||
@Autowired
|
||||
ClientCodeService clientCodeService;
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
private Imdg<ClientCode> clientCodeImdg;
|
||||
|
||||
|
||||
// ****************************-*******************
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
clientCodeImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_ClientCode, ClientCode.class);
|
||||
|
||||
// Словари для теста, применяются в ValidationConfig
|
||||
putToDictionary(IMDGDistributedNames.Map_WorkflowStatusDictionary, new WorkflowStatusDictionary(), "ACTV");
|
||||
putToDictionary(IMDGDistributedNames.Map_CompanySymbolDictionary, new CompanySymbolDictionary(), "CLRC");
|
||||
putToDictionary(IMDGDistributedNames.Map_CorporationSoleTypeDictionary, new CorporationSoleTypeDictionary(), "GDIR");
|
||||
putToDictionary(IMDGDistributedNames.Map_CountryCodeDictionary, new CountryCodeDictionary(), "RUS");
|
||||
putToDictionary(IMDGDistributedNames.Map_AllowedDictionary, new AllowedDictionary(), "ALWD");
|
||||
putToDictionary(IMDGDistributedNames.Map_LegalKindDictionary, new LegalKindDictionary(), "JURD");
|
||||
putToDictionary(IMDGDistributedNames.Map_OrganizationTypeDictionary, new OrganizationTypeDictionary(), "NCRD");
|
||||
|
||||
|
||||
Imdg<Company> companyImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
Company company1 = new Company();
|
||||
company1.setId(COMPANY_ID);
|
||||
company1.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
company1.setFullName("Company prime");
|
||||
company1.setShortName("Seizwell");
|
||||
company1.setProfile(new CompanyInfo());
|
||||
company1.getProfile().setCompanyId(COMPANY_ID);
|
||||
company1.getProfile().setCountryCode("TLDI");
|
||||
company1.getProfile().setDescription("Big profit from TLD Company Prime.");
|
||||
company1.getProfile().setLegalKind("TLDI");
|
||||
company1.getProfile().setResidence("TLDI");
|
||||
companyImdg.insert(company1);
|
||||
|
||||
Imdg<TradingClearingRegistry> tcrImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
TradingClearingRegistry registry1 = new TradingClearingRegistry();
|
||||
registry1.setId(TCR_ID);
|
||||
registry1.setCompanyId(COMPANY_ID);
|
||||
registry1.setCode("code-120-101");
|
||||
registry1.setMoneyAccountId(131L);
|
||||
registry1.setDepoAccountId(132L);
|
||||
registry1.setTradingClearingRegistryType(TradingClearingRegistryType.Client_B.getKey());
|
||||
registry1.setStatus(WorkflowStatus.Active.getKey());
|
||||
tcrImdg.insert(registry1);
|
||||
|
||||
Imdg<Account> accounts = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Imdg<ClearingAccount> clsAccounts = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
Account moneyAccount = new Account();
|
||||
moneyAccount.setId(131L);
|
||||
moneyAccount.setAccount("AAAA-4444");
|
||||
moneyAccount.setStatus("ACTV");
|
||||
moneyAccount.setCompanyId(COMPANY_ID); // для валидации принадлежности счёта
|
||||
accounts.insert(moneyAccount);
|
||||
ClearingAccount clsAcc = new ClearingAccount();
|
||||
clsAcc.setId(moneyAccount.getId());
|
||||
clsAcc.setCompanyId(COMPANY_ID);
|
||||
clsAcc.setAccountId(moneyAccount.getId());
|
||||
clsAccounts.insert(clsAcc);
|
||||
Imdg<DepoAccount> depoAccounts = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
Account depoAccount = new Account();
|
||||
depoAccount.setId(132L);
|
||||
depoAccount.setAccount("AAAB-44654");
|
||||
depoAccount.setStatus("ACTV");
|
||||
depoAccount.setCompanyId(COMPANY_ID); // для валидации принадлежности счёта
|
||||
accounts.insert(depoAccount);
|
||||
DepoAccount depoAcc = new DepoAccount();
|
||||
depoAcc.setId(depoAccount.getId());
|
||||
depoAcc.setCompanyId(COMPANY_ID);
|
||||
depoAcc.setAccountId(depoAccount.getId());
|
||||
depoAccounts.insert(depoAcc);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
private <D extends AbstractDictionary> void putToDictionary(String mapName, D object, String code) {
|
||||
Imdg<D> dMap = (Imdg) hazelcastServiceTest.getImdg(mapName, object.getClass());
|
||||
object.setId(2L);
|
||||
object.setCode(code);
|
||||
object.setName("name of " + code);
|
||||
dMap.insert(object);
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectTradingClearingRegistry() {
|
||||
TradingClearingRegistry tcr = clientCodeService.selectTradingClearingRegistry(COMPANY_ID, 131L, 132L);
|
||||
assertNotNull(tcr);
|
||||
assertEquals(41L, tcr.getId());
|
||||
|
||||
tcr = clientCodeService.selectTradingClearingRegistry(COMPANY_ID, 131L, null);
|
||||
assertNotNull(tcr);
|
||||
assertEquals(41L, tcr.getId());
|
||||
|
||||
assertNull(clientCodeService.selectTradingClearingRegistry(0L, 131L, 132L));
|
||||
assertNull(clientCodeService.selectTradingClearingRegistry(COMPANY_ID, 0L, 132L));
|
||||
assertNull(clientCodeService.selectTradingClearingRegistry(COMPANY_ID, 131L, 0L));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@link ClientCodeService#clientCodeUpdate(BaseRequest)}<br>
|
||||
* Тест проверяет создание {@link ClientCode} в IMDG при передаче из Apache Kafka (очередь 1).<br>
|
||||
* Входной запрос {@link ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest}:<br>
|
||||
**/
|
||||
@Test
|
||||
void clientCodeNew1() {
|
||||
//ARRANGE
|
||||
final String ccCode = "Lucky planet";
|
||||
ClientCodeNewRequest clientCodeNewRequest = new ClientCodeNewRequest();
|
||||
clientCodeNewRequest.setCompanyId(COMPANY_ID);
|
||||
clientCodeNewRequest.setCode(ccCode);
|
||||
clientCodeNewRequest.setTradingClearingRegistryId(TCR_ID);
|
||||
clientCodeNewRequest.setDepoAccountId(null);
|
||||
clientCodeNewRequest.setMoneyAccountId(null);
|
||||
clientCodeNewRequest.setStatus("ACTV");
|
||||
|
||||
ClientCode predictableClientCode = new ClientCode();
|
||||
predictableClientCode.setCode(ccCode);
|
||||
predictableClientCode.setStatus("ACTV");
|
||||
predictableClientCode.setCompanyId(COMPANY_ID);
|
||||
// predictableClientCode.setMoneyAccountId(131L);
|
||||
// predictableClientCode.setDepoAccountId(132L);
|
||||
// predictableClientCode.setTradingClearingRegistryId(TCR_ID);
|
||||
|
||||
//ACT
|
||||
String jsonString = TestUtils.getJsonStringForNew(clientCodeNewRequest, ID);
|
||||
|
||||
TestUtils.addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_NEW, PARTITION, 0, jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
predictableClientCode.setId(resultNew.getId());
|
||||
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
||||
assertNotNull(resultNew.getCreated());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ClientCodeService#clientCodeUpdate(BaseRequest)}<br>
|
||||
* Тест проверяет создание {@link ClientCode} в IMDG при передаче из Apache Kafka (очередь 2).<br>
|
||||
* Входной запрос {@link ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest}:<br>
|
||||
**/
|
||||
@Test
|
||||
void clientCodeNew2() {
|
||||
//ARRANGE
|
||||
final String ccCode = "Lucky planet";
|
||||
ClientCodeNewRequest clientCodeNewRequest = new ClientCodeNewRequest();
|
||||
clientCodeNewRequest.setCompanyId(COMPANY_ID);
|
||||
clientCodeNewRequest.setCode(ccCode);
|
||||
clientCodeNewRequest.setTradingClearingRegistryId(TCR_ID);
|
||||
clientCodeNewRequest.setDepoAccountId(null);
|
||||
clientCodeNewRequest.setMoneyAccountId(null);
|
||||
clientCodeNewRequest.setStatus("ACTV");
|
||||
|
||||
ClientCode predictableClientCode = new ClientCode();
|
||||
predictableClientCode.setCode(ccCode);
|
||||
predictableClientCode.setStatus("ACTV");
|
||||
predictableClientCode.setCompanyId(COMPANY_ID);
|
||||
// predictableClientCode.setMoneyAccountId(131L);
|
||||
// predictableClientCode.setDepoAccountId(132L);
|
||||
// predictableClientCode.setTradingClearingRegistryId(TCR_ID);
|
||||
|
||||
//ACT
|
||||
String jsonString = TestUtils.getJsonStringForNew(clientCodeNewRequest, ID);
|
||||
|
||||
TestUtils.addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_NEW_UM_COMPANY, PARTITION, 0, jsonString);
|
||||
|
||||
//ASSERT
|
||||
TestUtils.waitingSendAndCheckRecord(ID, mockProducer, producerRecord);
|
||||
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
predictableClientCode.setId(resultNew.getId());
|
||||
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
||||
assertNotNull(resultNew.getCreated());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@link ClientCodeService#clientCodeUpdate(BaseRequest)}<br>
|
||||
* Тест проверяет создание {@link ClientCode} в IMDG при передаче из Apache Kafka (очередь 1).<br>
|
||||
* NEW с заполненными MoneyAccountId(131L), DepoAccountId(132L); - от этого будет создан ТКР.
|
||||
* Входной запрос {@link ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeNewRequest}:<br>
|
||||
**/
|
||||
@Test
|
||||
void clientCodeNew3() {
|
||||
//ARRANGE
|
||||
final String ccCode = "Lucky planet2";
|
||||
ClientCodeNewRequest clientCodeNewRequest = new ClientCodeNewRequest();
|
||||
clientCodeNewRequest.setCompanyId(COMPANY_ID);
|
||||
clientCodeNewRequest.setCode(ccCode);
|
||||
clientCodeNewRequest.setTradingClearingRegistryId(null);
|
||||
clientCodeNewRequest.setMoneyAccountId(131L);
|
||||
clientCodeNewRequest.setDepoAccountId(132L);
|
||||
clientCodeNewRequest.setStatus("ACTV");
|
||||
|
||||
ClientCode predictableClientCode = new ClientCode();
|
||||
predictableClientCode.setCode(ccCode);
|
||||
predictableClientCode.setStatus("ACTV");
|
||||
predictableClientCode.setCompanyId(COMPANY_ID);
|
||||
predictableClientCode.setMoneyAccountId(131L);
|
||||
predictableClientCode.setDepoAccountId(132L);
|
||||
predictableClientCode.setTradingClearingRegistryId(TCR_ID);
|
||||
|
||||
//ACT
|
||||
String jsonString = TestUtils.getJsonStringForNew(clientCodeNewRequest, ID);
|
||||
|
||||
TestUtils.addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_NEW, PARTITION, 0, jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
predictableClientCode.setId(resultNew.getId());
|
||||
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
||||
assertNotNull(resultNew.getCreated());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ClientCodeService#clientCodeUpdate(BaseRequest)}<br>
|
||||
* Тест проверяет обновление сущности {@link ClientCode} в IMDG при передаче из Apache Kafka.<br>
|
||||
* Входной запрос {@link ru.spcex.clearing.platform.messaging.domain.cud.account.ClientCodeUpdateRequest}:<br>
|
||||
**/
|
||||
@Test
|
||||
void clientCodeUpdate() {
|
||||
//ARRANGE
|
||||
ClientCode existsClientCode = new ClientCode();
|
||||
existsClientCode.setId(ID);
|
||||
existsClientCode.setCompanyId(COMPANY_ID);
|
||||
existsClientCode.setCode("0000");
|
||||
existsClientCode.setTradingClearingRegistryId(TCR_ID);
|
||||
existsClientCode.setMoneyAccountId(131L);
|
||||
existsClientCode.setDepoAccountId(132L);
|
||||
existsClientCode.setStatus("ACTV");
|
||||
clientCodeImdg.insert(existsClientCode);
|
||||
|
||||
ClientCodeUpdateRequest clientCodeUpdateRequest = new ClientCodeUpdateRequest();
|
||||
clientCodeUpdateRequest.setId(ID);
|
||||
clientCodeUpdateRequest.setCompanyId(COMPANY_ID);
|
||||
clientCodeUpdateRequest.setCode("1111");
|
||||
clientCodeUpdateRequest.setTradingClearingRegistryId(TCR_ID);
|
||||
clientCodeUpdateRequest.setMoneyAccountId(131L);
|
||||
clientCodeUpdateRequest.setDepoAccountId(132L);
|
||||
clientCodeUpdateRequest.setStatus("ACTV");
|
||||
|
||||
ClientCode predictableClientCode = new ClientCode();
|
||||
predictableClientCode.setId(ID);
|
||||
predictableClientCode.setCompanyId(COMPANY_ID);
|
||||
predictableClientCode.setCode("1111");
|
||||
predictableClientCode.setTradingClearingRegistryId(TCR_ID);
|
||||
predictableClientCode.setMoneyAccountId(131L);
|
||||
predictableClientCode.setDepoAccountId(132L);
|
||||
predictableClientCode.setStatus("ACTV");
|
||||
|
||||
//ACT
|
||||
String jsonString = TestUtils.getJsonStringForUpdate(clientCodeUpdateRequest, ID);
|
||||
|
||||
TestUtils.addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_UPDATE, PARTITION, 0, jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
|
||||
ClientCode resultUpdating = clientCodeImdg.getSingleObjectByID(ID);
|
||||
CLIENT_CODE_MATCHER.assertMatch(resultUpdating, predictableClientCode);
|
||||
assertNotNull(resultUpdating.getUpdated());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@link ClientCodeService#clientCodeUpdate(BaseRequest)}<br>
|
||||
* Тест проверяет удаление {@link ClientCode} из IMDG при передаче из Apache Kafka.<br>
|
||||
* Входной запрос {@link ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest}:<br>
|
||||
**/
|
||||
@Test
|
||||
void clientCodeDelete1() {
|
||||
//ARRANGE
|
||||
ClientCode existsClientCode = new ClientCode();
|
||||
existsClientCode.setId(ID);
|
||||
existsClientCode.setCompanyId(COMPANY_ID);
|
||||
existsClientCode.setCode("0000");
|
||||
// Если следующие поля заполнить, то дополнительно отправит сообщение в trading-clearing-registry-update:
|
||||
existsClientCode.setTradingClearingRegistryId(null);
|
||||
existsClientCode.setMoneyAccountId(null);
|
||||
existsClientCode.setDepoAccountId(null);
|
||||
existsClientCode.setStatus("ACTV");
|
||||
|
||||
clientCodeImdg.insert(existsClientCode);
|
||||
|
||||
CommonDeleteRequest clientCodeDeleteRequest = new CommonDeleteRequest();
|
||||
clientCodeDeleteRequest.setId(ID);
|
||||
|
||||
Assertions.assertNotNull(clientCodeImdg.getSingleObjectByID(ID)); // verify test data
|
||||
|
||||
//ACT
|
||||
String jsonString = TestUtils.getJsonStringForUpdate(clientCodeDeleteRequest, ID);
|
||||
|
||||
TestUtils.addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_DELETE, PARTITION, 0, jsonString);
|
||||
|
||||
//ASSERT
|
||||
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
ClientCode resultUpdate = clientCodeImdg.getSingleObjectByID(ID);
|
||||
assertEquals(WorkflowStatus.Blocked.getKey(), resultUpdate.getStatus());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * {@link ClientCodeService#clientCodeUpdate(BaseRequest)}<br>
|
||||
// * Тест проверяет удаление {@link ClientCode} из IMDG при передаче из Apache Kafka.<br>
|
||||
// * У ClientCode заполнены MoneyAccountId, DepoAccountId - по этому при удалении должно направиться дополнительное сообщение в очередь DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE<br>
|
||||
// * Входной запрос {@link ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest}:<br>
|
||||
// **/
|
||||
// @Test
|
||||
// void clientCodeDelete2() {
|
||||
// //ARRANGE
|
||||
// ClientCode existsClientCode = new ClientCode();
|
||||
// existsClientCode.setId(ID);
|
||||
// existsClientCode.setCompanyId(COMPANY_ID);
|
||||
// existsClientCode.setCode("0000");
|
||||
// // Если следующие поля заполнить, то дополнительно отправит сообщение в trading-clearing-registry-update:
|
||||
// existsClientCode.setTradingClearingRegistryId(TCR_ID);
|
||||
// existsClientCode.setMoneyAccountId(131L);
|
||||
// existsClientCode.setDepoAccountId(132L);
|
||||
// existsClientCode.setStatus("ACTV");
|
||||
//
|
||||
// clientCodeImdg.insert(existsClientCode);
|
||||
//
|
||||
// CommonDeleteRequest clientCodeDeleteRequest = new CommonDeleteRequest();
|
||||
// clientCodeDeleteRequest.setId(ID);
|
||||
//
|
||||
// Assertions.assertNotNull(clientCodeImdg.getSingleObjectByID(ID)); // verify test data
|
||||
//
|
||||
// //ACT
|
||||
// String jsonString = getJsonStringForUpdate(clientCodeDeleteRequest, ID);
|
||||
//
|
||||
// addRecordToKafka((MockConsumer) clientCodeService.getConsumer(), Consts.DESTINATION_CLIENT_CODE_DELETE, PARTITION, 0, jsonString);
|
||||
//
|
||||
// //ASSERT
|
||||
//
|
||||
// waitingWhenAddedRecordAndCheckIt(ID, mockProducer, producerRecord);
|
||||
// ClientCode resultUpdate = clientCodeImdg.getSingleObjectByID(ID);
|
||||
// Assertions.assertNull(resultUpdate);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.DepoAccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.DepoAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.DepoAccountNewRequest;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
DepoAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountHelper.class,
|
||||
DepoAccountService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class DepoAccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<DepoAccount> CLEARING_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator("created", "updated");
|
||||
private static final int PARTITION = 0;
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
private static final String DEPO_ACCOUNT_TYPE_DICT = "A";
|
||||
private static final String ACCOUNT_VALUE = "account-value";
|
||||
private static final String TRADING_CODE = "trading-code";
|
||||
|
||||
@Autowired
|
||||
DepoAccountService depoAccountService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
private Imdg<DepoAccount> depoAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<DepoAccountTypeDictionary> depoAccountTypeDictionaryImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
depoAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_DepoAccount, DepoAccount.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
depoAccountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_DepoAccountTypeDictionary, DepoAccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
company.setTradingCode(TRADING_CODE);
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Depo.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Depo.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
DepoAccountTypeDictionary depoAccountTypeDictionary = new DepoAccountTypeDictionary();
|
||||
depoAccountTypeDictionary.setName(DEPO_ACCOUNT_TYPE_DICT);
|
||||
depoAccountTypeDictionary.setCode(DEPO_ACCOUNT_TYPE_DICT);
|
||||
depoAccountTypeDictionaryImdg.insert(depoAccountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void depoAccountNew() {
|
||||
DepoAccountNewRequest depoAccountNewRequest = new DepoAccountNewRequest();
|
||||
depoAccountNewRequest.setAccount(ACCOUNT_VALUE);
|
||||
depoAccountNewRequest.setCompanyId(companyId);
|
||||
depoAccountNewRequest.setDepoAccountType(DEPO_ACCOUNT_TYPE_DICT);
|
||||
|
||||
String jsonString = getJsonStringForNew(depoAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) depoAccountService.getConsumer(),
|
||||
Consts.DESTINATION_DEPO_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
predictableAccount.setAccountType(AccountType.Depo.getKey());
|
||||
predictableAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
|
||||
DepoAccount predictableDepoAccount = new DepoAccount();
|
||||
predictableDepoAccount.setCompanyId(companyId);
|
||||
predictableDepoAccount.setDepoAccountType(DEPO_ACCOUNT_TYPE_DICT);
|
||||
|
||||
Account resultAccountNew = accountImdg.getFirstObjectByFieldValues(Map.of("accountType", AccountType.Depo.getKey()));
|
||||
DepoAccount resultDepoAccountNew = depoAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
|
||||
predictableAccount.setId(resultAccountNew.getId());
|
||||
predictableDepoAccount.setAccountId(resultAccountNew.getId());
|
||||
predictableDepoAccount.setId(resultDepoAccountNew.getId());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(resultAccountNew, predictableAccount);
|
||||
CLEARING_ACCOUNT_MATCHER.assertMatch(resultDepoAccountNew, predictableDepoAccount);
|
||||
|
||||
depoAccountImdg.delete(resultDepoAccountNew);
|
||||
accountImdg.delete(resultAccountNew);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.AccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.InformationAccountValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.InformationAccountNewRequest;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
InformationAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountHelper.class,
|
||||
InformationAccountService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class InformationAccountServiceTest {
|
||||
public static final MatcherFactory.Matcher<InformationAccount> INFORMATION_ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator("created", "updated");
|
||||
private static final int PARTITION = 0;
|
||||
private static final String account = "123456789123";
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
private Long anltAccountId;
|
||||
|
||||
@Autowired
|
||||
InformationAccountService informationAccountService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
private Imdg<InformationAccount> informationAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
informationAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
clearImdg(accountImdg);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
companyImdg.insert(company);
|
||||
|
||||
AccountTypeDictionary accountTypeDictionary = new AccountTypeDictionary();
|
||||
accountTypeDictionary.setCode(AccountType.Info.getKey());
|
||||
accountTypeDictionary.setName(AccountType.Info.getKey());
|
||||
accountTypeDictionaryImdg.insert(accountTypeDictionary);
|
||||
|
||||
ClearingMemberCategory clearingMemberCategory = new ClearingMemberCategory();
|
||||
clearingMemberCategory.setClearingMemberCategory(ClearingCategory.B.getKey());
|
||||
clearingMemberCategory.setCompanyId(companyId);
|
||||
clearingMemberCategoryImdg.insert(clearingMemberCategory);
|
||||
|
||||
Relation relation = new Relation();
|
||||
relation.setId(relationId);
|
||||
relation.setConsumerId(companyId);
|
||||
relation.setService(Service.MKR.getKey());
|
||||
relationImdg.insert(relation);
|
||||
|
||||
Account accountAnlt = new Account();
|
||||
accountAnlt.setAccountType(AccountType.Anlt.getKey());
|
||||
accountAnlt.setCompanyId(1L);
|
||||
anltAccountId = accountImdg.insert(accountAnlt);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountInformationNew() {
|
||||
InformationAccountNewRequest InformationAccountNewRequest = new InformationAccountNewRequest();
|
||||
InformationAccountNewRequest.setCompanyId(companyId);
|
||||
InformationAccountNewRequest.setAccount(account);
|
||||
|
||||
String jsonString = getJsonStringForNew(InformationAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) informationAccountService.getConsumer(),
|
||||
Consts.DESTINATION_INFORMATION_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccountType(AccountType.Info.getKey());
|
||||
predictableAccount.setStatus(ServiceStatus.Active.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
predictableAccount.setCompanyId(companyId);
|
||||
|
||||
InformationAccount predictableInfoAccount = new InformationAccount();
|
||||
predictableInfoAccount.setCompanyId(companyId);
|
||||
predictableInfoAccount.setClearingAccountId(anltAccountId);
|
||||
|
||||
Account resultAccountNew = accountImdg.getFirstObjectByFieldValues(Map.of("accountType", AccountType.Info.getKey()));
|
||||
InformationAccount resultInfoAccountNew = informationAccountImdg.getFirstObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
|
||||
predictableAccount.setId(resultAccountNew.getId());
|
||||
predictableAccount.setAccount(account);
|
||||
predictableInfoAccount.setAccountId(resultAccountNew.getId());
|
||||
predictableInfoAccount.setId(resultInfoAccountNew.getId());
|
||||
|
||||
ACCOUNT_MATCHER.assertMatch(resultAccountNew, predictableAccount);
|
||||
INFORMATION_ACCOUNT_MATCHER.assertMatch(resultInfoAccountNew, predictableInfoAccount);
|
||||
|
||||
informationAccountImdg.delete(resultInfoAccountNew);
|
||||
accountImdg.delete(resultAccountNew);
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountIncrementSequence() {
|
||||
Imdg<InformationAccount> accountInfoImdg = hazelcastServiceTest.getImdg( IMDGDistributedNames.Map_InformationAccount, InformationAccount.class );
|
||||
|
||||
{
|
||||
Account account = new Account();
|
||||
account.setId(120L);
|
||||
account.setAccountType(AccountType.Info.getKey());
|
||||
account.setCompanyId(10L);
|
||||
account.setAccount("39911810000000127000");
|
||||
accountImdg.insert(account);
|
||||
InformationAccount accountInfo = new InformationAccount();
|
||||
accountInfo.setId(121L);
|
||||
accountInfo.setAccountId(account.getId());
|
||||
accountInfo.setCompanyId(account.getCompanyId());
|
||||
accountInfoImdg.insert(accountInfo);
|
||||
}
|
||||
UserRoleVerification userRoleVerification = Mockito.mock(UserRoleVerification.class);
|
||||
InformationAccountService infoAccSvc=new InformationAccountService(null,null,null,
|
||||
null, userRoleVerification, hazelcastServiceTest, null, null, null, null);
|
||||
Long n = infoAccSvc.accountNextId();
|
||||
Assertions.assertEquals(13L, n);
|
||||
n = infoAccSvc.accountNextId();
|
||||
Assertions.assertEquals(14L, n);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.producer.MockProducer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.clearing.platform.dictionary.ClearingAccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.AccountStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
SDFProcessService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class SDFProcessServiceTest {
|
||||
@Autowired
|
||||
SDFProcessService sdfProcessService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
private Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private Imdg<Account> accountImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<ClearingAccountTypeDictionary> clearingAccountTypeDictionaryImdg;
|
||||
private Imdg<AccountTypeDictionary> accountTypeDictionaryImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<Relation> relationImdg;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
clearingAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
accountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class
|
||||
);
|
||||
clearingAccountTypeDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccountTypeDictionary, ClearingAccountTypeDictionary.class
|
||||
);
|
||||
clearingMemberCategoryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class
|
||||
);
|
||||
relationImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Relation, Relation.class
|
||||
);
|
||||
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseSdf52Status() {
|
||||
Assertions.assertEquals(AccountStatus.BLOCKED, sdfProcessService.parseSdf52Status(0L));
|
||||
Assertions.assertEquals(AccountStatus.ACTIVE, sdfProcessService.parseSdf52Status(1L));
|
||||
Assertions.assertEquals(AccountStatus.ACTIVE, sdfProcessService.parseSdf52Status(3L));
|
||||
Assertions.assertEquals(AccountStatus.CLOSE, sdfProcessService.parseSdf52Status(2L));
|
||||
Assertions.assertEquals(null, sdfProcessService.parseSdf52Status(4705211956118233163L));
|
||||
Assertions.assertEquals(null, sdfProcessService.parseSdf52Status(null));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,357 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||
import ru.spcex.clearing.account.config.BeanConfiguration;
|
||||
import ru.spcex.clearing.account.config.validation.TradingClearingRegistryValidationConfig;
|
||||
import ru.spcex.clearing.account.config.validation.ValidationConfig;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryUpdateRequest;
|
||||
import ru.spcex.clearing.test.MatcherFactory;
|
||||
import ru.spcex.clearing.test.TestObjectCreator;
|
||||
import ru.spcex.clearing.test.config.ImdgTestConfig;
|
||||
import ru.spcex.clearing.test.config.KafkaTestConfig;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
import static ru.spcex.clearing.test.config.KafkaTestConfig.setMockFuture;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
BeanConfiguration.class,
|
||||
ValidationConfig.class,
|
||||
TradingClearingRegistryValidationConfig.class,
|
||||
TradingClearingRegistryService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class TradingClearingRegistryServiceTest {
|
||||
public static final MatcherFactory.Matcher<TradingClearingRegistry> TRADING_CLEARING_REGISTRY_MATCHER = usingIgnoringFieldsComparator();
|
||||
private static final int PARTITION = 0;
|
||||
private static final String TOPIC_ACCOUNT_NEW = Consts.ACCOUNT_NEW_SDF01;
|
||||
private static final String account = "123456789123";
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
@Autowired
|
||||
TradingClearingRegistryService tradingClearingRegistryService;
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("kafkaTestTemplate")
|
||||
protected KafkaTemplate<String, Object> kafkaTemplate;
|
||||
|
||||
private Imdg<TradingClearingRegistry> tradingClearingRegistryImdg;
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<CompanySymbols> companySymbolsImdg;
|
||||
private Imdg<ServiceStatusDictionary> serviceStatusDictionaryImdg;
|
||||
|
||||
private Imdg<ClearingAccount> clearingAccountImdg;
|
||||
private Long clearingAccountId;
|
||||
|
||||
private Imdg<DepoAccount> depoAccountImdg;
|
||||
private Long depoAccountId;
|
||||
|
||||
private Imdg<InformationAccount> informationAccountImdg;
|
||||
private Long infoAccountId;
|
||||
|
||||
private Imdg<Account> accountImdg;
|
||||
private Long accountId;
|
||||
|
||||
private Long account2Id;
|
||||
|
||||
static int newRequestCnt = 0;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
hazelcastServiceTest.waitAvailable();
|
||||
tradingClearingRegistryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class
|
||||
);
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
companySymbolsImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class
|
||||
);
|
||||
serviceStatusDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary, ServiceStatusDictionary.class
|
||||
);
|
||||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
clearingAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class
|
||||
);
|
||||
depoAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_DepoAccount, DepoAccount.class
|
||||
);
|
||||
informationAccountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
ServiceStatusDictionary serviceStatusDictionary = new ServiceStatusDictionary();
|
||||
serviceStatusDictionary.setCode(ServiceStatus.Active.getKey());
|
||||
serviceStatusDictionary.setName(ServiceStatus.Active.getKey());
|
||||
serviceStatusDictionaryImdg.insert(serviceStatusDictionary);
|
||||
|
||||
Company company = new Company();
|
||||
company.setId(companyId);
|
||||
company.setWorkflowStatus(WorkflowStatus.Active.getKey());
|
||||
company.setClearingCode("77");
|
||||
companyImdg.insert(company);
|
||||
|
||||
CompanySymbols companySymbols = new CompanySymbols();
|
||||
companySymbols.setCompanyId(companyId);
|
||||
companySymbols.setCompanySymbol(CompanySymbol.CLRC.getKey());
|
||||
companySymbolsImdg.insert(companySymbols);
|
||||
|
||||
Account account = new Account();
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
accountId = accountImdg.insert(account);
|
||||
|
||||
account2Id = accountImdg.insert(account);
|
||||
|
||||
DepoAccount depoAccount = new DepoAccount();
|
||||
depoAccount.setAccountId(accountId);
|
||||
depoAccount.setDepoAccountType("DAT");
|
||||
depoAccountId = depoAccountImdg.insert(depoAccount);
|
||||
|
||||
ClearingAccount clearingAccount = new ClearingAccount();
|
||||
clearingAccount.setAccountId(accountId);
|
||||
clearingAccount.setClearingAccountType("CAT");
|
||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||
|
||||
InformationAccount informationAccount = new InformationAccount();
|
||||
informationAccount.setAccountId(account2Id);
|
||||
infoAccountId = informationAccountImdg.insert(informationAccount);
|
||||
|
||||
new TestObjectCreator(hazelcastServiceTest).createUserAdmin(1000L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void tradingClearingRegistryNew_moneyAccount_clearingAccount() {
|
||||
setMockFuture(kafkaTemplate);
|
||||
TradingClearingRegistryNewRequest tradingClearingRegistryNewRequest = new TradingClearingRegistryNewRequest();
|
||||
tradingClearingRegistryNewRequest.setCompanyId(companyId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(accountId);
|
||||
tradingClearingRegistryNewRequest.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
|
||||
TradingClearingRegistry predictableTradingClearingRegistry = new TradingClearingRegistry();
|
||||
predictableTradingClearingRegistry.setCompanyId(companyId);
|
||||
predictableTradingClearingRegistry.setCode("0077MAT00001");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(accountId);
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryPurpose(TradingClearingRegistryPurpose.M.getKey());
|
||||
predictableTradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
|
||||
String jsonString = getJsonStringForNew(tradingClearingRegistryNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) tradingClearingRegistryService.getConsumer(),
|
||||
Consts.DESTINATION_TRADING_CLEARING_REGISTRY_NEW,
|
||||
newRequestCnt,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultNew = tradingClearingRegistryImdg.getAllValues().iterator().next();
|
||||
predictableTradingClearingRegistry.setId(resultNew.getId());
|
||||
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
||||
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
||||
|
||||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultNew, predictableTradingClearingRegistry);
|
||||
tradingClearingRegistryImdg.delete(resultNew);
|
||||
|
||||
newRequestCnt++;
|
||||
}
|
||||
|
||||
@Test
|
||||
void tradingClearingRegistryNew_moneyAccount_informationAccount() {
|
||||
setMockFuture(kafkaTemplate);
|
||||
clearImdg(tradingClearingRegistryImdg);
|
||||
TradingClearingRegistryNewRequest tradingClearingRegistryNewRequest = new TradingClearingRegistryNewRequest();
|
||||
tradingClearingRegistryNewRequest.setCompanyId(companyId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(account2Id);
|
||||
tradingClearingRegistryNewRequest.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
|
||||
TradingClearingRegistry predictableTradingClearingRegistry = new TradingClearingRegistry();
|
||||
predictableTradingClearingRegistry.setCompanyId(companyId);
|
||||
predictableTradingClearingRegistry.setCode("0077MAT00001");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(account2Id);
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryPurpose(TradingClearingRegistryPurpose.M.getKey());
|
||||
predictableTradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
|
||||
String jsonString = getJsonStringForNew(tradingClearingRegistryNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) tradingClearingRegistryService.getConsumer(),
|
||||
Consts.DESTINATION_TRADING_CLEARING_REGISTRY_NEW,
|
||||
newRequestCnt,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultNew = tradingClearingRegistryImdg.getAllValues().iterator().next();
|
||||
predictableTradingClearingRegistry.setId(resultNew.getId());
|
||||
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
||||
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
||||
|
||||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultNew, predictableTradingClearingRegistry);
|
||||
tradingClearingRegistryImdg.delete(resultNew);
|
||||
|
||||
newRequestCnt++;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void tradingClearingRegistryNew_depoAccount() {
|
||||
setMockFuture(kafkaTemplate);
|
||||
clearImdg(tradingClearingRegistryImdg);
|
||||
TradingClearingRegistryNewRequest tradingClearingRegistryNewRequest = new TradingClearingRegistryNewRequest();
|
||||
tradingClearingRegistryNewRequest.setCompanyId(companyId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(accountId);
|
||||
tradingClearingRegistryNewRequest.setDepoAccountId(account2Id);
|
||||
|
||||
TradingClearingRegistry predictableTradingClearingRegistry = new TradingClearingRegistry();
|
||||
predictableTradingClearingRegistry.setCompanyId(companyId);
|
||||
predictableTradingClearingRegistry.setCode("0077CDATT00001");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(accountId);
|
||||
predictableTradingClearingRegistry.setDepoAccountId(account2Id);
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryType("DAT");
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryPurpose(TradingClearingRegistryPurpose.C.getKey());
|
||||
predictableTradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
|
||||
String jsonString = getJsonStringForNew(tradingClearingRegistryNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) tradingClearingRegistryService.getConsumer(),
|
||||
Consts.DESTINATION_TRADING_CLEARING_REGISTRY_NEW,
|
||||
newRequestCnt,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultNew = tradingClearingRegistryImdg.getAllValues().iterator().next();
|
||||
predictableTradingClearingRegistry.setId(resultNew.getId());
|
||||
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
||||
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
||||
|
||||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultNew, predictableTradingClearingRegistry);
|
||||
tradingClearingRegistryImdg.delete(resultNew);
|
||||
|
||||
newRequestCnt++;
|
||||
}
|
||||
|
||||
@Test
|
||||
void tradingClearingRegistryUpdate() {
|
||||
TradingClearingRegistry existTradingClearingRegistry = new TradingClearingRegistry();
|
||||
existTradingClearingRegistry.setStatus(ServiceStatus.Closed.getKey());
|
||||
Long registryId = tradingClearingRegistryImdg.insert(existTradingClearingRegistry);
|
||||
|
||||
TradingClearingRegistryUpdateRequest tradingClearingRegistryUpdateRequest = new TradingClearingRegistryUpdateRequest();
|
||||
tradingClearingRegistryUpdateRequest.setStatus(ServiceStatus.Active.getKey());
|
||||
tradingClearingRegistryUpdateRequest.setId(registryId);
|
||||
|
||||
String jsonString = getJsonStringForUpdate(tradingClearingRegistryUpdateRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) tradingClearingRegistryService.getConsumer(),
|
||||
Consts.DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultUpdating = tradingClearingRegistryImdg.getSingleObjectByID(registryId);
|
||||
existTradingClearingRegistry.setUpdated(resultUpdating.getUpdated());
|
||||
existTradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultUpdating, existTradingClearingRegistry);
|
||||
tradingClearingRegistryImdg.delete(resultUpdating);
|
||||
}
|
||||
|
||||
@Test
|
||||
void tradingClearingRegistryBlock() {
|
||||
TradingClearingRegistry existTradingClearingRegistry = new TradingClearingRegistry();
|
||||
existTradingClearingRegistry.setStatus(ServiceStatus.Closed.getKey());
|
||||
Long registryId = tradingClearingRegistryImdg.insert(existTradingClearingRegistry);
|
||||
|
||||
CommonDeleteRequest tradingClearingRegistryDeleteRequest = new CommonDeleteRequest();
|
||||
tradingClearingRegistryDeleteRequest.setId(registryId);
|
||||
|
||||
String jsonString = getJsonStringForDelete(tradingClearingRegistryDeleteRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) tradingClearingRegistryService.getConsumer(),
|
||||
Consts.DESTINATION_TRADING_CLEARING_REGISTRY_BLOCK,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultUpdating = tradingClearingRegistryImdg.getSingleObjectByID(registryId);
|
||||
existTradingClearingRegistry.setUpdated(resultUpdating.getUpdated());
|
||||
existTradingClearingRegistry.setStatus(ServiceStatus.Blocked.getKey());
|
||||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultUpdating, existTradingClearingRegistry);
|
||||
tradingClearingRegistryImdg.delete(resultUpdating);
|
||||
}
|
||||
|
||||
@Test
|
||||
void makeCode() {
|
||||
Assertions.assertEquals("0005CAT00001", tradingClearingRegistryService.makeCode(
|
||||
"5", TradingClearingRegistryPurpose.C, TradingClearingRegistryType.Owner_A.getKey(), 1L
|
||||
));
|
||||
Assertions.assertEquals("0005CET00012", tradingClearingRegistryService.makeCode(
|
||||
"005", TradingClearingRegistryPurpose.C, "E", 12L
|
||||
));
|
||||
Assertions.assertEquals("0105CERT00012", tradingClearingRegistryService.makeCode(
|
||||
"000000105", TradingClearingRegistryPurpose.C, "ER", 100012L
|
||||
));
|
||||
|
||||
Assertions.assertEquals("0105MAT00012", tradingClearingRegistryService.makeCode(
|
||||
"000000105", TradingClearingRegistryPurpose.M, "A", 100012L
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseCodeSeqId() {
|
||||
Assertions.assertEquals(Long.valueOf(1L), tradingClearingRegistryService.parseCodeSeqId("0005CAT00001"));
|
||||
Assertions.assertEquals(Long.valueOf(5001), tradingClearingRegistryService.parseCodeSeqId("0005CAT05001"));
|
||||
Assertions.assertEquals(null, tradingClearingRegistryService.parseCodeSeqId("0005CAT"));
|
||||
Assertions.assertEquals(null, tradingClearingRegistryService.parseCodeSeqId(""));
|
||||
Assertions.assertEquals(null, tradingClearingRegistryService.parseCodeSeqId(null));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>backend-api</artifactId>
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
<description>Clearing backend API module</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>clearing-parent</artifactId>
|
||||
<parent>
|
||||
<artifactId>clearing-parent</artifactId>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<version>SPCEX-1.0.0.0</version>
|
||||
</parent>
|
||||
|
||||
|
||||
|
||||
<properties>
|
||||
<keycloak-spring-boot-starter.version>17.0.1</keycloak-spring-boot-starter.version>
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>keycloak-spring-boot-starter</artifactId>
|
||||
|
|
@ -67,6 +67,11 @@
|
|||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>test-clearing</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skyscreamer</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
|
|
@ -87,17 +92,26 @@
|
|||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test-autoconfigure</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.bom</groupId>
|
||||
<artifactId>keycloak-adapter-bom</artifactId>
|
||||
<version>${keycloak-spring-boot-starter.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<groupId>org.keycloak.bom</groupId>
|
||||
<artifactId>keycloak-adapter-bom</artifactId>
|
||||
<version>${keycloak-spring-boot-starter.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
@ -181,6 +195,19 @@
|
|||
</fileMapper>
|
||||
</fileMappers>
|
||||
</transformationSet>
|
||||
<transformationSet>
|
||||
<dir>src/main/resources/meta</dir>
|
||||
<includes>
|
||||
<include>data_initial.xml</include>
|
||||
</includes>
|
||||
<stylesheet>src/main/resources/meta/xsl/data.xsl</stylesheet>
|
||||
<fileMappers>
|
||||
<fileMapper
|
||||
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
|
||||
<targetExtension>data_initial.sql</targetExtension>
|
||||
</fileMapper>
|
||||
</fileMappers>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
@ -309,6 +336,31 @@
|
|||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<!-- Generate java_classes.java from META file
|
||||
command: mvn xml:transform@java -->
|
||||
<id>java</id>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>src/main/resources/meta</dir>
|
||||
<includes>
|
||||
<include>meta.xml</include>
|
||||
</includes>
|
||||
<stylesheet>src/main/resources/meta/xsl/java.xsl</stylesheet>
|
||||
<fileMappers>
|
||||
<fileMapper
|
||||
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
|
||||
<targetExtension>java_classes.java</targetExtension>
|
||||
</fileMapper>
|
||||
</fileMappers>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package ru.spcex.clearing.backendapi.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
@ -11,6 +13,8 @@ import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
|||
|
||||
@Configuration
|
||||
public class BackEndApiImdgConfig {
|
||||
Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Bean(name = "taskExecutorHazelcastClientInitializer")
|
||||
public ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer() {
|
||||
return createThreadPoolTaskExecutor(1, true);
|
||||
|
|
@ -21,6 +25,16 @@ public class BackEndApiImdgConfig {
|
|||
return createThreadPoolTaskExecutor(1, false);
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorHazelcastClientInitializerHist")
|
||||
public ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializerHist() {
|
||||
return createThreadPoolTaskExecutor(1, true);
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorIdGeneratorAwaiterHist")
|
||||
public ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiterHist() {
|
||||
return createThreadPoolTaskExecutor(1, false);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public ImdgProvider imdgProvider(
|
||||
|
|
@ -28,9 +42,33 @@ public class BackEndApiImdgConfig {
|
|||
@Qualifier("taskExecutorIdGeneratorAwaiter") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
||||
BackendApiSettings clientSetting
|
||||
) {
|
||||
return new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
if (clientSetting.getHazelcast() == null || clientSetting.getHazelcast().getClusterMembers() == null) {
|
||||
log.warn("Property \"backend-api.hazelcast.cluster-members\" not set!");
|
||||
throw new IllegalArgumentException("Property \"backend-api.hazelcast.cluster-members\" not set");
|
||||
}
|
||||
ImdgProvider imdg = new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
taskExecutorIdGeneratorAwaiter,
|
||||
clientSetting.getHazelcast());
|
||||
// todo корректное ожидание готовности imdg.waitAvailable();
|
||||
return imdg;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public ImdgProvider imdgProviderHist(
|
||||
@Qualifier("taskExecutorHazelcastClientInitializerHist") ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer,
|
||||
@Qualifier("taskExecutorIdGeneratorAwaiterHist") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
||||
BackendApiSettings clientSetting
|
||||
) {
|
||||
if (clientSetting.getHazelcastSearch() == null || clientSetting.getHazelcastSearch().getClusterMembers() == null) {
|
||||
log.warn("Property \"backend-api.hazelcast-search.cluster-members\" not set!");
|
||||
// может работать без history, но history будет недоступна
|
||||
}
|
||||
ImdgProvider imdg = new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
taskExecutorIdGeneratorAwaiter,
|
||||
clientSetting.getHazelcastSearch());
|
||||
// todo корректное ожидание готовности imdg.waitAvailable();
|
||||
return imdg;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,177 @@
|
|||
package ru.spcex.clearing.backendapi.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.HistorySubscription;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.specific.*;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class HistoryConfig {
|
||||
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
@Autowired
|
||||
public HistoryConfig(ImdgProvider imdgProvider) {
|
||||
this.pb = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_SearchMoneyBalanceRegister,
|
||||
SpcexObjectBase.class
|
||||
).predicateBuilder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public List<HistorySubscription> histSubscriptions() {
|
||||
List<HistorySubscription> hst = new LinkedList<>();
|
||||
hst.add(executionDeposit());
|
||||
hst.add(executionFond());
|
||||
hst.add(depoBalanceRegister());
|
||||
hst.add(moneyBalanceRegister());
|
||||
hst.add(admittedLiabilitiesRegister());
|
||||
hst.add(coveredLiabilitiesRegister());
|
||||
hst.add(moneyPaymentInstructionRegister());
|
||||
hst.add(depoPaymentInstructionRegister());
|
||||
hst.add(excludeLiabilitiesRegister());
|
||||
hst.add(liabilitiesRegister());
|
||||
hst.add(executionRegister());
|
||||
return hst;
|
||||
}
|
||||
|
||||
private HistorySubscription moneyBalanceRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("money-balance-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchMoneyBalanceRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_MoneyBalanceRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new CreatedFromCondition(pb),
|
||||
new CreatedToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription depoBalanceRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("depo-balance-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchDepoBalanceRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_DepoBalanceRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new CreatedFromCondition(pb),
|
||||
new CreatedToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription depoPaymentInstructionRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("depo-payment-instruction-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchDepoPaymentInstructionRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_DepoPaymentInstructionRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new CreatedFromCondition(pb),
|
||||
new CreatedToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription excludeLiabilitiesRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("exclude-liabilities-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchExcludeLiabilitiesRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_ExcludeLiabilitiesRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new CreatedFromCondition(pb),
|
||||
new CreatedToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription liabilitiesRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("liabilities-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchLiabilitiesRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_LiabilitiesRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new CreatedFromCondition(pb),
|
||||
new CreatedToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription admittedLiabilitiesRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("admitted-liabilities-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchAdmittedLiabilitiesRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_AdmittedLiabilitiesRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new ClearingDateFromCondition(pb),
|
||||
new ClearingDateToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription executionRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("execution-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchExecutionRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_ExecutionRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new ClearingDateFromCondition(pb),
|
||||
new ClearingDateToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription moneyPaymentInstructionRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("money-payment-instruction-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchMoneyPaymentInstructionRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_MoneyPaymentInstructionRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new ClearingDateFromCondition(pb),
|
||||
new ClearingDateToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription coveredLiabilitiesRegister() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("covered-liabilities-registers");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchCoveredLiabilitiesRegister);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_CoveredLiabilitiesRegister);
|
||||
sbscr.setConditions(List.of(
|
||||
new ClearingDateFromCondition(pb),
|
||||
new ClearingDateToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription executionDeposit() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("execution-deposits");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchExecutionDeposit);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_ExecutionDeposit);
|
||||
sbscr.setConditions(List.of(
|
||||
new TradingDateFromCondition(pb),
|
||||
new TradingDateToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
|
||||
private HistorySubscription executionFond() {
|
||||
HistorySubscription sbscr = new HistorySubscription();
|
||||
sbscr.setDestination("execution-fonds");
|
||||
sbscr.setSearchProxyMapName(IMDGDistributedNames.Map_SearchExecutionFond);
|
||||
sbscr.setFullHistoryMapName(IMDGDistributedNames.Map_ExecutionFond);
|
||||
sbscr.setConditions(List.of(
|
||||
new TradingDateFromCondition(pb),
|
||||
new TradingDateToCondition(pb)
|
||||
));
|
||||
return sbscr;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,20 @@ import org.apache.kafka.clients.consumer.OffsetResetStrategy;
|
|||
import org.apache.kafka.clients.producer.MockProducer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.core.ProducerFactory;
|
||||
import ru.spcex.clearing.backendapi.config.element.BackendApiSettings;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaConsumerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.KafkaProducerFactory;
|
||||
import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
|
|
@ -23,6 +31,29 @@ public class KafkaConfig {
|
|||
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ProducerFactory<String, Object> pf(BackendApiSettings settings) {
|
||||
KafkaProducerSettings kafkaSettings = settings.getKafkaProducer();
|
||||
return KafkaProducerFactory.producerFactory(kafkaSettings);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public KafkaTemplate<String, Object> kafkaTemplateS(ProducerFactory<String, Object> pf) {
|
||||
return new KafkaTemplate<>(pf);
|
||||
}
|
||||
|
||||
@Profile("!kafkaDisabled")
|
||||
@Autowired
|
||||
@Bean
|
||||
public KafkaSender kafkaSender(KafkaTemplate<String, Object> kafkaTemplate, ImdgProvider imdgProvider) {
|
||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||
return KafkaSender.setup()
|
||||
.saveRequestInfo(false)
|
||||
.setKafkaTemplate(kafkaTemplate)
|
||||
.idGenerator(imdgIdGenerator::nextId)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Profile("kafkaDisabled")
|
||||
@Bean
|
||||
public MockProducer<String, Object> createMockProducer() {
|
||||
|
|
@ -31,6 +62,7 @@ public class KafkaConfig {
|
|||
|
||||
@Profile("!kafkaDisabled")
|
||||
@Autowired
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Bean
|
||||
public Consumer<String, Object> createConsumer(BackendApiSettings settings) {
|
||||
return KafkaConsumerFactory.consumer(settings.getKafkaConsumer());
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import ru.spcex.platform.imdg.iml.hazelcast.config.HazelcastClientParams;
|
|||
@ConfigurationProperties("backend-api")
|
||||
public class BackendApiSettings {
|
||||
private HazelcastClientParams hazelcast;
|
||||
private HazelcastClientParams hazelcastSearch;
|
||||
private KafkaProducerSettings kafkaProducer;
|
||||
private KafkaConsumerSettings kafkaConsumer;
|
||||
private SecuritySettings security;
|
||||
|
|
@ -57,4 +58,12 @@ public class BackendApiSettings {
|
|||
public void setSecurity(SecuritySettings security) {
|
||||
this.security = security;
|
||||
}
|
||||
|
||||
public HazelcastClientParams getHazelcastSearch() {
|
||||
return hazelcastSearch;
|
||||
}
|
||||
|
||||
public void setHazelcastSearch(HazelcastClientParams hazelcastSearch) {
|
||||
this.hazelcastSearch = hazelcastSearch;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
|||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class AbstractQueueController {
|
||||
public abstract class AbstractQueueController {
|
||||
private final IOperator operator;
|
||||
|
||||
public AbstractQueueController(IOperator operator) {
|
||||
|
|
@ -15,7 +16,18 @@ public class AbstractQueueController {
|
|||
|
||||
protected <T> CudResponse processRequest(String destination, IAction<T> iAction) throws ExecutionException, InterruptedException {
|
||||
CudResponse responseToClient = new CudResponse();
|
||||
responseToClient.setPayload(operator.sendRequestToQueue(destination, iAction));
|
||||
responseToClient.setPayload(operator.sendRequestToQueue(destination, iAction, true));
|
||||
responseToClient.setCode(0);
|
||||
responseToClient.setMessage("success");
|
||||
return responseToClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Для оптимизации передачи userId
|
||||
*/
|
||||
protected <T> CudResponse processRequest(String destination, IAction<T> iAction, Long userId) throws ExecutionException, InterruptedException {
|
||||
CudResponse responseToClient = new CudResponse();
|
||||
responseToClient.setPayload(operator.sendRequestToQueue(destination, iAction, userId));
|
||||
responseToClient.setCode(0);
|
||||
responseToClient.setMessage("success");
|
||||
return responseToClient;
|
||||
|
|
|
|||
|
|
@ -1,28 +1,38 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.AccountNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.AccountUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accounting/accounts")
|
||||
public class AccountController {
|
||||
public class AccountController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public AccountController(IStateLoader stateLoader) {
|
||||
public AccountController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
|
|
@ -36,4 +46,40 @@ public class AccountController {
|
|||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "create account.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody AccountNewAction accountNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, accountNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update account.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody AccountUpdateAction accountUpdateAction) throws ExecutionException, InterruptedException {
|
||||
accountUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete account.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.account.AccountSymbols;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.AccountSymbolsNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accounting/depo-accounts-symbols")
|
||||
public class AccountSymbolsController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public AccountSymbolsController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all accounts-symbols.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_AccountSymbols, AccountSymbols.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "create AccountSymbols.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody AccountSymbolsNewAction accountNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_NEW, accountNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete AccountSymbols.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_DELETE, deleteAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,7 +16,8 @@ import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAc
|
|||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.account.BankAccountBackendGetById;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetByIdResponse;
|
||||
import ru.spcex.clearing.backendapi.meta.GetResponseFactory;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
|
@ -28,14 +29,16 @@ import java.util.Optional;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/securities/bank-accounts")
|
||||
@RequestMapping("/accounting/bank-accounts")
|
||||
public class BankAccountController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
private final GetResponseFactory responseMetaFactory;
|
||||
|
||||
@Autowired
|
||||
public BankAccountController(IOperator operator, IStateLoader stateLoader) {
|
||||
public BankAccountController(GetResponseFactory responseMetaFactory, IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
this.responseMetaFactory = responseMetaFactory;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create bank account.")
|
||||
|
|
@ -53,7 +56,7 @@ public class BankAccountController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody BankAccountUpdateAction bankAccountUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
@ -69,18 +72,21 @@ public class BankAccountController extends AbstractQueueController {
|
|||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_BANK_ACCOUNT_DELETE, deleteAction);
|
||||
return processRequest(Consts.DESTINATION_BANK_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get bank account.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = BankAccountBackendGetById.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetByIdResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public BankAccountBackendGetById getById(@ApiParam(value = "Идентификатор объекта", required = true, example = "1234")
|
||||
public CommonGetByIdResponse getById(@ApiParam(value = "Идентификатор объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) {
|
||||
Optional<BankAccount> bankAccount = stateLoader.getById(id, IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
BankAccountBackendGetById response = new BankAccountBackendGetById();
|
||||
bankAccount.ifPresentOrElse(response::fromEntity, () -> response.setCode(404));
|
||||
CommonGetByIdResponse response = new CommonGetByIdResponse();
|
||||
bankAccount.ifPresentOrElse( r -> {
|
||||
Map<String, Object> extractedByMeta = responseMetaFactory.responseFromObject(r);
|
||||
response.fromEntity(extractedByMeta);
|
||||
}, () -> response.setCode(404));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.securities;
|
||||
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
|
@ -17,22 +17,21 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/securities/information-accounts")
|
||||
public class InformationAccountController {
|
||||
@RequestMapping("/accounting/clearing-accounts")
|
||||
public class ClearingAccountController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public InformationAccountController(IStateLoader stateLoader) {
|
||||
public ClearingAccountController(IStateLoader stateLoader) {
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all information accounts.")
|
||||
@ApiOperation(value = "get all clearing account.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_InformationAccount,
|
||||
InformationAccount.class);
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.utilities;
|
||||
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
|
@ -8,11 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.misc.KeyRate;
|
||||
import ru.clearing.classes.statics.data.account.ClientCode;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.ClientCodeNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.ClientCodeUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.utilities.KeyRateNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.utilities.KeyRateUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
|
|
@ -26,40 +26,40 @@ import java.util.Map;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/utilities/key-rates")
|
||||
public class CudKeyRateController extends AbstractQueueController {
|
||||
@RequestMapping("/client-codes")
|
||||
public class ClientCodeController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public CudKeyRateController(IOperator operator, IStateLoader stateLoader) {
|
||||
public ClientCodeController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create key rate.")
|
||||
@ApiOperation(value = "create client code.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody KeyRateNewAction keyRateNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_KEY_RATE_NEW, keyRateNewAction);
|
||||
@RequestBody ClientCodeNewAction clientCodeNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_CLIENT_CODE_NEW, clientCodeNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update key rate.")
|
||||
@ApiOperation(value = "update client-code.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody KeyRateUpdateAction keyRateUpdateAction) throws ExecutionException, InterruptedException {
|
||||
keyRateUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_KEY_RATE_UPDATE, keyRateUpdateAction);
|
||||
@RequestBody ClientCodeUpdateAction clientCodeUpdateAction) throws ExecutionException, InterruptedException {
|
||||
clientCodeUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_CLIENT_CODE_UPDATE, clientCodeUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete key rate.")
|
||||
@ApiOperation(value = "delete client code.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
|
|
@ -67,15 +67,16 @@ public class CudKeyRateController extends AbstractQueueController {
|
|||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_KEY_RATE_DELETE, deleteAction);
|
||||
return processRequest(Consts.DESTINATION_CLIENT_CODE_DELETE, deleteAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all KeyRate's.")
|
||||
|
||||
@ApiOperation(value = "get all client codes.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_KeyRate, KeyRate.class);
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_ClientCode, ClientCode.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.account.AccountBalance;
|
||||
import ru.clearing.classes.statics.data.account.DepoAccount;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
|
@ -17,21 +17,21 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/account-balances")
|
||||
public class AccountBalanceController {
|
||||
@RequestMapping("/accounting/depo-accounts")
|
||||
public class DepoAccountController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public AccountBalanceController(IStateLoader stateLoader) {
|
||||
public DepoAccountController(IStateLoader stateLoader) {
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all account balances.")
|
||||
@ApiOperation(value = "get all depo account.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class);
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.account.InformationAccount;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.AccountInformationNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.BankAccountNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accounting/information-accounts")
|
||||
public class InformationAccountController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public InformationAccountController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all information accounts.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_InformationAccount,
|
||||
InformationAccount.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
// @ApiOperation(value = "Добавление информационного счета.")
|
||||
// @ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
// @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// @ResponseBody
|
||||
// public CudResponse add(
|
||||
// @ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
// @RequestBody AccountInformationNewAction accountNewInformationAction) throws ExecutionException, InterruptedException {
|
||||
// return processRequest(Consts.DESTINATION_INFORMATION_ACCOUNT_NEW, accountNewInformationAction);
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
package ru.spcex.clearing.backendapi.controller.queue.clearing;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.OrderRegister;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.clearing.VerificationResult;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -19,24 +17,22 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/order-registers")
|
||||
public class OrderRegisterController extends AbstractQueueController {
|
||||
@RequestMapping("/verification-results")
|
||||
public class VerificationResultController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public OrderRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
public VerificationResultController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all order registers.")
|
||||
@ApiOperation(value = "get all VerificationResult's.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_OrderRegister,
|
||||
OrderRegister.class);
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_VerificationResult, VerificationResult.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.generated.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ClearingMemberCategoryNewAction;
|
||||
|
|
@ -27,11 +27,11 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/clearing-member-categories")
|
||||
public class EditClearingMemberCategoryController extends AbstractQueueController {
|
||||
public class ClearingMemberCategoryController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public EditClearingMemberCategoryController(IOperator operator, IStateLoader stateLoader) {
|
||||
public ClearingMemberCategoryController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ public class EditClearingMemberCategoryController extends AbstractQueueControlle
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody ClearingMemberCategoryUpdateAction clearingMemberCategoryUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
@ -5,14 +5,14 @@ import io.swagger.annotations.ApiParam;
|
|||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.CompanyNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -26,12 +26,12 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/companies")
|
||||
public class DeleteCompanyController extends AbstractQueueController {
|
||||
public class CompanyController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public DeleteCompanyController(IOperator operator,
|
||||
IStateLoader stateLoader) {
|
||||
public CompanyController(IOperator operator,
|
||||
IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
|
@ -57,4 +57,14 @@ public class DeleteCompanyController extends AbstractQueueController {
|
|||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "new company.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody CompanyNewAction companyNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_COMPANY_NEW, companyNewAction);
|
||||
}
|
||||
}
|
||||
|
|
@ -14,9 +14,9 @@ import ru.spcex.clearing.backendapi.controller.request.cud.company.CompanyInfoUp
|
|||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.company.CompanyInfoBackendGetAll;
|
||||
import ru.spcex.clearing.backendapi.meta.GetResponseFactory;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
|
|
@ -29,15 +29,13 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/company-infos")
|
||||
public class EditCompanyInfoController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
public class CompanyInfoController extends AbstractQueueController {
|
||||
private final Imdg<Company> companyImdg;
|
||||
private final GetResponseFactory responseFactory;
|
||||
|
||||
@Autowired
|
||||
public EditCompanyInfoController(IOperator operator, IStateLoader stateLoader, ImdgProvider imdgProvider, GetResponseFactory responseFactory) {
|
||||
public CompanyInfoController(IOperator operator, ImdgProvider imdgProvider, GetResponseFactory responseFactory) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
this.companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.responseFactory = responseFactory;
|
||||
}
|
||||
|
|
@ -47,7 +45,7 @@ public class EditCompanyInfoController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody CompanyInfoUpdateAction companyInfoUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
@ -56,19 +54,14 @@ public class EditCompanyInfoController extends AbstractQueueController {
|
|||
}
|
||||
|
||||
@ApiOperation(value = "get all CompanyInfo's.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CompanyInfoBackendGetAll.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
public CompanyInfoBackendGetAll getAll() {
|
||||
Collection<Map<String, Object>> all = new ArrayList<>();
|
||||
Collection<Company> companies = companyImdg.getAllValues();
|
||||
for (Company company : companies) {
|
||||
if (company.getProfile() != null && company.getProfile().getId() != null) { // пока возвращает "пустой" CompanyInfo если его нет для Company
|
||||
all.add(responseFactory.responseFromObject(company.getProfile()));
|
||||
}
|
||||
}
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
CompanyInfoBackendGetAll response = new CompanyInfoBackendGetAll();
|
||||
response.fromEntity(companies);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +1,28 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.company;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.company.CompanyRoleSet;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.CompanyRoleSetNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/company-role-sets")
|
||||
|
|
@ -41,4 +47,26 @@ public class CompanyRoleSetController extends AbstractQueueController {
|
|||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create CompanyRoleSet.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse create(
|
||||
@ApiParam(value = "Значения полей нового объекта.", required = true)
|
||||
@RequestBody CompanyRoleSetNewAction companyRoleSetNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_COMPANY_ROLE_SET_NEW, companyRoleSetNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete CompanyRoleSet.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_COMPANY_ROLE_SET_DELETE, deleteAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.company.CompanySymbols;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.CompanySymbolNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.CompanySymbolUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ContactNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
|
|
@ -25,22 +28,33 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/company-symbols")
|
||||
public class EditCompanySymbolController extends AbstractQueueController {
|
||||
public class CompanySymbolController extends AbstractQueueController {
|
||||
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public EditCompanySymbolController(IOperator operator, IStateLoader stateLoader) {
|
||||
public CompanySymbolController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "create company symbol.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse create(
|
||||
@ApiParam(value = "Значения полей нового объекта.", required = true)
|
||||
@RequestBody CompanySymbolNewAction companySymbolNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_COMPANY_SYMBOL_NEW, companySymbolNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update company symbol.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody CompanySymbolUpdateAction companySymbolsUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
@ -58,4 +72,15 @@ public class EditCompanySymbolController extends AbstractQueueController {
|
|||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete company symbol.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_COMPANY_SYMBOL_DELETE, deleteAction);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.profile.Contact;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ContactNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ContactUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
|
|
@ -25,11 +27,11 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/contacts")
|
||||
public class EditContactController extends AbstractQueueController {
|
||||
public class ContactController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public EditContactController(IOperator operator, IStateLoader stateLoader) {
|
||||
public ContactController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
|
@ -39,7 +41,7 @@ public class EditContactController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody ContactUpdateAction contactUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
@ -47,6 +49,27 @@ public class EditContactController extends AbstractQueueController {
|
|||
return processRequest(Consts.DESTINATION_CONTACT_UPDATE, contactUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create company contact.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse create(
|
||||
@ApiParam(value = "Значения полей нового объекта.", required = true)
|
||||
@RequestBody ContactNewAction contactNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_CONTACT_NEW, contactNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete contact.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_CONTACT_DELETE, deleteAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all Contacts.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
|
|
@ -7,13 +7,12 @@ import io.swagger.annotations.ApiResponses;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ProfileDocumentNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ProfileDocumentUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
|
|
@ -57,4 +56,28 @@ public class ProfileDocumentController extends AbstractQueueController {
|
|||
@RequestBody ProfileDocumentNewAction profileDocumentNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_PROFILE_DOCUMENT_NEW, profileDocumentNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update profile document.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody ProfileDocumentUpdateAction profileDocumentUpdateAction) throws ExecutionException, InterruptedException {
|
||||
profileDocumentUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_PROFILE_DOCUMENT_UPDATE, profileDocumentUpdateAction);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "delete profile document.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_PROFILE_DOCUMENT_DELETE, deleteAction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class RelationController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody RelationUpdateAction relationUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,11 @@ import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllRespo
|
|||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -22,11 +26,16 @@ import java.util.Map;
|
|||
@RequestMapping("/execution-deposits")
|
||||
public class ExecutionDepositController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
private final ImdgPredicateBuilder imdgPredicateBuilder;
|
||||
|
||||
@Autowired
|
||||
public ExecutionDepositController(IOperator operator, IStateLoader stateLoader) {
|
||||
public ExecutionDepositController(IOperator operator, IStateLoader stateLoader,
|
||||
ImdgProvider imdgProvider) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
this.imdgPredicateBuilder = imdgProvider
|
||||
.getImdg(IMDGDistributedNames.Map_ExecutionDeposit, ExecutionDeposit.class)
|
||||
.predicateBuilder();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all ExecutionDeposits.")
|
||||
|
|
@ -34,9 +43,11 @@ public class ExecutionDepositController extends AbstractQueueController {
|
|||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
ImdgPredicate imdgPredicate = imdgPredicateBuilder.greatEqual("firstLegSettlementDate", LocalDate.now());
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_ExecutionDeposit,
|
||||
ExecutionDeposit.class);
|
||||
ExecutionDeposit.class,
|
||||
imdgPredicate);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.liabilities;
|
||||
package ru.spcex.clearing.backendapi.controller.queue.execution;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
|
|
@ -8,35 +8,47 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.liabilities.LiabilitiesClaimsMoney;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionFond;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/liabilities-claims-money")
|
||||
public class LiabilitiesClaimsMoneyController extends AbstractQueueController {
|
||||
@RequestMapping("/execution-fonds")
|
||||
public class ExecutionFondController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
private final ImdgPredicateBuilder imdgPredicateBuilder;
|
||||
|
||||
@Autowired
|
||||
public LiabilitiesClaimsMoneyController(IOperator operator, IStateLoader stateLoader) {
|
||||
public ExecutionFondController(IOperator operator,
|
||||
IStateLoader stateLoader,
|
||||
ImdgProvider imdgProvider) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
this.imdgPredicateBuilder = imdgProvider
|
||||
.getImdg(IMDGDistributedNames.Map_ExecutionFond, ExecutionFond.class)
|
||||
.predicateBuilder();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all LiabilitiesClaimsMoney.")
|
||||
@ApiOperation(value = "get all ExecutionFond.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
ImdgPredicate imdgPredicate = imdgPredicateBuilder.greatEqual("settlementDate", LocalDate.now());
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_LiabilitiesClaimsMoney,
|
||||
LiabilitiesClaimsMoney.class);
|
||||
IMDGDistributedNames.Map_ExecutionFond,
|
||||
ExecutionFond.class,
|
||||
imdgPredicate);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.ConditionProvider;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.HistorySubscription;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
|
||||
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||
import ru.spcex.clearing.backendapi.meta.GetResponseFactory;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/history")
|
||||
public class HistController {
|
||||
private final GetResponseFactory responseFactory;
|
||||
private final IStateLoader stateLoader;
|
||||
private final ConditionProvider conditionProvider;
|
||||
|
||||
@Autowired
|
||||
public HistController(GetResponseFactory responseFactory,
|
||||
IStateLoader stateLoader,
|
||||
ConditionProvider conditionProvider) {
|
||||
this.responseFactory = responseFactory;
|
||||
this.stateLoader = stateLoader;
|
||||
this.conditionProvider = conditionProvider;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Get history")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getHistory(
|
||||
@ApiParam(value = "destination сущности по которой запрашивается история", example = "money-balance-registers", required = true)
|
||||
@RequestParam("destination")
|
||||
String destination,
|
||||
@ApiParam(value = "Начальная точка поиска по дате", example = "2023-01-15")
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
|
||||
@RequestParam(name = "from", required = false)
|
||||
LocalDate from,
|
||||
@ApiParam(value = "Конечная точка поиска по дате", example = "2023-01-15")
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
|
||||
@RequestParam(name = "to", required = false)
|
||||
LocalDate to
|
||||
) {
|
||||
if (to == null && from == null) {
|
||||
throw new ActionValidationException(new EnumMessage(BackEndError.ValidationError, "from/to url params both empty"));
|
||||
}
|
||||
|
||||
Optional<Class<? extends SpcexObjectBase>> entityClass = responseFactory.classByDestination(destination);
|
||||
//class may be added to HistorySubscription if needed
|
||||
if (entityClass.isEmpty()) {
|
||||
throw new ActionValidationException(new EnumMessage(BackEndError.ValidationError,
|
||||
"destination " + "'" + destination + "' not supported (meta class not found)"));
|
||||
}
|
||||
|
||||
HistoryRequest req = new HistoryRequest();
|
||||
req.setTable(destination);
|
||||
req.setFrom(from);
|
||||
req.setTo(to);
|
||||
|
||||
HistorySubscription[] subscr = new HistorySubscription[1];
|
||||
ImdgPredicate[] prdct = new ImdgPredicate[1];
|
||||
conditionProvider.conditionForRequest(req).map(s -> subscr[0] = s, p -> prdct[0] = p);
|
||||
|
||||
Collection<Map<String, Object>> searchRes = stateLoader.getAllMetaTransform(
|
||||
subscr[0].getSearchProxyMapName(),
|
||||
subscr[0].getFullHistoryMapName(),
|
||||
entityClass.get(),
|
||||
prdct[0]
|
||||
);
|
||||
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(searchRes);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
|
||||
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||
import ru.spcex.clearing.backendapi.meta.GetResponseFactory;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.collection.Pair;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class ConditionProvider {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final GetResponseFactory responseFactory;
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
private final Map<String, HistorySubscription> subscriptions;
|
||||
|
||||
@Autowired
|
||||
public ConditionProvider(GetResponseFactory responseFactory, ImdgProvider imdgProvider,
|
||||
List<HistorySubscription> subscriptions) {
|
||||
this.responseFactory = responseFactory;
|
||||
this.subscriptions = new HashMap<>();
|
||||
Imdg<SpcexObjectBase> imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SearchMoneyBalanceRegister, SpcexObjectBase.class);
|
||||
this.pb = imdg.predicateBuilder();
|
||||
subscriptions.forEach(s -> this.subscriptions.put(s.getDestination(), s));
|
||||
}
|
||||
|
||||
public Pair<HistorySubscription, ImdgPredicate> conditionForRequest(HistoryRequest req) {
|
||||
String destination = req.getTable();
|
||||
HistorySubscription subscription = subscriptions.get(destination);
|
||||
if (subscription == null) {
|
||||
throw new ActionValidationException(new EnumMessage(BackEndError.ValidationError,
|
||||
"destination " + "'" + destination + "' not supported (subscription info not found)"));
|
||||
}
|
||||
|
||||
List<ImdgPredicate> predicates = subscription
|
||||
.getConditions()
|
||||
.stream()
|
||||
.map(c -> c.condition(req))
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.toList();
|
||||
|
||||
ImdgPredicate result;
|
||||
if (predicates.size() == 0) {
|
||||
//add boundary conditions?
|
||||
log.warn("destination '{}' zero predicates found", destination);
|
||||
result = pb.alwaysTrue();
|
||||
} else if (predicates.size() == 1) {
|
||||
result = predicates.iterator().next();
|
||||
} else {
|
||||
result = pb.and(predicates.toArray(new ImdgPredicate[0]));
|
||||
}
|
||||
|
||||
return new Pair<>(subscription, result);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HistorySubscription {
|
||||
private String destination;
|
||||
|
||||
private List<IHistoryCondition> conditions;
|
||||
private String searchProxyMapName;
|
||||
private String fullHistoryMapName;
|
||||
//class
|
||||
|
||||
|
||||
public List<IHistoryCondition> getConditions() {
|
||||
return conditions != null ? conditions : Collections.emptyList();
|
||||
}
|
||||
|
||||
public void setConditions(List<IHistoryCondition> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public String getSearchProxyMapName() {
|
||||
return searchProxyMapName;
|
||||
}
|
||||
|
||||
public void setSearchProxyMapName(String searchProxyMapName) {
|
||||
this.searchProxyMapName = searchProxyMapName;
|
||||
}
|
||||
|
||||
public String getFullHistoryMapName() {
|
||||
return fullHistoryMapName;
|
||||
}
|
||||
|
||||
public void setFullHistoryMapName(String fullHistoryMapName) {
|
||||
this.fullHistoryMapName = fullHistoryMapName;
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public void setDestination(String destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition;
|
||||
|
||||
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface IHistoryCondition {
|
||||
Optional<ImdgPredicate> condition(HistoryRequest req);
|
||||
|
||||
default Optional<ImdgPredicate> of(ImdgPredicate predicate) {
|
||||
return Optional.of(predicate);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition.specific;
|
||||
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.IHistoryCondition;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ClearingDateFromCondition implements IHistoryCondition {
|
||||
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
public ClearingDateFromCondition(ImdgPredicateBuilder pb) {
|
||||
this.pb = pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ImdgPredicate> condition(HistoryRequest req) {
|
||||
if (req.getFrom() != null) {
|
||||
return Optional.ofNullable(pb.greatEqual("clearingDate", req.getFrom()));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition.specific;
|
||||
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.IHistoryCondition;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ClearingDateToCondition implements IHistoryCondition {
|
||||
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
public ClearingDateToCondition(ImdgPredicateBuilder pb) {
|
||||
this.pb = pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ImdgPredicate> condition(HistoryRequest req) {
|
||||
if (req.getTo() != null) {
|
||||
return Optional.ofNullable(pb.lessEqual("clearingDate", req.getTo()));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition.specific;
|
||||
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.IHistoryCondition;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CreatedFromCondition implements IHistoryCondition {
|
||||
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
public CreatedFromCondition(ImdgPredicateBuilder pb) {
|
||||
this.pb = pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ImdgPredicate> condition(HistoryRequest req) {
|
||||
if (req.getFrom() != null) {
|
||||
return Optional.of(pb.greatEqual("created", TimeUtil.localDateToInstant(req.getFrom())));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition.specific;
|
||||
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.IHistoryCondition;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CreatedToCondition implements IHistoryCondition {
|
||||
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
public CreatedToCondition(ImdgPredicateBuilder pb) {
|
||||
this.pb = pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ImdgPredicate> condition(HistoryRequest req) {
|
||||
if (req.getTo() != null) {
|
||||
return Optional.of(pb.lessEqual("created", TimeUtil.localDateToInstant(req.getTo())));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition.specific;
|
||||
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.IHistoryCondition;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class TradingDateFromCondition implements IHistoryCondition {
|
||||
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
public TradingDateFromCondition(ImdgPredicateBuilder pb) {
|
||||
this.pb = pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ImdgPredicate> condition(HistoryRequest req) {
|
||||
if (req.getFrom() != null) {
|
||||
return Optional.ofNullable(pb.greatEqual("tradingDate", req.getFrom()));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.history.condition.specific;
|
||||
|
||||
import ru.spcex.clearing.backendapi.controller.queue.history.condition.IHistoryCondition;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.history.HistoryRequest;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class TradingDateToCondition implements IHistoryCondition {
|
||||
|
||||
private final ImdgPredicateBuilder pb;
|
||||
|
||||
public TradingDateToCondition(ImdgPredicateBuilder pb) {
|
||||
this.pb = pb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ImdgPredicate> condition(HistoryRequest req) {
|
||||
if (req.getTo() != null) {
|
||||
return Optional.ofNullable(pb.lessEqual("tradingDate", req.getTo()));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.liabilities;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.liabilities.LiabilitiesClaimsAssets;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/liabilities-claims-assets")
|
||||
public class LiabilitiesClaimsAssetController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public LiabilitiesClaimsAssetController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all LiabilitiesClaimsAssets.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_LiabilitiesClaimsAssets,
|
||||
LiabilitiesClaimsAssets.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +1,29 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.misc;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.misc.Listing;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ListingNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ListingUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/listings")
|
||||
|
|
@ -39,4 +46,40 @@ public class ListingController extends AbstractQueueController {
|
|||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "create Listing.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse create(
|
||||
@ApiParam(value = "Значения полей нового объекта.", required = true)
|
||||
@RequestBody ListingNewAction listingNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.LISTING_NEW, listingNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update Listing.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody ListingUpdateAction listingUpdateAction) throws ExecutionException, InterruptedException {
|
||||
listingUpdateAction.setId(id);
|
||||
return processRequest(Consts.LISTING_UPDATE, listingUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete Listing.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.LISTING_DELETE, deleteAction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,30 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.misc;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.misc.Notification;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.registry.NotificationUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/notifications")
|
||||
|
|
@ -39,4 +47,14 @@ public class NotificationController extends AbstractQueueController {
|
|||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create Notification.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody NotificationUpdateAction notificationUpdateAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.NOTIFICATION_UPDATE, notificationUpdateAction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,30 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.payment;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.payment.PaymentInstruction;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.payment.PIClearingOutbondActionNew;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/payment-instructions")
|
||||
|
|
@ -39,4 +47,14 @@ public class PaymentInstructionController extends AbstractQueueController {
|
|||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Досрочное изъятие части денежных средств по договору")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/clearing-outbound", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse clearingOutboundAction(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody PIClearingOutbondActionNew piClearingOutbondAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.PAYMENT_INSTRUCTION_CLEARING_OUTBOUND_ACTION, piClearingOutbondAction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.AdmittedLiabilitiesRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admitted-liabilities-registers")
|
||||
public class AdmittedLiabilitiesRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public AdmittedLiabilitiesRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all admittedLiabilitiesRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_AdmittedLiabilitiesRegister,
|
||||
AdmittedLiabilitiesRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.CoveredLiabilitiesRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/covered-liabilities-registers")
|
||||
public class CoveredLiabilitiesRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public CoveredLiabilitiesRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all coveredLiabilitiesRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_CoveredLiabilitiesRegister,
|
||||
CoveredLiabilitiesRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.CoveredDealRegister;
|
||||
import ru.clearing.classes.statics.data.register.DepoBalanceRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -19,24 +19,24 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/covered-deal-registers")
|
||||
public class CoveredDealRegisterController extends AbstractQueueController {
|
||||
@RequestMapping("/depo-balance-registers")
|
||||
public class DepoBalanceRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public CoveredDealRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
public DepoBalanceRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all covered deal registers.")
|
||||
@ApiOperation(value = "get all depoBalanceRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_CoveredDealRegister,
|
||||
CoveredDealRegister.class);
|
||||
IMDGDistributedNames.Map_DepoBalanceRegister,
|
||||
DepoBalanceRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.DepoPaymentInstructionRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/depo-payment-instruction-registers")
|
||||
public class DepoPaymentInstructionRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public DepoPaymentInstructionRegisterController(IOperator operator,
|
||||
IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all depoPaymentInstructionRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_DepoPaymentInstructionRegister,
|
||||
DepoPaymentInstructionRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.ExcludeLiabilitiesRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/exclude-liabilities-registers")
|
||||
public class ExcludeLiabilitiesRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public ExcludeLiabilitiesRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all excludeLiabilitiesRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_ExcludeLiabilitiesRegister,
|
||||
ExcludeLiabilitiesRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.misc.BalanceRegister;
|
||||
import ru.clearing.classes.statics.data.register.ExecutionRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -19,24 +19,24 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/balance-registers")
|
||||
public class BalanceRegisterController extends AbstractQueueController {
|
||||
@RequestMapping("/execution-registers")
|
||||
public class ExecutionRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public BalanceRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
public ExecutionRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all money balance registers.")
|
||||
@ApiOperation(value = "get all executionRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_BalanceRegister,
|
||||
BalanceRegister.class);
|
||||
IMDGDistributedNames.Map_ExecutionRegister,
|
||||
ExecutionRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.misc.ClearMemberRegister;
|
||||
import ru.clearing.classes.statics.data.register.LiabilitiesRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -19,24 +19,24 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/clearmember-registers")
|
||||
public class ClearMemberRegisterController extends AbstractQueueController {
|
||||
@RequestMapping("/liabilities-registers")
|
||||
public class LiabilitiesRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public ClearMemberRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
public LiabilitiesRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all money ClearMemberRegisters.")
|
||||
@ApiOperation(value = "get all liabilitiesRegister 's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_ClearMemberRegister,
|
||||
ClearMemberRegister.class);
|
||||
IMDGDistributedNames.Map_LiabilitiesRegister,
|
||||
LiabilitiesRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.AdmittedDealRegister;
|
||||
import ru.clearing.classes.statics.data.register.MoneyBalanceRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -19,24 +19,24 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admitted-deal-registers")
|
||||
public class AdmittedDealRegisterController extends AbstractQueueController {
|
||||
@RequestMapping("/money-balance-registers")
|
||||
public class MoneyBalanceRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public AdmittedDealRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
public MoneyBalanceRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all admitted deal registers.")
|
||||
@ApiOperation(value = "get all moneyBalanceRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_AdmittedDealRegister,
|
||||
AdmittedDealRegister.class);
|
||||
IMDGDistributedNames.Map_MoneyBalanceRegister,
|
||||
MoneyBalanceRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.MoneyPaymentInstructionRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/money-payment-instruction-register")
|
||||
public class MoneyPaymentInstructionRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public MoneyPaymentInstructionRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all moneyPaymentInstructionRegister's")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_MoneyPaymentInstructionRegister,
|
||||
MoneyPaymentInstructionRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.registry.*;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/registries")
|
||||
public class RegistryController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public RegistryController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all registries.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_Registry, Registry.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Досрочное изъятие части денежных средств по договору")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/splitDeposit", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse splitDepositAction(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody RSplitDepositActionNew rSplitDepositActionNew) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.REGISTRY_SPLIT_DEPOSIT_ACTION, rSplitDepositActionNew);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Отметить средства на возврат депозита")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/returnDeposit/{id}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse returnDepositAction(
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody ReturnDepositActionNew returnDepositAction) throws ExecutionException, InterruptedException {
|
||||
returnDepositAction.setId(id);
|
||||
return processRequest(Consts.REGISTRY_RETURN_DEPOSIT_ACTION, returnDepositAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Отметить средства на возврат депозита")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/identificationFunds/{id}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse identificationFundsAction(
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody IdentificationFundsActionNew identificationFundsActionNew) throws ExecutionException, InterruptedException {
|
||||
identificationFundsActionNew.setId(id);
|
||||
return processRequest(Consts.REGISTRY_IDENTIFICATION_FUNDS, identificationFundsActionNew);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Изменение даты возврата депозита")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/changeRefundDate/{groupId}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse changeRefundDate(
|
||||
@ApiParam(value = "Идентификатор группы связанных регистров.", required = true, example = "1234")
|
||||
@PathVariable("groupId") Long groupId,
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody ChangeRefundDateActionNew returnDepositAction) throws ExecutionException, InterruptedException {
|
||||
returnDepositAction.setGroupId(groupId);
|
||||
return processRequest(Consts.REGISTRY_CHANGE_REFUND_DATE_ACTION, returnDepositAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Установить отметку о получение выписки")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/changeStatusExtract/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse changeStatusExtract(
|
||||
@ApiParam(value = "Идентификатор регистра.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody ChangeStatusExtractActionNew changeStatusExtractAction) throws ExecutionException, InterruptedException {
|
||||
changeStatusExtractAction.setId(id);
|
||||
return processRequest(Consts.REGISTRY_CHANGE_STATUS_EXTRACT_ACTION, changeStatusExtractAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.UncoveredDealRegister;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/uncovered-deal-registers")
|
||||
public class UncoveredDealRegisterController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public UncoveredDealRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all uncovered deal registers.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_UncoveredDealRegister,
|
||||
UncoveredDealRegister.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.registry;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.registry.TradingClearingRegistryNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.registry.TradingClearingRegistryUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.registry.TradingClearingRegistryBackendGetById;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/trading-clearing-registries")
|
||||
public class TradingClearingRegistryController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public TradingClearingRegistryController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create TradingClearingRegistry.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody TradingClearingRegistryNewAction bankAccountNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_NEW, bankAccountNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update TradingClearingRegistry.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody TradingClearingRegistryUpdateAction tradingClearingRegistryUpdateAction) throws ExecutionException, InterruptedException {
|
||||
tradingClearingRegistryUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_UPDATE, tradingClearingRegistryUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete TradingClearingRegistry.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get TradingClearingRegistry by id.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = TradingClearingRegistryBackendGetById.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public TradingClearingRegistryBackendGetById getById(@ApiParam(value = "Идентификатор объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) {
|
||||
Optional<TradingClearingRegistry> tradingClearingRegistry = stateLoader.getById(id, IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
TradingClearingRegistryBackendGetById response = new TradingClearingRegistryBackendGetById();
|
||||
tradingClearingRegistry.ifPresentOrElse(response::fromEntity, () -> response.setCode(404));
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all TradingClearingRegistry's.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ public class ClearingCalendarController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody ClearingCalendarUpdateAction clearingCalendarUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import io.swagger.annotations.ApiOperation;
|
|||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -24,12 +26,14 @@ import ru.spcex.clearing.backendapi.security.KeycloakUtils;
|
|||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.platform.enumeration.Task;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
@ -37,6 +41,7 @@ import java.util.concurrent.ExecutionException;
|
|||
@Controller
|
||||
@RequestMapping("/launchers")
|
||||
public class LauncherController extends AbstractQueueController {
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final IStateLoader stateLoader;
|
||||
private final Imdg<User> userImdg;
|
||||
private final Imdg<AbstractDictionary> taskDictionary;
|
||||
|
|
@ -67,33 +72,49 @@ public class LauncherController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{task-code}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(@ApiParam(value = "Код задания из taskDictionary", required = true, example = "ABLK")
|
||||
@PathVariable("task-code") String dictionaryName) throws ExecutionException, InterruptedException {
|
||||
AbstractDictionary taskEnum = taskDictionary.getSingleObjectByFieldValues(Map.of("code", dictionaryName));
|
||||
@PathVariable("task-code") String dictionaryName) throws ExecutionException, InterruptedException {
|
||||
AbstractDictionary taskEnum = taskDictionary.getFirstObjectByFieldValues(Map.of("code", dictionaryName));
|
||||
if (taskEnum == null) {
|
||||
throw new NotFound404Exception("task dictionary element with code '" + dictionaryName + "'");
|
||||
}
|
||||
LauncherNew launcherCommand = new LauncherNew();
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
|
||||
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
|
||||
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
|
||||
if (user == null) {
|
||||
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
|
||||
}
|
||||
launcherCommand.setTask(dictionaryName);
|
||||
launcherCommand.setUserId(user.getId());
|
||||
// пока здесь, это требуется для сохранения истории
|
||||
saveLauncher(dictionaryName, user.getId());
|
||||
//топики ограничиваются наличием в taskDictionary
|
||||
//подписываются на разные топики в разных модулях, см. ru.spcex.platform.enumeration.Task#topic
|
||||
return processRequest("launcher-" + dictionaryName, launcherCommand);
|
||||
return processRequest(Consts.LAUNCHER_NEW, launcherCommand);
|
||||
}
|
||||
|
||||
private void saveLauncher(String taskCode, Long userId) {
|
||||
Launcher launcherCommandHistory = new Launcher();
|
||||
launcherCommandHistory.setTask(taskCode);
|
||||
launcherCommandHistory.setSenderId(userId);
|
||||
launcherCommandHistory.setCreated(Instant.now());
|
||||
launcherImdg.insert(launcherCommandHistory);
|
||||
@ApiOperation(value = "create specific launcher.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/specific", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse addSpecific(@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody LauncherNew launcherNew) throws ExecutionException, InterruptedException {
|
||||
if (launcherNew.getTask() == null) {
|
||||
throw new NotFound404Exception("task dictionary element with code '" + launcherNew.getTask() + "'");
|
||||
}
|
||||
AbstractDictionary taskEnum = taskDictionary.getFirstObjectByFieldValues(Map.of("code", launcherNew.getTask()));
|
||||
if (taskEnum == null) {
|
||||
throw new NotFound404Exception("task dictionary element with code '" + launcherNew.getTask() + "'");
|
||||
}
|
||||
if (!IEnumKey.contains(taskEnum.getCode(), Task.startOfClearing, Task.dbfExport_OUTV)) {
|
||||
log.warn(String.format("Task %s not support request with body", taskEnum.getCode()));
|
||||
} // else В мете эти модели с дополнительными параметрами (OUTV).
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
|
||||
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
|
||||
if (user == null) {
|
||||
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
|
||||
}
|
||||
launcherNew.setUserId(user.getId());
|
||||
return processRequest(Consts.LAUNCHER_NEW, launcherNew);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class PlannerController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody PlannerUpdateAction plannerUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class PlannerTemplateController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody PlannerTemplateUpdateAction plannerTemplateUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,318 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.sdf;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.sdf.*;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/s-dfs")
|
||||
public class SdfsController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public SdfsController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF01")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df01", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf01() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf01,
|
||||
SDf01.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF02")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df02", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf02() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf02,
|
||||
SDf02.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF03")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df03", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf03() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf03,
|
||||
SDf03.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF04")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df04", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf04() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf04,
|
||||
SDf04.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF05")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df05", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf05() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf05,
|
||||
SDf05.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF06")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df06", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf06() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf06,
|
||||
SDf06.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF07")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df07", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf07() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf07,
|
||||
SDf07.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF08")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df08", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf08() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf08,
|
||||
SDf08.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF09")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df09", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf09() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf09,
|
||||
SDf09.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF10")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df10", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf10() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf10,
|
||||
SDf10.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF11")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df11", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf11() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf11,
|
||||
SDf11.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF12")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df12", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf12() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf12,
|
||||
SDf12.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF13")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df13", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf13() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf13,
|
||||
SDf13.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF14")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df14", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf14() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf14,
|
||||
SDf14.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF20")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df20", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf20() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf20,
|
||||
SDf20.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF21")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df21", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf21() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf21,
|
||||
SDf21.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF52")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df52", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf52() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf52,
|
||||
SDf52.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF53")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df53", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf53() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf53,
|
||||
SDf53.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF54")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df54", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf54() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf54,
|
||||
SDf54.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF55")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df55", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf55() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf55,
|
||||
SDf55.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF56")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df56", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf56() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf56,
|
||||
SDf56.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all S_DF57")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(value = "s-df57", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAllSdf57() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_SDf57,
|
||||
SDf57.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.register;
|
||||
package ru.spcex.clearing.backendapi.controller.queue.securities;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.register.DealRegister;
|
||||
import ru.clearing.classes.statics.data.instrument.issue.CouponPeriod;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -19,24 +19,23 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/deal-registers")
|
||||
public class DealRegisterController extends AbstractQueueController {
|
||||
@RequestMapping("/securities/coupon-periods")
|
||||
public class CouponPeriodController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public DealRegisterController(IOperator operator, IStateLoader stateLoader) {
|
||||
public CouponPeriodController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all deal registers.")
|
||||
@ApiOperation(value = "get all coupon periods.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_DealRegister,
|
||||
DealRegister.class);
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_CouponPeriod,
|
||||
CouponPeriod.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.securities;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.instrument.issue.EquitySecurity;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.securities.EquitySecurityNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.securities.EquitySecurityUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.platform.enumeration.Status;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/securities/equity-securities")
|
||||
public class EquitySecurityController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public EquitySecurityController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create equity security.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody EquitySecurityNewAction equitySecurityNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_EQUITY_SECURITY_NEW, equitySecurityNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update equity security.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody EquitySecurityUpdateAction equitySecurityUpdateAction) throws ExecutionException, InterruptedException {
|
||||
equitySecurityUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_EQUITY_SECURITY_UPDATE, equitySecurityUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete equity security.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_EQUITY_SECURITY_DELETE, deleteAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all equity securities.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_EquitySecurity,
|
||||
EquitySecurity.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.securities;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.instrument.issue.FixedIncomeCashFlow;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/securities/fixed-income-cash-flows")
|
||||
public class FixedIncomeCashFlowController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public FixedIncomeCashFlowController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all fixed income cash flow securities.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_FixedIncomeCashFlow,
|
||||
FixedIncomeCashFlow.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.securities;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.instrument.issue.FixedIncomeSecurity;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.securities.FixedIncomeSecurityNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.securities.FixedIncomeSecurityUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.platform.enumeration.Status;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/securities/fixed-income-securities")
|
||||
public class FixedIncomeSecurityController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public FixedIncomeSecurityController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create fixed income security.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody FixedIncomeSecurityNewAction fixedIncomeSecurityNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_FIXED_INCOME_SECURITY_NEW, fixedIncomeSecurityNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update fixed income security.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody FixedIncomeSecurityUpdateAction fixedIncomeSecurityUpdateAction) throws ExecutionException, InterruptedException {
|
||||
fixedIncomeSecurityUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_FIXED_INCOME_SECURITY_UPDATE, fixedIncomeSecurityUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete fixed income security.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_FIXED_INCOME_SECURITY_DELETE, deleteAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all equity securities.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_FixedIncomeSecurity,
|
||||
FixedIncomeSecurity.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.misc.MoneyMarketSecurity;
|
||||
import ru.clearing.classes.statics.data.security.MoneyMarketSecurity;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.securities.MoneyMarketSecurityNewAction;
|
||||
|
|
@ -28,11 +28,11 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/securities/money-securities")
|
||||
public class CudMoneyMarketSecurityController extends AbstractQueueController {
|
||||
public class MoneyMarketSecurityController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public CudMoneyMarketSecurityController(IOperator operator, IStateLoader stateLoader) {
|
||||
public MoneyMarketSecurityController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ public class CudMoneyMarketSecurityController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody MoneyMarketSecurityUpdateAction moneySecurityUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
@ -77,8 +77,7 @@ public class CudMoneyMarketSecurityController extends AbstractQueueController {
|
|||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_MoneyMarketSecurity,
|
||||
MoneyMarketSecurity.class,
|
||||
Map.of("workflowStatus", Status.Active.getKey()));
|
||||
MoneyMarketSecurity.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -8,14 +8,21 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import ru.clearing.classes.statics.data.instrument.issue.EquitySecurity;
|
||||
import ru.clearing.classes.statics.data.instrument.issue.FixedIncomeSecurity;
|
||||
import ru.clearing.classes.statics.data.security.MoneyMarketSecurity;
|
||||
import ru.clearing.classes.statics.data.security.Security;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SecurityController и MoneyMarketSecurityController разные контроллеры, не путать.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/securities")
|
||||
public class SecurityController {
|
||||
|
|
@ -31,9 +38,16 @@ public class SecurityController {
|
|||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransformSpecificClass(
|
||||
IMDGDistributedNames.Map_MoneyMarketSecurity,
|
||||
Security.class);
|
||||
Collection<Map<String, Object>> all = new ArrayList<>();
|
||||
all.addAll(stateLoader.getAllMetaTransformSpecificClass(
|
||||
IMDGDistributedNames.Map_MoneyMarketSecurity, MoneyMarketSecurity.class
|
||||
));
|
||||
all.addAll(stateLoader.getAllMetaTransformSpecificClass(
|
||||
IMDGDistributedNames.Map_FixedIncomeSecurity, FixedIncomeSecurity.class
|
||||
));
|
||||
all.addAll(stateLoader.getAllMetaTransformSpecificClass(
|
||||
IMDGDistributedNames.Map_EquitySecurity, EquitySecurity.class
|
||||
));
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class UserController extends AbstractQueueController {
|
|||
UserIdResponse response = new UserIdResponse();
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
|
||||
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
|
||||
User user = username == null ? null : userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
|
||||
if (user == null) {
|
||||
log.info("getId user {} authenticated, but User object was not created", username);
|
||||
throw new IllegalStateException("couldn't return user id");
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
|||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetByIdResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.account.BankAccountBackendGetById;
|
||||
import ru.spcex.clearing.backendapi.errors.NotFound404Exception;
|
||||
import ru.spcex.clearing.backendapi.meta.GetResponseFactory;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
|
|
@ -51,7 +50,7 @@ public class StatementController extends AbstractQueueController {
|
|||
}
|
||||
|
||||
@ApiOperation(value = "get Statement by Id.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = BankAccountBackendGetById.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetByIdResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetByIdResponse getById(@ApiParam(value = "Идентификатор объекта", required = true, example = "1234")
|
||||
|
|
|
|||
|
|
@ -45,12 +45,21 @@ public class UserSettingsController extends AbstractQueueController {
|
|||
this.userImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_User, User.class);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "get all user settings.")
|
||||
@ApiOperation(value = "get all user settings for current user.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_UserSettings, UserSettings.class);
|
||||
public CommonGetAllResponse getAllForCurrentUser() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
|
||||
User user = username == null ? null : userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
|
||||
if (user == null) {
|
||||
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
|
||||
}
|
||||
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(IMDGDistributedNames.Map_UserSettings, UserSettings.class,
|
||||
Map.of("userId", user.getId())
|
||||
);
|
||||
var response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
return response;
|
||||
|
|
@ -65,7 +74,7 @@ public class UserSettingsController extends AbstractQueueController {
|
|||
@RequestBody UserSettingsUpdateAction userSettingsUpdateAction) throws ExecutionException, InterruptedException {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
|
||||
User user = userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
|
||||
User user = userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
|
||||
if (user == null) {
|
||||
throw new IllegalStateException("cannot obtain userId from logged in user " + username);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue