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

import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxBomPendingPartService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesBomPendingPart;
import cn.estsh.i3plus.ext.mes.pojo.repository.MesBomPendingPartRepository;
import cn.estsh.i3plus.ext.mes.pojo.sqlpack.MesExtHqlPack;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @PROJECT_NAME: i3plus-mes-panasonic-jx
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2023-11-20 10:55
 */
@Service
public class JxBomPendingPartService implements IJxBomPendingPartService {

    @Autowired
    private MesBomPendingPartRepository bomPendingPartRepository;

    @Override
    public ListPager<MesBomPendingPart> queryBomPendingPartByPager(MesBomPendingPart bomPendingPart, Pager pager) {
        DdlPackBean hqlPack = MesExtHqlPack.getBomPendingPart(bomPendingPart);
        int count = bomPendingPartRepository.findByHqlWhereCount(hqlPack);
        pager = PagerHelper.getPager(pager, count);
        hqlPack.setOrderByStr(bomPendingPart.orderBy());
        return new ListPager(bomPendingPartRepository.findByHqlWherePage(hqlPack, pager), pager);
    }
}
