company-service gateway-api http://jira.mfd.msk:8088/browse/CLS-347 bug fix, правки поиска
This commit is contained in:
parent
8a2855e32b
commit
2ee26a3d68
6 changed files with 87 additions and 15 deletions
|
|
@ -179,7 +179,11 @@ public class ClearingMemberCategoryService extends QueueConsumer implements Init
|
||||||
try {
|
try {
|
||||||
Imdg<ClearingMemberCategory> txClearingMemberCategoryMap = transaction.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
Imdg<ClearingMemberCategory> txClearingMemberCategoryMap = transaction.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||||
txClearingMemberCategoryMap.delete(clearingMemberCategory); // далить до cancelRelation внутри транзакции
|
txClearingMemberCategoryMap.delete(clearingMemberCategory); // далить до cancelRelation внутри транзакции
|
||||||
companyService.relationService.cancelRelation(transaction, clearingMemberCategory.getCompanyId(), clearingMemberCategory);
|
if (clearingMemberCategory.getCompanyId() == null) { // never, только тестовые данные
|
||||||
|
log.warn("Deleted clearingMemberCategory[{}] has not companyId", clearingMemberCategory.getId());
|
||||||
|
} else {
|
||||||
|
companyService.relationService.cancelRelation(transaction, clearingMemberCategory.getCompanyId(), clearingMemberCategory);
|
||||||
|
}
|
||||||
txOk = true;
|
txOk = true;
|
||||||
} finally {
|
} finally {
|
||||||
if (txOk)
|
if (txOk)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||||
import ru.spcex.platform.enumeration.CompanySymbol;
|
import ru.spcex.platform.enumeration.CompanySymbol;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||||
import ru.spcex.platform.utils.error.ValidationException;
|
import ru.spcex.platform.utils.error.ValidationException;
|
||||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||||
|
|
@ -48,7 +49,7 @@ public class MultiCompanyService
|
||||||
private final RequestHelper requestHelper;
|
private final RequestHelper requestHelper;
|
||||||
|
|
||||||
protected UserRoleVerification userRoleVerification;
|
protected UserRoleVerification userRoleVerification;
|
||||||
// private final ValidationHelper validationHelper;
|
// private final ValidationHelper validationHelper;
|
||||||
protected IMessageResolver messageResolver;
|
protected IMessageResolver messageResolver;
|
||||||
|
|
||||||
final CompanyService companyService;
|
final CompanyService companyService;
|
||||||
|
|
@ -128,7 +129,7 @@ public class MultiCompanyService
|
||||||
req.setCompanySymbols(
|
req.setCompanySymbols(
|
||||||
Stream.concat(req.getCompanySymbols().stream(), additionalSymbols(req.getCompany())).collect(Collectors.toList())
|
Stream.concat(req.getCompanySymbols().stream(), additionalSymbols(req.getCompany())).collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
companyId = getCompanyIdForCompanySymbols(req.getUuid(), req.getCompany());
|
companyId = getCompanyIdForCompanySymbols(req.getUuid(), req.getCompany(), req.getCompanySymbols());
|
||||||
log.debug("For request {} (uuid {}) company {}.", baseRequest.getId(), req.getUuid(), companyId == null ? "not found" : ("found, id=" + companyId));
|
log.debug("For request {} (uuid {}) company {}.", baseRequest.getId(), req.getUuid(), companyId == null ? "not found" : ("found, id=" + companyId));
|
||||||
if (companyId == null) {
|
if (companyId == null) {
|
||||||
log.debug("For request {} (uuid {}) company not found. Try find by other symbols.", baseRequest.getId(), req.getUuid());
|
log.debug("For request {} (uuid {}) company not found. Try find by other symbols.", baseRequest.getId(), req.getUuid());
|
||||||
|
|
@ -334,7 +335,7 @@ public class MultiCompanyService
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Long getCompanyIdForCompanySymbols(String uuid, CompanyNewRequest cnr) {
|
Long getCompanyIdForCompanySymbols(String uuid, CompanyNewRequest cnr, Collection<CompanySymbolNewRequest> companySymbols) {
|
||||||
CompanySymbols companySymbol = null;
|
CompanySymbols companySymbol = null;
|
||||||
if (StringUtils.isNotEmpty(uuid)) {
|
if (StringUtils.isNotEmpty(uuid)) {
|
||||||
log.trace("Search company by companySymbol uuid={}", uuid);
|
log.trace("Search company by companySymbol uuid={}", uuid);
|
||||||
|
|
@ -351,10 +352,10 @@ public class MultiCompanyService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (companySymbol == null && StringUtils.isNotEmpty(cnr.getCompanySymbolValue())) {
|
if (companySymbol == null && StringUtils.isNotEmpty(cnr.getCompanySymbolValue())
|
||||||
for (String companySymbolType : Arrays.asList(
|
&& IEnumKey.contains(cnr.getCompanySymbol(), CompanySymbol.INN, CompanySymbol.CIO)) { // вероятно там будет только UUID
|
||||||
cnr.getCompanySymbol(), CompanySymbol.INN.getKey(), CompanySymbol.CIO.getKey()
|
{
|
||||||
)) {
|
String companySymbolType = cnr.getCompanySymbol();
|
||||||
log.trace("Search company by companySymbol {}={}", companySymbolType, cnr.getCompanySymbolValue());
|
log.trace("Search company by companySymbol {}={}", companySymbolType, cnr.getCompanySymbolValue());
|
||||||
Collection<CompanySymbols> companySymbolsFromImdg = companySymbolsImdg.getCollectionObjectsByFieldValues(
|
Collection<CompanySymbols> companySymbolsFromImdg = companySymbolsImdg.getCollectionObjectsByFieldValues(
|
||||||
Map.of(
|
Map.of(
|
||||||
|
|
@ -367,10 +368,31 @@ public class MultiCompanyService
|
||||||
if (companySymbolsFromImdg.size() > 1) {
|
if (companySymbolsFromImdg.size() > 1) {
|
||||||
log.warn("For {} found > 1 company_symbols, use first (id = {})", companySymbolType, cnr.getCompanySymbolValue());
|
log.warn("For {} found > 1 company_symbols, use first (id = {})", companySymbolType, cnr.getCompanySymbolValue());
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (companySymbol == null && companySymbols != null) {
|
||||||
|
for (CompanySymbolNewRequest cSymbolReq : companySymbols) {
|
||||||
|
if (IEnumKey.contains(cSymbolReq.getCompanySymbol(), CompanySymbol.INN, CompanySymbol.CIO)) {
|
||||||
|
String companySymbolType = cSymbolReq.getCompanySymbol();
|
||||||
|
log.trace("Search company by companySymbol {}={}", companySymbolType, cSymbolReq.getCompanySymbolValue());
|
||||||
|
Collection<CompanySymbols> companySymbolsFromImdg = companySymbolsImdg.getCollectionObjectsByFieldValues(
|
||||||
|
Map.of(
|
||||||
|
"companySymbol", companySymbolType,
|
||||||
|
"companySymbolValue", cSymbolReq.getCompanySymbolValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!companySymbolsFromImdg.isEmpty()) {
|
||||||
|
companySymbol = companySymbolsFromImdg.iterator().next();
|
||||||
|
if (companySymbolsFromImdg.size() > 1) {
|
||||||
|
log.warn("For {} found > 1 company_symbols, use first (id = {})", companySymbolType, cSymbolReq.getCompanySymbolValue());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (companySymbol != null)
|
if (companySymbol != null)
|
||||||
return companySymbol.getCompanyId();
|
return companySymbol.getCompanyId();
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,7 @@ class ClearingMemberCategoryServiceTest {
|
||||||
String clearingMemberCategory = "0000";
|
String clearingMemberCategory = "0000";
|
||||||
ClearingMemberCategory existsClearingMemberCategory = new ClearingMemberCategory();
|
ClearingMemberCategory existsClearingMemberCategory = new ClearingMemberCategory();
|
||||||
existsClearingMemberCategory.setClearingMemberCategory(clearingMemberCategory);
|
existsClearingMemberCategory.setClearingMemberCategory(clearingMemberCategory);
|
||||||
|
existsClearingMemberCategory.setCompanyId(COMPANY_ID);
|
||||||
Long id = memberCategoryImdg.insert(existsClearingMemberCategory);
|
Long id = memberCategoryImdg.insert(existsClearingMemberCategory);
|
||||||
|
|
||||||
CommonDeleteRequest memberCategoryDeleteRequest = new CommonDeleteRequest();
|
CommonDeleteRequest memberCategoryDeleteRequest = new CommonDeleteRequest();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProviderAndAddAdminWithDefaultId;
|
import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProviderAndAddAdminWithDefaultId;
|
||||||
|
|
@ -48,6 +50,8 @@ import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProv
|
||||||
ProfileDocumentValidationConfig.class,
|
ProfileDocumentValidationConfig.class,
|
||||||
ContactService.class,
|
ContactService.class,
|
||||||
ContactValidationConfig.class,
|
ContactValidationConfig.class,
|
||||||
|
ClearingMemberCategoryService.class,
|
||||||
|
ClearingMemberCategoryValidationConfig.class,
|
||||||
|
|
||||||
KafkaTestConfig.class,
|
KafkaTestConfig.class,
|
||||||
ImdgTestConfig.class,
|
ImdgTestConfig.class,
|
||||||
|
|
@ -101,8 +105,8 @@ class MultiCompanyServiceTest {
|
||||||
CompanySymbols companySymbol = new CompanySymbols();
|
CompanySymbols companySymbol = new CompanySymbols();
|
||||||
companySymbol.setId(222L);
|
companySymbol.setId(222L);
|
||||||
companySymbol.setCompanyId(company.getId());
|
companySymbol.setCompanyId(company.getId());
|
||||||
companySymbol.setCompanySymbol(CompanySymbol.CLRC.getKey());
|
companySymbol.setCompanySymbol(CompanySymbol.INN.getKey());
|
||||||
companySymbol.setCompanySymbolValue("CL-VALUE");
|
companySymbol.setCompanySymbolValue("INN-VALUE");
|
||||||
companySymbolsImdg.insert(companySymbol);
|
companySymbolsImdg.insert(companySymbol);
|
||||||
|
|
||||||
Imdg<ProfileDocument> profileDocumentImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_ProfileDocument, ProfileDocument.class);
|
Imdg<ProfileDocument> profileDocumentImdg = hazelcastServiceTest.getImdg(IMDGDistributedNames.Map_ProfileDocument, ProfileDocument.class);
|
||||||
|
|
@ -130,9 +134,13 @@ class MultiCompanyServiceTest {
|
||||||
req.setCompanyId(COMPANY_ID);
|
req.setCompanyId(COMPANY_ID);
|
||||||
req.setCompanySymbol(CompanySymbol.CLRC.getKey());
|
req.setCompanySymbol(CompanySymbol.CLRC.getKey());
|
||||||
req.setCompanySymbolValue("CL-VALUE-2");
|
req.setCompanySymbolValue("CL-VALUE-2");
|
||||||
|
assertNull(multiCompanyService.findCompanySymbols(req));
|
||||||
|
|
||||||
|
req.setCompanySymbol(CompanySymbol.INN.getKey());
|
||||||
|
req.setCompanySymbolValue("INN-VALUE");
|
||||||
CompanySymbols symbol = multiCompanyService.findCompanySymbols(req);
|
CompanySymbols symbol = multiCompanyService.findCompanySymbols(req);
|
||||||
assertNotNull(symbol);
|
assertNotNull(symbol);
|
||||||
assertEquals("CL-VALUE", symbol.getCompanySymbolValue());
|
assertEquals("INN-VALUE", symbol.getCompanySymbolValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -151,8 +159,32 @@ class MultiCompanyServiceTest {
|
||||||
CompanyNewRequest req = new CompanyNewRequest();
|
CompanyNewRequest req = new CompanyNewRequest();
|
||||||
req.setCompanySymbol(CompanySymbol.CLRC.getKey());
|
req.setCompanySymbol(CompanySymbol.CLRC.getKey());
|
||||||
req.setCompanySymbolValue("CL-VALUE");
|
req.setCompanySymbolValue("CL-VALUE");
|
||||||
Long theId = multiCompanyService.getCompanyIdForCompanySymbols("SAMPLE-NO-uuid", req);
|
assertNull(multiCompanyService.getCompanyIdForCompanySymbols("SAMPLE-NO-uuid", req, null));
|
||||||
assertEquals(COMPANY_ID, theId);
|
|
||||||
|
req.setCompanySymbolValue("INN-VALUE");
|
||||||
|
assertNull(multiCompanyService.getCompanyIdForCompanySymbols("SAMPLE-NO-uuid", req, null));
|
||||||
|
req.setCompanySymbol(CompanySymbol.INN.getKey());
|
||||||
|
assertEquals(COMPANY_ID, multiCompanyService.getCompanyIdForCompanySymbols("SAMPLE-NO-uuid", req, null));
|
||||||
|
req.setCompanySymbol(null);
|
||||||
|
req.setCompanySymbolValue(null);
|
||||||
|
assertNull(multiCompanyService.getCompanyIdForCompanySymbols(null, req, null));
|
||||||
|
List<CompanySymbolNewRequest> csReq=new ArrayList<>();
|
||||||
|
assertNull(multiCompanyService.getCompanyIdForCompanySymbols(null, req, null));
|
||||||
|
assertNull(multiCompanyService.getCompanyIdForCompanySymbols(null, req, csReq));
|
||||||
|
{
|
||||||
|
CompanySymbolNewRequest cs=new CompanySymbolNewRequest();
|
||||||
|
cs.setCompanySymbol(CompanySymbol.CLRC.getKey());
|
||||||
|
cs.setCompanySymbolValue("INN-VALUE");
|
||||||
|
csReq.add(cs);
|
||||||
|
}
|
||||||
|
assertNull(multiCompanyService.getCompanyIdForCompanySymbols(null, req, csReq));
|
||||||
|
{
|
||||||
|
CompanySymbolNewRequest cs=new CompanySymbolNewRequest();
|
||||||
|
cs.setCompanySymbol(CompanySymbol.INN.getKey());
|
||||||
|
cs.setCompanySymbolValue("INN-VALUE");
|
||||||
|
csReq.add(cs);
|
||||||
|
}
|
||||||
|
assertEquals(COMPANY_ID, multiCompanyService.getCompanyIdForCompanySymbols(null, req, csReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import ru.clearing.classes.statics.data.company.Company;
|
import ru.clearing.classes.statics.data.company.Company;
|
||||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||||
import ru.clearing.platform.dictionary.ClearingCategoryDictionary;
|
import ru.clearing.platform.dictionary.ClearingCategoryDictionary;
|
||||||
|
import ru.clearing.platform.dictionary.ServiceStatusDictionary;
|
||||||
import ru.clearing.platform.dictionary.WorkflowStatusDictionary;
|
import ru.clearing.platform.dictionary.WorkflowStatusDictionary;
|
||||||
import ru.spcex.clearing.company.config.BeanConfiguration;
|
import ru.spcex.clearing.company.config.BeanConfiguration;
|
||||||
import ru.spcex.clearing.company.config.validation.RelationValidationConfig;
|
import ru.spcex.clearing.company.config.validation.RelationValidationConfig;
|
||||||
|
|
@ -92,6 +93,18 @@ class RelationServiceTest {
|
||||||
workflowStatusDictionary.setName("not active");
|
workflowStatusDictionary.setName("not active");
|
||||||
workflowStatusDictionaryImdg.insert(workflowStatusDictionary);
|
workflowStatusDictionaryImdg.insert(workflowStatusDictionary);
|
||||||
|
|
||||||
|
{
|
||||||
|
Imdg<ServiceStatusDictionary> serviceStatusDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||||
|
IMDGDistributedNames.Map_ServiceStatusDictionary,
|
||||||
|
ServiceStatusDictionary.class
|
||||||
|
);
|
||||||
|
ServiceStatusDictionary status=new ServiceStatusDictionary();
|
||||||
|
status.setId(1L);
|
||||||
|
status.setCode("ACTV");
|
||||||
|
status.setName("\"ACTV\"");
|
||||||
|
serviceStatusDictionaryImdg.insert(status);
|
||||||
|
}
|
||||||
|
|
||||||
Imdg<ClearingCategoryDictionary> clearingCategoryDictionaryImdg = hazelcastServiceTest.getImdg(
|
Imdg<ClearingCategoryDictionary> clearingCategoryDictionaryImdg = hazelcastServiceTest.getImdg(
|
||||||
IMDGDistributedNames.Map_ClearingCategoryDictionary,
|
IMDGDistributedNames.Map_ClearingCategoryDictionary,
|
||||||
ClearingCategoryDictionary.class
|
ClearingCategoryDictionary.class
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class CompanyRequestAdapter {
|
||||||
log.warn("Money account \"{}\" not found", client.getMoneyAccount());
|
log.warn("Money account \"{}\" not found", client.getMoneyAccount());
|
||||||
} else {
|
} else {
|
||||||
log.debug("Money account \"{}\" found with id={}", client.getMoneyAccount(), mAccount.getId());
|
log.debug("Money account \"{}\" found with id={}", client.getMoneyAccount(), mAccount.getId());
|
||||||
client.setDepoAccountId(mAccount.getId());
|
client.setMoneyAccountId(mAccount.getId());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Error happened when search money account \"{}\": {}", client.getMoneyAccount(), ExceptionUtils.getStackTrace(e));
|
log.warn("Error happened when search money account \"{}\": {}", client.getMoneyAccount(), ExceptionUtils.getStackTrace(e));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue