{"id":97417,"date":"2025-02-14T10:15:52","date_gmt":"2025-02-14T06:45:52","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/s1-1imj\/"},"modified":"2025-02-14T10:15:52","modified_gmt":"2025-02-14T06:45:52","slug":"s1-1imj","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/s1-1imj\/","title":{"rendered":"S1"},"content":{"rendered":"<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\n-- New batch query\nselect CLIENT_NBR, BRANCH_CD, ACCOUNT_CD, equity_total_amt AS MARKET_VALUE, CURRENCY_CD \nfrom TACCOUNT_BALANCE\nwhere (CLIENT_NBR, BRANCH_CD, ACCOUNT_CD, CURRENCY_CD) in \n(\n    &lt;foreach collection=\"accountList\" item=\"account\" separator=\",\"&gt;\n        (#{account.clientNumber}, #{account.branchCode}, #{account.accountCode}, #{account.currencyCode})\n    &lt;\/foreach&gt;\n)\n\n\n\n\u2014\u2014\n\nprivate void updateMarketValueFromBfs(List&lt;ProductSnapshot&gt; productSnapshots) {\n    if (productSnapshots == null || productSnapshots.isEmpty()) {\n        return;\n    }\n\n    \/\/ Convert snapshots to AccountValueData objects\n    List&lt;AccountValueData&gt; accountValueDataList = productSnapshots.stream()\n        .map(snapshot -&gt; {\n            AccountValueData data = new AccountValueData();\n            data.setClientNumber(snapshot.getClientNbr());\n            data.setBranchCode(snapshot.getBranchCd());\n            data.setAccountCode(snapshot.getAccountCd());\n            data.setCurrencyCode(AccountValueData.CURRENCY_CODE_CDN);\n            return data;\n        })\n        .collect(Collectors.toList());\n\n    \/\/ Single batch query to get all market values\n    Map&lt;String, BigDecimal&gt; marketValues = accountDao.getAccountMarketValues(accountValueDataList);\n\n    \/\/ Update snapshots with market values\n    for (ProductSnapshot snapshot : productSnapshots) {\n        String key = String.format(\"%s-%s-%s-%s\", \n            snapshot.getClientNbr(),\n            snapshot.getBranchCd(),\n            snapshot.getAccountCd(),\n            AccountValueData.CURRENCY_CODE_CDN);\n        snapshot.setBfsMarketValue(marketValues.getOrDefault(key, BigDecimal.ZERO));\n    }\n}\n\n\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#8212; 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 ( &lt;foreach collection=&#8221;accountList&#8221; item=&#8221;account&#8221; separator=&#8221;,&#8221;&gt; (#{account.clientNumber}, #{account.branchCode}, #{account.accountCode}, #{account.currencyCode}) &lt;\/foreach&gt; ) \u2014\u2014 private void updateMarketValueFromBfs(List&lt;ProductSnapshot&gt; productSnapshots) { if (productSnapshots == null || productSnapshots.isEmpty()) { return; } \/\/ Convert snapshots to AccountValueData objects List&lt;AccountValueData&gt; accountValueDataList = &hellip;<\/p>\n","protected":false},"author":2,"featured_media":97418,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-97417","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/97417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=97417"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/97417\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/97418"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=97417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=97417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=97417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}