Compare commits
1063 commits
sdf08
...
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 | ||
|
|
24e9b4f548 | ||
|
|
587da25d0c |
975 changed files with 64000 additions and 15034 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,18 +12,18 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAcco
|
|||
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.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.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
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.IErrorEnumId;
|
||||
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;
|
||||
|
||||
|
|
@ -57,10 +57,16 @@ public class AccountValidationConfig {
|
|||
AccountError.CompanyNotFound
|
||||
// company -> WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive
|
||||
),
|
||||
FieldRequiredRule.instance("account",
|
||||
FieldRequiredSpecificRule.instance("account",
|
||||
CorrespondentAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
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
|
||||
);
|
||||
|
|
@ -70,29 +76,37 @@ public class AccountValidationConfig {
|
|||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate, accountStatusPredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
return new EnumMessage(AccountError.AccountAlreadyExist, accounts.stream().findFirst().get().getAccount());
|
||||
}),
|
||||
DictionaryPresentRule.instance("status",
|
||||
CorrespondentAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
false,
|
||||
statusValue -> {
|
||||
if (ServiceStatus.Active.equalsByKey(statusValue.getCode())) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
}),
|
||||
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.WrongFieldValue,
|
||||
AccountError.DictionaryNotFound,
|
||||
accountType -> {
|
||||
if (AccountType.Corr.equalsByKey(accountType.getCode())) return null;
|
||||
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)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
@ -115,13 +129,7 @@ public class AccountValidationConfig {
|
|||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
account -> {
|
||||
// проверка на заблокированность счёта
|
||||
if (!AccountStatus.ACTIVE.getKey().equalsIgnoreCase(account.getStatus()))
|
||||
return AccountError.AccountNotActive;
|
||||
return null;
|
||||
}),
|
||||
AccountError.AccountNotFound),
|
||||
IdPresentRule.instance("companyId",
|
||||
CorrespondentAccountUpdateRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
|
|
@ -130,26 +138,29 @@ public class AccountValidationConfig {
|
|||
AccountError.CompanyNotFound,
|
||||
false,
|
||||
company -> {
|
||||
IErrorEnumId error = WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive;
|
||||
error = Objects.equals(company.getId(), correspondentAccountUpdateRequest.getCompanyId()) ? error : AccountError.WrongFieldValue;
|
||||
return error;
|
||||
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.WrongFieldValue),
|
||||
AccountError.DictionaryNotFound,
|
||||
false),
|
||||
DictionaryPresentRule.instance("accountType",
|
||||
CorrespondentAccountUpdateRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary,
|
||||
AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
accountType -> {
|
||||
if (AccountType.Corr.equalsByKey(accountType.getCode())) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
})
|
||||
AccountError.DictionaryNotFound,
|
||||
false
|
||||
// accountType -> {
|
||||
// if (AccountType.Corr.equalsByKey(accountType.getCode())) return null;
|
||||
// return AccountError.WrongFieldValue;
|
||||
// }
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
@ -164,15 +175,16 @@ public class AccountValidationConfig {
|
|||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
IdPresentSpecificRule.instance("id",
|
||||
CommonIdRequest::getId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
account -> {
|
||||
if (WorkflowStatus.Active.equalsByKey(account.getStatus())) return null;
|
||||
return AccountError.AccountNotActive;
|
||||
if (AccountStatus.BLOCKED.equalsByKey(account.getStatus()))
|
||||
return new EnumMessage(AccountError.AccountNotActive, account.getAccount());
|
||||
return null;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,23 +6,24 @@ 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.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
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.IValidator;
|
||||
import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||
|
||||
|
|
@ -45,6 +46,7 @@ public class BankAccountValidationConfig {
|
|||
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",
|
||||
|
|
@ -54,36 +56,30 @@ public class BankAccountValidationConfig {
|
|||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
false),
|
||||
FieldRequiredRule.instance("account",
|
||||
FieldNotBlankRequiredRule.instance("account",
|
||||
BankAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
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.Bank.getKey());
|
||||
ImdgPredicate finalPredicate = pb.and(accountValuePredicate,
|
||||
accountStatusPredicate,
|
||||
accountTypePredicate);
|
||||
Collection<Account> accounts = accountImdg.getCollectionObjectsByPredicate(finalPredicate);
|
||||
if (accounts.isEmpty()) return null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
AccountError.RequiredFieldEmpty
|
||||
),
|
||||
new SameAccountValidationRule<>(AccountType.Bank, BankAccountNewRequest::getAccount),
|
||||
DictionaryPresentRule.instance("currency",
|
||||
BankAccountNewRequest::getCurrency,
|
||||
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||
CurrencyCodeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue),
|
||||
AccountError.DictionaryNotFound),
|
||||
FieldRequiredRule.instance("bankIdentificationCode",
|
||||
BankAccountNewRequest::getBankIdentificationCode,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
FieldRequiredRule.instance("bankName",
|
||||
BankAccountNewRequest::getBankName,
|
||||
AccountError.RequiredFieldEmpty)
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("status",
|
||||
BankAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
@ -122,7 +118,7 @@ public class BankAccountValidationConfig {
|
|||
IMDGDistributedNames.Map_CurrencyCodeDictionary,
|
||||
CurrencyCodeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
|
|
@ -139,7 +135,7 @@ public class BankAccountValidationConfig {
|
|||
addImdg.accept(IMDGDistributedNames.Map_BankAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
IdPresentSpecificRule.instance("id",
|
||||
CommonIdRequest::getId,
|
||||
IMDGDistributedNames.Map_BankAccount,
|
||||
BankAccount.class,
|
||||
|
|
@ -151,8 +147,10 @@ public class BankAccountValidationConfig {
|
|||
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;
|
||||
if (account == null)
|
||||
return new EnumMessage(AccountError.AccountNotFound, accountId);
|
||||
if (AccountStatus.BLOCKED.equalsByKey(account.getStatus()))
|
||||
return new EnumMessage(AccountError.AccountNotActive, account.getAccount());
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,17 +5,19 @@ 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.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
|
|
@ -43,6 +45,7 @@ public class ClearingAccountValidationConfig {
|
|||
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,
|
||||
|
|
@ -52,30 +55,23 @@ public class ClearingAccountValidationConfig {
|
|||
AccountError.CompanyNotFound
|
||||
// company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null
|
||||
),
|
||||
FieldRequiredRule.instance("account",
|
||||
FieldNotBlankRequiredRule.instance("account",
|
||||
ClearingAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
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 null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
AccountError.RequiredFieldEmpty),
|
||||
new SameAccountValidationRule<>(AccountType.Clrn, ClearingAccountNewRequest::getAccount),
|
||||
DictionaryPresentRule.instance("clearingAccountType",
|
||||
ClearingAccountNewRequest::getClearingAccountType,
|
||||
IMDGDistributedNames.Map_ClearingAccountTypeDictionary,
|
||||
ClearingAccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue)
|
||||
AccountError.DictionaryNotFound),
|
||||
DictionaryPresentRule.instance("status",
|
||||
ClearingAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
@ -98,6 +94,8 @@ public class ClearingAccountValidationConfig {
|
|||
ClearingAccountUpdateRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
if (accountValue.isBlank())
|
||||
return AccountError.RequiredFieldEmpty;
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
|
@ -126,7 +124,7 @@ public class ClearingAccountValidationConfig {
|
|||
Imdg<Company> companyImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
Company company = companyImdg.getSingleObjectByFieldValues(Map.of("tradingCode", dealValue));
|
||||
Company company = companyImdg.getFirstObjectByFieldValues(Map.of("tradingCode", dealValue));
|
||||
if (company == null) return AccountError.WrongFieldValue;
|
||||
return null;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ 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.classes.statics.data.registry.TradingClearingRegistry;
|
||||
import ru.clearing.platform.dictionary.WorkflowStatusDictionary;
|
||||
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;
|
||||
|
|
@ -38,7 +37,7 @@ public class ClientCodeValidationConfig {
|
|||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||
addImdg.accept(IMDGDistributedNames.Map_WorkflowStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
FieldRequiredRule.instance("companyId", ClientCodeNewRequest::getCompanyId, AccountError.RequiredFieldEmpty),
|
||||
IdPresentRule.instance("companyId",
|
||||
|
|
@ -72,8 +71,8 @@ public class ClientCodeValidationConfig {
|
|||
|
||||
DictionaryPresentRule.instance("stauts",
|
||||
ClientCodeNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_WorkflowStatusDictionary,
|
||||
WorkflowStatusDictionary.class,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
|
|
@ -91,7 +90,7 @@ public class ClientCodeValidationConfig {
|
|||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_TradingClearingRegistry);
|
||||
addImdg.accept(IMDGDistributedNames.Map_WorkflowStatusDictionary);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ServiceStatusDictionary);
|
||||
return new ValidatorImpl<ImdgValidationContext<ClientCodeUpdateRequest>>(context,
|
||||
IdPresentRule.instance("id",
|
||||
ClientCodeUpdateRequest::getId,
|
||||
|
|
@ -132,8 +131,8 @@ public class ClientCodeValidationConfig {
|
|||
|
||||
DictionaryPresentRule.instance("stauts",
|
||||
ClientCodeUpdateRequest::getStatus,
|
||||
IMDGDistributedNames.Map_WorkflowStatusDictionary,
|
||||
WorkflowStatusDictionary.class,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
|
|
|
|||
|
|
@ -4,18 +4,18 @@ 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.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
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;
|
||||
|
|
@ -39,6 +39,7 @@ public class DepoAccountValidationConfig {
|
|||
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,
|
||||
|
|
@ -48,27 +49,20 @@ public class DepoAccountValidationConfig {
|
|||
AccountError.CompanyNotFound
|
||||
// company -> !WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()) ? AccountError.CompanyNotActive : null
|
||||
),
|
||||
FieldRequiredRule.instance("account",
|
||||
FieldNotBlankRequiredRule.instance("account",
|
||||
DepoAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
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 null;
|
||||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
AccountError.RequiredFieldEmpty),
|
||||
new SameAccountValidationRule<>(AccountType.Depo, DepoAccountNewRequest::getAccount),
|
||||
FieldRequiredRule.instance("depoAccountType",
|
||||
DepoAccountNewRequest::getDepoAccountType,
|
||||
AccountError.RequiredFieldEmpty)
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("status",
|
||||
DepoAccountNewRequest::getStatus,
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,20 +2,23 @@ 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.InformationAccount;
|
||||
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.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
|
@ -33,6 +36,9 @@ public class InformationAccountValidationConfig {
|
|||
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,
|
||||
|
|
@ -43,16 +49,17 @@ public class InformationAccountValidationConfig {
|
|||
company -> {
|
||||
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()))
|
||||
return AccountError.CompanyNotActive;
|
||||
Long companyId = company.getId();
|
||||
Imdg<InformationAccount> informationAccountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
Collection<InformationAccount> infoAccounts = informationAccountImdg.getCollectionObjectsByFieldValues(
|
||||
Map.of("companyId", companyId)
|
||||
);
|
||||
if (infoAccounts.isEmpty()) return null;
|
||||
return AccountError.InfoAccountAlreadyExist;
|
||||
})
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,10 +2,10 @@ 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.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
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.errors.AccountError;
|
||||
|
|
@ -16,14 +16,22 @@ import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingR
|
|||
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.ServiceStatus;
|
||||
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;
|
||||
|
||||
|
|
@ -39,32 +47,63 @@ public class TradingClearingRegistryValidationConfig {
|
|||
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,
|
||||
IdPresentRule.instance("companyId",
|
||||
IdPresentSpecificRule.instance("companyId",
|
||||
TradingClearingRegistryNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound),
|
||||
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<ClearingAccount> clearingAccountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
ClearingAccount clearingAccount = clearingAccountImdg.getSingleObjectByID(moneyAccountId);
|
||||
if (clearingAccount == null) {
|
||||
Imdg<InformationAccount> informationAccountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
InformationAccount infoAccount = informationAccountImdg.getSingleObjectByID(moneyAccountId);
|
||||
if (infoAccount == null) return AccountError.AccountNotFound;
|
||||
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",
|
||||
|
|
@ -74,7 +113,9 @@ public class TradingClearingRegistryValidationConfig {
|
|||
depoAccountId -> {
|
||||
if (depoAccountId == null) return null;
|
||||
Imdg<DepoAccount> depoAccountImdg = context.obtainMap(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
DepoAccount depoAccount = depoAccountImdg.getSingleObjectByID(depoAccountId);
|
||||
DepoAccount depoAccount = depoAccountImdg.getFirstObjectByFieldValues(
|
||||
Map.of("accountId", depoAccountId)
|
||||
);
|
||||
if (depoAccount == null) return AccountError.AccountNotFound;
|
||||
return null;
|
||||
}),
|
||||
|
|
@ -83,17 +124,49 @@ public class TradingClearingRegistryValidationConfig {
|
|||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
false,
|
||||
statusValue -> {
|
||||
String statusCode = statusValue.getCode();
|
||||
if (ServiceStatus.Active.equalsByKey(statusCode)) return null;
|
||||
return AccountError.WrongFieldValue;
|
||||
})
|
||||
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
|
||||
|
|
@ -116,7 +189,7 @@ public class TradingClearingRegistryValidationConfig {
|
|||
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||
ServiceStatusDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.WrongFieldValue,
|
||||
AccountError.DictionaryNotFound,
|
||||
false)
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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;
|
||||
|
|
@ -28,6 +29,7 @@ public class ValidationConfig {
|
|||
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);
|
||||
|
|
@ -39,9 +41,9 @@ public class ValidationConfig {
|
|||
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_WorkflowStatusDictionary, WorkflowStatusDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClientCode, ClientCode.class);
|
||||
|
||||
return imdg;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,11 @@ public enum AccountError implements IErrorEnumId {
|
|||
DepoAccountNotFound(5017L),
|
||||
MoneyAccountNotFound(5018L),
|
||||
ClearingCategoryNotFound(5019L),
|
||||
TradingClearingRegistryNotFound(5022L),
|
||||
ClearingCompanySymbolNotFound(5022L), // Для компании %s отсутствует клиринговый код».
|
||||
AccountForTradingClearingRegistryAlreadyUsed(5023L),
|
||||
AccountFieldNotSet(5024L),
|
||||
AccountDepoTypeRequired(5025L),
|
||||
TradingClearingRegistryNotFound(3022L),
|
||||
;
|
||||
|
||||
private final 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,9 @@ 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;
|
||||
|
|
@ -17,22 +20,18 @@ 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.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
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.sdf01.AccountTerminationRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonIdRequest;
|
||||
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.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.ClearingCategory;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
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;
|
||||
|
|
@ -41,14 +40,14 @@ import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
|||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
|
@ -56,6 +55,8 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
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;
|
||||
|
|
@ -68,6 +69,8 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
IMessageResolver messageResolver,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper,
|
||||
AccountHelper accountHelper,
|
||||
InformationAccountService informationAccountService,
|
||||
@Qualifier("correspondentAccountNewRequestValidator")
|
||||
Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator,
|
||||
@Qualifier("correspondentAccountUpdateRequestValidator")
|
||||
|
|
@ -75,6 +78,8 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
@Qualifier("correspondentAccountBlockRequestValidator")
|
||||
Function<CommonIdRequest, IValidator> accountBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.accountHelper = accountHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountMap = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
|
|
@ -88,6 +93,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
this.messageResolver = messageResolver;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.validationHelper = validationHelper;
|
||||
this.informationAccountService = informationAccountService;
|
||||
this.accountNewRequestValidator = accountNewRequestValidator;
|
||||
this.accountUpdateRequestValidator = accountUpdateRequestValidator;
|
||||
this.accountBlockRequestValidator = accountBlockRequestValidator;
|
||||
|
|
@ -95,9 +101,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
callback(AccountSdf01Request.class)
|
||||
.setFunction(this::accountNewSdf01)
|
||||
.forDestination(Consts.ACCOUNT_NEW_SDF01, callbacks::put);
|
||||
imdgProvider.waitAvailable();
|
||||
callback(CorrespondentAccountNewRequest.class)
|
||||
.setFunction(this::accountCorrespondentNew)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, callbacks::put);
|
||||
|
|
@ -107,6 +111,10 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
@ -126,19 +134,105 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
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);
|
||||
}
|
||||
account.setAccountType(req.getAccountType());
|
||||
account.setStatus(req.getStatus());
|
||||
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 = fillAccountFromRelation(account, userRequest.getId(), false);
|
||||
requestInfoUpdate = accountHelper.fillAccountFromRelation(account, userRequest.getId(), false);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
Long newId = accountMap.insert(account);
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
|
|
@ -151,6 +245,10 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
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());
|
||||
|
||||
|
|
@ -183,98 +281,45 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RequestInfoUpdate accountNewSdf01(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
log.debug("AccountSdf01Request received");
|
||||
|
||||
AccountSdf01Request req = userRequest.getRequestPayload();
|
||||
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);
|
||||
}
|
||||
sendStatementRequestBack(req.getGroupingSdf01Id(), accountToStatement);
|
||||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||
public RequestInfoUpdate accountTerminationForCompany(BaseRequest<AccountTerminationRequest> userRequest) {
|
||||
log.debug("AccountTerminationRequest received, id={}", userRequest.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate; // never - system
|
||||
|
||||
public void accountUpdateWithBrake(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
|
||||
}
|
||||
|
||||
public AccountSdfToStatementRequestPart responsePart(Long sdf01Id) {
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(sdf01Id);
|
||||
responsePart.setErrorCode(null);
|
||||
responsePart.setErrorText(null);
|
||||
return responsePart;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void sendStatementRequestBack(Long groupingSdf01Id, List<AccountSdfToStatementRequestPart> results) {
|
||||
StatementRequest request = new StatementRequest();
|
||||
request.setGroupId(groupingSdf01Id);
|
||||
request.setAccountCreationResults(results);
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.STATEMENT_PROCESS, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.STATEMENT_PROCESS, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Заполняет поля 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)");
|
||||
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++;
|
||||
}
|
||||
}
|
||||
finalRelationPredicate = relationPredicateBuilder.and(consumerIdPredicate, servicePredicate);
|
||||
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||
} else {
|
||||
finalRelationPredicate = relationPredicateBuilder.equals("consumerId", companyId);
|
||||
relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk)
|
||||
tx.commitTransaction();
|
||||
else
|
||||
tx.beginTransaction();
|
||||
}
|
||||
log.debug("For company {} block {} account (of {} account)", companyId, blockCount, accounts.size());
|
||||
|
||||
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());
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ 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.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;
|
||||
|
|
@ -40,7 +41,7 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
private final UserRoleVerification userRoleVerification;
|
||||
private final ValidationHelper validationHelper;
|
||||
|
||||
private final AccountService accountService;
|
||||
private final AccountHelper accountService;
|
||||
|
||||
private final Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator;
|
||||
private final Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator;
|
||||
|
|
@ -52,13 +53,13 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
ImdgProvider imdgProvider,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper,
|
||||
AccountService accountService,
|
||||
AccountHelper accountService,
|
||||
@Qualifier("bankAccountNewRequestValidator")
|
||||
Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator,
|
||||
Function<BankAccountNewRequest, IValidator> bankAccountNewRequestValidator,
|
||||
@Qualifier("bankAccountUpdateRequestValidator")
|
||||
Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator,
|
||||
Function<BankAccountUpdateRequest, IValidator> bankAccountUpdateRequestValidator,
|
||||
@Qualifier("bankAccountBlockRequestValidator")
|
||||
Function<CommonIdRequest, IValidator> 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);
|
||||
|
|
@ -101,7 +102,12 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Bank.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
if (req.getStatus() == null) {
|
||||
log.trace("Status not set in request. Use default: {}", account.getStatus());
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
} else {
|
||||
account.setStatus(req.getStatus());
|
||||
}
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
|
|
@ -114,6 +120,8 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
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 bankAccount = new BankAccount();
|
||||
|
|
@ -174,6 +182,8 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
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;
|
||||
|
|
@ -188,7 +198,7 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
bankAccount.getId(),
|
||||
account.getId());
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("successfully update, existing bankAccount with id {}", bankAccount.getId());
|
||||
return null;
|
||||
|
|
@ -209,27 +219,10 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
Account account = accountMap.getSingleObjectByID(bankAccount.getAccountId());
|
||||
account.setStatus(ServiceStatus.Blocked.getKey());
|
||||
account.setUpdated(Instant.now());
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
boolean txOk = false;
|
||||
imdgTransaction.beginTransaction();
|
||||
try {
|
||||
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 block, bank account id {}, new account id {}",
|
||||
bankAccount.getId(),
|
||||
account.getId());
|
||||
imdgTransaction.rollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
accountMap.update(account);
|
||||
//без изменений bankAccountMap.update(bankAccount);
|
||||
|
||||
log.debug("successfully block, existing bankAccount with id {}", bankAccount.getId());
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
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;
|
||||
|
|
@ -10,71 +12,105 @@ 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.registry.TradingClearingRegistryNewRequest;
|
||||
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.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
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.Map;
|
||||
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 AccountService accountService;
|
||||
private final AccountHelper accountService;
|
||||
private final SDFProcessService sdfProcessService;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<ClearingAccount> clearingAccountImdg;
|
||||
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,
|
||||
AccountService accountService,
|
||||
AccountHelper accountService,
|
||||
SDFProcessService sdfProcessService,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
IMessageResolver messageResolver,
|
||||
RequestHelper requestHelper,
|
||||
@Qualifier("clearingAccountNewRequestValidator")
|
||||
Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator,
|
||||
Function<ClearingAccountNewRequest, IValidator> clearingAccountNewRequestValidator,
|
||||
@Qualifier("clearingAccountUpdateRequestValidator")
|
||||
Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator) {
|
||||
Function<ClearingAccountUpdateRequest, IValidator> clearingAccountUpdateRequestValidator) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.accountService = accountService;
|
||||
this.sdfProcessService = sdfProcessService;
|
||||
this.validationHelper = validationHelper;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.clearingAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
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
|
||||
|
|
@ -85,6 +121,17 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +147,12 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Clrn.getKey());
|
||||
account.setStatus(ServiceStatus.Active.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);
|
||||
|
|
@ -114,6 +166,8 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
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();
|
||||
|
|
@ -125,12 +179,6 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setMoneyAccountId(accountId);
|
||||
request.setCompanyId(clearingAccount.getCompanyId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW,
|
||||
LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
||||
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)",
|
||||
|
|
@ -149,29 +197,421 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ClearingAccountUpdateRequest req = userRequest.getRequestPayload();
|
||||
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();
|
||||
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);
|
||||
|
||||
ClearingAccount clearingAccount = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", accountId));
|
||||
if (clearingAccount == null)
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.AccountNotFound, account.getAccount());
|
||||
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);
|
||||
|
||||
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());
|
||||
Account account = accountImdg.getCollectionObjectsByPredicate(finalPredicate).iterator().next();
|
||||
Long accountId = account.getId();
|
||||
|
||||
accountImdg.update(account);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ 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.error.ClearingBaseException;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
|
|
@ -51,6 +51,7 @@ 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;
|
||||
|
||||
|
|
@ -79,6 +80,7 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
@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);
|
||||
|
|
@ -94,6 +96,8 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
imdgProvider.waitAvailable();
|
||||
|
||||
callback(ClientCodeNewRequest.class)
|
||||
.setFunction(this::clientCodeNew)
|
||||
.forDestination(Consts.DESTINATION_CLIENT_CODE_NEW, callbacks::put);
|
||||
|
|
@ -111,6 +115,33 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверки
|
||||
* 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());
|
||||
|
|
@ -122,13 +153,17 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
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 {
|
||||
createAndWaitTCR(userRequest.getId(), null,
|
||||
requestInfoUpdate = createAndWaitTCR(userRequest.getId(), null,
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
} catch (ClearingBaseException e) {
|
||||
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());
|
||||
|
|
@ -145,7 +180,7 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
|
||||
|
||||
protected RequestInfoUpdate clientCodeNewFromApiUmCompany(BaseRequest<ClientCodeNewRequest> userRequest) {
|
||||
log.debug("ClientCodeNewRequest received {}", userRequest.getId());
|
||||
log.debug("ClientCodeNewRequest (UM_COMPANY) received {}", userRequest.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
|
@ -155,13 +190,17 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
|
||||
|
||||
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 {
|
||||
createAndWaitTCR(userRequest.getId(), null,
|
||||
requestInfoUpdate = createAndWaitTCR(userRequest.getId(), null,
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
} catch (ClearingBaseException e) {
|
||||
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());
|
||||
|
|
@ -185,6 +224,9 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
|
||||
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());
|
||||
|
|
@ -196,9 +238,10 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
boolean doCreateTCR = checkNeedCreateTCR(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
if (doCreateTCR) {
|
||||
try {
|
||||
createAndWaitTCR(userRequest.getId(), clientCode.getId(),
|
||||
requestInfoUpdate = createAndWaitTCR(userRequest.getId(), clientCode.getId(),
|
||||
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
|
||||
} catch (ClearingBaseException e) {
|
||||
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());
|
||||
|
|
@ -248,7 +291,7 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
if (depoAccountId != null) {
|
||||
query.put("depoAccountId", depoAccountId);
|
||||
}
|
||||
TradingClearingRegistry result = tradingClearingRegistryMap.getSingleObjectByFieldValues(query);
|
||||
TradingClearingRegistry result = tradingClearingRegistryMap.getFirstObjectByFieldValues(query);
|
||||
log.trace("TradingClearingRegistry by: {}; {}found", query, result == null ? "not " : "");
|
||||
return result;
|
||||
}
|
||||
|
|
@ -266,8 +309,8 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
}
|
||||
}
|
||||
|
||||
protected void createAndWaitTCR(Long reqId, Long clientCode,
|
||||
Long companyId, Long moneyAccountId, Long depoAccountId) throws ClearingBaseException {
|
||||
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);
|
||||
|
|
@ -281,17 +324,13 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
|
|||
// requestPayload.setStatus(WorkflowStatus.Active.getKey());
|
||||
requestPayload.setTradingClearingRegistryType(TradingClearingRegistryType.Client_B.getKey());
|
||||
request.setRequestPayload(requestPayload);
|
||||
try {
|
||||
// Следующий вызываемый метод обязательно должен быть synchronized.
|
||||
RequestInfoUpdate reply = tradingClearingRegistryService.tradingClearingRegistryNew(request);
|
||||
if (reply != null && Status.Error.equals(reply.getStatus())) {
|
||||
throw new ClearingBaseException(AccountError.GeneralError, "tradingClearingRegistryService return error: " + reply.getMessage());
|
||||
}
|
||||
} catch (ClearingBaseException expected) {
|
||||
throw expected;
|
||||
} catch (Exception e) {
|
||||
throw new ClearingBaseException(AccountError.GeneralError, "Waiting account-service timeout");
|
||||
|
||||
// Следующий вызываемый метод обязательно должен быть 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) {
|
||||
|
|
|
|||
|
|
@ -9,24 +9,29 @@ 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.registry.TradingClearingRegistryNewRequest;
|
||||
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.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
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
|
||||
|
|
@ -36,17 +41,15 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
private final KafkaSender kafkaSender;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final AccountService accountService;
|
||||
private final AccountHelper accountService;
|
||||
private final Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator;
|
||||
private final Imdg<Account> accountImdg;
|
||||
private final Imdg<DepoAccount> depoAccountImdg;
|
||||
|
||||
public DepoAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
KafkaSender kafkaSender,
|
||||
ValidationHelper validationHelper,
|
||||
ImdgProvider imdgProvider,
|
||||
AccountService accountService,
|
||||
AccountHelper accountService,
|
||||
@Qualifier("depoAccountNewRequestValidator")
|
||||
Function<DepoAccountNewRequest, IValidator> depoAccountNewRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
|
|
@ -55,8 +58,6 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
this.imdgProvider = imdgProvider;
|
||||
this.accountService = accountService;
|
||||
this.depoAccountNewRequestValidator = depoAccountNewRequestValidator;
|
||||
this.accountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
this.depoAccountImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_DepoAccount, DepoAccount.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -64,6 +65,10 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +85,12 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Depo.getKey());
|
||||
account.setStatus(ServiceStatus.Active.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);
|
||||
|
|
@ -94,22 +104,23 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
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);
|
||||
depoAccount.setDepoAccountType(req.getDepoAccountType());
|
||||
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();
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setDepoAccountId(accountId);
|
||||
request.setCompanyId(depoAccount.getCompanyId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
||||
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)",
|
||||
|
|
@ -120,4 +131,107 @@ public class DepoAccountService extends QueueConsumer implements InitializingBea
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,17 @@ 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;
|
||||
|
|
@ -48,9 +51,10 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
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 AccountService accountService;
|
||||
private final AccountHelper accountHelper;
|
||||
private final RequestHelper requestHelper;
|
||||
private final Function<InformationAccountNewRequest, IValidator> infoAccountNewRequestValidator;
|
||||
private final Imdg<InformationAccount> informationAccountImdg;
|
||||
|
|
@ -66,18 +70,20 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
Producer<String, Object> kafkaResponseQueue,
|
||||
KafkaSender kafkaSender,
|
||||
IMessageResolver messageResolver,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ImdgProvider imdgProvider,
|
||||
ValidationHelper validationHelper,
|
||||
AccountService accountService,
|
||||
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.accountService = accountService;
|
||||
this.accountHelper = accountHelper;
|
||||
this.requestHelper = requestHelper;
|
||||
this.infoAccountNewRequestValidator = infoAccountNewRequestValidator;
|
||||
this.informationAccountImdg = imdgProvider.getImdg(
|
||||
|
|
@ -99,11 +105,16 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
init();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RequestInfoUpdate informationAccountNew(BaseRequest<InformationAccountNewRequest> userRequest) {
|
||||
log.debug("InformationAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, infoAccountNewRequestValidator);
|
||||
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();
|
||||
|
|
@ -124,13 +135,19 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
account.setAccount(accountValue);
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Info.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setCompanyId(userRequest.getRequestPayload().getCompanyId());
|
||||
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);
|
||||
|
||||
requestInfoUpdate = accountHelper.fillAccountFromRelation(account, userRequest.getId(), true);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
ImdgTransaction imdgTransaction = imdgProvider.newTransaction();
|
||||
|
|
@ -140,23 +157,21 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
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(userRequest.getRequestPayload().getCompanyId());
|
||||
informationAccount.setCompanyId(req.getCompanyId());
|
||||
informationAccountId = informationAccountImdg.insert(informationAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setMoneyAccountId(informationAccountId);
|
||||
request.setCompanyId(informationAccount.getCompanyId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
|
|
@ -173,7 +188,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
|
||||
|
||||
public RequestInfoUpdate informationAccountSystemNew(BaseRequest<InformationAccountNewRequest> userRequest) {
|
||||
log.debug("InformationAccountNewRequest received (system)");
|
||||
log.debug("InformationAccountNewRequest received (system), request id={}", userRequest.getId());
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate;
|
||||
// RequestInfoUpdate requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, infoAccountNewRequestValidator);
|
||||
|
|
@ -194,23 +209,27 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
}
|
||||
|
||||
|
||||
// todo требуется последовательность n+1
|
||||
Long newId = informationAccountImdg.nextIDSequenceFor();
|
||||
Long infoSequenceId = accountNextId();
|
||||
Long infoSequenceId = accountNextId(); // требуется последовательность n+1
|
||||
String accountValue = generateInfoAccount(infoSequenceId);
|
||||
log.trace("New info-account id={}, sequenceId={}, account={}", newId, infoSequenceId, accountValue);
|
||||
|
||||
ImdgPredicate andPredicate = pb.and(
|
||||
pb.equals("companyId", 1L),
|
||||
pb.equals("accountType", AccountType.Anlt.getKey())
|
||||
);
|
||||
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");
|
||||
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();
|
||||
}
|
||||
Account anltAccount = accountsAnlt.iterator().next();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Account account = new Account();
|
||||
|
|
@ -220,8 +239,11 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
account.setCompanyId(forCompanyId);
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
requestInfoUpdate = accountService.fillAccountFromRelation(account, userRequest.getId(), true);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
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();
|
||||
|
|
@ -230,23 +252,20 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
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.setClearingAccountId(anltAccountId);
|
||||
informationAccount.setCompanyId(userRequest.getRequestPayload().getCompanyId());
|
||||
informationAccountId = informationAccountImdg.insert(informationAccount);
|
||||
txOk = true;
|
||||
} finally {
|
||||
if (txOk) {
|
||||
imdgTransaction.commitTransaction();
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setMoneyAccountId(informationAccountId);
|
||||
request.setCompanyId(informationAccount.getCompanyId());
|
||||
log.debug("Send message to kafka \"{}\": {}", Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, LogFormatter.toStringWrapper(request));
|
||||
kafkaSender.sendRequestToQueue(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, request);
|
||||
log.debug("successfully processed, new information account id {}, new account id {}",
|
||||
informationAccountId,
|
||||
accountId);
|
||||
|
|
@ -258,9 +277,23 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
@ -271,7 +304,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
*
|
||||
* @return infoCounter++
|
||||
*/
|
||||
protected Long accountNextId() {
|
||||
public synchronized Long accountNextId() {
|
||||
if (infoCounter == null) synchronized (this) {
|
||||
if (infoCounter == null) {
|
||||
log.debug("Init account-information counter.");
|
||||
|
|
@ -283,10 +316,12 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
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);
|
||||
|
|
@ -303,10 +338,12 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
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.getAndIncrement();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,9 +2,6 @@ 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.apache.kafka.common.header.Header;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
|
@ -19,33 +16,32 @@ 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.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.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.AccountType;
|
||||
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.ImdgPredicate;
|
||||
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.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
|
|
@ -55,6 +51,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
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;
|
||||
|
|
@ -66,13 +63,16 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
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,
|
||||
|
|
@ -86,19 +86,20 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
Function<CommonIdRequest, IValidator> tradingClearingRegistryBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.kafkaProducer = kafkaProducer;
|
||||
this.kafkaSender = kafkaSender;
|
||||
this.validationHelper = validationHelper;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.requestHelper = requestHelper;
|
||||
this.tradingClearingRegistryNewRequestValidator = tradingClearingRegistryNewRequestValidator;
|
||||
this.tradingClearingRegistryImdg = imdgProvider.getImdg(
|
||||
IMDGDistributedNames.Map_TradingClearingRegistry, TradingClearingRegistry.class
|
||||
);
|
||||
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;
|
||||
|
|
@ -106,8 +107,8 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
init();
|
||||
callback(TradingClearingRegistryNewRequest.class)
|
||||
imdgProvider.waitAvailable();
|
||||
callback(TradingClearingRegistryNewRequest.class) // todo deprecated - unused.
|
||||
.setFunction(this::tradingClearingRegistryAutoNew)
|
||||
.forDestination(Consts.DESTINATION_TRADING_CLEARING_REGISTRY_AUTO_NEW, callbacks::put);
|
||||
callback(TradingClearingRegistryNewRequest.class)
|
||||
|
|
@ -119,14 +120,16 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
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, tradingClearingRegistryNewRequestValidator);
|
||||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, tradingClearingRegistryAutoNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
TradingClearingRegistryNewRequest req = userRequest.getRequestPayload();
|
||||
|
|
@ -138,85 +141,73 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
|
||||
tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
||||
|
||||
DepoAccount depoAccount = req.getDepoAccountId() != null ? depoAccountImdg.getSingleObjectByID(req.getDepoAccountId()) : null;
|
||||
Account depoAccountMain = depoAccount != null ? accountImdg.getSingleObjectByID(depoAccount.getAccountId()) : null;
|
||||
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 = clearingAccountImdg.getSingleObjectByID(req.getMoneyAccountId());
|
||||
if (clearingAccount == null) infoAccount = informationAccountImdg.getSingleObjectByID(req.getMoneyAccountId());
|
||||
Long accountId = clearingAccount != null ? clearingAccount.getAccountId() : infoAccount.getAccountId();
|
||||
Account accountMain = accountImdg.getSingleObjectByID(accountId);
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
// Проверка выглядит очень сложно и запутанно, потому что репортеры сами не до конца понимают, какая она должна быть.
|
||||
// Пока что она соответствует ТЗ, но возможно будет правиться, поэтому расписана без выноса кода в методы и
|
||||
// прочих методов сокращения кода. В дальнейшем, после тестирования и окончательного выяснения вида проверки,
|
||||
// её стоит вынести на этап валидации запроса.
|
||||
// кроссвалидация
|
||||
if (req.getMoneyAccountId() == null && (req.getMoneyAccountId() == null || req.getDepoAccountId() == null)) {
|
||||
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
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());
|
||||
}
|
||||
}
|
||||
Relation relation = relationImdg.getSingleObjectByFieldValues(Map.of("consumerId", req.getCompanyId()));
|
||||
if (ru.spcex.platform.enumeration.Service.MKR.equalsByKey(relation.getService())) {
|
||||
TradingClearingRegistry registry = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (registry != null) {
|
||||
return requestHelper.makeErrorResponse(userRequest,
|
||||
AccountError.TradingClearingRegistryAlreadyExist,
|
||||
req.getCompanyId(),
|
||||
registry.getId());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
DepoAccount depoAccountForCheck = depoAccountImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (depoAccountForCheck == null)
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.DepoAccountNotFound, req.getCompanyId());
|
||||
} else if (ru.spcex.platform.enumeration.Service.FOND.equalsByKey(relation.getService())) {
|
||||
if (AccountType.Info.equalsByKey(accountMain.getStatus())) {
|
||||
TradingClearingRegistry registry = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of(
|
||||
"companyId", req.getCompanyId(),
|
||||
"tradingClearingRegistryType", TradingClearingRegistryPurpose.M.getKey()
|
||||
));
|
||||
if (registry != null) {
|
||||
return requestHelper.makeErrorResponse(userRequest,
|
||||
AccountError.TradingClearingRegistryAlreadyExist,
|
||||
req.getCompanyId(),
|
||||
registry.getId());
|
||||
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());
|
||||
}
|
||||
DepoAccount depoAccountForCheck = depoAccountImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (depoAccountForCheck == null)
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.DepoAccountNotFound, req.getCompanyId());
|
||||
} else if (AccountType.Clrn.equalsByKey(accountMain.getStatus())) {
|
||||
ImdgPredicateBuilder imdgPredicateBuilder = tradingClearingRegistryImdg.predicateBuilder();
|
||||
ImdgPredicate predicate = imdgPredicateBuilder.and(
|
||||
imdgPredicateBuilder.equals("companyId", req.getCompanyId()),
|
||||
imdgPredicateBuilder.or(
|
||||
imdgPredicateBuilder.equals("tradingClearingRegistryPurpose", TradingClearingRegistryPurpose.M.getKey()),
|
||||
imdgPredicateBuilder.equals("tradingClearingRegistryPurpose", TradingClearingRegistryPurpose.C.getKey())
|
||||
)
|
||||
);
|
||||
Collection<TradingClearingRegistry> registry = tradingClearingRegistryImdg.getCollectionObjectsByPredicate(predicate);
|
||||
if (!registry.isEmpty()) {
|
||||
return requestHelper.makeErrorResponse(userRequest,
|
||||
AccountError.TradingClearingRegistryAlreadyExist,
|
||||
req.getCompanyId(),
|
||||
registry.iterator().next().getId());
|
||||
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);
|
||||
}
|
||||
}
|
||||
DepoAccount depoAccountForCheck = depoAccountImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (depoAccountForCheck == null) {
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.DepoAccountNotFound, req.getCompanyId());
|
||||
}
|
||||
} else if (AccountType.Depo.equalsByKey(accountMain.getStatus())) {
|
||||
InformationAccount infoAccountForCheck = informationAccountImdg.getSingleObjectByFieldValues(
|
||||
Map.of("companyId", req.getCompanyId())
|
||||
);
|
||||
ClearingAccount clearingAccountForCheck = clearingAccountImdg.getSingleObjectByFieldValues(
|
||||
Map.of("companyId", req.getCompanyId())
|
||||
);
|
||||
if (infoAccountForCheck == null && clearingAccountForCheck == null)
|
||||
return requestHelper.makeErrorResponse(userRequest, AccountError.MoneyAccountNotFound, req.getCompanyId());
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,10 +251,9 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
tradingClearingRegistry.setTradingClearingRegistryPurpose(registryPurpose.getKey());
|
||||
|
||||
Company company = companyImdg.getSingleObjectByID(req.getCompanyId());
|
||||
String code = "%4s".formatted(company.getClearingCode()).replace(' ', '0');
|
||||
code += registryPurpose.getKey();
|
||||
if (registryPurpose == TradingClearingRegistryPurpose.C) code += tradingRegistryType + id;
|
||||
else code += "AT" + id;
|
||||
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();
|
||||
|
|
@ -271,6 +261,12 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
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;
|
||||
|
|
@ -291,7 +287,7 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
TradingClearingRegistryNewRequest req = userRequest.getRequestPayload();
|
||||
// Дополнительная проверка
|
||||
if (req.getMoneyAccountId() == null && (req.getMoneyAccountId() == null || req.getDepoAccountId() == null)) {
|
||||
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getFirstObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (registryByCompany == null) {
|
||||
return requestHelper.makeErrorResponse(userRequest,
|
||||
AccountError.TradingClearingRegistryNotFound,
|
||||
|
|
@ -306,13 +302,21 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
tradingClearingRegistry.setMoneyAccountId(req.getMoneyAccountId());
|
||||
tradingClearingRegistry.setDepoAccountId(req.getDepoAccountId());
|
||||
|
||||
DepoAccount depoAccount = req.getDepoAccountId() != null ? depoAccountImdg.getSingleObjectByID(req.getDepoAccountId()) : null;
|
||||
ClearingAccount clearingAccount = clearingAccountImdg.getSingleObjectByID(req.getMoneyAccountId());
|
||||
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;
|
||||
|
||||
tradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
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 (depoAccount != null) {
|
||||
if (req.getTradingClearingRegistryType() != null) {
|
||||
tradingRegistryType = req.getTradingClearingRegistryType();
|
||||
} else if (depoAccount != null) {
|
||||
tradingRegistryType = depoAccount.getDepoAccountType();
|
||||
} else {
|
||||
if (clearingAccount != null) tradingRegistryType = clearingAccount.getClearingAccountType();
|
||||
|
|
@ -326,10 +330,9 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
tradingClearingRegistry.setTradingClearingRegistryPurpose(registryPurpose.getKey());
|
||||
|
||||
Company company = companyImdg.getSingleObjectByID(req.getCompanyId());
|
||||
String code = "%4s".formatted(company.getClearingCode()).replace(' ', '0');
|
||||
code += registryPurpose.getKey();
|
||||
if (registryPurpose == TradingClearingRegistryPurpose.C) code += tradingRegistryType + id;
|
||||
else code += "AT" + id;
|
||||
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();
|
||||
|
|
@ -337,11 +340,70 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
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);
|
||||
|
|
@ -352,22 +414,27 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
|
||||
TradingClearingRegistryUpdateRequest req = userRequest.getRequestPayload();
|
||||
TradingClearingRegistry tradingClearingRegistry = tradingClearingRegistryImdg.getSingleObjectByID(req.getId());
|
||||
// Дополнительная проверка
|
||||
if (req.getMoneyAccountId() == null && (req.getMoneyAccountId() == null || req.getDepoAccountId() == null)) {
|
||||
TradingClearingRegistry registryByCompany = tradingClearingRegistryImdg.getSingleObjectByFieldValues(Map.of("companyId", req.getCompanyId()));
|
||||
if (registryByCompany == null) {
|
||||
return requestHelper.makeErrorResponse(userRequest,
|
||||
AccountError.TradingClearingRegistryNotFound,
|
||||
"companyId=" + req.getCompanyId());
|
||||
}
|
||||
|
||||
// кроссвалидация - нельзя менять эти поля:
|
||||
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) tradingClearingRegistry.setStatus(req.getStatus());
|
||||
|
||||
Instant now = Instant.now();
|
||||
tradingClearingRegistry.setUpdated(now);
|
||||
|
||||
tradingClearingRegistryImdg.update(tradingClearingRegistry);
|
||||
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;
|
||||
|
|
@ -392,4 +459,40 @@ public class TradingClearingRegistryService extends QueueConsumer implements Ini
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.kafka.clients.consumer.MockConsumer;
|
||||
import org.apache.kafka.clients.producer.MockProducer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
|
|
@ -23,40 +21,28 @@ 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.account.utils.MatcherFactory;
|
||||
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.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
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.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
||||
import ru.spcex.clearing.platform.messaging.service.Status;
|
||||
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.adapter.ImdgHazelcast;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
import static ru.spcex.clearing.test.config.ImdgTestConfig.currentID;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
|
|
@ -64,13 +50,15 @@ import static ru.spcex.clearing.test.config.ImdgTestConfig.currentID;
|
|||
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 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;
|
||||
|
|
@ -210,8 +198,16 @@ class AccountServiceTest {
|
|||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account resultUpdating = accountImdg.getSingleObjectByID(accountId);
|
||||
existAccount.setUpdated(resultUpdating.getUpdated());
|
||||
ACCOUNT_MATCHER.assertMatch(resultUpdating, existAccount);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -247,76 +243,4 @@ class AccountServiceTest {
|
|||
accountImdg.delete(resultBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link AccountService#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
|
||||
Long firstID = currentID.getAndIncrement();
|
||||
Long secondID = currentID.getAndIncrement();
|
||||
AccountSdfRequestPart accountSdfRequestPart = new AccountSdfRequestPart();
|
||||
accountSdfRequestPart.setSdfId(firstID);
|
||||
accountSdfRequestPart.setAccount(account);
|
||||
accountSdfRequestPart.setCompanyId(firstID);
|
||||
AccountSdf01Request accountSdf01Request = new AccountSdf01Request();
|
||||
accountSdf01Request.setGroupingSdf01Id(firstID);
|
||||
accountSdf01Request.setAccounts(Collections.singletonList(accountSdfRequestPart));
|
||||
BaseRequest<AccountSdf01Request> baseNewRequest = new BaseRequest<>();
|
||||
baseNewRequest.setRequestPayload(accountSdf01Request);
|
||||
baseNewRequest.setId(firstID);
|
||||
baseNewRequest.setActionType(ActionType.NEW);
|
||||
String jsonBaseNewRequest;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
jsonBaseNewRequest = objectMapper.writeValueAsString(baseNewRequest);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(firstID);
|
||||
responsePart.setErrorCode(null);
|
||||
responsePart.setErrorText(null);
|
||||
List<AccountSdfToStatementRequestPart> accountToStatement = Collections.singletonList(responsePart);
|
||||
StatementRequest statementRequest = new StatementRequest();
|
||||
statementRequest.setGroupId(firstID);
|
||||
statementRequest.setAccountCreationResults(accountToStatement);
|
||||
|
||||
BaseRequest<Object> baseRequest = new BaseRequest<>();
|
||||
baseRequest.setId(secondID);
|
||||
baseRequest.setActionType(ActionType.SYSTEM);
|
||||
baseRequest.setRequestPayload(statementRequest);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(account);
|
||||
predictableAccount.setCompanyId(firstID);
|
||||
|
||||
RequestInfo predictableRequestInfo = new RequestInfo();
|
||||
predictableRequestInfo.setId(secondID);
|
||||
predictableRequestInfo.setStatus(Status.Processing);
|
||||
|
||||
//KAFKA
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, 0, jsonBaseNewRequest);
|
||||
|
||||
//waiting for kafka producer send message (finale event)
|
||||
verify(producer, timeout(30_000L).times(2))
|
||||
.send(producerRecord.capture());
|
||||
//todo переписать валидацию ожидания на новые waitingSendAndCheckRecord / waitingWhenTryAddRecordAndCheckError
|
||||
|
||||
ImdgHazelcast<Account> accountImdg = (ImdgHazelcast<Account>) hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_Account, Account.class);
|
||||
|
||||
//ASSERT
|
||||
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", account));
|
||||
predictableAccount.setId(accountResult.getId());
|
||||
ACCOUNT_MATCHER.assertMatch(accountResult, predictableAccount);
|
||||
accountImdg.delete(accountResult);
|
||||
}
|
||||
}
|
||||
|
|
@ -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,17 +1,13 @@
|
|||
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.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;
|
||||
|
|
@ -25,7 +21,6 @@ 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.account.utils.MatcherFactory.Matcher;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
|
|
@ -34,12 +29,13 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewReq
|
|||
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.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.iml.hazelcast.service.HazelcastService;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
|
|
@ -49,13 +45,14 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
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.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
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 = {
|
||||
AccountService.class,
|
||||
AccountHelper.class,
|
||||
BankAccountService.class,
|
||||
ValidationConfig.class,
|
||||
BankAccountValidationConfig.class,
|
||||
|
|
@ -97,15 +94,11 @@ public class BankAccountServiceTest {
|
|||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Autowired
|
||||
private BankAccountService bankAccountService;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
|
@ -179,8 +172,8 @@ public class BankAccountServiceTest {
|
|||
addRecordToKafka((MockConsumer) bankAccountService.getConsumer(), TOPIC_ACCOUNT_NEW, PARTITION, 0, jsonString);
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
|
||||
Account accountResult = accountImdg.getSingleObjectBySQL(String.format("account = %s", acc));
|
||||
BankAccount bankAccountResult = bankAccountImdg.getSingleObjectBySQL(String.format("account = %s or companyId = %s", acc, addresseeIdNew));
|
||||
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);
|
||||
|
|
@ -216,11 +209,11 @@ public class BankAccountServiceTest {
|
|||
//AccountValidationRule.RequiredFields
|
||||
//WrongFieldValue
|
||||
bankAccountNewRequest.setCurrency(null);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "currency"));
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "null, currency"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCurrency("TT0");
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.WrongFieldValue, "currency"));
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.DictionaryNotFound, "TT0, CurrencyCodeDictionary"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setCurrency(currency);
|
||||
|
|
@ -239,36 +232,20 @@ public class BankAccountServiceTest {
|
|||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setAccount(acc);
|
||||
bankAccountNewRequest.setDestination(null);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "destination"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
bankAccountNewRequest.setDestination(destination);
|
||||
bankAccountNewRequest.setCompanyId(null);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.RequiredFieldEmpty, "companyId"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
bankAccountNewRequest.setCompanyId(addresseeIdNew);
|
||||
|
||||
//AccountValidationRule.CompanyPresent
|
||||
//CompanyNotFound
|
||||
bankAccountNewRequest.setCompanyId(999924535239L);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.CompanyNotFound, "companyId"));
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.CompanyNotFound, bankAccountNewRequest.getCompanyId()+", companyId"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
//CompanyNotActive
|
||||
company.setWorkflowStatus(Status.Blocked.getKey());
|
||||
companyImdg.insert(company);
|
||||
bankAccountNewRequest.setCompanyId(company.getId());
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.CompanyNotActive, "companyId"));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
|
||||
//AccountValidationRule.AccountIsNew
|
||||
//AccountAlreadyExist
|
||||
company.setWorkflowStatus(Status.Active.getKey());
|
||||
companyImdg.insert(company);
|
||||
Account existAccount = getTestAccount(accountId, acc);
|
||||
accountImdg.insert(existAccount);
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.AccountAlreadyExist, "account"));
|
||||
errMsg = messageResolver.resolve(new EnumMessage(AccountError.AccountAlreadyExist, existAccount.getAccount()));
|
||||
checkError(errMsg, bankAccountNewRequest);
|
||||
accountImdg.delete(existAccount);
|
||||
}
|
||||
|
|
@ -291,8 +268,9 @@ public class BankAccountServiceTest {
|
|||
//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(producer, timeout(30_000L).times(currentTime))
|
||||
verify(mockProducer, timeout(30_000L).times(currentTime))
|
||||
.send(producerRecord.capture());
|
||||
BaseRequest<Object> baseRequestResult = (BaseRequest<Object>) producerRecord.getValue().value();
|
||||
|
||||
|
|
@ -368,13 +346,13 @@ public class BankAccountServiceTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@link BankAccountService#bankAccountDelete(BaseRequest)}
|
||||
* {@link BankAccountService#bankAccountBlock(BaseRequest)}
|
||||
* Тест проверяет удаление сущности {@link BankAccount} в Hazelcast при передаче из Apache Kafka.
|
||||
* Входной запрос {@link CommonDeleteRequest}:
|
||||
* {@link CommonDeleteRequest#id} - Идентификатор записи
|
||||
*/
|
||||
@Test
|
||||
void bankAccountDelete() {
|
||||
void bankAccountBlock() {
|
||||
//ARRANGE
|
||||
BankAccount bankAccountExists = getBankAccount();
|
||||
bankAccountImdg.insert(bankAccountExists);
|
||||
|
|
@ -393,8 +371,8 @@ public class BankAccountServiceTest {
|
|||
//ASSERT
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
|
||||
BankAccount bankAccount = bankAccountImdg.getSingleObjectByID(ID);
|
||||
Assertions.assertNull(bankAccount);
|
||||
Account bankAccount = accountImdg.getSingleObjectByID(accountId);
|
||||
assertEquals(bankAccount.getStatus(), WorkflowStatus.Blocked.getKey());
|
||||
}
|
||||
|
||||
private Company getTestCompany() {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
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.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.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;
|
||||
|
|
@ -24,25 +21,31 @@ 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.utils.MatcherFactory;
|
||||
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.iml.hazelcast.service.HazelcastService;
|
||||
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 org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
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 = {
|
||||
|
|
@ -50,8 +53,9 @@ import static ru.spcex.clearing.test.TestUtils.*;
|
|||
ValidationConfig.class,
|
||||
ClearingAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
AccountHelper.class,
|
||||
ClearingAccountService.class,
|
||||
SDFProcessService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
class ClearingAccountServiceTest {
|
||||
|
|
@ -69,16 +73,16 @@ class ClearingAccountServiceTest {
|
|||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
@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;
|
||||
|
|
@ -159,8 +163,7 @@ class ClearingAccountServiceTest {
|
|||
0,
|
||||
jsonString);
|
||||
|
||||
verify(producer, timeout(30_000L).times(2))
|
||||
.send(producerRecord.capture());
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
|
|
@ -173,8 +176,8 @@ class ClearingAccountServiceTest {
|
|||
predictableClearingAccount.setCompanyId(companyId);
|
||||
predictableClearingAccount.setClearingAccountType(CLEARING_ACCOUNT_TYPE_DICT);
|
||||
|
||||
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Clrn.getKey()));
|
||||
ClearingAccount resultClearingAccountNew = clearingAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
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());
|
||||
|
|
@ -224,4 +227,64 @@ class ClearingAccountServiceTest {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
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.Assertions;
|
||||
|
|
@ -9,10 +8,8 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mockito;
|
||||
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;
|
||||
|
|
@ -27,13 +24,13 @@ 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.account.utils.MatcherFactory;
|
||||
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;
|
||||
|
|
@ -211,7 +208,7 @@ class ClientCodeServiceTest {
|
|||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
predictableClientCode.setId(resultNew.getId());
|
||||
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
||||
assertNotNull(resultNew.getCreated());
|
||||
|
|
@ -249,7 +246,7 @@ class ClientCodeServiceTest {
|
|||
|
||||
//ASSERT
|
||||
TestUtils.waitingSendAndCheckRecord(ID, mockProducer, producerRecord);
|
||||
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
predictableClientCode.setId(resultNew.getId());
|
||||
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
||||
assertNotNull(resultNew.getCreated());
|
||||
|
|
@ -289,7 +286,7 @@ class ClientCodeServiceTest {
|
|||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
ClientCode resultNew = clientCodeImdg.getSingleObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
ClientCode resultNew = clientCodeImdg.getFirstObjectBySQL(String.format("code = '%s'", ccCode));
|
||||
predictableClientCode.setId(resultNew.getId());
|
||||
CLIENT_CODE_MATCHER.assertMatch(resultNew, predictableClientCode);
|
||||
assertNotNull(resultNew.getCreated());
|
||||
|
|
@ -379,7 +376,7 @@ class ClientCodeServiceTest {
|
|||
|
||||
waitingSendAndCheckRecord(ID, mockProducer);
|
||||
ClientCode resultUpdate = clientCodeImdg.getSingleObjectByID(ID);
|
||||
Assertions.assertNull(resultUpdate);
|
||||
assertEquals(WorkflowStatus.Blocked.getKey(), resultUpdate.getStatus());
|
||||
}
|
||||
|
||||
// /**
|
||||
|
|
|
|||
|
|
@ -1,16 +1,11 @@
|
|||
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;
|
||||
|
|
@ -24,25 +19,22 @@ 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.account.utils.MatcherFactory;
|
||||
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.iml.hazelcast.service.HazelcastService;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.addRecordToKafka;
|
||||
import static ru.spcex.clearing.test.TestUtils.getJsonStringForNew;
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
|
|
@ -50,7 +42,7 @@ import static ru.spcex.clearing.test.TestUtils.getJsonStringForNew;
|
|||
ValidationConfig.class,
|
||||
DepoAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
AccountHelper.class,
|
||||
DepoAccountService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
|
|
@ -69,12 +61,8 @@ class DepoAccountServiceTest {
|
|||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
|
@ -159,8 +147,7 @@ class DepoAccountServiceTest {
|
|||
0,
|
||||
jsonString);
|
||||
|
||||
verify(producer, timeout(30_000L).times(2))
|
||||
.send(producerRecord.capture());
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(ACCOUNT_VALUE);
|
||||
|
|
@ -173,8 +160,8 @@ class DepoAccountServiceTest {
|
|||
predictableDepoAccount.setCompanyId(companyId);
|
||||
predictableDepoAccount.setDepoAccountType(DEPO_ACCOUNT_TYPE_DICT);
|
||||
|
||||
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Depo.getKey()));
|
||||
DepoAccount resultDepoAccountNew = depoAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
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());
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
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.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mockito;
|
||||
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;
|
||||
|
|
@ -24,26 +20,23 @@ 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.account.utils.MatcherFactory;
|
||||
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 ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.addRecordToKafka;
|
||||
import static ru.spcex.clearing.test.TestUtils.getJsonStringForNew;
|
||||
import static ru.spcex.clearing.test.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
import static ru.spcex.clearing.test.TestUtils.*;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {
|
||||
|
|
@ -51,7 +44,7 @@ import static ru.spcex.clearing.test.TestUtils.getJsonStringForNew;
|
|||
ValidationConfig.class,
|
||||
InformationAccountValidationConfig.class,
|
||||
AccountValidationConfig.class,
|
||||
AccountService.class,
|
||||
AccountHelper.class,
|
||||
InformationAccountService.class,
|
||||
ImdgTestConfig.class,
|
||||
KafkaTestConfig.class})
|
||||
|
|
@ -69,12 +62,8 @@ class InformationAccountServiceTest {
|
|||
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
@Autowired
|
||||
@Qualifier("mockProducer")
|
||||
protected Producer<String, Object> mockProducer;
|
||||
|
|
@ -96,6 +85,7 @@ class InformationAccountServiceTest {
|
|||
accountImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Account, Account.class
|
||||
);
|
||||
clearImdg(accountImdg);
|
||||
|
||||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
|
|
@ -143,6 +133,7 @@ class InformationAccountServiceTest {
|
|||
void accountInformationNew() {
|
||||
InformationAccountNewRequest InformationAccountNewRequest = new InformationAccountNewRequest();
|
||||
InformationAccountNewRequest.setCompanyId(companyId);
|
||||
InformationAccountNewRequest.setAccount(account);
|
||||
|
||||
String jsonString = getJsonStringForNew(InformationAccountNewRequest, 0L);
|
||||
|
||||
|
|
@ -152,9 +143,7 @@ class InformationAccountServiceTest {
|
|||
0,
|
||||
jsonString);
|
||||
|
||||
//waiting for kafka producer send message (finale event)
|
||||
verify(producer, timeout(30_000L).times(2))
|
||||
.send(producerRecord.capture());
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccountType(AccountType.Info.getKey());
|
||||
|
|
@ -166,11 +155,11 @@ class InformationAccountServiceTest {
|
|||
predictableInfoAccount.setCompanyId(companyId);
|
||||
predictableInfoAccount.setClearingAccountId(anltAccountId);
|
||||
|
||||
Account resultAccountNew = accountImdg.getSingleObjectByFieldValues(Map.of("accountType", AccountType.Info.getKey()));
|
||||
InformationAccount resultInfoAccountNew = informationAccountImdg.getSingleObjectByFieldValues(Map.of("accountId", resultAccountNew.getId()));
|
||||
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(informationAccountService.generateInfoAccount(resultInfoAccountNew.getId()));
|
||||
predictableAccount.setAccount(account);
|
||||
predictableInfoAccount.setAccountId(resultAccountNew.getId());
|
||||
predictableInfoAccount.setId(resultInfoAccountNew.getId());
|
||||
|
||||
|
|
@ -181,7 +170,6 @@ class InformationAccountServiceTest {
|
|||
accountImdg.delete(resultAccountNew);
|
||||
}
|
||||
|
||||
@Autowired ImdgProvider imdgProvider;
|
||||
@Test
|
||||
void accountIncrementSequence() {
|
||||
Imdg<InformationAccount> accountInfoImdg = hazelcastServiceTest.getImdg( IMDGDistributedNames.Map_InformationAccount, InformationAccount.class );
|
||||
|
|
@ -199,11 +187,12 @@ class InformationAccountServiceTest {
|
|||
accountInfo.setCompanyId(account.getCompanyId());
|
||||
accountInfoImdg.insert(accountInfo);
|
||||
}
|
||||
UserRoleVerification userRoleVerification = Mockito.mock(UserRoleVerification.class);
|
||||
InformationAccountService infoAccSvc=new InformationAccountService(null,null,null,
|
||||
null, imdgProvider, null, null, null, null);
|
||||
null, userRoleVerification, hazelcastServiceTest, null, null, null, null);
|
||||
Long n = infoAccSvc.accountNextId();
|
||||
Assertions.assertEquals(12L, n);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,13 @@
|
|||
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.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.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;
|
||||
|
|
@ -18,31 +15,30 @@ 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.account.utils.MatcherFactory;
|
||||
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.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.TradingClearingRegistryPurpose;
|
||||
import ru.spcex.platform.enumeration.TradingClearingRegistryType;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import static ru.spcex.clearing.account.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
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 = {
|
||||
|
|
@ -63,18 +59,19 @@ class TradingClearingRegistryServiceTest {
|
|||
TradingClearingRegistryService tradingClearingRegistryService;
|
||||
@Autowired
|
||||
@Qualifier("hazelcastServiceTest")
|
||||
private HazelcastService hazelcastServiceTest;
|
||||
private ImdgProvider hazelcastServiceTest;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<ProducerRecord> producerRecord;
|
||||
@SpyBean
|
||||
private MockProducer<String, Object> producer;
|
||||
@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;
|
||||
|
|
@ -102,6 +99,9 @@ class TradingClearingRegistryServiceTest {
|
|||
companyImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_Company, Company.class
|
||||
);
|
||||
companySymbolsImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_CompanySymbols, CompanySymbols.class
|
||||
);
|
||||
serviceStatusDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||
IMDGDistributedNames.Map_ServiceStatusDictionary, ServiceStatusDictionary.class
|
||||
);
|
||||
|
|
@ -128,8 +128,14 @@ class TradingClearingRegistryServiceTest {
|
|||
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);
|
||||
|
|
@ -153,15 +159,17 @@ class TradingClearingRegistryServiceTest {
|
|||
|
||||
@Test
|
||||
void tradingClearingRegistryNew_moneyAccount_clearingAccount() {
|
||||
setMockFuture(kafkaTemplate);
|
||||
TradingClearingRegistryNewRequest tradingClearingRegistryNewRequest = new TradingClearingRegistryNewRequest();
|
||||
tradingClearingRegistryNewRequest.setCompanyId(companyId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(clearingAccountId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(accountId);
|
||||
tradingClearingRegistryNewRequest.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
|
||||
TradingClearingRegistry predictableTradingClearingRegistry = new TradingClearingRegistry();
|
||||
predictableTradingClearingRegistry.setCompanyId(companyId);
|
||||
predictableTradingClearingRegistry.setCode("0077MAT");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(clearingAccountId);
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryType("CAT");
|
||||
predictableTradingClearingRegistry.setCode("0077MAT00001");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(accountId);
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryPurpose(TradingClearingRegistryPurpose.M.getKey());
|
||||
predictableTradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
|
||||
|
|
@ -177,7 +185,6 @@ class TradingClearingRegistryServiceTest {
|
|||
|
||||
TradingClearingRegistry resultNew = tradingClearingRegistryImdg.getAllValues().iterator().next();
|
||||
predictableTradingClearingRegistry.setId(resultNew.getId());
|
||||
predictableTradingClearingRegistry.setCode(predictableTradingClearingRegistry.getCode() + resultNew.getId());
|
||||
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
||||
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
||||
|
||||
|
|
@ -189,14 +196,17 @@ class TradingClearingRegistryServiceTest {
|
|||
|
||||
@Test
|
||||
void tradingClearingRegistryNew_moneyAccount_informationAccount() {
|
||||
setMockFuture(kafkaTemplate);
|
||||
clearImdg(tradingClearingRegistryImdg);
|
||||
TradingClearingRegistryNewRequest tradingClearingRegistryNewRequest = new TradingClearingRegistryNewRequest();
|
||||
tradingClearingRegistryNewRequest.setCompanyId(companyId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(infoAccountId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(account2Id);
|
||||
tradingClearingRegistryNewRequest.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
|
||||
TradingClearingRegistry predictableTradingClearingRegistry = new TradingClearingRegistry();
|
||||
predictableTradingClearingRegistry.setCompanyId(companyId);
|
||||
predictableTradingClearingRegistry.setCode("0077MAT");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(infoAccountId);
|
||||
predictableTradingClearingRegistry.setCode("0077MAT00001");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(account2Id);
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryType(TradingClearingRegistryType.Owner_A.getKey());
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryPurpose(TradingClearingRegistryPurpose.M.getKey());
|
||||
predictableTradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
|
|
@ -209,11 +219,10 @@ class TradingClearingRegistryServiceTest {
|
|||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, producer, producerRecord);
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultNew = tradingClearingRegistryImdg.getAllValues().iterator().next();
|
||||
predictableTradingClearingRegistry.setId(resultNew.getId());
|
||||
predictableTradingClearingRegistry.setCode(predictableTradingClearingRegistry.getCode() + resultNew.getId());
|
||||
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
||||
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
||||
|
||||
|
|
@ -226,16 +235,18 @@ class TradingClearingRegistryServiceTest {
|
|||
|
||||
@Test
|
||||
void tradingClearingRegistryNew_depoAccount() {
|
||||
setMockFuture(kafkaTemplate);
|
||||
clearImdg(tradingClearingRegistryImdg);
|
||||
TradingClearingRegistryNewRequest tradingClearingRegistryNewRequest = new TradingClearingRegistryNewRequest();
|
||||
tradingClearingRegistryNewRequest.setCompanyId(companyId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(clearingAccountId);
|
||||
tradingClearingRegistryNewRequest.setDepoAccountId(depoAccountId);
|
||||
tradingClearingRegistryNewRequest.setMoneyAccountId(accountId);
|
||||
tradingClearingRegistryNewRequest.setDepoAccountId(account2Id);
|
||||
|
||||
TradingClearingRegistry predictableTradingClearingRegistry = new TradingClearingRegistry();
|
||||
predictableTradingClearingRegistry.setCompanyId(companyId);
|
||||
predictableTradingClearingRegistry.setCode("0077CDAT");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(clearingAccountId);
|
||||
predictableTradingClearingRegistry.setDepoAccountId(depoAccountId);
|
||||
predictableTradingClearingRegistry.setCode("0077CDATT00001");
|
||||
predictableTradingClearingRegistry.setMoneyAccountId(accountId);
|
||||
predictableTradingClearingRegistry.setDepoAccountId(account2Id);
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryType("DAT");
|
||||
predictableTradingClearingRegistry.setTradingClearingRegistryPurpose(TradingClearingRegistryPurpose.C.getKey());
|
||||
predictableTradingClearingRegistry.setStatus(ServiceStatus.Active.getKey());
|
||||
|
|
@ -248,14 +259,12 @@ class TradingClearingRegistryServiceTest {
|
|||
0,
|
||||
jsonString);
|
||||
|
||||
waitingSendAndCheckRecord(0L, producer, producerRecord);
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultNew = tradingClearingRegistryImdg.getAllValues().iterator().next();
|
||||
predictableTradingClearingRegistry.setId(resultNew.getId());
|
||||
predictableTradingClearingRegistry.setCode(predictableTradingClearingRegistry.getCode() + resultNew.getId());
|
||||
predictableTradingClearingRegistry.setUpdated(resultNew.getUpdated());
|
||||
predictableTradingClearingRegistry.setCreated(resultNew.getCreated());
|
||||
predictableTradingClearingRegistry.setCompanyId(123L);
|
||||
|
||||
TRADING_CLEARING_REGISTRY_MATCHER.assertMatch(resultNew, predictableTradingClearingRegistry);
|
||||
tradingClearingRegistryImdg.delete(resultNew);
|
||||
|
|
@ -283,7 +292,7 @@ class TradingClearingRegistryServiceTest {
|
|||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(0L, producer, producerRecord);
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultUpdating = tradingClearingRegistryImdg.getSingleObjectByID(registryId);
|
||||
existTradingClearingRegistry.setUpdated(resultUpdating.getUpdated());
|
||||
|
|
@ -311,7 +320,7 @@ class TradingClearingRegistryServiceTest {
|
|||
jsonString);
|
||||
|
||||
//ASSERT
|
||||
waitingSendAndCheckRecord(0L, producer, producerRecord);
|
||||
waitingSendAndCheckRecord(0L, mockProducer);
|
||||
|
||||
TradingClearingRegistry resultUpdating = tradingClearingRegistryImdg.getSingleObjectByID(registryId);
|
||||
existTradingClearingRegistry.setUpdated(resultUpdating.getUpdated());
|
||||
|
|
@ -319,4 +328,30 @@ class TradingClearingRegistryServiceTest {
|
|||
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,63 +0,0 @@
|
|||
package ru.spcex.clearing.account.utils;
|
||||
|
||||
import com.hazelcast.core.IMap;
|
||||
import com.hazelcast.map.listener.EntryAddedListener;
|
||||
import com.hazelcast.map.listener.EntryRemovedListener;
|
||||
import com.hazelcast.map.listener.EntryUpdatedListener;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class ImapEvent<T> {
|
||||
private final IMap<Long, T> iMap;
|
||||
private final String listenerAdding;
|
||||
private final String listenerUpdating;
|
||||
private final String listenerRemoving;
|
||||
private final AtomicBoolean checkEventHappened = new AtomicBoolean(false);
|
||||
|
||||
public ImapEvent(IMap<Long, T> iMap) {
|
||||
this.iMap = iMap;
|
||||
listenerAdding = iMap.addEntryListener((EntryAddedListener<Long, T>) entryEvent -> {
|
||||
synchronized (checkEventHappened) {
|
||||
checkEventHappened.set(true);
|
||||
checkEventHappened.notify();
|
||||
}
|
||||
}, false);
|
||||
listenerUpdating = iMap.addEntryListener((EntryUpdatedListener<Long, T>) entryEvent -> {
|
||||
synchronized (checkEventHappened) {
|
||||
checkEventHappened.set(true);
|
||||
checkEventHappened.notify();
|
||||
}
|
||||
}, false);
|
||||
listenerRemoving = iMap.addEntryListener((EntryRemovedListener<Long, T>) entryEvent -> {
|
||||
synchronized (checkEventHappened) {
|
||||
checkEventHappened.set(true);
|
||||
checkEventHappened.notify();
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
public void waitWhenHappened() throws InterruptedException {
|
||||
//running timer task as daemon thread
|
||||
Timer timer = new Timer(true);
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
boolean secondRan;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkEventHappened.set(secondRan);//если что-то пойдет не так не тормозить основной поток
|
||||
secondRan = true;
|
||||
}
|
||||
}, 0, 30 * 1000);
|
||||
synchronized (checkEventHappened) {
|
||||
while (!checkEventHappened.get()) {
|
||||
checkEventHappened.wait(100);
|
||||
}
|
||||
}
|
||||
//preparing hazelcastImdgProvider for next test
|
||||
iMap.removeEntryListener(listenerAdding);
|
||||
iMap.removeEntryListener(listenerUpdating);
|
||||
iMap.removeEntryListener(listenerRemoving);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package ru.spcex.clearing.account.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Factory for creating test matchers.
|
||||
* <p>
|
||||
* Comparing actual and expected objects via AssertJ
|
||||
*/
|
||||
public class MatcherFactory {
|
||||
|
||||
public static <T> Matcher<T> usingIgnoringFieldsComparator(String... fieldsToIgnore) {
|
||||
return new Matcher<>(fieldsToIgnore);
|
||||
}
|
||||
|
||||
public static class Matcher<T> {
|
||||
private final String[] fieldsToIgnore;
|
||||
|
||||
private Matcher(String... fieldsToIgnore) {
|
||||
this.fieldsToIgnore = fieldsToIgnore;
|
||||
}
|
||||
|
||||
public void assertMatch(T actual, T expected) {
|
||||
assertThat(actual).usingRecursiveComparison().ignoringFields(fieldsToIgnore).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public final void assertMatch(Iterable<T> actual, T... expected) {
|
||||
assertMatch(actual, Arrays.asList(expected));
|
||||
}
|
||||
|
||||
public void assertMatch(Iterable<T> actual, Iterable<T> expected) {
|
||||
assertThat(actual).usingRecursiveFieldByFieldElementComparatorIgnoringFields(fieldsToIgnore).isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -195,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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +1,26 @@
|
|||
package ru.spcex.clearing.backendapi.config;
|
||||
|
||||
import org.apache.kafka.clients.admin.AdminClient;
|
||||
import org.apache.kafka.clients.admin.AdminClientConfig;
|
||||
import org.apache.kafka.clients.admin.NewTopic;
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
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.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.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
|
||||
|
|
@ -40,8 +31,6 @@ public class KafkaConfig {
|
|||
return KafkaProducerFactory.producer(settings.getKafkaProducer());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public ProducerFactory<String, Object> pf(BackendApiSettings settings) {
|
||||
KafkaProducerSettings kafkaSettings = settings.getKafkaProducer();
|
||||
|
|
@ -73,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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,28 +1,40 @@
|
|||
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 {
|
||||
public class InformationAccountController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public InformationAccountController(IStateLoader stateLoader) {
|
||||
public InformationAccountController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
|
|
@ -37,4 +49,15 @@ public class InformationAccountController {
|
|||
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);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
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.*;
|
||||
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;
|
||||
import ru.spcex.clearing.backendapi.service.IStateLoader;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/verification-results")
|
||||
public class VerificationResultController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public VerificationResultController(IOperator operator, IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
||||
@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_VerificationResult, VerificationResult.class);
|
||||
CommonGetAllResponse response = new CommonGetAllResponse();
|
||||
response.fromEntity(all);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,17 @@ import java.util.Map;
|
|||
@RequestMapping("/execution-fonds")
|
||||
public class ExecutionFondController extends AbstractQueueController {
|
||||
private final IStateLoader stateLoader;
|
||||
private final ImdgPredicateBuilder imdgPredicateBuilder;
|
||||
|
||||
@Autowired
|
||||
public ExecutionFondController(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 ExecutionFond.")
|
||||
|
|
@ -34,9 +44,11 @@ public class ExecutionFondController extends AbstractQueueController {
|
|||
@RequestMapping(method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonGetAllResponse getAll() {
|
||||
ImdgPredicate imdgPredicate = imdgPredicateBuilder.greatEqual("settlementDate", LocalDate.now());
|
||||
Collection<Map<String, Object>> all = stateLoader.getAllMetaTransform(
|
||||
IMDGDistributedNames.Map_ExecutionFond,
|
||||
ExecutionFond.class);
|
||||
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,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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,10 @@ 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.registry.Registry;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.registry.RSplitDepositActionNew;
|
||||
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;
|
||||
|
|
@ -57,4 +54,57 @@ public class RegistryController extends AbstractQueueController {
|
|||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -29,6 +31,7 @@ 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.util.Collection;
|
||||
|
|
@ -38,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;
|
||||
|
|
@ -69,14 +73,14 @@ public class LauncherController extends AbstractQueueController {
|
|||
@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));
|
||||
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);
|
||||
}
|
||||
|
|
@ -96,16 +100,16 @@ public class LauncherController extends AbstractQueueController {
|
|||
if (launcherNew.getTask() == null) {
|
||||
throw new NotFound404Exception("task dictionary element with code '" + launcherNew.getTask() + "'");
|
||||
}
|
||||
AbstractDictionary taskEnum = taskDictionary.getSingleObjectByFieldValues(Map.of("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 (!Task.startOfClearing.getKey().equals(taskEnum.getCode())) {
|
||||
throw new IllegalStateException(String.format("Task %s not support request with body", taskEnum.getCode()));
|
||||
}
|
||||
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.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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.InformationAccountNewRequest;
|
||||
|
||||
public class AccountInformationNewAction implements IAction<InformationAccountNewRequest> {
|
||||
|
||||
@ApiModelProperty(value = "Наименование компании", example = "1200")
|
||||
@JsonProperty
|
||||
private Long companyId;
|
||||
@ApiModelProperty(value = "Номер счета", example = "A30101111111111111776")
|
||||
@JsonProperty
|
||||
private String account;
|
||||
@ApiModelProperty(value = "Наименование статуса", example = "ACTV")
|
||||
@JsonProperty
|
||||
private String status;
|
||||
@ApiModelProperty(value = "Наименование типа счета", example = "INFO")
|
||||
@JsonProperty
|
||||
private String accountType;
|
||||
|
||||
@Override
|
||||
public InformationAccountNewRequest toRequest() {
|
||||
var req = new InformationAccountNewRequest();
|
||||
req.setCompanyId(this.companyId);
|
||||
req.setAccount(this.account);
|
||||
req.setStatus(this.status);
|
||||
req.setAccountType(this.accountType);
|
||||
return req;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.NEW;
|
||||
}
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(String accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountSymbolsNewRequest;
|
||||
|
||||
public class AccountSymbolsNewAction implements IAction<AccountSymbolsNewRequest> {
|
||||
|
||||
@ApiModelProperty(value = "Номер счета", example = "1200")
|
||||
@JsonProperty
|
||||
private Long accountId;
|
||||
@ApiModelProperty(value = "Значение реквизита", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String accountSymbolValue;
|
||||
|
||||
@Override
|
||||
public AccountSymbolsNewRequest toRequest() {
|
||||
var req = new AccountSymbolsNewRequest();
|
||||
req.setAccountId(this.accountId);
|
||||
req.setAccountSymbolValue(this.accountSymbolValue);
|
||||
return req;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.NEW;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(Long accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getAccountSymbolValue() {
|
||||
return accountSymbolValue;
|
||||
}
|
||||
|
||||
public void setAccountSymbolValue(String accountSymbolValue) {
|
||||
this.accountSymbolValue = accountSymbolValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.company;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.CompanyRoleSetNewRequest;
|
||||
|
||||
public class CompanyRoleSetNewAction implements IAction<CompanyRoleSetNewRequest> {
|
||||
@ApiModelProperty(value = "Наименование компании", example = "1234")
|
||||
@JsonProperty
|
||||
Long companyId;
|
||||
@ApiModelProperty(value = "Код роли компании", example = "ABCD")
|
||||
@JsonProperty
|
||||
String companyRole;
|
||||
@ApiModelProperty(value = "Код статуса", example = "ACTV")
|
||||
@JsonProperty
|
||||
String workflowStatus;
|
||||
|
||||
@Override
|
||||
public CompanyRoleSetNewRequest toRequest() {
|
||||
CompanyRoleSetNewRequest request = new CompanyRoleSetNewRequest();
|
||||
request.setCompanyId(this.companyId);
|
||||
request.setCompanyRole(this.companyRole);
|
||||
request.setWorkflowStatus(this.workflowStatus);
|
||||
return request;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.NEW;
|
||||
}
|
||||
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
public String getCompanyRole() {
|
||||
return companyRole;
|
||||
}
|
||||
|
||||
public void setCompanyRole(String companyRole) {
|
||||
this.companyRole = companyRole;
|
||||
}
|
||||
|
||||
public String getWorkflowStatus() {
|
||||
return workflowStatus;
|
||||
}
|
||||
|
||||
public void setWorkflowStatus(String workflowStatus) {
|
||||
this.workflowStatus = workflowStatus;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.history;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalDateSerializer;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class HistoryRequest {
|
||||
|
||||
@ApiModelProperty(value = "Таблица для поиска", example = "1200")
|
||||
@JsonProperty
|
||||
private String table;
|
||||
@ApiModelProperty(value = "Начальный точка поиска по дате", example = "2022-12-25")
|
||||
@JsonProperty
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
private LocalDate from;
|
||||
@ApiModelProperty(value = "Конечная точка поиска по дате ", example = "2022-12-25")
|
||||
@JsonProperty
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
private LocalDate to;
|
||||
|
||||
public String getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public void setTable(String table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public LocalDate getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(LocalDate from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public LocalDate getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(LocalDate to) {
|
||||
this.to = to;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.registry;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.RegistryChangeRefundDateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalDateSerializer;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ChangeRefundDateActionNew implements IAction<RegistryChangeRefundDateRequest> {
|
||||
|
||||
@JsonIgnore
|
||||
public Long groupId;
|
||||
@JsonProperty
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
public LocalDate refundDate;
|
||||
|
||||
@Override
|
||||
public RegistryChangeRefundDateRequest toRequest() {
|
||||
var req = new RegistryChangeRefundDateRequest();
|
||||
req.setGroupId(groupId);
|
||||
req.setRefundDate(refundDate);
|
||||
return req;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumMessage> validate() {
|
||||
List<EnumMessage> errors = new ArrayList<>();
|
||||
if (groupId == null) {
|
||||
errors.add(new EnumMessage(BackEndError.ValidationError, "url parameter 'groupId'"));
|
||||
}
|
||||
if (refundDate == null) {
|
||||
errors.add(new EnumMessage(BackEndError.ValidationError, "refundDate"));
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.UPDATE;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public LocalDate getRefundDate() {
|
||||
return refundDate;
|
||||
}
|
||||
|
||||
public void setRefundDate(LocalDate refundDate) {
|
||||
this.refundDate = refundDate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.registry;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.RegistryChangeStatusExtractRequest;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ChangeStatusExtractActionNew implements IAction<RegistryChangeStatusExtractRequest> {
|
||||
|
||||
@JsonIgnore
|
||||
public Long id;
|
||||
@JsonProperty
|
||||
public String shortName;
|
||||
@JsonProperty
|
||||
public String contract;
|
||||
@JsonProperty
|
||||
public BigDecimal balance;
|
||||
@JsonProperty
|
||||
public String registryStatus;
|
||||
|
||||
@Override
|
||||
public RegistryChangeStatusExtractRequest toRequest() {
|
||||
var req = new RegistryChangeStatusExtractRequest();
|
||||
req.setId(id);
|
||||
req.setShortName(shortName);
|
||||
req.setContract(contract);
|
||||
req.setBalance(balance);
|
||||
req.setRegistryStatus(registryStatus);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.UPDATE;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
public String getContract() {
|
||||
return contract;
|
||||
}
|
||||
|
||||
public void setContract(String contract) {
|
||||
this.contract = contract;
|
||||
}
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public String getRegistryStatus() {
|
||||
return registryStatus;
|
||||
}
|
||||
|
||||
public void setRegistryStatus(String registryStatus) {
|
||||
this.registryStatus = registryStatus;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.registry;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.IdentificationFundsRequest;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithId;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class IdentificationFundsActionNew implements IAction<IdentificationFundsRequest>, WithId {
|
||||
|
||||
@JsonIgnore
|
||||
public Long id;
|
||||
@ApiModelProperty(value = "Сумма", example = "1600.20")
|
||||
@JsonProperty
|
||||
public BigDecimal balance;
|
||||
@ApiModelProperty(value = "Торгово-клиринговый регистр", example = "1234")
|
||||
@JsonProperty
|
||||
public Long tradingClearingRegistryId;
|
||||
@ApiModelProperty(value = "Идентификатор компании", example = "1234")
|
||||
@JsonProperty
|
||||
public Long companyId;
|
||||
|
||||
@Override
|
||||
public IdentificationFundsRequest toRequest() {
|
||||
var req = new IdentificationFundsRequest();
|
||||
req.setId(id);
|
||||
req.setBalance(balance);
|
||||
req.setTradingClearingRegistryId(tradingClearingRegistryId);
|
||||
req.setCompanyId(companyId);
|
||||
return req;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumMessage> validate() {
|
||||
List<EnumMessage> errors = new ArrayList<>();
|
||||
if (id == null) {
|
||||
errors.add(new EnumMessage(BackEndError.ValidationError, "url parameter 'id'"));
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.NEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public Long getTradingClearingRegistryId() {
|
||||
return tradingClearingRegistryId;
|
||||
}
|
||||
|
||||
public void setTradingClearingRegistryId(Long tradingClearingRegistryId) {
|
||||
this.tradingClearingRegistryId = tradingClearingRegistryId;
|
||||
}
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.registry;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.NotificationUpdateRequest;
|
||||
|
||||
public class NotificationUpdateAction implements IAction<NotificationUpdateRequest> {
|
||||
@ApiModelProperty(value = "Идентификатор записи", example = "123")
|
||||
@JsonProperty
|
||||
public Long id;
|
||||
@ApiModelProperty(value = "Наименование статуса сообщения", example = "ACTV")
|
||||
@JsonProperty
|
||||
public String notificationStatus;
|
||||
@ApiModelProperty(value = "Наименование отправителя (не исопльзуется)", example = "1234")
|
||||
@JsonProperty(required = false)
|
||||
@Deprecated
|
||||
public Long senderId;
|
||||
|
||||
@Override
|
||||
public NotificationUpdateRequest toRequest() {
|
||||
var req = new NotificationUpdateRequest();
|
||||
req.setId(this.id);
|
||||
req.setNotificationStatus(this.notificationStatus);
|
||||
return req;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.UPDATE;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNotificationStatus() {
|
||||
return notificationStatus;
|
||||
}
|
||||
|
||||
public void setNotificationStatus(String notificationStatus) {
|
||||
this.notificationStatus = notificationStatus;
|
||||
}
|
||||
|
||||
public Long getSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
public void setSenderId(Long senderId) {
|
||||
this.senderId = senderId;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,9 @@ public class RSplitDepositActionNew implements IAction<RegistrySplitDepositActio
|
|||
@ApiModelProperty(value = "Договор для разделения", example = "ABCD")
|
||||
@JsonProperty
|
||||
public String contract;
|
||||
@ApiModelProperty(value = "Направление", example = "OUT")
|
||||
@JsonProperty
|
||||
public String direction;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -45,6 +48,7 @@ public class RSplitDepositActionNew implements IAction<RegistrySplitDepositActio
|
|||
req.setOutboundAmount(this.outboundAmount);
|
||||
req.setRefundDate(this.refundDate);
|
||||
req.setContract(this.contract);
|
||||
req.setDirection(this.direction);
|
||||
return req;
|
||||
}
|
||||
|
||||
|
|
@ -85,4 +89,12 @@ public class RSplitDepositActionNew implements IAction<RegistrySplitDepositActio
|
|||
public void setContract(String contract) {
|
||||
this.contract = contract;
|
||||
}
|
||||
|
||||
public String getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(String direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.registry;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.RegistryReturnDepositRequest;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithId;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ReturnDepositActionNew implements IAction<RegistryReturnDepositRequest>, WithId {
|
||||
|
||||
@JsonIgnore
|
||||
public Long id;
|
||||
@ApiModelProperty(value = "Сумма", example = "1600.20")
|
||||
@JsonProperty
|
||||
public BigDecimal balance;
|
||||
|
||||
@Override
|
||||
public RegistryReturnDepositRequest toRequest() {
|
||||
var req = new RegistryReturnDepositRequest();
|
||||
req.setId(id);
|
||||
req.setBalance(balance);
|
||||
return req;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EnumMessage> validate() {
|
||||
List<EnumMessage> errors = new ArrayList<>();
|
||||
if (id == null) {
|
||||
errors.add(new EnumMessage(BackEndError.ValidationError, "url parameter 'id'"));
|
||||
}
|
||||
if (balance == null) {
|
||||
errors.add(new EnumMessage(BackEndError.ValidationError, "balance"));
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.NEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
|||
import ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -35,6 +36,34 @@ public class LauncherNew implements IAction<Object> {
|
|||
@JsonProperty
|
||||
private Long sessionId;
|
||||
|
||||
@ApiModelProperty(value = "Текущий баланс (свободно)", example = "12.22")
|
||||
@JsonProperty
|
||||
private BigDecimal balance;
|
||||
@ApiModelProperty(value = "Текущий баланс (всего)", example = "12.22")
|
||||
@JsonProperty
|
||||
private BigDecimal fullBalance;
|
||||
@ApiModelProperty(value = "Наименование инструмента/валюты", example = "SPB")
|
||||
@JsonProperty
|
||||
private String securitySymbol;
|
||||
@ApiModelProperty(value = "Сумма отправителя", example = "12.22")
|
||||
@JsonProperty
|
||||
private BigDecimal creditLeg_amount;
|
||||
@ApiModelProperty(value = "Назначение платежа", example = "text")
|
||||
@JsonProperty
|
||||
private String paymentPurpose;
|
||||
@ApiModelProperty(value = "Участник отправитель", example = "1000")
|
||||
@JsonProperty
|
||||
private Long senderId;
|
||||
@ApiModelProperty(value = "Наименование счета отправителя", example = "1000")
|
||||
@JsonProperty
|
||||
private Long creditLeg_accountId;
|
||||
@ApiModelProperty(value = "Участник получатель", example = "1000")
|
||||
@JsonProperty
|
||||
private Long addresseeId;
|
||||
@ApiModelProperty(value = "Наименование счета получателя", example = "1000")
|
||||
@JsonProperty
|
||||
private Long debitLeg_accountId;
|
||||
|
||||
@Override
|
||||
public Object toRequest() {
|
||||
LauncherCommandRequest taskRunnerCommandRequest = new LauncherCommandRequest();
|
||||
|
|
@ -45,6 +74,15 @@ public class LauncherNew implements IAction<Object> {
|
|||
taskRunnerCommandRequest.setSection(section);
|
||||
taskRunnerCommandRequest.setSessionType(sessionType);
|
||||
taskRunnerCommandRequest.setSessionId(sessionId);
|
||||
taskRunnerCommandRequest.setBalance(balance);
|
||||
taskRunnerCommandRequest.setFullBalance(fullBalance);
|
||||
taskRunnerCommandRequest.setSecuritySymbol(securitySymbol);
|
||||
taskRunnerCommandRequest.setCreditLeg_amount(creditLeg_amount);
|
||||
taskRunnerCommandRequest.setPaymentPurpose(paymentPurpose);
|
||||
taskRunnerCommandRequest.setSenderId(senderId);
|
||||
taskRunnerCommandRequest.setCreditLeg_accountId(creditLeg_accountId);
|
||||
taskRunnerCommandRequest.setAddresseeId(addresseeId);
|
||||
taskRunnerCommandRequest.setDebitLeg_accountId(debitLeg_accountId);
|
||||
return taskRunnerCommandRequest;
|
||||
}
|
||||
|
||||
|
|
@ -117,4 +155,76 @@ public class LauncherNew implements IAction<Object> {
|
|||
public void setSessionId(Long sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public String getSecuritySymbol() {
|
||||
return securitySymbol;
|
||||
}
|
||||
|
||||
public void setSecuritySymbol(String securitySymbol) {
|
||||
this.securitySymbol = securitySymbol;
|
||||
}
|
||||
|
||||
public BigDecimal getCreditLeg_amount() {
|
||||
return creditLeg_amount;
|
||||
}
|
||||
|
||||
public void setCreditLeg_amount(BigDecimal creditLeg_amount) {
|
||||
this.creditLeg_amount = creditLeg_amount;
|
||||
}
|
||||
|
||||
public String getPaymentPurpose() {
|
||||
return paymentPurpose;
|
||||
}
|
||||
|
||||
public void setPaymentPurpose(String paymentPurpose) {
|
||||
this.paymentPurpose = paymentPurpose;
|
||||
}
|
||||
|
||||
public Long getSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
public void setSenderId(Long senderId) {
|
||||
this.senderId = senderId;
|
||||
}
|
||||
|
||||
public Long getCreditLeg_accountId() {
|
||||
return creditLeg_accountId;
|
||||
}
|
||||
|
||||
public void setCreditLeg_accountId(Long creditLeg_accountId) {
|
||||
this.creditLeg_accountId = creditLeg_accountId;
|
||||
}
|
||||
|
||||
public Long getAddresseeId() {
|
||||
return addresseeId;
|
||||
}
|
||||
|
||||
public void setAddresseeId(Long addresseeId) {
|
||||
this.addresseeId = addresseeId;
|
||||
}
|
||||
|
||||
public Long getDebitLeg_accountId() {
|
||||
return debitLeg_accountId;
|
||||
}
|
||||
|
||||
public void setDebitLeg_accountId(Long debitLeg_accountId) {
|
||||
this.debitLeg_accountId = debitLeg_accountId;
|
||||
}
|
||||
|
||||
public BigDecimal getFullBalance() {
|
||||
return fullBalance;
|
||||
}
|
||||
|
||||
public void setFullBalance(BigDecimal fullBalance) {
|
||||
this.fullBalance = fullBalance;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,10 @@ public class FixedIncomeSecurityNewAction implements IAction<FixedIncomeSecurity
|
|||
@ApiModelProperty(value = "Размер лота", example = "300.5")
|
||||
@JsonProperty
|
||||
public BigDecimal lotSize;
|
||||
@ApiModelProperty(value = "Номинал", example = "200.5")
|
||||
@ApiModelProperty(value = "Текущее значение номинала", example = "200.4")
|
||||
@JsonProperty
|
||||
public BigDecimal nominalForDate;
|
||||
@ApiModelProperty(value = "Номинал инструмента", example = "200.5")
|
||||
@JsonProperty
|
||||
public BigDecimal nominalValue;
|
||||
@ApiModelProperty(value = "Наименование валюты номинала", example = "RUB")
|
||||
|
|
@ -83,6 +86,7 @@ public class FixedIncomeSecurityNewAction implements IAction<FixedIncomeSecurity
|
|||
req.setIsin(this.getIsin());
|
||||
req.setBondType(this.getBondType());
|
||||
req.setLotSize(this.getLotSize());
|
||||
req.setNominalForDate(this.getNominalForDate());
|
||||
req.setNominalValue(this.getNominalValue());
|
||||
req.setNominalCurrency(this.getNominalCurrency());
|
||||
req.setMaturityDate(this.getMaturityDate());
|
||||
|
|
@ -151,6 +155,14 @@ public class FixedIncomeSecurityNewAction implements IAction<FixedIncomeSecurity
|
|||
this.lotSize = lotSize;
|
||||
}
|
||||
|
||||
public BigDecimal getNominalForDate() {
|
||||
return nominalForDate;
|
||||
}
|
||||
|
||||
public void setNominalForDate(BigDecimal nominalForDate) {
|
||||
this.nominalForDate = nominalForDate;
|
||||
}
|
||||
|
||||
public BigDecimal getNominalValue() {
|
||||
return nominalValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ public class FixedIncomeSecurityUpdateAction implements IAction<FixedIncomeSecur
|
|||
@ApiModelProperty(value = "Размер лота", example = "300.5")
|
||||
@JsonProperty
|
||||
public BigDecimal lotSize;
|
||||
@ApiModelProperty(value = "Номинал", example = "200.5")
|
||||
@ApiModelProperty(value = "Текущее значение номинала", example = "200.4")
|
||||
@JsonProperty
|
||||
public BigDecimal nominalForDate;
|
||||
@ApiModelProperty(value = "Номинал инструмента", example = "200.5")
|
||||
@JsonProperty
|
||||
public BigDecimal nominalValue;
|
||||
@ApiModelProperty(value = "Наименование валюты номинала", example = "RUB")
|
||||
|
|
@ -85,6 +88,7 @@ public class FixedIncomeSecurityUpdateAction implements IAction<FixedIncomeSecur
|
|||
req.setIsin(this.getIsin());
|
||||
req.setBondType(this.getBondType());
|
||||
req.setLotSize(this.getLotSize());
|
||||
req.setNominalForDate(this.getNominalForDate());
|
||||
req.setNominalValue(this.getNominalValue());
|
||||
req.setNominalCurrency(this.getNominalCurrency());
|
||||
req.setMaturityDate(this.getMaturityDate());
|
||||
|
|
@ -161,6 +165,14 @@ public class FixedIncomeSecurityUpdateAction implements IAction<FixedIncomeSecur
|
|||
this.lotSize = lotSize;
|
||||
}
|
||||
|
||||
public BigDecimal getNominalForDate() {
|
||||
return nominalForDate;
|
||||
}
|
||||
|
||||
public void setNominalForDate(BigDecimal nominalForDate) {
|
||||
this.nominalForDate = nominalForDate;
|
||||
}
|
||||
|
||||
public BigDecimal getNominalValue() {
|
||||
return nominalValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class DictionaryController {
|
|||
@ApiParam(value = "Код словаря", required = true, example = "1234")
|
||||
@PathVariable("code") String code) {
|
||||
Imdg<AbstractDictionary> dictionary = extractDictionaryImdgFromUrlParameter(dictionaryName, AbstractDictionary.class);
|
||||
AbstractDictionary value = dictionary.getSingleObjectByFieldValues(Map.of("code", code));
|
||||
AbstractDictionary value = dictionary.getFirstObjectByFieldValues(Map.of("code", code));
|
||||
if (value == null) throw new NotFound404Exception(dictionaryName + " code='" + code + "'");
|
||||
DictionaryBackendGetSingleValueV2 response = new DictionaryBackendGetSingleValueV2();
|
||||
response.setPayload(responseFactory.responseFromDictionary(dictionaryName, value));
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
package ru.spcex.clearing.backendapi.controller.test;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRawValue;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.registry.TradingClearingRegistryNewRequest;
|
||||
|
||||
public class AnyKafkaMessageAction implements IAction<TradingClearingRegistryNewRequest> {
|
||||
@ApiModelProperty(value = "полное имя класса payload для BaseRequest", example = "ru.spcex.clearing.platform.messaging.domain.cud.schedule.LauncherCommandRequest")
|
||||
@JsonProperty
|
||||
private String fullClassName;
|
||||
@JsonProperty
|
||||
private String topicName;
|
||||
@JsonRawValue
|
||||
public String json;
|
||||
|
||||
@JsonProperty("json")
|
||||
private void unpackRawJson(JsonNode json) {
|
||||
this.json = json.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradingClearingRegistryNewRequest toRequest() {
|
||||
var req = new TradingClearingRegistryNewRequest();
|
||||
return req;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.SYSTEM;
|
||||
}
|
||||
|
||||
public String getFullClassName() {
|
||||
return fullClassName;
|
||||
}
|
||||
|
||||
public void setFullClassName(String fullClassName) {
|
||||
this.fullClassName = fullClassName;
|
||||
}
|
||||
|
||||
public String getTopicName() {
|
||||
return topicName;
|
||||
}
|
||||
|
||||
public void setTopicName(String topicName) {
|
||||
this.topicName = topicName;
|
||||
}
|
||||
|
||||
public String getJson() {
|
||||
return json;
|
||||
}
|
||||
|
||||
public void setJson(String json) {
|
||||
this.json = json;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
package ru.spcex.clearing.backendapi.controller.test;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.ClassUtils;
|
||||
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.spcex.clearing.backendapi.errors.BackEndError;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.error.ValidationException;
|
||||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/anonymous/kafka-api")
|
||||
public class KafkaApiController {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final KafkaSender kafkaSender;
|
||||
private static final ObjectMapper json = new ObjectMapper();
|
||||
static {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public KafkaApiController(KafkaSender kafkaSender) {
|
||||
this.kafkaSender = kafkaSender;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Test backend-api availability.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = String.class)})
|
||||
@RequestMapping(method = RequestMethod.POST, path = "/any/message", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
@ResponseBody
|
||||
public String processGet(@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody AnyKafkaMessageAction bankAccountNewAction) throws ClassNotFoundException, ValidationException, JsonProcessingException {
|
||||
log.info("Call test method for backend-api controller");
|
||||
validate(bankAccountNewAction);
|
||||
Class<?> parameterType = ClassUtils.forName(bankAccountNewAction.getFullClassName(), ClassUtils.getDefaultClassLoader());
|
||||
JavaType requestType = json.getTypeFactory().constructSimpleType(parameterType, null);
|
||||
Object obj = json.readValue(bankAccountNewAction.getJson(), requestType);
|
||||
Long idOfBaseRequestMessage = kafkaSender.sendRequestToQueue(bankAccountNewAction.getTopicName(), obj);
|
||||
return "success: baseRequest.id = " + idOfBaseRequestMessage;
|
||||
}
|
||||
|
||||
private void validate(AnyKafkaMessageAction bankAccountNewAction) throws ValidationException {
|
||||
if (TextUtil.isEmpty(bankAccountNewAction.getTopicName())) {
|
||||
throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "topicName"));
|
||||
}
|
||||
if (TextUtil.isEmpty(bankAccountNewAction.getFullClassName())) {
|
||||
throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "fullClassName"));
|
||||
}
|
||||
if (TextUtil.isEmpty(bankAccountNewAction.getJson())) {
|
||||
throw new ValidationException(new EnumMessage(BackEndError.ValidationError, "json"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -130,6 +131,19 @@ public class GetResponseFactory {
|
|||
response.put(name, data);
|
||||
}
|
||||
|
||||
public Optional<Class<? extends SpcexObjectBase>> classByDestination(String destination) {
|
||||
Map<String, ObjectExtracted> extracted = meta.getObjectsExtractedByDestination();
|
||||
ObjectExtracted objectExtracted = extracted.get(destination);
|
||||
if (objectExtracted == null) return Optional.empty();
|
||||
try {
|
||||
Class<? extends SpcexObjectBase> clazz = (Class<? extends SpcexObjectBase>) objectExtracted.getClazz();
|
||||
return Optional.ofNullable(clazz);
|
||||
} catch (Exception e) {
|
||||
log.error(ExceptionUtils.getStackTrace(e));
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter
|
||||
.ofPattern("yyyy-MM-dd'T'HH:mm:ss+03:00")
|
||||
.withLocale(Locale.US)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package ru.spcex.clearing.backendapi.meta;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -67,6 +68,8 @@ public class MetaServer extends MetaBase {
|
|||
objectsExtractedByClazz.put(String.valueOf(classNameMock++), oe);
|
||||
if (objectElement.getSubscription() != null && objectElement.getSubscription().destination != null) {
|
||||
objectsExtractedByDestination.put(objectElement.getSubscription().destination, oe);
|
||||
} else if (!TextUtil.isEmpty(objectElement.getDestination())) {
|
||||
objectsExtractedByDestination.put(objectElement.getDestination(), oe);
|
||||
}
|
||||
for (ActionElement actionElement : objectElement.getActions()) {
|
||||
if (actionElement.getClazz() == null) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ public class ObjectElement {
|
|||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private String table = null;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private String destination = null;
|
||||
|
||||
@JsonProperty(value = "fields", required = true)
|
||||
private List<ActionField> fields = new LinkedList<>();
|
||||
|
||||
|
|
@ -76,4 +80,12 @@ public class ObjectElement {
|
|||
public Subscription getSubscriptionHistory() {
|
||||
return subscriptionHistory;
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public void setDestination(String destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,23 @@ package ru.spcex.clearing.backendapi.security;
|
|||
import org.keycloak.KeycloakPrincipal;
|
||||
import org.keycloak.adapters.spi.KeycloakAccount;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
public class KeycloakUtils {
|
||||
static Logger log = LoggerFactory.getLogger(KeycloakUtils.class);
|
||||
|
||||
/**
|
||||
* Достать username из Keycloak имплементации Authentication
|
||||
*/
|
||||
public static String getUserNameFromAuthentication(Authentication authentication) {
|
||||
if (authentication == null) return null;
|
||||
if (!(authentication instanceof KeycloakAuthenticationToken)) { // AnonymousAuthenticationToken
|
||||
log.trace("Authentication token class {} is not KeycloakAuthenticationToken", authentication.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
KeycloakAuthenticationToken auth = (KeycloakAuthenticationToken) authentication;
|
||||
if (auth == null) return null;
|
||||
KeycloakAccount details = (KeycloakAccount) auth.getDetails();
|
||||
return ((KeycloakPrincipal) details.getPrincipal())
|
||||
.getKeycloakSecurityContext()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package ru.spcex.clearing.backendapi.service;
|
||||
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
|
@ -15,4 +16,10 @@ public interface IStateLoader {
|
|||
<T extends SpcexObjectBase> Collection<Map<String, Object>> getAllMetaTransform(String mapName, Class<T> clazz);
|
||||
<T extends SpcexObjectBase> Collection<Map<String, Object>> getAllMetaTransformSpecificClass(String mapName, Class<T> clazz);
|
||||
<T extends SpcexObjectBase> Collection<Map<String, Object>> getAllMetaTransform(String mapName, Class<T> clazz, Map<String, ? extends Comparable<?>> conditions);
|
||||
<T extends SpcexObjectBase> Collection<Map<String, Object>> getAllMetaTransform(String mapName, Class<T> clazz, ImdgPredicate conditions);
|
||||
<T extends SpcexObjectBase> Collection<Map<String, Object>> getAllMetaTransform(
|
||||
String searchMapName,
|
||||
String mapName,
|
||||
Class<T> clazz,
|
||||
ImdgPredicate conditions);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
|||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
/**
|
||||
* Сервис для сигнализирования результатов запросов клиентов. Ассинхронное обновление статуса.
|
||||
* Клиент запрашивает периодически (или по событию) таблицу Map_RequestInfo и видит результат выполнения запросов.
|
||||
*/
|
||||
@Service
|
||||
public class RequestInfoAccepter extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
|
@ -37,9 +41,15 @@ public class RequestInfoAccepter extends QueueConsumer implements InitializingBe
|
|||
private void updateRequestInfo(BaseRequest<RequestInfoUpdate> requestInfoUpdateBaseRequest) {
|
||||
//will throw exception for any class other than RequestInfoUpdate
|
||||
RequestInfoUpdate statusInfo = requestInfoUpdateBaseRequest.getRequestPayload();
|
||||
if (statusInfo == null || statusInfo.getId() == null) {
|
||||
log.warn("BaseRequest id={}, RequestPayload={}: requestInfo id was null",
|
||||
requestInfoUpdateBaseRequest.getId(), statusInfo);
|
||||
return;
|
||||
}
|
||||
RequestInfo requestInfo = requestInfoImdg.getSingleObjectByID(statusInfo.getId());
|
||||
if (requestInfo == null) {
|
||||
log.warn("unknown requestInfo id={}", statusInfo.getId());
|
||||
log.warn("unknown requestInfo id={}; statusInfo: {}",
|
||||
statusInfo.getId(), statusInfo);
|
||||
return;
|
||||
}
|
||||
requestInfo.setStatus(statusInfo.getStatus());
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class OperatorImpl implements IOperator {
|
|||
protected Long currentUserId() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = KeycloakUtils.getUserNameFromAuthentication(authentication);
|
||||
User user = StringUtils.isEmpty(username) ? null : userImdg.getSingleObjectByFieldValues(Map.of("identifier", username));
|
||||
User user = StringUtils.isEmpty(username) ? null : userImdg.getFirstObjectByFieldValues(Map.of("identifier", username));
|
||||
if (user == null) {
|
||||
log.warn("UserID not found by login \"{}\"", username);
|
||||
return null;
|
||||
|
|
@ -82,6 +82,7 @@ public class OperatorImpl implements IOperator {
|
|||
saveRequestToStorage(destination, request);
|
||||
Future<RecordMetadata> send = kafka.send(new ProducerRecord<>(destination, request));
|
||||
send.get();
|
||||
log.debug("Request id={} by user {} send to queue \"{}\". Action: {}", request.getId(), request.getUserId(), destination, iAction);
|
||||
return new QueueSuccessResponse(request.getActionType(), request.getId());
|
||||
}
|
||||
|
||||
|
|
@ -101,13 +102,15 @@ public class OperatorImpl implements IOperator {
|
|||
saveRequestToStorage(destination, request);
|
||||
Future<RecordMetadata> send = kafka.send(new ProducerRecord<>(destination, request));
|
||||
send.get();
|
||||
log.debug("Request id={} by user {} send to queue \"{}\". Action: {}", request.getId(), userId, destination, iAction);
|
||||
return new QueueSuccessResponse(request.getActionType(), request.getId());
|
||||
}
|
||||
|
||||
private void saveRequestToStorage(String destination, BaseRequest<Object> request) {
|
||||
Imdg<RequestInfo> requestStorage = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
RequestInfo requestInfo = RequestInfo.create(request.getId());
|
||||
requestStorage.insert(requestInfo);
|
||||
Long storeId = requestStorage.insert(requestInfo);
|
||||
log.trace("Request id={} saved as RequestInfo with id={}", request.getId(), storeId);
|
||||
}
|
||||
|
||||
private void throwValidate(String destination, IAction<?> iAction) {
|
||||
|
|
|
|||
|
|
@ -1,28 +1,33 @@
|
|||
package ru.spcex.clearing.backendapi.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
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.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Service
|
||||
public class StateLoaderImpl implements IStateLoader {
|
||||
private final Map<String, Imdg<?>> allImdgMaps;
|
||||
private final Map<String, Imdg<?>> allHistMaps;
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final ImdgProvider imdgHistProvider;
|
||||
private final GetResponseFactory responseFactory;
|
||||
|
||||
@Autowired
|
||||
public StateLoaderImpl(ImdgProvider imdgProvider, GetResponseFactory responseFactory) {
|
||||
public StateLoaderImpl(@Qualifier("imdgProvider") ImdgProvider imdgProvider,
|
||||
@Qualifier("imdgProviderHist") ImdgProvider imdgHistProvider, GetResponseFactory responseFactory) {
|
||||
this.imdgHistProvider = imdgHistProvider;
|
||||
this.responseFactory = responseFactory;
|
||||
this.allImdgMaps = new ConcurrentHashMap<>();
|
||||
this.allHistMaps = new HashMap<>();
|
||||
this.imdgProvider = imdgProvider;
|
||||
}
|
||||
|
||||
|
|
@ -59,8 +64,38 @@ public class StateLoaderImpl implements IStateLoader {
|
|||
return responseFactory.responseFromObjectCollection(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends SpcexObjectBase> Collection<Map<String, Object>> getAllMetaTransform(String mapName,
|
||||
Class<T> clazz,
|
||||
ImdgPredicate conditions) {
|
||||
Imdg<T> imdg = getImdg(mapName, clazz);
|
||||
Collection<T> all = imdg.getCollectionObjectsByPredicate(conditions);
|
||||
return responseFactory.responseFromObjectCollection(all);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends SpcexObjectBase> Imdg<T> getImdg(String mapName, Class<T> clazz) {
|
||||
return (Imdg<T>) allImdgMaps.computeIfAbsent(mapName, (mapName1) -> imdgProvider.getImdg(mapName, clazz));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends SpcexObjectBase> Imdg<T> getHistImdg(String mapName, Class<T> clazz) {
|
||||
return (Imdg<T>) allHistMaps.computeIfAbsent(mapName, (mapName1) -> imdgHistProvider.getImdg(mapName, clazz));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends SpcexObjectBase> Collection<Map<String, Object>> getAllMetaTransform(
|
||||
String searchMapName,
|
||||
String mapName,
|
||||
Class<T> clazz,
|
||||
ImdgPredicate conditions) {
|
||||
Imdg<SpcexObjectBase> imdgSearch = getHistImdg(searchMapName, SpcexObjectBase.class);
|
||||
Imdg<T> imdgHistory = getHistImdg(mapName, clazz);
|
||||
Collection<Long> ids = imdgSearch.getCollectionIdsByPredicate(conditions);
|
||||
return ids.stream()
|
||||
.map(imdgHistory::getSingleObjectByID)
|
||||
.filter(Objects::nonNull)
|
||||
.map(o -> responseFactory.responseFromObject(o, clazz))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,8 +87,14 @@ public class ActionMetaValidation implements InitializingBean {
|
|||
Object value = field.extractValue(object);
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
log.warn("Error self-test validator on class {} and field {}: {}",
|
||||
metaAction.getClazz(), field.getMemberName(), ExceptionUtils.getStackTrace(e));
|
||||
String className = metaAction.getClazz().getName();
|
||||
if (className.endsWith(".MoneyMarketSecurityUpdateAction") || className.endsWith(".ChangeRefundDateActionNew")) {
|
||||
log.warn("Expected warning self-test validator on class {} and field {}: {}",
|
||||
className, field.getMemberName(), e.toString());
|
||||
} else {
|
||||
log.warn("Error self-test validator on class {} and field {}: {}",
|
||||
className, field.getMemberName(), ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,8 @@ public class ActionValidationProvider implements InitializingBean {
|
|||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
validators.put(Consts.DESTINATION_MONEY_MARKET_SECURITY_UPDATE, idPresent(IMDGDistributedNames.Map_MoneyMarketSecurity));
|
||||
validators.put(Consts.DESTINATION_MONEY_MARKET_SECURITY_DELETE, idPresent(IMDGDistributedNames.Map_MoneyMarketSecurity));
|
||||
validators.put(Consts.DESTINATION_RELATION_UPDATE, idPresent(IMDGDistributedNames.Map_Relation));
|
||||
validators.put(Consts.LAUNCHER_NEW, taskRunnerNew());
|
||||
validators.put(Consts.REGISTRY_RETURN_DEPOSIT_ACTION, idPresent(IMDGDistributedNames.Map_Registry));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public enum LauncherNewValidationRule implements IValidationRule<ImdgValidationC
|
|||
public Optional<EnumMessage> validate(ImdgValidationContext<LauncherNew> context) {
|
||||
LauncherNew validatedObject = context.getValidatedObject();
|
||||
Imdg<AbstractDictionary> taskDictionaryImdg = context.obtainMap(IMDGDistributedNames.Map_TaskDictionary, AbstractDictionary.class);
|
||||
AbstractDictionary taskEnum = taskDictionaryImdg.getSingleObjectByFieldValues(Map.of("code", validatedObject.getTask()));
|
||||
AbstractDictionary taskEnum = taskDictionaryImdg.getFirstObjectByFieldValues(Map.of("code", validatedObject.getTask()));
|
||||
if (taskEnum == null) {
|
||||
return of(BackEndError.ResourceNotFound, "taskDictionary " + validatedObject.getTask());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ backend-api.example-setting=test
|
|||
backend-api.hazelcast.cluster-members=127.0.0.1:5701
|
||||
backend-api.hazelcast.login=dev
|
||||
backend-api.hazelcast.password=dev-pass
|
||||
backend-api.hazelcast-search.cluster-members=127.0.0.1:5702
|
||||
backend-api.hazelcast-search.login=dev-hist
|
||||
backend-api.hazelcast-search.password=dev-pass-hist
|
||||
backend-api.kafka-producer.bootstrap-servers=localhost:9092
|
||||
backend-api.kafka-producer.acks=all
|
||||
backend-api.kafka-producer.retries=0
|
||||
|
|
@ -23,6 +26,10 @@ backend-api.kafka-consumer.auto-offset-reset=latest
|
|||
backend-api.kafka-consumer.linger-ms=1
|
||||
backend-api.kafka-consumer.buffer-memory=33554432
|
||||
backend-api.security.authorization-disabled=false
|
||||
#access logs, sample
|
||||
#server.tomcat.accesslog.directory=logs
|
||||
#server.tomcat.accesslog.enabled=true
|
||||
#server.tomcat.accesslog.pattern=%h %l %u %t \"%r\" %>s %b
|
||||
##keycloak
|
||||
##keycloak.auth-server-url=http://10.200.200.147:8080/
|
||||
##keycloak.realm=master
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<meta version="3.9.0.68">
|
||||
<enums>
|
||||
|
||||
</enums>
|
||||
<objects>
|
||||
<company id="1" fullName="АО Санкт-Петербургская Валютная Биржа" shortName="СПВБ" tradingCode="" clearingCode="" workflowStatus="ACTV"/>
|
||||
<company id="2" fullName="ЗАО «Петербургский Расчетный Центр»" shortName="ПРЦ" tradingCode="" clearingCode="" workflowStatus="ACTV"/>
|
||||
<company id="3" fullName="Торговая организация" shortName="ТС" tradingCode="" clearingCode="" workflowStatus="ACTV"/>
|
||||
<company id="4" fullName="ЗАО «Санкт-Петербургский Расчетно-Депозитарный Центр»" shortName="РДЦ" tradingCode="" clearingCode="" workflowStatus="ACTV"/>
|
||||
<!--company id="5" fullName="Центральный Банк Российской Федерации" shortName="ЦБ РФ" tradingCode="" clearingCode="" workflowStatus="ACTV"/-->
|
||||
<companySymbols id="1" companyId="1" companySymbol="BIC" companySymbolValue="044030920"/>
|
||||
<companySymbols id="2" companyId="2" companySymbol="BIC" companySymbolValue="044030505"/>
|
||||
<currency id="643" currency_code="RUB"/>
|
||||
<security id="643" instrumentType="CRNC" shortName="RUB" fullName="Российский рубль" securitySymbol="RUB" workflowStatus="ACTV"/>
|
||||
<account id="1" companyId="1" account="30414810300000006000" accountType="TRAN" status="ACTV" processingSign="ALWD"/>
|
||||
<account id="2" companyId="1" account="30414810600000007000" accountType="ANLT" status="ACTV" processingSign="ALWD"/>
|
||||
<account id="3" companyId="1" account="700100000AT0" accountType="DTRN" status="ACTV" processingSign="ALWD"/>
|
||||
<market id="1" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UESC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Обыкновенные акции"/>
|
||||
<market id="2" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NESC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Обыкновенные акции"/>
|
||||
<market id="3" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DESC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Обыкновенные акции"/>
|
||||
<market id="4" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="AESC" name="Размещение: акции (аукцион по цене)" exchangeId="1" description="Размещение: акции (аукцион по цене): Обыкновенные акции"/>
|
||||
<market id="5" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="WESC" name="Размещение: адресные заявки (подписка)" exchangeId="1" description="Размещение: адресные заявки (подписка): Обыкновенные акции"/>
|
||||
<market id="6" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UEPC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Привилегированные акции"/>
|
||||
<market id="7" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NEPC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Привилегированные акции"/>
|
||||
<market id="8" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DEPC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Привилегированные акции"/>
|
||||
<market id="9" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="AEPC" name="Размещение: акции (аукцион по цене)" exchangeId="1" description="Размещение: акции (аукцион по цене): Привилегированные акции"/>
|
||||
<market id="10" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="WEPC" name="Размещение: адресные заявки (подписка)" exchangeId="1" description="Размещение: адресные заявки (подписка): Привилегированные акции"/>
|
||||
<market id="11" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="ABVC" name="Размещение: Аукцион по цене" exchangeId="1" description="Размещение: Аукцион по цене: Купонные облигации с переменным купоном"/>
|
||||
<market id="12" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="KBVC" name="Размещение: Аукцион по ставке" exchangeId="1" description="Размещение: Аукцион по ставке: Купонные облигации с переменным купоном"/>
|
||||
<market id="13" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UBVC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Купонные облигации с переменным купоном"/>
|
||||
<market id="14" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NBVC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Купонные облигации с переменным купоном"/>
|
||||
<market id="15" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DBVC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Купонные облигации с переменным купоном"/>
|
||||
<market id="16" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="WBVC" name="Размещение: адресные заявки (подписка)" exchangeId="1" description="Размещение: адресные заявки (подписка): Купонные облигации с переменным купоном"/>
|
||||
<market id="17" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="ABFC" name="Размещение: Аукцион по цене" exchangeId="1" description="Размещение: Аукцион по цене: Купонные облигации с постоянным купоном"/>
|
||||
<market id="18" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="KBFC" name="Размещение: Аукцион по ставке" exchangeId="1" description="Размещение: Аукцион по ставке: Купонные облигации с постоянным купоном"/>
|
||||
<market id="19" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UBFC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Купонные облигации с постоянным купоном"/>
|
||||
<market id="20" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NBFC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Купонные облигации с постоянным купоном"/>
|
||||
<market id="21" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DBFC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Купонные облигации с постоянным купоном"/>
|
||||
<market id="22" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="WBFC" name="Размещение: адресные заявки (подписка)" exchangeId="1" description="Размещение: адресные заявки (подписка): Купонные облигации с постоянным купоном"/>
|
||||
<market id="23" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="ABIC" name="Размещение: Аукцион по цене" exchangeId="1" description="Размещение: Аукцион по цене: Облигации с индексированным номиналом"/>
|
||||
<market id="24" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="KBIC" name="Размещение: Аукцион по ставке" exchangeId="1" description="Размещение: Аукцион по ставке: Облигации с индексированным номиналом"/>
|
||||
<market id="25" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UBIC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Облигации с индексированным номиналом"/>
|
||||
<market id="26" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NBIC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Облигации с индексированным номиналом"/>
|
||||
<market id="27" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DBIC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Облигации с индексированным номиналом"/>
|
||||
<market id="28" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="WBIC" name="Размещение: адресные заявки (подписка)" exchangeId="1" description="Размещение: адресные заявки (подписка): Облигации с индексированным номиналом"/>
|
||||
<market id="29" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="ABMC" name="Размещение: Аукцион по цене" exchangeId="1" description="Размещение: Аукцион по цене: Облигации с амортизацией долга"/>
|
||||
<market id="30" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="KBMC" name="Размещение: Аукцион по ставке" exchangeId="1" description="Размещение: Аукцион по ставке: Облигации с амортизацией долга"/>
|
||||
<market id="31" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UBMC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Облигации с амортизацией долга"/>
|
||||
<market id="32" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NBMC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Облигации с амортизацией долга"/>
|
||||
<market id="33" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DBMC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Облигации с амортизацией долга"/>
|
||||
<market id="34" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="WBMC" name="Размещение: адресные заявки (подписка)" exchangeId="1" description="Размещение: адресные заявки (подписка): Облигации с амортизацией долга"/>
|
||||
<market id="35" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="BKVC" name="Размещение: Аукцион БР" exchangeId="1" description="Размещение: Аукцион БР: Облигации Банка России с переменным купоном (КОБР)"/>
|
||||
<market id="36" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="SKVC" name="Доразмещение: Адресные заявки БР" exchangeId="1" description="Доразмещение: Адресные заявки БР: Облигации Банка России с переменным купоном (КОБР)"/>
|
||||
<market id="37" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UKVC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Облигации Банка России с переменным купоном (КОБР)"/>
|
||||
<market id="38" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NKVC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Облигации Банка России с переменным купоном (КОБР)"/>
|
||||
<market id="39" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DKVC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Облигации Банка России с переменным купоном (КОБР)"/>
|
||||
<market id="45" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="ABEC" name="Размещение: Аукцион СПВБ" exchangeId="1" description="Размещение: Аукцион СПВБ: Биржевые облигации"/>
|
||||
<market id="46" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UBEC" name="Режим непрерывных торгов" exchangeId="1" description="Режим непрерывных торгов: Биржевые облигации"/>
|
||||
<market id="47" marketType="SCND" section="FOND" settlementCurrency="RUB" code="NBEC" name="Режим переговорных сделок (РПС)" exchangeId="1" description="Режим переговорных сделок (РПС): Биржевые облигации"/>
|
||||
<market id="48" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DBEC" name="Дискретный аукцион" exchangeId="1" description="Дискретный аукцион: Биржевые облигации"/>
|
||||
<market id="61" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="BMVC" name="ОФЗПК-Размещение: Аукцион БР" exchangeId="1" description="ОФЗПК-Размещение: Аукцион БР: Облигации Минфина"/>
|
||||
<market id="62" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="SMVC" name="ОФЗПК-Доразмещение: Адресные заявки БР" exchangeId="1" description="ОФЗПК-Доразмещение: Адресные заявки БР: Облигации Минфина"/>
|
||||
<market id="63" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UMVC" name="ОФЗПК-Режим непрерывных торгов" exchangeId="1" description="ОФЗПК-Режим непрерывных торгов: Облигации Минфина"/>
|
||||
<market id="64" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DMVC" name="ОФЗПК-Дискретный аукцион" exchangeId="1" description="ОФЗПК-Дискретный аукцион: Облигации Минфина"/>
|
||||
<market id="65" marketType="SCND" section="FOND" settlementCurrency="RUB" code="MMVC" name="ОФЗПК-Торги в режиме выкупа" exchangeId="1" description="ОФЗПК-Торги в режиме выкупа: Облигации Минфина"/>
|
||||
<market id="66" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="BMFC" name="ОФЗПД-Размещение: Аукцион БР" exchangeId="1" description="ОФЗПД-Размещение: Аукцион БР: Облигации Минфина"/>
|
||||
<market id="67" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="SMFC" name="ОФЗПД- Доразмещение: Адресные заявки БР" exchangeId="1" description="ОФЗПД- Доразмещение: Адресные заявки БР: Облигации Минфина"/>
|
||||
<market id="68" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UMFC" name="ОФЗПД-Режим непрерывных торгов" exchangeId="1" description="ОФЗПД-Режим непрерывных торгов: Облигации Минфина"/>
|
||||
<market id="69" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DMFC" name="ОФЗПД-Дискретный аукцион" exchangeId="1" description="ОФЗПД-Дискретный аукцион: Облигации Минфина"/>
|
||||
<market id="70" marketType="SCND" section="FOND" settlementCurrency="RUB" code="MMFC" name="ОФЗПД-Торги в режиме выкупа" exchangeId="1" description="ОФЗПД-Торги в режиме выкупа: Облигации Минфина"/>
|
||||
<market id="71" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="BMMC" name="ОФЗАД-Размещение: Аукцион БР" exchangeId="1" description="ОФЗАД-Размещение: Аукцион БР: Облигации Минфина"/>
|
||||
<market id="72" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="SMMC" name="ОФЗАД-Доразмещение: Адресные заявки БР" exchangeId="1" description="ОФЗАД-Доразмещение: Адресные заявки БР: Облигации Минфина"/>
|
||||
<market id="73" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UMMC" name="ОФЗАД-Режим непрерывных торгов" exchangeId="1" description="ОФЗАД-Режим непрерывных торгов: Облигации Минфина"/>
|
||||
<market id="74" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DMMC" name="ОФЗАД-Дискретный аукцион" exchangeId="1" description="ОФЗАД-Дискретный аукцион: Облигации Минфина"/>
|
||||
<market id="75" marketType="SCND" section="FOND" settlementCurrency="RUB" code="MMMC" name="ОФЗАД-Торги в режиме выкупа" exchangeId="1" description="ОФЗАД-Торги в режиме выкупа: Облигации Минфина"/>
|
||||
<market id="76" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="BMIC" name="ОФЗИН-Размещение: Аукцион БР" exchangeId="1" description="ОФЗИН-Размещение: Аукцион БР: Облигации Минфина"/>
|
||||
<market id="77" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="SMIC" name="ОФЗИН-Доразмещение: Адресные заявки БР" exchangeId="1" description="ОФЗИН-Доразмещение: Адресные заявки БР: Облигации Минфина"/>
|
||||
<market id="78" marketType="SCND" section="FOND" settlementCurrency="RUB" code="UMIC" name="ОФЗИН-Режим непрерывных торгов" exchangeId="1" description="ОФЗИН-Режим непрерывных торгов: Облигации Минфина"/>
|
||||
<market id="79" marketType="SCND" section="FOND" settlementCurrency="RUB" code="DMIC" name="ОФЗИН-Дискретный аукцион" exchangeId="1" description="ОФЗИН-Дискретный аукцион: Облигации Минфина"/>
|
||||
<market id="80" marketType="SCND" section="FOND" settlementCurrency="RUB" code="MMIC" name="ОФЗИН-Торги в режиме выкупа" exchangeId="1" description="ОФЗИН-Торги в режиме выкупа: Облигации Минфина"/>
|
||||
<market id="82" marketType="PRMR" section="FOND" settlementCurrency="RUB" code="BBVC" name="ОФЗ-ПК - Аукцион БР" exchangeId="1" description="ОФЗ-ПК - Аукцион БР"/>
|
||||
<market id="83" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMDTATSS" name="СПб ГУП АТС Смольного" exchangeId="1" description="СПб ГУП АТС Смольного"/>
|
||||
<market id="88" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMTTKFSP" name="Комитет финансов СПб" exchangeId="1" description="Комитет финансов СПб"/>
|
||||
<market id="89" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMDSKFLO" name="Комитет финансов ЛО" exchangeId="1" description="Комитет финансов ЛО"/>
|
||||
<market id="90" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMDTFSKB" name="ФСКМБ" exchangeId="1" description="ФСКМБ"/>
|
||||
<market id="91" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMDSFGGE" name="ФАУ ГГЭ" exchangeId="1" description="ФАУ ГГЭ"/>
|
||||
<market id="92" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMDTVRGO" name="ВВО РГО" exchangeId="1" description="ВВО РГО"/>
|
||||
<market id="93" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMDTTDRM" name="ООО Торговый дом РМ-Рейл" exchangeId="1" description="ООО Торговый дом РМ-Рейл"/>
|
||||
<market id="95" marketType="PRMR" section="MKR" settlementCurrency="RUB" code="XMDTRKFN" name="АО РК Финанс" exchangeId="1" description="АО РК Финанс"/>
|
||||
</objects>
|
||||
</meta>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
<xsl:template match="meta">-- DB version: <xsl:value-of select="$meta/@version"/>
|
||||
-- DATA version: <xsl:value-of select="@version"/>
|
||||
-- INSERT INTO DB_VERSION(ID, VERSION) values (1, '<xsl:value-of select="$meta/@version"/>') ON CONFLICT (ID) DO UPDATE SET VERSION = EXCLUDED.VERSION
|
||||
|
||||
<xsl:apply-templates select="*"/>
|
||||
</xsl:template>
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ DROP TABLE IF EXISTS <xsl:value-of select="$dbTableName"/>;
|
|||
CREATE TABLE <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="*" mode="field"/>);
|
||||
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/> IS '<xsl:value-of select="$dbNameComment"/>';
|
||||
<xsl:apply-templates select="*" mode="comment-enums"/>
|
||||
GRANT ALL PRIVILEGES ON TABLE <xsl:value-of select="$dbTableName"/> TO clearing;
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*" mode="objects">
|
||||
|
|
@ -53,6 +54,7 @@ DROP TABLE IF EXISTS <xsl:value-of select="$dbTableName"/>;
|
|||
CREATE TABLE <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="*[@name or @dbname or @type]" mode="field"/>);
|
||||
COMMENT ON TABLE <xsl:value-of select="$dbTableName"/> IS '<xsl:value-of select="$dbNameTComment"/>';
|
||||
<xsl:apply-templates select="*[@name or @dbname or @type]" mode="comment-objects"/>
|
||||
GRANT ALL PRIVILEGES ON TABLE <xsl:value-of select="$dbTableName"/> TO clearing;
|
||||
<xsl:if test="@logUpdates">
|
||||
|
||||
-- History log of <xsl:value-of select="name()"/> - <xsl:value-of select="$dbNameTComment"/>
|
||||
|
|
@ -65,6 +67,7 @@ COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_TIME IS '
|
|||
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_USER_ID IS 'Инициатор изменения';
|
||||
COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_TYPE IS 'Тип изменения';
|
||||
<xsl:apply-templates select="*[@name or @dbname or @type]" mode="comment-history-objects"/>
|
||||
GRANT ALL PRIVILEGES ON TABLE <xsl:value-of select="$dbTableName"/>_HISTORY TO clearing;
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
|
@ -73,12 +76,12 @@ COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>_HISTORY.EVENT_TYPE IS '
|
|||
<xsl:variable name="tp" select="@type"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@dbfield"><xsl:value-of select="@dbfield"/></xsl:when>
|
||||
<xsl:when test="@linkKeyCode"></xsl:when>
|
||||
<!--<xsl:when test="@linkKeyCode"></xsl:when>-->
|
||||
<xsl:when test="@extends"></xsl:when>
|
||||
<xsl:otherwise><xsl:if test="position() != '1'">, </xsl:if><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@linkKeyCode"></xsl:when>
|
||||
<!--<xsl:when test="@linkKeyCode"></xsl:when>-->
|
||||
<xsl:when test="@extends"></xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text> </xsl:text><xsl:value-of select="/meta/types/*[@id=$tp]/@type"/>
|
||||
|
|
@ -96,7 +99,7 @@ COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>.<xsl:call-template name=
|
|||
|
||||
<xsl:template match="*" mode="comment-objects">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@linkKeyCode"></xsl:when>
|
||||
<!--<xsl:when test="@linkKeyCode"></xsl:when>-->
|
||||
<xsl:when test="@extends"></xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name(parent::*)'/></xsl:call-template></xsl:variable>
|
||||
|
|
@ -106,7 +109,7 @@ COMMENT ON COLUMN <xsl:value-of select="$dbTableName"/>.<xsl:call-template name=
|
|||
|
||||
<xsl:template match="*" mode="comment-history-objects"><!-- todo похож на comment-objects только именем таблицы различается попробовать объединить -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="@linkKeyCode"></xsl:when>
|
||||
<!--<xsl:when test="@ "></xsl:when>-->
|
||||
<xsl:when test="@extends"></xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="dbTableName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name(parent::*)'/></xsl:call-template></xsl:variable>
|
||||
|
|
|
|||
|
|
@ -255,48 +255,44 @@ public class <xsl:value-of select="$nameObjFmt"/>HistoryMapStore extends Templat
|
|||
}
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="*" mode="mapstore-field-getFields" ><xsl:if test="position() != '1'">, </xsl:if> "<xsl:choose>
|
||||
<xsl:template match="*" mode="mapstore-field-getFields" ><xsl:choose><xsl:when test="@extends"></xsl:when><xsl:otherwise><xsl:if test="position() != '1'">, </xsl:if> "<xsl:choose>
|
||||
<xsl:when test="@dbfield"><xsl:value-of select="@dbfield"/></xsl:when>
|
||||
<xsl:otherwise><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:otherwise>
|
||||
</xsl:choose>"</xsl:template>
|
||||
</xsl:choose>"</xsl:otherwise></xsl:choose></xsl:template>
|
||||
<xsl:template match="*" mode="mapstore-field-setters" >
|
||||
<xsl:variable name="tp" select="@type"/>
|
||||
<xsl:variable name="javatp" select="/meta/types/*[@id=$tp]/@javatype"/> <xsl:choose>
|
||||
<xsl:when test="$javatp='Instant'">
|
||||
object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(getInstantFromTimestamp(resultSet, "<xsl:choose>
|
||||
<xsl:text> <!-- space   4 new line -->
|
||||
</xsl:text><xsl:if test="@extends">//ext: </xsl:if>
|
||||
<xsl:variable name="javatp" select="/meta/types/*[@id=$tp]/@javatype"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$javatp='Instant'">object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(getInstantFromTimestamp(resultSet, "<xsl:choose>
|
||||
<xsl:when test="@dbfield"><xsl:value-of select="@dbfield"/></xsl:when>
|
||||
<xsl:otherwise><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:otherwise>
|
||||
</xsl:choose>"))</xsl:when>
|
||||
<xsl:when test="$javatp='LocalDate'">
|
||||
object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(getLocalDateFromSqlDate(resultSet, "<xsl:choose>
|
||||
<xsl:when test="$javatp='LocalDate'">object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(getLocalDateFromSqlDate(resultSet, "<xsl:choose>
|
||||
<xsl:when test="@dbfield"><xsl:value-of select="@dbfield"/></xsl:when>
|
||||
<xsl:otherwise><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:otherwise>
|
||||
</xsl:choose>"))</xsl:when>
|
||||
<xsl:when test="$javatp='LocalTime'">
|
||||
object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(getLocalTimeFromSqlTime(resultSet, "<xsl:choose>
|
||||
<xsl:when test="$javatp='LocalTime'">object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(getLocalTimeFromSqlTime(resultSet, "<xsl:choose>
|
||||
<xsl:when test="@dbfield"><xsl:value-of select="@dbfield"/></xsl:when>
|
||||
<xsl:otherwise><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:otherwise>
|
||||
</xsl:choose>"))</xsl:when>
|
||||
<xsl:otherwise>
|
||||
object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(resultSet.getObject("<xsl:choose>
|
||||
<xsl:otherwise>object.set<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>(resultSet.getObject("<xsl:choose>
|
||||
<xsl:when test="@dbfield"><xsl:value-of select="@dbfield"/></xsl:when>
|
||||
<xsl:otherwise><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:otherwise>
|
||||
</xsl:choose>", <xsl:value-of select="$javatp"/>.class))</xsl:otherwise>
|
||||
</xsl:choose>;</xsl:template>
|
||||
|
||||
<xsl:template match="*" mode="mapstore-field-getters" ><xsl:if test="position() != '1'">, </xsl:if><!-- todo запятую в конце а не в начале, см. last()-->
|
||||
<xsl:template match="*" mode="mapstore-field-getters" ><xsl:if test="position() != '1' and not(@extends)">, </xsl:if><!-- todo запятую в конце а не в начале, см. last()-->
|
||||
<xsl:variable name="tp" select="@type"/>
|
||||
<xsl:variable name="javatp" select="/meta/types/*[@id=$tp]/@javatype"/>
|
||||
<xsl:text> <!-- space   4 new line -->
|
||||
</xsl:text><xsl:if test="@extends">//ext: </xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$javatp='Instant'">
|
||||
TimeUtil.toDateFromInstant(object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>())</xsl:when>
|
||||
<xsl:when test="$javatp='LocalDate'">
|
||||
TimeUtil.toDateFromLocalDate(object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>())</xsl:when>
|
||||
<xsl:when test="$javatp='LocalTime'">
|
||||
TimeUtil.toDateFromLocalTime(object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>())</xsl:when>
|
||||
<xsl:otherwise>
|
||||
object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>()</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:when test="$javatp='Instant'">TimeUtil.toDateFromInstant(object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>())</xsl:when>
|
||||
<xsl:when test="$javatp='LocalDate'">TimeUtil.toDateFromLocalDate(object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>())</xsl:when>
|
||||
<xsl:when test="$javatp='LocalTime'">TimeUtil.toDateFromLocalTime(object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>())</xsl:when>
|
||||
<xsl:otherwise>object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template>()</xsl:otherwise></xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
|
|
@ -305,7 +301,7 @@ object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconv
|
|||
|
||||
<xsl:variable name="tp" select="@type"/>
|
||||
|
||||
<xsl:if test="name()='id'"> // (in parent) </xsl:if> private <xsl:value-of select="/meta/types/*[@id=$tp]/@javatype"/> <xsl:text> <!-- space   --></xsl:text><xsl:value-of select="name()"/>;
|
||||
<xsl:if test="@extends"> // extend: </xsl:if><xsl:if test="name()='id'"> // (in parent) </xsl:if> private <xsl:value-of select="/meta/types/*[@id=$tp]/@javatype"/> <xsl:text> <!-- space   --></xsl:text><xsl:value-of select="name()"/>;
|
||||
<xsl:choose>
|
||||
<xsl:when test="@dbfield"> // DB field: <xsl:value-of select="@dbfield"/></xsl:when>
|
||||
<!-- new line -->
|
||||
|
|
@ -360,6 +356,7 @@ object.get<xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconv
|
|||
<xsl:variable name="tp" select="@type"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="name()='id'"></xsl:when>
|
||||
<xsl:when test="@extends"></xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="NameFmt"><xsl:call-template name='convertFirstUC_'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:variable>
|
||||
public <xsl:value-of select="/meta/types/*[@id=$tp]/@javatype"/> get<xsl:value-of select="$NameFmt"/>() {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ public class StateLoaderImplTestConfig {
|
|||
|
||||
@Bean(name = "stateLoaderImplTest")
|
||||
public StateLoaderImpl createStateLoaderImpl(@Qualifier("responseFactoryTest") GetResponseFactory responseFactory) {
|
||||
return new StateLoaderImpl(hazelcastServiceTest, responseFactory);
|
||||
return new StateLoaderImpl(hazelcastServiceTest, null, responseFactory);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ import static ru.spcex.clearing.test.json.MatcherFactoryWithJson.usingIgnoringFi
|
|||
DepoAccountController.class,
|
||||
//account misc
|
||||
ClientCodeController.class,
|
||||
AccountSymbolsController.class,
|
||||
//company
|
||||
CompanyRoleSetController.class,
|
||||
CompanyController.class,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ru.clearing.classes.statics.data.account.AccountSymbols;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.AccountSymbolsNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
|
||||
class AccountSymbolsControllerTest extends AbstractControllerTest {
|
||||
private static final String REST_URL = "/accounting/depo-accounts-symbols/";
|
||||
|
||||
/**
|
||||
* {@link AccountSymbolsController#add(AccountSymbolsNewAction)}<br>
|
||||
* Тест проверяет получение сущности {@link AccountSymbolsNewAction} по REST API и отправку в Apache Kafka.<br>
|
||||
* Входной запрос {@link AccountSymbolsNewAction}: {111L, "VALUE-1234"}
|
||||
*/
|
||||
@Test
|
||||
void add() throws Exception {
|
||||
//ARRANGE
|
||||
AccountSymbolsNewAction accountSymbolsNewAction = new AccountSymbolsNewAction();
|
||||
accountSymbolsNewAction.setAccountId(111L);
|
||||
accountSymbolsNewAction.setAccountSymbolValue("VALUE-1234");
|
||||
|
||||
//ACT and ASSERT
|
||||
checkAddingByRestApi(REST_URL, accountSymbolsNewAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_NEW, accountSymbolsNewAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link AccountSymbolsController#delete(Long)} <br>
|
||||
* Тест проверяет получение id сущности {@link Long} по REST API и отправку в Apache Kafka.<br>
|
||||
* Входной запрос /accounting/depo-accounts-symbols/{@link Long}: - 0L<br>
|
||||
*/
|
||||
@Test
|
||||
void delete() throws Exception {
|
||||
//ARRANGE
|
||||
long id = currentId.getAndIncrement();
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
//ACT and ASSERT
|
||||
checkDeletingByRestApi(REST_URL, id);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_DEPO_ACCOUNT_SYMBOLS_DELETE, deleteAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ClientCodeController#getAll()} <br>
|
||||
* Тест проверяет получение запроса по REST API и отправку всех записей из таблицы hazelcast Map_ClientCode.<br>
|
||||
* Входной запрос /client-codes/ <br>
|
||||
* Ответ CommonGetAllResponse <br>
|
||||
*/
|
||||
@Test
|
||||
void getAll() throws Exception {
|
||||
//ARRANGE
|
||||
AccountSymbols existAccountSymbols = new AccountSymbols();
|
||||
existAccountSymbols.setAccountId(111L);
|
||||
existAccountSymbols.setAccountSymbolValue("AAABBBVVCD");
|
||||
existAccountSymbols.setId(currentId.get());
|
||||
|
||||
//ACT and ASSERT
|
||||
checkGettingAllFromRestApi(IMDGDistributedNames.Map_AccountSymbols, existAccountSymbols, REST_URL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ class UserSettingsControllerTest extends AbstractControllerTest {
|
|||
//ARRANGE
|
||||
UserSettings userSettings = new UserSettings();
|
||||
userSettings.setId(currentId.get());
|
||||
userSettings.setUserId(currentId.get());
|
||||
userSettings.setUserId(currentId.get()); // отдаются по userId CLS-64, todo в тесте null
|
||||
userSettings.setJson("json");
|
||||
userSettings.setVersion("version");
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import java.nio.file.Paths;
|
|||
public class GetResponseFactoryTestConfiguration {
|
||||
@Bean("metaJsonTestPath")
|
||||
public Resource metaJsonPath() {
|
||||
Path path = Paths.get("src", "main", "resources", "meta.json");
|
||||
Path path = Paths.get("src", "main", "resources", "meta", "meta.json");
|
||||
return new PathResource(path);
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue