public String getLessData(Date startDate,Date endDate,String jobtype) {
try{
//间隔时间
long intervalTime = (endDate.getTime() - startDate.getTime())/threadnum;
//各线程执行状态初始化
threadStatus.clear();
//各数据集合执行初始化
datalist.clear();
//线程池
ExecutorService service = Executors.newFixedThreadPool(threadnum);
//循环开始线程
for(int i=0;i<threadnum;i++){
//获取时间参数
Date tmpstartDate = new Date(startDate.getTime()+i*intervalTime);
String sDay = RadarReportUtil.getStrDayFromDate(tmpstartDate);
String sTime = RadarReportUtil.getStrTimeFromDate(tmpstartDate);
Date tmpendDate = new Date(startDate.getTime()+(i+1)*intervalTime);
//获取时间参数
String eTime = RadarReportUtil.getStrTimeFromDate(tmpendDate);
//取数线程
RRSLessThread rrsLessThread = new RRSLessThread();
rrsLessThread.setDatalist(datalist);
rrsLessThread.setsDay(sDay);
rrsLessThread.setsTime(sTime);
rrsLessThread.seteTime(eTime);
rrsLessThread.setJobtype(jobtype);
rrsLessThread.setThreadStatus(threadStatus);
Thread t = new Thread(rrsLessThread);
service.execute(t);
}
service.shutdown();
try{
service.awaitTermination(1, TimeUnit.HOURS);
for(String status:threadStatus){
if(!status.equals("SUCCESS")){
return status;
}
}
System.out.println("----------------条数-------------"+datalist.size());
service.shutdownNow();
}catch(Exception e){
LOG.warn(e.getMessage());
//e.printStackTrace();
return "false:"+e.getMessage();
}
}catch(Exception e){
LOG.warn(e.getMessage());
//e.printStackTrace();
return "false:"+e.getMessage();
}
return "true";
}
try{
//间隔时间
long intervalTime = (endDate.getTime() - startDate.getTime())/threadnum;
//各线程执行状态初始化
threadStatus.clear();
//各数据集合执行初始化
datalist.clear();
//线程池
ExecutorService service = Executors.newFixedThreadPool(threadnum);
//循环开始线程
for(int i=0;i<threadnum;i++){
//获取时间参数
Date tmpstartDate = new Date(startDate.getTime()+i*intervalTime);
String sDay = RadarReportUtil.getStrDayFromDate(tmpstartDate);
String sTime = RadarReportUtil.getStrTimeFromDate(tmpstartDate);
Date tmpendDate = new Date(startDate.getTime()+(i+1)*intervalTime);
//获取时间参数
String eTime = RadarReportUtil.getStrTimeFromDate(tmpendDate);
//取数线程
RRSLessThread rrsLessThread = new RRSLessThread();
rrsLessThread.setDatalist(datalist);
rrsLessThread.setsDay(sDay);
rrsLessThread.setsTime(sTime);
rrsLessThread.seteTime(eTime);
rrsLessThread.setJobtype(jobtype);
rrsLessThread.setThreadStatus(threadStatus);
Thread t = new Thread(rrsLessThread);
service.execute(t);
}
service.shutdown();
try{
service.awaitTermination(1, TimeUnit.HOURS);
for(String status:threadStatus){
if(!status.equals("SUCCESS")){
return status;
}
}
System.out.println("----------------条数-------------"+datalist.size());
service.shutdownNow();
}catch(Exception e){
LOG.warn(e.getMessage());
//e.printStackTrace();
return "false:"+e.getMessage();
}
}catch(Exception e){
LOG.warn(e.getMessage());
//e.printStackTrace();
return "false:"+e.getMessage();
}
return "true";
}