StockMapper.java
StockService.java
StockController.java
StockMapper.xml
This commit is contained in:
sungsu
2024-01-22 11:02:49 +09:00
parent ba94f72e5e
commit e2f8967403
4 changed files with 74 additions and 40 deletions

View File

@@ -147,13 +147,8 @@ public class StockController {
@PostMapping("/create_process")
@ResponseBody
public boolean createProcess(StockDto dto) {
int i = service.createStock(dto);
if (i != 0) {
service.updateWarehousePlus(dto);
service.checkandUpdateOrCreateProcess(dto);
return true;
} else {
return false;
}
}

View File

@@ -1,5 +1,6 @@
package com.no1.wms.stock;
import com.no1.wms.in.InDto;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -43,6 +44,12 @@ public interface StockMapper {
int warehouseCount(Map<String, Object> m);//검색 글 갯수
int checkIfExistsStock(StockDto dto);
int updateStockProcess(StockDto dto);
int createStockProcess(StockDto dto);
}

View File

@@ -1,5 +1,6 @@
package com.no1.wms.stock;
import com.no1.wms.in.InDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -13,24 +14,24 @@ import java.util.Map;
public class StockService {
@Autowired
StockMapper mapper;
public int count(int searchn, String search) {
System.out.println(searchn+search);
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
System.out.println(searchn + search);
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn", searchn);
m.put("search", search);
return mapper.count(m);
}
public List<Map<String, Object>> list(int searchn, String search, int start, int perPage){
System.out.println(searchn+search);
public List<Map<String, Object>> list(int searchn, String search, int start, int perPage) {
System.out.println(searchn + search);
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("searchn", searchn);
m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
@@ -38,26 +39,26 @@ public class StockService {
List<Map<String, Object>> result = mapper.list(m);
log.debug("warehouseOne테스트 :: " + result);
return result;
}
public int count2(int searchn, String search) {
System.out.println(searchn+search);
System.out.println(searchn + search);
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn", searchn);
m.put("search", search);
return mapper.count2(m);
}
public List<Map<String, Object>> list2(int searchn, String search, int start, int perPage){
public List<Map<String, Object>> list2(int searchn, String search, int start, int perPage) {
System.out.println(searchn+search);
System.out.println(searchn + search);
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("searchn", searchn);
m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
@@ -68,30 +69,30 @@ public class StockService {
}
public Map<String, Object> stockOne(String id) {
return mapper.stockOne(id);
}
public int createStock(StockDto dto) {
return mapper.createStock(dto);
}
public int updateStock(StockDto dto) {
return mapper.updateStock(dto);
}
public int updateWarehouse(StockDto dto){
public int updateWarehouse(StockDto dto) {
return mapper.updateWarehouse(dto);
}
public int updateWarehousePlus(StockDto dto){
public int updateWarehousePlus(StockDto dto) {
return mapper.updateWarehousePlus(dto);
}
public int updateWarehouseDeleteStock(StockDto dto){
public int updateWarehouseDeleteStock(StockDto dto) {
return mapper.updateWarehouseDeleteStock(dto);
}
@@ -100,7 +101,7 @@ public class StockService {
}
public List<Map<String, Object>> productSelect(int searchn, String search, int start, int perPage){
public List<Map<String, Object>> productSelect(int searchn, String search, int start, int perPage) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn", searchn);
m.put("search", search);
@@ -115,13 +116,13 @@ public class StockService {
public int productCount(int searchn, String search) {
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn", searchn);
m.put("search", search);
return mapper.productCount(m);
}
public List<Map<String, Object>> warehousesSelect(int searchn, String search, int start, int perPage){
public List<Map<String, Object>> warehousesSelect(int searchn, String search, int start, int perPage) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn", searchn);
m.put("search", search);
@@ -136,8 +137,8 @@ public class StockService {
public int warehouseCount(int searchn, String search) {
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn", searchn);
m.put("search", search);
return mapper.warehouseCount(m);
}
@@ -147,5 +148,16 @@ public class StockService {
}
}
//createProcess
public boolean checkandUpdateOrCreateProcess(StockDto dto){
int j = mapper.checkIfExistsStock(dto);
if (j == 1){
mapper.updateStockProcess(dto);
}else{
mapper.createStockProcess(dto);
}
mapper.updateWarehousePlus(dto);
return true;
}
}

View File

@@ -210,4 +210,24 @@
where id = #{id}
</delete>
<!-- delete -->
<select id="checkIfExistsStock" resultType="int" parameterType="com.no1.wms.stock.StockDto">
SELECT COUNT(*) FROM stock
WHERE warehouse_id = #{warehouseId} AND product_id = #{productId}
</select>
<update id="updateStockProcess" parameterType="com.no1.wms.stock.StockDto">
UPDATE stock
SET quantity = quantity + #{quantity}
WHERE warehouse_id = #{warehouseId} AND product_id = #{productId}
</update>
<insert id="createStockProcess" parameterType="com.no1.wms.stock.StockDto">
INSERT INTO stock (id, warehouse_id, product_id, quantity, activation)
VALUES (UUID(), #{warehouseId}, #{productId}, #{quantity}, 1)
</insert>
</mapper>