コード例 #1
0
  public void deleteTask(String taskId) {
    if (StringUtils.isBlank(taskId)) {
      throw new BusinessException("taskId", ErrorCode.PARAMETER_NOT_FOUND);
    }
    try {
      // 删除巡检计划时先删除EP_TASK_STEP表记录
      EpTaskStepExample TaskStepExample = new EpTaskStepExample();
      EpTaskStepExample.Criteria criteria = TaskStepExample.createCriteria();
      criteria.andTaskIdEqualTo(taskId);
      epTaskStepDAO.deleteByExample(TaskStepExample);
      // 删除巡检计划时先删除关系表记录
      EpRTaskstepMonitorExample epRTaskstepMonitorExample = new EpRTaskstepMonitorExample();
      EpRTaskstepMonitorExample.Criteria epRTaskstepMonitorCriteria =
          epRTaskstepMonitorExample.createCriteria();
      epRTaskstepMonitorCriteria.andTaskIdEqualTo(taskId);
      epRTaskstepMonitorDao.deleteByExample(epRTaskstepMonitorExample);

      epTaskDAO.deleteByPrimaryKey(taskId);
    } catch (Exception e) {
      throw new BusinessException("resourceBeUsed", ErrorCode.RESOURCE_BE_USED);
    }
  }
コード例 #2
0
  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);
  }
コード例 #3
0
  public Map listTaskDetail(String taskId) {
    if (StringUtils.isBlank(taskId)) {
      throw new BusinessException("taskId", ErrorCode.PARAMETER_NOT_FOUND);
    }
    EpTask epTask = epTaskDAO.selectByPrimaryKey(taskId);
    Map map = new HashMap();
    if (epTask != null) {
      map.put("id", epTask.getId());
      map.put("taskName", epTask.getName());
      map.put("taskType", epTask.getType());
      map.put("organId", epTask.getOrganId());
      map.put("taskNote", epTask.getNote());
      map.put("branchId", epTask.getBranchId());
      EpTaskStepExample stepexample = new EpTaskStepExample();
      String orderByClause = "seq";
      stepexample.setOrderByClause(orderByClause);
      EpTaskStepExample.Criteria criteria = stepexample.createCriteria();
      criteria.andTaskIdEqualTo(taskId);
      List<EpTaskStep> list = epTaskStepDAO.selectByExample(stepexample);
      // System.out.println("list:"+list.size());
      List stepList = new ArrayList();
      if (list.size() > 0) {
        for (EpTaskStep epTaskStep : list) {
          EpTaskStepVO epTaskStepVO = new EpTaskStepVO();
          epTaskStepVO.setId(epTaskStep.getId());
          epTaskStepVO.setDeviceType(epTaskStep.getDeviceType());
          epTaskStepVO.setStepName(epTaskStep.getName());
          epTaskStepVO.setStepNote(epTaskStep.getNote());
          epTaskStepVO.setSequence(epTaskStep.getSeq() + "");
          epTaskStepVO.setTaskId(epTaskStep.getTaskId());
          List<EpRTaskstepMonitor> monitorList =
              epRTaskstepMonitorDao.listEpRTaskstepMonitor(epTaskStep.getId());
          System.out.println("1:" + epTaskStep.getId());
          List probersList = new ArrayList();
          List vicList = new ArrayList();
          String lastMonitorId = null;
          // System.out.println("monitorList:"+monitorList.size());
          if (monitorList.size() > 0) {
            for (EpRTaskstepMonitor monitor : monitorList) {
              Map mMap = new HashMap();
              if (monitor.getMonitorType().equals(new BigDecimal(2))) {
                EpRTaskstepMonitorVO vo = new EpRTaskstepMonitorVO();
                vo.setId(monitor.getMonitorId());
                probersList.add(vo);
              }
              /*
               * System.out .println("lastMonitorId:" +
               * lastMonitorId);
               * System.out.println("monitor.getMonitorId():" +
               * monitor.getMonitorId()); System.out
               * .println("lastMonitorId!=monitor.getMonitorId():"
               * + lastMonitorId != monitor .getMonitorId());
               * System.out
               * .println("lastMonitorId!=monitor.getMonitorId():"
               * + monitor.getMonitorId().equals( lastMonitorId));
               * System.out.println(monitor.getMonitorId().equals(
               * lastMonitorId));
               */
              if (monitor.getMonitorType().equals(new BigDecimal(1))
                  && !monitor.getMonitorId().equals(lastMonitorId)) {

                ListEpRTaskstepMonitorVO vo = new ListEpRTaskstepMonitorVO();
                vo.setId(monitor.getMonitorId());
                List viclist = new ArrayList();
                for (EpRTaskstepMonitor vmonitor : monitorList) {
                  if (monitor.getMonitorId().equals(vmonitor.getMonitorId())) {
                    EpRTaskstepMonitorVO visvo = new EpRTaskstepMonitorVO();
                    visvo.setId(vmonitor.getPresetId());
                    EpPreset epPreset = epPresetDAO.selectByPrimaryKey(vmonitor.getPresetId());
                    if (epPreset != null) {
                      viclist.add(epPreset);
                    }
                  }
                }
                vo.setPresets(viclist);
                vicList.add(vo);
              }

              lastMonitorId = monitor.getMonitorId();
            }
          }
          epTaskStepVO.setProbers(probersList);
          epTaskStepVO.setVics(vicList);
          stepList.add(epTaskStepVO);
        }
        map.put("steps", stepList);
      }
    }
    return map;
  }
コード例 #4
0
  public void updateEpTask(String jsonString) throws JSONException {
    JSONObject jsonObj = new JSONObject(jsonString);
    String taskName = jsonObj.getString("taskName");
    String taskType = jsonObj.getString("taskType");
    String organId = jsonObj.getString("organId");
    String id = jsonObj.getString("id");
    if (StringUtils.isBlank(id)) {
      throw new BusinessException("id", ErrorCode.PARAMETER_NOT_FOUND);
    }
    String taskNote = jsonObj.getString("taskNote");
    String branchId = jsonObj.getString("branchId");

    /*
     * EpTaskExample example = new EpTaskExample(); EpTaskExample.Criteria
     * criteria = example.createCriteria();
     * criteria.andNameEqualTo(taskName); List<EpTask> list =
     * epTaskDAO.selectByExample(example); System.out.println(list.size());
     * if (list.size() > 1 && list.get(0).getId() != id) { throw new
     * BusinessException("taskName", ErrorCode.NAME_EXIST); }
     */
    Long time = System.currentTimeMillis();
    EpTask epTask = new EpTask();
    epTask.setId(id);
    epTask.setCreateTime(new BigDecimal(time));
    epTask.setName(taskName);
    epTask.setType(new BigDecimal(taskType));
    epTask.setOrganId(organId);
    epTask.setNote(taskNote);
    epTask.setBranchId(branchId);
    // 更新task表
    epTaskDAO.updateByPrimaryKeySelective(epTask);
    // 删除EpTaskStep
    EpTaskStepExample TaskStepExample = new EpTaskStepExample();
    EpTaskStepExample.Criteria EpTaskStepcriteria = TaskStepExample.createCriteria();
    EpTaskStepcriteria.andTaskIdEqualTo(id);
    epTaskStepDAO.deleteByExample(TaskStepExample);
    // 删除EpTaskStepMonitor
    EpRTaskstepMonitorExample epRTaskstepMonitorExample = new EpRTaskstepMonitorExample();
    EpRTaskstepMonitorExample.Criteria epRTaskstepMonitorCriteria =
        epRTaskstepMonitorExample.createCriteria();
    epRTaskstepMonitorCriteria.andTaskIdEqualTo(id);
    epRTaskstepMonitorDao.deleteByExample(epRTaskstepMonitorExample);

    JSONArray jsonArray = jsonObj.getJSONArray("steps");
    if (jsonArray.length() > 0) {
      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject jsonSteps = new JSONObject(jsonArray.getString(i));
        String sequence = jsonSteps.getString("sequence");
        String stepName = jsonSteps.getString("stepName");
        String stepNote = jsonSteps.getString("stepNote");
        String deviceType = jsonSteps.getString("deviceType");
        if (StringUtils.isBlank(sequence)) {
          throw new BusinessException("sequence", ErrorCode.PARAMETER_NOT_FOUND);
        }
        if (StringUtils.isBlank(stepName)) {
          throw new BusinessException("stepName", ErrorCode.PARAMETER_NOT_FOUND);
        }
        String stepId = sequenceDAO.getEpTaskStepSeq();
        EpTaskStep epts = new EpTaskStep();
        epts.setSeq(Integer.parseInt(sequence));
        epts.setName(stepName);
        epts.setNote(stepNote);
        epts.setTaskId(id);
        epts.setDeviceType(deviceType);
        epts.setId(stepId);
        epTaskStepDAO.insert(epts);
        JSONArray probers = jsonSteps.getJSONArray("probers");
        if (probers.length() > 0) {
          for (int j = 0; j < probers.length(); j++) {
            JSONObject jsonprobers = new JSONObject(probers.getString(j));
            String monitorId = jsonprobers.getString("id");
            if (StringUtils.isBlank(monitorId)) {
              throw new BusinessException("id", ErrorCode.PARAMETER_NOT_FOUND);
            }
            String epRTaskStepMonitorId = sequenceDAO.getEpRTaskStepMonitorSeq();
            EpRTaskstepMonitor ertsm = new EpRTaskstepMonitor();
            ertsm.setId(epRTaskStepMonitorId);
            ertsm.setMonitorId(monitorId);
            ertsm.setStepId(stepId);
            ertsm.setTaskId(id);
            ertsm.setMonitorType(new BigDecimal(2));
            epRTaskstepMonitorDao.insert(ertsm);
          }
        }
        JSONArray vics = jsonSteps.getJSONArray("vics");
        if (vics.length() > 0) {
          for (int k = 0; k < vics.length(); k++) {
            JSONObject jsonvics = new JSONObject(vics.getString(k));
            String monitorId = jsonvics.getString("id");
            JSONArray presetsnum = jsonvics.getJSONArray("presets");
            if (presetsnum.length() > 0) {
              for (int l = 0; l < presetsnum.length(); l++) {
                JSONObject jsonpresets = new JSONObject(presetsnum.getString(l));
                String presetsnumid = jsonpresets.getString("id");
                if (StringUtils.isBlank(monitorId)) {
                  throw new BusinessException("id", ErrorCode.PARAMETER_NOT_FOUND);
                }
                String epRTaskStepMonitorId = sequenceDAO.getEpRTaskStepMonitorSeq();
                EpRTaskstepMonitor ertsm = new EpRTaskstepMonitor();
                ertsm.setPresetId(presetsnumid);
                ertsm.setId(epRTaskStepMonitorId);
                ertsm.setMonitorId(monitorId);
                ertsm.setStepId(stepId);
                ertsm.setTaskId(id);
                ertsm.setMonitorType(new BigDecimal(1));
                epRTaskstepMonitorDao.insert(ertsm);
              }
            } else {
              String epRTaskStepMonitorId = sequenceDAO.getEpRTaskStepMonitorSeq();
              EpRTaskstepMonitor ertsm = new EpRTaskstepMonitor();
              ertsm.setId(epRTaskStepMonitorId);
              ertsm.setMonitorId(monitorId);
              ertsm.setStepId(stepId);
              ertsm.setTaskId(id);
              ertsm.setMonitorType(new BigDecimal(1));
              epRTaskstepMonitorDao.insert(ertsm);
            }
          }
        }
      }
    }
  }