@ -86,6 +86,18 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
Long warehouseId = wmsInventoryCheckVo . getWarehouseId ( ) ;
List < String > locationCodes = wmsInventoryCheckVo . getLocationCodes ( ) ;
//在选择库位时已经过滤,此处不加此判断了
// for (String locationCode : locationCodes) {
// WmsInventoryCheckDetail queryInventoryCheckDetail = new WmsInventoryCheckDetail();
// queryInventoryCheckDetail.setInventoryCheckId(inventoryCheckId);
// queryInventoryCheckDetail.setLocationCode(locationCode);
//
// List<WmsInventoryCheckDetail> wmsInventoryCheckDetailList = wmsInventoryCheckDetailMapper.selectWmsInventoryCheckDetailList(queryInventoryCheckDetail);
// if (wmsInventoryCheckDetailList != null && !wmsInventoryCheckDetailList.isEmpty()) {
// throw new ServiceException("库位:" + locationCode + ",已经盘点过");
// }
// }
String userName = SecurityUtils . getUsername ( ) ;
Date currentDate = new Date ( ) ;
@ -93,11 +105,11 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
String warehouseInstockType = baseWarehouse . getWarehouseInstockType ( ) ;
String warehouseType = baseWarehouse . getWarehouseType ( ) ;
String inventoryCheckType = "" ;
if ( warehouseType . equals ( WmsConstants . WMS_WAREHOUSE_TYPE_NORMAL ) ) {
if ( warehouseType . equals ( WmsConstants . WMS_WAREHOUSE_TYPE_NORMAL ) ) {
inventoryCheckType = WmsConstants . WMS_INVENTORY_CHECK_TYPE_MANUAL ;
} else if ( warehouseType . equals ( WmsConstants . WMS_WAREHOUSE_TYPE_AGV ) ) {
} else if ( warehouseType . equals ( WmsConstants . WMS_WAREHOUSE_TYPE_AGV ) ) {
inventoryCheckType = WmsConstants . WMS_INVENTORY_CHECK_TYPE_WCS ;
} else {
} else {
throw new ServiceException ( "请选择人工仓库或agv仓库盘库" ) ;
}
@ -129,7 +141,8 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
toSetInventoryCheckId = wmsInventoryCheck . getInventoryCheckId ( ) ;
} else {
WmsInventoryCheck toUpdatedInventoryCheck = wmsInventoryCheckMapper . selectWmsInventoryCheckByInventoryCheckId ( inventoryCheckId ) ;
toUpdatedInventoryCheck . setInventoryingAmount ( toUpdatedInventoryCheck . getInventoriedAmount ( ) + ( long ) locationCodes . size ( ) ) ;
toUpdatedInventoryCheck . setInventoryingAmount ( toUpdatedInventoryCheck . getInventoryingAmount ( ) = = null ? 0 : toUpdatedInventoryCheck . getInventoryingAmount ( )
+ ( long ) locationCodes . size ( ) ) ;
toUpdatedInventoryCheck . setUpdateDate ( currentDate ) ;
toUpdatedInventoryCheck . setUpdateBy ( userName ) ;
wmsInventoryCheckMapper . updateWmsInventoryCheck ( toUpdatedInventoryCheck ) ;
@ -172,6 +185,7 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
wmsInventoryCheckDetail . setInventoryTime ( 0 L ) ;
wmsInventoryCheckDetail . setStockType ( WmsConstants . RWA_STOCK_STOCK_TYPE_RAW ) ;
wmsInventoryCheckDetail . setStockId ( wmsRawStock . getRawStockId ( ) ) ;
wmsInventoryCheckDetail . setStockAmount ( wmsRawStock . getTotalAmount ( ) ) ;
wmsInventoryCheckDetail . setLocationCode ( locationCode ) ;
wmsInventoryCheckDetail . setCheckStatus ( WmsConstants . WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING ) ;
wmsInventoryCheckDetail . setCreateDate ( currentDate ) ;
@ -361,28 +375,34 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
WmsInventoryCheck wmsInventoryCheck = wmsInventoryCheckMapper . selectWmsInventoryCheckByInventoryCheckId ( existedInventoryCheckDetail . getInventoryCheckId ( ) ) ;
//根据物料id查询库存数量
if ( stockType . equals ( WmsConstants . WMS_WAREHOUSE_INSTOCK_TYPE_RAW ) ) {
WmsRawStock queryRawStock = new WmsRawStock ( ) ;
queryRawStock . setMaterialId ( existedInventoryCheckDetail . getMaterialId ( ) ) ;
queryRawStock . setWarehouseId ( wmsInventoryCheck . getWarehouseId ( ) ) ;
List < WmsRawStock > wmsRawStockInList = wmsRawStockMapper . selectOnlyWmsRawStockInList ( queryRawStock ) ;
//需要区分批次和非批次, 所以需要通过totalAmount相加得出此物料库存总数量
BigDecimal stockAmount = wmsRawStockInList = = null | | wmsRawStockInList . isEmpty ( ) ? BigDecimal . ZERO :
wmsRawStockInList . stream ( )
. map ( WmsRawStock : : getTotalAmount )
. reduce ( BigDecimal . ZERO , BigDecimal : : add ) ;
existedInventoryCheckDetail . setStockAmount ( stockAmount ) ;
if ( StringUtils . isEmpty ( stockType ) ) {
} else {
WmsProductStock queryProductStock = new WmsProductStock ( ) ;
queryProductStock . setProductId ( existedInventoryCheckDetail . getMaterialId ( ) ) ;
queryProductStock . setWarehouseId ( wmsInventoryCheck . getWarehouseId ( ) ) ;
List < WmsProductStock > wmsProductStockInList = wmsProductStockMapper . selectOnlyWmsProductStockInList ( queryProductStock ) ;
//需要区分批次和非批次, 所以需要通过totalAmount相加得出此物料库存总数量
BigDecimal stockAmount = wmsProductStockInList = = null | | wmsProductStockInList . isEmpty ( ) ? BigDecimal . ZERO :
wmsProductStockInList . stream ( )
. map ( WmsProductStock : : getTotalAmount )
. reduce ( BigDecimal . ZERO , BigDecimal : : add ) ;
existedInventoryCheckDetail . setStockAmount ( stockAmount ) ;
if ( stockType . equals ( WmsConstants . WMS_WAREHOUSE_INSTOCK_TYPE_RAW ) ) {
WmsRawStock queryRawStock = new WmsRawStock ( ) ;
queryRawStock . setMaterialId ( existedInventoryCheckDetail . getMaterialId ( ) ) ;
queryRawStock . setLocationCode ( existedInventoryCheckDetail . getLocationCode ( ) ) ;
queryRawStock . setWarehouseId ( wmsInventoryCheck . getWarehouseId ( ) ) ;
List < WmsRawStock > wmsRawStockInList = wmsRawStockMapper . selectOnlyWmsRawStockInList ( queryRawStock ) ;
//按库位计算库存数量
BigDecimal stockAmount = wmsRawStockInList = = null | | wmsRawStockInList . isEmpty ( ) ? BigDecimal . ZERO :
wmsRawStockInList . stream ( )
. map ( WmsRawStock : : getTotalAmount )
. reduce ( BigDecimal . ZERO , BigDecimal : : add ) ;
existedInventoryCheckDetail . setStockAmount ( stockAmount ) ;
} else {
WmsProductStock queryProductStock = new WmsProductStock ( ) ;
queryProductStock . setProductId ( existedInventoryCheckDetail . getMaterialId ( ) ) ;
queryProductStock . setLocationCode ( existedInventoryCheckDetail . getLocationCode ( ) ) ;
queryProductStock . setWarehouseId ( wmsInventoryCheck . getWarehouseId ( ) ) ;
List < WmsProductStock > wmsProductStockInList = wmsProductStockMapper . selectOnlyWmsProductStockInList ( queryProductStock ) ;
//按库位计算库存数量
BigDecimal stockAmount = wmsProductStockInList = = null | | wmsProductStockInList . isEmpty ( ) ? BigDecimal . ZERO :
wmsProductStockInList . stream ( )
. map ( WmsProductStock : : getTotalAmount )
. reduce ( BigDecimal . ZERO , BigDecimal : : add ) ;
existedInventoryCheckDetail . setStockAmount ( stockAmount ) ;
}
}
@ -403,7 +423,11 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
@Override
@Transactional ( rollbackFor = Exception . class )
public int completeInventoryCheck ( WmsInventoryCheck wmsInventoryCheck ) {
List < WmsInventoryCheckDetail > wmsInventoryCheckDetailList = wmsInventoryCheck . getWmsInventoryCheckDetailList ( ) ;
// List<WmsInventoryCheckDetail> wmsInventoryCheckDetailList = wmsInventoryCheck.getWmsInventoryCheckDetailList();
WmsInventoryCheckDetail queryInventoryCheckDetail = new WmsInventoryCheckDetail ( ) ;
queryInventoryCheckDetail . setInventoryCheckId ( wmsInventoryCheck . getInventoryCheckId ( ) ) ;
List < WmsInventoryCheckDetail > wmsInventoryCheckDetailList = wmsInventoryCheckDetailMapper . selectWmsInventoryCheckDetailList ( queryInventoryCheckDetail ) ;
List < WmsInventoryCheckDetail > unconfirmedCheckDetails = wmsInventoryCheckDetailList . stream ( )
. filter ( checkDetail - > checkDetail . getInventoryTime ( ) < 1 ) . collect ( Collectors . toList ( ) ) ;
if ( unconfirmedCheckDetails ! = null & & ! unconfirmedCheckDetails . isEmpty ( ) ) {
@ -412,11 +436,12 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
Map < String , List < WmsInventoryCheckDetail > > inventoryCheckDetailMap = wmsInventoryCheckDetailList . stream ( )
. collect ( Collectors . groupingBy ( WmsInventoryCheckDetail : : getLocationCode ) ) ;
long completeLocationAmount = inventoryCheckDetailMap . entrySet ( ) . size ( ) ;
// long completeLocationAmount = inventoryCheckDetailMap.entrySet().size();
// List<Long> inventoryCheckDetailIds = wmsInventoryCheckDetailList.stream().map(WmsInventoryCheckDetail::getInventoryCheckDetailId).collect(Collectors.toList());
Date currentDate = new Date ( ) ;
String userName = SecurityUtils . getUsername ( ) ;
wmsInventoryCheckDetailList . forEach ( wmsInventoryCheckDetail - > {
wmsInventoryCheckDetail . setCheckStatus ( WmsConstants . WMS_INVENTORY_CHECK_DETAIL_STATUS_FINISH ) ;
wmsInventoryCheckDetail . setUpdateDate ( currentDate ) ;
@ -425,10 +450,12 @@ public class WmsInventoryCheckServiceImpl implements IWmsInventoryCheckService {
} ) ;
WmsInventoryCheck existedInventoryCheck = wmsInventoryCheckMapper . selectOnlyInventoryCheckByInventoryCheckId ( wmsInventoryCheck . getInventoryCheckId ( ) ) ;
Long inventoriedAmount = existedInventoryCheck . getInventoriedAmount ( ) ;
Long locationAmount = existedInventoryCheck . getLocationAmount ( ) ;
Long currentInventoriedAmount = inventoriedAmount + completeLocationAmount ;
Long inventoriedAmount = existedInventoryCheck . getInventoriedAmount ( ) ; //已盘点库位数量
Long inventoryingAmount = existedInventoryCheck . getInventoryingAmount ( ) ;
Long locationAmount = existedInventoryCheck . getLocationAmount ( ) ; //库位总数量
Long currentInventoriedAmount = inventoriedAmount + inventoryingAmount ; //当前已盘点库位总数量
wmsInventoryCheck . setInventoriedAmount ( currentInventoriedAmount ) ;
wmsInventoryCheck . setInventoryingAmount ( 0 L ) ;
wmsInventoryCheck . setUpdateDate ( currentDate ) ;
wmsInventoryCheck . setUpdateBy ( userName ) ;
if ( currentInventoriedAmount > = locationAmount ) {