From 9b2c90fa0abe194de3a32df97702fd009da88570 Mon Sep 17 00:00:00 2001
From: yaozc <yaozc@yhzhg.cn>
Date: Mon, 25 Mar 2024 09:59:51 +0000
Subject: [PATCH] 11111

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskRepository.java |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskRepository.java
index 01a3dd8..39d229b 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskRepository.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskRepository.java
@@ -16,11 +16,12 @@
 package me.zhengjie.modules.task.repository;
 
 import me.zhengjie.modules.task.domain.Task;
+import me.zhengjie.modules.task.domain.TaskInterface;
+
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -44,6 +45,30 @@
      */
 	List<Task> findByProjectId(Long id);
 
-	@Query(value = "SELECT * FROM task WHERE project_id = ?1 AND create_time < ?2", nativeQuery = true)
-	List<Task> findByProjectIdUntilDate(Long projectId, Date belongDate);
+	@Query(value = "SELECT COALESCE(SUM(plan_hours), 0.0) AS planHours, COALESCE(sum(plan_workload), 0.0) as planWorkload FROM task WHERE project_id = ?1", nativeQuery = true)
+	TaskInterface collectByProjectId(Long projectId);
+
+    /**
+     * 根据项目ID删除
+     * @param projectId
+     */
+    void deleteByProjectId(Long projectId);
+
+    /**
+     * 根据项目ID查询分组工时
+     * @param projectId
+     * @return
+     */
+    @Query(value = "SELECT t.id AS taskId, t.plan_hours AS planHours, p.id AS projectId, p.project_distinguish AS projectDistinguish FROM task t LEFT JOIN project p ON t.project_id = p.id WHERE t.project_id IN (?1)", nativeQuery = true)
+    List<TaskInterface> findSubgroupWorkingHoursByProjectId(List<Long> projectId);
+
+
+    /**
+     * 根据项目ID查询总工时
+     * @param projectId
+     * @return
+     */
+    @Query(value = "SELECT COALESCE(SUM(plan_hours), 0.0) FROM task WHERE project_id IN (?1)", nativeQuery = true)
+    Double sumWorkingHoursByProjectId(List<Long> projectId);
+
 }
\ No newline at end of file

--
Gitblit v1.9.3