Browse Source

Add remaining project details info

tags/Baseline_30082024_BACKEND_UAT
Wayne 1 year ago
parent
commit
75d86371a6
3 changed files with 27 additions and 4 deletions
  1. +1
    -0
      src/main/java/com/ffii/tsms/modules/project/entity/GradeAllocationRepository.kt
  2. +1
    -0
      src/main/java/com/ffii/tsms/modules/project/entity/StaffAllocationRepository.kt
  3. +25
    -4
      src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt

+ 1
- 0
src/main/java/com/ffii/tsms/modules/project/entity/GradeAllocationRepository.kt View File

@@ -3,4 +3,5 @@ package com.ffii.tsms.modules.project.entity;
import com.ffii.core.support.AbstractRepository

interface GradeAllocationRepository : AbstractRepository<GradeAllocation, Long> {
fun findByProject(project: Project): List<GradeAllocation>
}

+ 1
- 0
src/main/java/com/ffii/tsms/modules/project/entity/StaffAllocationRepository.kt View File

@@ -5,4 +5,5 @@ import com.ffii.tsms.modules.data.entity.Staff

interface StaffAllocationRepository : AbstractRepository<StaffAllocation, Long> {
fun findAssignedProjectsByStaff(staff: Staff): List<StaffAllocation>
fun findByProject(project: Project): List<StaffAllocation>
}

+ 25
- 4
src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt View File

@@ -201,6 +201,10 @@ open class ProjectsService(
return project.getOrNull()?.let {
val customerContact = it.customer?.id?.let { customerId -> customerContactService.findAllByCustomerId(customerId) } ?: emptyList()

val milestoneMap = it.milestones
.filter { milestone -> milestone.taskGroup?.id != null }
.associateBy { milestone -> milestone.taskGroup!!.id!! }

EditProjectDetails(
projectCode = it.code,
projectName = it.name,
@@ -217,10 +221,27 @@ open class ProjectsService(
clientContactId = customerContact.find { contact -> contact.name == it.custLeadName }?.id,
clientSubsidiaryId = it.customerSubsidiary?.id,
totalManhour = it.totalManhour,
manhourPercentageByGrade = emptyMap(),
taskGroups = emptyMap(),
allocatedStaffIds = emptyList(),
milestones = emptyMap(),
manhourPercentageByGrade = gradeAllocationRepository.findByProject(it)
.filter { allocation -> allocation.grade?.id != null }
.associate { allocation -> Pair(allocation.grade!!.id!!, allocation.manhour ?: 0.0) },
taskGroups = projectTaskRepository.findAllByProject(it)
.mapNotNull { projectTask -> if (projectTask.task?.taskGroup?.id != null) projectTask.task else null }
.groupBy { task -> task.taskGroup!!.id!! }
.mapValues { (taskGroupId, tasks) -> TaskGroupAllocation(
taskIds = tasks.mapNotNull { task -> task.id },
percentAllocation = milestoneMap[taskGroupId]?.stagePercentAllocation ?: 0.0
) },
allocatedStaffIds = staffAllocationRepository.findByProject(it).mapNotNull { allocation -> allocation.staff?.id },
milestones = milestoneMap.mapValues { (_, milestone) -> com.ffii.tsms.modules.project.web.models.Milestone(
startDate = milestone.startDate?.format(DateTimeFormatter.ISO_LOCAL_DATE),
endDate = milestone.endDate?.format(DateTimeFormatter.ISO_LOCAL_DATE),
payments = milestone.milestonePayments.map { payment -> PaymentInputs(
id = payment.id!!,
amount = payment.amount!!,
description = payment.description!!,
date = payment.date!!.format(DateTimeFormatter.ISO_LOCAL_DATE)
)}
)},
expectedProjectFee = it.expectedTotalFee
)
}


Loading…
Cancel
Save