@Override public List<Creditinfo> findByMultiAndPage(final String[] orgacode,final String timeStart, final String timeEnd) { List<Creditinfo> CreditinfoList = creditinfoDao.findAll( new Specification<Creditinfo>() { @Override public Predicate toPredicate(Root<Creditinfo> root, CriteriaQuery<?> query, CriteriaBuilder cb) { // TODO Auto-generated method stub Predicate predicate = cb.conjunction(); List<Expression<Boolean>> expressions = predicate .getExpressions(); // if (StringUtils.isNotBlank(creditinfo.getCreditcode())) { // expressions.add(cb.equal(root.<String> get("creditcode"),creditinfo.getCreditcode())); // 机构信用代码 // } if (orgacode!=null&&orgacode.length>0) { expressions.add(cb.and(root.<String>get("orgacode").in(orgacode))); // 机构信用代码 } if (StringUtils.isNotBlank(timeStart)||StringUtils.isNotBlank(timeEnd)) { expressions.add(cb.between(root.<String> get("inputdate"),timeStart,timeEnd)); // 机构信用代码 } return predicate; } }); return CreditinfoList; }
总结,方法要学会变通……