@Override public String getBrandResult(String brand, Date date) { Date yesterday = getYesterday(date); BrandStatResult bsr = new BrandStatResult(); BrandResult br = new BrandResult(brand, "", 0); br.setBrand(brand); br.setDate(yesterday); Double lastDayAmount = 0.0; List<BrandResult> bcr = this.dataDaoV2.getBrandResultByChannel(yesterday, brand); for (BrandResult b : bcr) { if (springProperty.isMockValue()) { b.setDayAmount(10000L); } if (b.getChannel().equals(Constants.B2C)) { // 统计数据不包括电商的 continue; } if (b.getPerDayAmount() != null) { lastDayAmount += b.getPerDayAmount(); } if (b.getDayAmount() != null) { br.setDayAmount(b.getDayAmount() + br.getDayAmount()); } } if (lastDayAmount != 0) { br.setDayLike(br.getDayAmount() / lastDayAmount - 1); } Collections.sort(bcr); bsr.setBrand(brand); bsr.setResult(0); bsr.setBrandResult(br); if (!brand.equals(Constants.B2C)) { bsr.setChannels(bcr); } Date firstDayOfThisWeek = getCalendarDate(yesterday, Calendar.WEEK_OF_MONTH); // daily line chart List<BrandLineChartResult> dailyLineChart = this.dataDaoV2.getBrandLineChartDayResult(yesterday, brand, "days", 8); bsr.setDailyLineChart(dailyLineChart); setLineChartColorAndDateStr(dailyLineChart, brand, Calendar.DAY_OF_MONTH, firstDayOfThisWeek); List<BrandLineChartResult> weeklyLineChart = this.dataDaoV2.getBrandLineChartDayResult( this.getCalendarDate(yesterday, Calendar.WEEK_OF_MONTH), brand, "weeks", 8); bsr.setWeeklyLineChart(weeklyLineChart); setLineChartColorAndDateStr(weeklyLineChart, brand, Calendar.WEEK_OF_MONTH, null); List<BrandLineChartResult> monthLineChart = this.dataDaoV2.getBrandLineChartDayResult( this.getCalendarDate(yesterday, Calendar.MONTH), brand, "months", 12); bsr.setMonthlyLineChart(monthLineChart); setLineChartColorAndDateStr(monthLineChart, brand, Calendar.MONTH, null); List<BrandLineChartResult> yearLineChart = this.dataDaoV2.getBrandLineChartDayResult( this.getCalendarDate(yesterday, Calendar.YEAR), brand, "years", 3); bsr.setYearlyLineChart(yearLineChart); setLineChartColorAndDateStr(yearLineChart, brand, Calendar.YEAR, null); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); jsonConfig.registerJsonValueProcessor(Integer.class, new IntegerJsonValueProcessor()); String result = JSONObject.fromObject(bsr, jsonConfig).toString(); return result; }