http://jira.mfd.msk:8088/browse/CLS-25 добавил класс LiabilitiesClaimsAssets. TODO заполнение по CLS-25
This commit is contained in:
parent
b25d9de2bd
commit
b67179ec8b
12 changed files with 652 additions and 1 deletions
|
|
@ -0,0 +1,229 @@
|
|||
package ru.clearing.classes.transaction.data.execution;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
|
||||
public class LiabilitiesClaimsAssets extends BusinessObject {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Long companyId;
|
||||
private Instant clearingDate;
|
||||
private Long accountId;
|
||||
private String accountType;
|
||||
private String account;
|
||||
private BigDecimal liabilitiesQuantity;
|
||||
private BigDecimal claimsQuantity;
|
||||
private String currency;
|
||||
private Instant settlementDate;
|
||||
private Instant tradingDate;
|
||||
private Instant refundDate;
|
||||
private BigDecimal price;
|
||||
private Long securityId;
|
||||
private String tradingCode;
|
||||
private String clearingCode;
|
||||
private String shortName;
|
||||
private String contract;
|
||||
private String comment;
|
||||
private String fullName;
|
||||
private Long parentId;
|
||||
private Long liabilitiesClaimsMoneyId;
|
||||
private Long clearingStatus;
|
||||
private Long paymentId;
|
||||
private Long refundPaymentId;
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
public void setCompanyId(Long value) {
|
||||
this.companyId = value;
|
||||
}
|
||||
|
||||
public Instant getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(Instant value) {
|
||||
this.clearingDate = value;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(Long value) {
|
||||
this.accountId = value;
|
||||
}
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(String value) {
|
||||
this.accountType = value;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String value) {
|
||||
this.account = value;
|
||||
}
|
||||
|
||||
public BigDecimal getLiabilitiesQuantity() {
|
||||
return liabilitiesQuantity;
|
||||
}
|
||||
|
||||
public void setLiabilitiesQuantity(BigDecimal value) {
|
||||
this.liabilitiesQuantity = value;
|
||||
}
|
||||
|
||||
public BigDecimal getClaimsQuantity() {
|
||||
return claimsQuantity;
|
||||
}
|
||||
|
||||
public void setClaimsQuantity(BigDecimal value) {
|
||||
this.claimsQuantity = value;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String value) {
|
||||
this.currency = value;
|
||||
}
|
||||
|
||||
public Instant getSettlementDate() {
|
||||
return settlementDate;
|
||||
}
|
||||
|
||||
public void setSettlementDate(Instant value) {
|
||||
this.settlementDate = value;
|
||||
}
|
||||
|
||||
public Instant getTradingDate() {
|
||||
return tradingDate;
|
||||
}
|
||||
|
||||
public void setTradingDate(Instant value) {
|
||||
this.tradingDate = value;
|
||||
}
|
||||
|
||||
public Instant getRefundDate() {
|
||||
return refundDate;
|
||||
}
|
||||
|
||||
public void setRefundDate(Instant value) {
|
||||
this.refundDate = value;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal value) {
|
||||
this.price = value;
|
||||
}
|
||||
|
||||
public Long getSecurityId() {
|
||||
return securityId;
|
||||
}
|
||||
|
||||
public void setSecurityId(Long value) {
|
||||
this.securityId = value;
|
||||
}
|
||||
|
||||
public String getTradingCode() {
|
||||
return tradingCode;
|
||||
}
|
||||
|
||||
public void setTradingCode(String value) {
|
||||
this.tradingCode = value;
|
||||
}
|
||||
|
||||
public String getClearingCode() {
|
||||
return clearingCode;
|
||||
}
|
||||
|
||||
public void setClearingCode(String value) {
|
||||
this.clearingCode = value;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String value) {
|
||||
this.shortName = value;
|
||||
}
|
||||
|
||||
public String getContract() {
|
||||
return contract;
|
||||
}
|
||||
|
||||
public void setContract(String value) {
|
||||
this.contract = value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String value) {
|
||||
this.comment = value;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String value) {
|
||||
this.fullName = value;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long value) {
|
||||
this.parentId = value;
|
||||
}
|
||||
|
||||
public Long getLiabilitiesClaimsMoneyId() {
|
||||
return liabilitiesClaimsMoneyId;
|
||||
}
|
||||
|
||||
public void setLiabilitiesClaimsMoneyId(Long value) {
|
||||
this.liabilitiesClaimsMoneyId = value;
|
||||
}
|
||||
|
||||
public Long getClearingStatus() {
|
||||
return clearingStatus;
|
||||
}
|
||||
|
||||
public void setClearingStatus(Long value) {
|
||||
this.clearingStatus = value;
|
||||
}
|
||||
|
||||
public Long getPaymentId() {
|
||||
return paymentId;
|
||||
}
|
||||
|
||||
public void setPaymentId(Long value) {
|
||||
this.paymentId = value;
|
||||
}
|
||||
|
||||
public Long getRefundPaymentId() {
|
||||
return refundPaymentId;
|
||||
}
|
||||
|
||||
public void setRefundPaymentId(Long value) {
|
||||
this.refundPaymentId = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
package ru.spcex.clearing.imdg.businessobject;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.transaction.data.execution.LiabilitiesClaimsAssets;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.base.TemplateMapStore;
|
||||
import ru.spcex.platform.utils.time.TimeUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Component
|
||||
public class LiabilitiesClaimsAssetsMapStore extends TemplateMapStore<LiabilitiesClaimsAssets> {
|
||||
|
||||
public LiabilitiesClaimsAssetsMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapName() {
|
||||
return IMDGDistributedNames.Map_LiabilitiesClaimsAssets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return "LIABILITIES_CLAIMS_ASSETS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getFields() {
|
||||
return new String[]{
|
||||
"ID", "COMPANY_ID", "CREATED_AT", "UPDATED_AT", "CLEARING_DATE", "ACCOUNT_ID", "ACCOUNT_TYPE", "ACCOUNT",
|
||||
"LIABILITIES_QUANTITY", "CLAIMS_QUANTITY", "CURRENCY", "SETTLEMENT_DATE", "TRADING_DATE", "REFUND_DATE",
|
||||
"PRICE", "SECURITY_ID", "TRADING_CODE", "CLEARING_CODE", "SHORT_NAME", "CONTRACT", "COMMENT", "FULL_NAME",
|
||||
"PARENT_ID", "LIABILITIES_CLAIMS_MONEY_ID", "CLEARING_STATUS", "PAYMENT_ID", "REFUND_PAYMENT_ID"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiabilitiesClaimsAssets objectReader(ResultSet resultSet) throws SQLException {
|
||||
LiabilitiesClaimsAssets object = new LiabilitiesClaimsAssets();
|
||||
object.setId(resultSet.getObject("ID", Long.class));
|
||||
object.setCompanyId(resultSet.getObject("COMPANY_ID", Long.class));
|
||||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setClearingDate(getInstantFromTimestamp(resultSet, "CLEARING_DATE"));
|
||||
object.setAccountId(resultSet.getObject("ACCOUNT_ID", Long.class));
|
||||
object.setAccountType(resultSet.getObject("ACCOUNT_TYPE", String.class));
|
||||
object.setAccount(resultSet.getObject("ACCOUNT", String.class));
|
||||
object.setLiabilitiesQuantity(resultSet.getObject("LIABILITIES_QUANTITY", BigDecimal.class));
|
||||
object.setClaimsQuantity(resultSet.getObject("CLAIMS_QUANTITY", BigDecimal.class));
|
||||
object.setCurrency(resultSet.getObject("CURRENCY", String.class));
|
||||
object.setSettlementDate(getInstantFromTimestamp(resultSet, "SETTLEMENT_DATE"));
|
||||
object.setTradingDate(getInstantFromTimestamp(resultSet, "TRADING_DATE"));
|
||||
object.setRefundDate(getInstantFromTimestamp(resultSet, "REFUND_DATE"));
|
||||
object.setPrice(resultSet.getObject("PRICE", BigDecimal.class));
|
||||
object.setSecurityId(resultSet.getObject("SECURITY_ID", Long.class));
|
||||
object.setTradingCode(resultSet.getObject("TRADING_CODE", String.class));
|
||||
object.setClearingCode(resultSet.getObject("CLEARING_CODE", String.class));
|
||||
object.setShortName(resultSet.getObject("SHORT_NAME", String.class));
|
||||
object.setContract(resultSet.getObject("CONTRACT", String.class));
|
||||
object.setComment(resultSet.getObject("COMMENT", String.class));
|
||||
object.setFullName(resultSet.getObject("FULL_NAME", String.class));
|
||||
object.setParentId(resultSet.getObject("PARENT_ID", Long.class));
|
||||
object.setLiabilitiesClaimsMoneyId(resultSet.getObject("LIABILITIES_CLAIMS_MONEY_ID", Long.class));
|
||||
object.setClearingStatus(resultSet.getObject("CLEARING_STATUS", Long.class));
|
||||
object.setPaymentId(resultSet.getObject("PAYMENT_ID", Long.class));
|
||||
object.setRefundPaymentId(resultSet.getObject("REFUND_PAYMENT_ID", Long.class));
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] objectToField(LiabilitiesClaimsAssets object) {
|
||||
Object[] args = new Object[]{
|
||||
object.getId(),
|
||||
object.getCompanyId(),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getAccountId(),
|
||||
object.getAccountType(),
|
||||
object.getAccount(),
|
||||
object.getLiabilitiesQuantity(),
|
||||
object.getClaimsQuantity(),
|
||||
object.getCurrency(),
|
||||
TimeUtil.toDateFromInstant(object.getSettlementDate()),
|
||||
TimeUtil.toDateFromInstant(object.getTradingDate()),
|
||||
TimeUtil.toDateFromInstant(object.getRefundDate()),
|
||||
object.getPrice(),
|
||||
object.getSecurityId(),
|
||||
object.getTradingCode(),
|
||||
object.getClearingCode(),
|
||||
object.getShortName(),
|
||||
object.getContract(),
|
||||
object.getComment(),
|
||||
object.getFullName(),
|
||||
object.getParentId(),
|
||||
object.getLiabilitiesClaimsMoneyId(),
|
||||
object.getClearingStatus(),
|
||||
object.getPaymentId(),
|
||||
object.getRefundPaymentId()
|
||||
};
|
||||
return args;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -45,11 +45,34 @@
|
|||
<version>5.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- IMDG clearing system -->
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>classes</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-enum</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>dictionary</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-imdg-api-hazelcast-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package ru.spcex.clearing.reports.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import ru.spcex.clearing.reports.config.element.ReportsServiceSettings;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.service.HazelcastService;
|
||||
|
||||
@Configuration
|
||||
public class ClearingImdgConfig {
|
||||
private static ThreadPoolTaskExecutor createThreadPoolTaskExecutor(int maxPoolSz, boolean waitForCompletion) {
|
||||
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
|
||||
if (maxPoolSz > 2) {
|
||||
pool.setKeepAliveSeconds(60);
|
||||
pool.setAllowCoreThreadTimeOut(true);
|
||||
}
|
||||
pool.setCorePoolSize(maxPoolSz);
|
||||
pool.setWaitForTasksToCompleteOnShutdown(waitForCompletion);
|
||||
return pool;
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorHazelcastClientInitializer")
|
||||
public ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer() {
|
||||
return createThreadPoolTaskExecutor(1, true);
|
||||
}
|
||||
|
||||
@Bean(name = "taskExecutorIdGeneratorAwaiter")
|
||||
public ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter() {
|
||||
return createThreadPoolTaskExecutor(1, false);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@Bean
|
||||
public ImdgProvider imdgProvider(
|
||||
@Qualifier("taskExecutorHazelcastClientInitializer") ThreadPoolTaskExecutor taskExecutorHazelcastClientInitializer,
|
||||
@Qualifier("taskExecutorIdGeneratorAwaiter") ThreadPoolTaskExecutor taskExecutorIdGeneratorAwaiter,
|
||||
ReportsServiceSettings settings
|
||||
) {
|
||||
return new HazelcastService(taskExecutorHazelcastClientInitializer,
|
||||
taskExecutorIdGeneratorAwaiter,
|
||||
settings.getHazelcast());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package ru.spcex.clearing.reports.config.element;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
//import ru.spcex.clearing.platform.messaging.config.element.KafkaConsumerSettings;
|
||||
//import ru.spcex.clearing.platform.messaging.config.element.KafkaProducerSettings;
|
||||
import ru.spcex.platform.imdg.iml.hazelcast.config.HazelcastClientParams;
|
||||
|
||||
@Component
|
||||
@PropertySource("file:${spring.config.location}/application.properties")
|
||||
//todo for test @PropertySource("classpath:application.properties")
|
||||
@ConfigurationProperties("reports-service")
|
||||
public class ReportsServiceSettings {
|
||||
private HazelcastClientParams hazelcast;
|
||||
// private KafkaConsumerSettings kafkaConsumer;
|
||||
// private KafkaProducerSettings kafkaProducer;
|
||||
|
||||
public HazelcastClientParams getHazelcast() {
|
||||
return hazelcast;
|
||||
}
|
||||
|
||||
public void setHazelcast(HazelcastClientParams hazelcast) {
|
||||
this.hazelcast = hazelcast;
|
||||
}
|
||||
|
||||
// public KafkaConsumerSettings getKafkaConsumer() {
|
||||
// return kafkaConsumer;
|
||||
// }
|
||||
//
|
||||
// public void setKafkaConsumer(KafkaConsumerSettings kafkaConsumer) {
|
||||
// this.kafkaConsumer = kafkaConsumer;
|
||||
// }
|
||||
//
|
||||
// public KafkaProducerSettings getKafkaProducer() {
|
||||
// return kafkaProducer;
|
||||
// }
|
||||
//
|
||||
// public void setKafkaProducer(KafkaProducerSettings kafkaProducer) {
|
||||
// this.kafkaProducer = kafkaProducer;
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package ru.spcex.clearing.reports.services;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.spcex.clearing.reports.reports.AbstractReport;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ReportDataCollector<T extends AbstractReport> {
|
||||
public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy'T'HH:mm:ss");
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
/**
|
||||
* T extends ReportWithPeriod
|
||||
* @return
|
||||
*/
|
||||
abstract public List<T> collectReportWithPeriod(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
/**
|
||||
* T extends ReportWithClearingStatus
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
abstract public List<T> collectReportWithClearingStatus(LocalDate startDate, LocalDate endDate, String clearingStatus);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param dateTimeNow LocalDateTime.now()
|
||||
* @return
|
||||
*/
|
||||
abstract public String getFileName(LocalDate startDate, LocalDate endDate, LocalDateTime dateTimeNow);
|
||||
}
|
||||
|
|
@ -52,6 +52,7 @@ public class ReportsService {
|
|||
|
||||
|
||||
/* ========= БТ 17.1 ========== */
|
||||
// todo see ReportDataCollector
|
||||
ReportBR_0420315_P1 reportBR_0420315_p1 = new ReportBR_0420315_P1(LocalDate.now(),
|
||||
LocalDate.now(),
|
||||
"BR",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
package ru.spcex.clearing.reports.services.collector;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.generated.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.misc.Listing;
|
||||
import ru.clearing.classes.transaction.data.execution.LiabilitiesClaimsAssets;
|
||||
import ru.clearing.platform.dictionary.ClearingStatusDictionary;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.reports.reports.bt_17_1.ReportBR_0420315_P1;
|
||||
import ru.spcex.clearing.reports.services.ReportDataCollector;
|
||||
import ru.spcex.platform.enumeration.ClearingStatus;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class Bt17_1_collector extends ReportDataCollector<ReportBR_0420315_P1> {
|
||||
private Imdg<Company> companyImdg;
|
||||
private Imdg<LiabilitiesClaimsAssets> liabilitiesClaimsAssetsImdg;
|
||||
private Imdg<ClearingMemberCategory> clearingMemberCategoryImdg;
|
||||
private Imdg<ClearingStatusDictionary> clearingStatusDictionaryImdg;
|
||||
private Imdg<Listing> listingImdg;
|
||||
|
||||
@Autowired
|
||||
public Bt17_1_collector(ImdgProvider imdgProvider) {
|
||||
companyImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Company, Company.class);
|
||||
liabilitiesClaimsAssetsImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_LiabilitiesClaimsAssets, LiabilitiesClaimsAssets.class);
|
||||
clearingMemberCategoryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingMemberCategory, ClearingMemberCategory.class);
|
||||
clearingStatusDictionaryImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_ClearingStatusDictionary, ClearingStatusDictionary.class);
|
||||
listingImdg = imdgProvider.getImdg(IMDGDistributedNames.Map_Listing, Listing.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportBR_0420315_P1> collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||
if (startDate.isAfter(endDate)) {
|
||||
throw new IllegalArgumentException("startDate(" + startDate + ") > endDate(" + endDate + ")");
|
||||
}
|
||||
List<ReportBR_0420315_P1> result = new ArrayList<>();
|
||||
|
||||
String ql = String.format("'%s' <= refundDate and refundDate <= '%s'", startDate, endDate);
|
||||
Collection<LiabilitiesClaimsAssets> liabilities = liabilitiesClaimsAssetsImdg.getCollectionObjectsBySQL(ql);
|
||||
for (LiabilitiesClaimsAssets liability : liabilities) {
|
||||
final Long companyId = liability.getCompanyId();
|
||||
Company company = companyImdg.getSingleObjectByID(companyId);
|
||||
if (company != null) {
|
||||
ClearingMemberCategory cmc = clearingMemberCategoryImdg.getSingleObjectByFieldValues(Map.of("companyId", companyId));
|
||||
if (cmc == null || !Arrays.asList("I", "V", "I,V").contains(cmc.getClearingMemberCategory())) {
|
||||
//todo уточнить фильтр need filter by I, V?
|
||||
log.trace("Filtered ClearingMemberCategory[{}].ClearingMemberCategory={}",
|
||||
cmc == null ? null : cmc.getId(), cmc == null ? null : cmc.getClearingMemberCategory());
|
||||
continue;
|
||||
}
|
||||
ClearingStatusDictionary clearingStatus = clearingStatusDictionaryImdg.getSingleObjectByID(liability.getClearingStatus());
|
||||
if (clearingStatus == null || !ClearingStatus.OK.getKey().equals(clearingStatus.getCode())) {
|
||||
continue;
|
||||
}
|
||||
ReportBR_0420315_P1 reportBR_0420315_p1 = new ReportBR_0420315_P1(startDate, endDate,
|
||||
"BR",
|
||||
cmc.getClearingMemberCategory(),
|
||||
clearingStatus.getCode());
|
||||
|
||||
Listing listing;
|
||||
{
|
||||
Map qParam = new HashMap<>();
|
||||
qParam.put("market", "MKRS"); // todo use const
|
||||
qParam.put("securityId", liability.getSecurityId());
|
||||
listing = listingImdg.getSingleObjectByFieldValues(qParam);
|
||||
}
|
||||
// liability.getPrice()// todo как там с учётом валют это делать?
|
||||
Integer contractorQty = StringUtils.isEmpty(liability.getContract()) ? 0 : 1; // todo то суммировать надо. Связь похоже много к 1. // liability.getContract() В данное поле необходимо записать общее количество исполненных договоров, шт. элемент contract из бизнес-объекта liabilitiesClaimsAssets
|
||||
BigDecimal liabilitiesAmount = liability.getPrice() == null ? BigDecimal.ZERO : liability.getPrice(); // todo как правильно считать?
|
||||
ReportBR_0420315_P1.Info_0420315_P1 info_0420315_p1 = new ReportBR_0420315_P1.Info_0420315_P1("companyId",
|
||||
company.getFullName(),
|
||||
listing == null ? null : listing.getMarket(),
|
||||
contractorQty.toString(),
|
||||
liabilitiesAmount.toString());
|
||||
reportBR_0420315_p1.getRows().add(info_0420315_p1);
|
||||
|
||||
result.add(reportBR_0420315_p1);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportBR_0420315_P1> collectReportWithClearingStatus(LocalDate startDate, LocalDate endDate, String clearingStatus) {
|
||||
throw new IllegalStateException("clearingStatus not supported by this class");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getFileName(LocalDate startDate, LocalDate endDate, LocalDateTime dateTimeNow) {
|
||||
return String.format("REPBR.0420315.P1.%s-%s.%s", DATE_FORMATTER.format(startDate), DATE_FORMATTER.format(endDate),
|
||||
DATE_TIME_FORMATTER.format(dateTimeNow));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
server.port=8080
|
||||
server.servlet.context-path=/reports_service
|
||||
spring.main.web-application-type=servlet
|
||||
spring.main.web-application-type=servlet
|
||||
|
||||
reports-service.hazelcast.cluster-members=127.0.0.1:5701
|
||||
reports-service.hazelcast.login=dev
|
||||
reports-service.hazelcast.password=dev-pass
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package ru.spcex.clearing.reports.services.impl;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import ru.spcex.clearing.reports.services.collector.Bt17_1_collector;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class Bt17_1_collectorTest {
|
||||
|
||||
@Test
|
||||
void getFileName() {
|
||||
Bt17_1_collector collector = Mockito.mock(Bt17_1_collector.class);
|
||||
Mockito.when(collector.getFileName(Mockito.any(),Mockito.any(),Mockito.any())).thenCallRealMethod();
|
||||
|
||||
String str = collector.getFileName(LocalDate.of(2020,1,1),
|
||||
LocalDate.of(2020,1,31),
|
||||
LocalDateTime.of(2021,4,20,12,20,44));
|
||||
assertEquals("REPBR.0420315.P1.01.01.2020-31.01.2020.20.04.2021T12:20:44", str);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package ru.spcex.platform.enumeration;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum ClearingStatus implements IEnumKey {
|
||||
OK("OK"),
|
||||
FAIL("FAIL"),
|
||||
MNG("MNG"),
|
||||
PROC("PROC");
|
||||
|
||||
ClearingStatus(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
private String key;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsByKey(String key) {
|
||||
return IEnumKey.super.equalsByKey(key);
|
||||
}
|
||||
}
|
||||
|
|
@ -108,6 +108,8 @@ public final class IMDGDistributedNames {
|
|||
public static final String Map_PaymentInstruction = "Map_PaymentInstruction";
|
||||
public static final String Map_Session = "Map_Session";
|
||||
public static final String Map_Notification = "Map_Notification";
|
||||
public static final String Map_LiabilitiesClaimsAssets = "Map_LiabilitiesClaimsAssets";
|
||||
|
||||
public static final String MAP_SEQUENCE_NAME = "MAP_SEQUENCE_NAME"; // todo вынести idGenerator отдельно и завернуть в метод, чтобы не напрямую обращаться.
|
||||
|
||||
private IMDGDistributedNames() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue