package com.aucma.dms.service.impl;

//import com.hw.common.core.utils.DateUtils;
//import com.hw.common.security.utils.SecurityUtils;
//import com.aucma.dms.domain.DmsPlanLubeDetail;
//import com.aucma.dms.mapper.DmsPlanLubeDetailMapper;
//import com.aucma.dms.service.IDmsPlanLubeDetailService;

import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.SecurityUtils;
import com.aucma.dms.domain.DmsPlanLubeDetail;
import com.aucma.dms.mapper.DmsPlanLubeDetailMapper;
import com.aucma.dms.service.IDmsPlanLubeDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 润滑计划明细Service业务层处理
 *
 * @author xins
 * @date 2024-03-21
 */
@Service
public class DmsPlanLubeDetailServiceImpl implements IDmsPlanLubeDetailService
{
    @Autowired
    private DmsPlanLubeDetailMapper dmsPlanLubeDetailMapper;

    /**
     * 查询润滑计划明细
     *
     * @param planLubeDetailId 润滑计划明细主键
     * @return 润滑计划明细
     */
    @Override
    public DmsPlanLubeDetail selectDmsPlanLubeDetailByPlanLubeDetailId(Long planLubeDetailId)
    {
        return dmsPlanLubeDetailMapper.selectDmsPlanLubeDetailByPlanLubeDetailId(planLubeDetailId);
    }

    /**
     * 查询润滑计划明细列表
     *
     * @param dmsPlanLubeDetail 润滑计划明细
     * @return 润滑计划明细
     */
    @Override
    public List<DmsPlanLubeDetail> selectDmsPlanLubeDetailList(DmsPlanLubeDetail dmsPlanLubeDetail)
    {
        return dmsPlanLubeDetailMapper.selectDmsPlanLubeDetailList(dmsPlanLubeDetail);
    }

    /**
     * 新增润滑计划明细
     *
     * @param dmsPlanLubeDetail 润滑计划明细
     * @return 结果
     */
    @Override
    public int insertDmsPlanLubeDetail(DmsPlanLubeDetail dmsPlanLubeDetail)
    {
        dmsPlanLubeDetail.setCreateBy(SecurityUtils.getLoginUser()==null ? SecurityUtils.getUserId() :SecurityUtils.getLoginUser().getUser().getUserId());
        dmsPlanLubeDetail.setCreateTime(DateUtils.getNowDate());
        dmsPlanLubeDetail.setIsFlag(1l);
        return dmsPlanLubeDetailMapper.insertDmsPlanLubeDetail(dmsPlanLubeDetail);
    }

    /**
     * 修改润滑计划明细
     *
     * @param dmsPlanLubeDetail 润滑计划明细
     * @return 结果
     */
    @Override
    public int updateDmsPlanLubeDetail(DmsPlanLubeDetail dmsPlanLubeDetail)
    {
        dmsPlanLubeDetail.setUpdateBy(SecurityUtils.getLoginUser()==null ? SecurityUtils.getUserId() :SecurityUtils.getLoginUser().getUser().getUserId());
        dmsPlanLubeDetail.setUpdateTime(DateUtils.getNowDate());
        return dmsPlanLubeDetailMapper.updateDmsPlanLubeDetail(dmsPlanLubeDetail);
    }

    /**
     * 批量删除润滑计划明细
     *
     * @param planLubeDetailIds 需要删除的润滑计划明细主键
     * @return 结果
     */
    @Override
    public int deleteDmsPlanLubeDetailByPlanLubeDetailIds(Long[] planLubeDetailIds)
    {
        return dmsPlanLubeDetailMapper.deleteDmsPlanLubeDetailByPlanLubeDetailIds(planLubeDetailIds);
    }

    /**
     * 删除润滑计划明细信息
     *
     * @param planLubeDetailId 润滑计划明细主键
     * @return 结果
     */
    @Override
    public int deleteDmsPlanLubeDetailByPlanLubeDetailId(Long planLubeDetailId)
    {
        return dmsPlanLubeDetailMapper.deleteDmsPlanLubeDetailByPlanLubeDetailId(planLubeDetailId);
    }

    @Override
    public List<DmsPlanLubeDetail> selectPlanLubeDetailByPlanLubeId(Long planLubeId) {
        return dmsPlanLubeDetailMapper.selectPlanLubeDetailByPlanLubeId(planLubeId);
    }
}
