/**
   * 根据 psTypeVo 来组装 中间件
   *
   * @param psTypeVo
   * @return
   */
  public MonitorServiceDTO getMonitorServiceDTOByPSTypeVo(PSTypeVo psTypeVo) {

    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 = psTypeVo.getId();
    String alias = psTypeVo.getPort();
    String ipAddress = psTypeVo.getIpaddress();
    String category = "portService";

    Node psTypeVoNode = PollingEngine.getInstance().getSocketByID(id);

    int status = 0;
    try {
      status = psTypeVoNode.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

    EventListDao eventListDao = new EventListDao();
    try {
      generalAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='1' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
      urgentAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='2' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
      seriousAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='3' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
    } catch (RuntimeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      eventListDao.close();
    }
    eventListSummary.put("generalAlarm", generalAlarm);
    eventListSummary.put("urgentAlarm", urgentAlarm);
    eventListSummary.put("seriousAlarm", seriousAlarm);

    String monflag = "否";
    if (psTypeVo.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;
  }
  /**
   * 根据 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;
  }