package com.qmth.themis.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.themis.business.dao.TIeInvigilateWarnInfoMapper;
import com.qmth.themis.business.dto.response.TEExamQueryDto;
import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
import com.qmth.themis.business.enums.VerifyExceptionEnum;
import com.qmth.themis.business.enums.WarningLevelEnum;
import com.qmth.themis.business.service.TIeInvigilateWarnInfoService;
import org.springframework.stereotype.Service;

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

/**
 * @Description: 监考预警信息 服务实现类
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
@Service
public class TIeInvigilateWarnInfoServiceImpl extends ServiceImpl<TIeInvigilateWarnInfoMapper, TIeInvigilateWarnInfo> implements TIeInvigilateWarnInfoService {

    @Resource
    TIeInvigilateWarnInfoMapper tIeInvigilateWarnInfoMapper;

    /**
     * 预警提醒
     *
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param userId
     * @param orgId
     * @return
     */
    @Override
    public Integer warningCount(Long examId, Long examActivityId, String roomCode, Long userId, Long orgId) {
        return tIeInvigilateWarnInfoMapper.warningCount(examId, examActivityId, roomCode, userId, orgId);
    }

    /**
     * 预警提醒
     *
     * @param examIdList
     * @param userId
     * @param orgId
     * @return
     */
    @Override
    public List<TEExamQueryDto> warningCountByList(List<Long> examIdList, Long userId, Long orgId) {
        return tIeInvigilateWarnInfoMapper.warningCountByList(examIdList, userId, orgId);
    }

    /**
     * 预警通知
     *
     * @param examId
     * @param userId
     * @param orgId
     * @return
     */
    @Override
    public List<TIeWarningNotifyDto> warningMessage(Long examId, Long userId, Long orgId) {
        return tIeInvigilateWarnInfoMapper.warningMessage(examId, userId, orgId);
    }

    /**
     * 查找预警和异常信息
     *
     * @param examRecordId
     * @param verifyExceptionEnum
     * @param warningLevelEnum
     * @return
     */
    @Override
    public List<Integer> findWarnAndExceptionInfo(Long examRecordId, VerifyExceptionEnum verifyExceptionEnum, WarningLevelEnum warningLevelEnum) {
        return tIeInvigilateWarnInfoMapper.findWarnAndExceptionInfo(examRecordId, Objects.nonNull(verifyExceptionEnum) ? verifyExceptionEnum.name() : null, Objects.nonNull(warningLevelEnum) ? warningLevelEnum.name() : null);
    }
}
