package com.ruoyi.ems.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.core.utils.DateTimeUtil;
import com.ruoyi.ems.domain.AdmOpAlarm;
import com.ruoyi.ems.mapper.AdmOpAlarmMapper;
import com.ruoyi.ems.service.IAdmOpAlarmService;

/**
 * 能源设施告警Service业务层处理
 *
 * @author ruoyi
 * @date 2024-08-26
 */
@Service
public class AdmOpAlarmServiceImpl implements IAdmOpAlarmService {
    @Autowired
    private AdmOpAlarmMapper admOpAlarmMapper;

    /**
     * 查询能源设施告警
     *
     * @param id 能源设施告警主键
     * @return 能源设施告警
     */
    @Override
    public AdmOpAlarm selectAdmOpAlarmById(Long id) {
        return admOpAlarmMapper.selectAdmOpAlarmById(id);
    }

    /**
     * 查询能源设施告警列表
     *
     * @param admOpAlarm 能源设施告警
     * @return 能源设施告警
     */
    @Override
    public List<AdmOpAlarm> selectAdmOpAlarmList(AdmOpAlarm admOpAlarm) {
        return admOpAlarmMapper.selectAdmOpAlarmList(admOpAlarm);
    }

    /**
     * 新增能源设施告警
     *
     * @param admOpAlarm 能源设施告警
     * @return 结果
     */
    @Override
    public int insertAdmOpAlarm(AdmOpAlarm admOpAlarm) {
        return admOpAlarmMapper.insertAdmOpAlarm(admOpAlarm);
    }

    /**
     * 修改能源设施告警
     *
     * @param admOpAlarm 能源设施告警
     * @return 结果
     */
    @Override
    public int updateAdmOpAlarm(AdmOpAlarm admOpAlarm) {
        return admOpAlarmMapper.updateAdmOpAlarm(admOpAlarm);
    }

    /**
     * 批量删除能源设施告警
     *
     * @param ids 需要删除的能源设施告警主键
     * @return 结果
     */
    @Override
    public int deleteAdmOpAlarmByIds(Long[] ids) {
        return admOpAlarmMapper.deleteAdmOpAlarmByIds(ids);
    }

    /**
     * 删除能源设施告警信息
     *
     * @param id 能源设施告警主键
     * @return 结果
     */
    @Override
    public int deleteAdmOpAlarmById(Long id) {
        return admOpAlarmMapper.deleteAdmOpAlarmById(id);
    }

    @Override
    public List<Map<String, Object>> qryAlarmTypeIndex(String areaCode) {
        return admOpAlarmMapper.qryAlarmTypeIndex(areaCode);
    }

    @Override
    public List<Map<String, Object>> qryAlarmTypeIndexDay(String areaCode) {
        String dateTime = DateTimeUtil.currentDateTime(DateTimeUtil.DateFormatter.yyyy_MM_dd);
        return admOpAlarmMapper.qryAlarmTypeIndexDay(dateTime, areaCode);
    }

    @Override
    public List<Map<String, Object>> qryAlarmTypeIndexMonth(String areaCode) {
        String firstDayOfRecentMonth = DateTimeUtil.getFirstDayOfRecentMonth();
        return admOpAlarmMapper.qryAlarmTypeIndexMonth(firstDayOfRecentMonth, areaCode);
    }

    @Override
    public List<Map<String, Object>> qryAlarmTypeIndexYear(String areaCode) {
        String firstDayOfRecentYear = DateTimeUtil.getFirstDayOfRecentYear();
        return admOpAlarmMapper.qryAlarmTypeIndexYear(firstDayOfRecentYear, areaCode);
    }
}
