mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-05 12:13:33 +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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user