/**
  * 修改 FTPConfig 的监视信息之后返回FTPConfig列表页面
  *
  * @return
  */
 private void changeFtpManage() {
   boolean result = false;
   FTPConfig ftpConfig = new FTPConfig();
   FTPConfigDao ftpConfigDao = null;
   try {
     String id = getParaValue("id");
     int monflag = getParaIntValue("value");
     ftpConfigDao = new FTPConfigDao();
     ftpConfig = (FTPConfig) ftpConfigDao.findByID(id);
     ftpConfig.setMonflag(monflag);
     result = ftpConfigDao.update(ftpConfig);
     Ftp ftp = (Ftp) PollingEngine.getInstance().getFtpByID(Integer.parseInt(id));
     ftp.setMonflag(monflag);
   } catch (Exception e) {
     e.printStackTrace();
     result = false;
   } finally {
     ftpConfigDao.close();
   }
 }
  /**
   * 根据 ftpConfig 来组装 中间件
   *
   * @param ftpConfig
   * @return
   */
  public MonitorServiceDTO getMonitorServiceDTOByFtp(FTPConfig ftpConfig) {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = simpleDateFormat.format(new Date());

    String starttime = date + " 00:00:00";
    String totime = date + " 23:59:59";

    int id = ftpConfig.getId();
    String alias = ftpConfig.getName();
    String ipAddress = ftpConfig.getIpaddress();
    String category = "ftp";

    Node ftpNode = PollingEngine.getInstance().getFtpByID(id);

    int status = 0;
    try {
      status = ftpNode.getStatus();
    } catch (RuntimeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Hashtable eventListSummary = new Hashtable();

    String generalAlarm = "0"; // 普通告警数  默认为 0
    String urgentAlarm = "0"; // 严重告警数  默认为 0
    String seriousAlarm = "0"; // 紧急告警数  默认为 0

    Ftpmonitor_historyDao ftpmonitor_historyDao = new Ftpmonitor_historyDao();
    try {
      seriousAlarm =
          ftpmonitor_historyDao.getCountByWhere(
              " where ftp_id='"
                  + id
                  + "'"
                  + " and is_canconnected='0' and mon_time>='"
                  + starttime
                  + "' and mon_time<='"
                  + totime
                  + "'");
    } catch (RuntimeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      ftpmonitor_historyDao.close();
    }
    eventListSummary.put("generalAlarm", generalAlarm);
    eventListSummary.put("urgentAlarm", urgentAlarm);
    eventListSummary.put("seriousAlarm", seriousAlarm);

    String monflag = "否";
    if (ftpConfig.getMonflag() == 1) {
      monflag = "是";
    }

    MonitorServiceDTO monitorServiceDTO = new MonitorServiceDTO();
    monitorServiceDTO.setId(id);
    monitorServiceDTO.setStatus(String.valueOf(status));
    monitorServiceDTO.setAlias(alias);
    monitorServiceDTO.setIpAddress(ipAddress);
    monitorServiceDTO.setPingValue("");
    monitorServiceDTO.setCategory(category);
    monitorServiceDTO.setEventListSummary(eventListSummary);
    monitorServiceDTO.setMonflag(monflag);
    return monitorServiceDTO;
  }