提交 e7241d13 authored 作者: whydesc's avatar whydesc

--新增业务流程履历表

上级 151ebb5b
......@@ -284,92 +284,6 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
}
}
// 给第一步申请人节点设置任务执行人和意见
// Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
// if (Objects.nonNull(task)) {
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getRealname() + "发起流程申请");
// taskService.setAssignee(task.getId(),sysUser.getUsername());
// taskService.complete(task.getId(), variables);
// }
/*======================todo 启动之后 回调以及关键数据保存======================*/
/**
//业务数据id
String dataId = variables.get("dataId").toString();
//如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId);
//设置数据
FlowNextDto nextFlowNode = flowTaskService.getNextFlowNode(task.getId(), variables);
taskService.complete(task.getId(), variables);
//下一个实例节点 多实例会是一个list,随意取一个即可 数组中定义Key是一致的
//Task task2 = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
List<Task> task2List = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().list();
Task task2 = null;
if(task2List.size()>0) task2 = task2List.get(0);
String doneUsers = business.getDoneUsers();
// 处理过流程的人
JSONArray doneUserList = new JSONArray();
if (StrUtil.isNotBlank(doneUsers)){
doneUserList = JSON.parseArray(doneUsers);
}
if (!doneUserList.contains(sysUser.getUsername())){
doneUserList.add(sysUser.getUsername());
}
if (nextFlowNode!=null){
//**有下一个节点
UserTask nextTask = nextFlowNode.getUserTask();
//能够处理下个节点的候选人
List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList();
List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList());
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), variables);
if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){
// 删除后重写
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.deleteCandidateUser(task2One.getId(),oldUser);
}
}
// 业务层有指定候选人,覆盖
for (Task task2One : task2List) {
for (String newUser : beforeParamsCandidateUsernames) {
taskService.addCandidateUser(task2One.getId(),newUser);
}
}
business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames));
}
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.start)
.setProposer(sysUser.getUsername())
.setTaskId(task2.getId())
.setTaskName(nextTask.getName())
.setTaskNameId(nextTask.getId())
.setPriority(nextTask.getPriority())
.setDoneUsers(doneUserList.toJSONString())
.setTodoUsers(JSON.toJSONString(collect_username))
;
} else {
// **没有下一个节点,流程已经结束了
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.pass)
.setProposer(sysUser.getUsername())
.setDoneUsers(doneUserList.toJSONString())
;
}
flowMyBusinessService.updateById(business);
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
// 流程处理完后,进行回调业务层
business.setValues(variables);
if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business);
*/
return Result.OK("流程启动成功");
} catch (Exception e) {
e.printStackTrace();
......@@ -519,85 +433,8 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
}
/*======================todo 启动之后 回调以及关键数据保存======================*/
/**
//业务数据id
String dataId = variables.get("dataId").toString();
//如果保存数据前未调用必调的FlowCommonService.initActBusiness方法,就会有问题
FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId);
//设置数据
FlowNextDto nextFlowNode = flowTaskService.getNextFlowNode(task.getId(), variables);
taskService.complete(task.getId(), variables);
//下一个实例节点 多实例会是一个list,随意取一个即可 数组中定义Key是一致的
//Task task2 = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult();
List<Task> task2List = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().list();
Task task2 = null;
if(task2List.size()>0) task2 = task2List.get(0);
String doneUsers = business.getDoneUsers();
// 处理过流程的人
JSONArray doneUserList = new JSONArray();
if (StrUtil.isNotBlank(doneUsers)){
doneUserList = JSON.parseArray(doneUsers);
}
if (!doneUserList.contains(sysUser.getUsername())){
doneUserList.add(sysUser.getUsername());
}
if (nextFlowNode!=null){
//**有下一个节点
UserTask nextTask = nextFlowNode.getUserTask();
//能够处理下个节点的候选人
List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList();
List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList());
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionKey(), variables);
if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)){
// 删除后重写
for (Task task2One : task2List) {
for (String oldUser : collect_username) {
taskService.deleteCandidateUser(task2One.getId(),oldUser);
}
}
// 业务层有指定候选人,覆盖
for (Task task2One : task2List) {
for (String newUser : beforeParamsCandidateUsernames) {
taskService.addCandidateUser(task2One.getId(),newUser);
}
}
business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames));
}
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.start)
.setProposer(sysUser.getUsername())
.setTaskId(task2.getId())
.setTaskName(nextTask.getName())
.setTaskNameId(nextTask.getId())
.setPriority(nextTask.getPriority())
.setDoneUsers(doneUserList.toJSONString())
.setTodoUsers(JSON.toJSONString(collect_username))
;
} else {
// **没有下一个节点,流程已经结束了
business.setProcessDefinitionId(procDefId)
.setProcessInstanceId(processInstance.getProcessInstanceId())
.setActStatus(ActStatus.pass)
.setProposer(sysUser.getUsername())
.setDoneUsers(doneUserList.toJSONString())
;
}
flowMyBusinessService.updateById(business);
//spring容器类名
String serviceImplName = business.getServiceImplName();
FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName);
// 流程处理完后,进行回调业务层
business.setValues(variables);
if (flowCallBackService!=null)flowCallBackService.afterFlowHandle(business);
*/
return Result.OK(result);
} catch (Exception e) {
e.printStackTrace();
......
package org.jeecg.modules.stm.my.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import org.jeecg.modules.stm.my.service.IMyTaskFlowHisService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
@Tag(name="my_task_flow_his")
@RestController
@RequestMapping("/my/myTaskFlowHis")
@Slf4j
public class MyTaskFlowHisController extends JeecgController<MyTaskFlowHis, IMyTaskFlowHisService> {
@Autowired
private IMyTaskFlowHisService myTaskFlowHisService;
/**
* 分页列表查询
*
* @param myTaskFlowHis
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "my_task_flow_his-分页列表查询")
@Operation(summary="my_task_flow_his-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MyTaskFlowHis>> queryPageList(MyTaskFlowHis myTaskFlowHis,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MyTaskFlowHis> queryWrapper = QueryGenerator.initQueryWrapper(myTaskFlowHis, req.getParameterMap());
Page<MyTaskFlowHis> page = new Page<MyTaskFlowHis>(pageNo, pageSize);
IPage<MyTaskFlowHis> pageList = myTaskFlowHisService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param myTaskFlowHis
* @return
*/
@AutoLog(value = "my_task_flow_his-添加")
@Operation(summary="my_task_flow_his-添加")
@RequiresPermissions("my:my_task_flow_his:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MyTaskFlowHis myTaskFlowHis) {
myTaskFlowHisService.save(myTaskFlowHis);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param myTaskFlowHis
* @return
*/
@AutoLog(value = "my_task_flow_his-编辑")
@Operation(summary="my_task_flow_his-编辑")
@RequiresPermissions("my:my_task_flow_his:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody MyTaskFlowHis myTaskFlowHis) {
myTaskFlowHisService.updateById(myTaskFlowHis);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "my_task_flow_his-通过id删除")
@Operation(summary="my_task_flow_his-通过id删除")
@RequiresPermissions("my:my_task_flow_his:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
myTaskFlowHisService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "my_task_flow_his-批量删除")
@Operation(summary="my_task_flow_his-批量删除")
@RequiresPermissions("my:my_task_flow_his:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.myTaskFlowHisService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "my_task_flow_his-通过id查询")
@Operation(summary="my_task_flow_his-通过id查询")
@GetMapping(value = "/queryById")
public Result<MyTaskFlowHis> queryById(@RequestParam(name="id",required=true) String id) {
MyTaskFlowHis myTaskFlowHis = myTaskFlowHisService.getById(id);
if(myTaskFlowHis==null) {
return Result.error("未找到对应数据");
}
return Result.OK(myTaskFlowHis);
}
/**
* 导出excel
*
* @param request
* @param myTaskFlowHis
*/
@RequiresPermissions("my:my_task_flow_his:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MyTaskFlowHis myTaskFlowHis) {
return super.exportXls(request, myTaskFlowHis, MyTaskFlowHis.class, "my_task_flow_his");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("my:my_task_flow_his:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MyTaskFlowHis.class);
}
}
package org.jeecg.modules.stm.my.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
@Data
@TableName("my_task_flow_his")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description="my_task_flow_his")
public class MyTaskFlowHis implements Serializable {
private static final long serialVersionUID = 1L;
/**id*/
@TableId(type = IdType.AUTO)
@Schema(description = "id")
private java.lang.Integer id;
/**表单的表名ID*/
@Excel(name = "表单的表名ID", width = 15)
@Schema(description = "表单的表名ID")
private java.lang.String formTableName;
/**业务主表ID*/
@Excel(name = "业务主表ID", width = 15)
@Schema(description = "业务主表ID")
private java.lang.String targetId;
/**部署ID*/
@Excel(name = "部署ID", width = 15)
@Schema(description = "部署ID")
private java.lang.String deployId;
/**任务ID*/
@Excel(name = "任务ID", width = 15)
@Schema(description = "任务ID")
private java.lang.String taskId;
/**实例ID*/
@Excel(name = "实例ID", width = 15)
@Schema(description = "实例ID")
private java.lang.String procInsId;
/**执行ID*/
@Excel(name = "执行ID", width = 15)
@Schema(description = "执行ID")
private java.lang.String executionId;
/**流程定义ID*/
@Excel(name = "流程定义ID", width = 15)
@Schema(description = "流程定义ID")
private java.lang.String procDefId;
/**代办人*/
@Excel(name = "代办人", width = 15)
@Schema(description = "代办人")
private java.lang.String uid;
/**代办角色*/
@Excel(name = "代办角色", width = 15)
@Schema(description = "代办角色")
private java.lang.String roleid;
/**节点ID*/
@Excel(name = "节点ID", width = 15)
@Schema(description = "节点ID")
private java.lang.String taskDefinitionKey;
/**操作时间*/
@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "操作时间")
private java.util.Date optionTime;
/**操作人*/
@Excel(name = "操作人", width = 15)
@Schema(description = "操作人")
private java.lang.String optionId;
/**操作类型*/
@Excel(name = "操作类型", width = 15)
@Schema(description = "操作类型")
private java.lang.String optionType;
/**节点类型*/
@Excel(name = "节点类型", width = 15)
@Schema(description = "节点类型")
private java.lang.String taskType;
}
package org.jeecg.modules.stm.my.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
public interface MyTaskFlowHisMapper extends BaseMapper<MyTaskFlowHis> {
}
package org.jeecg.modules.stm.my.service;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
public interface IMyTaskFlowHisService extends IService<MyTaskFlowHis> {
}
package org.jeecg.modules.stm.my.service.impl;
import org.jeecg.modules.stm.my.entity.MyTaskFlowHis;
import org.jeecg.modules.stm.my.mapper.MyTaskFlowHisMapper;
import org.jeecg.modules.stm.my.service.IMyTaskFlowHisService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: my_task_flow_his
* @Author: jeecg-boot
* @Date: 2026-04-10
* @Version: V1.0
*/
@Service
public class MyTaskFlowHisServiceImpl extends ServiceImpl<MyTaskFlowHisMapper, MyTaskFlowHis> implements IMyTaskFlowHisService {
}
<?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="org.jeecg.modules.stm.my.mapper.MyTaskFlowHisMapper">
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论