Merge branch 'dev' into plan_balance_dmx_dmt
This commit is contained in:
commit
e16767c15a
8 changed files with 87 additions and 27 deletions
|
|
@ -89,7 +89,15 @@ public class AnltSearcher {
|
||||||
if (tcrIndex == -1) {
|
if (tcrIndex == -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
comment = comment.substring(tcrIndex + 3);
|
if (comment.length() < (tcrIndex + 4)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int spaceAfterTCR = comment.indexOf(" ", tcrIndex + 4);
|
||||||
|
if (spaceAfterTCR == -1) {
|
||||||
|
comment = comment.substring(tcrIndex + 4);
|
||||||
|
} else {
|
||||||
|
comment = comment.substring(tcrIndex + 4, spaceAfterTCR);
|
||||||
|
}
|
||||||
return comment.replaceAll("\\s+", "");
|
return comment.replaceAll("\\s+", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ public class PaymentInstructionOutboundService {
|
||||||
log.debug("all checks passed, accCred.id={}, accDeb.id={}, addressee.id={}, sender.id={}, amount: {}",
|
log.debug("all checks passed, accCred.id={}, accDeb.id={}, addressee.id={}, sender.id={}, amount: {}",
|
||||||
accCred.getId(), accDeb.getId(), addressee.getId(), sender.getId(), amount);
|
accCred.getId(), accDeb.getId(), addressee.getId(), sender.getId(), amount);
|
||||||
|
|
||||||
String purpose = tcr != null ? "Вывод средств по ТКР " + tcr.getCode() + "." : "Вывод средств.";
|
String purpose = tcr != null ? "Вывод средств по ТКР " + tcr.getCode() + " ." : "Вывод средств.";
|
||||||
if (payload.getPaymentPurpose() != null) {
|
if (payload.getPaymentPurpose() != null) {
|
||||||
purpose += " " + payload.getPaymentPurpose();
|
purpose += " " + payload.getPaymentPurpose();
|
||||||
if (!(purpose.endsWith(".") || purpose.endsWith("!") || purpose.endsWith("?") || purpose.endsWith(";"))) {
|
if (!(purpose.endsWith(".") || purpose.endsWith("!") || purpose.endsWith("?") || purpose.endsWith(";"))) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package ru.spcex.clearing.statement;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.clearing.classes.statics.data.misc.Session;
|
||||||
import ru.clearing.classes.statics.data.sdf.*;
|
import ru.clearing.classes.statics.data.sdf.*;
|
||||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||||
|
|
@ -19,6 +20,7 @@ import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||||
import ru.spcex.platform.enumeration.ObjectType;
|
import ru.spcex.platform.enumeration.ObjectType;
|
||||||
import ru.spcex.platform.enumeration.Priority;
|
import ru.spcex.platform.enumeration.Priority;
|
||||||
import ru.spcex.platform.enumeration.SdfTable;
|
import ru.spcex.platform.enumeration.SdfTable;
|
||||||
|
import ru.spcex.platform.enumeration.WorkflowStatus;
|
||||||
import ru.spcex.platform.imdg.api.Imdg;
|
import ru.spcex.platform.imdg.api.Imdg;
|
||||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||||
import ru.spcex.platform.utils.text.TextUtil;
|
import ru.spcex.platform.utils.text.TextUtil;
|
||||||
|
|
@ -42,6 +44,7 @@ public class StatementServiceV2 {
|
||||||
private final Sdf57Executor sdf57Executor;
|
private final Sdf57Executor sdf57Executor;
|
||||||
private final Sdf04Executor sdf04Executor;
|
private final Sdf04Executor sdf04Executor;
|
||||||
private final Sdf13Executor sdf13Executor;
|
private final Sdf13Executor sdf13Executor;
|
||||||
|
private final Imdg<Session> sessionImdg;
|
||||||
private final Reviser reviser;
|
private final Reviser reviser;
|
||||||
private final SdfGroupManager grpMng;
|
private final SdfGroupManager grpMng;
|
||||||
|
|
||||||
|
|
@ -63,6 +66,7 @@ public class StatementServiceV2 {
|
||||||
this.sdf57Executor = sdf57Executor;
|
this.sdf57Executor = sdf57Executor;
|
||||||
this.sdf04Executor = sdf04Executor;
|
this.sdf04Executor = sdf04Executor;
|
||||||
this.sdf13Executor = sdf13Executor;
|
this.sdf13Executor = sdf13Executor;
|
||||||
|
this.sessionImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Session, Session.class);
|
||||||
this.reviser = reviser;
|
this.reviser = reviser;
|
||||||
this.grpMng = grpMng;
|
this.grpMng = grpMng;
|
||||||
}
|
}
|
||||||
|
|
@ -185,7 +189,8 @@ public class StatementServiceV2 {
|
||||||
removeFirstWithSameTableAndGroupId(sdf57);
|
removeFirstWithSameTableAndGroupId(sdf57);
|
||||||
reviser.doRevise(sdf01.getGroupId());
|
reviser.doRevise(sdf01.getGroupId());
|
||||||
//теперь можем продолжить сессию с шага 1
|
//теперь можем продолжить сессию с шага 1
|
||||||
if (!sessionStarted) {
|
if (!sessionStarted
|
||||||
|
|| sessionImdg.getFirstObjectBySQL("workflowStatus = '%s'".formatted(WorkflowStatus.Active.getKey())) != null) {
|
||||||
SessionContinueEvent continueSessionBn = new SessionContinueEvent(SdfTable.SDF_01, SdfTable.SDF_57);
|
SessionContinueEvent continueSessionBn = new SessionContinueEvent(SdfTable.SDF_01, SdfTable.SDF_57);
|
||||||
kafkaSender.sendRequestToQueue(Consts.CONTINUE_SESSION_BN_FIRST_PART, continueSessionBn);
|
kafkaSender.sendRequestToQueue(Consts.CONTINUE_SESSION_BN_FIRST_PART, continueSessionBn);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.MissingFormatArgumentException;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,7 +36,22 @@ public class IMDGMessageResolver implements IMessageResolver {
|
||||||
return simplFormatter.get();
|
return simplFormatter.get();
|
||||||
}
|
}
|
||||||
String textTemplate = errId + " " + errorDictionary.getName();
|
String textTemplate = errId + " " + errorDictionary.getName();
|
||||||
return String.format(textTemplate, errMsg.getArgs());
|
try {
|
||||||
|
return String.format(textTemplate, errMsg.getArgs());
|
||||||
|
} catch (MissingFormatArgumentException errFormatting) { // MissingFormatArgumentException
|
||||||
|
int argExpected = 0;
|
||||||
|
int i = 0, li = -1;
|
||||||
|
while ((i = textTemplate.indexOf("%", i)) >= 0 && i != li) {
|
||||||
|
argExpected++;
|
||||||
|
li = i;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
log.warn("Error dictionary {} text \"{}\" contains {} argument position, but message contains only: {}",
|
||||||
|
errId, textTemplate, argExpected, errMsg.getArgs().length);
|
||||||
|
Object[] arg = Arrays.copyOf(errMsg.getArgs(), Math.max(errMsg.getArgs().length, argExpected));
|
||||||
|
for (i = errMsg.getArgs().length; i < arg.length; i++) arg[i] = " ";
|
||||||
|
return String.format(textTemplate, arg);
|
||||||
|
}
|
||||||
} catch (Exception errFormatting) { // MissingFormatArgumentException
|
} catch (Exception errFormatting) { // MissingFormatArgumentException
|
||||||
log.warn("Error in message resolver for error {} id {}. Format error: {}", errMsg.getSubject(), errMsg.getSubject().getId(), errFormatting);
|
log.warn("Error in message resolver for error {} id {}. Format error: {}", errMsg.getSubject(), errMsg.getSubject().getId(), errFormatting);
|
||||||
return simplFormatter.get();
|
return simplFormatter.get();
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,26 @@ class IMDGMessageResolverTest {
|
||||||
@Test
|
@Test
|
||||||
void resolve() {
|
void resolve() {
|
||||||
ImdgProvider imdgProvider = Mockito.mock(ImdgProvider.class);
|
ImdgProvider imdgProvider = Mockito.mock(ImdgProvider.class);
|
||||||
Imdg<ErrorCodeDictionary> errorCodeDictionary = Mockito.mock(Imdg.class);
|
{
|
||||||
ErrorCodeDictionary error1Dict = new ErrorCodeDictionary();
|
Imdg<ErrorCodeDictionary> errorCodeDictionary = Mockito.mock(Imdg.class);
|
||||||
error1Dict.setId(1L);
|
ErrorCodeDictionary error1Dict = new ErrorCodeDictionary();
|
||||||
error1Dict.setCode("TEST");
|
error1Dict.setId(1L);
|
||||||
error1Dict.setName("Error 1 test. Two arg %s, %s.");
|
error1Dict.setCode("TEST");
|
||||||
Mockito.when(errorCodeDictionary.getSingleObjectByID(1L)).thenReturn(error1Dict);
|
error1Dict.setName("Error 1 test. Two arg %s, %s.");
|
||||||
Mockito.when(imdgProvider.getImdg(IMDGDistributedNames.Map_ErrorCodeDictionary, ErrorCodeDictionary.class))
|
Mockito.when(errorCodeDictionary.getSingleObjectByID(1L)).thenReturn(error1Dict);
|
||||||
.thenReturn(errorCodeDictionary);
|
ErrorCodeDictionary error2Dict = new ErrorCodeDictionary();
|
||||||
|
error2Dict.setId(2L);
|
||||||
|
error2Dict.setCode("TEST");
|
||||||
|
error2Dict.setName("Error 2 test. Two ar \\%QW.");
|
||||||
|
Mockito.when(errorCodeDictionary.getSingleObjectByID(2L)).thenReturn(error2Dict);
|
||||||
|
ErrorCodeDictionary error3Dict = new ErrorCodeDictionary();
|
||||||
|
error3Dict.setId(3L);
|
||||||
|
error3Dict.setCode("TEST");
|
||||||
|
error3Dict.setName("Error 3 test only.");
|
||||||
|
Mockito.when(errorCodeDictionary.getSingleObjectByID(3L)).thenReturn(error3Dict);
|
||||||
|
Mockito.when(imdgProvider.getImdg(IMDGDistributedNames.Map_ErrorCodeDictionary, ErrorCodeDictionary.class))
|
||||||
|
.thenReturn(errorCodeDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
IMDGMessageResolver resolver = new IMDGMessageResolver(imdgProvider);
|
IMDGMessageResolver resolver = new IMDGMessageResolver(imdgProvider);
|
||||||
|
|
||||||
|
|
@ -39,20 +50,32 @@ class IMDGMessageResolverTest {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
String text = resolver.resolve(new EnumMessage(err1, "one only this"));
|
String text = resolver.resolve(new EnumMessage(err1, "one only this"));
|
||||||
//assertEquals("Error 1 test. Two arg one only this, %s.", text);
|
assertEquals("1 Error 1 test. Two arg one only this, .", text);
|
||||||
// java.util.MissingFormatArgumentException: Format specifier '%s'
|
// java.util.MissingFormatArgumentException: Format specifier '%s'
|
||||||
assertEquals("(1) args [one only this]", text);
|
// assertEquals("(1) args [one only this]", text);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
String text = resolver.resolve(new EnumMessage(err1));
|
String text = resolver.resolve(new EnumMessage(err1));
|
||||||
//assertEquals("Error 1 test. Two arg %s, %s.", text);
|
assertEquals("1 Error 1 test. Two arg , .", text);
|
||||||
// java.util.MissingFormatArgumentException: Format specifier '%s'
|
// java.util.MissingFormatArgumentException: Format specifier '%s'
|
||||||
assertEquals("(1) args []", text);
|
// assertEquals("(1) args []", text);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
String text = resolver.resolve(new EnumMessage(ClearingErrorInternalTest.TestError2, "text"));
|
||||||
|
// java.util.UnknownFormatConversionException: Conversion = 'Q'
|
||||||
|
assertEquals("(2) args [text]", text);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
String text = resolver.resolve(new EnumMessage(ClearingErrorInternalTest.TestError3, "text"));
|
||||||
|
assertEquals("3 Error 3 test only.", text);
|
||||||
|
|
||||||
|
text = resolver.resolve(new EnumMessage(ClearingErrorInternalTest.TestError3));
|
||||||
|
assertEquals("3 Error 3 test only.", text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum ClearingErrorInternalTest implements IErrorEnumId { // see ClearingErrorInternal
|
enum ClearingErrorInternalTest implements IErrorEnumId { // see ClearingErrorInternal
|
||||||
TestError(1L);
|
TestError(1L), TestError2(2L), TestError3(3L);
|
||||||
private final Long id;
|
private final Long id;
|
||||||
|
|
||||||
ClearingErrorInternalTest(Long id) {
|
ClearingErrorInternalTest(Long id) {
|
||||||
|
|
|
||||||
|
|
@ -67,11 +67,13 @@ public class KSRepCashNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
||||||
|
|
||||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||||
String sql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.TM_T, RegistryTradingParams.OM_T).build();
|
String sql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.TM_T, RegistryTradingParams.OM_T).build();
|
||||||
List<Long> sessionIds = params.getSessionId();
|
|
||||||
if (sessionIds == null || sessionIds.isEmpty()) sessionIds = getSessionIdsForCurrentDate(sessionImdg);
|
|
||||||
ImdgPredicate finalPredicate = pb.and(
|
ImdgPredicate finalPredicate = pb.and(
|
||||||
pb.in("sessionId", sessionIds.toArray(new Long[0])),
|
pb.not(pb.in("registryStatus",
|
||||||
pb.equals("clearingDate", nowDate),
|
RegistryStatus.CLRD.getKey(),
|
||||||
|
RegistryStatus.UNCV.getKey(),
|
||||||
|
RegistryStatus.FAIL.getKey(),
|
||||||
|
RegistryStatus.NACK.getKey(),
|
||||||
|
RegistryStatus.NACC.getKey())),
|
||||||
pb.sql(sql),
|
pb.sql(sql),
|
||||||
pb.or(
|
pb.or(
|
||||||
pb.equals("accountType", AccountType.Clrn.getKey()),
|
pb.equals("accountType", AccountType.Clrn.getKey()),
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,14 @@ public class KSRepDepoNettoReportBuilder extends CSVReportBuilder<SessionIdParam
|
||||||
LocalDate nowDate = LocalDate.now();
|
LocalDate nowDate = LocalDate.now();
|
||||||
|
|
||||||
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
ImdgPredicateBuilder pb = registryImdg.predicateBuilder();
|
||||||
List<Long> sessionIds = params.getSessionId();
|
|
||||||
if (sessionIds == null || sessionIds.isEmpty()) sessionIds = getSessionIdsForCurrentDate(sessionImdg);
|
|
||||||
String sql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.TS_T, RegistryTradingParams.OS_T).build();
|
String sql = RegistryCodeSqlBuilder.getInstance(RegistryTradingParams.TS_T, RegistryTradingParams.OS_T).build();
|
||||||
ImdgPredicate finalPredicate = pb.and(
|
ImdgPredicate finalPredicate = pb.and(
|
||||||
pb.in("sessionId", sessionIds.toArray(new Long[0])),
|
pb.not(pb.in("registryStatus",
|
||||||
pb.equals("clearingDate", nowDate),
|
RegistryStatus.CLRD.getKey(),
|
||||||
|
RegistryStatus.UNCV.getKey(),
|
||||||
|
RegistryStatus.FAIL.getKey(),
|
||||||
|
RegistryStatus.NACK.getKey(),
|
||||||
|
RegistryStatus.NACC.getKey())),
|
||||||
pb.sql(sql),
|
pb.sql(sql),
|
||||||
pb.equals("accountType", AccountType.Depo.getKey()),
|
pb.equals("accountType", AccountType.Depo.getKey()),
|
||||||
pb.notNull("account")
|
pb.notNull("account")
|
||||||
|
|
|
||||||
|
|
@ -435,6 +435,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_1.setGroupId(Long.MAX_VALUE);
|
registry_1.setGroupId(Long.MAX_VALUE);
|
||||||
registry_1.setClearingDate(LocalDate.now());
|
registry_1.setClearingDate(LocalDate.now());
|
||||||
registry_1.setRegistryCode("OM_T");
|
registry_1.setRegistryCode("OM_T");
|
||||||
|
registry_1.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||||
registry_1.setRegistryDesignation(RegistryDesignation.O.getKey());
|
registry_1.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||||
registry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
registry_1.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||||
registry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
registry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||||
|
|
@ -450,6 +451,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_2.setGroupId(Long.MAX_VALUE);
|
registry_2.setGroupId(Long.MAX_VALUE);
|
||||||
registry_2.setClearingDate(LocalDate.now());
|
registry_2.setClearingDate(LocalDate.now());
|
||||||
registry_2.setRegistryCode("TM_T");
|
registry_2.setRegistryCode("TM_T");
|
||||||
|
registry_2.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||||
registry_2.setRegistryDesignation(RegistryDesignation.T.getKey());
|
registry_2.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||||
registry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
registry_2.setRegistryInstrumentType(RegistryInstrumentType.M.getKey());
|
||||||
registry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
registry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||||
|
|
@ -499,6 +501,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_1.setRegistryCode("TS_T");
|
registry_1.setRegistryCode("TS_T");
|
||||||
registry_1.setRegistryDesignation(RegistryDesignation.T.getKey());
|
registry_1.setRegistryDesignation(RegistryDesignation.T.getKey());
|
||||||
registry_1.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
registry_1.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
||||||
|
registry_1.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||||
registry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
registry_1.setRegistryUnit(RegistryUnit.T.getKey());
|
||||||
registry_1.setSecuritySymbol("SECURITY_SYMBOL");
|
registry_1.setSecuritySymbol("SECURITY_SYMBOL");
|
||||||
registry_1.setSessionId(sessionId);
|
registry_1.setSessionId(sessionId);
|
||||||
|
|
@ -516,6 +519,7 @@ public class ReportServiceTest_KS {
|
||||||
registry_2.setRegistryDesignation(RegistryDesignation.O.getKey());
|
registry_2.setRegistryDesignation(RegistryDesignation.O.getKey());
|
||||||
registry_2.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
registry_2.setRegistryInstrumentType(RegistryInstrumentType.S.getKey());
|
||||||
registry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
registry_2.setRegistryUnit(RegistryUnit.T.getKey());
|
||||||
|
registry_2.setRegistryStatus(RegistryStatus.PROC.getKey());
|
||||||
registry_2.setSecuritySymbol("SECURITY_SYMBOL");
|
registry_2.setSecuritySymbol("SECURITY_SYMBOL");
|
||||||
registry_2.setSessionId(sessionId);
|
registry_2.setSessionId(sessionId);
|
||||||
registry_2.setAccount("ACCOUNT");
|
registry_2.setAccount("ACCOUNT");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue