Flowable工作流部署到服务器生成流程图中文乱码

配置字体文件

package com.sziov.gacnev.flowable.config;

import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springframework.context.annotation.Configuration;

/**
 * Flowable配置
 */
@Configuration
public class FlowableConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {

    @Override
    public void configure(SpringProcessEngineConfiguration engineConfiguration) {
        engineConfiguration.setActivityFontName("宋体");
        engineConfiguration.setLabelFontName("宋体");
        engineConfiguration.setAnnotationFontName("宋体");
    }
}

生成流程图代码

package com.sziov.gacnev.flowable.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.engine.*;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.image.ProcessDiagramGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;


/**
 * 工作流流程实例管理
 * @author pwl
 */
@RestController
@RequestMapping("/v1")
@Slf4j
@Api(value = "工作流流程实例管理", description = "工作流流程实例管理")
public class FlowInstanceController {
    
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    ProcessEngine processEngine;
    @Autowired
    HistoryService historyService;
    @Autowired
    RepositoryService repositoryService;

    @ApiOperation(value = "流程实例图")
    @GetMapping("/public/instance/pic")
    public void showPic(HttpServletResponse resp, String processId) throws Exception {
        ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
        if (pi == null) {
            return;
        }
        List<Execution> executions = runtimeService
                .createExecutionQuery()
                .processInstanceId(processId)
                .list();

        List<String> activityIds = new ArrayList<>();
        List<String> flows = new ArrayList<>();
        for (Execution exe : executions) {
            List<String> ids = runtimeService.getActiveActivityIds(exe.getId());
            activityIds.addAll(ids);
        }

        /**
         * 生成流程图
         */
        BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId());
        ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
        ProcessDiagramGenerator diagramGenerator = engconf.getProcessDiagramGenerator();
        InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", activityIds, flows, engconf.getActivityFontName(), engconf.getLabelFontName(), engconf.getAnnotationFontName(), engconf.getClassLoader(), 1.0, false);
        OutputStream out = null;
        byte[] buf = new byte[1024];
        int legth = 0;
        try {
            out = resp.getOutputStream();
            while ((legth = in.read(buf)) != -1) {
                out.write(buf, 0, legth);
            }
        } finally {
            if (in != null) {
                in.close();
            }
            if (out != null) {
                out.close();
            }
        }
    }

}

获取中文字体

字体包这边已经为大家准备好了
链接:https://pan.baidu.com/s/1eF_VflVDkk-zLbcbuIdXbA
提取码:pwly

上传到服务器目录:/usr/share/fonts 下

在这里插入图片描述

使用unzip windowsFonts.zip 命令解压字体包

在这里插入图片描述

使用cd windowsFonts 进入目录下

在这里插入图片描述

使用 fc-cache -fv 命令安装字体,查看字体是否安装成功 fc-list 命令

在这里插入图片描述

重启java流程图接口所在的服务,再页面访问发现中文不再乱码了
在这里插入图片描述

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Flowable是一个开源的工作流引擎,它提供了一套完整的工作流管理解决方案。下面是Flowable工作流完成流程的简要介绍: 1. 建模:首先,你需要使用Flowable提供的建模工具(如Flowable Modeler)来设计和建立你的工作流模型。在建模过程中,你可以定义流程中的各个环节、任务、条件等。 2. 部署:完成建模后,你需要将工作流模型部署Flowable引擎中。部署过程会将模型转化为可执行的流程定义,并将其存储在Flowable引擎的数据库中。 3. 启动流程实例:一旦流程定义被部署,你可以通过调用Flowable API来启动一个流程实例。流程实例代表了一个具体的工作流程,它会根据流程定义中的规则和条件进行执行。 4. 执行任务:在流程实例运行过程中,各个环节的任务会被分配给相应的参与者。参与者可以通过Flowable提供的任务管理API来查看和执行自己的任务。 5. 流程控制:Flowable支持各种类型的流程控制,如并行网关、条件网关等。这些控制节点可以根据流程中的条件和规则来决定流程的走向。 6. 监控和管理:Flowable提供了丰富的监控和管理功能,可以帮助你实时监控流程的执行情况、查看流程历史记录、进行性能优化等。 总的来说,Flowable工作流通过建模、部署、启动流程实例、执行任务、流程控制以及监控和管理等步骤,实现了一个完整的工作流程。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值