Skip to content

Commit

Permalink
Merge pull request #220 from in27sung/order_and_receving
Browse files Browse the repository at this point in the history
order 와 receving 의 테스트 정보전달
  • Loading branch information
freehyeon authored Dec 19, 2024
2 parents 8ddd719 + 3f99346 commit 5aaf140
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 12 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, orderItemId);

// 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
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, int orderItemId) 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, int orderItemId) {
public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo,int orderId, List<OrderItemVO> completedItems) {
try {
// MyBatis 매퍼 호출
rdao.updateReceivingStatusToComplete(businessId, barcode, receivingShipmentNo, orderItemId);
// opService.processInboundAfterInspection(orderId, completedItems);
rdao.updateReceivingStatusToComplete(businessId, barcode, receivingShipmentNo);
opService.processInboundAfterInspection(orderId, completedItems);

} catch (Exception e) {
// 예외 처리
logger.error("입고 상태 업데이트 오류: " + e.getMessage());
Expand Down
8 changes: 7 additions & 1 deletion stockMate/src/main/resources/mappers/OrderMapper.xml
Original file line number Diff line number Diff line change
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>
2 changes: 1 addition & 1 deletion stockMate/src/main/webapp/WEB-INF/views/user/signin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ body {
<body>
<div class="login-container">
<h2>로그인</h2>
<form action="/user/login" method="post">
<form action="/user/signin" method="post">
<input type="email" name="email" placeholder="이메일" required>
<input type="password" name="password" placeholder="비밀번호" required>
<button type="submit">로그인</button>
Expand Down

0 comments on commit 5aaf140

Please sign in to comment.