zhangherong
2025-05-28 23960f90e373266d2cb618b7ab47fe5cfb8fdbd8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.jeecg.modules.flowable.service.impl;
 
import cn.hutool.core.util.StrUtil;
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.flowable.engine.history.HistoricActivityInstance;
import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl;
import org.jeecg.modules.flowable.domain.vo.FlowMy;
import org.jeecg.modules.flowable.domain.vo.WorkTaskDataVo;
import org.jeecg.modules.flowable.mapper.IWorkTaskVoMapper;
import org.jeecg.modules.flowable.service.IWorkTaskServiceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service
public class WorkTaskServiceImplVo extends ServiceImpl<IWorkTaskVoMapper, WorkTaskDataVo> implements IWorkTaskServiceVo {
    @Autowired
    FlowMyBusinessServiceImpl flowMyBusinessService;
 
    @Override
    public IPage<WorkTaskDataVo> toTaskBySelf(FlowMy flowMy, Page page) {
        IPage<WorkTaskDataVo> workTaskDataVoIPage = baseMapper.taskBySelf(flowMy, page);
        workTaskDataVoIPage.getRecords().forEach(workTaskDataVo -> {
            HistoricActivityInstance historicActivityInstance = flowMyBusinessService.getPreviousNode(workTaskDataVo.getId());
            if (historicActivityInstance != null) {
                workTaskDataVo.setPreNode(historicActivityInstance.getActivityName());
                workTaskDataVo.setPreNodeAssignee(historicActivityInstance.getAssignee());
            }
            if (StrUtil.isEmpty(workTaskDataVo.getAssignee())) {
                workTaskDataVo.setAssignee(flowMy.getUsername());
            }
        });
        return workTaskDataVoIPage;
    }
 
    @Override
    public Integer taskCountBySelf(String username) {
        Integer count = baseMapper.taskCountBySelf(username);
        if (count == null) {
            return 0;
        }
        return count;
    }
}