public void start(Connection con, Job job, java.util.Map<String, Object> context)
      throws Exception {

    PreparedStatement pstmt = null;
    String sql = null;
    String szAgree = (String) context.get("approveFlag");
    String suggest = (String) context.get("suggest");
    Connection con_lwf = (Connection) context.get("con_lwf");

    // 驳回
    if (!szAgree.equals("1")) {
      sql =
          "update t_fl_teacher_experience set status=3 " + " where teach_exp_id = ? and status=2 ";
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, job.getAppId());
      pstmt.executeUpdate();
      pstmt.close();
    }

    TeacherExperience applyObj = TeacherExperience.getTeacherExperience(con, job.getAppId());
    if (!szAgree.equals("1")) {
      int msgWay = JMessageEnum.SYSTEM_MESSAGE;
      java.util.Set<String> set = null;

      set = AppInfo.getApproverIdsByWf_id(con_lwf, job.getWf_id());
      String appName = "学术文章审批:" + applyObj.getTeach_exp_title();

      String subject = appName + "审批未通过,原因:" + suggest;

      String toUserIds[] = new String[set.size()];
      int i = 0;
      for (java.util.Iterator<String> iter = set.iterator(); iter.hasNext(); i++) {
        toUserIds[i] = (String) iter.next();
      }
      JMessageAdapter.sendMessage(
          msgWay,
          toUserIds,
          subject,
          subject,
          "-1",
          "/fl/teachExperience/teachExperience.jsp?teach_exp_id=" + job.getAppId());
    } else {
      applyObj.pass(con_lwf);
    }
  }
  /**
   * 审批
   *
   * @param user
   * @param jobId
   * @param agree
   * @param suggest
   */
  public void approve(JUser user, String jobId, boolean agree, String suggest) throws Exception {
    Connection con = null;
    PreparedStatement pstmt = null;
    String sql = null;
    Job job = null;
    java.util.Map<String, Object> context = new java.util.HashMap<String, Object>();
    StringBuffer contextXML = new StringBuffer();

    context.put("user_id", user.getUserId()); // 当前操作人
    context.put("approveFlag", (agree ? "1" : "0")); // 审批标记
    context.put("suggest", suggest); // 审批意见
    boolean end = true;
    try {
      con = JDatabase.getJDatabase().getConnection();
      con.setAutoCommit(false);
      job = Job.getJobById(con, jobId);

      contextXML.append("<ContextData>");
      contextXML.append("<approval><flag>" + (agree ? "1" : "0") + "</flag></approval>");

      if (agree) {
        YmContract contract = YmContract.getYmContractByConId(con, this.getCon_id());
        YmProcessItem item =
            YmProcessItem.getYmProcessItem(contract.getApply_project(), this.getApproval_type());
        if (item != null
            && !user.getUserId().equals(this.getApprover())
            && item.getCon_lead_app() == 1) {
          end = false;
          contextXML.append("<approver>" + this.getApprover() + "</approver>");
        }
        contextXML.append("<Participants>");
        contextXML.append("<Participant type=\"user\">");
        if (item != null
            && !user.getUserId().equals(this.getApprover())
            && item.getCon_lead_app() == 1) {
          contextXML.append("<user>" + this.getApprover() + "</user>");
        }
        contextXML.append("</Participant>");
        contextXML.append("</Participants>");
      }
      contextXML.append("</ContextData>");
      context.put("contextXML", contextXML.toString());
      job.setContext(context);
      job.start(con);

      if (!agree) {
        sql = "update t_ym_process_approval set status = 3 where approval_id = ? ";
        pstmt = con.prepareStatement(sql);
        pstmt.setString(1, this.getApproval_id());
        pstmt.executeUpdate();
        pstmt.close();
        YmContract contract = YmContract.getYmContractByConId(con, this.getCon_id());
        int msgWay = JMessageEnum.SYSTEM_MESSAGE;

        Set<String> set = new HashSet<String>();
        set.add(contract.getCon_visa_con());
        if (!set.contains(contract.getCon_visa_guide())) set.add(contract.getCon_visa_guide());

        String toUserIds[] = new String[set.size()];
        int i = 0;
        for (Iterator<String> iter = set.iterator(); iter.hasNext(); i++) {
          toUserIds[i] = (String) iter.next();
        }

        String subject =
            contract.getCstm_name()
                + "的办理进程"
                + JUtil.convertNull(this.getApproval_type_name())
                + "审核未通过";
        String url = "/ym/processControl.jsp?cmd=update&con_id=" + this.getCon_id();
        JMessageAdapter.sendMessage(msgWay, toUserIds, subject, subject, "-1", url);
      } else if (job.getActivityId().equals("manager") && end) {
        this.pass(con, suggest);
      }
      con.commit();
    } catch (Exception e) {
      throw e;
    } finally {
      if (con != null) con.rollback();
      if (con != null) con.close();
    }
  }
Exemple #3
0
  /**
   * 审批
   *
   * @param user
   * @param jobId
   * @param agree
   * @param suggest
   */
  public void approve(JUser user, String jobId, boolean agree, String suggest) throws Exception {
    GroupBook book = null;
    Connection con = null;
    PreparedStatement pstmt = null;
    String sql = null;
    Job job = null;
    java.util.Map<String, Object> context = new java.util.HashMap<String, Object>();
    StringBuffer contextXML = new StringBuffer();

    context.put("user_id", user.getUserId()); // 当前操作人
    context.put("approveFlag", (agree ? "1" : "0")); // 审批标记
    context.put("suggest", suggest); // 审批意见

    try {
      con = JDatabase.getJDatabase().getConnection();
      con.setAutoCommit(false);
      book = GroupBook.getGroupBook(con, this.getGroup_id());
      job = Job.getJobById(con, jobId);
      contextXML.append("<ContextData>");

      if (agree) {
        contextXML.append("<onlyManager>N</onlyManager>");
        contextXML.append("<Participants>");
        contextXML.append("<Participant type=\"user\"></Participant>");
        contextXML.append("</Participants>");
      }
      contextXML.append("</ContextData>");

      context.put("contextXML", contextXML.toString());
      job.setContext(context);
      job.start(con);

      if (!agree) {
        int msgWay = JMessageEnum.SYSTEM_MESSAGE;
        String subject = null;

        sql = "update t_ym_book set group_status = 3 where group_id = ? ";
        subject =
            book.getGroup_name()
                + "的"
                + GroupBasic.getGroupTypeName(this.getGroup_type())
                + "审批未通过,原因:"
                + suggest;
        pstmt = con.prepareStatement(sql);
        pstmt.setString(1, this.getGroup_id());
        pstmt.executeUpdate();
        pstmt.close();
        JMessageAdapter.sendMessage(
            msgWay,
            new String[] {book.getZxgw_id()},
            subject,
            subject,
            "-1",
            "/ym/group/groupBookControl.jsp?cmd=update&group_id=" + this.getGroup_id(),
            1);
      } else if (job.getActivityId().equals("manager")) {
        this.pass(con, user);
      }

      con.commit();
    } catch (Exception e) {
      throw e;
    } finally {
      if (con != null) con.rollback();
      if (con != null) con.close();
    }
  }