库存计算判空处理;
This commit is contained in:
+8
@@ -185,6 +185,14 @@ public class HandoverTaskOrderDomainService {
|
|||||||
BigDecimal checkVolume = outMaterialDetail.getCheckVolume();
|
BigDecimal checkVolume = outMaterialDetail.getCheckVolume();
|
||||||
BigDecimal checkGrossWeight = outMaterialDetail.getCheckGrossWeight();
|
BigDecimal checkGrossWeight = outMaterialDetail.getCheckGrossWeight();
|
||||||
BigDecimal checkNetWeight = outMaterialDetail.getCheckNetWeight();
|
BigDecimal checkNetWeight = outMaterialDetail.getCheckNetWeight();
|
||||||
|
|
||||||
|
// 初始化检查数据,避免空指针
|
||||||
|
checkQuantity = checkQuantity != null ? checkQuantity : BigDecimal.ZERO;
|
||||||
|
checkArea = checkArea != null ? checkArea : BigDecimal.ZERO;
|
||||||
|
checkVolume = checkVolume != null ? checkVolume : BigDecimal.ZERO;
|
||||||
|
checkGrossWeight = checkGrossWeight != null ? checkGrossWeight : BigDecimal.ZERO;
|
||||||
|
checkNetWeight = checkNetWeight != null ? checkNetWeight : BigDecimal.ZERO;
|
||||||
|
|
||||||
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
||||||
if (materialInventoryPO != null) {
|
if (materialInventoryPO != null) {
|
||||||
//更新库存数量
|
//更新库存数量
|
||||||
|
|||||||
+4
@@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -416,6 +417,9 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
|
|||||||
for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) {
|
for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) {
|
||||||
Long materialInventoryId = outMaterialDetail.getMaterialInventoryId();
|
Long materialInventoryId = outMaterialDetail.getMaterialInventoryId();
|
||||||
BigDecimal allocationQuantity = outMaterialDetail.getAllocationQuantity();
|
BigDecimal allocationQuantity = outMaterialDetail.getAllocationQuantity();
|
||||||
|
if (ObjectUtils.isEmpty(allocationQuantity)) {
|
||||||
|
allocationQuantity = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
||||||
if (materialInventoryPO != null) {
|
if (materialInventoryPO != null) {
|
||||||
//更新库存数量
|
//更新库存数量
|
||||||
|
|||||||
+16
-6
@@ -534,19 +534,29 @@ public class StockShelfOrderDomainService {
|
|||||||
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
|
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
|
||||||
} else if (materialInventoryPOS.size() == 1) {
|
} else if (materialInventoryPOS.size() == 1) {
|
||||||
MaterialInventory materialInventory = new MaterialInventory();
|
MaterialInventory materialInventory = new MaterialInventory();
|
||||||
|
BigDecimal shelvesQuantity = shelfMaterialDetail.getShelvesQuantity();
|
||||||
|
shelvesQuantity = shelvesQuantity != null ? shelvesQuantity : BigDecimal.ZERO;
|
||||||
MaterialInventoryPO materialInventoryPO = materialInventoryPOS.get(0);
|
MaterialInventoryPO materialInventoryPO = materialInventoryPOS.get(0);
|
||||||
BigDecimal newInventoryQuantity = materialInventoryPO.getInventoryQuantity().add(shelfMaterialDetail.getShelvesQuantity());
|
BigDecimal newInventoryQuantity = materialInventoryPO.getInventoryQuantity().add(shelvesQuantity);
|
||||||
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
|
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
|
||||||
BigDecimal newAllocationQuantity = materialInventoryPO.getAllocationQuantity().add(shelfMaterialDetail.getShelvesQuantity());
|
BigDecimal newAllocationQuantity = materialInventoryPO.getAllocationQuantity().add(shelvesQuantity);
|
||||||
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
|
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
|
||||||
BigDecimal oldArea = materialInventoryPO.getArea();
|
BigDecimal oldArea = materialInventoryPO.getArea();
|
||||||
BigDecimal newArea = oldArea.add(shelfMaterialDetail.getTotalArea());
|
BigDecimal totalArea = shelfMaterialDetail.getTotalArea();
|
||||||
|
totalArea = totalArea != null ? totalArea : BigDecimal.ZERO;
|
||||||
|
BigDecimal newArea = oldArea.add(totalArea);
|
||||||
BigDecimal oldVolume = materialInventoryPO.getVolume();
|
BigDecimal oldVolume = materialInventoryPO.getVolume();
|
||||||
BigDecimal newVolume = oldVolume.add(shelfMaterialDetail.getTotalVolume());
|
BigDecimal totalVolume = shelfMaterialDetail.getTotalVolume();
|
||||||
|
totalVolume = totalVolume != null ? totalVolume : BigDecimal.ZERO;
|
||||||
|
BigDecimal newVolume = oldVolume.add(totalVolume);
|
||||||
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
|
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
|
||||||
BigDecimal newGrossWeight = oldGrossWeight.add(shelfMaterialDetail.getTotalGrossWeight());
|
BigDecimal totalGrossWeight = shelfMaterialDetail.getTotalGrossWeight();
|
||||||
|
totalGrossWeight = totalGrossWeight != null ? totalGrossWeight : BigDecimal.ZERO;
|
||||||
|
BigDecimal newGrossWeight = oldGrossWeight.add(totalGrossWeight);
|
||||||
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
|
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
|
||||||
BigDecimal newNetWeight = oldNetWeight.add(shelfMaterialDetail.getTotalNetWeight());
|
BigDecimal totalNetWeight = shelfMaterialDetail.getTotalNetWeight();
|
||||||
|
totalNetWeight = totalNetWeight != null ? totalNetWeight : BigDecimal.ZERO;
|
||||||
|
BigDecimal newNetWeight = oldNetWeight.add(totalNetWeight);
|
||||||
|
|
||||||
materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
|
materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
|
||||||
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
|
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
|
||||||
|
|||||||
Reference in New Issue
Block a user