|
@@ -6,13 +6,16 @@ import com.iamberry.rst.core.cm.SalesOrderItem;
|
|
|
import com.iamberry.rst.core.fm.InventoryInfo;
|
|
|
import com.iamberry.rst.core.fm.InventoryLog;
|
|
|
import com.iamberry.rst.core.order.OrderWarehouse;
|
|
|
+import com.iamberry.rst.core.order.ProductColor;
|
|
|
import com.iamberry.rst.core.page.PageRequest;
|
|
|
import com.iamberry.rst.core.page.PagedResult;
|
|
|
import com.iamberry.rst.faces.cm.InventoryService;
|
|
|
import com.iamberry.rst.service.fm.mapper.InventoryLogMapper;
|
|
|
import com.iamberry.rst.service.fm.mapper.InventoryMapper;
|
|
|
import com.iamberry.rst.service.order.mapper.OrderWarehouseMapper;
|
|
|
+import com.iamberry.rst.service.product.mapper.ProductColorMapper;
|
|
|
import com.iamberry.rst.util.PageUtil;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -35,6 +38,8 @@ public class InventoryServiceImpl implements InventoryService {
|
|
|
private InventoryLogMapper inventoryLogMapper;
|
|
|
@Autowired
|
|
|
private OrderWarehouseMapper orderWarehouseMapper;
|
|
|
+ @Autowired
|
|
|
+ private ProductColorMapper productColorMapper;
|
|
|
|
|
|
@Override
|
|
|
public InventoryInfo getByInventoryId(Integer inventoryId) {
|
|
@@ -68,12 +73,28 @@ public class InventoryServiceImpl implements InventoryService {
|
|
|
@Override
|
|
|
public Integer addInventory(InventoryInfo invent) {
|
|
|
Integer flag = 0;
|
|
|
- if(invent.getInventoryProductBar() == null || invent.getWarehouseId() == null){
|
|
|
- throw new RuntimeException("【入库】更新库存失败,入库需要产品SKU与仓库ID。");
|
|
|
+ if(invent.getWarehouseId() == null){
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,出库仓库ID。");
|
|
|
+ }
|
|
|
+ if(invent.getInventoryProductBar() == null && invent.getInventoryProductColorId() == null){
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,出库需要产品SKU或颜色ID。");
|
|
|
+ }else{
|
|
|
+ ProductColor productColor = null;
|
|
|
+ if(!StringUtils.isEmpty(invent.getInventoryProductBar())){
|
|
|
+ productColor = productColorMapper.getProductColorByBar(invent.getInventoryProductBar());
|
|
|
+ }else{
|
|
|
+ productColor = productColorMapper.getProductColorById(invent.getInventoryProductColorId());
|
|
|
+ }
|
|
|
+ if(productColor != null){
|
|
|
+ invent.setInventoryProductBar(productColor.getColorBar());
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,产品SKU或颜色ID出错。");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
OrderWarehouse orderWarehouse = orderWarehouseMapper.getOrderWarehouseById(invent.getWarehouseId());
|
|
|
if(orderWarehouse == null){
|
|
|
- throw new RuntimeException("【入库】更新库存失败,查询仓库信息失败。");
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,查询仓库信息失败。");
|
|
|
}
|
|
|
String warehouseName = orderWarehouse.getWarehouseName();
|
|
|
InventoryInfo info = inventoryMapper.getByInventoryByBar(invent.getInventoryProductBar(),invent.getWarehouseId());
|
|
@@ -142,9 +163,25 @@ public class InventoryServiceImpl implements InventoryService {
|
|
|
@Override
|
|
|
public Integer minusInventory(InventoryInfo invent) {
|
|
|
Integer flag = 0;
|
|
|
- if(invent.getInventoryProductBar() == null || invent.getWarehouseId() == null){
|
|
|
- throw new RuntimeException("【出库】更新库存失败,出库需要产品SKU与仓库ID。");
|
|
|
+ if(invent.getWarehouseId() == null){
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,出库仓库ID。");
|
|
|
+ }
|
|
|
+ if(invent.getInventoryProductBar() == null && invent.getInventoryProductColorId() == null){
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,出库需要产品SKU或颜色ID。");
|
|
|
+ }else{
|
|
|
+ ProductColor productColor = null;
|
|
|
+ if(!StringUtils.isEmpty(invent.getInventoryProductBar())){
|
|
|
+ productColor = productColorMapper.getProductColorByBar(invent.getInventoryProductBar());
|
|
|
+ }else{
|
|
|
+ productColor = productColorMapper.getProductColorById(invent.getInventoryProductColorId());
|
|
|
+ }
|
|
|
+ if(productColor != null){
|
|
|
+ invent.setInventoryProductBar(productColor.getColorBar());
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,产品SKU或颜色ID出错。");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
OrderWarehouse orderWarehouse = orderWarehouseMapper.getOrderWarehouseById(invent.getWarehouseId());
|
|
|
if(orderWarehouse == null){
|
|
|
throw new RuntimeException("【出库】更新库存失败,查询仓库信息失败。");
|