Commit 5986f68a authored by neo's avatar neo

[dev] fixed bb parsed formula had it data

parent b8415682
......@@ -19,6 +19,7 @@ public class BBParasBo {
private Integer rowIndex;
private Integer period;
private Integer year;
private String formulaExpression;
private List<PeriodCellDataTemplate> expressionData = new ArrayList<>();
public static class PeriodCellDataTemplate {
......@@ -44,12 +45,18 @@ public class BBParasBo {
}
public BBParasBo(ValueEval[] args, OperationEvaluationContext ec) throws EvaluationException {
StringBuilder expression = new StringBuilder("");
begin(expression);
reportCode = resolverString(args, ec, 0);
concatPara(expression, reportCode);
try {
columnIndex = resolverInteger(args, ec, 1);
split(expression);
concatPara(expression, columnIndex);
} catch (Exception e) {
String columnStr = resolverString(args, ec, 1);
split(expression);
concatPara(expression, columnStr);
int rtn = 0;
columnStr = columnStr.toUpperCase();
char[] excelCol = columnStr.toCharArray();
......@@ -63,13 +70,40 @@ public class BBParasBo {
columnIndex = rtn;
}
rowIndex = resolverInteger(args, ec, 2);
split(expression);
concatPara(expression, rowIndex);
period = args.length >= 4 ? resolverInteger(args, ec, 3) : 0;
year = args.length == 5 ? resolverInteger(args, ec, 4) : 0;
if (args.length >= 4) {
split(expression);
concatPara(expression, period);
}
if (args.length == 5) {
split(expression);
concatPara(expression, year);
}
formulaExpression = expression.toString();
}
private StringBuilder begin(StringBuilder expression) {
return expression.append("BB(");
}
private StringBuilder end(StringBuilder expression) {
return expression.append(")");
}
private StringBuilder split(StringBuilder expression) {
return expression.append(",");
}
public void disCount() {
rowIndex--;
columnIndex--;
private StringBuilder concatPara(StringBuilder expression, String para) {
return expression.append("\"").append(para).append("\"");
}
private StringBuilder concatPara(StringBuilder expression, Integer para) {
return expression.append(para);
}
public BBParasBo(BBParasBo otherBo, int period, int curYear) {
......@@ -78,13 +112,20 @@ public class BBParasBo {
this.rowIndex = otherBo.rowIndex;
this.period = period;
this.year = curYear;
this.formulaExpression = otherBo.formulaExpression;
}
public String expression() {
return formulaExpression;
}
public String expressionData() {
if (!expressionData.isEmpty()) {
StringBuilder builder = new StringBuilder("PCT(");
for (PeriodCellDataTemplate pc : expressionData) {
builder.append(pc.toString()).append(",");
for (int i = 0; i < expressionData.size(); i++) {
builder.append(expressionData.get(i).toString());
if (i < expressionData.size() - 1)
builder.append(",");
}
builder.append(")");
return builder.toString();
......
......@@ -150,7 +150,7 @@ public class BB extends FunctionBase implements FreeRefFunction {
cellValue, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupID(), bo.getColumnIndex() - 1, bo.getRowIndex() - 1);
saveFormulaBlock(formulaContext.getPeriod(), ec,
bo.expression(), cellValue, dataSourceID);
bo.expression(), bo.expressionData(), dataSourceID);
}
}
}
......
......@@ -152,7 +152,7 @@ public class FunctionBase {
}
public void saveFormulaBlock(int period, OperationEvaluationContext ec,
String formulaExpression, BigDecimal val, Long dataSourceID) {
String formulaExpression, BigDecimal val, Long dataSourceID) {
Long cellTemplateID = getCellTemplateID(period, ec);
Date creatime = new Date();
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
......@@ -170,4 +170,23 @@ public class FunctionBase {
SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock);
}
public void saveFormulaBlock(int period, OperationEvaluationContext ec,
String formulaExpression, String val, Long dataSourceID) {
Long cellTemplateID = getCellTemplateID(period, ec);
Date creatime = new Date();
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setId(SpringContextUtil.distributedIDService.nextId());
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);
periodFormulaBlock.setCellTemplateId(cellTemplateID);
periodFormulaBlock.setFormulaExpression(formulaExpression);
periodFormulaBlock.setData(val);
periodFormulaBlock.setDataSourceId(dataSourceID);
periodFormulaBlock.setCreateBy("Admin");
periodFormulaBlock.setCreateTime(creatime);
periodFormulaBlock.setUpdateBy("Admin");
periodFormulaBlock.setUpdateTime(creatime);
SpringContextUtil.periodFormulaBlockMapper.insertSelective(periodFormulaBlock);
}
}
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