diff --git a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt index 32036db..87cdf08 100644 --- a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt +++ b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt @@ -2250,12 +2250,12 @@ open class ReportService( + " c.name as client, " + " sum(coalesce(t.normalConsumed, 0) + coalesce(t.otConsumed,0)) as consumed " + " from timesheet t " - + " left join team_log tl on tl.staffId = t.staffId and t.recordDate >= tl.`from` and (t.recordDate <= tl.`to` or tl.`to` is null) " +// + " left join team_log tl on tl.staffId = t.staffId and t.recordDate >= tl.`from` and (t.recordDate <= tl.`to` or tl.`to` is null) " + " left join staff s on s.id = t.staffId " + " left join project p on p.id = t.projectId " + " left join customer c on c.id = p.customerId " + " where t.deleted = false " - + " and (tl.teamId is not null and s.teamId is not null) " +// + " and (tl.teamId is not null and s.teamId is not null) " + " and t.projectId is not null " ) if (args.containsKey(("startDate"))) { @@ -2265,12 +2265,12 @@ open class ReportService( sql.append(" and t.recordDate < :endDate ") } if (args.containsKey(("teamId"))) { - sql.append(" and coalesce(tl.teamId, s.teamId) = :teamId ") + sql.append(" and p.teamlead = :teamId ") } if (args["groupBy"] == "staff") { - sql.append(" group by recordMonth, t.staffId, t.projectId, tl.teamId ") + sql.append(" group by recordMonth, t.staffId, t.projectId ") } else { - sql.append(" group by recordMonth, t.projectId, tl.teamId ") + sql.append(" group by recordMonth, t.projectId ") } return jdbcDao.queryForList(sql.toString(), args) } @@ -3785,8 +3785,8 @@ open class ReportService( tempRow2 = getOrCreateRow(sheet2, rowIndex) tempCell = getOrCreateCell(tempRow, columnIndex) tempCell2 = getOrCreateCell(tempRow2, columnIndex) - tempCell.setCellValue("${args["startDate"].toString()} - ${args["endDate"].toString()}") - tempCell2.setCellValue("${args["startDate"].toString()} - ${args["endDate"].toString()}") + tempCell.setCellValue("${args["startDate"].toString()} - ${(args["endDate"] as LocalDate).minusDays(1.toLong()).toString()}") + tempCell2.setCellValue("${args["startDate"].toString()} - ${(args["endDate"] as LocalDate).minusDays(1.toLong()).toString()}") // write months header rowIndex = 5 columnIndex = 3 diff --git a/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt b/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt index 97609fc..d402bef 100644 --- a/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt +++ b/src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt @@ -311,10 +311,11 @@ class ReportController( @Throws(ServletRequestBindingException::class, IOException::class) fun getProjectManhourSummary(@RequestBody @Valid request: ProjectManhourSummaryRequest): ResponseEntity { println("starting") + val teamlead = teamRepository.findById(request.teamId.toString().toLong()).orElseThrow().staff.id val args = mapOf( "startDate" to request.startDate, "endDate" to request.endDate, - "teamId" to request.teamId, + "teamId" to teamlead, ) val reportResult: ByteArray = excelReportService.generateProjectManhourSummaryReport(args) println("ending")