cn.schoolwow.data.thread.flow.work.ExecuteIntervalWorkFlow Maven / Gradle / Ivy
package cn.schoolwow.data.thread.flow.work;
import cn.schoolwow.data.thread.domain.DataThreadProgress;
import cn.schoolwow.data.thread.flow.handler.WorkTryCatchFinallyHandler;
import cn.schoolwow.data.thread.work.interval.IntervalDataThreadHandler;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.quickflow.flow.FunctionFlow;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;
public class ExecuteIntervalWorkFlow implements BusinessFlow {
@Override
public void executeBusinessFlow(FlowContext flowContext) throws Exception {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) flowContext.checkData("threadPoolExecutor");
List list = (List) flowContext.checkData("list");
int interval = (int) flowContext.checkData("interval");
if(interval<=0){
throw new IllegalArgumentException("任务间隔必须大于0");
}
IntervalDataThreadHandler intervalDataThreadHandler = (IntervalDataThreadHandler) flowContext.checkData("intervalDataThreadHandler");
DataThreadProgress dataThreadProgress = (DataThreadProgress) flowContext.checkData("dataThreadProgress");
int segment = list.size()/interval+(list.size()%interval>0?1:0);
dataThreadProgress.total = list.size();
dataThreadProgress.type = "Interval";
StringBuilder descriptionBuilder = new StringBuilder("分段列表:");
for(int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy