Implementation of a complete set of custom workflows

Source: Internet
Author: User

Overview:

This workflow uses a set of financial software business processing processes as an example to implement the following functions: Process customization, step customization, step repetition times, Step Type (sequence/parallel), and definition sorting, full use of database implementation, this article will analyze the business process, system design and implementation details in detail.

Terms:

Workflow [1] is an abstraction, generalization, and description of business rules between workflows and their operation steps. Workflow Modeling: describes how the logic and rules of work in a workflow are represented and computed in an appropriate model on the computer. The main problem to be solved in a workflow is that, to achieve a certain business goal, documents, information, or tasks are automatically transmitted between multiple participants based on certain predefined rules using a computer. The main function of the workflow management system is to define, execute, and manage workflows with the support of computer technology, coordinates information interaction between jobs and group members during workflow execution. Workflows must be implemented by the workflow management system.

Process: A workflow contains multiple workflows. You can select either of them for processing. The workflow contains step information;

Step: name of each stage in the process. A process contains multiple steps (also known as nodes in other workflows ).

 

Body:

Part 1: business logic analysis

1. Custom workflows refer to all links of workflows and their parameters. They are commonly used for document processing and business process approval. This system comes from a set of financial management software developed by myself. The business Handler has different permissions for different roles to perform business processing, and the entire process from loan investigation to loan approval from the loan database. Due to software functional requirements, the loan investigation should be fixed to the first step, and the loan approval should be set to the last step.

The number indicates the number of repeated steps.

2. User business processing includes:

1) Pass: The current step is processed. (select the next handler) the next step in the current process. If it is the last step, the process is completed;

2) Return: return the step to the previous step, that is, to the previous handler. If it is the first step, it cannot be returned;

3) Reject: the process is terminated directly, and no operation can be performed or rolled back to the first step. The second method is used in the system;

4) Recall: if the current step has been processed and the next handler has not processed it, the recall operation can be performed.

3. Order and Parallelism

Sequence means that when the previous handler specifies a handler, other operators with the permission to perform this step cannot view and operate. The process can continue only after the current handler completes the process; parallel processing is done by one employee after the previous handler specifies a fixed number of handling persons, regardless of the order before and after the processing is completed, and the next step is taken, the number of workers is determined by the number of duplicates in the current step.

The relationship between the two is as follows.

Part 2 System Design

The database design is as follows:

1) process info table: s_flow_info (flow_id, flow_name)

2) Step info table: s_action_info (action_id, action_name)

3) process-step info table: s_step_info (step_id, action_id, flow_id, step_repeat_no, step_order_no, step_type)

(Step_repeat_no indicates the number of repetitions, step_order_no indicates the order number, step_type indicates the type: 0 indicates the order, and 1 indicates the parallel operation)

4) process details: Rochelle tranct_proc (proc_id, loan_id, step_id, step_action, step_emp_id)

(Here, loan_id is the primary key of the Data master table, step_id is associated with s_action_info, and step_action stores the processing result: 0 -- fail, 1 -- pass, 2 -- Return, 3 -- reject, 4 -- recall, step_emp_id is the number of the employee currently being processed)

The process table, step table, and process step relational table are the core data tables, which determine the full customization of the workflow. The process detail table is an important data table, which is used for connection query.

Other related tables include:

1) Data Base table l_loan_info (loan_id, loan_name, flow_id, step_id ,...)

(Flow_id is the process number, and step_id is associated with s_action_info)

2) operate employee table e_emp_info (emp_id, emp_name ,..)

3) role info table e_role_info (role_id, role_name)

4) Employee-Role Relationship table e_emp_role (emp_role_id, emp_id, role_id)

(Associate role table with employee table)

5) Step role relationship table s_action_role (action_role_id, action_id, role_id)

(Associate role table with step table)

6). The next processing person table l_loan_next_emp (loan_next_emp_id, loan_id, next_emp_id, step_id)

(Next_emp_id is associated with the employee table e_emp_info and step_id is associated with s_action_info)

The data flow is as follows:

1) when the business occurs at the beginning, the data master table Rochelle loan_info inserts data, and its step_id is the number of the first step in the process, you can insert the operator number of the next handler to the l_loan_next_emp table of the next handler according to the number of repetitions in the next step. Insert the data in the process detail table and set step_id to the number of the current step; update the step_id of the base table l_loan_info to the next step number;

2) the process goes to the next step;

3) The next processor can view the current data to be processed (and the data to be processed in this phase), and select the processing result (0: fail, 1: Pass, 2: return, 3: reject) insert it into the process processing detail table. If it is changed to the next step number by updating the step_id of the primary table l_loan_info, return to the previous step number, if this parameter is not specified, the first step ID is updated;

4) You can view the processed data in the processed data. If the operator has not performed any operation in the next step, you can recall the data operation, insert the processing result (4: Recall) into the process processing schedule. The next_emp_id is the employee ID of the user ); update the step_id of the base table l_loan_info as the number of the first step of the process;

5) The next handler continues the cycle of 3) and 4) until the process ends;

6) in the last step of the process, insert the step_id value 0 in the processing result to the process details.

Part 3: Implementation Details

1. The code for obtaining the data list in step 1 is as follows:

SELECT * FROM L_loan_info WHERE step_id=@step_id

Here, @ step_id uses the code to obtain the first step ID of the current data.

2. Step 1: Obtain the code for the processed data list:

SELECT * FROM L_loan_info WHERE loan_id IN (SELECT DISTINCT loan_id FROM l_tranct_proc WHERE step_id=@step_id)

3. Obtain the list of data in any step (including unprocessed and processed data)

 

/// <Summary> /// method: Get approval (or approval) data list // development: Wang Hongjian http://www.cnblogs.com/walkingp http://www.51obj.cn//// time: 2010-6-29 // last modification time: 2010-6-29 // modify details: /// </Summary> /// <Param name = "step_emp_id"> approved by (default: current operator ): 0. Other persons and current users in this link </param> /// <Param name = "action_id"> step </param> /// <Param name = "step_action"> operation Value: 0: Pending approval/approval 1: Approved/approved _: All </param> // <Param name = "version"> versions: 3.0 </param> /// <returns> </returns> public list 

 

The above is the core code. Of course, you can adjust the corresponding code because the specific needs of the workflow are different.

 Part 4: running results

1. system parameter configuration

2. List to be processed

3. Processing page

(Note: Currently, this is the last processing, and the next processing person is invisible)

4. Recall page

Conclusion:

A complete custom workflow is widely used and complex in business logic. Therefore, more analysis and research are required to implement a universal workflow.

In addition, this article does not provide code or other materials for download. Do not leave a message for this.

Thank you!

Reference:

[1]: Wikipedia: workflow technology http://zh.wikipedia.org/zh-cn/workflow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.