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 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); }