|
@@ -4,7 +4,9 @@ import com.ffii.core.support.JdbcDao |
|
|
import com.ffii.tsms.modules.data.entity.* |
|
|
import com.ffii.tsms.modules.data.entity.* |
|
|
import com.ffii.tsms.modules.data.service.SalaryEffectiveService |
|
|
import com.ffii.tsms.modules.data.service.SalaryEffectiveService |
|
|
import com.ffii.tsms.modules.data.service.SalaryEffectiveService.MonthlyStaffSalaryData |
|
|
import com.ffii.tsms.modules.data.service.SalaryEffectiveService.MonthlyStaffSalaryData |
|
|
|
|
|
import com.ffii.tsms.modules.data.service.StaffsService |
|
|
import com.ffii.tsms.modules.project.entity.* |
|
|
import com.ffii.tsms.modules.project.entity.* |
|
|
|
|
|
import com.ffii.tsms.modules.report.web.model.ExportCurrentStaffInfoRequest |
|
|
import com.ffii.tsms.modules.report.web.model.costAndExpenseRequest |
|
|
import com.ffii.tsms.modules.report.web.model.costAndExpenseRequest |
|
|
import com.ffii.tsms.modules.timesheet.entity.Timesheet |
|
|
import com.ffii.tsms.modules.timesheet.entity.Timesheet |
|
|
import com.ffii.tsms.modules.timesheet.entity.TimesheetRepository |
|
|
import com.ffii.tsms.modules.timesheet.entity.TimesheetRepository |
|
@@ -54,7 +56,8 @@ open class ReportService( |
|
|
private val salaryRepository: SalaryRepository, |
|
|
private val salaryRepository: SalaryRepository, |
|
|
private val timesheetRepository: TimesheetRepository, |
|
|
private val timesheetRepository: TimesheetRepository, |
|
|
private val teamLogRepository: TeamLogRepository, |
|
|
private val teamLogRepository: TeamLogRepository, |
|
|
private val teamRepository: TeamRepository |
|
|
|
|
|
|
|
|
private val teamRepository: TeamRepository, |
|
|
|
|
|
private val staffService: StaffsService, |
|
|
) { |
|
|
) { |
|
|
private val logger: Log = LogFactory.getLog(javaClass) |
|
|
private val logger: Log = LogFactory.getLog(javaClass) |
|
|
private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd") |
|
|
private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd") |
|
@@ -76,6 +79,7 @@ open class ReportService( |
|
|
private val PROJECT_MANHOUR_SUMMARY = "templates/report/Project Manhour Summary.xlsx" |
|
|
private val PROJECT_MANHOUR_SUMMARY = "templates/report/Project Manhour Summary.xlsx" |
|
|
private val PROJECT_MONTHLY_REPORT = "templates/report/AR09_Project Daily Work Hours Analysis Report.xlsx" |
|
|
private val PROJECT_MONTHLY_REPORT = "templates/report/AR09_Project Daily Work Hours Analysis Report.xlsx" |
|
|
private val LAST_RECORD_REPORT = "templates/report/AR10_Staff Last Record Report.xlsx" |
|
|
private val LAST_RECORD_REPORT = "templates/report/AR10_Staff Last Record Report.xlsx" |
|
|
|
|
|
private val STAFF_INFORMATION = "templates/report/Staff Information.xlsx" |
|
|
|
|
|
|
|
|
private fun cellBorderArgs(top: Int, bottom: Int, left: Int, right: Int): MutableMap<String, Any> { |
|
|
private fun cellBorderArgs(top: Int, bottom: Int, left: Int, right: Int): MutableMap<String, Any> { |
|
|
var cellBorderArgs = mutableMapOf<String, Any>() |
|
|
var cellBorderArgs = mutableMapOf<String, Any>() |
|
@@ -5794,4 +5798,110 @@ open class ReportService( |
|
|
|
|
|
|
|
|
return outputStream.toByteArray() |
|
|
return outputStream.toByteArray() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Throws(IOException::class) |
|
|
|
|
|
private fun createStaffCurrentInfoWorkBook( |
|
|
|
|
|
staffIds: List<Long>, |
|
|
|
|
|
templatePath: String |
|
|
|
|
|
): Workbook{ |
|
|
|
|
|
val resource = ClassPathResource(templatePath) |
|
|
|
|
|
val templateInputStream = resource.inputStream |
|
|
|
|
|
val workbook: Workbook = XSSFWorkbook(templateInputStream) |
|
|
|
|
|
|
|
|
|
|
|
val result = staffService.getCurrentStaffInfo(staffIds) |
|
|
|
|
|
println(result) |
|
|
|
|
|
|
|
|
|
|
|
var sheet: Sheet = workbook.getSheetAt(0) |
|
|
|
|
|
var rowIndex = 1 // Assuming the location is in (1,2), which is the report date field |
|
|
|
|
|
var columnIndex = 1 |
|
|
|
|
|
|
|
|
|
|
|
val blackFont = workbook.createFont().apply { |
|
|
|
|
|
color = IndexedColors.BLACK.index |
|
|
|
|
|
fontHeightInPoints = 12 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val blackFontStyle = workbook.createCellStyle().apply { |
|
|
|
|
|
setFont(blackFont) |
|
|
|
|
|
borderTop = BorderStyle.THIN |
|
|
|
|
|
borderBottom = BorderStyle.THIN |
|
|
|
|
|
borderLeft = BorderStyle.THIN |
|
|
|
|
|
borderRight = BorderStyle.THIN |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sheet.getRow(rowIndex).createCell(columnIndex+1).apply { |
|
|
|
|
|
setCellValue(FORMATTED_TODAY) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var startRowIndex = 4 |
|
|
|
|
|
result.forEach { |
|
|
|
|
|
val row = |
|
|
|
|
|
if (sheet.getRow(startRowIndex) == null) sheet.createRow(startRowIndex) else sheet.getRow(startRowIndex) |
|
|
|
|
|
val staffIdCell = row.createCell(0) |
|
|
|
|
|
val teamCell = row.createCell(1) |
|
|
|
|
|
val staffNameCell = row.createCell(2) |
|
|
|
|
|
val employmentDateCell = row.createCell(3) |
|
|
|
|
|
val gradeCell = row.createCell(4) |
|
|
|
|
|
val positionCell = row.createCell(5) |
|
|
|
|
|
val salaryPointCell = row.createCell(6) |
|
|
|
|
|
val emailCell = row.createCell(7) |
|
|
|
|
|
|
|
|
|
|
|
staffIdCell.apply { |
|
|
|
|
|
setCellValue(it.getValue("staffId") as String) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
teamCell.apply { |
|
|
|
|
|
setCellValue(it.getValue("team") as String) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
staffNameCell.apply { |
|
|
|
|
|
setCellValue(it.getValue("name") as String) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
employmentDateCell.apply { |
|
|
|
|
|
setCellValue(it.getValue("employmentDate") as String) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gradeCell.apply { |
|
|
|
|
|
val grade = it.getValue("grade") as String |
|
|
|
|
|
val gradeCode = "GRADE $grade" |
|
|
|
|
|
setCellValue(gradeCode) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
positionCell.apply { |
|
|
|
|
|
setCellValue(it.getValue("description") as String) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
salaryPointCell.apply{ |
|
|
|
|
|
setCellValue((it.getValue("salaryId") as Int).toString()) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
emailCell.apply { |
|
|
|
|
|
setCellValue(it.getValue("email") as String) |
|
|
|
|
|
cellStyle = blackFontStyle |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
startRowIndex++ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return workbook |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun genStaffCurrentInfoFile( |
|
|
|
|
|
request: ExportCurrentStaffInfoRequest, |
|
|
|
|
|
): ByteArray{ |
|
|
|
|
|
val workbook = createStaffCurrentInfoWorkBook(request.staffIds, STAFF_INFORMATION) |
|
|
|
|
|
|
|
|
|
|
|
val outputStream: ByteArrayOutputStream = ByteArrayOutputStream() |
|
|
|
|
|
workbook.write(outputStream) |
|
|
|
|
|
workbook.close() |
|
|
|
|
|
|
|
|
|
|
|
return outputStream.toByteArray() |
|
|
|
|
|
} |
|
|
} |
|
|
} |