@Transactional(propagation = Propagation.REQUIRED)
 public void updateLeaveReceipt(SLeave leave) {
   this.leaveDao.updateByPrimaryKeySelective(leave);
   // 如果是调休,需减掉对应的加班时数
   if (leave.getTypeId().intValue() == 7) {
     SOvertimeCollection userOtCollection =
         this.overtimeCollectionDao.selectByPrimaryKey(leave.getUserId());
     userOtCollection.setHoursCollection(
         userOtCollection.getHoursCollection().floatValue()
             - leave.getLeaveDays().floatValue() * 8);
     this.overtimeCollectionDao.updateByPrimaryKey(userOtCollection);
   }
   // 如果是年假,需减掉对应的请假时数
   if (leave.getTypeId().intValue() == 3) {
     SAnnualLeave sal = this.leaveDao.getAnnualLeave(leave.getUserId());
     sal.setAnnualHours(sal.getAnnualHours().intValue() - leave.getLeaveDays().intValue());
     this.leaveDao.updateAnnualLeaveHours(sal);
   }
   String instanceId = "leave." + leave.getLeaveId();
   ProcessEngine processEngine = Configuration.getProcessEngine();
   List<Task> myTaskList =
       processEngine.getTaskService().findPersonalTasks(String.valueOf(leave.getUserId()));
   for (Task task : myTaskList) {
     if (task.getExecutionId().equals(instanceId)) {
       processEngine.getTaskService().completeTask(task.getId(), "申请");
       break;
     }
   }
 }
  @Transactional(propagation = Propagation.REQUIRED)
  public void addLeaveReceipt(SLeave leave, SUser loginUser) {
    if (leave.getLeaveId() == null) {
      if (leave.getStatus().intValue() == 2) {
        leave.setUserId(loginUser.getUserId());
        Integer leaveId = this.leaveDao.insert(leave);
      } else {
        leave.setUserId(loginUser.getUserId());
        leave.setLeaveTime(new Date());
        //				leave.setStatus(0);
        leave.setLeaveCode(NormalFun.getNextCode(Constants.LEAVE_PREFIX, leaveDao.getMaxCode()));
        Integer leaveId = this.leaveDao.insert(leave);
        // 如果是调休,需减掉对应的加班时数
        if (leave.getTypeId().intValue() == 7) {
          SOvertimeCollection userOtCollection =
              this.overtimeCollectionDao.selectByPrimaryKey(loginUser.getUserId());
          userOtCollection.setHoursCollection(
              userOtCollection.getHoursCollection().floatValue()
                  - leave.getLeaveDays().floatValue());
          this.overtimeCollectionDao.updateByPrimaryKey(userOtCollection);
        }
        // 如果是年假,需减掉对应的请假时数
        if (leave.getTypeId().intValue() == 3) {
          SAnnualLeave sal = this.leaveDao.getAnnualLeave(loginUser.getUserId());
          sal.setAnnualHours(sal.getAnnualHours().intValue() - leave.getLeaveDays().intValue());
          this.leaveDao.updateAnnualLeaveHours(sal);
        }

        SDepartment dept = this.departmentDao.getSDepartmentById(loginUser.getDepartmentId());
        ProcessEngine processEngine = Configuration.getProcessEngine();
        Map<String, Object> instanceVariables = new HashMap<String, Object>();
        instanceVariables.put("userName", loginUser.getUserName());
        instanceVariables.put("userId", String.valueOf(loginUser.getUserId()));
        instanceVariables.put("typeName", "休假单");
        instanceVariables.put("deptName", dept.getName());

        instanceVariables.put("leaveDays", leave.getLeaveDays());
        SPosition sp = positionDao.selectByPrimaryKey(loginUser.getPositionOrgId());
        instanceVariables.put("orgPosition", sp.getName());

        // 启动流程实例
        ProcessInstance processInstance =
            processEngine
                .getExecutionService()
                .startProcessInstanceByKey("leave", instanceVariables, String.valueOf(leaveId));
        //				processEngine.getExecutionService().setVariables(processInstance.getId(),
        // instanceVariables);

        List<Task> myTaskList =
            processEngine.getTaskService().findPersonalTasks(String.valueOf(loginUser.getUserId()));
        for (Task task : myTaskList) {
          if (task.getExecutionId().equals(processInstance.getId())) {
            // processEngine.getTaskService().setVariables(task.getId(), instanceVariables);
            processEngine.getTaskService().completeTask(task.getId(), "申请");
            break;
          }
        }
      }
    } else {
      if (leave.getStatus().intValue() == 2) {
        this.leaveDao.updateByPrimaryKeySelective(leave);
      } else {
        leave.setLeaveTime(new Date());
        leave.setLeaveCode(NormalFun.getNextCode(Constants.LEAVE_PREFIX, leaveDao.getMaxCode()));
        this.leaveDao.updateByPrimaryKeySelective(leave);
        // 如果是调休,需减掉对应的加班时数
        if (leave.getTypeId().intValue() == 7) {
          SOvertimeCollection userOtCollection =
              this.overtimeCollectionDao.selectByPrimaryKey(loginUser.getUserId());
          userOtCollection.setHoursCollection(
              userOtCollection.getHoursCollection().floatValue()
                  - leave.getLeaveDays().floatValue());
          this.overtimeCollectionDao.updateByPrimaryKey(userOtCollection);
        }
        // 如果是年假,需减掉对应的请假时数
        if (leave.getTypeId().intValue() == 3) {
          SAnnualLeave sal = this.leaveDao.getAnnualLeave(loginUser.getUserId());
          sal.setAnnualHours(sal.getAnnualHours().intValue() - leave.getLeaveDays().intValue());
          this.leaveDao.updateAnnualLeaveHours(sal);
        }

        SDepartment dept = this.departmentDao.getSDepartmentById(loginUser.getDepartmentId());
        ProcessEngine processEngine = Configuration.getProcessEngine();
        Map<String, Object> instanceVariables = new HashMap<String, Object>();
        instanceVariables.put("userName", loginUser.getUserName());
        instanceVariables.put("userId", String.valueOf(loginUser.getUserId()));
        instanceVariables.put("typeName", "休假单");
        instanceVariables.put("deptName", dept.getName());

        instanceVariables.put("leaveDays", leave.getLeaveDays());
        SPosition sp = positionDao.selectByPrimaryKey(loginUser.getPositionOrgId());
        instanceVariables.put("orgPosition", sp.getName());

        // 启动流程实例
        ProcessInstance processInstance =
            processEngine
                .getExecutionService()
                .startProcessInstanceByKey(
                    "leave", instanceVariables, String.valueOf(leave.getLeaveId()));
        //				processEngine.getExecutionService().setVariables(processInstance.getId(),
        // instanceVariables);

        List<Task> myTaskList =
            processEngine.getTaskService().findPersonalTasks(String.valueOf(loginUser.getUserId()));
        for (Task task : myTaskList) {
          if (task.getExecutionId().equals(processInstance.getId())) {
            // processEngine.getTaskService().setVariables(task.getId(), instanceVariables);
            processEngine.getTaskService().completeTask(task.getId(), "申请");
            break;
          }
        }
      }
    }
  }
Example #3
0
 /** point with a url to the configuration file */
 public Configuration setUrl(URL url) {
   impl.setUrl(url);
   return impl;
 }
Example #4
0
 public static ProcessEngine buildProcessEngine() {
   Configuration config = new Configuration();
   return config.buildProcessEngine();
 }
Example #5
0
 /** provide an input stream as the configuration resource */
 public Configuration setInputStream(InputStream inputStream) {
   impl.setInputStream(inputStream);
   return impl;
 }
Example #6
0
 /** provide a sax input source as the configuration resource */
 public Configuration setInputSource(InputSource inputSource) {
   impl.setInputSource(inputSource);
   return impl;
 }
Example #7
0
 /** provide an classpath resource as the configuration file */
 public Configuration setResource(String resource) {
   impl.setResource(resource);
   return impl;
 }
Example #8
0
 /** provide an xml string as the configuration resource */
 public Configuration setXmlString(String xmlString) {
   impl.setXmlString(xmlString);
   return impl;
 }
Example #9
0
 /**
  * provides the hibernate session factory programmatically. The hibernateSessionFactory parameter
  * is of type Object to prevent a dependency of the API on hibernate directly.
  */
 public Configuration setHibernateSessionFactory(Object hibernateSessionFactory) {
   return impl.setHibernateSessionFactory(hibernateSessionFactory);
 }
Example #10
0
 /**
  * after specifying the configuration resources with the other methods, a process engine can be
  * created.
  */
 public ProcessEngine buildProcessEngine() {
   return impl.buildProcessEngine();
 }
Example #11
0
 /** provide a File as the configuration file */
 public Configuration setFile(File file) {
   impl.setFile(file);
   return impl;
 }