From 212256171d042ffa9a2461a3f2c6cd7dc258fb60 Mon Sep 17 00:00:00 2001 From: shoqying Date: Thu, 19 Dec 2024 13:59:19 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=85=EA=B3=A0=20=EB=B0=94=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReceivingController.java | 81 ++++---- .../controller/ShipmentController.java | 9 +- .../com/stockm8/domain/vo/OrderItemVO.java | 1 + .../com/stockm8/persistence/ReceivingDAO.java | 14 +- .../stockm8/persistence/ReceivingDAOImpl.java | 26 ++- .../com/stockm8/persistence/ShipmentDAO.java | 3 + .../stockm8/persistence/ShipmentDAOImpl.java | 11 +- .../com/stockm8/service/ReceivingService.java | 13 +- .../stockm8/service/ReceivingServiceImpl.java | 61 +++--- .../com/stockm8/service/ShipmentService.java | 7 +- .../stockm8/service/ShipmentServiceImpl.java | 6 + .../main/resources/mappers/OrderMapper.xml | 3 + .../resources/mappers/receivingMapper.xml | 53 ++++-- .../main/resources/mappers/shipmentMapper.xml | 24 ++- .../WEB-INF/views/receiving/history.jsp | 5 +- .../webapp/WEB-INF/views/receiving/main.jsp | 1 - .../webapp/WEB-INF/views/receiving/scan.jsp | 20 +- .../webapp/WEB-INF/views/receiving/search.jsp | 1 - .../webapp/WEB-INF/views/shipment/history.jsp | 7 +- .../webapp/WEB-INF/views/shipment/main.jsp | 1 - .../webapp/WEB-INF/views/shipment/scan.jsp | 176 ++++++------------ .../webapp/WEB-INF/views/shipment/search.jsp | 1 - 22 files changed, 291 insertions(+), 233 deletions(-) diff --git a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java index 082d0a1..041e586 100644 --- a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java +++ b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java @@ -11,6 +11,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -19,11 +20,14 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.stockm8.domain.vo.Criteria; +import com.stockm8.domain.vo.OrderVO; import com.stockm8.domain.vo.PageVO; import com.stockm8.domain.vo.ProductVO; import com.stockm8.domain.vo.ReceivingShipmentVO; import com.stockm8.domain.vo.StockVO; import com.stockm8.domain.vo.UserVO; +import com.stockm8.service.OrderProcessor; +import com.stockm8.service.OrderService; import com.stockm8.service.ReceivingService; import com.stockm8.service.UserService; @@ -205,7 +209,8 @@ public String insert3POST(HttpServletRequest request) throws Exception { // http://localhost:8088/receiving/scan @RequestMapping(value = "/scan", method = RequestMethod.GET) public void scanGET(HttpServletRequest request, Model model, - @RequestParam(value = "receivingShipmentNo", required = false) Integer receivingShipmentNo) throws Exception { + @RequestParam(value = "receivingShipmentNo", required = false) Integer receivingShipmentNo, + @RequestParam(value = "orderItemId", required = false) Integer orderItemId) throws Exception { logger.info("scanGET() 호출"); // 세션에서 userId 가져오기 @@ -216,57 +221,65 @@ public void scanGET(HttpServletRequest request, Model model, UserVO user = uService.getUserById(userId); int businessId = user.getBusinessId(); - List rsn = rService.getReceivingShipmentNo(businessId, receivingShipmentNo); + List rsn = rService.getReceivingShipmentNo(businessId, receivingShipmentNo, orderItemId); model.addAttribute("rsn", rsn); + model.addAttribute("receivingShipmentNo", receivingShipmentNo); + model.addAttribute("orderItemId", orderItemId); } - // http://localhost:8088/receiving/scan @RequestMapping(value = "/scan", method = RequestMethod.POST) @ResponseBody - public Map scanPOST(@RequestBody Map bar, Model model, - HttpServletRequest request) throws Exception { - logger.info("scanPOST() 호출"); - - // 세션에서 userId 가져오기 + public Map scanPOST(@RequestBody Map payload, + Model model, HttpServletRequest request) throws Exception { + logger.info("scanPOST() 호출"); + + // 세션에서 userId 가져오기 HttpSession session = request.getSession(false); Long userId = (session != null) ? (Long)session.getAttribute("userId") : null; - + // userId로 사용자 정보 조회 UserVO user = uService.getUserById(userId); int businessId = user.getBusinessId(); + + // JSON 본문에서 값 추출 + String barcode = (String) payload.get("barcode"); + Integer receivingShipmentNo = (Integer) payload.get("receivingShipmentNo"); + Integer orderItemId = (Integer) payload.get("orderItemId"); + model.addAttribute("receivingShipmentNo", receivingShipmentNo); + model.addAttribute("orderItemId", orderItemId); - // QR 코드 데이터 처리 로직 (예: 데이터 저장, 검증 등) - String barcode = bar.get("barcode"); - Map response = new HashMap(); - + + Map response = new HashMap<>(); if (userId == null) { response.put("success", false); response.put("message", "로그인 정보가 없습니다."); return response; } - + try { - rService.ReceivingStatusToComplete(businessId, barcode); - int remainingStock = rService.increseStockByBarcode(businessId, barcode); - int reservedQuantity = rService.decreaseReservedQuantity(businessId, barcode); - ProductVO product = rService.productNameBarcode(businessId, barcode); - if (remainingStock >= 0) { - response.put("success", true); - response.put("remainingStock", remainingStock); - response.put("reservedQuantity", reservedQuantity); - response.put("productName", product.getProductName()); - response.put("productPrice", product.getProductPrice()); - } else { - response.put("success", false); - response.put("message", "유효하지 않은 바코드입니다."); - } - } catch (Exception e) { - response.put("success", false); - response.put("message", e.getMessage()); - } - return response; - } + rService.ReceivingStatusToComplete(businessId, barcode, receivingShipmentNo); + int remainingStock = rService.increseStockByBarcode(businessId, barcode, receivingShipmentNo, orderItemId); + int reservedQuantity = rService.decreaseReservedQuantity(businessId, barcode, receivingShipmentNo, orderItemId); + ProductVO product = rService.productNameBarcode(businessId, barcode, receivingShipmentNo); + + if (reservedQuantity >= 0) { + response.put("success", true); + response.put("remainingStock", remainingStock); + response.put("reservedQuantity", reservedQuantity); + response.put("productName", product.getProductName()); + response.put("productPrice", product.getProductPrice()); + } else { + response.put("success", false); + response.put("message", "유효하지 않은 바코드입니다."); + } + } catch (Exception e) { + response.put("success", false); + response.put("message", e.getMessage()); + logger.info("예외 발생" + e); + } + return response; + } // http://localhost:8088/receiving/allScan @RequestMapping(value = "/allScan", method = RequestMethod.GET) diff --git a/stockMate/src/main/java/com/stockm8/controller/ShipmentController.java b/stockMate/src/main/java/com/stockm8/controller/ShipmentController.java index abc98ba..083b9fd 100644 --- a/stockMate/src/main/java/com/stockm8/controller/ShipmentController.java +++ b/stockMate/src/main/java/com/stockm8/controller/ShipmentController.java @@ -39,7 +39,7 @@ public class ShipmentController { @Inject private UserService uService; - + // http://localhost:8088/shipment/main @RequestMapping(value = "/main", method = RequestMethod.GET) public void mainGET(Model model, HttpServletRequest request) throws Exception { @@ -205,7 +205,8 @@ public String insert3POST(HttpServletRequest request) throws Exception { // http://localhost:8088/shipment/scan @RequestMapping(value = "/scan", method = RequestMethod.GET) - public String scanGET(HttpServletRequest request) throws Exception { + public void scanGET(HttpServletRequest request, Model model, + @RequestParam(value = "receivingShipmentNo", required = false) Integer receivingShipmentNo) throws Exception { logger.info("scanGET() 호출"); // 세션에서 userId 가져오기 @@ -216,7 +217,9 @@ public String scanGET(HttpServletRequest request) throws Exception { UserVO user = uService.getUserById(userId); int businessId = user.getBusinessId(); - return "/shipment/scan"; + List rsn = sService.getReceivingShipmentNo(businessId, receivingShipmentNo); + + model.addAttribute("rsn", rsn); } // http://localhost:8088/shipment/scan diff --git a/stockMate/src/main/java/com/stockm8/domain/vo/OrderItemVO.java b/stockMate/src/main/java/com/stockm8/domain/vo/OrderItemVO.java index 8973046..a2882dc 100644 --- a/stockMate/src/main/java/com/stockm8/domain/vo/OrderItemVO.java +++ b/stockMate/src/main/java/com/stockm8/domain/vo/OrderItemVO.java @@ -11,6 +11,7 @@ public class OrderItemVO { private int productId; // 주문 상품 ID private int warehouseId; // 창고 ID private int quantity; // 주문 수량 + private int changeQuantity; // 바뀐 주문 수량 private double unitPrice; // 제품 단가 private String remarks; // 특정 상품에 대한 비고 사항 private double stotalPrice; // 주문 1건의 전체 총 금액 diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java index b84c731..dfe9788 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java @@ -34,24 +34,24 @@ public interface ReceivingDAO { public void insertReceiving(int businessId) throws Exception; // 바코드로 재고 조회 - public List selectQuantityCheckByBarcode(int businessId, String barcode) throws Exception; + public List selectQuantityCheckByBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; // 바코드로 재고 감소 - public int updateIncreseStock(int businessId, String barcode) throws Exception; + public int updateIncreseStock(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception; // 바코드로 재고 감소 실시간 조회 - public int selectStockByBarcode(int businessId, String barcode) throws Exception; + public int selectStockByBarcode(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemIdS) throws Exception; // 바코드 찍은 후 발주 수량 감소 - public int selectReservedQuantity(int businessId, String barcode) throws Exception; + public int selectReservedQuantity(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception; // 바코드 찍은 후 제품 이름 추출 - public ProductVO selectProductNameBarcode(int businessId, String barcode) throws Exception; + public ProductVO selectProductNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; // 수량 없을시 완료상태로 변경 - public void updateReceivingStatusToComplete(int businessId, String barcode) throws Exception; + public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; // 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기 - public List selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception; + public List selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int orderItemId) throws Exception; } // ReceivingDAO end \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java index e64b700..72d8215 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java @@ -103,70 +103,82 @@ public void insertReceiving(int businessId) throws Exception { } @Override - public List selectQuantityCheckByBarcode(int businessId, String barcode) throws Exception { + public List selectQuantityCheckByBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception { logger.info("selectReceiving() 호출"); Map paramMap = new HashMap(); paramMap.put("businessId", businessId); paramMap.put("barcode", barcode); + paramMap.put("receivingShipmentNo", receivingShipmentNo); return sqlSession.selectList(NAMESPACE + "selectQuantityCheckByBarcode", paramMap); } @Override - public int updateIncreseStock(int businessId, String barcode) throws Exception { + public int updateIncreseStock(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception { logger.info("updateDecreaseStock() 호출"); // 매개변수 묶기 Map params = new HashMap<>(); params.put("businessId", businessId); params.put("barcode", barcode); + params.put("receivingShipmentNo", receivingShipmentNo); + params.put("orderItemId", orderItemId); + // SQL 실행 return sqlSession.update(NAMESPACE + "updateIncreseStock", params); } @Override - public int selectStockByBarcode(int businessId, String barcode) throws Exception { + public int selectStockByBarcode(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception { logger.info("selectStockByBarcode() 호출"); Map params = new HashMap<>(); params.put("businessId", businessId); params.put("barcode", barcode); + params.put("receivingShipmentNo", receivingShipmentNo); + params.put("orderItemId", orderItemId); return sqlSession.selectOne(NAMESPACE + "selectStockByBarcode", params); } @Override - public int selectReservedQuantity(int businessId, String barcode) throws Exception { + public int selectReservedQuantity(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception { logger.info("selectReservedQuantity() 호출"); Map params = new HashMap<>(); params.put("businessId", businessId); params.put("barcode", barcode); + params.put("receivingShipmentNo", receivingShipmentNo); + params.put("orderItemId", orderItemId); return sqlSession.selectOne(NAMESPACE + "selectReservedQuantity", params); } @Override - public ProductVO selectProductNameBarcode(int businessId, String barcode) throws Exception { + public ProductVO selectProductNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception { logger.info("selectProductNameBarcode() 호출"); Map params = new HashMap<>(); params.put("businessId", businessId); params.put("barcode", barcode); + params.put("receivingShipmentNo", receivingShipmentNo); return sqlSession.selectOne(NAMESPACE + "selectProductNameBarcode", params); } @Override - public void updateReceivingStatusToComplete(int businessId, String barcode) throws Exception { + public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception { logger.info("updateReceivingStatusToComplete() 호출"); Map params = new HashMap<>(); params.put("businessId", businessId); params.put("barcode", barcode); + params.put("receivingShipmentNo", receivingShipmentNo); sqlSession.update(NAMESPACE + "updateReceivingStatusToComplete", params); } @Override - public List selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception { + public List selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int orderItemId) throws Exception { logger.info("selecttReceivingShipmentNo() 호출"); Map params = new HashMap<>(); params.put("businessId", businessId); params.put("receivingShipmentNo", receivingShipmentNo); + params.put("orderItemId", orderItemId); + return sqlSession.selectList(NAMESPACE + "getReceivingShipmentNo", params); } diff --git a/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAO.java b/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAO.java index 957fbf5..b1bff1f 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAO.java @@ -50,5 +50,8 @@ public interface ShipmentDAO { // 수량 없을시 완료상태로 변경 public void updateShipmentStatusToComplete(int businessId, String barcode) throws Exception; + + // 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기 + public List selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception; } // ShipmentDAO end \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAOImpl.java b/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAOImpl.java index ffdde3a..173bb0e 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ShipmentDAOImpl.java @@ -121,7 +121,7 @@ public int updateIncreseStock(int businessId, String barcode) throws Exception { params.put("barcode", barcode); // SQL 실행 - return sqlSession.update(NAMESPACE + "updateIncreseStock", params); + return sqlSession.update(NAMESPACE + "updateDecreaseStock", params); } @Override @@ -161,6 +161,15 @@ public void updateShipmentStatusToComplete(int businessId, String barcode) throw } + @Override + public List selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception { + logger.info("selecttReceivingShipmentNo() 호출"); + Map params = new HashMap<>(); + params.put("businessId", businessId); + params.put("receivingShipmentNo", receivingShipmentNo); + return sqlSession.selectList(NAMESPACE + "getReceivingShipmentNo", params); + } + diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java index f71fdfa..8a0ce75 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java @@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper; import com.stockm8.domain.vo.Criteria; +import com.stockm8.domain.vo.OrderItemVO; import com.stockm8.domain.vo.ProductVO; import com.stockm8.domain.vo.ReceivingShipmentVO; import com.stockm8.domain.vo.StockVO; @@ -13,7 +14,7 @@ public interface ReceivingService { // 메인 입고 리스트 - public List getReceivingList(int businessId) throws Exception; + public List getReceivingList(Integer businessId) throws Exception; // 메인 어제 입고 리스트 public List getYesterdayReceivingList(int businessId) throws Exception; @@ -37,19 +38,19 @@ public interface ReceivingService { public void insertReceiving(int businessId) throws Exception; // 바코드 찍은 후 재고수량 증가 - public int increseStockByBarcode(int businessId, String barcode) throws Exception; + public int increseStockByBarcode(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception; // 바코드 찍은 후 발주 수량 감소 - public int decreaseReservedQuantity(int businessId, String barcode) throws Exception; + public int decreaseReservedQuantity(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception; // 바코드 찍은 후 제품 이름 추출 - public ProductVO productNameBarcode(int businessId, String barcode) throws Exception; + public ProductVO productNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; // 수량 없을시 완료상태로 변경 - public void ReceivingStatusToComplete(int businessId, String barcode) throws Exception; + public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; // 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기 - public List getReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception; + public List getReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int rderItemId) throws Exception; } // ReceivingService end \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java index 7130bc5..1ec1560 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java @@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional; import com.stockm8.domain.vo.Criteria; +import com.stockm8.domain.vo.OrderItemVO; import com.stockm8.domain.vo.ProductVO; import com.stockm8.domain.vo.ReceivingShipmentVO; import com.stockm8.domain.vo.StockVO; @@ -29,7 +30,7 @@ public class ReceivingServiceImpl implements ReceivingService { // 메인 입고 리스트 @Override - public List getReceivingList(int businessId) throws Exception { + public List getReceivingList(Integer businessId) throws Exception { logger.info("getTodayReceivingList() 호출"); return rdao.selectReceivingList(businessId); } @@ -79,41 +80,53 @@ public void insertReceiving(int businessId) throws Exception { @Transactional @Override - public int increseStockByBarcode(int businessId, String barcode) throws Exception { - logger.info("increseStockByBarcode() 호출"); - List stock = rdao.selectQuantityCheckByBarcode(businessId, barcode); - if (stock == null) { - return -1; // 유효하지 않은 바코드 - } - - int updatedRows = rdao.updateIncreseStock(businessId, barcode); - if (updatedRows > 0) { - return rdao.selectStockByBarcode(businessId, barcode); // 증가 후 남은 재고 반환 - } else { - throw new RuntimeException("재고 업데이트 실패"); - } - } + public int increseStockByBarcode(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception { + logger.info("increseStockByBarcode() 호출"); + + // 바코드와 관련된 재고 정보 확인 + List stock = rdao.selectQuantityCheckByBarcode(businessId, barcode, receivingShipmentNo); + logger.info("파라미터: " + stock); + + if (stock.isEmpty()) { + logger.error("유효하지 않은 바코드 또는 재고가 없습니다."); + return -1; // 유효하지 않은 바코드 + } + + // 재고 증가 시도 + int updatedRows = rdao.updateIncreseStock(businessId, barcode, receivingShipmentNo, orderItemId); + logger.info("업데이트된 행 수: " + updatedRows); + + if (updatedRows > 0) { + // 재고가 정상적으로 증가한 후, 최신 재고 확인 + int remainingStock = rdao.selectStockByBarcode(businessId, barcode, receivingShipmentNo, orderItemId); + logger.info("업데이트 후 남은 재고: " + remainingStock); + return remainingStock; // 증가 후 남은 재고 반환 + } else { + logger.error("재고 업데이트 실패: 바코드 또는 입고 번호에 해당하는 재고가 존재하지 않거나 업데이트되지 않았습니다."); + throw new RuntimeException("재고 업데이트 실패"); + } + } @Override - public int decreaseReservedQuantity(int businessId, String barcode) throws Exception { + public int decreaseReservedQuantity(int businessId, String barcode, Integer receivingShipmentNo, Integer orderItemId) throws Exception { logger.info("decreaseReservedQuantity() 호출"); - return rdao.selectReservedQuantity(businessId, barcode); + return rdao.selectReservedQuantity(businessId, barcode, receivingShipmentNo, orderItemId); } @Override - public ProductVO productNameBarcode(int businessId, String barcode) throws Exception { + public ProductVO productNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception { logger.info("productNameBarcode() 호출"); - return rdao.selectProductNameBarcode(businessId, barcode); + return rdao.selectProductNameBarcode(businessId, barcode, receivingShipmentNo); } @Override - public void ReceivingStatusToComplete(int businessId, String barcode) { + public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) { try { // MyBatis 매퍼 호출 - rdao.updateReceivingStatusToComplete(businessId, barcode); -// opService.processInboundAfterInsepection; + rdao.updateReceivingStatusToComplete(businessId, barcode, receivingShipmentNo); +// opService.processInboundAfterInspection(orderId, completedItems); } catch (Exception e) { // 예외 처리 logger.error("입고 상태 업데이트 오류: " + e.getMessage()); @@ -121,10 +134,10 @@ public void ReceivingStatusToComplete(int businessId, String barcode) { } @Override - public List getReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception { + public List getReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int orderItemId) throws Exception { logger.info("getReceivingShipmentNo() 호출"); - return rdao.selectReceivingShipmentNo(businessId, receivingShipmentNo); + return rdao.selectReceivingShipmentNo(businessId, receivingShipmentNo, orderItemId); } diff --git a/stockMate/src/main/java/com/stockm8/service/ShipmentService.java b/stockMate/src/main/java/com/stockm8/service/ShipmentService.java index 52005c0..0961746 100644 --- a/stockMate/src/main/java/com/stockm8/service/ShipmentService.java +++ b/stockMate/src/main/java/com/stockm8/service/ShipmentService.java @@ -36,10 +36,10 @@ public interface ShipmentService { // rs 테이블 insert public void insertShipment(int businessId) throws Exception; - // 바코드 찍은 후 재고수량 증가 + // 바코드 찍은 후 재고수량 감소 public int increseStockByBarcode(int businessId, String barcode) throws Exception; - // 바코드 찍은 후 발주 수량 감소 + // 바코드 찍은 후 수주 수량 증가 public int decreaseReservedQuantity(int businessId, String barcode) throws Exception; // 바코드 찍은 후 제품 이름 추출 @@ -47,6 +47,9 @@ public interface ShipmentService { // 수량 없을시 완료상태로 변경 public void ShipmentStatusToComplete(int businessId, String barcode) throws Exception; + + // 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기 + public List getReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception; } // ShipmentService end \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/service/ShipmentServiceImpl.java b/stockMate/src/main/java/com/stockm8/service/ShipmentServiceImpl.java index 3ffb4bb..b7d25da 100644 --- a/stockMate/src/main/java/com/stockm8/service/ShipmentServiceImpl.java +++ b/stockMate/src/main/java/com/stockm8/service/ShipmentServiceImpl.java @@ -116,6 +116,12 @@ public void ShipmentStatusToComplete(int businessId, String barcode) { } } + @Override + public List getReceivingShipmentNo(int businessId, Integer receivingShipmentNo) throws Exception { + logger.info("getReceivingShipmentNo() 호출"); + + return sdao.selectReceivingShipmentNo(businessId, receivingShipmentNo); + } diff --git a/stockMate/src/main/resources/mappers/OrderMapper.xml b/stockMate/src/main/resources/mappers/OrderMapper.xml index f0fe0c4..b4caf7e 100644 --- a/stockMate/src/main/resources/mappers/OrderMapper.xml +++ b/stockMate/src/main/resources/mappers/OrderMapper.xml @@ -31,6 +31,7 @@ + @@ -110,6 +111,7 @@ product_id, warehouse_id, quantity, + change_quantity, unit_price, remarks, created_at @@ -118,6 +120,7 @@ #{productId}, #{warehouseId}, #{quantity}, + #{quantity} #{unitPrice}, #{remarks}, NOW() diff --git a/stockMate/src/main/resources/mappers/receivingMapper.xml b/stockMate/src/main/resources/mappers/receivingMapper.xml index df3ead8..d2bc114 100644 --- a/stockMate/src/main/resources/mappers/receivingMapper.xml +++ b/stockMate/src/main/resources/mappers/receivingMapper.xml @@ -134,6 +134,7 @@ WHERE NOT EXISTS ( - UPDATE stocks s - JOIN products p on p.product_id = s.product_id + UPDATE order_items o + JOIN products p on p.product_id = o.product_id + 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 - WHERE p.product_barcode = #{barcode} AND s.business_id = #{businessId} - AND s.reserved_quantity > 0 + s.reserved_quantity = s.reserved_quantity -1, + o.change_quantity = o.change_quantity -1 + WHERE p.product_barcode = #{barcode} + AND s.business_id = #{businessId} + AND o.change_quantity > 0 + AND r.receiving_shipment_no = #{receivingShipmentNo} + AND r.order_item_id = #{orderItemId} @@ -259,18 +278,22 @@ WHERE r.transaction_type = 'INBOUND' SELECT p.product_name, p.product_price FROM stocks s JOIN products p on p.product_id = s.product_id + JOIN receiving_shipment r on r.stock_id = s.stock_id WHERE p.product_barcode = #{barcode} AND s.business_id = #{businessId} + AND r.receiving_shipment_no = #{receivingShipmentNo} UPDATE receiving_shipment r 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' WHERE p.product_barcode = #{barcode} - AND s.reserved_quantity = 1 + AND o.change_quantity = 0 AND r.status = 'PENDING' - AND s.business_id = #{businessId}; + AND s.business_id = #{businessId} + AND r.receiving_shipment_no = #{receivingShipmentNo} diff --git a/stockMate/src/main/resources/mappers/shipmentMapper.xml b/stockMate/src/main/resources/mappers/shipmentMapper.xml index c507a31..3e050ec 100644 --- a/stockMate/src/main/resources/mappers/shipmentMapper.xml +++ b/stockMate/src/main/resources/mappers/shipmentMapper.xml @@ -233,7 +233,7 @@ WHERE r.transaction_type = 'OUTBOUND' UPDATE stocks s JOIN products p on p.product_id = s.product_id SET s.total_quantity = s.total_quantity - 1, - s.reserved_quantity = s.reserved_quantity -1 + s.reserved_quantity = s.reserved_quantity - 1 WHERE p.product_barcode = #{barcode} AND s.business_id = #{businessId} AND s.reserved_quantity > 0 @@ -274,4 +274,26 @@ WHERE r.transaction_type = 'OUTBOUND' + + + diff --git a/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp b/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp index 2d195c4..1d71e63 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp @@ -239,7 +239,6 @@ tr:hover {

입고 내역

입고 메인 - 입고 검수
@@ -274,6 +273,7 @@ tr:hover { + @@ -288,10 +288,11 @@ tr:hover { + " + "" + "" + - "" + + "" + "" + "" + "" + @@ -211,6 +217,14 @@ td { 다중 입고 검수
+
+ + +
+
+ + +
diff --git a/stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp b/stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp index 8d737b6..535982c 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp @@ -239,7 +239,6 @@ tr:hover {

입고 내역

입고 메인 - 입고 검수 diff --git a/stockMate/src/main/webapp/WEB-INF/views/shipment/history.jsp b/stockMate/src/main/webapp/WEB-INF/views/shipment/history.jsp index 43dcbf1..200e9b7 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/shipment/history.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/shipment/history.jsp @@ -239,7 +239,6 @@ tr:hover {

출고 내역

출고 메인 - 출고 검수
@@ -287,7 +286,11 @@ tr:hover {
- +
입고 번호주문 번호 입고 출고 입고 일자 입고 상태
- + ${vo.receivingShipmentNo} ${vo.orderItemId} 입고 diff --git a/stockMate/src/main/webapp/WEB-INF/views/receiving/main.jsp b/stockMate/src/main/webapp/WEB-INF/views/receiving/main.jsp index 1180060..98b8862 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/receiving/main.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/main.jsp @@ -15,7 +15,6 @@

입고 메인

입고 내역 -입고 검수 대쉬보드
diff --git a/stockMate/src/main/webapp/WEB-INF/views/receiving/scan.jsp b/stockMate/src/main/webapp/WEB-INF/views/receiving/scan.jsp index 654d16f..137da9f 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/receiving/scan.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/scan.jsp @@ -15,12 +15,18 @@ $(document).ready(function () { $("#barcodeInput").on("keyup", function (e) { if (e.key === "Enter") { let barcode = $(this).val().trim(); - if (barcode) { + let receivingShipmentNo = $("#receivingShipmentNo").val().trim(); + let orderItemId = $("#orderItemId").val().trim(); + if ((barcode && receivingShipmentNo && orderItemId)) { $.ajax({ url: "/receiving/scan", method: "POST", contentType: "application/json", - data: JSON.stringify({ barcode: barcode }), + data: JSON.stringify({ + barcode: barcode, + receivingShipmentNo: parseInt(receivingShipmentNo), + orderItemId: parseInt(orderItemId) + }), success: function (response) { if (response.success) { $("#stockInfo").html( @@ -28,7 +34,7 @@ $(document).ready(function () { "
제품명남은 재고총 재고량입고처리할 남은 수량단가
${vo.receivingShipmentNo } + + ${vo.receivingShipmentNo} + + 입고 diff --git a/stockMate/src/main/webapp/WEB-INF/views/shipment/main.jsp b/stockMate/src/main/webapp/WEB-INF/views/shipment/main.jsp index a4f2cf8..299f2ed 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/shipment/main.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/shipment/main.jsp @@ -15,7 +15,6 @@

출고 메인

출고 내역 -출고 검수 대쉬보드
diff --git a/stockMate/src/main/webapp/WEB-INF/views/shipment/scan.jsp b/stockMate/src/main/webapp/WEB-INF/views/shipment/scan.jsp index ab636e5..8065549 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/shipment/scan.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/shipment/scan.jsp @@ -1,5 +1,7 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> @@ -43,7 +45,7 @@ $(document).ready(function () { ); } else { alert("더이상 출고할 수량이 없습니다."); - if(confirm("발주를 새로 등록 하시겠습니까?")) { + if(confirm("수주를 새로 등록 하시겠습니까?")) { window.location.href = "/order/register"; } } @@ -216,126 +218,56 @@ td {

재고 정보가 여기에 표시됩니다.

- - - -
- - -
-
- - - - - - - - - - - -
상품명바코드단가수량
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
출고 번호입고 출고출고 일자출고 상태제품 번호제품명옵션명출고 수량제품 단가창고 위치작업 메모
${vo.receivingShipmentNo} + + 입고 + 출고 + ${vo.transactionType} + + + + + 대기중 + + + 완료됨 + + + ${vo.status} + + + ${vo.productId }${vo.productName }${vo.productDescription }${vo.changeQuantity }${vo.productPrice }${vo.warehouseId }${vo.memo }
diff --git a/stockMate/src/main/webapp/WEB-INF/views/shipment/search.jsp b/stockMate/src/main/webapp/WEB-INF/views/shipment/search.jsp index 5cb0f66..2ef09c5 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/shipment/search.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/shipment/search.jsp @@ -239,7 +239,6 @@ tr:hover {

출고 내역

출고 메인 - 출고 검수