All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.base4j.util.BatchQueryUtil Maven / Gradle / Ivy

The newest version!
package com.base4j.util;

import com.base4j.util.bean.Constant;

import java.util.ArrayList;
import java.util.List;


/**
 * 批量查询工具
* * @author huangjun * @version [版本号, 2017年9月22日] * @Description:解决查询参数中数据超过1000的问题 * @ClassName:BatchQueryUtil */ public class BatchQueryUtil { /** * 回调函数接口 * * @author Administrator */ public interface CallBack { /** * 获取结果 * * @param idList 主键集合 * @return */ List getResult(List idList); } private CallBack backFun; /** * 设置回调函数 * * @param cbFun */ public void setFun(CallBack cbFun) { backFun = cbFun; } /** * 当出现异常时会自动回调此函数,具体如何实现异常回调就不在这里详细描述了 */ @SuppressWarnings("unchecked") public List exeHalder(List idListAll) { List listAll = new ArrayList(); if (backFun != null) { List> splitListAll = CollectionsUtil.splitList(idListAll, Constant.SPLIT_SIZE); for (List splitList : splitListAll) { listAll.addAll(backFun.getResult(splitList)); } } return listAll; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy