Kaynağa Gözat

update

tags/Baseline_30082024_BACKEND_UAT
Mac\David 1 yıl önce
ebeveyn
işleme
4f1c05e608
2 değiştirilmiş dosya ile 116 ekleme ve 5 silme
  1. +92
    -5
      src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt
  2. +24
    -0
      src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt

+ 92
- 5
src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt Dosyayı Görüntüle

@@ -117,6 +117,15 @@ open class DashboardService(
}

sql.append(" group by p.id, p.code, p.name, te.code, s.name, p.totalManhour, milestonePayment.comingPaymentMilestone")

if (args["tableSorting"] == "ProjectName") {
sql.append(" ORDER BY p.name ASC")
} else if (args["tableSorting"] == "PercentageASC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) asc")
} else if (args["tableSorting"] == "PercentageDESC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) desc")
}

return jdbcDao.queryForList(sql.toString(), args)
}

@@ -162,7 +171,13 @@ open class DashboardService(
// + " 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"
)

if (args["tableSorting"] == "ProjectName") {
sql.append(" ORDER BY p.name ASC")
} else if (args["tableSorting"] == "PercentageASC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) asc")
} else if (args["tableSorting"] == "PercentageDESC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) desc")
}
return jdbcDao.queryForList(sql.toString(), args)
}

@@ -315,9 +330,55 @@ open class DashboardService(
// + " 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"
)
if (args["tableSorting"] == "ProjectName") {
sql.append(" ORDER BY p.name ASC")
} else if (args["tableSorting"] == "PercentageASC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) asc")
} else if (args["tableSorting"] == "PercentageDESC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/p.totalManhour)*100,2),0) desc")
}

return jdbcDao.queryForList(sql.toString(), args)
}

fun searchTeamConsumption(args: Map<String, Any>): List<Map<String, Any>>
{
val sql = StringBuilder(
"select"
+ " ROW_NUMBER() OVER (ORDER BY te.code, s.name, project.budgetedManhour) AS id,"
+ " te.code as team,"
+ " s.name as teamLead,"
+ " project.budgetedManhour as budgetedManhour,"
+ " COALESCE (sum(t.normalConsumed) + sum(t.otConsumed),0) as spentManhour,"
+ " COALESCE (project.budgetedManhour - sum(t.normalConsumed) - sum(t.otConsumed),0) as remainedManhour,"
+ " coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/project.budgetedManhour)*100,2),0) as manhourConsumptionPercentage"
+ " from team te"
+ " left join project p on p.teamLead = te.teamLead"
+ " 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 te.teamLead = s.id"
+ " left join ("
+ " select sum(p2.totalManhour) as budgetedManhour"
+ " from team t2"
+ " left join project p2 on p2.teamLead = t2.teamLead"
+ " where p2.teamLead in (:teamIds)"
+ " ) as project on 1 = 1"
+ " where p.teamLead in (:teamIds)"
+ " and p.status not in ('Pending to Start','Completed','Deleted')"
+ " group by te.code, s.name, project.budgetedManhour"
)

if (args["tableSorting"] == "ProjectName") {
sql.append(" ORDER BY te.code ASC")
} else if (args["tableSorting"] == "PercentageASC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/project.budgetedManhour)*100,2),0) asc")
} else if (args["tableSorting"] == "PercentageDESC") {
sql.append(" ORDER BY coalesce (round(((sum(t.normalConsumed) + sum(t.otConsumed))/project.budgetedManhour)*100,2),0) desc")
}

return jdbcDao.queryForList(sql.toString(), args)
}

fun searchFinancialSummaryCard(args: Map<String, Any>): List<Map<String, Any>> {
val sql = StringBuilder(
"select"
@@ -327,13 +388,19 @@ open class DashboardService(
+ " coalesce(pj.totalFee,0) as totalFee,"
+ " coalesce(pj.totalBudget,0) as totalBudget,"
+ " coalesce(sum(i.issueAmount),0) as totalInvoiced,"
+ " coalesce(pj.totalFee,0) - coalesce(sum(i.issueAmount),0) as unInvoiced,"
+ " coalesce(sum(i.paidAmount),0) as totalReceived,"
+ " round(expenditure.cumulativeExpenditure,2) as cumulativeExpenditure,"
+ " case"
+ " when coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2),0) >= 1 then 'Positive'"
+ " when coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2),0) < 1 then 'Negative'"
+ " end as cashFlowStatus,"
+ " coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2),0) as cpi"
+ " coalesce(round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2),0) as cpi,"
+ " coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),2),0) as projectedCpi,"
+ " case"
+ " when coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),2),0) >= 1 then 'Positive'"
+ " when coalesce(round(coalesce(pj.totalFee,0) / (expenditure.cumulativeExpenditure),2),0) < 1 then 'Negative'"
+ " end as projectedCashFlowStatus"
+ " from team t"
+ " left join ("
+ " select"
@@ -404,12 +471,18 @@ open class DashboardService(
+ " round(sum(p.expectedTotalFee) * 0.8,2) as totalBudget,"
+ " round(expenditure.cumulativeExpenditure,2) as cumulativeExpenditure,"
+ " sum(i.issueAmount) as totalInvoiced,"
+ " sum(p.expectedTotalFee) - sum(i.issueAmount) as unInvoiced,"
+ " sum(i.paidAmount) as totalReceived,"
+ " case"
+ " when round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2) >= 1 then 'Positive'"
+ " when round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2) < 1 then 'Negative'"
+ " end as cashFlowStatus,"
+ " round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2) as cpi"
+ " round(sum(i.issueAmount) / (expenditure.cumulativeExpenditure),2) as cpi,"
+ " round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),2) as projectedCpi,"
+ " case"
+ " when round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),2) >= 1 then 'Positive'"
+ " when round(sum(p.expectedTotalFee) / (expenditure.cumulativeExpenditure),2) < 1 then 'Negative'"
+ " end as projectedCashFlowStatus"
+ " from project p"
+ " left join ("
+ " select"
@@ -550,6 +623,11 @@ open class DashboardService(
+ " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'"
+ " end as cashFlowStatus,"
+ " coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as cpi,"
+ " coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as projectedCpi,"
+ " case"
+ " when coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) >= 1 then 'Positive'"
+ " when coalesce(round(p.totalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'"
+ " end as projectedCashFlowStatus,"
+ " case"
+ " when p.totalFee - sum(i.issueAmount) >= 0 then coalesce(round(p.totalFee - sum(i.issueAmount),2),0)"
+ " when p.totalFee - sum(i.issueAmount) < 0 then 0"
@@ -653,6 +731,11 @@ open class DashboardService(
+ " when coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'"
+ " end as cashFlowStatus,"
+ " coalesce(round(sum(i.issueAmount) / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as cpi,"
+ " coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) as projectedCpi,"
+ " case"
+ " when coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) >= 1 then 'Positive'"
+ " when coalesce(round(p.expectedTotalFee / (COALESCE(expenditure.cumulativeExpenditure,0)),2),0) < 1 then 'Negative'"
+ " end as projectedCashFlowStatus,"
// + " case"
// + " when coalesce(round(sum(p.expectedTotalFee) * 0.8,2),0) <= COALESCE(expenditure.cumulativeExpenditure,0) then coalesce(round(sum(p.expectedTotalFee) * 0.8,2),0) - coalesce(sum(i.issueAmount),0)"
// + " when coalesce(round(sum(p.expectedTotalFee) * 0.8,2),0) > COALESCE(expenditure.cumulativeExpenditure,0) and COALESCE(expenditure.cumulativeExpenditure,0) < coalesce(sum(i.issueAmount),0) then 0"
@@ -850,7 +933,9 @@ open class DashboardService(
+ " coalesce (sum(i.issueAmount) - sum(i.paidAmount),0) as receivable,"
+ " coalesce (round(sum(p.expectedTotalFee)*0.8,2),0) as totalBudget,"
+ " coalesce (expenditure.expenditure,0) as totalExpenditure,"
+ " coalesce (sum(p.expectedTotalFee)*0.8 - expenditure.expenditure,0) as expenditureReceivable"
+ " coalesce (sum(p.expectedTotalFee)*0.8 - expenditure.expenditure,0) as expenditureReceivable,"
+ " sum(p.expectedTotalFee) as totalProjectFee,"
+ " coalesce (round(sum(i.issueAmount)/sum(p.expectedTotalFee)*100,0),0) as invoicedPercentage"
+ " from project p"
+ " left join ("
+ " select"
@@ -1194,7 +1279,9 @@ open class DashboardService(
"select"
+ " concat(p.code,'-',p.name) as projectCodeAndName,"
+ " p.expectedTotalFee as totalFee,"
+ " expenditure.expenditure as expenditure,"
+ " p.expectedTotalFee * 0.8 as totalBudget,"
+ " coalesce (expenditure.expenditure,0) as expenditure,"
+ " (p.expectedTotalFee * 0.8) - coalesce (expenditure.expenditure,0) as remainingBudget,"
+ " case"
+ " when p.expectedTotalFee - expenditure.expenditure >= 0 then 'Within Budget'"
+ " when p.expectedTotalFee - expenditure.expenditure < 0 then 'Overconsumption'"


+ 24
- 0
src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt Dosyayı Görüntüle

@@ -51,6 +51,7 @@ class DashboardController(
fun searchCustomerSubsidiaryProject(request: HttpServletRequest?): List<Map<String, Any>> {
val customerId = request?.getParameter("customerId")
val subsidiaryId = request?.getParameter("subsidiaryId")
val tableSorting = request?.getParameter("tableSorting")
val args = mutableMapOf<String, Any>()
var result: List<Map<String, Any>> = emptyList()
if (customerId != null) {
@@ -59,6 +60,9 @@ class DashboardController(
if (subsidiaryId != null) {
args["subsidiaryId"] = subsidiaryId
}
if (tableSorting != null) {
args["tableSorting"] = tableSorting
}

if (customerId != null && subsidiaryId != null) {
result = dashboardService.searchCustomerSubsidiaryProject(args)
@@ -80,16 +84,36 @@ class DashboardController(
@GetMapping("/searchTeamProject")
fun searchTeamProject(request: HttpServletRequest?): List<Map<String, Any>> {
val teamLeadId = request?.getParameter("teamLeadId")
val tableSorting = request?.getParameter("tableSorting")
val args = mutableMapOf<String, Any>()
var result: List<Map<String, Any>> = emptyList()
if (teamLeadId != null) {
args["teamLeadId"] = teamLeadId
}
if (tableSorting != null) {
args["tableSorting"] = tableSorting
}

result = dashboardService.searchTeamProject(args)

return result
}
@GetMapping("/searchTeamConsumption")
fun searchTeamConsumption(request: HttpServletRequest?): List<Map<String, Any>> {
val args = mutableMapOf<String, Any>()
val teamIdList = request?.getParameter("teamIdList")
val tableSorting = request?.getParameter("tableSorting")
val teamIds = teamIdList?.split(",")?.map { it.toInt() }?.toList()
var result: List<Map<String, Any>> = emptyList()
if (teamIds != null) {
args["teamIds"] = teamIds
}
if (tableSorting != null) {
args["tableSorting"] = tableSorting
}
result = dashboardService.searchTeamProject(args)
return result
}
@GetMapping("/searchFinancialSummaryCard")
fun searchFinancialSummaryCard(request: HttpServletRequest?): List<Map<String, Any>> {
val authority = dashboardService.viewDashboardAuthority()


Yükleniyor…
İptal
Kaydet