company-service http://jira.mfd.msk:8088/browse/CLS-284 начало (доделать!)
This commit is contained in:
parent
5938786f84
commit
2829e50e7e
6 changed files with 54 additions and 20 deletions
|
|
@ -111,7 +111,7 @@ public class CompanyInfoService extends QueueConsumer implements InitializingBea
|
|||
transaction.beginTransaction();
|
||||
boolean txOk = false;
|
||||
try {
|
||||
companyService.relationHelper.onChangeWorkflowStatus(transaction, company, prevStatus, company.getWorkflowStatus());
|
||||
companyService.relationService.onChangeWorkflowStatus(transaction, company, prevStatus, company.getWorkflowStatus());
|
||||
Imdg<Company> txCompanyMap = transaction.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
txCompanyMap.update(company);
|
||||
log.trace("Company {} updated", company.getId());
|
||||
|
|
|
|||
|
|
@ -29,13 +29,11 @@ import ru.spcex.platform.imdg.api.ImdgId;
|
|||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.api.ImdgTransaction;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.error.ClearingBaseException;
|
||||
import ru.spcex.platform.utils.error.ValidationException;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
|
@ -56,7 +54,7 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
|
||||
protected CompanySymbolService companySymbolService;
|
||||
protected AccountNotificationHelper accountNotification;
|
||||
protected RelationHelper relationHelper;
|
||||
protected RelationService relationService;
|
||||
|
||||
@Autowired
|
||||
public CompanyService(Consumer<String, Object> kafkaQueue, Producer<String, Object> kafkaProducer,
|
||||
|
|
@ -73,7 +71,7 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
|
||||
CompanySymbolService companySymbolService,
|
||||
AccountNotificationHelper accountNotification,
|
||||
RelationHelper relationHelper
|
||||
RelationService relationService
|
||||
) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.imdgProvider = imdgProvider;
|
||||
|
|
@ -89,7 +87,7 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
this.companySymbolService = companySymbolService;
|
||||
companySymbolService.setCompanyService(this);
|
||||
this.accountNotification = accountNotification;
|
||||
this.relationHelper = relationHelper;
|
||||
this.relationService = relationService;
|
||||
|
||||
companyIMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
}
|
||||
|
|
@ -145,9 +143,9 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
companyMap.insert(company);
|
||||
log.debug("company-new request processed, BaseRequest.id = {}, company.id={}",
|
||||
companyNewRequestBaseRequest.getId(), company.getId());
|
||||
relationHelper.createNewRelation(transaction, company);
|
||||
relationService.createNewRelation(transaction, company);
|
||||
if (!(WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus()))) { // Block
|
||||
relationHelper.onChangeWorkflowStatus(transaction, company, null, company.getWorkflowStatus());
|
||||
relationService.onChangeWorkflowStatus(transaction, company, null, company.getWorkflowStatus());
|
||||
}
|
||||
txOk = true;
|
||||
} finally {
|
||||
|
|
@ -180,10 +178,10 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
log.trace("Company {} not found", updateRequest.getId());
|
||||
return requestHelper.makeErrorResponse(companyUpdateRequestBaseRequest, CompanyErrors.CompanyNotFound, updateRequest.getId());
|
||||
}
|
||||
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) {
|
||||
log.trace("Company {} not active: {}", company.getId(), company.getWorkflowStatus());
|
||||
return requestHelper.makeErrorResponse(companyUpdateRequestBaseRequest, CompanyErrors.CompanyDisabled, updateRequest.getId());
|
||||
}
|
||||
// if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) {
|
||||
// log.trace("Company {} not active: {}", company.getId(), company.getWorkflowStatus());
|
||||
// return requestHelper.makeErrorResponse(companyUpdateRequestBaseRequest, CompanyErrors.CompanyDisabled, updateRequest.getId());
|
||||
// }
|
||||
|
||||
company.setUpdated(Instant.now());
|
||||
company.setShortName(updateRequest.getShortName());
|
||||
|
|
@ -199,7 +197,7 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
if (updateRequest.getWorkflowStatus() != null) {
|
||||
company.setWorkflowStatus(updateRequest.getWorkflowStatus());
|
||||
if (!Objects.equals(prevStatus, company.getWorkflowStatus())) {
|
||||
relationHelper.onChangeWorkflowStatus(transaction, company, prevStatus, company.getWorkflowStatus());
|
||||
relationService.onChangeWorkflowStatus(transaction, company, prevStatus, company.getWorkflowStatus());
|
||||
} else {
|
||||
log.trace("Status was not changed");
|
||||
}
|
||||
|
|
@ -286,7 +284,7 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
String prevStatus = company.getWorkflowStatus();
|
||||
company.setWorkflowStatus(WorkflowStatus.Blocked.getKey());
|
||||
|
||||
relationHelper.onChangeWorkflowStatus(transaction, company, prevStatus, company.getWorkflowStatus());
|
||||
relationService.onChangeWorkflowStatus(transaction, company, prevStatus, company.getWorkflowStatus());
|
||||
log.debug("Update company.id={}", company.getId());
|
||||
companyMap.update(company);
|
||||
|
||||
|
|
@ -339,7 +337,7 @@ public class CompanyService extends QueueConsumer implements InitializingBean {
|
|||
|
||||
company.setWorkflowStatus(WorkflowStatus.Blocked.getKey());
|
||||
|
||||
relationHelper.onChangeWorkflowStatusOnlyRelationChange(transaction, company, company.getWorkflowStatus());
|
||||
relationService.onChangeWorkflowStatusOnlyRelationChange(transaction, company, company.getWorkflowStatus());
|
||||
log.debug("Update company.id={}", company.getId());
|
||||
companyMap.update(company);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
package ru.spcex.clearing.company.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.company.error.CompanyErrors;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.platform.enumeration.ServiceProduct;
|
||||
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;
|
||||
import ru.spcex.platform.utils.error.ValidationException;
|
||||
|
||||
|
|
@ -20,15 +30,41 @@ import java.util.Collection;
|
|||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class RelationHelper {
|
||||
public class RelationService extends QueueConsumer implements InitializingBean {
|
||||
protected static final Long SPVB_ID = 1L; // СПВБ
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected ImdgProvider imdgProvider;
|
||||
protected AccountNotificationHelper accountNotification;
|
||||
|
||||
@Autowired
|
||||
public RelationHelper(AccountNotificationHelper accountNotification) {
|
||||
public RelationService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider,
|
||||
|
||||
AccountNotificationHelper accountNotification) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.accountNotification = accountNotification;
|
||||
|
||||
// this.requestHelper = requestHelper.setLogger(log);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// this.profileDocumentMap = imdgProvider.getImdg(IMDGDistributedNames.Map_ProfileDocument, ProfileDocument.class);
|
||||
// this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
//todo all CLS-284
|
||||
// callback(ProfileDocumentNewRequest.class)
|
||||
// .setFunction(this::profileDocumentNew)
|
||||
// .forDestination(Consts.DESTINATION_PROFILE_DOCUMENT_NEW, callbacks::put);
|
||||
// callback(ProfileDocumentUpdateRequest.class)
|
||||
// .setFunction(this::profileDocumentUpdate)
|
||||
// .forDestination(Consts.DESTINATION_PROFILE_DOCUMENT_UPDATE, callbacks::put);
|
||||
// callback(CommonDeleteRequest.class)
|
||||
// .setFunction(this::profileDocumentDelete)
|
||||
// .forDestination(Consts.DESTINATION_PROFILE_DOCUMENT_DELETE, callbacks::put);
|
||||
// init();
|
||||
}
|
||||
|
||||
protected void createNewRelation(ImdgTransaction transaction, Company company) {
|
||||
|
|
@ -50,7 +50,7 @@ import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProv
|
|||
ValidationConfig.class,
|
||||
CompanySymbolService.class,
|
||||
AccountNotificationHelper.class,
|
||||
RelationHelper.class,
|
||||
RelationService.class,
|
||||
BeanConfiguration.class,
|
||||
|
||||
KafkaTestConfig.class,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProv
|
|||
ValidationConfig.class,
|
||||
CompanySymbolService.class,
|
||||
AccountNotificationHelper.class,
|
||||
RelationHelper.class,
|
||||
RelationService.class,
|
||||
|
||||
CompanySymbolService.class,
|
||||
CompanySymbolValidationConfig.class,
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ import static ru.spcex.clearing.test.config.ImdgTestConfig.waitAvailableImdgProv
|
|||
CompanyService.class,
|
||||
CompanyValidationConfig.class,
|
||||
AccountNotificationHelper.class,
|
||||
RelationHelper.class,
|
||||
RelationService.class,
|
||||
|
||||
KafkaTestConfig.class,
|
||||
ImdgTestConfig.class})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue