|
@@ -43,6 +43,7 @@ import org.flowable.engine.HistoryService;
|
|
|
import org.flowable.engine.RepositoryService;
|
|
|
import org.flowable.engine.RuntimeService;
|
|
|
import org.flowable.engine.TaskService;
|
|
|
+import org.flowable.engine.history.HistoricProcessInstance;
|
|
|
import org.flowable.engine.runtime.ProcessInstance;
|
|
|
import org.flowable.task.api.Task;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -146,7 +147,7 @@ public class FlowableTaskController {
|
|
|
Future<?> cpa = executorService.submit(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- System.out.println("cpa任务开始"+sdf.format(new Date()));
|
|
|
+ System.out.println("查询cpa待办开始"+sdf.format(new Date()));
|
|
|
try {
|
|
|
// cpa系统待办数据查询
|
|
|
if (inquireStatus.contains("cpa") || ("cpa").equals(belongProject)) {
|
|
@@ -170,14 +171,14 @@ public class FlowableTaskController {
|
|
|
}
|
|
|
// 当前线程执行完毕,计数器 -1
|
|
|
countDownLatch.countDown();
|
|
|
- System.out.println("cpa任务结束"+sdf.format(new Date()));
|
|
|
+ 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()));
|
|
|
+ System.out.println("查询ccpm待办开始"+sdf.format(new Date()));
|
|
|
try{
|
|
|
// ccpm系统待办数据查询
|
|
|
if (inquireStatus.contains("ccpm") || ("ccpm").equals(belongProject)) {
|
|
@@ -201,7 +202,7 @@ public class FlowableTaskController {
|
|
|
}
|
|
|
// 当前线程执行完毕,计数器 -1
|
|
|
countDownLatch.countDown();
|
|
|
- System.out.println("ccpm任务结束"+sdf.format(new Date()));
|
|
|
+ System.out.println("查询ccpm待办结束"+sdf.format(new Date()));
|
|
|
}
|
|
|
});
|
|
|
// 阻塞 等待线程池任务执行完后再执行后面代码
|
|
@@ -239,9 +240,125 @@ public class FlowableTaskController {
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("historic")
|
|
|
- public ResponseEntity historicListData(Page<HisTaskVo> page, Flow flow) {
|
|
|
- page = flowTaskService.historicList(page, flow);
|
|
|
- return ResponseEntity.ok ( page );
|
|
|
+ public ResponseEntity historicListData(Page<HisTaskVo> page, Flow flow) throws Exception {
|
|
|
+ //获取当前登陆人的信息
|
|
|
+ UserDTO currentUserDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ //判定如果当前登陆人是否可以查看其他服务的待办信息
|
|
|
+ if("1".equals(currentUserDTO.getOtherServiceFlag())){
|
|
|
+ // 中台数据查询
|
|
|
+ List<Map<String, Object>> cpa = queryHistoricListCenter(flow, "cpa", Global.getConfig("INQUIRE_STATUS"));
|
|
|
+ if (cpa.size() > 0) {
|
|
|
+ List<HisTaskVo> list = JSON.parseArray(JSON.toJSONString(cpa), HisTaskVo.class);
|
|
|
+ List<HisTaskVo> hisTaskVos = ConvertServiceUtil.convertHisTaskVoList(list);
|
|
|
+ // 将整合后的结果排序后分页
|
|
|
+ Page sortAndPaging = ConvertServiceUtil.getSortAndPagingHisTask(page, hisTaskVos);
|
|
|
+ return ResponseEntity.ok (sortAndPaging);
|
|
|
+ } else {
|
|
|
+ // 如果中台没有返回任何数据,就去查询本系统分页待办数据
|
|
|
+ Page <HisTaskVo> pageList = flowTaskService.historicList(page, flow, currentUserDTO);
|
|
|
+ return ResponseEntity.ok (pageList);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 查询本系统分页待办数据
|
|
|
+ Page <HisTaskVo> pageList = flowTaskService.historicList(page, flow, currentUserDTO);
|
|
|
+ return ResponseEntity.ok (pageList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("queryHistoricListCenter")
|
|
|
+ public List<Map<String,Object>> queryHistoricListCenter(Flow flow,String belongProject,String inquireStatus) throws Exception {
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ List<HisTaskVo> hisTaskVoList = new ArrayList<>();
|
|
|
+ // 任务数量(线程池的线程数量、计数器的值)
|
|
|
+ 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");
|
|
|
+ // 获取当前登录人信息
|
|
|
+ UserDTO currentUserDTO = UserUtils.getCurrentUserDTO();
|
|
|
+ // 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<HisTaskVo> pageList = flowTaskService.historicList(new Page<>(1, -1), flow, currentUserDTO);
|
|
|
+ pageList.getRecords().stream().forEach(item -> {
|
|
|
+ item.setBelongProject("cpa");
|
|
|
+ // 设置 processDefKey
|
|
|
+ if (StringUtils.isNotBlank(item.getProcessDefinitionId())) {
|
|
|
+ String[] split = item.getProcessDefinitionId().split(":");
|
|
|
+ if(split.length>0) {
|
|
|
+ item.setProcessDefKey(split[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 设置 businessId
|
|
|
+ HistoricProcessInstance finishedProcIns = flowTaskService.getFinishedProcIns(item.getProcessInstanceId());
|
|
|
+ if (finishedProcIns != null && finishedProcIns.getBusinessKey() != null && finishedProcIns.getBusinessKey().contains(":")) {
|
|
|
+ String[] ss = finishedProcIns.getBusinessKey().split(":");
|
|
|
+ item.setBusinessId(ss[1]);
|
|
|
+ } else if (finishedProcIns != null && finishedProcIns.getBusinessKey() != null) {
|
|
|
+ item.setBusinessId(finishedProcIns.getBusinessKey());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ hisTaskVoList.addAll(pageList.getRecords());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("cpa系统待办查询失败");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ // 当前线程执行完毕,计数器 -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.getHisTaskList(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 { // 如果是其他系统查询,则将结果格式化后返回
|
|
|
+ if (CollectionUtil.isNotEmpty(res)) {
|
|
|
+ List<HisTaskVo> hisTaskVos = JSON.parseArray(JSON.toJSONString(res), HisTaskVo.class);
|
|
|
+ hisTaskVoList.addAll(hisTaskVos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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)) {
|
|
|
+ result.addAll(JSON.parseArray(JSON.toJSONString(hisTaskVoList)));
|
|
|
+ } else if ("ccpm".equals(belongProject)) {
|
|
|
+ result.addAll(ConvertServiceUtil.copyHisTaskListToCcpm(hisTaskVoList));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|