|
楼主 |
发表于 2016-9-10 09:01:22
|
显示全部楼层
- public static void customerProcessAfterFinish() throws SQLException {
- // 流程结束时,将流程状态设置为“已结束”
- java.sql.Connection conn = null;
- java.sql.PreparedStatement pstmt = null;
- try {
- String key = com.justep.system.process.ProcessUtils.getProcessData1();
- String kSql = "update RU_customerApply RU_customerApply set RU_customerApply.fProcState='已结束' " + "where RU_customerApply='" + key + "'";
- KSQL.executeUpdate(kSql, null, "/ruidao/masion/data", null);
- // 流程结束时,按照动作类型更新用户信息
- String ksql = "select RU_customerRecord.* from RU_customerRecord RU_customerRecord where RU_customerRecord.fMainID='" + key + "' and (RU_customerRecord.fType='新增' or RU_customerRecord.fType='更新' or RU_customerRecord.fType='停用' or RU_customerRecord.fType='启用' )";
- com.justep.system.data.Table table = KSQL.select(ksql, null, "/ruidao/masion/data", null);
- // 在客户信息表中生成新的记录
- Iterator<Row> rows = table.iterator();
- Row row;
- row = rows.next();
-
- Collection<String> co = table.getColumnNames();
- Iterator<String> it = co.iterator();
- String colNames = "";
- String mySetString="";
- while (it.hasNext()) {
- String colName = it.next();
- if (colName.equals("RU_customerRecord") || colName.equals("fType") || colName.equals("fMainID")) {
- }else if(colName.equals("fFomerID")){
- colNames = colNames + "," + colName;
- }else {
- colNames = colNames + "," + colName;
- mySetString=mySetString+", ru_customer."+colName+"=ru_customerrecord."+ colName;
- }
- }
-
- mySetString=mySetString.substring(1);
- colNames = colNames.substring(1);
- String updateSql = "";
- if(row.getString("fType").equals("新增")){
-
- updateSql = "INSERT INTO ru_customer ( " + colNames.replaceAll("fFomerID", "fID") + ") select " + colNames + " from ru_customerrecord where RU_customerRecord.fMainID='" + key
- + "' and RU_customerRecord.fType='新增'";
- }else{
- updateSql = "UPDATE ru_customer INNER join ru_customerrecord ON ru_customer.fID=ru_customerrecord.fFomerID "+
- "set " +mySetString+
- " where RU_customerRecord.fMainID='"+key+"' and (RU_customerRecord.fType='更新' or RU_customerRecord.fType='停用' or RU_customerRecord.fType='启用')";
- }
- System.out.println(updateSql);
- conn = com.justep.model.ModelUtils.getConnectionInTransaction("/ruidao/masion/data");
- pstmt = conn.prepareStatement(updateSql);
- pstmt.execute();
- } catch (Exception e) {
- if (pstmt != null) {
- pstmt.close();
- }
- throw new RuntimeException(e.getMessage());
- }
- }
复制代码
|
|