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