From 42e2d6305a7fcefedeb80c5412ccfdaf27b314b3 Mon Sep 17 00:00:00 2001
From: yaozc2021 <yaozc@yhzhg.cn>
Date: Wed, 15 Jan 2025 09:22:43 +0000
Subject: [PATCH] Merge branch 'wcd-2411-update' of http://192.168.1.110:5678/r/pms-upgrade into wcd

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskUserRepository.java |   95 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskUserRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskUserRepository.java
index 0884b60..2ae35aa 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskUserRepository.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskUserRepository.java
@@ -16,8 +16,13 @@
 package me.zhengjie.modules.task.repository;
 
 import me.zhengjie.modules.task.domain.TaskUser;
+
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.Collection;
+import java.util.List;
 
 /**
 * @website https://eladmin.vip
@@ -25,4 +30,94 @@
 * @date 2022-12-28
 **/
 public interface TaskUserRepository extends JpaRepository<TaskUser, Long>, JpaSpecificationExecutor<TaskUser> {
+
+    /**
+     * 根据任务ID查询任务工时总和
+     * @param taskId /
+     * @return /
+     */
+    @Query(value = "SELECT COALESCE(SUM(task_hours),0) FROM task_user WHERE task_id = ?1 and enable = 1", nativeQuery = true)
+    Double sumTaskHoursByTaskId(Long taskId);
+
+    /**
+     * 根据任务ID查询任务工作量总和
+     * @param taskId /
+     * @return /
+     */
+    @Query(value = "SELECT COALESCE(SUM(task_workload),0) FROM task_user WHERE task_id = ?1 and enable = 1", nativeQuery = true)
+    Double sumTaskWorkloadByTaskId(Long taskId);
+
+    /**
+     * 根据任务ID查询所属用户
+     * @param taskId /
+     * @return /
+     */
+    @Query(value = "SELECT user_id FROM task_user WHERE task_id = ?1", nativeQuery = true)
+    List<Long> findUserIdByTaskId(Long taskId);
+
+    /**
+     * 根据用户ID查询项目ID
+     * @param userId
+     * @return
+     */
+    @Query(value = "SELECT project_id FROM task_user WHERE user_id = ?1", nativeQuery = true)
+    List<Long> findProjectIdByUserId(Long userId);
+
+    /**
+     * 根据用户ID、项目ID查询任务ID
+     * @param userId
+     * @return
+     */
+    @Query(value = "SELECT task_id FROM task_user WHERE user_id = ?1 AND project_id = ?2", nativeQuery = true)
+    List<Long> findTaskIdByUserIdAndProjectId(Long userId, Long projectId);
+
+    /**
+     * 根据多任务ID查询
+     * @param userId
+     * @param taskIds
+     * @return
+     */
+    List<TaskUser> findByUserIdAndTaskIdIn(Long userId, List<Long> taskIds);
+
+    /**
+     * 根据多任务ID查询
+     * @param taskIds
+     * @return
+     */
+    List<TaskUser> findByTaskIdIn(List<Long> taskIds);
+
+    /**
+     * 根据任务ID和员工ID查询
+     * @param taskId
+     * @param userId
+     * @return
+     */
+	List<TaskUser> findByTaskIdAndUserId(Long taskId, Long userId);
+
+    /**
+     * 根据任务ID和员工ID查询
+     * @param taskId
+     * @param userId
+     * @return
+     */
+	TaskUser findByTaskIdAndTaskInnerIdAndUserId(Long taskId, Long taskInnerId, Long userId);
+
+    /**
+     * 根据任务ID和员工ID查询
+     * @param taskId
+     * @param userId
+     * @return
+     */
+	TaskUser findByTaskIdAndUserIdAndEnable(Long taskId, Long userId, Boolean enable);
+
+    /**
+     * 根据项目ID删除
+     * @param projectId
+     */
+    void deleteByProjectId(Long projectId);
+
+	List<TaskUser> findByTaskId(Long id);
+
+    @Query(value = "select DISTINCT user_id from task_user where task_id = ?1",nativeQuery = true)
+    List<Long> getAllTaskCountByUserId(Long task_id);
 }
\ No newline at end of file

--
Gitblit v1.9.3