Are you still writing your own leave process? Activiti7 will help you quickly ask for leave!!!

Develop a habit, like first and then watch!!!

Preface

The focus of this blog will be on the explanation of the process and some key functions of Activiti7. The detailed Activiti7 tutorial will be explained in detail in a subsequent blog. The main thing is that I haven't finished it yet.

Insert picture description here

Process

No rules, no standards.

In fact, the process is equivalent to the rules we set in advance when we write the function.The functions we generally write are written according to the requirements of Party A's father, so the process of function execution should be written in accordance with the process defined by Party A's father. Then we can understand the concept of the process.

After understanding the concept of the process, we need to understand how we generally execute the process?

For the general process, we design the process table ourselves, and then bind our process table with our business data, so that our process can proceed step by step. Let’s 请假的流程describe how we generally implement this function through one . :
Insert picture description here
At first, you may think that when you look at the above process, this is good, clear at a glance, and refreshing. To be honest, I felt that way for the first time. It's not good. But I told you it was an illusion.

Insert picture description here

In the above design process, we must not only manage our business data, but also manage our task data, and each task data may still have a certain relationship. We must keep this relationship. Otherwise, how can we It can be confirmed that the supervisor is reviewing whose application for leave!!! So it will obviously increase our pressure on data management.

This kind of design cannot be said to be wrong, but with the development of the times, the following situation will inevitably arise: the department is becoming more and more refined (it is the mother 很多部门的意思), the process is getting more and more 复杂, the processing time is getting more and more ...

In this case, if we still design the table ourselves and bind it with our business data, then obviously it 开发的难度will not only increase a lot, but 维护难度also increase a lot in the later period . So we still have to help through the process framework Our more efficient development process.

Change requirements -> to kill the programmer

After talking about the general concept of the process, let's understand a little bit why we need a process framework to help us simplify the development of the process. There are several reasons, one is that it is 开发的难度getting bigger and 流程more complicated, and the other is需求整天变个不停 . Think about it You have finally finished writing a process before you don't use the process framework. It hasn't been two days since the customer said that the process has changed.

Insert picture description here

By the way, let me tell you about the specific areas that have caused us the most headaches after the requirements have been changed.

I believe that the most annoying thing in the development process is that the requirements are constantly changing. Because once the requirements change, it will cause the following series of reactions. As shown in the following figure:

Insert picture description here
Because there will be a series of chain reactions above, back-end developers generally start development after the requirements are as detailed as possible.

Because once the requirements change, the following items must basically be changed.

  • Database refactoring
    This should be understood by everyone. Even if you don’t understand, let’s take the following chestnut. Everyone will understand.
    Suppose we designed a table about users User like this:
    Insert picture description here
    But now the customer has new requirements , We need to store all the user’s detailed information including: phone number, home address, education background, etc., then obviously the User table in our database needs to be reconstructed. And the reconstruction will have the following two situations:
    1 . directly 原来的表add the above fields.
    2. 新建一张表Add the field on the tables before 将两张表关联them.
    Perhaps this time someone will say, the first option is not a good thing, not a second shark program also carved it !! It's really funny to create another table to associate with it! It's
    Insert picture description here
    actually not my shark carving. This actually depends on the situation. Obviously, we can directly add fields to the sample User table above. , But what about the User table below?
    Insert picture description here
    Assuming that there are 30 or more fields in our table, can we continue to add fields? Obviously doing this is stupid, quite stupid, very stupid, I am sure there's a stupid.
    because a table字段过多 after the database will seriously affect us about various operations性能 , so we can only choose the operating table and the associated points so we can continue to maintain relatively speaking, database-related operations performance.

  • The process needs to be rewritten
    . In fact, everyone can understand it. Let’s take a chestnut to help everyone understand:
    suppose we have developed a function about leave.
    Suppose our previous leave process is like this:
    Insert picture description here
    but the demand is changed to this:
    Insert picture description here
    So obviously our entire writing process about the leave process will be changed accordingly. So our back-end development's most annoying requirements have changed again, so that our entire development process will be abnormally slow, and sometimes even appear 重构process than the 推倒重新much longer time it takes to do so we are often able to see what the programmers and product managers fight news , this is normal.


  • If the new coupling relationship between the modules is only the above, it is okay, I am afraid that the customer has mentioned a module that has not been mentioned before. If this module is only related to our first module or the last module, it is actually still well, he was afraid to mention the function module is stuck in the middle of the two modules to perform, which was terrible, not only to the front and a binding module, while also bind after a module two embarrassing.
    this It's just like the show operation of a certain strange art. When watching a web series, it is hard to wait for you to get through the beginning of the commercial. After that, you finally watched half of the TV series. He gave you another spot commercial. After watching the spot commercial, you To watch the next half episode of the TV series, you say you are not angry.
    Insert picture description here

Activiti7 is very convenient and fast

Having talked about so many complicated things about the process and process development, let's briefly explain how Activiti7 helps us achieve it!

Here is a brief explanation, and the detailed tutorial will be fully shared in the next blog.

First of all, the first point is 不需要我们在单独设计创建that Activiti7 will help us自动创建并且管理 with the flow chart.Think about it, what a wonderful thing, basically all the problems of the process can be completed by Activiti7.

Insert picture description here
The second point Activiti7 greatly simplifies our previous repetitive management task information and associated operations.
We first need to understand the process operation of Activiti7. We can understand it through the following diagram:
Insert picture description here
In Activiti7, it is used at the beginning The entire process of operation is deployed, so that each user's operation will follow this process.
Then we will go through it in this order.
Let's draw a BPMN file first.
Insert picture description here
You can see that we are already in the BPMN file The operation process of the entire process is defined, and the operations in the process are subdivided into corresponding task nodes-(initiating leave, approving leave) , every time the user completes an action, the corresponding task node is completed and delivered to the next Task node, when all task nodes are completed, the process ends.

This saves us from thinking about how to store task nodes and their associated information.All these operations are handed over to Activiti7 to operate.

Then we only need to deploy the process definition:

    @Autowired
    private RepositoryService repositoryService;

    //根据bpmn部署流程
    @Test
    public void initDeploymentBPMN(){
    
    
        String filename="BPMN/Part4_Task.bpmn";//BPMN文件所在的位置
        Deployment deployment=repositoryService.createDeployment()
                .addClasspathResource(filename)
                .name("流程定义部署测试")
                .deploy();
        System.out.println(deployment.getName()+",部署成功");
    }

In this way, our process definition is successfully deployed.

Then we need to initialize a process instance defined by the process:

    @Autowired
    private RuntimeService runtimeService;

    //初始化流程实例
    @Test
    public void initProcessInstance(){
    
    

        ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("myProcess_Task");//BPMN文件的Id名
        System.out.println("ID:"+processInstance.getId());
        System.out.println("ProcessInstanceId:"+processInstance.getProcessInstanceId());
        System.out.println("ProcessDefinitionId:"+processInstance.getProcessDefinitionId());
    }

In this way, our process instance has been created. After that, we can execute the task nodes in our process instance step by step.

    @Autowired
    private TaskService taskService;
    //执行任务
    @Test
    public void completeTask(){
    
    
        taskService.complete("2d22f941-3f67-11eb-b3b6-3c58c24c1a1b");//任务节点的ID号
        System.out.println("该任务节点已经处理完毕");
    }

In this way, we can complete our task nodes, and our process is complete after all task nodes are completed.

Is it very convenient and fast?

And even if Party A’s father modifies the requirements, we only need to redraw our BPMN file, and then redeploy it, and then correspond our corresponding task completion node operations to our business data. Quite fast. No need to resemble before Same again.

Here is a simple leave process to write a number, is it quite convenient and fast!!!

Ok, I will explain the use of Activiti7 in detail in a later blog. If you are afraid of missing it, you can follow my public account. Newcomers need your support!!!

Insert picture description here

Guess you like

Origin blog.csdn.net/lovely__RR/article/details/111307803