@Override public String execute() throws Exception { pubList = publicationService.queryNormalByPublisherId(this.getSessionAdUserId()); // 获取前一天的数据 SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.DAY_OF_MONTH, -1); date = calendar.getTime(); String preDate = sf.format(date); Map<String, Object> map = new HashMap<String, Object>(); map.put("pid", getSessionPublisherId()); map.put("startDate", preDate); rList = dmStartTimesService.deviceSumAvgCount(map); if (rList != null && rList.size() > 0) { Integer ydStartUser = rList.get(0).getCount(); Integer ydNewUser = dmInstalledTimesService.deviceNewUser(map); Double at = rList.get(0).getAvg(); String atime = at + "毫秒"; if (at != null) { if (at > 1000) atime = opTime(at.longValue()); } else atime = ""; result.put("ydAvgTime", atime); result.put("ydStartSum", rList.get(0).getSum()); result.put("ydStartUser", ydStartUser); result.put("ydNewUser", ydNewUser); float rate = 0f; if (ydNewUser != null && ydStartUser != null && ydStartUser > 0) rate = (ydNewUser.floatValue() / ydStartUser.floatValue()) * 100; else { if (ydNewUser == null) ydNewUser = 0; rate = ydNewUser.floatValue() * 100; } result.put("ydNewUserRate", rate); } else { result.put("ydAvgTime", 0); result.put("ydStartSum", 0); result.put("ydStartUser", 0); result.put("ydNewUser", 0); result.put("ydNewUserRate", 0.0); } result.put("dayAvgStartSum", dmStartTimesService.deviceAvgStartSum(getSessionPublisherId())); Double dat = dmStartTimesService.deviceAvgStartUserTime(getSessionPublisherId()); String datime = dat + "毫秒"; if (dat != null) { if (dat > 1000) datime = opTime(dat.longValue()); } else datime = ""; result.put("dayAvgUseTime", datime); Double startUser = dmStartTimesService.deviceAvgStartUser(getSessionPublisherId()); Double newUser = dmInstalledTimesService.deviceAvgNewUser(getSessionPublisherId()); float dayRate = 0f; if (startUser != null && startUser > 0d) dayRate = (newUser.floatValue() / startUser.floatValue()) * 100; else { if (newUser == null) newUser = 0d; dayRate = newUser.floatValue() * 100; } result.put("dayAvgStartUser", startUser); result.put("dayAvgNewUser", newUser); result.put("dayNewUserRate", dayRate); result.put("TopStartSum", dmStartTimesService.deviceTopStartSum(getSessionPublisherId())); Integer topUser = dmStartTimesService.deviceTopStartSum(getSessionPublisherId()); Integer topNewUser = dmInstalledTimesService.deviceTopNewUserSum(getSessionPublisherId()); float topRate = 0f; if (topUser != null && topUser > 0) topRate = (topNewUser.floatValue() / topUser.floatValue()) * 100; else { if (topNewUser == null) topNewUser = 0; topRate = topNewUser * 100; } result.put("topStartUser", topUser); result.put("topNewUser", topNewUser); result.put("topNewUserRate", topRate); return SUCCESS; }