|
@@ -219,6 +219,7 @@ open class ReportService( |
|
|
staff: Staff, |
|
|
staff: Staff, |
|
|
timesheets: List<Map<String, Any>>, |
|
|
timesheets: List<Map<String, Any>>, |
|
|
leaves: List<Map<String, Any>>, |
|
|
leaves: List<Map<String, Any>>, |
|
|
|
|
|
totalConsumed: List<Map<String, Any>>, |
|
|
): ByteArray { |
|
|
): ByteArray { |
|
|
// Generate the Excel report with query results |
|
|
// Generate the Excel report with query results |
|
|
val workbook: Workbook = createStaffMonthlyWorkHourAnalysisReport( |
|
|
val workbook: Workbook = createStaffMonthlyWorkHourAnalysisReport( |
|
@@ -227,6 +228,7 @@ open class ReportService( |
|
|
staff, |
|
|
staff, |
|
|
timesheets, |
|
|
timesheets, |
|
|
leaves, |
|
|
leaves, |
|
|
|
|
|
totalConsumed, |
|
|
MONTHLY_WORK_HOURS_ANALYSIS_REPORT |
|
|
MONTHLY_WORK_HOURS_ANALYSIS_REPORT |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@@ -1170,6 +1172,7 @@ open class ReportService( |
|
|
staff: Staff, |
|
|
staff: Staff, |
|
|
timesheets: List<Map<String, Any>>, |
|
|
timesheets: List<Map<String, Any>>, |
|
|
leaves: List<Map<String, Any>>, |
|
|
leaves: List<Map<String, Any>>, |
|
|
|
|
|
totalConsumed: List<Map<String, Any>>, |
|
|
templatePath: String, |
|
|
templatePath: String, |
|
|
): Workbook { |
|
|
): Workbook { |
|
|
var projectList: List<String> = listOf() |
|
|
var projectList: List<String> = listOf() |
|
@@ -1179,7 +1182,7 @@ open class ReportService( |
|
|
println("----leaves-----") |
|
|
println("----leaves-----") |
|
|
println(leaves) |
|
|
println(leaves) |
|
|
// result = timesheet record mapped |
|
|
// result = timesheet record mapped |
|
|
var result: Map<String, Any> = mapOf() |
|
|
|
|
|
|
|
|
var result: Map<String, Any> = mapOf() |
|
|
if (timesheets.isNotEmpty()) { |
|
|
if (timesheets.isNotEmpty()) { |
|
|
projectList = timesheets.map { "${it["code"]}\n ${it["name"]}" }.toList().distinct() |
|
|
projectList = timesheets.map { "${it["code"]}\n ${it["name"]}" }.toList().distinct() |
|
|
result = timesheets.groupBy( |
|
|
result = timesheets.groupBy( |
|
@@ -1323,10 +1326,21 @@ open class ReportService( |
|
|
var otConsumed = 0.0 |
|
|
var otConsumed = 0.0 |
|
|
var leaveHours = 0.0 |
|
|
var leaveHours = 0.0 |
|
|
// normalConsumed data |
|
|
// normalConsumed data |
|
|
if (timesheets.isNotEmpty()) { |
|
|
|
|
|
timesheets.forEach { t -> |
|
|
|
|
|
normalConsumed += t["normalConsumed"] as Double |
|
|
|
|
|
otConsumed += t["otConsumed"] as Double |
|
|
|
|
|
|
|
|
// if (timesheets.isNotEmpty()) { |
|
|
|
|
|
// timesheets.forEach { t -> |
|
|
|
|
|
// normalConsumed += t["normalConsumed"] as Double |
|
|
|
|
|
// otConsumed += t["otConsumed"] as Double |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
if (totalConsumed.isNotEmpty()) { |
|
|
|
|
|
totalConsumed.forEach{ t -> |
|
|
|
|
|
val total = t["totalConsumed"] as Double |
|
|
|
|
|
if (total > 8.0) { |
|
|
|
|
|
normalConsumed += 8.0 |
|
|
|
|
|
otConsumed += total - 8.0 |
|
|
|
|
|
} else { |
|
|
|
|
|
normalConsumed += total |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
tempCell = sheet.getRow(rowIndex).createCell(2) |
|
|
tempCell = sheet.getRow(rowIndex).createCell(2) |
|
@@ -1950,6 +1964,19 @@ open class ReportService( |
|
|
) |
|
|
) |
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
} |
|
|
} |
|
|
|
|
|
open fun getTotalConsumed(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
|
|
|
val sql = StringBuilder("SELECT" |
|
|
|
|
|
+ " CAST(DATE_FORMAT(t.recordDate, '%d') AS SIGNED) AS recordDate, " |
|
|
|
|
|
+ " sum(t.normalConsumed) + sum(t.otConsumed) as totalConsumed " |
|
|
|
|
|
+ " from timesheet t " |
|
|
|
|
|
+ " left join project p on p.id = t.projectId " |
|
|
|
|
|
+ " where t.staffId = :staffId " |
|
|
|
|
|
+ " and t.recordDate BETWEEN :startDate and :endDate " |
|
|
|
|
|
+ " group by t.recordDate " |
|
|
|
|
|
+ " order by t.recordDate; " |
|
|
|
|
|
) |
|
|
|
|
|
return jdbcDao.queryForList(sql.toString(), args) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
open fun getLeaves(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
open fun getLeaves(args: Map<String, Any>): List<Map<String, Any>> { |
|
|
val sql = StringBuilder( |
|
|
val sql = StringBuilder( |
|
|