private void setLineChartColorAndDateStr(
     List<BrandLineChartResult> lineCharts, String brand, int type, Date firstDayOfThisWeek) {
   String color = "#E5006E";
   if (brand.equals("女装")) {
     color = "#E5006E";
   } else if (brand.equals("男装")) {
     color = "#17387A";
   } else if (brand.equals("乐町")) {
     color = "#F08DBA";
   } else if (brand.equals("童装")) {
     color = "#F7D800";
   } else if (brand.equals("赫奇")) {
     color = "#8BACDB";
   } else if (brand.equals("MG公司")) {
     color = "#E51D98";
   } else if (brand.equals("电商")) {
     color = "#D71515";
   }
   SimpleDateFormat sdf = null;
   SimpleDateFormat fsdf = null;
   SimpleDateFormat fsdf2 = null;
   if (type == Calendar.DAY_OF_MONTH) {
     sdf = new SimpleDateFormat("MM-dd\nEEEE", Locale.SIMPLIFIED_CHINESE);
     fsdf = new SimpleDateFormat("yy年MM月dd日 EEEE", Locale.SIMPLIFIED_CHINESE);
   } else if (type == Calendar.WEEK_OF_MONTH) {
     sdf = new SimpleDateFormat("MM-dd\n'W'w", Locale.SIMPLIFIED_CHINESE);
     fsdf = new SimpleDateFormat("'W'w MM.dd-", Locale.SIMPLIFIED_CHINESE);
     fsdf2 = new SimpleDateFormat("MM.dd", Locale.SIMPLIFIED_CHINESE);
   } else if (type == Calendar.MONTH) {
     sdf = new SimpleDateFormat("M月", Locale.SIMPLIFIED_CHINESE);
     fsdf = new SimpleDateFormat("yy年MM月", Locale.SIMPLIFIED_CHINESE);
   } else if (type == Calendar.YEAR) {
     sdf = new SimpleDateFormat("yyyy", Locale.SIMPLIFIED_CHINESE);
     fsdf = new SimpleDateFormat("yy年", Locale.SIMPLIFIED_CHINESE);
   }
   for (int i = 0; i < lineCharts.size(); i++) {
     BrandLineChartResult lc = lineCharts.get(i);
     if (springProperty.isMockValue()) {
       lc.setAmount(new Double(i * 100000L + 1));
       lc.setPreAmount(new Double(i * 500000L + 1));
     }
     lc.setDateStr(sdf.format(lc.getDate()));
     lc.setFullDateStr(fsdf.format(lc.getDate()));
     if (type == Calendar.WEEK_OF_MONTH) {
       String half = fsdf2.format(DateUtils.addDays(lc.getDate(), 6));
       lc.setFullDateStr(lc.getFullDateStr() + half);
     }
     if (type == Calendar.DAY_OF_MONTH) {
       lc.setDateStr(lc.getDateStr().replace("星期", "周"));
       lc.setFullDateStr(lc.getFullDateStr().replace("星期", "周"));
     }
     if (i == lineCharts.size() - 1) {
       lc.setColor(color);
     } else {
       lc.setColor("#BEBEBE");
     }
   }
 }
 @Override
 public String getIndexResult(String[] brands, Date date) {
   if (date != null) {
     DayStatus ds = dataDaoV2.getDayStatus(date);
     if (ds == null || ds.getStatus() == null || ds.getStatus() == 0) {
       SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日");
       return this.getErrorResult(3002, sdf.format(date) + "没有相关数据,请重新选择日期");
     }
   }
   Date yesterday = getYesterday(date);
   Set<String> bSet = new HashSet<String>();
   for (String brand : brands) {
     bSet.add(brand);
   }
   List<BrandResult> indexBrandResults = dataDaoV2.getBrandResult(yesterday, brands);
   for (BrandResult ibr : indexBrandResults) {
     if (springProperty.isMockValue()) {
       ibr.setDayAmount(10000L);
     }
     bSet.remove(ibr.getBrand());
   }
   for (String brand : bSet) {
     BrandResult ibr = new BrandResult(brand, "", 0);
     indexBrandResults.add(ibr);
   }
   IndexStatResult ir = new IndexStatResult();
   ir.setBrands(indexBrandResults);
   ir.setResult(0);
   ir.setDate(yesterday);
   ir.setClientVersion(springProperty.getClientVersion());
   Date realYesterday =
       DateUtils.addDays(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH), -1);
   DayStatus ds = dataDaoV2.getDayStatus(realYesterday);
   if (ds != null && ds.getStatus() != null && ds.getStatus().intValue() != 0) {
     ir.setYesterday(true);
   } else {
     ir.setYesterday(false);
   }
   List<Date> availableDates = dataDaoV2.getAvailableDates(realYesterday);
   List<String> ads = new ArrayList<String>();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   for (Date ad : availableDates) {
     ads.add(sdf.format(ad));
   }
   ir.setAvailableDates(ads);
   JsonConfig jsonConfig = new JsonConfig();
   jsonConfig.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd"));
   jsonConfig.registerJsonValueProcessor(Integer.class, new IntegerJsonValueProcessor());
   String result = JSONObject.fromObject(ir, jsonConfig).toString();
   return result;
 }
  @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;
  }