PrepareMemberCompanies stage
This commit is contained in:
parent
70cb5b3da9
commit
d0409a243e
10 changed files with 124 additions and 64 deletions
|
|
@ -17,7 +17,7 @@ public class PipelineConfiguration {
|
||||||
public List<Stage<ListingsRequestParam>> listingsRequestPipeline(ImdgProvider imdgProvider, KafkaSender kafkaSender) {
|
public List<Stage<ListingsRequestParam>> listingsRequestPipeline(ImdgProvider imdgProvider, KafkaSender kafkaSender) {
|
||||||
List<Stage<ListingsRequestParam>> pipeline = new ArrayList<>();
|
List<Stage<ListingsRequestParam>> pipeline = new ArrayList<>();
|
||||||
pipeline.add(new PrepareSecurities());
|
pipeline.add(new PrepareSecurities());
|
||||||
pipeline.add(new PrepareCompanies());
|
pipeline.add(new PrepareIssuerCompanies());
|
||||||
pipeline.add(new ValidateIncomeSecurities());
|
pipeline.add(new ValidateIncomeSecurities());
|
||||||
pipeline.add(new ValidateIssuerCompanies());
|
pipeline.add(new ValidateIssuerCompanies());
|
||||||
pipeline.add(new CheckSecurityExist(imdgProvider));
|
pipeline.add(new CheckSecurityExist(imdgProvider));
|
||||||
|
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
package ru.spcex.clearing.gatewayapi.logic.companies;
|
|
||||||
|
|
||||||
import ru.spcex.clearing.gatewayapi.logic.ProcessResult;
|
|
||||||
import ru.spcex.clearing.gatewayapi.logic.Stage;
|
|
||||||
import ru.spcex.clearing.gatewayapi.request.CompaniesRequest;
|
|
||||||
import ru.spcex.clearing.gatewayapi.request.objects.*;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GroupingMemberCompanyParts extends Stage<CompaniesRequestParam> {
|
|
||||||
@Override
|
|
||||||
public ProcessResult process(CompaniesRequestParam param) {
|
|
||||||
CompaniesRequest request = param.getCompaniesRequest();
|
|
||||||
|
|
||||||
List<MemberCompany> companyList = request.getCompanyList();
|
|
||||||
List<MemberCompanyInfo> companyInfoList = request.getCompanyInfoList();
|
|
||||||
List<MemberCompanyClearingCategory> companyClearingCategoryList = request.getCompanyClearingCategoryList();
|
|
||||||
List<MemberCompanySymbols> memberCompanySymbolsList = request.getMemberCompanySymbolsList();
|
|
||||||
List<MemberContact> contactList = request.getContactList();
|
|
||||||
List<ProfileDocument> profileDocumentList = request.getProfileDocumentList();
|
|
||||||
List<Client> clientList = request.getClientList();
|
|
||||||
|
|
||||||
Map<UUID, MemberCompany> companyForUUID = new HashMap<>();
|
|
||||||
for (MemberCompany memberCompany : companyList) {
|
|
||||||
if (companyForUUID.put(memberCompany.getId(), memberCompany) != null) {
|
|
||||||
throw new IllegalStateException("Duplicate key");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MemberCompanyInfo companyInfo : companyInfoList) {
|
|
||||||
UUID companyInfoUUID = companyInfo.getCompanyId();
|
|
||||||
MemberCompany company = companyForUUID.get(companyInfoUUID);
|
|
||||||
if (company == null) {
|
|
||||||
// todo error
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
company.getCompanyInfoList().add(companyInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MemberCompanyClearingCategory companyClearingCategory : companyClearingCategoryList) {
|
|
||||||
// todo in progress
|
|
||||||
// UUID companyClearingCate
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
package ru.spcex.clearing.gatewayapi.logic.companies;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import ru.spcex.clearing.gatewayapi.logic.ProcessResult;
|
||||||
|
import ru.spcex.clearing.gatewayapi.logic.Stage;
|
||||||
|
import ru.spcex.clearing.gatewayapi.request.CompaniesRequest;
|
||||||
|
import ru.spcex.clearing.gatewayapi.request.objects.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PrepareMemberCompanies extends Stage<CompaniesRequestParam> {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProcessResult process(CompaniesRequestParam param) {
|
||||||
|
CompaniesRequest request = param.getCompaniesRequest();
|
||||||
|
|
||||||
|
List<MemberCompany> companyList = request.getCompanyList();
|
||||||
|
Map<UUID, MemberCompany> companyForUUID = new HashMap<>();
|
||||||
|
for (MemberCompany memberCompany : companyList) {
|
||||||
|
if (companyForUUID.containsKey(memberCompany.getId())) {
|
||||||
|
log.warn("For company.UUID {} found > 1 element from request, use first", memberCompany.getId());
|
||||||
|
memberCompany.setInvalidData(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
companyForUUID.put(memberCompany.getId(), memberCompany);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MemberCompanyInfo> companyInfoList = request.getCompanyInfoList();
|
||||||
|
for (MemberCompanyInfo companyInfo : companyInfoList) {
|
||||||
|
UUID companyInfoUUID = companyInfo.getCompanyId();
|
||||||
|
MemberCompany company = companyForUUID.get(companyInfoUUID);
|
||||||
|
if (company == null) {
|
||||||
|
log.warn("For companyInfo.UUID {} not found company, companyInfo skipped", companyInfoUUID);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
company.setCompanyInfo(companyInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MemberCompanySymbols> memberCompanySymbolsList = param.getCompaniesRequest().getMemberCompanySymbolsList();
|
||||||
|
for (MemberCompanySymbols memberCompanySymbols : memberCompanySymbolsList) {
|
||||||
|
UUID memberCompanySymbolsUUID = memberCompanySymbols.getCompanyId();
|
||||||
|
MemberCompany memberCompany = companyForUUID.get(memberCompanySymbolsUUID);
|
||||||
|
if (memberCompany == null) {
|
||||||
|
log.warn("For companySymbols ({} = {}) not found company, companySymbols skipped",
|
||||||
|
memberCompanySymbols.getCompanySymbol(),
|
||||||
|
memberCompanySymbols.getCompanySymbolValue());
|
||||||
|
memberCompanySymbols.setInvalidData(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
memberCompany.getMemberCompanySymbolsList().add(memberCompanySymbols);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MemberContact> memberContactList = param.getCompaniesRequest().getContactList();
|
||||||
|
for (MemberContact memberContact : memberContactList) {
|
||||||
|
UUID memberContactUUID = memberContact.getCompanyId();
|
||||||
|
MemberCompany memberCompany = companyForUUID.get(memberContactUUID);
|
||||||
|
if (memberCompany == null) {
|
||||||
|
log.warn("For contact ({} = {}) not found company, skipped",
|
||||||
|
memberContact.getContactType(),
|
||||||
|
memberContact.getContactValue());
|
||||||
|
memberContact.setInvalidData(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
memberCompany.getContactList().add(memberContact);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MemberCompanyClearingCategory> companyClearingCategoryList = param.getCompaniesRequest().getCompanyClearingCategoryList();
|
||||||
|
for (MemberCompanyClearingCategory companyClearingCategory : companyClearingCategoryList) {
|
||||||
|
UUID companyClearingCategoryUUID = companyClearingCategory.getCompanyId();
|
||||||
|
MemberCompany memberCompany = companyForUUID.get(companyClearingCategoryUUID);
|
||||||
|
if (memberCompany == null) {
|
||||||
|
log.warn("For companyClearingCategory ({}) not found company, skipped", companyClearingCategory.getCategory());
|
||||||
|
companyClearingCategory.setInvalidData(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
memberCompany.getCompanyClearingCategoryList().add(companyClearingCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ProfileDocument> profileDocumentList = param.getCompaniesRequest().getProfileDocumentList();
|
||||||
|
for (ProfileDocument profileDocument : profileDocumentList) {
|
||||||
|
UUID profileDocumentUUID = profileDocument.getCompanyId();
|
||||||
|
MemberCompany memberCompany = companyForUUID.get(profileDocumentUUID);
|
||||||
|
if (memberCompany == null) {
|
||||||
|
log.warn("For profileDocument (documentType {}) not found company, skipped", profileDocument.getDocumentType());
|
||||||
|
profileDocument.setInvalidData(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
memberCompany.getProfileDocumentList().add(profileDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Client> clientList = param.getCompaniesRequest().getClientList();
|
||||||
|
for (Client client : clientList) {
|
||||||
|
UUID clientUUID = client.getCompanyId();
|
||||||
|
MemberCompany memberCompany = companyForUUID.get(clientUUID);
|
||||||
|
if (memberCompany == null) {
|
||||||
|
log.warn("For client (clientCode {}) not found company, skipped", client.getClientCode());
|
||||||
|
client.setInvalidData(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
memberCompany.getClientList().add(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PrepareCompanies extends Stage<ListingsRequestParam> {
|
public class PrepareIssuerCompanies extends Stage<ListingsRequestParam> {
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Client {
|
public class Client extends WithMapId {
|
||||||
@JsonProperty("company_id")
|
@JsonProperty("company_id")
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Ссылка на company",
|
value = "Ссылка на company",
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import java.util.UUID;
|
||||||
/**
|
/**
|
||||||
* Компания участник
|
* Компания участник
|
||||||
*/
|
*/
|
||||||
public class MemberCompany {
|
public class MemberCompany extends WithMapId {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Идентификатор участника",
|
value = "Идентификатор участника",
|
||||||
|
|
@ -63,7 +63,7 @@ public class MemberCompany {
|
||||||
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private List<MemberCompanyInfo> companyInfoList = new ArrayList<>();
|
private MemberCompanyInfo companyInfo;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private List<MemberCompanyClearingCategory> companyClearingCategoryList = new ArrayList<>();
|
private List<MemberCompanyClearingCategory> companyClearingCategoryList = new ArrayList<>();
|
||||||
|
|
@ -137,12 +137,12 @@ public class MemberCompany {
|
||||||
this.initiatorCode = initiatorCode;
|
this.initiatorCode = initiatorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MemberCompanyInfo> getCompanyInfoList() {
|
public MemberCompanyInfo getCompanyInfo() {
|
||||||
return companyInfoList;
|
return companyInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCompanyInfoList(List<MemberCompanyInfo> companyInfoList) {
|
public void setCompanyInfo(MemberCompanyInfo companyInfo) {
|
||||||
this.companyInfoList = companyInfoList;
|
this.companyInfo = companyInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MemberCompanyClearingCategory> getCompanyClearingCategoryList() {
|
public List<MemberCompanyClearingCategory> getCompanyClearingCategoryList() {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MemberCompanyClearingCategory {
|
public class MemberCompanyClearingCategory extends WithMapId {
|
||||||
@JsonProperty("company_id")
|
@JsonProperty("company_id")
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Ссылка на company",
|
value = "Ссылка на company",
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MemberCompanySymbols {
|
public class MemberCompanySymbols extends WithMapId {
|
||||||
@JsonProperty("company_id")
|
@JsonProperty("company_id")
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Ссылка на company",
|
value = "Ссылка на company",
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MemberContact {
|
public class MemberContact extends WithMapId {
|
||||||
@JsonProperty("company_id")
|
@JsonProperty("company_id")
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Ссылка на компанию",
|
value = "Ссылка на компанию",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import ru.spcex.clearing.gatewayapi.config.deserializers.LocalDateDeserializer;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ProfileDocument {
|
public class ProfileDocument extends WithMapId {
|
||||||
@JsonProperty("company_id")
|
@JsonProperty("company_id")
|
||||||
@ApiModelProperty(
|
@ApiModelProperty(
|
||||||
value = "Ссылка на company",
|
value = "Ссылка на company",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue