|
@@ -15,6 +15,7 @@ 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 |
|
|
import java.time.format.DateTimeFormatter |
|
|
import java.time.format.DateTimeFormatter |
|
|
|
|
|
import kotlin.jvm.optionals.getOrElse |
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
@@ -54,6 +55,10 @@ open class ProjectsService( |
|
|
return projectRepository.findInvoiceInfoSearchInfoById(id) |
|
|
return projectRepository.findInvoiceInfoSearchInfoById(id) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open fun markDeleted(id: Long) { |
|
|
|
|
|
projectRepository.save(projectRepository.findById(id).orElseThrow().apply { deleted = true }) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
open fun allAssignedProjects(): List<AssignedProject> { |
|
|
open fun allAssignedProjects(): List<AssignedProject> { |
|
|
return SecurityUtils.getUser().getOrNull()?.let { user -> |
|
|
return SecurityUtils.getUser().getOrNull()?.let { user -> |
|
|
staffRepository.findByUserId(user.id).getOrNull()?.let { staff -> |
|
|
staffRepository.findByUserId(user.id).getOrNull()?.let { staff -> |
|
@@ -105,13 +110,15 @@ open class ProjectsService( |
|
|
val taskGroupMap = tasksService.allTaskGroups().associateBy { it.id } |
|
|
val taskGroupMap = tasksService.allTaskGroups().associateBy { it.id } |
|
|
val gradeMap = gradeService.allGrades().associateBy { it.id } |
|
|
val gradeMap = gradeService.allGrades().associateBy { it.id } |
|
|
|
|
|
|
|
|
val project = |
|
|
|
|
|
Project().apply { |
|
|
|
|
|
|
|
|
val project = if (request.projectId != null && request.projectId > 0) projectRepository.findById(request.projectId).orElseThrow() else Project() |
|
|
|
|
|
project.apply { |
|
|
name = request.projectName |
|
|
name = request.projectName |
|
|
description = request.projectDescription |
|
|
description = request.projectDescription |
|
|
code = request.projectCode |
|
|
code = request.projectCode |
|
|
expectedTotalFee = request.expectedProjectFee |
|
|
expectedTotalFee = request.expectedProjectFee |
|
|
totalManhour = request.totalManhour |
|
|
totalManhour = request.totalManhour |
|
|
|
|
|
actualStart = request.projectActualStart |
|
|
|
|
|
actualEnd = request.projectActualEnd |
|
|
|
|
|
|
|
|
this.projectCategory = projectCategory |
|
|
this.projectCategory = projectCategory |
|
|
this.fundingType = fundingType |
|
|
this.fundingType = fundingType |
|
@@ -170,6 +177,13 @@ open class ProjectsService( |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (milestones.isNotEmpty()) { |
|
|
|
|
|
project.apply { |
|
|
|
|
|
planStart = milestones.mapNotNull { it.startDate }.minOrNull() |
|
|
|
|
|
planEnd = milestones.mapNotNull { it.endDate }.maxOrNull() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
val savedProject = projectRepository.save(project) |
|
|
val savedProject = projectRepository.save(project) |
|
|
milestoneRepository.saveAll(milestones) |
|
|
milestoneRepository.saveAll(milestones) |
|
|
projectTaskRepository.saveAll(tasksToSave) |
|
|
projectTaskRepository.saveAll(tasksToSave) |
|
@@ -206,11 +220,15 @@ open class ProjectsService( |
|
|
.associateBy { milestone -> milestone.taskGroup!!.id!! } |
|
|
.associateBy { milestone -> milestone.taskGroup!!.id!! } |
|
|
|
|
|
|
|
|
EditProjectDetails( |
|
|
EditProjectDetails( |
|
|
|
|
|
projectId = it.id, |
|
|
|
|
|
projectDeleted = it.deleted, |
|
|
projectCode = it.code, |
|
|
projectCode = it.code, |
|
|
projectName = it.name, |
|
|
projectName = it.name, |
|
|
projectCategoryId = it.projectCategory?.id, |
|
|
projectCategoryId = it.projectCategory?.id, |
|
|
projectDescription = it.description, |
|
|
projectDescription = it.description, |
|
|
projectLeadId = it.teamLead?.id, |
|
|
projectLeadId = it.teamLead?.id, |
|
|
|
|
|
projectActualStart = it.actualStart, |
|
|
|
|
|
projectActualEnd = it.actualEnd, |
|
|
serviceTypeId = it.serviceType?.id, |
|
|
serviceTypeId = it.serviceType?.id, |
|
|
fundingTypeId = it.fundingType?.id, |
|
|
fundingTypeId = it.fundingType?.id, |
|
|
contractTypeId = it.contractType?.id, |
|
|
contractTypeId = it.contractType?.id, |
|
|