String processInstanceId = task.getProcessInstanceId();
Record record = keyValue.findByRef(processInstanceId);
if (record != null) {
record = new RecordBuilder().build(record, STATUS_DRAFT_TASK,
getParameters());
keyValue.save(record);
businessKey = record.getCode();
}
} else if (this.notEmpty(businessKey)) {
// 如果是流程草稿,直接通过businessKey获得record,更新数据
Record record = keyValue.findByCode(businessKey);
record = new RecordBuilder().build(record, STATUS_DRAFT_PROCESS,
getParameters());
keyValue.save(record);
} else {
// 如果是第一次保存草稿,肯定是流程草稿,先初始化record,再保存数据
Record record = new RecordBuilder().build(bpmProcessId,
STATUS_DRAFT_PROCESS, getParameters(), userId);
keyValue.save(record);
businessKey = record.getCode();
}