Browse Source

EX01 return workbook when no timesheet mark in that team

tags/Baseline_30082024_BACKEND_UAT
MSI\2Fi 1 year ago
parent
commit
926e2d0a16
2 changed files with 45 additions and 7 deletions
  1. +1
    -1
      src/main/java/com/ffii/tsms/modules/data/service/TeamService.kt
  2. +44
    -6
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt

+ 1
- 1
src/main/java/com/ffii/tsms/modules/data/service/TeamService.kt View File

@@ -165,7 +165,7 @@ open class TeamService(


open fun combo2(): List<Map<String, Any>> { open fun combo2(): List<Map<String, Any>> {
val sql = StringBuilder("select" val sql = StringBuilder("select"
+ " t.id as id,"
+ " t.teamLead as id,"
+ " t.name, t.code " + " t.name, t.code "
+ " from team t" + " from team t"
+ " where t.deleted = false " + " where t.deleted = false "


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

@@ -181,14 +181,50 @@ open class ReportService(


val sheet = workbook.getSheetAt(0) val sheet = workbook.getSheetAt(0)


//Set Column 2, 3, 4 to auto width
sheet.setColumnWidth(2, 20*256)
sheet.setColumnWidth(3, 45*256)
sheet.setColumnWidth(4, 15*256)

val boldFont = sheet.workbook.createFont() val boldFont = sheet.workbook.createFont()
boldFont.bold = true boldFont.bold = true


val boldFontCellStyle = workbook.createCellStyle() val boldFontCellStyle = workbook.createCellStyle()
boldFontCellStyle.setFont(boldFont) boldFontCellStyle.setFont(boldFont)
var rowNum = 14


if (projects.isEmpty()){
// Fill the cell in Row 2-12 with thr calculated sum
rowNum = 1
val row1: Row = sheet.getRow(rowNum)
val genDateCell = row1.createCell(2)
genDateCell.setCellValue(LocalDate.now().toString())

rowNum = 2
val row2: Row = sheet.getRow(rowNum)
val row2Cell = row2.createCell(2)
val sql = StringBuilder("select"
+ " t.teamLead as id,"
+ " t.name, t.code "
+ " from team t"
+ " where t.deleted = false "
+ " and t.teamLead = :teamLead "
)
val args = mapOf("teamLead" to teamLeadId)
val team = jdbcDao.queryForMap(sql.toString(), args).get()
val code = team["code"]
val name = team["name"]
row2Cell.apply {
setCellValue("$code - $name")
}


var rowNum = 14
rowNum = 4
val row4: Row = sheet.getRow(rowNum)
val row4Cell = row4.createCell(2)
row4Cell.setCellValue(projects.size.toString())

return workbook
}


for(item in projects){ for(item in projects){
val row: Row = sheet.createRow(rowNum++) val row: Row = sheet.createRow(rowNum++)
@@ -200,7 +236,10 @@ open class ReportService(
descriptionCell.setCellValue(if (item["description"] != null) item.getValue("description").toString() else "N/A") descriptionCell.setCellValue(if (item["description"] != null) item.getValue("description").toString() else "N/A")


val clientCell = row.createCell(2) val clientCell = row.createCell(2)
clientCell.setCellValue(if (item["client"] != null) item.getValue("client").toString() else "N/A")
clientCell.apply {
setCellValue(if (item["client"] != null) item.getValue("client").toString() else "N/A")
}
CellUtil.setAlignment(clientCell, HorizontalAlignment.CENTER)


val teamLeadCell = row.createCell(3) val teamLeadCell = row.createCell(3)
teamLeadCell.setCellValue(if (item["teamLead"] != null) item.getValue("teamLead").toString() else "N/A") teamLeadCell.setCellValue(if (item["teamLead"] != null) item.getValue("teamLead").toString() else "N/A")
@@ -218,7 +257,6 @@ open class ReportService(
cellStyle.dataFormat = accountingStyle cellStyle.dataFormat = accountingStyle
} }



val budgetCell = row.createCell(7) val budgetCell = row.createCell(7)
budgetCell.apply { budgetCell.apply {
cellFormula = "G${rowNum} * 80%" cellFormula = "G${rowNum} * 80%"
@@ -267,15 +305,14 @@ open class ReportService(
cellStyle.dataFormat = accountingStyle cellStyle.dataFormat = accountingStyle
} }



val unsettledAmountCell = row.createCell(14) val unsettledAmountCell = row.createCell(14)
unsettledAmountCell.apply { unsettledAmountCell.apply {
cellFormula = "K${rowNum}-N${rowNum}" cellFormula = "K${rowNum}-N${rowNum}"
cellStyle = boldFontCellStyle cellStyle = boldFontCellStyle
cellStyle.dataFormat = accountingStyle cellStyle.dataFormat = accountingStyle
} }

} }
// Last row calculate the sum
val lastRowNum = rowNum + 1 val lastRowNum = rowNum + 1


val row: Row = sheet.createRow(rowNum) val row: Row = sheet.createRow(rowNum)
@@ -364,6 +401,7 @@ open class ReportService(
CellUtil.setCellStyleProperty(sumUnSettleCell,"borderTop", BorderStyle.THIN) CellUtil.setCellStyleProperty(sumUnSettleCell,"borderTop", BorderStyle.THIN)
CellUtil.setCellStyleProperty(sumUnSettleCell,"borderBottom", BorderStyle.DOUBLE) CellUtil.setCellStyleProperty(sumUnSettleCell,"borderBottom", BorderStyle.DOUBLE)


// Fill the cell in Row 2-12 with thr calculated sum
rowNum = 1 rowNum = 1
val row1: Row = sheet.getRow(rowNum) val row1: Row = sheet.getRow(rowNum)
val genDateCell = row1.createCell(2) val genDateCell = row1.createCell(2)
@@ -1060,7 +1098,7 @@ open class ReportService(
+ " cte_teamLead as (" + " cte_teamLead as ("
+ " select p.teamLead, p.code, t.name as teamName , t.code as teamCode" + " select p.teamLead, p.code, t.name as teamName , t.code as teamCode"
+ " from project p" + " from project p"
+ " left join team t on t.id = p.teamLead"
+ " left join team t on t.teamLead = p.teamLead "
+ " )" + " )"
+ " Select p.code, p.description, c.name as client, concat(cte_t.teamCode, \' - \', cte_t.teamName) as teamLead, p.planStart , p.planEnd , p.expectedTotalFee ," + " Select p.code, p.description, c.name as client, concat(cte_t.teamCode, \' - \', cte_t.teamName) as teamLead, p.planStart , p.planEnd , p.expectedTotalFee ,"
+ " s.name as staff , IFNULL(t.normalConsumed, 0) as normalConsumed, IFNULL(t.otConsumed , 0) as otConsumed, s2.hourlyRate," + " s.name as staff , IFNULL(t.normalConsumed, 0) as normalConsumed, IFNULL(t.otConsumed , 0) as otConsumed, s2.hourlyRate,"


Loading…
Cancel
Save