Browse Source

update

tags/Baseline_30082024_BACKEND_UAT
MSI\derek 1 year ago
parent
commit
514d2cdcfa
1 changed files with 25 additions and 25 deletions
  1. +25
    -25
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt

+ 25
- 25
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt View File

@@ -435,29 +435,29 @@ open class ReportService(
daysOfMonth.forEach { dayInfo -> daysOfMonth.forEach { dayInfo ->
rowIndex++ rowIndex++
rowSize++ rowSize++
tempCell = sheet.createRow(rowIndex).createCell(0)
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue(dayInfo.date) tempCell.setCellValue(dayInfo.date)
tempCell.cellStyle.dataFormat = dateStyle tempCell.cellStyle.dataFormat = dateStyle
tempCell.cellStyle.setFont(boldFont) tempCell.cellStyle.setFont(boldFont)
// cellStyle.alignment = HorizontalAlignment.LEFT // cellStyle.alignment = HorizontalAlignment.LEFT
tempCell = sheet.createRow(rowIndex).createCell(1)
tempCell = sheet.getRow(rowIndex).createCell(1)
tempCell.setCellValue(dayInfo.weekday) tempCell.setCellValue(dayInfo.weekday)
tempCell.cellStyle.setFont(boldFont) tempCell.cellStyle.setFont(boldFont)
// cellStyle.alignment = HorizontalAlignment.LEFT // cellStyle.alignment = HorizontalAlignment.LEFT
} }


rowIndex += 1 rowIndex += 1
tempCell = sheet.createRow(rowIndex).createCell(0)
tempCell = sheet.getRow(rowIndex).createCell(0)
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1))
tempCell.setCellValue("Sub-total") tempCell.setCellValue("Sub-total")
tempCell.cellStyle.setFont(boldFont) tempCell.cellStyle.setFont(boldFont)
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)
tempCell = sheet.createRow(rowIndex).createCell(1)
tempCell = sheet.getRow(rowIndex).createCell(1)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)


rowIndex += 1 rowIndex += 1
tempCell = sheet.createRow(rowIndex).createCell(0)
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Normal Hours [A]") tempCell.setCellValue("Total Normal Hours [A]")
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)


@@ -467,21 +467,21 @@ open class ReportService(
if (timesheets.isNotEmpty()) { if (timesheets.isNotEmpty()) {
timesheets.forEach { t -> timesheets.forEach { t ->
normalConsumed += t.normalConsumed!! normalConsumed += t.normalConsumed!!
otConsumed += t.otConsumed ?: 0.0
otConsumed += t.otConsumed ?: 0.0
} }
} }
tempCell = sheet.createRow(rowIndex).createCell(2)
tempCell = sheet.getRow(rowIndex).createCell(2)
tempCell.setCellValue(normalConsumed) tempCell.setCellValue(normalConsumed)
tempCell.cellStyle.dataFormat = accountingStyle tempCell.cellStyle.dataFormat = accountingStyle


sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1))
// //
rowIndex += 1 rowIndex += 1
tempCell = sheet.createRow(rowIndex).createCell(0)
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Other Hours [B]") tempCell.setCellValue("Total Other Hours [B]")
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
tempCell.cellStyle.setFont(boldFont) tempCell.cellStyle.setFont(boldFont)
tempCell = sheet.createRow(rowIndex).createCell(2)
tempCell = sheet.getRow(rowIndex).createCell(2)
tempCell.setCellValue(otConsumed) tempCell.setCellValue(otConsumed)
tempCell.cellStyle.dataFormat = accountingStyle tempCell.cellStyle.dataFormat = accountingStyle


@@ -490,7 +490,7 @@ open class ReportService(


// Total Leave Hours // Total Leave Hours
rowIndex += 1 rowIndex += 1
tempCell = sheet.createRow(rowIndex).createCell(0)
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Leave Hours") tempCell.setCellValue("Total Leave Hours")
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1))
@@ -499,22 +499,22 @@ open class ReportService(
leaveHours += l.leaveHours!! leaveHours += l.leaveHours!!
} }
} }
tempCell = sheet.createRow(rowIndex).createCell(2)
tempCell = sheet.getRow(rowIndex).createCell(2)
tempCell.setCellValue(leaveHours) tempCell.setCellValue(leaveHours)
tempCell.cellStyle.dataFormat = accountingStyle tempCell.cellStyle.dataFormat = accountingStyle


// Total Spent Manhours // Total Spent Manhours
rowIndex += 1 rowIndex += 1
tempCell = sheet.createRow(rowIndex).createCell(0)
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Spent Manhours [A+B]") tempCell.setCellValue("Total Spent Manhours [A+B]")
tempCell.cellStyle.setFont(boldFont) tempCell.cellStyle.setFont(boldFont)
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)
tempCell = sheet.createRow(rowIndex).createCell(1)
tempCell = sheet.getRow(rowIndex).createCell(1)
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)


tempCell = sheet.createRow(rowIndex).createCell(2)
tempCell = sheet.getRow(rowIndex).createCell(2)
tempCell.cellFormula = "C${rowIndex-2}+C${rowIndex-1}" tempCell.cellFormula = "C${rowIndex-2}+C${rowIndex-1}"
tempCell.cellStyle.dataFormat = accountingStyle tempCell.cellStyle.dataFormat = accountingStyle
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)
@@ -524,7 +524,7 @@ open class ReportService(
rowIndex = 7 rowIndex = 7
columnIndex = 2 columnIndex = 2
projectList.forEachIndexed { index, title -> projectList.forEachIndexed { index, title ->
tempCell = sheet.createRow(7).createCell(columnIndex + index)
tempCell = sheet.getRow(7).createCell(columnIndex + index)
tempCell.setCellValue(title) tempCell.setCellValue(title)
CellUtil.setAlignment(tempCell, HorizontalAlignment.RIGHT) CellUtil.setAlignment(tempCell, HorizontalAlignment.RIGHT)
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom)
@@ -533,13 +533,13 @@ open class ReportService(
if (timesheets.isNotEmpty()) { if (timesheets.isNotEmpty()) {
projectList.forEach { _ -> projectList.forEach { _ ->
for (i in 0 until rowSize) { for (i in 0 until rowSize) {
tempCell = sheet.createRow(8 + i).createCell(columnIndex)
tempCell = sheet.getRow(8 + i).createCell(columnIndex)
tempCell.setCellValue(0.0) tempCell.setCellValue(0.0)
tempCell.cellStyle.dataFormat = accountingStyle tempCell.cellStyle.dataFormat = accountingStyle
} }
timesheets.forEach { timesheet -> timesheets.forEach { timesheet ->
dayInt = timesheet.recordDate!!.dayOfMonth dayInt = timesheet.recordDate!!.dayOfMonth
tempCell = sheet.createRow(dayInt.plus(7)).createCell(columnIndex)
tempCell = sheet.getRow(dayInt.plus(7)).createCell(columnIndex)
tempCell.setCellValue(timesheet.normalConsumed!!) tempCell.setCellValue(timesheet.normalConsumed!!)


} }
@@ -550,46 +550,46 @@ open class ReportService(
if (leaves.isNotEmpty()) { if (leaves.isNotEmpty()) {
leaves.forEach { leave -> leaves.forEach { leave ->
for (i in 0 until rowSize) { for (i in 0 until rowSize) {
tempCell = sheet.createRow(8 + i).createCell(columnIndex)
tempCell = sheet.getRow(8 + i).createCell(columnIndex)
tempCell.setCellValue(0.0) tempCell.setCellValue(0.0)
tempCell.cellStyle.dataFormat = accountingStyle tempCell.cellStyle.dataFormat = accountingStyle


} }
dayInt = leave.recordDate!!.dayOfMonth dayInt = leave.recordDate!!.dayOfMonth
tempCell = sheet.createRow(dayInt.plus(7)).createCell(columnIndex)
tempCell = sheet.getRow(dayInt.plus(7)).createCell(columnIndex)
tempCell.setCellValue(leave.leaveHours!!) tempCell.setCellValue(leave.leaveHours!!)


} }
} }
///////////////////////////////////////////////////////// Leave Hours //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// Leave Hours ////////////////////////////////////////////////////////////////////
tempCell = sheet.createRow(rowIndex).createCell(columnIndex)
tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.setCellValue("Leave Hours") tempCell.setCellValue("Leave Hours")
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom)


columnIndex += 1 columnIndex += 1
tempCell = sheet.createRow(rowIndex).createCell(columnIndex)
tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.setCellValue("Daily Manhour Spent\n(Excluding Leave Hours)") tempCell.setCellValue("Daily Manhour Spent\n(Excluding Leave Hours)")
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom)


sheet.addMergedRegion(CellRangeAddress(6,6 , 2, columnIndex)) sheet.addMergedRegion(CellRangeAddress(6,6 , 2, columnIndex))
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rowIndex = 8 rowIndex = 8
// if (sheet.createRow(rowIndex - 1).getCell(2).stringCellValue != "Leave Hours") {
if (sheet.getRow(rowIndex - 1).getCell(2).stringCellValue != "Leave Hours") {
// cal daily spent manhour // cal daily spent manhour
for (i in 0 until rowSize) { for (i in 0 until rowSize) {
tempCell = sheet.createRow(rowIndex).createCell(columnIndex)
tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.cellFormula = "SUM(${getColumnAlphabet(2)}${rowIndex+1}:${getColumnAlphabet(columnIndex - 2)}${rowIndex+1})" // should columnIndex - 2 tempCell.cellFormula = "SUM(${getColumnAlphabet(2)}${rowIndex+1}:${getColumnAlphabet(columnIndex - 2)}${rowIndex+1})" // should columnIndex - 2
rowIndex++ rowIndex++
} }
// cal subtotal // cal subtotal
println(rowIndex) println(rowIndex)
for (i in 0 until columnSize - 2) { // minus last col for (i in 0 until columnSize - 2) { // minus last col
tempCell = sheet.createRow(rowIndex).createCell(2 + i)
tempCell = sheet.getRow(rowIndex).createCell(2 + i)
tempCell.cellFormula = "SUM(${getColumnAlphabet(2 + i)}9:${getColumnAlphabet(2 + i)}${rowIndex})" tempCell.cellFormula = "SUM(${getColumnAlphabet(2 + i)}9:${getColumnAlphabet(2 + i)}${rowIndex})"
tempCell.cellStyle.dataFormat = accountingStyle tempCell.cellStyle.dataFormat = accountingStyle
tempCell.cellStyle.setFont(boldFont) tempCell.cellStyle.setFont(boldFont)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)
// }
}
} }
return workbook return workbook
} }


Loading…
Cancel
Save