Skip to content

feat: バーコード印刷機能の大幅改善#10

Merged
Atsumi3 merged 9 commits intomasterfrom
feature/barcode-printing-improvements
Sep 23, 2025
Merged

feat: バーコード印刷機能の大幅改善#10
Atsumi3 merged 9 commits intomasterfrom
feature/barcode-printing-improvements

Conversation

@Atsumi3
Copy link
Copy Markdown
Member

@Atsumi3 Atsumi3 commented Sep 23, 2025

Summary

  • 商品選択式のバーコード印刷機能を実装
  • 1商品につき1ページ(44枚)のシール印刷レイアウトに最適化
  • 日本語フォント対応(JARファイルに埋め込み)

主な変更点

新機能

  • ✅ 商品一覧画面にチェックボックスを追加
  • ✅ 選択した商品のみを印刷する新しいAPIエンドポイント
  • ✅ 罫線表示のオン/オフ切り替え機能
  • ✅ 日本語フォントの埋め込みサポート

レイアウト改善

  • ✅ 1商品につき1ページ(44枚)の印刷方式
  • ✅ タイトルや店名を削除し、スペースを最大活用
  • ✅ 商品名を中央配置
  • ✅ バーコード番号を表示
  • ✅ シール用紙の仕様に準拠(4列×11行)

技術的改善

  • ✅ フォントファイルをJARに同梱(※フォントファイル自体はgitignore)
  • ✅ 環境非依存の日本語表示
  • ✅ iText 7を使用したPDF生成の最適化
  • ✅ テストを新仕様に対応

出力サンプル

罫線あり版

  • 切り取り用のガイドラインを表示
  • 4列×11行のグリッドレイアウト
  • 各セルに商品名とバーコードを配置

罫線なし版

  • シンプルな印刷レイアウト
  • 商品情報のみを表示
  • クリーンな仕上がり

※ 実際のPDFサンプルは以下のコマンドで生成できます:

curl -X POST "http://localhost:8080/api/item/barcode-pdf/selected?showBorders=true" \
  -H "Content-Type: application/json" \
  -d '[1,2,3]' \
  -o sample_with_borders.pdf

Test plan

  • 商品選択とチェックボックスの動作確認
  • PDFダウンロードの動作確認
  • 日本語商品名の表示確認
  • 罫線の表示/非表示切り替え確認
  • JARファイル実行時のフォント読み込み確認
  • BarcodeServiceTestが新仕様でパス

CI/CD Status

  • ビルド成功
  • 全テストパス

🤖 Generated with Claude Code

Atsumi3 and others added 4 commits September 24, 2025 00:26
- 商品選択式の印刷機能を追加
- 1商品につき1ページ(44枚)のレイアウトに変更
- 日本語フォント対応(JARファイル内に埋め込み)
- 罫線表示のトグル機能を追加
- レイアウトの最適化(商品名とバーコードのみ表示)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Atsumi3 Atsumi3 self-assigned this Sep 23, 2025
@Atsumi3 Atsumi3 requested a review from Copilot September 23, 2025 15:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a comprehensive barcode printing system improvement for Japanese product labeling. The main purpose is to enable selective barcode printing with optimized layout for sticker sheets (44 labels per page in 4×11 grid format).

Key changes:

  • Product selection interface with checkboxes for choosing specific items to print
  • New API endpoint for generating PDFs of selected products only
  • Enhanced layout optimized for commercial sticker sheets with precise dimensions
  • Japanese font embedding support for proper text rendering in PDFs

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
items/index.html Adds checkbox interface and JavaScript for product selection and PDF generation
fonts/README.md Documentation for Japanese font setup and embedding
V002__add_quantity_to_sale.sql SQL formatting improvement for quantity column addition
BarcodeService.kt Complete rewrite with optimized layout, font handling, and per-product page generation
SettingApiController.kt Removes unused variable assignment
ItemApiController.kt Adds new endpoint for selective barcode PDF generation
barcode_printing_layout_specs.md Comprehensive specification document for printing layouts

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

PdfFontFactory.createFont(fontPath, "Identity-H", PdfFontFactory.EmbeddingStrategy.PREFER_EMBEDDED)
} else {
// フォントが見つからない場合は標準フォントを使用(日本語は表示されません)
println("警告: 日本語フォントが見つかりません。src/main/resources/fonts/にフォントファイルを配置してください。")
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Using println() for logging in production code is not recommended. Consider using a proper logger (such as slf4j) instead of println() to maintain consistent logging practices and enable proper log level management.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +89
} catch (e: Exception) {
e.printStackTrace()
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Using printStackTrace() in production code is not recommended. Consider using a proper logger to record the exception details instead of printing directly to stderr.

Copilot uses AI. Check for mistakes.
.setFont(font)
.setFontSize(10f)
.setTextAlignment(TextAlignment.CENTER)
.setMarginTop(3.0f * 2.835f)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The magic number 2.835f appears multiple times throughout the code. Consider extracting this conversion factor (mm to points) as a named constant to improve code maintainability and reduce the risk of errors.

Copilot uses AI. Check for mistakes.
Atsumi3 and others added 3 commits September 24, 2025 00:44
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- 1商品1ページの仕様に合わせてテストを修正
- 各ページに該当商品のみが含まれることを検証

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Atsumi3
Copy link
Copy Markdown
Member Author

Atsumi3 commented Sep 23, 2025

📸 バーコード印刷機能のスクリーンショット

実装された新しいバーコード印刷機能のPDFサンプルです。

罫線あり版

切り取り用のガイドラインを表示:
barcode_with_borders_preview

罫線なし版

シンプルな印刷レイアウト:
barcode_no_borders_preview

主な機能

  • ✅ 1商品につき1ページ(44枚)の印刷
  • ✅ 日本語商品名の正しい表示(フォント埋め込み)
  • ✅ 罫線表示のオン/オフ切り替え
  • ✅ A4用紙に最適化された4×11グリッドレイアウト
  • ✅ 商品選択による印刷対象の制御

🤖 Generated with Claude Code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Atsumi3
Copy link
Copy Markdown
Member Author

Atsumi3 commented Sep 23, 2025

📸 バーコード印刷機能のスクリーンショット

実装された新しいバーコード印刷機能のPDFサンプルです。

罫線あり版

切り取り用のガイドラインを表示:
barcode_with_borders_preview

罫線なし版

シンプルな印刷レイアウト:
barcode_no_borders_preview

主な機能

  • ✅ 1商品につき1ページ(44枚)の印刷
  • ✅ 日本語商品名の正しい表示(フォント埋め込み)
  • ✅ 罫線表示のオン/オフ切り替え
  • ✅ A4用紙に最適化された4×11グリッドレイアウト
  • ✅ 商品選択による印刷対象の制御

テスト修正

  • ✅ BarcodeServiceTestを新しい仕様(1商品1ページ)に対応
  • ✅ 全テストがパス

🤖 Generated with Claude Code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Atsumi3 Atsumi3 requested a review from Copilot September 23, 2025 16:06
@Atsumi3 Atsumi3 merged commit 0a7918b into master Sep 23, 2025
2 checks passed
@Atsumi3 Atsumi3 deleted the feature/barcode-printing-improvements branch September 23, 2025 16:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/main/kotlin/info/nukoneko/kidspos/server/service/BarcodeService.kt:1

  • Incorrect path mapping: Windows Meiryo font path points to Linux IPA font location. The Linux font check should be on line 74-75, not 71.
package info.nukoneko.kidspos.server.service

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +108 to +114
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(selectedIds)
})
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Missing CSRF token in the fetch request. Spring Security's CSRF protection may block this POST request. Consider adding the CSRF token to the headers or using a form-based approach.

Copilot uses AI. Check for mistakes.
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