Skip to content

Commit

Permalink
Update stock/register
Browse files Browse the repository at this point in the history
  • Loading branch information
in27sung committed Dec 16, 2024
1 parent 9154364 commit 86bd1a5
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String registerStockPost(@ModelAttribute StockVO stock,
logger.info("Stock registered successfully: {}", stock);

model.addAttribute("success", "재고 등록이 성공적으로 완료되었습니다.");
return "redirect:/stock/list"; // 재고 목록 페이지로 이동
return "/stock/register";
}

// 재고 목록 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,5 @@ public List<StockVO> selectOnlyStockByBusinessId(int businessId) throws Exceptio
public List<CategoryVO> selectAllCategories() throws Exception {
return sqlSession.selectList(NAMESPACE + "selectAllCategories");
}

@Override
public List<CategoryVO> selectAllCategories() throws Exception {
return sqlSession.selectList(NAMESPACE + "selectAllCategories");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public void generateQRCode(int productId) throws Exception {
// QR 코드 저장 경로 생성
int businessId = product.getBusinessId(); // 상품의 비즈니스 ID
int categoryId = product.getCategoryId(); // 상품의 카테고리 ID
String basePath = "/Users/Insung/Documents/products"; // QR 코드 기본 저장 경로
// String basePath = "/usr/local/tomcat/webapps/upload";
// String basePath = "/Users/Insung/Documents/products"; // QR 코드 기본 저장 경로
String basePath = "/usr/local/tomcat/webapps/upload";

// 디렉토리 경로 생성
String directoryPath = basePath + File.separator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ private String createQRCodePath(ProductVO product) throws Exception {
// QR 코드 저장 경로 생성
int businessId = product.getBusinessId(); // 상품의 비즈니스 ID
int categoryId = product.getCategoryId(); // 상품의 카테고리 ID
String basePath = "/Users/Insung/Documents/products"; // QR 코드 기본 저장 경로
// String basePath = "/usr/local/tomcat/webapps/upload";
// String basePath = "/Users/Insung/Documents/products"; // QR 코드 기본 저장 경로
String basePath = "/usr/local/tomcat/webapps/upload";

// 디렉토리 경로 생성
String directoryPath = basePath + File.separator
Expand Down
54 changes: 26 additions & 28 deletions stockMate/src/main/resources/mappers/stockMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@
<!-- CategoryVO 매핑 (정의된 categoryResultMap을 사용) -->
<association property="category" resultMap="categoryResultMap"/>
</resultMap>

<!-- 재고 등록 (INSERT) -->
<insert id="insertStock" parameterType="com.stockm8.domain.vo.StockVO" useGeneratedKeys="true" keyProperty="stockId">
INSERT INTO stocks (
product_id,
warehouse_id,
business_id,
total_quantity,
reserved_quantity,
description,
is_deleted,
created_at,
updated_at
)
VALUES (
#{productId},
#{warehouseId},
#{businessId},
#{totalQuantity},
0,
#{description},
0,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
)
</insert>

<!-- 필터링된 재고 목록 조회 (정렬 기준 포함) -->
<select id="selectFilteredStocks" resultMap="stockResultMap">
Expand Down Expand Up @@ -99,34 +125,6 @@
</otherwise>
</choose>
</select>

<!-- 재고 등록 (INSERT) -->
<insert id="insertStock" parameterType="com.stockm8.domain.vo.StockVO" useGeneratedKeys="true" keyProperty="stockId">
INSERT INTO stocks (
product_id,
warehouse_id,
business_id,
total_quantity,
reserved_quantity,
available_stock,
description,
is_deleted,
created_at,
updated_at
)
VALUES (
#{productId},
#{warehouseId},
#{businessId},
#{totalQuantity},
#{reservedQuantity},
#{availableStock},
#{description},
0,
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
)
</insert>

<!-- 사업자 ID에 해당하는 재고 목록 조회 -->
<select id="selectStockListByBusinessId" resultMap="stockResultMap">
Expand Down
11 changes: 10 additions & 1 deletion stockMate/src/main/webapp/WEB-INF/views/qrScanner.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,20 @@ th, td {
toggleScannerBtn.textContent = "웹캠 시작";
}).catch(err => console.error("스캐너 종료 오류:", err));
}
let lastScannedTime = 0; // 마지막 스캔 시간 저장
// **스캔 성공 시 호출**
function onScanSuccess(decodedText) {
if (isScanning) return; // 중복 방지
const currentTime = new Date().getTime(); // 현재 시간 (밀리초)
if (isScanning || currentTime - lastScannedTime < 1000) {
// 1초 내에 같은 QR 코드 중복 스캔 방지
return;
}
isScanning = true;
lastScannedTime = currentTime; // 마지막 스캔 시간 업데이트
beepSound.play();
console.log("Scanned Text:", decodedText); // 디버깅 로그 추가
Expand Down
5 changes: 3 additions & 2 deletions stockMate/src/main/webapp/WEB-INF/views/stock/register.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<body>
<div class="container">
<button class="dashboard-btn" onclick="location.href='/dashboard';">대시보드로 돌아가기</button>
<button class="dashboard-btn" onclick="location.href='/stock/list';">재고 리스트</button>
<h1>재고 등록</h1>
<form id="stockForm" method="post" action="/stock/register">
<!-- 창고 선택 -->
Expand All @@ -33,8 +34,8 @@

<!-- 수량 입력 -->
<div class="form-group">
<label for="quantity">초기 수량</label>
<input type="number" id="quantity" name="quantity" min="1" required>
<label for="totalQuantity">초기 수량</label>
<input type="number" id="totalQuantity" name="totalQuantity" min="1" required>
</div>

<!-- 재고 설명 입력 -->
Expand Down

0 comments on commit 86bd1a5

Please sign in to comment.