|
|
|
@ -4,6 +4,7 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import com.hw.common.core.constant.MesConstants;
|
|
|
|
|
import com.hw.common.core.constant.SecurityConstants;
|
|
|
|
|
import com.hw.common.core.constant.WmsConstants;
|
|
|
|
|
import com.hw.common.core.domain.R;
|
|
|
|
@ -22,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.hw.common.core.utils.StringUtils;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -262,12 +264,22 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int finalConfirmProductOutstock(WmsProductOutstockConfirmVo wmsProductOutstockConfirmVo) {
|
|
|
|
|
WmsProductOutstockDetail productOutstockDetail = wmsProductOutstockDetailMapper.
|
|
|
|
|
selectWmsProductOutstockDetailByProductBarcode(wmsProductOutstockConfirmVo.getMaterialBarcode());
|
|
|
|
|
if (productOutstockDetail == null) {
|
|
|
|
|
WmsProductOutstockDetail queryProductOutstockDetail = new WmsProductOutstockDetail();
|
|
|
|
|
queryProductOutstockDetail.setProductBarcode(wmsProductOutstockConfirmVo.getMaterialBarcode());
|
|
|
|
|
List<WmsProductOutstockDetail> wmsProductOutstockDetailList = wmsProductOutstockDetailMapper.selectWmsProductOutstockDetailList(queryProductOutstockDetail);
|
|
|
|
|
if (wmsProductOutstockDetailList == null || wmsProductOutstockDetailList.isEmpty()) {
|
|
|
|
|
throw new ServiceException("没有此成品出库信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsProductOutstockDetail> unConfirmedProductOutstockDetailList = wmsProductOutstockDetailList.stream().
|
|
|
|
|
filter(wpod ->!wpod.getExecuteStatus().equals(WmsConstants.WMS_EXECUTE_STATUS_CONFIRM)).collect(Collectors.toList());
|
|
|
|
|
if(unConfirmedProductOutstockDetailList==null || unConfirmedProductOutstockDetailList.isEmpty()){
|
|
|
|
|
throw new ServiceException("没有待确认成品出库信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WmsProductOutstockDetail productOutstockDetail = unConfirmedProductOutstockDetailList.get(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String executeStatus = productOutstockDetail.getExecuteStatus();
|
|
|
|
|
if (executeStatus.equals(WmsConstants.WMS_EXECUTE_STATUS_CONFIRM)) {
|
|
|
|
|
throw new ServiceException("此成品出库已经确认,无需再次确认");
|
|
|
|
@ -300,9 +312,9 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int fourthFloorProduceOutstock(WmsProduceInstockVo wmsProduceInstockVo) {
|
|
|
|
|
public int firstFourthFloorProduceOutstock(WmsProduceInstockVo wmsProduceInstockVo) {
|
|
|
|
|
//对内生产可直接出库,外部销售需要申请后才能出库(外部销售在手机端操作出库)
|
|
|
|
|
Long warehouseId = wmsConfig.getFourthFloorProductWarehouseId();
|
|
|
|
|
Long warehouseId = wmsProduceInstockVo.getWarehouseId();
|
|
|
|
|
String materialBarcode = wmsProduceInstockVo.getMaterialBarcode();
|
|
|
|
|
|
|
|
|
|
WmsProductStock productStock = wmsProductStockMapper.selectProductStockByBatch(materialBarcode);
|
|
|
|
@ -312,15 +324,40 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
throw new ServiceException("没有库存信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WmsProductOutstock wmsProductOutstock = new WmsProductOutstock();
|
|
|
|
|
R<MesBaseBarcodeInfo> mesBaseBarcodeInfoData = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
|
|
|
|
|
if (mesBaseBarcodeInfoData == null) {
|
|
|
|
|
throw new ServiceException("物料条码有误");
|
|
|
|
|
}
|
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoData.getData();
|
|
|
|
|
if (mesBaseBarcodeInfo == null) {
|
|
|
|
|
throw new ServiceException("物料条码有误!");
|
|
|
|
|
}
|
|
|
|
|
Long materialId = mesBaseBarcodeInfo.getMaterialId();
|
|
|
|
|
Long saleOrderId = mesBaseBarcodeInfo.getSaleOrderId();
|
|
|
|
|
String saleorderCode = mesBaseBarcodeInfo.getSaleorderCode();
|
|
|
|
|
String planCode = mesBaseBarcodeInfo.getPlanCode();
|
|
|
|
|
String planDetailCode = mesBaseBarcodeInfo.getPlanDetailCode();
|
|
|
|
|
|
|
|
|
|
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
|
|
|
|
|
String outRequirement = warehouse.getOutRequirement();
|
|
|
|
|
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
Long productOutstockId=null;
|
|
|
|
|
//如果是直接出库
|
|
|
|
|
if (outRequirement.equals(WmsConstants.WMS_WAREHOUSE_OUT_REQUIREMENT_DIRECT)) {
|
|
|
|
|
WmsProductOutstock wmsProductOutstock = new WmsProductOutstock();
|
|
|
|
|
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.setProductId(materialId);
|
|
|
|
|
wmsProductOutstock.setPlanCode(planCode);
|
|
|
|
|
wmsProductOutstock.setPlanDetailCode(planDetailCode);
|
|
|
|
|
wmsProductOutstock.setSaleOrderId(saleOrderId);
|
|
|
|
|
wmsProductOutstock.setSaleorderCode(saleorderCode);
|
|
|
|
|
wmsProductOutstock.setProductBatch(materialBarcode);
|
|
|
|
|
wmsProductOutstock.setApplyBy(userName);
|
|
|
|
|
wmsProductOutstock.setApplyDate(currentDate);
|
|
|
|
@ -328,7 +365,96 @@ public class WmsProductOutstockServiceImpl implements IWmsProductOutstockService
|
|
|
|
|
|
|
|
|
|
wmsProductOutstockMapper.insertWmsProductOutstock(wmsProductOutstock);
|
|
|
|
|
|
|
|
|
|
return wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId());
|
|
|
|
|
productOutstockId = wmsProductOutstock.getProductOutstockId();
|
|
|
|
|
wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId());
|
|
|
|
|
} else {
|
|
|
|
|
WmsProductOutstock queryProductOutstock = new WmsProductOutstock();
|
|
|
|
|
queryProductOutstock.setWarehouseId(warehouseId);
|
|
|
|
|
queryProductOutstock.setExecuteIncompleteFlag("1");
|
|
|
|
|
queryProductOutstock.setProductType(WmsConstants.PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT);
|
|
|
|
|
queryProductOutstock.setProductId(materialId);
|
|
|
|
|
|
|
|
|
|
List<WmsProductOutstock> wmsProductOutstocks = wmsProductOutstockMapper.selectWmsProductOutstockList(queryProductOutstock);
|
|
|
|
|
if (wmsProductOutstocks == null || wmsProductOutstocks.isEmpty()) {
|
|
|
|
|
throw new ServiceException("请先从PDA执行成品出库申请");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (saleOrderId == null || saleOrderId.equals((0L))) {
|
|
|
|
|
throw new ServiceException("此成品为安全库存,不能出库");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsProductOutstock> saleProductOutstocks = wmsProductOutstocks.stream().filter(wmsProductOutstock ->
|
|
|
|
|
wmsProductOutstock.getSaleOrderId() != null && wmsProductOutstock.getSaleOrderId().equals(saleOrderId)
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
if (saleProductOutstocks == null || saleProductOutstocks.isEmpty()) {
|
|
|
|
|
throw new ServiceException("没有此销售订单[" + saleorderCode + "]的成品出库申请");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<WmsProductOutstock> auditPassProductOutstocks = saleProductOutstocks.stream().filter(wmsProductOutstock ->
|
|
|
|
|
wmsProductOutstock.getAuditStatus().equals(WmsConstants.WMS_AUDIT_STATUS_PASS)
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
if (auditPassProductOutstocks == null || auditPassProductOutstocks.isEmpty()) {
|
|
|
|
|
throw new ServiceException("此销售订单[" + saleorderCode + "]的成品出库申请未审核通过");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WmsProductOutstock productOutstock = saleProductOutstocks.get(0);
|
|
|
|
|
|
|
|
|
|
/**判断已出库数量和申请的数量*/
|
|
|
|
|
BigDecimal applyQty = productOutstock.getApplyQty() == null ? BigDecimal.ZERO : productOutstock.getApplyQty();
|
|
|
|
|
BigDecimal outstockQty = productOutstock.getOutstockQty() == null ? BigDecimal.ZERO : productOutstock.getOutstockQty();
|
|
|
|
|
|
|
|
|
|
BigDecimal currentOutstockQty = outstockQty.add(BigDecimal.ONE);
|
|
|
|
|
if (applyQty.compareTo(currentOutstockQty) < 0) {
|
|
|
|
|
throw new ServiceException(String.format("出库申请数量为%1$s,不能再出库", applyQty));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新出库记录
|
|
|
|
|
if (applyQty.compareTo(currentOutstockQty) == 0) {
|
|
|
|
|
productOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
|
|
|
|
|
productOutstock.setEndTime(currentDate);
|
|
|
|
|
} else if (applyQty.compareTo(currentOutstockQty) > 0) {
|
|
|
|
|
productOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_EXECUTING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
productOutstock.setOutstockQty(currentOutstockQty);
|
|
|
|
|
if (productOutstock.getBeginTime() == null) {
|
|
|
|
|
productOutstock.setBeginTime(currentDate);
|
|
|
|
|
}
|
|
|
|
|
productOutstock.setUpdateDate(currentDate);
|
|
|
|
|
productOutstock.setUpdateBy(userName);
|
|
|
|
|
wmsProductOutstockMapper.updateWmsProductOutstock(productOutstock);
|
|
|
|
|
|
|
|
|
|
wmsProductStockMapper.deleteWmsProductStockByProductStockId(productStock.getProductStockId());
|
|
|
|
|
|
|
|
|
|
productOutstockId = productOutstock.getProductOutstockId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//插入出库记录明细
|
|
|
|
|
WmsProductOutstockDetail wmsProductOutstockDetail = new WmsProductOutstockDetail();
|
|
|
|
|
wmsProductOutstockDetail.setProductOutstockId(productOutstockId);
|
|
|
|
|
wmsProductOutstockDetail.setLocationCode("virtual");
|
|
|
|
|
wmsProductOutstockDetail.setWarehouseId(warehouseId);
|
|
|
|
|
wmsProductOutstockDetail.setProductBarcode(materialBarcode);
|
|
|
|
|
wmsProductOutstockDetail.setProductBatch(mesBaseBarcodeInfo.getBatchCode());
|
|
|
|
|
wmsProductOutstockDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
|
|
|
|
|
wmsProductOutstockDetail.setProductId(materialId);
|
|
|
|
|
wmsProductOutstockDetail.setPlanAmount(BigDecimal.ONE);
|
|
|
|
|
wmsProductOutstockDetail.setOutstockAmount(BigDecimal.ONE);
|
|
|
|
|
wmsProductOutstockDetail.setBeginTime(currentDate);
|
|
|
|
|
wmsProductOutstockDetail.setEndTime(currentDate);
|
|
|
|
|
wmsProductOutstockDetail.setWarehouseId(productStock.getWarehouseId());
|
|
|
|
|
wmsProductOutstockDetail.setPlanAmount(BigDecimal.ONE);
|
|
|
|
|
wmsProductOutstockDetail.setOutstockAmount(BigDecimal.ONE);
|
|
|
|
|
wmsProductOutstockDetail.setUpdateDate(currentDate);
|
|
|
|
|
wmsProductOutstockDetail.setUpdateBy(userName);
|
|
|
|
|
|
|
|
|
|
wmsProductOutstockDetailMapper.insertWmsProductOutstockDetail(wmsProductOutstockDetail);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|