balance-service fix

This commit is contained in:
ialbert 2022-12-21 16:46:19 +03:00
parent 292675e92b
commit bbc10ca13b
2 changed files with 12 additions and 4 deletions

View file

@ -71,6 +71,7 @@ public class ValidationConfig {
Consumer<String> addImdg = (s) -> context.addImdg(s, getImdg(s)); Consumer<String> addImdg = (s) -> context.addImdg(s, getImdg(s));
addImdg.accept(IMDGDistributedNames.Map_Account); addImdg.accept(IMDGDistributedNames.Map_Account);
addImdg.accept(IMDGDistributedNames.Map_Company); addImdg.accept(IMDGDistributedNames.Map_Company);
addImdg.accept(IMDGDistributedNames.Map_CompanySymbols);
return new ValidatorImpl<>(context, return new ValidatorImpl<>(context,
Sdf16ValidationRule.CompanyPresent, Sdf16ValidationRule.CompanyPresent,
ExistClrnAccountValidationRule.AccountPresent, ExistClrnAccountValidationRule.AccountPresent,

View file

@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.clearing.classes.statics.data.sdf.SDf01; import ru.clearing.classes.statics.data.sdf.SDf01;
import ru.clearing.classes.statics.data.sdf.SDf09;
import ru.clearing.classes.statics.data.sdf.SDf16;
import ru.spcex.clearing.imdg.IMDGDistributedNames; import ru.spcex.clearing.imdg.IMDGDistributedNames;
import ru.spcex.clearing.platform.messaging.domain.BaseRequest; import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
import ru.spcex.clearing.platform.messaging.domain.Consts; import ru.spcex.clearing.platform.messaging.domain.Consts;
@ -23,6 +25,7 @@ import ru.spcex.platform.imdg.api.Imdg;
import ru.spcex.platform.imdg.api.ImdgProvider; import ru.spcex.platform.imdg.api.ImdgProvider;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -33,7 +36,7 @@ public class StatementService extends QueueConsumer implements InitializingBean
private final ImdgProvider imdgProvider; private final ImdgProvider imdgProvider;
private final KafkaSender kafkaReqProducer; private final KafkaSender kafkaReqProducer;
private final Imdg<? extends WithAccount> sdf01Imdg; private final Map<SdfTable, Imdg<? extends WithAccount>> sdfImdgs;
private final Map<SdfTable, AbstractExecutor<? extends WithAccount>> executorsMap; private final Map<SdfTable, AbstractExecutor<? extends WithAccount>> executorsMap;
@Autowired @Autowired
@ -43,9 +46,12 @@ public class StatementService extends QueueConsumer implements InitializingBean
@Qualifier("sdfExecutors") Map<SdfTable, AbstractExecutor<? extends WithAccount>> executorsMap) { @Qualifier("sdfExecutors") Map<SdfTable, AbstractExecutor<? extends WithAccount>> executorsMap) {
super(kafkaQueue); super(kafkaQueue);
this.imdgProvider = imdgProvider; this.imdgProvider = imdgProvider;
this.sdf01Imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf01, SDf01.class); this.sdfImdgs = new EnumMap<>(SdfTable.class);
this.kafkaReqProducer = kafkaReqProducer; this.kafkaReqProducer = kafkaReqProducer;
this.executorsMap = executorsMap; this.executorsMap = executorsMap;
this.sdfImdgs.put(SdfTable.SDF_01, imdgProvider.getImdg(IMDGDistributedNames.Map_SDf01, SDf01.class));
this.sdfImdgs.put(SdfTable.SDF_09, imdgProvider.getImdg(IMDGDistributedNames.Map_SDf09, SDf09.class));
this.sdfImdgs.put(SdfTable.SDF_16, imdgProvider.getImdg(IMDGDistributedNames.Map_SDf16, SDf16.class));
} }
@Override @Override
@ -61,13 +67,14 @@ public class StatementService extends QueueConsumer implements InitializingBean
Collection<? extends WithAccount> sdfGroup; Collection<? extends WithAccount> sdfGroup;
SdfTable table = statementRequest.getTable(); SdfTable table = statementRequest.getTable();
//map = getMapByTable(table) //map = getMapByTable(table)
Imdg<? extends WithAccount> sdfImdg = sdfImdgs.get(table);
if (statementRequest.getAccountCreationResults().size() == 0) { if (statementRequest.getAccountCreationResults().size() == 0) {
sdfGroup = sdf01Imdg.getCollectionObjectsByFieldValues(Map.of("generationId", statementRequest.getGroupId())); sdfGroup = sdfImdg.getCollectionObjectsByFieldValues(Map.of("generationId", statementRequest.getGroupId()));
} else { } else {
sdfGroup = statementRequest.getAccountCreationResults() sdfGroup = statementRequest.getAccountCreationResults()
.stream() .stream()
.filter(part -> part.getErrorCode() == null) //fixme эти случае должны попадать в ошибочный sdf02 .filter(part -> part.getErrorCode() == null) //fixme эти случае должны попадать в ошибочный sdf02
.map(part -> sdf01Imdg.getSingleObjectByID(part.getSdfId())) .map(part -> sdfImdg.getSingleObjectByID(part.getSdfId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
// sdf01Group = sdf01Group // sdf01Group = sdf01Group