@@ -7,12 +7,10 @@ import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | |||||
import com.ffii.tsms.modules.data.service.CustomerService | import com.ffii.tsms.modules.data.service.CustomerService | ||||
import com.ffii.tsms.modules.data.service.GradeService | import com.ffii.tsms.modules.data.service.GradeService | ||||
import com.ffii.tsms.modules.project.entity.* | import com.ffii.tsms.modules.project.entity.* | ||||
import com.ffii.tsms.modules.project.entity.Milestone | |||||
import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo | import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo | ||||
import com.ffii.tsms.modules.project.entity.projections.InvoiceSearchInfo | import com.ffii.tsms.modules.project.entity.projections.InvoiceSearchInfo | ||||
import com.ffii.tsms.modules.project.web.models.AssignedProject | |||||
import com.ffii.tsms.modules.project.web.models.MilestoneInfo | |||||
import com.ffii.tsms.modules.project.web.models.NewProjectRequest | |||||
import com.ffii.tsms.modules.project.web.models.NewProjectResponse | |||||
import com.ffii.tsms.modules.project.web.models.* | |||||
import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
import org.springframework.transaction.annotation.Transactional | import org.springframework.transaction.annotation.Transactional | ||||
import java.time.LocalDate | import java.time.LocalDate | ||||
@@ -197,6 +195,37 @@ open class ProjectsService( | |||||
} | } | ||||
} | } | ||||
open fun getProjectDetails(projectId: Long): EditProjectDetails? { | |||||
val project = projectRepository.findById(projectId) | |||||
return project.getOrNull()?.let { | |||||
val customerContact = it.customer?.id?.let { customerId -> customerContactService.findAllByCustomerId(customerId) } ?: emptyList() | |||||
EditProjectDetails( | |||||
projectCode = it.code, | |||||
projectName = it.name, | |||||
projectCategoryId = it.projectCategory?.id, | |||||
projectDescription = it.description, | |||||
projectLeadId = it.teamLead?.id, | |||||
serviceTypeId = it.serviceType?.id, | |||||
fundingTypeId = it.fundingType?.id, | |||||
contractTypeId = it.contractType?.id, | |||||
locationId = it.location?.id, | |||||
buildingTypeIds = it.buildingTypes.mapNotNull { buildingType -> buildingType.id }, | |||||
workNatureIds = it.workNatures.mapNotNull { workNature -> workNature.id }, | |||||
clientId = it.customer?.id, | |||||
clientContactId = customerContact.find { contact -> contact.name == it.custLeadName }?.id, | |||||
clientSubsidiaryId = it.customerSubsidiary?.id, | |||||
totalManhour = it.totalManhour, | |||||
manhourPercentageByGrade = emptyMap(), | |||||
taskGroups = emptyMap(), | |||||
allocatedStaffIds = emptyList(), | |||||
milestones = emptyMap(), | |||||
expectedProjectFee = it.expectedTotalFee | |||||
) | |||||
} | |||||
} | |||||
open fun allFundingTypes(): List<FundingType> { | open fun allFundingTypes(): List<FundingType> { | ||||
return fundingTypeRepository.findAll() | return fundingTypeRepository.findAll() | ||||
} | } | ||||
@@ -1,11 +1,12 @@ | |||||
package com.ffii.tsms.modules.project.web | package com.ffii.tsms.modules.project.web | ||||
import com.ffii.core.exception.NotFoundException | |||||
import com.ffii.tsms.modules.data.entity.* | import com.ffii.tsms.modules.data.entity.* | ||||
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | ||||
import com.ffii.tsms.modules.project.entity.Project | |||||
import com.ffii.tsms.modules.project.entity.ProjectCategory | import com.ffii.tsms.modules.project.entity.ProjectCategory | ||||
import com.ffii.tsms.modules.project.service.ProjectsService | import com.ffii.tsms.modules.project.service.ProjectsService | ||||
import com.ffii.tsms.modules.project.web.models.AssignedProject | import com.ffii.tsms.modules.project.web.models.AssignedProject | ||||
import com.ffii.tsms.modules.project.web.models.EditProjectDetails | |||||
import com.ffii.tsms.modules.project.web.models.NewProjectRequest | import com.ffii.tsms.modules.project.web.models.NewProjectRequest | ||||
import com.ffii.tsms.modules.project.web.models.NewProjectResponse | import com.ffii.tsms.modules.project.web.models.NewProjectResponse | ||||
import jakarta.validation.Valid | import jakarta.validation.Valid | ||||
@@ -34,6 +35,11 @@ class ProjectsController(private val projectsService: ProjectsService) { | |||||
return projectsService.saveProject(newProject) | return projectsService.saveProject(newProject) | ||||
} | } | ||||
@GetMapping("/projectDetails/{id}") | |||||
fun projectDetails(@PathVariable id: Long): EditProjectDetails { | |||||
return projectsService.getProjectDetails(id) ?: throw NotFoundException() | |||||
} | |||||
@GetMapping("/fundingTypes") | @GetMapping("/fundingTypes") | ||||
fun projectFundingTypes(): List<FundingType> { | fun projectFundingTypes(): List<FundingType> { | ||||
return projectsService.allFundingTypes() | return projectsService.allFundingTypes() | ||||
@@ -0,0 +1,34 @@ | |||||
package com.ffii.tsms.modules.project.web.models | |||||
data class EditProjectDetails( | |||||
// Project details | |||||
val projectCode: String?, | |||||
val projectName: String?, | |||||
val projectCategoryId: Long?, | |||||
val projectDescription: String?, | |||||
val projectLeadId: Long?, | |||||
val serviceTypeId: Long?, | |||||
val fundingTypeId: Long?, | |||||
val contractTypeId: Long?, | |||||
val locationId: Long?, | |||||
val buildingTypeIds: List<Long>, | |||||
val workNatureIds: List<Long>, | |||||
// Client details | |||||
val clientId: Long?, | |||||
val clientContactId: Long?, | |||||
val clientSubsidiaryId: Long?, | |||||
// Allocation | |||||
val totalManhour: Double?, | |||||
val manhourPercentageByGrade: Map<Long, Double>, | |||||
val taskGroups: Map<Long, TaskGroupAllocation>, | |||||
val allocatedStaffIds: List<Long>, | |||||
// Milestones | |||||
val milestones: Map<Long, Milestone>, | |||||
// Miscellaneous | |||||
val expectedProjectFee: Double? | |||||
) |