package com.ygtx.gxt.service.impl;

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

import com.ygtx.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ygtx.gxt.mapper.GxtUserFanInspectionScoreMapper;
import com.ygtx.gxt.domain.GxtUserFanInspectionScore;
import com.ygtx.gxt.service.IGxtUserFanInspectionScoreService;
import com.ygtx.common.utils.DateUtils;

/**
 * 维保风机类型检查得分Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-11-06
 */
@Service
public class GxtUserFanInspectionScoreServiceImpl implements IGxtUserFanInspectionScoreService 
{
    @Autowired
    private GxtUserFanInspectionScoreMapper gxtUserFanInspectionScoreMapper;

    /**
     * 查询维保风机类型检查得分
     * 
     * @param id 维保风机类型检查得分主键
     * @return 维保风机类型检查得分
     */
    @Override
    public GxtUserFanInspectionScore selectGxtUserFanInspectionScoreById(Long id)
    {
        return gxtUserFanInspectionScoreMapper.selectGxtUserFanInspectionScoreById(id);
    }

    /**
     * 查询维保风机类型检查得分列表
     * 
     * @param gxtUserFanInspectionScore 维保风机类型检查得分
     * @return 维保风机类型检查得分
     */
    @Override
    public List<GxtUserFanInspectionScore> selectGxtUserFanInspectionScoreList(GxtUserFanInspectionScore gxtUserFanInspectionScore)
    {
        return gxtUserFanInspectionScoreMapper.selectGxtUserFanInspectionScoreList(gxtUserFanInspectionScore);
    }

    /**
     * 查询当月维保机组类型评分
     * 
     * @return 维保风机类型检查得分集合
     */
    @Override
    public List<GxtUserFanInspectionScore> selectFanInspectionScoreForCurrentMonth()
    {
        GxtUserFanInspectionScore userFanInspectionScore = new GxtUserFanInspectionScore();
        userFanInspectionScore.setDeptId(SecurityUtils.getDeptId());
        return gxtUserFanInspectionScoreMapper.selectFanInspectionScoreForCurrentMonth(userFanInspectionScore);
    }

    /**
     * 根据条件查询维保机组类型评分
     * 
     * @param rtType 实时类型
     * @param monthPeriod 统计月份
     * @param userId 用户ID
     * @param deptId 部门ID
     * @return 维保风机类型检查得分集合
     */
    @Override
    public List<GxtUserFanInspectionScore> selectFanInspectionScoreByCondition(Integer rtType, String monthPeriod, Long userId, Long deptId, String permission)
    {
        if (rtType==null) {
            rtType=0;
        }
        GxtUserFanInspectionScore userFanInspectionScore = new GxtUserFanInspectionScore();
        userFanInspectionScore.setMonthPeriod(monthPeriod);
        userFanInspectionScore.setPermission(permission);
        if (rtType == 2) {
            userFanInspectionScore.setDeptId(deptId);
            return gxtUserFanInspectionScoreMapper.selectFanInspectionScoreForCurrentMonth(userFanInspectionScore);
        }else if (rtType == 1) {
            userFanInspectionScore.setDeptId(deptId);
        } else {
            userFanInspectionScore.setUserId(userId);
        }
        return gxtUserFanInspectionScoreMapper.selectFanInspectionScoreBySP(userFanInspectionScore);
    }


    @Override
    public List<GxtUserFanInspectionScore> selectFanInspectionScoreByDeptId(Integer rtType, String monthPeriod, Long userId, Long deptId, String permission)
    {
        GxtUserFanInspectionScore userFanInspectionScore = new GxtUserFanInspectionScore();
        userFanInspectionScore.setMonthPeriod(monthPeriod);
        userFanInspectionScore.setPermission(permission);
        userFanInspectionScore.setDeptId(deptId);
        return gxtUserFanInspectionScoreMapper.selectFanInspectionScoreByDeptId(userFanInspectionScore);
    }

    /**
     * 新增维保风机类型检查得分
     * 
     * @param gxtUserFanInspectionScore 维保风机类型检查得分
     * @return 结果
     */
    @Override
    public int insertGxtUserFanInspectionScore(GxtUserFanInspectionScore gxtUserFanInspectionScore)
    {
        return gxtUserFanInspectionScoreMapper.insertGxtUserFanInspectionScore(gxtUserFanInspectionScore);
    }

    /**
     * 修改维保风机类型检查得分
     * 
     * @param gxtUserFanInspectionScore 维保风机类型检查得分
     * @return 结果
     */
    @Override
    public int updateGxtUserFanInspectionScore(GxtUserFanInspectionScore gxtUserFanInspectionScore)
    {
        return gxtUserFanInspectionScoreMapper.updateGxtUserFanInspectionScore(gxtUserFanInspectionScore);
    }

    /**
     * 批量删除维保风机类型检查得分
     * 
     * @param ids 需要删除的维保风机类型检查得分主键
     * @return 结果
     */
    @Override
    public int deleteGxtUserFanInspectionScoreByIds(Long[] ids)
    {
        return gxtUserFanInspectionScoreMapper.deleteGxtUserFanInspectionScoreByIds(ids);
    }

    /**
     * 删除维保风机类型检查得分信息
     * 
     * @param id 维保风机类型检查得分主键
     * @return 结果
     */
    @Override
    public int deleteGxtUserFanInspectionScoreById(Long id)
    {
        return gxtUserFanInspectionScoreMapper.deleteGxtUserFanInspectionScoreById(id);
    }
}