flowable的数据表中有act_hi_comment和act_hi_attachment两张表,前者为意见表后者为附件表
act_hi_comment:
只有 TYPE_,TIME_,ACTION_ 这三个参数会自动生成, TASK_ID_,PROC_INST_ID_ 这两个参数,如果调用接口时候不设置,就不会有,.
type可以自定义,例如自定义为:通过/退回/提前终止(add时调用有type字段的方法即可),缺省提供了comment,event是事件,当给附件表增加记录时,它就会在意见表同时增加多少条记录,并且type的类型为event。所以取意见时,需要注意这个问题。
comment提供了以下方法,全部在TaskService中:
/** Add a comment to a task and/or process instance. */
Comment addComment(String taskId, String processInstanceId, String message);
/** Add a comment to a task and/or process instance with a custom type. */
Comment addComment(String taskId, String processInstanceId, String type, String message);
/** Update a comment to a task and/or process instance. */
void saveComment(Comment comment);
/**
* Returns an individual comment with the given id. Returns null if no comment exists with the given id.
*/
Comment getComment(String commentId);
/** Removes all comments from the provided task and/or process instance */
void deleteComments(String taskId, String processInstanceId);
/**
* Removes an individual comment with the given id.
*
* @throws FlowableObjectNotFoundException
* when no comment exists with the given id.
*/
void deleteComment(String commentId);
/** The comments related to the given task. */
List<Comment> getTaskComments(String taskId);
/** The comments related to the given task of the given type. */
List<Comment> getTaskComments(String taskId, String type);
/** All comments of a given type. */
List<Comment> getCommentsByType(String type);
/** The all events related to the given task. */
List<Event> getTaskEvents(String taskId);
/**
* Returns an individual event with the given id. Returns null if no event exists with the given id.
*/
Event getEvent(String eventId);
/** The comments related to the given process instance. */
List<Comment> getProcessInstanceComments(String processInstanceId);
/** The comments related to the given process instance. */
List<Comment> getProcessInstanceComments(String processInstanceId, String type);
有以下几点需要注意:
1、addComment才是新增,saveComment是修改。
2、addComment应在操作流程之前。例如当前流程节点待完成的任务添加comment,应该先addComment,再进行complete.
3、comment中有两个审批信息字段:message和fullMessage。message保存的是审批信息的前163个字段内容,而fullMessage保存的是longblob类型的完整审批内容信息,因此获取审批内容时,要获取fullMeaage的内容而不是message。
附件提供了以下方法:
/**
* Add a new attachment to a task and/or a process instance and use an input stream to provide the content
*/
Attachment createAttachment(String attachmentType, String taskId, String processInstanceId, String attachmentName, String attachmentDescription, InputStream content);
/**
* Add a new attachment to a task and/or a process instance and use an url as the content
*/
Attachment createAttachment(String attachmentType, String taskId, String processInstanceId, String attachmentName, String attachmentDescription, String url);
/** Update the name and description of an attachment */
void saveAttachment(Attachment attachment);
/** Retrieve a particular attachment */
Attachment getAttachment(String attachmentId);
/** Retrieve stream content of a particular attachment */
InputStream getAttachmentContent(String attachmentId);
/** The list of attachments associated to a task */
List<Attachment> getTaskAttachments(String taskId);
/** The list of attachments associated to a process instance */
List<Attachment> getProcessInstanceAttachments(String processInstanceId);
/** Delete an attachment */
void deleteAttachment(String attachmentId);