@@ -6,8 +6,8 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
@@ -93,16 +93,16 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
String is_used = ( String ) whereJson . get ( " is_used " ) ;
String is_have = ( String ) whereJson . get ( " is_have " ) ;
return structattrMapper . selectPage ( new Page < > ( page . getPage ( ) + 1 , page . getSize ( ) ) , new LambdaQueryWrapper < Structattr > ( )
. like ( StrUtil . isNotEmpty ( search ) , Structattr : : getStruct_code , search )
. like ( StrUtil . isNotEmpty ( search ) , Structattr : : getStruct_name , search )
. eq ( StrUtil . isNotEmpty ( stor_id ) , Structattr : : getStor_id , stor_id )
. eq ( StrUtil . isNotEmpty ( sect_id ) , Structattr : : getSect_id , sect_id )
. eq ( StrUtil . isNotEmpty ( lock_type ) , Structattr : : getLock_type , lock_type )
. eq ( StrUtil . isNotEmpty ( layer_num ) , Structattr : : getLayer_num , layer_num )
. eq ( StrUtil . isNotEmpty ( is_used ) , Structattr : : getIs_used , is_used )
. isNull ( " 1 " . equals ( is_have ) , Structattr : : getStoragevehicle_code )
. isNotNull ( " 2 " . equals ( is_have ) , Structattr : : getStoragevehicle_code )
return structattrMapper . selectPage ( new Page < > ( page . getPage ( ) + 1 , page . getSize ( ) ) , new LambdaQueryWrapper < Structattr > ( )
. like ( StrUtil . isNotEmpty ( search ) , Structattr : : getStruct_code , search )
. like ( StrUtil . isNotEmpty ( search ) , Structattr : : getStruct_name , search )
. eq ( StrUtil . isNotEmpty ( stor_id ) , Structattr : : getStor_id , stor_id )
. eq ( StrUtil . isNotEmpty ( sect_id ) , Structattr : : getSect_id , sect_id )
. eq ( StrUtil . isNotEmpty ( lock_type ) , Structattr : : getLock_type , lock_type )
. eq ( StrUtil . isNotEmpty ( layer_num ) , Structattr : : getLayer_num , layer_num )
. eq ( StrUtil . isNotEmpty ( is_used ) , Structattr : : getIs_used , is_used )
. isNull ( " 1 " . equals ( is_have ) , Structattr : : getStoragevehicle_code )
. isNotNull ( " 2 " . equals ( is_have ) , Structattr : : getStoragevehicle_code )
. orderByAsc ( Structattr : : getStruct_code )
) ;
@@ -123,7 +123,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
@Override
public List < Structattr > findBySectId ( String id ) {
return structattrMapper . selectList ( new LambdaQueryWrapper < > ( Structattr . class )
. eq ( Structattr : : getSect_id , id ) ) ;
. eq ( Structattr : : getSect_id , id ) ) ;
}
@Override
@@ -131,7 +131,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
public void create ( Structattr dto ) {
String struct_code = dto . getStruct_code ( ) ;
Structattr structattr = this . findByCode ( struct_code ) ;
if ( structattr ! = null ) {
if ( structattr ! = null ) {
throw new BadRequestException ( " 存在相同的库区编号 " ) ;
}
String currentUserId = SecurityUtils . getCurrentUserId ( ) ;
@@ -208,8 +208,8 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
public void changeActive ( JSONObject json ) {
String sect_id = json . getString ( " sect_id " ) ;
Sectattr sectattr = iSectattrService . getOne ( new LambdaQueryWrapper < > ( Sectattr . class )
. eq ( Sectattr : : getSect_id , sect_id )
. eq ( Sectattr : : getIs_used , BaseDataEnum . IS_YES_NOT . code ( " 是 " ) )
. eq ( Sectattr : : getSect_id , sect_id )
. eq ( Sectattr : : getIs_used , BaseDataEnum . IS_YES_NOT . code ( " 是 " ) )
) ;
if ( ObjectUtil . isEmpty ( sectattr ) ) {
throw new BadRequestException ( " 该仓位所属的库区已禁用,请先启用该库区! " ) ;
@@ -240,37 +240,37 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
@Override
public void updateStatusByCode ( String operate , JSONObject jsonObject ) {
//operate:0生成、1单据确认、2取消分配
switch ( operate ) {
switch ( operate ) {
case " 0 " :
//锁定仓位
this . update ( new LambdaUpdateWrapper < > ( Structattr . class )
. set ( Structattr : : getInv_id , jsonObject . getString ( " inv_id " ) )
. set ( Structattr : : getInv_code , jsonObject . getString ( " inv_code " ) )
. set ( Structattr : : getInv_type , jsonObject . getString ( " inv_type " ) )
. set ( Structattr : : getInv_id , jsonObject . getString ( " inv_id " ) )
. set ( Structattr : : getInv_code , jsonObject . getString ( " inv_code " ) )
. set ( Structattr : : getInv_type , jsonObject . getString ( " inv_type " ) )
. set ( Structattr : : getLock_type , jsonObject . getString ( " lock_type " ) )
. eq ( Structattr : : getStruct_code , jsonObject . getString ( " struct_code " ) )
. eq ( Structattr : : getStruct_code , jsonObject . getString ( " struct_code " ) )
) ;
break ;
case " 1 " :
//完成任务,解锁仓位绑定载具号
this . update ( new LambdaUpdateWrapper < > ( Structattr . class )
. set ( Structattr : : getInv_id , jsonObject . getString ( " inv_id " ) )
. set ( Structattr : : getInv_code , jsonObject . getString ( " inv_code " ) )
. set ( Structattr : : getInv_type , jsonObject . getString ( " inv_type " ) )
. set ( Structattr : : getStoragevehicle_code , jsonObject . getString ( " storagevehicle_code " ) )
. set ( Structattr : : getLock_type , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getStruct_code , jsonObject . getString ( " struct_code " ) )
. set ( Structattr : : getInv_id , jsonObject . getString ( " inv_id " ) )
. set ( Structattr : : getInv_code , jsonObject . getString ( " inv_code " ) )
. set ( Structattr : : getInv_type , jsonObject . getString ( " inv_type " ) )
. set ( Structattr : : getStoragevehicle_code , jsonObject . getString ( " storagevehicle_code " ) )
. set ( Structattr : : getLock_type , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getStruct_code , jsonObject . getString ( " struct_code " ) )
) ;
break ;
case " 2 " :
//解锁仓位
this . update ( new LambdaUpdateWrapper < > ( Structattr . class )
. set ( Structattr : : getInv_id , jsonObject . getString ( " inv_id " ) )
. set ( Structattr : : getInv_code , jsonObject . getString ( " inv_code " ) )
. set ( Structattr : : getInv_type , jsonObject . getString ( " inv_type " ) )
. set ( Structattr : : getLock_type , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getStruct_code , jsonObject . getString ( " struct_code " ) )
. set ( Structattr : : getInv_id , jsonObject . getString ( " inv_id " ) )
. set ( Structattr : : getInv_code , jsonObject . getString ( " inv_code " ) )
. set ( Structattr : : getInv_type , jsonObject . getString ( " inv_type " ) )
. set ( Structattr : : getLock_type , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getStruct_code , jsonObject . getString ( " struct_code " ) )
) ;
break ;
}
@@ -302,7 +302,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
. eq ( Structattr : : getStruct_code , struct_code )
) ;
if ( ObjectUtil . isEmpty ( one ) ) {
throw new BadRequestException ( " 此仓位编码不存在【 " + struct_code + " 】 " ) ;
throw new BadRequestException ( " 此仓位编码不存在【 " + struct_code + " 】 " ) ;
}
return one ;
}
@@ -319,6 +319,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
/**
* 出库分配
*
* @param param: 根据库区, 需要物料及数量,单据,批次分配具体货位
* @return 返回结果为仓位--对应--货物组盘物料信息及出库冻结数量
* 当前分配不会自动锁定货位及冻结出库数量,分配完成后需要手动锁定货位并冻结出库数量
@@ -326,22 +327,22 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
@Override
public List < StrategyStructMaterialVO > outBoundSectDiv ( StrategyStructParam param ) {
//只校验仓库,库区
Assert . noNullElements ( new Object [ ] { param . getStor_code ( ) , param . getSect_code ( ) } , " 请求参数不能为空 " ) ;
Assert . noNullElements ( new Object [ ] { param . getStor_code ( ) , param . getSect_code ( ) } , " 请求参数不能为空 " ) ;
StSectStrategy one = iStSectStrategyService . getOne ( new LambdaQueryWrapper < StSectStrategy > ( )
. eq ( StSectStrategy : : getSect_code , param . getSect_code ( ) )
. eq ( StSectStrategy : : getStrategy_type , StatusEnum . STRATEGY_TYPE . code ( " 出库 " ) ) ) ;
if ( one = = null ) {
throw new BadRequestException ( " 当前库区 " + param . getSect_code ( ) + " 未配置入出库规则 " ) ;
if ( one = = null ) {
throw new BadRequestException ( " 当前库区 " + param . getSect_code ( ) + " 未配置入出库规则 " ) ;
}
List < String > strategy = one . getStrategy ( ) ;
Map < String , Decisioner > decisionerMap = SpringContextHolder . getBeansOfType ( Decisioner . class ) ;
List list = null ;
for ( String decisionerType : strategy ) {
Decisioner decisioner = decisionerMap . get ( decisionerType ) ;
log . info ( " 执行出入库规格: " + decisioner . strategyConfig . getStrategy_name ( ) ) ;
log . info ( " 执行出入库规格: " + decisioner . strategyConfig . getStrategy_name ( ) ) ;
list = decisioner . handler ( list , param ) ;
if ( CollectionUtils . isEmpty ( list ) ) {
throw new BadRequestException ( " 当前策略 " + decisioner . strategyConfig . getStrategy_name ( ) + " 无可用货位,分配前数量: " + list . size ( ) ) ;
if ( CollectionUtils . isEmpty ( list ) ) {
throw new BadRequestException ( " 当前策略 " + decisioner . strategyConfig . getStrategy_name ( ) + " 无可用货位,分配前数量: " + list . size ( ) ) ;
}
}
return list ;
@@ -349,6 +350,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
/**
* 入库分配
*
* @param param: 根据库区, 需要物料及数量,单据,批次分配具体货位;按托进行分配:默认一托一个货位
* @return 返回结果为分配的具体仓位
* 当前分配不会自动锁定货位,分配完成后需要手动锁定货位
@@ -356,28 +358,28 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
@Override
public List < Structattr > inBoundSectDiv ( StrategyStructParam param ) {
//批号,单据暂时不校验,具体业务具体校验
Assert . noNullElements ( new Object [ ] { param . getQty ( ) , param . getMaterial_code ( ) , param . getSect_code ( ) } , " 请求参数不能为空 " ) ;
Assert . noNullElements ( new Object [ ] { param . getQty ( ) , param . getMaterial_code ( ) , param . getSect_code ( ) } , " 请求参数不能为空 " ) ;
StSectStrategy one = iStSectStrategyService . getOne ( new LambdaQueryWrapper < StSectStrategy > ( )
. eq ( StSectStrategy : : getSect_code , param . getSect_code ( ) )
. eq ( StSectStrategy : : getStrategy_type , StatusEnum . STRATEGY_TYPE . code ( " 入库 " ) ) ) ;
if ( one = = null ) {
throw new BadRequestException ( " 当前库区 " + param . getSect_code ( ) + " 未配置入库规则 " ) ;
if ( one = = null ) {
throw new BadRequestException ( " 当前库区 " + param . getSect_code ( ) + " 未配置入库规则 " ) ;
}
List < String > strategy = one . getStrategy ( ) ;
Map < String , Decisioner > decisionerMap = SpringContextHolder . getBeansOfType ( Decisioner . class ) ;
QueryWrapper < Structattr > query = new QueryWrapper < Structattr > ( )
. eq ( " is_used " , true )
. eq ( " lock_type " , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( " lock_type " , IOSEnum . LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( " sect_code " , param . getSect_code ( ) )
. isNull ( " storagevehicle_code " ) ;
List < Structattr > list = this . list ( query ) ;
for ( String decisionerType : strategy ) {
Decisioner decisioner = decisionerMap . get ( decisionerType ) ;
log . info ( " 执行入库规格: " + decisioner . strategyConfig . getStrategy_name ( ) ) ;
log . info ( " 执行入库规格: " + decisioner . strategyConfig . getStrategy_name ( ) ) ;
JSONObject params = ( JSONObject ) JSON . toJSON ( param ) ;
list = decisioner . handler ( list , params ) ;
if ( CollectionUtils . isEmpty ( list ) ) {
throw new BadRequestException ( " 当前策略 " + decisioner . strategyConfig . getStrategy_name ( ) + " 无可用货位,分配前数量: " + list . size ( ) ) ;
if ( CollectionUtils . isEmpty ( list ) ) {
throw new BadRequestException ( " 当前策略 " + decisioner . strategyConfig . getStrategy_name ( ) + " 无可用货位,分配前数量: " + list . size ( ) ) ;
}
}
return list ;
@@ -407,7 +409,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
BigDecimal subtract = vehicleMater . getQty ( ) . subtract ( vehicleMater . getFrozen_qty ( ) ) ;
//100-出50 = 50
//如果出库是手持库出确认则不在这边变动组盘信息
if ( ! changeDto . getInBound ( ) ) {
if ( ! changeDto . getInBound ( ) ) {
UpdateWrapper < GroupPlate > update = new UpdateWrapper < GroupPlate > ( )
. set ( " frozen_qty " , 0 )
. set ( " qty " , subtract )
@@ -434,7 +436,7 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
record . setGrowth ( changeDto . getInBound ( ) ) ;
records . add ( record ) ;
}
if ( ! CollectionUtils . isEmpty ( records ) ) {
if ( ! CollectionUtils . isEmpty ( records ) ) {
stIvtStructivtflowService . saveBatch ( records ) ;
}
}