Commit 0933ef59 authored by kevin's avatar kevin

#

parent b0658e9d
......@@ -174,7 +174,7 @@ public class FormulaAgent {
public static String _buildSql(String getField, String tableName, String filter, String filterValue, Integer period, FormulaContext formulaContext, String year, boolean bool) throws Exception {
String sql = "select " + getField + " from " + tableName + " where 1=1 and " + filter + filterValue;
String sql = "select sum (" + getField + ") as " + getField + " from " + tableName + " where 1=1 and " + filter + filterValue;
String _p = insertZero(formulaContext.getPeriod() - Math.abs(period));
String _period = insertZero(formulaContext.getPeriod());
String per = insertZero((formulaContext.getPeriod() - 1));
......@@ -183,13 +183,13 @@ public class FormulaAgent {
sql += " and tms_period = " + Integer.parseInt(year + _period);
} else if (period == -99) {
sql += " and tms_period between " + Integer.parseInt(year+"01") + " and " + Integer.parseInt(year + per);
sql += " and tms_period between " + Integer.parseInt(year + "01") + " and " + Integer.parseInt(year + per);
} else if (period == 99) {
sql += " and tms_period between " + Integer.parseInt(year+"01") + " and " + Integer.parseInt(year + _period);
sql += " and tms_period between " + Integer.parseInt(year + "01") + " and " + Integer.parseInt(year + _period);
} else {
if (period > 0)
throw new Exception("参数不正确");
sql += " and tms_period between " + Integer.parseInt(year + _p )+ " and " + Integer.parseInt(year + per);
sql += " and tms_period between " + Integer.parseInt(year + _p) + " and " + Integer.parseInt(year + per);
}
}
if (bool)
......@@ -219,15 +219,19 @@ public class FormulaAgent {
}
public double getTableDataByName(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) {
List<Map<String, Object>> stringObjectMap = jdbcTemplate.queryForList(buildSql(TableRule.map.get(tableName), getField, filter, filterValue, period, year, formulaContext));
Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(buildSql(TableRule.map.get(tableName), getField, filter, filterValue, period, year, formulaContext));
double rev = 0.00;
for (int i = 0, j = stringObjectMap.size(); i < j; i++) {
/* for (int i = 0, j = stringObjectMap.size(); i < j; i++) {
if (i == 1) {
rev = Long.parseLong(String.valueOf(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField))));
} else {
rev = rev + Long.parseLong(String.valueOf(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField))));
}
}
*/
if(stringObjectMap.get(StringUtil.underline2Camel(getField)) != null ){
return (double)stringObjectMap.get(StringUtil.underline2Camel(getField));
}
return rev;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment