private void saveOnlineFlow( SimpleObject context, final int page, final int t, final Date d, final String dstr, final int isHistory, final String date) { String text = ContextUtil.getContent(context); Document doc = ContextUtil.getDocumentOfContent(context); System.out.println(doc.toString()); DianXinFlow dxFlow = new DianXinFlow(); UUID uuid = UUID.randomUUID(); dxFlow.setId(uuid.toString()); dxFlow.setPhone(phoneNo); Date queryMonth = DateUtils.StringToDate(date, "yyyy/MM"); // 查询日期 dxFlow.setQueryMonth(queryMonth); String cycle = ""; if (isHistory == 0) { cycle = date + "/01-" + DateUtils.formatDate(new Date(), "yyyy/MM/dd"); } else { cycle = date + "/01-" + DateUtils.lastDayOfMonth(date, "yyyy/MM", "yyyy/MM/dd"); } dxFlow.setDependCycle(cycle); if (text.indexOf("没有查找到相关数据") >= 0) { if (page == 1) { dxFlow.setAllFlow(new BigDecimal(0)); dxFlow.setAllTime(new BigDecimal(0)); dxFlow.setAllPay(new BigDecimal(0.00)); flowList.add(dxFlow); } } else { if (page == 1) { Elements tables = doc.select("table"); if (isHistory == 0) { Element tr1 = tables.get(1).select("tr").get(1); String allpay = tr1.select("td").get(3).text().replaceAll("元", "").trim(); if (allpay.equals("")) { allpay = "0"; } String allTime = tr1.select("td").get(5).text().trim(); String allFlow = tr1.select("td").get(7).text().trim(); dxFlow.setAllFlow(new BigDecimal(allpay)); dxFlow.setAllTime(new BigDecimal(StringUtil.flowTimeFormat(allTime))); dxFlow.setAllPay(new BigDecimal(StringUtil.flowFormat(allFlow))); flowList.add(dxFlow); } else { Element tr1 = tables.get(2).select("tr").get(1); String allpay = tr1.select("td").get(3).text().replaceAll("元", "").trim(); if (allpay.equals("")) { allpay = "0"; } String allTime = tr1.select("td").get(5).text().trim(); String allFlow = tr1.select("td").get(7).text().trim(); dxFlow.setAllFlow(new BigDecimal(allpay)); dxFlow.setAllTime(new BigDecimal(StringUtil.flowTimeFormat(allTime))); dxFlow.setAllPay(new BigDecimal(StringUtil.flowFormat(allFlow))); flowList.add(dxFlow); } } String tableSort = InfoUtil.getInstance().getInfo("dx/sh", "tableSort"); String tbody = InfoUtil.getInstance().getInfo("dx/sh", "tbody"); String tr = InfoUtil.getInstance().getInfo("dx/sh", "tr"); String td = InfoUtil.getInstance().getInfo("dx/sh", "td"); Elements elements = doc.select(tableSort); if (elements != null && elements.size() > 0) { Elements elements2 = elements.first().select(tbody).first().select(tr); for (int j = 0; j < elements2.size(); j++) { try { Elements tds = elements2.get(j).select(td); if (tds.size() == 9 && isHistory == 1) { String beginTime = tds.get(3).text().trim(); // 开始时间 String fee = tds.get(8).text().trim().replaceAll("元", ""); // 费用(元) // String RecevierPhone = tds.get(2).text().trim();// 对方号码 String netType = tds.get(1).text().trim(); // 通讯类型 // String time_flow = tds.get(4).text().trim();// 时长/流量(分钟/KB) int tradeTime = TimeUtil.timetoint_HH_mm_ss( tds.get(5) .text() .trim() .replaceAll("小时", ":") .replaceAll("分", ":") .replaceAll("秒", "")); // 上网时长 String flow = tds.get(6).text().trim().replaceAll("KB", ""); // 总流量 String business = tds.get(7).text().trim(); // 漫游类型 Date beginTimeDate = null; BigDecimal feeDecimal = new BigDecimal(0); BigDecimal flows = new BigDecimal(0); try { beginTimeDate = DateUtils.StringToDate(beginTime, "yyyy-MM-dd HH:mm:ss"); feeDecimal = new BigDecimal(fee); flows = new BigDecimal(flow); } catch (Exception e) { e.printStackTrace(); } DianXinFlowDetail obj = new DianXinFlowDetail(); obj.setPhone(phoneNo); obj.setBeginTime(beginTimeDate); obj.setFee(feeDecimal); obj.setNetType(netType); obj.setTradeTime(tradeTime); obj.setFlow(flows); obj.setBusiness(business); flowDetailList.add(obj); } else if (tds.size() == 8 && isHistory == 0) { String beginTime = tds.get(1).text().trim(); // 开始时间 String fee = tds.get(2).text().trim().replaceAll("元", ""); // 费用(元) // String RecevierPhone = tds.get(2).text().trim();// 对方号码 String netType = tds.get(3).text().trim(); // 通讯类型 // String time_flow = tds.get(4).text().trim();// 时长/流量(分钟/KB) int tradeTime = TimeUtil.timetoint_HH_mm_ss( tds.get(5) .text() .trim() .replaceAll("小时", ":") .replaceAll("分", ":") .replaceAll("秒", "")); // 上网时长 int flow = Integer.parseInt(tds.get(6).text().trim().replaceAll("KB", "")); // 总流量 String business = tds.get(7).text().trim(); // 漫游类型 Date beginTimeDate = null; BigDecimal feeDecimal = new BigDecimal(0); try { beginTimeDate = DateUtils.StringToDate(beginTime, "yyyy-MM-dd HH:mm:ss"); feeDecimal = new BigDecimal(fee); } catch (Exception e) { e.printStackTrace(); } DianXinFlowDetail obj = new DianXinFlowDetail(); obj.setPhone(phoneNo); obj.setBeginTime(beginTimeDate); obj.setFee(feeDecimal); obj.setNetType(netType); obj.setTradeTime(tradeTime); obj.setFlow(new BigDecimal(flow)); obj.setBusiness(business); flowDetailList.add(obj); } } catch (Exception e) { logger.error("saveSmsLog", e); } } if (text.contains("下一页")) { if (text.contains("下一页")) { if (isHistory == 1) requestOnlineFlowService(page + 1, 2, d, dstr, isHistory, date); else requestThisMonthService(page + 1, t, "", "", isHistory); } } } } }