Commit b0658e9d authored by kevin's avatar kevin

#

parent 072dc907
...@@ -26,5 +26,7 @@ public class TableRule { ...@@ -26,5 +26,7 @@ public class TableRule {
map.put("ZXXJLLB", "cash_flow_final"); map.put("ZXXJLLB", "cash_flow_final");
map.put("CITZCFZB", "cit_balance_sheet_prc_adjust"); map.put("CITZCFZB", "cit_balance_sheet_prc_adjust");
map.put("CITLRB", "cit_profit_prc_adjust"); map.put("CITLRB", "cit_profit_prc_adjust");
map.put("CIT_TBAM", "cit_tbam");
} }
} }
...@@ -146,18 +146,18 @@ public class FormulaAgent { ...@@ -146,18 +146,18 @@ public class FormulaAgent {
public static String buildSql(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) { public static String buildSql(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) {
String sql = ""; /*
String[] split = filterValue.split(" ");
String para3 = null;
if (split[0].indexOf(">=") != -1) { if (split[0].indexOf(">=") != -1) {
filterValue = "> " + split[1] + "and" + filter + " =" + split[1]; filterValue = " > " + split[1] + " or " + filter + " = " + split[1];
} else if (split[0].indexOf("<=") != -1) { } else if (split[0].indexOf("<=") != -1) {
filterValue = "< " + split[1] + "and" + filter + " =" + split[1]; filterValue = " < " + split[1] + " or " + filter + " = " + split[1];
} else { } else {
filterValue = split[0] + "'" + split[1] + "'"; filterValue = split[0] + " = " + split[1] + "";
} }
if ("cit_balance_sheet_prc_adjust".equals(tableName) || ("cit_profit_prc_adjust".equals(tableName))) { */
if (tableName.substring(0, 3).equals("cit")) {
try { try {
return _buildSql(getField, tableName, filter, filterValue, period, formulaContext, year, true); return _buildSql(getField, tableName, filter, filterValue, period, formulaContext, year, true);
} catch (Exception e) { } catch (Exception e) {
...@@ -180,16 +180,16 @@ public class FormulaAgent { ...@@ -180,16 +180,16 @@ public class FormulaAgent {
String per = insertZero((formulaContext.getPeriod() - 1)); String per = insertZero((formulaContext.getPeriod() - 1));
if (!bool) { if (!bool) {
if (period == 0) { if (period == 0) {
sql += " and tms_period = " + year + _period; sql += " and tms_period = " + Integer.parseInt(year + _period);
} else if (period == -99) { } else if (period == -99) {
sql += " and tms_period between " + year + "01 and " + year + per; sql += " and tms_period between " + Integer.parseInt(year+"01") + " and " + Integer.parseInt(year + per);
} else if (period == 99) { } else if (period == 99) {
sql += " and tms_period between " + year + "01 and " + year + _period; sql += " and tms_period between " + Integer.parseInt(year+"01") + " and " + Integer.parseInt(year + _period);
} else { } else {
if (period > 0) if (period > 0)
throw new Exception("参数不正确"); throw new Exception("参数不正确");
sql += " and tms_period between " + year + _p + " and " + year + per; sql += " and tms_period between " + Integer.parseInt(year + _p )+ " and " + Integer.parseInt(year + per);
} }
} }
if (bool) if (bool)
...@@ -211,16 +211,16 @@ public class FormulaAgent { ...@@ -211,16 +211,16 @@ public class FormulaAgent {
@Autowired @Autowired
JdbcTemplate jdbcTemplate; JdbcTemplate jdbcTemplate;
/* public static void main(String[] args) { public static void main(String[] args) {
FormulaAgent formulaAgent = new FormulaAgent(); FormulaAgent formulaAgent = new FormulaAgent();
FormulaContext formulaContext = new FormulaContext(); FormulaContext formulaContext = new FormulaContext();
formulaContext.setPeriod(3); formulaContext.setPeriod(3);
formulaAgent.getTableDataByName("CITLRB", "end_bal", "item_name", "= 小帅哥", -3, "2018", formulaContext); formulaAgent.getTableDataByName("CIT_TBAM", "ending_balance", "attribute", "= '销售费用-财产损耗、盘亏及毁损损失'", 0, "2018", formulaContext);
}*/ }
public Long getTableDataByName(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) { 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)); List<Map<String, Object>> stringObjectMap = jdbcTemplate.queryForList(buildSql(TableRule.map.get(tableName), getField, filter, filterValue, period, year, formulaContext));
Long rev = 0L; 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) { if (i == 1) {
rev = Long.parseLong(String.valueOf(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField)))); rev = Long.parseLong(String.valueOf(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField))));
......
...@@ -28,7 +28,7 @@ public class TABLESUMIF extends FunctionBase implements FreeRefFunction { ...@@ -28,7 +28,7 @@ public class TABLESUMIF extends FunctionBase implements FreeRefFunction {
//进行参数验证 //进行参数验证
public void parameterCheck(ValueEval[] args, OperationEvaluationContext ec) { public void parameterCheck(ValueEval[] args, OperationEvaluationContext ec) {
argsLength = args.length; argsLength = args.length;
if (argsLength != 6) //参数小于当做异常处理, 最后俩参数可以取默认值 if (argsLength != 6) //参数小于6当做异常处理, 最后俩参数可以取默认值
throw Exceptions.parameterError; throw Exceptions.parameterError;
try { try {
tableName = resolverString(args, ec, 0); tableName = resolverString(args, ec, 0);
...@@ -42,7 +42,6 @@ public class TABLESUMIF extends FunctionBase implements FreeRefFunction { ...@@ -42,7 +42,6 @@ public class TABLESUMIF extends FunctionBase implements FreeRefFunction {
} }
Integer argsLength; Integer argsLength;
String getField; String getField;
Integer period; Integer period;
String year; String year;
......
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