| @@ -4,12 +4,9 @@ import com.ffii.core.support.AbstractBaseEntityService | |||||
| import com.ffii.core.support.JdbcDao | import com.ffii.core.support.JdbcDao | ||||
| import com.ffii.tsms.modules.data.entity.* | import com.ffii.tsms.modules.data.entity.* | ||||
| import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | ||||
| //import com.ffii.tsms.modules.data.web.models.NewCustomerResponse | |||||
| import com.ffii.tsms.modules.data.web.models.NewStaffRequest | import com.ffii.tsms.modules.data.web.models.NewStaffRequest | ||||
| import com.ffii.tsms.modules.data.web.models.NewStaffResponse | |||||
| import com.ffii.tsms.modules.user.entity.User | import com.ffii.tsms.modules.user.entity.User | ||||
| import com.ffii.tsms.modules.user.entity.UserRepository | import com.ffii.tsms.modules.user.entity.UserRepository | ||||
| import org.springframework.beans.BeanUtils | |||||
| import org.springframework.security.crypto.password.PasswordEncoder | import org.springframework.security.crypto.password.PasswordEncoder | ||||
| import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | import org.springframework.transaction.annotation.Transactional | ||||
| @@ -8,7 +8,6 @@ import com.ffii.tsms.modules.data.entity.Staff | |||||
| import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | import com.ffii.tsms.modules.data.entity.projections.StaffSearchInfo | ||||
| import com.ffii.tsms.modules.data.service.StaffsService | import com.ffii.tsms.modules.data.service.StaffsService | ||||
| import com.ffii.tsms.modules.data.web.models.NewStaffRequest | import com.ffii.tsms.modules.data.web.models.NewStaffRequest | ||||
| import com.ffii.tsms.modules.data.web.models.NewStaffResponse | |||||
| import jakarta.servlet.http.HttpServletRequest | import jakarta.servlet.http.HttpServletRequest | ||||
| import jakarta.validation.Valid | import jakarta.validation.Valid | ||||
| import org.springframework.http.HttpStatus | import org.springframework.http.HttpStatus | ||||
| @@ -31,6 +31,10 @@ open class Milestone : IdEntity<Long>() { | |||||
| @JoinColumn(name = "projectId") | @JoinColumn(name = "projectId") | ||||
| open var project: Project? = null | open var project: Project? = null | ||||
| @ManyToOne | |||||
| @JoinColumn(name = "taskGroupId") | |||||
| open var taskGroup: TaskGroup? = null | |||||
| final override fun equals(other: Any?): Boolean { | final override fun equals(other: Any?): Boolean { | ||||
| if (this === other) return true | if (this === other) return true | ||||
| if (other == null) return false | if (other == null) return false | ||||
| @@ -54,6 +54,10 @@ open class Project : BaseEntity<Long>() { | |||||
| @Column(name = "custLeadEmail") | @Column(name = "custLeadEmail") | ||||
| open var custLeadEmail: String? = null | open var custLeadEmail: String? = null | ||||
| @ManyToOne | |||||
| @JoinColumn(name = "customerSubsidiaryId") | |||||
| open var customerSubsidiary: Subsidiary? = null | |||||
| @Column(name = "remark", length = 1500) | @Column(name = "remark", length = 1500) | ||||
| open var remark: String? = null | open var remark: String? = null | ||||
| @@ -0,0 +1,6 @@ | |||||
| package com.ffii.tsms.modules.project.entity; | |||||
| import com.ffii.core.support.AbstractRepository | |||||
| interface TaskGroupRepository : AbstractRepository<TaskGroup, Long> { | |||||
| } | |||||
| @@ -19,6 +19,7 @@ open class ProjectsService( | |||||
| private val customerService: CustomerService, | private val customerService: CustomerService, | ||||
| private val tasksService: TasksService, | private val tasksService: TasksService, | ||||
| private val customerContactService: CustomerContactService, | private val customerContactService: CustomerContactService, | ||||
| private val subsidiaryService: SubsidiaryService, | |||||
| private val projectCategoryRepository: ProjectCategoryRepository, | private val projectCategoryRepository: ProjectCategoryRepository, | ||||
| private val staffRepository: StaffRepository, | private val staffRepository: StaffRepository, | ||||
| private val staffAllocationRepository: StaffAllocationRepository, | private val staffAllocationRepository: StaffAllocationRepository, | ||||
| @@ -66,8 +67,10 @@ open class ProjectsService( | |||||
| val teamLead = staffRepository.findById(request.projectLeadId).orElseThrow() | val teamLead = staffRepository.findById(request.projectLeadId).orElseThrow() | ||||
| val customer = customerService.findCustomer(request.clientId) | val customer = customerService.findCustomer(request.clientId) | ||||
| val clientContact = customerContactService.findByContactId(request.clientContactId) | val clientContact = customerContactService.findByContactId(request.clientContactId) | ||||
| val customerSubsidiary = request.clientSubsidiaryId?.let { subsidiaryService.findSubsidiary(it) } | |||||
| val allTasksMap = tasksService.allTasks().associateBy { it.id } | val allTasksMap = tasksService.allTasks().associateBy { it.id } | ||||
| val taskGroupMap = tasksService.allTaskGroups().associateBy { it.id } | |||||
| val project = | val project = | ||||
| Project().apply { | Project().apply { | ||||
| @@ -90,6 +93,7 @@ open class ProjectsService( | |||||
| custLeadName = clientContact.name | custLeadName = clientContact.name | ||||
| custLeadEmail = clientContact.email | custLeadEmail = clientContact.email | ||||
| custLeadPhone = clientContact.phone | custLeadPhone = clientContact.phone | ||||
| this.customerSubsidiary = customerSubsidiary | |||||
| } | } | ||||
| @@ -100,8 +104,9 @@ open class ProjectsService( | |||||
| Milestone().apply { | Milestone().apply { | ||||
| val newMilestone = this | val newMilestone = this | ||||
| this.project = project | this.project = project | ||||
| this.startDate = LocalDate.parse(requestMilestone.startDate) | |||||
| this.endDate = LocalDate.parse(requestMilestone.endDate) | |||||
| this.taskGroup = taskGroupMap[taskStageId] | |||||
| this.startDate = requestMilestone.startDate?.let { LocalDate.parse(it) } | |||||
| this.endDate = requestMilestone.endDate?.let { LocalDate.parse(it) } | |||||
| this.milestonePayments = requestMilestone.payments.map { | this.milestonePayments = requestMilestone.payments.map { | ||||
| MilestonePayment().apply { | MilestonePayment().apply { | ||||
| this.description = it.description | this.description = it.description | ||||
| @@ -1,15 +1,13 @@ | |||||
| package com.ffii.tsms.modules.project.service | package com.ffii.tsms.modules.project.service | ||||
| import com.ffii.tsms.modules.project.entity.Task | |||||
| import com.ffii.tsms.modules.project.entity.TaskRepository | |||||
| import com.ffii.tsms.modules.project.entity.TaskTemplate | |||||
| import com.ffii.tsms.modules.project.entity.TaskTemplateRepository | |||||
| import com.ffii.tsms.modules.project.entity.* | |||||
| import org.springframework.stereotype.Service | import org.springframework.stereotype.Service | ||||
| @Service | @Service | ||||
| class TasksService( | class TasksService( | ||||
| private val taskTemplateRepository: TaskTemplateRepository, | private val taskTemplateRepository: TaskTemplateRepository, | ||||
| private val taskRepository: TaskRepository | |||||
| private val taskRepository: TaskRepository, | |||||
| private val taskGroupRepository: TaskGroupRepository | |||||
| ) { | ) { | ||||
| fun allTasks(): List<Task> { | fun allTasks(): List<Task> { | ||||
| return taskRepository.findAll() | return taskRepository.findAll() | ||||
| @@ -28,4 +26,8 @@ class TasksService( | |||||
| } | } | ||||
| ) | ) | ||||
| } | } | ||||
| fun allTaskGroups(): List<TaskGroup> { | |||||
| return taskGroupRepository.findAll() | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,6 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset wayne:project_customer_subsidiary | |||||
| ALTER TABLE project ADD customerSubsidiaryId INT NULL; | |||||
| ALTER TABLE project ADD CONSTRAINT FK_PROJECT_ON_CUSTOMERSUBSIDIARYID FOREIGN KEY (customerSubsidiaryId) REFERENCES subsidiary (id); | |||||
| @@ -0,0 +1,6 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset wayne:milestone_task_group | |||||
| ALTER TABLE milestone ADD taskGroupId INT NULL; | |||||
| ALTER TABLE milestone ADD CONSTRAINT FK_MILESTONE_ON_TASKGROUPID FOREIGN KEY (taskGroupId) REFERENCES task_group (id); | |||||