(一)  開始一個(gè)請(qǐng)假流程
                 //user是請(qǐng)假人的actorId
                 ExecutionService es=JbpmServiceFactory.getInstance().openExecutionService(user);
                  HashMap vs=new HashMap();
                 //一些參數(shù)
                  vs.put(Constants.REQUEST_STATUS,String.valueOf(0));
                  vs.put(Constants.REQUEST_RETURN_INFO,"No info!");
                  vs.put(Constants.USER_NAME,EncodeTransfer.toISO(user));
                  vs.put(Constants.REQUEST_DAYS,String.valueOf(rea.getDays()));
                  try {
                     //開啟請(qǐng)假流程
                      es.startProcessInstance(Constants.WORK_NAME, vs);
                      log.info("["+user+"]"+"申請(qǐng)假期開始!請(qǐng)假"+rea.getDays()+"天!");
                      return am.findForward("main");
                  } catch (ExecutionException ex) {
                      ex.printStackTrace();
                      log.error("請(qǐng)假進(jìn)程無法開始!");
                      return am.findForward("error");
                  }finally{
                      es.close();
                  }
          (二)當(dāng)前執(zhí)行任務(wù)
              對(duì)于部門經(jīng)理或者老板,找到要處理的請(qǐng)假。
                 String actorId = (String) req.getSession().getAttribute(Constants.USER);
                      if(actorId.equals("wang")){
                          actorId="boss";
                      }else if(actorId.equals("bigli")){
                          actorId="chief";
                      }
                      // get the execution service
                      ExecutionService executionService = JbpmServiceFactory.getInstance().
                                                          openExecutionService(actorId);

                      // get the tasklist from jbpm for user
                      List tasks = new ArrayList();
                      // add the jbpm tasks
                      tasks.addAll(executionService.getTaskList(actorId));
                      // put the tasklist into the form
                      mf.setTasks(tasks);
                      // get the tasklist from jbpm for user
                      List definitions = new ArrayList();
                      // add the jbpm definitions
                      definitions.addAll(executionService.getLatestDefinitions());
                      // put the tasklist into the form
                      mf.setRequests(definitions);
                      // close the execution service
                      executionService.close();
                      req.getSession().setAttribute("mainForm",mf);
                      log.debug("任務(wù): " + tasks);
                      log.debug("當(dāng)前可以執(zhí)行的請(qǐng)求: " + definitions);
          (三)處理請(qǐng)假
                     String actorId = (String) reqrest.getSession().getAttribute(Constants.
                              USER);
                      Long tokenId=new Long(req.getParameter("tokenId"));
                      // get the execution service
                      ExecutionService executionService = JbpmServiceFactory.getInstance().
                                                          openExecutionService(actorId);
                      Map hm=executionService.getVariables(tokenId);//變量
                      String act=req.getParameter("action");//進(jìn)行轉(zhuǎn)換的transition
                      executionService.endOfState(tokenId,hm,act);
                      executionService.close();

          posts - 5, comments - 3, trackbacks - 0, articles - 0

          Copyright © 蝦米老

          主站蜘蛛池模板: 琼结县| 祁东县| 会泽县| 宜宾县| 永修县| 游戏| 锡林浩特市| 汶上县| 乌鲁木齐县| 楚雄市| 正镶白旗| 比如县| 剑阁县| 蒙城县| 乌拉特前旗| 彩票| 屯昌县| 济宁市| 平阴县| 太原市| 裕民县| 临沧市| 克什克腾旗| 宝山区| 西乡县| 江山市| 连州市| 盘锦市| 北碚区| 广昌县| 金沙县| 洪洞县| 蒙城县| 英德市| 临沧市| 台北县| 通道| 澄城县| 德昌县| 石阡县| 丹江口市|