diff --git a/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java b/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java index be15d446..9f0663e8 100644 --- a/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java +++ b/src/main/java/com/kamco/cd/kamcoback/label/dto/LabelAllocateDto.java @@ -322,17 +322,40 @@ public class LabelAllocateDto { @AllArgsConstructor public static class WorkHistoryDto { + @Schema(description = "행 번호") private Integer rowNum; + + @Schema(description = "변화탐지년도", example = "2021-2022") private String changeDetectionYear; + + @Schema(description = "국유IN 회차") private Long stage; + + @Schema(description = "반영일") private ZonedDateTime gukyuinApplyDttm; + + @Schema(description = "할당건수") private Long assignedCnt; + + @Schema(description = "완료건수") private Long completeCnt; + + @Schema(description = "Skip건수") private Long skipCnt; + + @Schema(description = "잔여건수") private Long remainCnt; - // private String status; + + @Schema(description = "상태 (진행중/완료)") + private String status; + + @Schema(description = "진행률 (%)") private Double percent; + + @Schema(description = "작업기간 시작일") private ZonedDateTime createdDttm; + + @Schema(description = "작업기간 종료일") private ZonedDateTime projectCloseDttm; } } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java index 685a8217..358e9f4f 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/label/LabelAllocateRepositoryImpl.java @@ -1515,12 +1515,20 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto mapSheetAnalInferenceEntity.createdDttm, mapSheetAnalInferenceEntity.inspectionClosedYn, mapSheetAnalInferenceEntity.updatedDttm) - .orderBy(mapSheetAnalInferenceEntity.id.desc()) + .orderBy( + // 진행중인 작업이 최상단 (remainCnt > 0) + new CaseBuilder() + .when(totalCnt.subtract(completeCnt).subtract(skipCnt).gt(0L)) + .then(0) + .otherwise(1) + .asc(), + // 최신 작업순 (반영일 기준) + mapSheetAnalInferenceEntity.gukyuinApplyDttm.desc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) .fetch(); - // rowNum과 remainCnt, percent를 Java에서 계산 + // rowNum, remainCnt, percent, status를 Java에서 계산 int startRow = (int) pageable.getOffset() + 1; for (int i = 0; i < list.size(); i++) { WorkHistoryDto dto = list.get(i); @@ -1538,6 +1546,13 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto } else { dto.setPercent(0.0); } + + // status 계산 (잔여건수가 0이고 진행률이 100%면 "완료", 아니면 "진행중") + if (dto.getRemainCnt() == 0 && dto.getPercent() >= 100.0) { + dto.setStatus("완료"); + } else { + dto.setStatus("진행중"); + } } Long countQuery = @@ -1606,12 +1621,20 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto mapSheetAnalInferenceEntity.createdDttm, mapSheetAnalInferenceEntity.inspectionClosedYn, mapSheetAnalInferenceEntity.updatedDttm) - .orderBy(mapSheetAnalInferenceEntity.id.desc()) + .orderBy( + // 진행중인 작업이 최상단 (remainCnt > 0) + new CaseBuilder() + .when(totalCnt.subtract(completeCnt).subtract(skipCnt).gt(0L)) + .then(0) + .otherwise(1) + .asc(), + // 최신 작업순 (반영일 기준) + mapSheetAnalInferenceEntity.gukyuinApplyDttm.desc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) .fetch(); - // rowNum과 remainCnt, percent를 Java에서 계산 + // rowNum, remainCnt, percent, status를 Java에서 계산 int startRow = (int) pageable.getOffset() + 1; for (int i = 0; i < list.size(); i++) { WorkHistoryDto dto = list.get(i); @@ -1629,6 +1652,13 @@ public class LabelAllocateRepositoryImpl implements LabelAllocateRepositoryCusto } else { dto.setPercent(0.0); } + + // status 계산 (잔여건수가 0이고 진행률이 100%면 "완료", 아니면 "진행중") + if (dto.getRemainCnt() == 0 && dto.getPercent() >= 100.0) { + dto.setStatus("완료"); + } else { + dto.setStatus("진행중"); + } } Long countQuery =