package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.ep;

import cn.estsh.i3plus.ext.mes.pcn.api.busi.ep.IEpWorkOrderExtBindSnService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesWorkOrderExtBindSn;
import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.MesWorkOrderExtBindSnRepository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author wangjie
 * @version 1.0
 * @date 2021/1/13 9:28
 **/
@Slf4j
@Service
public class EpWorkOrderExtBindSnService implements IEpWorkOrderExtBindSnService {

    @Autowired
    private MesWorkOrderExtBindSnRepository workOrderExtBindSnRepository;

    @Override
    public MesWorkOrderExtBindSn getWorkOrderExtBindSnByOrderNo(String organizeCode, String workOrderNo) {
        if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo) ) {
            return null;
        }
        return workOrderExtBindSnRepository.getByProperty(
                new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_ORDER_NO},
                new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workOrderNo});
    }
}
