| @@ -1039,7 +1039,40 @@ open class DashboardService( | |||||
| return jdbcDao.queryForList(sql.toString(), args) | return jdbcDao.queryForList(sql.toString(), args) | ||||
| } | } | ||||
| fun projectResourceSummaryInformation(args: Map<String, Any>): List<Map<String, Any>> { | fun projectResourceSummaryInformation(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val sql = StringBuilder("select" | |||||
| val sql = StringBuilder( | |||||
| // "select" | |||||
| // + " concat(p.code,'-',p.name) as projectCodeAndName," | |||||
| // + " p.expectedTotalFee as totalFee," | |||||
| // + " expenditure.expenditure as expenditure," | |||||
| // + " case" | |||||
| // + " when p.expectedTotalFee - expenditure.expenditure >= 0 then 'Within Budget'" | |||||
| // + " when p.expectedTotalFee - expenditure.expenditure < 0 then 'Overconsumption'" | |||||
| // + " end as status," | |||||
| // + " p.totalManhour as plannedResources," | |||||
| // + " sum(t.normalConsumed) + sum(t.otConsumed) as resourcesSpent," | |||||
| // + " p.totalManhour - sum(t.normalConsumed) + sum(t.otConsumed) as remainingResources" | |||||
| // + " from project p" | |||||
| // + " left join project_task pt on p.id = pt.project_id" | |||||
| // + " left join timesheet t on pt.id = t.projectTaskId" | |||||
| // + " left join(" | |||||
| // + " select" | |||||
| // + " sum(r.expenditure) as expenditure" | |||||
| // + " from(" | |||||
| // + " select" | |||||
| // + " (coalesce(sum(t.normalConsumed),0) * s2.hourlyRate) + (coalesce(sum(t.otConsumed),0) * s2.hourlyRate * 1.0) as expenditure" | |||||
| // + " from project p" | |||||
| // + " left join project_task pt on p.id = pt.project_id" | |||||
| // + " left join timesheet t on pt.id = t.projectTaskId" | |||||
| // + " left join staff s on t.staffId = s.id" | |||||
| // + " left join salary s2 on s.salaryId = s2.salaryPoint" | |||||
| // + " where t.id is not null" | |||||
| // + " and p.id = :projectId" | |||||
| // + " group by s2.hourlyRate" | |||||
| // + " ) as r" | |||||
| // + " ) as expenditure on 1 = 1" | |||||
| // + " where p.id = :projectId" | |||||
| // + " group by expenditure.expenditure" | |||||
| "select" | |||||
| + " concat(p.code,'-',p.name) as projectCodeAndName," | + " concat(p.code,'-',p.name) as projectCodeAndName," | ||||
| + " p.expectedTotalFee as totalFee," | + " p.expectedTotalFee as totalFee," | ||||
| + " expenditure.expenditure as expenditure," | + " expenditure.expenditure as expenditure," | ||||
| @@ -1048,8 +1081,8 @@ open class DashboardService( | |||||
| + " when p.expectedTotalFee - expenditure.expenditure < 0 then 'Overconsumption'" | + " when p.expectedTotalFee - expenditure.expenditure < 0 then 'Overconsumption'" | ||||
| + " end as status," | + " end as status," | ||||
| + " p.totalManhour as plannedResources," | + " p.totalManhour as plannedResources," | ||||
| + " sum(t.normalConsumed) + sum(t.otConsumed) as resourcesSpent," | |||||
| + " p.totalManhour - sum(t.normalConsumed) + sum(t.otConsumed) as remainingResources" | |||||
| + " sum(ifnull(t.normalConsumed, 0) + ifnull(t.otConsumed, 0)) as resourcesSpent," | |||||
| + " p.totalManhour - sum(ifnull(t.normalConsumed, 0) + ifnull(t.otConsumed, 0)) as remainingResources" | |||||
| + " from project p" | + " from project p" | ||||
| + " left join project_task pt on p.id = pt.project_id" | + " left join project_task pt on p.id = pt.project_id" | ||||
| + " left join timesheet t on pt.id = t.projectTaskId" | + " left join timesheet t on pt.id = t.projectTaskId" | ||||
| @@ -1076,28 +1109,52 @@ open class DashboardService( | |||||
| return jdbcDao.queryForList(sql.toString(), args) | return jdbcDao.queryForList(sql.toString(), args) | ||||
| } | } | ||||
| fun projectResourceSummaryMainStage(args: Map<String, Any>): List<Map<String, Any>> { | fun projectResourceSummaryMainStage(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val sql = StringBuilder("select" | |||||
| val sql = StringBuilder( | |||||
| // "select" | |||||
| // + " p.id as projectId," | |||||
| // + " tg.id," | |||||
| // + " tg.name," | |||||
| // + " count(distinct pt.id) as taskCount," | |||||
| // + " g.name," | |||||
| // + " ifnull(ga.manhour, 0) as plannedResourcesPercentage," | |||||
| // + " ifnull(p.totalManhour, 0) * ifnull(ga.manhour, 0) / 100 as plannedResources," | |||||
| // + " ifnull(p.totalManhour, 0) as totalPlannedResources," | |||||
| // + " sum(ifnull(case when s.gradeId = g.id then t.normalConsumed else 0 end, 0) + ifnull(case when s.gradeId = g.id and ga.projectId = p.id then t.otConsumed else 0 end, 0)) as actualResourcesSpent," | |||||
| // + " sum(ifnull(t.normalConsumed, 0) + ifnull(t.otConsumed, 0)) as totalActualResourcesSpent" | |||||
| // + " from project p" | |||||
| // + " left join project_task pt on pt.project_id = p.id" | |||||
| // + " left join milestone m on m.projectId = p.id and m.id = pt.milestoneId" | |||||
| // + " left join task_group tg on tg.id = m.taskGroupId" | |||||
| // + " left join grade_allocation ga ON ga.projectId = p.id" | |||||
| // + " left join grade g ON g.id = ga.gradeId" | |||||
| // + " left join timesheet t on t.projectTaskId = pt.id" | |||||
| // + " left join staff s on s.id = t.staffId" | |||||
| // + " where p.deleted = false" | |||||
| // + " and p.id = :projectId" | |||||
| // + " group by p.id, tg.id, tg.name, g.name, plannedResourcesPercentage, plannedResources" | |||||
| // + " order by p.id;" | |||||
| "select" | |||||
| + " p.id as projectId," | + " p.id as projectId," | ||||
| + " tg.id," | + " tg.id," | ||||
| + " tg.name," | + " tg.name," | ||||
| + " count(distinct pt.id) as taskCount," | + " count(distinct pt.id) as taskCount," | ||||
| + " g.name," | + " g.name," | ||||
| + " ifnull(ga.manhour, 0) as plannedResourcesPercentage," | |||||
| + " ifnull(p.totalManhour, 0) * ifnull(ga.manhour, 0) / 100 as plannedResources," | |||||
| + " ifnull(p.totalManhour, 0) as totalPlannedResources," | |||||
| + " ifnull(m.stagePercentAllocation, 0) as plannedResourcesPercentage," | |||||
| + " ifnull(p.totalManhour, 0) * (ifnull(ga.manhour, 0) / 100) * (ifnull(m.stagePercentAllocation, 0) / 100) as plannedResources," | |||||
| + " ifnull(p.totalManhour, 0) * (ifnull(m.stagePercentAllocation, 0) / 100) as totalPlannedResources," | |||||
| + " sum(ifnull(case when s.gradeId = g.id then t.normalConsumed else 0 end, 0) + ifnull(case when s.gradeId = g.id and ga.projectId = p.id then t.otConsumed else 0 end, 0)) as actualResourcesSpent," | + " sum(ifnull(case when s.gradeId = g.id then t.normalConsumed else 0 end, 0) + ifnull(case when s.gradeId = g.id and ga.projectId = p.id then t.otConsumed else 0 end, 0)) as actualResourcesSpent," | ||||
| + " sum(ifnull(t.normalConsumed, 0) + ifnull(t.otConsumed, 0)) as totalActualResourcesSpent" | + " sum(ifnull(t.normalConsumed, 0) + ifnull(t.otConsumed, 0)) as totalActualResourcesSpent" | ||||
| + " from project p" | + " from project p" | ||||
| + " left join project_task pt on pt.project_id = p.id" | + " left join project_task pt on pt.project_id = p.id" | ||||
| + " left join milestone m on m.projectId = p.id and m.id = pt.milestoneId" | + " left join milestone m on m.projectId = p.id and m.id = pt.milestoneId" | ||||
| + " left join task_group tg on tg.id = m.taskGroupId" | |||||
| + " left join task_group tg on tg.id = m.taskGroupId " | |||||
| + " left join grade_allocation ga ON ga.projectId = p.id" | + " left join grade_allocation ga ON ga.projectId = p.id" | ||||
| + " left join grade g ON g.id = ga.gradeId" | + " left join grade g ON g.id = ga.gradeId" | ||||
| + " left join timesheet t on t.projectTaskId = pt.id" | + " left join timesheet t on t.projectTaskId = pt.id" | ||||
| + " left join staff s on s.id = t.staffId" | + " left join staff s on s.id = t.staffId" | ||||
| + " where p.deleted = false" | + " where p.deleted = false" | ||||
| + " and p.id = :projectId" | + " and p.id = :projectId" | ||||
| + " group by p.id, tg.id, tg.name, g.name, plannedResourcesPercentage, plannedResources" | |||||
| + " group by p.id, tg.id, tg.name, g.name, plannedResourcesPercentage, plannedResources, totalPlannedResources" | |||||
| + " order by p.id;" | + " order by p.id;" | ||||
| ) | ) | ||||