From 0db6e3f4c5df464f54888417463dc622cf07733d Mon Sep 17 00:00:00 2001 From: 16358 <1635849544@qq.com> Date: Tue, 14 Jan 2025 10:20:20 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=8A=A5=E8=A1=A8=E5=85=AC=E5=BC=8F?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FormulaOperatipnImpl.java | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/shkd-cosmic-debug/src/main/java/shkd/epm/servicehelper/impl/FormulaOperatipnImpl.java b/shkd-cosmic-debug/src/main/java/shkd/epm/servicehelper/impl/FormulaOperatipnImpl.java index fb0d314..8507f06 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/epm/servicehelper/impl/FormulaOperatipnImpl.java +++ b/shkd-cosmic-debug/src/main/java/shkd/epm/servicehelper/impl/FormulaOperatipnImpl.java @@ -30,11 +30,6 @@ public class FormulaOperatipnImpl implements FormulaOperatipnService { Map param1 = (Map) cast.get("param"); //公共参数--财年 组织 期间 Map param2 = (Map) cast.get("commParam"); - - //获取指定预算体系id - QFilter shownumber = new QFilter("shownumber", "=", "CXHB_TIXI"); - DynamicObject priceModel = BusinessDataServiceHelper.loadSingle("bcm_model","id", shownumber.toArray()); - //遍历公式 Iterator iterator = param1.entrySet().iterator(); while (iterator.hasNext()){ @@ -42,24 +37,36 @@ public class FormulaOperatipnImpl implements FormulaOperatipnService { key = (String)next.getKey(); //["","","1002001","QMZMYEA","0","0","",""] ArrayList value = (ArrayList) next.getValue(); - typeSet.add((String)value.get(2)); + typeSet.add((String)value.get(3)); + + //获取指定预算体系id + String budgetsystem = value.get(0); + Long priceModelid = 0L; + if(budgetsystem.isEmpty()){ + QFilter shownumber = new QFilter("shownumber", "=", "CX01"); + DynamicObject priceModel = BusinessDataServiceHelper.loadSingle("epm_model","id", shownumber.toArray()); + }else{ + QFilter shownumber = new QFilter("shownumber", "=", budgetsystem); + DynamicObject priceModel = BusinessDataServiceHelper.loadSingle("epm_model","id", shownumber.toArray()); + priceModelid = (Long)priceModel.getPkValue(); + } + ArrayList> maps = makeReslutMap(value); - Long priceModelid = (Long)priceModel.getPkValue(); if("expensebudget".equals(formulaName)){ //获取费用预算 BgControlServiceImpl bgControlService = new BgControlServiceImpl(); String json = bgControlService.queryBalanceWithoutCentralized(priceModelid, maps, typeSet, false); // 解析 JSON 数据 - JSONObject jsonObject = new JSONObject(json); - JSONArray dataArray = jsonObject.getJSONArray("data"); - JSONObject firstEntry = dataArray.getJSONObject(0); - // 获取 budget 参数 - int budgetValue = firstEntry.getInt("budget"); - log.info("Budget: " + budgetValue); + JSONArray jsonArray = new JSONArray(json); + JSONObject jsonObject = jsonArray.getJSONObject(0); + + // 获取 actual 的数额 + int actualAmount = jsonObject.getInt("actual"); + log.info("actual: " + actualAmount); resultStr = "{\n" + " \"id\":"+key+"\n" + " {\n" + - " \"v\":"+budgetValue+"\n" + + " \"v\":"+actualAmount+"\n" + " \"type\":1\n" + " }\n" + " } "; @@ -84,22 +91,27 @@ public class FormulaOperatipnImpl implements FormulaOperatipnService { //把参数组装成查询预算所需的格式 public ArrayList> makeReslutMap(ArrayList value){ - - ArrayList> resultMap = new ArrayList(){{ - add( - new HashMap() {{ - put("Entity", value.get(0)); - put("Account", value.get(1)); - put("Version", value.get(3)); - put("Currency", value.get(4)); - put("AuditTrail", value.get(5)); - put("ChangeType", value.get(6)); - put("DataType", value.get(7)); - put("Metric", value.get(8)); - put("BudgetPeriod", value.get(9)); - }} - ); - }}; + ArrayList> resultMap = new ArrayList>(); + Map map = new HashMap(); + map.put("Entity", value.get(1)); + map.put("Account", value.get(2)); + map.put("Version", value.get(4)); + map.put("Currency", value.get(5)); + map.put("AuditTrail", value.get(6)); + map.put("ChangeType", value.get(7)); + map.put("DataType", value.get(8)); + map.put("Metric", value.get(9)); + map.put("BudgetPeriod", value.get(10)); +// map.put("Entity", "Entity"); +// map.put("Account", "Account"); +// map.put("Version", "Version"); +// map.put("Currency", "Currency"); +// map.put("AuditTrail", "Currency"); +// map.put("ChangeType", "ChangeType"); +// map.put("DataType", "DataType"); +// map.put("Metric", "Metric"); +// map.put("BudgetPeriod", "BudgetPeriod"); + resultMap.add(map); return resultMap; } }