--- ProfileDocumentService set up
This commit is contained in:
parent
960d0e6b68
commit
19add71925
5 changed files with 119 additions and 1 deletions
|
|
@ -59,6 +59,10 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
log.debug("successfully processed, grouping id={}, processed number={}", req.getGroupingSdf01Id(), accountToStatement.size());
|
||||
}
|
||||
|
||||
private void accountUpdateWithBrake(BaseRequest<AccountSdf01Request> userRequest) {
|
||||
|
||||
}
|
||||
|
||||
private AccountSdfToStatementRequestPart responsePart(Long sdf01Id) {
|
||||
AccountSdfToStatementRequestPart responsePart = new AccountSdfToStatementRequestPart();
|
||||
responsePart.setSdfId(sdf01Id);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ public class DeleteCompanyController extends AbstractQueueController {
|
|||
private final IStateLoader stateLoader;
|
||||
|
||||
@Autowired
|
||||
public DeleteCompanyController(IOperator operator, IStateLoader stateLoader) {
|
||||
public DeleteCompanyController(IOperator operator,
|
||||
IStateLoader stateLoader) {
|
||||
super(operator);
|
||||
this.stateLoader = stateLoader;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package ru.spcex.clearing.company.config;
|
||||
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfo;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
@Configuration
|
||||
public class KafkaSenderConfig {
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public KafkaSender kafkaSender(Producer<String, Object> kafkaProducer,
|
||||
ImdgProvider imdgProvider) {
|
||||
ImdgId imdgIdGenerator = imdgProvider.getImdgIdGenerator();
|
||||
return KafkaSender
|
||||
.setup()
|
||||
.producer(kafkaProducer)
|
||||
.idGenerator(imdgIdGenerator::nextId)
|
||||
.imdgProvider(s -> {
|
||||
Imdg<RequestInfo> imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
return imdg::insert;
|
||||
})
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
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.lang.NonNull;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
public class ProfileDocumentService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private Imdg<ProfileDocument> profileDocumentMap;
|
||||
private Imdg<Company> companyMap;
|
||||
private ImdgProvider imdgProvider;
|
||||
private KafkaSender kafkaReqProducer;
|
||||
|
||||
@Autowired
|
||||
public ProfileDocumentService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
KafkaSender kafkaReqProducer,
|
||||
ImdgProvider imdgProvider) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.imdgProvider = imdgProvider;
|
||||
this.kafkaReqProducer = kafkaReqProducer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
this.profileDocumentMap = imdgProvider.getImdg(IMDGDistributedNames.Map_ProfileDocument, ProfileDocument.class);
|
||||
this.companyMap = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
|
||||
callback(ProfileDocumentNewRequest.class)
|
||||
.setConsumer(this::newProfileDocument)
|
||||
.forDestination(Consts.DESTINATION_PROFILE_DOCUMENT_NEW, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private void newProfileDocument(BaseRequest<ProfileDocumentNewRequest> profileDocumentNewRequestBaseRequest) {
|
||||
log.trace("Start processing ProfileDocumentNewRequest!");
|
||||
ProfileDocumentNewRequest profileDocumentNewRequest = profileDocumentNewRequestBaseRequest.getRequestPayload();
|
||||
Long companyId = profileDocumentNewRequest.getCompanyId();
|
||||
Company company = companyMap.getSingleObjectByID(companyId);
|
||||
if (company != null && !company.getWorkflowStatus().equalsIgnoreCase("ACTV")) {
|
||||
throw new IllegalStateException("Wrong company with ID " + companyId + " and workflow status " + company.getWorkflowStatus());
|
||||
}
|
||||
ProfileDocument profileDocument = new ProfileDocument();
|
||||
profileDocument.setCompanyId(profileDocumentNewRequest.getCompanyId());
|
||||
profileDocument.setDocumentType(profileDocumentNewRequest.getDocumentType());
|
||||
profileDocument.setIssueDate(profileDocumentNewRequest.getIssueDate());
|
||||
profileDocument.setIssuePlace(profileDocumentNewRequest.getIssuePlace());
|
||||
profileDocument.setIssuer(profileDocumentNewRequest.getIssuer());
|
||||
profileDocument.setIssuerCode(profileDocumentNewRequest.getIssuerCode());
|
||||
profileDocument.setName(profileDocumentNewRequest.getName());
|
||||
profileDocument.setNumber(profileDocumentNewRequest.getNumber());
|
||||
profileDocument.setPlace(profileDocumentNewRequest.getPlace());
|
||||
profileDocument.setValidFromDate(profileDocumentNewRequest.getValidFromDate());
|
||||
profileDocument.setValidToDate(profileDocumentNewRequest.getValidToDate());
|
||||
profileDocument.setLink(profileDocumentNewRequest.getLink());
|
||||
profileDocumentMap.insert(profileDocument);
|
||||
if (profileDocument.getDocumentType().equalsIgnoreCase("XCNT")) {
|
||||
|
||||
//kafkaReqProducer.sendRequestToQueue(Consts.EXPORT_PROCESS, exportRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.account.brake.document;
|
||||
|
||||
public class AccountUpdateWithBrakeRequest {
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue