@ -913,6 +913,11 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}
String loadStatus = carsLoadEntity . getLoadStatus ( ) ;
if ( ! "80" . equals ( loadStatus ) ) {
log . warn ( "#############unloadByLoadId: 配载计划已终点卸车确认 loadStatus={}" , loadStatus ) ;
throw new CustomerException ( 400 , "配载计划已终点卸车确认" ) ;
}
if ( ! "20" . equals ( loadStatus ) & & ! "40" . equals ( loadStatus ) ) {
log . warn ( "#############unloadByLoadId: 配载计划暂未到车 loadStatus={}" , loadStatus ) ;
throw new CustomerException ( 400 , "配载计划暂未到车" ) ;
@ -3409,6 +3414,17 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R . fail ( 405 , "配载计划信息不存在" ) ;
}
TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService . findEntityByLoadIdAndNodeId ( loadId , warehouseId ) ;
if ( Objects . isNull ( loadLineEntity ) ) {
log . warn ( "############batchUnload: 配载计划节点信息不存在 loadId={} warehouseId={}" , loadId , warehouseId ) ;
return R . fail ( 405 , "配载计划节点信息不存在" ) ;
}
String unloadStatus = loadLineEntity . getUnloadStatus ( ) ;
if ( ! "0" . equals ( unloadStatus ) ) {
log . warn ( "############batchUnload: 当前网点已经卸车确认 loadId={} warehouseId={}" , loadId , warehouseId ) ;
return R . fail ( 405 , "当前网点已经卸车确认" ) ;
}
Long nowWarehouseId = carsLoadEntity . getNowWarehouseId ( ) ;
if ( ! warehouseId . equals ( nowWarehouseId ) ) {
log . warn ( "############batchUnload: 当前节点还未到车 loadId={} warehouseId={}" , loadId , warehouseId ) ;
@ -3452,6 +3468,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
// //把waybillEntities转成WaybillNo为键值的map
// Map<String,WarehouseWaybillEntity> waybillMap = waybillEntities.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, e -> e));
List < TrunklineCarsUnloadLogEntity > unloadLogList = new ArrayList < > ( ) ;
List < String > orderCodeList = trunklineCarsLoadScanService . findIncomingOrdeCodesByCarsLoadScanIds ( carsLoadScanIds , warehouseId ) ;
Map < String , Long > orderCodes = new HashMap < > ( ) ;
if ( ! Objects . isNull ( orderCodeList ) ) {
@ -3467,13 +3485,45 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
//把loadScanEntityList通过isData=0和isData=1分成两个新的list
List < TrunklineCarsLoadScanEntity > loadScanEntityListNoData = loadScanEntityList . stream ( ) . filter ( e - > e . getIsData ( ) = = 0 ) . collect ( Collectors . toList ( ) ) ;
loadScanEntityListNoData . forEach ( e - > {
Integer isAbnormal = 0 ;
String remark = "正常卸车" ;
e . setScanStatus ( "2" ) ;
e . setUnloadNodeId ( warehouseId ) ;
e . setUnloadNodeName ( warehouseName ) ;
e . setUnloadAbnormal ( 0 ) ;
Long finalNodeId = e . getFinalNodeId ( ) ;
if ( ! finalNodeId . equals ( warehouseId ) ) {
isAbnormal = 1 ;
remark = "卸车仓库与目的仓不一致,异常卸车" ;
}
e . setUnloadAbnormal ( isAbnormal ) ;
e . setUnloadNum ( 1 ) ;
e . setUnloadUserName ( nickName ) ;
e . setRemark ( remark ) ;
updateScanEntityList . add ( e ) ;
TrunklineCarsUnloadLogEntity entity = new TrunklineCarsUnloadLogEntity ( ) ;
entity . setTenantId ( tenantId ) ;
entity . setCreateUser ( userId ) ;
entity . setUpdateUser ( userId ) ;
entity . setCreateDept ( deptId ) ;
entity . setCreateTime ( date ) ;
entity . setUpdateTime ( date ) ;
entity . setWarehouseId ( warehouseId ) ;
entity . setWarehouseName ( warehouseName ) ;
entity . setLoadId ( loadId ) ;
entity . setLoadCode ( carsLoadEntity . getCarsNo ( ) ) ;
entity . setWaybillId ( e . getWaybillId ( ) ) ;
entity . setWaybillNo ( e . getWaybillNo ( ) ) ;
entity . setOrderCode ( e . getOrderCode ( ) ) ;
entity . setScanCode ( e . getScanCode ( ) ) ;
entity . setNum ( e . getUnloadNum ( ) ) ;
entity . setType ( e . getType ( ) ) ;
entity . setIsData ( e . getIsData ( ) ) ;
entity . setIsAbnormal ( isAbnormal ) ;
entity . setFromWarehouseId ( e . getFromWarehouseId ( ) ) ;
entity . setLoadScanId ( e . getId ( ) ) ;
entity . setRemark ( remark ) ;
unloadLogList . add ( entity ) ;
} ) ;
@ -3484,8 +3534,6 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
//需要修改仓库信息的打托数据
List < String > trayCodes = new ArrayList < > ( ) ;
List < String > orderPackageCodes = new ArrayList < > ( ) ;
List < TrunklineCarsUnloadLogEntity > unloadLogList = new ArrayList < > ( ) ;
List < TrunklineCarsLoadScanEntity > loadScanEntityListHasData = loadScanEntityList . stream ( ) . filter ( e - > e . getIsData ( ) = = 1 ) . collect ( Collectors . toList ( ) ) ;
@ -4174,44 +4222,96 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
@Override
public R batchSign ( LoadCarsDTO loadCarsDTO ) {
List < Long > loadScanIds = loadCarsDTO . getLoadScanIds ( ) ;
Long warehouseId = loadCarsDTO . getWarehouseId ( ) ;
String warehouseName = loadCarsDTO . getWarehouseName ( ) ;
List < TrunklineCarsLoadScanEntity > list = trunklineCarsLoadScanService . findListByIds ( loadScanIds ) ;
List < TrunklineCarsLoadScanVO > list = trunklineCarsLoadScanService . findListHasSignOrderIdByIds ( loadScanIds ) ;
List < DistributionParcelListEntity > parcelListEntityList = trunklineCarsLoadScanService . findParceListByCarsLoadScanIds ( loadScanIds ) ;
//把parcelListEntityList通过orderPackageCode分组
Map < String , List < DistributionParcelListEntity > > parcelListMap = parcelListEntityList . stream ( ) . collect ( Collectors . groupingBy ( DistributionParcelListEntity : : getOrderPackageCode ) ) ;
for ( TrunklineCarsLoadScanEntity carsLoadScanEntity : list ) {
Long loadScanId = carsLoadScanEntity . getId ( ) ;
Long loadId = carsLoadScanEntity . getLoadId ( ) ;
Long warehouseId = carsLoadScanEntity . getWarehouseId ( ) ;
String orderCode = carsLoadScanEntity . getOrderCode ( ) ;
String waybillNo = carsLoadScanEntity . getWaybillNo ( ) ;
String scanCode = carsLoadScanEntity . getScanCode ( ) ;
Integer num = carsLoadScanEntity . getNum ( ) ;
QueryWrapper < TrunklineCarsOrderEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "load_id" , loadId )
. eq ( "node_id" , warehouseId )
. eq ( "order_code" , orderCode )
. eq ( "waybill_no" , waybillNo ) ;
TrunklineCarsOrderEntity one = trunklineCarsOrderService . getOne ( queryWrapper ) ;
if ( Objects . isNull ( one ) ) {
log . warn ( "############batchSign: 包件不在该车次中 " ) ;
return R . fail ( 405 , "包件不在该车次中" ) ;
}
List < Long > signOrderIds = new ArrayList < > ( ) ;
List < TrunklineCarsLoadScanEntity > updateCarsLoadScanList = new ArrayList < > ( ) ;
List < DistributionParcelListEntity > updateParcelList = new ArrayList < > ( ) ;
String isCustomer = one . getIsCustomer ( ) ;
if ( "0" . equals ( isCustomer ) ) {
log . warn ( "############batchSign: 订单不是直发商家订单 orderCode={} waybillNo={}" , orderCode , waybillNo ) ;
return R . fail ( 405 , "订单不是直发商家订单" ) ;
Date date = new Date ( ) ;
if ( ! list . isEmpty ( ) ) {
//排除list中scanStatus = 1的数据
list = list . stream ( ) . filter ( e - > ! "1" . equals ( e . getScanStatus ( ) ) ) . collect ( Collectors . toList ( ) ) ;
List < String > orderPackageCodes = new ArrayList < > ( ) ;
Set < Long > loadIds = new HashSet < > ( ) ;
//把list通过signOrderId进行分组
Map < Long , List < TrunklineCarsLoadScanVO > > map = list . stream ( ) . collect ( Collectors . groupingBy ( TrunklineCarsLoadScanVO : : getSignOrderId ) ) ;
map . keySet ( ) . forEach ( e - > {
List < TrunklineCarsLoadScanVO > trunklineCarsLoadScanVOS = map . get ( e ) ; //该签收单对应的包件
trunklineCarsLoadScanVOS . forEach ( t - > {
TrunklineCarsLoadScanEntity entity = new TrunklineCarsLoadScanEntity ( ) ;
BeanUtil . copy ( t , entity ) ;
entity . setScanStatus ( "3" ) ;
entity . setUnloadNum ( t . getNum ( ) ) ;
entity . setSignTime ( date ) ;
if ( entity . getType ( ) . equals ( 1 ) ) {
String scanCode = entity . getScanCode ( ) ;
List < DistributionParcelListEntity > parcelList = parcelListMap . get ( scanCode ) ;
if ( ! Objects . isNull ( parcelList ) ) {
parcelList . forEach ( p - > {
p . setOrderPackageStatus ( "70" ) ;
updateParcelList . add ( p ) ;
} ) ;
}
orderPackageCodes . add ( entity . getScanCode ( ) ) ;
}
updateCarsLoadScanList . add ( entity ) ;
loadIds . add ( entity . getLoadId ( ) ) ;
} ) ;
signOrderIds . add ( e ) ;
} ) ;
Long signOrderId = one . getSignOrderId ( ) ;
trunklineCarsLoadScanService . updateBatchById ( updateCarsLoadScanList ) ;
Integer type = carsLoadScanEntity . getType ( ) ;
if ( 1 = = type ) {
signScanPackageCode ( signOrderId , scanCode , "PC批量签收" ) ;
} else if ( 2 = = type ) {
signZeroOrder ( signOrderId , loadScanId , num , "PC批量签收" ) ;
//生成签收记录
trunklineCarsSignLogService . addList ( updateCarsLoadScanList , "PC批量签收" ) ;
//重新计算数量
loadIds . forEach ( this : : updateNumByLoadId ) ;
//重新计算签收单的数量
signOrderIds . forEach ( this : : updateSignOrderNumBySignOrderId ) ;
distributionParcelListClient . updateList ( updateParcelList ) ;
try {
String content = "包件在 " + warehouseName + "直发商家签收" ;
packageTrackLogAsyncService . addPackageTrackLog ( AuthUtil . getTenantId ( ) , AuthUtil . getUserId ( ) , Func . firstLong ( AuthUtil . getDeptId ( ) ) , AuthUtil . getNickName ( ) , orderPackageCodes , warehouseId , warehouseName , WorkNodeEnums . SIGN_DIRECT_SHIPPER . getCode ( ) , content ) ;
} catch ( Exception e ) {
log . warn ( "###########存入日志信息失败" ) ;
}
// 推送签收数据给工厂
try {
updateParcelList . forEach ( parcelListEntity - > {
if ( ObjectUtil . isNotEmpty ( parcelListEntity ) ) {
List < Object > contents = new ArrayList < > ( ) ;
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . put ( "packageCode" , parcelListEntity . getOrderPackageCode ( ) ) ;
contents . add ( jsonObject ) ;
NodePushMsg msg = new NodePushMsg ( ) ;
msg . setNode ( WorkNodeEnums . CLERK_REVIEW ) ;
msg . setBrand ( BrandEnums . getByValue ( parcelListEntity . getBrandName ( ) ) ) ;
msg . setOperator ( AuthUtil . getNickName ( ) ) ;
msg . setOperatorTime ( new Date ( ) ) ;
msg . setContent ( contents ) ;
log . info ( "推送工厂数据:{}" , JSONUtil . toJsonStr ( msg ) ) ;
factoryDataMessageSender . sendNodeDataByBrand ( msg ) ;
}
} ) ;
} catch ( Exception e ) {
log . error ( "推送签收数据给工厂失败 {}" , e ) ;
}
}
return R . success ( "签收完成" ) ;
}
@ -5262,10 +5362,15 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
return R . fail ( 405 , "配载计划信息不存在" ) ;
}
String loadCode = carsLoadEntity . getCarsNo ( ) ;
String loadStatus = carsLoadEntity . getLoadStatus ( ) ;
if ( "80" . equals ( loadStatus ) ) {
log . warn ( "##############unloadPackage: 配载计划已经卸车确认 loadId={}" , loadId ) ;
return R . fail ( 405 , "配载计划已经卸车确认" ) ;
TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService . findEntityByLoadIdAndNodeId ( loadId , warehouseId ) ;
if ( Objects . isNull ( loadLineEntity ) ) {
log . warn ( "############unloadPackage: 配载计划节点信息不存在 loadId={} warehouseId={}" , loadId , warehouseId ) ;
return R . fail ( 405 , "配载计划节点信息不存在" ) ;
}
String unloadStatus = loadLineEntity . getUnloadStatus ( ) ;
if ( ! "0" . equals ( unloadStatus ) ) {
log . warn ( "############unloadPackage: 当前网点已经卸车确认 loadId={} warehouseId={}" , loadId , warehouseId ) ;
return R . fail ( 405 , "当前网点已经卸车确认" ) ;
}
TrunklineCarsLoadLineEntity carsLoadLineEntity = trunklineCarsLoadLineService . findEntityByLoadIdAndNodeId ( loadId , warehouseId ) ;
@ -5671,10 +5776,15 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}
String loadCode = carsLoadEntity . getCarsNo ( ) ;
String loadStatus = carsLoadEntity . getLoadStatus ( ) ;
if ( "80" . equals ( loadStatus ) ) {
log . warn ( "##############unloadZero: 配载计划已经卸车确认 loadStatus={}" , loadStatus ) ;
return R . fail ( 405 , "配载计划已经卸车确认" ) ;
TrunklineCarsLoadLineEntity loadLineEntity = trunklineCarsLoadLineService . findEntityByLoadIdAndNodeId ( loadId , warehouseId ) ;
if ( Objects . isNull ( loadLineEntity ) ) {
log . warn ( "############unloadZero: 配载计划节点信息不存在 loadId={} warehouseId={}" , loadId , warehouseId ) ;
return R . fail ( 405 , "配载计划节点信息不存在" ) ;
}
String unloadStatus = loadLineEntity . getUnloadStatus ( ) ;
if ( ! "0" . equals ( unloadStatus ) ) {
log . warn ( "############unloadZero: 当前网点已经卸车确认 loadId={} warehouseId={}" , loadId , warehouseId ) ;
return R . fail ( 405 , "当前网点已经卸车确认" ) ;
}
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getEntityWarehouseId ( warehouseId ) ;