public String createEpRTaskEmployee(
     String taskId,
     String employeeId,
     String userId,
     String allotUserId,
     String executeTime,
     BigDecimal executeTimeType,
     BigDecimal taskType,
     String supportEmployee) {
   if (StringUtils.isBlank(taskId)) {
     throw new BusinessException("taskId", ErrorCode.PARAMETER_NOT_FOUND);
   }
   if (StringUtils.isBlank(employeeId)) {
     throw new BusinessException("employeeId", ErrorCode.PARAMETER_NOT_FOUND);
   }
   if (StringUtils.isBlank(allotUserId)) {
     throw new BusinessException("allotUserId", ErrorCode.PARAMETER_NOT_FOUND);
   }
   if (StringUtils.isBlank(executeTime)) {
     throw new BusinessException("executeTime", ErrorCode.PARAMETER_NOT_FOUND);
   }
   String id = sequenceDAO.getEpRTaskEmployeeSeq();
   EpRTaskEmployee erte = new EpRTaskEmployee();
   erte.setId(id);
   erte.setTaskId(taskId);
   erte.setEmployeeId(employeeId);
   erte.setUserId(userId);
   erte.setAllotUserId(allotUserId);
   erte.setExecuteTime(executeTime);
   erte.setExecuteTimeType(executeTimeType);
   erte.setTaskType(taskType);
   erte.setSupportEmployee(supportEmployee);
   epRTaskEmployeeDAO.insert(erte);
   return id;
 }
 public void deleteEpRTaskEmployee(String id) {
   if (StringUtils.isBlank(id)) {
     throw new BusinessException("id", ErrorCode.PARAMETER_NOT_FOUND);
   }
   try {
     epRTaskEmployeeDAO.deleteByPrimaryKey(id);
   } catch (Exception e) {
     throw new BusinessException("resourceBeUsed", ErrorCode.RESOURCE_BE_USED);
   }
 }
  public List<EpRTaskEmployeeDetailVO> ListEpRTaskEmployee(
      String taskId, String employeeId, String userId, String allotUserId, String executeTime) {
    EpRTaskEmployee epRTaskEmployee = new EpRTaskEmployee();
    epRTaskEmployee.setTaskId(taskId);
    epRTaskEmployee.setEmployeeId(employeeId);
    epRTaskEmployee.setUserId(userId);
    epRTaskEmployee.setAllotUserId(allotUserId);
    epRTaskEmployee.setExecuteTime(executeTime);

    List<EpRTaskEmployeeDetailVO> list = epRTaskEmployeeDAO.ListEpRTaskEmployee(epRTaskEmployee);
    return list;
  }
  public void finishTask(String jsonString) throws JSONException {
    JSONObject jsonObj = new JSONObject(jsonString);
    String epRtaskEmployeeId = jsonObj.getString("id");
    String taskResult = jsonObj.getString("result");
    EpRTaskEmployee epRTaskEmployee = epRTaskEmployeeDAO.selectByPrimaryKey(epRtaskEmployeeId);
    EpTask epTask = epTaskDAO.selectByPrimaryKey(epRTaskEmployee.getTaskId());
    EpTaskHistory taskHistory = new EpTaskHistory();
    String historyTaskId = sequenceDAO.getEpTaskHistoryeq();
    taskHistory.setId(historyTaskId);
    taskHistory.setAllotUserId(epRTaskEmployee.getAllotUserId());
    Branch branch = branchDAO.selectByPrimaryKey(epTask.getBranchId());
    String branchName = null;
    if (branch != null) {
      branchName = branch.getName();
    }

    taskHistory.setBranchName(branchName);
    String EmployeeId = epRTaskEmployee.getEmployeeId();
    AcEmployees acEmployees = acEmployeesDAO.selectByPrimaryKey(EmployeeId);
    String employeeName = null;
    if (acEmployees != null) {
      employeeName = acEmployees.getName();
    }
    taskHistory.setEmployeeName(employeeName);
    Long endTime = System.currentTimeMillis();
    taskHistory.setSupportEmployee(epRTaskEmployee.getSupportEmployee());
    taskHistory.setEmployeeId(EmployeeId);
    taskHistory.setEndTime(endTime.toString());
    taskHistory.setExecuteTime(epRTaskEmployee.getExecuteTime());
    taskHistory.setExecuteTimeType(epRTaskEmployee.getExecuteTimeType());
    taskHistory.setNote(epTask.getNote());
    String organName = null;
    Organ organ = organDAO.selectByPrimaryKey(epTask.getOrganId());
    if (organ != null) {
      organName = organ.getName();
    }
    taskHistory.setOrganName(organName);
    taskHistory.setResult(taskResult);
    taskHistory.setTaskId(epRTaskEmployee.getTaskId());
    taskHistory.setTaskName(epTask.getName());
    taskHistory.setTaskType(epTask.getType());
    taskHistory.setType(new BigDecimal(1));
    taskHistory.setUserId(epRTaskEmployee.getUserId());
    JSONArray jsonArray = jsonObj.getJSONArray("steps");
    epTaskHistoryDAO.insert(taskHistory);
    if (jsonArray.length() > 0) {
      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject jsonSteps = new JSONObject(jsonArray.getString(i));
        String stepId = jsonSteps.getString("stepId");
        String result = jsonSteps.getString("result");
        System.out.println("result:" + result);
        String stepCaptureId = jsonSteps.getString("stepCaptureId");
        EpTaskStepHistory epTaskStepHistory = new EpTaskStepHistory();
        String taskStephistoryId = sequenceDAO.getEpTaskStepHistoryeq();
        EpTaskStep epTaskStep = epTaskStepDAO.selectByPrimaryKey(stepId);
        if (epTaskStep == null) {
          throw new BusinessException("EP_TASK_STEP  STEP_ID", ErrorCode.RESOURCE_NOT_FOUND);
        }
        epTaskStepHistory.setDeviceType(epTaskStep.getDeviceType());
        epTaskStepHistory.setHistoryTaskId(historyTaskId);
        epTaskStepHistory.setId(taskStephistoryId);
        epTaskStepHistory.setResult(result);
        epTaskStepHistory.setSeq(new BigDecimal(epTaskStep.getSeq()));
        epTaskStepHistory.setStepId(stepId);
        epTaskStepHistory.setStepCaptureId(stepCaptureId);
        epTaskStepHistory.setStepName(epTaskStep.getName());
        epTaskStepHistory.setStepNote(epTaskStep.getNote());
        epTaskStepHistoryDAO.insert(epTaskStepHistory);
      }
    }
    epRTaskEmployeeDAO.deleteByPrimaryKey(epRtaskEmployeeId);
  }