Ver código fonte

update dashboard (progress by team)

add_swagger
cyril.tsui 9 meses atrás
pai
commit
227a1e9ca8
1 arquivos alterados com 40 adições e 13 exclusões
  1. +40
    -13
      src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt

+ 40
- 13
src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt Ver arquivo

@@ -393,7 +393,7 @@ open class DashboardService(
return tempList
}
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,"
+ " t.id as teamId,"
+ " 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)
}

@@ -430,14 +448,14 @@ open class DashboardService(
+ " s.name as teamLead,"
// + " GROUP_CONCAT(DISTINCT tg.name ORDER BY tg.name) as 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,"
+ " 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"
+ " from project p"
+ " left join project_task pt on p.id = pt.project_id"
@@ -462,18 +480,27 @@ open class DashboardService(
+ " 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"
+ " 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()"
+ " ) AS subquery"
+ " GROUP BY pid"
+ " ORDER BY comingPaymentMilestone ASC"
+ " ) 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"
)

if (args["tableSorting"] == "ProjectName") {
sql.append(" ORDER BY p.name ASC")
} else if (args["tableSorting"] == "PercentageASC") {


Carregando…
Cancelar
Salvar