Skip to content

Instantly share code, notes, and snippets.

@henryyan
Created January 20, 2013 07:27
Show Gist options
  • Save henryyan/4577147 to your computer and use it in GitHub Desktop.
Save henryyan/4577147 to your computer and use it in GitHub Desktop.
根据历史的流程数据创建运行时任务
import java.util.HashMap;
import java.util.Map;
public class InsertActivitiRecordFromHistory {
public static void main(String[] args) {
long id = 424101; // 当前的ID
String pdid = "effectInsurance:10:424004"; // 新的流程定义ID
// 流程实例ID
String pids = "389222,393016,398339,402645,407997,408506,408519,408528,420320";
// 节点
Map<String, String> technologyMap = new HashMap<String, String>();
technologyMap.put("393016", "103");
technologyMap.put("398339", "103");
technologyMap.put("402645", "112");
technologyMap.put("389222", "112");
technologyMap.put("407997", "129");
technologyMap.put("408506", "129");
technologyMap.put("408519", "129");
technologyMap.put("408528", "129");
technologyMap.put("420320", "123");
// 业务ID
Map<String, String> bkeyMap = new HashMap<String, String>();
bkeyMap.put("389222", "38051");
bkeyMap.put("393016", "39051");
bkeyMap.put("398339", "39052");
bkeyMap.put("402645", "39100");
bkeyMap.put("407997", "39101");
bkeyMap.put("408506", "39102");
bkeyMap.put("408519", "39103");
bkeyMap.put("408528", "39104");
bkeyMap.put("420320", "40056");
String[] split = pids.split(",");
for (String pid : split) {
StringBuffer sb = new StringBuffer();
// runtime process instalce
sb.append("insert into act_ru_execution values(");
sb.append(pid);
sb.append(", 1");
sb.append(", " + pid);
sb.append(", " + bkeyMap.get(pid));
sb.append(", null");
sb.append(", '" + pdid + "'");
sb.append(", null");
sb.append(",'sendQuote'");
sb.append(", '1'");
sb.append(", '0'");
sb.append(", '1'");
sb.append(", '0'");
sb.append(", '1'");
sb.append(", '2');\n");
// runtime task
sb.append("insert into act_ru_task values(");
sb.append(id++ + ", 1, " + pid + ", " + pid);
sb.append(", '" + pdid + "'");
sb.append(", '发送报价', null, null");
sb.append(", 'sendQuote'");
sb.append(", null, ");
sb.append(technologyMap.get(pid));
sb.append(", null, 50, sysdate, null, '1'");
sb.append(");\n");
// history task
sb.append("insert into act_hi_taskinst values(");
sb.append(pid);
sb.append(",'" + pdid + "'");
sb.append(", 'sendQuote'");
sb.append(", " + pid + ", " + pid);
sb.append(", null");
sb.append(",'发送报价'");
sb.append(", null");
sb.append(", null");
sb.append(", " + technologyMap.get(pid));
sb.append(", sysdate");
sb.append(", null");
sb.append(", null");
sb.append(", null");
sb.append(", 50");
sb.append(", null);\n");
sb.append("insert into act_hi_actinst values(");
sb.append(id + ", '" + pdid + "', " + pid + ", " + pid);
sb.append(",'sendQuote'");
sb.append(",'发送报价'");
sb.append(",'userTask'");
sb.append("," + technologyMap.get(pid));
sb.append(", sysdate, null");
sb.append(", null");
sb.append(", " + id + ", null);\n");
String insertVar = "INSERT INTO act_ru_variable arv"
+ " SELECT id_, 1, ahi.var_type_, ahi.name_, ahi.execution_id_, ahi.proc_inst_id_, ahi.task_id_, ahi.bytearray_id_, ahi.double_,ahi.long_, ahi.text_, ahi.text2_"
+ " FROM act_hi_detail ahi" + " WHERE ahi.proc_inst_id_ = " + pid;
sb.append(insertVar + ";");
// history activity
System.out.println(sb.toString());
System.out.println();
}
System.out.println("update act_ge_property set value_ = " + (id + 1) + " where name_ = 'next.dbid';");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment