From 323fea9c5e45e0a6cb17a4a40170356bdb414ef2 Mon Sep 17 00:00:00 2001 From: "Mac\\David" Date: Fri, 14 Jun 2024 16:52:33 +0800 Subject: [PATCH] api bug fix --- .../modules/data/service/DashboardService.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt b/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt index d47da65..9c7cb08 100644 --- a/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt +++ b/src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt @@ -89,13 +89,14 @@ open class DashboardService( + " left join milestone m on p.id = m.projectId and curdate() >= m.startDate and curdate() <= m.endDate" + " left join task_group tg on m.taskGroupId = tg.id" + " left join (" - + " SELECT pid, MAX(comingPaymentMilestone) AS comingPaymentMilestone" + + " SELECT pid, MIN(comingPaymentMilestone) AS comingPaymentMilestone" + " FROM (" + " SELECT p.id AS pid, mp.date AS comingPaymentMilestone" + " FROM project p" + " LEFT JOIN milestone m ON p.id = m.projectId" + " LEFT JOIN milestone_payment mp ON m.id = mp.milestoneId" - + " WHERE p.teamLead = :teamLeadId" + + " WHERE p.customerId = :customerId" + + " and p.customerSubsidiaryId = :subsidiaryId" + " AND p.status NOT IN ('Pending to Start', 'Completed', 'Deleted')" + " AND mp.date >= CURDATE()" + " ) AS subquery" @@ -142,13 +143,13 @@ open class DashboardService( + " left join milestone m on p.id = m.projectId and curdate() >= m.startDate and curdate() <= m.endDate" + " left join task_group tg on m.taskGroupId = tg.id" + " left join (" - + " SELECT pid, MAX(comingPaymentMilestone) AS comingPaymentMilestone" + + " SELECT pid, MIN(comingPaymentMilestone) AS comingPaymentMilestone" + " FROM (" + " SELECT p.id AS pid, mp.date AS comingPaymentMilestone" + " FROM project p" + " LEFT JOIN milestone m ON p.id = m.projectId" + " LEFT JOIN milestone_payment mp ON m.id = mp.milestoneId" - + " WHERE p.teamLead = :teamLeadId" + + " WHERE p.customerId = :customerId" + " AND p.status NOT IN ('Pending to Start', 'Completed', 'Deleted')" + " AND mp.date >= CURDATE()" + " ) AS subquery" @@ -296,7 +297,7 @@ open class DashboardService( + " left join milestone m on p.id = m.projectId and curdate() >= m.startDate and curdate() <= m.endDate" + " left join task_group tg on m.taskGroupId = tg.id" + " left join (" - + " SELECT pid, MAX(comingPaymentMilestone) AS comingPaymentMilestone" + + " SELECT pid, MIN(comingPaymentMilestone) AS comingPaymentMilestone" + " FROM (" + " SELECT p.id AS pid, mp.date AS comingPaymentMilestone" + " FROM project p" @@ -1587,7 +1588,7 @@ open class DashboardService( + " from staff s" + " left join staff_allocation sa on sa.staff_id = s.id" + " left join project p on sa.project_id = p.id" - + " left join timesheet t on p.id = t.projectId" + + " left join timesheet t on p.id = t.projectId and s.id = t.staffId" + " where s.id = :staffId" + " and t.recordDate >= :startdate" + " and t.recordDate <= last_day(:startdate)" @@ -1618,7 +1619,7 @@ open class DashboardService( + " from staff s" + " left join staff_allocation sa on sa.staff_id = s.id" + " left join project p on sa.project_id = p.id" - + " left join timesheet t on p.id = t.projectId" + + " left join timesheet t on p.id = t.projectId and s.id = t.staffId" + " where s.id = :staffId" + " and t.recordDate >= :startdate" + " and t.recordDate <= :enddate" @@ -1649,7 +1650,7 @@ open class DashboardService( + " from staff s" + " left join staff_allocation sa on sa.staff_id = s.id" + " left join project p on sa.project_id = p.id" - + " left join timesheet t on p.id = t.projectId" + + " left join timesheet t on p.id = t.projectId and s.id = t.staffId" + " where s.id = :staffId" + " and t.recordDate = :startdate" + " group by p.id, p.name"