|
@@ -2911,35 +2911,59 @@ open class DashboardService( |
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
} |
|
|
} |
|
|
fun IndividualStaffManhoursSpentByMonth(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
fun IndividualStaffManhoursSpentByMonth(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
|
|
|
// println("starting") |
|
|
val sql = StringBuilder( |
|
|
val sql = StringBuilder( |
|
|
"select" |
|
|
|
|
|
+ " p2.id as id," |
|
|
|
|
|
+ " p2.code as projectNo," |
|
|
|
|
|
+ " p2.name as projectName," |
|
|
|
|
|
+ " coalesce (result.manhours,0) as manhours," |
|
|
|
|
|
+ " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage" |
|
|
|
|
|
+ " from staff s2" |
|
|
|
|
|
+ " left join staff_allocation sa2 on sa2.staff_id = s2.id" |
|
|
|
|
|
+ " left join project p2 on sa2.project_id = p2.id" |
|
|
|
|
|
+ " left join (" |
|
|
|
|
|
+ " select" |
|
|
|
|
|
+ " p.id as pid," |
|
|
|
|
|
+ " p.name as projectName," |
|
|
|
|
|
+ " 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" |
|
|
|
|
|
+ " left join timesheet t on s.id = t.staffId" |
|
|
|
|
|
+ " where s.id = :staffId" |
|
|
|
|
|
+ " and t.recordDate >= :startdate" |
|
|
|
|
|
+ " and t.recordDate <= last_day(:startdate)" |
|
|
|
|
|
+ " group by p.id, p.name" |
|
|
|
|
|
+ " ) as result on result.pid = p2.id" |
|
|
|
|
|
+ " where s2.id = :staffId" |
|
|
|
|
|
+ " and result.manhours > 0" |
|
|
|
|
|
+ " group by p2.id, p2.name, result.manhours" |
|
|
|
|
|
|
|
|
// "select" |
|
|
|
|
|
// + " p2.id as id," |
|
|
|
|
|
// + " p2.code as projectNo," |
|
|
|
|
|
// + " p2.name as projectName," |
|
|
|
|
|
// + " coalesce (result.manhours,0) as manhours," |
|
|
|
|
|
// + " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage" |
|
|
|
|
|
// + " from staff s2" |
|
|
|
|
|
// + " left join staff_allocation sa2 on sa2.staff_id = s2.id" |
|
|
|
|
|
// + " left join project p2 on sa2.project_id = p2.id" |
|
|
|
|
|
// + " left join (" |
|
|
|
|
|
// + " select" |
|
|
|
|
|
// + " p.id as pid," |
|
|
|
|
|
// + " p.name as projectName," |
|
|
|
|
|
// + " 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" |
|
|
|
|
|
// + " left join timesheet t on s.id = t.staffId" |
|
|
|
|
|
// + " where s.id = :staffId" |
|
|
|
|
|
// + " and t.recordDate >= :startdate" |
|
|
|
|
|
// + " and t.recordDate <= last_day(:startdate)" |
|
|
|
|
|
// + " group by p.id, p.name" |
|
|
|
|
|
// + " ) as result on result.pid = p2.id" |
|
|
|
|
|
// + " where s2.id = :staffId" |
|
|
|
|
|
// + " and result.manhours > 0" |
|
|
|
|
|
// + " group by p2.id, p2.name, result.manhours" |
|
|
|
|
|
"with result as (" |
|
|
|
|
|
+ " select " |
|
|
|
|
|
+ " p.id, " |
|
|
|
|
|
+ " p.code, " |
|
|
|
|
|
+ " p.name, " |
|
|
|
|
|
+ " sum(coalesce(t.normalConsumed, 0) + coalesce(t.otConsumed, 0)) as manhours " |
|
|
|
|
|
+ " from timesheet t " |
|
|
|
|
|
+ " left join project p on p.id = t.projectId " |
|
|
|
|
|
+ " left join staff s on s.id = t.staffId " |
|
|
|
|
|
+ " where t.deleted = false " |
|
|
|
|
|
+ " and t.projectId is not null " |
|
|
|
|
|
+ " and t.staffId = :staffId " |
|
|
|
|
|
+ " and t.recordDate >= :startdate " |
|
|
|
|
|
+ " and t.recordDate <= last_day(:startdate) " |
|
|
|
|
|
+ " group by p.id, p.code, p.name " |
|
|
|
|
|
+ " ) " |
|
|
|
|
|
+ " select " |
|
|
|
|
|
+ " r.id, " |
|
|
|
|
|
+ " r.code as projectNo, " |
|
|
|
|
|
+ " r.name as projectName, " |
|
|
|
|
|
+ " r.manhours, " |
|
|
|
|
|
+ " (r.manhours / (select sum(manhours) from result)) * 100 as percentage " |
|
|
|
|
|
+ " from result r " |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// println("ending") |
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
} |
|
|
} |
|
|
fun IndividualStaffManhoursSpentWeekly(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
fun IndividualStaffManhoursSpentWeekly(args: Map<String, Any>): List<Map<String, Any>> { |
|
|