/** * 导出当前页统计数据 * * @return */ public boolean exportData() { boolean bool = false; int count = 0; int size = 0; String fileURL = null; // 文件路径 String[] title = null; String[][] body = null; // List<StudentStat> stuStatList = null; try { stuStatList = getSession("stuStatList"); size = stuStatList.size(); } catch (Exception e) { logger.error("获取导出数据异常", e); } // 没有数据,返回提示信息 if (size == 0) { msg = "没有数据,无法导出!"; logger.error(msg); // return "msg"; return bool; } fileURL = getRealPath(downFileURL); // 设置保存路径 // 14个大小 title = new String[] { "来源", "页流量", "注册人数 ", "登录人数 ", "跳出人数 ", "到达微学习页", "首次用户", "非重复用户 ", "重复用户", "带来订单", "带来流水", "统计日期" }; body = new String[size][title.length]; // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Map<Integer, String> map = new HashMap<Integer, String>(); queryFroms(); // 查询所有来源 if (listForm != null && listForm.size() > 0) { for (From lf : listForm) { map.put(lf.getId(), lf.getName()); } } for (StudentStat ss : stuStatList) { if (map != null && map.keySet().size() > 0) { // 来源 body[count][0] = map.get(ss.getFromId()); } else { body[count][0] = ""; } body[count][1] = String.valueOf(ss.getPageFlow()); // 页流量 body[count][2] = String.valueOf(ss.getRegisterCount()); // 注册人数 body[count][3] = String.valueOf(ss.getLoginCount()); // 登录人数 body[count][4] = String.valueOf(ss.getOutCount()); // 跳出人数 body[count][5] = String.valueOf(ss.getArriveWxxCount()); // 到达微学习页 body[count][6] = String.valueOf(ss.getFirstUserCount()); // 首次用户 body[count][7] = String.valueOf(ss.getNonRepeatUserCount()); // 非重复用户 body[count][8] = String.valueOf(ss.getRepeatUserCount()); // 重复用户 body[count][9] = String.valueOf(ss.getOrderCount()); // 带来订单 body[count][10] = String.valueOf(ss.getRunningWaterCount()); // 带来流水 if (ss.getSearchDate() != null && ss.getSearchDate().length() > 0 && !ss.getSearchDate().equals("null")) { body[count][11] = ss.getSearchDate(); } else { body[count][11] = ""; } count++; } try { // 创建文件 Utils.writeCSV(title, body, fileURL); bool = true; } catch (Exception e) { logger.error("微学习-导出数据-写文件错误->", e); } return bool; }