diff --git a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java index 1e20500..271335d 100644 --- a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java +++ b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java @@ -43,59 +43,132 @@ public void mainGET(Model model) throws Exception { model.addAttribute("ReceivingList", ReceivingList); model.addAttribute("YesterdayReceivingList", YesterdayReceivingList); model.addAttribute("TDBYReceivingList", TDBYReceivingList); - } + // http://localhost:8088/receiving/history @RequestMapping(value = "/history", method = RequestMethod.GET) - public String historyGET(@RequestParam(value = "startDate", required = false) String startDate, - @RequestParam(value = "endDate", required = false) String endDate, - @RequestParam(value = "keyword", required = false) String keyword, - Criteria cri, - Model model) throws Exception { + public void historyGET(@RequestParam(value = "startDate", required = false) String startDate, + @RequestParam(value = "endDate", required = false) String endDate, + @RequestParam(value = "keyword", required = false) String keyword, + Criteria cri, + Model model) throws Exception { logger.info("historyGET() 호출"); List ReceivingList; + int totalCount = 0; + + ReceivingList = rService.getReceivingHistoryList(cri); + totalCount = rService.getTotalCount(); // 전체 개수 + + PageVO pageVO = new PageVO(); + pageVO.setCri(cri); + pageVO.setTotalCount(totalCount); + model.addAttribute("pageVO", pageVO); + + logger.info(ReceivingList.size() + "개"); + model.addAttribute("ReceivingList", ReceivingList); + } + + // http://localhost:8088/receiving/search + @RequestMapping(value = "/search", method = RequestMethod.GET) + public void searchGET(@RequestParam(value = "startDate", required = false) String startDate, + @RequestParam(value = "endDate", required = false) String endDate, + @RequestParam(value = "keyword", required = false) String keyword, + Criteria cri, + Model model) throws Exception { + logger.info("searchGET() 호출"); + + List ReceivingList; + + int totalCount = 0; + // 날짜와 키워드가 모두 있는 경우 if (startDate != null && endDate != null && keyword != null) { ReceivingList = rService.getHistoryByDateRange(startDate, endDate, keyword, cri); - int totalCount = rService.getTotalCountBySearch(startDate, endDate, keyword, cri); - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); // 총 개수를 검색 조건에 맞게 계산 - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCountBySearch(startDate, endDate, keyword); + } else if (keyword != null) { ReceivingList = rService.getHistoryByDateRange(null, null, keyword, cri); - int totalCount = rService.getTotalCountBySearch(null, null, keyword, cri); - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCountBySearch(null, null, keyword); + } else if (startDate != null && endDate != null) { ReceivingList = rService.getHistoryByDateRange(startDate, endDate, null, cri); - int totalCount = rService.getTotalCountBySearch(startDate, endDate, null, cri); - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCountBySearch(startDate, endDate, null); + } else { ReceivingList = rService.getReceivingHistoryList(cri); - int totalCount = rService.getTotalCount(); // 전체 개수 - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCount(); // 전체 개수 + } + + PageVO pageVO = new PageVO(); + pageVO.setCri(cri); + pageVO.setTotalCount(totalCount); + model.addAttribute("pageVO", pageVO); logger.info(ReceivingList.size() + "개"); model.addAttribute("ReceivingList", ReceivingList); - - return "/receiving/history"; } + // 새로고침 + @RequestMapping(value = "/insert1", method = RequestMethod.POST) + public String insert1POST() throws Exception { + logger.info("insertPOST() 호출"); + + rService.insertReceiving(); + + return "redirect:/receiving/main"; + } + + // 새로고침 + @RequestMapping(value = "/insert2", method = RequestMethod.POST) + public String insert2POST() throws Exception { + logger.info("insertPOST() 호출"); + + rService.insertReceiving(); + + return "redirect:/receiving/history"; + } + + // 새로고침 + @RequestMapping(value = "/insert3", method = RequestMethod.POST) + public String insert3POST() throws Exception { + logger.info("insertPOST() 호출"); + + rService.insertReceiving(); + + return "redirect:/receiving/search"; + } - + // http://localhost:8088/receiving/scanner + @RequestMapping(value = "/scanner", method = RequestMethod.GET) + public String scannerGET(@RequestParam(value = "qrData", required = false) String qrData, Model model) throws Exception { + logger.info("scannerGET() 호출"); + // QR 코드 데이터 처리 로직 (예: 데이터 저장, 검증 등) + logger.info("받은 QR 코드 데이터: " + qrData); + + // 처리 결과를 JSP로 전달 + model.addAttribute("qrData", qrData); + + return "/receiving/scanner"; + } + + @RequestMapping(value = "/scanner", method = RequestMethod.POST) + public String scannePOST(@RequestParam(value = "qrData", required = false) String qrData, Model model) throws Exception { + logger.info("scannerGET() 호출"); + // QR 코드 데이터 처리 로직 (예: 데이터 저장, 검증 등) + logger.info("받은 QR 코드 데이터: " + qrData); + + // 처리 결과를 JSP로 전달 + model.addAttribute("qrData", qrData); + + return "/receiving/scanner"; + } + + + -} // ReceivingController end +} // ReceivingController end \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java index 9117ff8..d8cd814 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java @@ -23,9 +23,12 @@ public interface ReceivingDAO { public List selectHistoryByDateRange(String startDate, String endDate, String keyword, Criteria cri) throws Exception; // 검색시 모든 리스트 개수 - public int selectTotalCountBySearch(String startDate, String endDate, String keyword, Criteria cri) throws Exception; + public int selectTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception; // 리스트 모든 개수 public int selectTotalCount() throws Exception; + + // rs 테이블 insert + public void insertReceiving() 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 ac9220b..ee4c735 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java @@ -72,13 +72,12 @@ public List selectHistoryByDateRange(String startDate, Stri } @Override - public int selectTotalCountBySearch(String startDate, String endDate, String keyword, Criteria cri) throws Exception { + public int selectTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception { Map paramMap = new HashMap<>(); paramMap.put("startDate", startDate); paramMap.put("endDate", endDate); paramMap.put("keyword", keyword); - paramMap.put("cri", cri); return sqlSession.selectOne(NAMESPACE + "getTotalCountBySearch", paramMap); } @@ -88,6 +87,14 @@ public int selectTotalCount() throws Exception { return sqlSession.selectOne(NAMESPACE + "getTotalCount"); } + + @Override + public void insertReceiving() throws Exception { + logger.info("insertReceiving() 호출"); + sqlSession.insert(NAMESPACE + "insertReceiving"); + } + + diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java index b9b8592..3d2c2bc 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java @@ -2,10 +2,12 @@ import java.util.List; +import org.apache.ibatis.annotations.Mapper; + import com.stockm8.domain.vo.Criteria; import com.stockm8.domain.vo.ReceivingShipmentVO; - +@Mapper public interface ReceivingService { // 메인 입고 리스트 @@ -24,9 +26,12 @@ public interface ReceivingService { public List getHistoryByDateRange(String startDate, String endDate, String keyword, Criteria cri) throws Exception; // 입고 내역 검색 - public int getTotalCountBySearch(String startDate, String endDate, String keyword, Criteria cri) throws Exception; + public int getTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception; // 글 모든 개수 public int getTotalCount() throws Exception; + + // rs 테이블 insert + public void insertReceiving() 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 dda4167..9de00ef 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java @@ -52,10 +52,9 @@ public List getHistoryByDateRange(String startDate, String } @Override - public int getTotalCountBySearch(String startDate, String endDate, String keyword, - Criteria cri) throws Exception { + public int getTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception { logger.info("getTotalCountBySearch() 호출"); - return rdao.selectTotalCountBySearch(startDate, endDate, keyword, cri); + return rdao.selectTotalCountBySearch(startDate, endDate, keyword); } @Override @@ -63,6 +62,13 @@ public int getTotalCount() throws Exception { logger.info("getTotalCount() 호출"); return rdao.selectTotalCount(); } + + @Override + public void insertReceiving() throws Exception { + logger.info("insertReceiving() 호출"); + rdao.insertReceiving(); + } + diff --git a/stockMate/src/main/resources/mappers/receivingMapper.xml b/stockMate/src/main/resources/mappers/receivingMapper.xml index 77659d0..c096d32 100644 --- a/stockMate/src/main/resources/mappers/receivingMapper.xml +++ b/stockMate/src/main/resources/mappers/receivingMapper.xml @@ -25,8 +25,36 @@ - + + + INSERT INTO receiving_shipment ( + transaction_type, + status, + product_id, + change_quantity, + transaction_unit, + order_item_id, + stock_id, + warehouse_id, + created_by + ) + SELECT + 'in', + 'pending', + p.product_id, + o.quantity, + p.base_unit, + o.order_item_id, + s.stock_id, + o.warehouse_id, + u.created_by + FROM products p + JOIN order_items o ON o.product_id = p.product_id + JOIN stocks s ON s.product_id = p.product_id + JOIN users u ON u.business_id = p.business_id; + + SELECT COUNT(*) - FROM test_receiving_shipment r - JOIN test_products p ON r.product_id = p.product_id + FROM receiving_shipment r + JOIN products p ON r.product_id = p.product_id r.created_at >= #{startDate} @@ -168,7 +196,7 @@ 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 76c8bc2..e64fad0 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp @@ -239,14 +239,18 @@ tr:hover {

입고 내역

입고 메인 +
+ +
+ -
+ name="endDate" value="${param.endDate}"> @@ -259,6 +263,7 @@ tr:hover { // 날짜 input 초기화 (브라우저에서 기본값으로 설정됨) document.getElementById('startDate').value = ''; document.getElementById('endDate').value = ''; + document.getElementById('keyword').value = ''; } @@ -309,17 +314,17 @@ tr:hover { 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 01b1077..c08c4cd 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/receiving/main.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/main.jsp @@ -114,6 +114,10 @@

입고 메인

입고 내역 +입고 스캔 + + +
diff --git a/stockMate/src/main/webapp/WEB-INF/views/receiving/scanner.jsp b/stockMate/src/main/webapp/WEB-INF/views/receiving/scanner.jsp new file mode 100644 index 0000000..a22423a --- /dev/null +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/scanner.jsp @@ -0,0 +1,53 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + + QR 코드 및 바코드 스캔 + + + +

QR 코드 및 바코드 스캔

+ + + + +

스캔된 데이터: 여기에 스캔 결과가 표시됩니다.

+ + + + + + + + + diff --git a/stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp b/stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp new file mode 100644 index 0000000..14ada32 --- /dev/null +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp @@ -0,0 +1,333 @@ +<%@ 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"%> + + + + +입고 내역 + + + + +

입고 내역

+ 입고 메인 + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
입고 번호입고 출고입고 일자입고 상태제품 번호제품명옵션명입고 수량수량 단위제품 단가작업 메모
${vo.receivingShipmentNo }${vo.transactionType }${vo.status }${vo.productId }${vo.name }${vo.description }${vo.changeQuantity }${vo.transactionUnit }${vo.price }${vo.memo }
+ + + + + + 검색 결과가 없습니다. + + + +
+ +
+ + + \ No newline at end of file