java基础知识

最后发布时间:2020-07-09 00:58:06 浏览量:
 Scanner scanner = new Scanner(System.in);
    int n1 = 0, n2 = 0;
    boolean bError = true;
    while (bError) {
        if (scanner.hasNextInt())
            n1 = scanner.nextInt();
        else {
            scanner.next();
            continue;
        }
        if (scanner.hasNextInt())
            n2 = scanner.nextInt();
        else {
            scanner.next();
            continue;
        }
        bError = false;
    }
    System.out.println(n1);
    System.out.println(n2);
tblCarton2RCardLogRepository.findAll(new Specification<TblCarton2RCardLog>() {
    @Override
    public  Predicate toPredicate(Root<TblCarton2RCardLog> root, CriteriaQuery<?> query,CriteriaBuilder cb) {
        List<Predicate> list = new ArrayList<Predicate>();

        list.add(cb.equal(root.get("cartonNo").as(String.class), cartonNo));//某普通字段

        list.add(cb.equal(root.get("id").get("rCard").as(String.class), rCard));//主键中某字段

        list.add(cb.like(root.get("mocode").as(String.class), "%" + mocode + "%"));//like

        list.add(cb.between(root.get("frozenDate").as(Long.class), frozenDateStart, frozenDateEnd));//between and

        list.add(cb.greaterThanOrEqualTo(root.get("id").get("rcard").as(String.class), rCardStart));//大于等于

        list.add(root.get("id").get("lotNo").as(String.class).in(lotNos));//in

        //ORDER BY packdate DESC,packtime DESC
        Predicate[] p = new Predicate[list.size()];
        query.where(cb.and(list.toArray(p)));
        query.orderBy(cb.desc(root.get("packDate")),cb.desc(root.get("packTime")));

        return query.getRestriction();
    }
});
快捷入口
计算机知识 思维导图 浏览PDF 下载PDF
分享到:
标签