package com.yanzhu.jh.project.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.yanzhu.jh.project.mapper.SurProjectAttendanceDataMapper;
import com.yanzhu.jh.project.domain.SurProjectAttendanceData;
import com.yanzhu.jh.project.service.ISurProjectAttendanceDataService;
import com.ruoyi.common.utils.SecurityUtils;
/**
 * 劳务实名制管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-09-24
 */
@Service
public class SurProjectAttendanceDataServiceImpl implements ISurProjectAttendanceDataService 
{
    @Autowired
    private SurProjectAttendanceDataMapper surProjectAttendanceDataMapper;

    /**
     * 查询劳务实名制管理
     * 
     * @param id 劳务实名制管理主键
     * @return 劳务实名制管理
     */
    @Override
    public SurProjectAttendanceData selectSurProjectAttendanceDataById(Long id)
    {
        return surProjectAttendanceDataMapper.selectSurProjectAttendanceDataById(id);
    }

    /**
     * 查询劳务实名制管理列表
     * 
     * @param surProjectAttendanceData 劳务实名制管理
     * @return 劳务实名制管理
     */
    @Override
    public List<SurProjectAttendanceData> selectSurProjectAttendanceDataList(SurProjectAttendanceData surProjectAttendanceData)
    {
        return surProjectAttendanceDataMapper.selectSurProjectAttendanceDataList(surProjectAttendanceData);
    }

    /**
     * 新增劳务实名制管理
     * 
     * @param surProjectAttendanceData 劳务实名制管理
     * @return 结果
     */
    @Override
    public int insertSurProjectAttendanceData(SurProjectAttendanceData surProjectAttendanceData)
    {

        surProjectAttendanceData.setCreateBy("task");
        surProjectAttendanceData.setCreateTime(DateUtils.getNowDate());
        return surProjectAttendanceDataMapper.insertSurProjectAttendanceData(surProjectAttendanceData);
    }

    /**
     * 修改劳务实名制管理
     * 
     * @param surProjectAttendanceData 劳务实名制管理
     * @return 结果
     */
    @Override
    public int updateSurProjectAttendanceData(SurProjectAttendanceData surProjectAttendanceData)
    {
        surProjectAttendanceData.setUpdateBy("task");
        surProjectAttendanceData.setUpdateTime(DateUtils.getNowDate());
        return surProjectAttendanceDataMapper.updateSurProjectAttendanceData(surProjectAttendanceData);
    }

    /**
     * 批量删除劳务实名制管理
     * 
     * @param ids 需要删除的劳务实名制管理主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectAttendanceDataByIds(Long[] ids)
    {
        return surProjectAttendanceDataMapper.deleteSurProjectAttendanceDataByIds(ids);
    }

    /**
     * 删除劳务实名制管理信息
     * 
     * @param id 劳务实名制管理主键
     * @return 结果
     */
    @Override
    public int deleteSurProjectAttendanceDataById(Long id)
    {
        return surProjectAttendanceDataMapper.deleteSurProjectAttendanceDataById(id);
    }

    @Override
    public void add(SurProjectAttendanceData sdata) {
        SurProjectAttendanceData where=new SurProjectAttendanceData();
        where.setVendorsCode(sdata.getVendorsCode());
        where.setCfgid(sdata.getCfgid());
        where.setServerid(sdata.getServerid());
        List<SurProjectAttendanceData> list=selectSurProjectAttendanceDataList(where);
        if(list.size()==0){
            insertSurProjectAttendanceData(sdata);
        }else{
            sdata.setId(list.get(0).getId());
            updateSurProjectAttendanceData(sdata);
        }
    }

    @Override
    public long getLastServerId(SurProjectAttendanceData where) {
        return surProjectAttendanceDataMapper.getLastServerId(where);
    }

    @Override
    public List<SurProjectAttendanceData> groupByComany(SurProjectAttendanceData where) {
        return surProjectAttendanceDataMapper.groupByComany(where);
    }
}
