处理提交
This commit is contained in:
21
JeeThink-workFlow/pom.xml
Normal file
21
JeeThink-workFlow/pom.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>jeethink</artifactId>
|
||||
<groupId>com.jeethink</groupId>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>jeethink-workFlow</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.jeethink</groupId>
|
||||
<artifactId>jeethink-activiti</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,152 @@
|
||||
package com.jeethink.leave.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.jeethink.common.annotation.Log;
|
||||
import com.jeethink.common.core.controller.BaseController;
|
||||
import com.jeethink.common.core.domain.AjaxResult;
|
||||
import com.jeethink.common.core.domain.entity.SysUser;
|
||||
import com.jeethink.common.core.page.TableDataInfo;
|
||||
import com.jeethink.common.enums.BusinessType;
|
||||
import com.jeethink.common.utils.SecurityUtils;
|
||||
import com.jeethink.common.utils.poi.ExcelUtil;
|
||||
import com.jeethink.leave.domain.BizLeave;
|
||||
import com.jeethink.leave.service.IBizLeaveService;
|
||||
|
||||
/**
|
||||
* 请假流程Controller
|
||||
*
|
||||
* @author jeethink
|
||||
* @date 2020-09-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/workflow/leave")
|
||||
public class BizLeaveController extends BaseController {
|
||||
@Autowired
|
||||
private IBizLeaveService bizLeaveService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询请假流程列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('workflow:leave')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(BizLeave bizLeave) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
bizLeave.setCreateBy(SecurityUtils.getUsername());
|
||||
}
|
||||
bizLeave.setType("leave");
|
||||
startPage();
|
||||
List<BizLeave> list = bizLeaveService.selectBizLeaveList(bizLeave);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 导出请假流程列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('workflow:leave')")
|
||||
@Log(title = "请假流程", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(BizLeave bizLeave) {
|
||||
bizLeave.setType("leave");
|
||||
List<BizLeave> list = bizLeaveService.selectBizLeaveList(bizLeave);
|
||||
ExcelUtil<BizLeave> util = new ExcelUtil<BizLeave>(BizLeave.class);
|
||||
return util.exportExcel(list, "leave");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请假流程详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('workflow:leave')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(bizLeaveService.selectBizLeaveById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增请假流程
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('workflow:leave')")
|
||||
@Log(title = "请假流程", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BizLeave bizLeave) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
if (SysUser.isAdmin(userId)) {
|
||||
return AjaxResult.error("提交申请失败:不允许管理员提交申请!");
|
||||
}
|
||||
bizLeave.setType("leave");
|
||||
return toAjax(bizLeaveService.insertBizLeave(bizLeave));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改请假流程
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('workflow:leave')")
|
||||
@Log(title = "请假流程", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BizLeave bizLeave) {
|
||||
return toAjax(bizLeaveService.updateBizLeave(bizLeave));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除请假流程
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('workflow:leave')")
|
||||
@Log(title = "请假流程", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(bizLeaveService.deleteBizLeaveByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交申请
|
||||
*/
|
||||
@Log(title = "请假业务", businessType = BusinessType.UPDATE)
|
||||
@PostMapping( "/submitApply/{id}")
|
||||
@ResponseBody
|
||||
public AjaxResult submitApply(@PathVariable Long id) {
|
||||
BizLeave leave = bizLeaveService.selectBizLeaveById(id);
|
||||
String applyUserId = SecurityUtils.getUsername();
|
||||
bizLeaveService.submitApply(leave, applyUserId, "leave", new HashMap<>());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的待办列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/taskList")
|
||||
@ResponseBody
|
||||
public TableDataInfo taskList(BizLeave bizLeave) {
|
||||
bizLeave.setType("leave");
|
||||
List<BizLeave> list = bizLeaveService.findTodoTasks(bizLeave, SecurityUtils.getUsername());
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的已办列表
|
||||
* @param bizLeave
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/taskDoneList")
|
||||
@ResponseBody
|
||||
public TableDataInfo taskDoneList(BizLeave bizLeave) {
|
||||
bizLeave.setType("leave");
|
||||
List<BizLeave> list = bizLeaveService.findDoneTasks(bizLeave, SecurityUtils.getUsername());
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
package com.jeethink.leave.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.jeethink.activiti.domain.ActivitiBaseEntity;
|
||||
import com.jeethink.common.annotation.Excel;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 请假流程对象 biz_leave
|
||||
*
|
||||
* @author jeethink
|
||||
* @date 2020-09-17
|
||||
*/
|
||||
public class BizLeave extends ActivitiBaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 请假类型 */
|
||||
@Excel(name = "请假类型")
|
||||
private String type;
|
||||
|
||||
|
||||
|
||||
/** 开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date leaveStartTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date leaveEndTime;
|
||||
|
||||
/** 请假时长,单位秒 */
|
||||
@Excel(name = "请假时长,单位秒")
|
||||
private Long totalTime;
|
||||
|
||||
|
||||
/** 申请人 */
|
||||
@Excel(name = "申请人")
|
||||
private String applyUser;
|
||||
|
||||
/** 申请时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date applyTime;
|
||||
|
||||
/** 实际开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "实际开始时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date realityStartTime;
|
||||
|
||||
/** 实际结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "实际结束时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date realityEndTime;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setLeaveStartTime(Date leaveStartTime)
|
||||
{
|
||||
this.leaveStartTime = leaveStartTime;
|
||||
}
|
||||
|
||||
public Date getLeaveStartTime()
|
||||
{
|
||||
return leaveStartTime;
|
||||
}
|
||||
public void setLeaveEndTime(Date leaveEndTime)
|
||||
{
|
||||
this.leaveEndTime = leaveEndTime;
|
||||
}
|
||||
|
||||
public Date getLeaveEndTime()
|
||||
{
|
||||
return leaveEndTime;
|
||||
}
|
||||
public void setTotalTime(Long totalTime)
|
||||
{
|
||||
this.totalTime = totalTime;
|
||||
}
|
||||
|
||||
public Long getTotalTime()
|
||||
{
|
||||
return totalTime;
|
||||
}
|
||||
|
||||
public void setApplyUser(String applyUser)
|
||||
{
|
||||
this.applyUser = applyUser;
|
||||
}
|
||||
|
||||
public String getApplyUser()
|
||||
{
|
||||
return applyUser;
|
||||
}
|
||||
public void setApplyTime(Date applyTime)
|
||||
{
|
||||
this.applyTime = applyTime;
|
||||
}
|
||||
|
||||
public Date getApplyTime()
|
||||
{
|
||||
return applyTime;
|
||||
}
|
||||
public void setRealityStartTime(Date realityStartTime)
|
||||
{
|
||||
this.realityStartTime = realityStartTime;
|
||||
}
|
||||
|
||||
public Date getRealityStartTime()
|
||||
{
|
||||
return realityStartTime;
|
||||
}
|
||||
public void setRealityEndTime(Date realityEndTime)
|
||||
{
|
||||
this.realityEndTime = realityEndTime;
|
||||
}
|
||||
|
||||
public Date getRealityEndTime()
|
||||
{
|
||||
return realityEndTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("type", getType())
|
||||
.append("title", getTitle())
|
||||
.append("reason", getReason())
|
||||
.append("leaveStartTime", getLeaveStartTime())
|
||||
.append("leaveEndTime", getLeaveEndTime())
|
||||
.append("totalTime", getTotalTime())
|
||||
.append("instanceId", getInstanceId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("applyUser", getApplyUser())
|
||||
.append("applyTime", getApplyTime())
|
||||
.append("realityStartTime", getRealityStartTime())
|
||||
.append("realityEndTime", getRealityEndTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.jeethink.leave.listener;
|
||||
|
||||
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeethink.leave.domain.BizLeave;
|
||||
import com.jeethink.leave.service.IBizLeaveService;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <b>监听器使用范例</b>:销假后处理器
|
||||
* <p>
|
||||
* 设置销假时间
|
||||
* </p>
|
||||
* <p>
|
||||
* 使用Spring代理,可以注入Bean,管理事物
|
||||
* </p>
|
||||
*
|
||||
* @author HenryYan
|
||||
*/
|
||||
@Component
|
||||
@Transactional
|
||||
public class ReportBackEndProcessor implements TaskListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
IBizLeaveService bizLeaveService;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.activiti.engine.delegate.TaskListener#notify(org.activiti.engine.delegate
|
||||
* .DelegateTask)
|
||||
*/
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
BizLeave leave = bizLeaveService.selectBizLeaveById(new Long(delegateTask.getExecution().getProcessInstanceBusinessKey()));
|
||||
Object realityStartTime = delegateTask.getVariable("realityStartTime");
|
||||
leave.setRealityStartTime((Date) realityStartTime);
|
||||
Object realityEndTime = delegateTask.getVariable("realityEndTime");
|
||||
leave.setRealityEndTime((Date) realityEndTime);
|
||||
bizLeaveService.updateBizLeave(leave);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.jeethink.leave.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jeethink.leave.domain.BizLeave;
|
||||
|
||||
/**
|
||||
* 请假流程Mapper接口
|
||||
*
|
||||
* @author jeethink
|
||||
* @date 2020-09-17
|
||||
*/
|
||||
public interface BizLeaveMapper
|
||||
{
|
||||
/**
|
||||
* 查询请假流程
|
||||
*
|
||||
* @param id 请假流程ID
|
||||
* @return 请假流程
|
||||
*/
|
||||
public BizLeave selectBizLeaveById(Long id);
|
||||
|
||||
/**
|
||||
* 查询请假流程列表
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 请假流程集合
|
||||
*/
|
||||
public List<BizLeave> selectBizLeaveList(BizLeave bizLeave);
|
||||
|
||||
/**
|
||||
* 新增请假流程
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBizLeave(BizLeave bizLeave);
|
||||
|
||||
/**
|
||||
* 修改请假流程
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBizLeave(BizLeave bizLeave);
|
||||
|
||||
/**
|
||||
* 删除请假流程
|
||||
*
|
||||
* @param id 请假流程ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBizLeaveById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除请假流程
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBizLeaveByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.jeethink.leave.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
|
||||
import com.jeethink.leave.domain.BizLeave;
|
||||
|
||||
/**
|
||||
* 请假流程Service接口
|
||||
*
|
||||
* @author jeethink
|
||||
* @date 2020-09-17
|
||||
*/
|
||||
public interface IBizLeaveService
|
||||
{
|
||||
/**
|
||||
* 查询请假流程
|
||||
*
|
||||
* @param id 请假流程ID
|
||||
* @return 请假流程
|
||||
*/
|
||||
public BizLeave selectBizLeaveById(Long id);
|
||||
|
||||
/**
|
||||
* 查询请假流程列表
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 请假流程集合
|
||||
*/
|
||||
public List<BizLeave> selectBizLeaveList(BizLeave bizLeave);
|
||||
|
||||
/**
|
||||
* 新增请假流程
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertBizLeave(BizLeave bizLeave);
|
||||
|
||||
/**
|
||||
* 修改请假流程
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateBizLeave(BizLeave bizLeave);
|
||||
|
||||
/**
|
||||
* 批量删除请假流程
|
||||
*
|
||||
* @param ids 需要删除的请假流程ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBizLeaveByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除请假流程信息
|
||||
*
|
||||
* @param id 请假流程ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteBizLeaveById(Long id);
|
||||
/**
|
||||
* 启动流程
|
||||
* @param entity
|
||||
* @param applyUserId
|
||||
* @return
|
||||
*/
|
||||
ProcessInstance submitApply(BizLeave entity, String applyUserId, String key, Map<String, Object> variables);
|
||||
|
||||
/**
|
||||
* 查询我的待办列表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<BizLeave> findTodoTasks(BizLeave leave, String userId);
|
||||
/**
|
||||
* 查询我的已办列表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<BizLeave> findDoneTasks(BizLeave bizLeaveVo, String userId);
|
||||
}
|
@ -0,0 +1,302 @@
|
||||
package com.jeethink.leave.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.jeethink.activiti.service.IProcessService;
|
||||
import com.jeethink.common.core.domain.entity.SysUser;
|
||||
import com.jeethink.common.core.page.PageDomain;
|
||||
import com.jeethink.common.core.page.TableSupport;
|
||||
import com.jeethink.common.utils.DateUtils;
|
||||
import com.jeethink.common.utils.SecurityUtils;
|
||||
import com.jeethink.common.utils.StringUtils;
|
||||
import com.jeethink.leave.domain.BizLeave;
|
||||
import com.jeethink.leave.mapper.BizLeaveMapper;
|
||||
import com.jeethink.leave.service.IBizLeaveService;
|
||||
import com.jeethink.system.mapper.SysUserMapper;
|
||||
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* 请假流程Service业务层处理
|
||||
*
|
||||
* @author jeethink
|
||||
* @date 2020-09-17
|
||||
*/
|
||||
@Service
|
||||
public class BizLeaveServiceImpl implements IBizLeaveService {
|
||||
@Autowired
|
||||
private BizLeaveMapper bizLeaveMapper;
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private IProcessService processService;
|
||||
@Autowired
|
||||
private RuntimeService runtimeService;
|
||||
@Autowired
|
||||
private HistoryService historyService;
|
||||
/**
|
||||
* 查询请假流程
|
||||
*
|
||||
* @param id 请假流程ID
|
||||
* @return 请假流程
|
||||
*/
|
||||
@Override
|
||||
public BizLeave selectBizLeaveById(Long id) {
|
||||
BizLeave leave = bizLeaveMapper.selectBizLeaveById(id);
|
||||
SysUser sysUser = userMapper.selectUserByUserName(leave.getApplyUser());
|
||||
if (sysUser != null) {
|
||||
leave.setApplyUserName(sysUser.getUserName());
|
||||
}
|
||||
return leave;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询请假流程列表
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 请假流程
|
||||
*/
|
||||
@Override
|
||||
public List<BizLeave> selectBizLeaveList(BizLeave bizLeave) {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
|
||||
// PageHelper 仅对第一个 List 分页
|
||||
Page<BizLeave> list = (Page<BizLeave>) bizLeaveMapper.selectBizLeaveList(bizLeave);
|
||||
Page<BizLeave> returnList = new Page<>();
|
||||
for (BizLeave leave: list) {
|
||||
SysUser sysUser = userMapper.selectUserByUserName(leave.getCreateBy());
|
||||
if (sysUser != null) {
|
||||
leave.setCreateUserName(sysUser.getUserName());
|
||||
}
|
||||
SysUser sysUser2 = userMapper.selectUserByUserName(leave.getApplyUser());
|
||||
if (sysUser2 != null) {
|
||||
leave.setApplyUserName(sysUser2.getUserName());
|
||||
}
|
||||
// 当前环节
|
||||
if (StringUtils.isNotBlank(leave.getInstanceId())) {
|
||||
List<Task> taskList = taskService.createTaskQuery()
|
||||
.processInstanceId(leave.getInstanceId())
|
||||
// .singleResult();
|
||||
.list(); // 例如请假会签,会同时拥有多个任务
|
||||
if (!CollectionUtils.isEmpty(taskList)) {
|
||||
TaskEntityImpl task = (TaskEntityImpl) taskList.get(0);
|
||||
leave.setTaskId(task.getId());
|
||||
if (task.getSuspensionState() == 2) {
|
||||
leave.setTaskName("已挂起");
|
||||
leave.setSuspendState("2");
|
||||
} else {
|
||||
leave.setTaskName(task.getName());
|
||||
leave.setSuspendState("1");
|
||||
}
|
||||
} else {
|
||||
// 已办结或者已撤销
|
||||
leave.setTaskName("已结束");
|
||||
}
|
||||
} else {
|
||||
leave.setTaskName("未启动");
|
||||
}
|
||||
returnList.add(leave);
|
||||
}
|
||||
returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal());
|
||||
returnList.setPageNum(pageNum);
|
||||
returnList.setPageSize(pageSize);
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增请假流程
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertBizLeave(BizLeave bizLeave) {
|
||||
bizLeave.setCreateBy(SecurityUtils.getUsername());
|
||||
bizLeave.setCreateTime(DateUtils.getNowDate());
|
||||
return bizLeaveMapper.insertBizLeave(bizLeave);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改请假流程
|
||||
*
|
||||
* @param bizLeave 请假流程
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateBizLeave(BizLeave bizLeave) {
|
||||
bizLeave.setUpdateTime(DateUtils.getNowDate());
|
||||
return bizLeaveMapper.updateBizLeave(bizLeave);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除请假流程
|
||||
*
|
||||
* @param ids 需要删除的请假流程ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBizLeaveByIds(Long[] ids) {
|
||||
return bizLeaveMapper.deleteBizLeaveByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除请假流程信息
|
||||
*
|
||||
* @param id 请假流程ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteBizLeaveById(Long id) {
|
||||
return bizLeaveMapper.deleteBizLeaveById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动流程
|
||||
* @param entity
|
||||
* @param applyUserId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ProcessInstance submitApply(BizLeave entity, String applyUserId, String key, Map<String, Object> variables) {
|
||||
entity.setApplyUser(applyUserId);
|
||||
entity.setApplyTime(DateUtils.getNowDate());
|
||||
entity.setUpdateBy(applyUserId);
|
||||
bizLeaveMapper.updateBizLeave(entity);
|
||||
String businessKey = entity.getId().toString(); // 实体类 ID,作为流程的业务 key
|
||||
|
||||
ProcessInstance processInstance = processService.submitApply(applyUserId, businessKey, entity.getTitle(), entity.getReason(), key, variables);
|
||||
|
||||
String processInstanceId = processInstance.getId();
|
||||
entity.setInstanceId(processInstanceId); // 建立双向关系
|
||||
bizLeaveMapper.updateBizLeave(entity);
|
||||
|
||||
return processInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待办任务
|
||||
*/
|
||||
public Page<BizLeave> findTodoTasks(BizLeave leave, String userId) {
|
||||
// 手动分页
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
Page<BizLeave> list = new Page<>();
|
||||
|
||||
List<BizLeave> results = new ArrayList<>();
|
||||
List<Task> tasks = processService.findTodoTasks(userId, leave.getType());
|
||||
// 根据流程的业务ID查询实体并关联
|
||||
for (Task task : tasks) {
|
||||
TaskEntityImpl taskImpl = (TaskEntityImpl) task;
|
||||
String processInstanceId = taskImpl.getProcessInstanceId();
|
||||
// 条件过滤 1
|
||||
if (StringUtils.isNotBlank(leave.getInstanceId()) && !leave.getInstanceId().equals(processInstanceId)) {
|
||||
continue;
|
||||
}
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||
String businessKey = processInstance.getBusinessKey();
|
||||
BizLeave leave2 = bizLeaveMapper.selectBizLeaveById(new Long(businessKey));
|
||||
// 条件过滤 2
|
||||
if (StringUtils.isNotBlank(leave.getType()) && !leave.getType().equals(leave2.getType())) {
|
||||
continue;
|
||||
}
|
||||
leave2.setTaskId(taskImpl.getId());
|
||||
if (taskImpl.getSuspensionState() == 2) {
|
||||
leave2.setTaskName("已挂起");
|
||||
} else {
|
||||
leave2.setTaskName(taskImpl.getName());
|
||||
}
|
||||
SysUser sysUser = userMapper.selectUserByUserName(leave2.getApplyUser());
|
||||
leave2.setApplyUserName(sysUser.getUserName());
|
||||
results.add(leave2);
|
||||
}
|
||||
|
||||
List<BizLeave> tempList;
|
||||
if (pageNum != null && pageSize != null) {
|
||||
int maxRow = (pageNum - 1) * pageSize + pageSize > results.size() ? results.size() : (pageNum - 1) * pageSize + pageSize;
|
||||
tempList = results.subList((pageNum - 1) * pageSize, maxRow);
|
||||
list.setTotal(results.size());
|
||||
list.setPageNum(pageNum);
|
||||
list.setPageSize(pageSize);
|
||||
} else {
|
||||
tempList = results;
|
||||
}
|
||||
|
||||
list.addAll(tempList);
|
||||
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 查询已办列表
|
||||
* @param bizLeave
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<BizLeave> findDoneTasks(BizLeave bizLeave, String userId) {
|
||||
// 手动分页
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
Page<BizLeave> list = new Page<>();
|
||||
|
||||
List<BizLeave> results = new ArrayList<>();
|
||||
List<HistoricTaskInstance> hisList = processService.findDoneTasks(userId, bizLeave.getType());
|
||||
// 根据流程的业务ID查询实体并关联
|
||||
for (HistoricTaskInstance instance : hisList) {
|
||||
String processInstanceId = instance.getProcessInstanceId();
|
||||
// 条件过滤 1
|
||||
if (StringUtils.isNotBlank(bizLeave.getInstanceId()) && !bizLeave.getInstanceId().equals(processInstanceId)) {
|
||||
continue;
|
||||
}
|
||||
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||
String businessKey = processInstance.getBusinessKey();
|
||||
BizLeave leave2 = bizLeaveMapper.selectBizLeaveById(new Long(businessKey));
|
||||
BizLeave newLeave = new BizLeave();
|
||||
BeanUtils.copyProperties(leave2, newLeave);
|
||||
// 条件过滤 2
|
||||
if (StringUtils.isNotBlank(bizLeave.getType()) && !bizLeave.getType().equals(leave2.getType())) {
|
||||
continue;
|
||||
}
|
||||
newLeave.setTaskId(instance.getId());
|
||||
newLeave.setTaskName(instance.getName());
|
||||
newLeave.setDoneTime(instance.getEndTime());
|
||||
SysUser sysUser = userMapper.selectUserByUserName(leave2.getApplyUser());
|
||||
newLeave.setApplyUserName(sysUser.getUserName());
|
||||
results.add(newLeave);
|
||||
}
|
||||
|
||||
List<BizLeave> tempList;
|
||||
if (pageNum != null && pageSize != null) {
|
||||
int maxRow = (pageNum - 1) * pageSize + pageSize > results.size() ? results.size() : (pageNum - 1) * pageSize + pageSize;
|
||||
tempList = results.subList((pageNum - 1) * pageSize, maxRow);
|
||||
list.setTotal(results.size());
|
||||
list.setPageNum(pageNum);
|
||||
list.setPageSize(pageSize);
|
||||
} else {
|
||||
tempList = results;
|
||||
}
|
||||
|
||||
list.addAll(tempList);
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
<?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.jeethink.leave.mapper.BizLeaveMapper">
|
||||
|
||||
<resultMap type="BizLeave" id="BizLeaveResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="type" column="type" />
|
||||
<result property="title" column="title" />
|
||||
<result property="reason" column="reason" />
|
||||
<result property="leaveStartTime" column="leave_start_time" />
|
||||
<result property="leaveEndTime" column="leave_end_time" />
|
||||
<result property="totalTime" column="total_time" />
|
||||
<result property="instanceId" column="instance_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="applyUser" column="apply_user" />
|
||||
<result property="applyTime" column="apply_time" />
|
||||
<result property="realityStartTime" column="reality_start_time" />
|
||||
<result property="realityEndTime" column="reality_end_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectBizLeaveVo">
|
||||
select id, type, title, reason, leave_start_time, leave_end_time, total_time, instance_id, create_by, create_time, update_by, update_time, apply_user, apply_time, reality_start_time, reality_end_time from biz_leave
|
||||
</sql>
|
||||
|
||||
<select id="selectBizLeaveList" parameterType="BizLeave" resultMap="BizLeaveResult">
|
||||
<include refid="selectBizLeaveVo"/>
|
||||
<where>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
<if test="reason != null and reason != ''"> and reason = #{reason}</if>
|
||||
<if test="leaveStartTime != null "> and leave_start_time = #{leaveStartTime}</if>
|
||||
<if test="leaveEndTime != null "> and leave_end_time = #{leaveEndTime}</if>
|
||||
<if test="totalTime != null "> and total_time = #{totalTime}</if>
|
||||
<if test="instanceId != null and instanceId != ''"> and instance_id = #{instanceId}</if>
|
||||
<if test="applyUser != null and applyUser != ''"> and apply_user = #{applyUser}</if>
|
||||
<if test="applyTime != null "> and apply_time = #{applyTime}</if>
|
||||
<if test="realityStartTime != null "> and reality_start_time = #{realityStartTime}</if>
|
||||
<if test="realityEndTime != null "> and reality_end_time = #{realityEndTime}</if>
|
||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectBizLeaveById" parameterType="Long" resultMap="BizLeaveResult">
|
||||
<include refid="selectBizLeaveVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertBizLeave" parameterType="BizLeave" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into biz_leave
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">type,</if>
|
||||
<if test="title != null">title,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
<if test="leaveStartTime != null">leave_start_time,</if>
|
||||
<if test="leaveEndTime != null">leave_end_time,</if>
|
||||
<if test="totalTime != null">total_time,</if>
|
||||
<if test="instanceId != null">instance_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="applyUser != null">apply_user,</if>
|
||||
<if test="applyTime != null">apply_time,</if>
|
||||
<if test="realityStartTime != null">reality_start_time,</if>
|
||||
<if test="realityEndTime != null">reality_end_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="title != null">#{title},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
<if test="leaveStartTime != null">#{leaveStartTime},</if>
|
||||
<if test="leaveEndTime != null">#{leaveEndTime},</if>
|
||||
<if test="totalTime != null">#{totalTime},</if>
|
||||
<if test="instanceId != null">#{instanceId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="applyUser != null">#{applyUser},</if>
|
||||
<if test="applyTime != null">#{applyTime},</if>
|
||||
<if test="realityStartTime != null">#{realityStartTime},</if>
|
||||
<if test="realityEndTime != null">#{realityEndTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateBizLeave" parameterType="BizLeave">
|
||||
update biz_leave
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="title != null">title = #{title},</if>
|
||||
<if test="reason != null">reason = #{reason},</if>
|
||||
<if test="leaveStartTime != null">leave_start_time = #{leaveStartTime},</if>
|
||||
<if test="leaveEndTime != null">leave_end_time = #{leaveEndTime},</if>
|
||||
<if test="totalTime != null">total_time = #{totalTime},</if>
|
||||
<if test="instanceId != null">instance_id = #{instanceId},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="applyUser != null">apply_user = #{applyUser},</if>
|
||||
<if test="applyTime != null">apply_time = #{applyTime},</if>
|
||||
<if test="realityStartTime != null">reality_start_time = #{realityStartTime},</if>
|
||||
<if test="realityEndTime != null">reality_end_time = #{realityEndTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBizLeaveById" parameterType="Long">
|
||||
delete from biz_leave where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBizLeaveByIds" parameterType="String">
|
||||
delete from biz_leave where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user