From bc263d8bed5d1405f275bb8638a9bec9eaf06585 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期一, 31 三月 2025 09:42:00 +0800 Subject: [PATCH] 添加审签逻辑,移动flow通用代码,添加根据角色查询用户,新增时间工具类,修改指派设备bug --- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java | 64 +++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 1 deletions(-) diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java index b1bf9e6..ce39c92 100644 --- a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java @@ -4,13 +4,21 @@ 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: 娴佺▼涓氬姟鎵╁睍琛� @@ -23,6 +31,34 @@ @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) @@ -58,6 +94,32 @@ * @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; } } -- Gitblit v1.9.3