Specification<RetMtrlSpare> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();
if (CollectionUtils.isNotEmpty(mtrlStatList)) {
predicates.add(root.get("mtrlStat").in(mtrlStatList));
}
if (StringUtils.isNotBlank(iary.getMtrlProdId())) {
predicates.add(criteriaBuilder.equal(root.get("mtrlProdId"), iary.getMtrlProdId()));
}
if (StringUtils.isNotBlank(iary.getMtrlDsc())) {
predicates.add(criteriaBuilder.equal(root.get("mtrlDsc"), iary.getMtrlDsc()));
}
if (StringUtils.isNotBlank(iary.getMtrlType())) {
predicates.add(criteriaBuilder.equal(root.get("mtrlTyp"), iary.getMtrlType()));
}
if (StringUtils.isNotBlank(iary.getMtrlSeqId())) {
predicates.add(criteriaBuilder.equal(root.get("mtrlSeqId"), iary.getMtrlSeqId()));
}
if (CollectionUtils.isNotEmpty(toolIdList)) {
predicates.add(root.get("toolId").in(toolIdList));
}
if (CollectionUtils.isNotEmpty(actToolList)) {
predicates.add(root.get("actToolId").in(actToolList));
}
if (CollectionUtils.isNotEmpty(deptList)) {
predicates.add(root.get("dept").in(deptList));
}
if (CollectionUtils.isNotEmpty(actDeptList)) {
predicates.add(root.get("actDept").in(actDeptList));
}
if (StringUtils.isNotBlank(iary.getMtrlCate())) {
predicates.add(criteriaBuilder.equal(root.get("mtrlCate"), iary.getMtrlCate()));
}
Predicate[] p = predicates.toArray(new Predicate[0]);
return criteriaBuilder.and(p);
};
Sort sort = Sort.by(Sort.Direction.DESC, "moveinTimestamp");
List<RetMtrlSpare> retMtrlSpareList;
long tblCnt = 0l;
//判断分页
if (com.totainfo.common.util.Util.shouldPage(inTrx)) {
//按分页和排序查询
Page<RetMtrlSpare> retMtrlSparePage = retMtrlSpareDao.findAll(specification, com.totainfo.common.util.Util.getPageable(inTrx, sort));
retMtrlSpareList = retMtrlSparePage.getContent();
tblCnt = retMtrlSparePage.getTotalElements();
} else {
retMtrlSpareList = retMtrlSpareDao.findAll(specification, sort);
}
版权声明:本文为qq_44058265原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。