This commit is contained in:
parent
1775ababa1
commit
0390f3d20e
3 changed files with 75 additions and 53 deletions
|
|
@ -45,10 +45,13 @@ public class PaymentInstructionBuilder {
|
|||
"companyId", registry.getCompanyId(),
|
||||
"companySymbol", CompanySymbol.BIC.getKey())
|
||||
);
|
||||
CompanySymbols counterCompanySymbols = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
|
||||
"companyId", registry.getCounterPartyId(),
|
||||
"companySymbol", CompanySymbol.BIC.getKey())
|
||||
);
|
||||
CompanySymbols counterCompanySymbols = null;
|
||||
if (registry.getCounterPartyId() != null) {
|
||||
counterCompanySymbols = companySymbolsImdg.getSingleObjectByFieldValues(Map.of(
|
||||
"companyId", registry.getCounterPartyId(),
|
||||
"companySymbol", CompanySymbol.BIC.getKey())
|
||||
);
|
||||
}
|
||||
|
||||
if (companySymbols != null) {
|
||||
paymentInstruction.setPayeeBic(companySymbols.getCompanySymbolValue());
|
||||
|
|
|
|||
|
|
@ -4,56 +4,56 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
|
|||
|
||||
public enum TaskType implements IEnumKey {
|
||||
/**
|
||||
* step 0
|
||||
* step 0/9
|
||||
*/
|
||||
StartRevise("rev"),
|
||||
ContinueRevise("s-1"),
|
||||
StartRevise("CLR0"),
|
||||
ContinueRevise("CLR 0_0"),
|
||||
|
||||
/**
|
||||
* step 1
|
||||
*/
|
||||
DealsPrepare("s-2"),
|
||||
DealsPrepare("CL01"),
|
||||
/**
|
||||
* step 2
|
||||
*/
|
||||
RequirementsAndObligationsCreate("s-3"),
|
||||
RequirementsAndObligationsCreate("CL02"),
|
||||
/**
|
||||
* step 3
|
||||
*/
|
||||
ObligationsAdmission("s-4"),
|
||||
ObligationsAdmission("CL03"),
|
||||
/**
|
||||
* step 4
|
||||
*/
|
||||
InclusionToPool("s-5"),
|
||||
InclusionToPool("CL04"),
|
||||
/**
|
||||
* step 5
|
||||
*/
|
||||
InspectionObligations("S-6"),
|
||||
InspectionObligations("CL05"),
|
||||
/**
|
||||
* Step 6: forming Registry on Obligations and Settlement requirements
|
||||
*/
|
||||
FormingRegistersOnOS("s-7"),
|
||||
FormingRegistersOnOS("CL06"),
|
||||
/**
|
||||
* step 7
|
||||
*/
|
||||
FormingPaymentInstruction("s-8"),
|
||||
|
||||
|
||||
FormingPaymentInstruction("CL07"),
|
||||
/**
|
||||
* step 8
|
||||
*/
|
||||
UnlockResources("unlc"),
|
||||
|
||||
|
||||
UnlockResources("CL08"),
|
||||
// /**
|
||||
// * step 0/9
|
||||
// */
|
||||
// AgainRevise("CL09"),
|
||||
/**
|
||||
* Step 10
|
||||
*/
|
||||
FinishingSession("s-10"),
|
||||
FinishingSession("CL10"),
|
||||
|
||||
/**
|
||||
* Step 11
|
||||
*/
|
||||
EndStageNotification("s-11");
|
||||
EndStageNotification("CL11");
|
||||
|
||||
private String key;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,63 +65,82 @@ public class InspectionObligations implements ISessionStage {
|
|||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
|
||||
RegistryTradingParams registryTradingParamsOMT = new RegistryTradingParams(RegistryDesignation.O,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
|
||||
RegistryTradingParams registryTradingParamsTMT = new RegistryTradingParams(RegistryDesignation.T,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
|
||||
|
||||
String sqlCondition = String.format("%s and registryStatus = '%s'",
|
||||
RegistryCodeSqlBuilder.getInstance(registryTradingParamsOST, registryTradingParamsTMT).build(),
|
||||
RegistryCodeSqlBuilder.getInstance(registryTradingParamsOST, registryTradingParamsTMT, registryTradingParamsOMT).build(),
|
||||
RegistryStatus.POOL.getKey());
|
||||
|
||||
Collection<Registry> obligations = registryImdg.getCollectionObjectsBySQL(sqlCondition);
|
||||
Map<Long, Map<Long, List<Registry>>> registryByGroupIdAndCompanyId = obligations.stream().
|
||||
collect(Collectors.groupingBy(Registry::getGroupId, Collectors.groupingBy(Registry::getCompanyId)));
|
||||
Map<Long, List<Registry>> registryByGroupIdAndCompanyId = obligations.stream().
|
||||
collect(Collectors.groupingBy(Registry::getGroupId));
|
||||
|
||||
List<Long> insecurityGroups = new ArrayList<>();
|
||||
List<Long> alreadyUpdatedToUncover = new ArrayList<>();
|
||||
for (Registry currentRegistry : obligations) {
|
||||
if (insecurityGroups.contains(currentRegistry.getGroupId())) {
|
||||
log.debug("Skip insecurity groupId: {}", currentRegistry.getGroupId());
|
||||
continue;
|
||||
}
|
||||
if (IEnumKey.getEnumByKey(RegistryDesignation.class, currentRegistry.getRegistryDesignation()) == RegistryDesignation.A) {
|
||||
String sqlCounterRegistryCondition = String.format("registryDesignation = '%s' and " +
|
||||
"registryInstrumentType in ('%s', '%s') and " +
|
||||
"registryUnit = '%s' and " +
|
||||
"tradingClearingRegistryId = '%s' and " +
|
||||
"companyId = '%s' and ",
|
||||
RegistryDesignation.A,
|
||||
RegistryInstrumentType.S.getKey(), RegistryInstrumentType.M.getKey(),
|
||||
RegistryUnit.F.getKey(),
|
||||
currentRegistry.getTradingClearingRegistryId(),
|
||||
currentRegistry.getCompanyId());
|
||||
Registry counterRegistry = registryImdg.getSingleObjectBySQL(sqlCounterRegistryCondition);
|
||||
if (currentRegistry.getBalance().compareTo(counterRegistry.getBalance()) > 0) {
|
||||
log.warn("{}", msgResolver.resolve(new EnumMessage(ClearingError.InsecurityObligation, currentRegistry.getCompanyId())));
|
||||
insecurityGroups.add(currentRegistry.getGroupId());
|
||||
break;
|
||||
}
|
||||
currentRegistry.setRegistryStatus("OK");
|
||||
registryImdg.update(counterRegistry);
|
||||
if (IEnumKey.getEnumByKey(RegistryDesignation.class, currentRegistry.getRegistryDesignation()) == RegistryDesignation.O) {
|
||||
log.debug("Its t registry, skip");
|
||||
continue;
|
||||
}
|
||||
|
||||
RegistryTradingParams counterRegistryTradingParams = null;
|
||||
if (IEnumKey.getEnumByKey(RegistryDesignation.class, currentRegistry.getRegistryDesignation()) == RegistryDesignation.O
|
||||
&& IEnumKey.getEnumByKey(RegistryInstrumentType.class, currentRegistry.getRegistryInstrumentType()) == RegistryInstrumentType.S) {
|
||||
counterRegistryTradingParams = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
} else if (IEnumKey.getEnumByKey(RegistryDesignation.class, currentRegistry.getRegistryDesignation()) == RegistryDesignation.O
|
||||
&& IEnumKey.getEnumByKey(RegistryInstrumentType.class, currentRegistry.getRegistryInstrumentType()) == RegistryInstrumentType.M) {
|
||||
counterRegistryTradingParams = new RegistryTradingParams(RegistryDesignation.A,
|
||||
RegistryInstrumentType.M,
|
||||
null,
|
||||
RegistryUnit.F);
|
||||
}
|
||||
|
||||
String sqlCounterRegistryCondition = String.format("%s and " +
|
||||
"tradingClearingRegistryId = '%s' and " +
|
||||
"companyId = '%s' and ",
|
||||
RegistryCodeSqlBuilder.getInstance(counterRegistryTradingParams).build(),
|
||||
currentRegistry.getTradingClearingRegistryId(),
|
||||
currentRegistry.getCompanyId());
|
||||
Registry counterRegistry = registryImdg.getSingleObjectBySQL(sqlCounterRegistryCondition);
|
||||
if (currentRegistry.getBalance().compareTo(counterRegistry.getBalance()) > 0) {
|
||||
log.warn("{}", msgResolver.resolve(new EnumMessage(ClearingError.InsecurityObligation, currentRegistry.getCompanyId())));
|
||||
currentRegistry.setRegistryStatus("UNCV");
|
||||
alreadyUpdatedToUncover.add(currentRegistry.getId());
|
||||
insecurityGroups.add(currentRegistry.getGroupId());
|
||||
registryImdg.update(currentRegistry);
|
||||
continue;
|
||||
}
|
||||
currentRegistry.setRegistryStatus("OK");
|
||||
registryImdg.update(currentRegistry);
|
||||
}
|
||||
|
||||
for (Long insecuritiesGroupId : insecurityGroups) {
|
||||
for (Map.Entry<Long, List<Registry>> entrySet : registryByGroupIdAndCompanyId.get(insecuritiesGroupId).entrySet()) {
|
||||
if (entrySet.getKey().equals(processedCompanyId)) {
|
||||
for (Registry registry : entrySet.getValue()) {
|
||||
registry.setRegistryStatus("UNCV");
|
||||
registryImdg.update(registry);
|
||||
}
|
||||
} else {
|
||||
for (Registry registry : entrySet.getValue()) {
|
||||
if (!insecurityGroups.isEmpty()) {
|
||||
for (Long insecuritiesGroupId : insecurityGroups) {
|
||||
for (Registry registry : registryByGroupIdAndCompanyId.get(insecuritiesGroupId)) {
|
||||
if (!alreadyUpdatedToUncover.contains(registry)) {
|
||||
registry.setRegistryStatus("FAIL");
|
||||
registryImdg.update(registry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new StageResult(null, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue