@ -240,7 +240,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
BigDecimal planAmount = wmsRawOutstock . getOutstockAmount ( ) ;
BigDecimal planAmount = wmsRawOutstock . getOutstockAmount ( ) ;
WmsRawStock wmsRawStock = wmsRawStockMapper . selectRawStockByBarcode ( instockBatch ) ;
WmsRawStock wmsRawStock = wmsRawStockMapper . selectRawStockByBarcode ( instockBatch ) ;
if ( wmsRawStock ! = null ) {
if ( wmsRawStock ! = null ) {
BigDecimal occupyAmount = wmsRawStock . getOccupyAmount ( ) = = null ?
BigDecimal occupyAmount = wmsRawStock . getOccupyAmount ( ) = = null | |
wmsRawStock . getOccupyAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ?
BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) ;
BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) ;
if ( occupyAmount . compareTo ( planAmount ) > = 0 ) {
if ( occupyAmount . compareTo ( planAmount ) > = 0 ) {
wmsRawStock . setOccupyAmount ( occupyAmount . subtract ( planAmount ) ) ;
wmsRawStock . setOccupyAmount ( occupyAmount . subtract ( planAmount ) ) ;
@ -306,27 +307,35 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
}
}
}
String batchCode = baseBarcodeInfo . getBatchCode ( ) ;
WmsBaseLocation baseLocation = wmsBaseLocationMapper . selectWmsBaseLocationByLocationCode ( locationCode ) ;
if ( baseLocation = = null ) {
throw new ServiceException ( "库位码有误" ) ;
}
//todo: 后续判断outrequirement
//判断是否有此出库任务,人工出库的同一个出库记录, 同一个库位、同一个物料对应一个明细( agv的有可能是多个)
//判断是否有此出库任务,人工出库的同一个出库记录, 同一个库位、同一个物料对应一个明细( agv的有可能是多个)
WmsRawOutstock queryRawOutstock = new WmsRawOutstock ( ) ;
WmsRawOutstock wmsRawOutstock ;
queryRawOutstock . setLocationCode ( locationCode ) ;
if ( rawOutstockId ! = null ) {
queryRawOutstock . setInstockBatch ( batchCode ) ;
wmsRawOutstock = wmsRawOutstockMapper . selectWmsRawOutstockByRawOutstockId ( rawOutstockId ) ;
queryRawOutstock . setExecuteStatusStr ( WmsConstants . WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants . WMS_EXECUTE_STATUS_EXECUTING ) ;
} else {
queryRawOutstock . setAuditStatus ( WmsConstants . WMS_AUDIT_STATUS_PASS ) ;
WmsRawOutstock queryRawOutstock = new WmsRawOutstock ( ) ;
queryRawOutstock . setRawOutstockId ( rawOutstockId ) ;
queryRawOutstock . setWarehouseId ( baseLocation . getWarehouseId ( ) ) ;
queryRawOutstock . setMaterialId ( baseBarcodeInfo . getMaterialId ( ) ) ;
queryRawOutstock . setExecuteStatusStr ( WmsConstants . WMS_EXECUTE_STATUS_TOEXECUTE + "," + WmsConstants . WMS_EXECUTE_STATUS_EXECUTING ) ;
queryRawOutstock . setAuditStatus ( WmsConstants . WMS_AUDIT_STATUS_PASS ) ;
queryRawOutstock . setRawOutstockId ( rawOutstockId ) ;
List < WmsRawOutstock > wmsRawOutstocks = wmsRawOutstockMapper . selectWmsRawOutstockList ( queryRawOutstock ) ;
if ( wmsRawOutstocks = = null | | wmsRawOutstocks . isEmpty ( ) ) {
throw new ServiceException ( "无此出库任务" ) ;
}
List < WmsRawOutstock > wmsRawOutstocks = wmsRawOutstockMapper . selectWmsRawOutstockList ( queryRawOutstock ) ;
if ( wmsRawOutstocks . size ( ) > 1 ) {
if ( wmsRawOutstocks = = null | | wmsRawOutstocks . isEmpty ( ) ) {
throw new ServiceException ( "请选择具体出库任务后点击确认" ) ;
throw new ServiceException ( "无此出库任务" ) ;
}
}
if ( wmsRawOutstocks . size ( ) > 1 ) {
wmsRawOutstock = wmsRawOutstocks . get ( 0 ) ;
throw new ServiceException ( "请选择具体出库任务后点击确认" ) ;
}
}
WmsRawOutstock wmsRawOutstock = wmsRawOutstocks . get ( 0 ) ;
WmsRawOutstockDetail queryRawOutstockDetail = new WmsRawOutstockDetail ( ) ;
WmsRawOutstockDetail queryRawOutstockDetail = new WmsRawOutstockDetail ( ) ;
queryRawOutstockDetail . setRawOutstockId ( wmsRawOutstock . getRawOutstockId ( ) ) ;
queryRawOutstockDetail . setRawOutstockId ( wmsRawOutstock . getRawOutstockId ( ) ) ;
@ -369,20 +378,22 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawOutstock . setUpdateBy ( userName ) ;
wmsRawOutstock . setUpdateBy ( userName ) ;
wmsRawOutstockMapper . updateWmsRawOutstock ( wmsRawOutstock ) ;
wmsRawOutstockMapper . updateWmsRawOutstock ( wmsRawOutstock ) ;
insertRawOutstockDetail ( wmsRawOutstock , materialBarcode , batchCode , userName , currentDate ) ;
insertRawOutstockDetail ( wmsRawOutstock , locationCode , materialBarcode , baseBarcodeInfo . getBatchCode ( ) , userName , currentDate ) ;
updateRawStock ( materialBarcode , outstockAmount , userName , currentDate ) ;
updateRawStock ( locationCode , batchCode , outstockAmount , userName , currentDate ) ;
//trigger中更新stocktotal的占用数量和库存数量
return 1 ;
return 1 ;
}
}
public void insertRawOutstockDetail ( WmsRawOutstock wmsRawOutstock , String materialBarcode, String batchCode ,
public void insertRawOutstockDetail ( WmsRawOutstock wmsRawOutstock , String locationCode, String materialBarcode, String batchCode ,
String userName , Date currentDate ) {
String userName , Date currentDate ) {
WmsRawOutstockDetail wmsRawOutstockDetail = new WmsRawOutstockDetail ( ) ;
WmsRawOutstockDetail wmsRawOutstockDetail = new WmsRawOutstockDetail ( ) ;
wmsRawOutstockDetail . setRawOutstockId ( wmsRawOutstock . getRawOutstockId ( ) ) ;
wmsRawOutstockDetail . setRawOutstockId ( wmsRawOutstock . getRawOutstockId ( ) ) ;
wmsRawOutstockDetail . setTaskCode ( wmsRawOutstock . getTaskCode ( ) ) ;
wmsRawOutstockDetail . setTaskCode ( wmsRawOutstock . getTaskCode ( ) ) ;
wmsRawOutstockDetail . setWarehouseId ( wmsRawOutstock . getWarehouseId ( ) ) ;
wmsRawOutstockDetail . setWarehouseId ( wmsRawOutstock . getWarehouseId ( ) ) ;
wmsRawOutstockDetail . setLocationCode ( wmsRawOutstock. getLocationCode ( ) ) ;
wmsRawOutstockDetail . setLocationCode ( locationCode ) ;
wmsRawOutstockDetail . setMaterialId ( wmsRawOutstock . getMaterialId ( ) ) ;
wmsRawOutstockDetail . setMaterialId ( wmsRawOutstock . getMaterialId ( ) ) ;
wmsRawOutstockDetail . setMaterialBarcode ( materialBarcode ) ;
wmsRawOutstockDetail . setMaterialBarcode ( materialBarcode ) ;
wmsRawOutstockDetail . setInstockBatch ( batchCode ) ;
wmsRawOutstockDetail . setInstockBatch ( batchCode ) ;
@ -398,15 +409,14 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
}
public void updateRawStock ( String locationCode, String batchC ode, BigDecimal outstockAmount , String userName , Date currentDate ) {
public void updateRawStock ( String materialBarc ode, BigDecimal outstockAmount , String userName , Date currentDate ) {
//更新原材料库存占用数量和总数量
//更新原材料库存占用数量和总数量
//todo 批次码
WmsRawStock wmsRawStock = wmsRawStockMapper . selectRawStockByBarcode ( materialBarcode ) ;
WmsRawStock wmsRawStock = wmsRawStockMapper . selectRawStockByBarcode ( batchCode ) ;
if ( wmsRawStock = = null ) {
if ( wmsRawStock = = null ) {
throw new ServiceException ( "没找到库存信息" ) ;
throw new ServiceException ( "没找到库存信息" ) ;
} else {
} else {
BigDecimal totalAmount = wmsRawStock . getTotalAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getTotalAmount ( ) ;
BigDecimal totalAmount = wmsRawStock . getTotalAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getTotalAmount ( ) ;
BigDecimal occupyAmount = wmsRawStock . getOccupyAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) ;
BigDecimal occupyAmount = wmsRawStock . getOccupyAmount ( ) = = null || wmsRawStock . getOccupyAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) ;
BigDecimal updatedOccupyAmount = occupyAmount . subtract ( outstockAmount ) ;
BigDecimal updatedOccupyAmount = occupyAmount . subtract ( outstockAmount ) ;
BigDecimal updatedTotalAmount = totalAmount . subtract ( outstockAmount ) ;
BigDecimal updatedTotalAmount = totalAmount . subtract ( outstockAmount ) ;
updatedOccupyAmount = updatedOccupyAmount . compareTo ( BigDecimal . ZERO ) > = 0 ? updatedOccupyAmount : BigDecimal . ZERO ;
updatedOccupyAmount = updatedOccupyAmount . compareTo ( BigDecimal . ZERO ) > = 0 ? updatedOccupyAmount : BigDecimal . ZERO ;
@ -508,8 +518,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
Long stockTotalId = rawOutstockDetail . getStockTotalId ( ) ;
Long stockTotalId = rawOutstockDetail . getStockTotalId ( ) ;
WmsStockTotal wmsStockTotal = wmsStockTotalMapper . selectWmsStockTotalByStockTotalId ( stockTotalId ) ;
WmsStockTotal wmsStockTotal = wmsStockTotalMapper . selectWmsStockTotalByStockTotalId ( stockTotalId ) ;
BigDecimal totalAmount = wmsStockTotal . getTotalAmount ( ) ;
BigDecimal totalAmount = wmsStockTotal . getTotalAmount ( ) ;
BigDecimal frozenAmount = wmsStockTotal . getFrozenAmount ( ) = = null ? BigDecimal . ZERO : wmsStockTotal . getFrozenAmount ( ) ;
BigDecimal frozenAmount = wmsStockTotal . getFrozenAmount ( ) = = null || wmsStockTotal . getFrozenAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsStockTotal . getFrozenAmount ( ) ;
BigDecimal occupyAmount = wmsStockTotal . getOccupyAmount ( ) = = null ? BigDecimal . ZERO : wmsStockTotal . getOccupyAmount ( ) ;
BigDecimal occupyAmount = wmsStockTotal . getOccupyAmount ( ) = = null || wmsStockTotal . getOccupyAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsStockTotal . getOccupyAmount ( ) ;
BigDecimal availableAmount = totalAmount . subtract ( frozenAmount ) . subtract ( occupyAmount ) ;
BigDecimal availableAmount = totalAmount . subtract ( frozenAmount ) . subtract ( occupyAmount ) ;
BigDecimal planAmount = rawOutstockDetail . getPlanAmount ( ) = = null ?
BigDecimal planAmount = rawOutstockDetail . getPlanAmount ( ) = = null ?
@ -692,8 +702,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
String moveMaterialBarcode = "" ;
String moveMaterialBarcode = "" ;
Long moveMaterialId = null ;
Long moveMaterialId = null ;
for ( WmsRawStock wmsRawStock : rawStockList ) {
for ( WmsRawStock wmsRawStock : rawStockList ) {
BigDecimal occupyAmount = wmsRawStock . getOccupyAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) ;
BigDecimal occupyAmount = wmsRawStock . getOccupyAmount ( ) = = null || wmsRawStock . getOccupyAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) ;
BigDecimal frozenAmount = wmsRawStock . getFrozenAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getFrozenAmount ( ) ;
BigDecimal frozenAmount = wmsRawStock . getFrozenAmount ( ) = = null || wmsRawStock . getFrozenAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsRawStock . getFrozenAmount ( ) ;
WmsBaseLocation wmsBaseLocation = baseLocationsMap . get ( wmsRawStock . getLocationCode ( ) ) ;
WmsBaseLocation wmsBaseLocation = baseLocationsMap . get ( wmsRawStock . getLocationCode ( ) ) ;
//先确认出库库位,可用数量>=1, 库位状态是正常的
//先确认出库库位,可用数量>=1, 库位状态是正常的
@ -1042,8 +1052,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
queryRawStock . setWarehouseId ( wmsConfig . getFourthFloorPalteWarehouseId ( ) ) ;
queryRawStock . setWarehouseId ( wmsConfig . getFourthFloorPalteWarehouseId ( ) ) ;
List < WmsRawStock > wmsRawStocks = wmsRawStockMapper . selectWmsRawStockList ( queryRawStock ) ;
List < WmsRawStock > wmsRawStocks = wmsRawStockMapper . selectWmsRawStockList ( queryRawStock ) ;
List < WmsRawStock > availableRawStocks = wmsRawStocks . stream ( ) . filter ( wmsRawStock - >
List < WmsRawStock > availableRawStocks = wmsRawStocks . stream ( ) . filter ( wmsRawStock - >
( wmsRawStock . getTotalAmount ( ) . subtract ( wmsRawStock . getOccupyAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) )
( wmsRawStock . getTotalAmount ( ) . subtract ( wmsRawStock . getOccupyAmount ( ) = = null || wmsRawStock . getOccupyAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) )
. subtract ( wmsRawStock . getFrozenAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getFrozenAmount ( ) ) ) . compareTo ( BigDecimal . ZERO ) > 0 ) . collect ( Collectors . toList ( ) ) ;
. subtract ( wmsRawStock . getFrozenAmount ( ) = = null || wmsRawStock . getFrozenAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsRawStock . getFrozenAmount ( ) ) ) . compareTo ( BigDecimal . ZERO ) > 0 ) . collect ( Collectors . toList ( ) ) ;
if ( availableRawStocks ! = null & & ! availableRawStocks . isEmpty ( ) ) {
if ( availableRawStocks ! = null & & ! availableRawStocks . isEmpty ( ) ) {
List < String > returnMsg = availableRawStocks . stream ( ) . map ( WmsRawStock : : getLocationAndMaterial ) . collect ( Collectors . toList ( ) ) ;
List < String > returnMsg = availableRawStocks . stream ( ) . map ( WmsRawStock : : getLocationAndMaterial ) . collect ( Collectors . toList ( ) ) ;
return returnMsg . toString ( ) ;
return returnMsg . toString ( ) ;
@ -1058,8 +1068,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
querySafeRawStock . setWarehouseId ( wmsConfig . getFourthFloorPalteWarehouseId ( ) ) ;
querySafeRawStock . setWarehouseId ( wmsConfig . getFourthFloorPalteWarehouseId ( ) ) ;
List < WmsRawStock > safeRawStocks = wmsRawStockMapper . selectWmsRawStockList ( querySafeRawStock ) ;
List < WmsRawStock > safeRawStocks = wmsRawStockMapper . selectWmsRawStockList ( querySafeRawStock ) ;
List < WmsRawStock > availableSafeRawStocks = safeRawStocks . stream ( ) . filter ( wmsRawStock - >
List < WmsRawStock > availableSafeRawStocks = safeRawStocks . stream ( ) . filter ( wmsRawStock - >
( wmsRawStock . getTotalAmount ( ) . subtract ( wmsRawStock . getOccupyAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) )
( wmsRawStock . getTotalAmount ( ) . subtract ( wmsRawStock . getOccupyAmount ( ) = = null || wmsRawStock . getOccupyAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsRawStock . getOccupyAmount ( ) )
. subtract ( wmsRawStock . getFrozenAmount ( ) = = null ? BigDecimal . ZERO : wmsRawStock . getFrozenAmount ( ) ) ) . compareTo ( BigDecimal . ZERO ) > 0 ) . collect ( Collectors . toList ( ) ) ;
. subtract ( wmsRawStock . getFrozenAmount ( ) = = null || wmsRawStock . getFrozenAmount ( ) . compareTo ( BigDecimal . ZERO ) < 0 ? BigDecimal . ZERO : wmsRawStock . getFrozenAmount ( ) ) ) . compareTo ( BigDecimal . ZERO ) > 0 ) . collect ( Collectors . toList ( ) ) ;
if ( availableSafeRawStocks ! = null & & ! availableSafeRawStocks . isEmpty ( ) ) {
if ( availableSafeRawStocks ! = null & & ! availableSafeRawStocks . isEmpty ( ) ) {
List < String > returnMsg = availableSafeRawStocks . stream ( ) . map ( WmsRawStock : : getLocationAndMaterial ) . collect ( Collectors . toList ( ) ) ;
List < String > returnMsg = availableSafeRawStocks . stream ( ) . map ( WmsRawStock : : getLocationAndMaterial ) . collect ( Collectors . toList ( ) ) ;
return returnMsg . toString ( ) ;
return returnMsg . toString ( ) ;
@ -1108,7 +1118,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawOutstock . setApplyDate ( currentDate ) ;
wmsRawOutstock . setApplyDate ( currentDate ) ;
wmsRawOutstockMapper . insertWmsRawOutstock ( wmsRawOutstock ) ;
wmsRawOutstockMapper . insertWmsRawOutstock ( wmsRawOutstock ) ;
this . insertRawOutstockDetail ( wmsRawOutstock , materialBarcode, batchCode ,
this . insertRawOutstockDetail ( wmsRawOutstock , locationCode, materialBarcode, batchCode ,
userName , currentDate ) ;
userName , currentDate ) ;
directOutstockUpdateRawStock ( locationCode , materialBarcode , outstockAmount , userName , currentDate ) ;
directOutstockUpdateRawStock ( locationCode , materialBarcode , outstockAmount , userName , currentDate ) ;