package com.ruoyi.powerdistribution.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.powerdistribution.mapper.PdmMaintenanceProcessMapper;
import com.ruoyi.powerdistribution.domain.PdmMaintenanceProcess;
import com.ruoyi.powerdistribution.service.IPdmMaintenanceProcessService;

/**
 * 检修计划全流程管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@Service
public class PdmMaintenanceProcessServiceImpl implements IPdmMaintenanceProcessService 
{
    @Autowired
    private PdmMaintenanceProcessMapper pdmMaintenanceProcessMapper;

    /**
     * 查询检修计划全流程管理
     * 
     * @param id 检修计划全流程管理主键
     * @return 检修计划全流程管理
     */
    @Override
    public PdmMaintenanceProcess selectPdmMaintenanceProcessById(Long id)
    {
        return pdmMaintenanceProcessMapper.selectPdmMaintenanceProcessById(id);
    }

    /**
     * 查询检修计划全流程管理列表
     * 
     * @param pdmMaintenanceProcess 检修计划全流程管理
     * @return 检修计划全流程管理
     */
    @Override
    public List<PdmMaintenanceProcess> selectPdmMaintenanceProcessList(PdmMaintenanceProcess pdmMaintenanceProcess)
    {
        return pdmMaintenanceProcessMapper.selectPdmMaintenanceProcessList(pdmMaintenanceProcess);
    }

    /**
     * 新增检修计划全流程管理
     * 
     * @param pdmMaintenanceProcess 检修计划全流程管理
     * @return 结果
     */
    @Override
    public int insertPdmMaintenanceProcess(PdmMaintenanceProcess pdmMaintenanceProcess)
    {
        pdmMaintenanceProcess.setCreateTime(DateUtils.getNowDate());
        return pdmMaintenanceProcessMapper.insertPdmMaintenanceProcess(pdmMaintenanceProcess);
    }

    /**
     * 修改检修计划全流程管理
     * 
     * @param pdmMaintenanceProcess 检修计划全流程管理
     * @return 结果
     */
    @Override
    public int updatePdmMaintenanceProcess(PdmMaintenanceProcess pdmMaintenanceProcess)
    {
        pdmMaintenanceProcess.setUpdateTime(DateUtils.getNowDate());
        if(StringUtils.isNotEmpty(pdmMaintenanceProcess.getApproveFileName())){
            pdmMaintenanceProcess.setIsApprove("2");
        }
        if(StringUtils.isNotEmpty(pdmMaintenanceProcess.getMaintenanceFileName())){
            pdmMaintenanceProcess.setIsMaintenance("2");
        }
        return pdmMaintenanceProcessMapper.updatePdmMaintenanceProcess(pdmMaintenanceProcess);
    }

    /**
     * 批量删除检修计划全流程管理
     * 
     * @param ids 需要删除的检修计划全流程管理主键
     * @return 结果
     */
    @Override
    public int deletePdmMaintenanceProcessByIds(Long[] ids)
    {
        return pdmMaintenanceProcessMapper.deletePdmMaintenanceProcessByIds(ids);
    }

    /**
     * 删除检修计划全流程管理信息
     * 
     * @param id 检修计划全流程管理主键
     * @return 结果
     */
    @Override
    public int deletePdmMaintenanceProcessById(Long id)
    {
        return pdmMaintenanceProcessMapper.deletePdmMaintenanceProcessById(id);
    }
}
