package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base.bu3;

import cn.estsh.i3plus.ext.mes.pcn.api.base.bu3.IMesOuterPackageDetailService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesOuterPackageDetail;
import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.MesOuterPackageDetailRepository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xinwang.yi
 * @version 1.0
 * @date 2023/01/11 13:34
 **/
@Service
public class MesOuterPackageDetailService implements IMesOuterPackageDetailService {

    @Autowired
    private MesOuterPackageDetailRepository outerPackageDetailRepository;

    @Override
    public MesOuterPackageDetail getBoundOuterPackDetailByWorkOrderNoAndPackNo(String organizeCode, String workOrderNo, String packageNo) {
        return outerPackageDetailRepository.getByProperty(new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_ORDER_NO, MesPcnExtConstWords.PACKAGENO, MesPcnExtConstWords.BIND_STATUS},
                new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), workOrderNo, packageNo, MesPcnExtEnumUtil.PACKAGE_BIND_STATUS.BINGDING.getValue()});
    }

    @Override
    public List<MesOuterPackageDetail> findBoundOuterPackDetailByWorkOrderNo(String organizeCode, String workOrderNo) {
        return outerPackageDetailRepository.findByProperty(new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_ORDER_NO, MesPcnExtConstWords.BIND_STATUS},
                new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), workOrderNo, MesPcnExtEnumUtil.PACKAGE_BIND_STATUS.BINGDING.getValue()});
    }
}
