Merge branch 'dev' into execution_and_deals_status
This commit is contained in:
commit
911c90bc45
18 changed files with 190 additions and 90 deletions
|
|
@ -216,15 +216,14 @@ public class Sdf10Executor {
|
|||
|
||||
private void createDs_i(Registry as_t, BigDecimal summ, String outDocument) {
|
||||
Registry rgsD = as_t.clone();
|
||||
RegistryManager.zeroState(rgsD);
|
||||
rgsD.setRegistryDesignation(RegistryDesignation.D.getKey());
|
||||
rgsD.setRegistryUnit(RegistryUnit.I.getKey());
|
||||
rgsD.setRegistryCode(RegistryUtil.clearingCode(rgsD));
|
||||
rgsD.setBalance(summ);
|
||||
rgsD.setDebit(BigDecimal.ZERO);
|
||||
rgsD.setCredit(BigDecimal.ZERO);
|
||||
rgsD.setDiffBalance(BigDecimal.ZERO);
|
||||
rgsD.setCheckBalance(BigDecimal.ZERO);
|
||||
rgsD.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
rgsD.setOpenBalance(BigDecimal.ZERO);
|
||||
rgsD.setCloseBalance(BigDecimal.ZERO);
|
||||
rgsD.setContract(outDocument);
|
||||
registryImdg.insert(rgsD);
|
||||
log.debug("created DS*I.id={}", rgsD.getId());
|
||||
|
|
|
|||
|
|
@ -156,15 +156,14 @@ public class DmiService {
|
|||
return Optional.empty();
|
||||
}
|
||||
Registry rgsD = am_t.clone();
|
||||
RegistryManager.zeroState(rgsD);
|
||||
rgsD.setOpenBalance(BigDecimal.ZERO);
|
||||
rgsD.setCloseBalance(BigDecimal.ZERO);
|
||||
rgsD.setRegistryDesignation(RegistryDesignation.D.getKey());
|
||||
rgsD.setRegistryUnit(RegistryUnit.I.getKey());
|
||||
rgsD.setRegistryCode(RegistryUtil.clearingCode(rgsD));
|
||||
rgsD.setBalance(summ);
|
||||
|
||||
rgsD.setDebit(BigDecimal.ZERO);
|
||||
rgsD.setCredit(BigDecimal.ZERO);
|
||||
rgsD.setDiffBalance(BigDecimal.ZERO);
|
||||
rgsD.setCheckBalance(BigDecimal.ZERO);
|
||||
rgsD.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
return Optional.of(rgsD);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import org.springframework.scheduling.support.PeriodicTrigger;
|
|||
import ru.spcex.clearing.dbf.importer.config.settings.ImportDBFServiceSettings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
|
|
@ -60,6 +61,8 @@ public class SFTPConfig {
|
|||
fileSync.setTemporaryFileSuffix(".tmp");
|
||||
fileSync.setRemoteDirectory(settings.getStore().getSftpIn().getSftpSrcDir());
|
||||
fileSync.setFilter(new AcceptAllFileListFilter<>());
|
||||
fileSync.setPreserveTimestamp(true);
|
||||
fileSync.setComparator(Comparator.comparingInt(f -> f.getAttrs().getMTime()));
|
||||
return fileSync;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|||
import ru.spcex.clearing.dbf.importer.logic.Processor;
|
||||
import ru.spcex.clearing.dbf.importer.logic.data.ResultContainer;
|
||||
import ru.spcex.clearing.dbf.importer.logic.data.enums.ETable;
|
||||
import ru.spcex.platform.utils.collection.Pair;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
|
@ -59,13 +60,22 @@ public class DBFImporterService {
|
|||
} else {
|
||||
log.trace("no files were found");
|
||||
}
|
||||
|
||||
// Сортировка по возрастанию времени изменения - обрабатывать только в таком порядке
|
||||
List<Pair<File, ETable>> orderByTimeFiles = new ArrayList<>();
|
||||
for (Map.Entry<ETable, List<File>> newFilesEntry : newFiles.entrySet()) {
|
||||
ETable currTable = newFilesEntry.getKey();
|
||||
List<File> fileList = newFilesEntry.getValue();
|
||||
for (File dbfFile : fileList) {
|
||||
processor.process(ResultContainer.createNewTask(currTable, dbfFile));
|
||||
orderByTimeFiles.add(new Pair<>(dbfFile, currTable));
|
||||
}
|
||||
}
|
||||
orderByTimeFiles.sort(Comparator.comparingLong(iF -> iF.getFirst().lastModified()));
|
||||
for (Pair<File, ETable> newFilesEntry : orderByTimeFiles) {
|
||||
ETable currTable = newFilesEntry.getSecond();
|
||||
File dbfFile = newFilesEntry.getFirst();
|
||||
processor.process(ResultContainer.createNewTask(currTable, dbfFile));
|
||||
}
|
||||
} finally {
|
||||
if (newFiles != null && newFiles.size() > 0) {
|
||||
cleanFiles(newFiles);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public class FileChecker {
|
|||
|
||||
List<File> resultFiles = new LinkedList<>();
|
||||
if (dbfFiles != null && dbfFiles.length >= 1) {
|
||||
Arrays.sort(dbfFiles, Comparator.comparingLong(File::lastModified));
|
||||
resultFiles.addAll(Arrays.asList(dbfFiles));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,16 +38,16 @@ public class KSCommissionTradesReport {
|
|||
@CsvDate(value = "dd.MM.yyyy")
|
||||
private LocalDate agreementDate;
|
||||
|
||||
@CsvBindByName(column = "SUM")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
private BigDecimal sum;
|
||||
|
||||
@CsvBindByName(column = "AGREEMENT_SETTLEMENT_DATE")
|
||||
@CsvBindByPosition(position = 8)
|
||||
@CsvBindByPosition(position = 7)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
private LocalDate agreementSettlementDate;
|
||||
|
||||
@CsvBindByName(column = "SUM")
|
||||
@CsvBindByPosition(position = 8)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
private BigDecimal sum;
|
||||
|
||||
@CsvBindByName(column = "REPAYM_DATE")
|
||||
@CsvBindByPosition(position = 9)
|
||||
@CsvDate(value = "dd.MM.yyyy")
|
||||
|
|
|
|||
|
|
@ -41,6 +41,16 @@ public class KSRepCashNettoReport {
|
|||
@CsvDate(value = "dd.MM.yyyy")
|
||||
private LocalDate date;
|
||||
|
||||
@CsvBindByName(column = "OBL_VALUE")
|
||||
@CsvBindByPosition(position = 7)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
private BigDecimal oblValue;
|
||||
|
||||
@CsvBindByName(column = "REQ_VALUE")
|
||||
@CsvBindByPosition(position = 8)
|
||||
@CsvNumber(value = "#0.00", writeFormat = "#0.00")
|
||||
private BigDecimal reqValue;
|
||||
|
||||
|
||||
public String getFirmId() {
|
||||
return firmId;
|
||||
|
|
@ -98,4 +108,19 @@ public class KSRepCashNettoReport {
|
|||
this.date = date;
|
||||
}
|
||||
|
||||
public BigDecimal getOblValue() {
|
||||
return oblValue;
|
||||
}
|
||||
|
||||
public void setOblValue(BigDecimal oblValue) {
|
||||
this.oblValue = oblValue;
|
||||
}
|
||||
|
||||
public BigDecimal getReqValue() {
|
||||
return reqValue;
|
||||
}
|
||||
|
||||
public void setReqValue(BigDecimal reqValue) {
|
||||
this.reqValue = reqValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@ import ru.spcex.platform.utils.enumeration.IEnumKey;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
|
|
@ -180,13 +177,39 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
|||
|
||||
BigDecimal cmtBalance = BigDecimal.ZERO;
|
||||
BigDecimal lmtBalance = BigDecimal.ZERO;
|
||||
BigDecimal oblValue = BigDecimal.ZERO;
|
||||
BigDecimal reqValue = BigDecimal.ZERO;
|
||||
Set<SessionType> sessionTypeForValue = Set.of(
|
||||
SessionType.IPOT,
|
||||
SessionType.TRDT,
|
||||
SessionType.LIQU,
|
||||
SessionType.IPOB,
|
||||
SessionType.IPO0
|
||||
);
|
||||
Set<SessionType> sessionTypeForOblReqValue = Set.of(
|
||||
SessionType.FINL,
|
||||
SessionType.MEDM,
|
||||
SessionType.XDEP
|
||||
);
|
||||
for (Registry cmtRegistry : cmtRegistries) {
|
||||
if (cmtRegistry.getBalance() != null) cmtBalance = cmtBalance.add(cmtRegistry.getBalance());
|
||||
if (cmtRegistry.getBalance() != null) {
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, cmtRegistry.getSessionType());
|
||||
if (sessionType == null) continue;
|
||||
if (sessionTypeForValue.contains(sessionType)) cmtBalance = cmtBalance.add(cmtRegistry.getBalance());
|
||||
if (sessionTypeForOblReqValue.contains(sessionType)) reqValue = reqValue.add(cmtRegistry.getBalance());
|
||||
}
|
||||
}
|
||||
for (Registry lmtRegistry : lmtRegistries) {
|
||||
if (lmtRegistry.getBalance() != null) lmtBalance = lmtBalance.add(lmtRegistry.getBalance());
|
||||
if (lmtRegistry.getBalance() != null) {
|
||||
SessionType sessionType = IEnumKey.getEnumByKey(SessionType.class, lmtRegistry.getSessionType());
|
||||
if (sessionType == null) continue;
|
||||
if (sessionTypeForValue.contains(sessionType)) lmtBalance = lmtBalance.add(lmtRegistry.getBalance());
|
||||
if (sessionTypeForOblReqValue.contains(sessionType)) oblValue = oblValue.add(lmtRegistry.getBalance());
|
||||
}
|
||||
}
|
||||
ksRepCashNettoReport.setValue(cmtBalance.subtract(lmtBalance));
|
||||
ksRepCashNettoReport.setOblValue(oblValue);
|
||||
ksRepCashNettoReport.setReqValue(reqValue);
|
||||
|
||||
rows.add(ksRepCashNettoReport);
|
||||
} catch (Throwable e) {
|
||||
|
|
|
|||
|
|
@ -93,6 +93,49 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
executions.addAll(executionDeposits);
|
||||
executions.addAll(executionFonds);
|
||||
|
||||
Map<ExecutionKey, String> statusForExecution = new HashMap<>();
|
||||
executions.forEach(execution -> {
|
||||
if (Set.of("S", "SELL").contains(execution.getSide())) {
|
||||
String status = "";
|
||||
if (execution.getCoverageStatus() != null) {
|
||||
Long groupId = execution.getExchangeExecutionId();
|
||||
String coverageStatus = execution.getCoverageStatus().toUpperCase();
|
||||
CoverageStatus coverage = IEnumKey.getEnumByKey(CoverageStatus.class, coverageStatus);
|
||||
// Есть 2 пары Execution, SELL и BUY, статус определяем заранее по SELL и проставляем в BUY
|
||||
if (coverage == CoverageStatus.DEND) {
|
||||
if (execution instanceof ExecutionFond) {
|
||||
ImdgPredicateBuilder pbRegistry = registryImdg.predicateBuilder();
|
||||
String registryPredicateStr = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams._S_T).build();
|
||||
Collection<Registry> registryCollection = registryImdg.getCollectionObjectsByPredicate(
|
||||
pbRegistry.and(
|
||||
pbRegistry.equals("groupId", groupId),
|
||||
pbRegistry.equals("companyId", execution.getCompanyId()),
|
||||
pbRegistry.in("registryStatus",
|
||||
RegistryStatus.NACC.getKey(),
|
||||
RegistryStatus.NACK.getKey(),
|
||||
RegistryStatus.FAIL.getKey(),
|
||||
RegistryStatus.UNCV.getKey()),
|
||||
pbRegistry.sql(registryPredicateStr)
|
||||
)
|
||||
);
|
||||
if (registryCollection.isEmpty()) {
|
||||
status = null;
|
||||
} else {
|
||||
Registry registry = registryCollection.iterator().next();
|
||||
RegistryStatus registryStatus = IEnumKey.getEnumByKey(RegistryStatus.class, registry.getRegistryStatus());
|
||||
if (registryStatus == RegistryStatus.NACK || registryStatus == RegistryStatus.UNCV) {
|
||||
status = "3";
|
||||
} else if (registryStatus == RegistryStatus.NACC || registryStatus == RegistryStatus.FAIL) {
|
||||
status = "2";
|
||||
}
|
||||
}
|
||||
}
|
||||
statusForExecution.put(new ExecutionKey(groupId, execution.getSessionId()), status);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
rows = new ArrayList<>(executions.size());
|
||||
for (ExecutionCommon execution : executions) {
|
||||
try {
|
||||
|
|
@ -224,74 +267,34 @@ public class KSRepTradesReportBuilder extends CSVReportBuilder<EmptyParams, KSRe
|
|||
status = "1";
|
||||
} else if (coverage == CoverageStatus.DEND) {
|
||||
if (execution instanceof ExecutionDeposit) {
|
||||
ksRepTradesReport.setStatus("2");
|
||||
status = "2";
|
||||
} else {
|
||||
ImdgPredicateBuilder pbRegistry = registryImdg.predicateBuilder();
|
||||
String registryPredicateStr = RegistryCodeSqlBuilder.getInstance(
|
||||
RegistryTradingParams.OS_T,
|
||||
RegistryTradingParams.TS_T,
|
||||
RegistryTradingParams.OM_T,
|
||||
RegistryTradingParams.TM_T
|
||||
).build();
|
||||
Long groupId = execution.getExchangeExecutionId();
|
||||
Collection<Registry> registryCollection = registryImdg.getCollectionObjectsByPredicate(
|
||||
pbRegistry.and(
|
||||
pbRegistry.sql(registryPredicateStr), pbRegistry.equals("groupId", groupId)
|
||||
)
|
||||
);
|
||||
if (registryCollection.isEmpty()) {
|
||||
status = statusForExecution.get(new ExecutionKey(groupId, execution.getSessionId()));
|
||||
if (status == null) {
|
||||
log.warn(
|
||||
"Broken execution (empty registries). Registry for groupId = {} not found. Execution (id = {}) skipped",
|
||||
"Broken execution (can't define status). Registry for groupId = {}, companyId = {} not found. Execution (id = {}) skipped",
|
||||
groupId,
|
||||
execution.getCompanyId(),
|
||||
execution.getId()
|
||||
);
|
||||
continue;
|
||||
}
|
||||
boolean allOk = checkRegistryStatus(
|
||||
registryCollection,
|
||||
List.of(RegistryStatus.NACK, RegistryStatus.NACC, RegistryStatus.FAIL, RegistryStatus.UNCV)
|
||||
);
|
||||
if (allOk) {
|
||||
for (Registry registry : registryCollection) {
|
||||
RegistryInstrumentType registryInstrumentType = IEnumKey.getEnumByKey(RegistryInstrumentType.class, registry.getRegistryInstrumentType());
|
||||
if (registryInstrumentType == RegistryInstrumentType.M) {
|
||||
ksRepTradesReport.setStatus("2");
|
||||
break;
|
||||
}
|
||||
if (registryInstrumentType == RegistryInstrumentType.S) {
|
||||
ksRepTradesReport.setStatus("3");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
ksRepTradesReport.setStatus(status);
|
||||
|
||||
rows.add(ksRepTradesReport);
|
||||
} catch (Throwable e) {
|
||||
log.error("Can't create report row for execution_%s (id = %d), skipped".formatted(execution instanceof ExecutionFond ? "fond" : "deposit", execution.getId()), e);
|
||||
log.error("Can't create report row for execution_%s (id = %d), skipped".formatted(
|
||||
execution instanceof ExecutionFond ? "fond" : "deposit",
|
||||
execution.getId()), e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkRegistryStatus(Collection<Registry> registries, Collection<RegistryStatus> registryStatuses) {
|
||||
for (Registry registry : registries) {
|
||||
RegistryStatus registryStatus = IEnumKey.getEnumByKey(RegistryStatus.class, registry.getRegistryStatus());
|
||||
if (registryStatuses.contains(registryStatus)) continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkRegistryInstrumentType(Collection<Registry> registries, Collection<RegistryInstrumentType> RegistryInstrumentTypes) {
|
||||
for (Registry registry : registries) {
|
||||
RegistryInstrumentType RegistryInstrumentType = IEnumKey.getEnumByKey(RegistryInstrumentType.class, registry.getRegistryInstrumentType());
|
||||
if (RegistryInstrumentTypes.contains(RegistryInstrumentType)) continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
private record ExecutionKey(Long groupId, Long sessionId) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -642,7 +642,7 @@ public class ReportServiceTest_KS {
|
|||
executionFond.setQuantity(BigDecimal.valueOf(123.456789));
|
||||
executionFond.setExchangeExecutionId(222L);
|
||||
executionFond.setExchangeExecutionTime(Instant.ofEpochMilli(LocalDateTime.of(2022, 1, 1, 1, 1, 1).toEpochSecond(ZoneOffset.UTC)));
|
||||
executionFond.setCoverageStatus(CoverageStatus.ALWD.getKey());
|
||||
executionFond.setCoverageStatus(CoverageStatus.DEND.getKey());
|
||||
executionFondImdg.insert(executionFond);
|
||||
|
||||
Market market = new Market();
|
||||
|
|
@ -651,20 +651,20 @@ public class ReportServiceTest_KS {
|
|||
|
||||
Registry registry = new Registry();
|
||||
registry.setSessionId(sessionId_2);
|
||||
registry.setRegistryCode("OM_T");
|
||||
registry.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
registry.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
registry.setCompanyId(COMPANY_ID);
|
||||
registry.setRegistryCode("_S_T");
|
||||
registry.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
||||
registry.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry.setGroupId(Long.parseLong("%s%d%d".formatted(dateFormatter_yyyyMMdd.format(LocalDate.now()), 222, marketId)));
|
||||
registry.setGroupId(222L);
|
||||
registry.setRegistryStatus(RegistryStatus.FAIL.getKey());
|
||||
registry.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
||||
registryImdg.insert(registry);
|
||||
|
||||
Registry registry_2 = new Registry();
|
||||
registry_2.setSessionId(sessionId_2);
|
||||
registry_2.setRegistryCode("OM_T");
|
||||
registry_2.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||
registry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
registry_2.setCompanyId(COMPANY_ID);
|
||||
registry_2.setRegistryCode("_S_T");
|
||||
registry_2.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
||||
registry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||
registry_2.setGroupId(executionFond_3.getExchangeExecutionId());
|
||||
registry_2.setRegistryStatus(RegistryStatus.FAIL.getKey());
|
||||
|
|
@ -729,6 +729,7 @@ public class ReportServiceTest_KS {
|
|||
registry_1.setClearingDate(LocalDate.now());
|
||||
registry_1.setRegistryCode("LM_T");
|
||||
registry_1.setTradingClearingRegistry("TKR");
|
||||
registry_1.setSessionType(SessionType.IPO0.getKey());
|
||||
registry_1.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_1.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
registry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||
|
|
@ -744,6 +745,7 @@ public class ReportServiceTest_KS {
|
|||
registry_2.setSettlementDate(LocalDate.now());
|
||||
registry_2.setGroupId(Long.MAX_VALUE);
|
||||
registry_2.setClearingDate(LocalDate.now());
|
||||
registry_2.setSessionType(SessionType.IPO0.getKey());
|
||||
registry_2.setRegistryCode("CM_T");
|
||||
registry_2.setTradingClearingRegistry("TKR");
|
||||
registry_2.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
|
|
@ -768,6 +770,7 @@ public class ReportServiceTest_KS {
|
|||
registry_3.setGroupId(Long.MAX_VALUE);
|
||||
registry_3.setClearingDate(LocalDate.now());
|
||||
registry_3.setRegistryCode("LM_T");
|
||||
registry_3.setSessionType(SessionType.FINL.getKey());
|
||||
registry_3.setTradingClearingRegistry("TKR");
|
||||
registry_3.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||
registry_3.setRegistryDesignation(RegistryDesignation.L.getKey());
|
||||
|
|
@ -783,6 +786,7 @@ public class ReportServiceTest_KS {
|
|||
registry_4.setTradingCode("TRADING_CODE");
|
||||
registry_4.setSettlementDate(LocalDate.now());
|
||||
registry_4.setGroupId(Long.MAX_VALUE);
|
||||
registry_4.setSessionType(SessionType.FINL.getKey());
|
||||
registry_4.setClearingDate(LocalDate.now());
|
||||
registry_4.setRegistryCode("CM_T");
|
||||
registry_4.setTradingClearingRegistry("TKR");
|
||||
|
|
@ -1121,7 +1125,21 @@ public class ReportServiceTest_KS {
|
|||
}
|
||||
}
|
||||
if (findEqual) continue;
|
||||
Assertions.fail("For actual line '%s' not found expected line".formatted(String.join(",", actualLine)));
|
||||
Assertions.fail("For actual line '%s' not found expected line".formatted(String.join(", ", actualLine)));
|
||||
}
|
||||
|
||||
List<String> errors = new ArrayList<>();
|
||||
for (int idx = 0; idx < expectedHeaders.length; idx++) {
|
||||
if (!Objects.equals(expectedHeaders[idx], actualHeaders[idx])) {
|
||||
errors.add("expected header (%s) for idx = %d not equal actual header (%s)".formatted(
|
||||
expectedHeaders[idx],
|
||||
idx,
|
||||
actualHeaders[idx])
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!errors.isEmpty()) {
|
||||
Assertions.fail("Files equal, but header sequence broken, cause: %s".formatted(String.join(",", errors)));
|
||||
}
|
||||
|
||||
expectedCSVReader.close();
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
"FIRM_ID","FIRM_ID_INITIATOR","SECCODE","CLASS_CODE","AGREEMENT_NUMBER","AGREEMENT_NUMBER_POSTFIX","AGREEMENT_DATE","SUM","AGREEMENT_SETTLEMENT_DATE","REPAYM_DATE","EXEC_STATUS"
|
||||
"CLEARING_CODE","TRADING_CODE","CONT~RACT","market","CONT","CONT~RACT","01.01.1991","-77.78","02.01.2022","10.11.2023","Исполнен"
|
||||
"FIRM_ID","FIRM_ID_INITIATOR","SECCODE","CLASS_CODE","AGREEMENT_NUMBER","AGREEMENT_NUMBER_POSTFIX","AGREEMENT_DATE","AGREEMENT_SETTLEMENT_DATE","SUM","REPAYM_DATE","EXEC_STATUS"
|
||||
"CLEARING_CODE","TRADING_CODE","CONT~RACT","market","CONT","CONT~RACT","01.01.1991","06.11.2023","-77.78","16.11.2023","Исполнен"
|
||||
|
|
|
|||
|
|
|
@ -1,3 +1,3 @@
|
|||
"FIRMID","SESSION_ID","SESSION_DATE","ACCOUNT","TKR","VALUE","DATE"
|
||||
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT","TKR","22.22","01.11.2023"
|
||||
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT_FROM_ACCOUNT","TKR","22.22","01.11.2023"
|
||||
"FIRMID","SESSION_ID","SESSION_DATE","ACCOUNT","TKR","VALUE","DATE","OBL_VALUE","REQ_VALUE"
|
||||
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT","TKR","22.22","16.11.2023","0.00","0.00"
|
||||
"TRADING_CODE","2","20.01.1970T02:49:58","ACCOUNT_FROM_ACCOUNT","TKR","0.00","16.11.2023","22.22","44.44"
|
||||
|
|
|
|||
|
|
|
@ -1,5 +1,5 @@
|
|||
"SESSION_ID","SESSION_DATE","TR_ID","AGREEMENT_NUMBER","FIRM_ID","TKR","ACCOUNT","DEPO_ACCOUNT","CASH_LIABILITY","DEPO_LIABILITY","TRADE_NUM","CLASS_CODE","TRADE_DATE","STATUS"
|
||||
"4","20.01.1970T07:09:07","222","CONTRACT","TRADING_CODE","TKR","","","8888.89","0","222","3333","20.01.1970T02:49:58","0"
|
||||
"4","20.01.1970T07:09:07","222","CONTRACT","TRADING_CODE","TKR","","","8888.89","0","222","3333","20.01.1970T02:49:58","2"
|
||||
"3","20.01.1970T15:54:43","222","","TRADING_CODE","TKR","","","-8888.89","123","222","3333","20.01.1970T02:49:58","1"
|
||||
"3","20.01.1970T15:54:43","222","","TRADING_CODE","TKR","","","-8888.89","123","222","3333","20.01.1970T02:49:58","0"
|
||||
"3","20.01.1970T15:54:43","222","","TRADING_CODE","TKR","","","8888.89","-123","222","3333","20.01.1970T02:49:58","1"
|
||||
"3","20.01.1970T15:54:43","222","","TRADING_CODE","TKR","","","-8888.89","123","222","3333","20.01.1970T02:49:58","2"
|
||||
"3","20.01.1970T15:54:43","222","","TRADING_CODE","TKR","","","8888.89","-123","222","3333","20.01.1970T02:49:58","2"
|
||||
|
|
|
|||
|
|
|
@ -22,6 +22,7 @@ import org.springframework.scheduling.support.PeriodicTrigger;
|
|||
import ru.spcex.clearing.swt.importer.config.settings.ImportSWTServiceSettings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
|
|
@ -60,6 +61,8 @@ public class SFTPConfig {
|
|||
fileSync.setTemporaryFileSuffix(".tmp");
|
||||
fileSync.setRemoteDirectory(settings.getStore().getSftpIn().getSftpSrcDir());
|
||||
fileSync.setFilter(new AcceptAllFileListFilter<>());
|
||||
fileSync.setPreserveTimestamp(true);
|
||||
fileSync.setComparator(Comparator.comparingInt(f -> f.getAttrs().getMTime()));
|
||||
return fileSync;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public class FileChecker {
|
|||
|
||||
List<File> resultFiles = new LinkedList<>();
|
||||
if (swtFiles != null && swtFiles.length >= 1) {
|
||||
Arrays.sort(swtFiles, Comparator.comparingLong(File::lastModified));
|
||||
resultFiles.addAll(Arrays.asList(swtFiles));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|||
import ru.spcex.clearing.swt.importer.logic.Processor;
|
||||
import ru.spcex.clearing.swt.importer.logic.data.ResultContainer;
|
||||
import ru.spcex.clearing.swt.importer.logic.data.enums.ETable;
|
||||
import ru.spcex.platform.utils.collection.Pair;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
|
@ -81,13 +82,21 @@ public class SWTImporterService {
|
|||
} else {
|
||||
log.trace("no files were found");
|
||||
}
|
||||
// Сортировка по возрастанию времени изменения - обрабатывать только в таком порядке
|
||||
List<Pair<File, ETable>> orderByTimeFiles = new ArrayList<>();
|
||||
for (Map.Entry<ETable, List<File>> newFilesEntry : newFiles.entrySet()) {
|
||||
ETable currTable = newFilesEntry.getKey();
|
||||
List<File> fileList = newFilesEntry.getValue();
|
||||
for (File swtFile : fileList) {
|
||||
processor.process(ResultContainer.createNewTask(currTable, swtFile));
|
||||
orderByTimeFiles.add(new Pair<>(swtFile, currTable));
|
||||
}
|
||||
}
|
||||
orderByTimeFiles.sort(Comparator.comparingLong(iF -> iF.getFirst().lastModified()));
|
||||
for (Pair<File, ETable> newFilesEntry : orderByTimeFiles) {
|
||||
ETable currTable = newFilesEntry.getSecond();
|
||||
File swtFile = newFilesEntry.getFirst();
|
||||
processor.process(ResultContainer.createNewTask(currTable, swtFile));
|
||||
}
|
||||
} finally {
|
||||
if (newFiles != null && newFiles.size() > 0) {
|
||||
cleanFiles(newFiles);
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ public record RegistryTradingParams(RegistryDesignation registryDesignation,
|
|||
public final static RegistryTradingParams DMAI;
|
||||
public final static RegistryTradingParams D__I;
|
||||
public final static RegistryTradingParams D__V;
|
||||
public final static RegistryTradingParams _S_T;
|
||||
|
||||
static {
|
||||
OS_T = new RegistryTradingParams(RegistryDesignation.O,
|
||||
|
|
@ -255,6 +256,10 @@ public record RegistryTradingParams(RegistryDesignation registryDesignation,
|
|||
null,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
_S_T = new RegistryTradingParams(null,
|
||||
RegistryInstrumentType.S,
|
||||
null,
|
||||
RegistryUnit.T);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ package ru.spcex.platform.enumeration;
|
|||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum SessionType implements IEnumKey {
|
||||
IPOB("IPOB"), IPO0("IPO0"), IPOT("IPOT"), TRDT("TRDT"), MEDM("MEDM"), FINL("FINL"), XDEP("XDEP"),
|
||||
IPOB("IPOB"), IPO0("IPO0"), IPOT("IPOT"), TRDT("TRDT"),
|
||||
MEDM("MEDM"), FINL("FINL"), XDEP("XDEP"), LIQU("LIQU"),
|
||||
;
|
||||
|
||||
SessionType(String key) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue