This commit is contained in:
parent
ad84cbd6a6
commit
e0dcd24604
8 changed files with 101 additions and 4 deletions
|
|
@ -7,4 +7,5 @@ import java.util.Collection;
|
|||
|
||||
public abstract class AbstractExecutor<T extends WithAccount> {
|
||||
abstract Result execute(Collection<T> sdf, StatementRequest statementRequest);
|
||||
abstract String exportTableName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
this.errorResolver = errorResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
String exportTableName() {
|
||||
return "DF-02";
|
||||
}
|
||||
|
||||
public Result execute(Collection<SDf01> sdf, StatementRequest statementRequest){
|
||||
Result result = new Result();
|
||||
Long generationIdForGroup = imdgProvider.getImdgIdGenerator().nextId();
|
||||
|
|
|
|||
|
|
@ -57,6 +57,11 @@ public class Sdf09Executor extends AbstractExecutor<SDf09> {
|
|||
this.errorResolver = errorResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
String exportTableName() {
|
||||
return "DF-10";
|
||||
}
|
||||
|
||||
public Result execute(Collection<SDf09> sdf, StatementRequest statementRequest){
|
||||
Result result = new Result();
|
||||
Long generationIdForGroup = imdgProvider.getImdgIdGenerator().nextId();
|
||||
|
|
|
|||
|
|
@ -12,8 +12,11 @@ import ru.clearing.classes.statics.data.statement.Statement;
|
|||
import ru.spcex.clearing.balance.errors.BalanceError;
|
||||
import ru.spcex.clearing.balance.validation.ValidationStored;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.utilities.NotificationNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.platform.enumeration.*;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
|
@ -43,16 +46,17 @@ public class Sdf16Executor extends AbstractExecutor<SDf16> {
|
|||
private final AccountBalanceService accountBalanceService;
|
||||
private final IMessageResolver errorResolver;
|
||||
private final Imdg<AccountBalance> accountBalanceImdg;
|
||||
private final KafkaSender kafaSender;
|
||||
|
||||
public Sdf16Executor(Function<SDf16, IValidator> sDf16Validator,
|
||||
LoggingService errorLogger,
|
||||
ImdgProvider imdgProvider,
|
||||
AccountBalanceService accountBalanceService,
|
||||
IMessageResolver errorResolver) {
|
||||
IMessageResolver errorResolver, KafkaSender kafaSender) {
|
||||
this.statementImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Statement, Statement.class);
|
||||
this.sdf17Imdg = imdgProvider.getImdg(IMDGDistributedNames.Map_SDf17, SDf17.class);
|
||||
this.accountBalanceImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class);
|
||||
;
|
||||
this.kafaSender = kafaSender;
|
||||
this.sDf16Validator = sDf16Validator;
|
||||
this.errorLogger = errorLogger;
|
||||
this.imdgProvider = imdgProvider;
|
||||
|
|
@ -60,6 +64,11 @@ public class Sdf16Executor extends AbstractExecutor<SDf16> {
|
|||
this.errorResolver = errorResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
String exportTableName() {
|
||||
return "DF-17";
|
||||
}
|
||||
|
||||
public Result execute(Collection<SDf16> sdf, StatementRequest statementRequest) {
|
||||
Result result = new Result();
|
||||
Long generationIdForGroup = imdgProvider.getImdgIdGenerator().nextId();
|
||||
|
|
@ -106,10 +115,23 @@ public class Sdf16Executor extends AbstractExecutor<SDf16> {
|
|||
statement.setOperationStatus(OperationStatus.Executed.getKey());
|
||||
}
|
||||
statementImdg.update(statement);
|
||||
NotificationNewRequest notificationNewRequest = createNotification(statement.getId(),
|
||||
statement.getSenderId(),
|
||||
statement.getAddresseeId());
|
||||
kafaSender.sendRequestToQueue(Consts.NOTIFICATION_NEW, notificationNewRequest);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private NotificationNewRequest createNotification(Long id, Long senderId, Long addresseeId) {
|
||||
NotificationNewRequest request = new NotificationNewRequest();
|
||||
request.setSenderId(senderId);
|
||||
request.setAddresseeId(addresseeId);
|
||||
request.setObjectType(ObjectType.statement.getKey());
|
||||
request.setObjectId(id);
|
||||
return request;
|
||||
}
|
||||
|
||||
private Statement createFlow(SDf16 sdf, Company company, Account account) {
|
||||
Statement statement = new Statement();
|
||||
statement.setAddresseeId(company.getId());
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class StatementService extends QueueConsumer implements InitializingBean
|
|||
if (res.getAccountRequests().size() == 0) {
|
||||
ExportToFileRequest exportRequest = new ExportToFileRequest();
|
||||
exportRequest.setSdfGroupId(res.getGenerationId());
|
||||
exportRequest.setNameOfTable("DF-02");
|
||||
exportRequest.setNameOfTable(service.exportTableName());
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.EXPORT_PROCESS, exportRequest);
|
||||
} else {
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.ACCOUNT_NEW, createAccountsRequest(statementRequest.getGroupId(), res.getAccountRequests()));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.platform.enumeration;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum ObjectType implements IEnumKey {
|
||||
statement("STMT");
|
||||
|
||||
private final String key;
|
||||
|
||||
ObjectType(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,6 @@ public interface Consts {
|
|||
String USER_LOGOUT_SUCCESS = "user-logout-success";
|
||||
String USER_SETTINGS_UPDATE = "user-settings-update";
|
||||
|
||||
//todo
|
||||
String STATEMENT_PROCESS = "statement-process";
|
||||
String SDF04_PROCESS = "sdf04-process";
|
||||
String SDF03_PROCESS = "sdf03-process";
|
||||
|
|
@ -49,6 +48,7 @@ public interface Consts {
|
|||
String ACCOUNT_NEW = "account-new";
|
||||
String BALANCE_ACCOUNT_NEW = "balance-account-new";
|
||||
String LAUNCHER_NEW = "launcher-new";
|
||||
String NOTIFICATION_NEW = "notification-new";
|
||||
|
||||
String REQUEST_INFO_UPDATE = "request-info-update";
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.utilities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class NotificationNewRequest {
|
||||
@JsonProperty
|
||||
public Long senderId;
|
||||
@JsonProperty
|
||||
public Long addresseeId;
|
||||
@JsonProperty
|
||||
public String objectType;
|
||||
@JsonProperty
|
||||
public Long objectId;
|
||||
|
||||
public Long getSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
public void setSenderId(Long senderId) {
|
||||
this.senderId = senderId;
|
||||
}
|
||||
|
||||
public Long getAddresseeId() {
|
||||
return addresseeId;
|
||||
}
|
||||
|
||||
public void setAddresseeId(Long addresseeId) {
|
||||
this.addresseeId = addresseeId;
|
||||
}
|
||||
|
||||
public String getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
|
||||
public void setObjectType(String objectType) {
|
||||
this.objectType = objectType;
|
||||
}
|
||||
|
||||
public Long getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
public void setObjectId(Long objectId) {
|
||||
this.objectId = objectId;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue