springboot+flowable入门第四篇

本文介绍了SpringBoot结合Flowable实现任务管理的三个核心操作:查询个人任务、完成任务及查看历史任务。通过示例代码展示了如何使用TaskService查询当前分配给'张三'的任务,获取并打印任务变量,以及如何完成指定ID的任务。此外,还展示了如何查询历史任务列表,并打印任务名称及结束时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

springboot+flowable入门第四篇

对应哔哩哔哩的第六集
https://www.bilibili.com/video/BV1rg411N7QJ?p=6
对应代码码云地址
https://gitee.com/fjdaima/flowable_study01

1.查询自己的任务

    /**
     * 查看任务表
     */
    @RequestMapping("/query/task")
    public String queryTask(){
        TaskService taskService = processEngine.getTaskService();
        Task task = taskService.createTaskQuery().taskAssignee("张三").singleResult();
        Map<String, Object> processVariables = taskService.getVariables(task.getId());
        System.out.println("员工名字"+processVariables.get("employee"));
        System.out.println("员工请假天数"+processVariables.get("nrOfHolidays"));
        System.out.println("员工理由"+processVariables.get("description"));
        return "成功";
    }

2.完成自己的任务

    /**
     * 完成自己的任务
     */
    @RequestMapping("/complete/task")
    public String completeTask(){
        TaskService taskService = processEngine.getTaskService();
        String taskId = "5008";
        taskService.complete(taskId);
        return "成功";
    }

2.查看自己的历史任务

    /**
     * 查看自己的历史
     */
    @RequestMapping("/history/task")
    public String historyTask(){
        String name = "张三";
        HistoryService historyService = processEngine.getHistoryService();
        List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskAssignee(name).list();
        for (HistoricTaskInstance historicTaskInstance: list){

            System.out.println(historicTaskInstance.getName() + "=====" +new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(historicTaskInstance.getEndTime()));
        }
        return "成功";
    }

参考他人文章

https://blog.youkuaiyun.com/Master_chaoAndQi/article/details/80639362
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_43472248

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值