瀏覽代碼

update

tags/Baseline_30082024_BACKEND_UAT
cyril.tsui 1 年之前
父節點
當前提交
f743d5de5e
共有 1 個文件被更改,包括 9 次插入7 次删除
  1. +9
    -7
      src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt

+ 9
- 7
src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt 查看文件

@@ -159,12 +159,11 @@ open class ProjectsService(
}



// Milestones and tasks
val tasksToSave = mutableListOf<ProjectTask>()
val milestones = request.taskGroups.entries.map { (taskStageId, taskGroupAllocation) ->
val taskGroup = taskGroupRepository.findById(taskStageId).orElse(TaskGroup())
val milestone = milestoneRepository.findByProjectAndTaskGroup(project, taskGroup) ?: Milestone()
val taskGroup = taskGroupRepository.findById(taskStageId).orElse(TaskGroup()) ?: TaskGroup()
val milestone = if (project.id != null && project.id!! > 0L) milestoneRepository.findByProjectAndTaskGroup(project, taskGroup) ?: Milestone() else Milestone()
milestone.apply {
val newMilestone = this
val requestMilestone = request.milestones[taskStageId]
@@ -172,9 +171,11 @@ open class ProjectsService(
this.taskGroup = taskGroupMap[taskStageId]
this.startDate = requestMilestone?.startDate?.let { LocalDate.parse(it) }
this.endDate = requestMilestone?.endDate?.let { LocalDate.parse(it) }
this.milestonePayments.removeAll(this.milestonePayments)
if (this.milestonePayments.isNotEmpty()) {
this.milestonePayments.removeAll(this.milestonePayments)
}
requestMilestone?.payments?.map {
val milestonePayment = if (it.id > 0) milestonePaymentRepository.findById(it.id).orElse(MilestonePayment()) else MilestonePayment()
val milestonePayment = milestonePaymentRepository.findById(it.id).orElse(MilestonePayment()) ?:MilestonePayment()
this.milestonePayments.add(milestonePayment.apply {
this.milestone = newMilestone
this.description = it.description
@@ -187,7 +188,8 @@ open class ProjectsService(
this.stagePercentAllocation = taskGroupAllocation.percentAllocation

taskGroupAllocation.taskIds.map { taskId ->
val projectTask = projectTaskRepository.findByProjectAndTask(project, allTasksMap[taskId]!!) ?:ProjectTask()
val projectTask = if (project.id != null && project.id!! > 0L) projectTaskRepository.findByProjectAndTask(project, allTasksMap[taskId]!!) ?:ProjectTask() else ProjectTask()

projectTask.apply {
this.project = project
this.milestone = newMilestone
@@ -201,7 +203,7 @@ open class ProjectsService(

// Grade allocation (from manhourPercentageByGrade)
val gradeAllocations = request.manhourPercentageByGrade.entries.map {
val gradeAllocation = gradeAllocationRepository.findByProjectAndGrade(project, gradeMap[it.key]!!) ?: GradeAllocation()
val gradeAllocation = if (project.id != null && project.id!! > 0L) gradeAllocationRepository.findByProjectAndGrade(project, gradeMap[it.key]!!) ?: GradeAllocation() else GradeAllocation()

gradeAllocation.apply {
this.project = project


Loading…
取消
儲存