Spring boot 2.0 + activiti 7 integration (4) — those pits encountered (1)

Time:2019-12-15

1. Certification issues

Problem Description:

When activiti7 is integrated with springboot2.0, activiti uses identity authentication, and the direct access error after integration is as follows:

{
    "timestamp": "2019-12-13T02:54:05.254+0000",
    "status": 401,
    "error": "Unauthorized",
    "message": "Unauthorized",
    "path": "/"
}

terms of settlement:

Start class add (exclude automatic assembly of authentication):

@SpringBootApplication(exclude ={SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})

2. JSON result set does not return null

Problem Description:

After integration, the JSON result set returned by springmvc excludes null fields, such as defining the returned result set {ID, name}. If name = = null, the returned result set is as follows:

{
    "id": 1,
}

Name field removed

Terms of settlement

Add in YML (Jackson can control whether the result set returned by JSON displays null fields):

  jackson:
    default-property-inclusion: always

3. Process initiator assignment

Problem description

I want to save the initiator of the process. The online solution is to add the attribute assignment of activiti: initiator. In fact, it is to insert the start user ID field in ‘activity hi procinst’. However, there is no identityservice interface in activiti7, so,identityService.setAuthenticatedUserId(`”zx”`);No use. The initiator cannot be assigned.

Terms of settlement

1. Create a new table association process (in use)

To create a new process associated table, you can bring all the resources needed by your own business process in the process, which is more flexible, reduces the coupling with activiti, and recommends.

2. Directly insert the start? User? ID? Manually (Theory)

In theory, since you know the specific fields of that table, you can manually insert the initiator according to processinstanceid.

3, others

Activiti7 should have other solutions, but the API of activiti7 has not been found. The source code is a headache, and the first one is more suitable for projects. After integration, it is separation and independence.

4. Process variables

Problem description

Spring boot 2.0 + activiti 7 integration (4) -- those pits encountered (1)
As shown in the figure above, there is a branch at the gateway, and the variable is audit. The test process is as follows:
Do not follow branch process (normal operation):

Start - > leave application - > leader approval - > approved (assigned audit = = 1) - > end

Branch process (circulation operation):

Start - > leave application - > leader approval - > approval failed (assigned audit = = 0) - > leave application - > leader approval - > approved (assigned audit = = 1) - > leave application - >

After the first assignment of audit, continue to usetaskService.complete(taskId,variables);Assignment cannot change the value of audit.

Terms of settlement

Before calling complete, thesetVariableAssignment

taskService.setVariable(taskId,"audit",audit);

The reason lies inact_ru_variableTable. After assigning audit to the process for the first time, activiti thinks that this is a variable in the process. It will be saved in theact_ru_variableTable, because the corresponding field already exists in the database, it will be used latertaskService.complete(taskId,variables);Cannot change value, onlysetVariable