/** * 通过审批 * * @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()); }