split sdf08/21, unit session section -> MULT

This commit is contained in:
ialbert 2024-06-11 18:48:24 +03:00
parent 4e2e3d9547
commit 6feeb77b1f
6 changed files with 37 additions and 47 deletions

View file

@ -45,10 +45,10 @@ public enum RegistryStep3ValidationRule implements IValidationRule<ImdgValidatio
}
Imdg<Relation> relationImdg = context.obtainMap(IMDGDistributedNames.Map_Relation, Relation.class);
Imdg<Session> sessionImdg = context.obtainMap(IMDGDistributedNames.Map_Session, Session.class);
Session activeSession = sessionImdg.getSingleObjectByID(validatedObject.getSessionId());
//Session activeSession = sessionImdg.getSingleObjectByID(validatedObject.getSessionId());
Relation relation = relationImdg.getFirstObjectByFieldValues(Map.of(
"consumerId", validatedObject.getCompanyId(),
"service", activeSession.getSection()));
"service", validatedObject.getSection()));
if (relation == null || (!ServiceStatus.Active.equalsByKey(relation.getServiceStatus()) && !ServiceStatus.Reopened.equalsByKey(relation.getServiceStatus()))) {
return of(ClearingError.ClearingUnavailableForCompany, sectionFind.get(), validatedObject.getCompanyId());
}

View file

@ -324,7 +324,7 @@ public class UnitedSession extends AbstractSession implements InitializingBean {
@Override
protected Section section() {
return Section.FOND;
return Section.MULT;
}
@Override

View file

@ -252,8 +252,7 @@ public class FormingPaymentInstructionAssets implements ISessionStage {
.debitLegAccount(debitLegAccount)
.creditLegAccount(creditLegAccount)
.amount(amount)
.currency(SessionType.CURR.equals(sessionType) || Section.CURR.equalsByKey(registry.getSection())
? registry.getSecuritySymbol() : null)
.currency(registry.getSecuritySymbol())
.sessionId(sessionId)
.checkBLKD((SessionType.FINL.equals(sessionType) || SessionType.MEDM.equals(sessionType))
&& !isPositiveBalance ? registry : null)

View file

@ -8,7 +8,7 @@ import ru.spcex.platform.enumeration.SdfTable;
public enum SdfGroup {
// Sdf01And57(SdfTable.SDF_01, SdfTable.SDF_57),
Sdf08And21(SdfTable.SDF_08, SdfTable.SDF_21),
// Sdf08And21(SdfTable.SDF_08, SdfTable.SDF_21),
//------ session groups ------ (4), (1 57), (13), (8 21)
//session_Triple(SdfTable.SDF_04, SdfTable.SDF_01, SdfTable.SDF_57),

View file

@ -118,9 +118,11 @@ public class StatementServiceV2 {
switch (table) {
case SDF_01 -> processSdf01(systemRequest.getRequestPayload());
case SDF_04 -> processSdf04(systemRequest.getRequestPayload());
case SDF_08 -> processSdf08(systemRequest.getRequestPayload());
case SDF_10 -> sdf10Executor.execute(systemRequest);
case SDF_13 -> processSdf13(systemRequest.getRequestPayload());
case SDF_20 -> sdf20Executor.execute(systemRequest);
case SDF_21 -> processSdf21(systemRequest.getRequestPayload());
case SDF_55 -> sdf55Executor.execute(systemRequest);
case SDF_57 -> processSdf57(systemRequest.getRequestPayload());
default -> log.error("unknown table {}", table);
@ -148,9 +150,9 @@ public class StatementServiceV2 {
log.debug("find full set of SDF requests: {}", fullGroup.stream()
.map(stReq -> stReq.getTable().getKey() + " generationId=" + stReq.getGroupId())
.collect(TextUtil.join));
if (sdfGroup.get() == SdfGroup.Sdf08And21) {
processSdf08And21(find(SdfTable.SDF_08, fullGroup), find(SdfTable.SDF_21, fullGroup));
}
// if (sdfGroup.get() == SdfGroup.Sdf08And21) {
// processSdf08And21(find(SdfTable.SDF_08, fullGroup), find(SdfTable.SDF_21, fullGroup));
// }
// else if (sdfGroup.get() == SdfGroup.Sdf01And57) {
// processSdf01Parent(find(SdfTable.SDF_01, fullGroup), find(SdfTable.SDF_57, fullGroup));
// }
@ -164,9 +166,9 @@ public class StatementServiceV2 {
// processSdf08And21(find(SdfTable.SDF_08, fullGroup), find(SdfTable.SDF_21, fullGroup));
// processSdf01And57(find(SdfTable.SDF_01, fullGroup), find(SdfTable.SDF_57, fullGroup));
//}
else {
throw new IllegalStateException("not implemented");
}
// else {
throw new IllegalStateException("not implemented");
// }
}
private static StatementRequest find(SdfTable table, Collection<StatementRequest> reqs) {
@ -177,27 +179,6 @@ public class StatementServiceV2 {
return first.get();
}
/**
* fromAccService передается когда пришел ответ от account-service
* в этом случае: по key находим пару в которой сохранен sdf57 запрос и частично выполненный sdf01
* вместо старого sdf01 запроса выполняем новый пришедший от account-service
*/
private void processSdf08And21(StatementRequest sdf08, StatementRequest sdf21) {
Result sdf08Res = processSdf08(sdf08);
removeFirstWithSameTableAndGroupId(sdf08);
if (sdf08Res.getAccountRequests().size() > 0) {
log.info("sdf08 execution wasn't complete, waiting for an answer from account-service");
return;
}
//затем sdf21
processSdf21(sdf21);
removeFirstWithSameTableAndGroupId(sdf21);
//fixme ревизия для бумаг reviser.doRevise(pair.getFirst().getGroupId());
SessionContinueEvent continueSessionBn = new SessionContinueEvent(SdfTable.SDF_08, SdfTable.SDF_21);
kafkaSender.sendRequestToQueue(Consts.CONTINUE_SESSION_BN_FIRST_PART, continueSessionBn);
log.info("pair sdf08/sdf21 processed successfully");
}
private void processSdf04(StatementRequest statementRequest) {
Imdg<SDf04> sdfImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf04, SDf04.class);
Collection<? extends SpcexObjectBase> sdfGroup = sdfImdg.getCollectionObjectsByFieldValues(Map.of(
@ -304,36 +285,45 @@ public class StatementServiceV2 {
}
private Result processSdf08(StatementRequest statementRequest) {
private void processSdf08(StatementRequest sdf08) {
Imdg<SDf08> sdfImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf08, SDf08.class);
Collection<SDf08> sdfGroup;
if (statementRequest.getAccountCreationResults().size() == 0) {
if (sdf08.getAccountCreationResults().isEmpty()) {
sdfGroup = sdfImdg.getCollectionObjectsByFieldValues(Map.of(
"generationId", statementRequest.getGroupId()));
"generationId", sdf08.getGroupId()));
} else {
sdfGroup = statementRequest.getAccountCreationResults()
sdfGroup = sdf08.getAccountCreationResults()
.stream()
.filter(part -> part.getErrorCode() == null)
.map(part -> sdfImdg.getSingleObjectByID(part.getSdfId()))
.collect(Collectors.toList());
}
Result res = sdf08Executor.execute(sdfGroup, statementRequest);
if (res.getAccountRequests().size() != 0) {
AccountSdf01Request createAccsReq = StatementService.createAccountsRequest(statementRequest.getGroupId(),
res.getAccountRequests(),
res.getChildGenerationId());
Result sdf08Res = sdf08Executor.execute(sdfGroup, sdf08);
if (!sdf08Res.getAccountRequests().isEmpty()) {
AccountSdf01Request createAccsReq = StatementService.createAccountsRequest(sdf08.getGroupId(),
sdf08Res.getAccountRequests(),
sdf08Res.getChildGenerationId());
kafkaSender.sendRequestToQueue(Consts.ACCOUNT_NEW_SDF08, createAccsReq);
} else if (sdf08Executor.isNeedToSendCommand()) {
sdf08Executor.sendCommand(kafkaSender, res);
sdf08Executor.sendCommand(kafkaSender, sdf08Res);
}
removeFirstWithSameTableAndGroupId(sdf08);
if (!sdf08Res.getAccountRequests().isEmpty()) {
log.info("sdf08 execution wasn't complete, waiting for an answer from account-service");
} else {
log.info("sdf08 execution was complete.");
}
return res;
}
private void processSdf21(StatementRequest statementRequest) {
private void processSdf21(StatementRequest sdf21) {
Imdg<SDf21> sdfImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf21, SDf21.class);
Collection<SDf21> sdfGroup = sdfImdg.getCollectionObjectsByFieldValues(Map.of(
"generationId", statementRequest.getGroupId()));
Result res = sdf21Executor.execute(sdfGroup, statementRequest);
"generationId", sdf21.getGroupId()));
Result res = sdf21Executor.execute(sdfGroup, sdf21);
removeFirstWithSameTableAndGroupId(sdf21);
SessionContinueEvent continueSessionBn = new SessionContinueEvent(SdfTable.SDF_08, SdfTable.SDF_21);
kafkaSender.sendRequestToQueue(Consts.CONTINUE_SESSION_BN_FIRST_PART, continueSessionBn);
log.info("sdf21 processed successfully");
}

View file

@ -5,6 +5,7 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
public enum Section implements IEnumKey {
MKR("MKR"),
FOND("FOND"),
MULT("MULT"),
CURR("CURR");
Section(String key) {