DowntimeHistoryDao.java 1.8 KB
package com.sitech.ismp.check.downtime;

import com.sitech.database.dao.BaseDao;
import org.apache.log4j.Logger;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author frank  zmm@honggroup.com.cn
 * @Description:  告警历史dao
 * @Package com.sitech.ismp.check.downtime
 * @ClassName: com.sitech.ismp.check.downtime.DowntimeHistoryDao
 * @date 2017年04月19日 14:06
 */
public class DowntimeHistoryDao extends BaseDao {
    private static Logger log=Logger.getLogger(DowntimeHistoryDao.class);

    /**
     * 添加告警信息
     * @param bean
     */
    public void addDowntimeHistory(DowntimeHistoryBean bean){
        try {
            sqlmapClient.insert("addDowntimeHistory", bean);
        } catch (SQLException e) {
            log.error("Exception while addDowntimeHistory.",e);
        }
    }

    /**
     *
     * @param deviceIp
     * @param createDate
     * @return
     */
    public List<DowntimeHistoryBean> getDowntimeHistoryByIp(String deviceIp,String createDate){
        HashMap<String,String> param=new HashMap<String, String>();
        param.put("DEVICE_IP",deviceIp);
        param.put("CREATE_DATE",createDate);
        List<DowntimeHistoryBean> beanList=new ArrayList<DowntimeHistoryBean>();
        try {
            beanList=sqlmapClient.queryForList("getDowntimeHistoryByIp", param);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return beanList;
    }

    /**
     * 删除表中的所有数据。
     * @return
     */
    public int deleteDowntimeHistory(){
        try {
            return sqlmapClient.delete("deleteDowntimeHistory", null);
        } catch (Exception e) {
            error.error("Exception while deleteDowntimeHistory.", e);
        }
        return -1;
    }

}