@ -422,7 +422,6 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
//判断仓库类型,出库记录保存对应操作类型,出库记录明细保存对应出库方式
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper . selectWmsBaseWarehouseByWarehouseId ( warehouseId ) ;
String warehouseType = warehouse . getWarehouseType ( ) ;
String operationType = WmsConstants . OPERATION_TYPE_MAP . get ( warehouseType ) ;
String outstockWay = WmsConstants . OUTSTOCK_WAY_MAP . get ( warehouseType ) ;
String queryQualityStatus = WmsConstants . WMS_QUALITY_STATUS_PASS ;
@ -430,8 +429,10 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
List < WmsRawOutstockDetail > toUpdatedRawOutstockDetails = new ArrayList < > ( ) ;
Date currentDate = new Date ( ) ;
String userName = SecurityUtils . getUsername ( ) ;
//传入的申请领料list遍历
rawOutstockDetails . forEach ( rawOutstockDetail - > {
BigDecimal planAmount = rawOutstockDetail . getPlanAmount ( ) = = null ? BigDecimal . ZERO : rawOutstockDetail . getPlanAmount ( ) ;
BigDecimal planAmount = rawOutstockDetail . getPlanAmount ( ) = = null ?
BigDecimal . ZERO : rawOutstockDetail . getPlanAmount ( ) ; //申请数量
Long materialId = rawOutstockDetail . getMaterialId ( ) ;
if ( planAmount . compareTo ( BigDecimal . ZERO ) > 0 ) {
BigDecimal realRawStock = BigDecimal . ZERO ; //实际库存总量
@ -459,12 +460,12 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawStock . setUpdateDate ( currentDate ) ;
wmsRawStock . setUpdateBy ( userName ) ;
//如果同一个物料有多条记录的处理(最好避免前端可以传多条同一个物料的申请),
// 提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
// 提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper . updateWmsRawStock ( wmsRawStock ) ;
//原材料出库记录明细
//原材料出库记录明细 (有break, 以下方法需要写在下面)
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail ( wmsRawStock , materialId ,
available Amount, currentDate , userName , outstockWay ) ;
plan Amount, currentDate , userName , outstockWay ) ;
toUpdatedRawOutstockDetails . add ( wmsRawOutstockDetail ) ;
planAmount = planAmount . subtract ( availableAmount ) ;
@ -476,10 +477,11 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper . updateWmsRawStock ( wmsRawStock ) ;
//原材料出库记录明细
//原材料出库记录明细 (有break, 以下方法需要写在下面)
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail ( wmsRawStock , materialId ,
available Amount, currentDate , userName , outstockWay ) ;
plan Amount, currentDate , userName , outstockWay ) ;
toUpdatedRawOutstockDetails . add ( wmsRawOutstockDetail ) ;
planAmount = BigDecimal . ZERO ;
break ;
} else if ( planAmount . compareTo ( availableAmount ) < 0 ) {
@ -490,10 +492,11 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper . updateWmsRawStock ( wmsRawStock ) ;
//原材料出库记录明细
//原材料出库记录明细 (有break, 以下方法需要写在下面)
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail ( wmsRawStock , materialId ,
planAmount , currentDate , userName , outstockWay ) ;
toUpdatedRawOutstockDetails . add ( wmsRawOutstockDetail ) ;
planAmount = BigDecimal . ZERO ;
break ;
}
@ -501,37 +504,16 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
}
//以上将申请的数量跟库存数量比对, 如果库存数量足够则planAmount减去库存会=0,如果不够则剩余的planAmount会>0
if ( planAmount . compareTo ( BigDecimal . ZERO ) > 0 ) {
throw new ServiceException ( "物料 编号为[" + materialId + "]库存不足,只有" + realRawStock ) ;
throw new ServiceException ( "物料 名称为[" + rawOutstockDetail . getMaterialName ( ) + "]库存不足,只有" + realRawStock ) ;
}
}
} ) ;
handleRawOutstock ( wmsRawOutstock , warehouse , userName , currentDate , toUpdatedRawOutstockDetails ) ;
//出库要求 ( 0申请出库, 1申请审核出库, 2直接出库)
String outRequirement = warehouse . getOutRequirement ( ) ;
String auditStatus = WmsConstants . WMS_AUDIT_STATUS_PASS ;
if ( outRequirement . equals ( WmsConstants . WMS_WAREHOUSE_OUT_REQUIREMENT_APPLY_AUDIT ) ) {
wmsRawOutstock . setAuditStatus ( WmsConstants . RAW_OUTSTOCK_AUDIT_STATUS_TOAUDIT ) ;
wmsRawOutstock . setExecuteStatus ( WmsConstants . WMS_EXECUTE_STATUS_TOEXECUTE ) ;
} else {
wmsRawOutstock . setAuditStatus ( WmsConstants . WMS_AUDIT_STATUS_PASS ) ;
wmsRawOutstock . setExecuteStatus ( WmsConstants . WMS_EXECUTE_STATUS_FINISH ) ;
}
wmsRawOutstock . setTaskCode ( Seq . getId ( Seq . rawOutstockSeqType , Seq . rawOutstockSeqCode ) ) ;
wmsRawOutstock . setStationId ( SecurityUtils . getStationId ( ) ) ;
wmsRawOutstock . setOperationType ( operationType ) ;
wmsRawOutstock . setApplyBy ( userName ) ;
wmsRawOutstock . setApplyDate ( currentDate ) ;
int rows = wmsRawOutstockMapper . insertWmsRawOutstock ( wmsRawOutstock ) ;
wmsRawOutstock . setWmsRawOutstockDetailList ( toUpdatedRawOutstockDetails ) ;
insertWmsRawOutstockDetail ( wmsRawOutstock ) ;
return rows ;
return 1 ;
}
@ -555,6 +537,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawOutstockDetail . setPlanAmount ( availableAmount ) ;
wmsRawOutstockDetail . setExecuteStatus ( WmsConstants . WMS_EXECUTE_STATUS_TOEXECUTE ) ;
wmsRawOutstockDetail . setOutstockWay ( outstockWay ) ;
wmsRawOutstockDetail . setPalletInfoCode ( wmsRawStock . getPalletInfoCode ( ) ) ;
wmsRawOutstockDetail . setQualityStatus ( wmsRawStock . getQualityStatus ( ) ) ;
wmsRawOutstockDetail . setCreateDate ( currentDate ) ;
wmsRawOutstockDetail . setCreateBy ( userName ) ;
@ -563,6 +546,59 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
public void handleRawOutstock ( WmsRawOutstock wmsRawOutstock , WmsBaseWarehouse warehouse ,
String userName , Date currentDate , List < WmsRawOutstockDetail > toUpdatedRawOutstockDetails ) {
//出库要求 ( 0申请出库, 1申请审核出库, 2直接出库)
String outRequirement = warehouse . getOutRequirement ( ) ;
String warehouseType = warehouse . getWarehouseType ( ) ;
String operationType = WmsConstants . OPERATION_TYPE_MAP . get ( warehouseType ) ;
if ( warehouseType . equals ( WmsConstants . WMS_WAREHOUSE_TYPE_NORMAL ) ) {
if ( outRequirement . equals ( WmsConstants . WMS_WAREHOUSE_OUT_REQUIREMENT_APPLY_AUDIT ) ) {
wmsRawOutstock . setAuditStatus ( WmsConstants . RAW_OUTSTOCK_AUDIT_STATUS_TOAUDIT ) ;
wmsRawOutstock . setExecuteStatus ( WmsConstants . WMS_EXECUTE_STATUS_TOEXECUTE ) ;
} else {
wmsRawOutstock . setAuditStatus ( WmsConstants . WMS_AUDIT_STATUS_PASS ) ;
wmsRawOutstock . setExecuteStatus ( WmsConstants . WMS_EXECUTE_STATUS_FINISH ) ;
}
wmsRawOutstock . setTaskCode ( Seq . getId ( Seq . rawOutstockSeqType , Seq . rawOutstockSeqCode ) ) ;
wmsRawOutstock . setStationId ( SecurityUtils . getStationId ( ) ) ;
wmsRawOutstock . setOperationType ( operationType ) ;
wmsRawOutstock . setApplyBy ( userName ) ;
wmsRawOutstock . setApplyDate ( currentDate ) ;
wmsRawOutstockMapper . insertWmsRawOutstock ( wmsRawOutstock ) ;
wmsRawOutstock . setWmsRawOutstockDetailList ( toUpdatedRawOutstockDetails ) ;
insertWmsRawOutstockDetail ( wmsRawOutstock ) ;
} else {
List < WmsRawOutstock > toInsertedRawOutstocks = new ArrayList < > ( ) ;
toUpdatedRawOutstockDetails . forEach ( wmsRawOutstockDetail - > {
WmsRawOutstock toInsertedRawOutstock = new WmsRawOutstock ( ) ;
toInsertedRawOutstock . setTaskCode ( Seq . getId ( Seq . rawOutstockSeqType , Seq . rawOutstockSeqCode ) ) ;
toInsertedRawOutstock . setWarehouseId ( wmsRawOutstock . getWarehouseId ( ) ) ;
toInsertedRawOutstock . setLocationCode ( wmsRawOutstockDetail . getLocationCode ( ) ) ;
toInsertedRawOutstock . setStationId ( SecurityUtils . getStationId ( ) ) ;
toInsertedRawOutstock . setPalletInfoCode ( wmsRawOutstockDetail . getPalletInfoCode ( ) ) ;
toInsertedRawOutstock . setOperationType ( operationType ) ;
toInsertedRawOutstock . setApplyBy ( userName ) ;
toInsertedRawOutstock . setApplyDate ( currentDate ) ;
toInsertedRawOutstock . setEndStationCode ( SecurityUtils . getStationCode ( ) ) ;
toInsertedRawOutstock . setPlanCode ( wmsRawOutstock . getPlanCode ( ) ) ;
toInsertedRawOutstock . setPlanDetailCode ( wmsRawOutstock . getPlanDetailCode ( ) ) ;
toInsertedRawOutstock . setMaterialBatch ( wmsRawOutstockDetail . getInstockBatch ( ) ) ;
toInsertedRawOutstock . setOutstockAmount ( wmsRawOutstockDetail . getPlanAmount ( ) ) ;
toInsertedRawOutstock . setTaskType ( WmsConstants . WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_PICKING ) ;
toInsertedRawOutstock . setAuditStatus ( WmsConstants . WMS_AUDIT_STATUS_PASS ) ;
toInsertedRawOutstock . setExecuteStatus ( WmsConstants . WMS_EXECUTE_STATUS_TOEXECUTE ) ;
toInsertedRawOutstocks . add ( toInsertedRawOutstock ) ;
} ) ;
wmsRawOutstockMapper . batchWmsRawOutstock ( toInsertedRawOutstocks ) ;
}
}
/ * *
* AGV 原 材 料 出 库
*