/**
   * 跳转到编辑页面
   *
   * @return
   */
  public String toedit() {
    try {
      int systemID = form.getSystemIDValue();
      String eventFlowName = form.getEventFlowName();
      if (systemID <= 0 || eventFlowName == null) {
        return Action.ERROR;
      }

      EventFlowDTO dto = new EventFlowDTO();
      dto.setSystemID(systemID);
      dto.setEventFlowName(eventFlowName);
      // 查询KV事件列表
      this.eventList = this.service.listKVEvent(dto);
      // 查询事件流详情
      this.eventFlowList = this.service.getTheKVEventFlow(dto);

      if (eventFlowList != null && eventFlowList.size() > 0) {
        form.setEventFlowName(eventFlowList.get(0).getEventFlowName());
      }

      LogUtil.log(dto, "事件流-跳转到编辑页面");

      return "edit";
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
  /**
   * 查询KV事件流列表
   *
   * @return
   */
  public String init() {
    try {
      // 检查action传递过来的systemID合法性r
      if (form == null || StringUtil.isNullOrEmpty(form.getSystemID())) {
        return Action.ERROR;
      }
      int systemID = NumericUtil.tryParse(form.getSystemID(), -1);
      if (systemID <= 0) {
        return Action.ERROR;
      }
      form.setSystemID(form.getSystemID());
      form.setTips(form.getTips() == null ? "" : form.getTips());

      BaseDTO dto = new BaseDTO();
      dto.setSystemID(systemID);
      // 查询KV事件流列表
      this.eventFlowList = this.service.listKVEventFlow(dto);

      LogUtil.log(dto, "事件流-列表");

      return Action.SUCCESS;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
  /**
   * 添加事件流
   *
   * @return
   */
  public String add() {
    int systemID = form.getSystemIDValue();
    String eventFlowName = form.getEventFlowName();
    String eventFlowDesc = form.getEventFlowDesc();
    String[] ids = form.getEventID();
    if (systemID == 0
        || null == eventFlowName
        || "".equals(eventFlowName.trim())
        || null == ids
        || "".equals(ids.length <= 0)) {
      return Action.SUCCESS;
    }

    List<EventFlowDTO> list = new ArrayList<EventFlowDTO>();
    EventFlowDTO dto = null;
    for (int i = 0, len = ids.length; i < len; i++) {
      dto = new EventFlowDTO();
      dto.setSystemID(systemID);
      dto.setEventFlowName(eventFlowName);
      dto.setEventFlowDesc(eventFlowDesc == null ? "" : eventFlowDesc);
      dto.setEventFlowStep(i + 1);
      dto.setFinalEventID(ids[i]);
      list.add(dto);
    }
    // 添加操作
    service.addKVEventFlow(list);

    LogUtil.log(dto, "事件流-添加");

    form.setTips("事件流添加成功!");
    return "success_redirect";
  }
  /**
   * 查询日启动次数
   *
   * @return
   */
  public String querystartcnt() {
    Date startDate = form.getStartDate();
    int systemID = form.getSystemIDValue();
    String appVersion = form.getAppVersion();
    String model = form.getModel();

    if (systemID == 0) {
      return Action.SUCCESS;
    }
    if (startDate == null) {
      return Action.SUCCESS;
    }

    BaseDTO dto = new BaseDTO();
    dto.setStartDate(startDate);
    dto.setSystemID(systemID);
    dto.setAppVersion(appVersion);
    dto.setModel(model);

    startcntEntity = new BaseEntity();
    List<ColumnValueEntity> list = service.getUseoftenStartcntList(dto);
    setStartcntColumn();
    startcntEntity.setValueList(list);
    ServletActionContext.getRequest()
        .getSession()
        .setAttribute(Constants.NEARME_SESSION_REPROT_DATA, startcntEntity);

    LogUtil.log(dto, "使用频率时长分析"); // log记录查询

    return "querystartcnt";
  }
  public String query() {
    Date startDate = form.getStartDate();
    Date endDate = form.getEndDate();
    String lidu = form.getLidu();
    String appVersion = form.getAppVersion();
    String qudao = form.getQudao();

    if (startDate == null || endDate == null || startDate.after(endDate)) {
      return Action.SUCCESS;
    }

    ZjbDTO dto = new ZjbDTO();
    dto.setStartDate(startDate);
    dto.setEndDate(endDate);
    dto.setLidu(lidu);
    dto.setAppVersion(appVersion);
    dto.setQudao(qudao);
    channelserviceList = service.getChannelserviceList(dto);
    ServletActionContext.getRequest()
        .getSession()
        .setAttribute(Constants.NEARME_SESSION_REPROT_DATA, channelserviceList);

    LogUtil.log(dto, TAG);

    return Action.SUCCESS;
  }
  /**
   * 查询
   *
   * @return
   */
  public String query() {
    int systemID = form.getSystemIDValue();
    Date startDate = form.getStartDate();
    Date endDate = startDate; // 周数据用到
    String lidu = form.getLidu();
    String model = form.getModel();

    if (Constants.MONTHLY.equals(lidu)) {
      startDate = DateUtil.getFirstDayOfXmonthAgo(startDate, 0);
    } else if (Constants.WEEKLY.equals(lidu)) {
      startDate = DateUtil.AddDays(startDate, -6);
    }

    ColorosDTO dto = new ColorosDTO();
    dto.setStartDate(startDate);
    dto.setEndDate(endDate);
    dto.setLidu(lidu);
    dto.setSystemID(systemID);
    dto.setModel(model);
    versionactiveList = service.getVersionactiveList(dto);
    ServletActionContext.getRequest()
        .getSession()
        .setAttribute(Constants.NEARME_SESSION_REPROT_DATA, versionactiveList);

    LogUtil.log(dto, TAG);

    return Action.SUCCESS;
  }
  /**
   * 初始化
   *
   * @return
   */
  public String init() {
    // 检查action传递过来的systemID合法性
    if (form == null || StringUtil.isNullOrEmpty(form.getSystemID())) {
      return Action.ERROR;
    }

    String startDate = DateUtil.getDateOfXdaysAgo(1);
    String lidu = Constants.DAILY;
    int systemID = form.getSystemIDValue();

    form.setStartTime(startDate);
    form.setLidu(lidu);

    ColorosDTO dto = new ColorosDTO();
    dto.setStartDate(DateUtil.parseDate(startDate, "yyyy-MM-dd"));
    dto.setLidu(lidu);
    dto.setSystemID(systemID);
    versionactiveList = service.getVersionactiveList(dto);
    ServletActionContext.getRequest()
        .getSession()
        .setAttribute(Constants.NEARME_SESSION_REPROT_DATA, versionactiveList);

    LogUtil.log(dto, TAG);

    return Action.SUCCESS;
  }
  /**
   * 删除事件流
   *
   * @return
   */
  public String delete() {
    int systemID = form.getSystemIDValue();
    String eventFlowName = form.getEventFlowName();
    if (systemID == 0 || null == eventFlowName || "".equals(eventFlowName.trim())) {
      return Action.SUCCESS;
    }
    EventFlowDTO dto = new EventFlowDTO();
    dto.setSystemID(systemID);
    dto.setEventFlowName(eventFlowName);
    // 删除操作
    service.deleteKVEventFlow(dto);

    LogUtil.log(dto, "事件流-删除");

    return "success_redirect";
  }
  /**
   * 查询某个事件流详情
   *
   * @return
   */
  public String select() {
    int systemID = form.getSystemIDValue();
    String eventFlowName = form.getEventFlowName();
    if (systemID == 0 || null == eventFlowName || "".equals(eventFlowName.trim())) {
      return Action.SUCCESS;
    }

    EventFlowDTO dto = new EventFlowDTO();
    dto.setSystemID(systemID);
    dto.setEventFlowName(eventFlowName);
    // 查询某个事件流详情
    this.eventFlowList = this.service.getTheKVEventFlow(dto);

    LogUtil.log(dto, "事件流-详情");

    return Action.SUCCESS;
  }
  /** 初始化日使用时长 */
  private void initUsetime() {
    String startDate = DateUtil.getDateOfXdaysAgo(1);

    formusetime.setStartTime(startDate);
    formusetime.setSystemID(form.getSystemID());

    BaseDTO dto = new BaseDTO();
    dto.setStartDate(DateUtil.parseDate(startDate, "yyyy-MM-dd"));
    dto.setSystemID(formusetime.getSystemIDValue());

    List<ColumnValueEntity> list = service.getUseoftenUsetimeList(dto);
    setUsetimeColumn();
    usetimeEntity.setValueList(list);

    ServletActionContext.getRequest()
        .getSession()
        .setAttribute(Constants.NEARME_SESSION_REPROT_DATA_2, usetimeEntity);

    LogUtil.log(dto, "使用频率时长分析"); // log记录查询
  }
  /**
   * 跳转到添加页面
   *
   * @return
   */
  public String toadd() {
    try {
      int systemID = form.getSystemIDValue();
      String eventFlowName = form.getEventFlowName();
      if (systemID <= 0 || eventFlowName == null) {
        return Action.ERROR;
      }

      EventDTO dto = new EventDTO();
      dto.setSystemID(systemID);
      // 查询KV事件列表
      this.eventList = this.service.listKVEvent(dto);

      LogUtil.log(dto, "事件流-跳转到添加页面");

      return "add";
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
  public String init() {
    String startDate = DateUtil.getDateOfXdaysAgo(30);
    String endDate = DateUtil.getToday();
    form = new ZjbForm();
    form.setStartTime(startDate);
    form.setEndTime(endDate);
    form.setLidu(Constants.DAILY);

    ZjbDTO dto = new ZjbDTO();
    dto.setStartDate(DateUtil.parseDate(startDate, "yyyy-MM-dd"));
    dto.setEndDate(DateUtil.parseDate(endDate, "yyyy-MM-dd"));
    dto.setLidu(form.getLidu());
    channelserviceList = service.getChannelserviceList(dto);
    ServletActionContext.getRequest()
        .getSession()
        .setAttribute(Constants.NEARME_SESSION_REPROT_DATA, channelserviceList);

    LogUtil.log(dto, TAG);

    return Action.SUCCESS;
  }