| | |
| | | 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.HistoryService; |
| | | import org.flowable.engine.history.HistoricActivityInstance; |
| | | import org.jeecg.modules.flowable.apithird.business.dto.FlowMyBusinessDto; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.mapper.FlowMyBusinessMapper; |
| | | import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; |
| | | import org.jeecg.modules.flowable.domain.dto.FlowTaskDto; |
| | | import org.jeecg.modules.flowable.util.TimeUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Isolation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: 流程业务扩展表 |
| | |
| | | @Autowired |
| | | private FlowMyBusinessMapper flowMyBusinessMapper; |
| | | |
| | | @Autowired |
| | | private HistoryService historyService; |
| | | |
| | | public HistoricActivityInstance getPreviousNode(String taskId) { |
| | | // 获取当前任务的执行实例 ID |
| | | String executionId = historyService.createHistoricTaskInstanceQuery() |
| | | .taskId(taskId) |
| | | .singleResult() |
| | | .getExecutionId(); |
| | | |
| | | // 查询历史活动实例 |
| | | List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery() |
| | | .executionId(executionId) |
| | | .activityType("userTask") |
| | | .finished() |
| | | .orderByHistoricActivityInstanceEndTime() |
| | | .desc() |
| | | .list(); |
| | | |
| | | // 取第一个结果,即上一级节点 |
| | | if (!historicActivityInstances.isEmpty()) { |
| | | return historicActivityInstances.get(0); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | @Transactional(isolation = Isolation.READ_COMMITTED) // 降低隔离级别 |
| | | public FlowMyBusiness getByDataId(String dataId) { |
| | | LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId,dataId) |
| | |
| | | * @return |
| | | */ |
| | | public IPage<FlowMyBusinessDto> getPageList(Page page, FlowMyBusinessDto flowMyBusinessDto){ |
| | | return flowMyBusinessMapper.PageList(page,flowMyBusinessDto); |
| | | IPage<FlowMyBusinessDto> flowMyBusinessDtoIPage =flowMyBusinessMapper.PageList(page,flowMyBusinessDto); |
| | | flowMyBusinessDtoIPage.getRecords().forEach(item -> { |
| | | if (!("").equals(item.getTaskId())&&item.getTaskId()!=null){ |
| | | HistoricActivityInstance historicActivityInstance = getPreviousNode(item.getTaskId()); |
| | | if (historicActivityInstance != null){ |
| | | item.setPreNode(historicActivityInstance.getActivityName()); |
| | | } |
| | | } |
| | | if (item.getDoneUsers() == null){ |
| | | item.setDoneUsers(""); |
| | | }else { |
| | | //去除[] |
| | | item.setDoneUsers(item.getDoneUsers().replaceAll("\\[", "").replaceAll("\\]", "")); |
| | | item.setDoneUsers(item.getDoneUsers().replaceAll("\"", "")); |
| | | } |
| | | //计算处理时长 |
| | | Date kssj=item.getStartTime(); |
| | | Date jssj; |
| | | if (item.getEndTime() != null){ |
| | | jssj=item.getEndTime(); |
| | | }else { |
| | | jssj=new Date(); |
| | | } |
| | | item.setDuration(TimeUtil.howLong(kssj, jssj,2)); |
| | | |
| | | }); |
| | | return flowMyBusinessDtoIPage; |
| | | } |
| | | } |