From 6754df3c4faf22d426d45d1c4995c865cab686de Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Mon, 20 Feb 2023 02:45:16 +0000
Subject: [PATCH] 流水相关
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskDaliyRepository.java | 85 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskDaliyRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskDaliyRepository.java
index a2259ff..47332ff 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskDaliyRepository.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/repository/TaskDaliyRepository.java
@@ -23,6 +23,7 @@
import org.springframework.data.jpa.repository.Query;
import java.sql.Timestamp;
+import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -73,12 +74,61 @@
Double findSumConsumedWorkloadByProjectIdAndTaskId(Long projectId, Long taskId);
/**
- * 根据项目ID、任务ID查询
+ * 根据项目ID、任务ID、用户ID查询
* @param projectId
* @param taskId
* @return
*/
- List<TaskDaliy> findByProjectIdAndTaskId(Long projectId, Long taskId);
+ List<TaskDaliy> findByProjectIdAndTaskIdAndUserId(Long projectId, Long taskId, Long userId);
+
+ /**
+ * 根据项目ID查询任务日报信息
+ * @param projectId
+ * @return
+ */
+ @Query(value = "SELECT COALESCE(SUM(consumed_hours), 0.0) AS consumedHours, COALESCE(sum(consumed_workload), 0.0) as consumedWorkload FROM task_daliy WHERE project_id = ?1 AND fill_date < ?2", nativeQuery = true)
+ TaskDailyInterface collectByProjectIdAndFillDateLessThan(Long projectId, Timestamp fillDate);
+
+ /**
+ * 根据项目ID查询任务日报信息
+ * @param projectId
+ * @return
+ */
+ @Query(value = "SELECT td.task_id AS taskId, COALESCE(MAX(td.task_progress), 0) AS taskProgress, COALESCE(SUM(consumed_hours), 0) AS consumedHours, COALESCE(sum(consumed_workload), 0.0) as consumedWorkload, plan_hours AS planHours FROM task_daliy td INNER JOIN task t ON (td.task_id = t.id) WHERE td.project_id = ?1 AND td.fill_date < ?2 GROUP BY td.task_id", nativeQuery = true)
+ List<TaskDailyInterface> collectByProjectIdAndFillDateLessThanGroupByTaskIdJoinTask(Long projectId, Timestamp fillDate);
+
+ /**
+ * 根据项目ID查询任务日报信息
+ * @param projectId
+ * @return
+ */
+ @Query(value = "SELECT user_id AS userId, fill_date AS fillDate, COALESCE(SUM(consumed_hours), 0) AS consumedHours FROM task_daliy WHERE project_id = ?1 AND fill_date < ?2 GROUP BY user_id, fill_date", nativeQuery = true)
+ List<TaskDailyInterface> collectByProjectIdAndFillDateLessThanGroupByUserIdAndFillDate(Long projectId, Timestamp fillDate);
+
+ /**
+ * 根据项目ID查询任务日报信息
+ * @param projectId
+ * @return
+ */
+ @Query(value = "SELECT user_id AS userId, fill_date AS fillDate, COALESCE(SUM(consumed_hours), 0) AS consumedHours FROM task_daliy WHERE project_id = ?1 GROUP BY user_id, fill_date", nativeQuery = true)
+ List<TaskDailyInterface> collectByProjectIdGroupByUserIdAndFillDate(Long projectId);
+
+ /**
+ * 根据项目ID、任务ID查询
+ * @param projectId
+ * @return
+ */
+ @Query(value = "SELECT user_id AS userId, COALESCE(SUM(consumed_hours), 0) AS consumedHours FROM task_daliy WHERE project_id = ?1 GROUP BY user_id", nativeQuery = true)
+ List<TaskDailyInterface> collectCostByProjectIdGroupUser(Long projectId);
+
+ /**
+ * 根据项目ID、任务ID查询
+ * @param projectId
+ * @return
+ */
+ @Query(value = "SELECT user_id AS userId, task_id AS taskId, COALESCE(MAX(task_progress), 0) AS taskProgress FROM task_daliy WHERE project_id = ?1 AND fill_date <= ?2 GROUP BY user_id, task_id", nativeQuery = true)
+ List<TaskDailyInterface> collectCostByProjectIdAndFillDateLessThanGroupUserAndTaskId(Long projectId, Timestamp edate);
+
/**
* 根据项目ID、任务ID、用户ID查询总消耗工时、总消耗工作量、最大任务进度
@@ -89,4 +139,35 @@
*/
@Query(value = "SELECT COALESCE(SUM(consumed_hours), 0) AS consumedHours, COALESCE(SUM(consumed_workload), 0) AS consumedWorkload, COALESCE(MAX(task_progress), 0) AS taskProgress FROM task_daliy WHERE project_id = ?1 AND task_id = ?2 AND user_id = ?3", nativeQuery = true)
TaskDailyInterface findSumConsumedHoursAndSumConsumedWorkloadAndMaxTaskProgressByProjectIdAndTaskIdAndUserId(Long projectId, Long taskId, Long userId);
+
+ /**
+ * 根据userId,开始时间结束时间范围查询日志表
+ * @param userId
+ * @param startDate
+ * @param endDate
+ * @return
+ */
+ @Query(value = "SELECT id,project_id,task_id,user_id,fill_date,consumed_workload,task_progress,settlement_status,SUM( consumed_hours ) AS consumed_hours,remarks,create_by,create_time,update_by,update_time from task_daliy where user_id = ?1 and fill_date <= ?3 and fill_date >= ?2 group by fill_date", nativeQuery = true)
+ List<TaskDaliy> findAllByUserAndDate(Long userId, LocalDate startDate, LocalDate endDate);
+
+ /**
+ * 根据用户ID查询参与的项目ID
+ * @param userId
+ * @return
+ */
+ @Query(value = "SELECT DISTINCT(project_id) FROM task_user WHERE user_id = ?1", nativeQuery = true)
+ List<Long> findProjectIdByUserId(Long userId);
+
+ /**
+ * 根据项目ID删除
+ * @param projectId
+ */
+ void deleteByProjectId(Long projectId);
+
+ /**
+ * 根据项目ID查询
+ * @param projectId
+ * @return
+ */
+ List<TaskDaliy> findByProjectId(Long projectId);
}
\ No newline at end of file
--
Gitblit v1.9.3