ソースを参照

update project

tags/Baseline_30082024_BACKEND_UAT
cyril.tsui 1年前
コミット
e86edfdd2e
7個のファイルの変更44行の追加8行の削除
  1. +1
    -1
      src/main/java/com/ffii/tsms/modules/data/service/CustomerContactService.kt
  2. +8
    -0
      src/main/java/com/ffii/tsms/modules/project/entity/Project.kt
  3. +1
    -1
      src/main/java/com/ffii/tsms/modules/project/entity/ProjectRepository.kt
  4. +3
    -0
      src/main/java/com/ffii/tsms/modules/project/entity/projections/ProjectSearchInfo.kt
  5. +10
    -6
      src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt
  6. +1
    -0
      src/main/java/com/ffii/tsms/modules/project/web/models/EditProjectDetails.kt
  7. +20
    -0
      src/main/resources/db/changelog/changes/20240522_01_cyril/01_update_project.sql

+ 1
- 1
src/main/java/com/ffii/tsms/modules/data/service/CustomerContactService.kt ファイルの表示

@@ -17,7 +17,7 @@ class CustomerContactService(
}

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

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


+ 8
- 0
src/main/java/com/ffii/tsms/modules/project/entity/Project.kt ファイルの表示

@@ -123,4 +123,12 @@ open class Project : BaseEntity<Long>() {
// @JsonBackReference
@JoinColumn(name = "mainProjectId")
open var mainProject: Project? = null

@ManyToOne
@JoinColumn(name = "customerContactId")
open var customerContact: CustomerContact? = null

@ManyToOne
@JoinColumn(name = "subsidiaryContactId")
open var subsidiaryContact: SubsidiaryContact? = null
}

+ 1
- 1
src/main/java/com/ffii/tsms/modules/project/entity/ProjectRepository.kt ファイルの表示

@@ -25,7 +25,7 @@ interface ProjectRepository : AbstractRepository<Project, Long> {
"")
fun getLatestCodeNumberByMainProject(isClpProject: Boolean, id: Serializable?): Long?

@Query("SELECT max(cast(substring_index(p.code, '-', -1) as long)) FROM Project p WHERE p.code like ?1 and p.id != ?2")
@Query("SELECT max(case when length(p.code) - length(replace(p.code, '-', '')) > 1 then cast(substring_index(p.code, '-', -1) as long) end) FROM Project p WHERE p.code like ?1 and p.id != ?2")
fun getLatestCodeNumberBySubProject(code: String, id: Serializable?): Long?

fun findAllByStatusIsNotAndMainProjectIsNull(status: String): List<Project>

+ 3
- 0
src/main/java/com/ffii/tsms/modules/project/entity/projections/ProjectSearchInfo.kt ファイルの表示

@@ -11,6 +11,9 @@ interface ProjectSearchInfo {
val code: String?
val status: String?

@get:Value("#{target.mainProject?.code}")
val mainProject: String?

@get:Value("#{target.projectCategory.name}")
val category: String?



+ 10
- 6
src/main/java/com/ffii/tsms/modules/project/service/ProjectsService.kt ファイルの表示

@@ -210,6 +210,8 @@ open class ProjectsService(
custLeadPhone =
if (request.isSubsidiaryContact == null || !request.isSubsidiaryContact) clientContact.phone else subsidiaryContact.phone
this.customerSubsidiary = customerSubsidiary
this.customerContact = if (customerSubsidiary == null) clientContact else null
this.subsidiaryContact = if (customerSubsidiary != null) subsidiaryContact else null
}


@@ -325,11 +327,11 @@ open class ProjectsService(
val project = projectRepository.findById(projectId)

return project.getOrNull()?.let {
val subsidiaryContact = it.customerSubsidiary?.id?.let { subsidiaryId ->
subsidiaryContactService.findAllBySubsidiaryId(subsidiaryId)
} ?: emptyList()
val customerContact = it.customer?.id?.let { customerId -> customerContactService.findAllByCustomerId(customerId) }
?: emptyList()
// val subsidiaryContact = it.customerSubsidiary?.id?.let { subsidiaryId ->
// subsidiaryContactService.findAllBySubsidiaryId(subsidiaryId)
// } ?: emptyList()
// 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!! }
@@ -345,6 +347,7 @@ open class ProjectsService(
projectActualEnd = it.actualEnd,
projectStatus = it.status,
isClpProject = it.isClpProject,
mainProjectId = it.mainProject?.id,
serviceTypeId = it.serviceType?.id,
fundingTypeId = it.fundingType?.id,
contractTypeId = it.contractType?.id,
@@ -353,7 +356,8 @@ open class ProjectsService(
buildingTypeIds = it.buildingTypes.mapNotNull { buildingType -> buildingType.id },
workNatureIds = it.workNatures.mapNotNull { workNature -> workNature.id },
clientId = it.customer?.id,
clientContactId = subsidiaryContact.find { contact -> contact.name == it.custLeadName }?.id ?: customerContact.find { contact -> contact.name == it.custLeadName }?.id,
clientContactId = it.subsidiaryContact?.id ?: it.customerContact?.id,
// subsidiaryContact.find { contact -> contact.name == it.custLeadName }?.id ?: customerContact.find { contact -> contact.name == it.custLeadName }?.id,
clientSubsidiaryId = it.customerSubsidiary?.id,
totalManhour = it.totalManhour,
manhourPercentageByGrade = gradeAllocationRepository.findByProject(it)


+ 1
- 0
src/main/java/com/ffii/tsms/modules/project/web/models/EditProjectDetails.kt ファイルの表示

@@ -15,6 +15,7 @@ data class EditProjectDetails(
val projectActualEnd: LocalDate?,
val projectStatus: String?,
val isClpProject: Boolean?,
val mainProjectId: Long?,

val serviceTypeId: Long?,
val fundingTypeId: Long?,


+ 20
- 0
src/main/resources/db/changelog/changes/20240522_01_cyril/01_update_project.sql ファイルの表示

@@ -0,0 +1,20 @@
-- liquibase formatted sql
-- changeset cyril:project

ALTER TABLE `project`
ADD COLUMN `customerContactId` INT NULL DEFAULT NULL AFTER `mainProjectId`,
ADD COLUMN `subsidiaryContactId` INT NULL DEFAULT NULL AFTER `customerContactId`,
ADD INDEX `FK_PROJECT_ON_CUSTOMERCONTACTID` (`customerContactId` ASC) VISIBLE,
ADD INDEX `FK_PROJECT_ON_SUBSIDIARYCONTACTID` (`subsidiaryContactId` ASC) VISIBLE;
;
ALTER TABLE `project`
ADD CONSTRAINT `FK_PROJECT_ON_CUSTOMERCONTACTID`
FOREIGN KEY (`customerContactId`)
REFERENCES `customer_contact` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
ADD CONSTRAINT `FK_PROJECT_ON_SUBSIDIARYCONTACTID`
FOREIGN KEY (`subsidiaryContactId`)
REFERENCES `subsidiary_contact` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;

読み込み中…
キャンセル
保存