| @@ -118,4 +118,9 @@ open class Project : BaseEntity<Long>() { | |||||
| @Column(name = "isClpProject") | @Column(name = "isClpProject") | ||||
| open var isClpProject: Boolean? = null | open var isClpProject: Boolean? = null | ||||
| } | |||||
| @ManyToOne | |||||
| // @JsonBackReference | |||||
| @JoinColumn(name = "mainProjectId") | |||||
| open var mainProject: Project? = null | |||||
| } | |||||
| @@ -4,6 +4,7 @@ import com.ffii.core.support.AbstractRepository | |||||
| import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo | import com.ffii.tsms.modules.project.entity.projections.InvoiceInfoSearchInfo | ||||
| import com.ffii.tsms.modules.project.entity.projections.InvoiceSearchInfo | import com.ffii.tsms.modules.project.entity.projections.InvoiceSearchInfo | ||||
| import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | import com.ffii.tsms.modules.project.entity.projections.ProjectSearchInfo | ||||
| import org.springframework.data.jpa.repository.Query | |||||
| import java.io.Serializable | import java.io.Serializable | ||||
| import java.time.LocalDate | import java.time.LocalDate | ||||
| @@ -21,4 +22,11 @@ interface ProjectRepository : AbstractRepository<Project, Long> { | |||||
| fun findAllByPlanStartLessThanEqualAndPlanEndGreaterThanEqual(remainedDateFrom: LocalDate?, remainedDateTo: LocalDate?):List<Project> | fun findAllByPlanStartLessThanEqualAndPlanEndGreaterThanEqual(remainedDateFrom: LocalDate?, remainedDateTo: LocalDate?):List<Project> | ||||
| //fun findAllByDateRange(start: LocalDate, end: LocalDate): List<Project> | //fun findAllByDateRange(start: LocalDate, end: LocalDate): List<Project> | ||||
| @Query("SELECT max(cast(substring_index(substring_index(p.code, '-', 2), '-', -1) as long)) FROM Project p WHERE p.isClpProject = ?1 and p.id != ?2" + | |||||
| "") | |||||
| 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") | |||||
| fun getLatestCodeNumberBySubProject(code: String, id: Serializable?): Long? | |||||
| } | } | ||||
| @@ -131,11 +131,11 @@ open class ProjectsService( | |||||
| val checkIsClpProject = isClpProject != null && isClpProject | val checkIsClpProject = isClpProject != null && isClpProject | ||||
| val prefix = if (checkIsClpProject) "C" else "M" | val prefix = if (checkIsClpProject) "C" else "M" | ||||
| val latestProjectCode = projectRepository.findFirstByIsClpProjectAndIdIsNotOrderByIdDesc(checkIsClpProject, project.id ?: -1) | |||||
| val latestProjectCode = projectRepository.getLatestCodeNumberByMainProject(checkIsClpProject, project.id ?: -1) | |||||
| if (latestProjectCode != null) { | if (latestProjectCode != null) { | ||||
| val lastFix = latestProjectCode.code!!.split("-")[1] //C-0001 -> 0001 | |||||
| return "$prefix-" + String.format("%04d", lastFix.toLong() + 1L) | |||||
| val lastFix = latestProjectCode | |||||
| return "$prefix-" + String.format("%04d", lastFix + 1L) | |||||
| } else { | } else { | ||||
| return "$prefix-0001" | return "$prefix-0001" | ||||
| } | } | ||||
| @@ -615,20 +615,20 @@ open class ReportService( | |||||
| } | } | ||||
| } | } | ||||
| groupedTimesheets.entries.forEach { (key, value) -> | |||||
| logger.info("key: $key") | |||||
| logger.info("value: " + value.sumOf { it }) | |||||
| } | |||||
| groupedInvoices.entries.forEach { (key, value) -> | |||||
| logger.info("key: $key") | |||||
| logger.info("value: " + value) | |||||
| groupedInvoices[key]!!.forEachIndexed { index, invoice -> | |||||
| logger.info("index: $index") | |||||
| logger.info("invoice: $invoice") | |||||
| invoice.get("paidAmount") | |||||
| } | |||||
| } | |||||
| // groupedTimesheets.entries.forEach { (key, value) -> | |||||
| // logger.info("key: $key") | |||||
| // logger.info("value: " + value.sumOf { it }) | |||||
| // } | |||||
| // | |||||
| // groupedInvoices.entries.forEach { (key, value) -> | |||||
| // logger.info("key: $key") | |||||
| // logger.info("value: " + value) | |||||
| // groupedInvoices[key]!!.forEachIndexed { index, invoice -> | |||||
| // logger.info("index: $index") | |||||
| // logger.info("invoice: $invoice") | |||||
| // invoice.get("paidAmount") | |||||
| // } | |||||
| // } | |||||
| combinedResults.forEach { result: String -> | combinedResults.forEach { result: String -> | ||||
| @@ -703,7 +703,7 @@ open class ReportService( | |||||
| } | } | ||||
| createCell(4).apply { | createCell(4).apply { | ||||
| setCellValue("Monthly Manpower Expenditure") | |||||
| setCellValue("Manpower Expenditure") | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,14 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset cyril:project | |||||
| ALTER TABLE `project` | |||||
| ADD COLUMN `mainProjectId` INT NULL DEFAULT NULL AFTER `isClpProject`, | |||||
| CHANGE COLUMN `status` `status` VARCHAR(40) CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci' NULL DEFAULT 'Pending To Start' , | |||||
| ADD INDEX `FK_PROJECT_ON_MAINPROJECTID` (`mainProjectId` ASC) VISIBLE; | |||||
| ; | |||||
| ALTER TABLE `project` | |||||
| ADD CONSTRAINT `FK_PROJECT_ON_MAINPROJECTID` | |||||
| FOREIGN KEY (`mainProjectId`) | |||||
| REFERENCES `project` (`id`) | |||||
| ON DELETE NO ACTION | |||||
| ON UPDATE NO ACTION; | |||||
| @@ -0,0 +1,9 @@ | |||||
| -- liquibase formatted sql | |||||
| -- changeset cyril:project_category | |||||
| UPDATE project_category | |||||
| SET name='Awarded Project' | |||||
| WHERE id=1; | |||||
| UPDATE project_category | |||||
| SET name='Project to be bidded' | |||||
| WHERE id=2; | |||||