1、报表公式开发
This commit is contained in:
parent
52e52dc9cb
commit
0db6e3f4c5
|
@ -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<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);
|
||||
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<Map<String,String>> makeReslutMap(ArrayList<String> value){
|
||||
|
||||
ArrayList<Map<String,String>> resultMap = new ArrayList(){{
|
||||
add(
|
||||
new HashMap<String, String>() {{
|
||||
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<Map<String,String>> resultMap = new ArrayList<Map<String, String>>();
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue