fix after review
This commit is contained in:
parent
15abb8cbfa
commit
90b8d80ce8
7 changed files with 30 additions and 56 deletions
|
|
@ -27,7 +27,6 @@ import ru.spcex.platform.utils.validation.ValidatorImpl;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
@ -55,10 +54,6 @@ public class ValidationConfig {
|
||||||
return reportRequest -> {
|
return reportRequest -> {
|
||||||
ImdgValidationContext<ReportRequest> context = new ImdgValidationContext<>();
|
ImdgValidationContext<ReportRequest> context = new ImdgValidationContext<>();
|
||||||
context.setValidatedObject(reportRequest);
|
context.setValidatedObject(reportRequest);
|
||||||
|
|
||||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
|
||||||
// todo add dictionary for check reportId
|
|
||||||
|
|
||||||
return new ValidatorImpl<>(context,
|
return new ValidatorImpl<>(context,
|
||||||
EnumPresentRule.instance("reportId",
|
EnumPresentRule.instance("reportId",
|
||||||
ReportRequest::getReportId,
|
ReportRequest::getReportId,
|
||||||
|
|
@ -79,10 +74,6 @@ public class ValidationConfig {
|
||||||
return reportRequestWithSessionId -> {
|
return reportRequestWithSessionId -> {
|
||||||
ImdgValidationContext<ReportRequestWithSessionId> context = new ImdgValidationContext<>();
|
ImdgValidationContext<ReportRequestWithSessionId> context = new ImdgValidationContext<>();
|
||||||
context.setValidatedObject(reportRequestWithSessionId);
|
context.setValidatedObject(reportRequestWithSessionId);
|
||||||
|
|
||||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
|
||||||
// todo add dictionary for check reportId
|
|
||||||
|
|
||||||
return new ValidatorImpl<>(context,
|
return new ValidatorImpl<>(context,
|
||||||
EnumPresentRule.instance("reportId",
|
EnumPresentRule.instance("reportId",
|
||||||
ReportRequestWithSessionId::getReportId,
|
ReportRequestWithSessionId::getReportId,
|
||||||
|
|
@ -109,10 +100,6 @@ public class ValidationConfig {
|
||||||
return reportRequestWithSessionIdList -> {
|
return reportRequestWithSessionIdList -> {
|
||||||
ImdgValidationContext<ReportRequestWithSessionIdList> context = new ImdgValidationContext<>();
|
ImdgValidationContext<ReportRequestWithSessionIdList> context = new ImdgValidationContext<>();
|
||||||
context.setValidatedObject(reportRequestWithSessionIdList);
|
context.setValidatedObject(reportRequestWithSessionIdList);
|
||||||
|
|
||||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
|
||||||
// todo add dictionary for check reportId
|
|
||||||
|
|
||||||
return new ValidatorImpl<>(context,
|
return new ValidatorImpl<>(context,
|
||||||
EnumPresentRule.instance("reportId",
|
EnumPresentRule.instance("reportId",
|
||||||
ReportRequestWithSessionIdList::getReportId,
|
ReportRequestWithSessionIdList::getReportId,
|
||||||
|
|
@ -140,10 +127,6 @@ public class ValidationConfig {
|
||||||
return reportRequestWithPeriod -> {
|
return reportRequestWithPeriod -> {
|
||||||
ImdgValidationContext<ReportRequestWithPeriod> context = new ImdgValidationContext<>();
|
ImdgValidationContext<ReportRequestWithPeriod> context = new ImdgValidationContext<>();
|
||||||
context.setValidatedObject(reportRequestWithPeriod);
|
context.setValidatedObject(reportRequestWithPeriod);
|
||||||
|
|
||||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
|
||||||
// todo add dictionary for check reportId
|
|
||||||
|
|
||||||
return new ValidatorImpl<>(context,
|
return new ValidatorImpl<>(context,
|
||||||
EnumPresentRule.instance("reportId",
|
EnumPresentRule.instance("reportId",
|
||||||
ReportRequestWithPeriod::getReportId,
|
ReportRequestWithPeriod::getReportId,
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,11 @@ package ru.spcex.clearing.reports.errors;
|
||||||
|
|
||||||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||||
|
|
||||||
// todo codes
|
|
||||||
public enum ReportError implements IErrorEnumId {
|
public enum ReportError implements IErrorEnumId {
|
||||||
InternalError(99000L),
|
InternalError(4000L),
|
||||||
UserVerifyDenial(99001L),
|
UserVerifyDenial(4001L),
|
||||||
RequiredFieldEmpty(99002L),
|
RequiredFieldEmpty(4002L),
|
||||||
WrongFieldValue(99004L),
|
WrongFieldValue(4004L),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
|
|
|
||||||
|
|
@ -29,24 +29,16 @@ public class PeriodLiabilitiesClaimsReportBuilder extends LiabilitiesClaimsRepor
|
||||||
@Override
|
@Override
|
||||||
protected Collection<ExecutionFond> getExecutionFondsForReport(SessionIdListParams params) {
|
protected Collection<ExecutionFond> getExecutionFondsForReport(SessionIdListParams params) {
|
||||||
if (params.getSessionIdList() == null || params.getSessionIdList().isEmpty()) return Collections.emptyList();
|
if (params.getSessionIdList() == null || params.getSessionIdList().isEmpty()) return Collections.emptyList();
|
||||||
StringBuilder sql = new StringBuilder("sessionId in (");
|
return executionFondImdg.getCollectionObjectsByPredicate(
|
||||||
for (Long sessionId : params.getSessionIdList()) {
|
executionFondImdg.predicateBuilder().in("sessionId", params.getSessionIdList().toArray(new Long[0]))
|
||||||
sql.append(sessionId).append(",");
|
);
|
||||||
}
|
|
||||||
sql.setLength(sql.length() - 1);
|
|
||||||
sql.append(")");
|
|
||||||
return executionFondImdg.getCollectionObjectsBySQL(sql.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<ExecutionDeposit> getExecutionDepositsForReport(SessionIdListParams params) {
|
protected Collection<ExecutionDeposit> getExecutionDepositsForReport(SessionIdListParams params) {
|
||||||
if (params.getSessionIdList() == null || params.getSessionIdList().isEmpty()) return Collections.emptyList();
|
if (params.getSessionIdList() == null || params.getSessionIdList().isEmpty()) return Collections.emptyList();
|
||||||
StringBuilder sql = new StringBuilder("sessionId in (");
|
return executionDepositImdg.getCollectionObjectsByPredicate(
|
||||||
for (Long sessionId : params.getSessionIdList()) {
|
executionDepositImdg.predicateBuilder().in("sessionId", params.getSessionIdList().toArray(new Long[0]))
|
||||||
sql.append(sessionId).append(",");
|
);
|
||||||
}
|
|
||||||
sql.setLength(sql.length() - 1);
|
|
||||||
sql.append(")");
|
|
||||||
return executionDepositImdg.getCollectionObjectsBySQL(sql.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ public class UnfulfilledDealReportBuilder extends CSVReportBuilder<SessionIdPara
|
||||||
);
|
);
|
||||||
Collection<ExecutionFond> executionFonds = executionFondImdg.getCollectionObjectsByPredicate(predicate);
|
Collection<ExecutionFond> executionFonds = executionFondImdg.getCollectionObjectsByPredicate(predicate);
|
||||||
|
|
||||||
|
lines = new ArrayList<>(executionFonds.size());
|
||||||
for (ExecutionFond executionFond : executionFonds) {
|
for (ExecutionFond executionFond : executionFonds) {
|
||||||
Company company = companyImdg.getSingleObjectByID(executionFond.getCompanyId());
|
Company company = companyImdg.getSingleObjectByID(executionFond.getCompanyId());
|
||||||
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;
|
if (!WorkflowStatus.Active.equalsByKey(company.getWorkflowStatus())) continue;
|
||||||
|
|
@ -81,7 +82,6 @@ public class UnfulfilledDealReportBuilder extends CSVReportBuilder<SessionIdPara
|
||||||
String settleCode = sTrade != null ? sTrade.getClassCode() : null;
|
String settleCode = sTrade != null ? sTrade.getClassCode() : null;
|
||||||
|
|
||||||
int valueIdx = 0;
|
int valueIdx = 0;
|
||||||
lines = new ArrayList<>(executionFonds.size());
|
|
||||||
String[] line = new String[getHeaders().length];
|
String[] line = new String[getHeaders().length];
|
||||||
line[valueIdx++] = id;
|
line[valueIdx++] = id;
|
||||||
line[valueIdx++] = securityId;
|
line[valueIdx++] = securityId;
|
||||||
|
|
|
||||||
|
|
@ -89,16 +89,16 @@ public class ReportService extends QueueConsumer implements InitializingBean {
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
callback(ReportRequest.class)
|
callback(ReportRequest.class)
|
||||||
.setFunction(this::createReport)
|
.setFunction(this::createReport)
|
||||||
.forDestination(Consts.DESTINATION_CREATE_REPORT, callbacks::put);
|
.forDestination(Consts.CREATE_REPORT, callbacks::put);
|
||||||
callback(ReportRequestWithSessionId.class)
|
callback(ReportRequestWithSessionId.class)
|
||||||
.setFunction(this::createReportForSessionId)
|
.setFunction(this::createReportForSessionId)
|
||||||
.forDestination(Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID, callbacks::put);
|
.forDestination(Consts.CREATE_REPORT_FOR_SESSION_ID, callbacks::put);
|
||||||
callback(ReportRequestWithSessionIdList.class)
|
callback(ReportRequestWithSessionIdList.class)
|
||||||
.setFunction(this::createReportForSessionIdList)
|
.setFunction(this::createReportForSessionIdList)
|
||||||
.forDestination(Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID_LIST, callbacks::put);
|
.forDestination(Consts.CREATE_REPORT_FOR_SESSION_ID_LIST, callbacks::put);
|
||||||
callback(ReportRequestWithPeriod.class)
|
callback(ReportRequestWithPeriod.class)
|
||||||
.setFunction(this::createReportForPeriod)
|
.setFunction(this::createReportForPeriod)
|
||||||
.forDestination(Consts.DESTINATION_CREATE_REPORT_FOR_PERIOD, callbacks::put);
|
.forDestination(Consts.CREATE_REPORT_FOR_PERIOD, callbacks::put);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequestWithSessionId, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequestWithSessionId, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID,
|
Consts.CREATE_REPORT_FOR_SESSION_ID,
|
||||||
reportRequestWithSessionIdCnt++,
|
reportRequestWithSessionIdCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -229,7 +229,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequestWithPeriod, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequestWithPeriod, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID_LIST,
|
Consts.CREATE_REPORT_FOR_SESSION_ID_LIST,
|
||||||
reportRequestWithSessionIdListCnt++,
|
reportRequestWithSessionIdListCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -252,7 +252,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT,
|
Consts.CREATE_REPORT,
|
||||||
reportRequestCnt++,
|
reportRequestCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -284,7 +284,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID,
|
Consts.CREATE_REPORT_FOR_SESSION_ID,
|
||||||
reportRequestWithSessionIdCnt++,
|
reportRequestWithSessionIdCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -314,7 +314,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_PERIOD,
|
Consts.CREATE_REPORT_FOR_PERIOD,
|
||||||
reportRequestWithPeriodCnt++,
|
reportRequestWithPeriodCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -341,7 +341,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT,
|
Consts.CREATE_REPORT,
|
||||||
reportRequestCnt++,
|
reportRequestCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -394,7 +394,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID,
|
Consts.CREATE_REPORT_FOR_SESSION_ID,
|
||||||
reportRequestWithSessionIdCnt++,
|
reportRequestWithSessionIdCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -446,7 +446,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID,
|
Consts.CREATE_REPORT_FOR_SESSION_ID,
|
||||||
reportRequestWithSessionIdCnt++,
|
reportRequestWithSessionIdCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -495,7 +495,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID,
|
Consts.CREATE_REPORT_FOR_SESSION_ID,
|
||||||
reportRequestWithSessionIdCnt++,
|
reportRequestWithSessionIdCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -545,7 +545,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID,
|
Consts.CREATE_REPORT_FOR_SESSION_ID,
|
||||||
reportRequestWithSessionIdCnt++,
|
reportRequestWithSessionIdCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
@ -595,7 +595,7 @@ public class ReportServiceTest {
|
||||||
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
String jsonString = TestUtils.getJsonStringForSystem(reportRequest, 0L);
|
||||||
|
|
||||||
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
TestUtils.addRecordToKafka((MockConsumer) reportService.getConsumer(),
|
||||||
Consts.DESTINATION_CREATE_REPORT_FOR_SESSION_ID,
|
Consts.CREATE_REPORT_FOR_SESSION_ID,
|
||||||
reportRequestWithSessionIdCnt++,
|
reportRequestWithSessionIdCnt++,
|
||||||
0,
|
0,
|
||||||
jsonString);
|
jsonString);
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,10 @@ public interface Consts {
|
||||||
String DESTINATION_BANK_ACCOUNT_UPDATE = "bank-account-update";
|
String DESTINATION_BANK_ACCOUNT_UPDATE = "bank-account-update";
|
||||||
String DESTINATION_BANK_ACCOUNT_NEW = "bank-account-new";
|
String DESTINATION_BANK_ACCOUNT_NEW = "bank-account-new";
|
||||||
|
|
||||||
String DESTINATION_CREATE_REPORT = "destination-create-report";
|
String CREATE_REPORT = "create-report";
|
||||||
String DESTINATION_CREATE_REPORT_FOR_SESSION_ID = "destination-create-report-for-session-id";
|
String CREATE_REPORT_FOR_SESSION_ID = "create-report-for-session-id";
|
||||||
String DESTINATION_CREATE_REPORT_FOR_SESSION_ID_LIST = "destination-create-report-for-session-id-list";
|
String CREATE_REPORT_FOR_SESSION_ID_LIST = "create-report-for-session-id-list";
|
||||||
String DESTINATION_CREATE_REPORT_FOR_PERIOD = "destination-create-report-for-period";
|
String CREATE_REPORT_FOR_PERIOD = "create-report-for-period";
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
String ACCOUNT_NEW_SDF01 = "account-new-sdf01";
|
String ACCOUNT_NEW_SDF01 = "account-new-sdf01";
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue