Exemplo n.º 1
0
  /**
   * 通过终止审批
   *
   * @param con
   * @param user
   * @throws Exception
   */
  public void passStop(Connection con, JUser user) throws Exception {
    PreparedStatement pstmt = null;
    String sql = null;

    GroupBook book = GroupBook.getGroupBook(con, this.getGroup_id());
    sql =
        " update t_ym_book set group_status = -1, group_stop_status = 4 "
            + " where group_id = ? and group_stop_status = 2 and group_status >= 4 ";

    pstmt = con.prepareStatement(sql);
    pstmt.setString(1, this.group_id);
    pstmt.executeUpdate();
    pstmt.close();

    String subject =
        book.getGroup_name() + "的" + GroupBasic.getGroupTypeName(this.getGroup_type()) + "终止审批已通过";
    int msgWay = JMessageEnum.SYSTEM_MESSAGE;
    JMessageAdapter.sendMessage(
        msgWay,
        new String[] {book.getZxgw_id()},
        subject,
        subject,
        "-1",
        "/ym/group/groupBookControl.jsp?cmd=update&group_id=" + this.getGroup_id(),
        1);
  }
  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);
    }
  }
Exemplo n.º 3
0
  /**
   * 通过审批
   *
   * @param con
   * @param user
   * @throws Exception
   */
  public void pass(Connection con, JUser user) throws Exception {
    PreparedStatement pstmt = null;
    String sql = null;

    GroupBook book = GroupBook.getGroupBook(con, this.getGroup_id());

    String subject = null;
    if (JUtil.convertNull(book.getGroup_no()).length() == 0) {
      sql = " update t_ym_book set group_no = ? " + " where group_id = ? and group_status < 4 ";

      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, createGroupNO());
      pstmt.setString(2, this.group_id);
      pstmt.executeUpdate();
      pstmt.close();
    }

    subject =
        book.getGroup_name() + "的" + GroupBasic.getGroupTypeName(this.getGroup_type()) + "审批已已通过";
    sql =
        " update t_ym_book set group_status = 4, pass_date = ? "
            + " where group_id = ? and group_status < 4 ";

    pstmt = con.prepareStatement(sql);
    pstmt.setTimestamp(1, new java.sql.Timestamp(System.currentTimeMillis()));
    pstmt.setString(2, this.group_id);
    pstmt.executeUpdate();
    pstmt.close();

    int msgWay = JMessageEnum.SYSTEM_MESSAGE;

    JMessageAdapter.sendMessage(
        msgWay,
        new String[] {book.getZxgw_id()},
        subject,
        subject,
        "-1",
        "/ym/group/groupBookControl.jsp?cmd=update&group_id=" + this.getGroup_id(),
        1);
  }
Exemplo n.º 4
0
  /**
   * 撤回
   *
   * @param con
   * @param con_id
   * @throws Exception
   */
  public void revoke(Connection con, String reason) throws Exception {
    PreparedStatement pstmt = null;
    String qry = "";
    int updateCount = 0;
    qry = "update t_ym_process_approval set status = 1 where status = 2 and approval_id = ? ";
    pstmt = con.prepareStatement(qry);
    pstmt.setString(1, this.getApproval_id());
    updateCount = pstmt.executeUpdate();
    pstmt.close();

    YmContract contract = YmContract.getYmContractByConId(con, this.getCon_id());
    if (updateCount != 1) throw new Exception("审批中的记录不是一条," + this.getApproval_id());
    AppInfo.revoke(con, this.getApproval_id(), "ym_process", "撤回  原因:" + reason);

    int msgWay = JMessageEnum.SYSTEM_MESSAGE;
    String toUserIds[] = new String[] {this.getApprover()};

    String subject =
        contract.getCstm_name() + "的" + this.getApproval_type_name() + "的审批被顾问撤回,撤回原因:" + reason;
    String url = "/ym/processControl.jsp?cmd=update&con_id=" + contract.getCon_id();
    JMessageAdapter.sendMessage(msgWay, toUserIds, subject, subject, "-1", url);
  }
Exemplo n.º 5
0
  /**
   * 通过审批
   *
   * @param con
   */
  public void pass(Connection con, String suggest) throws Exception {
    String sql = null;
    PreparedStatement pstmt = null;
    YmContract contract = YmContract.getYmContractByConId(con, this.getCon_id());
    java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis());
    int updateCount = 0;
    sql =
        "update t_ym_process_approval set status = 4, pass_date = ? where approval_id = ? and status = 2 ";
    pstmt = con.prepareStatement(sql);
    pstmt.setTimestamp(1, now);
    pstmt.setString(2, this.getApproval_id());
    updateCount = pstmt.executeUpdate();
    pstmt.close();
    if (updateCount != 1) throw new Exception("更新记录不是一条");

    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=" + contract.getCon_id();
    JMessageAdapter.sendMessage(msgWay, toUserIds, subject, subject, "-1", url);

    YmProcessItem item =
        YmProcessItem.getYmProcessItem(contract.getApply_project(), this.getApproval_type());
    if (YmProcess.isNewProcess(contract.getApply_project())) {
      int count = 0;
      sql = " select count(*) item_count from t_ym_process_date where con_id = ? and item_id = ?  ";
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, contract.getCon_id());
      pstmt.setString(2, item.getItem_id());
      ResultSet rs = pstmt.executeQuery();

      if (rs.next()) {
        count = rs.getInt("item_count");
      }
      rs.close();
      pstmt.close();
      if (count == 0) {
        sql = " insert into t_ym_process_date(con_id, item_id, done_date) values(?, ?, ?) ";
        pstmt = con.prepareStatement(sql);
        pstmt.setString(1, contract.getCon_id());
        pstmt.setString(2, item.getItem_id());
        pstmt.setDate(3, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
        pstmt.executeUpdate();
        pstmt.close();
      } else {
        sql = " update t_ym_process_date set done_date = ? where con_id = ? and item_id = ? ";
        pstmt = con.prepareStatement(sql);
        pstmt.setDate(1, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
        pstmt.setString(2, contract.getCon_id());
        pstmt.setString(3, item.getItem_id());
        pstmt.executeUpdate();
        pstmt.close();
      }
    }

    if (item.getShow_approval() == 1 && this.getApproval_type().indexOf("date_item") > -1) {
      // 如果时间点已经录过,则不覆盖
      sql =
          " select "
              + this.getApproval_type()
              + " as type_date from t_ym_process where con_id = ? ";
      pstmt = con.prepareStatement(sql);
      pstmt.setString(1, contract.getCon_id());
      ResultSet rs = pstmt.executeQuery();
      java.sql.Date type_date = null;
      if (rs.next()) {
        type_date = rs.getDate("type_date");
      }
      rs.close();
      pstmt.close();
      if (type_date == null) {
        // 审批时间既为提交时间
        sql = " update t_ym_process set " + this.getApproval_type() + " = ? where con_id = ? ";
        pstmt = con.prepareStatement(sql);
        pstmt.setDate(1, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
        pstmt.setString(2, contract.getCon_id());
        updateCount = pstmt.executeUpdate();
        pstmt.close();
        if (updateCount == 0) {
          sql = " insert into t_ym_process(" + this.getApproval_type() + ", con_id) values(?,?)";
          pstmt = con.prepareStatement(sql);
          pstmt.setDate(1, JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")));
          pstmt.setString(2, contract.getCon_id());
          pstmt.executeUpdate();
        }
        KHRecord.saveYjDate(
            con,
            JUtil.str2SQLDate(JUtil.formatDate(now, "YYYY-MM-DD")),
            contract.getCon_no(),
            this.getApproval_type());
      }
    }
    // 生成新流程
    YmProcessEvolve.initEvolveDay1(con, this.getCon_id());
    // 保存办理进程时,修改办理进展
    YmProcessEvolve.autoModifyEvolve(con, this.getCon_id());
    // 保存办理进程时,修改办理进展(针对于新流程)
    YmProcessEvolve.autoModifyEvolve1(con, this.getCon_id());
  }
Exemplo n.º 6
0
  /**
   * 审批
   *
   * @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();
    }
  }
Exemplo n.º 7
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();
    }
  }