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 cddded1..795823a 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 @@ -69,7 +69,7 @@ open class DashboardService( + " p.totalManhour as budgetedManhour," + " sum(t.normalConsumed) + sum(t.otConsumed) as spentManhour," + " p.totalManhour - sum(t.normalConsumed) - sum(t.otConsumed) as remainedManhour," - + " coalesce (round(((sum(t.normalConsumed) - sum(t.otConsumed))/p.totalManhour)*100,2),0) as manhourConsumptionPercentage," + + " coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) as manhourConsumptionPercentage," + " DATE_FORMAT(milestonePayment.comingPaymentMilestone, '%Y-%m-%d') as comingPaymentMilestone" + " from project p" + " left join project_task pt on p.id = pt.project_id" @@ -112,7 +112,7 @@ open class DashboardService( + " p.totalManhour as budgetedManhour," + " COALESCE (sum(t.normalConsumed) + sum(t.otConsumed),0) as spentManhour," + " COALESCE (p.totalManhour - sum(t.normalConsumed) - sum(t.otConsumed),0) as remainedManhour," - + " coalesce (round(((sum(t.normalConsumed) - sum(t.otConsumed))/p.totalManhour)*100,2),0) as manhourConsumptionPercentage," + + " coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) as manhourConsumptionPercentage," + " DATE_FORMAT(milestonePayment.comingPaymentMilestone, '%Y-%m-%d') as comingPaymentMilestone" + " from project p" + " left join project_task pt on p.id = pt.project_id" @@ -256,7 +256,7 @@ open class DashboardService( + " p.totalManhour as budgetedManhour," + " COALESCE (sum(t.normalConsumed) + sum(t.otConsumed),0) as spentManhour," + " COALESCE (p.totalManhour - sum(t.normalConsumed) - sum(t.otConsumed),0) as remainedManhour," - + " coalesce (round(((sum(t.normalConsumed) - sum(t.otConsumed))/p.totalManhour)*100,2),0) as manhourConsumptionPercentage," + + " coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) as manhourConsumptionPercentage," + " DATE_FORMAT(milestonePayment.comingPaymentMilestone, '%Y-%m-%d') as comingPaymentMilestone" + " from project p" + " left join project_task pt on p.id = pt.project_id" @@ -483,6 +483,7 @@ open class DashboardService( + " p.code as projectCode," + " p.name as projectName," + " c.name as customerName," + + " s3.name as subsidiaryName," + " p.expectedTotalFee as totalFee," + " round(p.expectedTotalFee * 0.8,2) as totalBudget," + " COALESCE(round(expenditure.cumulativeExpenditure,2),0) as cumulativeExpenditure," @@ -500,6 +501,7 @@ open class DashboardService( + " end as totalUninvoiced" + " from team t" + " left join project p on t.teamLead = p.teamLead" + + " left join subsidiary s3 on p.customerSubsidiaryId = s3.id" + " left join customer c on p.customerId = c.id" + " left join invoice i on p.code = i.projectCode" + " left join (" @@ -1434,7 +1436,7 @@ open class DashboardService( + " select" + " p.id as pid," + " p.name as projectName," - + " coalesce (sum(t.normalConsumed)+sum(t.otConsumed),0) as manhours" + + " coalesce (coalesce(sum(t.normalConsumed),0)+coalesce(sum(t.otConsumed),0),0) as manhours" + " from staff s" + " left join staff_allocation sa on sa.staff_id = s.id" + " left join project p on sa.project_id = p.id" @@ -1445,6 +1447,7 @@ open class DashboardService( + " group by p.id, p.name" + " ) as result on result.pid = p2.id" + " where s2.id = :staffId" + + " group by p2.id, p2.name, result.manhours" ) return jdbcDao.queryForList(sql.toString(), args) @@ -1463,7 +1466,7 @@ open class DashboardService( + " select" + " p.id as pid," + " p.name as projectName," - + " coalesce (sum(t.normalConsumed)+sum(t.otConsumed),0) as manhours" + + " coalesce (coalesce(sum(t.normalConsumed),0)+coalesce(sum(t.otConsumed),0),0) as manhours" + " from staff s" + " left join staff_allocation sa on sa.staff_id = s.id" + " left join project p on sa.project_id = p.id" @@ -1474,6 +1477,7 @@ open class DashboardService( + " group by p.id, p.name" + " ) as result on result.pid = p2.id" + " where s2.id = :staffId" + + " group by p2.id, p2.name, result.manhours" ) return jdbcDao.queryForList(sql.toString(), args) @@ -1492,7 +1496,7 @@ open class DashboardService( + " select" + " p.id as pid," + " p.name as projectName," - + " coalesce (sum(t.normalConsumed)+sum(t.otConsumed),0) as manhours" + + " coalesce (coalesce(sum(t.normalConsumed),0)+coalesce(sum(t.otConsumed),0),0) as manhours" + " from staff s" + " left join staff_allocation sa on sa.staff_id = s.id" + " left join project p on sa.project_id = p.id" @@ -1502,6 +1506,7 @@ open class DashboardService( + " group by p.id, p.name" + " ) as result on result.pid = p2.id" + " where s2.id = :staffId" + + " group by p2.id, p2.name, result.manhours" ) return jdbcDao.queryForList(sql.toString(), args) @@ -1521,6 +1526,18 @@ open class DashboardService( return jdbcDao.queryForList(sql.toString(), args) } + fun IndividualStaffTotalLeaveHoursByDay(args: Map): List> { + val sql = StringBuilder( + "select" + + " coalesce (sum(l.leaveHours),0) as leaveHours" + + " from staff s2" + + " left join `leave` l on s2.id = l.staffId" + + " where l.recordDate = :startdate" + + " and s2.id = :staffId" + ) + + return jdbcDao.queryForList(sql.toString(), args) + } fun IndividualStaffTotalManhoursSpentWeekly(args: Map): List> { val sql = StringBuilder( "select" @@ -1537,6 +1554,19 @@ open class DashboardService( return jdbcDao.queryForList(sql.toString(), args) } + fun IndividualStaffTotalLeaveHoursWeekly(args: Map): List> { + val sql = StringBuilder( + "select" + + " coalesce (sum(l.leaveHours),0) as leaveHours" + + " from staff s2" + + " left join `leave` l on s2.id = l.staffId" + + " where l.recordDate >= :startdate" + + " and l.recordDate <= :enddate" + + " and s2.id = :staffId" + ) + + return jdbcDao.queryForList(sql.toString(), args) + } fun IndividualStaffTotalManhoursSpentByMonthly(args: Map): List> { val sql = StringBuilder( "select" @@ -1551,6 +1581,31 @@ open class DashboardService( + " and t.recordDate <= last_day(:startdate)" ) + return jdbcDao.queryForList(sql.toString(), args) + } + fun IndividualStaffTotalLeaveHoursMonthly(args: Map): List> { + val sql = StringBuilder( + "select" + + " coalesce (sum(l.leaveHours),0) as leaveHours" + + " from staff s2" + + " left join `leave` l on s2.id = l.staffId" + + " where l.recordDate >= :startdate" + + " and l.recordDate <= last_day(:startdate)" + + " and s2.id = :staffId" + ) + + return jdbcDao.queryForList(sql.toString(), args) + } + fun staffCombo(args: Map): List> { + val sql = StringBuilder( + "select" + + " s.id as id," + + " s.name as name," + + " concat(s.staffId ,'-',s.name) as label" + + " from staff s" + + " where s.deleted = 0" + ) + return jdbcDao.queryForList(sql.toString(), args) } } diff --git a/src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt b/src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt index 601e575..80f1055 100644 --- a/src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt +++ b/src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt @@ -318,7 +318,7 @@ class DashboardController( val publicHolidayList = publicHolidayListParam.split(",").map { it.trim() } args["publicHolidayList"] = publicHolidayList } - return dashboardService.newMonthlyUnsubmittedTimeSheet(args) + return dashboardService.monthlyUnsubmittedTimeSheet(args) } @GetMapping("/searchTotalManhoursSpentByStaffGrade") fun searchTotalManhoursSpentByStaffGrade(request: HttpServletRequest?): List> { @@ -348,13 +348,15 @@ class DashboardController( args["startdate"] = startdate } if (staffId != null) { - args["staff"] = staffId + args["staffId"] = staffId } val result = mutableMapOf() val individualStaffManhoursSpentByDay = dashboardService.IndividualStaffManhoursSpentByDay(args) val individualStaffTotalManhoursSpentByDay = dashboardService.IndividualStaffTotalManhoursSpentByDay(args) + val individualStaffTotalLeaveHoursByDay = dashboardService.IndividualStaffTotalLeaveHoursByDay(args) result["individualStaffManhoursSpentByDay"] = individualStaffManhoursSpentByDay result["individualStaffTotalManhoursSpentByDay"] = individualStaffTotalManhoursSpentByDay + result["individualStaffTotalLeaveHoursByDay"] = individualStaffTotalLeaveHoursByDay return listOf(result) } @GetMapping("/searchTotalManhoursSpentByStaffWeekly") @@ -370,13 +372,15 @@ class DashboardController( args["enddate"] = enddate } if (staffId != null) { - args["staff"] = staffId + args["staffId"] = staffId } val result = mutableMapOf() val individualStaffManhoursSpentWeekly = dashboardService.IndividualStaffManhoursSpentWeekly(args) val individualStaffTotalManhoursSpentWeekly = dashboardService.IndividualStaffTotalManhoursSpentWeekly(args) + val individualStaffTotalLeaveHoursWeekly = dashboardService.IndividualStaffTotalLeaveHoursWeekly(args) result["individualStaffManhoursSpentWeekly"] = individualStaffManhoursSpentWeekly result["individualStaffTotalManhoursSpentWeekly"] = individualStaffTotalManhoursSpentWeekly + result["individualStaffTotalLeaveHoursWeekly"] = individualStaffTotalLeaveHoursWeekly return listOf(result) } @GetMapping("/searchTotalManhoursSpentByStaffByMonth") @@ -388,13 +392,20 @@ class DashboardController( args["startdate"] = startdate } if (staffId != null) { - args["staff"] = staffId + args["staffId"] = staffId } val result = mutableMapOf() val individualStaffManhoursSpentByMonth = dashboardService.IndividualStaffManhoursSpentByMonth(args) val individualStaffTotalManhoursSpentByMonth = dashboardService.IndividualStaffTotalManhoursSpentByMonthly(args) + val individualStaffTotalLeaveHoursByMonth = dashboardService.IndividualStaffTotalLeaveHoursMonthly(args) result["individualStaffManhoursSpentByMonth"] = individualStaffManhoursSpentByMonth result["individualStaffTotalManhoursSpentByMonth"] = individualStaffTotalManhoursSpentByMonth + result["individualStaffTotalLeaveHoursByMonth"] = individualStaffTotalLeaveHoursByMonth return listOf(result) } + @GetMapping("/searchStaffCombo") + fun searchStaffCombo(request: HttpServletRequest?): List> { + val args = mutableMapOf() + return dashboardService.staffCombo(args) + } } \ No newline at end of file