Browse Source

api update

tags/Baseline_30082024_BACKEND_UAT
Mac\David 1 year ago
parent
commit
c13e8de113
2 changed files with 31 additions and 16 deletions
  1. +24
    -12
      src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt
  2. +7
    -4
      src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt

+ 24
- 12
src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt View File

@@ -721,11 +721,14 @@ open class DashboardService(
+ " when year(p.planStart) = :year and year(p.planEnd) > :year then 12 - month(p.planStart)"
+ " else PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1"
+ " end AS 'Duration',"
+ " PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1 as projectDuration,"
+ " p.expectedTotalFee*0.8 as totalBudget,"
+ " (p.expectedTotalFee*0.8) / (PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1) as aniticipateExpenditure,"
+ " ROUND(p.totalManhour / (PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1), 2) AS 'AverageManhours',"
+ " p.teamLead, p.totalManhour"
+ " FROM project p"
+ " WHERE p.status = 'On-going'"
+ " and p.id in (1,2,3,4,5,6)"
+ " and p.id in (:projectIds)"
+ " and (year(p.planStart) <= :year and year(p.planEnd) >= :year)"
+ " order by teamLead, planStart"
)
@@ -734,6 +737,7 @@ open class DashboardService(
}
fun CashFlowLedger(args: Map<String, Any>): List<Map<String, Any>> {
val sql = StringBuilder("select"
+ " ROW_NUMBER() OVER (ORDER BY date, income, expenditure) AS id,"
+ " date,"
+ " COALESCE(ROUND(income, 2), 0) AS income,"
+ " COALESCE(ROUND(expenditure, 2), 0) AS expenditure,"
@@ -830,13 +834,18 @@ open class DashboardService(
+ " left join team t on p.teamLead = t.teamLead"
+ " left join invoice i on p.code = i.projectCode"
+ " where p.status = 'On-going'"
+ " and t.id = :teamId"
+ " and year(i.receiptDate) = :year"
+ " and i.id is not null"
+ " group by month(i.receiptDate)"
+ " ) as invoice on months.month = invoice.invoiceMonth"

)

if (args != null) {
if (args.containsKey("teamId"))
sql.append(" AND t.id = :teamId")
}
sql.append(" and year(i.receiptDate) = :year"
+ " and i.id is not null"
+ " group by month(i.receiptDate)"
+ " ) as invoice on months.month = invoice.invoiceMonth")

return jdbcDao.queryForList(sql.toString(), args)
}
fun TeamCashFlowExpenditure(args: Map<String, Any>): List<Map<String, Any>> {
@@ -885,13 +894,16 @@ open class DashboardService(
+ " 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 t2.id = :teamId"
+ " and year(t.recordDate) = :year"
+ " group by month(t.recordDate),s2.hourlyRate"
+ " ) as r"
+ " group by r.recordMonth"
+ " ) as expenditure on months.month = expenditure.recordMonth"
)
if (args != null) {
if (args.containsKey("teamId"))
sql.append(" AND t2.id = :teamId")
}
sql.append(" and year(t.recordDate) = :year"
+ " group by month(t.recordDate),s2.hourlyRate"
+ " ) as r"
+ " group by r.recordMonth"
+ " ) as expenditure on months.month = expenditure.recordMonth")

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


+ 7
- 4
src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt View File

@@ -192,10 +192,13 @@ class DashboardController(
@GetMapping("/searchTeamCashFlow")
fun searchTeamCashFlow(request: HttpServletRequest?): List<Map<String, Any>> {
val args = mutableMapOf<String, Any>()
val teamIdList = request?.getParameter("teamIdList")
val teamIds = teamIdList?.split(",")?.map { it.toInt() }?.toList()
if (teamIds != null) {
args["teamIds"] = teamIds
val teamId = request?.getParameter("teamId")
val year = request?.getParameter("year")
if (teamId != null) {
args["teamId"] = teamId
}
if (year != null) {
args["year"] = year
}
val result = mutableMapOf<String, Any>()
val teamCashFlowIncome = dashboardService.TeamCashFlowIncome(args)


Loading…
Cancel
Save