public void seleccionarMarcaDocente(ActionEvent event) { int paramDocId; int paramSesId; String paramCurNombre; String paramSecNombre; AcDocente acDoc; AcSesionAsistencia sesAsis; AcSesionEfectivaAsisDoc sesEfecAsisDoc; AsistenciaDocenteBean asisDoc; ClSeccion clSec; HSAsistenciaDocenteDAO asisDocDAO; HSDocenteDAO docDAO; Timestamp t1; Timestamp t2; paramDocId = CommonWeb.parseObjToInt(CommonWeb.getParamFromUIParameterUI(event, "w_doc_id")); paramSesId = CommonWeb.parseObjToInt(CommonWeb.getParamFromUIParameterUI(event, "w_ses_id")); paramCurNombre = CommonWeb.getParamFromUIParameterUI(event, "p_cur_nombre"); paramSecNombre = CommonWeb.getParamFromUIParameterUI(event, "p_sec_nombre"); asisDocDAO = CommonDAO.getAsistenciaDocenteDAO(); docDAO = CommonDAO.getAcDocenteDAO(); try { sesEfecAsisDoc = asisDocDAO.listaMarcadoDeAsistencia_x_Docente(paramSesId); asisDoc = new AsistenciaDocenteBean(); if (sesEfecAsisDoc instanceof AcSesionEfectivaAsisDoc) { asisDoc.setDoc_id(sesEfecAsisDoc.getAcDocente().getId()); asisDoc.setDoc_codigo(sesEfecAsisDoc.getAcDocente().getDocCodigo()); asisDoc.setDoc_nombre(sesEfecAsisDoc.getAcDocente().getDocNombre()); asisDoc.setSes_id(sesEfecAsisDoc.getAcSesionAsistencia().getSesId()); clSec = CommonDAO.getClSeccionDAO() .seleccionarSeccion(sesEfecAsisDoc.getAcSesionAsistencia().getAcSeccion().getId()); try { asisDoc.setSec_nombre(clSec.getSecNombre()); } catch (Exception ex) { asisDoc.setSec_nombre("NO DETERMINADO"); ex.printStackTrace(); } try { asisDoc.setCur_nombre(clSec.getClArbolAcademico().getArbAcadPadre().getArbDescripcion()); } catch (Exception ex) { asisDoc.setCur_nombre("NO DETERMINADO"); ex.printStackTrace(); } asisDoc.setEstasis_code(sesEfecAsisDoc.getSesefeasisdocTipo()); asisDoc.setSesefeasisdoc_fecha( sesEfecAsisDoc.getAcSesionAsistencia().getSesFechaRegistro()); asisDoc.setSesefeasisdoc_id(sesEfecAsisDoc.getSesefeasisdocId()); t1 = sesEfecAsisDoc.getSesefeasisdocRegistro(); t2 = sesEfecAsisDoc.getSesefeasisdocSalida(); if (t1 != null) { asisDoc.setReg_hora(t1.getHours()); asisDoc.setReg_min(t1.getMinutes()); } if (t2 != null) { asisDoc.setSal_hora(t2.getHours()); asisDoc.setSal_min(t2.getMinutes()); } sesAsis = asisDocDAO.listarSessionAsistencia_x_sesid(paramSesId); asisDoc.setRegistro(sesAsis.getSesFechaInicio()); asisDoc.setSalida(sesAsis.getSesFechaFin()); asisDoc.setSesefeasisdoc_registro(sesEfecAsisDoc.getSesefeasisdocRegistro()); asisDoc.setSesefeasisdoc_salida(sesEfecAsisDoc.getSesefeasisdocSalida()); asisDoc.setSesefeasisdoc_obs(sesEfecAsisDoc.getSesefeasisdocObs()); } else { // System.out.println("nuevo ingreso!"); acDoc = docDAO.seleccionarDocente(paramDocId); sesAsis = asisDocDAO.listarSessionAsistencia_x_sesid(paramSesId); asisDoc.setRegistro(sesAsis.getSesFechaInicio()); asisDoc.setSalida(sesAsis.getSesFechaFin()); asisDoc.setSesefeasisdoc_fecha(sesAsis.getSesFechaRegistro()); asisDoc.setDoc_id(acDoc.getId()); asisDoc.setDoc_codigo(acDoc.getDocCodigo()); asisDoc.setDoc_nombre(acDoc.getDocNombre()); asisDoc.setSes_id(paramSesId); asisDoc.setSec_nombre(paramSecNombre); asisDoc.setCur_nombre(paramCurNombre); } asisDocente = asisDoc; oncomplete = "Richfaces.showModalPanel('mpAsisDocente')"; } catch (Exception e) { e.printStackTrace(); } }
@Override public void run() { // thread content // TODO Auto-generated method stub if (timerfirst) { // lock by the first thread executing it timerfirst = false; while (true) { while (!computerClock) { // switch between program clock and computer clock try { Thread.currentThread().sleep(1000); // sleep every second } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // second++; //increase the timer by a second // if (second == 60) //increase the minute and hour and day // { // second = 0; // minute++; // } // if (minute ==60){ // minute = 0; // hour++; // } // if (hour ==24){ // hour = 0; // day++; // weekday = (weekday+1) % weekdays.length; // parent.UpdateCal(); //redraw the view // } // if ((day == 29) && (month == 2)){ //2 means February, check leap year // if (year % 4 != 0 || (year % 100)== 0 && (year % 400) != 0){ // e.g. 1700 is not a // leap year // day = 1; // month++; // } // // // } // if ((day == 30) && (month ==2)){ //handling of leap year // day = 1; // month++; // } // if (((month == 1) || (month == 3)|| (month == 5)|| (month == 7)|| (month == 8) // ||(month == 10) || (month == 12)) && (day== 32)){ //handling of months with 31 days // day = 1; // month++; // } // if (((month == 4) || (month == 6)|| (month == 9)|| (month == 11)) && (day== 31)){ // //handling of months with 30 days // day =1; // month++; // } // if (month==13){ //switch to a new year // month =1; // year++; // } currentTime.setTime(currentTime.getTime() + 1000); year = currentTime.getYear() + 1900; month = currentTime.getMonth() + 1; day = currentTime.getDate(); hour = currentTime.getHours(); minute = currentTime.getMinutes(); second = currentTime.getSeconds(); weekday = currentTime.getDay(); // outputTheCurrentTime(); } while (computerClock) { try { // obtain the computer time every second Thread.currentThread().sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } Calendar cal = Calendar.getInstance(); day = cal.get(Calendar.DATE); month = cal.get(Calendar.MONTH) + 1; year = cal.get(Calendar.YEAR); hour = cal.get(Calendar.HOUR_OF_DAY); minute = cal.get(Calendar.MINUTE); second = cal.get(Calendar.SECOND); weekday = cal.get(Calendar.DAY_OF_WEEK) - 1; } } } else { // Thread 2 is responsible for providing an user interface for accessing the timer int option = -1; while (option != 0) { System.out.println("1) Output the current time"); // System.out.println("2) Modify the time"); System.out.println("2) Switch mode (Program clock <-> Computer Clock)"); System.out.println("0) Quit"); System.out.print("Please choose an option: "); Scanner scanner = new Scanner(System.in); option = Integer.parseInt(scanner.next()); if (option == 1) { outputTheCurrentTime(); } // if (option == 2){ // System.out.println("Please input the year, month(in integer), day, hour, minute // and second separated by a space: "); // year = Integer.parseInt(scanner.next()); // month = Integer.parseInt(scanner.next()); // day = Integer.parseInt(scanner.next()); // hour = Integer.parseInt(scanner.next()); // minute = Integer.parseInt(scanner.next()); // second = Integer.parseInt(scanner.next()); // // // //Sun = 0, Mon = 1, Tue = 2, Wed = 3, Thurs = 4. Fri = 5, Sat = 6 // java.util.GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(); // //set the weekday of the input date // cal.setTime(new Timestamp(year-1900, month-1, day, hour, minute, second, 0)); // // weekday = cal.get(java.util.Calendar.DAY_OF_WEEK)-1; // // // if (parent != null) // parent.UpdateCal(); //redraw the view // System.out.println(); // } if (option == 3) { // switch between program timer and computer clock if (!computerClock) { computerClock = true; System.out.println("Computer Clock is in effective."); } else { computerClock = false; System.out.println("Program Clock is in effective."); } System.out.println(); } } } }
private TCG toTCG() { TCG graph = new TCG(); // 找当前活跃节点,应该是place CustomedPlace p = this.lastActivePlace; if (null == p) return null; TCGNode tnode = new TCGNode(String.valueOf(p.getId())); this.startTCGNode = tnode; graph.addNode(tnode); // 给lastActivePlace的直接后继加弧,别的都由普通库所加弧 LinkedList<PlaceToTransition> oArc = lastActivePlace.getOutArc(); for (PlaceToTransition ptt : oArc) { CustomedTransition cto = ptt.t; TCGNode newnode = new TCGNode( String.valueOf(cto.getId()), new TimeDesc(0, cto.getInnerTime()[0]), new TimeDesc(0, cto.getInnerTime()[1])); graph.addNode(newnode); TimeConstraint tc = new TimeConstraint( tnode, newnode, new TimeDesc(0, 0), TimeDesc.MAXTIME(), TimeConstraint.DIRECT); graph.addConstraint(tc); } /*Set<String> pSet = pttList.keySet(); for(Iterator it=pSet.iterator();it.hasNext();){ String id = (String)it.next(); String idArray[] = id.split(","); if(null != idArray && idArray.length > 1 && null != idArray[0] && idArray[0].equals(String.valueOf(p.getId())) && null != idArray[1]){ PlaceToTransition pttt = (PlaceToTransition)pttList.get(idArray[1]); if(pttt!=null){ CustomedTransition ct = pttt.t; TCGNode newnode = new TCGNode(idArray[1],new TimeDesc(0,ct.getInnerTime()[0]),new TimeDesc(0,ct.getInnerTime()[1])); graph.addNode(newnode); TimeConstraint tc = new TimeConstraint(tnode,newnode,new TimeDesc(0,0),TimeDesc.MAXTIME(),TimeConstraint.DIRECT); graph.addConstraint(tc); } } }*/ // 遍历所有库所,加弧和变迁,加的是前置后置,绝对时间约束 Set<Integer> pSet = this.fpList.keySet(); for (Iterator<Integer> it = pSet.iterator(); it.hasNext(); ) { Integer id = (Integer) it.next(); CustomedPlace cp = fpList.get(id); if (cp.isVisited() || cp.isInvalid() || cp == this.lastActivePlace) ; LinkedList<TransitionToPlace> inArc = cp.getInArc(); LinkedList<PlaceToTransition> outArc = cp.getOutArc(); if (inArc != null && outArc != null) { for (TransitionToPlace ttp : inArc) { CustomedTransition cti = ttp.t; for (PlaceToTransition ptt : outArc) { CustomedTransition cto = ptt.t; if (cti != null && cto != null) { TCGNode t1 = new TCGNode( String.valueOf(cti.getId()), new TimeDesc(0, cti.getInnerTime()[0]), new TimeDesc(0, cti.getInnerTime()[1])); TCGNode t2 = new TCGNode( String.valueOf(cto.getId()), new TimeDesc(0, cto.getInnerTime()[0]), new TimeDesc(0, cto.getInnerTime()[1])); graph.addNode(t1); graph.addNode(t2); TimeConstraint tc = new TimeConstraint( t1, t2, new TimeDesc(0, 0), TimeDesc.MAXTIME(), TimeConstraint.DIRECT); graph.addConstraint(tc); } } } } } // 遍历所有变迁,加截止时间约束 Timestamp startTime = this.parentProcess.startTime; // Timestamp lastUpdateTime = this.lastActivePlace.getAvailableTime(); Timestamp lastUpdateTime = new Timestamp(System.currentTimeMillis()); Set<Integer> tSet = this.ftList.keySet(); for (Iterator<Integer> it = tSet.iterator(); it.hasNext(); ) { Integer id = (Integer) it.next(); CustomedTransition ct = ftList.get(id); if (ct.isVisited() || ct.isInvalid()) ; TCGNode has = graph.getNode(String.valueOf(ct.getId())); if (null == has) { has = new TCGNode( String.valueOf(ct.getId()), new TimeDesc(0, ct.getInnerTime()[0]), new TimeDesc(0, ct.getInnerTime()[1])); graph.addNode(has); } if (ct.getDeadLine() != 0) { @SuppressWarnings("deprecation") int gap = lastUpdateTime.getMinutes() - startTime.getMinutes(); int relative = ct.getDeadLine() - gap; @SuppressWarnings("unused") TimeConstraint tc1 = new TimeConstraint( this.startTCGNode, has, new TimeDesc(0, 0), new TimeDesc(0, relative), TimeConstraint.ASSIGNED); } } return graph; }