private static final Integer WORKITEM_MAX_NUMBER = 200; private int savePbhProblemworkitem(List<ProblemWorkitemVm> problemworkitem) { try { int count = 0; int limit = countStep(problemworkitem.size(), WORKITEM_MAX_NUMBER); List<List<ProblemWorkitemVm>> splitList = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> problemworkitem.stream().skip(a * WORKITEM_MAX_NUMBER).limit(WORKITEM_MAX_NUMBER).parallel().collect(Collectors.toList())).collect(Collectors.toList()); for(List<ProblemWorkitemVm> pwList : splitList){ count += pgMapper.savePbhProblemWorkitem(pwList); } return count; } catch (Exception e) { log.error(e.getMessage()); return 0; } } /** * 计算切分次数 */ private static Integer countStep(Integer size, Integer maxNumber) { return (size + maxNumber - 1) / maxNumber; }
标签:WORKITEM,MAX,NUMBER,保存,limit,SQL,Mybatis,Integer From: https://www.cnblogs.com/LittleMaster/p/17851256.html