This commit is contained in:
parent
2e6e453f69
commit
42c0b6b9d1
7 changed files with 47 additions and 21 deletions
|
|
@ -158,13 +158,20 @@ public class CompanyValidationConfig {
|
|||
CorporationSoleTypeDictionary.class,
|
||||
CompanyErrors.RequiredFieldEmpty,
|
||||
CompanyErrors.DictionaryNotFound, false),
|
||||
DictionaryPresentRule.instance("CountryCode",
|
||||
CompanyInfoUpdateRequest::getCountryCode,
|
||||
IdPresentRule.instance("CountryCodeId",
|
||||
CompanyInfoUpdateRequest::getCountryCodeId,
|
||||
IMDGDistributedNames.Map_CountryCodeDictionary,
|
||||
CountryCodeDictionary.class,
|
||||
CompanyErrors.RequiredFieldEmpty,
|
||||
CompanyErrors.DictionaryNotFound,
|
||||
false),
|
||||
DictionaryPresentRule.instance("CountryCode",
|
||||
CompanyInfoUpdateRequest::getCountryCode,
|
||||
IMDGDistributedNames.Map_CountryCodeDictionary,
|
||||
CountryCodeDictionary.class,
|
||||
CompanyErrors.RequiredFieldEmpty,
|
||||
CompanyErrors.DictionaryNotFound,
|
||||
false),
|
||||
DictionaryPresentRule.instance("ProfessionalSign",
|
||||
CompanyInfoUpdateRequest::getProfessionalSign,
|
||||
IMDGDistributedNames.Map_AllowedDictionary,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package ru.spcex.clearing.company.service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
|
|
@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.profile.CompanyInfo;
|
||||
import ru.clearing.platform.dictionary.CountryCodeDictionary;
|
||||
import ru.spcex.clearing.company.error.CompanyErrors;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
|
|
@ -27,15 +31,12 @@ import ru.spcex.platform.imdg.api.ImdgTransaction;
|
|||
import ru.spcex.platform.utils.error.ValidationException;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Service
|
||||
public class CompanyInfoService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final ImdgProvider imdgProvider;
|
||||
private final Imdg<Company> companyMap;
|
||||
private final Imdg<CountryCodeDictionary> countryCodeDictionaryImdg;
|
||||
protected final CompanyService companyService;
|
||||
private final RequestHelper requestHelper;
|
||||
private final ValidationHelper validationHelper;
|
||||
|
|
@ -53,6 +54,7 @@ public class CompanyInfoService extends QueueConsumer implements InitializingBea
|
|||
this.companyService = companyService;
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
this.countryCodeDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_CountryCodeDictionary, CountryCodeDictionary.class);
|
||||
this.validationHelper = validationHelper;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.companyInfoUpdateRequestValidator = companyInfoUpdateRequestValidator;
|
||||
|
|
@ -87,6 +89,7 @@ public class CompanyInfoService extends QueueConsumer implements InitializingBea
|
|||
log.trace("Company {} not found", req.getId());
|
||||
return requestHelper.makeErrorResponse(companyInfoReq, CompanyErrors.CompanyNotFound, companyInfoReq.getId());
|
||||
}
|
||||
|
||||
company.setUpdated(Instant.now());
|
||||
if (StringUtils.isNotEmpty(req.getShortName()))
|
||||
company.setShortName(req.getShortName());
|
||||
|
|
@ -94,7 +97,12 @@ public class CompanyInfoService extends QueueConsumer implements InitializingBea
|
|||
company.setFullName(req.getFullName());
|
||||
CompanyInfo companyInfo = company.getProfile();
|
||||
|
||||
companyInfo.setCountryCode(req.getCountryCode());
|
||||
String countryCode = req.getCountryCode();
|
||||
if (req.getCountryCodeId() != null) {
|
||||
CountryCodeDictionary countryCodeDictionary = countryCodeDictionaryImdg.getSingleObjectByID(req.getCountryCodeId());
|
||||
countryCode = countryCodeDictionary.getCode();
|
||||
}
|
||||
companyInfo.setCountryCode(countryCode);
|
||||
companyInfo.setProfessionalSign(req.getProfessionalSign());
|
||||
companyInfo.setLegalKind(req.getLegalKind());
|
||||
companyInfo.setOrganizationType(req.getOrganizationType());
|
||||
|
|
|
|||
|
|
@ -161,10 +161,7 @@ public class MultiCompanyService
|
|||
}
|
||||
}
|
||||
|
||||
List<CompanySymbolNewRequest> companySymbolNewRequests = req.getCompanySymbols().stream()
|
||||
.filter(companySymbolNewRequest -> !companySymbolNewRequest.getCompanySymbol().equals("TAXN"))
|
||||
.toList();
|
||||
for (CompanySymbolNewRequest partRequest : companySymbolNewRequests) {
|
||||
for (CompanySymbolNewRequest partRequest : req.getCompanySymbols()) {
|
||||
CompanySymbols existSymbol = findCompanySymbols(partRequest);
|
||||
if (existSymbol == null) {
|
||||
log.trace("For company[{}] do new companySymbol", companyId);
|
||||
|
|
|
|||
|
|
@ -44,17 +44,21 @@ public class CompanyRequestAdapter {
|
|||
|
||||
public CompanyInfoUpdateRequest toCompanyInfoRequest(CompanyInfo companyInfo) {
|
||||
CompanyInfoUpdateRequest companyInfoUpdateRequest = new CompanyInfoUpdateRequest();
|
||||
String resCountryCode;
|
||||
switch (companyInfo.getCountryCode()) {
|
||||
case 643 -> resCountryCode = "RUS";
|
||||
case 998 -> resCountryCode = "WRLD";
|
||||
default -> resCountryCode = "XTRN";
|
||||
}
|
||||
companyInfoUpdateRequest.setCountryCode(resCountryCode);
|
||||
Long counterCodeId = Long.valueOf(companyInfo.getCountryCode());
|
||||
companyInfoUpdateRequest.setCountryCodeId(counterCodeId);
|
||||
companyInfoUpdateRequest.setProfessionalSign(companyInfo.getProfessionalSign());
|
||||
companyInfoUpdateRequest.setLegalKind(companyInfo.getLegalKind());
|
||||
companyInfoUpdateRequest.setOrganizationType(companyInfo.getOrganizationType());
|
||||
companyInfoUpdateRequest.setResidence(companyInfo.getResidence());
|
||||
|
||||
String residence;
|
||||
if (counterCodeId == 643L) {
|
||||
residence = "RUS";
|
||||
} else if (counterCodeId == 998L) {
|
||||
residence = "WRLD";
|
||||
} else {
|
||||
residence = "XTRN";
|
||||
}
|
||||
companyInfoUpdateRequest.setResidence(residence);
|
||||
return companyInfoUpdateRequest;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class CompanyHistoryMapStore extends BusinessEventMapStore<CompanyHistory
|
|||
}
|
||||
}
|
||||
batchInsertUpdate(insertStatement, batchArgs);
|
||||
batchInsertUpdate(insertCompanyInfoStatement, batchCompanyInfoArgs);
|
||||
batchInsertUpdate(insertCompanyInfoStatement, batchCompanyInfoArgs, "COMPANY_INFO_HISTORY", getFieldsForCompanyInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class CompanyMapStore extends BusinessObjectMapStore<Company> {
|
|||
}
|
||||
}
|
||||
batchInsertUpdate(insertStatement, batchArgs);
|
||||
batchInsertUpdate(insertCompanyInfoStatement, batchCompanyInfoArgs);
|
||||
batchInsertUpdate(insertCompanyInfoStatement, batchCompanyInfoArgs, "COMPANY_INFO", getFieldsForCompanyInfo());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ public class CompanyInfoUpdateRequest {
|
|||
@JsonProperty
|
||||
private String countryCode;
|
||||
@JsonProperty
|
||||
private Long countryCodeId;
|
||||
@JsonProperty
|
||||
private String description;
|
||||
@JsonProperty
|
||||
private String professionalSign;
|
||||
|
|
@ -66,6 +68,14 @@ public class CompanyInfoUpdateRequest {
|
|||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
public Long getCountryCodeId() {
|
||||
return countryCodeId;
|
||||
}
|
||||
|
||||
public void setCountryCodeId(Long countryCodeId) {
|
||||
this.countryCodeId = countryCodeId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue