效果图

image.png

前段代码

image.png

image.png

注意点:

  • serverAggregates: true,
  • aggregate: [{field: “wareAmt”, aggregate: “sum”}]

后段代码

controller类

  1. public AggregatesResponseData queryTotal(FsUseFund dto, @RequestParam(defaultValue = DEFAULT_PAGE) int page,
  2. @RequestParam(defaultValue = DEFAULT_PAGE_SIZE) int pageSize, HttpServletRequest request) {
  3. IRequest requestContext = createRequestContext(request);
  4. AggregatesResponseData aggregatesResponseData = service.selectSumUseFundNew(requestContext, dto, page, pageSize);
  5. return aggregatesResponseData;
  6. }

controller返回的是AggregatesResponseData数据

service类

  1. Map<String,Map<String,Object>> aggregates=new HashMap<>();
  2. Map<String,Object> wareAmtSumA=new HashMap<>();
  3. wareAmtSumA.put(FsUseFund.AGGREGATE_SUM,wareAmtSum);
  4. aggregates.put(FsUseFund.FIELD_WARE_AMT,wareAmtSumA);
  5. AggregatesResponseData aggregatesResponseData = new AggregatesResponseData(fsUseFunds);
  6. aggregatesResponseData.setAggregates(aggregates);
  7. return aggregatesResponseData;

fsUseFunds存的是需要返回前台的List数据
aggregates存的是map函数,里面包含各列的数据。各列的数据是以map的形式存储。
FsUseFund.FIELD_WARE_AMT是前台的列名字段,
FsUseFund.AGGREGATE_SUM是sum