Commit dc6cc0f1 by naan1993

增加查看流程图功能

parent ce094079
......@@ -3,6 +3,7 @@ package com.stylefeng.guns.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.stylefeng.guns.config.properties.GunsFlowableProperties;
import com.stylefeng.guns.core.datasource.DruidProperties;
import com.stylefeng.guns.core.flowable.GunsDefaultProcessDiagramGenerator;
import org.flowable.spring.SpringAsyncExecutor;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.AbstractProcessEngineAutoConfiguration;
......@@ -43,6 +44,10 @@ public class FlowableConfig extends AbstractProcessEngineAutoConfiguration {
PlatformTransactionManager transactionManager,
SpringAsyncExecutor springAsyncExecutor) throws IOException {
return this.baseSpringProcessEngineConfiguration(flowableDataSource(), transactionManager, springAsyncExecutor);
SpringProcessEngineConfiguration configuration = this.baseSpringProcessEngineConfiguration(flowableDataSource(), transactionManager, springAsyncExecutor);
configuration.setActivityFontName("宋体");
configuration.setLabelFontName("宋体");
configuration.setProcessDiagramGenerator(new GunsDefaultProcessDiagramGenerator());
return configuration;
}
}
......@@ -3,20 +3,17 @@ package com.stylefeng.guns.modular.flowable.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.common.persistence.model.Expense;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.modular.flowable.service.IExpenseService;
import com.stylefeng.guns.modular.flowable.warpper.ExpenseWarpper;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -35,12 +32,6 @@ public class ExpenseController extends BaseController {
@Autowired
private IExpenseService expenseService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
/**
* 跳转到报销管理首页
*/
......@@ -58,14 +49,15 @@ public class ExpenseController extends BaseController {
}
/**
* 跳转到修改报销管理
* 查看当前流程图
*/
@RequestMapping("/expense_update/{expenseId}")
public String expenseUpdate(@PathVariable Integer expenseId, Model model) {
Expense expense = expenseService.selectById(expenseId);
model.addAttribute("item", expense);
LogObjectHolder.me().set(expense);
return PREFIX + "expense_edit.html";
public void expenseView(@PathVariable Integer expenseId) {
try {
expenseService.printProcessImage(expenseId);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.service.IService;
import com.stylefeng.guns.common.persistence.model.Expense;
import com.stylefeng.guns.modular.flowable.model.TaskVo;
import java.io.IOException;
import java.util.List;
/**
......@@ -41,4 +42,9 @@ public interface IExpenseService extends IService<Expense> {
*/
List<TaskVo> getProcessList();
/**
* 绘画当前流程图
*/
void printProcessImage(Integer expenseId) throws IOException;
}
......@@ -7,16 +7,22 @@ import com.stylefeng.guns.common.constant.state.ExpenseState;
import com.stylefeng.guns.common.persistence.dao.ExpenseMapper;
import com.stylefeng.guns.common.persistence.model.Expense;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.support.HttpKit;
import com.stylefeng.guns.modular.flowable.model.TaskVo;
import com.stylefeng.guns.modular.flowable.service.IExpenseService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
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.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -38,6 +44,12 @@ public class ExpenseServiceImpl extends ServiceImpl<ExpenseMapper, Expense> impl
@Autowired
private TaskService taskService;
@Autowired
private RepositoryService repositoryService;
@Autowired
private ProcessEngine processEngine;
@Override
@Transactional(rollbackFor = Exception.class)
public void add(Expense expense) {
......@@ -127,4 +139,50 @@ public class ExpenseServiceImpl extends ServiceImpl<ExpenseMapper, Expense> impl
}
return taskVos;
}
@Override
public void printProcessImage(Integer expenseId) throws IOException {
Expense expense = this.selectById(expenseId);
String processId = expense.getProcessId();
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
//使用流程实例ID,查询正在执行的执行对象表,返回流程实例对象
String InstanceId = task.getProcessInstanceId();
List<Execution> executions = runtimeService
.createExecutionQuery()
.processInstanceId(InstanceId)
.list();
//得到正在执行的Activity的Id
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);
OutputStream out = null;
byte[] buf = new byte[1024];
int legth = 0;
try {
out = HttpKit.getResponse().getOutputStream();
while ((legth = in.read(buf)) != -1) {
out.write(buf, 0, legth);
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal">
<input type="hidden" id="id" value="${item.id}">
<div class="row">
<div class="col-sm-12">
<#input id="money" name="报销金额" value="${item.money}" disabled="disabled"/>
<#input id="desc" name="描述" value="${item.desc}" disabled="disabled"/>
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="ExpenseInfoDlg.close()"/>
</div>
</div>
</div>
</div>
</div>
<script src="${ctxPath}/static/modular/flowable/expense/expense_info.js"></script>
@}
......@@ -29,13 +29,13 @@ Expense.initColumn = function () {
};
/**
* 查看审核记录
* 流程详情
*/
Expense.findRecord = function (id) {
var index = layer.open({
type: 2,
title: '报销管理详情',
area: ['600px', '350px'], //宽高
title: '流程详情',
area: ['1000px', '500px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/expense/expense_update/' + id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment