Initial commit
This commit is contained in:
parent
41fc5e5fd5
commit
bf0bcfa2d0
@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户表 前端控制器
|
||||
@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
*/
|
||||
@Api(tags = "用户管理接口")
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/admin/system/sysUser")
|
||||
public class SysUserController {
|
||||
|
||||
@ -139,5 +142,16 @@ public class SysUserController {
|
||||
sysUserService.removeById(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getCurrentUser")
|
||||
public Result getCurrentUser() {
|
||||
Map<String, Object> map = sysUserService.getCurrentUser();
|
||||
return Result.ok(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@ package com.atguigu.auth.service;
|
||||
import com.atguigu.model.system.SysUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户表 服务类
|
||||
@ -28,4 +30,11 @@ public interface SysUserService extends IService<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
SysUser getUserByUsername(String username);
|
||||
|
||||
/**
|
||||
* 获取当前用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getCurrentUser();
|
||||
}
|
||||
|
@ -3,11 +3,15 @@ package com.atguigu.auth.service.impl;
|
||||
import com.atguigu.auth.mapper.SysUserMapper;
|
||||
import com.atguigu.auth.service.SysUserService;
|
||||
import com.atguigu.model.system.SysUser;
|
||||
import com.atguigu.security.custom.LoginUserInfoHelper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户表 服务实现类
|
||||
@ -49,4 +53,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
public SysUser getUserByUsername(String username) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getCurrentUser() {
|
||||
SysUser sysUser = baseMapper.selectById(LoginUserInfoHelper.getUserId());
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("name", sysUser.getName());
|
||||
map.put("phone", sysUser.getPhone());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.atguigu.process.controller.api;
|
||||
|
||||
import com.atguigu.auth.service.SysUserService;
|
||||
import com.atguigu.common.result.Result;
|
||||
import com.atguigu.model.process.Process;
|
||||
import com.atguigu.model.process.ProcessTemplate;
|
||||
@ -7,6 +8,7 @@ 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.ApprovalVo;
|
||||
import com.atguigu.vo.process.ProcessFormVo;
|
||||
import com.atguigu.vo.process.ProcessVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -37,12 +39,15 @@ 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,
|
||||
@ -103,5 +108,46 @@ public class ProcessController {
|
||||
return Result.ok(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批
|
||||
*
|
||||
* @param approvalVo
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "审批")
|
||||
@PostMapping("approve")
|
||||
public Result approve(@RequestBody ApprovalVo approvalVo) {
|
||||
oaProcessService.approve(approvalVo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询已处理
|
||||
*
|
||||
* @param page
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "已处理")
|
||||
@GetMapping("/findProcessed/{page}/{limit}")
|
||||
public Result findProcessed(@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.findProcessed(pageParam);
|
||||
return Result.ok(pageModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询已发起
|
||||
*
|
||||
* @param page
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "已发起")
|
||||
@GetMapping("/findStarted/{page}/{limit}")
|
||||
public Result findStarted(@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Long page, @ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable Long limit) {
|
||||
Page<ProcessVo> pageParam = new Page<>(page, limit);
|
||||
IPage<ProcessVo> pageModel = oaProcessService.findStarted(pageParam);
|
||||
return Result.ok(pageModel);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.atguigu.process.service;
|
||||
|
||||
import com.atguigu.model.process.Process;
|
||||
import com.atguigu.vo.process.ApprovalVo;
|
||||
import com.atguigu.vo.process.ProcessFormVo;
|
||||
import com.atguigu.vo.process.ProcessQueryVo;
|
||||
import com.atguigu.vo.process.ProcessVo;
|
||||
@ -56,4 +57,27 @@ public interface OaProcessService extends IService<Process> {
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> show(Long id);
|
||||
|
||||
/**
|
||||
* 审批
|
||||
*
|
||||
* @param approvalVo
|
||||
*/
|
||||
void approve(ApprovalVo approvalVo);
|
||||
|
||||
/**
|
||||
* 分页查询已处理
|
||||
*
|
||||
* @param pageParam
|
||||
* @return
|
||||
*/
|
||||
IPage<ProcessVo> findProcessed(Page<Process> pageParam);
|
||||
|
||||
/**
|
||||
* 分页查询已发起
|
||||
*
|
||||
* @param pageParam
|
||||
* @return
|
||||
*/
|
||||
IPage<ProcessVo> findStarted(Page<ProcessVo> pageParam);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ 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.ApprovalVo;
|
||||
import com.atguigu.vo.process.ProcessFormVo;
|
||||
import com.atguigu.vo.process.ProcessQueryVo;
|
||||
import com.atguigu.vo.process.ProcessVo;
|
||||
@ -19,10 +20,16 @@ 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.bpmn.model.BpmnModel;
|
||||
import org.activiti.bpmn.model.EndEvent;
|
||||
import org.activiti.bpmn.model.FlowNode;
|
||||
import org.activiti.bpmn.model.SequenceFlow;
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.history.HistoricTaskInstanceQuery;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
@ -31,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
@ -236,7 +244,7 @@ public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process>
|
||||
|
||||
//2 根据流程id获取流程记录信息
|
||||
LambdaQueryWrapper<ProcessRecord> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProcessRecord::getProcessId,id);
|
||||
wrapper.eq(ProcessRecord::getProcessId, id);
|
||||
List<ProcessRecord> processRecordList = oaProcessRecordService.list(wrapper);
|
||||
|
||||
//3 根据模板id查询模板信息
|
||||
@ -246,16 +254,16 @@ public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process>
|
||||
//可以看到信息不一定能审批,不能重复审批
|
||||
boolean isApprove = false;
|
||||
List<Task> taskList = this.getCurrentTaskList(process.getProcessInstanceId());
|
||||
for(Task task : taskList) {
|
||||
for (Task task : taskList) {
|
||||
//判断任务审批人是否是当前用户
|
||||
String username = LoginUserInfoHelper.getUsername();
|
||||
if(task.getAssignee().equals(username)) {
|
||||
if (task.getAssignee().equals(username)) {
|
||||
isApprove = true;
|
||||
}
|
||||
}
|
||||
|
||||
//5 查询数据封装到map集合,返回
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("process", process);
|
||||
map.put("processRecordList", processRecordList);
|
||||
map.put("processTemplate", processTemplate);
|
||||
@ -263,6 +271,165 @@ public class OaProcessServiceImpl extends ServiceImpl<OaProcessMapper, Process>
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批
|
||||
*
|
||||
* @param approvalVo
|
||||
*/
|
||||
@Override
|
||||
public void approve(ApprovalVo approvalVo) {
|
||||
//1 从approvalVo获取任务id,根据任务id获取流程变量
|
||||
String taskId = approvalVo.getTaskId();
|
||||
Map<String, Object> variables = taskService.getVariables(taskId);
|
||||
for (Map.Entry<String, Object> entry : variables.entrySet()) {
|
||||
System.out.println(entry.getKey());
|
||||
System.out.println(entry.getValue());
|
||||
}
|
||||
|
||||
//2 判断审批状态值
|
||||
if (approvalVo.getStatus() == 1) {
|
||||
//2.1 状态值 =1 审批通过
|
||||
Map<String, Object> variable = new HashMap<>();
|
||||
taskService.complete(taskId, variable);
|
||||
} else {
|
||||
//2.2 状态值 = -1 驳回,流程直接结束
|
||||
this.endTask(taskId);
|
||||
}
|
||||
|
||||
//3 记录审批相关过程信息 oa_process_record
|
||||
String description = approvalVo.getStatus().intValue() == 1 ? "已通过" : "驳回";
|
||||
oaProcessRecordService.record(approvalVo.getProcessId(), approvalVo.getStatus(), description);
|
||||
|
||||
//4 查询下一个审批人,更新流程表记录 process表记录
|
||||
Process process = baseMapper.selectById(approvalVo.getProcessId());
|
||||
//查询任务
|
||||
List<Task> taskList = this.getCurrentTaskList(process.getProcessInstanceId());
|
||||
if (!CollectionUtils.isEmpty(taskList)) {
|
||||
List<String> assignList = new ArrayList<>();
|
||||
for (Task task : taskList) {
|
||||
String assignee = task.getAssignee();
|
||||
SysUser sysUser = sysUserService.getUserByUsername(assignee);
|
||||
assignList.add(sysUser.getName());
|
||||
|
||||
//TODO 公众号消息推送
|
||||
}
|
||||
//更新process流程信息
|
||||
process.setDescription("等待" + StringUtils.join(assignList.toArray(), ",") + "审批");
|
||||
process.setStatus(1);
|
||||
} else {
|
||||
if (approvalVo.getStatus().intValue() == 1) {
|
||||
process.setDescription("审批完成(通过)");
|
||||
process.setStatus(2);
|
||||
} else {
|
||||
process.setDescription("审批完成(驳回)");
|
||||
process.setStatus(-1);
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(process);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询已处理
|
||||
*
|
||||
* @param pageParam
|
||||
* @return
|
||||
*/
|
||||
//已处理
|
||||
@Override
|
||||
public IPage<ProcessVo> findProcessed(Page<Process> pageParam) {
|
||||
//封装查询条件
|
||||
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery().taskAssignee(LoginUserInfoHelper.getUsername()).finished().orderByTaskCreateTime().desc();
|
||||
|
||||
//调用方法条件分页查询,返回list集合
|
||||
// 开始位置 和 每页显示记录数
|
||||
int begin = (int) ((pageParam.getCurrent() - 1) * pageParam.getSize());
|
||||
int size = (int) pageParam.getSize();
|
||||
List<HistoricTaskInstance> list = query.listPage(begin, size);
|
||||
long totalCount = query.count();
|
||||
|
||||
//遍历返回list集合,封装List<ProcessVo>
|
||||
List<ProcessVo> processVoList = new ArrayList<>();
|
||||
for (HistoricTaskInstance item : list) {
|
||||
//流程实例id
|
||||
String processInstanceId = item.getProcessInstanceId();
|
||||
//根据流程实例id查询获取process信息
|
||||
LambdaQueryWrapper<Process> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Process::getProcessInstanceId, processInstanceId);
|
||||
Process process = baseMapper.selectOne(wrapper);
|
||||
// process -- processVo
|
||||
ProcessVo processVo = new ProcessVo();
|
||||
BeanUtils.copyProperties(process, processVo);
|
||||
processVo.setTaskId("0");
|
||||
//放到list
|
||||
processVoList.add(processVo);
|
||||
}
|
||||
|
||||
//IPage封装分页查询所有数据,返回
|
||||
IPage<ProcessVo> pageModel = new Page<ProcessVo>(pageParam.getCurrent(), pageParam.getSize(), totalCount);
|
||||
pageModel.setRecords(processVoList);
|
||||
return pageModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询已发起
|
||||
*
|
||||
* @param pageParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<ProcessVo> findStarted(Page<ProcessVo> pageParam) {
|
||||
ProcessQueryVo processQueryVo = new ProcessQueryVo();
|
||||
processQueryVo.setUserId(LoginUserInfoHelper.getUserId());
|
||||
IPage<ProcessVo> pageModel = baseMapper.selectPage(pageParam, processQueryVo);
|
||||
for (ProcessVo item : pageModel.getRecords()) {
|
||||
item.setTaskId("0");
|
||||
}
|
||||
return pageModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束流程
|
||||
*
|
||||
* @param taskId
|
||||
*/
|
||||
private void endTask(String taskId) {
|
||||
//1 根据任务id获取任务对象 Task
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
|
||||
//2 获取流程定义模型 BpmnModel
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
||||
|
||||
//3 获取结束流向节点
|
||||
List<EndEvent> endEventList = bpmnModel.getMainProcess().findFlowElementsOfType(EndEvent.class);
|
||||
if (CollectionUtils.isEmpty(endEventList)) {
|
||||
return;
|
||||
}
|
||||
FlowNode endFlowNode = (FlowNode) endEventList.get(0);
|
||||
|
||||
//4 当前流向节点
|
||||
FlowNode currentFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
|
||||
|
||||
// 临时保存当前活动的原始方向
|
||||
List originalSequenceFlowList = new ArrayList<>();
|
||||
originalSequenceFlowList.addAll(currentFlowNode.getOutgoingFlows());
|
||||
//5 清理当前流动方向
|
||||
currentFlowNode.getOutgoingFlows().clear();
|
||||
|
||||
//6 创建新流向
|
||||
SequenceFlow newSequenceFlow = new SequenceFlow();
|
||||
newSequenceFlow.setId("newSequenceFlow");
|
||||
newSequenceFlow.setSourceFlowElement(currentFlowNode);
|
||||
newSequenceFlow.setTargetFlowElement(endFlowNode);
|
||||
|
||||
//7 当前节点指向新方向
|
||||
List newSequenceFlowList = new ArrayList();
|
||||
newSequenceFlowList.add(newSequenceFlow);
|
||||
currentFlowNode.setOutgoingFlows(newSequenceFlowList);
|
||||
|
||||
//8 完成当前任务
|
||||
taskService.complete(task.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前任务列表
|
||||
*
|
||||
|
@ -47,7 +47,11 @@ public class CodeGet {
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
|
||||
strategy.setInclude("oa_process_record");
|
||||
strategy.setInclude("wechat_menu");
|
||||
|
||||
//去掉前缀
|
||||
strategy.setTablePrefix("wechat_");
|
||||
|
||||
//数据库表映射到实体的命名策略
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
//数据库表字段映射到实体的命名策略
|
||||
|
Loading…
Reference in New Issue
Block a user