Backend Development 10 min read

Optimizing Legal Template Contract Workflow with OA System and Activiti

This article describes how a corporate legal department streamlined contract handling by abstracting template contracts into an OA-based online process, reusing common approval nodes, leveraging a configuration center for validation, and implementing a generic validator with sample Java code, resulting in reduced workload and improved user experience.

转转QA
转转QA
转转QA
Optimizing Legal Template Contract Workflow with OA System and Activiti

Problem Background

The legal department of an enterprise is responsible for handling contracts, and as the company grows, the number and complexity of contracts (e.g., labor, lease, signing agreements) increase, leading to low processing efficiency due to lengthy approval workflows and high modification costs.

Contracts are divided into template contracts (fixed content, only partial fields need filling) and non‑template contracts. The department aims to extend template‑contract capabilities to an OA system to handle filling, modification, archiving, and approval online.

Workload Optimization Ideas and Methods

The original workflow includes contract conversion, filling, and archiving review. The conversion step turns design files into PDFs; the filling step adds information such as contact phone and address; the archiving review step submits the filled contract through multiple levels of approvers before final storage.

By abstracting these steps into an OA system, conversion becomes an upload step, and the multi‑level review is modeled as an Activiti process, eliminating the need for manual hand‑offs.

However, creating a separate Activiti process for each template contract would cause a bottleneck as the number of templates grows.

To solve this, the existing dozens of templates were analyzed and grouped into five major categories, each sharing common approval nodes (e.g., finance review). Reusing these nodes allows a single generic approval flow per category, reducing the number of processes needed.

File content validation rules are externalized to an Apollo configuration center, enabling Excel data validation and selection boxes, and a generic validator checks contract data against these rules.

Example implementation of the generic validator:

public static OpResult
> checkExcelIsValidOrNot(InputStream inputStream, String templateName) throws Exception {
    Sheet sheetByStream = getSheetByStream(inputStream, "sheet1");
    StringBuilder errMsg = new StringBuilder();
    String templateData = config.getProperty(templateName, "");
    JsonNode jsonNode = JsonUtil.string2JsonNode(templateData);
    JsonNode content = jsonNode.get("content");
    HashMap
PDFNeedMap = Maps.newHashMap();
    int row = 1;
    int max = 200;
    while (row < max) {
        try {
            String keyInChn = ExcelUtil.readCell(sheetByStream, row, 1, null, "");
            String valueInChn = ExcelUtil.readCell(sheetByStream, row, 3, null, "");
            keyInChn = keyInChn.trim();
            valueInChn = valueInChn.trim();
            int lengthLimitForKey = content.get(keyInChn).asInt();
            if (StringUtils.isNotBlank(valueInChn) && valueInChn.length() <= lengthLimitForKey) {
                PDFNeedMap.put(keyInChn, valueInChn);
            } else {
                errMsg.append("字段:").append(keyInChn).append(" 填写的参数不合法.");
            }
        } catch (Exception e) {
            log.info("读取Excel结束,error: " + e);
            break;
        }
        row += 1;
    }
    String err = errMsg.toString();
    // 如果excel是合法的,那么err字符串就会是空的。
    if (StringUtils.isNotBlank(err)) {
        return OpResult.createFailResult(-1, err);
    }
    return OpResult.createSucResult(PDFNeedMap);
}

Optimizing User Experience

After the redesign, the OA legal‑template system offers an intuitive interface and clear logic, reducing cognitive load for both users and developers.

Typical user scenarios include selecting a template to download an editable PDF, filling the PDF according to Excel‑based rules, uploading the filled file for automatic validation, generating a finalized non‑editable PDF, and proceeding through the approval workflow.

Summary

The optimization abstracts and generalizes contract handling, turning N‑times work for N contracts into a single‑time process per contract, while moving validation logic to a configurable center, thus improving efficiency and code maintainability.

Future Outlook

Although the current solution still requires creating new Activiti flows for each new approval matrix, the plan is to further abstract these flows and matrices into configurable components, aiming to reduce development effort to near‑zero per new template.

backend developmentprocess optimizationWorkflow AutomationActivitiContract ManagementOA system
转转QA
Written by

转转QA

In the era of knowledge sharing, discover 转转QA from a new perspective.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.