|
@@ -1,6 +1,7 @@ |
|
|
package com.ffii.tsms.modules.project.service |
|
|
package com.ffii.tsms.modules.project.service |
|
|
|
|
|
|
|
|
import com.ffii.tsms.modules.data.entity.StaffRepository |
|
|
|
|
|
|
|
|
import com.ffii.tsms.modules.data.entity.* |
|
|
|
|
|
import com.ffii.tsms.modules.data.service.CustomerContactService |
|
|
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo |
|
|
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo |
|
|
import com.ffii.tsms.modules.data.service.CustomerService |
|
|
import com.ffii.tsms.modules.data.service.CustomerService |
|
|
import com.ffii.tsms.modules.project.entity.Project |
|
|
import com.ffii.tsms.modules.project.entity.Project |
|
@@ -14,8 +15,15 @@ import org.springframework.stereotype.Service |
|
|
class ProjectsService( |
|
|
class ProjectsService( |
|
|
private val projectRepository: ProjectRepository, |
|
|
private val projectRepository: ProjectRepository, |
|
|
private val customerService: CustomerService, |
|
|
private val customerService: CustomerService, |
|
|
|
|
|
private val customerContactService: CustomerContactService, |
|
|
private val projectCategoryRepository: ProjectCategoryRepository, |
|
|
private val projectCategoryRepository: ProjectCategoryRepository, |
|
|
private val staffRepository: StaffRepository |
|
|
|
|
|
|
|
|
private val staffRepository: StaffRepository, |
|
|
|
|
|
private val fundingTypeRepository: FundingTypeRepository, |
|
|
|
|
|
private val serviceTypeRepository: ServiceTypeRepository, |
|
|
|
|
|
private val contractTypeRepository: ContractTypeRepository, |
|
|
|
|
|
private val locationRepository: LocationRepository, |
|
|
|
|
|
private val buildingTypeRepository: BuildingTypeRepository, |
|
|
|
|
|
private val workNatureRepository: WorkNatureRepository |
|
|
) { |
|
|
) { |
|
|
fun allProjects(): List<ProjectSearchInfo> { |
|
|
fun allProjects(): List<ProjectSearchInfo> { |
|
|
return projectRepository.findProjectSearchInfoBy() |
|
|
return projectRepository.findProjectSearchInfoBy() |
|
@@ -28,35 +36,62 @@ class ProjectsService( |
|
|
fun saveProject(request: NewProjectRequest): Project { |
|
|
fun saveProject(request: NewProjectRequest): Project { |
|
|
val projectCategory = |
|
|
val projectCategory = |
|
|
projectCategoryRepository.findById(request.projectCategoryId).orElseThrow() |
|
|
projectCategoryRepository.findById(request.projectCategoryId).orElseThrow() |
|
|
|
|
|
val fundingType = fundingTypeRepository.findById(request.fundingTypeId).orElseThrow() |
|
|
|
|
|
val serviceType = serviceTypeRepository.findById(request.serviceTypeId).orElseThrow() |
|
|
|
|
|
val contractType = contractTypeRepository.findById(request.contractTypeId).orElseThrow() |
|
|
|
|
|
val location = locationRepository.findById(request.locationId).orElseThrow() |
|
|
|
|
|
val buildingTypes = buildingTypeRepository.findAllById(request.buildingTypeIds).toMutableSet() |
|
|
|
|
|
val workNatures = workNatureRepository.findAllById(request.workNatureIds).toMutableSet() |
|
|
|
|
|
|
|
|
val teamLead = staffRepository.findById(request.projectLeadId).orElseThrow() |
|
|
val teamLead = staffRepository.findById(request.projectLeadId).orElseThrow() |
|
|
|
|
|
val customer = customerService.findCustomer(request.clientId) |
|
|
|
|
|
val clientContact = customerContactService.findByContactId(request.clientContactId) |
|
|
|
|
|
|
|
|
// val _customer = |
|
|
|
|
|
// SaveCustomerRequest( |
|
|
|
|
|
// name = request.clientName, |
|
|
|
|
|
// code = request.clientCode, |
|
|
|
|
|
// // email = request.clientEmail, |
|
|
|
|
|
// // phone = request.clientPhone, |
|
|
|
|
|
// // contactName = request.clientContactName, |
|
|
|
|
|
// brNo = null, |
|
|
|
|
|
// address = null, |
|
|
|
|
|
// district = null, |
|
|
|
|
|
// deleteSubsidiaryIds = emptyList(), |
|
|
|
|
|
// addSubsidiaryIds = emptyList(), |
|
|
|
|
|
// id = null |
|
|
|
|
|
// ) |
|
|
|
|
|
// val customer = customerService.saveCustomer(_customer) |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Add tasks, milestones, allocated |
|
|
|
|
|
|
|
|
// TODO: Add tasks, milestones, allocated staff |
|
|
val project = |
|
|
val project = |
|
|
Project().apply { |
|
|
Project().apply { |
|
|
name = request.projectName |
|
|
name = request.projectName |
|
|
description = request.projectDescription |
|
|
description = request.projectDescription |
|
|
code = request.projectCode |
|
|
code = request.projectCode |
|
|
this.projectCategory = projectCategory |
|
|
this.projectCategory = projectCategory |
|
|
|
|
|
this.fundingType = fundingType |
|
|
|
|
|
this.serviceType = serviceType |
|
|
|
|
|
this.contractType = contractType |
|
|
|
|
|
this.location = location |
|
|
|
|
|
this.buildingTypes = buildingTypes |
|
|
|
|
|
this.workNatures = workNatures |
|
|
|
|
|
|
|
|
this.teamLead = teamLead |
|
|
this.teamLead = teamLead |
|
|
// this.customer = customer |
|
|
|
|
|
|
|
|
this.customer = customer |
|
|
|
|
|
custLeadName = clientContact.name |
|
|
|
|
|
custLeadEmail = clientContact.email |
|
|
|
|
|
custLeadPhone = clientContact.phone |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return projectRepository.save(project) |
|
|
return projectRepository.save(project) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun allFundingTypes(): List<FundingType> { |
|
|
|
|
|
return fundingTypeRepository.findAll() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun allLocationTypes(): List<Location> { |
|
|
|
|
|
return locationRepository.findAll() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun allServiceTypes(): List<ServiceType> { |
|
|
|
|
|
return serviceTypeRepository.findAll() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun allContractTypes(): List<ContractType> { |
|
|
|
|
|
return contractTypeRepository.findAll() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun allBuildingTypes(): List<BuildingType> { |
|
|
|
|
|
return buildingTypeRepository.findAll() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun allWorkNatures(): List<WorkNature> { |
|
|
|
|
|
return workNatureRepository.findAll() |
|
|
|
|
|
} |
|
|
} |
|
|
} |