소스 검색

update work report

tags/Baseline_30082024_BACKEND_UAT
MSI\derek 1 년 전
부모
커밋
84f7b98599
2개의 변경된 파일41개의 추가작업 그리고 22개의 파일을 삭제
  1. +41
    -22
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt
  2. BIN
      src/main/resources/templates/report/AR08_Monthly Work Hours Analysis Report.xlsx

+ 41
- 22
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt 파일 보기

@@ -381,6 +381,10 @@ open class ReportService(
val monthStyle = workbook.createDataFormat().getFormat("mmm, yyyy")
val dateStyle = workbook.createDataFormat().getFormat("dd/mm/yyyy")

val boldStyle = workbook.createCellStyle()
val boldFont = workbook.createFont()
boldFont.bold = true
boldStyle.setFont(boldFont)
val daysOfMonth = (1..month.lengthOfMonth()).map { day ->
val date = month.withDayOfMonth(day)
val formattedDate = date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))
@@ -390,8 +394,6 @@ open class ReportService(

val sheet: Sheet = workbook.getSheetAt(0)

val boldFont = sheet.workbook.createFont()
boldFont.bold = true
// sheet.forceFormulaRecalculation = true; //Calculate formulas

var rowIndex = 1 // Assuming the location is in (1,2), which is the report date field
@@ -403,22 +405,27 @@ open class ReportService(
var dayInt = 0
var tempCell: Cell

tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.setCellValue(FORMATTED_TODAY)
sheet.getRow(rowIndex).createCell(columnIndex).apply {
setCellValue(FORMATTED_TODAY)
}

rowIndex = 2
tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.setCellValue(month)
tempCell.cellStyle.dataFormat = monthStyle
sheet.getRow(rowIndex).getCell(columnIndex).apply {
setCellValue(month)
// cellStyle.setFont(boldStyle)

cellStyle.dataFormat = monthStyle
}

rowIndex = 3
tempCell. sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.setCellValue(staff.name)
sheet.getRow(rowIndex).createCell(columnIndex).apply {
setCellValue(staff.name)
}

rowIndex = 4
tempCell.sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.setCellValue(staff.team.name)
sheet.getRow(rowIndex).createCell(columnIndex).apply {
setCellValue(staff.team.name)
}

rowIndex = 5
tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
@@ -430,6 +437,7 @@ open class ReportService(

val ThinBorderBottom: MutableMap<String?, Any?> = mutableMapOf()
ThinBorderBottom["borderBottom"] = BorderStyle.THIN
ThinBorderBottom["wrapText"] = true
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rowIndex = 7
daysOfMonth.forEach { dayInfo ->
@@ -437,12 +445,12 @@ open class ReportService(
rowSize++
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue(dayInfo.date)
tempCell.cellStyle = boldStyle
tempCell.cellStyle.dataFormat = dateStyle
tempCell.cellStyle.setFont(boldFont)
// cellStyle.alignment = HorizontalAlignment.LEFT
tempCell = sheet.getRow(rowIndex).createCell(1)
tempCell.setCellValue(dayInfo.weekday)
tempCell.cellStyle.setFont(boldFont)
tempCell.cellStyle = boldStyle
// cellStyle.alignment = HorizontalAlignment.LEFT
}

@@ -450,7 +458,7 @@ open class ReportService(
tempCell = sheet.getRow(rowIndex).createCell(0)
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1))
tempCell.setCellValue("Sub-total")
tempCell.cellStyle.setFont(boldFont)
tempCell.cellStyle = boldStyle
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)
tempCell = sheet.getRow(rowIndex).createCell(1)
@@ -459,6 +467,7 @@ open class ReportService(
rowIndex += 1
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Normal Hours [A]")
tempCell.cellStyle = boldStyle
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)

var normalConsumed = 0.0
@@ -479,8 +488,8 @@ open class ReportService(
rowIndex += 1
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Other Hours [B]")
tempCell.cellStyle = boldStyle
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
tempCell.cellStyle.setFont(boldFont)
tempCell = sheet.getRow(rowIndex).createCell(2)
tempCell.setCellValue(otConsumed)
tempCell.cellStyle.dataFormat = accountingStyle
@@ -492,6 +501,7 @@ open class ReportService(
rowIndex += 1
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Leave Hours")
tempCell.cellStyle = boldStyle
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1))
if (leaves.isNotEmpty()) {
@@ -507,7 +517,7 @@ open class ReportService(
rowIndex += 1
tempCell = sheet.getRow(rowIndex).createCell(0)
tempCell.setCellValue("Total Spent Manhours [A+B]")
tempCell.cellStyle.setFont(boldFont)
tempCell.cellStyle = boldStyle
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)
tempCell = sheet.getRow(rowIndex).createCell(1)
@@ -526,9 +536,13 @@ open class ReportService(
projectList.forEachIndexed { index, title ->
tempCell = sheet.getRow(7).createCell(columnIndex + index)
tempCell.setCellValue(title)
CellUtil.setAlignment(tempCell, HorizontalAlignment.RIGHT)
tempCell.cellStyle = boldStyle
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
CellUtil.setVerticalAlignment(tempCell, VerticalAlignment.CENTER)
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom)
columnSize++
}
println(columnSize)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (timesheets.isNotEmpty()) {
projectList.forEach { _ ->
@@ -564,11 +578,16 @@ open class ReportService(
///////////////////////////////////////////////////////// Leave Hours ////////////////////////////////////////////////////////////////////
tempCell = sheet.getRow(rowIndex).createCell(columnIndex)
tempCell.setCellValue("Leave Hours")
tempCell.cellStyle = boldStyle
CellUtil.setVerticalAlignment(tempCell, VerticalAlignment.CENTER)
CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER)
CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom)

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

sheet.addMergedRegion(CellRangeAddress(6,6 , 2, columnIndex))
@@ -583,18 +602,18 @@ open class ReportService(
}
// cal subtotal
println(rowIndex)
for (i in 0 until columnSize - 2) { // minus last col
tempCell = sheet.getRow(rowIndex).createCell(2 + i)
for (i in 0 ..columnSize ) { // minus last col
println(sheet.getRow(rowIndex).getCell(2 + i))
tempCell = sheet.getRow(rowIndex).getCell(2 + i) ?: sheet.getRow(rowIndex).createCell(2 + i)
tempCell.cellFormula = "SUM(${getColumnAlphabet(2 + i)}9:${getColumnAlphabet(2 + i)}${rowIndex})"
tempCell.cellStyle = boldStyle
tempCell.cellStyle.dataFormat = accountingStyle
tempCell.cellStyle.setFont(boldFont)
CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom)
}
}
return workbook
}


@Throws(IOException::class)
private fun createSalaryList(
salarys: List<Salary>,


BIN
src/main/resources/templates/report/AR08_Monthly Work Hours Analysis Report.xlsx 파일 보기


불러오는 중...
취소
저장