@ -16,8 +16,10 @@
* /
package com.logpm.distribution.service.impl ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.logpm.basic.feign.IBasicTenantCodeClient ;
import com.logpm.distribution.dto.DistributionStockListDTO ;
import com.logpm.distribution.entity.* ;
import com.logpm.distribution.service.* ;
import com.logpm.distribution.vo.DistributionStockArticleVO ;
@ -34,9 +36,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl ;
import org.springframework.transaction.annotation.Transactional ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Objects ;
import java.util.* ;
import java.util.concurrent.atomic.AtomicReference ;
@ -113,56 +113,62 @@ public class DistributionStockListServiceImpl extends BaseServiceImpl<Distributi
/ * *
*
* @param distributionStockList
* @param distributionStockListDTO
* @return
* /
@Override
@Transactional ( rollbackFor = Exception . class )
public Boolean parcels ( DistributionStockListEntity distributionStockList ) {
List < DistributionStockEntity > list = new ArrayList < > ( ) ;
List < DistributionUnpackingDetailsEntity > detailsEntities = new ArrayList < > ( ) ;
distributionStockList . getParcels ( ) . forEach ( i - > {
//查询包件信息
DistributionParcelDetailsEntity one = distributionParcelDetailsService . getOne ( Wrappers . < DistributionParcelDetailsEntity > query ( ) . lambda ( )
. eq ( DistributionParcelDetailsEntity : : getId , i . getParcelsId ( ) )
. eq ( DistributionParcelDetailsEntity : : getIsDeleted , 0 )
) ;
for ( Integer integer = 0 ; integer < i . getUnpackingQuantity ( ) ; integer + + ) {
//添加拆包信息
DistributionStockEntity distributionStock = new DistributionStockEntity ( ) ;
distributionStock . setStockListId ( Long . parseLong ( one . getStockArticleId ( ) ) ) ;
distributionStock . setParcelListId ( Long . parseLong ( one . getParcelListId ( ) ) ) ;
distributionStock . setConditions ( 1 ) ; //1 在库
distributionStock . setUnpackingQuantity ( 1 ) ;
distributionStock . setUnit ( one . getUnit ( ) ) ;
distributionStock . setGoodsAllocation ( one . getGoodsAllocation ( ) ) ;
// String s1 = basicTenantCodeClient.shelfCode(AuthUtil.getTenantId(), "7");
String random = Func . random ( 15 , RandomType . INT ) ;
// distributionStock.setCoding(s1+random);
distributionStock . setCoding ( random ) ;
list . add ( distributionStock ) ;
//添加拆包记录
DistributionStockListEntity one1 = baseMapper . selectById ( distributionStockList . getId ( ) ) ;
DistributionUnpackingDetailsEntity distributionUnpackingDetails = new DistributionUnpackingDetailsEntity ( one . getStockArticleId ( ) , one1 . getOrderSelfNumbering ( ) , distributionStockList . getId ( ) , one . getName ( ) , i . getUnpackingQuantity ( ) ) ;
detailsEntities . add ( distributionUnpackingDetails ) ;
}
} ) ;
if ( list . size ( ) > 0 ) {
//修改库存品信息
int total = distributionStockList . getParcels ( ) . stream ( ) . mapToInt ( DistributionStockEntity : : getUnpackingQuantity ) . sum ( ) ;
DistributionStockListEntity distributionStockList1 = new DistributionStockListEntity ( ) ;
distributionStockList1 . setId ( distributionStockList . getId ( ) ) ;
distributionStockList1 . setUnpack ( true ) ;
distributionStockList1 . setQuantityStock ( total ) ;
distributionStockList1 . setOutboundQuantity ( 0 ) ;
baseMapper . updateById ( distributionStockList1 ) ;
//添加拆包
distributionStockService . saveBatch ( list ) ;
}
if ( detailsEntities . size ( ) > 0 ) {
//添加拆包记录
distributionUnpackingDetailsService . saveBatch ( detailsEntities ) ;
public Boolean parcels ( DistributionStockListDTO distributionStockListDTO ) {
//查询客户是不是有该物资的拆包
DistributionStockListEntity one2 = this . getOne ( Wrappers . < DistributionStockListEntity > query ( ) . lambda ( )
. eq ( DistributionStockListEntity : : getPid , distributionStockListDTO . getId ( ) )
. eq ( DistributionStockListEntity : : getMaterialId , distributionStockListDTO . getMaterialId ( ) )
. eq ( DistributionStockListEntity : : getMarketId , distributionStockListDTO . getMarketId ( ) )
. eq ( ObjectUtil . isNotEmpty ( distributionStockListDTO . getStoreId ( ) ) , DistributionStockListEntity : : getStoreId , distributionStockListDTO . getStoreId ( ) )
) ;
//客户物资信息
DistributionStockListEntity one = this . getOne ( Wrappers . < DistributionStockListEntity > query ( ) . lambda ( )
. eq ( DistributionStockListEntity : : getId , distributionStockListDTO . getId ( ) )
/ * . eq ( DistributionStockListEntity : : getMarketId , distributionStockListDTO . getMarketId ( ) )
. eq ( ObjectUtil . isNotEmpty ( distributionStockListDTO . getStoreId ( ) ) , DistributionStockListEntity : : getStoreId , distributionStockListDTO . getStoreId ( ) )
. isNull ( DistributionStockListEntity : : getPid ) * /
) ;
if ( ObjectUtil . isNotEmpty ( one2 ) ) {
//有修改
DistributionStockListEntity d = new DistributionStockListEntity ( ) ;
d . setId ( one2 . getId ( ) ) ;
int i = one2 . getQuantityStock ( ) + distributionStockListDTO . getStoreNum ( ) ;
d . setQuantityStock ( i ) ;
this . updateById ( d ) ;
} else {
//没有新增
DistributionStockListEntity distributionStockListEntity = new DistributionStockListEntity ( ) ;
BeanUtils . copyProperties ( one , distributionStockListEntity ) ;
distributionStockListEntity . setPid ( one . getId ( ) ) ;
distributionStockListEntity . setSku ( distributionStockListDTO . getSku ( ) ) ;
distributionStockListEntity . setQuantityStock ( distributionStockListDTO . getStoreNum ( ) ) ;
distributionStockListEntity . setUnpackingQuantity ( 0 ) ;
distributionStockListEntity . setId ( null ) ;
this . save ( distributionStockListEntity ) ;
}
//修改客户物资记录
DistributionStockListEntity distributionStockListEntity = new DistributionStockListEntity ( ) ;
distributionStockListEntity . setId ( one . getId ( ) ) ;
distributionStockListEntity . setQuantityStock ( one . getQuantityStock ( ) - distributionStockListDTO . getUnpackingQuantity ( ) ) ;
distributionStockListEntity . setUnpackingQuantity ( distributionStockListDTO . getUnpackingQuantity ( ) ) ;
baseMapper . updateById ( distributionStockListEntity ) ;
//添加拆包记录
DistributionUnpackingDetailsEntity distributionUnpackingDetails = new DistributionUnpackingDetailsEntity ( ) ;
distributionUnpackingDetails . setStockArticleId ( Optional . ofNullable ( one . getStockArticleId ( ) ) . orElse ( null ) ) ;
distributionUnpackingDetails . setOrderSelfNumber ( Optional . ofNullable ( one . getOrderSelfNumbering ( ) ) . 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 ) ) ;
distributionUnpackingDetailsService . save ( distributionUnpackingDetails ) ;
return true ;
}
@ -211,4 +217,12 @@ public class DistributionStockListServiceImpl extends BaseServiceImpl<Distributi
return this . save ( distributionStockList ) ;
}
@Override
public IPage < DistributionStockListVO > pageOwn ( IPage < Object > page , Map < String , Object > distributionStockList ) {
DistributionStockListEntity distributionStockListEntity = JSONObject . parseObject ( JSONObject . toJSONString ( distributionStockList ) , DistributionStockListEntity . class ) ;
IPage < DistributionStockListVO > page1 = baseMapper . pageOwn ( page , distributionStockListEntity ) ;
return page1 ;
}
}