Skip to content

Commit

Permalink
Update manager
Browse files Browse the repository at this point in the history
  • Loading branch information
in27sung committed Dec 19, 2024
2 parents f75bbb7 + 5aaf140 commit 9b7aab4
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stockm8.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -20,6 +21,7 @@
import org.springframework.web.bind.annotation.ResponseBody;

import com.stockm8.domain.vo.Criteria;
import com.stockm8.domain.vo.OrderItemVO;
import com.stockm8.domain.vo.OrderVO;
import com.stockm8.domain.vo.PageVO;
import com.stockm8.domain.vo.ProductVO;
Expand All @@ -30,6 +32,7 @@
import com.stockm8.service.OrderService;
import com.stockm8.service.ReceivingService;
import com.stockm8.service.UserService;
import com.stockm8.domain.vo.OrderItemVO;

@Controller
@RequestMapping(value = "/receiving/*")
Expand All @@ -43,6 +46,9 @@ public class ReceivingController {
@Inject
private UserService uService;

@Inject
private OrderService orderService;

// http://localhost:8088/receiving/main
@RequestMapping(value = "/main", method = RequestMethod.GET)
public void mainGET(Model model, HttpServletRequest request) throws Exception {
Expand Down Expand Up @@ -249,7 +255,6 @@ public Map<String, Object> scanPOST(@RequestBody Map<String, Object> payload,
model.addAttribute("receivingShipmentNo", receivingShipmentNo);
model.addAttribute("orderItemId", orderItemId);


Map<String, Object> response = new HashMap<>();
if (userId == null) {
response.put("success", false);
Expand All @@ -258,7 +263,20 @@ public Map<String, Object> scanPOST(@RequestBody Map<String, Object> payload,
}

try {
rService.ReceivingStatusToComplete(businessId, barcode, receivingShipmentNo);

// OrderItemVO 리스트 생성
List<OrderItemVO> completedItems = new ArrayList<>();
OrderItemVO item = new OrderItemVO();
item.setOrderItemId(orderItemId);
completedItems.add(item);

// OrderService를 통해 orderId 가져오기
// OrderService에 해당 메소드 추가 필요
int orderId = orderService.getOrderIdByOrderItemId(orderItemId);

rService.ReceivingStatusToComplete(businessId, barcode, receivingShipmentNo, orderId, completedItems);


int remainingStock = rService.increseStockByBarcode(businessId, barcode, receivingShipmentNo, orderItemId);
int reservedQuantity = rService.decreaseReservedQuantity(businessId, barcode, receivingShipmentNo, orderItemId);
ProductVO product = rService.productNameBarcode(businessId, barcode, receivingShipmentNo);
Expand Down
2 changes: 2 additions & 0 deletions stockMate/src/main/java/com/stockm8/persistence/OrderDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public interface OrderDAO {
// 전체 주문 개수 조회 (페이징 계산)
public int getTotalOrderCount(int businessId);

// 오더아이디
public int getOrderIdByOrderItemId(Integer orderItemId) throws Exception;


} // OrderDAO
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ public List<OrderItemVO> getOrderItemsByOrderId(int orderId) throws Exception {
public int getTotalOrderCount(int businessId) {
return sqlSession.selectOne(NAMESPACE + "getTotalOrderCount", businessId); }


@Override
public int getOrderIdByOrderItemId(Integer orderItemId) throws Exception {
return sqlSession.selectOne(NAMESPACE + "getOrderIdByOrderItemId", orderItemId);
}


} // OrderImpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface ReceivingDAO {
public ProductVO selectProductNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception;

// 수량 없을시 완료상태로 변경
public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception;
public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo, int orderItemId) throws Exception;

// 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기
public List<ReceivingShipmentVO> selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int orderItemId) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ public ProductVO selectProductNameBarcode(int businessId, String barcode, Intege
}

@Override
public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception {
public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo, int orderItemId) throws Exception {
logger.info("updateReceivingStatusToComplete() 호출");
Map<String, Object> params = new HashMap<>();
params.put("businessId", businessId);
params.put("barcode", barcode);
params.put("receivingShipmentNo", receivingShipmentNo);
params.put("orderItemId", orderItemId);
sqlSession.update(NAMESPACE + "updateReceivingStatusToComplete", params);

}
Expand Down
3 changes: 3 additions & 0 deletions stockMate/src/main/java/com/stockm8/service/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ public interface OrderService {
// 전체 주문 개수 조회 (페이징 계산)
public int getTotalOrderCount(int businessId);

// 오더 아이디 가져가는 메소드

public int getOrderIdByOrderItemId(Integer orderItemId) throws Exception;

} //OrderService
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ public int getTotalOrderCount(int businessId) {
}



@Override
public int getOrderIdByOrderItemId(Integer orderItemId) throws Exception {
return odao.getOrderIdByOrderItemId(orderItemId);
}


} //OrderServiceImpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ public interface ReceivingService {
public ProductVO productNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception;

// 수량 없을시 완료상태로 변경
public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception;

public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo,int orderId, List<OrderItemVO> completedItems) throws Exception;




// 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기
public List<ReceivingShipmentVO> getReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int rderItemId) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class ReceivingServiceImpl implements ReceivingService {
@Inject
private ReceivingDAO rdao;

// @Inject
// private OrderProcessor opService;
@Inject
private OrderProcessor opService;


// 메인 입고 리스트
Expand Down Expand Up @@ -122,11 +122,12 @@ public ProductVO productNameBarcode(int businessId, String barcode, Integer rece
}

@Override
public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) {
public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo,int orderId, List<OrderItemVO> completedItems) {
try {
// MyBatis 매퍼 호출
rdao.updateReceivingStatusToComplete(businessId, barcode, receivingShipmentNo);
// opService.processInboundAfterInspection(orderId, completedItems);
opService.processInboundAfterInspection(orderId, completedItems);

} catch (Exception e) {
// 예외 처리
logger.error("입고 상태 업데이트 오류: " + e.getMessage());
Expand Down
10 changes: 8 additions & 2 deletions stockMate/src/main/resources/mappers/OrderMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
#{productId},
#{warehouseId},
#{quantity},
#{quantity}
#{quantity},
#{unitPrice},
#{remarks},
NOW()
Expand Down Expand Up @@ -231,5 +231,11 @@
JOIN users u ON o.created_by = u.user_id
WHERE u.business_id = #{businessId}
</select>



<select id="getOrderIdByOrderItemId" parameterType="int" resultType="int">
SELECT order_id
FROM order_items
WHERE order_item_id = #{orderItemId}
</select>
</mapper>
6 changes: 4 additions & 2 deletions stockMate/src/main/resources/mappers/receivingMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ WHERE r.transaction_type = 'INBOUND'
JOIN stocks s on o.product_id = s.product_id
JOIN receiving_shipment r on r.stock_id = s.stock_id AND r.order_item_id = o.order_item_id
SET s.total_quantity = s.total_quantity + 1,
s.reserved_quantity = s.reserved_quantity -1,
o.change_quantity = o.change_quantity -1
WHERE p.product_barcode = #{barcode}
AND s.business_id = #{businessId}
Expand Down Expand Up @@ -288,12 +287,15 @@ AND r.order_item_id = #{orderItemId}
JOIN products p ON r.product_id = p.product_id
JOIN stocks s ON s.product_id = p.product_id
JOIN order_items o ON s.product_id = o.product_id
SET r.status = 'COMPLETED'
SET r.status = 'COMPLETED',
s.reserved_quantity = s.reserved_quantity - o.quantity
WHERE p.product_barcode = #{barcode}
AND o.change_quantity = 0
AND r.status = 'PENDING'
AND s.business_id = #{businessId}
AND r.receiving_shipment_no = #{receivingShipmentNo}
AND r.order_item_id = #{orderItemId}
AND o.order_item_id = r.order_item_id;
</update>
<!-- receiving scan을 위한 매퍼 -->

Expand Down
2 changes: 2 additions & 0 deletions stockMate/src/main/webapp/WEB-INF/views/user/signin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ body {
<body>
<div class="login-container">
<h2>로그인</h2>

<%-- 에러 메시지 표시 --%>
<c:if test="${not empty errorMessage}">
<div class="error-banner">${errorMessage}</div>
Expand All @@ -104,6 +105,7 @@ body {
<c:if test="${not empty successMessage}">
<div class="success-banner">${successMessage}</div>
</c:if>

<form action="/user/signin" method="post">
<input type="email" name="email" placeholder="이메일" required>
<input type="password" name="password" placeholder="비밀번호" required>
Expand Down

0 comments on commit 9b7aab4

Please sign in to comment.