Commit 3d08514e by naan1993

增加审批流程管理

parent 5e6533a4
package com.stylefeng.guns.common.constant.state;
/**
* 是否是菜单的枚举
*
* @author fengshuonan
* @date 2017年6月1日22:50:11
*/
public enum ExpenseState {
SUBMITING(1, "待提交"),
CHECKING(2, "待审核"),
PASS(3, "审核通过"),
UN_PASS(4, "未通过");
int code;
String message;
ExpenseState(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static String valueOf(Integer status) {
if (status == null) {
return "";
} else {
for (ExpenseState s : ExpenseState.values()) {
if (s.getCode() == status) {
return s.getMessage();
}
}
return "";
}
}
}
package com.stylefeng.guns.common.persistence.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.stylefeng.guns.common.persistence.model.Expense;
/**
* <p>
* 报销表 Mapper 接口
* </p>
*
* @author stylefeng
* @since 2017-12-04
*/
public interface ExpenseMapper extends BaseMapper<Expense> {
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stylefeng.guns.common.persistence.dao.ExpenseMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.stylefeng.guns.common.persistence.model.Expense">
<id column="id" property="id" />
<result column="money" property="money" />
<result column="desc" property="desc" />
<result column="createtime" property="createtime" />
<result column="state" property="state" />
<result column="userid" property="userid" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, money, desc, createtime, state, userid
</sql>
</mapper>
package com.stylefeng.guns.common.persistence.model;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
* 报销表
* </p>
*
* @author stylefeng
* @since 2017-12-05
*/
public class Expense extends Model<Expense> {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
private Integer id;
/**
* 报销金额
*/
private BigDecimal money;
/**
* 描述
*/
private String desc;
private Date createtime;
/**
* 状态: 1.待提交 2:待审核 3.审核通过
*/
private Integer state;
/**
* 用户id
*/
private Integer userid;
/**
* 流程定义id
*/
private String processId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public BigDecimal getMoney() {
return money;
}
public void setMoney(BigDecimal money) {
this.money = money;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public Integer getUserid() {
return userid;
}
public void setUserid(Integer userid) {
this.userid = userid;
}
public String getProcessId() {
return processId;
}
public void setProcessId(String processId) {
this.processId = processId;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "Expense{" +
"id=" + id +
", money=" + money +
", desc=" + desc +
", createtime=" + createtime +
", state=" + state +
", userid=" + userid +
", processId=" + processId +
"}";
}
}
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.util.List;
import java.util.Map;
/**
* 报销管理控制器
*
* @author fengshuonan
* @Date 2017-12-04 21:11:36
*/
@Controller
@RequestMapping("/expense")
public class ExpenseController extends BaseController {
private String PREFIX = "/flowable/expense/";
@Autowired
private IExpenseService expenseService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
/**
* 跳转到报销管理首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "expense.html";
}
/**
* 跳转到添加报销管理
*/
@RequestMapping("/expense_add")
public String expenseAdd() {
return PREFIX + "expense_add.html";
}
/**
* 跳转到修改报销管理
*/
@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";
}
/**
* 获取报销管理列表
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String condition) {
EntityWrapper<Expense> expenseEntityWrapper = new EntityWrapper<>();
expenseEntityWrapper.eq("userid", ShiroKit.getUser().getId());
List<Map<String, Object>> stringObjectMap = expenseService.selectMaps(expenseEntityWrapper);
return super.warpObject(new ExpenseWarpper(stringObjectMap));
}
/**
* 新增报销管理
*/
@RequestMapping(value = "/add")
@ResponseBody
public Object add(Expense expense) {
expenseService.add(expense);
return super.SUCCESS_TIP;
}
/**
* 删除报销管理
*/
@RequestMapping(value = "/delete")
@ResponseBody
public Object delete(@RequestParam Integer expenseId) {
expenseService.delete(expenseId);
return SUCCESS_TIP;
}
/**
* 修改报销管理
*/
@RequestMapping(value = "/update")
@ResponseBody
public Object update(Expense expense) {
expenseService.updateById(expense);
return super.SUCCESS_TIP;
}
/**
* 报销管理详情
*/
@RequestMapping(value = "/detail/{expenseId}")
@ResponseBody
public Object detail(@PathVariable("expenseId") Integer expenseId) {
return expenseService.selectById(expenseId);
}
}
package com.stylefeng.guns.modular.flowable.controller;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.flowable.service.IExpenseService;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 审批管理控制器
*
* @author fengshuonan
* @Date 2017-12-04 21:11:36
*/
@Controller
@RequestMapping("/process")
public class ProcessController extends BaseController {
private String PREFIX = "/flowable/process/";
@Autowired
private IExpenseService expenseService;
@Autowired
private TaskService taskService;
@Autowired
private RuntimeService runtimeService;
/**
* 跳转到审批管理首页
*/
@RequestMapping("")
public String index() {
return PREFIX + "process.html";
}
/**
* 获取审批管理列表
*/
@RequestMapping(value = "/list")
@ResponseBody
public Object list(String condition) {
return expenseService.getProcessList();
}
/**
* 审核通过
*/
@RequestMapping(value = "/pass")
@ResponseBody
public Object pass(String taskId) {
expenseService.pass(taskId);
return super.SUCCESS_TIP;
}
/**
* 审核不通过
*/
@RequestMapping(value = "/unPass")
@ResponseBody
public Object unPass(String taskId) {
expenseService.unPass(taskId);
return super.SUCCESS_TIP;
}
}
package com.stylefeng.guns.modular.flowable.handler;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
/**
* 员工经理任务分配
*/
public class BossTaskHandler implements TaskListener {
@Override
public void notify(DelegateTask delegateTask) {
delegateTask.setAssignee("老板");
}
}
package com.stylefeng.guns.modular.flowable.handler; package com.stylefeng.guns.modular.flowable.handler;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import org.flowable.engine.delegate.TaskListener; import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
...@@ -12,20 +10,7 @@ public class ManagerTaskHandler implements TaskListener { ...@@ -12,20 +10,7 @@ public class ManagerTaskHandler implements TaskListener {
@Override @Override
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
/** delegateTask.setAssignee("经理");
* 获取当前用户
*/
ShiroUser user = ShiroKit.getUser();
/**
* 获取当前用户的上一级领导
*/
Integer deptId = user.getDeptId();
/**
* 设置个人任务的办理人
*/
delegateTask.setAssignee("");
} }
} }
package com.stylefeng.guns.modular.flowable.model;
import java.util.Date;
/**
* 任务列表vo
*
* @author fengshuonan
* @date 2017-12-04 23:18
*/
public class TaskVo {
private String id;
private String name;
private Date createTime;
private String assignee;
private Object money;
private Boolean selfFlag;
public TaskVo() {
}
public TaskVo(String id, String name, Date createTime, String assignee, Object money, Boolean flag) {
this.id = id;
this.name = name;
this.createTime = createTime;
this.assignee = assignee;
this.money = money;
this.selfFlag = flag;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getAssignee() {
return assignee;
}
public void setAssignee(String assignee) {
this.assignee = assignee;
}
public Object getMoney() {
return money;
}
public void setMoney(Object money) {
this.money = money;
}
public Boolean getSelfFlag() {
return selfFlag;
}
public void setSelfFlag(Boolean selfFlag) {
this.selfFlag = selfFlag;
}
}
package com.stylefeng.guns.modular.flowable.service;
import com.baomidou.mybatisplus.service.IService;
import com.stylefeng.guns.common.persistence.model.Expense;
import com.stylefeng.guns.modular.flowable.model.TaskVo;
import java.util.List;
/**
* <p>
* 报销表 服务类
* </p>
*
* @author stylefeng
* @since 2017-12-04
*/
public interface IExpenseService extends IService<Expense> {
/**
* 新增一个报销单
*/
void add(Expense expense);
/**
* 删除一个报销单
*/
void delete(Integer expenseId);
/**
* 通过审批
*/
void pass(String taskId);
/**
* 通过审批
*/
void unPass(String taskId);
/**
* 获取审批列表
*/
List<TaskVo> getProcessList();
}
package com.stylefeng.guns.modular.flowable.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
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.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.engine.runtime.ProcessInstance;
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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* 报销表 服务实现类
* </p>
*
* @author stylefeng
* @since 2017-12-04
*/
@Service
public class ExpenseServiceImpl extends ServiceImpl<ExpenseMapper, Expense> implements IExpenseService {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Override
@Transactional(rollbackFor = Exception.class)
public void add(Expense expense) {
//保存业务数据
expense.setUserid(ShiroKit.getUser().getId());
expense.setState(ExpenseState.SUBMITING.getCode());
//启动流程
HashMap<String, Object> map = new HashMap<>();
map.put("taskUser", ShiroKit.getUser().getName());
map.put("money", expense.getMoney());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Expense", map);
expense.setProcessId(processInstance.getId());
this.insert(expense);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Integer expenseId) {
Expense expense = this.selectById(expenseId);
List<ProcessInstance> list = runtimeService.createProcessInstanceQuery().processInstanceId(expense.getProcessId()).list();
for (ProcessInstance processInstance : list) {
if (processInstance.getId().equals(expense.getProcessId())) {
runtimeService.deleteProcessInstance(processInstance.getProcessInstanceId(), "取消报销");
}
}
this.deleteById(expenseId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void pass(String taskId) {
//使用任务ID,查询任务对象,获取流程流程实例ID
Task task = taskService.createTaskQuery()//
.taskId(taskId)
.singleResult();
//通过审核
HashMap<String, Object> map = new HashMap<>();
map.put("outcome", "通过");
taskService.complete(taskId, map);
//判断流程是否结束,结束之后修改状态
ProcessInstance pi = runtimeService.createProcessInstanceQuery()//
.processInstanceId(task.getProcessInstanceId())//使用流程实例ID查询
.singleResult();
Wrapper<Expense> wrapper = new EntityWrapper<Expense>().eq("processId", task.getProcessInstanceId());
Expense expense = this.selectOne(wrapper);
//审核通过修改为通过状态
if (pi == null) {
expense.setState(ExpenseState.PASS.getCode());
expense.updateById();
} else {
//审核通过如果还有记录则为经理或boss审核中
expense.setState(ExpenseState.CHECKING.getCode());
expense.updateById();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void unPass(String taskId) {
HashMap<String, Object> map = new HashMap<>();
map.put("outcome", "驳回");
taskService.complete(taskId, map);
}
@Override
public List<TaskVo> getProcessList() {
String name = ShiroKit.getUser().getName();
List<Task> list = taskService.createTaskQuery()
.taskAssignee(name)
.orderByTaskCreateTime().desc()
.list();
ArrayList<TaskVo> taskVos = new ArrayList<>();
for (Task task : list) {
Object money = runtimeService.getVariable(task.getExecutionId(), "money");
String taskUser = (String) taskService.getVariable(task.getId(), "taskUser");
boolean flag = false;
if (name.equals(taskUser)) {
flag = false;
} else {
flag = true;
}
taskVos.add(new TaskVo(task.getId(), task.getName(), task.getCreateTime(), taskUser, money, flag));
}
return taskVos;
}
}
package com.stylefeng.guns.modular.flowable.warpper;
import com.stylefeng.guns.common.constant.state.ExpenseState;
import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import java.util.Map;
/**
* 报销列表的包装
*
* @author fengshuonan
* @date 2017年12月4日21:56:06
*/
public class ExpenseWarpper extends BaseControllerWarpper {
public ExpenseWarpper(Object list) {
super(list);
}
@Override
public void warpTheMap(Map<String, Object> map) {
Integer state = (Integer) map.get("state");
map.put("stateName", ExpenseState.valueOf(state));
}
}
...@@ -59,18 +59,18 @@ public class GunsGeneratorConfig extends AbstractGeneratorConfig { ...@@ -59,18 +59,18 @@ public class GunsGeneratorConfig extends AbstractGeneratorConfig {
* mybatis-plus 生成器开关 * mybatis-plus 生成器开关
*/ */
contextConfig.setEntitySwitch(true); contextConfig.setEntitySwitch(true);
contextConfig.setDaoSwitch(true); contextConfig.setDaoSwitch(false);
contextConfig.setServiceSwitch(true); contextConfig.setServiceSwitch(false);
/** /**
* guns 生成器开关 * guns 生成器开关
*/ */
contextConfig.setControllerSwitch(true); contextConfig.setControllerSwitch(false);
contextConfig.setIndexPageSwitch(true); contextConfig.setIndexPageSwitch(false);
contextConfig.setAddPageSwitch(true); contextConfig.setAddPageSwitch(false);
contextConfig.setEditPageSwitch(true); contextConfig.setEditPageSwitch(false);
contextConfig.setJsSwitch(true); contextConfig.setJsSwitch(false);
contextConfig.setInfoJsSwitch(true); contextConfig.setInfoJsSwitch(false);
contextConfig.setSqlSwitch(true); contextConfig.setSqlSwitch(false);
} }
} }
...@@ -15,7 +15,7 @@ guns: ...@@ -15,7 +15,7 @@ guns:
################### 项目启动端口 ################### ################### 项目启动端口 ###################
server: server:
port: 8080 port: 80
################### beetl配置 ################### ################### beetl配置 ###################
beetl: beetl:
...@@ -61,7 +61,7 @@ mybatis-plus: ...@@ -61,7 +61,7 @@ mybatis-plus:
db-column-underline: false db-column-underline: false
refresh-mapper: true refresh-mapper: true
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: false
cache-enabled: true #配置的缓存的全局开关 cache-enabled: true #配置的缓存的全局开关
lazyLoadingEnabled: true #延时加载的开关 lazyLoadingEnabled: true #延时加载的开关
multipleResultSetsEnabled: true #开启的话,延时加载一个属性时会加载该对象全部属性,否则按需加载属性 multipleResultSetsEnabled: true #开启的话,延时加载一个属性时会加载该对象全部属性,否则按需加载属性
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</userTask> </userTask>
<userTask id="bossTask" name="老板审批"> <userTask id="bossTask" name="老板审批">
<extensionElements> <extensionElements>
<flowable:taskListener event="create" class="com.stylefeng.guns.modular.flowable.handler.ManagerTaskHandler"></flowable:taskListener> <flowable:taskListener event="create" class="com.stylefeng.guns.modular.flowable.handler.BossTaskHandler"></flowable:taskListener>
</extensionElements> </extensionElements>
</userTask> </userTask>
<endEvent id="end" name="结束"></endEvent> <endEvent id="end" name="结束"></endEvent>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<sequenceFlow id="flow1" sourceRef="start" targetRef="fillTask"></sequenceFlow> <sequenceFlow id="flow1" sourceRef="start" targetRef="fillTask"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="fillTask" targetRef="judgeTask"></sequenceFlow> <sequenceFlow id="flow2" sourceRef="fillTask" targetRef="judgeTask"></sequenceFlow>
<sequenceFlow id="judgeMore" name="大于500元" sourceRef="judgeTask" targetRef="bossTask"> <sequenceFlow id="judgeMore" name="大于500元" sourceRef="judgeTask" targetRef="bossTask">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${money}>500]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money > 500}]]></conditionExpression>
</sequenceFlow> </sequenceFlow>
<sequenceFlow id="bossPassFlow" name="通过" sourceRef="bossTask" targetRef="end"> <sequenceFlow id="bossPassFlow" name="通过" sourceRef="bossTask" targetRef="end">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression>
</sequenceFlow> </sequenceFlow>
<sequenceFlow id="judgeLess" name="小于500元" sourceRef="judgeTask" targetRef="directorTak"> <sequenceFlow id="judgeLess" name="小于500元" sourceRef="judgeTask" targetRef="directorTak">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${money}<=500]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money <= 500}]]></conditionExpression>
</sequenceFlow> </sequenceFlow>
</process> </process>
<bpmndi:BPMNDiagram id="BPMNDiagram_Expense"> <bpmndi:BPMNDiagram id="BPMNDiagram_Expense">
......
@layout("/common/_container.html"){
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>报销管理管理</h5>
</div>
<div class="ibox-content">
<div class="row row-lg">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<#NameCon id="condition" name="名称" />
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="Expense.search()"/>
</div>
</div>
<div class="hidden-xs" id="ExpenseTableToolbar" role="group">
<#button name="新增报销单" icon="fa-plus" clickFun="Expense.openAddExpense()"/>
</div>
<#table id="ExpenseTable"/>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="${ctxPath}/static/modular/flowable/expense/expense.js"></script>
@}
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal">
<input type="hidden" id="id" value="">
<div class="row">
<div class="col-sm-12">
<#input id="money" name="报销金额" underline="true"/>
<#input id="desc" name="描述"/>
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-12">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="ExpenseInfoDlg.addSubmit()"/>
<#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>
@}
@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}"/>
<#input id="desc" name="描述" value="${item.desc}" />
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="ExpenseInfoDlg.editSubmit()"/>
<#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>
@}
@layout("/common/_container.html"){
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>报销管理管理</h5>
</div>
<div class="ibox-content">
<div class="row row-lg">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<#NameCon id="condition" name="名称" />
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="Process.search()"/>
</div>
</div>
<#table id="ProcessTable"/>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="${ctxPath}/static/modular/flowable/process/process.js"></script>
@}
/**
* 报销管理管理初始化
*/
var Expense = {
id: "ExpenseTable", //表格id
seItem: null, //选中的条目
table: null,
layerIndex: -1
};
/**
* 初始化表格的列
*/
Expense.initColumn = function () {
return [
{field: 'selectItem', radio: true},
{title: '报销id', field: 'id', visible: true, align: 'center', valign: 'middle'},
{title: '报销金额', field: 'money', visible: true, align: 'center', valign: 'middle'},
{title: '描述', field: 'desc', visible: true, align: 'center', valign: 'middle'},
{title: '状态', field: 'stateName', visible: true, align: 'center', valign: 'middle'},
{title: '创建时间', field: 'createtime', visible: true, align: 'center', valign: 'middle'},
{
title: '操作', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) {
return '<button type="button" class="btn btn-primary button-margin" onclick="Expense.findRecord(' + row.id + ')" id=""><i class="fa fa-edit"></i>&nbsp;查看</button>' +
'<button type="button" class="btn btn-danger button-margin" onclick="Expense.deleteRecord(' + row.id + ')" id=""><i class="fa fa-arrows-alt"></i>&nbsp;删除</button>';
}
}
];
};
/**
* 查看审核记录
*/
Expense.findRecord = function (id) {
var index = layer.open({
type: 2,
title: '报销管理详情',
area: ['600px', '350px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/expense/expense_update/' + id
});
this.layerIndex = index;
};
/**
* 删除审核记录
*/
Expense.deleteRecord = function (id) {
var ajax = new $ax(Feng.ctxPath + "/expense/delete", function (data) {
Feng.success("删除成功!");
Expense.table.refresh();
}, function (data) {
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("expenseId", id);
ajax.start();
};
/**
* 点击添加报销管理
*/
Expense.openAddExpense = function () {
var index = layer.open({
type: 2,
title: '添加报销管理',
area: ['600px', '350px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/expense/expense_add'
});
this.layerIndex = index;
};
/**
* 查询报销管理列表
*/
Expense.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
Expense.table.refresh({query: queryData});
};
$(function () {
var defaultColunms = Expense.initColumn();
var table = new BSTable(Expense.id, "/expense/list", defaultColunms);
table.setPaginationType("client");
Expense.table = table.init();
});
/**
* 初始化报销管理详情对话框
*/
var ExpenseInfoDlg = {
expenseInfoData : {}
};
/**
* 清除数据
*/
ExpenseInfoDlg.clearData = function() {
this.expenseInfoData = {};
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
ExpenseInfoDlg.set = function(key, val) {
this.expenseInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
ExpenseInfoDlg.get = function(key) {
return $("#" + key).val();
}
/**
* 关闭此对话框
*/
ExpenseInfoDlg.close = function() {
parent.layer.close(window.parent.Expense.layerIndex);
}
/**
* 收集数据
*/
ExpenseInfoDlg.collectData = function() {
this
.set('id')
.set('money')
.set('desc')
;
}
/**
* 提交添加
*/
ExpenseInfoDlg.addSubmit = function() {
this.clearData();
this.collectData();
//提交信息
var ajax = new $ax(Feng.ctxPath + "/expense/add", function(data){
Feng.success("添加成功!");
window.parent.Expense.table.refresh();
ExpenseInfoDlg.close();
},function(data){
Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(this.expenseInfoData);
ajax.start();
}
/**
* 提交修改
*/
ExpenseInfoDlg.editSubmit = function() {
this.clearData();
this.collectData();
//提交信息
var ajax = new $ax(Feng.ctxPath + "/expense/update", function(data){
Feng.success("修改成功!");
window.parent.Expense.table.refresh();
ExpenseInfoDlg.close();
},function(data){
Feng.error("修改失败!" + data.responseJSON.message + "!");
});
ajax.set(this.expenseInfoData);
ajax.start();
}
$(function() {
});
/**
* 报销管理管理初始化
*/
var Process = {
id: "ProcessTable", //表格id
seItem: null, //选中的条目
table: null,
layerIndex: -1
};
/**
* 初始化表格的列
*/
Process.initColumn = function () {
return [
{field: 'selectItem', radio: true},
{title: '任务id', field: 'id', visible: true, align: 'center', valign: 'middle'},
{title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
{title: '金额', field: 'money', visible: true, align: 'center', valign: 'middle'},
{title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
{title: '申请人', field: 'assignee', visible: true, align: 'center', valign: 'middle'},
{
title: '操作', visible: true, align: 'center', valign: 'middle', formatter: function (value, row, index) {
if (row.selfFlag == true) {
return '<button type="button" class="btn btn-primary button-margin" onclick="Process.pass(' + row.id + ')" id=""><i class="fa fa-edit"></i>&nbsp;通过</button>' +
'<button type="button" class="btn btn-danger button-margin" onclick="Process.unPass(' + row.id + ')" id=""><i class="fa fa-arrows-alt"></i>&nbsp;不通过</button>';
} else {
return '<button type="button" class="btn btn-primary button-margin" onclick="Process.pass(' + row.id + ')" id=""><i class="fa fa-edit"></i>&nbsp;通过</button>';
}
}
}
];
};
/**
* 通过审核
*/
Process.pass = function (id) {
var ajax = new $ax(Feng.ctxPath + "/process/pass", function (data) {
Feng.success("审核成功!");
Process.table.refresh();
}, function (data) {
Feng.error("审核失败!" + data.responseJSON.message + "!");
});
ajax.set("taskId", id);
ajax.start();
};
/**
* 未通过审核
*/
Process.unPass = function (id) {
var ajax = new $ax(Feng.ctxPath + "/process/unPass", function (data) {
Feng.success("审核成功!");
Process.table.refresh();
}, function (data) {
Feng.error("审核失败!" + data.responseJSON.message + "!");
});
ajax.set("taskId", id);
ajax.start();
};
/**
* 查询报销管理列表
*/
Process.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
Process.table.refresh({query: queryData});
};
$(function () {
var defaultColunms = Process.initColumn();
var table = new BSTable(Process.id, "/process/list", defaultColunms);
table.setPaginationType("client");
Process.table = table.init();
});
/**
* 初始化报销管理详情对话框
*/
var ExpenseInfoDlg = {
expenseInfoData : {}
};
/**
* 清除数据
*/
ExpenseInfoDlg.clearData = function() {
this.expenseInfoData = {};
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
ExpenseInfoDlg.set = function(key, val) {
this.expenseInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
ExpenseInfoDlg.get = function(key) {
return $("#" + key).val();
}
/**
* 关闭此对话框
*/
ExpenseInfoDlg.close = function() {
parent.layer.close(window.parent.Expense.layerIndex);
}
/**
* 收集数据
*/
ExpenseInfoDlg.collectData = function() {
this
.set('id')
.set('money')
.set('desc')
;
}
/**
* 提交添加
*/
ExpenseInfoDlg.addSubmit = function() {
this.clearData();
this.collectData();
//提交信息
var ajax = new $ax(Feng.ctxPath + "/expense/add", function(data){
Feng.success("添加成功!");
window.parent.Expense.table.refresh();
ExpenseInfoDlg.close();
},function(data){
Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(this.expenseInfoData);
ajax.start();
}
/**
* 提交修改
*/
ExpenseInfoDlg.editSubmit = function() {
this.clearData();
this.collectData();
//提交信息
var ajax = new $ax(Feng.ctxPath + "/expense/update", function(data){
Feng.success("修改成功!");
window.parent.Expense.table.refresh();
ExpenseInfoDlg.close();
},function(data){
Feng.error("修改失败!" + data.responseJSON.message + "!");
});
ajax.set(this.expenseInfoData);
ajax.start();
}
$(function() {
});
package com.stylefeng.guns.flowable; package com.stylefeng.guns.flowable;
import com.alibaba.fastjson.JSON;
import org.flowable.engine.*; import org.flowable.engine.*;
import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration; import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.Deployment;
...@@ -54,6 +55,21 @@ public class FlowableTest { ...@@ -54,6 +55,21 @@ public class FlowableTest {
} }
/** /**
* 查看发布
*/
@Test
public void findDeploy() {
RepositoryService repositoryService = processEngine.getRepositoryService();
List<Deployment> list = repositoryService.createDeploymentQuery().list();
for (Deployment deployment : list) {
System.out.println(deployment.getCategory());
System.out.println(deployment.getName());
System.out.println("deploy = " + deployment.getId());
System.out.println("key = " + deployment.getKey());
}
}
/**
* 启动流程 * 启动流程
*/ */
@Test @Test
...@@ -71,10 +87,18 @@ public class FlowableTest { ...@@ -71,10 +87,18 @@ public class FlowableTest {
*/ */
@Test @Test
public void queryProcess() { public void queryProcess() {
List<ProcessInstance> list1 = processEngine.getRuntimeService().createProcessInstanceQuery().list();
for (ProcessInstance processDefinition : list1) {
System.out.println("id = " + processDefinition.getId());
System.out.println("getDeploymentId = " + processDefinition.getDeploymentId());
System.out.println("getTenantId = " + processDefinition.getTenantId());
System.out.println("name = " + processDefinition.getName());
}
System.err.println("---------------------------------");
List<ProcessDefinition> list = processEngine.getRepositoryService() List<ProcessDefinition> list = processEngine.getRepositoryService()
.createProcessDefinitionQuery() .createProcessDefinitionQuery()
.list(); .list();
for (ProcessDefinition processDefinition : list) { for (ProcessDefinition processDefinition : list) {
System.out.println("id = " + processDefinition.getId()); System.out.println("id = " + processDefinition.getId());
System.out.println("getDeploymentId = " + processDefinition.getDeploymentId()); System.out.println("getDeploymentId = " + processDefinition.getDeploymentId());
...@@ -91,7 +115,8 @@ public class FlowableTest { ...@@ -91,7 +115,8 @@ public class FlowableTest {
*/ */
@Test @Test
public void delProcess() { public void delProcess() {
processEngine.getRepositoryService().deleteDeployment("1", true); processEngine.getRuntimeService().deleteProcessInstance("67501","abcd");
//processEngine.getRepositoryService().deleteDeployment("25001", true);
System.out.println("删除成功"); System.out.println("删除成功");
} }
...@@ -100,17 +125,29 @@ public class FlowableTest { ...@@ -100,17 +125,29 @@ public class FlowableTest {
*/ */
@Test @Test
public void queryMyTask() { public void queryMyTask() {
String name = "fsn"; String name = "张三";
TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery().taskAssignee(name); TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery().taskAssignee(name);
List<Task> list = taskQuery.list(); List<Task> list = taskQuery.list();
for (Task task : list) { for (Task task : list) {
System.out.println("name = " + task.getName()); System.out.println("name = " + task.getName());
System.out.println(JSON.toJSON(task.getTaskLocalVariables()));
} }
System.out.println("查询完毕!"); System.out.println("查询完毕!");
} }
/**
* 完成任务
*/
@Test
public void complete() {
HashMap<String, Object> map = new HashMap<>();
map.put("money", 600);
TaskService taskService = processEngine.getTaskService();
taskService.complete("47513", map);
}
public static void main(String[] args) { public static void main(String[] args) {
ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration() ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()
.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/flowable?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull") .setJdbcUrl("jdbc:mysql://127.0.0.1:3306/flowable?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull")
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</userTask> </userTask>
<userTask id="bossTask" name="老板审批"> <userTask id="bossTask" name="老板审批">
<extensionElements> <extensionElements>
<flowable:taskListener event="create" class="com.stylefeng.guns.modular.flowable.handler.ManagerTaskHandler"></flowable:taskListener> <flowable:taskListener event="create" class="com.stylefeng.guns.modular.flowable.handler.BossTaskHandler"></flowable:taskListener>
</extensionElements> </extensionElements>
</userTask> </userTask>
<endEvent id="end" name="结束"></endEvent> <endEvent id="end" name="结束"></endEvent>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<sequenceFlow id="flow1" sourceRef="start" targetRef="fillTask"></sequenceFlow> <sequenceFlow id="flow1" sourceRef="start" targetRef="fillTask"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="fillTask" targetRef="judgeTask"></sequenceFlow> <sequenceFlow id="flow2" sourceRef="fillTask" targetRef="judgeTask"></sequenceFlow>
<sequenceFlow id="judgeMore" name="大于500元" sourceRef="judgeTask" targetRef="bossTask"> <sequenceFlow id="judgeMore" name="大于500元" sourceRef="judgeTask" targetRef="bossTask">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${money}>500]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money > 500}]]></conditionExpression>
</sequenceFlow> </sequenceFlow>
<sequenceFlow id="bossPassFlow" name="通过" sourceRef="bossTask" targetRef="end"> <sequenceFlow id="bossPassFlow" name="通过" sourceRef="bossTask" targetRef="end">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${outcome=='通过'}]]></conditionExpression>
</sequenceFlow> </sequenceFlow>
<sequenceFlow id="judgeLess" name="小于500元" sourceRef="judgeTask" targetRef="directorTak"> <sequenceFlow id="judgeLess" name="小于500元" sourceRef="judgeTask" targetRef="directorTak">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${money}<=500]]></conditionExpression> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${money <= 500}]]></conditionExpression>
</sequenceFlow> </sequenceFlow>
</process> </process>
<bpmndi:BPMNDiagram id="BPMNDiagram_Expense"> <bpmndi:BPMNDiagram id="BPMNDiagram_Expense">
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<mybatisplus-spring-boot-starter.version>1.0.4</mybatisplus-spring-boot-starter.version> <mybatisplus-spring-boot-starter.version>1.0.4</mybatisplus-spring-boot-starter.version>
<shiro.version>1.4.0</shiro.version> <shiro.version>1.4.0</shiro.version>
<mybatis-plus.version>2.1.0</mybatis-plus.version> <mybatis-plus.version>2.1.0</mybatis-plus.version>
<fastjson.version>1.2.31</fastjson.version> <fastjson.version>1.2.41</fastjson.version>
<commons.io.version>2.5</commons.io.version> <commons.io.version>2.5</commons.io.version>
<velocity.version>1.7</velocity.version> <velocity.version>1.7</velocity.version>
<kaptcha.version>2.3.2</kaptcha.version> <kaptcha.version>2.3.2</kaptcha.version>
......
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