package com.yunfeiyun.agmp.fms.service.impl;

import java.util.List;

import com.yunfeiyun.agmp.common.enums.SysWarnEnum;
import com.yunfeiyun.agmp.common.utils.DateUtils;
import com.yunfeiyun.agmp.common.utils.SecurityUtils;
import com.yunfeiyun.agmp.fms.domain.SysWarn;
import com.yunfeiyun.agmp.fms.domain.SysWarnread;
import com.yunfeiyun.agmp.fms.mapper.SysWarnMapper;
import com.yunfeiyun.agmp.fms.mapper.SysWarnreadMapper;
import com.yunfeiyun.agmp.fms.domain.reqvo.SelectCountOfScreenReqVo;
import com.yunfeiyun.agmp.fms.domain.reqvo.SysWarnReqVo;
import com.yunfeiyun.agmp.fms.domain.resvo.SysWarnResVo;
import com.yunfeiyun.agmp.fms.service.ISysWarnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 系统预警Service业务层处理
 * 
 * @author 杨晓辉
 * @date 2023-07-05
 */
@Service
public class SysWarnServiceImpl implements ISysWarnService
{
    @Autowired
    private SysWarnMapper sysWarnMapper;
    @Autowired
    private SysWarnreadMapper sysWarnreadMapper;

    /**
     * 查询系统预警
     * 
     * @param warnId 系统预警主键
     * @return 系统预警
     */
    @Override
    public SysWarn selectSysWarnByWarnId(String warnId)
    {
        return sysWarnMapper.selectSysWarnByWarnId(warnId);
    }

    /**
     * 查询系统预警列表
     * 
     * @param reqVo 系统预警
     * @return 系统预警
     */
    @Override
    public List<SysWarnResVo> selectSysWarnList(SysWarnReqVo reqVo)
    {
        return sysWarnMapper.selectSysWarnList(reqVo);
    }

    @Override
    public List<SysWarnResVo> selectSysWarnListOfScreen(SysWarnReqVo reqVo) {
        return sysWarnMapper.selectSysWarnListOfScreen(reqVo);
    }

    @Override
    public List<SysWarnResVo> selectCountOfSysWarn(SysWarnReqVo reqVo) {
        return sysWarnMapper.selectCountOfSysWarn(reqVo);
    }

    @Override
    public Integer selectCount(SelectCountOfScreenReqVo reqVo) {
        return sysWarnMapper.selectCount(reqVo);
    }

    @Override
    public int read(SysWarn sysWarn) {
        SysWarnread sysWarnread = new SysWarnread();
        sysWarnread.setWarnreadId(sysWarnread.getId());
        sysWarnread.setWarnId(sysWarn.getWarnId());
        sysWarnread.setWarnreadCreateddate(DateUtils.dateTimeNow());
        sysWarnread.setUserId(SecurityUtils.getUserId());
        return sysWarnreadMapper.insertSysWarnread(sysWarnread);
    }

    @Override
    public void genWarn(String warnJumpurl, String warnRemark, SysWarnEnum.SysWarnType warnType, SysWarnEnum.SysWarnClass warnClass) {
        SysWarn sysWarn = new SysWarn();
        sysWarn.setWarnClass(warnClass.getCode());
        sysWarn.setWarnType(warnType.getCode());
        sysWarn.setWarnId(sysWarn.getId());
        sysWarn.setWarnJumpurl(warnJumpurl);
        sysWarn.setWarnRemark(warnRemark);
        sysWarn.setWarnCreateddate(DateUtils.dateTimeNow());
        sysWarnMapper.insertSysWarn(sysWarn);
    }

    /**
     * 新增系统预警
     * 
     * @param sysWarn 系统预警
     * @return 结果
     */
    @Override
    public int insertSysWarn(SysWarn sysWarn)
    {
        return sysWarnMapper.insertSysWarn(sysWarn);
    }

    /**
     * 修改系统预警
     * 
     * @param sysWarn 系统预警
     * @return 结果
     */
    @Override
    public int updateSysWarn(SysWarn sysWarn)
    {
        return sysWarnMapper.updateSysWarn(sysWarn);
    }

    /**
     * 批量删除系统预警
     * 
     * @param warnIds 需要删除的系统预警主键
     * @return 结果
     */
    @Override
    public int deleteSysWarnByWarnIds(String[] warnIds)
    {
        return sysWarnMapper.deleteSysWarnByWarnIds(warnIds);
    }

    /**
     * 删除系统预警信息
     * 
     * @param warnId 系统预警主键
     * @return 结果
     */
    @Override
    public int deleteSysWarnByWarnId(String warnId)
    {
        return sysWarnMapper.deleteSysWarnByWarnId(warnId);
    }
}
