|
@@ -3,26 +3,21 @@ package com.ningdatech.pmapi.instance; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
|
|
import com.ningdatech.pmapi.AppTests; |
|
|
import com.ningdatech.pmapi.AppTests; |
|
|
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; |
|
|
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; |
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; |
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; |
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; |
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; |
|
|
import com.wflow.contants.ProcessConstant; |
|
|
|
|
|
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; |
|
|
|
|
|
import com.wflow.workflow.bean.dto.TodoCenterListReqDTO; |
|
|
import com.wflow.workflow.bean.dto.TodoCenterListReqDTO; |
|
|
import com.wflow.workflow.enums.ProcessHandlerEnum; |
|
|
|
|
|
import org.flowable.engine.HistoryService; |
|
|
import org.flowable.engine.HistoryService; |
|
|
import org.flowable.engine.RuntimeService; |
|
|
import org.flowable.engine.RuntimeService; |
|
|
import org.flowable.engine.history.HistoricActivityInstance; |
|
|
import org.flowable.engine.history.HistoricActivityInstance; |
|
|
|
|
|
import org.flowable.engine.history.HistoricProcessInstance; |
|
|
import org.flowable.engine.runtime.ActivityInstance; |
|
|
import org.flowable.engine.runtime.ActivityInstance; |
|
|
import org.flowable.task.api.history.HistoricTaskInstance; |
|
|
import org.flowable.task.api.history.HistoricTaskInstance; |
|
|
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery; |
|
|
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery; |
|
|
import org.flowable.variable.api.history.HistoricVariableInstance; |
|
|
|
|
|
import org.junit.Test; |
|
|
import org.junit.Test; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
@@ -49,7 +44,7 @@ public class InstanceTest extends AppTests { |
|
|
private IProjectInstService projectInstService; |
|
|
private IProjectInstService projectInstService; |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void test(){ |
|
|
|
|
|
|
|
|
public void test() { |
|
|
String instanceId = "896fa188-96d8-11ed-9539-e2d4e8f16b2f"; |
|
|
String instanceId = "896fa188-96d8-11ed-9539-e2d4e8f16b2f"; |
|
|
Object user = runtimeService.getVariable(instanceId, |
|
|
Object user = runtimeService.getVariable(instanceId, |
|
|
"owner"); |
|
|
"owner"); |
|
@@ -57,7 +52,7 @@ public class InstanceTest extends AppTests { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testHistory(){ |
|
|
|
|
|
|
|
|
public void testHistory() { |
|
|
//如果有已经被审核过的 节点 |
|
|
//如果有已经被审核过的 节点 |
|
|
List<HistoricActivityInstance> finished = historyService.createHistoricActivityInstanceQuery() |
|
|
List<HistoricActivityInstance> finished = historyService.createHistoricActivityInstanceQuery() |
|
|
.processInstanceId("085af7ef-d133-11ed-a3f6-02426daa406d").finished() |
|
|
.processInstanceId("085af7ef-d133-11ed-a3f6-02426daa406d").finished() |
|
@@ -68,7 +63,7 @@ public class InstanceTest extends AppTests { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testRuntime(){ |
|
|
|
|
|
|
|
|
public void testRuntime() { |
|
|
//如果有已经被审核过的 节点 |
|
|
//如果有已经被审核过的 节点 |
|
|
List<ActivityInstance> userTask = runtimeService.createActivityInstanceQuery() |
|
|
List<ActivityInstance> userTask = runtimeService.createActivityInstanceQuery() |
|
|
.processInstanceId("1709ebe3-d148-11ed-9351-02426daa406d") |
|
|
.processInstanceId("1709ebe3-d148-11ed-9351-02426daa406d") |
|
@@ -78,7 +73,7 @@ public class InstanceTest extends AppTests { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void testTodo(){ |
|
|
|
|
|
|
|
|
public void testTodo() { |
|
|
String employeeCode = "GE_e9d5c7917acd4eeea04ff2a9454af62e"; |
|
|
String employeeCode = "GE_e9d5c7917acd4eeea04ff2a9454af62e"; |
|
|
// 查出项目库项目 |
|
|
// 查出项目库项目 |
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
|
ProjectListReq projectListReq = new ProjectListReq(); |
|
@@ -93,7 +88,7 @@ public class InstanceTest extends AppTests { |
|
|
List<ProjectInst> projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) |
|
|
List<ProjectInst> projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) |
|
|
.in(ProjectInst::getProjectId, projectIdList) |
|
|
.in(ProjectInst::getProjectId, projectIdList) |
|
|
.orderByDesc(ProjectInst::getProjectId)); |
|
|
.orderByDesc(ProjectInst::getProjectId)); |
|
|
Map<String, Project> projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); |
|
|
|
|
|
|
|
|
Map<String, Project> projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); |
|
|
List<String> instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); |
|
|
List<String> instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
// 查出用户工作流 |
|
|
// 查出用户工作流 |
|
@@ -108,7 +103,7 @@ public class InstanceTest extends AppTests { |
|
|
historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql); |
|
|
historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql); |
|
|
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list(); |
|
|
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list(); |
|
|
|
|
|
|
|
|
Set set = new HashSet(); |
|
|
|
|
|
|
|
|
Set<String> set = new HashSet<>(); |
|
|
List<HistoricTaskInstance> taskInstanceList = taskInstances.stream() |
|
|
List<HistoricTaskInstance> taskInstanceList = taskInstances.stream() |
|
|
.filter(t -> instCodes.contains(t.getProcessInstanceId())) |
|
|
.filter(t -> instCodes.contains(t.getProcessInstanceId())) |
|
|
.sorted(Comparator.comparing(HistoricTaskInstance::getEndTime)).collect(Collectors.toList()) |
|
|
.sorted(Comparator.comparing(HistoricTaskInstance::getEndTime)).collect(Collectors.toList()) |
|
@@ -120,14 +115,34 @@ public class InstanceTest extends AppTests { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
public void test2(){ |
|
|
|
|
|
|
|
|
public void test2() { |
|
|
// 获取节点处理结果 |
|
|
// 获取节点处理结果 |
|
|
// Map<String, ProcessHandlerEnum> varMap = historyService.createHistoricVariableInstanceQuery() |
|
|
// Map<String, ProcessHandlerEnum> varMap = historyService.createHistoricVariableInstanceQuery() |
|
|
// .processInstanceId("e99fe24c-d21c-11ed-af5d-02426daa406d") |
|
|
// .processInstanceId("e99fe24c-d21c-11ed-af5d-02426daa406d") |
|
|
// .variableNameLike("approve_%") |
|
|
// .variableNameLike("approve_%") |
|
|
// .list().stream() |
|
|
// .list().stream() |
|
|
// .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ProcessHandlerEnum) v.getValue())); |
|
|
// .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ProcessHandlerEnum) v.getValue())); |
|
|
runtimeService.removeVariable("564102ce-d1ff-11ed-b694-02424b2b849f","approve_7d2a191a-d1ff-11ed-b694-02424b2b849f"); |
|
|
|
|
|
|
|
|
runtimeService.removeVariable("564102ce-d1ff-11ed-b694-02424b2b849f", "approve_7d2a191a-d1ff-11ed-b694-02424b2b849f"); |
|
|
System.out.println(1); |
|
|
System.out.println(1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void usageTimeStat() { |
|
|
|
|
|
// 查询所有已完成的流程实例 |
|
|
|
|
|
List<HistoricProcessInstance> processInstanceList = historyService.createHistoricProcessInstanceQuery() |
|
|
|
|
|
.orderByProcessInstanceStartTime() |
|
|
|
|
|
.desc() |
|
|
|
|
|
.finished() |
|
|
|
|
|
.list(); |
|
|
|
|
|
|
|
|
|
|
|
// 统计每个流程实例的审批耗时 |
|
|
|
|
|
for (HistoricProcessInstance processInstance : processInstanceList) { |
|
|
|
|
|
System.out.println("流程实例ID:" + processInstance.getId()); |
|
|
|
|
|
System.out.println("流程开始时间:" + processInstance.getStartTime()); |
|
|
|
|
|
System.out.println("流程结束时间:" + processInstance.getEndTime()); |
|
|
|
|
|
System.out.println("流程耗时(ms):" + processInstance.getDurationInMillis() / 1000); |
|
|
|
|
|
System.out.println("================================================================"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |