|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.ffii.tsms.modules.project.service |
|
|
|
|
|
|
|
import com.ffii.tsms.modules.common.SecurityUtils |
|
|
|
import com.ffii.tsms.modules.data.entity.* |
|
|
|
import com.ffii.tsms.modules.data.service.CustomerContactService |
|
|
|
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo |
|
|
@@ -8,11 +9,14 @@ import com.ffii.tsms.modules.data.service.GradeService |
|
|
|
import com.ffii.tsms.modules.project.entity.* |
|
|
|
import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo |
|
|
|
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 org.springframework.stereotype.Service |
|
|
|
import org.springframework.transaction.annotation.Transactional |
|
|
|
import java.time.LocalDate |
|
|
|
import java.time.format.DateTimeFormatter |
|
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
|
|
|
|
|
@Service |
|
|
|
open class ProjectsService( |
|
|
@@ -51,6 +55,33 @@ open class ProjectsService( |
|
|
|
return projectRepository.findInvoiceInfoSearchInfoById(id) |
|
|
|
} |
|
|
|
|
|
|
|
open fun allAssignedProjects(): List<AssignedProject> { |
|
|
|
return SecurityUtils.getUser().getOrNull()?.let { user -> |
|
|
|
staffRepository.findByUserId(user.id).getOrNull()?.let { staff -> |
|
|
|
staffAllocationRepository.findAssignedProjectsByStaff(staff) |
|
|
|
.mapNotNull { it.project?.let { project -> |
|
|
|
AssignedProject( |
|
|
|
id = project.id!!, |
|
|
|
code = project.code!!, |
|
|
|
name = project.name!!, |
|
|
|
tasks = projectTaskRepository.findAllByProject(project).mapNotNull { pt -> pt.task }, |
|
|
|
milestones = milestoneRepository.findAllByProject(project) |
|
|
|
.filter { milestone -> milestone.taskGroup?.id != null } |
|
|
|
.associateBy { milestone -> milestone.taskGroup!!.id!! } |
|
|
|
.mapValues { (_, milestone) -> MilestoneInfo( |
|
|
|
startDate = milestone.startDate?.format(DateTimeFormatter.ISO_LOCAL_DATE), |
|
|
|
endDate = milestone.endDate?.format(DateTimeFormatter.ISO_LOCAL_DATE) |
|
|
|
) }, |
|
|
|
hoursAllocated = project.totalManhour ?: 0.0, |
|
|
|
hoursAllocatedOther = 0.0, |
|
|
|
hoursSpent = 0.0, |
|
|
|
hoursSpentOther = 0.0 |
|
|
|
) |
|
|
|
} } |
|
|
|
} |
|
|
|
} ?: emptyList() |
|
|
|
} |
|
|
|
|
|
|
|
open fun allProjectCategories(): List<ProjectCategory> { |
|
|
|
return projectCategoryRepository.findAll() |
|
|
|
} |
|
|
|