@@ -909,43 +909,94 @@ public class InboundPdaServiceImpl implements InboundPdaService {
}
}
@Override
@Override
@Transactional
public JSONObject getStructInfo ( String struct_code ) {
public void returnInbound ( ReturnInboundDto returnInboundDto ) {
if ( StrUtil . isEmptyIfStr ( struct_code ) ) {
throw new BadRequestException ( " 查询失败:库位编码不能为空 " ) ;
log . info ( " PDA提交退料入库 参数:{} " , JSON . toJSONString ( returnInboundDto ) ) ;
// 查询库区
Sectattr sectDao = iSectattrService . findByCode ( returnInboundDto . getSect_code ( ) ) ;
if ( sectDao = = null ) {
throw new BadRequestException ( " 仓库不存在 " ) ;
}
}
//获取库位
Structattr struct = iStructattrService . findByCode ( struct_code ) ;
if ( struct = = null ) {
throw new BadRequestException ( " 查询失败:库位 " + struct_code + " 不存在 " ) ;
}
JSONObject json = new JSONObject ( ) ;
json . put ( " struct_id " , struct . getStruct_id ( ) ) ;
json . put ( " struct_code " , struct . getStruct_code ( ) ) ;
json . put ( " struct_name " , struct . getStruct_name ( ) ) ;
json . put ( " sect_id " , struct . getSect_id ( ) ) ;
json . put ( " sect_code " , struct . getSect_code ( ) ) ;
json . put ( " stor_id " , struct . getStor_id ( ) ) ;
json . put ( " stor_code " , struct . getStor_code ( ) ) ;
json . put ( " stor_name " , struct . getStor_name ( ) ) ;
json . put ( " storagevehicle_code " , struct . getStoragevehicle_code ( ) ) ;
json . put ( " lock_type " , struct . getLock_type ( ) ) ;
json . put ( " is_used " , struct . getIs_used ( ) ) ;
// 库位是否已有托盘: true=累加物料, false=组盘入库
json . put ( " has_vehicle " , StrUtil . isNotBlank ( struct . getStoragevehicle_code ( ) ) ) ;
return json ;
}
/**
* 退料入库:
* <ul>
* <li>未传 struct_code → 平库模式:仓库编码与库区编码一致,单库位单托盘永久绑定,按仓库定位虚拟库位,沿用"按物料判断在库累加/组盘"逻辑;</li>
* <li>传入 struct_code → 货架立库模式:按库位定位。库位已有托盘则在原托盘上累加物料;库位为空则使用 vehicle_code 绑定托盘并组盘入库。</li>
* </ul>
* 注意:页面取自退料单 target_house_code 的值是仓库编码( stor_code) , 原代码误当作库区编码( sect_code) 使用,
* 此处统一按仓库编码处理。
*/
@Override
@Transactional
public void returnInbound ( ReturnInboundDto dto ) {
log . info ( " PDA提交退料入库 参数:{} " , JSON . toJSONString ( dto ) ) ;
String storCode = dto . getStor_code ( ) ;
String structCode = dto . getStruct_code ( ) ;
if ( StrUtil . isBlank ( storCode ) ) {
throw new BadRequestException ( " 入库失败:仓库编码不能为空 " ) ;
}
BsrealStorattr storDao = iSrealStorattrService . findByCode ( storCode ) ;
if ( storDao = = null ) {
throw new BadRequestException ( " 入库失败:仓库 " + storCode + " 不存在 " ) ;
}
if ( StrUtil . isNotBlank ( structCode ) ) {
// 货架立库
returnInboundForRack ( dto , storDao , structCode , dto . getVehicle_code ( ) ) ;
} else {
// 平库
returnInboundForFlat ( dto , storDao ) ;
}
}
/**
* 平库退料入库:按仓库定位虚拟库位(单库位单托盘永久绑定),物料已在库则累加,否则组盘。
* 原逻辑沿用,仅将误用的 sect_code 修正为 stor_code。
*/
private void returnInboundForFlat ( ReturnInboundDto dto , BsrealStorattr storDao ) {
//获取虚拟库位(平库:仓库编码=库区编码,单库位且与单托盘永久绑定)
List < Structattr > structList = iStructattrService . lambdaQuery ( )
List < Structattr > structList = iStructattrService . lambdaQuery ( )
. eq ( Structattr : : getSect _id , sect Dao . getSect _id ( ) )
. eq ( Structattr : : getStor _id , stor Dao . getStor _id ( ) )
. eq ( Structattr : : getLock_type , LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getLock_type , LOCK_TYPE . code ( " 未锁定 " ) )
. eq ( Structattr : : getIs_used , 1 )
. eq ( Structattr : : getIs_used , 1 )
. isNotNull ( Structattr : : getStoragevehicle_code )
. isNotNull ( Structattr : : getStoragevehicle_code )
. orderByAsc ( Structattr : : getCreate_time ) . list ( ) ;
. orderByAsc ( Structattr : : getCreate_time ) . list ( ) ;
if ( structList . isEmpty ( ) ) {
if ( structList . isEmpty ( ) ) {
throw new BadRequestException ( " 入库失败:未找到可用虚拟货位 " ) ;
throw new BadRequestException ( " 入库失败:未找到可用虚拟货位 " ) ;
}
}
Structattr struct = structList . get ( 0 ) ;
Structattr struct = structList . get ( 0 ) ;
log . info ( " 平库入库:找到虚拟库位{} " , JSON . toJSONString ( struct ) ) ;
log . info ( " 平库退料 入库:找到虚拟库位{} " , JSON . toJSONString ( struct ) ) ;
String storagevehicleCode = struct . getStoragevehicle_code ( ) ; //载具编码
String storagevehicleCode = struct . getStoragevehicle_code ( ) ; //载具编码
boolean flag = false ;
boolean flag = false ;
List < GroupPlate > gpList = new ArrayList < > ( ) ;
List < GroupPlate > gpList = new ArrayList < > ( ) ;
List < AddInvParam > addInvParams = new ArrayList < > ( ) ;
List < AddInvParam > addInvParams = new ArrayList < > ( ) ;
for ( ReturnInboundDto . ReturnInboundDtlDto item : returnInboundD to. getDetailList ( ) ) {
for ( ReturnInboundDto . ReturnInboundDtlDto item : d to. getDetailList ( ) ) {
//判断当前物料是否在库内
//判断当前物料是否在库内(按仓库编码过滤)
List < StructattrVechielDto > structattrVechielDtos = iStructattrService . collectVechicle (
List < StructattrVechielDto > structattrVechielDtos = iStructattrService . collectVechicle (
MapOf . of ( " sect _code " , returnInboundD to. getSect _code ( ) , " material_code " , item . getSku_code ( ) ) ) ;
MapOf . of ( " stor _code " , d to. getStor _code ( ) , " material_code " , item . getSku_code ( ) ) ) ;
if ( ! structattrVechielDtos . isEmpty ( ) ) {
if ( ! structattrVechielDtos . isEmpty ( ) ) {
StructattrVechielDto groupPlate = structattrVechielDtos . get ( 0 ) ;
StructattrVechielDto groupPlate = structattrVechielDtos . get ( 0 ) ;
Structattr structattr = iStructattrService . getOne ( new LambdaQueryWrapper < Structattr > ( )
Structattr structattr = iStructattrService . getOne ( new LambdaQueryWrapper < Structattr > ( )
. eq ( Structattr : : getStoragevehicle_code , groupPlate . getStoragevehicle_code ( ) )
. eq ( Structattr : : getStoragevehicle_code , groupPlate . getStoragevehicle_code ( ) )
. eq ( Structattr : : getSect _code , returnInboundD to. getSect _code ( ) )
. eq ( Structattr : : getStor _code , d to. getStor _code ( ) )
. last ( " limit 1 " ) ) ;
. last ( " limit 1 " ) ) ;
if ( Objects . equals ( structattr . getSect _code ( ) , returnInboundD to. getSect _code ( ) ) ) {
if ( structattr ! = null & & Objects. equals ( structattr . getStor _code ( ) , d to. getStor _code ( ) ) ) {
//已在库,增加库存
//已在库,增加库存
flag = true ;
flag = true ;
AddInvParam addParam = new AddInvParam ( ) ;
AddInvParam addParam = new AddInvParam ( ) ;
@@ -954,9 +1005,9 @@ public class InboundPdaServiceImpl implements InboundPdaService {
addParam . setStoragevehicleCode ( groupPlate . getStoragevehicle_code ( ) ) ;
addParam . setStoragevehicleCode ( groupPlate . getStoragevehicle_code ( ) ) ;
addParam . setUnitName ( groupPlate . getQty_unit_name ( ) ) ;
addParam . setUnitName ( groupPlate . getQty_unit_name ( ) ) ;
addParam . setUnitId ( groupPlate . getQty_unit_id ( ) ) ;
addParam . setUnitId ( groupPlate . getQty_unit_id ( ) ) ;
addParam . setExtCode ( returnInboundD to. getBill_id ( ) ) ;
addParam . setExtCode ( d to. getBill_id ( ) ) ;
addParam . setExtType ( BILL_TYPE . code ( " MES生产退货入库 " ) ) ;
addParam . setExtType ( BILL_TYPE . code ( " MES生产退货入库 " ) ) ;
addParam . setSectCode ( returnInboundDto . getSect_code ( ) ) ;
addParam . setSectCode ( structattr . getSect_code ( ) ) ;
addParam . setStructCode ( structattr . getStruct_code ( ) ) ;
addParam . setStructCode ( structattr . getStruct_code ( ) ) ;
addParam . setStorCode ( structattr . getStor_code ( ) ) ;
addParam . setStorCode ( structattr . getStor_code ( ) ) ;
addParam . setQty ( item . getQty ( ) ) ;
addParam . setQty ( item . getQty ( ) ) ;
@@ -975,35 +1026,34 @@ public class InboundPdaServiceImpl implements InboundPdaService {
. qty_unit_name ( unitDao . getUnit_name ( ) )
. qty_unit_name ( unitDao . getUnit_name ( ) )
. qty ( item . getQty ( ) )
. qty ( item . getQty ( ) )
. status ( GROUP_PLATE_STATUS . code ( " 组盘 " ) )
. status ( GROUP_PLATE_STATUS . code ( " 组盘 " ) )
. ext_code ( returnInboundD to. getBill_id ( ) )
. ext_code ( d to. getBill_id ( ) )
. ext_type ( BILL_TYPE . code ( " MES生产退货入库 " ) )
. ext_type ( BILL_TYPE . code ( " MES生产退货入库 " ) )
. ext_dtl_code ( item . getItem_no ( ) )
. ext_dtl_code ( StrUtil . blankToDefault ( item . getSource_billdtl_id ( ) , item. getItem_no ( ) ) )
. create_id ( SecurityUtils . getCurrentUserId ( ) )
. create_id ( SecurityUtils . getCurrentUserId ( ) )
. create_name ( SecurityUtils . getCurrentNickName ( ) )
. create_name ( SecurityUtils . getCurrentNickName ( ) )
. create_time ( DateUtil . now ( ) )
. create_time ( DateUtil . now ( ) )
. build ( ) ;
. build ( ) ;
if ( flag ) {
if ( flag ) {
gpList . add ( plateDao ) ;
gpList . add ( plateDao ) ;
} else {
} else {
iMdPbGroupplateService . save ( plateDao ) ;
iMdPbGroupplateService . save ( plateDao ) ;
}
}
}
}
if ( flag ) iStInventoryService . changeInventory ( InventoryChangeType . ADD_INV , addInvParams ) ;
if ( flag ) iStInventoryService . changeInventory ( InventoryChangeType . ADD_INV , addInvParams ) ;
GroupPlateInboundDto groupPlateInboundDto = new GroupPlateInboundDto ( ) ;
GroupPlateInboundDto groupPlateInboundDto = new GroupPlateInboundDto ( ) ;
groupPlateInboundDto . setSect_code ( sectDao . getSect_code ( ) ) ;
groupPlateInboundDto . setSect_code ( struct . getSect_code ( ) ) ;
groupPlateInboundDto . setVehicle_code ( storagevehicleCode ) ;
groupPlateInboundDto . setVehicle_code ( storagevehicleCode ) ;
groupPlateInboundDto . setGroupPlateList ( gpList ) ;
groupPlateInboundDto . setGroupPlateList ( gpList ) ;
// this.submitGroupPlateInbound(groupPlateInboundDto, false);
// 查询组盘明细
// 查询组盘明细
List < GroupPlate > plateDaoList ;
List < GroupPlate > plateDaoList ;
if ( groupPlateInboundDto . getGroupPlateList ( ) . isEmpty ( ) ) {
if ( groupPlateInboundDto . getGroupPlateList ( ) . isEmpty ( ) ) {
plateDaoList = iMdPbGroupplateService . list (
plateDaoList = iMdPbGroupplateService . list (
new QueryWrapper < GroupPlate > ( ) . lambda ( )
new QueryWrapper < GroupPlate > ( ) . lambda ( )
. eq ( GroupPlate : : getStoragevehicle_code , groupPlateInboundDto . getVehicle_code ( ) )
. eq ( GroupPlate : : getStoragevehicle_code , groupPlateInboundDto . getVehicle_code ( ) )
. eq ( GroupPlate : : getStatus , GROUP_PLATE_STATUS . code ( " 组盘 " ) )
. eq ( GroupPlate : : getStatus , GROUP_PLATE_STATUS . code ( " 组盘 " ) )
) ;
) ;
} else {
} else {
plateDaoList = groupPlateInboundDto . getGroupPlateList ( ) ;
plateDaoList = groupPlateInboundDto . getGroupPlateList ( ) ;
}
}
@@ -1015,11 +1065,9 @@ public class InboundPdaServiceImpl implements InboundPdaService {
. map ( row - > row . getQty ( ) . doubleValue ( ) )
. map ( row - > row . getQty ( ) . doubleValue ( ) )
. reduce ( Double : : sum ) . orElse ( 0 . 0 ) ;
. reduce ( Double : : sum ) . orElse ( 0 . 0 ) ;
// 查询库区
// 组织主表数据(仓库、库区信息取自定位到的虚拟库位)
// Sectattr sectDao = iSectattrService.findByCode(groupPlateInboundDto.getSect_code());
// 组织主表数据
Map < String , Object > jsonMst = new HashMap < > ( ) ;
Map < String , Object > jsonMst = new HashMap < > ( ) ;
jsonMst . put ( " stor_id " , sectDao . getStor_id ( ) ) ;
jsonMst . put ( " stor_id " , struct . getStor_id ( ) ) ;
jsonMst . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
jsonMst . put ( " bill_status " , IOSEnum . BILL_STATUS . code ( " 生成 " ) ) ;
jsonMst . put ( " total_qty " , total_qty ) ;
jsonMst . put ( " total_qty " , total_qty ) ;
jsonMst . put ( " detail_count " , 1 ) ;
jsonMst . put ( " detail_count " , 1 ) ;
@@ -1027,7 +1075,6 @@ public class InboundPdaServiceImpl implements InboundPdaService {
jsonMst . put ( " biz_date " , DateUtil . now ( ) ) ;
jsonMst . put ( " biz_date " , DateUtil . now ( ) ) ;
// 组织明细数据
// 组织明细数据
ArrayList < HashMap > tableData = new ArrayList < > ( ) ;
ArrayList < HashMap > tableData = new ArrayList < > ( ) ;
// GroupPlate plateDao = plateDaoList.get(0);
for ( GroupPlate plateDao : plateDaoList ) {
for ( GroupPlate plateDao : plateDaoList ) {
HashMap < String , Object > dtl = new HashMap < > ( ) ;
HashMap < String , Object > dtl = new HashMap < > ( ) ;
MdMeMaterialbase materDao = iMdMeMaterialbaseService . getByCode ( plateDao . getMaterial_code ( ) ) ;
MdMeMaterialbase materDao = iMdMeMaterialbaseService . getByCode ( plateDao . getMaterial_code ( ) ) ;
@@ -1044,21 +1091,18 @@ public class InboundPdaServiceImpl implements InboundPdaService {
dtl . put ( " ext_type " , plateDao . getExt_type ( ) ) ;
dtl . put ( " ext_type " , plateDao . getExt_type ( ) ) ;
dtl . put ( " source_billdtl_id " , plateDao . getExt_dtl_code ( ) ) ;
dtl . put ( " source_billdtl_id " , plateDao . getExt_dtl_code ( ) ) ;
dtl . put ( " callback_strategy " , " SapReturnCallBack " ) ;
dtl . put ( " callback_strategy " , " SapReturnCallBack " ) ;
// 调用新增
tableData . add ( dtl ) ;
tableData . add ( dtl ) ;
}
}
jsonMst . put ( " tableData " , tableData ) ;
jsonMst . put ( " tableData " , tableData ) ;
String iostorinv_id = iRawAssistIStorService . insertDtl ( jsonMst ) ;
String iostorinv_id = iRawAssistIStorService . insertDtl ( jsonMst ) ;
// 查询仓库
BsrealStorattr storeDao = iSrealStorattrService . getById ( sectDao . getStor_id ( ) ) ;
// 组织主数据
// 组织主数据
Map < String , Object > jsonMst1 = new HashMap < > ( ) ;
Map < String , Object > jsonMst1 = new HashMap < > ( ) ;
jsonMst1 . put ( " checked " , true ) ;
jsonMst1 . put ( " checked " , true ) ;
jsonMst1 . put ( " sect_id " , sectDao . getSect_id ( ) ) ;
jsonMst1 . put ( " sect_id " , struct . getSect_id ( ) ) ;
jsonMst1 . put ( " stor_id " , sectDao . getStor_id ( ) ) ;
jsonMst1 . put ( " stor_id " , struct . getStor_id ( ) ) ;
jsonMst1 . put ( " sect_code " , sectDao . getSect_code ( ) ) ;
jsonMst1 . put ( " sect_code " , struct . getSect_code ( ) ) ;
jsonMst1 . put ( " stor_code " , storeDao . getStor_code ( ) ) ;
jsonMst1 . put ( " stor_code " , struct . getStor_code ( ) ) ;
jsonMst1 . put ( " storagevehicle_code " , groupPlateInboundDto . getVehicle_code ( ) ) ;
jsonMst1 . put ( " storagevehicle_code " , groupPlateInboundDto . getVehicle_code ( ) ) ;
// 组织明细数据
// 组织明细数据
List < IOStorInvDtl > ioStorInvDtls = ioStorInvDtlMapper . selectList (
List < IOStorInvDtl > ioStorInvDtls = ioStorInvDtlMapper . selectList (
@@ -1081,6 +1125,172 @@ public class InboundPdaServiceImpl implements InboundPdaService {
iRawAssistIStorService . disFinish ( ioStorInvDis ) ;
iRawAssistIStorService . disFinish ( ioStorInvDis ) ;
}
}
/**
* 货架立库退料入库:按库位定位。
* <ul>
* <li>库位已有托盘: 在原托盘上累加物料( ADD_INV 维护组盘表数量);</li>
* <li>库位为空:使用传入托盘号绑定到库位并入库。</li>
* </ul>
* 入库单明细分配到指定库位(非自动分配),单据直接完成,回传策略 SapReturnCallBack。
*/
private void returnInboundForRack ( ReturnInboundDto dto , BsrealStorattr storDao ,
String structCode , String vehicleCode ) {
Structattr struct = iStructattrService . findByCode ( structCode ) ;
if ( struct = = null ) {
throw new BadRequestException ( " 入库失败:库位 " + structCode + " 不存在 " ) ;
}
if ( ! Objects . equals ( struct . getStor_id ( ) , storDao . getStor_id ( ) ) ) {
throw new BadRequestException ( " 入库失败:库位 " + structCode + " 不属于仓库 " + storDao . getStor_code ( ) ) ;
}
if ( struct . getIs_used ( ) = = null | | ! struct . getIs_used ( ) ) {
throw new BadRequestException ( " 入库失败:库位 " + structCode + " 未启用 " ) ;
}
if ( ! LOCK_TYPE . code ( " 未锁定 " ) . equals ( struct . getLock_type ( ) ) ) {
throw new BadRequestException ( " 入库失败:库位 " + structCode + " 已锁定 " ) ;
}
boolean hasVehicle = StrUtil . isNotBlank ( struct . getStoragevehicle_code ( ) ) ;
String storagevehicleCode ;
if ( hasVehicle ) {
// 库位已有托盘:在原托盘上累加物料;若用户同时传了托盘号需与原托盘一致
storagevehicleCode = struct . getStoragevehicle_code ( ) ;
if ( StrUtil . isNotBlank ( vehicleCode ) & & ! Objects . equals ( storagevehicleCode , vehicleCode . trim ( ) ) ) {
throw new BadRequestException ( " 入库失败:库位 " + structCode + " 已绑定托盘 "
+ storagevehicleCode + " ,与扫描托盘 " + vehicleCode + " 不一致 " ) ;
}
} else {
// 库位为空:组盘入库,必须提供托盘号
if ( StrUtil . isBlank ( vehicleCode ) ) {
throw new BadRequestException ( " 入库失败:库位 " + structCode + " 为空,请扫描或输入托盘号 " ) ;
}
storagevehicleCode = vehicleCode . trim ( ) ;
// 校验该托盘未在其它库位上
long vehicleUsed = iStructattrService . count ( new LambdaQueryWrapper < Structattr > ( )
. eq ( Structattr : : getStoragevehicle_code , storagevehicleCode ) ) ;
if ( vehicleUsed > 0 ) {
throw new BadRequestException ( " 入库失败:托盘 " + storagevehicleCode + " 已在库内其它库位,请核实 " ) ;
}
iMdPbStoragevehicleinfoService . chackAndInsert ( storagevehicleCode ) ;
// 将托盘绑定到当前空库位
struct . setStoragevehicle_code ( storagevehicleCode ) ;
iStructattrService . update ( struct ) ;
}
final String now = DateUtil . now ( ) ;
String currentUserId = SecurityUtils . getCurrentUserId ( ) ;
String nickName = SecurityUtils . getCurrentNickName ( ) ;
final List < IOStorInvDtl > ioStorInvDtls = new ArrayList < > ( ) ;
final List < IOStorInvDis > ioStorInvDiss = new ArrayList < > ( ) ;
List < AddInvParam > addInvParams = new ArrayList < > ( ) ;
List < InFinishParam > inFinishParams = new ArrayList < > ( ) ;
// 生成入库单(直接完成态,分配到指定库位)
IOStorInv ioStorInvIn = new IOStorInv ( ) ;
ioStorInvIn . setIostorinv_id ( IdUtil . getStringId ( ) ) ;
ioStorInvIn . setBill_code ( CodeUtil . getNewCode ( " IN_STORE_CODE " ) ) ;
ioStorInvIn . setIo_type ( IOSEnum . IO_TYPE . code ( " 入库 " ) ) ;
ioStorInvIn . setBill_type ( IOSEnum . BILL_TYPE . code ( " 退货入库 " ) ) ;
ioStorInvIn . setBiz_date ( DateUtil . today ( ) ) ;
ioStorInvIn . setStor_code ( storDao . getStor_code ( ) ) ;
ioStorInvIn . setStor_name ( storDao . getStor_name ( ) ) ;
ioStorInvIn . setStor_id ( storDao . getStor_id ( ) ) ;
ioStorInvIn . setDetail_count ( 1 ) ;
ioStorInvIn . setBill_status ( IOSEnum . BILL_STATUS . code ( " 完成 " ) ) ;
ioStorInvIn . setCreate_mode ( IOSEnum . CREATE_MODE . code ( " 终端产生 " ) ) ;
ioStorInvIn . setInput_optid ( currentUserId ) ;
ioStorInvIn . setInput_optname ( nickName ) ;
ioStorInvIn . setInput_time ( now ) ;
ioStorInvIn . setIs_delete ( BaseDataEnum . IS_YES_NOT . code ( " 否 " ) ) ;
ioStorInvIn . setIs_upload ( BaseDataEnum . IS_YES_NOT . code ( " 是 " ) ) ;
int seq = 1 ;
for ( ReturnInboundDto . ReturnInboundDtlDto item : dto . getDetailList ( ) ) {
MdMeMaterialbase material = iMdMeMaterialbaseService . getByCode ( item . getSku_code ( ) ) ;
String pcsn = Optional . ofNullable ( item . getBatch_no ( ) ) . filter ( s - > ! s . isEmpty ( ) ) . orElse ( " 1 " ) ;
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl ( ) ;
ioStorInvDtl . setIostorinv_id ( ioStorInvIn . getIostorinv_id ( ) ) ;
ioStorInvDtl . setIostorinvdtl_id ( IdUtil . getStringId ( ) ) ;
ioStorInvDtl . setSeq_no ( String . valueOf ( seq ) ) ;
ioStorInvDtl . setMaterial_code ( material . getMaterial_code ( ) ) ;
ioStorInvDtl . setMaterial_id ( material . getMaterial_id ( ) ) ;
ioStorInvDtl . setQty_unit_id ( material . getQty_unit_id ( ) ) ;
ioStorInvDtl . setQty_unit_name ( material . getQty_unit_name ( ) ) ;
ioStorInvDtl . setPcsn ( pcsn ) ;
ioStorInvDtl . setBill_status ( IOSEnum . BILL_STATUS . code ( " 完成 " ) ) ;
ioStorInvDtl . setAssign_qty ( item . getQty ( ) ) ;
ioStorInvDtl . setPlan_qty ( item . getQty ( ) ) ;
ioStorInvDtl . setUnassign_qty ( BigDecimal . ZERO ) ;
ioStorInvDtl . setReal_qty ( item . getQty ( ) ) ;
// 来源单据信息: source_bill_code=退料单号, insertDtl 与回调 SapReturnCallBack 均按此查退料单
ioStorInvDtl . setSource_bill_code ( dto . getBill_id ( ) ) ;
ioStorInvDtl . setSource_bill_type ( BILL_TYPE . code ( " MES生产退货入库 " ) ) ;
ioStorInvDtl . setSource_billdtl_id ( StrUtil . blankToDefault ( item . getSource_billdtl_id ( ) , item . getItem_no ( ) ) ) ;
ioStorInvDtl . setCallback_strategy ( " SapReturnCallBack " ) ;
ioStorInvDtls . add ( ioStorInvDtl ) ;
// 分配明细:直接分配到指定库位
final IOStorInvDis ioStorInvDis = new IOStorInvDis ( ) ;
ioStorInvDis . setIostorinvdis_id ( IdUtil . getStringId ( ) ) ;
ioStorInvDis . setIostorinv_id ( ioStorInvIn . getIostorinv_id ( ) ) ;
ioStorInvDis . setIostorinvdtl_id ( ioStorInvDtl . getIostorinvdtl_id ( ) ) ;
ioStorInvDis . setSeq_no ( " 1 " ) ;
ioStorInvDis . setMaterial_id ( material . getMaterial_id ( ) ) ;
ioStorInvDis . setMaterial_code ( material . getMaterial_code ( ) ) ;
ioStorInvDis . setSect_code ( struct . getSect_code ( ) ) ;
ioStorInvDis . setStruct_code ( struct . getStruct_code ( ) ) ;
ioStorInvDis . setPcsn ( pcsn ) ;
ioStorInvDis . setStoragevehicle_code ( storagevehicleCode ) ;
ioStorInvDis . setWork_status ( IOSEnum . INBILL_DIS_STATUS . code ( " 完成 " ) ) ;
ioStorInvDis . setIs_issued ( BaseDataEnum . IS_YES_NOT . code ( " 是 " ) ) ;
ioStorInvDis . setQty_unit_id ( material . getQty_unit_id ( ) ) ;
ioStorInvDis . setQty_unit_name ( material . getQty_unit_name ( ) ) ;
ioStorInvDis . setPlan_qty ( item . getQty ( ) ) ;
ioStorInvDis . setReal_qty ( item . getQty ( ) ) ;
ioStorInvDiss . add ( ioStorInvDis ) ;
AddInvParam addParam = new AddInvParam ( ) ;
addParam . setPcsn ( pcsn ) ;
addParam . setMaterialCode ( material . getMaterial_code ( ) ) ;
addParam . setStoragevehicleCode ( storagevehicleCode ) ;
addParam . setUnitName ( material . getQty_unit_name ( ) ) ;
addParam . setUnitId ( material . getQty_unit_id ( ) ) ;
addParam . setExtCode ( dto . getBill_id ( ) ) ;
addParam . setExtType ( BILL_TYPE . code ( " MES生产退货入库 " ) ) ;
addParam . setSectCode ( struct . getSect_code ( ) ) ;
addParam . setStorCode ( storDao . getStor_code ( ) ) ;
addParam . setStructCode ( struct . getStruct_code ( ) ) ;
addParam . setQty ( item . getQty ( ) ) ;
addInvParams . add ( addParam ) ;
InFinishParam inFinishParam = new InFinishParam ( ) ;
inFinishParam . setPcsn ( pcsn ) ;
inFinishParam . setMaterialCode ( material . getMaterial_code ( ) ) ;
inFinishParam . setStoragevehicleCode ( storagevehicleCode ) ;
inFinishParam . setUnitName ( material . getQty_unit_name ( ) ) ;
inFinishParam . setUnitId ( material . getQty_unit_id ( ) ) ;
inFinishParam . setQty ( item . getQty ( ) ) ;
inFinishParam . setExtCode ( ioStorInvIn . getBill_code ( ) ) ;
inFinishParam . setExtType ( ioStorInvIn . getBill_type ( ) ) ;
inFinishParam . setStorCode ( storDao . getStor_code ( ) ) ;
inFinishParam . setSectCode ( struct . getSect_code ( ) ) ;
inFinishParam . setStructCode ( struct . getStruct_code ( ) ) ;
inFinishParams . add ( inFinishParam ) ;
seq + + ;
}
ioStorInvMapper . insert ( ioStorInvIn ) ;
ioStorInvDtlMapper . batchInsert ( ioStorInvDtls ) ;
ioStorInvDisMapper . batchSave ( ioStorInvDiss ) ;
// ADD_INV 维护组盘表数量(累加/新建 status=入库 记录) , IN_FINISH 写库存变动流水
iStInventoryService . changeInventory ( InventoryChangeType . ADD_INV , addInvParams ) ;
iStInventoryService . changeInventory ( InventoryChangeType . IN_FINISH , inFinishParams ) ;
// 完成后回传 SAP( 与平库 disFinish 触发的回调一致)
for ( IOStorInvDtl dtl : ioStorInvDtls ) {
callbackStrategyPublish . callbackStrategy ( dtl . getCallback_strategy ( ) , dtl ) ;
}
}
/**
/**
* 生产组盘入库
* 生产组盘入库
* @param dto
* @param dto
@@ -1091,6 +1301,10 @@ public class InboundPdaServiceImpl implements InboundPdaService {
if ( dto . getItems ( ) . isEmpty ( ) ) {
if ( dto . getItems ( ) . isEmpty ( ) ) {
throw new BadRequestException ( " 组盘物料为空 " ) ;
throw new BadRequestException ( " 组盘物料为空 " ) ;
}
}
List < Structattr > listByVeh = iStructattrService . list ( new LambdaQueryWrapper < Structattr > ( )
. eq ( Structattr : : getStoragevehicle_code , dto . getVehicle_code ( ) ) ) ;
if ( listByVeh . stream ( ) . anyMatch ( item - > ! Objects . equals ( item . getStruct_code ( ) , dto . getLocation_code ( ) ) ) )
throw new BadRequestException ( " 当前托盘已存在其他库位! " ) ;
iMdPbStoragevehicleinfoService . chackAndInsert ( dto . getVehicle_code ( ) ) ;
iMdPbStoragevehicleinfoService . chackAndInsert ( dto . getVehicle_code ( ) ) ;
Structattr structattr = iStructattrService . getByCode ( dto . getLocation_code ( ) ) ;
Structattr structattr = iStructattrService . getByCode ( dto . getLocation_code ( ) ) ;
BsrealStorattr storattrIn = storattrService . findByCode ( structattr . getStor_code ( ) ) ;
BsrealStorattr storattrIn = storattrService . findByCode ( structattr . getStor_code ( ) ) ;