package com.yanzhu.jh.project.service.impl;

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

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.file.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.jh.project.mapper.SurProjectWorkSpecialMapper;
import com.yanzhu.jh.project.domain.SurProjectWorkSpecial;
import com.yanzhu.jh.project.service.ISurProjectWorkSpecialService;
import com.ruoyi.common.utils.SecurityUtils;
/**
 * 项目特种人员Service业务层处理
 * 
 * @author JiangYuQi
 * @date 2023-08-09
 */
@Service
public class SurProjectWorkSpecialServiceImpl implements ISurProjectWorkSpecialService 
{
    @Autowired
    private SurProjectWorkSpecialMapper surProjectWorkSpecialMapper;

    /**
     * 查询项目特种人员
     * 
     * @param id 项目特种人员主键
     * @return 项目特种人员
     */
    @Override
    public SurProjectWorkSpecial selectSurProjectWorkSpecialById(Long id)
    {
        return surProjectWorkSpecialMapper.selectSurProjectWorkSpecialById(id);
    }

    /**
     * 查询项目特种人员列表
     * 
     * @param surProjectWorkSpecial 项目特种人员
     * @return 项目特种人员
     */
    @Override
    public List<SurProjectWorkSpecial> selectSurProjectWorkSpecialList(SurProjectWorkSpecial surProjectWorkSpecial)
    {
        return surProjectWorkSpecialMapper.selectSurProjectWorkSpecialList(surProjectWorkSpecial);
    }

    /**
     * 查询项目特种人员数量统计
     *
     * @param surProjectWorkSpecial 项目特种人员
     * @return 项目特种人员集合
     */
    @Override
    public Map<String,Object> findWorkSpecialCount(SurProjectWorkSpecial surProjectWorkSpecial) {
        Map<String,Object> dataMap = new HashMap<>();
        dataMap.put("expired",surProjectWorkSpecialMapper.selectSurProjectWorkSpecialExpired(surProjectWorkSpecial));
        dataMap.put("notExpired",surProjectWorkSpecialMapper.selectSurProjectWorkSpecialNotExpired(surProjectWorkSpecial));
        return dataMap;
    }

    /**
     * 查询项目特种人员统计列表
     *
     * @param surProjectWorkSpecial 项目特种人员
     * @return 项目特种人员集合
     */
    @Override
    public List<Map<String,Object>> selectBgscreenWorkSpecialList(SurProjectWorkSpecial surProjectWorkSpecial) {
        return surProjectWorkSpecialMapper.selectBgscreenWorkSpecialList(surProjectWorkSpecial);
    }
    /**
     * 新增项目特种人员
     * 
     * @param surProjectWorkSpecial 项目特种人员
     * @return 结果
     */
    @Override
    public int insertSurProjectWorkSpecial(SurProjectWorkSpecial surProjectWorkSpecial)
    {
        surProjectWorkSpecial.setCreateBy(SecurityUtils.getUsername());
        surProjectWorkSpecial.setDeptId(SecurityUtils.getDeptId());
        surProjectWorkSpecial.setCreateTime(DateUtils.getNowDate());
        surProjectWorkSpecial.setCredentialType(FileUtils.getFileLastNameUpCase(surProjectWorkSpecial.getCredentialFile()));
        return surProjectWorkSpecialMapper.insertSurProjectWorkSpecial(surProjectWorkSpecial);
    }

    /**
     * 修改项目特种人员
     * 
     * @param surProjectWorkSpecial 项目特种人员
     * @return 结果
     */
    @Override
    public int updateSurProjectWorkSpecial(SurProjectWorkSpecial surProjectWorkSpecial)
    {
        surProjectWorkSpecial.setUpdateBy(SecurityUtils.getUsername());
        surProjectWorkSpecial.setUpdateTime(DateUtils.getNowDate());
        surProjectWorkSpecial.setCredentialType(FileUtils.getFileLastNameUpCase(surProjectWorkSpecial.getCredentialFile()));
        return surProjectWorkSpecialMapper.updateSurProjectWorkSpecial(surProjectWorkSpecial);
    }

    /**
     * 批量删除项目特种人员
     * 
     * @param ids 需要删除的项目特种人员主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectWorkSpecialByIds(Long[] ids)
    {
        return surProjectWorkSpecialMapper.deleteSurProjectWorkSpecialByIds(ids);
    }

    /**
     * 删除项目特种人员信息
     * 
     * @param id 项目特种人员主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectWorkSpecialById(Long id)
    {
        return surProjectWorkSpecialMapper.deleteSurProjectWorkSpecialById(id);
    }
}
