|
|
|
@ -98,73 +98,122 @@ public class DistributionDeliveryInfoServiceImpl extends BaseServiceImpl<Distrib
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<DistributionParcelListVO> selectDistributionDeliveryInfowrapPage(Map<String, Object> reservationPackageDTO, IPage<DistributionParcelListVO> page) { |
|
|
|
|
if (Func.isEmpty(reservationPackageDTO.get("reservationId"))) { |
|
|
|
|
// 参数非空校验
|
|
|
|
|
if (reservationPackageDTO == null || page == null) { |
|
|
|
|
throw new IllegalArgumentException("ReservationPackageDTO and page cannot be null"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// reservationId的数据类型转换安全性校验
|
|
|
|
|
String reservationIdStr = (String) reservationPackageDTO.get("reservationId"); |
|
|
|
|
if (Func.isEmpty(reservationIdStr)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
long reservationId; |
|
|
|
|
try { |
|
|
|
|
reservationId = Long.parseLong(reservationIdStr); |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
log.error("Invalid reservationId format: {}", reservationIdStr, e); |
|
|
|
|
throw new IllegalArgumentException("Invalid reservationId format"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 逻辑保持不变,优化了数据类型转换的安全性检查
|
|
|
|
|
if (Func.isNotEmpty(reservationPackageDTO.get("orderPackageStatus"))) { |
|
|
|
|
String orderPackageStatus = (String) reservationPackageDTO.get("orderPackageStatus"); |
|
|
|
|
if (Func.isNotBlank(orderPackageStatus)) { |
|
|
|
|
if (!"70".equals(orderPackageStatus)) { |
|
|
|
|
reservationPackageDTO.put("unSigning", "70"); |
|
|
|
|
reservationPackageDTO.remove("orderPackageStatus"); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotBlank(orderPackageStatus) && !"70".equals(orderPackageStatus)) { |
|
|
|
|
reservationPackageDTO.put("unSigning", "70"); |
|
|
|
|
reservationPackageDTO.remove("orderPackageStatus"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<DistributionParcelListEntity> parcelListEntityList = baseMapper.selectDistributionDeliverywrapInfoPage(page, reservationPackageDTO); |
|
|
|
|
|
|
|
|
|
Set<Long> ids = new HashSet<>(); |
|
|
|
|
Set<String> orderPackageCodes = new HashSet<>(); |
|
|
|
|
|
|
|
|
|
for (DistributionParcelListEntity distributionParcelListEntity : parcelListEntityList) { |
|
|
|
|
ids.add(distributionParcelListEntity.getId()); |
|
|
|
|
orderPackageCodes.add(distributionParcelListEntity.getOrderPackageCode()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<DistributionParcelListVO> parcelListVOS = DistributionParcelListWrapper.build().listVO(parcelListEntityList); |
|
|
|
|
parcelListVOS.forEach(p -> { |
|
|
|
|
//查询扫描表,
|
|
|
|
|
DistributionLoadscanEntity loadscanEntity = distributionLoadscanService.getOne(Wrappers.<DistributionLoadscanEntity>query().lambda() |
|
|
|
|
.eq(DistributionLoadscanEntity::getPackageId, p.getId()) |
|
|
|
|
.eq(DistributionLoadscanEntity::getReservationId, Long.parseLong((String) reservationPackageDTO.get("reservationId"))) |
|
|
|
|
.ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) |
|
|
|
|
.eq(DistributionLoadscanEntity::getOrderPackageCode, p.getOrderPackageCode()) |
|
|
|
|
); |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity)) { |
|
|
|
|
try { |
|
|
|
|
p.setLoadingTime(loadscanEntity.getScanTime()); |
|
|
|
|
switch (loadscanEntity.getScanStatus()) { |
|
|
|
|
case "1": |
|
|
|
|
p.setScanStatus(LoadingStatusConstant.quxiao.getName()); |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
p.setScanStatus(LoadingStatusConstant.saomiao.getName()); |
|
|
|
|
break; |
|
|
|
|
case "3": |
|
|
|
|
p.setScanStatus(LoadingStatusConstant.queren.getName()); |
|
|
|
|
break; |
|
|
|
|
case "4": |
|
|
|
|
p.setScanStatus(LoadingStatusConstant.yijianzhuangche.getName()); |
|
|
|
|
break; |
|
|
|
|
case "5": |
|
|
|
|
p.setScanStatus(LoadingStatusConstant.buluzhuangche.getName()); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
log.info("selectDistributionDeliveryInfowrapPage >>>loadscanEntity.getScanStatus() 不满足匹配条件 {}",loadscanEntity.getScanStatus()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getSigningTime())) { |
|
|
|
|
p.setSigningTime(loadscanEntity.getSigningTime()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getScanUser())) { |
|
|
|
|
p.setScanUser(loadscanEntity.getScanUser()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getDriverName())) { |
|
|
|
|
p.setDriverName(loadscanEntity.getDriverName()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getSigningUser())) { |
|
|
|
|
p.setSigningUser(loadscanEntity.getSigningUser()); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(">>> 系统异常",e); |
|
|
|
|
throw new CustomerException("系统异常,请联系管理员"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 保持不变,优化性能需要注意的是ids和orderPackageCodes的处理
|
|
|
|
|
List<DistributionLoadscanEntity> loadscanEntitys = distributionLoadscanService.list(Wrappers.<DistributionLoadscanEntity>query().lambda() |
|
|
|
|
.in(DistributionLoadscanEntity::getPackageId, ids) |
|
|
|
|
.eq(DistributionLoadscanEntity::getReservationId, reservationId) |
|
|
|
|
.ne(DistributionLoadscanEntity::getScanStatus, LoadingStatusConstant.quxiao.getValue()) |
|
|
|
|
.in(DistributionLoadscanEntity::getOrderPackageCode, orderPackageCodes) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 对加载的VO列表进行处理的逻辑抽取到一个独立的方法
|
|
|
|
|
processParcelListVOS(parcelListVOS, loadscanEntitys, reservationIdStr); |
|
|
|
|
|
|
|
|
|
return page.setRecords(parcelListVOS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void processParcelListVOS(List<DistributionParcelListVO> parcelListVOS, List<DistributionLoadscanEntity> loadscanEntitys, String reservationIdStr) { |
|
|
|
|
parcelListVOS.forEach(p -> { |
|
|
|
|
DistributionLoadscanEntity loadscanEntity = getLoadscanEntity(loadscanEntitys, p); |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity)) { |
|
|
|
|
try { |
|
|
|
|
updateParcelStatus(p, loadscanEntity); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("Processing parcel failed for reservationId: {}, Error: {}", reservationIdStr, e.getMessage(), e); |
|
|
|
|
throw new CustomerException("Processing parcel failed. Please contact administrator"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateParcelStatus(DistributionParcelListVO parcel, DistributionLoadscanEntity loadscanEntity) { |
|
|
|
|
parcel.setLoadingTime(loadscanEntity.getScanTime()); |
|
|
|
|
switch (loadscanEntity.getScanStatus()) { |
|
|
|
|
case "1": |
|
|
|
|
parcel.setScanStatus(LoadingStatusConstant.quxiao.getName()); |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
parcel.setScanStatus(LoadingStatusConstant.saomiao.getName()); |
|
|
|
|
break; |
|
|
|
|
case "3": |
|
|
|
|
parcel.setScanStatus(LoadingStatusConstant.queren.getName()); |
|
|
|
|
break; |
|
|
|
|
case "4": |
|
|
|
|
parcel.setScanStatus(LoadingStatusConstant.yijianzhuangche.getName()); |
|
|
|
|
break; |
|
|
|
|
case "5": |
|
|
|
|
parcel.setScanStatus(LoadingStatusConstant.buluzhuangche.getName()); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
log.info("loadscanEntity.getScanStatus() does not meet matching conditions: {}", loadscanEntity.getScanStatus()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getSigningTime())) { |
|
|
|
|
parcel.setSigningTime(loadscanEntity.getSigningTime()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getScanUser())) { |
|
|
|
|
parcel.setScanUser(loadscanEntity.getScanUser()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getDriverName())) { |
|
|
|
|
parcel.setDriverName(loadscanEntity.getDriverName()); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(loadscanEntity.getSigningUser())) { |
|
|
|
|
parcel.setSigningUser(loadscanEntity.getSigningUser()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DistributionLoadscanEntity getLoadscanEntity(List<DistributionLoadscanEntity> loadscanEntitys, DistributionParcelListVO p) { |
|
|
|
|
for (DistributionLoadscanEntity loadscanEntity : loadscanEntitys) { |
|
|
|
|
if(loadscanEntity.getPackageId().equals(p.getId())&& loadscanEntity.getOrderPackageCode().equals(p.getOrderPackageCode())){ |
|
|
|
|
return loadscanEntity; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<DistributionDeliveryInfoVO> selectDistributionDeliveryInfopackdetail(IPage<DistributionDeliveryInfoVO> page, DistributionDeliveryInfoDTO distributionDeliveryInfoDTO) { |
|
|
|
|
List<DistributionDeliveryInfoVO> distributionDeliveryInfoVOS = baseMapper.selectDistributionDeliverypackdetailPage(page, distributionDeliveryInfoDTO); |
|
|
|
|