package com.ruoyi.baseinfo.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.baseinfo.mapper.BaseWorkingprocedureInfoMapper;
import com.ruoyi.baseinfo.domain.BaseWorkingprocedureInfo;
import com.ruoyi.baseinfo.service.IBaseWorkingprocedureInfoService;
import com.ruoyi.common.core.text.Convert;

/**
 * 工序基础信息Service业务层处理
 * 
 * @author CaesarBao
 * @date 2020-10-22
 */
@Service
public class BaseWorkingprocedureInfoServiceImpl implements IBaseWorkingprocedureInfoService 
{
    @Autowired
    private BaseWorkingprocedureInfoMapper baseWorkingprocedureInfoMapper;

    /**
     * 查询工序基础信息
     * 
     * @param objid 工序基础信息ID
     * @return 工序基础信息
     */
    @Override
    public BaseWorkingprocedureInfo selectBaseWorkingprocedureInfoById(Long objid)
    {
        return baseWorkingprocedureInfoMapper.selectBaseWorkingprocedureInfoById(objid);
    }

    /**
     * 查询工序基础信息列表
     * 
     * @param baseWorkingprocedureInfo 工序基础信息
     * @return 工序基础信息
     */
    @Override
    public List<BaseWorkingprocedureInfo> selectBaseWorkingprocedureInfoList(BaseWorkingprocedureInfo baseWorkingprocedureInfo)
    {
        return baseWorkingprocedureInfoMapper.selectBaseWorkingprocedureInfoList(baseWorkingprocedureInfo);
    }

    /**
     * 新增工序基础信息
     * 
     * @param baseWorkingprocedureInfo 工序基础信息
     * @return 结果
     */
    @Override
    public int insertBaseWorkingprocedureInfo(BaseWorkingprocedureInfo baseWorkingprocedureInfo)
    {
        baseWorkingprocedureInfo.setCreateTime(DateUtils.getNowDate());
        return baseWorkingprocedureInfoMapper.insertBaseWorkingprocedureInfo(baseWorkingprocedureInfo);
    }

    /**
     * 修改工序基础信息
     * 
     * @param baseWorkingprocedureInfo 工序基础信息
     * @return 结果
     */
    @Override
    public int updateBaseWorkingprocedureInfo(BaseWorkingprocedureInfo baseWorkingprocedureInfo)
    {
        baseWorkingprocedureInfo.setUpdateTime(DateUtils.getNowDate());
        return baseWorkingprocedureInfoMapper.updateBaseWorkingprocedureInfo(baseWorkingprocedureInfo);
    }

    /**
     * 删除工序基础信息对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteBaseWorkingprocedureInfoByIds(String ids)
    {
        return baseWorkingprocedureInfoMapper.deleteBaseWorkingprocedureInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除工序基础信息信息
     * 
     * @param objid 工序基础信息ID
     * @return 结果
     */
    @Override
    public int deleteBaseWorkingprocedureInfoById(Long objid)
    {
        return baseWorkingprocedureInfoMapper.deleteBaseWorkingprocedureInfoById(objid);
    }

    @Override
    public List<BaseWorkingprocedureInfo> selectAddBaseWorkingprocedureInfoList()
    {
        return baseWorkingprocedureInfoMapper.selectAddBaseWorkingprocedureInfoList();
    }

    @Override
    public List<BaseWorkingprocedureInfo> selectEditBaseWorkingprocedureInfoList(String workingProcedureId) {
        List<BaseWorkingprocedureInfo> cbWorkingprocedureInfoList = baseWorkingprocedureInfoMapper.selectAddBaseWorkingprocedureInfoList();
        for (BaseWorkingprocedureInfo baseWorkingprocedureInfo: cbWorkingprocedureInfoList
             ) {
            if(baseWorkingprocedureInfo.getWorkingProcedureId().equals(workingProcedureId)){
                baseWorkingprocedureInfo.setFlag(true);
                break;
            }
        }
        return cbWorkingprocedureInfoList;
    }
}
