Package com. Runyi. Dataprocessing. Service. Impl;
import java.util.ArrayList;
Import the Java. Util. Date;
import java.util.List;
Import the Java. Util. Set;
The import org. Quartz. CronScheduleBuilder;
The import org. Quartz. CronTrigger;
The import org. Quartz. JobBuilder;
The import org. Quartz. JobDetail;
The import org. Quartz. JobKey;
The import org. Quartz. The Scheduler;
The import org. Quartz. SchedulerException;
The import org. Quartz. SchedulerFactory;
The import org. Quartz. The Trigger;
The import org. Quartz. TriggerBuilder;
The import org. Quartz. TriggerKey;
The import org. Quartz. Impl. StdSchedulerFactory;
The import org. Quartz. Impl. Matchers. GroupMatcher;
The import org. Springframework. Beans. Factory. The annotation. Autowired;
import org.springframework.context.annotation.Bean;
The import org. Springframework. Stereotype. Service;
The import com.runyi.com mon. Pojo. RunyiResult;
The import com.runyi.dataprocessing.com mon. TaskInfo;
The import com. Runyi. Dataprocessing. Service. DataprocessingService;
@ Service
Public class DataprocessingServiceImpl implements DataprocessingService {
The @autowired
Private Scheduler Scheduler.
@ Override
Public RunyiResult workJob (String dataprocessingchoice) {
//the task scheduler
/* *
* start processing
*/
If (dataprocessingchoice. Equals (" 01. Client applications data processing ")) {
//to determine whether a system has a task start
//1. The first task information
Try {
List
//if the record is not null, do the following
TaskInfo set_data=https://bbs.csdn.net/topics/new TaskInfo ();
Set_data. SetJobName (" ");
If (List_message!=null& & List_message. The size () & gt; 0 {
//from (1) obtain an array is there a jobName for "job1 is jobGroup for the record of" group1 "
for(int i=0; I
If (data_list. GetJobName (.) the equals (" job1 is ") & amp; & Data_list. GetJobGroup (.) the equals (" group1 ")) {
set_data=https://bbs.csdn.net/topics/List_message.get (I);//(2) if find job1 is and group1, do not repeat launches the application data processing
System. The out. Print (" has entered the assumptions, view the set_data. GetJobName: "+ (TaskInfo set_data). GetJobGroup () +" \ n ");
}
}
}
//set_data initial assignment unchanged, the execution starts
if(! (set_data. GetJobName (.) the equals (" job1 is "))) {
//if the record is empty, will enable customers to apply for the data processing
Try {
OpenJob (scheduler);
//start the task
The scheduler. The start ();
} the catch (SchedulerException e) {
e.printStackTrace();
}
}
//throw exception
} the catch (Exception e) {
e.printStackTrace();
}//end of task information
} else if (dataprocessingchoice equals (" 02. Customers apply data processing off ")) {
Try {
String name="job1 is";
String group="group1";
DeleteJob (name, group);
} the catch (Exception e) {
e.printStackTrace();
}
} else if (dataprocessingchoice equals (" 03. Adjust the melting time between processing as 1 seconds ")) {
Try {
String name="trigger1";
String group="triggergroup1";
0/1 String newTime="* * * *?" ;
ModifyJob (name, group, newTime);
} the catch (Exception e) {
e.printStackTrace();
}
} else if (dataprocessingchoice equals (" 04. Adjust processing between melting time to 2 seconds, ")) {
Try {
String name="trigger1";
String group="triggergroup1";
String newTime=".two survivors * * * *?" ;
ModifyJob (name, group, newTime);
} the catch (Exception e) {
e.printStackTrace();
}
} else if (dataprocessingchoice equals (" 05. Adjust the melting time between processing as 3 seconds ")) {
Try {
String name="trigger1";
String group="triggergroup1";
String newTime="0/3 * * * *?" ;
ModifyJob (name, group, newTime);
} the catch (Exception e) {
e.printStackTrace();
}
} else if (dataprocessingchoice equals (" 06. Adjust the melting time between processing as 5 seconds ")) {
Try {
String name="trigger1";
String group="triggergroup1";
0/5 String newTime="* * * *?" ;
ModifyJob (name, group, newTime);
} the catch (Exception e) {
e.printStackTrace();
}
} else if (dataprocessingchoice equals (" 07. Adjust the melting time between processing as 7 seconds ")) {
Try {
String name="trigger1";
String group="triggergroup1";
0/7 String newTime="* * * *?" ;
ModifyJob (name, group, newTime);
} the catch (Exception e) {
e.printStackTrace();
}
} else if (dataprocessingchoice equals (" 08. Adjust the melting time between processing as 9 seconds ")) {
Try {
String name="trigger1";
String group="triggergroup1";
0/9 String newTime="* * * *?" ;
ModifyJob (name, group, newTime);
} the catch (Exception e) {
e.printStackTrace();
}
}//client application data processing end closing
Return RunyiResult. Ok ();
}
/* *
* 01. Open a task
* @ param scheduler
*/
Private void openJob (Scheduler Scheduler) {
Try {
//1. Create a JobDetail
JobDetail JobDetail=JobBuilder. NewJob (Autoworkaplication. Class). WithIdentity (" job1 is ", "group1"). The build ();
//2. The trigger expression object
0/3 CronScheduleBuilder CronScheduleBuilder=CronScheduleBuilder. CronSchedule (" * * * *?" );
//3. Prepare a trigger object
CronTrigger CronTrigger=TriggerBuilder. NewTrigger (.) withIdentity (" trigger1 ", "triggergroup1")
WithSchedule (cronScheduleBuilder). The build ();
//4. Begin scheduling
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull