Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
ialbert 2023-02-08 11:21:38 +03:00
commit 8ae1c18344
3 changed files with 37 additions and 15 deletions

View file

@ -99,9 +99,12 @@ public class ExecutionDepositComponent {
public void processNewTS() {
log.debug("Start check new S_TRADE after {}", tradingDay);
ImdgPredicateBuilder pb = sTradeImdg.predicateBuilder();
ImdgPredicate sql = pb.greatEqual("tradeDateTime", tradingDay);
Collection<STrade> sTrades = sTradeImdg.getCollectionObjectsByPredicate(sql);
Collection<STrade> sTrades;
{
ImdgPredicateBuilder pb = sTradeImdg.predicateBuilder();
ImdgPredicate sql = pb.greatEqual("tradeDateTime", tradingDay);
sTrades = sTradeImdg.getCollectionObjectsByPredicate(sql);
}
log.info("Found {} new s_trade with trade_num>{}", sTrades.size(), tradeNum);
if (sTrades.isEmpty()) {
@ -130,15 +133,31 @@ public class ExecutionDepositComponent {
}
}
// Необходимо проверять отсутствие ExecutionDeposit с exchangeExecutionId и clearingDate.
// Но при этом, во время создания новых ExecutionDeposit по STrade, TradeNum могут повторяться.
LocalDate today = LocalDate.now();
HashSet<Long> existTradeNumsOfExecutionDeposit = new HashSet<>();
{
Set<Long> tradeNums = sTrades.stream().map(STrade::getTradeNum).filter(Objects::nonNull).collect(Collectors.toSet());
log.debug("Check {} s_trade tradeNum=[{}] on date {}", sTrades.size(), tradeNums, today);
ImdgPredicateBuilder pb = executionDepositImdg.predicateBuilder();
Collection<ExecutionDeposit> existsEDeposit = executionDepositImdg.getCollectionObjectsByPredicate(
pb.and(
pb.in("exchangeExecutionId", tradeNums.toArray(new Comparable[0])),
pb.equals("clearingDate", today)
)
// Map.of("exchangeExecutionId", trade.getTradeNum(),"clearingDate", today)
);
for (ExecutionDeposit ed : existsEDeposit) {
existTradeNumsOfExecutionDeposit.add(ed.getExchangeExecutionId());
}
}
for (STrade trade : sTrades) {
log.trace("Check s_trade[{}].tradeNum={} on date {}", trade.getId(), trade.getTradeNum(), today);
Collection<ExecutionDeposit> existsEDeposit = executionDepositImdg.getCollectionObjectsByFieldValues(Map.of(
"exchangeExecutionId", trade.getTradeNum(),
"clearingDate", today
));
boolean existsEDeposit = existTradeNumsOfExecutionDeposit.contains(trade.getTradeNum());
if (existsEDeposit.isEmpty()) {
if (!existsEDeposit) {
log.trace("S_TRADE[{}] new", trade.getId());
// Проверка secCode
@ -160,8 +179,7 @@ public class ExecutionDepositComponent {
}
} else {
long[] idToLong = existsEDeposit.stream().mapToLong(SpcexObjectBase::getId).toArray();
log.trace("S_TRADE[{}] already has executionDeposit: {}", trade.getId(), Arrays.toString(idToLong));
log.trace("S_TRADE[{}] already has executionDeposit: exchangeExecutionId={} on date {}", trade.getId(), trade.getTradeNum(), today);
}
}

View file

@ -181,9 +181,13 @@ public class SdfCreatorBySTLDPayment {
ClearingCategory getClearingCategory(PaymentInstruction paymentInstruction) {
ClearingMemberCategory category = clearingMemberCategoryImdg.getSingleObjectByFieldValues(
Map.of("companyId", paymentInstruction.getSenderId()));
String categoryKey = !TextUtil.isEmpty(category.getClearingMemberCategory())
? category.getClearingMemberCategory() : "";
Map.of("companyId", paymentInstruction.getSenderId()));
if (category == null) {
log.trace("ClearingMemberCategory not found by paymentInstruction[{}].companyId={}",
paymentInstruction.getId(), paymentInstruction.getSenderId());
}
String categoryKey = category != null
? category.getClearingMemberCategory() : "";
return IEnumKey.getEnumByKeyOrUndefined(ClearingCategory.class,
categoryKey);
}

View file

@ -245,8 +245,8 @@ public class PaymentInstructionCreator {
payment1.setSenderId(SPVB_ID); // СПВБ
{
String sqlLCA = String.format("securityId = %s and companyId != %s",
liabilitiesClaimsAssets.getSecurityId(), liabilitiesClaimsAssets.getCompanyId());
String sqlLCA = String.format("exchangeExecutionId = %s and side != '%s'",
executionDeposit.getExchangeExecutionId(), executionDeposit.getSide());
ExecutionDeposit counterExecutionDeposit = executionDepositImdg.getSingleObjectBySQL(sqlLCA);
if (counterExecutionDeposit == null) {
log.warn("Counter ExecutionDeposit not found for : {}", sqlLCA);