Initial commit
This commit is contained in:
parent
39a3866312
commit
cf275fc83d
@ -0,0 +1,39 @@
|
|||||||
|
package com.atguigu.security.custom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClassName: LoginUserInfoHelper
|
||||||
|
* Package: com.atguigu.security.custom
|
||||||
|
* 获取当前用户信息帮助类
|
||||||
|
*
|
||||||
|
* @author yovinchen
|
||||||
|
* @Create 2023/6/23 09:24
|
||||||
|
*/
|
||||||
|
public class LoginUserInfoHelper {
|
||||||
|
|
||||||
|
private static ThreadLocal<Long> userId = new ThreadLocal<Long>();
|
||||||
|
private static ThreadLocal<String> username = new ThreadLocal<String>();
|
||||||
|
|
||||||
|
public static Long getUserId() {
|
||||||
|
return userId.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUserId(Long _userId) {
|
||||||
|
userId.set(_userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeUserId() {
|
||||||
|
userId.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUsername() {
|
||||||
|
return username.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUsername(String _username) {
|
||||||
|
username.set(_username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeUsername() {
|
||||||
|
username.remove();
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import com.atguigu.common.jwt.JwtHelper;
|
|||||||
import com.atguigu.common.result.Result;
|
import com.atguigu.common.result.Result;
|
||||||
import com.atguigu.common.result.ResultCodeEnum;
|
import com.atguigu.common.result.ResultCodeEnum;
|
||||||
import com.atguigu.common.utils.ResponseUtil;
|
import com.atguigu.common.utils.ResponseUtil;
|
||||||
|
import com.atguigu.security.custom.LoginUserInfoHelper;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
@ -60,12 +61,15 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
String token = request.getHeader("token");
|
String token = request.getHeader("token");
|
||||||
logger.info("token:" + token);
|
logger.info("token:" + token);
|
||||||
if (!StringUtils.isEmpty(token)) {
|
if (!StringUtils.isEmpty(token)) {
|
||||||
String useruame = JwtHelper.getUsername(token);
|
String username = JwtHelper.getUsername(token);
|
||||||
logger.info("useruame:" + useruame);
|
logger.info("username:" + username);
|
||||||
//认证成功
|
//认证成功
|
||||||
if (!StringUtils.isEmpty(useruame)) {
|
if (!StringUtils.isEmpty(username)) {
|
||||||
|
//当前用户信息放到 Thresdlocal 里面
|
||||||
|
LoginUserInfoHelper.setUserId(JwtHelper.getUserId(token));
|
||||||
|
LoginUserInfoHelper.setUsername(username);
|
||||||
//通过username从reids中获取权限数据
|
//通过username从reids中获取权限数据
|
||||||
String authString = (String) redisTemplate.opsForValue().get(useruame);
|
String authString = (String) redisTemplate.opsForValue().get(username);
|
||||||
//将redis中获取的字符串权限数据转换为 ArrayList<SimpleGrantedAuthority>
|
//将redis中获取的字符串权限数据转换为 ArrayList<SimpleGrantedAuthority>
|
||||||
if (!StringUtils.isEmpty(authString)) {
|
if (!StringUtils.isEmpty(authString)) {
|
||||||
List<Map> mapList = JSON.parseArray(authString, Map.class);
|
List<Map> mapList = JSON.parseArray(authString, Map.class);
|
||||||
@ -74,9 +78,9 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
for (Map map : mapList) {
|
for (Map map : mapList) {
|
||||||
authList.add(new SimpleGrantedAuthority((String) map.get("authority")));
|
authList.add(new SimpleGrantedAuthority((String) map.get("authority")));
|
||||||
}
|
}
|
||||||
return new UsernamePasswordAuthenticationToken(useruame, null, authList);
|
return new UsernamePasswordAuthenticationToken(username, null, authList);
|
||||||
} else {
|
} else {
|
||||||
return new UsernamePasswordAuthenticationToken(useruame, null, new ArrayList<>());
|
return new UsernamePasswordAuthenticationToken(username, null, new ArrayList<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,5 +27,5 @@ public interface SysUserService extends IService<SysUser> {
|
|||||||
* @param username
|
* @param username
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SysUser getByUsername(String username);
|
SysUser getUserByUsername(String username);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUser getByUsername(String username) {
|
public SysUser getUserByUsername(String username) {
|
||||||
return baseMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
return baseMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
SysUser sysUser = sysUserService.getByUsername(username);
|
SysUser sysUser = sysUserService.getUserByUsername(username);
|
||||||
if (null == sysUser) {
|
if (null == sysUser) {
|
||||||
throw new UsernameNotFoundException("用户名不存在!");
|
throw new UsernameNotFoundException("用户名不存在!");
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
package com.atguigu.process.controller.api;
|
package com.atguigu.process.controller.api;
|
||||||
|
|
||||||
import com.atguigu.common.result.Result;
|
import com.atguigu.common.result.Result;
|
||||||
|
import com.atguigu.model.process.ProcessTemplate;
|
||||||
import com.atguigu.model.process.ProcessType;
|
import com.atguigu.model.process.ProcessType;
|
||||||
|
import com.atguigu.process.service.OaProcessService;
|
||||||
|
import com.atguigu.process.service.OaProcessTemplateService;
|
||||||
import com.atguigu.process.service.OaProcessTypeService;
|
import com.atguigu.process.service.OaProcessTypeService;
|
||||||
|
import com.atguigu.vo.process.ProcessFormVo;
|
||||||
|
import com.atguigu.vo.process.ProcessVo;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -30,8 +35,51 @@ public class ProcessController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OaProcessTypeService oaProcessTypeService;
|
private OaProcessTypeService oaProcessTypeService;
|
||||||
|
@Autowired
|
||||||
|
private OaProcessTemplateService oaProcessTemplateService;
|
||||||
|
@Autowired
|
||||||
|
private OaProcessService oaProcessService;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "待处理")
|
||||||
|
@GetMapping("/findPending/{page}/{limit}")
|
||||||
|
public Result findPending(
|
||||||
|
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||||
|
@PathVariable Long page,
|
||||||
|
|
||||||
|
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||||
|
@PathVariable Long limit) {
|
||||||
|
Page<Process> pageParam = new Page<>(page, limit);
|
||||||
|
IPage<ProcessVo> page1 = oaProcessService.findPending(pageParam);
|
||||||
|
return Result.ok(page1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动流程
|
||||||
|
*
|
||||||
|
* @param processFormVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "启动流程")
|
||||||
|
@PostMapping("/startUp")
|
||||||
|
public Result start(@RequestBody ProcessFormVo processFormVo) {
|
||||||
|
oaProcessService.startUp(processFormVo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取审批模板
|
||||||
|
*
|
||||||
|
* @param processTemplateId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取审批模板")
|
||||||
|
@GetMapping("getProcessTemplate/{processTemplateId}")
|
||||||
|
public Result get(@PathVariable Long processTemplateId) {
|
||||||
|
ProcessTemplate processTemplate = oaProcessTemplateService.getById(processTemplateId);
|
||||||
|
return Result.ok(processTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有审批分类和每一个分类所有审批模版
|
* 查询所有审批分类和每一个分类所有审批模版
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.atguigu.process.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.model.process.ProcessRecord;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 审批记录 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yovinchen
|
||||||
|
* @since 2023-06-23
|
||||||
|
*/
|
||||||
|
public interface OaProcessRecordMapper extends BaseMapper<ProcessRecord> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?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.atguigu.process.mapper.OaProcessRecordMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.atguigu.process.service;
|
||||||
|
|
||||||
|
import com.atguigu.model.process.ProcessRecord;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 审批记录 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yovinchen
|
||||||
|
* @since 2023-06-23
|
||||||
|
*/
|
||||||
|
public interface OaProcessRecordService extends IService<ProcessRecord> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录操作审批信息记录
|
||||||
|
*
|
||||||
|
* @param processId
|
||||||
|
* @param status
|
||||||
|
* @param description
|
||||||
|
*/
|
||||||
|
void record(Long processId, int status, String description);
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.atguigu.process.service;
|
package com.atguigu.process.service;
|
||||||
|
|
||||||
import com.atguigu.model.process.Process;
|
import com.atguigu.model.process.Process;
|
||||||
|
import com.atguigu.vo.process.ProcessFormVo;
|
||||||
import com.atguigu.vo.process.ProcessQueryVo;
|
import com.atguigu.vo.process.ProcessQueryVo;
|
||||||
import com.atguigu.vo.process.ProcessVo;
|
import com.atguigu.vo.process.ProcessVo;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -30,4 +31,19 @@ public interface OaProcessService extends IService<Process> {
|
|||||||
* 部署流程定义
|
* 部署流程定义
|
||||||
*/
|
*/
|
||||||
void deployByZip(String deployPath);
|
void deployByZip(String deployPath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动流程
|
||||||
|
*
|
||||||
|
* @param processFormVo
|
||||||
|
*/
|
||||||
|
void startUp(ProcessFormVo processFormVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询待处理的任务列表
|
||||||
|
*
|
||||||
|
* @param pageParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<ProcessVo> findPending(Page<java.lang.Process> pageParam);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.atguigu.process.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.auth.service.SysUserService;
|
||||||
|
import com.atguigu.model.process.ProcessRecord;
|
||||||
|
import com.atguigu.model.system.SysUser;
|
||||||
|
import com.atguigu.process.mapper.OaProcessRecordMapper;
|
||||||
|
import com.atguigu.process.service.OaProcessRecordService;
|
||||||
|
import com.atguigu.security.custom.LoginUserInfoHelper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 审批记录 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yovinchen
|
||||||
|
* @since 2023-06-23
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class OaProcessRecordServiceImpl extends ServiceImpl<OaProcessRecordMapper, ProcessRecord> implements OaProcessRecordService {
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录操作审批信息记录
|
||||||
|
*
|
||||||
|
* @param processId
|
||||||
|
* @param status
|
||||||
|
* @param description
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void record(Long processId, int status, String description) {
|
||||||
|
Long userId = LoginUserInfoHelper.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.getById(userId);
|
||||||
|
|
||||||
|
ProcessRecord processRecord = new ProcessRecord();
|
||||||
|
processRecord.setProcessId(processId);
|
||||||
|
processRecord.setStatus(status);
|
||||||
|
processRecord.setDescription(description);
|
||||||
|
processRecord.setOperateUser(sysUser.getName());
|
||||||
|
processRecord.setOperateUserId(userId);
|
||||||
|
|
||||||
|
baseMapper.insert(processRecord);
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,40 @@
|
|||||||
package com.atguigu.process.service.impl;
|
package com.atguigu.process.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.atguigu.auth.service.SysUserService;
|
||||||
import com.atguigu.model.process.Process;
|
import com.atguigu.model.process.Process;
|
||||||
|
import com.atguigu.model.process.ProcessTemplate;
|
||||||
|
import com.atguigu.model.system.SysUser;
|
||||||
import com.atguigu.process.mapper.OaProcessMapper;
|
import com.atguigu.process.mapper.OaProcessMapper;
|
||||||
|
import com.atguigu.process.service.OaProcessRecordService;
|
||||||
import com.atguigu.process.service.OaProcessService;
|
import com.atguigu.process.service.OaProcessService;
|
||||||
|
import com.atguigu.process.service.OaProcessTemplateService;
|
||||||
|
import com.atguigu.security.custom.LoginUserInfoHelper;
|
||||||
|
import com.atguigu.vo.process.ProcessFormVo;
|
||||||
import com.atguigu.vo.process.ProcessQueryVo;
|
import com.atguigu.vo.process.ProcessQueryVo;
|
||||||
import com.atguigu.vo.process.ProcessVo;
|
import com.atguigu.vo.process.ProcessVo;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.activiti.engine.HistoryService;
|
||||||
import org.activiti.engine.RepositoryService;
|
import org.activiti.engine.RepositoryService;
|
||||||
|
import org.activiti.engine.RuntimeService;
|
||||||
|
import org.activiti.engine.TaskService;
|
||||||
import org.activiti.engine.repository.Deployment;
|
import org.activiti.engine.repository.Deployment;
|
||||||
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
|
import org.activiti.engine.task.Task;
|
||||||
|
import org.activiti.engine.task.TaskQuery;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,10 +48,28 @@ import java.util.zip.ZipInputStream;
|
|||||||
@Service
|
@Service
|
||||||
public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process> implements OaProcessService {
|
public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process> implements OaProcessService {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RepositoryService repositoryService;
|
private RepositoryService repositoryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OaProcessTemplateService oaProcessTemplateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuntimeService runtimeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TaskService taskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OaProcessRecordService oaProcessRecordService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HistoryService historyService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取分页列表
|
* 获取分页列表
|
||||||
*
|
*
|
||||||
@ -65,4 +104,135 @@ public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process>
|
|||||||
System.out.println("deployment.getName() = " + deployment.getName());
|
System.out.println("deployment.getName() = " + deployment.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动流程
|
||||||
|
*
|
||||||
|
* @param processFormVo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void startUp(ProcessFormVo processFormVo) {
|
||||||
|
// 1 根据当前用户id获取用户信息
|
||||||
|
SysUser sysUser = sysUserService.getById(LoginUserInfoHelper.getUserId());
|
||||||
|
|
||||||
|
// 2 根据审批模板id把模板信息查询
|
||||||
|
ProcessTemplate processTemplate = oaProcessTemplateService.getById(processFormVo.getProcessTemplateId());
|
||||||
|
|
||||||
|
// 3 保存提交审批信息到业务表,oa_process
|
||||||
|
Process process = new Process();
|
||||||
|
// processFormVo复制到process对象里面
|
||||||
|
BeanUtils.copyProperties(processFormVo, process);
|
||||||
|
// 其他值
|
||||||
|
process.setStatus(1); //审批中
|
||||||
|
String workNo = System.currentTimeMillis() + "";
|
||||||
|
process.setProcessCode(workNo);
|
||||||
|
process.setUserId(LoginUserInfoHelper.getUserId());
|
||||||
|
process.setFormValues(processFormVo.getFormValues());
|
||||||
|
process.setTitle(sysUser.getName() + "发起" + processTemplate.getName() + "申请");
|
||||||
|
baseMapper.insert(process);
|
||||||
|
|
||||||
|
|
||||||
|
// 4 启动流程实例 - RuntimeService
|
||||||
|
// 4.1 流程定义key
|
||||||
|
String processDefinitionKey = processTemplate.getProcessDefinitionKey();
|
||||||
|
|
||||||
|
//4.2 业务key processId
|
||||||
|
String businessKey = String.valueOf(process.getId());
|
||||||
|
|
||||||
|
//4.3 流程参数 form表单json数据,转换map集合
|
||||||
|
String formValues = processFormVo.getFormValues();
|
||||||
|
JSONObject jsonObject = JSON.parseObject(formValues);
|
||||||
|
JSONObject formData = jsonObject.getJSONObject("formData");
|
||||||
|
// 遍历formData得到的内容,封装map集合
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
for (Map.Entry<String, Object> entry : formData.entrySet()) {
|
||||||
|
map.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
Map<String, Object> variable = new HashMap<>();
|
||||||
|
variable.put("data", map);
|
||||||
|
|
||||||
|
// 启动流程实例
|
||||||
|
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, variable);
|
||||||
|
|
||||||
|
// 5 查询下一个审批人
|
||||||
|
// 审批人可能多个
|
||||||
|
List<Task> taskList = this.getCurrentTaskList(processInstance.getId());
|
||||||
|
List<String> nameList = new ArrayList<>();
|
||||||
|
for (Task task : taskList) {
|
||||||
|
String assigneeName = task.getAssignee();
|
||||||
|
SysUser user = sysUserService.getUserByUsername(assigneeName);
|
||||||
|
String name = user.getName();
|
||||||
|
nameList.add(name);
|
||||||
|
|
||||||
|
// TODO 6 推送消息
|
||||||
|
}
|
||||||
|
process.setProcessInstanceId(processInstance.getId());
|
||||||
|
process.setDescription("等待" + StringUtils.join(nameList.toArray(), ",") + "审批");
|
||||||
|
// 7 业务和流程关联 更新oa_process数据
|
||||||
|
baseMapper.updateById(process);
|
||||||
|
|
||||||
|
// 记录操作审批信息记录
|
||||||
|
oaProcessRecordService.record(process.getId(), 1, "发起申请");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询待处理的列表
|
||||||
|
*
|
||||||
|
* @param pageParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPage<ProcessVo> findPending(Page<java.lang.Process> pageParam) {
|
||||||
|
|
||||||
|
//1 封装查询条件,根据当前登录的用户名称
|
||||||
|
TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee(LoginUserInfoHelper.getUsername()).orderByTaskCreateTime().desc();
|
||||||
|
|
||||||
|
//2 调用方法分页条件查询,返回list集合,待办任务集合
|
||||||
|
//listPage方法有两个参数
|
||||||
|
//第一个参数:开始位置 第二个参数:每页显示记录数
|
||||||
|
int begin = (int) ((pageParam.getCurrent() - 1) * pageParam.getSize());
|
||||||
|
int size = (int) pageParam.getSize();
|
||||||
|
List<Task> taskList = taskQuery.listPage(begin, size);
|
||||||
|
long totalCount = taskQuery.count();
|
||||||
|
|
||||||
|
//3 封装返回list集合数据 到 List<ProcessVo>里面
|
||||||
|
//List<Task> -- List<ProcessVo>
|
||||||
|
List<ProcessVo> processVoList = new ArrayList<>();
|
||||||
|
for (Task task : taskList) {
|
||||||
|
|
||||||
|
//从task获取流程实例id
|
||||||
|
String processInstanceId = task.getProcessInstanceId();
|
||||||
|
//根据流程实例id获取实例对象
|
||||||
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||||
|
//从流程实例对象获取业务key---processId
|
||||||
|
Long businessKey = Long.valueOf(processInstance.getBusinessKey());
|
||||||
|
if (businessKey == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//根据业务key获取Process对象
|
||||||
|
Process process = baseMapper.selectById(businessKey);
|
||||||
|
|
||||||
|
//Process对象 复制 ProcessVo对象
|
||||||
|
ProcessVo processVo = new ProcessVo();
|
||||||
|
BeanUtils.copyProperties(process, processVo);
|
||||||
|
processVo.setTaskId(task.getId());
|
||||||
|
|
||||||
|
//放到最终list集合processVoList
|
||||||
|
processVoList.add(processVo);
|
||||||
|
}
|
||||||
|
//4 封装返回IPage对象
|
||||||
|
IPage<ProcessVo> page = new Page<>(pageParam.getCurrent(), pageParam.getSize(), totalCount);
|
||||||
|
page.setRecords(processVoList);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前任务列表
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<Task> getCurrentTaskList(String id) {
|
||||||
|
return taskService.createTaskQuery().processInstanceId(id).list();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package com.atguigu.process.service.impl;
|
package com.atguigu.process.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.model.process.ProcessTemplate;
|
||||||
import com.atguigu.model.process.ProcessType;
|
import com.atguigu.model.process.ProcessType;
|
||||||
import com.atguigu.process.mapper.OaProcessTypeMapper;
|
import com.atguigu.process.mapper.OaProcessTypeMapper;
|
||||||
|
import com.atguigu.process.service.OaProcessTemplateService;
|
||||||
import com.atguigu.process.service.OaProcessTypeService;
|
import com.atguigu.process.service.OaProcessTypeService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -19,6 +23,9 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class OaProcessTypeServiceImpl extends ServiceImpl<OaProcessTypeMapper, ProcessType> implements OaProcessTypeService {
|
public class OaProcessTypeServiceImpl extends ServiceImpl<OaProcessTypeMapper, ProcessType> implements OaProcessTypeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OaProcessTemplateService oaProcessTemplateService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有审批分类和每一个分类所有审批模版
|
* 查询所有审批分类和每一个分类所有审批模版
|
||||||
*
|
*
|
||||||
@ -28,7 +35,22 @@ public class OaProcessTypeServiceImpl extends ServiceImpl<OaProcessTypeMapper, P
|
|||||||
public List<ProcessType> findProcessType() {
|
public List<ProcessType> findProcessType() {
|
||||||
|
|
||||||
|
|
||||||
|
// 1、 查询所有审批分类,返回list集合
|
||||||
|
List<ProcessType> processTypeList = baseMapper.selectList(null);
|
||||||
|
|
||||||
return null;
|
// 2、 遍历返回所有审批分类list集合
|
||||||
|
for (ProcessType processType : processTypeList) {
|
||||||
|
// 3、 得到每个审批分类,根据审批分类id查询对应审批模板
|
||||||
|
// 审批分类id
|
||||||
|
Long id = processType.getId();
|
||||||
|
// 根据审批分类id查询对应审批模板
|
||||||
|
LambdaQueryWrapper<ProcessTemplate> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(ProcessTemplate::getProcessTypeId, id);
|
||||||
|
List<ProcessTemplate> processTemplateList = oaProcessTemplateService.list(queryWrapper);
|
||||||
|
|
||||||
|
// 4、 根据审批分类id查询对应审批模板数据(List)封装到每个审批分类对象里面
|
||||||
|
processType.setProcessTemplateList(processTemplateList);
|
||||||
|
}
|
||||||
|
return processTypeList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class CodeGet {
|
|||||||
// 5、策略配置
|
// 5、策略配置
|
||||||
StrategyConfig strategy = new StrategyConfig();
|
StrategyConfig strategy = new StrategyConfig();
|
||||||
|
|
||||||
strategy.setInclude("oa_process");
|
strategy.setInclude("oa_process_record");
|
||||||
//数据库表映射到实体的命名策略
|
//数据库表映射到实体的命名策略
|
||||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||||
//数据库表字段映射到实体的命名策略
|
//数据库表字段映射到实体的命名策略
|
||||||
|
Loading…
Reference in New Issue
Block a user