입고 전체적으로 수정

This commit is contained in:
Kana
2024-01-19 18:39:29 +09:00
parent 721d76a097
commit 6641e4ac9b
9 changed files with 592 additions and 78 deletions

View File

@@ -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;
}
}
@@ -135,7 +170,7 @@ public class InController {
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){
@RequestParam String name, String product_id, ModelAndView mav){
int perPage = 9; // 한 페이지에 보일 글의 갯수
int startRow = (page - 1) * perPage;
@@ -143,8 +178,8 @@ public class InController {
List<Map<String, Object>> list = null;
int count = 0;
list = stockservice.warehousesSelect(searchn, search, startRow, perPage);
count = stockservice.warehouseCount(searchn, search);
list = stockservice.warehousesSelect(searchn, search, startRow, perPage, product_id);
count = stockservice.warehouseCount(searchn, search, product_id);
mav.addObject("list", list);
@@ -176,6 +211,4 @@ public class InController {
}

View File

@@ -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;

View File

@@ -9,4 +9,9 @@ import org.apache.ibatis.annotations.Mapper;
public interface InMapper {
List<InDto> inList(Map<String, Object> m);
int count(Map<String, Object> m);
int createProcess(InDto dto);
int createProcess2(InDto dto);
InDto selectById (String id);
int updateById(InDto dto);
}

View File

@@ -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);
}

View File

@@ -37,8 +37,25 @@
<!-- insert -->
<insert id="createProcess" parameterType="InDto">
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)
</insert>
<!-- update -->
<update id="updateById" parameterType="InDto">
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}
</update>
<!-- delete -->
@@ -102,6 +119,45 @@
</where>
ORDER BY proin.in_date desc LIMIT #{start} , #{perPage}
</select>
<select id="selectById" parameterType="String" resultMap="inResultMap">
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
WHERE proin.id = #{id}
</select>
<select id="checkIfExistsStock" resultType="int" parameterType="InDto">
SELECT COUNT(*) FROM stock
WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id}
</select>
<update id="updateStockProcess" parameterType="InDto">
UPDATE stock
SET quantity = quantity + #{quantity}
WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id}
</update>
<insert id="createStockProcess" parameterType="InDto">
INSERT INTO stock (id, warehouse_id, product_id, quantity, activation)
VALUES (UUID(), #{warehouse_id}, #{product_id}, #{quantity}, 1)
</insert>
</mapper>

View File

@@ -100,6 +100,13 @@
aria-describedby="basic-addon1">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon4">메모</span>
<input type="text" name="note" id="note" class="form-control"
placeholder="메모를 입력하세요" aria-label="메모" value="${dto.note }"
aria-describedby="basic-addon1">
</div>
<c:set var="userData" value="${sessionScope.userData}" />
<input type='hidden' id="manager_id" value="${userData.id }">
@@ -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("입고 추가에 실패하였습니다.");
}

View File

@@ -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

View File

@@ -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"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div class="mt-5 mb-5 text-center">
<div class="row">
<h1>입고 상세페이지</h1>
<div class="col-10" style="text-align: right;">
<button type="button" class="btn btn-danger" onclick="goDelete()">삭제</button>
</div>
</div>
</div>
<hr>
<div style="text-align: center">
<form>
<div class="ulTag">
<div class="row">
<div class="col-12" style="text-align: center;">
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon1">제품명</span>
<input type="text" class="form-control" placeholder="제품명" aria-label="제품명" value="${dto.productDto.name}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon2">회사명</span>
<input type="text" class="form-control" placeholder="회사명" aria-label="회사명" value="${pDto.company_name}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon3">분류</span>
<input type="text" class="form-control" placeholder="분류" aria-label="분류" value="${pDto.categoryDto.cls_nm_4}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon4">거래처</span>
<input type="text" class="form-control" placeholder="거래처" aria-label="거래처" value="${pDto.vendorDto.name}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon5">수량</span>
<input type="number" class="form-control" placeholder="수량을 입력하세요" aria-label="수량" value="${dto.quantity}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon6">창고명</span>
<input type="text" class="form-control" placeholder="창고명" aria-label="창고명" value="${dto.warehouseDto.name}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon7">입고날짜</span>
<fmt:formatDate value="${dto.in_date}" pattern="yyyy-MM-dd HH:mm:ss" type="date" var="formattedInDate" />
<input type="datetime-local" id="in_date" name="in_date" class="form-control" placeholder="날짜을 입력하세요" aria-label="입고날짜" value="${formattedInDate}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon8">메모</span>
<input type="text" class="form-control" placeholder="메모가 없습니다." aria-label="메모" value="${dto.note}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon9">담당자</span>
<input type="text" class="form-control" placeholder="담당자" aria-label="담당자" value="${dto.accountDto.name}" readonly>
</div>
<input type='hidden' id="id" value="${dto.id}">
</div>
</div>
</div>
<div class="row">
<div class="col-12 ">
<div class="w-40 col-centered" style="text-align: right">
<button type="button" class="btn btn-primary" id="checkBtn">확인</button>
<button type="button" class="btn btn-warning" id="modifyBtn">수정</button>
</div>
</div>
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("#checkBtn").on("click", function() {
$(location).attr("href", "/in/list");
})//checkBtn click
$("#modifyBtn").on("click", function() {
var id = $("#id").val();
var form = document.createElement("form");
form.action = "/in/update";
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();
})//modifyBtn click
});//ready
</script>
</body>
</html>

View File

@@ -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"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div class="mt-5 mb-5 text-center">
<div class="row">
<h1>입고 수정</h1>
</div>
</div>
<hr>
<div style="text-align: center">
<form>
<div class="ulTag">
<div class="row">
<div class="col-12" style="text-align: center;">
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon1">제품명</span>
<input type="text" class="form-control" name="productName" placeholder="제품명을 검색하세요"
aria-label="제품명" id="productName" value="${dto.productDto.name}" readonly>
<button class="btn btn-outline-secondary rounded-end" id="searchProductName"
style="background-color:#FF5E5E;" type="button"
onclick="showSearchModal_product('제품 검색','product')">검색</button>
<input type='hidden' id="product_id" value="">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span id='company_name_span' class="input-group-text">회사명</span>
<input readonly id="company_name" type="text" class="form-control"
value="${pDto.company_name}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span id='cls_Nm_4_span' class="input-group-text">분류</span>
<input readonly id="cls_Nm_4" type="text" class="form-control"
value="${pDto.categoryDto.cls_nm_4}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span id='cls_Nm_4_span' class="input-group-text">거래처</span>
<input readonly id="vendor_name" type="text" class="form-control"
value="${pDto.vendorDto.name}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon2">수량</span>
<input type="number" name="quantity" id="quantity" class="form-control"
value="${dto.quantity}" readonly>
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon3">창고명</span>
<input type="text" name="warehouse_name" id="warehouse_name" class="form-control"
placeholder="창고를 검색하세요" aria-label="창고명" value="${dto.warehouseDto.name}"
aria-describedby="basic-addon1" readonly>
<button class="btn btn-outline-secondary rounded-end" id="searchWarehouseName"
style="background-color:#FF5E5E;" type="button"
onclick="showSearchModal_warehouse('창고 검색','warehouse_capacity_currentCapacity')">검색</button>
<input type='hidden' id="warehouse_id" value="">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span id='address_span' class="input-group-text">주소</span>
<input readonly id="Address_name" type="text" class="form-control"
value="${wDto.address}">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span id='capacity_span' class="input-group-text">용적</span>
<input readonly id="Capacity_name" type="text" class="form-control"
value="${wDto.capacity}">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span id='remainingCapacity_span' class="input-group-text">잔여 용량</span>
<input readonly id="remainingcapacity" type="text" placeholder=""
value="${wDto.currentCapacity}" class="form-control">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon4">입고날짜</span>
<fmt:formatDate value="${dto.in_date}" pattern="yyyy-MM-dd HH:mm:ss" type="date" var="formattedDate" />
<input type="datetime-local" id="in_date" name="in_date" class="form-control"
placeholder="날짜을 입력하세요" aria-label="입고날짜" value="${formattedDate}"
aria-describedby="basic-addon1">
</div>
<div class="input-group mb-3 w-40 col-centered">
<span class="input-group-text" id="basic-addon5">메모</span>
<input type="text" name="note" id="note" class="form-control"
placeholder="메모를 입력하세요" aria-label="메모" value="${dto.note}"
aria-describedby="basic-addon1">
</div>
<c:set var="userData" value="${sessionScope.userData}" />
<input type='hidden' id="manager_id" value="${userData.id}">
</div>
</div>
</div>
<div class="row">
<div class="col-12 ">
<div class="w-40 col-centered" style="text-align: right">
<button type="button" class="btn btn-primary" id="submitBtn">수정 완료</button>
<button type="button" class="btn btn-secondary" id="cancelBtn">취소</button>
</div>
</div>
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
$("#cancelBtn").on("click", function(){
var id = $("#id").val();
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();
})//cancelBtn
$("#submitBtn").on("click", function(){
var product_id = $("#product_id").val();
var quantity = $("#quantity").val();
var warehouse_id = $("#warehouse_id").val();
var in_date = $("#in_date").val();
var manager_id = $("#manager_id").val();
var note = $("#note").val();
if(!name){
alert("제품명을 입력해야 합니다.");
$("#name").focus();
return false;
}
if(!product_id){
alert("제품을 선택해야합니다.");
return false;
}
if(!quantity){
alert("수량을 입력해야 합니다.");
$("#quantity").focus();
return false;
}
if(!warehouse_id){
alert("창고을 선택해야합니다.");
return false;
}
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,
note : note
}
$.ajax({
url: "/in/update_process",
type: "put",
data: data,
datatype:"json"
}).done(function(data) {
if (data == true) {
alert("입고 정보를 수정했습니다.");
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();
} else {
alert("입고 수정에 실패하였습니다.");
}
}).fail(function() {
alert("오류가 발생했습니다.");
}).always(function() {
//
});
});//submitBtn
});//ready
function showSearchModal(title, val){
$("#searchModalLabel").text(title);
const data = { name : val};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/product/show_modal', // 요청할 서버url
dataType : 'html', // 데이터 타입 (html, xml, json, text 등등)
data : data,
success : function(result) { // 결과 성공 콜백함수
$("#search_modal_body").html(result);
searchModalBootStrap.show();
},
error : function(request, status, error) {
alert(error)
}
});
}
function showSearchModal2(title, val){
$("#searchModalLabel").text(title);
const data = { name : val};
$.ajax({
type : 'post', // 타입 (get, post, put 등등)
url : '/product/show_modal2', // 요청할 서버url
dataType : 'html', // 데이터 타입 (html, xml, json, text 등등)
data : data,
success : function(result) { // 결과 성공 콜백함수
$("#search_modal_body").html(result);
searchModalBootStrap.show();
},
error : function(request, status, error) {
alert(error)
}
});
}
</script>
</body>
</html>