调整库存和记录方法集合;

This commit is contained in:
王奎兴
2026-04-02 13:59:50 +08:00
parent 9f02532892
commit 7f32271adc
7 changed files with 610 additions and 565 deletions
@@ -20,7 +20,9 @@ import com.mhd.wms.domain.inventoryAdjustmentRecord.repository.mapper.InventoryA
import com.mhd.wms.domain.materialBarCode.repository.facade.IMaterialBarCodeService; import com.mhd.wms.domain.materialBarCode.repository.facade.IMaterialBarCodeService;
import com.mhd.wms.domain.materialBarCode.repository.po.MaterialBarCodePO; import com.mhd.wms.domain.materialBarCode.repository.po.MaterialBarCodePO;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory; import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.facade.IMaterialInventoryService;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper; import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO;
import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail; import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail;
import com.mhd.wms.domain.outMaterialDetail.repository.mapper.OutMaterialDetailMapper; import com.mhd.wms.domain.outMaterialDetail.repository.mapper.OutMaterialDetailMapper;
import com.mhd.wms.domain.pickingMaterialDetail.repository.mapper.PickingMaterialDetailMapper; import com.mhd.wms.domain.pickingMaterialDetail.repository.mapper.PickingMaterialDetailMapper;
@@ -70,6 +72,8 @@ public class HandoverTaskOrderDomainService {
private PickingMaterialDetailMapper pickingMaterialDetailMapper; private PickingMaterialDetailMapper pickingMaterialDetailMapper;
@Autowired @Autowired
private IMaterialBarCodeService materialBarCodeService; private IMaterialBarCodeService materialBarCodeService;
@Autowired
private IMaterialInventoryService materialInventoryService;
/** /**
@@ -330,110 +334,120 @@ public class HandoverTaskOrderDomainService {
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId); MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
if (materialInventoryPO != null) { if (materialInventoryPO != null) {
MaterialInventoryParamDO materialInventoryParamDO = new MaterialInventoryParamDO();
//更新库存数量 //更新库存数量
//库存数量 // //库存数量
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity(); // BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO; // oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO;
//可用数量 // //可用数量
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity(); // BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO; // oldAllocationQuantity = oldAllocationQuantity != null ? oldAllocationQuantity : BigDecimal.ZERO;
//冻结数量(出库交接不变动冻结数量) // //冻结数量(出库交接不变动冻结数量)
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity(); // BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO; // oldFreezeQuantity = oldFreezeQuantity != null ? oldFreezeQuantity : BigDecimal.ZERO;
//扣减后库存数量 // //扣减后库存数量
BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(checkQuantity); // BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(checkQuantity);
//扣减后可用数量 // //扣减后可用数量
BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(checkQuantity); // BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(checkQuantity);
BigDecimal newFreezeQuantity = oldFreezeQuantity; // BigDecimal newFreezeQuantity = oldFreezeQuantity;
//
//
//
BigDecimal oldArea = materialInventoryPO.getArea(); // BigDecimal oldArea = materialInventoryPO.getArea();
BigDecimal oldVolume = materialInventoryPO.getVolume(); // BigDecimal oldVolume = materialInventoryPO.getVolume();
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight(); // BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight(); // BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
//
// 初始化旧数据,避免空指针 // // 初始化旧数据,避免空指针
oldArea = oldArea != null ? oldArea : BigDecimal.ZERO; // oldArea = oldArea != null ? oldArea : BigDecimal.ZERO;
oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO; // oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO;
oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO; // oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO;
oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO; // oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO;
//
BigDecimal newArea = oldArea.subtract(checkArea); // BigDecimal newArea = oldArea.subtract(checkArea);
BigDecimal newVolume = oldVolume.subtract(checkVolume); // BigDecimal newVolume = oldVolume.subtract(checkVolume);
BigDecimal newGrossWeight = oldGrossWeight.subtract(checkGrossWeight); // BigDecimal newGrossWeight = oldGrossWeight.subtract(checkGrossWeight);
BigDecimal newNetWeight = oldNetWeight.subtract(checkNetWeight); // BigDecimal newNetWeight = oldNetWeight.subtract(checkNetWeight);
//
materialInventoryPO.setInventoryQuantity(newInventoryQuantity); // materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
materialInventoryPO.setAllocationQuantity(materialInventoryPO.getAllocationQuantity()); // materialInventoryPO.setAllocationQuantity(materialInventoryPO.getAllocationQuantity());
materialInventoryPO.setFreezeQuantity(materialInventoryPO.getFreezeQuantity().subtract(outMaterialDetail.getCheckQuantity()) ); // materialInventoryPO.setFreezeQuantity(materialInventoryPO.getFreezeQuantity().subtract(outMaterialDetail.getCheckQuantity()) );
materialInventoryPO.setArea(newArea); // materialInventoryPO.setArea(newArea);
materialInventoryPO.setVolume(newVolume); // materialInventoryPO.setVolume(newVolume);
materialInventoryPO.setGrossWeight(newGrossWeight); // materialInventoryPO.setGrossWeight(newGrossWeight);
materialInventoryPO.setNetWeight(newNetWeight); // materialInventoryPO.setNetWeight(newNetWeight);
MaterialInventory materialInventory = new MaterialInventory(); // MaterialInventory materialInventory = new MaterialInventory();
BeanUtils.copyProperties(materialInventoryPO, materialInventory); // BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory); //materialInventoryMapper.updateById(materialInventory);
materialInventoryParamDO.setArea(checkArea);
materialInventoryParamDO.setVolume(checkVolume);
materialInventoryParamDO.setGrossWeight(checkGrossWeight);
materialInventoryParamDO.setNetWeight(checkNetWeight);
materialInventoryParamDO.setQuantity(checkQuantity);
materialInventoryParamDO.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
materialInventoryParamDO.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
materialInventoryParamDO.setType("4");
materialInventoryService.kctzjl(materialInventoryParamDO,"出库",loginUser);
materialInventoryService.xgkc(materialInventoryParamDO);
//库存调整记录 //库存调整记录
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); // InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setAdjustAction("出库"); // inventoryAdjustmentRecord.setAdjustAction("出库");
inventoryAdjustmentRecord.setRelateNo(orderNumber); // inventoryAdjustmentRecord.setRelateNo(orderNumber);
inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); // inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); // inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); // inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName());
inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); // inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName());
// inventoryAdjustmentRecord.setAdjustBeforeStatusCode("he_ge"); //// inventoryAdjustmentRecord.setAdjustBeforeStatusCode("he_ge");
// inventoryAdjustmentRecord.setAdjustBeforeStatusName("合格"); //// inventoryAdjustmentRecord.setAdjustBeforeStatusName("合格");
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo()); // inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo());
inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName()); // inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName());
inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode()); // inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode());
if (inventoryAdjustmentRecord.getBarCode() == null || inventoryAdjustmentRecord.getBarCode().isEmpty()){ // if (inventoryAdjustmentRecord.getBarCode() == null || inventoryAdjustmentRecord.getBarCode().isEmpty()){
getBarCode(materialInventoryPO, inventoryAdjustmentRecord); // getBarCode(materialInventoryPO, inventoryAdjustmentRecord);
} // }
inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setAdjustType(1L); // inventoryAdjustmentRecord.setAdjustType(1L);
inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId()); // inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId());
inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName()); // inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName());
inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId()); // inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId());
inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode()); // inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode());
inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName()); // inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName());
inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId()); // inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId());
inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode()); // inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode());
inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName()); // inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode()); // inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode());
inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName()); // inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName());
inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); // inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId()); // inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId());
inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName()); // inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName());
inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId()); // inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); // inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
UserPo userPo = loginUser.getUserPo(); // UserPo userPo = loginUser.getUserPo();
if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); // if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName());
inventoryAdjustmentRecord.setCreateTime(new Date()); // inventoryAdjustmentRecord.setCreateTime(new Date());
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); // inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
inventoryAdjustmentRecord.setAllocationAfterQuantity(oldAllocationQuantity); // inventoryAdjustmentRecord.setAllocationAfterQuantity(oldAllocationQuantity);
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); // inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity.subtract(outMaterialDetail.getCheckQuantity()));//调整后 冻结-出库 // inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity.subtract(outMaterialDetail.getCheckQuantity()));//调整后 冻结-出库
inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity); // inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity);
inventoryAdjustmentRecord.setInventoryAfterQuantity(newInventoryQuantity); // inventoryAdjustmentRecord.setInventoryAfterQuantity(newInventoryQuantity);
// 调整前:库存数量(净重、毛重、体积、面积) // // 调整前:库存数量(净重、毛重、体积、面积)
inventoryAdjustmentRecord.setNetWeight(oldNetWeight); // inventoryAdjustmentRecord.setNetWeight(oldNetWeight);
inventoryAdjustmentRecord.setGrossWeight(oldGrossWeight); // inventoryAdjustmentRecord.setGrossWeight(oldGrossWeight);
inventoryAdjustmentRecord.setVolume(oldVolume); // inventoryAdjustmentRecord.setVolume(oldVolume);
inventoryAdjustmentRecord.setArea(oldArea); // inventoryAdjustmentRecord.setArea(oldArea);
// 调整后:库存数量 - 复核时填写的数量 // // 调整后:库存数量 - 复核时填写的数量
inventoryAdjustmentRecord.setAdjustedNetWeight(newNetWeight); // inventoryAdjustmentRecord.setAdjustedNetWeight(newNetWeight);
inventoryAdjustmentRecord.setAdjustedGrossWeight(newGrossWeight); // inventoryAdjustmentRecord.setAdjustedGrossWeight(newGrossWeight);
inventoryAdjustmentRecord.setAdjustedVolume(newVolume); // inventoryAdjustmentRecord.setAdjustedVolume(newVolume);
inventoryAdjustmentRecord.setAdjustedArea(newArea); // inventoryAdjustmentRecord.setAdjustedArea(newArea);
//
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); // inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
} }
} }
} }
@@ -524,4 +538,4 @@ public class HandoverTaskOrderDomainService {
} }
@@ -15,6 +15,7 @@ import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo;
import com.mhd.wms.domain.materialBaseInfo.repository.facade.IMaterialBaseInfoService; import com.mhd.wms.domain.materialBaseInfo.repository.facade.IMaterialBaseInfoService;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory; import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.facade.IMaterialInventoryService; import com.mhd.wms.domain.materialInventory.repository.facade.IMaterialInventoryService;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -276,45 +277,62 @@ public class InventoryAdjustmentRecordDomainService {
*/ */
@Transactional @Transactional
public Boolean inventoryFrozenForAll(InventoryAdjustmentRecordDO inventoryAdjustmentRecordDO) { public Boolean inventoryFrozenForAll(InventoryAdjustmentRecordDO inventoryAdjustmentRecordDO) {
InventoryAdjustmentRecordDO inventoryAdjustmentRecord = new InventoryAdjustmentRecordDO(); //InventoryAdjustmentRecordDO inventoryAdjustmentRecord = new InventoryAdjustmentRecordDO();
LoginUser loginUser = SecurityUtils.getLoginUser(); try {
inventoryAdjustmentRecord.setAdjustAction("库存冻结"); LoginUser loginUser = SecurityUtils.getLoginUser();
inventoryAdjustmentRecord.setOrganizationId(loginUser.getUserPo().getOrganizationId()); BigDecimal adjustQuantity = inventoryAdjustmentRecordDO.getAdjustQuantity();
inventoryAdjustmentRecord.setOrganizationName(loginUser.getUserPo().getOrganizationName()); MaterialInventoryParamDO materialInventoryParamDO = new MaterialInventoryParamDO();
inventoryAdjustmentRecord.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId()); materialInventoryParamDO.setMaterialInventoryId(inventoryAdjustmentRecordDO.getMaterialInventoryId());
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); materialInventoryParamDO.setQuantity(adjustQuantity);
inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername()); materialInventoryParamDO.setType("7");
inventoryAdjustmentRecord.setCreateTime(new Date()); materialInventoryService.kctzjl(materialInventoryParamDO,"库存冻结",loginUser);
MaterialInventory materialInventory = materialInventoryService.getById(inventoryAdjustmentRecordDO.getMaterialInventoryId()); materialInventoryService.xgkc(materialInventoryParamDO);
inventoryAdjustmentRecord.setAdjustType(3L); return true;
if (ObjectUtil.isNotNull(materialInventory)) { } catch (Exception e) {
BeanUtils.copyProperties(materialInventory, inventoryAdjustmentRecord); e.printStackTrace();
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity()); return false;
inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity());
MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper<MaterialBaseInfo>().lambda()
.eq(MaterialBaseInfo::getMaterialBaseInfoId,materialInventory.getMaterialBaseInfoId()).eq(BaseVOEntity::getDelFlag,1));
if (ObjectUtil.isNotNull(materialBaseInfo)) {
inventoryAdjustmentRecord.setMaterialCode(materialBaseInfo.getMaterialCode());
inventoryAdjustmentRecord.setMaterialName(materialBaseInfo.getMaterialName());
inventoryAdjustmentRecord.setBarCode(materialBaseInfo.getBarCode());
inventoryAdjustmentRecord.setShipperId(materialBaseInfo.getShipperId());
inventoryAdjustmentRecord.setShipperName(materialBaseInfo.getShipperName());
}
//可用数量减,冻结数量加
materialInventory.setAllocationQuantity(materialInventory.getInventoryQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity()));
materialInventory.setFreezeQuantity(inventoryAdjustmentRecordDO.getAdjustQuantity());
if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) {
throw new ServiceException("冻结可用数量不能小于0");
}
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity());
} else {
throw new ServiceException("根据物料库存id查询不到物料库存信息!");
} }
materialInventoryService.updateById(materialInventory);
return inventoryAdjustmentRecordService.insert(inventoryAdjustmentRecord);
// inventoryAdjustmentRecord.setAdjustAction("库存冻结");
// inventoryAdjustmentRecord.setOrganizationId(loginUser.getUserPo().getOrganizationId());
// inventoryAdjustmentRecord.setOrganizationName(loginUser.getUserPo().getOrganizationName());
// inventoryAdjustmentRecord.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
// inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
// inventoryAdjustmentRecord.setCreateByName(loginUser.getUsername());
// inventoryAdjustmentRecord.setCreateTime(new Date());
// MaterialInventory materialInventory = materialInventoryService.getById(inventoryAdjustmentRecordDO.getMaterialInventoryId());
// inventoryAdjustmentRecord.setAdjustType(3L);
// if (ObjectUtil.isNotNull(materialInventory)) {
// BeanUtils.copyProperties(materialInventory, inventoryAdjustmentRecord);
// inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity());
// inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity());
// inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity());
// MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper<MaterialBaseInfo>().lambda()
// .eq(MaterialBaseInfo::getMaterialBaseInfoId,materialInventory.getMaterialBaseInfoId()).eq(BaseVOEntity::getDelFlag,1));
// if (ObjectUtil.isNotNull(materialBaseInfo)) {
// inventoryAdjustmentRecord.setMaterialCode(materialBaseInfo.getMaterialCode());
// inventoryAdjustmentRecord.setMaterialName(materialBaseInfo.getMaterialName());
// inventoryAdjustmentRecord.setBarCode(materialBaseInfo.getBarCode());
// inventoryAdjustmentRecord.setShipperId(materialBaseInfo.getShipperId());
// inventoryAdjustmentRecord.setShipperName(materialBaseInfo.getShipperName());
// }
// //可用数量减,冻结数量加
// materialInventory.setAllocationQuantity(materialInventory.getInventoryQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity()));
// materialInventory.setFreezeQuantity(inventoryAdjustmentRecordDO.getAdjustQuantity());
// if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) {
// throw new ServiceException("冻结可用数量不能小于0");
// }
// inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
// inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity());
// inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity());
// } else {
// throw new ServiceException("根据物料库存id查询不到物料库存信息!");
// }
// materialInventoryService.updateById(materialInventory);
// return inventoryAdjustmentRecordService.insert(inventoryAdjustmentRecord);
} }
/** /**
@@ -113,7 +113,5 @@ public interface IMaterialInventoryService extends IService<MaterialInventory>
* */ * */
public void xgkc(MaterialInventoryParamDO materialInventoryParamDO); public void xgkc(MaterialInventoryParamDO materialInventoryParamDO);
public void kctzjl(MaterialInventory materialInventory, String orderNumber, LoginUser loginUser, public void kctzjl(MaterialInventoryParamDO materialInventoryParamDO,String adjustAction,LoginUser loginUser);
BigDecimal oldArea, BigDecimal oldGrossWeight, BigDecimal oldNetWeight, BigDecimal oldVolume
,BigDecimal oldInventoryQuantity, BigDecimal oldAllocationQuantity, BigDecimal oldFreezeQuantity,String adjustAction);
} }
@@ -560,17 +560,18 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
} }
@Override @Override
public void kctzjl(MaterialInventory materialInventory, String orderNumber, LoginUser loginUser, public void kctzjl(MaterialInventoryParamDO materialInventoryParamDO,
BigDecimal oldArea, BigDecimal oldGrossWeight, BigDecimal oldNetWeight, BigDecimal oldVolume String adjustAction,LoginUser loginUser) {
,BigDecimal oldInventoryQuantity, BigDecimal oldAllocationQuantity, BigDecimal oldFreezeQuantity,
String adjustAction) {
//库存调整记录 //库存调整记录
Long materialInventoryId = materialInventoryParamDO.getMaterialInventoryId();
MaterialInventory materialInventory = materialInventoryMapper.selectOne(new QueryWrapper<MaterialInventory>().lambda()
.eq(MaterialInventory::getMaterialInventoryId, materialInventoryId));
Long materialBaseInfoId = materialInventory.getMaterialBaseInfoId(); Long materialBaseInfoId = materialInventory.getMaterialBaseInfoId();
MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper<MaterialBaseInfo>().lambda() MaterialBaseInfo materialBaseInfo = materialBaseInfoService.getOne(new QueryWrapper<MaterialBaseInfo>().lambda()
.eq(MaterialBaseInfo::getMaterialBaseInfoId, materialBaseInfoId).eq(BaseVOEntity::getDelFlag,1)); .eq(MaterialBaseInfo::getMaterialBaseInfoId, materialBaseInfoId).eq(BaseVOEntity::getDelFlag,1));
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setAdjustAction(adjustAction); inventoryAdjustmentRecord.setAdjustAction(adjustAction);
inventoryAdjustmentRecord.setRelateNo(orderNumber); inventoryAdjustmentRecord.setRelateNo(materialInventoryParamDO.getInOrderNumber());
inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName());
@@ -588,6 +589,9 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
} }
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId()); inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setAdjustType(1L); inventoryAdjustmentRecord.setAdjustType(1L);
if ("库存冻结".equals(adjustAction)) {
inventoryAdjustmentRecord.setAdjustType(3L);
}
inventoryAdjustmentRecord.setOrganizationId(materialInventory.getOrganizationId()); inventoryAdjustmentRecord.setOrganizationId(materialInventory.getOrganizationId());
inventoryAdjustmentRecord.setOrganizationName(materialInventory.getOrganizationName()); inventoryAdjustmentRecord.setOrganizationName(materialInventory.getOrganizationName());
inventoryAdjustmentRecord.setTopOrganizationId(materialInventory.getTopOrganizationId()); inventoryAdjustmentRecord.setTopOrganizationId(materialInventory.getTopOrganizationId());
@@ -607,22 +611,80 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
UserPo userPo = loginUser.getUserPo(); UserPo userPo = loginUser.getUserPo();
if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName());
inventoryAdjustmentRecord.setCreateTime(new Date()); inventoryAdjustmentRecord.setCreateTime(new Date());
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
inventoryAdjustmentRecord.setAllocationAfterQuantity(oldAllocationQuantity); if ("分配库存".equals(adjustAction)) {
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity());//调整后 冻结-出库 inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity().subtract(materialInventoryParamDO.getQuantity()));
inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity); inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity()); inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity().add(materialInventoryParamDO.getQuantity()));//调整后 冻结-出库
// 调整前:库存数量(净重、毛重、体积、面积) inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setNetWeight(oldNetWeight); inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setGrossWeight(oldGrossWeight); } else if ("上架".equals(adjustAction)){
inventoryAdjustmentRecord.setVolume(oldVolume); if (materialInventory == null) {
inventoryAdjustmentRecord.setArea(oldArea); inventoryAdjustmentRecord.setAllocationBeforeQuantity(BigDecimal.ZERO);
// 调整后:库存数量 - 复核时填写的数量 inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventoryParamDO.getQuantity());
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight()); inventoryAdjustmentRecord.setFreezeBeforeQuantity(BigDecimal.ZERO);
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight()); inventoryAdjustmentRecord.setFreezeAfterQuantity(BigDecimal.ZERO);//调整后 冻结-出库
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume()); inventoryAdjustmentRecord.setInventoryBeforeQuantity(BigDecimal.ZERO);
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea()); inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryParamDO.getQuantity());
// 调整前:库存数量(净重、毛重、体积、面积)
inventoryAdjustmentRecord.setNetWeight(BigDecimal.ZERO);
inventoryAdjustmentRecord.setGrossWeight(BigDecimal.ZERO);
inventoryAdjustmentRecord.setVolume(BigDecimal.ZERO);
inventoryAdjustmentRecord.setArea(BigDecimal.ZERO);
// 调整后:库存数量 - 复核时填写的数量
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventoryParamDO.getNetWeight());
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventoryParamDO.getGrossWeight());
inventoryAdjustmentRecord.setAdjustedVolume(materialInventoryParamDO.getVolume());
inventoryAdjustmentRecord.setAdjustedArea(materialInventoryParamDO.getArea());
} else {
inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity().add(materialInventoryParamDO.getQuantity()));
inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity());
inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity());//调整后 冻结-出库
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity().add(materialInventoryParamDO.getQuantity()));
// 调整前:库存数量(净重、毛重、体积、面积)
inventoryAdjustmentRecord.setNetWeight(materialInventory.getNetWeight());
inventoryAdjustmentRecord.setGrossWeight(materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setVolume(materialInventory.getVolume());
inventoryAdjustmentRecord.setArea(materialInventory.getArea());
// 调整后:库存数量 - 复核时填写的数量
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight().add(inventoryAdjustmentRecord.getNetWeight()));
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight().add(inventoryAdjustmentRecord.getGrossWeight()));
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume().add(inventoryAdjustmentRecord.getVolume()));
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea().add(inventoryAdjustmentRecord.getArea()));
}
} else if ("出库交接".equals(adjustAction)){
inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity());
inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity().subtract(materialInventoryParamDO.getQuantity()));//调整后 冻结-出库
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity().subtract(materialInventoryParamDO.getQuantity()));
// 调整前:库存数量(净重、毛重、体积、面积)
inventoryAdjustmentRecord.setNetWeight(materialInventory.getNetWeight());
inventoryAdjustmentRecord.setGrossWeight(materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setVolume(materialInventory.getVolume());
inventoryAdjustmentRecord.setArea(materialInventory.getArea());
// 调整后:库存数量 - 复核时填写的数量
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight().subtract(inventoryAdjustmentRecord.getNetWeight()));
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight().subtract(inventoryAdjustmentRecord.getGrossWeight()));
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume().subtract(inventoryAdjustmentRecord.getVolume()));
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea().subtract(inventoryAdjustmentRecord.getArea()));
} else if ("移位".equals(adjustAction)){
inventoryAdjustmentRecord.setAllocationBeforeQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventoryParamDO.getQuantity());
//inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity());//调整后 冻结-出库
//inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity);
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
} else if ("库存冻结".equals(adjustAction)) {
}
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
} }
@@ -661,6 +723,7 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
if (materialBaseInfo != null) { if (materialBaseInfo != null) {
materialInventory.setShipperId(materialBaseInfo.getShipperId()); materialInventory.setShipperId(materialBaseInfo.getShipperId());
materialInventory.setShipperName(materialBaseInfo.getShipperName()); materialInventory.setShipperName(materialBaseInfo.getShipperName());
materialInventory.setShipperCode(materialBaseInfo.getShipperCode());
} }
//仓库信息 //仓库信息
materialInventory.setOrganizationId(materialInventoryParamDO.getOrganizationId()); materialInventory.setOrganizationId(materialInventoryParamDO.getOrganizationId());
@@ -686,7 +749,14 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
materialInventory.setExtAttr4(materialInventoryParamDO.getExtAttr4()); materialInventory.setExtAttr4(materialInventoryParamDO.getExtAttr4());
materialInventory.setExpiryDate(materialInventoryParamDO.getExpiryDate()); materialInventory.setExpiryDate(materialInventoryParamDO.getExpiryDate());
materialInventory.setInventoryDate(materialInventoryParamDO.getInventoryDate()); materialInventory.setInventoryDate(materialInventoryParamDO.getInventoryDate());
materialInventory.setBatchNumber(materialInventoryParamDO.getBatchNumber());
materialInventory.setUnit(materialBaseInfo.getUnitCode());
materialInventory.setUnitName(materialBaseInfo.getUnitName());
//创建人信息
materialInventory.setCreateBy(materialInventoryParamDO.getCreateBy());
materialInventory.setCreateByName(materialInventoryParamDO.getCreateByName());
materialInventory.setCreateTime(new Date());
materialInventory.setBarCode(materialInventoryParamDO.getBarCode());
materialInventoryMapper.insert(materialInventory); materialInventoryMapper.insert(materialInventory);
} else { } else {
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId); MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
@@ -993,7 +1063,7 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(quantity); BigDecimal newInventoryQuantity = oldInventoryQuantity.subtract(quantity);
//扣减后可用数量 //扣减后可用数量
BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(quantity); BigDecimal newAllocationQuantity = oldAllocationQuantity.subtract(quantity);
BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(quantity); BigDecimal newFreezeQuantity = oldFreezeQuantity.add(quantity);
@@ -1013,8 +1083,8 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
BigDecimal newGrossWeight = oldGrossWeight.subtract(grossWeight); BigDecimal newGrossWeight = oldGrossWeight.subtract(grossWeight);
BigDecimal newNetWeight = oldNetWeight.subtract(netWeight); BigDecimal newNetWeight = oldNetWeight.subtract(netWeight);
materialInventoryPO.setInventoryQuantity(newInventoryQuantity); //materialInventoryPO.setInventoryQuantity(newInventoryQuantity);
//materialInventoryPO.setAllocationQuantity(materialInventoryPO.getAllocationQuantity()); materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
materialInventoryPO.setFreezeQuantity(newFreezeQuantity); materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
materialInventoryPO.setArea(newArea); materialInventoryPO.setArea(newArea);
materialInventoryPO.setVolume(newVolume); materialInventoryPO.setVolume(newVolume);
@@ -68,6 +68,8 @@ public class MaterialInventoryParamDO extends MaterialBaseDO {
//类型(1:上架2:分配3:取消分配4:出库交接5:移位6:库存调整7:库存冻结) //类型(1:上架2:分配3:取消分配4:出库交接5:移位6:库存调整7:库存冻结)
private String type; private String type;
private String barCode;
@@ -96,4 +98,6 @@ public class MaterialInventoryParamDO extends MaterialBaseDO {
private String lotNumber; private String lotNumber;
private String batchNumber;
} }
@@ -20,9 +20,11 @@ import com.mhd.wms.domain.materialBarCode.repository.po.MaterialBarCodePO;
import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo; import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo;
import com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper; import com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper;
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory; import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
import com.mhd.wms.domain.materialInventory.repository.facade.IMaterialInventoryService;
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper; import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO; import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO; import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO;
import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail; import com.mhd.wms.domain.outMaterialDetail.entity.OutMaterialDetail;
import com.mhd.wms.domain.outMaterialDetail.repository.facade.IOutMaterialDetailService; import com.mhd.wms.domain.outMaterialDetail.repository.facade.IOutMaterialDetailService;
import com.mhd.wms.domain.outMaterialDetail.repository.mapper.OutMaterialDetailMapper; import com.mhd.wms.domain.outMaterialDetail.repository.mapper.OutMaterialDetailMapper;
@@ -79,6 +81,9 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
private IPickingMaterialDetailService pickingMaterialDetailService; private IPickingMaterialDetailService pickingMaterialDetailService;
@Autowired @Autowired
private IMaterialBarCodeService materialBarCodeService; private IMaterialBarCodeService materialBarCodeService;
@Autowired
private IMaterialInventoryService materialInventoryService;
/** /**
* 查询物料明细列表 * 查询物料明细列表
@@ -467,61 +472,72 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
materialInventoryPO.setFreezeQuantity(newFreezeQuantity); materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
MaterialInventory materialInventory = new MaterialInventory(); MaterialInventory materialInventory = new MaterialInventory();
BeanUtils.copyProperties(materialInventoryPO, materialInventory); BeanUtils.copyProperties(materialInventoryPO, materialInventory);
materialInventoryMapper.updateById(materialInventory); MaterialInventoryParamDO materialInventoryParamDO = new MaterialInventoryParamDO();
BigDecimal zero = BigDecimal.ZERO;
materialInventoryParamDO.setArea(zero);
materialInventoryParamDO.setVolume(zero);
materialInventoryParamDO.setNetWeight(zero);
materialInventoryParamDO.setGrossWeight(zero);
materialInventoryParamDO.setQuantity(allocationQuantity);
materialInventoryParamDO.setType("2");
materialInventoryParamDO.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
materialInventoryService.kctzjl(materialInventoryParamDO,"分配库存",loginUser);
materialInventoryService.xgkc(materialInventoryParamDO);
//materialInventoryMapper.updateById(materialInventory);
//库存调整记录 //库存调整记录
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); // InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setAdjustAction("分配库存"); // inventoryAdjustmentRecord.setAdjustAction("分配库存");
inventoryAdjustmentRecord.setRelateNo(outOrderNumber); // inventoryAdjustmentRecord.setRelateNo(outOrderNumber);
inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); // inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode()); // inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventory.getMaterialStatusCode() == null ? "" : materialInventory.getMaterialStatusCode());
inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); // inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName());
inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName()); // inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventory.getMaterialStatusName() == null ? "" : materialInventory.getMaterialStatusName());
inventoryAdjustmentRecord.setAdjustType(1L); // inventoryAdjustmentRecord.setAdjustType(1L);
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo()); // inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo());
inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName()); // inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName());
inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode()); // inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode());
if (inventoryAdjustmentRecord.getBarCode().equals("")){ // if (inventoryAdjustmentRecord.getBarCode().equals("")){
getBarCode(materialInventoryPO, inventoryAdjustmentRecord); // getBarCode(materialInventoryPO, inventoryAdjustmentRecord);
} // }
inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId()); // inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId());
inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName()); // inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName());
inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId()); // inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId());
inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode()); // inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode());
inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName()); // inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName());
inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId()); // inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId());
inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode()); // inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode());
inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName()); // inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode()); // inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode());
inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName()); // inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName());
inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); // inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId()); // inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId());
inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName()); // inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName());
inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId()); // inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); // inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
UserPo userPo = loginUser.getUserPo(); // UserPo userPo = loginUser.getUserPo();
if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); // if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName());
inventoryAdjustmentRecord.setCreateTime(new Date()); // inventoryAdjustmentRecord.setCreateTime(new Date());
inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity); // inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity);
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); // inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); // inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity); // inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity);
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity()); // inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity()); // inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity());
inventoryAdjustmentRecord.setNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight()); // inventoryAdjustmentRecord.setNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight());
inventoryAdjustmentRecord.setGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight()); // inventoryAdjustmentRecord.setGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight());
inventoryAdjustmentRecord.setVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume()); // inventoryAdjustmentRecord.setVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume());
inventoryAdjustmentRecord.setArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea()); // inventoryAdjustmentRecord.setArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea());
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight()); // inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight());
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight()); // inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight());
inventoryAdjustmentRecord.setAdjustedVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume()); // inventoryAdjustmentRecord.setAdjustedVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume());
inventoryAdjustmentRecord.setAdjustedArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea()); // inventoryAdjustmentRecord.setAdjustedArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); // inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
} }
/*Long uniqueId = outMaterialDetail.getUniqueId(); /*Long uniqueId = outMaterialDetail.getUniqueId();
String outOrderNumber1 = outMaterialDetail.getOutOrderNumber(); String outOrderNumber1 = outMaterialDetail.getOutOrderNumber();
@@ -803,73 +819,79 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
BigDecimal allocationQuantity = outMaterialDetail.getActualQuantity(); BigDecimal allocationQuantity = outMaterialDetail.getActualQuantity();
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId); MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
if (materialInventoryPO != null) { if (materialInventoryPO != null) {
//更新库存数量 MaterialInventoryParamDO materialInventoryParamDO = new MaterialInventoryParamDO();
//可用数量 materialInventoryParamDO.setMaterialInventoryId(materialInventoryId);
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity(); materialInventoryParamDO.setQuantity(allocationQuantity);
//冻结数量 materialInventoryParamDO.setType("3");
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity(); materialInventoryService.kctzjl(materialInventoryParamDO,"取消分配",loginUser);
//分配后可用数量 materialInventoryService.xgkc(materialInventoryParamDO);
BigDecimal newAllocationQuantity = oldAllocationQuantity.add(allocationQuantity); // //更新库存数量
//分配后冻结数量 // //可用数量
BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(allocationQuantity); // BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
materialInventoryPO.setAllocationQuantity(newAllocationQuantity); // //冻结数量
materialInventoryPO.setFreezeQuantity(newFreezeQuantity); // BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
materialInventoryMapper.updateById(materialInventoryPO); // //分配后可用数量
// BigDecimal newAllocationQuantity = oldAllocationQuantity.add(allocationQuantity);
// //分配后冻结数量
//库存调整记录 // BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(allocationQuantity);
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); // materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
inventoryAdjustmentRecord.setAdjustAction("分配库存"); // materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
inventoryAdjustmentRecord.setRelateNo(outOrderNumber); // materialInventoryMapper.updateById(materialInventoryPO);
inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode()); //
inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode()); //
inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName()); // //库存调整记录
inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName()); // InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setAdjustType(1L); // inventoryAdjustmentRecord.setAdjustAction("分配库存");
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setRelateNo(outOrderNumber);
inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo()); // inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode());
inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName()); // inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode());
inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode()); // inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName());
if (inventoryAdjustmentRecord.getBarCode().equals("")){ // inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName());
getBarCode(materialInventoryPO, inventoryAdjustmentRecord); // inventoryAdjustmentRecord.setAdjustType(1L);
} // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo());
inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId()); // inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName());
inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName()); // inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode());
inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId()); // if (inventoryAdjustmentRecord.getBarCode().equals("")){
inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode()); // getBarCode(materialInventoryPO, inventoryAdjustmentRecord);
inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName()); // }
inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode()); // inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId());
inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName()); // inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId());
inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode()); // inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode());
inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName()); // inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName());
inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); // inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId());
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode());
inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId()); // inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName());
inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName()); // inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId()); // inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName());
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); // inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
inventoryAdjustmentRecord.setNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight()); // inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId());
inventoryAdjustmentRecord.setVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume()); // inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName());
inventoryAdjustmentRecord.setArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea()); // inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId());
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight()); // inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight()); // inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
inventoryAdjustmentRecord.setAdjustedVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume()); // inventoryAdjustmentRecord.setNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight());
inventoryAdjustmentRecord.setAdjustedArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea()); // inventoryAdjustmentRecord.setGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight());
UserPo userPo = loginUser.getUserPo(); // inventoryAdjustmentRecord.setVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume());
if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); // inventoryAdjustmentRecord.setArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea());
inventoryAdjustmentRecord.setCreateTime(new Date()); // inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventoryPO.getNetWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getNetWeight());
inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity); // inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventoryPO.getGrossWeight() == null ? BigDecimal.ZERO : materialInventoryPO.getGrossWeight());
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); // inventoryAdjustmentRecord.setAdjustedVolume(materialInventoryPO.getVolume() == null ? BigDecimal.ZERO : materialInventoryPO.getVolume());
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); // inventoryAdjustmentRecord.setAdjustedArea(materialInventoryPO.getArea() == null ? BigDecimal.ZERO : materialInventoryPO.getArea());
inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity); // UserPo userPo = loginUser.getUserPo();
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity()); // if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity()); // inventoryAdjustmentRecord.setCreateTime(new Date());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); // inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity);
// inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
// inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
// inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity);
// inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity());
// inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity());
// inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
} }
List<OutMaterialDetailDO> children = outMaterialDetail.getChildren(); List<OutMaterialDetailDO> children = outMaterialDetail.getChildren();
@@ -887,66 +909,74 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
BigDecimal allocationQuantity = outMaterialDetail.getActualQuantity(); BigDecimal allocationQuantity = outMaterialDetail.getActualQuantity();
MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId); MaterialInventory materialInventoryPO = materialInventoryMapper.selectById(materialInventoryId);
if (materialInventoryPO != null) { if (materialInventoryPO != null) {
//更新库存数量
//可用数量
BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
//冻结数量
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
//分配后可用数量
BigDecimal newAllocationQuantity = oldAllocationQuantity.add(allocationQuantity);
//分配后冻结数量
BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(allocationQuantity);
materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
materialInventoryMapper.updateById(materialInventoryPO);
MaterialInventoryParamDO materialInventoryParamDO = new MaterialInventoryParamDO();
materialInventoryParamDO.setMaterialInventoryId(materialInventoryId);
materialInventoryParamDO.setQuantity(allocationQuantity);
materialInventoryParamDO.setType("3");
materialInventoryService.kctzjl(materialInventoryParamDO,"取消分配",loginUser);
materialInventoryService.xgkc(materialInventoryParamDO);
// //更新库存数量
//库存调整记录 // //可用数量
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); // BigDecimal oldAllocationQuantity = materialInventoryPO.getAllocationQuantity();
inventoryAdjustmentRecord.setAdjustAction("分配库存"); // //冻结数量
inventoryAdjustmentRecord.setRelateNo(outOrderNumber); // BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode()); // //分配后可用数量
inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode()); // BigDecimal newAllocationQuantity = oldAllocationQuantity.add(allocationQuantity);
inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName()); // //分配后冻结数量
inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName()); // BigDecimal newFreezeQuantity = oldFreezeQuantity.subtract(allocationQuantity);
inventoryAdjustmentRecord.setAdjustType(1L); // materialInventoryPO.setAllocationQuantity(newAllocationQuantity);
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // materialInventoryPO.setFreezeQuantity(newFreezeQuantity);
inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo()); // materialInventoryMapper.updateById(materialInventoryPO);
inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName()); //
inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode()); //
if (inventoryAdjustmentRecord.getBarCode().equals("")){ //
getBarCode(materialInventoryPO, inventoryAdjustmentRecord); // //库存调整记录
} // InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId()); // inventoryAdjustmentRecord.setAdjustAction("分配库存");
inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId()); // inventoryAdjustmentRecord.setRelateNo(outOrderNumber);
inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName()); // inventoryAdjustmentRecord.setAdjustAfterStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode());
inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId()); // inventoryAdjustmentRecord.setAdjustBeforeStatusCode(materialInventoryPO.getMaterialStatusCode() == null ? "" : materialInventoryPO.getMaterialStatusCode());
inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode()); // inventoryAdjustmentRecord.setAdjustAfterStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName());
inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName()); // inventoryAdjustmentRecord.setAdjustBeforeStatusName(materialInventoryPO.getMaterialStatusName() == null ? "" : materialInventoryPO.getMaterialStatusName());
inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId()); // inventoryAdjustmentRecord.setAdjustType(1L);
inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName()); // inventoryAdjustmentRecord.setMaterialCode(outMaterialDetail.getMaterialNo());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setMaterialName(outMaterialDetail.getCommodityName());
inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode()); // inventoryAdjustmentRecord.setBarCode(outMaterialDetail.getBarCode());
inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName()); // if (inventoryAdjustmentRecord.getBarCode().equals("")){
inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId()); // getBarCode(materialInventoryPO, inventoryAdjustmentRecord);
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId()); // }
inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(outMaterialDetail.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName()); // inventoryAdjustmentRecord.setOrganizationId(stockOutOrder.getOrganizationId());
inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId()); // inventoryAdjustmentRecord.setOrganizationName(stockOutOrder.getOrganizationName());
inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId()); // inventoryAdjustmentRecord.setTopOrganizationId(stockOutOrder.getTopOrganizationId());
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid()); // inventoryAdjustmentRecord.setWarehouseCode(stockOutOrder.getWarehouseCode());
UserPo userPo = loginUser.getUserPo(); // inventoryAdjustmentRecord.setWarehouseName(stockOutOrder.getWarehouseName());
if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName()); // inventoryAdjustmentRecord.setWarehouseId(stockOutOrder.getWarehouseId());
inventoryAdjustmentRecord.setCreateTime(new Date()); // inventoryAdjustmentRecord.setStorageCode(materialInventoryPO.getStorageCode());
inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity); // inventoryAdjustmentRecord.setStorageName(materialInventoryPO.getStorageName());
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity); // inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity); // inventoryAdjustmentRecord.setStorageLocationCode(materialInventoryPO.getStorageLocationCode());
inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity); // inventoryAdjustmentRecord.setStorageLocationName(materialInventoryPO.getStorageLocationName());
inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity()); // inventoryAdjustmentRecord.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity()); // inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord); // inventoryAdjustmentRecord.setShipperId(stockOutOrder.getShipperId());
// inventoryAdjustmentRecord.setShipperName(stockOutOrder.getShipperName());
// inventoryAdjustmentRecord.setStorageSectionId(materialInventoryPO.getStorageSectionId());
// inventoryAdjustmentRecord.setStorageLocationId(materialInventoryPO.getStorageLocationId());
// inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
// UserPo userPo = loginUser.getUserPo();
// if (userPo != null) inventoryAdjustmentRecord.setCreateByName(userPo.getUserName());
// inventoryAdjustmentRecord.setCreateTime(new Date());
// inventoryAdjustmentRecord.setAllocationAfterQuantity(newAllocationQuantity);
// inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
// inventoryAdjustmentRecord.setFreezeBeforeQuantity(oldFreezeQuantity);
// inventoryAdjustmentRecord.setFreezeAfterQuantity(newFreezeQuantity);
// inventoryAdjustmentRecord.setInventoryBeforeQuantity(materialInventoryPO.getInventoryQuantity());
// inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventoryPO.getInventoryQuantity());
// inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
} }
} }
} }
@@ -50,6 +50,7 @@ import com.mhd.wms.domain.materialInventory.repository.facade.IMaterialInventory
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper; import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO; import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO; import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParamDO;
import com.mhd.wms.domain.materialMoreDetail.repository.todo.MaterialMoreDetailDO; import com.mhd.wms.domain.materialMoreDetail.repository.todo.MaterialMoreDetailDO;
import com.mhd.wms.domain.serialNumber.entity.SerialNumber; import com.mhd.wms.domain.serialNumber.entity.SerialNumber;
import com.mhd.wms.domain.serialNumber.repository.facade.ISerialNumberService; import com.mhd.wms.domain.serialNumber.repository.facade.ISerialNumberService;
@@ -678,63 +679,64 @@ public class StockShelfOrderDomainService {
MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId); MaterialBaseInfo materialBaseInfo = materialBaseInfoMapper.selectById(materialBaseInfoId);
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (materialInventoryPOS.size() == 0) { if (materialInventoryPOS.size() == 0) {
MaterialInventory materialInventory = new MaterialInventory(); MaterialInventoryParamDO inventoryParamDO = new MaterialInventoryParamDO();
materialInventory.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber()); // MaterialInventory materialInventory = new MaterialInventory();
materialInventory.setLotNumber(shelfMaterialDetail.getLotNumber()); // materialInventory.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber());
//仓库信息 // materialInventory.setLotNumber(shelfMaterialDetail.getLotNumber());
materialInventory.setWarehouseId(stockReceiptOrderDO.getWarehouseId()); // //仓库信息
materialInventory.setWarehouseCode(stockReceiptOrderDO.getWarehouseCode()); // materialInventory.setWarehouseId(stockReceiptOrderDO.getWarehouseId());
materialInventory.setWarehouseName(stockReceiptOrderDO.getWarehouseName()); // materialInventory.setWarehouseCode(stockReceiptOrderDO.getWarehouseCode());
// materialInventory.setWarehouseName(stockReceiptOrderDO.getWarehouseName());
//组织信息 //
materialInventory.setOrganizationId(stockReceiptOrderDO.getOrganizationId()); // //组织信息
materialInventory.setTopOrganizationId(stockReceiptOrderDO.getTopOrganizationId()); // materialInventory.setOrganizationId(stockReceiptOrderDO.getOrganizationId());
materialInventory.setOrganizationName(stockReceiptOrderDO.getOrganizationName()); // materialInventory.setTopOrganizationId(stockReceiptOrderDO.getTopOrganizationId());
// materialInventory.setOrganizationName(stockReceiptOrderDO.getOrganizationName());
//货主信息 //
materialInventory.setShipperId(stockReceiptOrderDO.getShipperId()); // //货主信息
materialInventory.setShipperName(stockReceiptOrderDO.getShipperName()); // materialInventory.setShipperId(stockReceiptOrderDO.getShipperId());
materialInventory.setShipperCode(stockReceiptOrderDO.getShipperCode()); // materialInventory.setShipperName(stockReceiptOrderDO.getShipperName());
// materialInventory.setShipperCode(stockReceiptOrderDO.getShipperCode());
//物料信息/库位库区 //
materialInventory.setMaterialBaseInfoId(shelfMaterialDetail.getMaterialBaseInfoId()); // //物料信息/库位库区
materialInventory.setStorageSectionId(shelfMaterialDetail.getStorageSectionId()); // materialInventory.setMaterialBaseInfoId(shelfMaterialDetail.getMaterialBaseInfoId());
materialInventory.setStorageCode(shelfMaterialDetail.getStorageCode()); // materialInventory.setStorageSectionId(shelfMaterialDetail.getStorageSectionId());
materialInventory.setStorageName(shelfMaterialDetail.getStorageName()); // materialInventory.setStorageCode(shelfMaterialDetail.getStorageCode());
materialInventory.setStorageLocationId(shelfMaterialDetail.getStorageLocationId()); // materialInventory.setStorageName(shelfMaterialDetail.getStorageName());
materialInventory.setStorageLocationCode(shelfMaterialDetail.getStorageLocationCode()); // materialInventory.setStorageLocationId(shelfMaterialDetail.getStorageLocationId());
materialInventory.setStorageLocationName(shelfMaterialDetail.getStorageLocationName()); // materialInventory.setStorageLocationCode(shelfMaterialDetail.getStorageLocationCode());
// materialInventory.setStorageLocationName(shelfMaterialDetail.getStorageLocationName());
//批次属性信息 //
materialInventory.setExtAttr1(shelfMaterialDetail.getExtAttr1()); // //批次属性信息
materialInventory.setExtAttr2(shelfMaterialDetail.getExtAttr2()); // materialInventory.setExtAttr1(shelfMaterialDetail.getExtAttr1());
materialInventory.setExtAttr3(shelfMaterialDetail.getExtAttr3()); // materialInventory.setExtAttr2(shelfMaterialDetail.getExtAttr2());
materialInventory.setExtAttr4(shelfMaterialDetail.getExtAttr4()); // materialInventory.setExtAttr3(shelfMaterialDetail.getExtAttr3());
materialInventory.setInventoryDate(shelfMaterialDetail.getInventoryDate()); // materialInventory.setExtAttr4(shelfMaterialDetail.getExtAttr4());
materialInventory.setExpiryDate(shelfMaterialDetail.getExpiryDate()); // materialInventory.setInventoryDate(shelfMaterialDetail.getInventoryDate());
materialInventory.setProductionDate(shelfMaterialDetail.getProductionDate()); // materialInventory.setExpiryDate(shelfMaterialDetail.getExpiryDate());
materialInventory.setBoxPalletNo(shelfMaterialDetail.getBoxPalletNo()); // materialInventory.setProductionDate(shelfMaterialDetail.getProductionDate());
materialInventory.setSheetRefNo(shelfMaterialDetail.getSheetRefNo()); // materialInventory.setBoxPalletNo(shelfMaterialDetail.getBoxPalletNo());
materialInventory.setBatchRefNo(shelfMaterialDetail.getBatchRefNo()); // materialInventory.setSheetRefNo(shelfMaterialDetail.getSheetRefNo());
materialInventory.setBatchNumber(shelfMaterialDetail.getBatchNumber()); // materialInventory.setBatchRefNo(shelfMaterialDetail.getBatchRefNo());
// materialInventory.setBatchNumber(shelfMaterialDetail.getBatchNumber());
//库存数量信息 //
materialInventory.setInventoryQuantity(shelfMaterialDetail.getShelvesQuantity()); // //库存数量信息
materialInventory.setAllocationQuantity(shelfMaterialDetail.getShelvesQuantity()); // materialInventory.setInventoryQuantity(shelfMaterialDetail.getShelvesQuantity());
materialInventory.setFreezeQuantity(BigDecimal.ZERO); // materialInventory.setAllocationQuantity(shelfMaterialDetail.getShelvesQuantity());
// materialInventory.setFreezeQuantity(BigDecimal.ZERO);
//创建人信息 //
materialInventory.setCreateBy(loginUser.getUserid()); // //创建人信息
materialInventory.setCreateByName(loginUser.getUsername()); // materialInventory.setCreateBy(loginUser.getUserid());
materialInventory.setCreateTime(new Date()); // materialInventory.setCreateByName(loginUser.getUsername());
// materialInventory.setCreateTime(new Date());
//体积 重量等 //
materialInventory.setVolume(shelfMaterialDetail.getTotalVolume()); // //体积 重量等
materialInventory.setArea(shelfMaterialDetail.getTotalArea()); // materialInventory.setVolume(shelfMaterialDetail.getTotalVolume());
materialInventory.setGrossWeight(shelfMaterialDetail.getTotalGrossWeight()); // materialInventory.setArea(shelfMaterialDetail.getTotalArea());
materialInventory.setNetWeight(shelfMaterialDetail.getTotalNetWeight()); // materialInventory.setGrossWeight(shelfMaterialDetail.getTotalGrossWeight());
materialInventory.setUnit(materialBaseInfo.getUnitCode()); // materialInventory.setNetWeight(shelfMaterialDetail.getTotalNetWeight());
materialInventory.setUnitName(materialBaseInfo.getUnitName()); // materialInventory.setUnit(materialBaseInfo.getUnitCode());
// materialInventory.setUnitName(materialBaseInfo.getUnitName());
// 条码优先取上架明细的 barCode为空则从 material_bar_code 表取优先 EA 单位 // 条码优先取上架明细的 barCode为空则从 material_bar_code 表取优先 EA 单位
String insertBarCode = shelfMaterialDetail.getBarCode(); String insertBarCode = shelfMaterialDetail.getBarCode();
if (StringUtils.isBlank(insertBarCode) && shelfMaterialDetail.getMaterialBaseInfoId() != null) { if (StringUtils.isBlank(insertBarCode) && shelfMaterialDetail.getMaterialBaseInfoId() != null) {
@@ -752,91 +754,69 @@ public class StockShelfOrderDomainService {
log.warn("获取条码失败,materialBaseInfoId={},错误:{}", shelfMaterialDetail.getMaterialBaseInfoId(), e.getMessage()); log.warn("获取条码失败,materialBaseInfoId={},错误:{}", shelfMaterialDetail.getMaterialBaseInfoId(), e.getMessage());
} }
} }
materialInventory.setBarCode(insertBarCode); //materialInventory.setBarCode(insertBarCode);
inventoryParamDO.setBarCode(insertBarCode);
inventoryParamDO.setArea(shelfMaterialDetail.getTotalArea());
inventoryParamDO.setVolume(shelfMaterialDetail.getTotalVolume());
inventoryParamDO.setNetWeight(shelfMaterialDetail.getTotalNetWeight());
inventoryParamDO.setGrossWeight(shelfMaterialDetail.getTotalGrossWeight());
inventoryParamDO.setMaterialInventoryId(null);
inventoryParamDO.setMaterialBaseInfoId(materialBaseInfo.getMaterialBaseInfoId());
materialInventoryMapper.insert(materialInventory); inventoryParamDO.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber());
inventoryParamDO.setLotNumber(shelfMaterialDetail.getLotNumber());
inventoryParamDO.setQuantity(shelfMaterialDetail.getShelvesQuantity());
//仓库信息
inventoryParamDO.setMaterialBaseInfoId(shelfMaterialDetail.getMaterialBaseInfoId());
inventoryParamDO.setStorageSectionId(shelfMaterialDetail.getStorageSectionId());
inventoryParamDO.setStorageCode(shelfMaterialDetail.getStorageCode());
inventoryParamDO.setStorageName(shelfMaterialDetail.getStorageName());
inventoryParamDO.setStorageLocationId(shelfMaterialDetail.getStorageLocationId());
inventoryParamDO.setStorageLocationCode(shelfMaterialDetail.getStorageLocationCode());
inventoryParamDO.setStorageLocationName(shelfMaterialDetail.getStorageLocationName());
inventoryParamDO.setWarehouseId(stockReceiptOrderDO.getWarehouseId());
inventoryParamDO.setWarehouseCode(stockReceiptOrderDO.getWarehouseCode());
inventoryParamDO.setWarehouseName(stockReceiptOrderDO.getWarehouseName());
//组织信息
inventoryParamDO.setOrganizationId(stockReceiptOrderDO.getOrganizationId());
inventoryParamDO.setTopOrganizationId(stockReceiptOrderDO.getTopOrganizationId());
inventoryParamDO.setOrganizationName(stockReceiptOrderDO.getOrganizationName());
//货主信息
inventoryParamDO.setShipperId(stockReceiptOrderDO.getShipperId());
inventoryParamDO.setShipperName(stockReceiptOrderDO.getShipperName());
inventoryParamDO.setShipperCode(stockReceiptOrderDO.getShipperCode());
inventoryParamDO.setExtAttr1(shelfMaterialDetail.getExtAttr1());
inventoryParamDO.setExtAttr2(shelfMaterialDetail.getExtAttr2());
inventoryParamDO.setExtAttr3(shelfMaterialDetail.getExtAttr3());
inventoryParamDO.setExtAttr4(shelfMaterialDetail.getExtAttr4());
inventoryParamDO.setInventoryDate(shelfMaterialDetail.getInventoryDate());
inventoryParamDO.setExpiryDate(shelfMaterialDetail.getExpiryDate());
inventoryParamDO.setProductionDate(shelfMaterialDetail.getProductionDate());
inventoryParamDO.setBoxPalletNo(shelfMaterialDetail.getBoxPalletNo());
inventoryParamDO.setSheetRefNo(shelfMaterialDetail.getSheetRefNo());
inventoryParamDO.setBatchRefNo(shelfMaterialDetail.getBatchRefNo());
inventoryParamDO.setBatchNumber(shelfMaterialDetail.getBatchNumber());
inventoryParamDO.setCreateBy(loginUser.getUserid());
inventoryParamDO.setCreateByName(loginUser.getUsername());
inventoryParamDO.setCreateTime(new Date());
//materialInventoryMapper.insert(materialInventory);
//库存调整记录 //库存调整记录
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord(); materialInventoryService.kctzjl(inventoryParamDO,"入库", loginUser);
inventoryAdjustmentRecord.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber()); materialInventoryService.xgkc(inventoryParamDO);
inventoryAdjustmentRecord.setLotNumber(shelfMaterialDetail.getLotNumber());
inventoryAdjustmentRecord.setAdjustAction("入库");
inventoryAdjustmentRecord.setRelateNo(stockReceiptOrderDO.getInOrderNumber());
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.setAdjustType(1L);
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setMaterialCode(shelfMaterialDetail.getMaterialCode());
inventoryAdjustmentRecord.setMaterialName(shelfMaterialDetail.getMaterialName());
// 条码优先取上架明细上的条码如果为空则根据物料基础信息ID从物料条码表中获取单位代码为EA的条码
String shelfBarCode = shelfMaterialDetail.getBarCode();
if (StringUtils.isBlank(shelfBarCode) && shelfMaterialDetail.getMaterialBaseInfoId() != null) {
try {
java.util.List<MaterialBarCodePO> barCodeList = materialBarCodeService.getInfoByMaterialBaseInfoIds(shelfMaterialDetail.getMaterialBaseInfoId());
if (barCodeList != null && !barCodeList.isEmpty()) {
// 优先选择单位代码为EA的条码若不存在则取第一条
MaterialBarCodePO eaBarCode = barCodeList.stream()
.filter(po -> "EA".equals(po.getUnitCode()))
.findFirst()
.orElse(barCodeList.get(0));
if (eaBarCode != null && StringUtils.isNotBlank(eaBarCode.getBarCode())) {
shelfBarCode = eaBarCode.getBarCode();
}
}
} catch (Exception e) {
log.warn("根据物料基础信息ID获取条码失败,materialBaseInfoId={},错误:{}", shelfMaterialDetail.getMaterialBaseInfoId(), e.getMessage());
}
}
inventoryAdjustmentRecord.setBarCode(shelfBarCode);
inventoryAdjustmentRecord.setMaterialBaseInfoId(shelfMaterialDetail.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setOrganizationId(stockReceiptOrderDO.getOrganizationId());
inventoryAdjustmentRecord.setOrganizationName(stockReceiptOrderDO.getOrganizationName());
inventoryAdjustmentRecord.setTopOrganizationId(stockReceiptOrderDO.getTopOrganizationId());
inventoryAdjustmentRecord.setWarehouseCode(stockReceiptOrderDO.getWarehouseCode());
inventoryAdjustmentRecord.setWarehouseName(stockReceiptOrderDO.getWarehouseName());
inventoryAdjustmentRecord.setWarehouseId(stockReceiptOrderDO.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.setShipperId(stockReceiptOrderDO.getShipperId());
inventoryAdjustmentRecord.setShipperName(stockReceiptOrderDO.getShipperName());
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.setAllocationAfterQuantity(materialInventory.getAllocationQuantity());
inventoryAdjustmentRecord.setAllocationBeforeQuantity(BigDecimal.ZERO);
inventoryAdjustmentRecord.setFreezeBeforeQuantity(BigDecimal.ZERO);
inventoryAdjustmentRecord.setFreezeAfterQuantity(BigDecimal.ZERO);
inventoryAdjustmentRecord.setInventoryBeforeQuantity(BigDecimal.ZERO);
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setNetWeight(BigDecimal.ZERO );
inventoryAdjustmentRecord.setGrossWeight(BigDecimal.ZERO);
inventoryAdjustmentRecord.setVolume(BigDecimal.ZERO);
inventoryAdjustmentRecord.setArea(BigDecimal.ZERO);
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight() == null ? BigDecimal.ZERO : materialInventory.getNetWeight());
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight() == null ? BigDecimal.ZERO : materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume() == null ? BigDecimal.ZERO : materialInventory.getVolume());
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea() == null ? BigDecimal.ZERO : materialInventory.getArea());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
} else if (materialInventoryPOS.size() == 1) { } else if (materialInventoryPOS.size() == 1) {
MaterialInventory materialInventory = new MaterialInventory(); MaterialInventoryParamDO inventoryParamDO = new MaterialInventoryParamDO();
materialInventory.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber());
materialInventory.setLotNumber(shelfMaterialDetail.getLotNumber());
BigDecimal shelvesQuantity = shelfMaterialDetail.getShelvesQuantity(); BigDecimal shelvesQuantity = shelfMaterialDetail.getShelvesQuantity();
shelvesQuantity = shelvesQuantity != null ? shelvesQuantity : BigDecimal.ZERO; shelvesQuantity = shelvesQuantity != null ? shelvesQuantity : BigDecimal.ZERO;
MaterialInventoryPO materialInventoryPO = materialInventoryPOS.get(0); MaterialInventoryPO materialInventoryPO = materialInventoryPOS.get(0);
BigDecimal oldFreezeQuantity = materialInventoryPO.getFreezeQuantity();
BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity(); BigDecimal oldInventoryQuantity = materialInventoryPO.getInventoryQuantity();
oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO; oldInventoryQuantity = oldInventoryQuantity != null ? oldInventoryQuantity : BigDecimal.ZERO;
BigDecimal newInventoryQuantity = oldInventoryQuantity.add(shelvesQuantity); BigDecimal newInventoryQuantity = oldInventoryQuantity.add(shelvesQuantity);
@@ -848,110 +828,41 @@ public class StockShelfOrderDomainService {
BigDecimal oldArea = materialInventoryPO.getArea(); BigDecimal oldArea = materialInventoryPO.getArea();
oldArea = oldArea != null ? oldArea : BigDecimal.ZERO; oldArea = oldArea != null ? oldArea : BigDecimal.ZERO;
BigDecimal totalArea = shelfMaterialDetail.getTotalArea(); BigDecimal totalArea = shelfMaterialDetail.getTotalArea();
totalArea = totalArea != null ? totalArea : BigDecimal.ZERO; totalArea = totalArea != null ? totalArea : BigDecimal.ZERO;
BigDecimal newArea = oldArea.add(totalArea); BigDecimal newArea = oldArea.add(totalArea);
BigDecimal oldVolume = materialInventoryPO.getVolume(); BigDecimal oldVolume = materialInventoryPO.getVolume();
oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO; oldVolume = oldVolume != null ? oldVolume : BigDecimal.ZERO;
BigDecimal totalVolume = shelfMaterialDetail.getTotalVolume(); BigDecimal totalVolume = shelfMaterialDetail.getTotalVolume();
totalVolume = totalVolume != null ? totalVolume : BigDecimal.ZERO; totalVolume = totalVolume != null ? totalVolume : BigDecimal.ZERO;
BigDecimal newVolume = oldVolume.add(totalVolume); BigDecimal newVolume = oldVolume.add(totalVolume);
BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight(); BigDecimal oldGrossWeight = materialInventoryPO.getGrossWeight();
oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO; oldGrossWeight = oldGrossWeight != null ? oldGrossWeight : BigDecimal.ZERO;
BigDecimal totalGrossWeight = shelfMaterialDetail.getTotalGrossWeight(); BigDecimal totalGrossWeight = shelfMaterialDetail.getTotalGrossWeight();
totalGrossWeight = totalGrossWeight != null ? totalGrossWeight : BigDecimal.ZERO; totalGrossWeight = totalGrossWeight != null ? totalGrossWeight : BigDecimal.ZERO;
BigDecimal newGrossWeight = oldGrossWeight.add(totalGrossWeight); BigDecimal newGrossWeight = oldGrossWeight.add(totalGrossWeight);
BigDecimal oldNetWeight = materialInventoryPO.getNetWeight(); BigDecimal oldNetWeight = materialInventoryPO.getNetWeight();
oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO; oldNetWeight = oldNetWeight != null ? oldNetWeight : BigDecimal.ZERO;
BigDecimal totalNetWeight = shelfMaterialDetail.getTotalNetWeight(); BigDecimal totalNetWeight = shelfMaterialDetail.getTotalNetWeight();
totalNetWeight = totalNetWeight != null ? totalNetWeight : BigDecimal.ZERO; totalNetWeight = totalNetWeight != null ? totalNetWeight : BigDecimal.ZERO;
BigDecimal newNetWeight = oldNetWeight.add(totalNetWeight); BigDecimal newNetWeight = oldNetWeight.add(totalNetWeight);
materialInventoryPO.setInventoryQuantity(newInventoryQuantity); inventoryParamDO.setArea(totalArea);
materialInventoryPO.setAllocationQuantity(newAllocationQuantity); inventoryParamDO.setVolume(totalVolume);
materialInventoryPO.setArea(newArea); inventoryParamDO.setNetWeight(totalNetWeight);
materialInventoryPO.setVolume(newVolume); inventoryParamDO.setGrossWeight(totalGrossWeight);
materialInventoryPO.setGrossWeight(newGrossWeight); inventoryParamDO.setMaterialInventoryId(materialInventoryPO.getMaterialInventoryId());
materialInventoryPO.setNetWeight(newNetWeight); inventoryParamDO.setMaterialBaseInfoId(materialInventoryPO.getMaterialBaseInfoId());
BeanUtils.copyProperties(materialInventoryPO, materialInventory); inventoryParamDO.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber());
materialInventory.setUpdateBy(loginUser.getUserid()); inventoryParamDO.setLotNumber(shelfMaterialDetail.getLotNumber());
materialInventory.setUpdateByName(loginUser.getUsername()); inventoryParamDO.setQuantity(shelfMaterialDetail.getShelvesQuantity());
materialInventory.setUpdateTime(new Date()); inventoryParamDO.setType("1");
// 如果库存记录没有 barCode则补充写入 //库存调整记录
if (StringUtils.isBlank(materialInventoryPO.getBarCode())) { materialInventoryService.kctzjl(inventoryParamDO, "入库", loginUser);
String updateBarCode = shelfMaterialDetail.getBarCode(); materialInventoryService.xgkc(inventoryParamDO);
if (StringUtils.isBlank(updateBarCode) && shelfMaterialDetail.getMaterialBaseInfoId() != null) {
try {
List<MaterialBarCodePO> barCodeList = materialBarCodeService.getInfoByMaterialBaseInfoIds(shelfMaterialDetail.getMaterialBaseInfoId());
if (barCodeList != null && !barCodeList.isEmpty()) {
MaterialBarCodePO eaBarCode = barCodeList.stream()
.filter(po -> "EA".equals(po.getUnitCode()))
.findFirst().orElse(barCodeList.get(0));
if (eaBarCode != null && StringUtils.isNotBlank(eaBarCode.getBarCode())) {
updateBarCode = eaBarCode.getBarCode();
}
}
} catch (Exception e) {
log.warn("获取条码失败,materialBaseInfoId={},错误:{}", shelfMaterialDetail.getMaterialBaseInfoId(), e.getMessage());
}
}
materialInventory.setBarCode(updateBarCode);
}
materialInventoryMapper.updateById(materialInventory);
InventoryAdjustmentRecord inventoryAdjustmentRecord = new InventoryAdjustmentRecord();
inventoryAdjustmentRecord.setInOrderNumber(stockReceiptOrderDO.getInOrderNumber());
inventoryAdjustmentRecord.setLotNumber(shelfMaterialDetail.getLotNumber());
inventoryAdjustmentRecord.setAdjustAction("入库");
inventoryAdjustmentRecord.setRelateNo(stockReceiptOrderDO.getInOrderNumber());
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.setAdjustType(1L);
inventoryAdjustmentRecord.setMaterialBaseInfoId(materialInventory.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setMaterialCode(shelfMaterialDetail.getMaterialCode());
inventoryAdjustmentRecord.setMaterialName(shelfMaterialDetail.getMaterialName());
inventoryAdjustmentRecord.setBarCode(shelfMaterialDetail.getBarCode());
inventoryAdjustmentRecord.setMaterialBaseInfoId(shelfMaterialDetail.getMaterialBaseInfoId());
inventoryAdjustmentRecord.setOrganizationId(stockReceiptOrderDO.getOrganizationId());
inventoryAdjustmentRecord.setOrganizationName(stockReceiptOrderDO.getOrganizationName());
inventoryAdjustmentRecord.setTopOrganizationId(stockReceiptOrderDO.getTopOrganizationId());
inventoryAdjustmentRecord.setWarehouseCode(stockReceiptOrderDO.getWarehouseCode());
inventoryAdjustmentRecord.setWarehouseName(stockReceiptOrderDO.getWarehouseName());
inventoryAdjustmentRecord.setWarehouseId(stockReceiptOrderDO.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.setShipperId(stockReceiptOrderDO.getShipperId());
inventoryAdjustmentRecord.setShipperName(stockReceiptOrderDO.getShipperName());
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.setAllocationAfterQuantity(newAllocationQuantity);
inventoryAdjustmentRecord.setAllocationBeforeQuantity(oldAllocationQuantity);
inventoryAdjustmentRecord.setFreezeBeforeQuantity(materialInventory.getFreezeQuantity());
inventoryAdjustmentRecord.setFreezeAfterQuantity(materialInventory.getFreezeQuantity());
inventoryAdjustmentRecord.setInventoryBeforeQuantity(oldInventoryQuantity);
inventoryAdjustmentRecord.setInventoryAfterQuantity(newInventoryQuantity);
inventoryAdjustmentRecord.setCreateBy(loginUser.getUserid());
inventoryAdjustmentRecord.setCreateTime(new Date());
inventoryAdjustmentRecord.setNetWeight(BigDecimal.ZERO );
inventoryAdjustmentRecord.setGrossWeight(BigDecimal.ZERO);
inventoryAdjustmentRecord.setVolume(BigDecimal.ZERO);
inventoryAdjustmentRecord.setArea(BigDecimal.ZERO);
inventoryAdjustmentRecord.setAdjustedNetWeight(materialInventory.getNetWeight() == null ? BigDecimal.ZERO : materialInventory.getNetWeight());
inventoryAdjustmentRecord.setAdjustedGrossWeight(materialInventory.getGrossWeight() == null ? BigDecimal.ZERO : materialInventory.getGrossWeight());
inventoryAdjustmentRecord.setAdjustedVolume(materialInventory.getVolume() == null ? BigDecimal.ZERO : materialInventory.getVolume());
inventoryAdjustmentRecord.setAdjustedArea(materialInventory.getArea() == null ? BigDecimal.ZERO : materialInventory.getArea());
inventoryAdjustmentRecordMapper.insert(inventoryAdjustmentRecord);
} }
} }
} }