调整库存方法整合;
This commit is contained in:
+6
-8
@@ -1,10 +1,12 @@
|
||||
package com.mhd.wms.domain.materialInventory.repository.facade;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParentDO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryQueryListDO;
|
||||
import com.mhd.wms.domain.statementStatistics.po.ImmediateInventoryPO;
|
||||
@@ -109,13 +111,9 @@ public interface IMaterialInventoryService extends IService<MaterialInventory>
|
||||
* type 类型(1:上架2:分配3:取消分配4:出库交接5:移位6:库存调整7:库存冻结)
|
||||
* materialInventoryId 物料库存ID
|
||||
* */
|
||||
public void xgkc(BigDecimal netWeight,
|
||||
BigDecimal grossWeight,
|
||||
BigDecimal volume,
|
||||
BigDecimal area,
|
||||
BigDecimal quantity,
|
||||
String type,
|
||||
Long materialInventoryId);
|
||||
public void xgkc(MaterialInventoryParamDO materialInventoryParamDO);
|
||||
|
||||
//public void kctzjl();
|
||||
public void kctzjl(MaterialInventory materialInventory, String orderNumber, LoginUser loginUser,
|
||||
BigDecimal oldArea, BigDecimal oldGrossWeight, BigDecimal oldNetWeight, BigDecimal oldVolume
|
||||
,BigDecimal oldInventoryQuantity, BigDecimal oldAllocationQuantity, BigDecimal oldFreezeQuantity,String adjustAction);
|
||||
}
|
||||
+226
-85
@@ -5,11 +5,18 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.core.web.domain.BaseVOEntity;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.SystemServiceFeign;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.wms.domain.inventoryAdjustmentRecord.entity.InventoryAdjustmentRecord;
|
||||
import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.mapper.InventoryAdjustmentRecordMapper;
|
||||
import com.mhd.wms.domain.materialBarCode.repository.facade.IMaterialBarCodeService;
|
||||
import com.mhd.wms.domain.materialBarCode.repository.po.MaterialBarCodePO;
|
||||
import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo;
|
||||
import com.mhd.wms.domain.materialGoodsRule.repository.facade.IMaterialGoodsRuleService;
|
||||
import com.mhd.wms.domain.materialGoodsRule.repository.po.BatchDetailPO;
|
||||
import com.mhd.wms.domain.materialGoodsRule.repository.po.BatchPO;
|
||||
@@ -20,6 +27,7 @@ import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryM
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParentDO;
|
||||
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryQueryListDO;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.facade.IMaterialBaseInfoService;
|
||||
@@ -52,6 +60,10 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
||||
private MaterialInventoryMapper materialInventoryMapper;
|
||||
@Autowired
|
||||
private IMaterialBaseInfoService materialBaseInfoService;
|
||||
@Autowired
|
||||
private IMaterialBarCodeService materialBarCodeService;
|
||||
@Autowired
|
||||
private InventoryAdjustmentRecordMapper inventoryAdjustmentRecordMapper;
|
||||
|
||||
/**
|
||||
* 查询物料库存列表
|
||||
@@ -503,97 +515,226 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xgkc(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, String type, Long materialInventoryId) {
|
||||
netWeight = netWeight != null ? netWeight : BigDecimal.ZERO;
|
||||
grossWeight = grossWeight != null ? grossWeight : BigDecimal.ZERO;
|
||||
volume = volume != null ? volume : BigDecimal.ZERO;
|
||||
area = area != null ? area : BigDecimal.ZERO;
|
||||
quantity = quantity != null ? quantity : BigDecimal.ZERO;
|
||||
public void xgkc(MaterialInventoryParamDO materialInventoryParamDO) {
|
||||
BigDecimal netWeight = materialInventoryParamDO.getNetWeight() != null ? materialInventoryParamDO.getNetWeight() : BigDecimal.ZERO;
|
||||
BigDecimal grossWeight = materialInventoryParamDO.getGrossWeight() != null ? materialInventoryParamDO.getGrossWeight() : BigDecimal.ZERO;
|
||||
BigDecimal volume = materialInventoryParamDO.getVolume() != null ? materialInventoryParamDO.getVolume() : BigDecimal.ZERO;
|
||||
BigDecimal area = materialInventoryParamDO.getArea() != null ? materialInventoryParamDO.getArea() : BigDecimal.ZERO;
|
||||
BigDecimal quantity = materialInventoryParamDO.getQuantity() != null ? materialInventoryParamDO.getQuantity() : BigDecimal.ZERO;
|
||||
String type = materialInventoryParamDO.getType();
|
||||
Long materialInventoryId = materialInventoryParamDO.getMaterialInventoryId();
|
||||
|
||||
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
||||
if (materialInventoryPO != null) {
|
||||
//类型(1:上架2:分配3:取消分配4:出库交接5:移位6:库存调整7:库存冻结)
|
||||
switch (type) {
|
||||
case "1":
|
||||
// 上架
|
||||
sj(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "2":
|
||||
// 分配
|
||||
ff(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "3":
|
||||
// 取消分配
|
||||
qxff(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "4":
|
||||
// 出库交接
|
||||
ckjj(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "5":
|
||||
// 移位
|
||||
yw(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "6":
|
||||
// 库存调整
|
||||
kctz(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "7":
|
||||
// 库存冻结
|
||||
kcdj(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("错误的类型");
|
||||
//类型(1:上架2:分配3:取消分配4:出库交接5:移位6:库存调整7:库存冻结)
|
||||
switch (type) {
|
||||
case "1":
|
||||
// 上架
|
||||
sj(netWeight, grossWeight, volume, area, quantity, materialInventoryId, materialInventoryParamDO);
|
||||
break;
|
||||
case "2":
|
||||
// 分配
|
||||
ff(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "3":
|
||||
// 取消分配
|
||||
qxff(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "4":
|
||||
// 出库交接
|
||||
ckjj(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "5":
|
||||
// 移位
|
||||
yw(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "6":
|
||||
// 库存调整
|
||||
kctz(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
case "7":
|
||||
// 库存冻结
|
||||
kcdj(netWeight, grossWeight, volume, area, quantity, materialInventoryId);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("错误的类型");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kctzjl(MaterialInventory materialInventory, String orderNumber, LoginUser loginUser,
|
||||
BigDecimal oldArea, BigDecimal oldGrossWeight, BigDecimal oldNetWeight, BigDecimal oldVolume
|
||||
,BigDecimal oldInventoryQuantity, BigDecimal oldAllocationQuantity, BigDecimal oldFreezeQuantity,
|
||||
String adjustAction) {
|
||||
//库存调整记录
|
||||
Long materialBaseInfoId = materialInventory.getMaterialBaseInfoId();
|
||||
MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper<MaterialBaseInfo>().lambda()
|
||||
.eq(MaterialBaseInfo::getMaterialBaseInfoId, materialBaseInfoId).eq(BaseVOEntity::getDelFlag,1));
|
||||
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
|
||||
inventoryAdjustmentRecord.setAdjustAction(adjustAction);
|
||||
inventoryAdjustmentRecord.setRelateNo(orderNumber);
|
||||
inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
|
||||
inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
|
||||
inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName());
|
||||
inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName());
|
||||
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId());
|
||||
if (ObjectUtil.isNotNull(materialBaseInfo)) {
|
||||
inventoryAdjustmentRecord.setMaterialCode(materialBaseInfo.getMaterialCode());
|
||||
inventoryAdjustmentRecord.setMaterialName(materialBaseInfo.getMaterialName());
|
||||
inventoryAdjustmentRecord.setBarCode(materialBaseInfo.getBarCode());
|
||||
inventoryAdjustmentRecord.setShipperId(materialBaseInfo.getShipperId());
|
||||
inventoryAdjustmentRecord.setShipperName(materialBaseInfo.getShipperName());
|
||||
}
|
||||
if (inventoryAdjustmentRecord.getBarCode() == null || inventoryAdjustmentRecord.getBarCode().isEmpty()){
|
||||
getBarCode(materialInventory, inventoryAdjustmentRecord);
|
||||
}
|
||||
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId());
|
||||
inventoryAdjustmentRecord.setAdjustType(1L);
|
||||
inventoryAdjustmentRecord.setOrganizationId(materialInventory.getOrganizationId());
|
||||
inventoryAdjustmentRecord.setOrganizationName(materialInventory.getOrganizationName());
|
||||
inventoryAdjustmentRecord.setTopOrganizationId(materialInventory.getTopOrganizationId());
|
||||
inventoryAdjustmentRecord.setWarehouseCode(materialInventory.getWarehouseCode());
|
||||
inventoryAdjustmentRecord.setWarehouseName(materialInventory.getWarehouseName());
|
||||
inventoryAdjustmentRecord.setWarehouseId(materialInventory.getWarehouseId());
|
||||
inventoryAdjustmentRecord.setStorageCode(materialInventory.getStorageCode());
|
||||
inventoryAdjustmentRecord.setStorageName(materialInventory.getStorageName());
|
||||
inventoryAdjustmentRecord.setStorageLocationId(materialInventory.getStorageLocationId());
|
||||
inventoryAdjustmentRecord.setStorageLocationCode(materialInventory.getStorageLocationCode());
|
||||
inventoryAdjustmentRecord.setStorageLocationName(materialInventory.getStorageLocationName());
|
||||
inventoryAdjustmentRecord.setMaterialInventoryId(materialInventory.getMaterialInventoryId());
|
||||
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId());
|
||||
inventoryAdjustmentRecord.setStorageSectionId(materialInventory.getStorageSectionId());
|
||||
inventoryAdjustmentRecord.setStorageLocationId(materialInventory.getStorageLocationId());
|
||||
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName());
|
||||
inventoryAdjustmentRecord.setCreateTime(new Date());
|
||||
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
|
||||
inventoryAdjustmentRecord.setAllocationAfterQuantity(oldAllocationQuantity);
|
||||
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
|
||||
inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity());//调整后 冻结-出库
|
||||
inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity);
|
||||
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
|
||||
// 调整前:库存数量(净重、毛重、体积、面积)
|
||||
inventoryAdjustmentRecord.setNetWeight(oldNetWeight);
|
||||
inventoryAdjustmentRecord.setGrossWeight(oldGrossWeight);
|
||||
inventoryAdjustmentRecord.setVolume(oldVolume);
|
||||
inventoryAdjustmentRecord.setArea(oldArea);
|
||||
// 调整后:库存数量 - 复核时填写的数量
|
||||
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight());
|
||||
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight());
|
||||
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume());
|
||||
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea());
|
||||
|
||||
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
|
||||
}
|
||||
|
||||
private void getBarCode(MaterialInventory materialInventoryPO, InventoryAdjustmentRecord inventoryAdjustmentRecord) {
|
||||
List<MaterialBarCodePO> materialBarCodePOList = materialBarCodeService.getInfoByMaterialBaseInfoIds(materialInventoryPO.getMaterialBaseInfoId());
|
||||
if (materialBarCodePOList != null && !materialBarCodePOList.isEmpty()) {
|
||||
Map<Long, MaterialBarCodePO> collect = materialBarCodePOList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
MaterialBarCodePO::getMaterialBaseInfoId,
|
||||
po -> po,
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
MaterialBarCodePO materialBarCodePO = collect.get(materialInventoryPO.getMaterialBaseInfoId());
|
||||
if (materialBarCodePO != null && materialBarCodePO.getBarCode() != null) {
|
||||
inventoryAdjustmentRecord.setBarCode(materialBarCodePO.getBarCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sj(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId) {
|
||||
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
||||
if (materialInventoryPO != null) {
|
||||
//库存数量
|
||||
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
|
||||
oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO;
|
||||
//可用数量
|
||||
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
|
||||
oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO;
|
||||
//冻结数量(出库交接不变动冻结数量)
|
||||
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
|
||||
oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO;
|
||||
//扣减后库存数量
|
||||
BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(quantity);
|
||||
//扣减后可用数量
|
||||
BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(quantity);
|
||||
BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(quantity);
|
||||
|
||||
|
||||
|
||||
BigDecimal oldArea = materialInventoryPO.getArea();
|
||||
BigDecimal oldVolume = materialInventoryPO.getVolume();
|
||||
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
|
||||
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
|
||||
|
||||
// 初始化旧数据,避免空指针
|
||||
oldArea = oldArea != null ? oldArea : BigDecimal.ZERO;
|
||||
oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO;
|
||||
oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO;
|
||||
oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO;
|
||||
|
||||
BigDecimal newArea = oldArea.add(area);
|
||||
BigDecimal newVolume = oldVolume.add(volume);
|
||||
BigDecimal newGrossWeight = oldGrossWeight.add(grossWeight);
|
||||
BigDecimal newNetWeight = oldNetWeight.add(netWeight);
|
||||
|
||||
materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
|
||||
//materialInventoryPO.setAllocationQuantity(materialInventoryPO.getAllocationQuantity());
|
||||
materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
|
||||
materialInventoryPO.setArea(newArea);
|
||||
materialInventoryPO.setVolume(newVolume);
|
||||
materialInventoryPO.setGrossWeight(newGrossWeight);
|
||||
materialInventoryPO.setNetWeight(newNetWeight);
|
||||
private void sj(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId,MaterialInventoryParamDO materialInventoryParamDO) {
|
||||
if (materialInventoryId == null) {
|
||||
Long materialBaseInfoId = materialInventoryParamDO.getMaterialBaseInfoId();
|
||||
MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper<MaterialBaseInfo>().lambda()
|
||||
.eq(MaterialBaseInfo::getMaterialBaseInfoId, materialBaseInfoId).eq(BaseVOEntity::getDelFlag,1));
|
||||
MaterialInventory materialInventory = new MaterialInventory();
|
||||
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
||||
materialInventoryMapper.updateById(materialInventory);
|
||||
materialInventory.setInventoryQuantity(quantity);
|
||||
materialInventory.setAllocationQuantity(quantity);
|
||||
materialInventory.setFreezeQuantity(BigDecimal.ZERO);
|
||||
materialInventory.setArea(area);
|
||||
materialInventory.setVolume(volume);
|
||||
materialInventory.setGrossWeight(grossWeight);
|
||||
materialInventory.setNetWeight(netWeight);
|
||||
materialInventory.setMaterialBaseInfoId(materialInventoryParamDO.getMaterialBaseInfoId());
|
||||
materialInventory.setInOrderNumber(materialInventoryParamDO.getInOrderNumber());
|
||||
if (materialBaseInfo != null) {
|
||||
materialInventory.setShipperId(materialBaseInfo.getShipperId());
|
||||
materialInventory.setShipperName(materialBaseInfo.getShipperName());
|
||||
}
|
||||
//仓库信息
|
||||
materialInventory.setOrganizationId(materialInventoryParamDO.getOrganizationId());
|
||||
materialInventory.setOrganizationName(materialInventoryParamDO.getOrganizationName());
|
||||
materialInventory.setTopOrganizationId(materialInventoryParamDO.getTopOrganizationId());
|
||||
materialInventory.setWarehouseCode(materialInventoryParamDO.getWarehouseCode());
|
||||
materialInventory.setWarehouseName(materialInventoryParamDO.getWarehouseName());
|
||||
materialInventory.setWarehouseId(materialInventoryParamDO.getWarehouseId());
|
||||
materialInventory.setStorageCode(materialInventoryParamDO.getStorageCode());
|
||||
materialInventory.setStorageName(materialInventoryParamDO.getStorageName());
|
||||
materialInventory.setStorageLocationId(materialInventoryParamDO.getStorageLocationId());
|
||||
materialInventory.setStorageLocationCode(materialInventoryParamDO.getStorageLocationCode());
|
||||
materialInventory.setStorageLocationName(materialInventoryParamDO.getStorageLocationName());
|
||||
materialInventory.setStorageSectionId(materialInventoryParamDO.getStorageSectionId());
|
||||
//更多属性
|
||||
materialInventory.setBatchRefNo(materialInventoryParamDO.getBatchRefNo());
|
||||
materialInventory.setSheetRefNo(materialInventoryParamDO.getSheetRefNo());
|
||||
materialInventory.setBoxPalletNo(materialInventoryParamDO.getBoxPalletNo());
|
||||
materialInventory.setProductionDate(materialInventoryParamDO.getProductionDate());
|
||||
materialInventory.setExtAttr1(materialInventoryParamDO.getExtAttr1());
|
||||
materialInventory.setExtAttr2(materialInventoryParamDO.getExtAttr2());
|
||||
materialInventory.setExtAttr3(materialInventoryParamDO.getExtAttr3());
|
||||
materialInventory.setExtAttr4(materialInventoryParamDO.getExtAttr4());
|
||||
materialInventory.setExpiryDate(materialInventoryParamDO.getExpiryDate());
|
||||
materialInventory.setInventoryDate(materialInventoryParamDO.getInventoryDate());
|
||||
|
||||
materialInventoryMapper.insert(materialInventory);
|
||||
} else {
|
||||
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
|
||||
if (materialInventoryPO != null) {
|
||||
//库存数量
|
||||
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
|
||||
oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO;
|
||||
//可用数量
|
||||
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
|
||||
oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO;
|
||||
//冻结数量(出库交接不变动冻结数量)
|
||||
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
|
||||
oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO;
|
||||
//扣减后库存数量
|
||||
BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(quantity);
|
||||
//扣减后可用数量
|
||||
BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(quantity);
|
||||
BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(quantity);
|
||||
|
||||
|
||||
|
||||
BigDecimal oldArea = materialInventoryPO.getArea();
|
||||
BigDecimal oldVolume = materialInventoryPO.getVolume();
|
||||
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
|
||||
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
|
||||
|
||||
// 初始化旧数据,避免空指针
|
||||
oldArea = oldArea != null ? oldArea : BigDecimal.ZERO;
|
||||
oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO;
|
||||
oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO;
|
||||
oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO;
|
||||
|
||||
BigDecimal newArea = oldArea.add(area);
|
||||
BigDecimal newVolume = oldVolume.add(volume);
|
||||
BigDecimal newGrossWeight = oldGrossWeight.add(grossWeight);
|
||||
BigDecimal newNetWeight = oldNetWeight.add(netWeight);
|
||||
|
||||
materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
|
||||
//materialInventoryPO.setAllocationQuantity(materialInventoryPO.getAllocationQuantity());
|
||||
materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
|
||||
materialInventoryPO.setArea(newArea);
|
||||
materialInventoryPO.setVolume(newVolume);
|
||||
materialInventoryPO.setGrossWeight(newGrossWeight);
|
||||
materialInventoryPO.setNetWeight(newNetWeight);
|
||||
MaterialInventory materialInventory = new MaterialInventory();
|
||||
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
||||
materialInventoryMapper.updateById(materialInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ff(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId) {
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.mhd.wms.domain.materialInventory.repository.todo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.mhd.common.core.annotation.Excel;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseDO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 物料库存对象 material_inventory
|
||||
*
|
||||
* @author gen
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class MaterialInventoryParamDO extends MaterialBaseDO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//库存id
|
||||
private Long materialInventoryId;
|
||||
//物料基础信息id
|
||||
private Long materialBaseInfoId;
|
||||
//物料明细ID
|
||||
private Long materialDetailId;
|
||||
|
||||
//仓库信息参数
|
||||
private Long organizationId;
|
||||
private String organizationName;
|
||||
private Long topOrganizationId;
|
||||
//仓库ID
|
||||
private Long warehouseId;
|
||||
//仓库编码
|
||||
private String warehouseCode;
|
||||
//仓库名称
|
||||
private String warehouseName;
|
||||
//存储区ID
|
||||
private Long storageSectionId;
|
||||
//存储区编码
|
||||
private String storageCode;
|
||||
//存储区名称
|
||||
private String storageName;
|
||||
//存储位置ID
|
||||
private Long storageLocationId;
|
||||
//存储位置编码
|
||||
private String storageLocationCode;
|
||||
//存储位置名称
|
||||
private String storageLocationName;
|
||||
|
||||
|
||||
//调整参数
|
||||
|
||||
//调整数量
|
||||
private BigDecimal quantity;
|
||||
//净重
|
||||
private BigDecimal netWeight;
|
||||
//毛重
|
||||
private BigDecimal grossWeight;
|
||||
//体积
|
||||
private BigDecimal volume;
|
||||
//面积
|
||||
private BigDecimal area;
|
||||
//类型(1:上架2:分配3:取消分配4:出库交接5:移位6:库存调整7:库存冻结)
|
||||
private String type;
|
||||
|
||||
|
||||
|
||||
|
||||
//更多属性
|
||||
private String batchRefNo;
|
||||
private String sheetRefNo;
|
||||
//箱码
|
||||
private String boxPalletNo;
|
||||
//扩展字段2
|
||||
private String extAttr1;
|
||||
//扩展字段1
|
||||
private String extAttr2;
|
||||
//生产日期
|
||||
private Date productionDate;
|
||||
//过期日期
|
||||
private Date expiryDate;
|
||||
//库存日期
|
||||
private Date inventoryDate;
|
||||
//扩展字段3
|
||||
private Date extAttr3;
|
||||
//扩展字段4
|
||||
private Date extAttr4;
|
||||
|
||||
|
||||
private String inOrderNumber;
|
||||
|
||||
private String lotNumber;
|
||||
|
||||
}
|
||||
+5
-5
@@ -82,11 +82,11 @@ CREATE TABLE "NGWL_TEST_WMS"."SYS_TABLE_CONFIG" (
|
||||
"CREATE_TIME" TIMESTAMP(6),
|
||||
"CREATE_BY" BIGINT DEFAULT 0,
|
||||
"CREATE_BY_NAME" VARCHAR(200 CHAR) DEFAULT '',
|
||||
"UPDATE_TIME" TIMESTAMP(6),
|
||||
"UPDATE_BY" BIGINT DEFAULT 0,
|
||||
"UPDATE_BY_NAME" VARCHAR(200 CHAR) DEFAULT '',
|
||||
"DEL_FLAG" TINYINT DEFAULT 1,
|
||||
"ID" BIGINT IDENTITY(1,1) NOT NULL
|
||||
"UPDATE_TIME" TIMESTAMP(6),
|
||||
"UPDATE_BY" BIGINT DEFAULT 0,
|
||||
"UPDATE_BY_NAME" VARCHAR(200 CHAR) DEFAULT '',
|
||||
"DEL_FLAG" TINYINT DEFAULT 1,
|
||||
"ID" BIGINT IDENTITY(1,1) NOT NULL
|
||||
)
|
||||
;
|
||||
COMMENT ON COLUMN "NGWL_TEST_WMS"."SYS_TABLE_CONFIG"."ORGANIZATION_ID" IS '组织id';
|
||||
|
||||
Reference in New Issue
Block a user