java多线程excel上传_java多线程处理下载请求 csv/excel文件

pageResult = insuranceService.listByCodeTypOrderStatusTranDate(appBean.getClientCode(), codeList, typeList, statusList, formatter.parse(startDate), dayEnd(formatter.parse(endDate)), PageInfo.ALL); final List

dataList = new ArrayList(); for (InsuranceOrder order : pageResult.getResults()) { dataList.add(orderExt); } Runnable writer = new Runnable() { @Override public void run() { try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(output, "GBK"));) { StringBuilder sb = new StringBuilder(); sb.append("订单号").append(CSV_SEPERATOR) .append("保单号").append(CSV_SEPERATOR) .append("险种SKU代码").append(CSV_SEPERATOR) .append("保险名称").append(CSV_SEPERATOR) .append("保险类型").append(CSV_SEPERATOR) .append("是否犹退"); bw.append(sb.toString()); bw.newLine(); for (InsuranceOrderExt orderExt : dataList) { User user = userService.findByUserId(appBean.getClientCode(), orderExt.getUserId()); sb = new StringBuilder(); UserInfo userinfo = userInfoService.getUserInfoByUserId(appBean.getClientCode(), orderExt.getUserId()); InsuranceRelatedUser insuranceRelatedUser = insuranceRelatedUserService.findById(orderExt.getId()); InsuranceProductInfo productInfo = insuranceProductService.findInsuranceProductInfoByProductId(appBean.getClientCode(), orderExt.getProduct().getId()); sb.append("\t").append(orderExt.getId()).append(CSV_SEPERATOR); sb.append("\t").append(orderExt.getProductId()).append(CSV_SEPERATOR); sb.append(orderExt.getProductCode()).append(CSV_SEPERATOR) .append(orderExt.getProductName()).append(CSV_SEPERATOR) .append(orderExt.getProductType().getKey()).append(CSV_SEPERATOR); bw.newLine(); } bw.flush(); } catch (Exception ex) { logger.error("Exception happened when write CSV for project investors.", ex); } } }; Thread thread = new Thread(writer); thread.start(); return Response.ok(input, "text/csv").encoding("UTF-8").header("Content-Disposition", contentDisposition).build(); }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值