浏览代码

fix

tags/Baseline_30082024_BACKEND_UAT
Mac\David 1年前
父节点
当前提交
089487abde
共有 2 个文件被更改,包括 38 次插入14 次删除
  1. +34
    -14
      src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt
  2. +4
    -0
      src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt

+ 34
- 14
src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt 查看文件

@@ -102,6 +102,7 @@ open class DashboardService(
+ " ) milestonePayment on 1=1" + " ) milestonePayment on 1=1"
+ " where p.customerId = :customerId" + " where p.customerId = :customerId"
+ " and p.customerSubsidiaryId = :subsidiaryId" + " and p.customerSubsidiaryId = :subsidiaryId"
+ " and (tg.name != '5. Miscellaneous' or tg.name is null)"
+ " and p.status not in (\"Pending to Start\",\"Completed\",\"Deleted\")" + " and p.status not in (\"Pending to Start\",\"Completed\",\"Deleted\")"
) )


@@ -153,6 +154,7 @@ open class DashboardService(
+ " where p.customerId = :customerId" + " where p.customerId = :customerId"
+ " and isNull(p.customerSubsidiaryId)" + " and isNull(p.customerSubsidiaryId)"
+ " and p.status not in (\"Pending to Start\",\"Completed\",\"Deleted\")" + " 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, tg.name, p.totalManhour, milestonePayment.comingPaymentMilestone" + " group by p.id, p.code, p.name, te.code, s.name, tg.name, p.totalManhour, milestonePayment.comingPaymentMilestone"
) )


@@ -302,6 +304,7 @@ open class DashboardService(
+ " ) milestonePayment on 1=1" + " ) milestonePayment on 1=1"
+ " where p.teamLead = :teamLeadId" + " where p.teamLead = :teamLeadId"
+ " and p.status not in (\"Pending to Start\",\"Completed\",\"Deleted\")" + " 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, tg.name, p.totalManhour, milestonePayment.comingPaymentMilestone" + " group by p.id, p.code, p.name, te.code, s.name, tg.name, p.totalManhour, milestonePayment.comingPaymentMilestone"
) )


@@ -312,9 +315,9 @@ open class DashboardService(
"select" "select"
+ " t.id as teamId," + " t.id as teamId,"
+ " t.name as teamName," + " t.name as teamName,"
+ " count(p.name) as projectNo,"
+ " coalesce(sum(p.expectedTotalFee),0) as totalFee,"
+ " coalesce(sum(round(p.expectedTotalFee * 0.8,2)),0) as totalBudget,"
+ " pj.projectNo as projectNo,"
+ " coalesce(pj.totalFee,0) as totalFee,"
+ " coalesce(pj.totalBudget,0) as totalBudget,"
+ " coalesce(sum(i.issueAmount),0) as totalInvoiced," + " coalesce(sum(i.issueAmount),0) as totalInvoiced,"
+ " coalesce(sum(i.paidAmount),0) as totalReceived," + " coalesce(sum(i.paidAmount),0) as totalReceived,"
+ " round(expenditure.cumulativeExpenditure,2) as cumulativeExpenditure," + " round(expenditure.cumulativeExpenditure,2) as cumulativeExpenditure,"
@@ -324,7 +327,17 @@ open class DashboardService(
+ " end as cashFlowStatus," + " 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"
+ " from team t" + " from team t"
+ " left join project p on t.teamLead = p.teamLead"
+ " left join ("
+ " select"
+ " t2.id as tid,"
+ " count(p.id) as projectNo,"
+ " sum(p.expectedTotalFee) as totalFee,"
+ " sum(round(p.expectedTotalFee * 0.8,2)) as totalBudget"
+ " from team t2"
+ " left join project p on t2.teamLead = p.teamLead"
+ " where p.status = 'On-going'"
+ " group by t2.id"
+ " ) as pj on pj.tid = t.id"
+ " left join (" + " left join ("
+ " select" + " select"
+ " t3.id as tid," + " t3.id as tid,"
@@ -361,7 +374,7 @@ open class DashboardService(
+ " group by r.teamId" + " group by r.teamId"
+ " ) as expenditure on expenditure.teamId = t.id" + " ) as expenditure on expenditure.teamId = t.id"
+ " where t.deleted = 0" + " where t.deleted = 0"
+ " and p.status = 'On-going'"
+ " and pj.projectNo is not null"
) )


if (viewDashboardAuthority() == "self") { if (viewDashboardAuthority() == "self") {
@@ -835,7 +848,7 @@ open class DashboardService(
+ " COALESCE(ROUND(expenditure, 2), 0) AS expenditure," + " COALESCE(ROUND(expenditure, 2), 0) AS expenditure,"
+ " ROUND(SUM(COALESCE(income, 0) - COALESCE(expenditure, 0)) OVER (ORDER BY parsed_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 2) AS balance," + " ROUND(SUM(COALESCE(income, 0) - COALESCE(expenditure, 0)) OVER (ORDER BY parsed_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 2) AS balance,"
+ " CASE" + " CASE"
+ " WHEN income > 0 THEN paymentMilestone"
+ " WHEN income > 0 THEN concat('Invoice Receipt: ',invoiceNo)"
+ " ELSE 'Monthly Manpower Expenditure'" + " ELSE 'Monthly Manpower Expenditure'"
+ " END AS remarks" + " END AS remarks"
+ " FROM (" + " FROM ("
@@ -844,7 +857,7 @@ open class DashboardService(
+ " DATE_FORMAT(i.receiptDate, '%m/%y') AS formatted_date," + " DATE_FORMAT(i.receiptDate, '%m/%y') AS formatted_date,"
+ " SUM(i.paidAmount) AS income," + " SUM(i.paidAmount) AS income,"
+ " NULL AS expenditure," + " NULL AS expenditure,"
+ " i.paymentMilestone AS paymentMilestone"
+ " i.invoiceNo AS invoiceNo"
+ " FROM" + " FROM"
+ " project p" + " project p"
+ " LEFT JOIN invoice i ON p.code = i.projectCode" + " LEFT JOIN invoice i ON p.code = i.projectCode"
@@ -854,7 +867,7 @@ open class DashboardService(
+ " GROUP BY" + " GROUP BY"
+ " parsed_date," + " parsed_date,"
+ " formatted_date," + " formatted_date,"
+ " i.paymentMilestone"
+ " i.invoiceNo"
+ " UNION" + " UNION"
+ " SELECT" + " SELECT"
+ " DATE_FORMAT(r.date, '%Y-%m') AS parsed_date," + " DATE_FORMAT(r.date, '%Y-%m') AS parsed_date,"
@@ -1428,8 +1441,10 @@ open class DashboardService(
+ " coalesce (sum(t.normalConsumed)+sum(t.otConsumed),0) as manhours" + " coalesce (sum(t.normalConsumed)+sum(t.otConsumed),0) as manhours"
+ " from grade g" + " from grade g"
+ " left join staff s on g.id = s.gradeId" + " left join staff s on g.id = s.gradeId"
+ " left join team t2 on s.teamId = t2.id"
+ " left join timesheet t on s.id = t.staffId" + " left join timesheet t on s.id = t.staffId"
+ " where g.deleted = 0" + " where g.deleted = 0"
+ " and t2.id = :teamId"
+ " and t.recordDate >= :startdate" + " and t.recordDate >= :startdate"
+ " and t.recordDate < DATE_FORMAT(:enddate, '%Y-%m-%d 23:59:59')" + " and t.recordDate < DATE_FORMAT(:enddate, '%Y-%m-%d 23:59:59')"


@@ -1437,9 +1452,9 @@ open class DashboardService(


if (viewDashboardAuthority() == "self") { if (viewDashboardAuthority() == "self") {
val teamId = staffsService.currentStaff()?.team?.id val teamId = staffsService.currentStaff()?.team?.id
if (teamId != null) {
sql.append(" and s.teamId = $teamId")
}
// if (teamId != null) {
// sql.append(" and s.teamId = $teamId")
// }
} }


sql.append(" group by g.id" sql.append(" group by g.id"
@@ -1471,16 +1486,18 @@ open class DashboardService(
+ " from grade g" + " from grade g"
+ " left join grade_allocation ga on g.id = ga.gradeId" + " left join grade_allocation ga on g.id = ga.gradeId"
+ " left join project p on ga.projectId = p.id" + " left join project p on ga.projectId = p.id"
+ " left join team t on p.teamLead = t.teamLead"
+ " where p.status = 'On-going'" + " where p.status = 'On-going'"
+ " and t.id = :teamId"
+ " and p.planEnd > :startdate" + " and p.planEnd > :startdate"
+ " and p.planStart < :enddate" + " and p.planStart < :enddate"
) )


if (viewDashboardAuthority() == "self") { if (viewDashboardAuthority() == "self") {
val teamLeadId = staffsService.currentStaff()?.id val teamLeadId = staffsService.currentStaff()?.id
if (teamLeadId != null) {
sql.append(" and p.teamLead = $teamLeadId")
}
// if (teamLeadId != null) {
// sql.append(" and p.teamLead = $teamLeadId")
// }
} }


sql.append(" order by g.id") sql.append(" order by g.id")
@@ -1491,6 +1508,7 @@ open class DashboardService(
val sql = StringBuilder( val sql = StringBuilder(
"select" "select"
+ " p2.id as id," + " p2.id as id,"
+ " p2.code as projectNo,"
+ " p2.name as projectName," + " p2.name as projectName,"
+ " coalesce (result.manhours,0) as manhours," + " coalesce (result.manhours,0) as manhours,"
+ " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage" + " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage"
@@ -1521,6 +1539,7 @@ open class DashboardService(
val sql = StringBuilder( val sql = StringBuilder(
"select" "select"
+ " p2.id as id," + " p2.id as id,"
+ " p2.code as projectNo,"
+ " p2.name as projectName," + " p2.name as projectName,"
+ " coalesce (result.manhours,0) as manhours," + " coalesce (result.manhours,0) as manhours,"
+ " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage" + " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage"
@@ -1551,6 +1570,7 @@ open class DashboardService(
val sql = StringBuilder( val sql = StringBuilder(
"select" "select"
+ " p2.id as id," + " p2.id as id,"
+ " p2.code as projectNo,"
+ " p2.name as projectName," + " p2.name as projectName,"
+ " coalesce (result.manhours,0) as manhours," + " coalesce (result.manhours,0) as manhours,"
+ " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage" + " coalesce (round((result.manhours/ sum(result.manhours))*100,2),0) as percentage"


+ 4
- 0
src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt 查看文件

@@ -329,12 +329,16 @@ class DashboardController(
val args = mutableMapOf<String, Any>() val args = mutableMapOf<String, Any>()
val startdate = request?.getParameter("startdate") val startdate = request?.getParameter("startdate")
val enddate = request?.getParameter("enddate") val enddate = request?.getParameter("enddate")
val teamId = request?.getParameter("teamId")
if (startdate != null) { if (startdate != null) {
args["startdate"] = startdate args["startdate"] = startdate
} }
if (enddate != null) { if (enddate != null) {
args["enddate"] = enddate args["enddate"] = enddate
} }
if (teamId != null) {
args["teamId"] = teamId
}
val result = mutableMapOf<String, Any>() val result = mutableMapOf<String, Any>()
val staffGradeTotalManhours = dashboardService.staffGradeTotalManhours(args) val staffGradeTotalManhours = dashboardService.staffGradeTotalManhours(args)
val staffGradeTotalPlannedManhours = dashboardService.staffGradeTotalPlannedManhours(args) val staffGradeTotalPlannedManhours = dashboardService.staffGradeTotalPlannedManhours(args)


正在加载...
取消
保存