From ad7cbfd8fd19fcce4345a4907c1f059a34c2869b Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期四, 11 十二月 2025 15:49:15 +0800
Subject: [PATCH] 工作台
---
business/src/main/java/com/ycl/service/impl/IndexHomeServiceImpl.java | 921 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 874 insertions(+), 47 deletions(-)
diff --git a/business/src/main/java/com/ycl/service/impl/IndexHomeServiceImpl.java b/business/src/main/java/com/ycl/service/impl/IndexHomeServiceImpl.java
index 938bb41..629823e 100644
--- a/business/src/main/java/com/ycl/service/impl/IndexHomeServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/IndexHomeServiceImpl.java
@@ -1,30 +1,53 @@
package com.ycl.service.impl;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
-import com.ycl.common.annotation.DataScope;
import com.ycl.common.base.Result;
import com.ycl.common.constant.ProcessOverTimeConstants;
import com.ycl.common.core.domain.BaseEntity;
-import com.ycl.common.enums.business.CodingRulerCodeTypeEnum;
-import com.ycl.common.enums.business.CodingRulerStatusEnum;
-import com.ycl.common.enums.business.ProjectCategoryEnum;
-import com.ycl.common.enums.business.ProjectStatusEnum;
+import com.ycl.common.core.domain.entity.SysDept;
+import com.ycl.common.core.domain.entity.SysRole;
+import com.ycl.common.core.domain.entity.SysUser;
+import com.ycl.common.enums.business.*;
import com.ycl.common.utils.SecurityUtils;
+import com.ycl.domain.entity.ProcessCoding;
+import com.ycl.domain.entity.ProcessLog;
import com.ycl.domain.entity.ProjectInfo;
+import com.ycl.domain.entity.ProjectProcess;
import com.ycl.domain.form.ProjectProgressStatisticsForm;
-import com.ycl.domain.vo.ProjectInfoVO;
-import com.ycl.domain.vo.ProjectVO;
+import com.ycl.domain.query.WaitTodoQuery;
+import com.ycl.domain.vo.*;
+import com.ycl.factory.FlowServiceFactory;
+import com.ycl.mapper.ProcessCodingMapper;
+import com.ycl.mapper.ProcessLogMapper;
import com.ycl.mapper.ProjectInfoMapper;
import com.ycl.service.IndexHomeService;
-import com.ycl.service.ProjectInfoService;
import com.ycl.service.ProjectProcessService;
+import com.ycl.service.common.TaskCommonService;
import com.ycl.system.mapper.SysDeptMapper;
+import com.ycl.system.service.ISysDeptService;
+import com.ycl.system.service.ISysRoleService;
+import com.ycl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.bpmn.model.Process;
+import org.flowable.bpmn.model.UserTask;
+import org.flowable.engine.history.HistoricProcessInstance;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.identitylink.api.IdentityLink;
+import org.flowable.identitylink.api.IdentityLinkInfo;
+import org.flowable.task.api.Task;
+import org.flowable.task.api.TaskQuery;
+import org.flowable.task.api.history.HistoricTaskInstance;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import java.text.DecimalFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
@@ -37,49 +60,44 @@
**/
@Service
@RequiredArgsConstructor
-public class IndexHomeServiceImpl implements IndexHomeService {
+@Slf4j
+public class IndexHomeServiceImpl extends FlowServiceFactory implements IndexHomeService {
private final SysDeptMapper sysDeptMapper;
private final ProjectInfoMapper projectInfoMapper;
+
+ private final ProjectProcessService projectProcessService;
+
+ private final ProcessLogMapper processLogMapper;
+
+ private final ProcessCodingMapper processCodingMapper;
+
+ private final ISysUserService sysUserService;
+
+ private final ISysDeptService sysDeptService;
+
+ private final ISysRoleService sysRoleService;
+
+ private final TaskCommonService taskCommonService;
+
+
@Override
public Result projectCodingStatusCount() {
//鏉冮檺鎺у埗
- Long userId = SecurityUtils.getUserId();
- List<ProjectInfo> list;
- if (SecurityUtils.isAdmin(userId)){
- //鏌ヨ鍏ㄩ儴
- list = new LambdaQueryChainWrapper<>(projectInfoMapper)
- .eq(ProjectInfo::getDeleted, Boolean.FALSE)
- .eq(ProjectInfo::getUsedStatus, 2) //瀹℃牳閫氳繃
- .list();
- }else{
- String ancestors = sysDeptMapper.selectAncestors(userId);
- String[] ancestorArr = ancestors.split(",");
- List<String> ancestorList = Arrays.stream(ancestorArr).collect(Collectors.toList());
- ancestorList.add(SecurityUtils.getDeptId() + "");
- //鑾峰緱鏈崟浣嶄互鍙婂叾瀛愬崟浣峝eptId;
- list = new LambdaQueryChainWrapper<>(projectInfoMapper)
- .eq(ProjectInfo::getDeleted, Boolean.FALSE)
- .eq(ProjectInfo::getUsedStatus, 2) //瀹℃牳閫氳繃
- .in(ProjectInfo::getProjectOwnerUnit, ancestorList)
- .list();
- }
-
-
-
+ List<ProjectInfo> loginUserOwnProjectInfo = getLoginUserOwnProjectInfo();
Map<String,Integer> map = new HashMap<>();
map.put(ProcessOverTimeConstants.GREEN,0);
map.put(ProcessOverTimeConstants.YELLOW,0);
map.put(ProcessOverTimeConstants.RED,0);
map.put("total",0);
- if (CollectionUtils.isEmpty(list)) {
+ if (CollectionUtils.isEmpty(loginUserOwnProjectInfo)) {
//杩斿洖榛樿鍊�
return Result.ok().data(map);
}
- Map<String, List<ProjectInfo>> collect = list.stream()
+ Map<String, List<ProjectInfo>> collect = loginUserOwnProjectInfo.stream()
.filter(project -> project.getCoding() != null) // 杩囨护coding涓簄ull鐨勬儏鍐�
.collect(Collectors.groupingBy(ProjectInfo::getCoding));
@@ -93,7 +111,7 @@
map.put(ProcessOverTimeConstants.RED, collect.get(ProcessOverTimeConstants.RED).size());
}
- map.put("total", list.size());
+ map.put("total", loginUserOwnProjectInfo.size());
return Result.ok().data(map);
}
@@ -115,29 +133,838 @@
finish+=1;
}
}
- Map<String,Integer> map = new HashMap<>();
- map.put(ProjectCategoryEnum.RESERVE.getCode(),reserve);
- map.put(ProjectCategoryEnum.PREVIOUS.getCode(),previous);
- map.put(ProjectCategoryEnum.IMPLEMENT.getCode(),implement);
- map.put(ProjectCategoryEnum.FINISH.getCode(),finish);
+
+
+ Map<String,Object> map = new HashMap<>();
+ Integer[] yData = new Integer[]{
+ projectVOS.size(),
+ reserve,
+ previous,
+ implement,
+ finish
+ };
+ String[] xData = new String[]{
+ "鍦ㄥ簱", "鍌ㄥ","鍓嶆湡","瀹炴柦","绔e伐"
+ };
+ map.put("xData",xData);
+ map.put("yData",yData);
return Result.ok().data(map);
}
@Override
- public Result projectTaskStatus(ProjectProgressStatisticsForm form) {
- return null;
+ public List<ProjectInfo> getLoginUserOwnProjectInfo(){
+ //鏉冮檺鎺у埗
+ Long userId = SecurityUtils.getUserId();
+ List<ProjectInfo> list;
+ if (SecurityUtils.isAdmin(userId)){
+ //鏌ヨ鍏ㄩ儴
+ list = new LambdaQueryChainWrapper<>(projectInfoMapper)
+ .eq(ProjectInfo::getDeleted, Boolean.FALSE)
+ .eq(ProjectInfo::getUsedStatus, 2)//瀹℃牳閫氳繃
+ .orderBy(true, true, ProjectInfo::getId)
+ .list();
+ }else{
+ String ancestors = sysDeptMapper.selectAncestors(userId);
+ String[] ancestorArr = ancestors.split(",");
+ List<String> ancestorList = Arrays.stream(ancestorArr).collect(Collectors.toList());
+ ancestorList.add(SecurityUtils.getDeptId() + "");
+ //鑾峰緱鏈崟浣嶄互鍙婂叾瀛愬崟浣峝eptId;
+ list = new LambdaQueryChainWrapper<>(projectInfoMapper)
+ .eq(ProjectInfo::getDeleted, Boolean.FALSE)
+ .eq(ProjectInfo::getUsedStatus, 2) //瀹℃牳閫氳繃
+ .in(ProjectInfo::getProjectOwnerUnit, ancestorList)
+ .orderBy(true, true, ProjectInfo::getId)
+ .list();
+ }
+ return list;
}
@Override
- @DataScope(deptAlias = "d")
- public Result projectFundingStatus( ) {
+ public Result projectTaskStatus(ProjectProgressStatisticsForm form) {
+ //鑾峰緱鏄」鐩�
+ List<ProjectInfo> loginUserOwnProjectInfo = getLoginUserOwnProjectInfo();
- List<ProjectInfoVO> projectInfoAndFunding = projectInfoMapper.getProjectInfoAndFunding(new BaseEntity());
+
+ if (CollectionUtils.isEmpty(loginUserOwnProjectInfo)) {
+ return Result.ok().data(loginUserOwnProjectInfo);
+ }
+ Map<String, String> projectMap = loginUserOwnProjectInfo.stream()
+ .collect(Collectors.toMap(
+ projectInfo -> String.valueOf(projectInfo.getId()), // key: 椤圭洰ID
+ ProjectInfo::getProjectName, // value: 椤圭洰瀵硅薄鏈韩
+ (existing, replacement) -> existing // 澶勭悊閲嶅ID鐨勫啿绐佺瓥鐣ワ紙淇濈暀鍘熸湁鍊硷級
+ ));
+
+
+
+ //鑾峰緱椤圭洰ids
+ List<Long> ids = loginUserOwnProjectInfo.stream().map(ProjectInfo::getId).collect(Collectors.toList());
+
+
+ //鏇村叿椤圭洰ids鑾峰緱鎵�鏈夊搴旀祦绋嬩俊鎭� ProjectProcess 娴佺▼瀹氫箟ID processDefId;娴佺▼瀹炰緥id processInsId;
+ List<ProjectProcess> projectProcessList = new LambdaQueryChainWrapper<>(projectProcessService.getBaseMapper())
+ .eq(ProjectProcess::getDeleted, Boolean.FALSE)
+ .in(ProjectProcess::getProjectId, ids).list();
+
+ Date statisticsTime = form.getStartTime();
+ if (statisticsTime == null) {
+ statisticsTime = new Date(); // 濡傛灉鏈紶鍏ユ椂闂达紝榛樿浣跨敤褰撳墠鏃堕棿
+ }
+ LocalDate statisticsLocalDate = statisticsTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+ LocalDate firstDayOfMonth = statisticsLocalDate.with(TemporalAdjusters.firstDayOfMonth());
+ LocalDate lastDayOfMonth = statisticsLocalDate.with(TemporalAdjusters.lastDayOfMonth());
+
+ Date monthStart = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ Date monthEnd = Date.from(lastDayOfMonth.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
+
+ // 瀛樺偍姣忎釜娴佺▼瀹炰緥鐨勭粺璁$粨鏋�
+ List<Map<String, Object>> processStatisticsList = new ArrayList<>();
+
+ // 鑾峰緱娴佺▼鏃ュ織琛ㄤ腑 浠诲姟淇℃伅 鎸夋祦绋嬪疄鍒梚d鍒嗙粍
+ Map<String, List<ProcessLog>> groupMap = new LambdaQueryChainWrapper<>(processLogMapper)
+ .eq(ProcessLog::getDeleted, Boolean.FALSE)
+ .in(ProcessLog::getProjectId, ids).list()
+ .stream().collect(Collectors.groupingBy(ProcessLog::getProcessInsId));
+
+
+ for (ProjectProcess projectProcess : projectProcessList) {
+
+ String processInstanceId = projectProcess.getProcessInsId();
+ if (processInstanceId == null) {
+ continue;
+ }
+
+ // 鍗曚釜娴佺▼鐨勭粺璁$粨鏋�
+ Map<String, Object> processResult = new HashMap<>();
+ processResult.put("id",projectProcess.getProjectId());
+ processResult.put("projectName", projectMap.get(projectProcess.getProjectId()));
+
+ int completedCount = 0; // 宸插畬鎴愪换鍔℃暟
+ int inProgressCount = 0; // 杩涜涓换鍔℃暟
+ int notStartedCount = 0; // 鏈紑濮嬩换鍔℃暟
+
+ try {
+ // 1. 鑾峰彇璇ユ祦绋嬪疄渚嬬殑鎵�鏈夊凡瀹屾垚浠诲姟
+ List<HistoricTaskInstance> completedTasks = historyService.createHistoricTaskInstanceQuery()
+ .processInstanceId(processInstanceId)
+ .finished()
+ .list();
+ // 鍘婚噸鍘嗗彶淇℃伅 鎺掗櫎鐩稿悓鐨勪换鍔ey淇濈暀鏈�鏂扮殑浠诲姟
+ completedTasks = projectProcessService.distinctHisTask(completedTasks);
+ // 闇�瑕佹帓闄ゅ凡瀹屾垚浠诲姟涓椹冲洖鐨勪换鍔℃暟
+ List<ProcessLog> taskLogs = groupMap.get(projectProcess.getProcessInsId());
+ if ("144".equals(projectProcess.getProjectId())) {
+ for (ProcessLog processLog : taskLogs) {
+ System.out.println("鎵撳嵃淇℃伅");
+ System.out.println(processLog.toString());
+ }
+ }
+ if (!CollectionUtils.isEmpty(taskLogs)) {
+ //鎺掗櫎鎺夋墍鏈夎椹冲洖鐨勪换鍔�
+ // 鑾峰彇鎵�鏈夎椹冲洖浠诲姟鐨処D鍒楄〃
+ List<String> rejectedTaskIds = taskLogs.stream()
+ .filter(log -> {
+ // 鍒ゆ柇鏄惁涓洪┏鍥炵被鍨嬬殑鏃ュ織锛堟牴鎹綘鐨勬灇涓惧�艰皟鏁达級
+ return ProcessLogEventTypeEnum.REJECT.equals(log.getEventType());
+ })
+ .map(ProcessLog::getTaskId) // 鍋囪鏃ュ織涓湁taskId瀛楁鍏宠仈浠诲姟
+ .filter(Objects::nonNull) // 杩囨护鎺塶ull鐨則askId
+ .collect(Collectors.toList());
+
+ // 鎺掗櫎琚┏鍥炵殑浠诲姟锛岀敓鎴愭柊鐨勫凡瀹屾垚浠诲姟闆嗗悎
+
+ // 灏嗚繃婊ゅ悗鐨勯泦鍚堣祴鍊肩粰鍘熷彉閲�
+ completedTasks = completedTasks.stream()
+ .filter(task -> !rejectedTaskIds.contains(task.getId())) //淇濈暀涓嶅寘鍚┏鍥炵殑taskId
+ .collect(Collectors.toList());
+ }
+
+
+ // 鏈湀鏈�鍚庝竴澶╁畬鎴愮殑 灞炰簬宸插畬鎴� after 涔嬪悗 before 涔嬪墠
+ for (HistoricTaskInstance task : completedTasks) {
+ Date completionTime = task.getEndTime();
+ if (completionTime != null &&
+ completionTime.before(monthEnd)) {
+ completedCount++;
+ }
+ }
+ // 鑾峰緱涓婁竴姝ユ湭瑕嗙洊鍒版煡璇㈡潯浠剁殑鍏冪礌 瀹屾垚鏃堕棿鏄湪鏈湀涔嬪悗
+ List<HistoricTaskInstance> excessCompletedTasks = completedTasks.stream().filter(
+ task -> { Date endTime = task.getEndTime();
+ return endTime != null && endTime.after(monthEnd);
+ }).collect(Collectors.toList());
+
+ // 寰幆瀹屾垚鏃堕棿鏄湪鏈湀涔嬪悗鐨�
+ for (HistoricTaskInstance task : excessCompletedTasks) {
+ Date createTime = task.getCreateTime();
+ Date endTime = task.getEndTime();
+
+ // 鏈湀鍒涘缓锛屽畬鎴愬湪鏈湀涔嬪悗 灞炰簬杩涜涓�
+ if (createTime != null && endTime != null) {
+ if (createTime.before(monthEnd) && createTime.after(monthStart) && endTime.after(monthEnd)) {
+ inProgressCount++;
+ }
+ }
+
+
+ }
+ // 2. 鑾峰彇璇ユ祦绋嬪疄渚嬬殑鎵�鏈夎繘琛屼腑浠诲姟
+ List<Task> activeTasks = taskService.createTaskQuery()
+ .processInstanceId(processInstanceId)
+ .active()
+ .list();
+ for (Task task : activeTasks) {
+ Date createTime = task.getCreateTime();
+ // 杩涜涓殑浠诲姟 鍒ゆ柇鍒涘缓鏃堕棿鏄惁鍦ㄤ笅涓湀涔嬪墠 濡傛灉鏄湰鏈堝垯鍔�1
+ if (createTime != null && createTime.before(monthEnd)) {
+ inProgressCount++;
+ }
+
+ }
+
+
+
+
+ // 5. 缁熻鏈紑濮嬩换鍔★紙鑾峰彇娴佺▼瀹氫箟鐨勬�讳换鍔℃暟 - 宸茬粺璁$殑浠诲姟鏁帮級
+ ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
+ .processInstanceId(processInstanceId)
+ .singleResult();
+
+ if (processInstance != null) {
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
+ Process mainProcess = bpmnModel.getMainProcess();
+ List<UserTask> userTasks = mainProcess.findFlowElementsOfType(UserTask.class);
+ int totalUserTaskCount = userTasks.size();
+
+ // 鏈紑濮嬩换鍔℃暟 = 鎬讳换鍔℃暟 - 宸插畬鎴� - 杩涜涓�
+ notStartedCount = totalUserTaskCount - completedCount - inProgressCount;
+
+ // 纭繚鏈紑濮嬩换鍔℃暟涓嶄负璐熸暟
+ if (notStartedCount < 0) {
+ notStartedCount = 0;
+ }
+ }
+ } catch (Exception e) {
+ // 寮傚父澶勭悊
+ notStartedCount = 0;
+ }
+
+ // 璁剧疆褰撳墠娴佺▼鐨勭粺璁$粨鏋�
+ int totalTasks = completedCount + inProgressCount + notStartedCount;
+
+ double completedPercent = totalTasks == 0 ? 0 : (completedCount * 100.0 / totalTasks);
+ double inProgressPercent = totalTasks == 0 ? 0 : (inProgressCount * 100.0 / totalTasks);
+ double notStartedPercent = totalTasks == 0 ? 0 : (notStartedCount * 100.0 / totalTasks);
+ //鍥涜垗浜斿叆
+ completedPercent = Math.round(completedPercent * 10) / 10.0;
+ inProgressPercent = Math.round(inProgressPercent * 10) / 10.0;
+ notStartedPercent = Math.round(notStartedPercent * 10) / 10.0;
+ //淇濈暀涓�浣�
+ DecimalFormat df = new DecimalFormat("#.#");
+
+ // 鏍煎紡鍖栫粨鏋滐紙鍙�夛細淇濈暀涓哄瓧绗︿覆鎴栬浆鎹负Double锛�
+ String completedFormatted = df.format(completedPercent);
+ String inProgressFormatted = df.format(inProgressPercent);
+ String notStartedFormatted = df.format(notStartedPercent);
+
+ processResult.put("completed", completedFormatted);
+ processResult.put("co", completedCount);
+ processResult.put("co2", inProgressCount);
+ processResult.put("co3", notStartedCount);
+ processResult.put("inProgress", inProgressFormatted);
+ processResult.put("notStarted", notStartedFormatted);
+ processResult.put("totalTasks",totalTasks) ;
+
+ // 娣诲姞鍒扮粨鏋滃垪琛�
+ processStatisticsList.add(processResult);
+ }
+
+ return Result.ok().data(processStatisticsList);
+ }
+
+ @Override
+ public Result projectFundingStatus( ) {
+ List<ProjectInvestmentFundingVO> projectInfoAndFunding = projectInfoMapper.getProjectInfoAndFunding(new BaseEntity());
+ //鎺掗櫎绌烘暟鎹�
+ projectInfoAndFunding = projectInfoAndFunding.stream().filter(Objects::nonNull).collect(Collectors.toList());
+
return Result.ok().data(projectInfoAndFunding);
+ }
+ @Override
+ public int countWaitTask() {
+ Long userId = SecurityUtils.getUserId();
+ List<ProjectInfo> loginUserOwnProjectInfo = getLoginUserOwnProjectInfo();
+ if (CollectionUtils.isEmpty(loginUserOwnProjectInfo)) {
+ return 0;
+ }
+ List<Long> ids = loginUserOwnProjectInfo.stream()
+ .filter(Objects::nonNull)
+ .map(ProjectInfo::getId)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(ids)) {
+ return 0;
+ }
+ List<ProjectProcess> projectProcessList = new LambdaQueryChainWrapper<>(projectProcessService.getBaseMapper())
+ .eq(ProjectProcess::getDeleted, Boolean.FALSE)
+ .in(ProjectProcess::getProjectId, ids)
+ .list();
+ if (CollectionUtils.isEmpty(projectProcessList)) {
+ return 0;
+ }
+ List<String> targetProcessInsIds = projectProcessList.stream()
+ .filter(Objects::nonNull) // 杩囨护null鐨凱rojectProcess瀵硅薄
+ .map(ProjectProcess::getProcessInsId)
+ .filter(defId -> defId != null && !defId.trim().isEmpty()) // 鍏堝垽null鍐峵rim锛屼慨澶嶉闄�3
+ .distinct()
+ .collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(targetProcessInsIds)) {
+ return 0;
+ }
+
+ List<Task> allRunningTasks = taskService.createTaskQuery().active().list();
+ if (CollectionUtils.isEmpty(allRunningTasks)) {
+ return 0;
+ }
+ List<Task> targetRunningTasks = allRunningTasks.stream()
+ .filter(Objects::nonNull)
+ .filter(task -> {
+ // 鍏堝垽null锛屽啀鍖归厤锛屼慨澶嶉闄�1
+ String processInsId = task.getProcessInstanceId();
+ return processInsId != null && targetProcessInsIds.contains(processInsId);
+ })
+ .filter(task -> {
+ String assignee = task.getAssignee();
+ return assignee == null || userId.toString().equals(assignee);//鎺掗櫎棰嗗彇浜�
+ })
+ .collect(Collectors.toList());
+
+
+ return targetRunningTasks.size();
}
@Override
public Result projectAdvanceCheckPoint() {
- return null;
+ List<ProjectInfo> loginUserOwnProjectInfo = getLoginUserOwnProjectInfo();
+ if (CollectionUtils.isEmpty(loginUserOwnProjectInfo)) {
+ return Result.ok().data(loginUserOwnProjectInfo);
+ }
+ //鑾峰緱椤圭洰ids
+ List<Long> ids = loginUserOwnProjectInfo.stream().map(ProjectInfo::getId).collect(Collectors.toList());
+ List<ProjectProcess> projectProcessList = new LambdaQueryChainWrapper<>(projectProcessService.getBaseMapper())
+ .eq(ProjectProcess::getDeleted, Boolean.FALSE)
+ .in(ProjectProcess::getProjectId, ids).list();
+ Long userId = SecurityUtils.getUserId();
+ //娴佺▼瀹炰緥id闆嗗悎
+ List<String> targetProcessInsIds = projectProcessList.stream()
+ .map(ProjectProcess::getProcessInsId)
+ .distinct()
+ .filter(defId -> defId != null && !defId.trim().isEmpty())
+ .collect(Collectors.toList());
+ //缁勮椤圭洰娴佺▼淇℃伅 椤圭洰id涓簁ey
+ Map<String,CheckPointVO> map = new HashMap<>();
+ for (ProjectInfo projectInfo : loginUserOwnProjectInfo){
+ CheckPointVO checkPointVO = new CheckPointVO();
+ checkPointVO.setId(projectInfo.getId());
+ checkPointVO.setProjectName(projectInfo.getProjectName());
+ map.put(String.valueOf(projectInfo.getId()),checkPointVO);
+ }
+ //缁勮娴佺▼淇℃伅
+ for (ProjectProcess projectProcess : projectProcessList) {
+
+ CheckPointVO checkPointVO = map.get(projectProcess.getProjectId());
+ checkPointVO.setProcessDefinitionId(projectProcess.getProcessDefId());
+ checkPointVO.setProcessInstanceId(projectProcess.getProcessInsId());
+
+ //鑾峰緱娴佺▼閮ㄧ讲id
+ ProcessInstance process = runtimeService.createProcessInstanceQuery()
+ .processInstanceId(projectProcess.getProcessInsId()).singleResult();
+ if (Objects.nonNull(process)) {
+ checkPointVO.setDeployId(process.getDeploymentId()); // 杩愯涓祦绋嬬洿鎺ュ彇閮ㄧ讲ID
+ checkPointVO.setProcessName(process.getProcessDefinitionName());
+ } else {
+ // 2. 杩愯涓祦绋嬩笉瀛樺湪锛堝凡缁撴潫锛夛紝鏌ュ巻鍙叉祦绋嬪疄渚�
+ HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceId(projectProcess.getProcessInsId()).singleResult();
+ // 鍘嗗彶娴佺▼鍙栭儴缃睮D
+ checkPointVO.setDeployId(hisProcess.getDeploymentId());
+ checkPointVO.setProcessName(hisProcess.getProcessDefinitionName());
+ }
+ map.put(projectProcess.getProjectId(),checkPointVO);
+ }
+ // 杞崲涓簂ist鍚庢寜 娴佺▼瀹炰緥id鍒嗙粍
+ List<CheckPointVO> checkPointList = map.values().stream()
+ .collect(Collectors.toList());
+ // 鑾峰緱缁勮濂界殑 娴佺▼map 閿负娴佺▼瀹炰緥id锛�
+ Map<String, CheckPointVO> processInfoMap = checkPointList.stream()
+ .filter(Objects::nonNull) // 閬垮厤null鍏冪礌瀵艰嚧寮傚父锛堝彲閫夛紝鎸夐渶淇濈暀锛�
+ .filter(vo -> vo.getProcessInstanceId() != null) // 杩囨护娴佺▼瀹氫箟ID涓簄ull鐨勬棤鏁堟暟鎹�
+ .collect(Collectors.toMap(
+ CheckPointVO::getProcessInstanceId, // key锛氭祦绋嬪畾涔塈D锛堟浛鎹负浣犵殑瀹為檯鏂规硶鍚嶏級
+ vo -> vo, // value锛氬師濮婥heckPointVO瀵硅薄
+ (oldVal, newVal) -> newVal // 鍐茬獊绛栫暐锛氬瓨鍦ㄩ噸澶岻D鏃朵繚鐣欏悗鑰咃紙鎸夐渶璋冩暣锛�
+ ));
+
+
+ List<Task> allRunningTasks = taskService.createTaskQuery().active().list();
+
+ List<Task> targetRunningTasks = allRunningTasks.stream()
+ // 鍏抽敭鍖归厤锛氫换鍔$殑娴佺▼瀹氫箟ID 瀛樺湪浜� projectProcessList 鐨勬祦绋嬪畾涔塈D鍒楄〃涓�
+ .filter(task -> targetProcessInsIds.contains(task.getProcessInstanceId()))
+ .filter(task -> {
+ String assignee = task.getAssignee();
+ log.info("assignee:{}",assignee);
+ return assignee == null || userId.toString().equals(assignee);
+ })
+ .collect(Collectors.toList());
+
+ List<TaskInfoVo> list = new ArrayList<>();
+ // 鎸夋祦绋嬪疄渚媔d鍒嗙粍
+ if (!CollectionUtils.isEmpty(targetRunningTasks)){
+
+ //鏌ヨ鍒版墍鏈�
+ List<String> taskIds = targetRunningTasks.stream().map(Task::getId).collect(Collectors.toList());
+ // 浠诲姟杩愯鏃朵笉鍦� list涓紝鍙兘浠诲姟娌℃湁璁剧疆瓒呮椂鏃堕棿
+ List<ProcessCoding> processCodingList = new LambdaQueryChainWrapper<>(processCodingMapper)
+ .eq(ProcessCoding::getDeleted, Boolean.FALSE)
+ .in(ProcessCoding::getTaskId, taskIds)
+ .list();
+ log.info("processCodingList.size():{}", processCodingList.size()); // 鐪嬫棩蹇楁槸鍚︿负0
+ Map<String, ProcessCoding> processCodingMap = new HashMap<>();
+ //鎸塼askId杞崲涓簃ap鏂归潰涓嬮潰鑾峰彇
+ if (!CollectionUtils.isEmpty(processCodingList)){
+ processCodingMap = processCodingList.stream()
+ .filter(Objects::nonNull) // 閬垮厤null鍏冪礌瀵艰嚧NPE锛堝彲閫変繚鐣欙級
+ .filter(vo -> vo.getTaskId() != null) // 杩囨护taskId涓簄ull鐨勬棤鏁堟暟鎹�
+ .collect(Collectors.toMap(
+ ProcessCoding::getTaskId, // key锛氫粛涓簍askId
+ vo -> vo, // value锛氬師濮婸rocessCoding瀵硅薄
+ // 鍐茬獊绛栫暐锛氭瘮杈冨垱寤烘椂闂达紝淇濈暀鏇存柊鐨勯偅涓�
+ (oldVal, newVal) -> {
+ // 鑾峰彇涓よ�呭垱寤烘椂闂达紙鏍规嵁瀹為檯鏂规硶鍚嶈皟鏁达紝濡俫etGmtCreate()
+ Date oldCreateTime = oldVal.getGmtCreate();
+ Date newCreateTime = newVal.getGmtCreate();
+
+ // 澶勭悊鍒涘缓鏃堕棿涓簄ull鐨勬儏鍐碉紙浼樺厛绾э細鏈夋椂闂�>鏃犳椂闂达紝閮芥棤鍒欎繚鐣欏悗鑰咃級
+ if (oldCreateTime == null) return newVal;
+ if (newCreateTime == null) return oldVal;
+
+ // 姣旇緝鏃堕棿鎴筹紝杩斿洖鏇村ぇ鐨勶紙鏇存柊鐨勶級瀵硅薄
+ return newCreateTime.getTime() > oldCreateTime.getTime() ? newVal : oldVal;
+ }
+ ));
+ }
+ for (Task task : targetRunningTasks) {
+
+ TaskInfoVo taskVo = new TaskInfoVo();
+
+ taskVo.setId(task.getId());
+ taskVo.setTaskName(task.getName());
+ taskVo.setStartTime(task.getCreateTime());
+ taskVo.setEndTime(task.getDueDate());
+// taskVo.setTaskType();
+
+ List<Long> handlerIds = new ArrayList<>(2);
+ List<String> handlerNames = new ArrayList<>(2);
+ List<Long> handlerUnitIds = new ArrayList<>(2);
+ List<String> handlerUnitNames = new ArrayList<>(2);
+ List<String> promoterNames = new ArrayList<>(2);
+ List<String> promoterUnitNames = new ArrayList<>(2);
+ CustomerTaskVO customerTaskVO = new CustomerTaskVO();
+ customerTaskVO.setHandlerId(handlerIds);
+ customerTaskVO.setHandlerName(handlerNames);
+ customerTaskVO.setHandlerUnitId(handlerUnitIds);
+ customerTaskVO.setHandlerUnitName(handlerUnitNames);
+ customerTaskVO.setPromoterName(promoterNames);
+ customerTaskVO.setPromoterUnitName(promoterUnitNames);
+
+ // 娴佺▼澶勭悊浜轰俊鎭�
+ List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(task.getId());
+ for (IdentityLinkInfo identityLink : identityLinksForTask) {
+ // 缁戝畾鐨勬槸鐢ㄦ埛锛屾煡鍑虹敤鎴峰鍚嶃�侀儴闂�
+ if (StringUtils.isNotBlank(identityLink.getUserId())) {
+ // 澶勭悊鍙橀噺琛ㄨ揪寮忥紝杩愯涓殑浠诲姟鏃犻渶鍐嶅鐞嗚〃杈惧紡浜嗭紝flowable宸茬粡鑷姩鏍规嵁鍙橀噺璁剧疆浜�
+ customerTaskVO.setHandlerType(HandlerTypeEnum.USER);
+ SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
+ if (Objects.nonNull(sysUser)) {
+ customerTaskVO.getHandlerId().add(sysUser.getUserId());
+ customerTaskVO.getHandlerName().add(this.getUserShowName(sysUser));
+ if (Objects.nonNull(sysUser.getDept())) {
+ customerTaskVO.getHandlerUnitId().add(sysUser.getDept().getDeptId());
+ customerTaskVO.getHandlerUnitName().add(sysUser.getDept().getDeptName());
+ customerTaskVO.getPromoterName().add(this.getUserShowName(sysUser));
+ String[] str = sysUser.getDept().getAncestors().split(",");
+ if (str.length >= 4){
+ customerTaskVO.getPromoterUnitName().add(sysUser.getDept().getParentName() +"-"+sysUser.getDept().getDeptName());
+ }else {
+ customerTaskVO.getPromoterUnitName().add(sysUser.getDept().getDeptName());
+ }
+
+ }
+ }
+ // 缁戝畾鐨勬槸瑙掕壊鎴栬�呴儴闂�
+ } else if (StringUtils.isNotBlank(identityLink.getGroupId())) {
+ if (identityLink.getGroupId().startsWith("dept")) { // 閮ㄩ棬鐨刬d鏄姞浜嗗墠缂�鐨勫锛歞ept:1
+ customerTaskVO.setHandlerType(HandlerTypeEnum.DEPT);
+ String[] split = identityLink.getGroupId().split(":");
+ if (split.length > 1) {
+ // 閮ㄩ棬
+ SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
+ if (Objects.nonNull(dept)) {
+ customerTaskVO.getHandlerUnitId().add(dept.getDeptId());
+ customerTaskVO.getHandlerUnitName().add(dept.getDeptName());
+ customerTaskVO.getPromoterName().add(this.getDeptLeaderShowName(dept));
+ customerTaskVO.getPromoterUnitName().add(this.setDeptNameWithParentName(dept));
+ }
+ }
+ } else {
+ customerTaskVO.setHandlerType(HandlerTypeEnum.ROLE);
+ SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
+ if (Objects.nonNull(role)) {
+ customerTaskVO.getHandlerUnitId().add(Long.parseLong(identityLink.getGroupId()));
+ customerTaskVO.getHandlerUnitName().add(role.getRoleName());
+ }
+ }
+ }
+ this.distinctVo(customerTaskVO);
+ }
+ taskVo.setCustomerTaskInfo(customerTaskVO);
+
+ //缁勮浠诲姟淇℃伅
+ CheckPointVO checkPointVO = processInfoMap.get(task.getProcessInstanceId());
+ if (checkPointVO != null) {
+ taskVo.setCheckPointInfo(checkPointVO);
+ }
+ //瓒呮椂鏃堕棿鍜屾鏁板湪 processCodingList涓� 杩欓噷闇�瑕佹洿鍏穞askId鏉ヨ幏寰楀搴斾俊鎭�
+ ProcessCoding processCoding = processCodingMap.get(task.getId());
+ //璁剧疆瓒呮椂淇℃伅
+ if (processCoding != null) {
+
+ String overTimeTotalStr = processCoding.getOverTimeTotal();
+ long overTimeTotal = 0L;
+ if (StringUtils.isNotBlank(overTimeTotalStr)) {
+ try {
+ overTimeTotal = Long.parseLong(overTimeTotalStr.trim());
+ } catch (NumberFormatException e) {
+
+ }
+ }
+ String overTimeDesc = convertHoursToDayHourStr(overTimeTotal);
+ taskVo.setTotalOverTime(overTimeDesc);
+
+ // 2. 鎻愬彇绾㈢爜闃堝�� 濡傦細 0-22 澶�-灏忔椂 骞惰浆鎹负灏忔椂
+ String redTimeStr = processCoding.getRedTime();
+ Long redTimeSec = getTime(redTimeStr);
+ Double redTimeHour = null;
+ if (redTimeSec != null && redTimeSec > 0) {
+ redTimeHour = redTimeSec / 3600.0;
+ }
+ long overTimeCount = 0L;
+ // 鍒ゆ柇瓒呮椂娆℃暟
+ if (overTimeTotal > 0 && redTimeHour != null && redTimeHour > 0) {
+ overTimeCount = (long) (overTimeTotal / redTimeHour);
+ }
+
+
+ taskVo.setOverTimeCount(overTimeCount);
+ }else {
+ //涓簄ull 璇存槑鏈厤缃秴鏃舵椂闂� 榛樿鏈秴鏃�
+ taskVo.setOverTimeCount(0L);
+ taskVo.setTotalOverTime("0灏忔椂");
+ }
+ list.add(taskVo);
+ }
+
+
+ }
+
+ return Result.ok().data(list);
}
+
+ public HashMap<String,Object> buildEmptyResultMap(){
+ HashMap<String,Object> map = new HashMap<>();
+ map.put("data", new ArrayList<>());
+ map.put("total", 0L);
+ return map;
+ }
+ @Override
+ public Result getWaitTaskList(WaitTodoQuery baseQuery) {
+ int pageNum = (int) baseQuery.getCurrentPage();
+ int pageSize = (int) baseQuery.getPageSize();
+ Long userId = SecurityUtils.getUserId(); // 褰撳墠鐢ㄦ埛ID
+ boolean isAdmin = SecurityUtils.getLoginUser().getUser().isAdmin(); // 鏄惁绠$悊鍛�
+ List<String> userGroups = taskCommonService.getCurrentUserGroups(); // 褰撳墠鐢ㄦ埛鎵�灞炵粍
+ List<ProjectInfo> targetProjectList = new ArrayList<>();
+ String queryProjectId = baseQuery.getId();
+
+
+ if ("all".equals(queryProjectId) || StringUtils.isBlank(queryProjectId)){
+ // 鏌ヨ鍏ㄩ儴
+ targetProjectList = getLoginUserOwnProjectInfo();
+ }else{
+ try {
+ Long projectId = Long.parseLong(queryProjectId);
+ // 鈶� 鏌ヨ璇ラ」鐩熀纭�淇℃伅锛堟浛鎹负瀹為檯鏌ヨ鏂规硶锛�
+ ProjectInfo projectInfo = projectInfoMapper.selectById(projectId);
+ if (projectInfo == null) {
+ // 椤圭洰涓嶅瓨鍦紝杩斿洖绌烘暟鎹�
+ return Result.ok().data(buildEmptyResultMap());
+ }
+ //
+ targetProjectList.add(projectInfo);
+ } catch (NumberFormatException e) {
+ // 椤圭洰ID鏍煎紡閿欒锛岃繑鍥炵┖鏁版嵁
+ return Result.ok().data(buildEmptyResultMap());
+ }
+ }
+
+ List<Long> projectIds = targetProjectList.stream().map(ProjectInfo::getId).collect(Collectors.toList());
+
+ List<ProjectProcess> projectProcessList = new LambdaQueryChainWrapper<>(projectProcessService.getBaseMapper())
+ .eq(ProjectProcess::getDeleted, Boolean.FALSE)
+ .in(ProjectProcess::getProjectId, projectIds).list();
+ // 4. 鎻愬彇鏈夋晥鐨勬祦绋嬪疄渚婭D锛堝幓閲�+闈炵┖杩囨护锛�
+ List<String> targetProcessInsIds = projectProcessList.stream()
+ .map(ProjectProcess::getProcessInsId)
+ .distinct()
+ .filter(defId -> defId != null && !defId.trim().isEmpty())
+ .collect(Collectors.toList());
+
+ if (CollectionUtils.isEmpty(targetProcessInsIds)) {
+ return Result.ok().data(new HashMap<String, Object>() {{
+ put("data", new ArrayList<>());
+ put("total", 0L);
+ }});
+ }
+
+ // 5. 鏋勫缓processInfoMap锛堟牳蹇冿細椤圭洰ID鈫扖heckPointVO锛屽啀鍏宠仈娴佺▼淇℃伅锛�
+ Map<String, CheckPointVO> map = new HashMap<>();
+ // 鍏堝~鍏呴」鐩熀纭�淇℃伅
+ for (ProjectInfo projectInfo : targetProjectList) {
+ CheckPointVO checkPointVO = new CheckPointVO();
+ checkPointVO.setId(projectInfo.getId());
+ checkPointVO.setProjectName(projectInfo.getProjectName());
+ map.put(String.valueOf(projectInfo.getId()), checkPointVO);
+ }
+ // 鍐嶅~鍏呮祦绋嬩俊鎭紙閮ㄧ讲ID銆佹祦绋嬪悕绉扮瓑锛�
+ for (ProjectProcess projectProcess : projectProcessList) {
+ CheckPointVO checkPointVO = map.get(projectProcess.getProjectId());
+ if (checkPointVO == null) {
+ continue; // 鏃犲尮閰嶉」鐩紝璺宠繃
+ }
+ checkPointVO.setProcessDefinitionId(projectProcess.getProcessDefId());
+ checkPointVO.setProcessInstanceId(projectProcess.getProcessInsId());
+
+ // 鑾峰緱娴佺▼閮ㄧ讲id鍜屾祦绋嬪悕绉帮紙鍏煎杩愯涓�/宸茬粨鏉熸祦绋嬶級
+ ProcessInstance process = runtimeService.createProcessInstanceQuery()
+ .processInstanceId(projectProcess.getProcessInsId()).singleResult();
+ if (Objects.nonNull(process)) {
+ checkPointVO.setDeployId(process.getDeploymentId());
+ checkPointVO.setProcessName(process.getProcessDefinitionName());
+ } else {
+ HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery()
+ .processInstanceId(projectProcess.getProcessInsId()).singleResult();
+ if (Objects.nonNull(hisProcess)) { // 閬垮厤鍘嗗彶娴佺▼涓簄ull鐨凬PE
+ checkPointVO.setDeployId(hisProcess.getDeploymentId());
+ checkPointVO.setProcessName(hisProcess.getProcessDefinitionName());
+ }
+ }
+ map.put(projectProcess.getProjectId(), checkPointVO);
+ }
+ Map<String, CheckPointVO> processInfoMap = map.values().stream()
+ .filter(Objects::nonNull)
+ .filter(vo -> vo.getProcessInstanceId() != null)
+ .collect(Collectors.toMap(
+ CheckPointVO::getProcessInstanceId,
+ vo -> vo,
+ (oldVal, newVal) -> newVal // 閲嶅娴佺▼瀹炰緥ID淇濈暀鍚庤��
+ ));
+
+ TaskQuery query = getTaskService().createTaskQuery()
+ .active() // 鏈畬鎴愩�佹湭鎸傝捣鐨勬椿璺冧换鍔�
+ .processInstanceIdIn(targetProcessInsIds); // 浠呮煡椤圭洰鍏宠仈鐨勬祦绋嬪疄渚嬩换鍔�
+
+ // 鏉冮檺杩囨护锛氶潪绠$悊鍛樹粎鏌ヨ嚜宸辨湁鏉冮檺鐨勪换鍔★紙宸查鍙�+鍊欓�夛級
+ if (!isAdmin) {
+ query.or()
+ .taskAssignee(userId+"") // 鑷繁宸查鍙栫殑浠诲姟
+ .taskCandidateUser(userId+"") // 鑷繁鏄�欓�夌敤鎴风殑浠诲姟
+ .taskCandidateGroupIn(userGroups) // 鑷繁鍦ㄥ�欓�夌粍鐨勪换鍔�
+ .endOr();
+ }
+
+ query.orderByTaskCreateTime().desc();
+ List<Task> allTaskList = query.list();
+ // 鎺掗櫎棰嗗彇浜洪棶棰�
+ allTaskList = allTaskList.stream()
+ .filter(Objects::nonNull) // 绌轰换鍔¢槻鎶�
+ .filter(task -> {
+ String assignee = task.getAssignee();
+ return assignee == null || userId.toString().equals(assignee);
+ })
+ .collect(Collectors.toList());
+ Set<String> taskIdSet = new HashSet<>();
+ List<Task> distinctAllTaskList = new ArrayList<>();
+ for (Task task : allTaskList) {
+ if (!taskIdSet.contains(task.getId())) {
+ taskIdSet.add(task.getId());
+ distinctAllTaskList.add(task);
+ //
+ }
+ }
+
+ long distinctTotal = distinctAllTaskList.size();
+ System.out.println("鍘婚噸鍚庢�绘暟锛�" + distinctTotal);
+
+
+ int startIndex = (pageNum - 1) * pageSize;
+ List<Task> pageTaskList = new ArrayList<>();
+ if (startIndex < distinctAllTaskList.size()) {
+ int endIndex = Math.min(startIndex + pageSize, distinctAllTaskList.size());
+ pageTaskList = distinctAllTaskList.subList(startIndex, endIndex);
+ }
+
+
+ List<TaskInfoVo> taskInfoVoList = new ArrayList<>();
+ //鏌ヨ浠诲姟鐘舵��
+ List<String> taskIds = pageTaskList.stream().map(Task::getId).collect(Collectors.toList());
+ HashMap<String,ProcessLog> taskInfoMap = new HashMap<>();
+ if (!CollectionUtils.isEmpty(taskIds)) {
+ taskInfoMap = new LambdaQueryChainWrapper<>(processLogMapper)
+ .eq(ProcessLog::getDeleted, Boolean.FALSE)
+ .in(ProcessLog::getTaskId, taskIds).list()
+ .stream()
+ .filter(processLog -> processLog.getTaskId() != null && processLog.getGmtCreate() != null)
+ .collect(Collectors.toMap(
+ // Key锛歵askId杞瓧绗︿覆
+ ProcessLog::getTaskId,
+ // Value锛歅rocessLog瀵硅薄鏈韩
+ processLog -> processLog,
+ // 鍐茬獊绛栫暐锛氫繚鐣檊mtCreate鏇存柊鐨勯偅鏉¤褰�
+ (existing, replacement) -> {
+ return replacement.getGmtCreate().after(existing.getGmtCreate())
+ ? replacement : existing;
+ },
+ HashMap::new
+ ));
+ }
+
+
+ for (Task task : pageTaskList) {
+ TaskInfoVo taskVo = new TaskInfoVo();
+ taskVo.setId(task.getId());
+ taskVo.setTaskName(task.getName());
+ taskVo.setStartTime(task.getCreateTime());
+ taskVo.setEndTime(task.getDueDate());
+ // 濉厖浠诲姟鐘舵�佸瓧娈�
+ taskVo.setTaskType("寰呭畬鎴�");
+ ProcessLog processLog = taskInfoMap.get(task.getId());
+ if (Objects.nonNull(processLog)) {
+ taskVo.setTaskType(processLog.getEventType().getDesc());
+ }
+
+ CheckPointVO checkPointVO = processInfoMap.get(task.getProcessInstanceId());
+ if (checkPointVO != null) {
+ taskVo.setCheckPointInfo(checkPointVO);
+ }
+
+ taskInfoVoList.add(taskVo);
+ }
+ //鎺掗櫎 宸插畬鎴愮殑
+ taskInfoVoList = taskInfoVoList.stream().filter(taskInfoVo -> {
+ if (ProcessLogEventTypeEnum.FINISHED.getDesc().equals(taskInfoVo.getTaskType())){
+ return false;
+ }
+ return true;
+ }).collect(Collectors.toList());
+ HashMap<String, Object> resultMap = new HashMap<>();
+ resultMap.put("data", taskInfoVoList);
+ resultMap.put("total", distinctTotal);
+ return Result.ok().data(resultMap);
+ }
+
+
+
+ private String convertHoursToDayHourStr(long totalHours) {
+ if (totalHours < 0) {
+ return "0灏忔椂"; // 闃插尽鎬у鐞嗚礋鏁板満鏅�
+ }
+ long days = totalHours / 24; // 璁$畻澶╂暟
+ long hours = totalHours % 24; // 璁$畻鍓╀綑灏忔椂鏁�
+
+ StringBuilder sb = new StringBuilder();
+ if (days > 0) {
+ sb.append(days).append("澶�");
+ }
+ // 灏忔椂鏁版棤璁烘槸鍚︿负0锛岄兘灞曠ず锛堜篃鍙牴鎹笟鍔¤皟鏁达細濡�0灏忔椂鏃朵笉灞曠ず锛�
+ if (hours > 0 || days == 0) {
+ sb.append(hours).append("灏忔椂");
+ }
+ return sb.toString();
+ }
+ // 瀵归儴闂ㄨ礋璐d汉闆嗗悎淇℃伅杩涜鍘婚噸
+ private void distinctVo(CustomerTaskVO vo) {
+ vo.setHandlerId(vo.getHandlerId().stream().distinct().collect(Collectors.toList()));
+ vo.setHandlerName(vo.getHandlerName().stream().distinct().collect(Collectors.toList()));
+ vo.setHandlerUnitId(vo.getHandlerUnitId().stream().distinct().collect(Collectors.toList()));
+ vo.setHandlerUnitName(vo.getHandlerUnitName().stream().distinct().collect(Collectors.toList()));
+ }
+ //鎷兼帴鐢ㄦ埛鏄电О浠ュ強鐢佃瘽
+ private String getUserShowName(SysUser user) {
+ return user.getNickName() + (StringUtils.isNotBlank(user.getPhonenumber()) ? "(" + user.getPhonenumber() + ")" : "");
+ }
+ //鎷兼帴閮ㄩ棬璐熻矗浜轰互鍙婄數璇�
+ private String getDeptLeaderShowName(SysDept dept) {
+ return dept.getLeader() + (StringUtils.isNotBlank(dept.getPhone()) ? "(" + dept.getPhone() + ")" : "");
+ }
+ //鎷兼帴涓婄骇閮ㄩ棬浠ュ強鏈儴闂ㄥ悕绉�
+ private String setDeptNameWithParentName(SysDept dept) {
+ String[] str = dept.getAncestors().split(",");
+ if (str.length >= 4){
+ return dept.getParentName() + " / " + dept.getDeptName();
+ }else {
+ return dept.getDeptName();
+ }
+ }
+ private Long getTime(String timeStr) {
+ Long time = null;
+ if (StringUtils.isNotBlank(timeStr)) {
+ String[] timeArr = timeStr.split("-");
+ // 瑙f瀽澶╂暟鍜屽皬鏃舵暟
+ int days = Integer.parseInt(timeArr[0]);
+ int hours = 0;
+ if (timeArr.length > 1) {
+ hours = Integer.parseInt(timeArr[1]);
+ }
+ time = (days * 24L + hours) * 3600L;
+// //鍒�-绉�
+// time= (days * 60L) + hours;
+ }
+ return time;
+ }
+
+ @Override
+ public Result getProjectList(){
+ List<ProjectInfo> loginUserOwnProjectInfo = getLoginUserOwnProjectInfo();
+ return Result.ok().data(loginUserOwnProjectInfo);
+ }
+
+ @Override
+ public Result getProjectSelectList() {
+ List<ProjectInfo> loginUserOwnProjectInfo = getLoginUserOwnProjectInfo();
+ if (CollectionUtils.isEmpty(loginUserOwnProjectInfo)) {
+ return Result.ok().data(loginUserOwnProjectInfo);
+ }
+
+ Map<String, String> projectMap = loginUserOwnProjectInfo.stream()
+ .collect(Collectors.toMap(
+ projectInfo -> String.valueOf(projectInfo.getId()), // key: 椤圭洰ID
+ ProjectInfo::getProjectName, // value: 椤圭洰瀵硅薄鏈韩
+ (existing, replacement) -> existing, // 澶勭悊閲嶅ID鐨勫啿绐佺瓥鐣ワ紙淇濈暀鍘熸湁鍊硷級
+ LinkedHashMap::new
+ ));
+ return Result.ok().data(projectMap);
+ }
+
+
}
--
Gitblit v1.8.0