| @@ -393,7 +393,7 @@ open class DashboardService( | |||||
| return tempList | return tempList | ||||
| } | } | ||||
| fun TeamProjectNo(args: Map<String, Any>): List<Map<String, Any>> { | fun TeamProjectNo(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val sql = StringBuilder("select" | |||||
| val sql = StringBuilder("with teamProject as (select" | |||||
| + " ROW_NUMBER() OVER (ORDER BY t.id,t.teamLead,t.code,t.name) AS id," | + " ROW_NUMBER() OVER (ORDER BY t.id,t.teamLead,t.code,t.name) AS id," | ||||
| + " t.id as teamId," | + " t.id as teamId," | ||||
| + " t.teamLead as teamLeadId," | + " t.teamLead as teamLeadId," | ||||
| @@ -414,7 +414,25 @@ open class DashboardService( | |||||
| } | } | ||||
| } | } | ||||
| sql.append(" group by t.id,t.teamLead,t.code,t.name") | |||||
| sql.append(" group by t.id,t.teamLead,t.code,t.name)" | |||||
| + " select" | |||||
| + " *" | |||||
| + " from teamProject tp" | |||||
| ) | |||||
| if (viewDashboardAuthority() != "self") { | |||||
| sql.append(" union all" | |||||
| + " select" | |||||
| + " null as id," | |||||
| + " null as teamId," | |||||
| + " null as teamLeadId," | |||||
| + " 'All' as teamCode," | |||||
| + " null as teamName," | |||||
| + " sum(tp.projectNo) as projectNo" | |||||
| + " from teamProject tp" | |||||
| + " order by id") | |||||
| } | |||||
| return jdbcDao.queryForList(sql.toString(), args) | return jdbcDao.queryForList(sql.toString(), args) | ||||
| } | } | ||||
| @@ -430,14 +448,14 @@ open class DashboardService( | |||||
| + " s.name as teamLead," | + " s.name as teamLead," | ||||
| // + " GROUP_CONCAT(DISTINCT tg.name ORDER BY tg.name) as expectedStage," | // + " GROUP_CONCAT(DISTINCT tg.name ORDER BY tg.name) as expectedStage," | ||||
| + " taskGroup.expectedStage," | + " taskGroup.expectedStage," | ||||
| + " 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," | |||||
| + " ifnull(p.totalManhour, 0) as budgetedManhour," | |||||
| + " COALESCE (sum(ifnull(t.normalConsumed, 0)) + sum(ifnull(t.otConsumed, 0)),0) as spentManhour," | |||||
| + " COALESCE (ifnull(p.totalManhour, 0) - sum(ifnull(t.normalConsumed, 0)) - sum(ifnull(t.otConsumed, 0)),0) as remainedManhour," | |||||
| + " coalesce (round(((sum(ifnull(t.normalConsumed, 0)) + sum(ifnull(t.otConsumed, 0)))/ifnull(p.totalManhour, 0))*100,2),0) as manhourConsumptionPercentage," | |||||
| + " COALESCE (DATE_FORMAT(milestonePayment.comingPaymentMilestone, '%Y-%m-%d'),'NA') as comingPaymentMilestone," | + " COALESCE (DATE_FORMAT(milestonePayment.comingPaymentMilestone, '%Y-%m-%d'),'NA') as comingPaymentMilestone," | ||||
| + " case" | + " case" | ||||
| + " when COALESCE (p.totalManhour - sum(t.normalConsumed) - sum(t.otConsumed),0) > 0 then 0" | |||||
| + " when COALESCE (p.totalManhour - sum(t.normalConsumed) - sum(t.otConsumed),0) <= 0 then 1" | |||||
| + " when COALESCE (ifnull(p.totalManhour, 0) - sum(ifnull(t.normalConsumed, 0)) - sum(ifnull(t.otConsumed, 0)),0) > 0 then 0" | |||||
| + " when COALESCE (ifnull(p.totalManhour, 0) - sum(ifnull(t.normalConsumed, 0)) - sum(ifnull(t.otConsumed, 0)),0) <= 0 then 1" | |||||
| + " end as alert" | + " end as alert" | ||||
| + " 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" | ||||
| @@ -462,18 +480,27 @@ open class DashboardService( | |||||
| + " FROM project p" | + " FROM project p" | ||||
| + " LEFT JOIN milestone m ON p.id = m.projectId" | + " LEFT JOIN milestone m ON p.id = m.projectId" | ||||
| + " LEFT JOIN milestone_payment mp ON m.id = mp.milestoneId" | + " LEFT JOIN milestone_payment mp ON m.id = mp.milestoneId" | ||||
| + " WHERE p.teamLead = :teamLeadId" | |||||
| + " AND p.status NOT IN ('Pending to Start', 'Completed', 'Deleted')" | |||||
| ) | |||||
| if (args["teamLeadId"] != null && args["teamLeadId"].toString().toInt() > 0) { | |||||
| sql.append(" WHERE p.teamLead = :teamLeadId") | |||||
| } | |||||
| sql.append(" AND p.status NOT IN ('Pending to Start', 'Completed', 'Deleted')" | |||||
| + " AND mp.date >= CURDATE()" | + " AND mp.date >= CURDATE()" | ||||
| + " ) AS subquery" | + " ) AS subquery" | ||||
| + " GROUP BY pid" | + " GROUP BY pid" | ||||
| + " ORDER BY comingPaymentMilestone ASC" | + " ORDER BY comingPaymentMilestone ASC" | ||||
| + " ) milestonePayment on milestonePayment.pid = p.id" | + " ) milestonePayment on milestonePayment.pid = p.id" | ||||
| + " where p.teamLead = :teamLeadId" | |||||
| + " and p.status not in (\"Pending to Start\",\"Completed\",\"Deleted\")" | |||||
| // + " and (tg.name != '5. Miscellaneous' or tg.name is null)" | |||||
| ) | |||||
| if (args["teamLeadId"] != null && args["teamLeadId"].toString().toInt() > 0) { | |||||
| sql.append(" WHERE p.teamLead = :teamLeadId") | |||||
| } | |||||
| sql.append(" and p.status not in (\"Pending to Start\",\"Completed\",\"Deleted\")" | |||||
| // + " and (tg.name != '5. Miscellaneous' or tg.name is null)" | |||||
| + " group by p.id, p.code, p.name, te.code, s.name, p.totalManhour, milestonePayment.comingPaymentMilestone, taskGroup.expectedStage" | + " group by p.id, p.code, p.name, te.code, s.name, p.totalManhour, milestonePayment.comingPaymentMilestone, taskGroup.expectedStage" | ||||
| ) | ) | ||||
| if (args["tableSorting"] == "ProjectName") { | if (args["tableSorting"] == "ProjectName") { | ||||
| sql.append(" ORDER BY p.name ASC") | sql.append(" ORDER BY p.name ASC") | ||||
| } else if (args["tableSorting"] == "PercentageASC") { | } else if (args["tableSorting"] == "PercentageASC") { | ||||