package com.casic.missiles.modular.alarm.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.casic.missiles.modular.alarm.service.IAlarmRecordsService;
import com.casic.missiles.modular.system.model.AlarmRecords;
import com.casic.missiles.core.datascope.DataScope;
import com.casic.missiles.core.util.EhcacheConstant;
import com.casic.missiles.core.util.ToolUtil;
import com.casic.missiles.modular.system.dao.AlarmRecordsMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author casic123
 * @since 2019-05-17
 */
@Service
public class AlarmRecordsServiceImpl extends ServiceImpl<AlarmRecordsMapper, AlarmRecords> implements IAlarmRecordsService {


    @Override
    public List<Map<String,Object>> alarmList(Page<Map<String,Object>> page, String keywords, String beginTime, String endTime, String status, String alarmType, String alarmContent, DataScope dataScope) {
        String sContent = null;
        if (ToolUtil.isNotEmpty(alarmContent)){
            sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent));
        }
        return this.baseMapper.alarmList(page,keywords,beginTime,endTime,status,alarmType,sContent,dataScope);
    }

    /**
     * 查询告警列表，不分页，批量消警用
     */
    @Override
    public List<AlarmRecords> alarmListNoPage(DataScope dataScope, String keywords, String alarmType, String alarmContent, String beginTime, String endTime) {
        String sContent = null;
        if (ToolUtil.isNotEmpty(alarmContent)){
            sContent = EhcacheConstant.retBean().getAlarmContentName(Integer.valueOf(alarmContent));
        }
        return this.baseMapper.alarmListNoPage(dataScope,keywords,alarmType,sContent,beginTime,endTime);
    }

    @Override
    public boolean cancelAlarm(int id, String jobStatus, String handleMessage, long personId) {
        return this.baseMapper.cancelAlarm(id,jobStatus,handleMessage,personId);
    }

}
