Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
70320834ae
3 changed files with 46 additions and 23 deletions
|
|
@ -26,6 +26,7 @@ import ru.spcex.clearing.platform.messaging.domain.cud.securitites.MoneyMarketSe
|
|||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.enumeration.Allowed;
|
||||
import ru.spcex.platform.enumeration.Market;
|
||||
import ru.spcex.platform.enumeration.MoneyFlowSide;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
|
@ -133,31 +134,45 @@ public class ExecutionDepositComponent {
|
|||
}
|
||||
}
|
||||
|
||||
// Необходимо проверять отсутствие ExecutionDeposit с exchangeExecutionId и clearingDate.
|
||||
// Необходимо проверять отсутствие ExecutionDeposit с exchangeExecutionId и clearingDate и side.
|
||||
// Но при этом, во время создания новых 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);
|
||||
boolean existsEDeposit = existTradeNumsOfExecutionDeposit.contains(trade.getTradeNum());
|
||||
log.trace("Check s_trade[{}].tradeNum={} operation={} on date {}", trade.getId(), trade.getTradeNum(), trade.getOperation(), today);
|
||||
boolean existEDeposit;
|
||||
{
|
||||
ImdgPredicateBuilder pb = executionDepositImdg.predicateBuilder();
|
||||
|
||||
if (!existsEDeposit) {
|
||||
ImdgPredicate predicateOperation = pb.equals("side", trade.getOperation());
|
||||
if ("B".equalsIgnoreCase(trade.getOperation())) {
|
||||
predicateOperation = pb.or(predicateOperation, pb.equals("side", MoneyFlowSide.BUY.getKey()));
|
||||
}
|
||||
// if ("BUY".equalsIgnoreCase(trade.getOperation())) {
|
||||
// predicateOperation = pb.or(predicateOperation, pb.equals("side", "B"));
|
||||
// }
|
||||
if ("S".equalsIgnoreCase(trade.getOperation())) {
|
||||
predicateOperation = pb.or(predicateOperation, pb.equals("side", MoneyFlowSide.SELL.getKey()));
|
||||
}
|
||||
// if ("SELL".equalsIgnoreCase(trade.getOperation())) {
|
||||
// predicateOperation = pb.or(predicateOperation, pb.equals("side", "S"));
|
||||
// }
|
||||
|
||||
ImdgPredicate predicate = pb.and(
|
||||
pb.equals("exchangeExecutionId", trade.getTradeNum()),
|
||||
pb.equals("clearingDate", today),
|
||||
predicateOperation
|
||||
);
|
||||
Collection<ExecutionDeposit> existsEDeposit = executionDepositImdg.getCollectionObjectsByPredicate(predicate);
|
||||
// Collection<ExecutionDeposit> existsEDeposit=executionDepositImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
// "exchangeExecutionId", trade.getTradeNum(),
|
||||
// "clearingDate", today
|
||||
// ));
|
||||
existEDeposit = !existsEDeposit.isEmpty();
|
||||
log.trace("Check exist ExecutionDeposit, SQL \"{}\", found {}, exist {}", predicate, existsEDeposit.size(), existEDeposit);
|
||||
}
|
||||
|
||||
if (!existEDeposit) {
|
||||
log.trace("S_TRADE[{}] new", trade.getId());
|
||||
|
||||
// Проверка secCode
|
||||
|
|
@ -172,6 +187,7 @@ public class ExecutionDepositComponent {
|
|||
newED = createExecutionDeposit(trade, null, null);
|
||||
executionDepositImdg.insert(newED);
|
||||
sendNotification(newED);
|
||||
log.debug("New executionDeposit.id={} was created.", newED.getId());
|
||||
} catch (ClearingException ce) {
|
||||
auditMessage(ce);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -270,7 +286,14 @@ public class ExecutionDepositComponent {
|
|||
eDeposit.setFirstLegAmount(sTrade.getValue());
|
||||
eDeposit.setSecondLegAmount(sTrade.getValue());
|
||||
//eDeposit.setInterestAmount(null);
|
||||
eDeposit.setSide(sTrade.getOperation());//Символьный код по справочнику moneyFlowSide), соответствующий значению из s_trade.operation (sTrade.getOperation())
|
||||
String operation = sTrade.getOperation(); //Символьный код по справочнику moneyFlowSide), соответствующий значению из s_trade.operation (sTrade.getOperation())
|
||||
if ("B".equalsIgnoreCase(operation)) {
|
||||
operation = MoneyFlowSide.BUY.getKey();
|
||||
}
|
||||
if ("S".equalsIgnoreCase(operation)) {
|
||||
operation = MoneyFlowSide.SELL.getKey();
|
||||
}
|
||||
eDeposit.setSide(operation);
|
||||
eDeposit.setSettlementCurrency("RUB"); // (справочник currencyCode)
|
||||
eDeposit.setCompanyId(company.getId());
|
||||
eDeposit.setDuration(sTrade.getDaysToMatDate());
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="ru.spcex.clearing.service.Clearing" level="trace" additivity="false">
|
||||
<logger name="ru.spcex.clearing.service" level="trace" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class ImdgPredicateBuilderHazelcast implements ImdgPredicateBuilder {
|
|||
public ImdgPredicate and(ImdgPredicate paramA, ImdgPredicate paramB, ImdgPredicate paramC) {
|
||||
ImdgPredicateHazelcast paramAMy = (ImdgPredicateHazelcast) paramA;
|
||||
ImdgPredicateHazelcast paramBMy = (ImdgPredicateHazelcast) paramB;
|
||||
ImdgPredicateHazelcast paramCMy = (ImdgPredicateHazelcast) paramB;
|
||||
ImdgPredicateHazelcast paramCMy = (ImdgPredicateHazelcast) paramC;
|
||||
return new ImdgPredicateHazelcast(Predicates.and(paramAMy.hazelcastPredicate, paramBMy.hazelcastPredicate, paramCMy.hazelcastPredicate));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue