PDA端容器移位库存调整记录修改
This commit is contained in:
+53
-21
@@ -570,7 +570,7 @@ public class ShiftManageDomainService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description app 容器移位
|
||||
* @description app 容器移位(PDA 端直接调用 PC 端移位流程:insert + finishShiftByPC)
|
||||
* @author ZhouGY
|
||||
* @date 2024/7/30 14:24
|
||||
* @param containerShiftDOList
|
||||
@@ -580,7 +580,11 @@ public class ShiftManageDomainService {
|
||||
public Boolean appMoveContainShift(List<ContainerShiftDO> containerShiftDOList){
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String shiftNumber = OrderSequence.getOrderCode("YW");
|
||||
List<ShiftMaterialDetailDO> shiftMaterialDetailDOList = shiftMaterialDetailService.appMoveContainShift(containerShiftDOList, shiftNumber);
|
||||
// 仅构建移位明细结构,不执行库存变更(库存变更由 PC finishShiftByPC 统一处理)
|
||||
List<ShiftMaterialDetailDO> shiftMaterialDetailDOList = shiftMaterialDetailService.buildShiftMaterialDetailListFromContainerShift(containerShiftDOList);
|
||||
if (CollectionUtils.isEmpty(shiftMaterialDetailDOList)) {
|
||||
throw new ServiceException("容器移位明细不能为空");
|
||||
}
|
||||
ShiftManageDO shiftManageDO = new ShiftManageDO();
|
||||
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
|
||||
shiftManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
|
||||
@@ -588,7 +592,7 @@ public class ShiftManageDomainService {
|
||||
shiftManageDO.setWarehouseName(associationWarehouseCacheDO.getWarehouseName());
|
||||
shiftManageDO.setShiftNumber(shiftNumber);
|
||||
shiftManageDO.setRemark("容器移位生成");
|
||||
shiftManageDO.setShiftStatus(4);//默认以为完成
|
||||
shiftManageDO.setShiftStatus(1);// 先创建为已创建状态,由 finishShiftByPC 完成
|
||||
shiftManageDO.setAuditStatus(3);
|
||||
shiftManageDO.setAuditBy(loginUser.getUserid());
|
||||
shiftManageDO.setAuditByName(loginUser.getUsername());
|
||||
@@ -601,12 +605,22 @@ public class ShiftManageDomainService {
|
||||
shiftManageDO.setQuantity(quantity);
|
||||
shiftManageDO.setShiftQuantity(quantity);
|
||||
shiftManageDO.setShiftMaterialDetailList(shiftMaterialDetailDOList);
|
||||
//新增移位单
|
||||
// 1. 新增移位单(PC insert)
|
||||
insert(shiftManageDO);
|
||||
//生成移位追溯记录
|
||||
// 2. 获取新创建的移位单
|
||||
ShiftManagePO shiftManagePO = shiftManageService.getInfoByShiftNumber(shiftManageDO.getShiftNumber());
|
||||
genInventoryStandingDetail(shiftManagePO);
|
||||
return true;
|
||||
if (shiftManagePO == null) {
|
||||
throw new ServiceException("容器移位单创建失败");
|
||||
}
|
||||
// 3. 调用 PC 完成移位(库存变更、库存调整记录、移位追溯由 finishShiftByPC 统一处理)
|
||||
ShiftManageDO finishShiftDO = new ShiftManageDO();
|
||||
finishShiftDO.setShiftManageId(shiftManagePO.getShiftManageId());
|
||||
ShiftMaterialDetailDO queryDO = new ShiftMaterialDetailDO();
|
||||
queryDO.setShiftNumber(shiftNumber);
|
||||
List<ShiftMaterialDetailPO> shiftMaterialDetailPOList = shiftMaterialDetailService.queryListChildren(queryDO);
|
||||
List<ShiftMaterialDetailDO> finishDetailList = shiftMaterialDetailPOList.stream().map(po -> convertShiftDetailPOToDO(po)).collect(Collectors.toList());
|
||||
finishShiftDO.setShiftMaterialDetailList(finishDetailList);
|
||||
return finishShiftByPC(finishShiftDO);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -701,21 +715,24 @@ public class ShiftManageDomainService {
|
||||
));
|
||||
for (ShiftMaterialDetailPO shiftMaterialDetailPO : shiftMaterialDetailPOList){
|
||||
MaterialInventory materialInventoryOldDb = materialInventoryService.getById(shiftMaterialDetailPO.getMaterialInventoryId());
|
||||
BigDecimal shiftQuantity = shiftMaterialDetailPO.getShiftQuantity();
|
||||
//构建新物料库存信息
|
||||
shiftMaterialDetailPO.setMaterialMoreDetailList(MaterialMoreDetailMap.get(shiftMaterialDetailPO.getShiftNumber()));
|
||||
// shiftMaterialDetailPO.setNetWeight(materialInventoryOldDb.getNetWeight());
|
||||
// shiftMaterialDetailPO.setGrossWeight(materialInventoryOldDb.getGrossWeight());
|
||||
// shiftMaterialDetailPO.setVolume(materialInventoryOldDb.getVolume());
|
||||
// shiftMaterialDetailPO.setArea(materialInventoryOldDb.getArea());
|
||||
// shiftMaterialDetailPO.setMaterialInventoryId(materialInventoryOldDb.getMaterialInventoryId());
|
||||
materialInventoryNowList.add(genMaterialInventory(shiftMaterialDetailPO));
|
||||
List<ShiftMaterialDetailPO> shiftMaterialDetailPOChildrenList = shiftMaterialDetailPO.getChildren();
|
||||
for (ShiftMaterialDetailPO shiftMaterialDetailPOChildren : shiftMaterialDetailPOChildrenList){
|
||||
shiftQuantity = shiftQuantity.add(shiftMaterialDetailPOChildren.getShiftQuantity());
|
||||
//构建新物料库存信息
|
||||
materialInventoryNowList.add(genMaterialInventory(shiftMaterialDetailPOChildren));
|
||||
};
|
||||
boolean hasChildren = !CollectionUtils.isEmpty(shiftMaterialDetailPOChildrenList);
|
||||
// 有子项时仅用子项参与库存计算,避免父项+子项重复累加(容器移位已改为扁平结构无子项,此处主要防护按单移位的父子同目标场景)
|
||||
BigDecimal shiftQuantity;
|
||||
if (hasChildren) {
|
||||
shiftQuantity = shiftMaterialDetailPOChildrenList.stream()
|
||||
.map(c -> c.getShiftQuantity() != null ? c.getShiftQuantity() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
shiftMaterialDetailPO.setMaterialMoreDetailList(MaterialMoreDetailMap.get(shiftMaterialDetailPO.getShiftNumber()));
|
||||
for (ShiftMaterialDetailPO shiftMaterialDetailPOChildren : shiftMaterialDetailPOChildrenList) {
|
||||
shiftMaterialDetailPOChildren.setMaterialMoreDetailList(MaterialMoreDetailMap.get(shiftMaterialDetailPO.getShiftNumber()));
|
||||
materialInventoryNowList.add(genMaterialInventory(shiftMaterialDetailPOChildren));
|
||||
}
|
||||
} else {
|
||||
shiftQuantity = shiftMaterialDetailPO.getShiftQuantity() != null ? shiftMaterialDetailPO.getShiftQuantity() : BigDecimal.ZERO;
|
||||
shiftMaterialDetailPO.setMaterialMoreDetailList(MaterialMoreDetailMap.get(shiftMaterialDetailPO.getShiftNumber()));
|
||||
materialInventoryNowList.add(genMaterialInventory(shiftMaterialDetailPO));
|
||||
}
|
||||
if (materialInventoryOldDb.getInventoryQuantity().compareTo(shiftQuantity) < 0){
|
||||
throw new ServiceException("物料原库位下的物料库存不足,不能进行移位");
|
||||
}
|
||||
@@ -850,6 +867,9 @@ public class ShiftManageDomainService {
|
||||
}
|
||||
|
||||
private void BatchAttributeAssignment(List<MaterialMoreDetailPO> materialMoreDetailList, MaterialInventoryDO materialInventoryDONow) {
|
||||
if (CollectionUtils.isEmpty(materialMoreDetailList)) {
|
||||
return;
|
||||
}
|
||||
for (MaterialMoreDetailPO materialMoreDetailPO : materialMoreDetailList) {
|
||||
if (materialMoreDetailPO == null || materialMoreDetailPO.getBatchLabels() == null) {
|
||||
continue;
|
||||
@@ -894,4 +914,16 @@ public class ShiftManageDomainService {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** PO 转 DO,含 children 递归转换 */
|
||||
private ShiftMaterialDetailDO convertShiftDetailPOToDO(ShiftMaterialDetailPO po) {
|
||||
ShiftMaterialDetailDO d = new ShiftMaterialDetailDO();
|
||||
BeanUtils.copyProperties(po, d, "children");
|
||||
if (!CollectionUtils.isEmpty(po.getChildren())) {
|
||||
List<ShiftMaterialDetailDO> childList = po.getChildren().stream()
|
||||
.map(this::convertShiftDetailPOToDO).collect(Collectors.toList());
|
||||
d.setChildren(childList);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -81,6 +81,13 @@ public interface IShiftMaterialDetailService extends IService<ShiftMaterialDetai
|
||||
*/
|
||||
public List<ShiftMaterialDetailDO> appMoveContainShift(List<ContainerShiftDO> containerShiftDOList, String shiftNumber);
|
||||
|
||||
/**
|
||||
* 容器移位:仅构建移位明细结构(供 PDA 调用 PC 移位流程使用,不执行库存变更)
|
||||
* @param containerShiftDOList 容器移位明细
|
||||
* @return 移位物料明细列表(主项含 children 子项)
|
||||
*/
|
||||
public List<ShiftMaterialDetailDO> buildShiftMaterialDetailListFromContainerShift(List<ContainerShiftDO> containerShiftDOList);
|
||||
|
||||
/**
|
||||
* @description 批量修改物料信息
|
||||
* @author ZhouGY
|
||||
|
||||
+158
-41
@@ -408,6 +408,62 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
return shiftMaterialDetailDOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 容器移位:仅构建移位明细结构(扁平结构,每条目标一条记录),不执行库存变更和库存调整记录(供 PDA 调用 PC 移位流程使用)
|
||||
* 与按单移位区分:不生成父项+子项,避免同一笔移位重复插入、重复计算库存
|
||||
*/
|
||||
@Override
|
||||
public List<ShiftMaterialDetailDO> buildShiftMaterialDetailListFromContainerShift(List<ContainerShiftDO> containerShiftDOList) {
|
||||
List<ShiftMaterialDetailDO> shiftMaterialDetailDOList = new ArrayList<>();
|
||||
for (ContainerShiftDO containerShiftDO : containerShiftDOList){
|
||||
List<ShiftMoveMaterialQuantityPO> shiftMoveMaterialQuantityList = containerShiftDO.getChildren();
|
||||
if (CollectionUtils.isEmpty(shiftMoveMaterialQuantityList)) continue;
|
||||
BigDecimal totalShiftQuantity = BigDecimal.ZERO;
|
||||
for (ShiftMoveMaterialQuantityPO c : shiftMoveMaterialQuantityList) {
|
||||
if (c.getShiftQuantity() != null && c.getShiftQuantity().compareTo(BigDecimal.ZERO) > 0) {
|
||||
totalShiftQuantity = totalShiftQuantity.add(c.getShiftQuantity());
|
||||
}
|
||||
}
|
||||
if (totalShiftQuantity.compareTo(BigDecimal.ZERO) <= 0) continue;
|
||||
MaterialInventory materialInventoryOldDb = materialInventoryMapper.selectById(containerShiftDO.getMaterialInventoryId());
|
||||
if (ObjectUtil.isNull(materialInventoryOldDb)){
|
||||
throw new ServiceException("原库位【" + containerShiftDO.getContainerTypeName() + "】不存在,不能进行移位");
|
||||
}
|
||||
if (materialInventoryOldDb.getInventoryQuantity().compareTo(totalShiftQuantity) < 0){
|
||||
throw new ServiceException("容器【" + containerShiftDO.getContainerTypeName() + "】下的物料库存不足,不能进行移位");
|
||||
}
|
||||
// 容器移位只生成扁平明细(每条目标一条记录),不生成父项,避免 insert 时父+子两条记录、updateMaterialInventory 重复计算
|
||||
for (ShiftMoveMaterialQuantityPO shiftMoveMaterialQuantityPO : shiftMoveMaterialQuantityList) {
|
||||
if (ObjectUtil.isNull(shiftMoveMaterialQuantityPO.getShiftQuantity()) || shiftMoveMaterialQuantityPO.getShiftQuantity().compareTo(BigDecimal.ZERO) == 0){
|
||||
continue;
|
||||
}
|
||||
ShiftMaterialDetailDO detailDO = new ShiftMaterialDetailDO();
|
||||
detailDO.setMaterialInventoryId(containerShiftDO.getMaterialInventoryId());
|
||||
detailDO.setMaterialBaseInfoId(containerShiftDO.getMaterialBaseInfoId());
|
||||
detailDO.setQuantity(shiftMoveMaterialQuantityPO.getShiftQuantity());
|
||||
detailDO.setShiftQuantity(shiftMoveMaterialQuantityPO.getShiftQuantity());
|
||||
detailDO.setNewStorageLocationId(shiftMoveMaterialQuantityPO.getNewStorageLocationId());
|
||||
detailDO.setNewStorageSectionId(shiftMoveMaterialQuantityPO.getNewStorageSectionId());
|
||||
detailDO.setNewStorageCode(shiftMoveMaterialQuantityPO.getNewStorageCode());
|
||||
detailDO.setNewStorageName(shiftMoveMaterialQuantityPO.getNewStorageName());
|
||||
detailDO.setNewStorageLocationCode(shiftMoveMaterialQuantityPO.getNewStorageLocationCode());
|
||||
detailDO.setNewStorageLocationName(shiftMoveMaterialQuantityPO.getNewStorageLocationName());
|
||||
detailDO.setContainerId(shiftMoveMaterialQuantityPO.getContainerId());
|
||||
detailDO.setContainerCode(shiftMoveMaterialQuantityPO.getContainerCode());
|
||||
detailDO.setContainerType(shiftMoveMaterialQuantityPO.getContainerType());
|
||||
detailDO.setContainerTypeName(shiftMoveMaterialQuantityPO.getContainerTypeName());
|
||||
detailDO.setLevel(1);
|
||||
detailDO.setChildren(null);
|
||||
if (shiftMoveMaterialQuantityPO.getNetWeight() != null) detailDO.setNetWeight(shiftMoveMaterialQuantityPO.getNetWeight());
|
||||
if (shiftMoveMaterialQuantityPO.getGrossWeight() != null) detailDO.setGrossWeight(shiftMoveMaterialQuantityPO.getGrossWeight());
|
||||
if (shiftMoveMaterialQuantityPO.getVolume() != null) detailDO.setVolume(shiftMoveMaterialQuantityPO.getVolume());
|
||||
if (shiftMoveMaterialQuantityPO.getArea() != null) detailDO.setArea(shiftMoveMaterialQuantityPO.getArea());
|
||||
shiftMaterialDetailDOList.add(detailDO);
|
||||
}
|
||||
}
|
||||
return shiftMaterialDetailDOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 容器移位生成库存调整记录:原库位减少记录 + 各目标库位增加记录
|
||||
*/
|
||||
@@ -416,9 +472,9 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
List<ShiftMoveMaterialQuantityPO> shiftMoveMaterialQuantityList, String shiftNumber) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
MaterialBaseInfoPO materialBaseInfo = materialBaseInfoService.getInfo(containerShiftDO.getMaterialBaseInfoId());
|
||||
String materialCode = materialBaseInfo != null ? materialBaseInfo.getMaterialCode() : "";
|
||||
String materialName = materialBaseInfo != null ? materialBaseInfo.getMaterialName() : "";
|
||||
String barCode = materialBaseInfo != null ? materialBaseInfo.getBarCode() : "";
|
||||
String materialCode = materialBaseInfo != null && materialBaseInfo.getMaterialCode() != null ? materialBaseInfo.getMaterialCode() : "";
|
||||
String materialName = materialBaseInfo != null && materialBaseInfo.getMaterialName() != null ? materialBaseInfo.getMaterialName() : "";
|
||||
String barCode = materialBaseInfo != null && materialBaseInfo.getBarCode() != null ? materialBaseInfo.getBarCode() : "";
|
||||
BigDecimal oldQty = materialInventoryOldDb.getInventoryQuantity() != null ? materialInventoryOldDb.getInventoryQuantity() : BigDecimal.ZERO;
|
||||
BigDecimal oldAlloc = materialInventoryOldDb.getAllocationQuantity() != null ? materialInventoryOldDb.getAllocationQuantity() : BigDecimal.ZERO;
|
||||
BigDecimal newQty = oldQty.subtract(totalShiftQuantity).max(BigDecimal.ZERO);
|
||||
@@ -442,13 +498,15 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
if (materialInventoryOldDb.getVolume() != null) adjVol = materialInventoryOldDb.getVolume().multiply(ratio);
|
||||
if (materialInventoryOldDb.getArea() != null) adjArea = materialInventoryOldDb.getArea().multiply(ratio);
|
||||
}
|
||||
// 原库位减少记录(adjusted 为移出量,取负表示减少)
|
||||
// 原库位减少记录(adjusted 为移出量,取负表示减少),冻结数量留在原库位不变
|
||||
BigDecimal oldFreeze = materialInventoryOldDb.getFreezeQuantity() != null ? materialInventoryOldDb.getFreezeQuantity() : BigDecimal.ZERO;
|
||||
InventoryAdjustmentRecord recordOld = buildInventoryAdjustmentRecord(loginUser, containerShiftDO, materialInventoryOldDb,
|
||||
materialCode, materialName, barCode, shiftNumber,
|
||||
materialInventoryOldDb.getWarehouseId(), materialInventoryOldDb.getWarehouseCode(), materialInventoryOldDb.getWarehouseName(),
|
||||
materialInventoryOldDb.getStorageSectionId(), materialInventoryOldDb.getStorageCode(), materialInventoryOldDb.getStorageName(),
|
||||
materialInventoryOldDb.getStorageLocationId(), materialInventoryOldDb.getStorageLocationCode(), materialInventoryOldDb.getStorageLocationName(),
|
||||
materialInventoryOldDb.getMaterialInventoryId(), oldQty, oldAlloc, newQty, newAlloc,
|
||||
oldFreeze, oldFreeze,
|
||||
materialInventoryOldDb.getNetWeight(), materialInventoryOldDb.getGrossWeight(), materialInventoryOldDb.getVolume(), materialInventoryOldDb.getArea(),
|
||||
adjNet.negate(), adjGross.negate(), adjVol.negate(), adjArea.negate());
|
||||
inventoryAdjustmentRecordMapper.insert(recordOld);
|
||||
@@ -471,17 +529,23 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
BigDecimal afterQty = beforeQty.add(c.getShiftQuantity());
|
||||
BigDecimal afterAlloc = beforeAlloc.add(c.getShiftQuantity());
|
||||
Long newInvId = materialInventoryDb != null ? materialInventoryDb.getMaterialInventoryId() : null;
|
||||
Long whId = materialInventoryDb != null ? materialInventoryDb.getWarehouseId()
|
||||
: (SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()) != null
|
||||
? SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()).getWarehouseId() : containerShiftDO.getWarehouseId());
|
||||
String whCode = materialInventoryDb != null ? materialInventoryDb.getWarehouseCode() : (containerShiftDO.getWarehouseCode() != null ? containerShiftDO.getWarehouseCode() : "");
|
||||
String whName = materialInventoryDb != null ? materialInventoryDb.getWarehouseName() : (containerShiftDO.getWarehouseName() != null ? containerShiftDO.getWarehouseName() : "");
|
||||
// 目标库位仓库信息:优先用目标库存,无则用原库位(同仓移位)
|
||||
Long whId = materialInventoryDb != null && materialInventoryDb.getWarehouseId() != null ? materialInventoryDb.getWarehouseId()
|
||||
: materialInventoryOldDb.getWarehouseId();
|
||||
String whCode = materialInventoryDb != null && StringUtils.isNotBlank(materialInventoryDb.getWarehouseCode())
|
||||
? materialInventoryDb.getWarehouseCode() : (StringUtils.isNotBlank(materialInventoryOldDb.getWarehouseCode()) ? materialInventoryOldDb.getWarehouseCode() : "");
|
||||
String whName = materialInventoryDb != null && StringUtils.isNotBlank(materialInventoryDb.getWarehouseName())
|
||||
? materialInventoryDb.getWarehouseName() : (StringUtils.isNotBlank(materialInventoryOldDb.getWarehouseName()) ? materialInventoryOldDb.getWarehouseName() : "");
|
||||
// 目标库位:新增时 freeze 为 0;已存在时用目标库位自身的 freeze
|
||||
BigDecimal newFreeze = materialInventoryDb != null && materialInventoryDb.getFreezeQuantity() != null
|
||||
? materialInventoryDb.getFreezeQuantity() : BigDecimal.ZERO;
|
||||
InventoryAdjustmentRecord recordNew = buildInventoryAdjustmentRecord(loginUser, containerShiftDO, materialInventoryOldDb,
|
||||
materialCode, materialName, barCode, shiftNumber,
|
||||
whId, whCode, whName,
|
||||
c.getNewStorageSectionId(), c.getNewStorageCode(), c.getNewStorageName(),
|
||||
c.getNewStorageLocationId(), c.getNewStorageLocationCode(), c.getNewStorageLocationName(),
|
||||
newInvId, beforeQty, beforeAlloc, afterQty, afterAlloc,
|
||||
newFreeze, newFreeze,
|
||||
BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO,
|
||||
c.getNetWeight() != null ? c.getNetWeight() : BigDecimal.ZERO,
|
||||
c.getGrossWeight() != null ? c.getGrossWeight() : BigDecimal.ZERO,
|
||||
@@ -498,6 +562,7 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
Long storageLocationId, String storageLocationCode, String storageLocationName,
|
||||
Long materialInventoryId, BigDecimal inventoryBefore, BigDecimal allocationBefore,
|
||||
BigDecimal inventoryAfter, BigDecimal allocationAfter,
|
||||
BigDecimal freezeBefore, BigDecimal freezeAfter,
|
||||
BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area,
|
||||
BigDecimal adjustedNetWeight, BigDecimal adjustedGrossWeight, BigDecimal adjustedVolume, BigDecimal adjustedArea) {
|
||||
InventoryAdjustmentRecord r = new InventoryAdjustmentRecord();
|
||||
@@ -508,14 +573,14 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
r.setOrganizationName(materialInventoryOldDb.getOrganizationName());
|
||||
r.setTopOrganizationId(materialInventoryOldDb.getTopOrganizationId());
|
||||
r.setMaterialBaseInfoId(containerShiftDO.getMaterialBaseInfoId());
|
||||
r.setMaterialCode(materialCode);
|
||||
r.setMaterialName(materialName);
|
||||
r.setBarCode(barCode);
|
||||
r.setMaterialCode(materialCode != null ? materialCode : "");
|
||||
r.setMaterialName(materialName != null ? materialName : "");
|
||||
r.setBarCode(barCode != null ? barCode : "");
|
||||
r.setShipperId(materialInventoryOldDb.getShipperId());
|
||||
r.setShipperName(materialInventoryOldDb.getShipperName());
|
||||
r.setWarehouseId(warehouseId);
|
||||
r.setWarehouseCode(warehouseCode);
|
||||
r.setWarehouseName(warehouseName);
|
||||
r.setWarehouseCode(warehouseCode != null ? warehouseCode : "");
|
||||
r.setWarehouseName(warehouseName != null ? warehouseName : "");
|
||||
r.setStorageSectionId(storageSectionId);
|
||||
r.setStorageCode(storageCode);
|
||||
r.setStorageName(storageName);
|
||||
@@ -523,12 +588,12 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
r.setStorageLocationCode(storageLocationCode);
|
||||
r.setStorageLocationName(storageLocationName);
|
||||
r.setMaterialInventoryId(materialInventoryId);
|
||||
r.setInventoryBeforeQuantity(inventoryBefore);
|
||||
r.setAllocationBeforeQuantity(allocationBefore);
|
||||
r.setInventoryAfterQuantity(inventoryAfter);
|
||||
r.setAllocationAfterQuantity(allocationAfter);
|
||||
r.setFreezeBeforeQuantity(materialInventoryOldDb.getFreezeQuantity() != null ? materialInventoryOldDb.getFreezeQuantity() : BigDecimal.ZERO);
|
||||
r.setFreezeAfterQuantity(materialInventoryOldDb.getFreezeQuantity() != null ? materialInventoryOldDb.getFreezeQuantity() : BigDecimal.ZERO);
|
||||
r.setInventoryBeforeQuantity(inventoryBefore != null ? inventoryBefore : BigDecimal.ZERO);
|
||||
r.setAllocationBeforeQuantity(allocationBefore != null ? allocationBefore : BigDecimal.ZERO);
|
||||
r.setInventoryAfterQuantity(inventoryAfter != null ? inventoryAfter : BigDecimal.ZERO);
|
||||
r.setAllocationAfterQuantity(allocationAfter != null ? allocationAfter : BigDecimal.ZERO);
|
||||
r.setFreezeBeforeQuantity(freezeBefore != null ? freezeBefore : BigDecimal.ZERO);
|
||||
r.setFreezeAfterQuantity(freezeAfter != null ? freezeAfter : BigDecimal.ZERO);
|
||||
r.setAdjustBeforeStatusCode(materialInventoryOldDb.getMaterialStatusCode() != null ? materialInventoryOldDb.getMaterialStatusCode() : "");
|
||||
r.setAdjustBeforeStatusName(materialInventoryOldDb.getMaterialStatusName() != null ? materialInventoryOldDb.getMaterialStatusName() : "");
|
||||
r.setAdjustAfterStatusCode(materialInventoryOldDb.getMaterialStatusCode() != null ? materialInventoryOldDb.getMaterialStatusCode() : "");
|
||||
@@ -708,27 +773,79 @@ public class ShiftMaterialDetailImpl extends ServiceImpl<ShiftMaterialDetailMapp
|
||||
InventoryAdjustmentRecord inventoryAdjustmentRecord2 = new InventoryAdjustmentRecord();
|
||||
BeanUtils.copyProperties(inventoryAdjustmentRecord, inventoryAdjustmentRecord2);
|
||||
inventoryAdjustmentRecord2.setInventoryAdjustmentId(null);
|
||||
inventoryAdjustmentRecord2.setNetWeight(BigDecimal.ZERO);
|
||||
inventoryAdjustmentRecord2.setGrossWeight(BigDecimal.ZERO);
|
||||
inventoryAdjustmentRecord2.setVolume(BigDecimal.ZERO);
|
||||
inventoryAdjustmentRecord2.setArea(BigDecimal.ZERO);
|
||||
inventoryAdjustmentRecord.setInventoryBeforeQuantity(BigDecimal.ZERO);
|
||||
inventoryAdjustmentRecord.setAllocationBeforeQuantity(BigDecimal.ZERO);
|
||||
inventoryAdjustmentRecord2.setAdjustedNetWeight(shiftMaterialDetailDO.getNetWeight());
|
||||
inventoryAdjustmentRecord2.setAdjustedGrossWeight(shiftMaterialDetailDO.getGrossWeight());
|
||||
inventoryAdjustmentRecord2.setAdjustedVolume(shiftMaterialDetailDO.getVolume());
|
||||
inventoryAdjustmentRecord2.setAdjustedArea(shiftMaterialDetailDO.getArea());
|
||||
inventoryAdjustmentRecord.setWarehouseCode(shiftMaterialDetailDO.getNewWarehouseCode());
|
||||
inventoryAdjustmentRecord.setWarehouseName(shiftMaterialDetailDO.getNewWarehouseName());
|
||||
inventoryAdjustmentRecord.setWarehouseId(shiftMaterialDetailDO.getNewWarehouseId());
|
||||
inventoryAdjustmentRecord.setStorageCode(shiftMaterialDetailDO.getNewStorageCode());
|
||||
inventoryAdjustmentRecord.setStorageName(shiftMaterialDetailDO.getNewStorageName());
|
||||
inventoryAdjustmentRecord.setStorageLocationId(shiftMaterialDetailDO.getNewStorageLocationId());
|
||||
inventoryAdjustmentRecord.setStorageLocationCode(shiftMaterialDetailDO.getNewStorageLocationCode());
|
||||
inventoryAdjustmentRecord.setStorageLocationName(shiftMaterialDetailDO.getNewStorageLocationName());
|
||||
inventoryAdjustmentRecord.setStorageSectionId(shiftMaterialDetailDO.getNewStorageSectionId());
|
||||
inventoryAdjustmentRecord.setStorageLocationId(shiftMaterialDetailDO.getNewStorageLocationId());
|
||||
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord2);//移位后物料记录
|
||||
// 移入库存:调整前净重/毛重/体积/面积应为新库位当前值,调整值=移入物料的净重/毛重/体积/面积
|
||||
MaterialInventory newLocationInventory = queryNewLocationMaterialInventory(shiftMaterialDetailDO);
|
||||
BigDecimal newNetBefore = newLocationInventory != null && newLocationInventory.getNetWeight() != null ? newLocationInventory.getNetWeight() : BigDecimal.ZERO;
|
||||
BigDecimal newGrossBefore = newLocationInventory != null && newLocationInventory.getGrossWeight() != null ? newLocationInventory.getGrossWeight() : BigDecimal.ZERO;
|
||||
BigDecimal newVolBefore = newLocationInventory != null && newLocationInventory.getVolume() != null ? newLocationInventory.getVolume() : BigDecimal.ZERO;
|
||||
BigDecimal newAreaBefore = newLocationInventory != null && newLocationInventory.getArea() != null ? newLocationInventory.getArea() : BigDecimal.ZERO;
|
||||
BigDecimal shiftNet = shiftMaterialDetailDO.getNetWeight() != null ? shiftMaterialDetailDO.getNetWeight() : BigDecimal.ZERO;
|
||||
BigDecimal shiftGross = shiftMaterialDetailDO.getGrossWeight() != null ? shiftMaterialDetailDO.getGrossWeight() : BigDecimal.ZERO;
|
||||
BigDecimal shiftVol = shiftMaterialDetailDO.getVolume() != null ? shiftMaterialDetailDO.getVolume() : BigDecimal.ZERO;
|
||||
BigDecimal shiftArea = shiftMaterialDetailDO.getArea() != null ? shiftMaterialDetailDO.getArea() : BigDecimal.ZERO;
|
||||
inventoryAdjustmentRecord2.setNetWeight(newNetBefore);
|
||||
inventoryAdjustmentRecord2.setGrossWeight(newGrossBefore);
|
||||
inventoryAdjustmentRecord2.setVolume(newVolBefore);
|
||||
inventoryAdjustmentRecord2.setArea(newAreaBefore);
|
||||
// 调整后 = 调整前 + 移入量
|
||||
inventoryAdjustmentRecord2.setAdjustedNetWeight(newNetBefore.add(shiftNet));
|
||||
inventoryAdjustmentRecord2.setAdjustedGrossWeight(newGrossBefore.add(shiftGross));
|
||||
inventoryAdjustmentRecord2.setAdjustedVolume(newVolBefore.add(shiftVol));
|
||||
inventoryAdjustmentRecord2.setAdjustedArea(newAreaBefore.add(shiftArea));
|
||||
// 新库位信息应设置到 inventoryAdjustmentRecord2(移位后记录),之前错误设置到了 inventoryAdjustmentRecord
|
||||
inventoryAdjustmentRecord2.setWarehouseCode(shiftMaterialDetailDO.getNewWarehouseCode());
|
||||
inventoryAdjustmentRecord2.setWarehouseName(shiftMaterialDetailDO.getNewWarehouseName());
|
||||
inventoryAdjustmentRecord2.setWarehouseId(shiftMaterialDetailDO.getNewWarehouseId());
|
||||
inventoryAdjustmentRecord2.setStorageCode(shiftMaterialDetailDO.getNewStorageCode());
|
||||
inventoryAdjustmentRecord2.setStorageName(shiftMaterialDetailDO.getNewStorageName());
|
||||
inventoryAdjustmentRecord2.setStorageLocationId(shiftMaterialDetailDO.getNewStorageLocationId());
|
||||
inventoryAdjustmentRecord2.setStorageLocationCode(shiftMaterialDetailDO.getNewStorageLocationCode());
|
||||
inventoryAdjustmentRecord2.setStorageLocationName(shiftMaterialDetailDO.getNewStorageLocationName());
|
||||
inventoryAdjustmentRecord2.setStorageSectionId(shiftMaterialDetailDO.getNewStorageSectionId());
|
||||
inventoryAdjustmentRecord2.setMaterialInventoryId(null);
|
||||
// 移入库存:调整前数量应为新库位当前库存(移位前),调整后=调整前+移入数量;冻结数量应为新库位的,非原库位
|
||||
BigDecimal newInvBefore = newLocationInventory != null && newLocationInventory.getInventoryQuantity() != null
|
||||
? newLocationInventory.getInventoryQuantity() : BigDecimal.ZERO;
|
||||
BigDecimal newAllocBefore = newLocationInventory != null && newLocationInventory.getAllocationQuantity() != null
|
||||
? newLocationInventory.getAllocationQuantity() : BigDecimal.ZERO;
|
||||
BigDecimal newFreezeBefore = newLocationInventory != null && newLocationInventory.getFreezeQuantity() != null
|
||||
? newLocationInventory.getFreezeQuantity() : BigDecimal.ZERO;
|
||||
BigDecimal shiftQty = shiftMaterialDetailDO.getShiftQuantity() != null ? shiftMaterialDetailDO.getShiftQuantity() : BigDecimal.ZERO;
|
||||
inventoryAdjustmentRecord2.setInventoryBeforeQuantity(newInvBefore);
|
||||
inventoryAdjustmentRecord2.setAllocationBeforeQuantity(newAllocBefore);
|
||||
inventoryAdjustmentRecord2.setFreezeBeforeQuantity(newFreezeBefore);
|
||||
inventoryAdjustmentRecord2.setFreezeAfterQuantity(newFreezeBefore);
|
||||
inventoryAdjustmentRecord2.setInventoryAfterQuantity(newInvBefore.add(shiftQty));
|
||||
inventoryAdjustmentRecord2.setAllocationAfterQuantity(newAllocBefore.add(shiftQty));
|
||||
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord2);//移位后物料记录(新库位增加)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新库位当前物料库存(移位前),用于移入库存调整记录的调整前数量
|
||||
* 查询条件与 updateMaterialInventory.genMaterialInventory 一致
|
||||
*/
|
||||
private MaterialInventory queryNewLocationMaterialInventory(ShiftMaterialDetailDO shiftMaterialDetailDO) {
|
||||
if (shiftMaterialDetailDO.getNewWarehouseId() == null || shiftMaterialDetailDO.getNewStorageLocationId() == null
|
||||
|| shiftMaterialDetailDO.getMaterialBaseInfoId() == null) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MaterialInventory> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(MaterialInventory::getWarehouseId, shiftMaterialDetailDO.getNewWarehouseId());
|
||||
qw.eq(MaterialInventory::getStorageSectionId, shiftMaterialDetailDO.getNewStorageSectionId());
|
||||
qw.eq(MaterialInventory::getStorageLocationId, shiftMaterialDetailDO.getNewStorageLocationId());
|
||||
qw.eq(MaterialInventory::getMaterialBaseInfoId, shiftMaterialDetailDO.getMaterialBaseInfoId());
|
||||
qw.eq(MaterialInventory::getBatchNumber, shiftMaterialDetailDO.getBatchNumber() != null ? shiftMaterialDetailDO.getBatchNumber() : "");
|
||||
qw.eq(MaterialInventory::getMaterialStatusCode, shiftMaterialDetailDO.getMaterialStatusCode() != null ? shiftMaterialDetailDO.getMaterialStatusCode() : "");
|
||||
if (ObjectUtil.isNotNull(shiftMaterialDetailDO.getContainerId()) && shiftMaterialDetailDO.getContainerId() != 0) {
|
||||
qw.eq(MaterialInventory::getContainerId, shiftMaterialDetailDO.getContainerId());
|
||||
} else {
|
||||
qw.and(w -> w.isNull(MaterialInventory::getContainerId).or().eq(MaterialInventory::getContainerId, 0));
|
||||
}
|
||||
try {
|
||||
return materialInventoryService.getOne(qw);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user