package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;

import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxProduceSnService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesProduceSnExt;
import cn.estsh.i3plus.ext.mes.pojo.repository.MesProduceSnExtRepository;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.util.MesConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @PROJECT_NAME: i3plus-mes-panasonic-jx
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2023-11-29 11:39
 */
@Service
public class JxProduceSnService implements IJxProduceSnService {

    @Autowired
    private MesProduceSnExtRepository produceSnExtRepository;

    @Override
    public MesProduceSnExt getProduceSn(String organizeCode, String productSn) {

        if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null;

        return produceSnExtRepository.getByProperty(
                new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, MesExtConstWords.PRODUCT_SN},
                new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), productSn});
    }
}
