@ -16,6 +16,7 @@
* /
package com.logpm.warehouse.service.impl ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.Wrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
@ -43,6 +44,8 @@ import com.logpm.warehouse.service.*;
import com.logpm.warehouse.vo.* ;
import lombok.AllArgsConstructor ;
import lombok.extern.log4j.Log4j2 ;
import org.springblade.common.constant.common.IsOrNoConstant ;
import org.springblade.common.constant.orderpackage.OrderPackageStatusConstant ;
import org.springblade.common.exception.CustomerException ;
import org.springblade.common.utils.CommonUtil ;
import org.springblade.core.mp.base.BaseServiceImpl ;
@ -54,6 +57,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat ;
import java.util.* ;
import java.util.concurrent.atomic.AtomicInteger ;
import java.util.function.Function ;
import java.util.concurrent.atomic.AtomicReference ;
import java.util.stream.Collectors ;
@ -94,6 +99,7 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
@Override
public IPage < TaskQuestVO > selectTaskQuestPage ( IPage < TaskQuestVO > page , TaskQuestVO taskQuest ) {
//获取当前登录人仓库
@ -222,7 +228,21 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
public IPage < TaskContractVO > selectcontractList ( IPage < TaskContractVO > page , TaskSearchDTO taskSearchDTO ) {
List < Long > collect = this . getmyWarehouseList ( ) ;
baseMapper . setSqlMode ( ) ;
String goodsType = taskSearchDTO . getGoodsType ( ) ;
switch ( goodsType ) {
case "1" :
//订制品
List < TaskContractVO > list = baseMapper . selectcontractList ( page , taskSearchDTO , collect ) ;
break ;
case "2" :
//零担
break ;
case "3" :
//库存品
break ;
}
List < TaskContractVO > list = baseMapper . selectcontractList ( page , taskSearchDTO , collect ) ;
if ( ! list . isEmpty ( ) ) {
for ( TaskContractVO taskContractVO : list ) {
Long orderId = taskContractVO . getOrderId ( ) ;
@ -305,6 +325,7 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
}
/ * *
* 出来托盘信息
* @return
@ -953,6 +974,138 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
}
@Override
@Transactional
public R queryContract ( TaskSearchDTO taskSearchDTO ) {
String goodsType = taskSearchDTO . getGoodsType ( ) ;
Integer type = taskSearchDTO . getType ( ) ;
if ( type = = 1 ) {
String code = taskSearchDTO . getCode ( ) ;
if ( Func . isEmpty ( code ) ) {
log . error ( "####################订单合同号为空" ) ;
return Resp . scanFail ( "操作失败" , "请填写正确合同号" ) ;
}
//查询包件 赋予到订单上
List < DistributionParcelListEntity > entityListByOrderCode = distributionParcelListClient . findEntityListByOrderCode ( taskSearchDTO . getCode ( ) , taskSearchDTO . getWarehouseId ( ) ) ;
if ( Func . isNotEmpty ( entityListByOrderCode ) ) {
DistributionParcelListEntity parcelListEntity = entityListByOrderCode . get ( 0 ) ;
taskSearchDTO . setCode ( parcelListEntity . getOrderCode ( ) ) ;
}
}
String incomingBatch = taskSearchDTO . getIncomingBatch ( ) ;
if ( Func . isEmpty ( incomingBatch ) ) {
log . error ( "####################订单合同号为空" ) ;
return Resp . scanFail ( "操作失败" , "请输入正确合同号" ) ;
}
Long taskQuestId = taskSearchDTO . getTaskId ( ) ;
verifyTask ( taskQuestId , taskSearchDTO . getWarehouseId ( ) ) ;
List < TaskQuestChildEntity > taskQuestChildEntityList = taskQuestChildService . list ( Wrappers . < TaskQuestChildEntity > query ( ) . lambda ( )
. eq ( TaskQuestChildEntity : : getQuestId , taskQuestId )
. eq ( TaskQuestChildEntity : : getRefType , 1 ) ) ;
DistributionStockArticleEntity stockArticleEntity = null ;
AtomicInteger libNum = new AtomicInteger ( ) ;
List < String > marketNames = null ;
if ( Func . isEmpty ( taskQuestId ) ) {
//全仓盘点
stockArticleEntity = distributionStockArticleClient . findStockArticleByOrderCodeAndWarehouseId ( incomingBatch , taskSearchDTO . getWarehouseId ( ) ) ;
} else {
if ( Func . isNotEmpty ( taskQuestChildEntityList ) ) {
marketNames = taskQuestChildEntityList . stream ( ) . map ( TaskQuestChildEntity : : getRefName ) . collect ( Collectors . toList ( ) ) ;
stockArticleEntity = distributionStockArticleClient . findStockArticleByCodeAndMarketAndWarehouseId ( taskSearchDTO . getCode ( ) , marketNames , taskSearchDTO . getWarehouseId ( ) ) ;
} else {
log . error ( "###################盘点任务查询失败" ) ;
}
}
switch ( goodsType ) {
case "1" :
if ( Func . isEmpty ( stockArticleEntity ) ) {
log . error ( "###################此订单不属于该次盘点任务" ) ;
return Resp . scanFail ( "操作失败" , "不属于该任务" ) ;
}
DistributionParcelListEntity parcelListEntity = new DistributionParcelListEntity ( ) ;
parcelListEntity . setStockArticleId ( stockArticleEntity . getId ( ) ) ;
List < DistributionParcelListEntity > parcelList = distributionParcelListClient . getParcelList ( parcelListEntity ) ;
if ( Func . isEmpty ( parcelList ) ) {
log . error ( "###################查询订单包件错误,订单ID:{}" , stockArticleEntity . getId ( ) ) ;
}
if ( stockArticleEntity . getIsZero ( ) . equals ( IsOrNoConstant . no . getValue ( ) ) ) {
parcelList . forEach ( p - > {
QuestDetailEntity questDetailEntity = new QuestDetailEntity ( ) ;
if ( ! p . getOrderPackageStatus ( ) . equals ( OrderPackageStatusConstant . yichuku . getValue ( ) ) & & ! p . getOrderPackageStatus ( ) . equals ( OrderPackageStatusConstant . yiqianshou . getValue ( ) ) ) {
WarehouseTrayEntity warehouseTrayEntity = baseMapper . selectTratInfo ( p . getId ( ) , taskSearchDTO . getWarehouseId ( ) ) ;
WarehouseUpdownGoodsEntity updownGoodsPack = getUpdownGoodsPack ( p . getId ( ) , "3" , p . getOrderPackageCode ( ) , taskSearchDTO . getWarehouseId ( ) ) ;
if ( Func . isNotEmpty ( warehouseTrayEntity ) ) {
questDetailEntity . setTrayCode ( warehouseTrayEntity . getPalletCode ( ) ) ;
questDetailEntity . setTrayId ( warehouseTrayEntity . getId ( ) ) ;
}
if ( Func . isNotEmpty ( updownGoodsPack ) ) {
questDetailEntity . setAllocationId ( updownGoodsPack . getId ( ) ) ;
}
questDetailEntity . setOrdePackageCode ( p . getOrderPackageCode ( ) ) ;
questDetailEntity . setOrderCode ( p . getOrderCode ( ) ) ;
questDetailEntity . setOrderId ( p . getStockArticleId ( ) ) ;
libNum . getAndAdd ( p . getQuantity ( ) ) ;
questDetailEntity . setIsNew ( 0 ) ;
questDetailEntity . setQuestId ( taskQuestId ) ;
questDetailEntity . setQuestStatus ( 0 ) ;
questDetailEntity . setQuestTarget ( 1 ) ;
questDetailEntity . setQuestType ( 3 ) ;
questDetailService . save ( questDetailEntity ) ;
}
} ) ;
} else {
QuestDetailEntity questDetailEntity = new QuestDetailEntity ( ) ;
DistributionStockArticleEntity stockArticleInfo = getStockArticleInfo ( stockArticleEntity . getId ( ) ) ;
WarehouseUpdownGoodsEntity updownGoodsPack = getUpdownGoodsPack ( stockArticleInfo . getId ( ) , "1" , stockArticleInfo . getOrderCode ( ) , taskSearchDTO . getWarehouseId ( ) ) ;
List < WarehouseTrayEntity > warehouseTrayEntities = baseMapper . selectZeroOrderTratInfo ( stockArticleInfo . getId ( ) , taskSearchDTO . getWarehouseId ( ) ) ;
if ( Func . isNotEmpty ( warehouseTrayEntities ) ) {
List < String > strings = warehouseTrayEntities . stream ( ) . map ( WarehouseTrayEntity : : getPalletCode ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
questDetailEntity . setTrayCode ( String . join ( "," , strings ) ) ;
}
if ( Func . isNotEmpty ( updownGoodsPack ) ) {
questDetailEntity . setAllocationId ( updownGoodsPack . getId ( ) ) ;
}
questDetailEntity . setOrderCode ( stockArticleInfo . getOrderCode ( ) ) ;
libNum . getAndAdd ( stockArticleInfo . getHandQuantity ( ) ) ;
questDetailEntity . setIsNew ( 0 ) ;
questDetailEntity . setQuestId ( taskQuestId ) ;
questDetailEntity . setQuestStatus ( 0 ) ;
questDetailEntity . setQuestTarget ( 1 ) ;
questDetailEntity . setQuestType ( 3 ) ;
questDetailService . save ( questDetailEntity ) ;
}
break ;
case "2" :
//库存品
List < DistributionStockListEntity > stockListByWarehouseIdAndMarketAndStockListInfo = distributionStockListClient . getStockListByWarehouseIdAndMarketAndStockListInfo ( incomingBatch , marketNames , taskSearchDTO . getWarehouseId ( ) ) ;
stockListByWarehouseIdAndMarketAndStockListInfo . forEach ( s - > {
QuestDetailEntity questDetailEntity = new QuestDetailEntity ( ) ;
questDetailEntity . setOrderCode ( s . getOrderCode ( ) ) ;
questDetailEntity . setIsNew ( 0 ) ;
questDetailEntity . setQuestId ( taskQuestId ) ;
questDetailEntity . setQuestStatus ( 0 ) ;
questDetailEntity . setQuestTarget ( 1 ) ;
questDetailEntity . setQuestType ( 3 ) ;
libNum . getAndAdd ( s . getQuantityStock ( ) - s . getOutboundQuantity ( ) ) ;
questDetailEntity . setStockId ( s . getId ( ) ) ;
questDetailService . save ( questDetailEntity ) ;
} ) ;
break ;
default :
log . error ( "####################缺少货物类型字段" ) ;
break ;
}
TaskContractVO taskContractVO = new TaskContractVO ( ) ;
taskContractVO . setTotal ( stockArticleEntity . getTotalNumber ( ) ) ;
taskContractVO . setOrderId ( stockArticleEntity . getId ( ) ) ;
taskContractVO . setUnTotal ( 0 ) ;
taskContractVO . setZktotal ( libNum . get ( ) ) ;
return R . data ( taskContractVO ) ;
}
private String getQuestNum ( String warehouseCode ) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( "yyyyMMddHHmmss" ) ;
return "PDRW-" + warehouseCode + "-" + simpleDateFormat . format ( new Date ( ) ) + new Random ( ) . nextInt ( 900 ) + 100 ;