From 5cd4558fb1a7178653d77e1a982e6f26d06b5db5 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期一, 31 三月 2025 17:39:00 +0800
Subject: [PATCH] 中心综合利用率趋势接口

---
 lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/business/service/impl/FlowMyBusinessServiceImpl.java |   81 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 78 insertions(+), 3 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 8dbf02e..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,11 +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: 娴佺▼涓氬姟鎵╁睍琛�
@@ -18,7 +28,37 @@
  */
 @Service
 public class FlowMyBusinessServiceImpl extends ServiceImpl<FlowMyBusinessMapper, FlowMyBusiness> implements IFlowMyBusinessService {
+    @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)
@@ -39,12 +79,47 @@
     }
 
     /**
+     * 娴佺▼-鎴戠殑宸插姙
+     * @param flowMyBusinessDto
+     * @param page
+     * @return
+     */
+    public IPage<FlowTaskDto> getPageListMyBusiness(Page page, FlowMyBusinessDto flowMyBusinessDto){
+        return flowMyBusinessMapper.PageListMyBusiness(page,flowMyBusinessDto);
+    }
+
+    /**
      * 娴佺▼鎬诲彴璐�
      * @param flowMyBusinessDto
      * @return
      */
-    @Override
-    public IPage<FlowMyBusinessDto> findPageList(Page page, FlowMyBusinessDto flowMyBusinessDto){
-        return this.baseMapper.findPageList(page,flowMyBusinessDto);
+    public IPage<FlowMyBusinessDto> getPageList(Page page, FlowMyBusinessDto 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