mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 12:13:24 +09:00
in complete
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@@ -78,8 +79,10 @@ public class InController {
|
||||
|
||||
@PostMapping("/create_process")
|
||||
@ResponseBody
|
||||
public boolean createProcess(InDto dto) {
|
||||
return inService.chechAndUpdateOrCreateProcess(dto);
|
||||
public int createProcess(InDto dto) {
|
||||
boolean create = inService.chechAndUpdateOrCreateProcessForCreate(dto);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@PostMapping("/read")
|
||||
@@ -109,13 +112,9 @@ public class InController {
|
||||
// 수정 - Ajax
|
||||
@PutMapping("/update_process")
|
||||
@ResponseBody
|
||||
public boolean update_process(InDto dto) {
|
||||
int i = inService.updateById(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public boolean updateProcess(InDto dto) {
|
||||
return inService.chechAndUpdateProcess(dto);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +199,11 @@ public class InController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ResponseBody
|
||||
public boolean delete(String id) {
|
||||
return inService.deactivateById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,5 +16,10 @@ public interface InMapper {
|
||||
int checkIfExistsStock(InDto dto);
|
||||
int updateStockProcess(InDto dto);
|
||||
int createStockProcess(InDto dto);
|
||||
|
||||
int currntStockQuantity(InDto dto);
|
||||
int currntInQuantity(InDto dto);
|
||||
int updateStockProcessForUpdate(InDto dto);
|
||||
int deactivateById(String id);
|
||||
String selectWarehouseQuantity(String warehouseId);
|
||||
int updateWarehouseQuantity(Map<String, Object> m);
|
||||
}
|
||||
|
||||
@@ -59,14 +59,17 @@ public class InService {
|
||||
}
|
||||
|
||||
//createProcess
|
||||
public boolean chechAndUpdateOrCreateProcess(InDto dto) {
|
||||
public boolean chechAndUpdateOrCreateProcessForCreate(InDto dto) {
|
||||
|
||||
|
||||
|
||||
int j = mapper.checkIfExistsStock(dto);
|
||||
if(j == 1) {
|
||||
int k = mapper.updateStockProcess(dto);
|
||||
if(k == 1) {
|
||||
int i = mapper.createProcess(dto);
|
||||
if(i == k) {
|
||||
System.out.println("달라서 새로만듬");
|
||||
//System.out.println("같아서 합침");
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
@@ -80,7 +83,7 @@ public class InService {
|
||||
if(k == 1) {
|
||||
int i = mapper.createProcess(dto);
|
||||
if(i == k) {
|
||||
System.out.println("같아서 합침");
|
||||
//System.out.println("달라서 새로만듬");
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
@@ -93,7 +96,68 @@ public class InService {
|
||||
}
|
||||
}
|
||||
|
||||
//updateProcess
|
||||
public boolean chechAndUpdateProcess(InDto dto) {
|
||||
int j = mapper.checkIfExistsStock(dto);//재고에 동일한 창고, 제품이 있는지
|
||||
if(j == 1) {//재고에 동일한 창고, 제품이 있다면
|
||||
int currentStockQuantity = mapper.currntStockQuantity(dto);//현재 재고의 개수
|
||||
int changeInQuantity = Integer.parseInt(dto.getQuantity());//변경된 입고의 개수
|
||||
int currentInQuantity = mapper.currntInQuantity(dto);//기존의 입고의 개수
|
||||
int modifiedStockQuantity = currentStockQuantity + changeInQuantity - currentInQuantity;//수정된 재고의 개수
|
||||
if(currentStockQuantity == modifiedStockQuantity) {//현재 재고의 개수와 변한 재고의 개수가 같다면
|
||||
int i = mapper.updateById(dto);//재고는 놔두고 입고만 업데이트 한다
|
||||
if(i == 1) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else{//현재 재고의 개수보다 변한 재고의 개수가 더 크거나 작다면
|
||||
int i = mapper.updateById(dto); // 입고를 먼저 업데이트하고
|
||||
dto.setQuantity(modifiedStockQuantity+"");// 변경 개수를 적용하여
|
||||
int k = mapper.updateStockProcessForUpdate(dto); // 재고테이블에 반영한다.
|
||||
if (i == k) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}//else
|
||||
}else {// 재고에 동일 재품 동일 창고가 없다면 오류발생.
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean deactivateById(String id) {
|
||||
InDto dto = mapper.selectById(id);
|
||||
int j = mapper.checkIfExistsStock(dto);//재고에 동일한 창고, 제품이 있는지
|
||||
if(j == 1) {
|
||||
int currentStockQuantity = mapper.currntStockQuantity(dto);//스톡의 재고수
|
||||
int deactivateInQuantity = Integer.parseInt(dto.getQuantity());//in의 재고수
|
||||
if(currentStockQuantity >= deactivateInQuantity) {//스톡의 재고수가 in의 재고수보다 많을 때
|
||||
mapper.deactivateById(id);// 입고 비활성화
|
||||
int modifiedStockQuantity = currentStockQuantity - deactivateInQuantity;
|
||||
dto.setQuantity(modifiedStockQuantity+"");// 변경 개수를 적용하여
|
||||
int k = mapper.updateStockProcessForUpdate(dto); // 재고테이블에 반영한다.
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
//사용하지 않음.
|
||||
public void updateWarehouse(InDto dto) {
|
||||
String warehouseId = dto.getId();
|
||||
String updateValue = mapper.selectWarehouseQuantity(warehouseId);
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
m.put("warehouseId", warehouseId);
|
||||
m.put("updateValue", updateValue);
|
||||
mapper.updateWarehouseQuantity(m);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,11 +38,14 @@
|
||||
|
||||
<!-- 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 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>
|
||||
|
||||
|
||||
<insert id="createStockProcess" parameterType="InDto">
|
||||
INSERT INTO stock (id, warehouse_id, product_id, quantity, activation)
|
||||
VALUES (UUID(), #{warehouse_id}, #{product_id}, #{quantity}, 1)
|
||||
</insert>
|
||||
|
||||
|
||||
<!-- update -->
|
||||
@@ -52,13 +55,30 @@
|
||||
warehouse_id = #{warehouse_id}, manager_id = #{manager_id}, note = #{note}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<update id="deactivateById" parameterType="String">
|
||||
UPDATE product_in
|
||||
SET activation = 0
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateStockProcessForUpdate" parameterType="InDto">
|
||||
UPDATE stock
|
||||
SET quantity = #{quantity}
|
||||
WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id} and activation = 1
|
||||
</update>
|
||||
|
||||
<update id="updateStockProcess" parameterType="InDto">
|
||||
UPDATE stock
|
||||
SET quantity = quantity + #{quantity}
|
||||
WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id} and activation = 1
|
||||
</update>
|
||||
|
||||
<update id="updateWarehouseQuantity" parameterType="Map">
|
||||
update warehouse set current_capacity = #{updateValue} where id = #{warehouseId} and activation = 1
|
||||
</update>
|
||||
|
||||
<!-- delete -->
|
||||
|
||||
<!-- select -->
|
||||
<select id="count" parameterType="map" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
@@ -141,19 +161,29 @@
|
||||
|
||||
<select id="checkIfExistsStock" resultType="int" parameterType="InDto">
|
||||
SELECT COUNT(*) FROM stock
|
||||
WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id}
|
||||
WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id} and activation = 1
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
<select id="currntStockQuantity" parameterType="InDto" resultType="int">
|
||||
SELECT quantity
|
||||
FROM stock
|
||||
WHERE warehouse_id = #{warehouse_id} AND product_id = #{product_id} and activation = 1
|
||||
</select>
|
||||
|
||||
<select id="currntInQuantity" parameterType="InDto" resultType="int">
|
||||
SELECT quantity
|
||||
FROM product_in
|
||||
WHERE id = #{id} and activation = 1
|
||||
</select>
|
||||
|
||||
<select id="selectWarehouseQuantity" parameterType="String" resultType="String">
|
||||
select sum(quantity) from stock where warehouse_id = #{warehouseId} and activation = 1
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row row-buttons">
|
||||
<div class="col-3 text-start">
|
||||
<!-- <img alt="엑셀이미지" src="엑셀이미지"> -->
|
||||
<img width="50" height="50" src="https://img.icons8.com/color/48/ms-excel.png" alt="ms-excel"/>
|
||||
<button type="button" class="btn btn-success" id="downlodeExcelForm">양식다운로드</button>
|
||||
|
||||
|
||||
@@ -101,25 +101,10 @@
|
||||
</div><!-- row row-buttons -->
|
||||
<div class="row row-buttons">
|
||||
<form name="uplodeExcleForm" id="uplodeExcleForm" method="post" onsubmit="return _onSubmit();" action="/category/uplodeExcel" enctype="multipart/form-data" class="form-horizontal">
|
||||
<div class="col-4 text-start">
|
||||
<table id="datatable-scroller" class="table table-bordered tbl_Form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="active" style="text-align:right"><label class="control-label" for="">파일 업로드</label></th>
|
||||
<td>
|
||||
<input type="file" name="file" id="file" accept=".xlsx, .xls"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-4 text-start">
|
||||
<div class="d-flex justify-content-start align-items-center">
|
||||
<button type="submit" class="btn btn-success" id="uploadExcel">업로드</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="file" name="file" id="file" accept=".xlsx, .xls"/>
|
||||
<button type="submit" class="btn btn-success" id="uploadExcel">업로드</button>
|
||||
</form><!-- uplodeExcleForm -->
|
||||
|
||||
</div><!-- row row-buttons -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
alert("삭제되었습니다.");
|
||||
$(location).attr("href", "/category/list");
|
||||
} else {
|
||||
alert("정상적으로 삭제되지 않았습니다..");
|
||||
alert("정상적으로 삭제되지 않았습니다.");
|
||||
}
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
@@ -127,8 +127,6 @@
|
||||
$("#yesNoModalBodyTextDiv").text(yesNoModal.body);
|
||||
yesNoModal.yesFunction = deleteCategoryFunction;
|
||||
yesNoModalBootStrap.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -138,6 +138,10 @@
|
||||
var in_date = $("#in_date").val();
|
||||
var manager_id = $("#manager_id").val();
|
||||
var note = $("#note").val();
|
||||
var quantity = parseInt($("#quantity").val(), 10);
|
||||
var remainingcapacity = parseInt($("#remainingcapacity").val(), 10);
|
||||
|
||||
|
||||
|
||||
if(!product_id){
|
||||
alert("제품을 선택해야합니다.");
|
||||
@@ -153,6 +157,12 @@
|
||||
alert("창고을 선택해야합니다.");
|
||||
return false;
|
||||
}
|
||||
if (quantity > remainingcapacity) {
|
||||
alert("적재 할 재고량이 잔여 용량을 넘을 수 없습니다.");
|
||||
$("#quantity").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!in_date){
|
||||
in_date = new Date();
|
||||
in_date = in_date.toISOString();
|
||||
|
||||
@@ -113,8 +113,41 @@
|
||||
|
||||
});//ready
|
||||
|
||||
function deleteInFunction(){
|
||||
var id = $("#id").val();
|
||||
$.ajax({
|
||||
url: "/in/delete",
|
||||
type: "delete",
|
||||
data: {
|
||||
"id": id
|
||||
},
|
||||
datatype:"json"
|
||||
}).done(function(data) {
|
||||
if (data == true) {
|
||||
alert("삭제되었습니다.");
|
||||
$(location).attr("href", "/in/list");
|
||||
} else {
|
||||
alert("정상적으로 삭제되지 않았습니다.");
|
||||
}
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
}).always(function() {
|
||||
//
|
||||
});
|
||||
|
||||
}//deleteInFunction
|
||||
|
||||
|
||||
function goDelete(){
|
||||
yesNoModalTextDefine("입고 삭제", "해당 입고를 삭제하시겠습니까?");
|
||||
$("#yesNoModalLabel").text(yesNoModal.title);
|
||||
$("#yesNoModalBodyTextDiv").text(yesNoModal.body);
|
||||
yesNoModal.yesFunction = deleteInFunction;
|
||||
yesNoModalBootStrap.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -28,7 +28,7 @@
|
||||
<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="">
|
||||
<input type='hidden' id="product_id" value="${dto.product_id}">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
@@ -52,7 +52,7 @@
|
||||
<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>
|
||||
value="${dto.quantity}">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
@@ -63,7 +63,7 @@
|
||||
<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="">
|
||||
<input type='hidden' id="warehouse_id" value="${dto.warehouse_id}">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
@@ -145,11 +145,11 @@
|
||||
var in_date = $("#in_date").val();
|
||||
var manager_id = $("#manager_id").val();
|
||||
var note = $("#note").val();
|
||||
if(!name){
|
||||
alert("제품명을 입력해야 합니다.");
|
||||
$("#name").focus();
|
||||
return false;
|
||||
}
|
||||
var id = $("#id").val();
|
||||
var quantityAdjustment = parseInt($("#quantityAdjustment").val(), 10);
|
||||
var remainingcapacity = parseInt($("#remainingcapacity").val(), 10);
|
||||
|
||||
|
||||
if(!product_id){
|
||||
alert("제품을 선택해야합니다.");
|
||||
return false;
|
||||
@@ -164,6 +164,12 @@
|
||||
alert("창고을 선택해야합니다.");
|
||||
return false;
|
||||
}
|
||||
if (quantityAdjustment > remainingcapacity) {
|
||||
alert("적재 할 재고량이 재고량 한도를 넘을 수 없습니다.");
|
||||
$("#quantityAdjustment").focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!in_date){
|
||||
in_date = new Date();
|
||||
in_date = in_date.toISOString();
|
||||
@@ -178,9 +184,10 @@
|
||||
in_date : in_date,
|
||||
manager_id : manager_id,
|
||||
warehouse_id : warehouse_id,
|
||||
note : note
|
||||
note : note,
|
||||
id : id
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
$.ajax({
|
||||
url: "/in/update_process",
|
||||
type: "put",
|
||||
@@ -208,6 +215,7 @@
|
||||
|
||||
} else {
|
||||
alert("입고 수정에 실패하였습니다.");
|
||||
console.log(data);
|
||||
}
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
|
||||
Reference in New Issue
Block a user