Skip to content

fix: 0319 통합 테스트 이후 개선 사항 반영#254

Merged
ehdghksahd merged 3 commits into
mainfrom
서동환
Mar 19, 2026

Hidden character warning

The head ref may contain hidden characters: "\uc11c\ub3d9\ud658"
Merged

fix: 0319 통합 테스트 이후 개선 사항 반영#254
ehdghksahd merged 3 commits into
mainfrom
서동환

Conversation

@ehdghksahd

Copy link
Copy Markdown
Collaborator

작업 내용

재고 이력: 날짜 필터링 안 되는 문제 수정
재고 조정: 조정(+) / 조정(-) 분리
재고 조정: 조정했는데 조정 이력으로 안 들어가는 문제 수정
재고 부족 순위 데이터 이상 수정
임계치 이하인데 재고 부족으로 카운트되지 않는 문제 수정
재고 ES 동기화 확인 및 수정
재고 분석: 총 보유 배치(가용 가능) 숫자 불일치 수정
대시보드 주문: 이모티콘 변경 또는 제거
대시보드: 부족 재고 데이터 이상 확인 및 수정
폐기 관리: 정렬/필터(금액 큰 순, 최신순, 사유별 등) 검토 및 반영

# Conflicts:
#	src/main/java/kr/inventory/ai/stock/service/StockShortageAiQueryService.java
#	src/main/java/kr/inventory/ai/stock/tool/dto/response/StockShortageSummaryItemToolResponse.java
#	src/main/java/kr/inventory/domain/analytics/document/stock/StockShortageDocument.java
#	src/main/java/kr/inventory/domain/stock/service/StockInboundService.java
@ehdghksahd ehdghksahd merged commit 657676a into main Mar 19, 2026
1 check failed
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 0319 통합 테스트 이후 발견된 여러 재고 관리 시스템의 개선 사항을 반영합니다. 주요 목적은 재고 데이터의 정확성과 일관성을 높이고, 사용자 경험을 개선하는 것입니다. 특히, 재고 이력 조회 필터링 기능을 확장하고, 폐기 기록에 대한 정렬 옵션을 추가하며, 재고 변경 사항이 Elasticsearch에 실시간으로 동기화되도록 하여 분석 데이터의 신뢰도를 향상시키는 데 중점을 두었습니다. 또한, 재고 부족 및 조정 관련 데이터 이상을 수정하여 시스템의 전반적인 안정성을 강화했습니다.

Highlights

  • 재고 이력 필터링 개선: 재고 이력 검색 시 날짜 필터링 외에 참조 유형(ReferenceType) 및 거래 유형(TransactionType)별로 필터링할 수 있는 기능이 추가되었습니다.
  • 폐기 관리 정렬 기능 추가: 폐기 기록 조회 시 폐기 날짜(wasteDate) 및 폐기 금액(amount)을 기준으로 동적으로 정렬할 수 있는 기능이 구현되었습니다.
  • Elasticsearch 동기화 강화: 재고 입고, 출고, 실사 조정 및 폐기 처리와 같은 주요 재고 변경 작업 시, 관련 재고 배치(IngredientStockBatch) 문서가 비동기적으로 Elasticsearch에 인덱싱되도록 하여 데이터 일관성을 높였습니다. 인덱싱 실패 시 에러 로깅도 추가되었습니다.
  • 재고 부족 및 임계치 관련 데이터 이상 수정: 통합 테스트 이후 발견된 재고 부족 순위 데이터 이상 및 임계치 이하 재고가 부족으로 카운트되지 않는 문제 등 재고 분석 관련 여러 데이터 이상이 수정되었습니다.
  • 재고 조정 이력 누락 문제 수정: 재고 조정 작업이 조정 이력으로 제대로 기록되지 않던 문제가 수정되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

통합 테스트 이후 발견된 여러 개선 사항들이 잘 반영되었습니다. 특히 재고 로그 검색 기능이 ReferenceType 필터링을 통해 향상되었고, 폐기 기록에 대한 동적 정렬 기능이 추가되어 데이터 활용도가 높아졌습니다. 가장 중요한 변경 사항은 StockBatchIndexingService를 통한 Elasticsearch 동기화 로직의 일관된 적용입니다. 재고 수량 변경이 발생하는 모든 서비스(입고, 출고, 실사, 폐기)에서 Elasticsearch 업데이트가 보장되며, StockBatchIndexingService 자체에 비동기 처리와 견고한 예외 처리가 추가되어 시스템의 안정성과 데이터 일관성이 크게 개선되었습니다.

Comment on lines +18 to +29
@Async
public void index(IngredientStockBatch batch) {
IngredientStockBatchDocument doc = IngredientStockBatchDocument.from(batch,
batch.getIngredient().getLowStockThreshold());
stockBatchSearchRepository.save(doc);
log.debug("[ES] 재고 배치 인덱싱 완료 batchId={}", batch.getBatchId());
try {
IngredientStockBatchDocument doc = IngredientStockBatchDocument.from(batch,
batch.getIngredient().getLowStockThreshold());

stockBatchSearchRepository.save(doc);
log.debug("[ES] 재고 배치 인덱싱 완료 batchId={}", batch.getBatchId());
} catch (Exception e) {
log.error("[ES] 재고 배치 인덱싱 실패 batchId={}", batch.getBatchId(), e);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

StockBatchIndexingService의 index 메서드에 @Async 어노테이션을 추가하여 비동기 처리를 도입하고, 내부적으로 try-catch 블록을 통해 예외를 처리하도록 변경한 점은 매우 좋습니다. 이는 메인 스레드의 블로킹을 방지하여 애플리케이션의 응답성을 높이고, Elasticsearch 인덱싱 실패 시에도 전체 시스템에 영향을 주지 않도록 견고성을 확보합니다. 특히 예외 발생 시 상세한 로그를 남기는 것은 문제 발생 시 디버깅에 큰 도움이 됩니다. 이는 Repository Style Guide의 '에러 처리/경계값: 실패 케이스가 명확하고 일관적인가' (14행) 원칙에 부합합니다.

Comment on lines +73 to 78
private BooleanExpression referenceTypeEq(ReferenceType type) {
return type != null ? stockLog.referenceType.eq(type) : null;
}

private BooleanExpression TransactionTypeEq(TransactionType type) {
return type != null ? stockLog.transactionType.eq(type) : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

기존 typeEq 메서드를 TransactionTypeEq로 이름을 변경하고, referenceTypeEq 메서드를 새로 추가하여 StockLogSearchRequest의 변경된 필드에 맞춰 쿼리 조건을 구성한 점은 명확성과 가독성을 높이는 좋은 변경입니다. 이는 Repository Style Guide의 '명확성(가독성): 이름/구조/흐름이 한 번에 이해되는가' (11행) 원칙을 잘 따르고 있습니다.

Comment on lines +67 to +91
private OrderSpecifier<?>[] getAllOrderSpecifiers(Pageable pageable) {
List<OrderSpecifier<?>> orders = new ArrayList<>();

if (!pageable.getSort().isEmpty()) {
for (Sort.Order sortOrder : pageable.getSort()) {
Order direction = sortOrder.getDirection().isAscending() ? Order.ASC : Order.DESC;

switch (sortOrder.getProperty()) {
case "wasteDate":
orders.add(new OrderSpecifier<>(direction, wasteRecord.wasteDate));
break;
case "amount":
orders.add(new OrderSpecifier<>(direction, wasteRecord.wasteAmount));
break;
default:
orders.add(new OrderSpecifier<>(Order.DESC, wasteRecord.wasteDate));
break;
}
}
} else {
orders.add(new OrderSpecifier<>(Order.DESC, wasteRecord.wasteDate));
}

return orders.toArray(new OrderSpecifier[0]);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

getAllOrderSpecifiers 메서드를 추가하여 Pageable 객체의 정렬 정보를 기반으로 동적으로 OrderSpecifier 배열을 생성하도록 구현한 점은 폐기 기록 조회 기능의 유연성을 크게 향상시킵니다. wasteDateamount에 대한 정렬을 지원하고, 기본 정렬을 wasteDate.desc()로 설정한 것도 합리적입니다. 이는 Repository Style Guide의 '가독성 / 유지보수성 / 변경 용이성' (3행) 목표에 기여합니다.

Comment on lines 446 to +448
ingredientStockBatchRepository.save(adjustmentBatch);

try {
stockBatchIndexingService.index(adjustmentBatch);
} catch (Exception e) {
log.error("[ES] 입고 인덱싱 실패 batchId={}", adjustmentBatch.getBatchId(), e);
}
stockBatchIndexingService.index(adjustmentBatch);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

StockBatchIndexingService의 index 메서드에 이미 예외 처리가 포함되어 있으므로, createAdjustmentBatch 메서드에서 중복된 try-catch 블록을 제거한 것은 좋은 리팩터링입니다. 이는 코드의 중복을 줄이고, 예외 처리 로직을 한 곳으로 집중시켜 유지보수성을 높입니다. 이는 Repository Style Guide의 '동일한 패턴(검증/변환/로깅/예외)은 공통화한다' (35행) 원칙에 부합합니다.

Suggested change
ingredientStockBatchRepository.save(adjustmentBatch);
try {
stockBatchIndexingService.index(adjustmentBatch);
} catch (Exception e) {
log.error("[ES] 입고 인덱싱 실패 batchId={}", adjustmentBatch.getBatchId(), e);
}
stockBatchIndexingService.index(adjustmentBatch);
stockBatchIndexingService.index(adjustmentBatch);

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.

1 participant