Home > Back-end >  Java background automatically assigned to the team
Java background automatically assigned to the team

Time:12-07

Existing six group group 1, group 2, group 3,,,,,,,
Demand is a project to be distributed again I click to automatically assigned to the first team to stay a distribution program click automatically assigned to the second team to realize sequence automatically assigned tasks according to the group if there is a certain team leave or special case team this jump empty again the next round of tasks in sequence (six group is a circle round)

CodePudding user response:

Beg god for help

CodePudding user response:

 public class Test07 {

Public static void main (String [] args) {
//TODO Auto - generated method stub
Group g1=new Group (" 1 ");
Group g2=new Group (" 2 ");
Group g3=new Group (" 3 ");
Group g4=new Group (" 4 ");
Group the g5=new Group (" 5 ");
Group g6=new Group (" 6 ");

G1. SetNext (g2);
G2. SetNext (g3);
G3. SetNext (g4);
G4. SetNext (g5);
The g5. SetNext (g6);
G6. SetNext (g1);

New Thread (() - & gt; {
Try {
Thread.sleep (6000);
{} catch InterruptedException (e)
e.printStackTrace();
}
The g5. SetOk (false);
}). The start ();

Group gg=g1;
While ((gg=gg. DoSomething ())!=null);

}

Static class Group {
String name;
Private Boolean isOk=true;
Private Group next;

Public Group (String name) {
super();
this.name=name;
}

Public void setNext (Group next) {
This. Next=next;
}

Public void setOk (Boolean isOk) {
Enclosing isOk=isOk;
}

Public Boolean isOk () {
Return isOk.
}

Private void _doSomething () {
Try {
Thread.sleep(1000);
System. The out. Println (enclosing name);
{} catch InterruptedException (e)
//TODO Auto - generated the catch block,
e.printStackTrace();
}
}

Public Group doSomething () throws NullPointerException {
If (this. IsOk ())
Enclosing _doSomething ();
The else
Return this. Next. DoSomething ();

Return this. The next;
}

}

}

CodePudding user response:

Thank you but my current demand is the project to deal with deal with the first project to be distributed at the front desk to click to automatically this order according to the group assigned to a project team 1 click when deal with staff to deal with the second project for the project will be automatically assigned to group 2 so on

CodePudding user response:

Design a structure: the team name, team serial number (for example, must continuously starting from 1), group whether to ask for leave, the second: the current group sequence number, it is best to set up a corresponding table structure, the group information into the database, assign tasks according to the current updates the current serial number + 1 is the group number assigned to, when the current serial number sequence number is greater than the largest group, reset the serial number for the smallest group,

CodePudding user response:

Create an array length is 6 multiples of that time reading, subscript decided to set number
  • Related