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

import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesTimeEfficientCfgService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesTimeEfficientCfg;
import cn.estsh.i3plus.pojo.mes.repository.MesTimeEfficientCfgRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class MesTimeEfficientCfgService implements IMesTimeEfficientCfgService {

    @Autowired
    private MesTimeEfficientCfgRepository timeEfficientCfgRepository;

    @Override
    public List<MesTimeEfficientCfg> getTimeEfficientCfgList(String organizeCode, Long sourceId) {
        if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(sourceId)) return null;
        return timeEfficientCfgRepository.findByProperty(
                new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.SOURCE_ID},
                new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), sourceId});
    }

}
