| @@ -248,9 +248,10 @@ open class ReportService( | |||||
| } | } | ||||
| @Throws(IOException::class) | @Throws(IOException::class) | ||||
| fun generateProjectManhourSummaryReport(args: Map<String, Any>): ByteArray { | fun generateProjectManhourSummaryReport(args: Map<String, Any>): ByteArray { | ||||
| val manhourSummary = getManhourSummary(args) | |||||
| val manhourSummary = getManhourSummary(args + mapOf("groupBy" to "project")) | |||||
| val manhourSummary2 = getManhourSummary(args + mapOf("groupBy" to "staff")) | |||||
| // Generate the Excel report with query results | // Generate the Excel report with query results | ||||
| val workbook: Workbook = createProjectManhourSummaryReport(args, manhourSummary, PROJECT_MANHOUR_SUMMARY) | |||||
| val workbook: Workbook = createProjectManhourSummaryReport(args, manhourSummary, manhourSummary2, PROJECT_MANHOUR_SUMMARY) | |||||
| // Write the workbook to a ByteArrayOutputStream | // Write the workbook to a ByteArrayOutputStream | ||||
| val outputStream: ByteArrayOutputStream = ByteArrayOutputStream() | val outputStream: ByteArrayOutputStream = ByteArrayOutputStream() | ||||
| workbook.write(outputStream) | workbook.write(outputStream) | ||||
| @@ -2242,8 +2243,7 @@ open class ReportService( | |||||
| open fun getManhourSummary(args: Map<String, Any>): List<Map<String, Any>> { | open fun getManhourSummary(args: Map<String, Any>): List<Map<String, Any>> { | ||||
| val sql = StringBuilder("select" | val sql = StringBuilder("select" | ||||
| + " DATE_FORMAT(t.recordDate, '%b-%Y') AS recordMonth, " | + " DATE_FORMAT(t.recordDate, '%b-%Y') AS recordMonth, " | ||||
| + " t.staffId, " | |||||
| + " s.name as staff, " | |||||
| + (if (args["groupBy"] == "staff") " t.staffId, s.name as staff, " else "" ) | |||||
| + " p.id as projectId, " | + " p.id as projectId, " | ||||
| + " p.code as projectCode, " | + " p.code as projectCode, " | ||||
| + " p.name as projectName, " | + " p.name as projectName, " | ||||
| @@ -2267,7 +2267,11 @@ open class ReportService( | |||||
| if (args.containsKey(("teamId"))) { | if (args.containsKey(("teamId"))) { | ||||
| sql.append(" and coalesce(tl.teamId, s.teamId) = :teamId ") | sql.append(" and coalesce(tl.teamId, s.teamId) = :teamId ") | ||||
| } | } | ||||
| sql.append(" group by recordMonth, t.staffId, t.projectId, tl.teamId ") | |||||
| if (args["groupBy"] == "staff") { | |||||
| sql.append(" group by recordMonth, t.staffId, t.projectId, tl.teamId ") | |||||
| } else { | |||||
| sql.append(" group by recordMonth, t.projectId, tl.teamId ") | |||||
| } | |||||
| return jdbcDao.queryForList(sql.toString(), args) | return jdbcDao.queryForList(sql.toString(), args) | ||||
| } | } | ||||
| @@ -3705,6 +3709,7 @@ open class ReportService( | |||||
| private fun createProjectManhourSummaryReport( | private fun createProjectManhourSummaryReport( | ||||
| args: Map<String, Any>, | args: Map<String, Any>, | ||||
| manhourSummary: List<Map<String, Any>>, | manhourSummary: List<Map<String, Any>>, | ||||
| manhourSummary2: List<Map<String, Any>>, | |||||
| templatePath: String ) | templatePath: String ) | ||||
| : Workbook | : Workbook | ||||
| { | { | ||||
| @@ -3746,7 +3751,7 @@ open class ReportService( | |||||
| } | } | ||||
| .sortedBy { it["projectCode"] as String } | .sortedBy { it["projectCode"] as String } | ||||
| val result2 = manhourSummary.groupBy { mapOf("staff" to it["staff"], "projectCode" to it["projectCode"], "projectName" to it["projectName"], "client" to it["client"]) } | |||||
| val result2 = manhourSummary2.groupBy { mapOf("staff" to it["staff"], "projectCode" to it["projectCode"], "projectName" to it["projectName"], "client" to it["client"]) } | |||||
| .map { entry -> | .map { entry -> | ||||
| val monthlyConsumption = entry.value.associate { it["recordMonth"] to it["consumed"] } | val monthlyConsumption = entry.value.associate { it["recordMonth"] to it["consumed"] } | ||||
| mapOf( | mapOf( | ||||