|
|
@@ -0,0 +1,141 @@
|
|
|
+package com.xunmei.core.panel.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.xunmei.common.core.domain.panel.adapter.PanelAdapter;
|
|
|
+import com.xunmei.common.core.domain.panel.dto.PanelListDto;
|
|
|
+import com.xunmei.common.core.domain.panel.enums.PanelTypeEnums;
|
|
|
+import com.xunmei.common.core.domain.panel.vo.PanelListVo;
|
|
|
+import com.xunmei.common.core.domain.panel.vo.PanelResultVo;
|
|
|
+import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
+import com.xunmei.core.drill.service.ICoreDrillTaskService;
|
|
|
+import com.xunmei.core.edu.service.ICoreEduTrainingTaskService;
|
|
|
+import com.xunmei.core.panel.service.PanelService;
|
|
|
+import com.xunmei.core.resumption.service.ResumptionService;
|
|
|
+import com.xunmei.core.retrieval.service.ICoreMonitoringRetrievalTaskService;
|
|
|
+import com.xunmei.core.safetyCheck.service.ICoreSafetyTaskService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class PanelServiceImpl implements PanelService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ResumptionService resumptionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICoreMonitoringRetrievalTaskService coreMonitoringRetrievalTaskService;
|
|
|
+ @Autowired
|
|
|
+ private ICoreSafetyTaskService safetyTaskService;
|
|
|
+ @Autowired
|
|
|
+ private ICoreDrillTaskService drillTaskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICoreEduTrainingTaskService eduTrainingTaskService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<PanelResultVo> selectPage() {
|
|
|
+ PanelListDto panelListDto = PanelAdapter.getMapperSelectParam(SecurityUtils.getLoginUser().getOrgId(),
|
|
|
+ SecurityUtils.getLoginUser().getRoles(),
|
|
|
+ SecurityUtils.getUserId());
|
|
|
+
|
|
|
+ List<PanelListVo> resultList = Collections.synchronizedList(new ArrayList<>(6));
|
|
|
+
|
|
|
+ //履职任务
|
|
|
+ CompletableFuture<List<PanelListVo>> resumptionTaskFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return resumptionService.selectCurUserTaskList(panelListDto);
|
|
|
+ }).whenComplete((resumptionTaskList, throwable) -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(resumptionTaskList)) {
|
|
|
+ resultList.addAll(resumptionTaskList);
|
|
|
+ }
|
|
|
+ if (throwable != null) {
|
|
|
+ log.error("resumptionTaskFuture Exception error.", throwable);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //监控调阅任务
|
|
|
+ CompletableFuture<List<PanelListVo>> monitorTaskFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return coreMonitoringRetrievalTaskService.selectCurUserTaskList(panelListDto);
|
|
|
+ }).whenComplete((monitorTaskList, throwable) -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(monitorTaskList)) {
|
|
|
+ resultList.addAll(monitorTaskList);
|
|
|
+ }
|
|
|
+ if (throwable != null) {
|
|
|
+ log.error("monitorTaskFuture Exception error.", throwable);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //安全检查任务
|
|
|
+ CompletableFuture<List<PanelListVo>> safetyTaskFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return safetyTaskService.selectCurUserTaskList(panelListDto);
|
|
|
+ }).whenComplete((safetyTaskList, throwable) -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(safetyTaskList)) {
|
|
|
+ resultList.addAll(safetyTaskList);
|
|
|
+ }
|
|
|
+ if (throwable != null) {
|
|
|
+ log.error("safetyTaskFuture Exception error.", throwable);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ //预案演练任务
|
|
|
+ CompletableFuture<List<PanelListVo>> drillTaskFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return drillTaskService.selectCurUserTaskList(panelListDto);
|
|
|
+ }).whenComplete((drillTaskList, throwable) -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(drillTaskList)) {
|
|
|
+ resultList.addAll(drillTaskList);
|
|
|
+ }
|
|
|
+ if (throwable != null) {
|
|
|
+ log.error("drillTaskFuture Exception error.", throwable);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //教育培训任务
|
|
|
+ CompletableFuture<List<PanelListVo>> eduTrainingTaskFuture = CompletableFuture.supplyAsync(() -> {
|
|
|
+ return eduTrainingTaskService.selectCurUserTaskList(panelListDto);
|
|
|
+ }).whenComplete((duTrainingTaskList, throwable) -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(duTrainingTaskList)) {
|
|
|
+ resultList.addAll(duTrainingTaskList);
|
|
|
+ }
|
|
|
+ if (throwable != null) {
|
|
|
+ log.error("eduTrainingTaskFuture Exception error.", throwable);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<CompletableFuture<List<PanelListVo>>> futureList = ListUtil.list(true,
|
|
|
+ resumptionTaskFuture,
|
|
|
+ monitorTaskFuture,
|
|
|
+ safetyTaskFuture,
|
|
|
+ drillTaskFuture,
|
|
|
+ eduTrainingTaskFuture);
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 多个任务
|
|
|
+ CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0])).join();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("CompletableFuture.allOf Exception error.", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Map<Integer, List<PanelListVo>> listMap = resultList.stream().collect(Collectors.groupingBy(PanelListVo::getType));
|
|
|
+ //将 resultList根据type字段分组,并排序
|
|
|
+ Map<Integer, List<PanelListVo>> listMap = resultList.stream().sorted(Comparator.comparing(PanelListVo::getType)).collect(Collectors.groupingBy(PanelListVo::getType));
|
|
|
+ List<PanelResultVo> list = new ArrayList<PanelResultVo>();
|
|
|
+ for (Integer type : listMap.keySet()) {
|
|
|
+ PanelResultVo vo = new PanelResultVo();
|
|
|
+ vo.setTaskType(type);
|
|
|
+ vo.setTaskTypeText(PanelTypeEnums.getName(type));
|
|
|
+ vo.setDataList(listMap.get(type));
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|