برنامه نویسی

S1


-- New batch query
select CLIENT_NBR, BRANCH_CD, ACCOUNT_CD, equity_total_amt AS MARKET_VALUE, CURRENCY_CD 
from TACCOUNT_BALANCE
where (CLIENT_NBR, BRANCH_CD, ACCOUNT_CD, CURRENCY_CD) in 
(
    <foreach collection="accountList" item="account" separator=",">
        (#{account.clientNumber}, #{account.branchCode}, #{account.accountCode}, #{account.currencyCode})
    </foreach>
)



——

private void updateMarketValueFromBfs(List<ProductSnapshot> productSnapshots) {
    if (productSnapshots == null || productSnapshots.isEmpty()) {
        return;
    }

    // Convert snapshots to AccountValueData objects
    List<AccountValueData> accountValueDataList = productSnapshots.stream()
        .map(snapshot -> {
            AccountValueData data = new AccountValueData();
            data.setClientNumber(snapshot.getClientNbr());
            data.setBranchCode(snapshot.getBranchCd());
            data.setAccountCode(snapshot.getAccountCd());
            data.setCurrencyCode(AccountValueData.CURRENCY_CODE_CDN);
            return data;
        })
        .collect(Collectors.toList());

    // Single batch query to get all market values
    Map<String, BigDecimal> marketValues = accountDao.getAccountMarketValues(accountValueDataList);

    // Update snapshots with market values
    for (ProductSnapshot snapshot : productSnapshots) {
        String key = String.format("%s-%s-%s-%s", 
            snapshot.getClientNbr(),
            snapshot.getBranchCd(),
            snapshot.getAccountCd(),
            AccountValueData.CURRENCY_CODE_CDN);
        snapshot.setBfsMarketValue(marketValues.getOrDefault(key, BigDecimal.ZERO));
    }
}


نوشته های مشابه

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

دکمه بازگشت به بالا