mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 19:54:00 +09:00
#수정
StockMapper.java StockService.java StockController.java StockMapper.xml
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -44,5 +45,11 @@ public interface StockMapper {
|
||||
|
||||
|
||||
|
||||
int checkIfExistsStock(StockDto dto);
|
||||
int updateStockProcess(StockDto dto);
|
||||
int createStockProcess(StockDto dto);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -16,21 +17,21 @@ public class StockService {
|
||||
|
||||
public int count(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.count(m);
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> list(int searchn, String search, int start, int perPage){
|
||||
public List<Map<String, Object>> list(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);
|
||||
@@ -43,21 +44,21 @@ public class StockService {
|
||||
|
||||
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);
|
||||
@@ -83,15 +84,15 @@ public class StockService {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user