|
|
@ -13,14 +13,11 @@ import com.hw.common.security.utils.SecurityUtils;
|
|
|
|
import com.hw.mes.api.RemoteMesService;
|
|
|
|
import com.hw.mes.api.RemoteMesService;
|
|
|
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
|
|
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
|
|
|
import com.hw.wms.config.WmsConfig;
|
|
|
|
import com.hw.wms.config.WmsConfig;
|
|
|
|
import com.hw.wms.domain.WmsBaseWarehouse;
|
|
|
|
import com.hw.wms.domain.*;
|
|
|
|
import com.hw.wms.domain.WmsProductStock;
|
|
|
|
|
|
|
|
import com.hw.wms.domain.vo.WmsProduceInstockVo;
|
|
|
|
import com.hw.wms.domain.vo.WmsProduceInstockVo;
|
|
|
|
import com.hw.wms.domain.vo.WmsProductOutstockAuditVo;
|
|
|
|
import com.hw.wms.domain.vo.WmsProductOutstockAuditVo;
|
|
|
|
import com.hw.wms.domain.vo.WmsProductOutstockConfirmVo;
|
|
|
|
import com.hw.wms.domain.vo.WmsProductOutstockConfirmVo;
|
|
|
|
import com.hw.wms.mapper.WmsBaseWarehouseMapper;
|
|
|
|
import com.hw.wms.mapper.*;
|
|
|
|
import com.hw.wms.mapper.WmsProductOutstockDetailMapper;
|
|
|
|
|
|
|
|
import com.hw.wms.mapper.WmsProductStockMapper;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
@ -28,9 +25,6 @@ import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
|
|
import com.hw.common.core.utils.StringUtils;
|
|
|
|
import com.hw.common.core.utils.StringUtils;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import com.hw.wms.domain.WmsProductOutstockDetail;
|
|
|
|
|
|
|
|
import com.hw.wms.mapper.WmsProductOutstockMapper;
|
|
|
|
|
|
|
|
import com.hw.wms.domain.WmsProductOutstock;
|
|
|
|
|
|
|
|
import com.hw.wms.service.IWmsProductOutstockService;
|
|
|
|
import com.hw.wms.service.IWmsProductOutstockService;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
@ -52,6 +46,9 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private WmsProductStockMapper wmsProductStockMapper;
|
|
|
|
private WmsProductStockMapper wmsProductStockMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private WmsStockTotalMapper wmsStockTotalMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
|
|
|
|
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
|
|
|
|
|
|
|
|
|
|
|
@ -98,6 +95,7 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
* @return 结果
|
|
|
|
* @return 结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public int insertWmsProductOutstock(WmsProductOutstock wmsProductOutstock) {
|
|
|
|
public int insertWmsProductOutstock(WmsProductOutstock wmsProductOutstock) {
|
|
|
|
Long warehouseId = wmsProductOutstock.getWarehouseId();
|
|
|
|
Long warehouseId = wmsProductOutstock.getWarehouseId();
|
|
|
|
String saleorderCode = wmsProductOutstock.getSaleorderCode();
|
|
|
|
String saleorderCode = wmsProductOutstock.getSaleorderCode();
|
|
|
@ -107,26 +105,22 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
throw new ServiceException("申请数量需大于0");
|
|
|
|
throw new ServiceException("申请数量需大于0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WmsProductStock queryProductStock = new WmsProductStock();
|
|
|
|
WmsStockTotal queryStockTotal = new WmsStockTotal();
|
|
|
|
queryProductStock.setWarehouseId(warehouseId);
|
|
|
|
queryStockTotal.setWarehouseId(warehouseId);
|
|
|
|
queryProductStock.setSaleorderCode(saleorderCode);
|
|
|
|
queryStockTotal.setMaterialId(productId);
|
|
|
|
queryProductStock.setProductId(productId);
|
|
|
|
queryStockTotal.setSaleOrderId(wmsProductOutstock.getSaleOrderId());
|
|
|
|
queryProductStock.setSaleOrderId(wmsProductOutstock.getSaleOrderId());
|
|
|
|
List<WmsStockTotal> wmsStockTotals = wmsStockTotalMapper.selectOnlyWmsStockTotalList(queryStockTotal);
|
|
|
|
|
|
|
|
if (wmsStockTotals == null || wmsStockTotals.isEmpty()) {
|
|
|
|
//group by wps.warehouse_id,wps.sale_order_id,wps.product_id获取的以下库存信息
|
|
|
|
|
|
|
|
List<WmsProductStock> productStocks = wmsProductStockMapper.selectWmsProductStocksBySaleorder(queryProductStock);
|
|
|
|
|
|
|
|
if (productStocks == null || productStocks.isEmpty()) {
|
|
|
|
|
|
|
|
throw new ServiceException("没有库存");
|
|
|
|
throw new ServiceException("没有库存");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WmsStockTotal wmsStockTotal = wmsStockTotals.get(0);
|
|
|
|
|
|
|
|
|
|
|
|
WmsProductStock productStock = productStocks.get(0);
|
|
|
|
|
|
|
|
BigDecimal orderAmount = productStock.getOrderAmount();
|
|
|
|
|
|
|
|
/*获取仓库可用库存数量*/
|
|
|
|
/*获取仓库可用库存数量*/
|
|
|
|
BigDecimal totalAmount = productStock.getTotalAmount() == null ? BigDecimal.ZERO : productStock.getTotalAmount();
|
|
|
|
BigDecimal totalAmount = wmsStockTotal.getTotalAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getTotalAmount();
|
|
|
|
BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount();//冻结数量暂时没用
|
|
|
|
BigDecimal frozenAmount = wmsStockTotal.getFrozenAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getFrozenAmount();//冻结数量暂时没用
|
|
|
|
BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount();//
|
|
|
|
BigDecimal occupyAmount = wmsStockTotal.getOccupyAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getOccupyAmount();//
|
|
|
|
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
|
|
|
|
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
|
|
|
|
BigDecimal sumApplyQty = productStock.getApplyAmount() == null ? BigDecimal.ZERO : productStock.getApplyAmount();//获取已申请出库数量
|
|
|
|
// BigDecimal sumApplyQty = productStock.getApplyAmount() == null ? BigDecimal.ZERO : productStock.getApplyAmount();//获取已申请出库数量
|
|
|
|
|
|
|
|
|
|
|
|
// WmsProductOutstock queryProductOutStock = new WmsProductOutstock();
|
|
|
|
// WmsProductOutstock queryProductOutStock = new WmsProductOutstock();
|
|
|
|
// queryProductOutStock.setSaleorderCode(saleorderCode);
|
|
|
|
// queryProductOutStock.setSaleorderCode(saleorderCode);
|
|
|
@ -136,11 +130,8 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
// List<WmsProductOutstock> wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutStock);
|
|
|
|
// List<WmsProductOutstock> wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutStock);
|
|
|
|
// BigDecimal sumApplyQty = wmsProductOutstocks.stream().map(WmsProductOutstock::getApplyQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
// BigDecimal sumApplyQty = wmsProductOutstocks.stream().map(WmsProductOutstock::getApplyQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
|
|
//可申请数量
|
|
|
|
if (applyQty.compareTo(availableAmount) > 0) {
|
|
|
|
BigDecimal availableApplyQty = availableAmount.subtract(sumApplyQty);
|
|
|
|
throw new ServiceException("可申请数量为" + availableAmount);
|
|
|
|
|
|
|
|
|
|
|
|
if (applyQty.compareTo(availableApplyQty) > 0) {
|
|
|
|
|
|
|
|
throw new ServiceException("可申请数量为" + availableApplyQty);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
|
|
|
|
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
|
|
|
@ -165,6 +156,12 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
|
|
|
|
|
|
|
int rows = wmsProductOutstockMapper.insertWmsProductOutstock(wmsProductOutstock);
|
|
|
|
int rows = wmsProductOutstockMapper.insertWmsProductOutstock(wmsProductOutstock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wmsStockTotal.setOccupyAmount(occupyAmount.add(applyQty));
|
|
|
|
|
|
|
|
wmsStockTotal.setUpdateBy(userName);
|
|
|
|
|
|
|
|
wmsStockTotal.setUpdateDate(currentDate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wmsStockTotalMapper.updateWmsStockTotal(wmsStockTotal);
|
|
|
|
|
|
|
|
|
|
|
|
//如果是agv自动仓库,需要调用WCS轮询查询成品出库记录进行调度出库
|
|
|
|
//如果是agv自动仓库,需要调用WCS轮询查询成品出库记录进行调度出库
|
|
|
|
|
|
|
|
|
|
|
|
return rows;
|
|
|
|
return rows;
|
|
|
|