瀏覽代碼

Add project types

tags/Baseline_30082024_BACKEND_UAT
Wayne 1 年之前
父節點
當前提交
7557ebe34d
共有 11 個文件被更改,包括 138 次插入28 次删除
  1. +6
    -0
      src/main/java/com/ffii/tsms/modules/data/entity/BuildingTypeRepository.kt
  2. +6
    -0
      src/main/java/com/ffii/tsms/modules/data/entity/ContractTypeRepository.kt
  3. +6
    -0
      src/main/java/com/ffii/tsms/modules/data/entity/FundingTypeRepository.kt
  4. +6
    -0
      src/main/java/com/ffii/tsms/modules/data/entity/LocationRepository.kt
  5. +6
    -0
      src/main/java/com/ffii/tsms/modules/data/entity/ServiceTypeRepository.kt
  6. +6
    -0
      src/main/java/com/ffii/tsms/modules/data/entity/WorkNatureRepository.kt
  7. +4
    -0
      src/main/java/com/ffii/tsms/modules/data/service/CustomerContactService.kt
  8. +2
    -2
      src/main/java/com/ffii/tsms/modules/data/web/StaffsController.kt
  9. +55
    -20
      src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt
  10. +31
    -0
      src/main/java/com/ffii/tsms/modules/project/web/ProjectsController.kt
  11. +10
    -6
      src/main/java/com/ffii/tsms/modules/project/web/models/NewProjectRequest.kt

+ 6
- 0
src/main/java/com/ffii/tsms/modules/data/entity/BuildingTypeRepository.kt 查看文件

@@ -0,0 +1,6 @@
package com.ffii.tsms.modules.data.entity;

import com.ffii.core.support.AbstractRepository

interface BuildingTypeRepository : AbstractRepository<BuildingType, Long> {
}

+ 6
- 0
src/main/java/com/ffii/tsms/modules/data/entity/ContractTypeRepository.kt 查看文件

@@ -0,0 +1,6 @@
package com.ffii.tsms.modules.data.entity;

import com.ffii.core.support.AbstractRepository

interface ContractTypeRepository : AbstractRepository<ContractType, Long> {
}

+ 6
- 0
src/main/java/com/ffii/tsms/modules/data/entity/FundingTypeRepository.kt 查看文件

@@ -0,0 +1,6 @@
package com.ffii.tsms.modules.data.entity;

import com.ffii.core.support.AbstractRepository

interface FundingTypeRepository : AbstractRepository<FundingType, Long> {
}

+ 6
- 0
src/main/java/com/ffii/tsms/modules/data/entity/LocationRepository.kt 查看文件

@@ -0,0 +1,6 @@
package com.ffii.tsms.modules.data.entity;

import com.ffii.core.support.AbstractRepository

interface LocationRepository : AbstractRepository<Location, Long> {
}

+ 6
- 0
src/main/java/com/ffii/tsms/modules/data/entity/ServiceTypeRepository.kt 查看文件

@@ -0,0 +1,6 @@
package com.ffii.tsms.modules.data.entity;

import com.ffii.core.support.AbstractRepository

interface ServiceTypeRepository : AbstractRepository<ServiceType, Long> {
}

+ 6
- 0
src/main/java/com/ffii/tsms/modules/data/entity/WorkNatureRepository.kt 查看文件

@@ -0,0 +1,6 @@
package com.ffii.tsms.modules.data.entity;

import com.ffii.core.support.AbstractRepository

interface WorkNatureRepository : AbstractRepository<WorkNature, Long> {
}

+ 4
- 0
src/main/java/com/ffii/tsms/modules/data/service/CustomerContactService.kt 查看文件

@@ -15,6 +15,10 @@ class CustomerContactService(
return customerContactRepository.findAllByCustomerId(customerId)
}

fun findByContactId(contactId: Long): CustomerContact {
return customerContactRepository.findById(contactId).orElseThrow()
}

fun saveContactsByCustomer(saveCustomerId: Long, saveCustomerContact: List<CustomerContact>) {

val customerContactList = mutableListOf<CustomerContact>()


+ 2
- 2
src/main/java/com/ffii/tsms/modules/data/web/StaffsController.kt 查看文件

@@ -15,8 +15,8 @@ import org.springframework.web.bind.annotation.*
@RequestMapping("/staffs")
class StaffsController(private val staffsService: StaffsService) {
@GetMapping("/teamLeads")
fun teamLeads(): List<Staff> {
return staffsService.getTeamLeads()
fun teamLeads(): List<StaffSearchInfo> {
return staffsService.allStaff()
}
@GetMapping
fun allStaff(): List<StaffSearchInfo> {


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

@@ -1,6 +1,7 @@
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.data.service.CustomerService
import com.ffii.tsms.modules.project.entity.Project
@@ -14,8 +15,15 @@ import org.springframework.stereotype.Service
class ProjectsService(
private val projectRepository: ProjectRepository,
private val customerService: CustomerService,
private val customerContactService: CustomerContactService,
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> {
return projectRepository.findProjectSearchInfoBy()
@@ -28,35 +36,62 @@ class ProjectsService(
fun saveProject(request: NewProjectRequest): Project {
val projectCategory =
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 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 =
Project().apply {
name = request.projectName
description = request.projectDescription
code = request.projectCode
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.customer = customer
this.customer = customer
custLeadName = clientContact.name
custLeadEmail = clientContact.email
custLeadPhone = clientContact.phone
}

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()
}
}

+ 31
- 0
src/main/java/com/ffii/tsms/modules/project/web/ProjectsController.kt 查看文件

@@ -1,5 +1,6 @@
package com.ffii.tsms.modules.project.web

import com.ffii.tsms.modules.data.entity.*
import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo
import com.ffii.tsms.modules.project.entity.Project
import com.ffii.tsms.modules.project.entity.ProjectCategory
@@ -25,4 +26,34 @@ class ProjectsController(private val projectsService: ProjectsService) {
fun saveProject(@Valid @RequestBody newProject: NewProjectRequest): Project {
return projectsService.saveProject(newProject)
}

@GetMapping("/fundingTypes")
fun projectFundingTypes(): List<FundingType> {
return projectsService.allFundingTypes()
}

@GetMapping("/serviceTypes")
fun projectServiceTypes(): List<ServiceType> {
return projectsService.allServiceTypes()
}

@GetMapping("/contractTypes")
fun projectContractTypes(): List<ContractType> {
return projectsService.allContractTypes()
}

@GetMapping("/locationTypes")
fun projectLocationTypes(): List<Location> {
return projectsService.allLocationTypes()
}

@GetMapping("/buildingTypes")
fun projectBuildingTypes(): List<BuildingType> {
return projectsService.allBuildingTypes()
}

@GetMapping("/workNatures")
fun projectWorkNatures(): List<WorkNature> {
return projectsService.allWorkNatures()
}
}

+ 10
- 6
src/main/java/com/ffii/tsms/modules/project/web/models/NewProjectRequest.kt 查看文件

@@ -12,12 +12,16 @@ data class NewProjectRequest(
val projectDescription: String,
val projectLeadId: Long,

val clientCode: String,
val clientName: String,
val clientContactName: String,
val clientPhone: String,
val clientEmail: String,
val clientSubsidiary: String,
val serviceTypeId: Long,
val fundingTypeId: Long,
val contractTypeId: Long,
val locationId: Long,
val buildingTypeIds: List<Long>,
val workNatureIds: List<Long>,

val clientId: Long,
val clientContactId: Long,
val clientSubsidiaryId: Long?,

val tasks: Map<Long, TaskAllocation>,



Loading…
取消
儲存