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

import cn.estsh.i3plus.ext.mes.pcn.api.base.jx.IJxBadnessClassifyDetailService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesBadnessClassifyDetail;
import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.MesBadnessClassifyDetailRepository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.MesBadnessClassifyRepository;
import cn.estsh.i3plus.ext.mes.pcn.pojo.sqlpack.MesPcnExtHqlPack;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
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.impp.framework.boot.exception.ImppExceptionBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @PROJECT_NAME: i3plus-qms-panasonic
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2022-06-07 10:45
 */
@Service
public class JxBadnessClassifyDetailService implements IJxBadnessClassifyDetailService {

    @Autowired
    private MesBadnessClassifyDetailRepository badnessClassifyDetailDao;

    @Override
    public ListPager<MesBadnessClassifyDetail> queryBadnessClassifyDetailPager(MesBadnessClassifyDetail buBadnessClassifyDetail, Pager pager) {
        DdlPackBean packBean = MesPcnExtHqlPack.getSxBadnessClassifyDetail(buBadnessClassifyDetail);
        pager = PagerHelper.getPager(pager, badnessClassifyDetailDao.findByHqlWhereCount(packBean));
        packBean.setOrderByStr(" order by modifyDatetime desc ");
        List<MesBadnessClassifyDetail> sxQmsBuBadnessClassifyDetails = badnessClassifyDetailDao.findByHqlWherePage(packBean, pager);
        return new ListPager(sxQmsBuBadnessClassifyDetails, pager);
    }
}
