@ -18,6 +18,7 @@ package com.logpm.distribution.appcontroller;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
@ -28,9 +29,12 @@ import com.logpm.basicdata.feign.IBasicdataTrayClient;
import com.logpm.distribution.bean.Resp ;
import com.logpm.distribution.config.RedissonConfig ;
import com.logpm.distribution.dto.app.StockConfigInfoVO ;
import com.logpm.distribution.dto.app.StockConfigOrderPackageListVO ;
import com.logpm.distribution.dto.app.StockupDTO ;
import com.logpm.distribution.dto.app.StockupZeroDTO ;
import com.logpm.distribution.entity.* ;
import com.logpm.distribution.mapper.DistributionReservationStocklistMapper ;
import com.logpm.distribution.service.* ;
import com.logpm.distribution.vo.* ;
import com.logpm.warehouse.entity.WarehouseUpdownGoodsEntity ;
@ -39,10 +43,13 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation ;
import lombok.AllArgsConstructor ;
import lombok.extern.log4j.Log4j2 ;
import org.jetbrains.annotations.NotNull ;
import org.jetbrains.annotations.Nullable ;
import org.redisson.api.RLock ;
import org.springblade.common.constant.DictBizConstant ;
import org.springblade.common.constant.RabbitConstant ;
import org.springblade.common.constant.pda.PdaAudioLingoStatus ;
import org.springblade.common.constant.reservation.ReservationOrderStatusConstant ;
import org.springblade.common.constant.stockup.StockupStatusConstant ;
import org.springblade.common.constant.stockup.StockupTypeStatusConstant ;
import org.springblade.common.utils.CommonUtil ;
@ -51,14 +58,17 @@ import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.redis.cache.BladeRedis ;
import org.springblade.core.secure.utils.AuthUtil ;
import org.springblade.core.tool.api.R ;
import org.springblade.core.tool.utils.Func ;
import org.springblade.core.tool.utils.StringUtil ;
import org.springblade.system.cache.DictBizCache ;
import org.springframework.amqp.rabbit.core.RabbitTemplate ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.jdbc.datasource.DataSourceTransactionManager ;
import org.springframework.transaction.TransactionDefinition ;
import org.springframework.web.bind.annotation.* ;
import java.lang.reflect.Field ;
import java.text.SimpleDateFormat ;
import java.util.* ;
import java.util.concurrent.TimeUnit ;
import java.util.stream.Collectors ;
@ -90,15 +100,21 @@ public class DistributionStockupAppController extends BladeController {
private final IWarehouseUpdownGoodsClient warehouseUpdownGoodsClient ;
private final IWarehouseUpdownGoodsLogClient warehouseUpdownGoodsLogClient ;
private final IWarehouseGoodsAllocationClient warehouseGoodsAllocationClient ;
private IWarehouseUpdownTypeClient warehouseUpdownTypeClient ;
private IDistributionAsyncService distributionAsyncService ;
private final IWarehouseUpdownTypeClient warehouseUpdownTypeClient ;
private final IDistributionAsyncService distributionAsyncService ;
private final IDistributionDeliveryDetailsService distributionDeliveryDetailsService ;
private final RabbitTemplate rabbitTemplate ;
private final BladeRedis bladeRedis ;
private final IDistributionStockListService iDistributionStockListService ;
private DataSourceTransactionManager dataSourceTransactionManager ;
private TransactionDefinition transactionDefinition ;
private final DataSourceTransactionManager dataSourceTransactionManager ;
private final TransactionDefinition transactionDefinition ;
private final IDistributionStockListService distributionStockListService ;
private final IDisStockOrdercodeRecoService disStockOrdercodeRecoService ;
/ * *
* 备货信息表 任务客户 分页列表
@ -248,6 +264,8 @@ public class DistributionStockupAppController extends BladeController {
if ( orderStatus . equals ( 1 ) ) {
//查询客户订单对应的
List < DistributionStockupOrderListVO > list = distributionStockupService . selectStockupOrderList ( stockupDTO ) ;
//根据list列表统计计划件数
Integer planNum = 0 ;
Integer scanNum = 0 ;
@ -273,6 +291,8 @@ public class DistributionStockupAppController extends BladeController {
map . put ( "scanNum" , scanNum ) ;
map . put ( "orderList" , list ) ;
} else if ( orderStatus . equals ( 2 ) ) {
//查询客户订单对应的库存品
List < DistributionStockupStockListVO > list = distributionStockupService . selectStockupStockList ( stockupDTO ) ;
//根据list列表统计计划件数
@ -281,8 +301,9 @@ public class DistributionStockupAppController extends BladeController {
for ( DistributionStockupStockListVO vo : list ) {
planNum = planNum + vo . getPlanNum ( ) ;
scanNum = scanNum + vo . getRealNum ( ) ;
Boolean aBoolean = distributionStockupService . getClientStockupTray ( reservationId , vo . getAllocationId ( ) ) ;
vo . setTrayLean ( aBoolean ) ;
// 库存品 没有整托备货的概念
// Boolean aBoolean = distributionStockupService.getClientStockupTray(reservationId, vo.getAllocationId());
// vo.setTrayLean(aBoolean);
}
map . put ( "planNum" , planNum ) ;
map . put ( "scanNum" , scanNum ) ;
@ -296,6 +317,21 @@ public class DistributionStockupAppController extends BladeController {
}
@ResponseBody
@PostMapping ( "/stockConfigList" )
@ApiOperationSupport ( order = 1 )
@ApiOperation ( value = "配置包条码" , notes = "传入stockupDTO" )
public R stockConfigList ( @RequestBody StockupDTO stockupDTO ) {
StockConfigInfoVO stockConfigOrderPackageListVOS = distributionStockupService . stockConfigList ( stockupDTO ) ;
return R . data ( stockConfigOrderPackageListVOS ) ;
}
@ResponseBody
@PostMapping ( "/orderInfo" )
@ApiOperationSupport ( order = 1 )
@ -363,6 +399,7 @@ public class DistributionStockupAppController extends BladeController {
return R . data ( infoVO ) ;
} else {
DistributionStockupStockListInfoVO infoVO = distributionStockupService . selectStockListInfo ( reservationId , stockListId , allocationId ) ;
// DistributionStockupStockListInfoVO infoVO = distributionStockupService.selectStockListInfoByCargoNumber(reservationId, stockupDTO.getCargoNumber(), allocationId);
return R . data ( infoVO ) ;
}
@ -379,17 +416,22 @@ public class DistributionStockupAppController extends BladeController {
@ApiOperation ( value = "备货库存品生成包件码" , notes = "传入stockupDTO" )
public R stockupStockListPackageCode ( @RequestBody StockupDTO stockupDTO ) {
Long reservationId = stockupDTO . getReservationId ( ) ; //预约单id
Long stockListId = stockupDTO . getStockListId ( ) ; //库存品id
// 根据当前库位获取最早入库的入库批次
Long stockListId = distributionStockupService . selectStockListInfoByCargoNumber ( stockupDTO . getReservationId ( ) , stockupDTO . getCargoNumber ( ) , stockupDTO . getAllocationId ( ) ) ;
log . warn ( "##############stockupStockListPackageCode: 库存品id为空 stockListId={}" , stockListId ) ;
if ( Objects . isNull ( stockListId ) ) {
return R . fail ( "当前库位没有无数据的库存品" ) ;
}
Integer packageNum = stockupDTO . getPackageNum ( ) ; //包条数量
//查询客户订单详情
log . warn ( "##############stockupStockListPackageCode: 预约单id为空 reservationId={}" , reservationId ) ;
if ( Objects . isNull ( reservationId ) ) {
return R . fail ( "预约单id不能为空" ) ;
}
log . warn ( "##############stockupStockListPackageCode: 库存品id为空 stockListId={}" , stockListId ) ;
if ( Objects . isNull ( stockListId ) ) {
return R . fail ( "库存品id不能为空" ) ;
}
log . warn ( "##############stockupStockListPackageCode: 包条数量为空 packageNum={}" , packageNum ) ;
if ( Objects . isNull ( packageNum ) ) {
return R . fail ( "包条数量不能为空" ) ;
@ -398,6 +440,7 @@ public class DistributionStockupAppController extends BladeController {
return R . data ( list ) ;
}
@PostMapping ( "/scanningCode" )
@ApiOperation ( value = "整托备货" )
public R scanningCodelist ( @RequestBody StockupDTO stockupDTO ) {
@ -475,25 +518,49 @@ public class DistributionStockupAppController extends BladeController {
//查询库存品信息
DistributionReservationStocklistEntity byId = distributionReservationStocklistService . getById ( stockupDTO . getDeliveryDetailsId ( ) ) ;
if ( ObjectUtils . isNotNull ( byId ) ) {
DistributionStockListEntity byId1 = iD istributionStockListService. getById ( byId . getStocklistId ( ) ) ;
DistributionStockListEntity byId1 = d istributionStockListService. getById ( byId . getStocklistId ( ) ) ;
if ( byId1 . getSourceType ( ) . equals ( "2" ) ) {
//导入
List < DistributionStockupTrayVO > list = distributionStockupService . getLocationSelection ( stockupDTO ) ; //自提
if ( ! list . isEmpty ( ) & & ObjectUtils . isNotNull ( list . get ( 0 ) ) ) {
SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ;
list . stream ( ) . forEach ( i - > {
if ( ObjectUtils . isNotNull ( i . getCreateTime ( ) ) ) {
i . setWarehousingTime ( format . format ( i . getCreateTime ( ) ) ) ;
}
} ) ;
return R . data ( list ) ;
}
List < DistributionStockupTrayVO > listMarket = distributionStockupService . getLocationMarketSelection ( stockupDTO ) ; //商配
if ( ! listMarket . isEmpty ( ) & & ObjectUtils . isNotNull ( listMarket . get ( 0 ) ) ) {
SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ;
list . stream ( ) . forEach ( i - > {
if ( ObjectUtils . isNotNull ( i . getCreateTime ( ) ) ) {
i . setWarehousingTime ( format . format ( i . getCreateTime ( ) ) ) ;
}
} ) ;
return R . data ( listMarket ) ;
}
} else {
//订单
List < DistributionStockupTrayVO > list = distributionStockupService . getLocationSelectionOrder ( stockupDTO ) ; //自提
if ( ! list . isEmpty ( ) & & ObjectUtils . isNotNull ( list . get ( 0 ) ) ) {
SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ;
list . stream ( ) . forEach ( i - > {
if ( ObjectUtils . isNotNull ( i . getCreateTime ( ) ) ) {
i . setWarehousingTime ( format . format ( i . getCreateTime ( ) ) ) ;
}
} ) ;
return R . data ( list ) ;
}
List < DistributionStockupTrayVO > listMarket = distributionStockupService . getLocationMarketSelectionOrder ( stockupDTO ) ; //商配
if ( ! listMarket . isEmpty ( ) & & ObjectUtils . isNotNull ( listMarket . get ( 0 ) ) ) {
SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ;
list . stream ( ) . forEach ( i - > {
if ( ObjectUtils . isNotNull ( i . getCreateTime ( ) ) ) {
i . setWarehousingTime ( format . format ( i . getCreateTime ( ) ) ) ;
}
} ) ;
return R . data ( listMarket ) ;
}
@ -505,7 +572,6 @@ public class DistributionStockupAppController extends BladeController {
}
@PutMapping ( "/updateStockArea" )
@ApiOperation ( value = "修改备货区" )
public R updateStockArea ( @RequestBody StockupDTO stockupDTO ) {
@ -541,7 +607,6 @@ public class DistributionStockupAppController extends BladeController {
}
@PostMapping ( "/getStockupArea" )
@ApiOperation ( value = "查询可修改备货区" )
public R getGoodsArea ( @RequestBody StockupDTO stockupDTO ) {
@ -560,6 +625,123 @@ public class DistributionStockupAppController extends BladeController {
}
@ResponseBody
@PostMapping ( "/stockupScanCheck" )
@ApiOperationSupport ( order = 1 )
@ApiOperation ( value = "备货扫描检查" , notes = "传入stockupDTO" )
public R stockupScanCheck ( @RequestBody StockupDTO stockupDTO ) {
Integer scanType = stockupDTO . getScanType ( ) ; //扫码类型
if ( scanType = = 2 ) {
//库存品扫描
Long stockListId = stockupDTO . getStockListId ( ) ;
String packetBarCode = stockupDTO . getPacketBarCode ( ) ;
String orderCode = stockupDTO . getOrderCode ( ) ; //订单自编号
Long stockupId = stockupDTO . getStockupId ( ) ; //备货任务ID
Long reservationId = stockupDTO . getReservationId ( ) ; //预约单id
//判断是否可以继续备货
DistributionStockListEntity distributionStockListEntities = distributionStockupService . selectStockListInfoByCargoNumberList ( stockupDTO . getReservationId ( ) , stockupDTO . getCargoNumber ( ) , stockupDTO . getAllocationId ( ) , stockupDTO . getPacketBarCode ( ) ) ;
if ( ObjectUtils . isNull ( distributionStockListEntities ) ) {
return R . data ( 60003 , "" , "该包件还不是库存品!" ) ;
}
// 通过当前预约单和货物定位当前计划的库存品批次
List < DistributionStockListEntity > planDistributionStockListEntities = getPlanDistributionStockListEntities ( stockupDTO ) ;
//是否更新计划
boolean isUpdate = false ;
Long updateStockListId = null ;
// 验证当前货位的货位和计划批次是否相同
for ( DistributionStockListEntity planDistributionStockListEntity : planDistributionStockListEntities ) {
if ( planDistributionStockListEntity . getSourceType ( ) . equals ( "2" ) ) {
if ( planDistributionStockListEntity . getOrderCode ( ) . equals ( distributionStockListEntities . getIncomingBatch ( ) ) ) {
isUpdate = true ;
updateStockListId = distributionStockListEntities . getId ( ) ;
break ;
}
}
}
if ( isUpdate ) {
return R . data ( 60002 , updateStockListId , "当前包件批次号与入库批次号不符,是否确认修改计划批次" ) ;
}
}
return R . data ( 200 , "" , "扫描成功!" ) ;
}
/ * *
* 获取计划中库存品
* @param stockupDTO
* @return
* /
private List < DistributionStockListEntity > getPlanDistributionStockListEntities ( StockupDTO stockupDTO ) {
LambdaQueryWrapper < DistributionReservationStocklistEntity > lambdaQueryWrapper = new LambdaQueryWrapper ( ) ;
lambdaQueryWrapper . eq ( DistributionReservationStocklistEntity : : getReservationId , stockupDTO . getReservationId ( ) ) ;
lambdaQueryWrapper . eq ( DistributionReservationStocklistEntity : : getStockListStatus , 1 ) ;
List < DistributionReservationStocklistEntity > list1 = distributionReservationStocklistService . list ( lambdaQueryWrapper ) ;
// 通过计划的上的库存品id 查询库存品信息
List < Long > collect = list1 . stream ( ) . map ( DistributionReservationStocklistEntity : : getStocklistId ) . collect ( Collectors . toList ( ) ) ;
List < DistributionStockListEntity > planDistributionStockListEntities = distributionStockListService . listByIds ( collect ) ;
return planDistributionStockListEntities ;
}
//todo 这里代码没有写完 等TJJ 和CYZ 空了来写
// 修改预约备货信息 需要传入修改的包条
public R updateStockup ( @RequestBody StockupDTO stockupDTO ) {
// 增加实际扫描的包件对应的库存品信息 增加在预约库存品中间表上
DistributionReservationStocklistEntity reservationStocklistEntity = new DistributionReservationStocklistEntity ( ) ;
reservationStocklistEntity . setReservationId ( stockupDTO . getReservationId ( ) ) ;
reservationStocklistEntity . setReservationNum ( 0 ) ;
reservationStocklistEntity . setLoadingStatus ( "10" ) ;
reservationStocklistEntity . setSigningStatus ( "10" ) ;
reservationStocklistEntity . setStockListStatus ( "3" ) ;
DistributionStockListEntity stockListEntity = distributionStockListService . getById ( stockupDTO . getStockListId ( ) ) ;
if ( ObjectUtils . isNotNull ( stockListEntity ) ) {
reservationStocklistEntity . setStocklistId ( stockListEntity . getId ( ) ) ;
reservationStocklistEntity . setUnit ( stockListEntity . getCargoUnit ( ) ) ;
reservationStocklistEntity . setRealityNum ( 0 ) ;
}
// 这里需要对原来的预约库存信息进行取消
distributionReservationStocklistService . save ( reservationStocklistEntity ) ;
// 默认 计划数量和实际数量为0
return R . fail ( "操作成功" ) ;
//查询出原来的库存品信息
// DistributionReservationStocklistEntity reservationStocklist = distributionReservationStocklistService.getOne(Wrappers.<DistributionReservationStocklistEntity>query().lambda()
// .eq(DistributionReservationStocklistEntity::getReservationId, stockupDTO.getReservationId())
// .eq(DistributionReservationStocklistEntity::getStocklistId, stockupDTO.getStockListId())
// .ne(DistributionReservationStocklistEntity::getStockListStatus, ReservationOrderStatusConstant.quxiao.getValue())
// );
// 再次执行扫描 读取这预约计划下面正常的库存品信息 扣减数量 对新增的预约库存品信息进行增加预约数量和实际数量
// 修改logpm_dis_stock_list_detail 这张表上的库存品ID和包件ID
}
@ResponseBody
@PostMapping ( "/stockupScan" )
@ApiOperationSupport ( order = 1 )
@ -578,127 +760,27 @@ public class DistributionStockupAppController extends BladeController {
}
lock . lock ( 5 , TimeUnit . SECONDS ) ;
if ( scanType = = 1 ) {
//包件扫描
String orderCode = stockupDTO . getOrderCode ( ) ; //订单自编号
String packetBarCode = stockupDTO . getPacketBarCode ( ) ; //包件码
Long stockupId = stockupDTO . getStockupId ( ) ; //备货任务ID
Long reservationId = stockupDTO . getReservationId ( ) ; //预约单id
if ( StringUtil . isBlank ( orderCode ) ) {
log . warn ( "##################stockupScan: 包件扫码,订单自编号为空" ) ;
return R . fail ( "包件扫码:订单自编号不能为空" ) ;
}
if ( StringUtil . isBlank ( packetBarCode ) ) {
log . warn ( "##################stockupScan: 包件扫码,包件码为空" ) ;
return R . fail ( "包件扫码:包件码不能为空" ) ;
}
if ( ObjectUtils . isNull ( stockupId ) ) {
log . warn ( "##################stockupId: 包件扫码,备货区为空" ) ;
return R . fail ( "包件扫码:备货任务ID不能为空" ) ;
}
if ( Objects . isNull ( reservationId ) ) {
log . warn ( "##################stockupScan: 包件扫码,预约单id为空" ) ;
return R . fail ( "包件扫码:预约单id不能为空" ) ;
}
return stockupScanByCustom ( stockupDTO ) ;
Integer integer = distributionStockupService . selectPackage ( stockupDTO ) ;
switch ( integer ) {
case 1 :
DistributionStockupEntity distributionStockupEntity = distributionStockupService . getById ( stockupDTO . getStockupId ( ) ) ;
//正常
//先保存扫码包件信息,后续由队列来出来余下补充信息
DistributionStockEntity entity = new DistributionStockEntity ( ) ;
DistributionParcelListEntity one = distributionParcelListService . getOne ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( )
. eq ( DistributionParcelListEntity : : getOrderPackageCode , stockupDTO . getPacketBarCode ( ) )
) ;
entity . setOrderSelfNumbering ( one . getOrderCode ( ) ) ;
entity . setStockArticle ( one . getStockArticleId ( ) ) ;
entity . setCoding ( packetBarCode ) ;
// entity.setStockupArea(stockupArea);
entity . setStockupId ( stockupId ) ;
entity . setParcelListId ( one . getId ( ) ) ;
entity . setStockQuantity ( 1 ) ;
if ( distributionStockupEntity . getTypeService ( ) . equals ( "3" ) ) {
entity . setBillLadingId ( reservationId ) ;
DistributionStockupEntity byId = distributionStockupService . getById ( stockupId ) ;
entity . setStockupArea ( byId . getStockupArea ( ) ) ;
} else if ( scanType = = 2 ) {
R fail = stockupScanByStock ( stockupDTO ) ;
if ( fail ! = null ) return fail ;
//修改包件备货状态
one . setOrderPackageStockupStatus ( StockupStatusConstant . yibeihuo . getValue ( ) ) ;
//todo 待下架操作
// warehouseUpdownTypeClient.downPackage(stockupDTO.getPacketBarCode());
distributionParcelListService . updateById ( one ) ;
} else {
entity . setReservationId ( reservationId ) ;
}
if ( ObjectUtils . isNotNull ( stockupDTO . getAllocationId ( ) ) ) {
// warehouseUpdownGoodsClient.selectMsgBywrap();
WarehouseUpdownGoodsEntity warehouseUpdownGoodsEntity = new WarehouseUpdownGoodsEntity ( ) ;
warehouseUpdownGoodsEntity . setAllocationId ( stockupDTO . getAllocationId ( ) ) ;
warehouseUpdownGoodsEntity . setAssociationValue ( stockupDTO . getPacketBarCode ( ) ) ;
warehouseUpdownGoodsEntity . setWarehouseId ( distributionStockupEntity . getWarehouseId ( ) ) ;
WarehouseUpdownGoodsEntity locationInformation = warehouseUpdownGoodsClient . getLocationInformation ( warehouseUpdownGoodsEntity ) ;
entity . setAllocationTitle ( locationInformation . getPositionCode ( ) ) ;
entity . setAllocationId ( stockupDTO . getAllocationId ( ) ) ;
}
entity . setConditions ( "0" ) ;
entity . setType ( 2 ) ;
entity . setOutboundType ( distributionStockupEntity . getTypeService ( ) ) ;
distributionStockService . save ( entity ) ;
//修改订单备货状态
distributionAsyncService . updateStockArticleStock ( one . getStockArticleId ( ) ) ;
// dataSourceTransactionManager.commit(transactionStatus);//提交
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "messageId" , CommonUtil . getUUID ( ) ) ;
map . put ( "scanType" , scanType ) ;
map . put ( "stockupId" , stockupDTO . getStockupId ( ) ) ;
map . put ( "logId" , entity . getId ( ) ) ;
map . put ( "messageData" , entity ) ;
map . put ( "createTime" , new Date ( ) . getTime ( ) ) ;
//将消息携带绑定键值
rabbitTemplate . convertAndSend ( RabbitConstant . STOCKUP_SCAN_EXCHANGE , RabbitConstant . STOCKUP_SCAN_ROUTING , map ) ;
//查询是否货位数据是否该下架
Map < String , Object > mapState = new HashMap < > ( ) ;
mapState . put ( "messageId" , CommonUtil . getUUID ( ) ) ;
mapState . put ( "scanType" , scanType ) ;
mapState . put ( "stockupId" , stockupDTO . getStockupId ( ) ) ;
mapState . put ( "typeService" , stockupDTO . getTypeService ( ) ) ;
mapState . put ( "reservationId" , stockupDTO . getReservationId ( ) ) ;
mapState . put ( "logId" , entity . getId ( ) ) ;
mapState . put ( "messageData" , entity ) ;
mapState . put ( "createTime" , new Date ( ) . getTime ( ) ) ;
//将消息携带绑定键值
rabbitTemplate . convertAndSend ( RabbitConstant . STOCKUP_STATE_UPDATE_EXCHANGE , RabbitConstant . STOCKUP_STATE_UPDATE_ROUTING , mapState ) ;
log . warn ( "###################stockupScan: 未知的扫码类型 scanType={}" , scanType ) ;
return R . fail ( "未知的扫码类型" ) ;
String audioValue = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . saomiaochenggong . getValue ( ) ) ;
//查询是否货位数据是否该下架
// distributionAsyncService.stockupSelfOffShelf(stockupDTO);
return Resp . scanSuccess ( PdaAudioLingoStatus . saomiaochenggong . getName ( ) , audioValue ) ;
case 2 :
//重复扫描
String audioValue2 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . chongfusaomiao . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . chongfusaomiao . getName ( ) , audioValue2 ) ;
case 3 :
//包件不存在
String audioValue3 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . baotiaomabucunzai . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . baotiaomabucunzai . getName ( ) , audioValue3 ) ;
case 4 :
//操作失败
String audioValue4 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . caozuoshibai . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . caozuoshibai . getName ( ) , audioValue4 ) ;
case 5 :
//窜货
String audioValue5 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . buzai . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . buzai . getName ( ) , audioValue5 ) ;
default :
log . warn ( "###备货扫描:未知错误" ) ;
return Resp . scanFail ( PdaAudioLingoStatus . weizhicuowu . getName ( ) , PdaAudioLingoStatus . weizhicuowu . getName ( ) ) ;
}
} else if ( scanType = = 2 ) {
/ * *
* 库存品扫码
*
* @param stockupDTO
* @return
* /
@Nullable
private R stockupScanByStock ( StockupDTO stockupDTO ) {
//库存品扫描
Long reservationId = stockupDTO . getReservationId ( ) ;
Long stockListId = stockupDTO . getStockListId ( ) ;
@ -716,10 +798,10 @@ public class DistributionStockupAppController extends BladeController {
log . warn ( "##################stockupScan: 库存品扫码,备货区为空" ) ;
return R . fail ( "库存品扫码:备货任务ID不能为空" ) ;
}
if ( Objects . isNull ( stockListId ) ) {
log . warn ( "##################stockupScan: 库存品扫码,库存品id为空" ) ;
return R . fail ( "库存品扫码:库存品id不能为空" ) ;
}
// if (Objects.isNull(stockListId)) {
// log.warn( "##################stockupScan: 库存品扫码,库存品id为空");
// return R.fail("库存品扫码:库存品id不能为空");
// }
if ( Objects . isNull ( reservationId ) ) {
log . warn ( "##################stockupScan: 库存品扫码,预约单id为空" ) ;
return R . fail ( "库存品扫码:预约单id不能为空" ) ;
@ -733,7 +815,20 @@ public class DistributionStockupAppController extends BladeController {
return R . fail ( "货位ID不能为空" ) ;
}
//判断是否可以继续备货
DistributionStockListEntity byId = iDistributionStockListService . getById ( stockListId ) ;
DistributionStockListEntity byId = null ;
if ( ObjectUtils . isNull ( stockListId ) ) {
// 通过扫码的二维码 查询其对应的库存存信息
if ( stockupDTO . getStockPrint ( ) = = 1 ) {
byId = distributionStockListService . selectStockInforByOrderPackageCode ( stockupDTO . getPacketBarCode ( ) ) ;
} else {
byId = disStockOrdercodeRecoService . selectStockOrdercodeRecoListByCode ( stockupDTO . getPacketBarCode ( ) ) ;
}
stockupDTO . setStockListId ( byId . getId ( ) ) ;
} else {
byId = distributionStockListService . getById ( stockListId ) ;
}
List < WarehouseUpdownGoodsEntity > locationInformation ;
if ( byId . getSourceType ( ) . equals ( "2" ) ) {
//导入
@ -749,24 +844,33 @@ public class DistributionStockupAppController extends BladeController {
return Resp . scanFail ( "当前货位的库存品已为零,请更换货位继续!!" , "当前货位的库存品已为零,请更换货位继续!!" ) ;
}
} else {
//查询包件信息
// 读取码表上的配置项 是否开启验证批次号
String isCheckIncomingBatch = DictBizCache . getValue ( "isCheckIncomingBatch" , "isCheckIncomingBatch" ) ;
List < DistributionParcelListEntity > list = distributionParcelListService . list ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( )
. eq ( DistributionParcelListEntity : : getOrderPackageCode , packetBarCode )
. eq ( DistributionParcelListEntity : : getOrderCode , byId . getIncomingBatch ( ) )
. eq ( DistributionParcelListEntity : : getWarehouseId , byId . getWarehouseId ( ) )
) ;
//查询包件信息
if ( ObjectUtils . isNotNull ( list ) & & list . size ( ) > 1 ) {
return Resp . scanFail ( "查询到重复包条信息!!" , "查询到重复包条信息!!" ) ;
}
if ( ObjectUtils . isNull ( list ) ) {
return Resp . scanFail ( "没有查询到包件信息 ! " , "没有查询到包件信息 ! " ) ;
}
log . info ( ">>>>> obj {}" , list . get ( 0 ) . getConditions ( ) ) ;
DistributionParcelListEntity distributionParcelListEntity = list . get ( 0 ) ;
if ( 2 ! = distributionParcelListEntity . getConditions ( ) ) {
return Resp . scanFail ( "当前包件不是库存品,无法备货!!" , "当前包件不是库存品,无法备货!!" ) ;
}
WarehouseUpdownGoodsEntity warehouseUpdownGoodsEntity = new WarehouseUpdownGoodsEntity ( ) ;
warehouseUpdownGoodsEntity . setAllocationId ( stockupDTO . getAllocationId ( ) ) ;
warehouseUpdownGoodsEntity . setAssociationId ( list . get ( 0 ) . getId ( ) ) ;
@ -799,7 +903,7 @@ public class DistributionStockupAppController extends BladeController {
entity . setReservationId ( reservationId ) ;
}
entity . setReservationId ( reservationId ) ;
entity . setStockListId ( stockListId ) ;
entity . setStockListId ( stockupDTO . getStock ListId ( ) ) ;
//添加物料信息
// DistributionStockListEntity byId = iDistributionStockListService.getById(stockListId);
if ( ObjectUtils . isNotNull ( byId . getMarketId ( ) ) ) {
@ -846,18 +950,28 @@ public class DistributionStockupAppController extends BladeController {
}
entity . setConditions ( "0" ) ;
entity . setType ( 2 ) ;
entity . setAllocationId ( stockupDTO . getAllocationId ( ) ) ;
distributionStockService . save ( entity ) ;
// dataSourceTransactionManager.commit(transactionStatus);//提交
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "messageId" , CommonUtil . getUUID ( ) ) ;
map . put ( "scanType" , scanType ) ;
map . put ( "scanType" , stockupDTO . getS canType ( ) ) ;
map . put ( "logId" , entity . getId ( ) ) ;
map . put ( "messageData" , entity ) ;
map . put ( "createTime" , new Date ( ) . getTime ( ) ) ;
// 完成对扫描库存品信息的数量维护
// 根据当前扫码对象查询得到当前的扫码对象的库存品信息
//将消息携带绑定键值
rabbitTemplate . convertAndSend ( RabbitConstant . STOCKUP_SCAN_EXCHANGE , RabbitConstant . STOCKUP_SCAN_ROUTING , map ) ;
String audioValue = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . saomiaochenggong . getValue ( ) ) ;
//扫码成功
return Resp . scanSuccess ( PdaAudioLingoStatus . saomiaochenggong . getName ( ) , audioValue ) ;
case 2 :
@ -905,17 +1019,138 @@ public class DistributionStockupAppController extends BladeController {
//"没有待绑定的库存品信息!"
return Resp . scanFail ( "该包件与备货物料不匹配!" , "该包件与备货物料不匹配!" ) ;
}
return null ;
}
/ * *
* 扫描定制品信息
*
* @param stockupDTO
* @return
* /
@NotNull
private R stockupScanByCustom ( StockupDTO stockupDTO ) {
//包件扫描
String orderCode = stockupDTO . getOrderCode ( ) ; //订单自编号
String packetBarCode = stockupDTO . getPacketBarCode ( ) ; //包件码
Long stockupId = stockupDTO . getStockupId ( ) ; //备货任务ID
Long reservationId = stockupDTO . getReservationId ( ) ; //预约单id
if ( StringUtil . isBlank ( orderCode ) ) {
log . warn ( "##################stockupScan: 包件扫码,订单自编号为空" ) ;
return R . fail ( "包件扫码:订单自编号不能为空" ) ;
}
if ( StringUtil . isBlank ( packetBarCode ) ) {
log . warn ( "##################stockupScan: 包件扫码,包件码为空" ) ;
return R . fail ( "包件扫码:包件码不能为空" ) ;
}
if ( ObjectUtils . isNull ( stockupId ) ) {
log . warn ( "##################stockupId: 包件扫码,备货区为空" ) ;
return R . fail ( "包件扫码:备货任务ID不能为空" ) ;
}
if ( Objects . isNull ( reservationId ) ) {
log . warn ( "##################stockupScan: 包件扫码,预约单id为空" ) ;
return R . fail ( "包件扫码:预约单id不能为空" ) ;
}
Integer integer = distributionStockupService . selectPackage ( stockupDTO ) ;
switch ( integer ) {
case 1 :
DistributionStockupEntity distributionStockupEntity = distributionStockupService . getById ( stockupDTO . getStockupId ( ) ) ;
//正常
//先保存扫码包件信息,后续由队列来出来余下补充信息
DistributionStockEntity entity = new DistributionStockEntity ( ) ;
DistributionParcelListEntity one = distributionParcelListService . getOne ( Wrappers . < DistributionParcelListEntity > query ( ) . lambda ( )
. eq ( DistributionParcelListEntity : : getOrderPackageCode , stockupDTO . getPacketBarCode ( ) )
) ;
entity . setOrderSelfNumbering ( one . getOrderCode ( ) ) ;
entity . setStockArticle ( one . getStockArticleId ( ) ) ;
entity . setCoding ( packetBarCode ) ;
// entity.setStockupArea(stockupArea);
entity . setStockupId ( stockupId ) ;
entity . setParcelListId ( one . getId ( ) ) ;
entity . setStockQuantity ( 1 ) ;
if ( distributionStockupEntity . getTypeService ( ) . equals ( "3" ) ) {
entity . setBillLadingId ( reservationId ) ;
DistributionStockupEntity byId = distributionStockupService . getById ( stockupId ) ;
entity . setStockupArea ( byId . getStockupArea ( ) ) ;
//修改包件备货状态
one . setOrderPackageStockupStatus ( StockupStatusConstant . yibeihuo . getValue ( ) ) ;
//todo 待下架操作
// warehouseUpdownTypeClient.downPackage(stockupDTO.getPacketBarCode());
distributionParcelListService . updateById ( one ) ;
} else {
entity . setReservationId ( reservationId ) ;
}
// }catch (TransactionException e){
// e.printStackTrace();
// log.error("######:备货扫描",e.getMessage());
// dataSourceTransactionManager.rollback(transactionStatus);
// }
if ( ObjectUtils . isNotNull ( stockupDTO . getAllocationId ( ) ) ) {
// warehouseUpdownGoodsClient.selectMsgBywrap();
WarehouseUpdownGoodsEntity warehouseUpdownGoodsEntity = new WarehouseUpdownGoodsEntity ( ) ;
warehouseUpdownGoodsEntity . setAllocationId ( stockupDTO . getAllocationId ( ) ) ;
warehouseUpdownGoodsEntity . setAssociationValue ( stockupDTO . getPacketBarCode ( ) ) ;
warehouseUpdownGoodsEntity . setWarehouseId ( distributionStockupEntity . getWarehouseId ( ) ) ;
WarehouseUpdownGoodsEntity locationInformation = warehouseUpdownGoodsClient . getLocationInformation ( warehouseUpdownGoodsEntity ) ;
entity . setAllocationTitle ( locationInformation . getPositionCode ( ) ) ;
entity . setAllocationId ( stockupDTO . getAllocationId ( ) ) ;
}
entity . setConditions ( "0" ) ;
entity . setType ( 2 ) ;
entity . setOutboundType ( distributionStockupEntity . getTypeService ( ) ) ;
distributionStockService . save ( entity ) ;
//修改订单备货状态
distributionAsyncService . updateStockArticleStock ( one . getStockArticleId ( ) ) ;
// dataSourceTransactionManager.commit(transactionStatus);//提交
log . warn ( "###################stockupScan: 未知的扫码类型 scanType={}" , scanType ) ;
return R . fail ( "未知的扫码类型" ) ;
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "messageId" , CommonUtil . getUUID ( ) ) ;
map . put ( "scanType" , stockupDTO . getScanType ( ) ) ;
map . put ( "stockupId" , stockupDTO . getStockupId ( ) ) ;
map . put ( "logId" , entity . getId ( ) ) ;
map . put ( "messageData" , entity ) ;
map . put ( "createTime" , new Date ( ) . getTime ( ) ) ;
//将消息携带绑定键值
rabbitTemplate . convertAndSend ( RabbitConstant . STOCKUP_SCAN_EXCHANGE , RabbitConstant . STOCKUP_SCAN_ROUTING , map ) ;
//查询是否货位数据是否该下架
Map < String , Object > mapState = new HashMap < > ( ) ;
mapState . put ( "messageId" , CommonUtil . getUUID ( ) ) ;
mapState . put ( "scanType" , stockupDTO . getScanType ( ) ) ;
mapState . put ( "stockupId" , stockupDTO . getStockupId ( ) ) ;
mapState . put ( "typeService" , stockupDTO . getTypeService ( ) ) ;
mapState . put ( "reservationId" , stockupDTO . getReservationId ( ) ) ;
mapState . put ( "logId" , entity . getId ( ) ) ;
mapState . put ( "messageData" , entity ) ;
mapState . put ( "createTime" , new Date ( ) . getTime ( ) ) ;
//将消息携带绑定键值
rabbitTemplate . convertAndSend ( RabbitConstant . STOCKUP_STATE_UPDATE_EXCHANGE , RabbitConstant . STOCKUP_STATE_UPDATE_ROUTING , mapState ) ;
String audioValue = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . saomiaochenggong . getValue ( ) ) ;
//查询是否货位数据是否该下架
// distributionAsyncService.stockupSelfOffShelf(stockupDTO);
return Resp . scanSuccess ( PdaAudioLingoStatus . saomiaochenggong . getName ( ) , audioValue ) ;
case 2 :
//重复扫描
String audioValue2 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . chongfusaomiao . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . chongfusaomiao . getName ( ) , audioValue2 ) ;
case 3 :
//包件不存在
String audioValue3 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . baotiaomabucunzai . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . baotiaomabucunzai . getName ( ) , audioValue3 ) ;
case 4 :
//操作失败
String audioValue4 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . caozuoshibai . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . caozuoshibai . getName ( ) , audioValue4 ) ;
case 5 :
//窜货
String audioValue5 = DictBizCache . getValue ( DictBizConstant . PDA_AUDIO , PdaAudioLingoStatus . buzai . getValue ( ) ) ;
return Resp . scanFail ( PdaAudioLingoStatus . buzai . getName ( ) , audioValue5 ) ;
default :
log . warn ( "###备货扫描:未知错误" ) ;
return Resp . scanFail ( PdaAudioLingoStatus . weizhicuowu . getName ( ) , PdaAudioLingoStatus . weizhicuowu . getName ( ) ) ;
}
}