|
@@ -33,6 +33,7 @@ import com.jeeplus.sys.constant.CommonConstants;
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.sys.utils.Global;
|
|
import com.jeeplus.sys.utils.Global;
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
|
+import lombok.SneakyThrows;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.flowable.bpmn.model.Process;
|
|
import org.flowable.bpmn.model.Process;
|
|
@@ -51,6 +52,7 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 流程个人任务相关Controller
|
|
* 流程个人任务相关Controller
|
|
@@ -131,36 +133,78 @@ public class FlowableTaskController {
|
|
public List<Map<String,Object>> queryTodoListCenter(Flow flow,String belongProject,String inquireStatus) throws Exception {
|
|
public List<Map<String,Object>> queryTodoListCenter(Flow flow,String belongProject,String inquireStatus) throws Exception {
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
List<ProcessVo> processVoList = new ArrayList<>();
|
|
List<ProcessVo> processVoList = new ArrayList<>();
|
|
- // cpa系统
|
|
|
|
- if (inquireStatus.contains("cpa") || ("cpa").equals(belongProject)) {
|
|
|
|
- Page <ProcessVo> pageList = flowTaskService.todoList(new Page<>(1, -1), flow);
|
|
|
|
- pageList.getRecords().stream().forEach(item->{
|
|
|
|
- item.setBelongProject("cpa");
|
|
|
|
- // 查询审核人
|
|
|
|
- if (Objects.nonNull(item.getTask()) && StringUtils.isNotBlank(item.getTask().getAssignee())) {
|
|
|
|
- UserDTO userDTO = UserUtils.get(item.getTask().getAssignee());
|
|
|
|
- if (Objects.nonNull(userDTO) && StringUtils.isNotBlank(userDTO.getName())) {
|
|
|
|
- item.getTask().setAssignee(userDTO.getName());
|
|
|
|
|
|
+ // 任务数量(线程池的线程数量、计数器的值)
|
|
|
|
+ int taskVolume = 2;
|
|
|
|
+ // 创建线程池
|
|
|
|
+ ExecutorService executorService = Executors.newFixedThreadPool(taskVolume);
|
|
|
|
+ // 创建单次计数器(事实上就是创建多个锁,每次.countDown()会释放一把锁,使用.await()就是等待全部锁被释放,所以这个计数器是线程安全的)
|
|
|
|
+ CountDownLatch countDownLatch = new CountDownLatch(taskVolume);
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ // cpa线程任务
|
|
|
|
+ Future<?> cpa = executorService.submit(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ System.out.println("cpa任务开始"+sdf.format(new Date()));
|
|
|
|
+ try {
|
|
|
|
+ // cpa系统待办数据查询
|
|
|
|
+ if (inquireStatus.contains("cpa") || ("cpa").equals(belongProject)) {
|
|
|
|
+ Page<ProcessVo> pageList = flowTaskService.todoList(new Page<>(1, -1), flow);
|
|
|
|
+ pageList.getRecords().stream().forEach(item -> {
|
|
|
|
+ item.setBelongProject("cpa");
|
|
|
|
+ // 查询审核人
|
|
|
|
+ if (Objects.nonNull(item.getTask()) && StringUtils.isNotBlank(item.getTask().getAssignee())) {
|
|
|
|
+ UserDTO userDTO = UserUtils.get(item.getTask().getAssignee());
|
|
|
|
+ if (Objects.nonNull(userDTO) && StringUtils.isNotBlank(userDTO.getName())) {
|
|
|
|
+ item.getTask().setAssignee(userDTO.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ List<ProcessVo> processVos = pageList.getRecords();
|
|
|
|
+ processVoList.addAll(processVos);
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println("cpa系统待办查询失败");
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
- });
|
|
|
|
- List<ProcessVo> processVos = pageList.getRecords();
|
|
|
|
- processVoList.addAll(processVos);
|
|
|
|
- }
|
|
|
|
- // ccpm系统
|
|
|
|
- if(inquireStatus.contains("ccpm") || ("ccpm").equals(belongProject)){
|
|
|
|
- // 访问ccpm
|
|
|
|
- Object response = flowRequest.getNotifyList(flow, belongProject);
|
|
|
|
- if (Objects.nonNull(response)) {
|
|
|
|
- List<Map<String, Object>> res = JSONObject.parseArray(JSON.toJSONString(response));
|
|
|
|
- if (("ccpm").equals(belongProject)) { // 如果是ccpm系统查询,则直接返回
|
|
|
|
- result.addAll(res);
|
|
|
|
- } else { // 如果是其他系统查询,则将结果格式化后返回
|
|
|
|
- List<ProcessVo> processVos = ConvertServiceUtil.convertProcessVoList(res);
|
|
|
|
- processVoList.addAll(processVos);
|
|
|
|
|
|
+ // 当前线程执行完毕,计数器 -1
|
|
|
|
+ countDownLatch.countDown();
|
|
|
|
+ System.out.println("cpa任务结束"+sdf.format(new Date()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ // ccpm线程任务
|
|
|
|
+ Future<?> ccpm = executorService.submit(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ System.out.println("ccpm任务开始"+sdf.format(new Date()));
|
|
|
|
+ try{
|
|
|
|
+ // ccpm系统待办数据查询
|
|
|
|
+ if (inquireStatus.contains("ccpm") || ("ccpm").equals(belongProject)) {
|
|
|
|
+ // 访问ccpm
|
|
|
|
+ Object response = flowRequest.getNotifyList(flow, belongProject);
|
|
|
|
+ if (Objects.nonNull(response)) {
|
|
|
|
+ List<Map<String, Object>> res = JSONObject.parseArray(JSON.toJSONString(response));
|
|
|
|
+ if (("ccpm").equals(belongProject)) { // 如果是ccpm系统查询,则直接返回
|
|
|
|
+ result.addAll(res);
|
|
|
|
+ } else { // 如果是其他系统查询,则将结果格式化后返回
|
|
|
|
+ List<ProcessVo> processVos = ConvertServiceUtil.convertProcessVoList(res);
|
|
|
|
+ processVoList.addAll(processVos);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println("ccpm系统待办查询失败");
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+ // 当前线程执行完毕,计数器 -1
|
|
|
|
+ countDownLatch.countDown();
|
|
|
|
+ System.out.println("ccpm任务结束"+sdf.format(new Date()));
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ });
|
|
|
|
+ // 阻塞 等待线程池任务执行完后再执行后面代码
|
|
|
|
+ // 设置最大等待时间 5秒
|
|
|
|
+ countDownLatch.await(5,TimeUnit.SECONDS);
|
|
|
|
+ // 关闭线程池
|
|
|
|
+ executorService.shutdown();
|
|
// 根据不同系统返回不同字段值
|
|
// 根据不同系统返回不同字段值
|
|
if ("cpa".equals(belongProject)) {
|
|
if ("cpa".equals(belongProject)) {
|
|
result.addAll(JSON.parseArray(JSON.toJSONString(processVoList)));
|
|
result.addAll(JSON.parseArray(JSON.toJSONString(processVoList)));
|