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

import cn.estsh.i3plus.ext.mes.api.busi.jx.IJxManualReportTravelService;
import cn.estsh.i3plus.ext.mes.pojo.bean.MesManualReportTravel;
import cn.estsh.i3plus.ext.mes.pojo.repository.MesManualReportTravelRepository;
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-10-27 10:18
 */
@Service
public class JxManualReportTravelService implements IJxManualReportTravelService {

    @Autowired
    private MesManualReportTravelRepository manualReportTravelRepository;

    @Override
    public ListPager<MesManualReportTravel> queryManualReportTravelByPager(MesManualReportTravel manualReportTravel, Pager pager) {

        DdlPackBean packBean = MesExtHqlPack.getMesManualReportTravel(manualReportTravel);

        pager = PagerHelper.getPager(pager, manualReportTravelRepository.findByHqlWhereCount(packBean));

        packBean.setOrderByStr(manualReportTravel.orderBy());

        return new ListPager(manualReportTravelRepository.findByHqlWhere(packBean), pager);
    }
}
