package com.op.mes.service.impl;

import com.op.common.core.utils.DateUtils;
import com.op.mes.domain.ProOrderWorkorderBatch;
import com.op.mes.mapper.ProOrderWorkorderBatchMapper;
import com.op.mes.service.IProOrderWorkorderBatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 生产工单批次Service业务层处理
 *
 * @author Open Platform
 * @date 2023-07-18
 */
@Service
public class ProOrderWorkorderBatchServiceImpl implements IProOrderWorkorderBatchService {
    @Autowired
    private ProOrderWorkorderBatchMapper proOrderWorkorderBatchMapper;

    /**
     * 查询生产工单批次
     *
     * @param workorderId 生产工单批次主键
     * @return 生产工单批次
     */
    @Override
    public ProOrderWorkorderBatch selectProOrderWorkorderBatchByWorkorderId(String workorderId) {
        return proOrderWorkorderBatchMapper.selectProOrderWorkorderBatchByWorkorderId(workorderId);
    }

    /**
     * 查询生产工单批次列表
     *
     * @param proOrderWorkorderBatch 生产工单批次
     * @return 生产工单批次
     */
    @Override
    public List<ProOrderWorkorderBatch> selectProOrderWorkorderBatchList(ProOrderWorkorderBatch proOrderWorkorderBatch) {
        return proOrderWorkorderBatchMapper.selectProOrderWorkorderBatchList(proOrderWorkorderBatch);
    }

    /**
     * 新增生产工单批次
     *
     * @param proOrderWorkorderBatch 生产工单批次
     * @return 结果
     */
    @Override
    public int insertProOrderWorkorderBatch(ProOrderWorkorderBatch proOrderWorkorderBatch) {
        proOrderWorkorderBatch.setCreateTime(DateUtils.getNowDate());
        return proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(proOrderWorkorderBatch);
    }

    /**
     * 修改生产工单批次
     *
     * @param proOrderWorkorderBatch 生产工单批次
     * @return 结果
     */
    @Override
    public int updateProOrderWorkorderBatch(ProOrderWorkorderBatch proOrderWorkorderBatch) {
        proOrderWorkorderBatch.setUpdateTime(DateUtils.getNowDate());
        return proOrderWorkorderBatchMapper.updateProOrderWorkorderBatch(proOrderWorkorderBatch);
    }

    /**
     * 批量删除生产工单批次
     *
     * @param workorderIds 需要删除的生产工单批次主键
     * @return 结果
     */
    @Override
    public int deleteProOrderWorkorderBatchByWorkorderIds(String[] workorderIds) {
        return proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds);
    }

    /**
     * 删除生产工单批次信息
     *
     * @param workorderId 生产工单批次主键
     * @return 结果
     */
    @Override
    public int deleteProOrderWorkorderBatchByWorkorderId(String workorderId) {
        return proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderId(workorderId);
    }
}