//package com.product.kt.test.service; // //import java.util.List; //import java.util.concurrent.Future; // //import org.slf4j.Logger; //import org.slf4j.LoggerFactory; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.scheduling.annotation.Async; //import org.springframework.scheduling.annotation.AsyncResult; //import org.springframework.stereotype.Component; // //import com.product.core.entity.FieldSetEntity; // // //@Component //public class SyncToolsHandler { // // private static final Logger LOG = LoggerFactory.getLogger(SyncToolsHandler.class); // // @Autowired // WriteToolService writeToolService; // // /** // * 异步执行 // * // * @param readToolList // * @param pageIndex // * @return // */ //// @Async("ToolTask") // public Future syncTools(List readToolList, int pageIndex, String tableName, String timeField) { // // System.out.println("thread name " + Thread.currentThread().getName()); // // LOG.info(String.format("此批数据的段数为:%s 此段数据的数据条数为:%s", pageIndex, readToolList.size())); // // //声明future对象 // Future result = new AsyncResult(""); // // //循环遍历 // if (null != readToolList && readToolList.size() > 0) { // try { // int listSize = readToolList.size(); // int listStart = 0, listEnd = 0; // int ropeNum = listSize / 2000; // // for (int i = 0; i < ropeNum; i++) { // //数据入库操作 // listStart = i * 2000; // listEnd = i * 2000 + 2000; // writeToolService.writeData(readToolList.subList(listStart, listEnd), tableName, timeField); // } // writeToolService.writeData(readToolList.subList(listEnd, listSize), tableName, timeField); // // } catch (Exception e) { // //记录出现异常的时间,线程name // result = new AsyncResult("fail,time=" + System.currentTimeMillis() + ",thread id=" + Thread.currentThread().getName() + ",pageIndex=" + pageIndex); // } // } // return result; // } //}