예제 #1
0
  public boolean fillFromForm(BaseForm form) {
    if (form == null) {
      return false;
    }
    // 提取起始、结束日期
    Date t1 = DateUtil.AddDays(DateUtil.trunc(new Date()), -1); // 昨天
    if (form.getDays() != null) {
      endDate = t1;
      form.setEndTime(DateUtil.formatDate(t1, "yyyy-MM-dd"));
      startDate = DateUtil.AddDays(t1, 0 - NumericUtil.tryParse(form.getDays(), 30));
      form.setStartTime(DateUtil.formatDate(startDate, "yyyy-MM-dd"));
    } else {
      startDate = form.getStartDate();
      endDate = form.getEndDate();
    }

    // 判断日期有效性
    if (getEndDate() == null) {
      endDate = t1;
      // 设置回FORM,避免查询数据使用的日期和页面显示日期不一致
      form.setEndTime(DateUtil.formatDate(t1, "yyyy-MM-dd"));
    }
    if (getStartDate() == null || getEndDate().before(getStartDate())) {
      startDate = DateUtil.AddDays(t1, -30);
      // 设置回FORM,避免查询数据使用的日期和页面显示日期不一致
      form.setStartTime(DateUtil.formatDate(startDate, "yyyy-MM-dd"));
    }

    systemID = form.getSystemIDValue();
    model = form.getModel();
    appVersion = form.getAppVersion();

    return true;
  }
  /**
   * 查询
   *
   * @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;
  }