company-service http://jira.mfd.msk:8088/browse/CLS-272 доделал коммент к таску 27/апр/23 16:24

This commit is contained in:
AKurakin 2023-05-04 17:10:55 +03:00
parent 864bbcf125
commit b6eb7a9d71
3 changed files with 24 additions and 47 deletions

View file

@ -68,16 +68,6 @@ public class ClientCodeValidationConfig {
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId()) acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
? null : CompanyErrors.AccountNotFound ? null : CompanyErrors.AccountNotFound
), ),
IdPresentRule.instance("tradingClearingRegistryId",
ClientCodeNewRequest::getTradingClearingRegistryId,
IMDGDistributedNames.Map_TradingClearingRegistry,
TradingClearingRegistry.class,
CompanyErrors.RequiredFieldEmpty,
CompanyErrors.TradingClearingRegistryNotFound,
false,
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
? null : CompanyErrors.TradingClearingRegistryNotFound
),
DictionaryPresentRule.instance("stauts", DictionaryPresentRule.instance("stauts",
@ -139,16 +129,6 @@ public class ClientCodeValidationConfig {
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId()) acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
? null : CompanyErrors.AccountNotFound ? null : CompanyErrors.AccountNotFound
), ),
IdPresentRule.instance("tradingClearingRegistryId",
ClientCodeUpdateRequest::getTradingClearingRegistryId,
IMDGDistributedNames.Map_TradingClearingRegistry,
TradingClearingRegistry.class,
CompanyErrors.RequiredFieldEmpty,
CompanyErrors.TradingClearingRegistryNotFound,
false,
acc -> Objects.equals(context.getValidatedObject().getCompanyId(), acc.getCompanyId())
? null : CompanyErrors.TradingClearingRegistryNotFound
),
DictionaryPresentRule.instance("stauts", DictionaryPresentRule.instance("stauts",
ClientCodeUpdateRequest::getStatus, ClientCodeUpdateRequest::getStatus,

View file

@ -147,14 +147,6 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
} }
} }
if (req.getTradingClearingRegistryId() == null && req.getMoneyAccountId() != null) {
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
if (tradingClearingRegistry == null) {
return makeErrorResponse(userRequest, CompanyErrors.TradingClearingRegistryNotFound);
} else {
req.setTradingClearingRegistryId(tradingClearingRegistry.getId());
}
}
ClientCode newClientCode = buildClientCode(req); ClientCode newClientCode = buildClientCode(req);
clientCodeMap.insert(newClientCode); clientCodeMap.insert(newClientCode);
log.debug("successfully processed, new clientCode id {}", newClientCode.getId()); log.debug("successfully processed, new clientCode id {}", newClientCode.getId());
@ -188,14 +180,6 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
} }
} }
if (req.getTradingClearingRegistryId() == null && req.getMoneyAccountId() != null) {
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
if (tradingClearingRegistry == null) {
return makeErrorResponse(userRequest, CompanyErrors.TradingClearingRegistryNotFound);
} else {
req.setTradingClearingRegistryId(tradingClearingRegistry.getId());
}
}
ClientCode newClientCode = buildClientCode(req); ClientCode newClientCode = buildClientCode(req);
clientCodeMap.insert(newClientCode); clientCodeMap.insert(newClientCode);
log.debug("successfully processed, new clientCode id {}", newClientCode.getId()); log.debug("successfully processed, new clientCode id {}", newClientCode.getId());
@ -233,14 +217,6 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
} }
} }
if (req.getTradingClearingRegistryId() == null && req.getMoneyAccountId() != null) {
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
if (tradingClearingRegistry == null) {
return makeErrorResponse(userRequest, CompanyErrors.TradingClearingRegistryNotFound);
} else {
req.setTradingClearingRegistryId(tradingClearingRegistry.getId());
}
}
updateClientCode(clientCode, req); updateClientCode(clientCode, req);
clientCodeMap.update(clientCode); clientCodeMap.update(clientCode);
@ -392,7 +368,17 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
clientCode.setCompanyId(req.getCompanyId()); clientCode.setCompanyId(req.getCompanyId());
clientCode.setCode(req.getCode()); clientCode.setCode(req.getCode());
clientCode.setTradingClearingRegistryId(req.getTradingClearingRegistryId());
if (req.getMoneyAccountId() != null) {
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
if (tradingClearingRegistry == null) {
log.warn("TCR not found: CompanyId {}, MoneyAccountId {}, DepoAccountId {}",
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
} else {
clientCode.setTradingClearingRegistryId(tradingClearingRegistry.getId());
}
}
clientCode.setMoneyAccountId(req.getMoneyAccountId()); clientCode.setMoneyAccountId(req.getMoneyAccountId());
clientCode.setDepoAccountId(req.getDepoAccountId()); clientCode.setDepoAccountId(req.getDepoAccountId());
clientCode.setStatus(req.getStatus()); clientCode.setStatus(req.getStatus());
@ -405,6 +391,17 @@ public class ClientCodeService extends QueueConsumer implements InitializingBean
clientCode.setCompanyId(req.getCompanyId()); clientCode.setCompanyId(req.getCompanyId());
clientCode.setCode(req.getCode()); clientCode.setCode(req.getCode());
if (req.getMoneyAccountId() != null) {
TradingClearingRegistry tradingClearingRegistry = selectTradingClearingRegistry(req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
if (tradingClearingRegistry == null) {
log.warn("TCR not found: CompanyId {}, MoneyAccountId {}, DepoAccountId {}",
req.getCompanyId(), req.getMoneyAccountId(), req.getDepoAccountId());
} else {
clientCode.setTradingClearingRegistryId(tradingClearingRegistry.getId());
}
}
clientCode.setTradingClearingRegistryId(req.getTradingClearingRegistryId()); clientCode.setTradingClearingRegistryId(req.getTradingClearingRegistryId());
clientCode.setMoneyAccountId(req.getMoneyAccountId()); clientCode.setMoneyAccountId(req.getMoneyAccountId());
clientCode.setDepoAccountId(req.getDepoAccountId()); clientCode.setDepoAccountId(req.getDepoAccountId());

View file

@ -184,7 +184,7 @@ class ClientCodeServiceTest {
predictableClientCode.setCompanyId(COMPANY_ID); predictableClientCode.setCompanyId(COMPANY_ID);
// predictableClientCode.setMoneyAccountId(131L); // predictableClientCode.setMoneyAccountId(131L);
// predictableClientCode.setDepoAccountId(132L); // predictableClientCode.setDepoAccountId(132L);
predictableClientCode.setTradingClearingRegistryId(TCR_ID); // predictableClientCode.setTradingClearingRegistryId(TCR_ID);
//ACT //ACT
String jsonString = getJsonStringForNew(clientCodeNewRequest, ID); String jsonString = getJsonStringForNew(clientCodeNewRequest, ID);
@ -222,7 +222,7 @@ class ClientCodeServiceTest {
predictableClientCode.setCompanyId(COMPANY_ID); predictableClientCode.setCompanyId(COMPANY_ID);
// predictableClientCode.setMoneyAccountId(131L); // predictableClientCode.setMoneyAccountId(131L);
// predictableClientCode.setDepoAccountId(132L); // predictableClientCode.setDepoAccountId(132L);
predictableClientCode.setTradingClearingRegistryId(TCR_ID); // predictableClientCode.setTradingClearingRegistryId(TCR_ID);
//ACT //ACT
String jsonString = getJsonStringForNew(clientCodeNewRequest, ID); String jsonString = getJsonStringForNew(clientCodeNewRequest, ID);