ureport2使用springbean方式打印导出参数太长问题

因为系统业务需要,只能使用springbean方式打印导出,勾选数据量少的时候一切正常,勾选上千条时参数太长系统报错,记录一下解决办法

handlePrint() {
      this.loading = true;
      pdfFileStream({
        ids: this.Ids,
        file: "file:test.ureport.xml",
      }).then((response) => {
        this.$tools.printPdf(response);//打印pdf流
        this.loading = false;
      });
    },
    

export function pdfFileStream(data) {
  return request({
    url: '/system/printExcle/pdfFileStream',
    method: 'post',
    data: data,
    timeout: 1000000,
    responseType: 'blob',
  })
}


@RestController
@RequestMapping("/system/printExcle")
public class PrintExcleController {
    @Autowired
    private ExportManager exportManager;
/**
     * 打印-pdf流
     * @param resp
     * @throws IOException
     */
    @PostMapping("/pdfFileStream")
    public void pdfFileStream(@RequestBody PrintVo printVo, HttpServletResponse resp) throws IOException
    {
        if (printVo!=null) {
            if(StringUtils.isNotBlank(printVo.getFile())) {
                Map<String, Object> parameters = new HashMap<>();
                parameters.put("file",printVo.getFile());
                if(printVo.getIds()!=null){
                    parameters.put("ids",StringUtils.join(printVo.getIds(), ","));
                }
                fileStream(parameters, resp);
            }
        }

    }
public void fileStream(Map<String, Object> parameters, HttpServletResponse resp) throws IOException
    {
        OutputStream outputStream=resp.getOutputStream();
        try {
            resp.setContentType("application/pdf");
            resp.setHeader("Content-Disposition","inline");
            ExportConfigure configure=new ExportConfigureImpl(parameters.get("file").toString(),parameters,outputStream);
            exportManager.exportPdf(configure);
        }catch(Exception ex) {
            throw new ReportException(ex);
        }finally {
            outputStream.flush();
            outputStream.close();
        }
    }

    public void excel(Map<String, Object> parameters, HttpServletResponse resp) throws IOException
    {
        OutputStream outputStream=null;
        try {
            resp.setContentType("application/octet-stream;charset=ISO8859-1");
            resp.setHeader("Content-Disposition","attachment");
            outputStream=resp.getOutputStream();
            ExportConfigure configure=new ExportConfigureImpl(parameters.get("file").toString(),parameters,outputStream);
            exportManager.exportExcel(configure);
        }catch(Exception ex) {
            throw new ReportException(ex);
        }finally {
            outputStream.flush();
            outputStream.close();
        }
    }
}

  public class PrintVo {

    private String[] ids;
    private String file;
  }

@Component
public class CauseChangeHistoryBean {

    public List<Test> test(String dsName, String datasetName, Map<String, Object> parameters) {
        List<Test> list = new ArrayList<>();
        ......................
        return list;
}
  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值