SDF01 SDF06 fileName пробрасывается для экспортера
This commit is contained in:
parent
06c809f48f
commit
1c1b134edf
7 changed files with 42 additions and 8 deletions
|
|
@ -3,6 +3,7 @@ package ru.clearing.classes.statics.data.sdf;
|
|||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithAccount;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithFileName;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithMarket;
|
||||
|
||||
import java.time.Instant;
|
||||
|
|
@ -12,7 +13,7 @@ import java.time.Instant;
|
|||
* <p>
|
||||
* DB table: S_DF01
|
||||
**/
|
||||
public class SDf01 extends SpcexObjectBase implements WithAccount, WithMarket {
|
||||
public class SDf01 extends SpcexObjectBase implements WithAccount, WithMarket, WithFileName {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private String curr_code;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.clearing.classes.statics.data.sdf;
|
|||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithFileName;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
|
|
@ -11,7 +12,7 @@ import java.time.Instant;
|
|||
* <p>
|
||||
* DB table: S_DF06
|
||||
**/
|
||||
public class SDf06 extends SpcexObjectBase {
|
||||
public class SDf06 extends SpcexObjectBase implements WithFileName {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private String account;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,21 @@ package ru.spcex.clearing.service.executors;
|
|||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.StatementRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.sender.KafkaSender;
|
||||
import ru.spcex.clearing.service.model.Result;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithFileName;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class AbstractExecutor<T> {
|
||||
public abstract Result execute(Collection<T> sdf, StatementRequest statementRequest);
|
||||
public abstract String exportTableName();
|
||||
public abstract boolean isNeedToSendCommand();
|
||||
public abstract void sendCommand(KafkaSender kafkaSender, Result result);
|
||||
public static String getFileName(Collection<? extends WithFileName> sdfs) {
|
||||
return sdfs.stream()
|
||||
.map(WithFileName::getFileName)
|
||||
.filter(Objects::nonNull)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
ExportToFileRequest exportRequest = new ExportToFileRequest();
|
||||
exportRequest.setSdfGroupId(result.getChildGenerationId());
|
||||
exportRequest.setNameOfTable(exportTableName());
|
||||
exportRequest.setFileName(result.getFileName());
|
||||
kafkaSender.sendRequestToQueue(Consts.EXPORT_PROCESS, exportRequest);
|
||||
}
|
||||
|
||||
|
|
@ -106,8 +107,8 @@ public class Sdf01Executor extends AbstractExecutor<SDf01> {
|
|||
Result result = new Result();
|
||||
Long generationIdForGroup = statementRequest.getChildGenerationId() != null ? statementRequest.getChildGenerationId() : imdgProvider.getImdgIdGenerator().nextId();
|
||||
result.setChildGenerationId(generationIdForGroup);
|
||||
// boolean reviseFailed = false;
|
||||
log.info("SDF01 execution: sdf01 number={}, groupId={}", sdf.size(), sdf.stream().findFirst().map(SDf01::getGenerationId).orElse(null));
|
||||
result.setFileName(getFileName(sdf));
|
||||
log.info("SDF01 execution: sdf01 file={} number={}, groupId={}", result.getFileName(), sdf.size(), sdf.stream().findFirst().map(SDf01::getGenerationId).orElse(null));
|
||||
for (SDf01 sdf01 : sdf) {
|
||||
IValidator validator = sDf01Validator.apply(sdf01);
|
||||
Optional<EnumMessage> error = validator.tillFirstError();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import ru.spcex.platform.imdg.api.ImdgProvider;
|
|||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
import ru.spcex.platform.utils.number.BigDecimalUtil;
|
||||
import ru.spcex.platform.utils.text.TextUtil;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -105,6 +106,8 @@ public class Sdf06Executor {
|
|||
Collection<SDf06> sdfs = sdfImdg.getCollectionObjectsByFieldValues(Map.of(
|
||||
"generationId", groupId
|
||||
));
|
||||
String fileName = AbstractExecutor.getFileName(sdfs);
|
||||
log.info("start processing SDF06: groupId={} file={}", groupId, fileName);
|
||||
Instant now = Instant.now();
|
||||
Long sdf07GroupId = idGenerator.nextId();
|
||||
if (sdf06GroupId != null) {
|
||||
|
|
@ -114,7 +117,7 @@ public class Sdf06Executor {
|
|||
errorSdf07.setGenerationId(sdf07GroupId);
|
||||
sdf07Imdg.insert(errorSdf07);
|
||||
});
|
||||
sendToExporter(sdf07GroupId);
|
||||
sendToExporter(sdf07GroupId, fileName);
|
||||
return;
|
||||
}
|
||||
Collection<AssetOperationRequest> requests = new ArrayList<>();
|
||||
|
|
@ -169,7 +172,7 @@ public class Sdf06Executor {
|
|||
assetOperationListRequest.setAssetOperationRequests(requests);
|
||||
kafkaSender.sendRequestToQueue(Consts.ASSET_OPERATION, assetOperationListRequest);
|
||||
} else if (sdf07WasCreated) {
|
||||
sendToExporter(sdf07GroupId);
|
||||
sendToExporter(sdf07GroupId, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -197,6 +200,7 @@ public class Sdf06Executor {
|
|||
|
||||
public void processGatewayResponse(BaseRequest<AssetOperationApprovalRequest> req) {
|
||||
Instant now = Instant.now();
|
||||
String fileName = null;
|
||||
for (SingleAssetResponse gatewayMsg : req.getRequestPayload().getApprovals()) {
|
||||
//получаем запрос для текущей группы sdf06
|
||||
//находим группу
|
||||
|
|
@ -209,6 +213,9 @@ public class Sdf06Executor {
|
|||
|
||||
Long sdf06Id = stmt.getInSDfId();
|
||||
SDf06 sdf06 = sdf06Imdg.getSingleObjectByID(sdf06Id);
|
||||
if (fileName == null && !TextUtil.isEmpty(sdf06.getFileName())) {
|
||||
fileName = sdf06.getFileName();
|
||||
}
|
||||
if (sdf06 == null) {
|
||||
log.error("Sdf06.id {} not found by statement.id {}", sdf06Id, statementId);
|
||||
return;
|
||||
|
|
@ -241,7 +248,7 @@ public class Sdf06Executor {
|
|||
statementImdg.update(stmt);
|
||||
}
|
||||
}
|
||||
sendToExporter(sdf07GroupId);
|
||||
sendToExporter(sdf07GroupId, fileName);
|
||||
log.debug("All gateway responses received for SDF06 groupId {}. SDF07 groupId {}", sdf06GroupId, sdf07GroupId);
|
||||
clearContext();
|
||||
}
|
||||
|
|
@ -251,10 +258,11 @@ public class Sdf06Executor {
|
|||
this.sdf07GroupId = null;
|
||||
}
|
||||
|
||||
private void sendToExporter(Long generationId) {
|
||||
private void sendToExporter(Long generationId, String fileName) {
|
||||
ExportToFileRequest exportRequest = new ExportToFileRequest();
|
||||
exportRequest.setSdfGroupId(generationId);
|
||||
exportRequest.setNameOfTable("DF-07");
|
||||
exportRequest.setFileName(fileName);
|
||||
kafkaSender.sendRequestToQueue(Consts.EXPORT_PROCESS, exportRequest);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||
public class Result {
|
||||
private List<AccountSdfRequestPart> accountRequests = new ArrayList<>();
|
||||
private Long childGenerationId;
|
||||
private String fileName;
|
||||
|
||||
public List<AccountSdfRequestPart> getAccountRequests() {
|
||||
return accountRequests;
|
||||
|
|
@ -24,4 +25,12 @@ public class Result {
|
|||
public void setChildGenerationId(Long generationId) {
|
||||
this.childGenerationId = generationId;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package ru.spcex.platform.classes.base.interfaces;
|
||||
|
||||
public interface WithFileName {
|
||||
String getFileName();
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue