红字部分代表mybatis的批量操作调用方法:
int num = 0; int maxLength = 200; int size = usableCodes.size(); if (size <= maxLength) { bean = createBean(bean,entity,usableCodes); num = receiptMapper.receipt(bean); } else { // 计算循环次数 int eachTime = (size / maxLength) + 1; for (int i = 0; i < eachTime; i++) { int fromIndex = 0; int toIndex = 0; fromIndex = (i * maxLength); toIndex = (fromIndex + maxLength); if (i + 1 == eachTime) { toIndex = usableCodes.size(); } List<String> subList = usableCodes.subList(fromIndex, toIndex); if (subList.size() > 0) { bean = createBean(bean,entity,subList); num += receiptMapper.receipt(bean); } } }