diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockListInfoEntity.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockListInfoEntity.java index 234e0fd4f..7619466ee 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockListInfoEntity.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionStockListInfoEntity.java @@ -107,6 +107,13 @@ public class DistributionStockListInfoEntity extends TenantEntity { */ @ApiModelProperty(value = "仓库ID") private Long warehouseId; + + + /** + * 仓库ID + */ + @ApiModelProperty(value = "仓库ID") + private Long stockListId; /** * 仓库名称 */ diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java index d3ddf7566..e83bccd7e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockListServiceImpl.java @@ -223,95 +223,229 @@ public class DistributionStockListServiceImpl extends BaseServiceImpl list = new ArrayList<>(); Long aLong = 0L; - if(ObjectUtil.isNotEmpty(distributionStockListDTO.getDescriptionGoods())){ - //选择的 - //查询客户是不是有该物资的拆包 - one2 = this.getOne(Wrappers.query().lambda() - .eq(DistributionStockListEntity::getMaterialId, distributionStockListDTO.getMaterialId()) - .eq(DistributionStockListEntity::getMarketId, distributionStockListDTO.getMarketId()) - .eq(ObjectUtil.isNotEmpty(distributionStockListDTO.getStoreId()), DistributionStockListEntity::getStoreId, distributionStockListDTO.getStoreId()) - ); - - }else{ - //新增物料信息 - basicMaterialEntity.setName(distributionStockListDTO.getMaterialIdName()); - basicMaterialEntity.setProductCode(distributionStockListDTO.getCargoNumber()); - basicMaterialEntity.setPackingSpecification(distributionStockListDTO.getCargoNorms()); - basicMaterialEntity.setSku(distributionStockListDTO.getSku()); - basicMaterialEntity.setPackageNum(distributionStockListDTO.getPackageNum()+""); - basicMaterialEntity.setLogpmUnit(distributionStockListDTO.getCargoUnit()); - basicMaterialEntity.setPid(distributionStockListDTO.getMaterialId()); - aLong = basicMaterialClient.addMaterial(basicMaterialEntity); - //客户物资信息 - list = this.list(Wrappers.query().lambda() -// .eq(DistributionStockListEntity::getId, distributionStockListDTO.getId()) - .eq(DistributionStockListEntity::getMarketId, distributionStockListDTO.getMarketId()) - .eq(DistributionStockListEntity::getMaterialId, distributionStockListDTO.getMaterialId()) - .eq(ObjectUtil.isNotEmpty(distributionStockListDTO.getStoreId()), DistributionStockListEntity::getStoreId, distributionStockListDTO.getStoreId()) - ); - - } - if (list.get(0).getCargoNumber().equals(distributionStockListDTO.getCargoNumber())){ - log.error("库存品拆包选择目标物料一致:{}",distributionStockListDTO.getCargoNumber()); + BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); + if (Func.isEmpty(myCurrentWarehouse)){ + log.error("##################拆包未授权myCurrentWarehouse:{}",myCurrentWarehouse); return false; } - //没有新增 - DistributionStockListEntity distributionStockListEntity = new DistributionStockListEntity(); - BeanUtils.copyProperties(list.get(0),distributionStockListEntity); - distributionStockListEntity.setIncomingBatch("CB_"+new Date().getTime()); - distributionStockListEntity.setPid(list.get(0).getId()); - distributionStockListEntity.setSku(distributionStockListDTO.getSku()); - distributionStockListEntity.setQuantityStock((distributionStockListDTO.getStoreNum() * Integer.parseInt(distributionStockListDTO.getPackageNum()))); - distributionStockListEntity.setUnpackingQuantity(0); - distributionStockListEntity.setCargoUnit(DictBizCache.getValue(DictBizConstant.LOGPM_UNIT,distributionStockListDTO.getCargoUnit()) ); - distributionStockListEntity.setMaterialId(aLong); - distributionStockListEntity.setDescriptionGoods(distributionStockListDTO.getMaterialIdName()); - distributionStockListEntity.setCargoNumber(distributionStockListDTO.getCargoNumber()); - distributionStockListEntity.setCargoNorms(distributionStockListDTO.getCargoNorms()); - distributionStockListEntity.setQuantityOccupied(0); - distributionStockListEntity.setId(null); - - if(ObjectUtils.isNotNull(one2.getId())){ + + + DistributionStockListEntity one2 = this.getOne(Wrappers.query().lambda() + .eq(DistributionStockListEntity::getMaterialId, distributionStockListDTO.getMaterialId()) + .eq(DistributionStockListEntity::getPid, distributionStockListDTO.getId()) + .eq(DistributionStockListEntity::getMarketId, distributionStockListDTO.getMarketId()) + .eq(DistributionStockListEntity::getWarehouseId, myCurrentWarehouse.getId()) + .eq(ObjectUtil.isNotEmpty(distributionStockListDTO.getStoreId()), DistributionStockListEntity::getStoreId, distributionStockListDTO.getStoreId()) + ); + DistributionStockListInfoEntity distributionStockListInfo = new DistributionStockListInfoEntity(); + DistributionUnpackingDetailsEntity distributionUnpackingDetails = new DistributionUnpackingDetailsEntity(); + DistributionStockListEntity one = this.getOne(Wrappers.query().lambda() + .eq(DistributionStockListEntity::getId, distributionStockListDTO.getId()) + .eq(DistributionStockListEntity::getMarketId, distributionStockListDTO.getMarketId()) + .eq(DistributionStockListEntity::getMaterialId, distributionStockListDTO.getMaterialId()) + .eq(DistributionStockListEntity::getWarehouseId, myCurrentWarehouse.getId()) + .eq(ObjectUtil.isNotEmpty(distributionStockListDTO.getStoreId()), DistributionStockListEntity::getStoreId, distributionStockListDTO.getStoreId()) + ); + if (Func.isNotEmpty(one2)) { + //查询是否存在有拆包产物 + //存在则是进行数量的累加 //有修改 DistributionStockListEntity d = new DistributionStockListEntity(); d.setId(one2.getId()); int i = one2.getQuantityStock() + (distributionStockListDTO.getStoreNum() * Integer.parseInt(distributionStockListDTO.getPackageNum())); d.setQuantityStock(i); + d.setWarehouseId(myCurrentWarehouse.getId()); + d.setWarehouseName(myCurrentWarehouse.getName()); this.updateById(d); + //新增入库记录 + BeanUtil.copyProperties(d, distributionStockListInfo); + distributionStockListInfo.setId(null); + distributionStockListInfo.setStockListId(d.getId()); + distributionStockListInfo.setOutboundQuantity(0); + distributionStockListInfo.setGroundingTime(new Date()); + distributionStockListInfo.setQuantityStock(i); + distributionStockListInfoService.save(distributionStockListInfo); + //添加拆包记录 + distributionUnpackingDetails.setStockArticleId(Optional.ofNullable(one2.getStockArticleId()).orElse(null)); + distributionUnpackingDetails.setOrderSelfNumber(Optional.ofNullable(one2.getOrderCode()).orElse(null)); + distributionUnpackingDetails.setItemName(Optional.ofNullable(one2.getDescriptionGoods()).orElse(null)); + distributionUnpackingDetails.setUnpackingQuantity(Optional.ofNullable(one2.getUnpackingQuantity()).orElse(null)); + distributionUnpackingDetails.setStockListId(Optional.ofNullable(distributionStockListDTO.getId()).orElse(null)); + } else { + if (one.getCargoNumber().equals(distributionStockListDTO.getCargoNumber())) { + log.error("库存品拆包选择目标物料一致:{}", distributionStockListDTO.getCargoNumber()); + return false; + } + //查询物是否是新增的,如果是新增物料则需要进行物料信息的保存 + BasicMaterialEntity materialByProductCode = basicMaterialClient.getMaterialByProductCode(distributionStockListDTO.getCargoNumber()); + if (Func.isEmpty(materialByProductCode)) { + basicMaterialEntity.setName(distributionStockListDTO.getMaterialIdName()); + basicMaterialEntity.setProductCode(distributionStockListDTO.getCargoNumber()); + basicMaterialEntity.setPackingSpecification(distributionStockListDTO.getCargoNorms()); + basicMaterialEntity.setSku(distributionStockListDTO.getSku()); + basicMaterialEntity.setPackageNum(distributionStockListDTO.getPackageNum() + ""); + basicMaterialEntity.setPackageNum(distributionStockListDTO.getPackageNum() + ""); + basicMaterialEntity.setLogpmUnit(distributionStockListDTO.getCargoUnit()); + basicMaterialEntity.setPid(distributionStockListDTO.getMaterialId()); + aLong = basicMaterialClient.addMaterial(basicMaterialEntity); + }else { + aLong = one.getMaterialId(); + } + if (Func.isNotEmpty(one)) { + //生成新的库存品信息 + DistributionStockListEntity distributionStockListEntity = new DistributionStockListEntity(); + BeanUtils.copyProperties(one, distributionStockListEntity); + distributionStockListEntity.setIncomingBatch("CB_" + new Date().getTime()); + distributionStockListEntity.setPid(one.getId()); + distributionStockListEntity.setSku(distributionStockListDTO.getSku()); + distributionStockListEntity.setQuantityStock((distributionStockListDTO.getStoreNum() * Integer.parseInt(distributionStockListDTO.getPackageNum()))); + distributionStockListEntity.setUnpackingQuantity(0); + distributionStockListEntity.setOutboundQuantity(0); + distributionStockListEntity.setMaterialId(aLong); + distributionStockListEntity.setCargoUnit(DictBizCache.getValue(DictBizConstant.LOGPM_UNIT, distributionStockListDTO.getCargoUnit())); + distributionStockListEntity.setDescriptionGoods(distributionStockListDTO.getMaterialIdName()); + distributionStockListEntity.setCargoNumber(distributionStockListDTO.getCargoNumber()); + distributionStockListEntity.setCargoNorms(distributionStockListDTO.getCargoNorms()); + distributionStockListEntity.setQuantityOccupied(0); + distributionStockListEntity.setId(null); + this.save(distributionStockListEntity); + //新增入库记录 + BeanUtil.copyProperties(distributionStockListEntity, distributionStockListInfo); + distributionStockListInfo.setId(null); + distributionStockListInfo.setStockListId(distributionStockListEntity.getId()); + distributionStockListInfo.setOutboundQuantity(0); + distributionStockListInfo.setGroundingTime(new Date()); + distributionStockListInfo.setQuantityStock((distributionStockListDTO.getStoreNum() * Integer.parseInt(distributionStockListDTO.getPackageNum()))); + distributionStockListInfoService.save(distributionStockListInfo); + //添加拆包记录 + distributionUnpackingDetails.setStockArticleId(Optional.ofNullable(one.getStockArticleId()).orElse(null)); + distributionUnpackingDetails.setOrderSelfNumber(Optional.ofNullable(one.getOrderCode()).orElse(null)); + distributionUnpackingDetails.setItemName(Optional.ofNullable(one.getDescriptionGoods()).orElse(null)); + distributionUnpackingDetails.setUnpackingQuantity(Optional.ofNullable(one.getUnpackingQuantity()).orElse(null)); + distributionUnpackingDetails.setStockListId(Optional.ofNullable(distributionStockListDTO.getId()).orElse(null)); + } else { + log.error("#################查询库存品失败"); + return false; + } - }else{ - this.save(distributionStockListEntity); } - //新增入库记录 - DistributionStockListInfoEntity distributionStockListInfo = new DistributionStockListInfoEntity(); - BeanUtil.copyProperties(distributionStockListEntity,distributionStockListInfo); - distributionStockListInfo.setGroundingTime(new Date()); - distributionStockListInfoService.save(distributionStockListInfo); - - //修改客户物资记录 - DistributionStockListEntity stockListEntity = new DistributionStockListEntity(); - stockListEntity.setId(list.get(0).getId()); - stockListEntity.setQuantityStock(list.get(0).getQuantityStock()-distributionStockListDTO.getUnpackingQuantity()); - stockListEntity.setUnpackingQuantity( list.get(0).getUnpackingQuantity() + distributionStockListDTO.getUnpackingQuantity()); - this.updateById(stockListEntity); - - - //添加拆包记录 - DistributionUnpackingDetailsEntity distributionUnpackingDetails= new DistributionUnpackingDetailsEntity(); - distributionUnpackingDetails.setStockArticleId(Optional.ofNullable(list.get(0).getStockArticleId()).orElse(null)); - distributionUnpackingDetails.setOrderSelfNumber(Optional.ofNullable(list.get(0).getOrderCode()).orElse(null)); - distributionUnpackingDetails.setItemName(Optional.ofNullable(list.get(0).getDescriptionGoods()).orElse(null)); - distributionUnpackingDetails.setUnpackingQuantity(Optional.ofNullable(list.get(0).getUnpackingQuantity()).orElse(null)); - distributionUnpackingDetails.setStockListId(Optional.ofNullable(distributionStockListDTO.getId()).orElse(null)); - + distributionStockListInfo.setId(null); distributionUnpackingDetailsService.save(distributionUnpackingDetails); + //对原来的库存品进行数据维护 + one.setQuantityStock(one.getQuantityStock() - distributionStockListDTO.getStoreNum()); + this.updateById(one); return true; } + + + + +// //不存在拆包产物 +// //添加新的库存品信息 +// list = this.list(Wrappers.query().lambda() +//// .eq(DistributionStockListEntity::getId, distributionStockListDTO.getId()) +// .eq(DistributionStockListEntity::getMarketId, distributionStockListDTO.getMarketId()) +// .eq(DistributionStockListEntity::getMaterialId, distributionStockListDTO.getMaterialId()) +// .eq(ObjectUtil.isNotEmpty(distributionStockListDTO.getStoreId()), DistributionStockListEntity::getStoreId, distributionStockListDTO.getStoreId()) +// ); +// } + + +// if(ObjectUtil.isNotEmpty(distributionStockListDTO.getDescriptionGoods())){ +// //选择的 +// //查询客户是不是有该物资的拆包 +// one2 = this.getOne(Wrappers.query().lambda() +// .eq(DistributionStockListEntity::getMaterialId, distributionStockListDTO.getMaterialId()) +// .eq(DistributionStockListEntity::getMarketId, distributionStockListDTO.getMarketId()) +// .eq(ObjectUtil.isNotEmpty(distributionStockListDTO.getStoreId()), DistributionStockListEntity::getStoreId, distributionStockListDTO.getStoreId()) +// ); +// }else{ +// //新增物料信息 +// basicMaterialEntity.setName(distributionStockListDTO.getMaterialIdName()); +// basicMaterialEntity.setProductCode(distributionStockListDTO.getCargoNumber()); +// basicMaterialEntity.setPackingSpecification(distributionStockListDTO.getCargoNorms()); +// basicMaterialEntity.setSku(distributionStockListDTO.getSku()); +// basicMaterialEntity.setPackageNum(distributionStockListDTO.getPackageNum()+""); +// basicMaterialEntity.setLogpmUnit(distributionStockListDTO.getCargoUnit()); +// basicMaterialEntity.setPid(distributionStockListDTO.getMaterialId()); +// aLong = basicMaterialClient.addMaterial(basicMaterialEntity); +// //客户物资信息 +// list = this.list(Wrappers.query().lambda() +//// .eq(DistributionStockListEntity::getId, distributionStockListDTO.getId()) +// .eq(DistributionStockListEntity::getMarketId, distributionStockListDTO.getMarketId()) +// .eq(DistributionStockListEntity::getMaterialId, distributionStockListDTO.getMaterialId()) +// .eq(ObjectUtil.isNotEmpty(distributionStockListDTO.getStoreId()), DistributionStockListEntity::getStoreId, distributionStockListDTO.getStoreId()) +// ); +// +// } +// if (list.get(0).getCargoNumber().equals(distributionStockListDTO.getCargoNumber())){ +// log.error("库存品拆包选择目标物料一致:{}",distributionStockListDTO.getCargoNumber()); +// return false; +// } +// DistributionStockListEntity distributionStockListEntity = new DistributionStockListEntity(); +// if (Func.isNotEmpty(list)&& list.size()>0){ +// //没有新增 +// distributionStockListEntity = new DistributionStockListEntity(); +// BeanUtils.copyProperties(list.get(0),distributionStockListEntity); +// distributionStockListEntity.setIncomingBatch("CB_"+new Date().getTime()); +// distributionStockListEntity.setPid(list.get(0).getId()); +// distributionStockListEntity.setSku(distributionStockListDTO.getSku()); +// distributionStockListEntity.setQuantityStock((distributionStockListDTO.getStoreNum() * Integer.parseInt(distributionStockListDTO.getPackageNum()))); +// distributionStockListEntity.setUnpackingQuantity(0); +// distributionStockListEntity.setCargoUnit(DictBizCache.getValue(DictBizConstant.LOGPM_UNIT,distributionStockListDTO.getCargoUnit()) ); +// distributionStockListEntity.setMaterialId(aLong); +// distributionStockListEntity.setDescriptionGoods(distributionStockListDTO.getMaterialIdName()); +// distributionStockListEntity.setCargoNumber(distributionStockListDTO.getCargoNumber()); +// distributionStockListEntity.setCargoNorms(distributionStockListDTO.getCargoNorms()); +// distributionStockListEntity.setQuantityOccupied(0); +// distributionStockListEntity.setId(null); +// }else { +// list.add(one2); +// } + + +// if(ObjectUtils.isNotNull(one2.getId())){ +// //有修改 +// DistributionStockListEntity d = new DistributionStockListEntity(); +// d.setId(one2.getId()); +// int i = one2.getQuantityStock() + (distributionStockListDTO.getStoreNum() * Integer.parseInt(distributionStockListDTO.getPackageNum())); +// d.setQuantityStock(i); +// this.updateById(d); +// +// }else{ +// this.save(distributionStockListEntity); +// } +// //新增入库记录 +// DistributionStockListInfoEntity distributionStockListInfo = new DistributionStockListInfoEntity(); +// BeanUtil.copyProperties(distributionStockListEntity,distributionStockListInfo); +// distributionStockListInfo.setGroundingTime(new Date()); +// distributionStockListInfoService.save(distributionStockListInfo); +// +// //修改客户物资记录 +// DistributionStockListEntity stockListEntity = new DistributionStockListEntity(); +// stockListEntity.setId(list.get(0).getId()); +// stockListEntity.setQuantityStock(list.get(0).getQuantityStock()-distributionStockListDTO.getUnpackingQuantity()); +// stockListEntity.setUnpackingQuantity( list.get(0).getUnpackingQuantity() + distributionStockListDTO.getUnpackingQuantity()); +// this.updateById(stockListEntity); +// +// +// //添加拆包记录 +// DistributionUnpackingDetailsEntity distributionUnpackingDetails= new DistributionUnpackingDetailsEntity(); +// distributionUnpackingDetails.setStockArticleId(Optional.ofNullable(list.get(0).getStockArticleId()).orElse(null)); +// distributionUnpackingDetails.setOrderSelfNumber(Optional.ofNullable(list.get(0).getOrderCode()).orElse(null)); +// distributionUnpackingDetails.setItemName(Optional.ofNullable(list.get(0).getDescriptionGoods()).orElse(null)); +// distributionUnpackingDetails.setUnpackingQuantity(Optional.ofNullable(list.get(0).getUnpackingQuantity()).orElse(null)); +// distributionUnpackingDetails.setStockListId(Optional.ofNullable(distributionStockListDTO.getId()).orElse(null)); +// +// distributionUnpackingDetailsService.save(distributionUnpackingDetails); +// return true; +// } + /** * 查询客户信息 * @param