package com.op.mes.service.impl;

import com.op.common.core.utils.DateUtils;
import com.op.mes.domain.ProOrderWorkorder;
import com.op.mes.mapper.ProOrderWorkorderMapper;
import com.op.mes.service.IProOrderWorkorderService;
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 ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
    @Autowired
    private ProOrderWorkorderMapper proOrderWorkorderMapper;

    /**
     * 查询生产工单
     *
     * @param workorderId 生产工单主键
     * @return 生产工单
     */
    @Override
    public ProOrderWorkorder selectProOrderWorkorderByWorkorderId(String workorderId) {
        return proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
    }

    /**
     * 查询生产工单列表
     *
     * @param proOrderWorkorder 生产工单
     * @return 生产工单
     */
    @Override
    public List<ProOrderWorkorder> selectProOrderWorkorderList(ProOrderWorkorder proOrderWorkorder) {
        return proOrderWorkorderMapper.selectProOrderWorkorderList(proOrderWorkorder);
    }

    /**
     * 新增生产工单
     *
     * @param proOrderWorkorder 生产工单
     * @return 结果
     */
    @Override
    public int insertProOrderWorkorder(ProOrderWorkorder proOrderWorkorder) {
        proOrderWorkorder.setCreateTime(DateUtils.getNowDate());
        return proOrderWorkorderMapper.insertProOrderWorkorder(proOrderWorkorder);
    }

    /**
     * 修改生产工单
     *
     * @param proOrderWorkorder 生产工单
     * @return 结果
     */
    @Override
    public int updateProOrderWorkorder(ProOrderWorkorder proOrderWorkorder) {
        proOrderWorkorder.setUpdateTime(DateUtils.getNowDate());
        return proOrderWorkorderMapper.updateProOrderWorkorder(proOrderWorkorder);
    }

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

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