|
|
|
@ -4,12 +4,18 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import com.hw.common.core.constant.SecurityConstants;
|
|
|
|
|
import com.hw.common.core.constant.WmsConstants;
|
|
|
|
|
import com.hw.common.core.domain.R;
|
|
|
|
|
import com.hw.common.core.exception.ServiceException;
|
|
|
|
|
import com.hw.common.core.utils.uuid.Seq;
|
|
|
|
|
import com.hw.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.hw.mes.api.RemoteMesService;
|
|
|
|
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
|
|
|
|
import com.hw.wms.config.WmsConfig;
|
|
|
|
|
import com.hw.wms.domain.WmsBaseWarehouse;
|
|
|
|
|
import com.hw.wms.domain.WmsProductStock;
|
|
|
|
|
import com.hw.wms.domain.vo.WmsProduceInstockVo;
|
|
|
|
|
import com.hw.wms.domain.vo.WmsProductOutstockConfirmVo;
|
|
|
|
|
import com.hw.wms.mapper.WmsBaseWarehouseMapper;
|
|
|
|
|
import com.hw.wms.mapper.WmsProductOutstockDetailMapper;
|
|
|
|
@ -26,6 +32,8 @@ import com.hw.wms.mapper.WmsProductOutstockMapper;
|
|
|
|
|
import com.hw.wms.domain.WmsProductOutstock;
|
|
|
|
|
import com.hw.wms.service.IWmsProductOutstockService;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 成品出库记录Service业务层处理
|
|
|
|
|
*
|
|
|
|
@ -46,6 +54,12 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
@Autowired
|
|
|
|
|
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private WmsConfig wmsConfig;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private RemoteMesService remoteMesService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询成品出库记录
|
|
|
|
|
*
|
|
|
|
@ -97,6 +111,8 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
queryProductStock.setSaleorderCode(saleorderCode);
|
|
|
|
|
queryProductStock.setProductId(productId);
|
|
|
|
|
queryProductStock.setSaleOrderId(wmsProductOutstock.getSaleOrderId());
|
|
|
|
|
|
|
|
|
|
//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("没有库存");
|
|
|
|
@ -270,4 +286,57 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
return wmsProductOutstockDetailMapper.updateWmsProductOutstockDetail(productOutstockDetail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增成品出库记录(适用于Web端,适用于4楼成品出库,出虚拟库,无库位)
|
|
|
|
|
*
|
|
|
|
|
* @param wmsProduceInstockVo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int fourthFloorProduceOutstock(WmsProduceInstockVo wmsProduceInstockVo) {
|
|
|
|
|
//对内生产可直接出库,外部销售需要申请后才能出库(外部销售在手机端操作出库)
|
|
|
|
|
Long warehouseId = wmsConfig.getFourthFloorProductWarehouseId();
|
|
|
|
|
String materialBarcode = wmsProduceInstockVo.getMaterialBarcode();
|
|
|
|
|
|
|
|
|
|
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode);
|
|
|
|
|
BigDecimal availableAmount = getAvailableAmount(productStock); //可申请数量
|
|
|
|
|
|
|
|
|
|
if (availableAmount.compareTo(BigDecimal.ONE) < 0) {
|
|
|
|
|
throw new ServiceException("没有库存信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WmsProductOutstock wmsProductOutstock = new WmsProductOutstock();
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
wmsProductOutstock.setWarehouseId(warehouseId);
|
|
|
|
|
wmsProductOutstock.setProductType(WmsConstants.WMS_PRODUCT_OUTSTOCK_PRODUCT_TYPE_PRODUCT);
|
|
|
|
|
wmsProductOutstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL);
|
|
|
|
|
wmsProductOutstock.setOutstockType(WmsConstants.WMS_PRODUCT_OUTSTOCK_TYPE_SALE);
|
|
|
|
|
wmsProductOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
|
|
|
|
|
wmsProductOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
|
|
|
|
|
wmsProductOutstock.setApplyBy(userName);
|
|
|
|
|
wmsProductOutstock.setApplyDate(currentDate);
|
|
|
|
|
wmsProductOutstock.setTaskCode(Seq.getId(Seq.productOutstockSeqType, Seq.productOutstockCode));
|
|
|
|
|
|
|
|
|
|
wmsProductOutstockMapper.insertWmsProductOutstock(wmsProductOutstock);
|
|
|
|
|
|
|
|
|
|
return wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static BigDecimal getAvailableAmount(WmsProductStock productStock) {
|
|
|
|
|
if (productStock == null) {
|
|
|
|
|
throw new ServiceException("没有库存信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*获取仓库可用库存数量*/
|
|
|
|
|
BigDecimal totalAmount = productStock.getTotalAmount() == null ? BigDecimal.ZERO : productStock.getTotalAmount();
|
|
|
|
|
BigDecimal frozenAmount = productStock.getFrozenAmount() == null ? BigDecimal.ZERO : productStock.getFrozenAmount();//冻结数量暂时没用
|
|
|
|
|
BigDecimal occupyAmount = productStock.getOccupyAmount() == null ? BigDecimal.ZERO : productStock.getOccupyAmount();//
|
|
|
|
|
BigDecimal availableAmount = totalAmount.subtract(frozenAmount).subtract(occupyAmount);
|
|
|
|
|
return availableAmount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|