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(); }