|
|
@@ -181,14 +181,50 @@ open class ReportService( |
|
|
|
|
|
|
|
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() |
|
|
|
boldFont.bold = true |
|
|
|
|
|
|
|
val boldFontCellStyle = workbook.createCellStyle() |
|
|
|
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){ |
|
|
|
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") |
|
|
|
|
|
|
|
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) |
|
|
|
teamLeadCell.setCellValue(if (item["teamLead"] != null) item.getValue("teamLead").toString() else "N/A") |
|
|
@@ -218,7 +257,6 @@ open class ReportService( |
|
|
|
cellStyle.dataFormat = accountingStyle |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val budgetCell = row.createCell(7) |
|
|
|
budgetCell.apply { |
|
|
|
cellFormula = "G${rowNum} * 80%" |
|
|
@@ -267,15 +305,14 @@ open class ReportService( |
|
|
|
cellStyle.dataFormat = accountingStyle |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val unsettledAmountCell = row.createCell(14) |
|
|
|
unsettledAmountCell.apply { |
|
|
|
cellFormula = "K${rowNum}-N${rowNum}" |
|
|
|
cellStyle = boldFontCellStyle |
|
|
|
cellStyle.dataFormat = accountingStyle |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
// Last row calculate the sum |
|
|
|
val lastRowNum = rowNum + 1 |
|
|
|
|
|
|
|
val row: Row = sheet.createRow(rowNum) |
|
|
@@ -364,6 +401,7 @@ open class ReportService( |
|
|
|
CellUtil.setCellStyleProperty(sumUnSettleCell,"borderTop", BorderStyle.THIN) |
|
|
|
CellUtil.setCellStyleProperty(sumUnSettleCell,"borderBottom", BorderStyle.DOUBLE) |
|
|
|
|
|
|
|
// Fill the cell in Row 2-12 with thr calculated sum |
|
|
|
rowNum = 1 |
|
|
|
val row1: Row = sheet.getRow(rowNum) |
|
|
|
val genDateCell = row1.createCell(2) |
|
|
@@ -1060,7 +1098,7 @@ open class ReportService( |
|
|
|
+ " cte_teamLead as (" |
|
|
|
+ " select p.teamLead, p.code, t.name as teamName , t.code as teamCode" |
|
|
|
+ " 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 ," |
|
|
|
+ " s.name as staff , IFNULL(t.normalConsumed, 0) as normalConsumed, IFNULL(t.otConsumed , 0) as otConsumed, s2.hourlyRate," |
|
|
|