Skip to content

[FEAT] MRP 실행 시 최소 시작일 추가 및 생산 계획 목록 조회 상태 필터 추가#33

Merged
taemin3 merged 1 commit intomainfrom
SPM-474
Nov 9, 2025
Merged

[FEAT] MRP 실행 시 최소 시작일 추가 및 생산 계획 목록 조회 상태 필터 추가#33
taemin3 merged 1 commit intomainfrom
SPM-474

Conversation

@taemin3
Copy link
Contributor

@taemin3 taemin3 commented Nov 9, 2025

📝 Summary

  • MRP 실행 시 최소 시작일 추가 및 생산 계획 목록 조회 상태 필터 추가

🙏 Question & PR point

📬 Reference

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능
    • 생산 계획 조회 시 상태별 필터링 기능 추가
    • 주문별 최소 시작 날짜 정보 제공
    • 리드타임을 반영한 향상된 지연 판정 로직 적용

@coderabbitai
Copy link

coderabbitai bot commented Nov 9, 2025

요약

부품 주문 API에 상태 기반 필터링을 추가하고, MRP 로직에서 사용할 minimumStartDate 필드를 도입하여 주문 상태 전환 로직을 개선했습니다.

변경 사항

내용 / 파일(들) 요약
컨트롤러 업데이트
src/main/java/com/sampoom/factory/api/part/controller/PartOrderController.java
GET /orders/production-plans 엔드포인트에 선택적 요청 파라미터 statuses (List) 추가. 서비스 호출 시 상태 필터 파라미터 전달.
엔티티 확장
src/main/java/com/sampoom/factory/api/part/entity/PartOrder.java
minimumStartDate 필드(LocalDateTime) 추가, @Column(name = "minimum_start_date") 매핑. updateMinimumStartDate() 공개 메서드 추가.
DTO 업데이트
src/main/java/com/sampoom/factory/api/part/dto/PartOrderResponseDto.java
minimumStartDate 필드(LocalDateTime) 추가, scheduledDate 이후 위치.
서비스 로직 개선
src/main/java/com/sampoom/factory/api/part/service/PartOrderService.java
MRP 로직에서 minimumStartDate 계산(requiredDate - 총 리드타임) 추가. 상태 전환 로직을 minimumStartDate 기반으로 변경(과거인 경우 Delayed/확정 판단, 미래인 경우 자동 확정). getProductionPlans() 시그니처에 statuses 필터 파라미터 추가. 응답 DTO에 minimumStartDate 노출.

시퀀스 다이어그램

sequenceDiagram
    participant Controller as PartOrderController
    participant Service as PartOrderService
    participant Entity as PartOrder
    participant DB as Database

    Controller->>Service: getProductionPlans(factoryId, statuses, priorities, ...)
    Service->>DB: 상태/우선순위로 주문 조회
    DB-->>Service: PartOrder 리스트 반환
    
    loop MRP 로직 처리
        Service->>Service: minimumStartDate 계산<br/>(requiredDate - 총 리드타임)
        Service->>Entity: updateMinimumStartDate(계산된값)
        Entity->>DB: 데이터 업데이트
    end
    
    loop 상태 전환 로직
        alt minimumStartDate이 과거인 경우
            Service->>Service: scheduledDate vs requiredDate 비교
            alt 지연된 경우
                Service->>Entity: 상태 = Delayed
            else 정상인 경우
                Service->>Entity: 상태 = Confirmed
            end
        else minimumStartDate이 미래인 경우
            Service->>Entity: 상태 자동 확정
        end
        Entity->>DB: 상태 업데이트
    end
    
    Service->>Service: 응답 DTO 생성<br/>(minimumStartDate 포함)
    Service-->>Controller: PartOrderResponseDto 리스트 반환
    Controller-->>Client: JSON 응답 반환
Loading

예상 코드 리뷰 난이도

🎯 3 (보통) | ⏱️ ~25분

  • 상세 검토 영역:
    • MRP 로직의 minimumStartDate 계산 정확성 및 리드타임 반영 확인
    • 상태 전환 로직의 조건문 변경(단순 비교 → 두 단계 조건)이 기존 동작과의 호환성 검토
    • 상태 필터 적용 시 기본값 폴백 로직의 명확성 확인
    • 여러 응답 DTO 메서드(toResponseDto, toProductionPlanResponseDto)에서 minimumStartDate 일관성 확인

관련 PR

제안 레이블

ready-to-merge

제안 리뷰어

  • Lee-Jong-Jin
  • Sangyoon98
  • CHOOSLA
  • yangjiseonn
  • vivivim

시 🐰

필터를 더하고 날짜를 계산하고,
최소 시작일로 상태를 결정하네,
MRP의 지혜로 부품 주문 다듬고,
과거와 미래 사이를 헤아려,
지연과 확정의 길을 나누니라! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 주요 내용을 명확하게 요약하고 있습니다. MRP 실행 시 최소 시작일 추가와 생산 계획 목록 조회 상태 필터 추가라는 두 가지 주요 기능이 코드 변경사항과 정확히 일치합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch SPM-474

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@yangjiseonn yangjiseonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인요

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/com/sampoom/factory/api/part/service/PartOrderService.java (1)

221-254: now 값 재사용으로 시간 일관성 확보 제안
scheduledDate 계산 시점과 이후 상태 판단 시점이 서로 다른 LocalDateTime.now() 호출에 의존해 미세한 오차가 생길 수 있습니다. 한 번만 캡처한 now를 재사용하면 계산 기준이 일관돼 디버깅 및 테스트가 조금 더 수월해집니다.

다음과 같이 정리하면 됩니다:

-        LocalDateTime scheduledDate = LocalDateTime.now().plusDays(totalLeadTimeDays);
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime scheduledDate = now.plusDays(totalLeadTimeDays);
         partOrder.updateScheduledDate(scheduledDate);
 
         LocalDateTime minimumStartDate = partOrder.getRequiredDate().minusDays(totalLeadTimeDays);
         partOrder.updateMinimumStartDate(minimumStartDate);
 
         log.info("MRP 계산 완료 - 주문 ID: {}, 총 리드타임: {}일, 예정일: {}, 최소 시작일: {}",
             partOrder.getId(), totalLeadTimeDays, scheduledDate, minimumStartDate);
 
-        LocalDateTime now = LocalDateTime.now();
         if (minimumStartDate.isBefore(now)) {
             ...
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2d3857 and 1d64201.

📒 Files selected for processing (4)
  • src/main/java/com/sampoom/factory/api/part/controller/PartOrderController.java (2 hunks)
  • src/main/java/com/sampoom/factory/api/part/dto/PartOrderResponseDto.java (1 hunks)
  • src/main/java/com/sampoom/factory/api/part/entity/PartOrder.java (2 hunks)
  • src/main/java/com/sampoom/factory/api/part/service/PartOrderService.java (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (3)
src/main/java/com/sampoom/factory/api/part/dto/PartOrderResponseDto.java (1)

24-24: DTO에 최소 시작일 노출 확인
신규 필드 minimumStartDate가 DTO에 자연스럽게 추가되어 서비스에서 계산된 값을 그대로 응답에 실을 수 있게 된 점 확인했습니다. 기존 빌더와의 호환성도 유지되어 문제 없습니다.

src/main/java/com/sampoom/factory/api/part/entity/PartOrder.java (1)

56-96: 엔티티에 최소 시작일 필드 추가 확인
minimum_start_date 컬럼과 갱신 메서드가 엔티티에 잘 반영되어 MRP 계산 결과를 영속화할 수 있는 구조가整備되었습니다.

src/main/java/com/sampoom/factory/api/part/controller/PartOrderController.java (1)

98-107: 상태 필터 파라미터 전달 확인
요청 파라미터 statuses를 추가해 선택적 상태 필터링을 지원하고, 서비스 호출부도 새 시그니처에 맞춰 정렬된 것 확인했습니다.

@taemin3 taemin3 merged commit b8863b3 into main Nov 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants