1、报表公式开发

This commit is contained in:
16358 2025-01-14 10:20:20 +08:00
parent 52e52dc9cb
commit 0db6e3f4c5
1 changed files with 42 additions and 30 deletions

View File

@ -30,11 +30,6 @@ public class FormulaOperatipnImpl implements FormulaOperatipnService {
Map param1 = (Map) cast.get("param"); Map param1 = (Map) cast.get("param");
//公共参数--财年 组织 期间 //公共参数--财年 组织 期间
Map param2 = (Map) cast.get("commParam"); 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(); Iterator iterator = param1.entrySet().iterator();
while (iterator.hasNext()){ while (iterator.hasNext()){
@ -42,24 +37,36 @@ public class FormulaOperatipnImpl implements FormulaOperatipnService {
key = (String)next.getKey(); key = (String)next.getKey();
//["","","1002001","QMZMYEA","0","0","",""] //["","","1002001","QMZMYEA","0","0","",""]
ArrayList<String> value = (ArrayList<String>) next.getValue(); ArrayList<String> value = (ArrayList<String>) 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<Map<String, String>> maps = makeReslutMap(value); ArrayList<Map<String, String>> maps = makeReslutMap(value);
Long priceModelid = (Long)priceModel.getPkValue();
if("expensebudget".equals(formulaName)){ if("expensebudget".equals(formulaName)){
//获取费用预算 //获取费用预算
BgControlServiceImpl bgControlService = new BgControlServiceImpl(); BgControlServiceImpl bgControlService = new BgControlServiceImpl();
String json = bgControlService.queryBalanceWithoutCentralized(priceModelid, maps, typeSet, false); String json = bgControlService.queryBalanceWithoutCentralized(priceModelid, maps, typeSet, false);
// 解析 JSON 数据 // 解析 JSON 数据
JSONObject jsonObject = new JSONObject(json); JSONArray jsonArray = new JSONArray(json);
JSONArray dataArray = jsonObject.getJSONArray("data"); JSONObject jsonObject = jsonArray.getJSONObject(0);
JSONObject firstEntry = dataArray.getJSONObject(0);
// 获取 budget 参数 // 获取 actual 的数额
int budgetValue = firstEntry.getInt("budget"); int actualAmount = jsonObject.getInt("actual");
log.info("Budget: " + budgetValue); log.info("actual: " + actualAmount);
resultStr = "{\n" + resultStr = "{\n" +
" \"id\":"+key+"\n" + " \"id\":"+key+"\n" +
" {\n" + " {\n" +
" \"v\":"+budgetValue+"\n" + " \"v\":"+actualAmount+"\n" +
" \"type\":1\n" + " \"type\":1\n" +
" }\n" + " }\n" +
" } "; " } ";
@ -84,22 +91,27 @@ public class FormulaOperatipnImpl implements FormulaOperatipnService {
//把参数组装成查询预算所需的格式 //把参数组装成查询预算所需的格式
public ArrayList<Map<String,String>> makeReslutMap(ArrayList<String> value){ public ArrayList<Map<String,String>> makeReslutMap(ArrayList<String> value){
ArrayList<Map<String,String>> resultMap = new ArrayList<Map<String, String>>();
ArrayList<Map<String,String>> resultMap = new ArrayList(){{ Map<String, String> map = new HashMap<String, String>();
add( map.put("Entity", value.get(1));
new HashMap<String, String>() {{ map.put("Account", value.get(2));
put("Entity", value.get(0)); map.put("Version", value.get(4));
put("Account", value.get(1)); map.put("Currency", value.get(5));
put("Version", value.get(3)); map.put("AuditTrail", value.get(6));
put("Currency", value.get(4)); map.put("ChangeType", value.get(7));
put("AuditTrail", value.get(5)); map.put("DataType", value.get(8));
put("ChangeType", value.get(6)); map.put("Metric", value.get(9));
put("DataType", value.get(7)); map.put("BudgetPeriod", value.get(10));
put("Metric", value.get(8)); // map.put("Entity", "Entity");
put("BudgetPeriod", value.get(9)); // 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; return resultMap;
} }
} }