|
@@ -2,11 +2,9 @@ package com.ffii.tsms.modules.report.web |
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper |
|
|
import com.fasterxml.jackson.databind.ObjectMapper |
|
|
import com.fasterxml.jackson.module.kotlin.KotlinModule |
|
|
import com.fasterxml.jackson.module.kotlin.KotlinModule |
|
|
import com.ffii.tsms.modules.data.entity.Customer |
|
|
|
|
|
import com.ffii.tsms.modules.data.entity.StaffRepository |
|
|
|
|
|
|
|
|
import com.ffii.tsms.modules.data.entity.* |
|
|
//import com.ffii.tsms.modules.data.entity.projections.FinancialStatusReportInfo |
|
|
//import com.ffii.tsms.modules.data.entity.projections.FinancialStatusReportInfo |
|
|
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo |
|
|
import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo |
|
|
import com.ffii.tsms.modules.data.entity.Team |
|
|
|
|
|
import com.ffii.tsms.modules.data.service.CustomerService |
|
|
import com.ffii.tsms.modules.data.service.CustomerService |
|
|
import com.ffii.tsms.modules.data.service.TeamService |
|
|
import com.ffii.tsms.modules.data.service.TeamService |
|
|
import com.ffii.tsms.modules.project.entity.* |
|
|
import com.ffii.tsms.modules.project.entity.* |
|
@@ -35,11 +33,12 @@ import java.time.LocalDate |
|
|
import java.net.URLEncoder |
|
|
import java.net.URLEncoder |
|
|
import java.time.format.DateTimeFormatter |
|
|
import java.time.format.DateTimeFormatter |
|
|
import org.springframework.stereotype.Controller |
|
|
import org.springframework.stereotype.Controller |
|
|
import com.ffii.tsms.modules.data.entity.TeamRepository |
|
|
|
|
|
import com.ffii.tsms.modules.data.entity.CustomerRepository |
|
|
|
|
|
import org.springframework.data.jpa.repository.JpaRepository |
|
|
import org.springframework.data.jpa.repository.JpaRepository |
|
|
import com.ffii.tsms.modules.project.entity.Project |
|
|
import com.ffii.tsms.modules.project.entity.Project |
|
|
import com.ffii.tsms.modules.report.web.model.* |
|
|
import com.ffii.tsms.modules.report.web.model.* |
|
|
|
|
|
import com.ffii.tsms.modules.timesheet.entity.Timesheet |
|
|
|
|
|
import org.springframework.data.domain.Example |
|
|
|
|
|
import org.springframework.data.domain.ExampleMatcher |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/reports") |
|
|
@RequestMapping("/reports") |
|
@@ -87,6 +86,34 @@ class ReportController( |
|
|
.body(ByteArrayResource(reportResult)) |
|
|
.body(ByteArrayResource(reportResult)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/ProjectPotentialDelayReport") |
|
|
|
|
|
@Throws(ServletRequestBindingException::class, IOException::class) |
|
|
|
|
|
fun getProjectPotentialDelayReport(@RequestBody @Valid request: ProjectPotentialDelayReportRequest): ResponseEntity<Resource> { |
|
|
|
|
|
|
|
|
|
|
|
val team = if (request.teamId.lowercase() == "all") null else teamRepository.findById(request.teamId.toLong()).orElse(null) |
|
|
|
|
|
val searchedTeam = if (team == null) "All" else team.code + " - " +team.name |
|
|
|
|
|
val client = if (request.clientId.lowercase() == "all") null else customerRepository.findById(request.clientId.toLong()).orElse(null) |
|
|
|
|
|
val searchedClient = if (client == null) "All" else client.code + " - " +client.name |
|
|
|
|
|
|
|
|
|
|
|
val matcher = ExampleMatcher.matching().withIgnoreNullValues() |
|
|
|
|
|
val exampleQuery = Example.of(Project().apply { |
|
|
|
|
|
// org.springframework.dao.InvalidDataAccessApiUsageException: Path 'teamLead.team.staff' from root Project must not span a cyclic property reference |
|
|
|
|
|
// [{ com.ffii.tsms.modules.project.entity.Project@6847e037 }] -teamLead-> [{ com.ffii.tsms.modules.data.entity.Staff@2a4c488b }] -team-> [{ com.ffii.tsms.modules.data.entity.Team@a09acb5 }] -staff-> [{ com.ffii.tsms.modules.data.entity.Staff@2a4c488b }] |
|
|
|
|
|
// teamLead = team?.staff |
|
|
|
|
|
customer = client |
|
|
|
|
|
status = "On-going" |
|
|
|
|
|
}, matcher) |
|
|
|
|
|
|
|
|
|
|
|
val projects = if (team == null) projectRepository.findAll(exampleQuery) else projectRepository.findAll(exampleQuery).filter { it.teamLead == team.staff } |
|
|
|
|
|
|
|
|
|
|
|
val projectTasks = projectTaskRepository.findAllByProjectIn(projects) |
|
|
|
|
|
val timesheets = timesheetRepository.findAllByProjectTaskIn(projectTasks) |
|
|
|
|
|
val reportResult: ByteArray = excelReportService.generateProjectPotentialDelayReport(searchedTeam, searchedClient, projects, timesheets) |
|
|
|
|
|
return ResponseEntity.ok() |
|
|
|
|
|
.header("filename", "Project Potential Delay Report - " + LocalDate.now() + ".xlsx") |
|
|
|
|
|
.body(ByteArrayResource(reportResult)) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@PostMapping("/StaffMonthlyWorkHourAnalysisReport") |
|
|
@PostMapping("/StaffMonthlyWorkHourAnalysisReport") |
|
|
@Throws(ServletRequestBindingException::class, IOException::class) |
|
|
@Throws(ServletRequestBindingException::class, IOException::class) |
|
|
fun StaffMonthlyWorkHourAnalysisReport(@RequestBody @Valid request: StaffMonthlyWorkHourAnalysisReportRequest): ResponseEntity<Resource> { |
|
|
fun StaffMonthlyWorkHourAnalysisReport(@RequestBody @Valid request: StaffMonthlyWorkHourAnalysisReportRequest): ResponseEntity<Resource> { |
|
|