diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java index 7f1db8d..ac5d756 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java @@ -4,6 +4,7 @@ import com.stockm8.domain.vo.Criteria; import com.stockm8.domain.vo.ReceivingShipmentVO; +import com.stockm8.domain.vo.StockVO; public interface ReceivingDAO { @@ -30,5 +31,14 @@ public interface ReceivingDAO { // recevingShipment 테이블 insert public void insertReceiving(int businessId) throws Exception; + + // 바코드로 재고 조회 + public List selectQuantityCheckByBarcode(int businessId, String barcode) throws Exception; + + // 바코드로 재고 감소 + public int updateIncreseStock(int businessId, String barcode) throws Exception; + + // 바코드로 재고 감소 실시간 조회 + public int selectStockByBarcode(int businessId, String barcode) 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 e67c86b..ca5b550 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java @@ -13,13 +13,14 @@ import com.stockm8.domain.vo.Criteria; import com.stockm8.domain.vo.ReceivingShipmentVO; +import com.stockm8.domain.vo.StockVO; @Repository public class ReceivingDAOImpl implements ReceivingDAO { private static final Logger logger = LoggerFactory.getLogger(ReceivingDAOImpl.class); - private static final String NAMESPACE = "com.stockm8.mapper.ReceivingShipmentMapper."; + private static final String NAMESPACE = "com.stockm8.mappers.receivingMapper."; // 디비 연결 객체 주입 @Inject @@ -28,7 +29,7 @@ public class ReceivingDAOImpl implements ReceivingDAO { // 입고 메인 오늘 들어올 리스트 @Override public List selectReceivingList(int businessId) throws Exception { - logger.info("ReceivingList() 호출"); + logger.info("selectReceivingList() 호출"); return sqlSession.selectList(NAMESPACE + "getReceivingList", businessId); } @@ -36,7 +37,7 @@ public List selectReceivingList(int businessId) throws Exce // 입고 메인 오늘 들어올 리스트 @Override public List selectYesterdayReceivingList(int businessId) throws Exception { - logger.info("ReceivingList() 호출"); + logger.info("selectYesterdayReceivingList() 호출"); return sqlSession.selectList(NAMESPACE + "getYesterdayReceivingList", businessId); } @@ -44,7 +45,7 @@ public List selectYesterdayReceivingList(int businessId) th // 입고 메인 오늘 들어올 리스트 @Override public List selectTDBYReceivingList(int businessId) throws Exception { - logger.info("ReceivingList() 호출"); + logger.info("selectTDBYReceivingList() 호출"); return sqlSession.selectList(NAMESPACE + "getTDBYReceivingList", businessId); } @@ -100,7 +101,36 @@ public void insertReceiving(int businessId) throws Exception { sqlSession.insert(NAMESPACE + "insertReceiving", businessId); } + @Override + public List selectQuantityCheckByBarcode(int businessId, String barcode) throws Exception { + logger.info("selectReceiving() 호출"); + Map paramMap = new HashMap(); + paramMap.put("businessId", businessId); + paramMap.put("barcode", barcode); + + return sqlSession.selectList(NAMESPACE + "selectQuantityCheckByBarcode", paramMap); + } + + @Override + public int updateIncreseStock(int businessId, String barcode) throws Exception { + logger.info("updateDecreaseStock() 호출"); + // 매개변수 묶기 + Map params = new HashMap<>(); + params.put("businessId", businessId); + params.put("barcode", barcode); + + // SQL 실행 + return sqlSession.update(NAMESPACE + "updateIncreseStock", params); + } + @Override + public int selectStockByBarcode(int businessId, String barcode) throws Exception { + logger.info("selectStockByBarcode() 호출"); + Map params = new HashMap<>(); + params.put("businessId", businessId); + params.put("barcode", barcode); + return sqlSession.selectOne(NAMESPACE + "selectStockByBarcode", params); + } diff --git a/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java b/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java index 5b6d747..07b0bcc 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java @@ -33,12 +33,5 @@ public interface StockDAO { // 카테고리 목록 조회 public List selectAllCategories() throws Exception; - // 바코드로 재고 조회 - public List selectQuantityCheckByBarcode(int businessId, String barcode) throws Exception; - - // 바코드로 재고 감소 - public int updateIncreseStock(int businessId, String barcode) throws Exception; - - // 바코드로 재고 감소 실시간 조회 - public int selectStockByBarcode(int businessId, String barcode) throws Exception; + } diff --git a/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java b/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java index 8e59c46..2bfb25d 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java @@ -95,36 +95,7 @@ public List selectAllCategories() throws Exception { - @Override - public List selectQuantityCheckByBarcode(int businessId, String barcode) throws Exception { - logger.info("selectReceiving() 호출"); - Map paramMap = new HashMap(); - paramMap.put("businessId", businessId); - paramMap.put("barcode", barcode); - - return sqlSession.selectList(NAMESPACE + "selectQuantityCheckByBarcode", paramMap); - } - - @Override - public int updateIncreseStock(int businessId, String barcode) throws Exception { - logger.info("updateDecreaseStock() 호출"); - // 매개변수 묶기 - Map params = new HashMap<>(); - params.put("businessId", businessId); - params.put("barcode", barcode); - - // SQL 실행 - return sqlSession.update(NAMESPACE + "updateIncreseStock", params); - } - @Override - public int selectStockByBarcode(int businessId, String barcode) throws Exception { - logger.info("selectStockByBarcode() 호출"); - Map params = new HashMap<>(); - params.put("businessId", businessId); - params.put("barcode", barcode); - return sqlSession.selectOne(NAMESPACE + "selectStockByBarcode", params); - } } diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java index a372a8e..3c1efbb 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java @@ -81,14 +81,14 @@ public void insertReceiving(int businessId) throws Exception { @Override public int increseStockByBarcode(int businessId, String barcode) throws Exception { logger.info("increseStockByBarcode() 호출"); - List stock = sdao.selectQuantityCheckByBarcode(businessId, barcode); + List stock = rdao.selectQuantityCheckByBarcode(businessId, barcode); if (stock == null) { return -1; // 유효하지 않은 바코드 } - int updatedRows = sdao.updateIncreseStock(businessId, barcode); + int updatedRows = rdao.updateIncreseStock(businessId, barcode); if (updatedRows > 0) { - return sdao.selectStockByBarcode(businessId, barcode); // 증가 후 남은 재고 반환 + return rdao.selectStockByBarcode(businessId, barcode); // 증가 후 남은 재고 반환 } else { throw new RuntimeException("재고 업데이트 실패"); } diff --git a/stockMate/src/main/resources/mappers/receivingMapper.xml b/stockMate/src/main/resources/mappers/receivingMapper.xml index 9084d26..0a4ec8a 100644 --- a/stockMate/src/main/resources/mappers/receivingMapper.xml +++ b/stockMate/src/main/resources/mappers/receivingMapper.xml @@ -4,7 +4,7 @@ "https://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -57,7 +57,7 @@ - select r.receiving_shipment_no, r.transaction_type, @@ -79,7 +79,7 @@ - select r.receiving_shipment_no, r.transaction_type, @@ -101,7 +101,7 @@ - select r.receiving_shipment_no, r.transaction_type, @@ -123,7 +123,7 @@ - select r.receiving_shipment_no, r.transaction_type, @@ -146,7 +146,7 @@ - SELECT r.receiving_shipment_no, r.transaction_type, @@ -211,5 +211,32 @@ AND u.business_id = #{businessId} + + + + + + + UPDATE stocks s + JOIN products p on p.product_id = s.product_id + SET s.total_quantity = s.total_quantity + 1 + WHERE p.product_barcode = #{barcode} AND s.business_id = #{businessId} + AND s.total_quantity > 0 + + + + + + diff --git a/stockMate/src/main/resources/mappers/stockMapper.xml b/stockMate/src/main/resources/mappers/stockMapper.xml index 1408efb..865ce24 100644 --- a/stockMate/src/main/resources/mappers/stockMapper.xml +++ b/stockMate/src/main/resources/mappers/stockMapper.xml @@ -211,31 +211,6 @@ WHERE business_id = #{businessId} AND is_deleted = 0 - - - - - - - UPDATE stocks s - JOIN products p on p.product_id = s.product_id - SET s.total_quantity = s.total_quantity + 1 - WHERE p.product_barcode = #{barcode} AND s.business_id = #{businessId} - AND s.total_quantity > 0 - - - - - + \ No newline at end of file