package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TEarlyWarningMapper;
import com.ruoyi.system.domain.TEarlyWarning;
import com.ruoyi.system.service.ITEarlyWarningService;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2023-09-27
 */
@Service
public class TEarlyWarningServiceImpl implements ITEarlyWarningService {
    @Autowired
    private TEarlyWarningMapper tEarlyWarningMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public TEarlyWarning selectTEarlyWarningById(Long id) {
        return tEarlyWarningMapper.selectTEarlyWarningById(id);
    }

    @Override
    public List<TEarlyWarning> selectTEarlyWarningByAlarmId(Long alarmId) {
        return tEarlyWarningMapper.selectTEarlyWarningByAlarmId(alarmId);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param tEarlyWarning 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TEarlyWarning> selectTEarlyWarningList(TEarlyWarning tEarlyWarning) {
        return tEarlyWarningMapper.selectTEarlyWarningList(tEarlyWarning);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param tEarlyWarning 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertTEarlyWarning(TEarlyWarning tEarlyWarning) {
        tEarlyWarning.setCreateTime(DateUtils.getNowDate());
        return tEarlyWarningMapper.insertTEarlyWarning(tEarlyWarning);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param tEarlyWarning 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTEarlyWarning(TEarlyWarning tEarlyWarning) {
        tEarlyWarning.setUpdateTime(DateUtils.getNowDate());
        tEarlyWarning.setEventRecord(tEarlyWarning.getMsg());
        tEarlyWarning.setState(tEarlyWarning.getSolve_status());
        return tEarlyWarningMapper.updateTEarlyWarning(tEarlyWarning);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTEarlyWarningByIds(Long[] ids) {
        return tEarlyWarningMapper.deleteTEarlyWarningByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTEarlyWarningById(Long id) {
        return tEarlyWarningMapper.deleteTEarlyWarningById(id);
    }

    @Override
    public List<TEarlyWarning> selectTEarlyWarningList_SOS(TEarlyWarning earlyWarning) {
        //SOS 预警类型
        earlyWarning.setType(16);
        return tEarlyWarningMapper.selectTEarlyWarningList_SOS(earlyWarning);
    }

    @Override
    public List<TEarlyWarning> selectTEarlyWarningList_FALLSOLVE(TEarlyWarning earlyWarning) {
        //跌倒 预警类型
        earlyWarning.setType(21);
        return tEarlyWarningMapper.selectTEarlyWarningList_SOS(earlyWarning);
    }

    @Override
    public List<TEarlyWarning> selectTEarlyWarningList_HEALTHSOLVE(TEarlyWarning earlyWarning) {
        //健康 预警类型
        //22:心率异常报警,23:血压异常报警，24:体温异常报警，25:血氧异常报警
        return tEarlyWarningMapper.selectTEarlyWarningList_HEALTHSOLVE(earlyWarning);
    }

    @Override
    public List<TEarlyWarning> selectTEarlyWarningList_OTHERSOLVE(TEarlyWarning earlyWarning) {
        //其他 预警类型
        return tEarlyWarningMapper.selectTEarlyWarningList_OTHERSOLVE(earlyWarning);
    }

    @Override
    public Integer selectTEarlyWarningCompletedCountByType(Integer type) {
        return tEarlyWarningMapper.selectTEarlyWarningCompletedCountByType(type);
    }

    @Override
    public Integer selectTEarlyWarningUnCompletedCountByType(Integer type) {
        return tEarlyWarningMapper.selectTEarlyWarningUnCompletedCountByType(type);
    }

    @Override
    public Integer selectTEarlyWarningUnCompletedAllCount() {
        return tEarlyWarningMapper.selectTEarlyWarningUnCompletedAllCount();
    }

    @Override
    public Double selectTEarlyWarningUnCompletedPercentageByType(Integer type) {
        return tEarlyWarningMapper.selectTEarlyWarningUnCompletedPercentageByType(type);
    }

    @Override
    public Double selectTEarlyWarningUnCompletedPercentageByAllType() {
        return tEarlyWarningMapper.selectTEarlyWarningUnCompletedPercentageByAllType();
    }
}
