/**
  * 检索条件DTO作成。
  *
  * @param 没有
  * @return 条件DTO
  */
 private UserRecoverDto createCondition() {
   UserRecoverDto dto = new UserRecoverDto();
   dto.setOidUserId(oidUserId);
   dto.setRecoverYear(ddlYear.getSelectedValue());
   dto.setRecoverMonth(ddlMonth.getSelectedValue());
   if (StringUtils.isEmpty(ddlYear.getSelectedValue())
       && !StringUtils.isEmpty(ddlMonth.getSelectedValue())) {
     dto.setRecoverYear(ConvUtils.convToString(DateUtils.getYear(DateUtils.getDate())));
   }
   // 每页起始位置
   dto.setPageIndex(ConvUtils.convToInt(rptList.getFirstItemOffset()));
   // 每页最大件数
   dto.setPageSize(ConvUtils.convToInt(rptList.getItemsPerPage()));
   // 条件BEAN返回
   return dto;
 }
 private boolean checkInput() {
   if (StringUtils.isEmpty(advertizeShowPageChoice.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "广告显示页面"));
     return false;
   } else if (StringUtils.isEmpty(showType.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "广告类型"));
     return false;
   } else if (StringUtils.isEmpty(sort.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "排序"));
     return false;
   } else if (StringUtils.isEmpty(validFlg.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "有效"));
     return false;
   } else if (opType.equals("I") && upLinksIcon.getFileUploads().size() == 0) {
     alertError(MessageUtils.getMessage("ERR0017", "图片"));
     return false;
   } else if (opType.equals("I") && upLinksBakIcon.getFileUploads().size() == 0) {
     alertError(MessageUtils.getMessage("ERR0017", "背景图片"));
     return false;
   } else if (StringUtils.isEmpty(linkUrl.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "公司网址"));
     return false;
   } else if (!StringUtils.isUrl(linkUrl.getValue())) {
     alertError(MessageUtils.getMessage("ERR0019", "公司网址"));
     return false;
   }
   clearAlert();
   return true;
 }
  /**
   * 填充控件。
   *
   * @param 没有
   * @return 没有
   */
  @Override
  protected void initComponent() {
    form = new FWForm("form");
    body.add(form);

    // 数据件数
    cnt = new FWLabel("cnt");
    form.add(cnt);

    grdContainser = new FWContainer("grdContainser");
    form.add(grdContainser);

    // 明细容器生成
    adminDP = new GridDataProvider();
    rptList = new FWDataView("rptList", adminDP, this);
    // 每页件数设定
    rptList.setItemsPerPage(getItemsPerPage());
    grdContainser.add(rptList);

    // 分页处理
    paging = new ILoanCustomPaging("paging", rptList, form, this);
    form.add(paging);

    // 产品类型
    ddlFinanceProdId =
        new FWDropDownChoice("ddlFinanceProdId", new ArrayList<ChoiceNameValue>(), false, this);
    ddlFinanceProdId.setSelectedValue("");
    ddlFinanceProdId.setAjaxOnSubmitEnable(true);
    form.add(ddlFinanceProdId);

    // 投资用户
    txtFinanceCoutom = new FWTextField("txtFinanceCoutom");
    form.add(txtFinanceCoutom);

    // 检索按钮
    findBtn = new FWSubmitLink("findBtn", this);
    form.add(findBtn);

    ajaxComponentBind();
  }
 /**
  * 检索条件DTO作成。
  *
  * @param 没有
  * @return 条件DTO
  */
 private FinanceProdTenderDto createCondition() {
   // 条件BEAN生成
   FinanceProdTenderDto dto = new FinanceProdTenderDto();
   // 产品类型
   dto.setOidFinanceProdId(ddlFinanceProdId.getValue());
   // 检索Key
   dto.setSearchKey(txtFinanceCoutom.getValue());
   // 每页起始位置
   dto.setPageIndex(ConvUtils.convToInt(rptList.getFirstItemOffset()));
   // 每页最大件数
   dto.setPageSize(ConvUtils.convToInt(rptList.getItemsPerPage()));
   // 条件BEAN返回
   return dto;
 }
  /** 画面项目初期表示设定 */
  private void setInitComponentValue() {
    // 设定融资产品类型
    List<Map<String, Object>> prodInfoList = financeProdService.getFinanceProdAllList();
    List<ChoiceNameValue> prodInfoChoiceList = new ArrayList<ChoiceNameValue>();
    ChoiceNameValue firstValue = new ChoiceNameValue();
    firstValue.setValue("");
    firstValue.setName("全部");
    prodInfoChoiceList.add(firstValue);

    ChoiceNameValue value = null;
    for (Map<String, Object> productInfoMap : prodInfoList) {

      value = new ChoiceNameValue();
      value.setValue(ConvUtils.convToString(productInfoMap.get("OID_FINANCE_PROD_ID")));
      value.setName(ConvUtils.convToString(productInfoMap.get("FINANCE_PROD_TITLE")));
      prodInfoChoiceList.add(value);
    }
    ddlFinanceProdId.setChoices(prodInfoChoiceList);
    // ddlFinanceProdId.setSelectedIndex(0);
  }
  protected void form_OnSubmit() {
    if (!checkInput()) {
      return;
    }
    // 业务鉴证
    AdvertizeDto dto = new AdvertizeDto();
    dto.setId(id);
    Map<String, Object> advertizeMap = operationsManageService.getAdvertizeById(dto);
    if (opType.equals("U") && advertizeMap.isEmpty()) {
      alertError(MessageUtils.getMessage("ERR0013", "数据已被删除。"));
      submitBtn.setDisabled(true);
      return;
    }

    // 文件上传
    String linksImgPath = "";
    String linksBakImgPath = "";
    try {
      if (upLinksIcon.getFileUploads().size() > 0) {
        linksImgPath =
            imageDataStoreManager.put(upLinksIcon.getFileName(), upLinksIcon.getInputStream());
      }
      if (upLinksBakIcon.getFileUploads().size() > 0) {
        linksBakImgPath =
            imageDataStoreManager.put(
                upLinksBakIcon.getFileName(), upLinksBakIcon.getInputStream());
      }
    } catch (FWImageDataStoreException e) {
      if (e.getErrorCode().equals("FW004005E")) {
        alertError(e.getMessage());
      } else {
        logger.error("图片上传失败。", e);
        if ("U".equals(opType)) {
          saveOperatorLog(
              Constants.OPERATOR_LOG_U, Constants.OPERATOR_LOG_FAILURE, "广告【" + id + "】编辑失败。");
        } else {
          saveOperatorLog(Constants.OPERATOR_LOG_I, Constants.OPERATOR_LOG_FAILURE, "广告添加失败。");
        }
        alertError(MessageUtils.getMessage("ERR0013", "图片上传失败。"));
      }
      return;
    }
    // 数据登陆
    dto.setAdvertizeShowPageId(advertizeShowPageChoice.getValue());
    dto.setShowType(showType.getValue());
    dto.setSort(sort.getValue());
    dto.setValidFlg(validFlg.getValue());
    dto.setImgPath(linksImgPath);
    dto.setBackgroundImgPath(linksBakImgPath);
    if (linkUrl.getValue().startsWith("http://")) {
      dto.setLinkUrl(linkUrl.getValue());
    } else {
      dto.setLinkUrl("http://" + linkUrl.getValue());
    }
    dto.setUpdUserId(getAdminUser().getOidAdminUserId());
    if (opType.equals("U")) {
      dto.setId(id);
      boolean upd = operationsManageService.updAdvertize(dto);
      if (upd) {
        try {
          if (!StringUtils.isEmpty(linksImgPath)) {
            imageDataStoreManager.delete(ConvUtils.convToString(advertizeMap.get("IMG_PATH")));
            linksIcon.setSrc(imageDataStoreManager.getURL(linksImgPath).replace("\\", "/"));
          }
          if (!StringUtils.isEmpty(linksBakImgPath)) {
            imageDataStoreManager.delete(
                ConvUtils.convToString(advertizeMap.get("BACKGROUND_IMG_PATH")));
            linksBakIcon.setSrc(imageDataStoreManager.getURL(linksBakImgPath).replace("\\", "/"));
          }
        } catch (FWImageDataStoreException e) {
          logger.error("图片删除失败。", e);
        }
        saveOperatorLog(
            Constants.OPERATOR_LOG_U,
            Constants.OPERATOR_LOG_SUCCESS,
            "广告【" + dto.getId() + "】更新成功。");

        submitBtn.setDisabled(true);
        alertSucc(2);
      } else {
        saveOperatorLog(
            Constants.OPERATOR_LOG_U,
            Constants.OPERATOR_LOG_FAILURE,
            "广告【" + dto.getId() + "】更新失败。");
        alertError(MessageUtils.getMessage("ERR0013", "数据可能已被删除。"));
      }
    } else {
      boolean add = operationsManageService.insAdvertize(dto);
      if (add) {
        saveOperatorLog(
            Constants.OPERATOR_LOG_I,
            Constants.OPERATOR_LOG_SUCCESS,
            "广告【"
                + advertizeShowPageChoice.getValue()
                + ','
                + showType.getValue()
                + ','
                + sort.getValue()
                + "】添加成功。");
        linksIcon.setVisible(true);
        linksIcon.setSrc(imageDataStoreManager.getURL(linksImgPath).replace("\\", "/"));
        linksBakIcon.setVisible(true);
        linksBakIcon.setSrc(imageDataStoreManager.getURL(linksBakImgPath).replace("\\", "/"));
        submitBtn.setDisabled(true);
        alertSucc(2);
      } else {
        saveOperatorLog(
            Constants.OPERATOR_LOG_I,
            Constants.OPERATOR_LOG_FAILURE,
            "广告【"
                + advertizeShowPageChoice.getValue()
                + ','
                + showType.getValue()
                + ','
                + sort.getValue()
                + "】添加失败。");
        alertError(MessageUtils.getMessage("ERR0012"));
      }
    }
  }
  @Override
  public void initPage() {
    advertizeShowPageChoice.setChoiceList(operationsManageService.getAdvertizeShowPageChoices());
    if ("U".equals(opType)) {
      txtLinksIcon.setVisible(false);
      txtLinksBakIcon.setVisible(false);
      // 检索数据
      AdvertizeDto dto = new AdvertizeDto();
      dto.setId(id);
      Map<String, Object> resultMap = operationsManageService.getAdvertizeById(dto);
      if (resultMap.isEmpty()) {
        alertError(MessageUtils.getMessage("ERR0013", "数据已被删除。"));
        submitBtn.setDisabled(true);
        return;
      }
      // 广告显示页面
      advertizeShowPageChoice.setSelectedValue(
          ConvUtils.convToString(resultMap.get("ADVERTIZE_SHOW_PAGE_ID")));
      // 广告类型
      showType.setSelectedValue(ConvUtils.convToString(resultMap.get("SHOW_TYPE")));
      // 排序
      sort.setValue(ConvUtils.convToString(resultMap.get("SORT")));
      if ("1".equals(showType.getValue())) {
        sort.setDisabled(false);
      } else {
        sort.setDisabled(true);
      }
      // 有效Flag
      validFlg.setSelectedValue(ConvUtils.convToString(resultMap.get("VALID_FLG")));
      // 图片
      linksIcon.setSrc(
          imageDataStoreManager
              .getURL(ConvUtils.convToString(resultMap.get("IMG_PATH")))
              .replace("\\", "/"));
      if (StringUtils.isEmpty(ConvUtils.convToString(resultMap.get("IMG_PATH")))) {
        linksIcon.setVisible(false);
      } else {
        linksIcon.setVisible(true);
      }
      // 背景图片
      linksBakIcon.setSrc(
          imageDataStoreManager
              .getURL(ConvUtils.convToString(resultMap.get("BACKGROUND_IMG_PATH")))
              .replace("\\", "/"));
      if (StringUtils.isEmpty(ConvUtils.convToString(resultMap.get("BACKGROUND_IMG_PATH")))) {
        linksBakIcon.setVisible(false);
      } else {
        linksBakIcon.setVisible(true);
      }
      // 链接地址
      linkUrl.setValue(ConvUtils.convToString(resultMap.get("LINK_URL")));

    } else {
      txtLinksIcon.setVisible(true);
      txtLinksBakIcon.setVisible(true);
      advertizeShowPageChoice.setSelectedIndex(0);
      showType.setSelectedValue("1");
      validFlg.setSelectedValue("1");
      linksIcon.setVisible(false);
      linksBakIcon.setVisible(false);
      linkUrl.setValue("http://");
    }
  }
 /** ajax应用的组件绑定 */
 private void ajaxComponentBind() {
   // 产品类型关联组件的绑定
   ddlFinanceProdId.addTargetComponent(grdContainser);
   ddlFinanceProdId.addTargetComponent(paging);
 }