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

import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesShiftGroupCenterCfgService;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesShiftGroupCenterCfg;
import cn.estsh.i3plus.pojo.mes.repository.MesShiftGroupCenterCfgRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description: 产线与班组的对应关系
 * @Author: gsz
 * @Date: 2024/5/21 14:16
 * @Modify:
 */
@Service
@Slf4j
public class MesShiftGroupCenterCfgServiceImpl implements IMesShiftGroupCenterCfgService {

    @Autowired
    private MesShiftGroupCenterCfgRepository mesShiftGroupCenterCfgRDao;

    @Override
    public ListPager<MesShiftGroupCenterCfg> queryMesShiftGroupCenterCfgByPager(MesShiftGroupCenterCfg bean, Pager pager) {

        DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
        DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBean);
        DdlPreparedPack.getStringEqualPack(bean.getShiftGroup(), "shiftGroup", packBean);
        DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
        pager = PagerHelper.getPager(pager, mesShiftGroupCenterCfgRDao.findByHqlWhereCount(packBean));

        List<MesShiftGroupCenterCfg> resultList = mesShiftGroupCenterCfgRDao.findByHqlWherePage(packBean, pager);

        return new ListPager<>(resultList, pager);
    }

}
