Initial commit
This commit is contained in:
parent
39a3866312
commit
bf21c15274
@ -89,7 +89,7 @@ public class JwtHelper {
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String token = JwtHelper.createToken(1L, "admin");
|
||||
String token = JwtHelper.createToken(4L, "lisi");
|
||||
System.out.println(token);
|
||||
String username = JwtHelper.getUsername(token);
|
||||
Long userId = JwtHelper.getUserId(token);
|
||||
|
@ -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.ResultCodeEnum;
|
||||
import com.atguigu.common.utils.ResponseUtil;
|
||||
import com.atguigu.security.custom.LoginUserInfoHelper;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
@ -60,12 +61,15 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
String token = request.getHeader("token");
|
||||
logger.info("token:" + token);
|
||||
if (!StringUtils.isEmpty(token)) {
|
||||
String useruame = JwtHelper.getUsername(token);
|
||||
logger.info("useruame:" + useruame);
|
||||
String username = JwtHelper.getUsername(token);
|
||||
logger.info("username:" + username);
|
||||
//认证成功
|
||||
if (!StringUtils.isEmpty(useruame)) {
|
||||
if (!StringUtils.isEmpty(username)) {
|
||||
//当前用户信息放到 Thresdlocal 里面
|
||||
LoginUserInfoHelper.setUserId(JwtHelper.getUserId(token));
|
||||
LoginUserInfoHelper.setUsername(username);
|
||||
//通过username从reids中获取权限数据
|
||||
String authString = (String) redisTemplate.opsForValue().get(useruame);
|
||||
String authString = (String) redisTemplate.opsForValue().get(username);
|
||||
//将redis中获取的字符串权限数据转换为 ArrayList<SimpleGrantedAuthority>
|
||||
if (!StringUtils.isEmpty(authString)) {
|
||||
List<Map> mapList = JSON.parseArray(authString, Map.class);
|
||||
@ -74,9 +78,9 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
for (Map map : mapList) {
|
||||
authList.add(new SimpleGrantedAuthority((String) map.get("authority")));
|
||||
}
|
||||
return new UsernamePasswordAuthenticationToken(useruame, null, authList);
|
||||
return new UsernamePasswordAuthenticationToken(username, null, authList);
|
||||
} 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
|
||||
* @return
|
||||
*/
|
||||
SysUser getByUsername(String username);
|
||||
SysUser getUserByUsername(String username);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SysUser getByUsername(String username) {
|
||||
public SysUser getUserByUsername(String username) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
SysUser sysUser = sysUserService.getByUsername(username);
|
||||
SysUser sysUser = sysUserService.getUserByUsername(username);
|
||||
if (null == sysUser) {
|
||||
throw new UsernameNotFoundException("用户名不存在!");
|
||||
}
|
||||
|
@ -12,10 +12,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -28,7 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Api(tags = "审批流管理")
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/process")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@CrossOrigin//跨域
|
||||
//@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class OaProcessController {
|
||||
|
||||
@Autowired
|
||||
|
@ -1,17 +1,24 @@
|
||||
package com.atguigu.process.controller.api;
|
||||
|
||||
import com.atguigu.common.result.Result;
|
||||
import com.atguigu.model.process.Process;
|
||||
import com.atguigu.model.process.ProcessTemplate;
|
||||
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.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.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ClassName: ProcessController
|
||||
@ -25,13 +32,53 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/process")
|
||||
@CrossOrigin//跨域
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
//@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class ProcessController {
|
||||
|
||||
@Autowired
|
||||
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> pageModel = oaProcessService.findPending(pageParam);
|
||||
return Result.ok(pageModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动流程
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有审批分类和每一个分类所有审批模版
|
||||
*
|
||||
@ -44,5 +91,17 @@ public class ProcessController {
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看审批详情信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("show/{id}")
|
||||
public Result show(@PathVariable Long id) {
|
||||
Map<String, Object> map = oaProcessService.show(id);
|
||||
return Result.ok(map);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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, Integer status, String description);
|
||||
}
|
@ -1,12 +1,15 @@
|
||||
package com.atguigu.process.service;
|
||||
|
||||
import com.atguigu.model.process.Process;
|
||||
import com.atguigu.vo.process.ProcessFormVo;
|
||||
import com.atguigu.vo.process.ProcessQueryVo;
|
||||
import com.atguigu.vo.process.ProcessVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 审批类型 服务类
|
||||
@ -30,4 +33,27 @@ public interface OaProcessService extends IService<Process> {
|
||||
* 部署流程定义
|
||||
*/
|
||||
void deployByZip(String deployPath);
|
||||
|
||||
/**
|
||||
* 启动流程
|
||||
*
|
||||
* @param processFormVo
|
||||
*/
|
||||
void startUp(ProcessFormVo processFormVo);
|
||||
|
||||
/**
|
||||
* 查询待处理的任务列表
|
||||
*
|
||||
* @param pageParam
|
||||
* @return
|
||||
*/
|
||||
IPage<ProcessVo> findPending(Page<Process> pageParam);
|
||||
|
||||
/**
|
||||
* 查看审批详情信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> show(Long id);
|
||||
}
|
||||
|
@ -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, Integer 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,43 @@
|
||||
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.ProcessRecord;
|
||||
import com.atguigu.model.process.ProcessTemplate;
|
||||
import com.atguigu.model.system.SysUser;
|
||||
import com.atguigu.process.mapper.OaProcessMapper;
|
||||
import com.atguigu.process.service.OaProcessRecordService;
|
||||
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.ProcessVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.activiti.engine.HistoryService;
|
||||
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.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.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
@ -27,10 +51,28 @@ import java.util.zip.ZipInputStream;
|
||||
@Service
|
||||
public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process> implements OaProcessService {
|
||||
|
||||
|
||||
@Autowired
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 获取分页列表
|
||||
*
|
||||
@ -52,17 +94,184 @@ public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process>
|
||||
*/
|
||||
@Override
|
||||
public void deployByZip(String deployPath) {
|
||||
// 定义zip输入流
|
||||
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(deployPath);
|
||||
|
||||
URL url = ClassLoader.getSystemResource("");
|
||||
System.out.println(url.getPath());
|
||||
File file = new File(url.getPath() + "/" + deployPath);
|
||||
if (!file.exists()) {
|
||||
throw new RuntimeException("文件不存在");
|
||||
} else {
|
||||
InputStream inputStream = null;
|
||||
ZipInputStream zipInputStream = null;
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream = new FileInputStream(file);
|
||||
zipInputStream = new ZipInputStream(inputStream);
|
||||
}
|
||||
// 流程部署
|
||||
Deployment deployment = repositoryService.createDeployment().addZipInputStream(zipInputStream).deploy();
|
||||
|
||||
System.out.println("deployment.getId() = " + deployment.getId());
|
||||
System.out.println("deployment.getName() = " + deployment.getName());
|
||||
System.out.println(deployment.getId());
|
||||
System.out.println(deployment.getName());
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
inputStream.close();
|
||||
zipInputStream.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动流程
|
||||
*
|
||||
* @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<Process> pageParam) {
|
||||
TaskQuery query = taskService.createTaskQuery().taskAssignee(LoginUserInfoHelper.getUsername()).orderByTaskCreateTime().desc();
|
||||
int begin = (int) ((pageParam.getCurrent() - 1) * pageParam.getSize());
|
||||
int size = (int) pageParam.getSize();
|
||||
List<Task> taskList = query.listPage(begin, size);
|
||||
List<ProcessVo> processVoList = new ArrayList<>();
|
||||
for (Task task : taskList) {
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
|
||||
String businessKey = processInstance.getBusinessKey();
|
||||
if (businessKey == null) {
|
||||
continue;
|
||||
}
|
||||
Process process = baseMapper.selectById(Long.parseLong(businessKey));
|
||||
ProcessVo processVo = new ProcessVo();
|
||||
BeanUtils.copyProperties(process, processVo);
|
||||
processVo.setTaskId(task.getId());
|
||||
processVoList.add(processVo);
|
||||
}
|
||||
IPage<ProcessVo> page = new Page<>(pageParam.getCurrent(), pageParam.getSize(), query.count());
|
||||
page.setRecords(processVoList);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看审批详情信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> show(Long id) {
|
||||
//1 根据流程id获取流程信息Process
|
||||
Process process = baseMapper.selectById(id);
|
||||
|
||||
//2 根据流程id获取流程记录信息
|
||||
LambdaQueryWrapper<ProcessRecord> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRecord::getProcessId,id);
|
||||
List<ProcessRecord> processRecordList = oaProcessRecordService.list(wrapper);
|
||||
|
||||
//3 根据模板id查询模板信息
|
||||
ProcessTemplate processTemplate = oaProcessTemplateService.getById(process.getProcessTemplateId());
|
||||
|
||||
//4 判断当前用户是否可以审批
|
||||
//可以看到信息不一定能审批,不能重复审批
|
||||
boolean isApprove = false;
|
||||
List<Task> taskList = this.getCurrentTaskList(process.getProcessInstanceId());
|
||||
for(Task task : taskList) {
|
||||
//判断任务审批人是否是当前用户
|
||||
String username = LoginUserInfoHelper.getUsername();
|
||||
if(task.getAssignee().equals(username)) {
|
||||
isApprove = true;
|
||||
}
|
||||
}
|
||||
|
||||
//5 查询数据封装到map集合,返回
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("process", process);
|
||||
map.put("processRecordList", processRecordList);
|
||||
map.put("processTemplate", processTemplate);
|
||||
map.put("isApprove", isApprove);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前任务列表
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private List<Task> getCurrentTaskList(String id) {
|
||||
List<Task> taskList = taskService.createTaskQuery().processInstanceId(id).list();
|
||||
return taskList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.atguigu.process.service.impl;
|
||||
|
||||
import com.atguigu.model.process.ProcessTemplate;
|
||||
import com.atguigu.model.process.ProcessType;
|
||||
import com.atguigu.process.mapper.OaProcessTypeMapper;
|
||||
import com.atguigu.process.service.OaProcessTemplateService;
|
||||
import com.atguigu.process.service.OaProcessTypeService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -19,6 +23,9 @@ import java.util.List;
|
||||
@Service
|
||||
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() {
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -10,21 +10,21 @@ spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://43.143.164.194:3306/guigu-oa?useSSL=false&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true
|
||||
# username: admin
|
||||
# password: admin
|
||||
url: jdbc:mysql://localhost:3306/guigu-oa?useSSL=false&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: root
|
||||
url: jdbc:mysql://43.143.164.194:3306/guigu-oa?useSSL=false&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true
|
||||
username: admin
|
||||
password: admin
|
||||
# url: jdbc:mysql://localhost:3306/guigu-oa?useSSL=false&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true
|
||||
# username: root
|
||||
# password: root
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
redis:
|
||||
host: localhost
|
||||
host: 43.143.164.194
|
||||
port: 6379
|
||||
database: 0
|
||||
timeout: 1800000
|
||||
password:
|
||||
password: redis
|
||||
jedis:
|
||||
pool:
|
||||
max-active: 20 #最大连接数
|
||||
|
@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
|
||||
<process id="leave" isExecutable="true">
|
||||
<startEvent id="sid-2C002908-F0BD-4C63-BDF6-15480E9AAE59"></startEvent>
|
||||
<userTask id="sid-D51DF33C-EEAC-4EF2-B3DE-F71B20956BF7" name="zhangsan Audit" activiti:assignee="zhangsan"></userTask>
|
||||
<userTask id="sid-F9B3F8AB-8ADA-436C-B496-1E8742808529" name="lisi Audit" activiti:assignee="lisi"></userTask>
|
||||
<endEvent id="sid-5F1FDFF1-0716-4413-9F4C-A9F884E0CFE5"></endEvent>
|
||||
<sequenceFlow id="sid-40DF2D05-C2CB-4831-ABED-373689B25C30" sourceRef="sid-D51DF33C-EEAC-4EF2-B3DE-F71B20956BF7" targetRef="sid-F9B3F8AB-8ADA-436C-B496-1E8742808529"></sequenceFlow>
|
||||
<sequenceFlow id="sid-E3C50B03-6FD5-4EE0-A356-0E89505C03E5" sourceRef="sid-F9B3F8AB-8ADA-436C-B496-1E8742808529" targetRef="sid-5F1FDFF1-0716-4413-9F4C-A9F884E0CFE5"></sequenceFlow>
|
||||
<sequenceFlow id="sid-54CB193B-361A-4212-8C45-50F1CE6A466A" sourceRef="sid-2C002908-F0BD-4C63-BDF6-15480E9AAE59" targetRef="sid-D51DF33C-EEAC-4EF2-B3DE-F71B20956BF7"></sequenceFlow>
|
||||
</process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_leave">
|
||||
<bpmndi:BPMNPlane bpmnElement="leave" id="BPMNPlane_leave">
|
||||
<bpmndi:BPMNShape bpmnElement="sid-2C002908-F0BD-4C63-BDF6-15480E9AAE59" id="BPMNShape_sid-2C002908-F0BD-4C63-BDF6-15480E9AAE59">
|
||||
<omgdc:Bounds height="30.0" width="30.0" x="201.125" y="115.0"></omgdc:Bounds>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape bpmnElement="sid-D51DF33C-EEAC-4EF2-B3DE-F71B20956BF7" id="BPMNShape_sid-D51DF33C-EEAC-4EF2-B3DE-F71B20956BF7">
|
||||
<omgdc:Bounds height="80.0" width="100.0" x="330.0" y="90.0"></omgdc:Bounds>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape bpmnElement="sid-F9B3F8AB-8ADA-436C-B496-1E8742808529" id="BPMNShape_sid-F9B3F8AB-8ADA-436C-B496-1E8742808529">
|
||||
<omgdc:Bounds height="80.0" width="100.0" x="540.0" y="90.0"></omgdc:Bounds>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape bpmnElement="sid-5F1FDFF1-0716-4413-9F4C-A9F884E0CFE5" id="BPMNShape_sid-5F1FDFF1-0716-4413-9F4C-A9F884E0CFE5">
|
||||
<omgdc:Bounds height="28.0" width="28.0" x="735.0" y="116.0"></omgdc:Bounds>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge bpmnElement="sid-E3C50B03-6FD5-4EE0-A356-0E89505C03E5" id="BPMNEdge_sid-E3C50B03-6FD5-4EE0-A356-0E89505C03E5">
|
||||
<omgdi:waypoint x="640.0" y="130.0"></omgdi:waypoint>
|
||||
<omgdi:waypoint x="735.0" y="130.0"></omgdi:waypoint>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge bpmnElement="sid-54CB193B-361A-4212-8C45-50F1CE6A466A" id="BPMNEdge_sid-54CB193B-361A-4212-8C45-50F1CE6A466A">
|
||||
<omgdi:waypoint x="231.125" y="130.0"></omgdi:waypoint>
|
||||
<omgdi:waypoint x="330.0" y="130.0"></omgdi:waypoint>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge bpmnElement="sid-40DF2D05-C2CB-4831-ABED-373689B25C30" id="BPMNEdge_sid-40DF2D05-C2CB-4831-ABED-373689B25C30">
|
||||
<omgdi:waypoint x="430.0" y="130.0"></omgdi:waypoint>
|
||||
<omgdi:waypoint x="540.0" y="130.0"></omgdi:waypoint>
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</definitions>
|
@ -47,7 +47,7 @@ public class CodeGet {
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
|
||||
strategy.setInclude("oa_process");
|
||||
strategy.setInclude("oa_process_record");
|
||||
//数据库表映射到实体的命名策略
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
//数据库表字段映射到实体的命名策略
|
||||
|
Loading…
Reference in New Issue
Block a user