private void updateTaskStatus(Long nmTerminalChangeIdTaskId, int status) {
    boolean flag = true;
    int i = 0;
    while (flag) {
      if (i++ > 50) {
        logger.warn("Data Terminal Change task update task status error.");
        manager = null;
        System.exit(0);
      }

      try {
        manager = new TerminalChangeTaskManagerImpl();
        TerminalChangeTask updateTask = new TerminalChangeTask();
        updateTask.setIntTaskStatus(status);
        updateTask.setDtTaskEndTime(DateTimeUtils.getCurrentDateStr());
        updateTask.setNmTerminalChangeIdTaskId(nmTerminalChangeIdTaskId);
        manager.update("updateTerminalChangeTask", updateTask);

        flag = false;
      } catch (SQLException e) {
        if (CommonErrorUtil.isTableLockError(e))
          logger.warn("Times[{}]-Table lock,waiting...msg:[{}].", i, e.getCause().getMessage());
        else
          logger.warn(
              "Update task status error, move current taskid [{}].", nmTerminalChangeIdTaskId);

        flag = true;
        try {
          Thread.sleep(6000);
        } catch (InterruptedException e2) {
        }
      } finally {
        manager = null;
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see com.etone.mantoeye.analyse.specific.ISpecificTaskJob#execute()
   */
  public void execute() {
    logger.info("[SpecificTaskJob] -- Exec Terminal Change Job.");

    // 2、得到當前需要執行的任務
    List<TerminalChangeTask> list = getCurrentTaskList();

    if (null != list && !list.isEmpty()) {
      // 3、得到第一個需要執行的任務
      TerminalChangeTask task = list.get(0);

      if (null != task) {
        logger.info("Terminal TaskName :{}.", task.getVcTaskName());

        // 3、更新任務狀態為執行中。。
        Long nmTerminalChangeIdTaskId = task.getNmTerminalChangeIdTaskId();

        logger.info("Mark Terminal Change Task Id:{} running.", nmTerminalChangeIdTaskId);
        updateTaskStatus(nmTerminalChangeIdTaskId, 1);

        // 4、終端升級數據反查尋
        Long nmTerminalChangeId = task.getNmTerminalChangeId();
        logger.debug("Terminal change back check : [{}].", nmTerminalChangeId);

        // 4.1更具終端升級統計表ID,找到相應的統計數據
        TerminalChange terminalChange = getTerminalChange(nmTerminalChangeId);

        if (null == terminalChange
            || (null != terminalChange && null == terminalChange.getNmTerminalChangeId())) {
          logger.error("任務信息與終端升級統計表信息不符,請檢查.");
          updateTaskStatus(nmTerminalChangeIdTaskId, 5);
          System.exit(1);
        }

        // 4.1.4結合所有條件值
        String oldCondition = getCondition(terminalChange, nmTerminalChangeIdTaskId)[0];

        String newCondition = getCondition(terminalChange, nmTerminalChangeIdTaskId)[1];

        logger.debug("old terminal condition -- >{}.", oldCondition);
        logger.debug("new terminal condition -- >{}.", newCondition);

        // 4.2開始、結束時間
        String dtStartTime = getTime(terminalChange)[0];
        String dtEndTime = getTime(terminalChange)[1];

        logger.debug("dtStartTime -->{}.", dtStartTime);
        logger.debug("dtEndTime -->{}.", dtEndTime);

        // 5.1條件組裝參數
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("dtStartTime", dtStartTime);
        map.put("dtEndTime", dtEndTime);
        map.put("oldCondition", oldCondition);
        map.put("newCondition", newCondition);
        map.put("nmTerminalChangeIdTaskId", nmTerminalChangeIdTaskId);

        runTerminalChangeTask(map);

        // 6.結束任務
        logger.info("Update Terminal Change Task Id {} status:complete.", nmTerminalChangeIdTaskId);
        updateTaskStatus(nmTerminalChangeIdTaskId, 2);
      }
    }
  }