reports-service http://jira.mfd.msk:8088/browse/CLS-25 понял про вложенность
This commit is contained in:
parent
3f0fe1d901
commit
47df118474
1 changed files with 28 additions and 20 deletions
|
|
@ -23,7 +23,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1, List<ReportBR_0420315_P1>> {
|
||||
public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1, ReportBR_0420315_P1> {
|
||||
protected static final List<String> ALLOW_CLEARING_MEMBER_CATEGORY = Arrays.asList(ClearingCategory.I.getKey(), ClearingCategory.V.getKey());
|
||||
protected static final String ALLOW_CLEARING_STATUS = ClearingStatus.OK.getKey();
|
||||
|
||||
|
|
@ -55,11 +55,15 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ReportBR_0420315_P1> collectReportWithPeriod(LocalDate startDate, LocalDate endDate) {
|
||||
public 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<>();
|
||||
ReportBR_0420315_P1 reportBR_0420315_p1 = new ReportBR_0420315_P1(startDate, endDate,
|
||||
"BR",
|
||||
"I,V", // cmc.getClearingMemberCategory()
|
||||
ALLOW_CLEARING_STATUS //clearingStatus.getCode() "OK"
|
||||
);
|
||||
|
||||
ClearingStatusDictionary allowClearingStatus = clearingStatusDictionaryImdg.getSingleObjectByFieldValues(Map.of("code", ALLOW_CLEARING_STATUS));
|
||||
if (allowClearingStatus == null) {
|
||||
|
|
@ -72,33 +76,35 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
|||
Collection<LiabilitiesClaimsAssets> liabilities = liabilitiesClaimsAssetsImdg.getCollectionObjectsBySQL(ql);
|
||||
|
||||
Map<Long, List<LiabilitiesClaimsAssets>> indexByCompany = MapUtil.indexList(liabilities, LiabilitiesClaimsAssets::getCompanyId);
|
||||
|
||||
for (LiabilitiesClaimsAssets liability : liabilities) {
|
||||
final Long companyId = liability.getCompanyId();
|
||||
for (Map.Entry<Long, List<LiabilitiesClaimsAssets>> companyEntry : indexByCompany.entrySet()) {
|
||||
final Long companyId = companyEntry.getKey();
|
||||
List<LiabilitiesClaimsAssets> liabilitiesOfCompany = companyEntry.getValue();
|
||||
Company company = companyImdg.getSingleObjectByID(companyId);
|
||||
if (company != null) {
|
||||
ClearingMemberCategory cmc = clearingMemberCategoryImdg.getSingleObjectByFieldValues(Map.of("companyId", companyId));
|
||||
String checkCategory = cmc == null ? null : cmc.getClearingMemberCategory();
|
||||
if (!ALLOW_CLEARING_MEMBER_CATEGORY.contains(checkCategory)) {
|
||||
// фильтруются <> I, V
|
||||
log.trace("Filtered ClearingMemberCategory[{}].ClearingMemberCategory={}",
|
||||
cmc == null ? null : cmc.getId(), checkCategory);
|
||||
log.trace("Filtered company[{}] ClearingMemberCategory[{}].ClearingMemberCategory={}",
|
||||
companyId, cmc == null ? null : cmc.getId(), checkCategory);
|
||||
continue;
|
||||
}
|
||||
ReportBR_0420315_P1 reportBR_0420315_p1 = new ReportBR_0420315_P1(startDate, endDate,
|
||||
"BR",
|
||||
cmc.getClearingMemberCategory(),
|
||||
ALLOW_CLEARING_STATUS //clearingStatus.getCode() "OK"
|
||||
);
|
||||
|
||||
Listing listing = findListing(Market.mkrs, liability.getSecurityId());
|
||||
HashSet<String> onMarket = new HashSet<>();
|
||||
|
||||
List<LiabilitiesClaimsAssets> allContract = indexByCompany.get(companyId);
|
||||
long contractorQty;
|
||||
double liabilitiesAmount = 0;
|
||||
{
|
||||
HashSet<String> collectedToSumm = new HashSet<>(); // чтобы дважды не посчитать 1 и тот же контракт
|
||||
for (LiabilitiesClaimsAssets lContract : allContract) {
|
||||
HashSet<Long> onMarketSecurity=new HashSet<>();
|
||||
for (LiabilitiesClaimsAssets lContract : liabilitiesOfCompany) {
|
||||
if (!onMarketSecurity.contains(lContract.getSecurityId())) {
|
||||
Listing listing = findListing(Market.mkrs, lContract.getSecurityId());
|
||||
if (listing!= null) {
|
||||
onMarket.add(listing.getMarket());
|
||||
}
|
||||
onMarketSecurity.add(lContract.getSecurityId());
|
||||
}
|
||||
if (lContract.getPrice() != null && StringUtils.isNotEmpty(lContract.getContract())
|
||||
&& !collectedToSumm.contains(lContract.getContract())) {
|
||||
collectedToSumm.add(lContract.getContract());
|
||||
|
|
@ -107,18 +113,20 @@ public class Bt17_1_P1_collector extends ReportDataCollector<ReportBR_0420315_P1
|
|||
}
|
||||
contractorQty = collectedToSumm.size();
|
||||
}
|
||||
String onMarketString = StringUtils.join(onMarket, ",");
|
||||
if (onMarket.size() != 1) { // Сейчас по коду ожидается один listing.market="MKRS" но потом могут быть несколько
|
||||
log.warn("Market for companyId[{}]: {}", companyId, onMarketString);
|
||||
}
|
||||
ReportBR_0420315_P1.Info_0420315_P1 info_0420315_p1 = new ReportBR_0420315_P1.Info_0420315_P1(company.getId().toString(),
|
||||
company.getFullName(),
|
||||
listing == null ? null : listing.getMarket(),
|
||||
onMarketString,
|
||||
String.valueOf(contractorQty),
|
||||
String.valueOf(liabilitiesAmount));
|
||||
reportBR_0420315_p1.getRows().add(info_0420315_p1);
|
||||
|
||||
result.add(reportBR_0420315_p1);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return reportBR_0420315_p1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue