|
|
@@ -35,6 +35,7 @@ import java.time.format.DateTimeFormatter |
|
|
|
import org.springframework.stereotype.Controller |
|
|
|
import org.springframework.data.jpa.repository.JpaRepository |
|
|
|
import com.ffii.tsms.modules.project.entity.Project |
|
|
|
import com.ffii.tsms.modules.project.service.SubsidiaryService |
|
|
|
import com.ffii.tsms.modules.report.web.model.* |
|
|
|
import com.ffii.tsms.modules.timesheet.entity.Timesheet |
|
|
|
import org.springframework.data.domain.Example |
|
|
@@ -56,6 +57,7 @@ class ReportController( |
|
|
|
private val leaveRepository: LeaveRepository, |
|
|
|
private val teamService: TeamService, |
|
|
|
private val customerService: CustomerService, |
|
|
|
private val subsidiaryService: SubsidiaryService, |
|
|
|
private val invoiceService: InvoiceService, private val gradeAllocationRepository: GradeAllocationRepository, |
|
|
|
private val subsidiaryRepository: SubsidiaryRepository |
|
|
|
) { |
|
|
@@ -154,7 +156,7 @@ class ReportController( |
|
|
|
fun ProjectResourceOverconsumptionReport(@RequestBody @Valid request: ProjectResourceOverconsumptionReport): ResponseEntity<Resource> { |
|
|
|
val lowerLimit = request.lowerLimit |
|
|
|
var team: String = "All" |
|
|
|
var customer: String = "All" |
|
|
|
var customerOrSubsidiary: String = "All" |
|
|
|
val args: MutableMap<String, Any> = mutableMapOf( |
|
|
|
"status" to request.status, |
|
|
|
"lowerLimit" to lowerLimit |
|
|
@@ -165,10 +167,14 @@ class ReportController( |
|
|
|
} |
|
|
|
if (request.custId != null) { |
|
|
|
args["custId"] = request.custId |
|
|
|
customer = customerService.find(request.custId).orElseThrow().name |
|
|
|
customerOrSubsidiary = customerService.find(request.custId).orElseThrow().name |
|
|
|
} |
|
|
|
if (request.subsidiaryId != null) { |
|
|
|
args["subsidiaryId"] = request.subsidiaryId |
|
|
|
customerOrSubsidiary = subsidiaryService.find(request.subsidiaryId).orElseThrow().name |
|
|
|
} |
|
|
|
val result: List<Map<String, Any>> = excelReportService.getProjectResourceOverconsumptionReport(args); |
|
|
|
val reportResult: ByteArray = excelReportService.generateProjectResourceOverconsumptionReport(team, customer, result, lowerLimit) |
|
|
|
val reportResult: ByteArray = excelReportService.generateProjectResourceOverconsumptionReport(team, customerOrSubsidiary, result, lowerLimit) |
|
|
|
// val mediaType: MediaType = MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") |
|
|
|
return ResponseEntity.ok() |
|
|
|
// .contentType(mediaType) |
|
|
|