From 6641e4ac9bf3a8542d0b57792a49abba1faee68b Mon Sep 17 00:00:00 2001 From: Kana Date: Fri, 19 Jan 2024 18:39:29 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=85=EA=B3=A0=20=EC=A0=84=EC=B2=B4?= =?UTF-8?q?=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/no1/wms/in/InController.java | 113 +++++--- src/main/java/com/no1/wms/in/InDto.java | 3 +- src/main/java/com/no1/wms/in/InMapper.java | 5 + src/main/java/com/no1/wms/in/InService.java | 14 + src/main/resources/mappers/InMapper.xml | 120 +++++--- src/main/webapp/WEB-INF/views/in/create.jsp | 21 +- src/main/webapp/WEB-INF/views/in/list.jsp | 18 +- src/main/webapp/WEB-INF/views/in/read.jsp | 120 ++++++++ src/main/webapp/WEB-INF/views/in/update.jsp | 256 ++++++++++++++++++ 9 files changed, 592 insertions(+), 78 deletions(-) create mode 100644 src/main/webapp/WEB-INF/views/in/read.jsp create mode 100644 src/main/webapp/WEB-INF/views/in/update.jsp diff --git a/src/main/java/com/no1/wms/in/InController.java b/src/main/java/com/no1/wms/in/InController.java index 21976aa..6f62822 100644 --- a/src/main/java/com/no1/wms/in/InController.java +++ b/src/main/java/com/no1/wms/in/InController.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @@ -17,6 +18,8 @@ import com.no1.wms.price.PriceDto; import com.no1.wms.product.ProductDto; import com.no1.wms.product.ProductService; import com.no1.wms.stock.StockService; +import com.no1.wms.warehouse.WarehouseDto; +import com.no1.wms.warehouse.WarehouseService; @Controller @RequestMapping("/in") @@ -28,6 +31,8 @@ public class InController { ProductService productService; @Autowired StockService stockservice; + @Autowired + WarehouseService warehouseService; @GetMapping("/list") //@ResponseBody @@ -70,24 +75,54 @@ public class InController { return "in/create"; } - /* - * + @PostMapping("/create_process") @ResponseBody - public boolean createProcess(PriceDto dto) { + public boolean createProcess(InDto dto) { int i = inService.createProcess(dto); - if (i == 1) { + int j = inService.createProcess2(dto); + if (i == 1 & i == j) { return true; } else { return false; } } - */ - - + @PostMapping("/read") + public String read(String id, Model m) { + InDto dto = inService.selectById(id); + String productId = dto.getProduct_id(); + ProductDto pDto = productService.selectById(productId); + m.addAttribute("pDto", pDto); + m.addAttribute("dto", dto); + return "in/read"; + } + // 수정 폼 + @PostMapping("/update") + public String update(String id, Model m) { + InDto dto = inService.selectById(id); + String productId = dto.getProduct_id(); + String warehouseId = dto.getWarehouse_id(); + ProductDto pDto = productService.selectById(productId); + WarehouseDto wDto = warehouseService.One(warehouseId); + m.addAttribute("wDto", wDto); + m.addAttribute("pDto", pDto); + m.addAttribute("dto", dto); + return "in/update"; + } + // 수정 - Ajax + @PutMapping("/update_process") + @ResponseBody + public boolean update_process(InDto dto) { + int i = inService.updateById(dto); + if (i == 1) { + return true; + } else { + return false; + } + } @@ -132,46 +167,44 @@ public class InController { } @PostMapping("/show_modal_warehouse") - public ModelAndView warehouseShowModal(@RequestParam(name = "searchn", defaultValue = "0") int searchn, - @RequestParam(name = "search", defaultValue = "") String search, - @RequestParam(name = "p", defaultValue = "1") int page, - @RequestParam String name, ModelAndView mav){ + public ModelAndView warehouseShowModal(@RequestParam(name = "searchn", defaultValue = "0") int searchn, + @RequestParam(name = "search", defaultValue = "") String search, + @RequestParam(name = "p", defaultValue = "1") int page, + @RequestParam String name, String product_id, ModelAndView mav){ - int perPage = 9; // 한 페이지에 보일 글의 갯수 - int startRow = (page - 1) * perPage; + int perPage = 9; // 한 페이지에 보일 글의 갯수 + int startRow = (page - 1) * perPage; - List> list = null; - int count = 0; - - list = stockservice.warehousesSelect(searchn, search, startRow, perPage); - count = stockservice.warehouseCount(searchn, search); - + List> list = null; + int count = 0; - mav.addObject("list", list); + list = stockservice.warehousesSelect(searchn, search, startRow, perPage, product_id); + count = stockservice.warehouseCount(searchn, search, product_id); - mav.addObject("start", startRow + 1); - int pageNum = 5;//보여질 페이지 번호 수 - int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수 + mav.addObject("list", list); - int begin = (page - 1) / pageNum * pageNum + 1; - int end = begin + pageNum - 1; - if (end > totalPages) { - end = totalPages; - } - mav.addObject("searchn", searchn); - mav.addObject("search", search); - mav.addObject("begin", begin); - mav.addObject("end", end); - mav.addObject("pageNum", pageNum); - mav.addObject("totalPages", totalPages); - mav.addObject("p" , page); + mav.addObject("start", startRow + 1); - mav.setViewName(name); - return mav; - } - - + int pageNum = 5;//보여질 페이지 번호 수 + int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수 + + int begin = (page - 1) / pageNum * pageNum + 1; + int end = begin + pageNum - 1; + if (end > totalPages) { + end = totalPages; + } + mav.addObject("searchn", searchn); + mav.addObject("search", search); + mav.addObject("begin", begin); + mav.addObject("end", end); + mav.addObject("pageNum", pageNum); + mav.addObject("totalPages", totalPages); + mav.addObject("p" , page); + + mav.setViewName(name); + return mav; + } diff --git a/src/main/java/com/no1/wms/in/InDto.java b/src/main/java/com/no1/wms/in/InDto.java index 5a06e44..96813ab 100644 --- a/src/main/java/com/no1/wms/in/InDto.java +++ b/src/main/java/com/no1/wms/in/InDto.java @@ -25,7 +25,8 @@ import lombok.NoArgsConstructor; public class InDto { private String id; - private String group_number; + @Builder.Default + private String group_number = null; private String product_id; @DateTimeFormat(pattern = "yyyy-MM-dd") private Date in_date; diff --git a/src/main/java/com/no1/wms/in/InMapper.java b/src/main/java/com/no1/wms/in/InMapper.java index 8ba3092..97883e0 100644 --- a/src/main/java/com/no1/wms/in/InMapper.java +++ b/src/main/java/com/no1/wms/in/InMapper.java @@ -9,4 +9,9 @@ import org.apache.ibatis.annotations.Mapper; public interface InMapper { List inList(Map m); int count(Map m); + int createProcess(InDto dto); + int createProcess2(InDto dto); + InDto selectById (String id); + int updateById(InDto dto); + } diff --git a/src/main/java/com/no1/wms/in/InService.java b/src/main/java/com/no1/wms/in/InService.java index 476da85..6adb815 100644 --- a/src/main/java/com/no1/wms/in/InService.java +++ b/src/main/java/com/no1/wms/in/InService.java @@ -30,7 +30,21 @@ public class InService { return mapper.count(m); };//카운터 + public int createProcess(InDto dto) { + return mapper.createProcess(dto); + } + public int createProcess2(InDto dto) { + return mapper.createProcess2(dto); + } + + public InDto selectById (String id) { + return mapper.selectById(id); + } + + public int updateById(InDto dto) { + return mapper.updateById(dto); + } diff --git a/src/main/resources/mappers/InMapper.xml b/src/main/resources/mappers/InMapper.xml index fbc9a7d..f375410 100644 --- a/src/main/resources/mappers/InMapper.xml +++ b/src/main/resources/mappers/InMapper.xml @@ -37,8 +37,25 @@ - + + INSERT INTO product_in (id, product_id, in_date, quantity, warehouse_id, manager_id, note, activation) + VALUES (UUID(), #{product_id}, #{in_date}, #{quantity}, #{warehouse_id}, #{manager_id}, #{note}, 1) + + + + + + + UPDATE product_in + SET product_id = #{product_id}, in_date = #{in_date},quantity = #{quantity}, + warehouse_id = #{warehouse_id}, manager_id = #{manager_id}, note = #{note} + WHERE id = #{id} + + + + + @@ -71,37 +88,76 @@ + SELECT + proin.id, proin.group_number, proin.product_id, proin.in_date, proin.quantity, proin.warehouse_id, proin.manager_id, proin.note, proin.activation, + planin.view_group_number, + pro.name as product_name, + w.name as warehouse_name, + a.name as account_name, + (SELECT price FROM prices WHERE product_id = proin.product_id ORDER BY registration_date DESC LIMIT 1) as latest_price + FROM + product_in as proin + LEFT JOIN plan_In as planin on proin.group_number = planin.group_number and proin.product_id = planin.product_id + LEFT JOIN product as pro on proin.product_id = pro.id + LEFT JOIN warehouse as w on proin.warehouse_id = w.id + LEFT JOIN account as a on proin.manager_id = a.id + + + + proin.activation = 1 and proin.product_id IN (SELECT id FROM product WHERE name LIKE CONCAT('%',#{search},'%')) + + + proin.activation = 1 AND proin.in_date LIKE CONCAT('%',#{search},'%') + + + proin.activation = 1 AND proin.manager_id IN (SELECT id FROM account WHERE name LIKE CONCAT('%',#{search},'%')) + + + proin.activation = 1 AND proin.group_number LIKE CONCAT('%',#{search},'%') + + + + ORDER BY proin.in_date desc LIMIT #{start} , #{perPage} + + + + + + + + + UPDATE stock + SET quantity = quantity + #{quantity} + WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id} + + + + INSERT INTO stock (id, warehouse_id, product_id, quantity, activation) + VALUES (UUID(), #{warehouse_id}, #{product_id}, #{quantity}, 1) + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/in/create.jsp b/src/main/webapp/WEB-INF/views/in/create.jsp index f5339d9..214f44c 100644 --- a/src/main/webapp/WEB-INF/views/in/create.jsp +++ b/src/main/webapp/WEB-INF/views/in/create.jsp @@ -100,6 +100,13 @@ aria-describedby="basic-addon1"> +
+ 메모 + +
+ @@ -130,7 +137,7 @@ var warehouse_id = $("#warehouse_id").val(); var in_date = $("#in_date").val(); var manager_id = $("#manager_id").val(); - + var note = $("#note").val(); if(!product_id){ alert("제품을 선택해야합니다."); @@ -148,14 +155,20 @@ } if(!in_date){ in_date = new Date(); + in_date = in_date.toISOString(); } + if(!note){ + note = ""; + } + const data = { product_id : product_id, quantity : quantity, in_date : in_date, manager_id : manager_id, - warehouse_id : warehouse_id + warehouse_id : warehouse_id, + note : note } @@ -167,7 +180,7 @@ }).done(function(data) { if (data == true) { alert("입고을 추가했습니다."); - $(location).attr("href", "/price/list"); + $(location).attr("href", "/in/list"); } else { alert("입고 추가에 실패하였습니다."); } @@ -176,7 +189,7 @@ }).always(function() { // }); - + });//submitBtn });//ready diff --git a/src/main/webapp/WEB-INF/views/in/list.jsp b/src/main/webapp/WEB-INF/views/in/list.jsp index b692e47..d6aa4ed 100644 --- a/src/main/webapp/WEB-INF/views/in/list.jsp +++ b/src/main/webapp/WEB-INF/views/in/list.jsp @@ -122,7 +122,23 @@ });//createButton - + $("body").on("click", ".detailTr", function(){ + var id = $(this).data("id"); + + var form = document.createElement("form"); + form.action = "/in/read"; + form.method = "POST"; + document.body.appendChild(form); + + var input = document.createElement("input"); + input.type = "hidden"; + input.name = "id"; + input.value = id; + form.appendChild(input); + + form.submit(); + + });//body detailTr diff --git a/src/main/webapp/WEB-INF/views/in/read.jsp b/src/main/webapp/WEB-INF/views/in/read.jsp new file mode 100644 index 0000000..a3e21e7 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/in/read.jsp @@ -0,0 +1,120 @@ +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + + + + +Insert title here + + +
+
+

입고 상세페이지

+
+ +
+
+
+
+ +
+
+
+
+
+
+ 제품명 + +
+ +
+ 회사명 + +
+ +
+ 분류 + +
+ +
+ 거래처 + +
+ +
+ 수량 + +
+ +
+ 창고명 + +
+ +
+ 입고날짜 + + +
+ +
+ 메모 + +
+ +
+ 담당자 + +
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/in/update.jsp b/src/main/webapp/WEB-INF/views/in/update.jsp new file mode 100644 index 0000000..7bdfab3 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/in/update.jsp @@ -0,0 +1,256 @@ +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + + + + +Insert title here + + +
+
+

입고 수정

+
+
+
+ +
+
+
+
+
+ +
+ 제품명 + + + +
+ +
+ 회사명 + +
+ +
+ 분류 + +
+ +
+ 거래처 + +
+ +
+ 수량 + +
+ +
+ 창고명 + + + +
+ +
+ 주소 + +
+ +
+ 용적 + +
+ +
+ 잔여 용량 + +
+ +
+ 입고날짜 + + + + +
+ +
+ 메모 + +
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file