Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
8f7a64122c
11 changed files with 66 additions and 13 deletions
|
|
@ -166,8 +166,8 @@ public class AccountValidationConfig {
|
|||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
account -> {
|
||||
if (WorkflowStatus.Active.equalsByKey(account.getStatus())) return null;
|
||||
return AccountError.AccountNotActive;
|
||||
if (AccountStatus.BLOCKED.equalsByKey(account.getStatus())) return AccountError.AccountNotActive;
|
||||
return null;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ public class TradingClearingRegistryValidationConfig {
|
|||
Imdg<InformationAccount> informationAccountImdg = context.obtainMap(
|
||||
IMDGDistributedNames.Map_InformationAccount, InformationAccount.class
|
||||
);
|
||||
InformationAccount infoAccount = informationAccountImdg.getSingleObjectByID(moneyAccountId);
|
||||
InformationAccount infoAccount = informationAccountImdg.getSingleObjectByFieldValues(
|
||||
Map.of("accountId",moneyAccountId));
|
||||
if (infoAccount == null) return AccountError.AccountNotFound;
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,11 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
account.setCompanyId(req.getCompanyId());
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(req.getAccountType());
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
if (req.getStatus() == null) {
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
} else {
|
||||
account.setStatus(req.getStatus());
|
||||
}
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import ru.spcex.clearing.util.security.UserRoleVerification;
|
|||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.ServiceStatus;
|
||||
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
|
|
@ -101,7 +102,7 @@ public class BankAccountService extends QueueConsumer implements InitializingBea
|
|||
Account account = new Account();
|
||||
account.setAccount(req.getAccount());
|
||||
account.setAccountType(AccountType.Bank.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setStatus(WorkflowStatus.Active.getKey());
|
||||
account.setCompanyId(req.getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
|
|
|
|||
|
|
@ -232,12 +232,13 @@ public class ClearingAccountService extends QueueConsumer implements Initializin
|
|||
clearingAccount.setAccountId(accountId);
|
||||
clearingAccount.setClearingAccountType(accountReq.getAccountType());
|
||||
clearingAccountId = clearingAccountImdg.insert(clearingAccount);
|
||||
log.trace("New account {}, clearingAccount {} was created.", accountId, clearingAccountId);
|
||||
log.debug("New account {}, clearingAccount {} was created.", accountId, clearingAccountId);
|
||||
|
||||
{
|
||||
TradingClearingRegistryNewRequest request = new TradingClearingRegistryNewRequest();
|
||||
request.setMoneyAccountId(accountId);
|
||||
request.setCompanyId(clearingAccount.getCompanyId());
|
||||
// request.setTradingClearingRegistryType(cl);
|
||||
toTCRRequests.add(request);
|
||||
}
|
||||
{
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class InformationAccountService extends QueueConsumer implements Initiali
|
|||
Account account = new Account();
|
||||
account.setAccount(accountValue);
|
||||
account.setAccountType(AccountType.Info.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());
|
||||
account.setStatus(ServiceStatus.Active.getKey());//fixme !!!
|
||||
account.setCompanyId(userRequest.getRequestPayload().getCompanyId());
|
||||
account.setCreated(now);
|
||||
account.setUpdated(now);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,9 @@ public class StatementService extends QueueConsumer implements InitializingBean
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!doSomeone) {
|
||||
if (doSomeone) {
|
||||
log.debug("For table {} done.", table);
|
||||
} else {
|
||||
log.warn("No operation for request.id={}; statementRequest GroupId={}, table={}",
|
||||
systemRequest.getId(), statementRequest.getGroupId(), statementRequest.getTable());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@ import ru.spcex.platform.imdg.api.Imdg;
|
|||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicate;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
|
||||
@Service
|
||||
|
|
@ -54,7 +56,7 @@ public class Sdf04Executor extends AbstractExecutor<SDf04> {
|
|||
//обычно мы ищем по группу sdf04, здесь как будто всегда только одна запись, todo нужно прочекать этот момент
|
||||
log.debug("Process sdf04 record; sdf04.id: {}", sdf04.getId());
|
||||
Collection<Registry> registries = selectRegistryForSDF04(sdf04.getC_acc_deb());
|
||||
registries.forEach(registry -> unlockRegistry(registry, new BigDecimal(sdf04.getSum_deb())));
|
||||
registries.forEach(registry -> unlockRegistry(registry, parseString(sdf04.getSum_deb())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -78,6 +80,17 @@ public class Sdf04Executor extends AbstractExecutor<SDf04> {
|
|||
boolean unlockRegistry(Registry registry, BigDecimal value) {
|
||||
if (registry.getBalance() == null) registry.setBalance(BigDecimal.ZERO);
|
||||
registry.setBalance(registry.getBalance().subtract(value));
|
||||
registry.setUpdated(Instant.now());
|
||||
registryImdg.update(registry);
|
||||
return true;
|
||||
}
|
||||
|
||||
private BigDecimal parseString(String str) {
|
||||
try {
|
||||
return new BigDecimal(str);
|
||||
} catch (Throwable e) {
|
||||
log.warn(ExceptionUtils.getStackTrace(e));
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class Sdf08Executor extends AbstractExecutor<SDf08> {
|
||||
|
|
@ -89,6 +90,27 @@ public class Sdf08Executor extends AbstractExecutor<SDf08> {
|
|||
public void sendCommand(KafkaSender kafkaSender, Result result) {
|
||||
}
|
||||
|
||||
Company searchCompany(String depoCode) {
|
||||
String tradingCode;
|
||||
if (depoCode.length() < 4) {
|
||||
log.warn("Depocode='{}' too short. Can not search company.", depoCode);
|
||||
tradingCode = depoCode;
|
||||
} else {
|
||||
tradingCode = depoCode.substring(1, 4);
|
||||
while (tradingCode.length() > 1 && tradingCode.startsWith("0"))
|
||||
tradingCode = tradingCode.substring(1);
|
||||
}
|
||||
String query = "tradingCode LIKE '" + tradingCode + "'";
|
||||
Collection<Company> companys = companyImdg.getCollectionObjectsBySQL(query);
|
||||
log.trace("Selected {} record for sql: {}", companys.size(), query);
|
||||
if (companys.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (companys.size() > 1)
|
||||
log.warn("Found {} company's by tradingCode='{}'", companys.size(), tradingCode);
|
||||
return companys.iterator().next();
|
||||
}
|
||||
|
||||
public Result execute(Collection<SDf08> sdf, StatementRequest statementRequest) {
|
||||
Result result = new Result();
|
||||
Long generationIdForGroup = imdgProvider.getImdgIdGenerator().nextId();
|
||||
|
|
@ -99,7 +121,7 @@ public class Sdf08Executor extends AbstractExecutor<SDf08> {
|
|||
Account account = validator.getStored(ValidationStored.Sdf08Account);
|
||||
if (statementRequest.getAccountCreationResults().size() == 0
|
||||
&& ClearingErrorInternal.AccountNotPresent.equals(error.map(EnumMessage::getSubject).orElse(null))) {
|
||||
Company company = validator.getStored(ValidationStored.Sdf08Company);
|
||||
Company company = searchCompany(sdf08.getDepoCode()); // validator.getStored(ValidationStored.Sdf08Company);
|
||||
Long companyId = company == null ? null : company.getId(); // account == null сегда, т.к. кейс AccountNotPresent
|
||||
if (companyId == null) {
|
||||
log.warn("account {} for sdf08.id={} not found. Can not send request for creation, cause company not found too", sdf08.getDepoCode(), sdf08.getId());
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@ import ru.spcex.platform.utils.enumeration.EnumMessage;
|
|||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public enum Sdf08NewValidationRule implements IValidationRule<ImdgValidationContext<SDf08>> {
|
||||
@Deprecated // unused, см. тз по поиску компаний "III - Изменение statement по sDf08" 1.
|
||||
CompanyPresent() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<SDf08> context) {
|
||||
|
|
@ -37,8 +39,9 @@ public enum Sdf08NewValidationRule implements IValidationRule<ImdgValidationCont
|
|||
public Optional<EnumMessage> validate(ImdgValidationContext<SDf08> context) {
|
||||
SDf08 sdf08 = context.getValidatedObject();
|
||||
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
|
||||
Account acc = accountImdg.getSingleObjectBySQL("account = '" + sdf08.getDepoCode()
|
||||
+ "' and accountType='" + ru.spcex.platform.enumeration.AccountType.Depo.getKey() + "'");
|
||||
Account acc = accountImdg.getSingleObjectByFieldValues(Map.of(
|
||||
"account", sdf08.getDepoCode()
|
||||
, "accountType",ru.spcex.platform.enumeration.AccountType.Depo.getKey()));
|
||||
if (acc == null) {
|
||||
return of (ClearingErrorInternal.AccountNotPresent, sdf08.getDepoCode());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package ru.spcex.clearing.swt.importer.logic.stages;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
|
@ -15,6 +17,7 @@ import java.util.function.Supplier;
|
|||
|
||||
@Component
|
||||
public class SWTImportKafkaMessenger implements InitializingBean {
|
||||
final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final Supplier<KafkaSender> kafka;
|
||||
private final Map<ETable, Consumer<Long>> messengers;
|
||||
|
||||
|
|
@ -38,6 +41,8 @@ public class SWTImportKafkaMessenger implements InitializingBean {
|
|||
Consumer<Long> messenger = messengers.get(table);
|
||||
if (messenger != null) {
|
||||
messenger.accept(groupId);
|
||||
} else {
|
||||
log.debug("No message stage for table {}", table);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +50,8 @@ public class SWTImportKafkaMessenger implements InitializingBean {
|
|||
StatementRequest statementRequest = new StatementRequest();
|
||||
statementRequest.setGroupId(groupId);
|
||||
statementRequest.setTable(table);
|
||||
kafka.get().sendRequestToQueue(Consts.STATEMENT_PROCESS, statementRequest);
|
||||
Long rid = kafka.get().sendRequestToQueue(Consts.STATEMENT_PROCESS, statementRequest);
|
||||
log.debug("Send message id={}; groupId={}, table={} to kafka \"{}\"", rid, groupId, table, Consts.STATEMENT_PROCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue