ソースを参照

api improvement

tags/Baseline_30082024_BACKEND_UAT
Mac\David 1年前
コミット
912f4e8f8e
2個のファイルの変更80行の追加16行の削除
  1. +26
    -15
      src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt
  2. +54
    -1
      src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt

+ 26
- 15
src/main/java/com/ffii/tsms/modules/data/service/DashboardService.kt ファイルの表示

@@ -629,13 +629,14 @@ open class DashboardService(
}
fun CashFlowReceivableAndExpenditure(args: Map<String, Any>): List<Map<String, Any>> {
val sql = StringBuilder("select"
+ "coalesce (round(sum(i.paidAmount)/sum(i.issueAmount)*100,0)) as receivedPercentage,"
+ "coalesce (round(expenditure.expenditure/(sum(p.expectedTotalFee)*0.8)*100,0)) as expenditurePercentage,"
+ " coalesce (round(sum(i.paidAmount)/sum(i.issueAmount)*100,0),0) as receivedPercentage,"
+ " coalesce (round(expenditure.expenditure/(sum(p.expectedTotalFee)*0.8)*100,0),0) as expenditurePercentage,"
+ " coalesce (sum(i.issueAmount),0) as totalInvoiced,"
+ " coalesce (sum(i.paidAmount),0) as totalReceived,"
+ " coalesce (sum(i.issueAmount) - sum(i.paidAmount),0) as receivable,"
+ " coalesce (round(sum(p.expectedTotalFee)*0.8,2),0) as totalBudget,"
+ " coalesce (expenditure.expenditure) as totalExpenditure"
+ " coalesce (expenditure.expenditure) as totalExpenditure,"
+ " coalesce (sum(p.expectedTotalFee)*0.8 - expenditure.expenditure,0) as expenditureReceivable"
+ " from project p"
+ " left join invoice i on p.code = i.projectCode"
+ " left join("
@@ -697,7 +698,8 @@ 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.id in (:projecIds)"
+ " where p.id in (:projectIds)"
+ " and year(mp.date) = :year"
+ " group by month(mp.date)"
+ " ) as anticipateIncome on months.month = anticipateIncome.anticipateIncomeDate"
)
@@ -706,17 +708,26 @@ open class DashboardService(
}
fun CashFlowAnticipateExpenditure(args: Map<String, Any>): List<Map<String, Any>> {
val sql = StringBuilder("select"
+ " p.id, p.name,"
+ " date_format(p.planStart, '%Y-%m') as planStart,"
+ " date_format(p.planEnd, '%Y-%m') as planEnd,"
+ " month(p.planStart) as startMonth,"
+ " PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1 AS 'Duration',"
+ " ROUND(p.totalManhour / (PERIOD_DIFF(DATE_FORMAT(p.planEnd, '%Y%m'), DATE_FORMAT(p.planStart, '%Y%m'))+1), 2) AS 'Average Manhours',"
+ " p.teamLead, p.totalManhour"
+ " FROM project p"
+ " WHERE p.status = 'On-going'"
+ " and p.id in (:productIds)"
+ " order by teamLead, planStart"
+ " p.id, p.name,"
+ " date_format(p.planStart, '%Y-%m') as planStart,"
+ " date_format(p.planEnd, '%Y-%m') as planEnd,"
+ " case"
+ " when year(p.planStart) < :year then 1"
+ " when year(p.planStart) = :year then month(p.planStart)"
+ " end as startMonth,"
+ " case"
+ " when year(p.planStart) < :year and year(p.planEnd) > :year then 12"
+ " when year(p.planStart) < :year and year(p.planEnd) = :year then month(p.planEnd)"
+ " 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',"
+ " 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 (year(p.planStart) <= :year and year(p.planEnd) >= :year)"
+ " order by teamLead, planStart"
)

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


+ 54
- 1
src/main/java/com/ffii/tsms/modules/data/web/DashboardController.kt ファイルの表示

@@ -150,5 +150,58 @@ class DashboardController(
result["expenditureList"] = cashFlowMonthlyExpenditure
return listOf(result)
}

@GetMapping("/searchCashFlowReceivableAndExpenditure")
fun searchCashFlowReceivableAndExpenditure(request: HttpServletRequest?): List<Map<String, Any>> {
val args = mutableMapOf<String, Any>()
val projectIdList = request?.getParameter("projectIdList")
val projectIds = projectIdList?.split(",")?.map { it.toInt() }?.toList()
if (projectIds != null) {
args["projectIds"] = projectIds
}
return dashboardService.CashFlowReceivableAndExpenditure(args)
}
@GetMapping("/searchCashFlowAnticipate")
fun searchCashFlowAnticipate(request: HttpServletRequest?): List<Map<String, Any>> {
val args = mutableMapOf<String, Any>()
val projectIdList = request?.getParameter("projectIdList")
val year = request?.getParameter("year")
val projectIds = projectIdList?.split(",")?.map { it.toInt() }?.toList()
if (projectIds != null) {
args["projectIds"] = projectIds
}
if (year != null) {
args["year"] = year
}
val result = mutableMapOf<String, Any>()
val cashFlowAnticipateIncome = dashboardService.CashFlowAnticipateIncome(args)
val cashFlowAnticipateExpenditure = dashboardService.CashFlowAnticipateExpenditure(args)
result["anticipateIncomeList"] = cashFlowAnticipateIncome
result["anticipateExpenditureList"] = cashFlowAnticipateExpenditure
return listOf(result)
}
@GetMapping("/searchCashFlowLedger")
fun searchCashFlowLedger(request: HttpServletRequest?): List<Map<String, Any>> {
val args = mutableMapOf<String, Any>()
val projectIdList = request?.getParameter("projectIdList")
val projectIds = projectIdList?.split(",")?.map { it.toInt() }?.toList()
if (projectIds != null) {
args["projectIds"] = projectIds
}
return dashboardService.CashFlowLedger(args)
}
@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 result = mutableMapOf<String, Any>()
val teamCashFlowIncome = dashboardService.TeamCashFlowIncome(args)
val teamCashFlowExpenditure = dashboardService.TeamCashFlowExpenditure(args)
result["teamCashFlowIncome"] = teamCashFlowIncome
result["teamCashFlowExpenditure"] = teamCashFlowExpenditure
return listOf(result)
}
}

読み込み中…
キャンセル
保存