Jieven 发布于69月前 0答/2110阅
元对象拦截器新增查询合计拦截,简单快速搞定汇总合计需求
/**
* 为Grid添加Footer汇总统计行
*/
public class DataMoneyIntercept extends MetaObjectIntercept {
@Override
public Kv queryFooter(AopContext ac) throws Exception {
double sum = 0;
double sum1 = 0;
double sum2 = 0;
for (Record record : ac.records) {
sum += record.getDouble("num");
sum1 += record.getDouble("num1");
sum2 += record.getDouble("num2");
}
return new Kv().set("moon", "汇总:(单位/元)").set("num", sum).set("num1", sum1).set("num2", sum2);
}
}