package com.pwt.web.service.impl;

import java.util.Collection;
import java.util.List;
import com.pwt.common.utils.DateUtils;
import com.pwt.netty.message2.Alarm;
import com.pwt.web.domain.DeviceType;
import com.pwt.web.domain.PwtAlarmRecordQueryParam;
import com.pwt.web.domain.PwtAlarmRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pwt.web.mapper.PwtAlarmRecordMapper;
import com.pwt.web.domain.PwtAlarmRecord;
import com.pwt.web.service.IPwtAlarmRecordService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 告警记录Service业务层处理
 * 
 * @author linyun
 * @date 2022-11-17
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PwtAlarmRecordServiceImpl implements IPwtAlarmRecordService
{
    @Autowired
    private PwtAlarmRecordMapper pwtAlarmRecordMapper;

    /**
     * 查询告警记录
     * 
     * @param recordId 告警记录ID
     * @return 告警记录
     */
    @Override
    public PwtAlarmRecord selectPwtAlarmRecordById(Long recordId)
    {
        return pwtAlarmRecordMapper.selectPwtAlarmRecordById(recordId);
    }

    /**
     * 查询告警记录列表
     * 
     * @return 告警记录
     */
    @Override
    public List<PwtAlarmRecordVo> selectPwtAlarmRecordList(PwtAlarmRecordQueryParam param)
    {
        return pwtAlarmRecordMapper.selectPwtAlarmRecordList(param);
    }

    /**
     * 新增告警记录
     * 
     * @param pwtAlarmRecord 告警记录
     * @return 结果
     */
    @Override
    public int insertPwtAlarmRecord(PwtAlarmRecord pwtAlarmRecord)
    {
        pwtAlarmRecord.setCreateTime(DateUtils.getNowDate());
        return pwtAlarmRecordMapper.insertPwtAlarmRecord(pwtAlarmRecord);
    }

    @Override
    public int insertPwtAlarmRecords(Collection<Alarm> alarms) {
        return pwtAlarmRecordMapper.insertPwtAlarmRecords(alarms);
    }

    /**
     * 修改告警记录
     * 
     * @param pwtAlarmRecord 告警记录
     * @return 结果
     */
    @Override
    public int updatePwtAlarmRecord(PwtAlarmRecord pwtAlarmRecord)
    {
        return pwtAlarmRecordMapper.updatePwtAlarmRecord(pwtAlarmRecord);
    }

    /**
     * 批量删除告警记录
     * 
     * @param recordIds 需要删除的告警记录ID
     * @return 结果
     */
    @Override
    public int deletePwtAlarmRecordByIds(Long[] recordIds)
    {
        return pwtAlarmRecordMapper.deletePwtAlarmRecordByIds(recordIds);
    }

    /**
     * 删除告警记录信息
     * 
     * @param recordId 告警记录ID
     * @return 结果
     */
    @Override
    public int deletePwtAlarmRecordById(Long recordId)
    {
        return pwtAlarmRecordMapper.deletePwtAlarmRecordById(recordId);
    }

    /**
     * 获取来源设备字典
     * @return
     */
    @Override
    public List<DeviceType> getSourceDeviceDict()
    {
        return pwtAlarmRecordMapper.getSourceDeviceDict();
    }
}
