|
|
|
@ -2513,7 +2513,6 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
List<DistributionParcelListEntity> list2 = distributionParcelListService.list(queryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<DistributionBillLadingScanEntity> qw = new QueryWrapper<>(); |
|
|
|
|
qw.in("stock_article_id", ids) |
|
|
|
|
.eq("is_deleted", 0); |
|
|
|
@ -2961,105 +2960,129 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* pda扫描 |
|
|
|
|
* |
|
|
|
|
* @param distrilbutionBillLading |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public Resp getScan(Map<String, Object> distrilbutionBillLading) { |
|
|
|
|
public Resp getScanNew(Map<String, Object> distributionBillLading) { |
|
|
|
|
// 参数校验
|
|
|
|
|
if (!isValidParameters(distributionBillLading)) { |
|
|
|
|
return Resp.scanFail("3000", "参数不完整或无效!!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object billLadingId = distributionBillLading.get("id"); |
|
|
|
|
String coding = distributionBillLading.get("coding").toString(); |
|
|
|
|
String type = distributionBillLading.get("type").toString(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
Object billLadingId = distrilbutionBillLading.get("id"); //提货ID
|
|
|
|
|
Object coding = distrilbutionBillLading.get("coding"); //包条码
|
|
|
|
|
Object type = distrilbutionBillLading.get("type"); //类型 2 订制品包件 1 库存品
|
|
|
|
|
if (Func.isNull(billLadingId) || ObjectUtil.isEmpty(coding) || Func.isNull(type)) { |
|
|
|
|
return Resp.scanFail("3000", "参数不完整!!"); |
|
|
|
|
} else { |
|
|
|
|
DistrilbutionBillLadingEntity billLadingEntity1 = baseMapper.selectById((Serializable) billLadingId); |
|
|
|
|
DistrilbutionAppBillLadingOrderMainVO billLadingOrderMainVO = baseMapper.getBillLadingOrderMainVO(Long.parseLong((String) billLadingId)); |
|
|
|
|
Integer planNum = billLadingOrderMainVO.getPlanNum(); |
|
|
|
|
Integer signedNum = billLadingOrderMainVO.getSignedNum(); |
|
|
|
|
if ((planNum + billLadingOrderMainVO.getInventoryNub()) == signedNum) { |
|
|
|
|
return Resp.scanFail("提货任务扫描已完成!", "提货任务扫描已完成!"); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotNull(billLadingEntity1) && "30".equals(billLadingEntity1.getConditions())) { |
|
|
|
|
DistrilbutionAppBillLadingOrderMainVO billLadingOrderMainVO = baseMapper.getBillLadingOrderMainVO(Long.parseLong(billLadingId.toString())); |
|
|
|
|
|
|
|
|
|
if (isTaskCompleted(billLadingOrderMainVO, billLadingEntity1)) { |
|
|
|
|
return Resp.scanFail("提货任务已完成!", "提货任务已完成!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); |
|
|
|
|
if (ObjectUtils.isNull(myCurrentWarehouse)) { |
|
|
|
|
if (myCurrentWarehouse == null) { |
|
|
|
|
return Resp.scanFail("请选择仓库!", "请选择仓库!"); |
|
|
|
|
} |
|
|
|
|
//查询是否签收
|
|
|
|
|
List<DistributionBillLadingScanEntity> list3 = distributionBillLadingScanService.list(Wrappers.<DistributionBillLadingScanEntity>query().lambda() |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId) |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getMaterialType, type) |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getPacketBarCode, coding) |
|
|
|
|
); |
|
|
|
|
if (!list3.isEmpty()) { |
|
|
|
|
|
|
|
|
|
if (isAlreadySigned(billLadingId, coding, type)) { |
|
|
|
|
return Resp.scanFail("该包件已签收!", "该包件已签收!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 添加扫描记录
|
|
|
|
|
DistributionBillLadingScanEntity distributionBillLadingScan = new DistributionBillLadingScanEntity(); |
|
|
|
|
distributionBillLadingScan.setMaterialType((String) type); |
|
|
|
|
distributionBillLadingScan.setMaterialType(type); |
|
|
|
|
distributionBillLadingScan.setBillLadingId(Long.parseLong(billLadingId.toString())); |
|
|
|
|
distributionBillLadingScan.setScanType(1); |
|
|
|
|
distributionBillLadingScan.setScanUser(AuthUtil.getUser().getNickName()); |
|
|
|
|
//扫描
|
|
|
|
|
return processScan(type, billLadingId, coding, distributionBillLadingScan); |
|
|
|
|
|
|
|
|
|
// return Resp.scanSuccess("签收成功", "签收成功");
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("自提扫描异常", e); |
|
|
|
|
return Resp.scanFail("系统异常!", "系统异常,请联系管理员"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isValidParameters(Map<String, Object> distributionBillLading) { |
|
|
|
|
return Func.isNotEmpty(distributionBillLading.get("id")) && |
|
|
|
|
Func.isNotEmpty(distributionBillLading.get("coding")) && |
|
|
|
|
Func.isNotEmpty(distributionBillLading.get("type")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isTaskCompleted(DistrilbutionAppBillLadingOrderMainVO billLadingOrderMainVO, DistrilbutionBillLadingEntity billLadingEntity1) { |
|
|
|
|
return (billLadingOrderMainVO.getPlanNum() + billLadingOrderMainVO.getInventoryNub()) == billLadingOrderMainVO.getSignedNum() || |
|
|
|
|
("30".equals(billLadingEntity1.getConditions())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isAlreadySigned(Object billLadingId, String coding, String type) { |
|
|
|
|
List<DistributionBillLadingScanEntity> list3 = distributionBillLadingScanService.list(Wrappers.<DistributionBillLadingScanEntity>query() |
|
|
|
|
.lambda() |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId) |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getMaterialType, type) |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getPacketBarCode, coding) |
|
|
|
|
); |
|
|
|
|
return !list3.isEmpty(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Resp processScan(String type, Object billLadingId, String coding, DistributionBillLadingScanEntity distributionBillLadingScan) { |
|
|
|
|
if ("1".equals(type)) { |
|
|
|
|
//查询该自提单存在几种品类的库存品
|
|
|
|
|
// 处理库存品包件逻辑
|
|
|
|
|
return handleOrderProduct(type, billLadingId, coding, distributionBillLadingScan); |
|
|
|
|
} else { |
|
|
|
|
// 处理库定制包件逻辑
|
|
|
|
|
return handleInventoryProduct(type, billLadingId, coding, distributionBillLadingScan); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Resp handleOrderProduct(String type, Object billLadingId, String coding, DistributionBillLadingScanEntity distributionBillLadingScan) { |
|
|
|
|
List<DistrilbutionBillLadingInventoryAppVO> inventoryAppVO = distributionDeliveryDetailsService.listCode(String.valueOf(billLadingId)); |
|
|
|
|
if (ObjectUtils.isNotNull(inventoryAppVO)) { |
|
|
|
|
if (inventoryAppVO == null) { |
|
|
|
|
return Resp.scanFail("包件信息不存在", "包件信息不存在"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Long> stocklistIds = inventoryAppVO.stream().map(DistrilbutionBillLadingInventoryAppVO::getStockListId).collect(Collectors.toList()); |
|
|
|
|
//查询该自提单所有的库存品包件信息
|
|
|
|
|
List<DisStockListDetailEntity> inventoryPackage = disStockListDetailService.list(Wrappers.<DisStockListDetailEntity>query().lambda() |
|
|
|
|
if(stocklistIds.isEmpty()){ |
|
|
|
|
return Resp.scanFail("库存品暂未备货,请联系库管人员!", "库存品暂未备货,请联系库管人员"); |
|
|
|
|
} |
|
|
|
|
List<DisStockListDetailEntity> inventoryPackage = disStockListDetailService.list(Wrappers.<DisStockListDetailEntity>query() |
|
|
|
|
.lambda() |
|
|
|
|
.eq(DisStockListDetailEntity::getReservationId, billLadingId) |
|
|
|
|
.in(DisStockListDetailEntity::getStockListId, stocklistIds) |
|
|
|
|
.ne(DisStockListDetailEntity::getStockPackageStatus, ReservationPackageStatusConstant.quxiao.getValue()) |
|
|
|
|
); |
|
|
|
|
Long stockListId = 0L; |
|
|
|
|
if (Func.isNotEmpty(inventoryPackage)) { |
|
|
|
|
//检测库存品包件是否都已经完成备货
|
|
|
|
|
boolean flag = inventoryPackage.stream().anyMatch(f -> Func.isEmpty(f.getStockPackageCode())); |
|
|
|
|
|
|
|
|
|
if (inventoryPackage == null || inventoryPackage.isEmpty()) { |
|
|
|
|
return Resp.scanFail("库存品暂未备货,请联系库管人员!", "库存品暂未备货,请联系库管人员"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 检查库存品包件是否完成备货
|
|
|
|
|
boolean flag = inventoryPackage.stream().anyMatch(f -> StringUtils.isBlank(f.getStockPackageCode())); |
|
|
|
|
if (flag) { |
|
|
|
|
return Resp.scanFail("库存品备货未完成,请联系库管人员!", "库存品备货未完成,请联系库管人员"); |
|
|
|
|
} |
|
|
|
|
//校验包件李彪是否存在满足码值的包件
|
|
|
|
|
List<DisStockListDetailEntity> collect = inventoryPackage.stream().filter(f -> coding.equals(f.getStockPackageCode())).collect(Collectors.toList()); |
|
|
|
|
if (collect.size() == 1) { |
|
|
|
|
//满足签收
|
|
|
|
|
distributionBillLadingScan.setPacketBarCode((String) coding); |
|
|
|
|
distributionBillLadingScan.setStockListId(collect.get(0).getStockListId()); |
|
|
|
|
distributionBillLadingScan.setQuantity(1); |
|
|
|
|
distributionBillLadingScanService.save(distributionBillLadingScan); |
|
|
|
|
stockListId = collect.get(0).getStockListId(); |
|
|
|
|
//扣减库存
|
|
|
|
|
distributionStockListMapper.deductionQuantityStock(collect.get(0).getStockListId(), collect.get(0).getNum()); |
|
|
|
|
|
|
|
|
|
DisStockListDetailEntity matchedPackage = inventoryPackage.stream() |
|
|
|
|
.filter(f -> coding.equals(f.getStockPackageCode())) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElse(null); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//不满足签收,记录为什么不满足
|
|
|
|
|
if (collect.size() > 1) { |
|
|
|
|
//已备货库存品包件存在多条一样的
|
|
|
|
|
|
|
|
|
|
log.info("########################PDA签收库存品包件存在多条一样的备货码值:{}", coding); |
|
|
|
|
if (matchedPackage == null) { |
|
|
|
|
return Resp.scanFail("系统无此编码!", "系统无此编码"); |
|
|
|
|
} else { |
|
|
|
|
//备货库存品不存在
|
|
|
|
|
return Resp.scanFail("系统无此编码!", "系统无此编码"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
distributionBillLadingScan.setPacketBarCode(coding); |
|
|
|
|
distributionBillLadingScan.setStockListId(matchedPackage.getStockListId()); |
|
|
|
|
distributionBillLadingScan.setQuantity(1); |
|
|
|
|
distributionBillLadingScanService.save(distributionBillLadingScan); |
|
|
|
|
distributionStockListMapper.deductionQuantityStock(matchedPackage.getStockListId(), matchedPackage.getNum()); |
|
|
|
|
|
|
|
|
|
Map<Long, List<DistrilbutionBillLadingInventoryAppVO>> stockListMap = inventoryAppVO.stream().collect(Collectors.groupingBy(DistrilbutionBillLadingInventoryAppVO::getStockListId)); |
|
|
|
|
//查询签收数量
|
|
|
|
|
List<DistributionBillLadingScanEntity> list = distributionBillLadingScanService.list(Wrappers.<DistributionBillLadingScanEntity>query().lambda() |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId) |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getMaterialType, "1") |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getStockListId, stockListId) |
|
|
|
|
.eq(DistributionBillLadingScanEntity::getStockListId, matchedPackage.getStockListId()) |
|
|
|
|
); |
|
|
|
|
List<DistrilbutionBillLadingInventoryAppVO> billLadingInventoryAppVOS = stockListMap.get(stockListId); |
|
|
|
|
List<DistrilbutionBillLadingInventoryAppVO> billLadingInventoryAppVOS = stockListMap.get(matchedPackage.getStockListId()); |
|
|
|
|
if (Func.isNotEmpty(billLadingInventoryAppVOS)) { |
|
|
|
|
DistrilbutionBillLadingInventoryAppVO distrilbutionBillLadingInventoryAppVO = billLadingInventoryAppVOS.get(0); |
|
|
|
|
if (list.size() == distrilbutionBillLadingInventoryAppVO.getQuantity()) { |
|
|
|
@ -3073,24 +3096,28 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
distributionAsyncService.getInventorySelfPickup(distrilbutionBillLadingInventoryAppVO.getStockArticleId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
return Resp.scanFail("库存品暂未备货请联系库管人员!", "库存品暂未备货请联系库管人员"); |
|
|
|
|
|
|
|
|
|
// 其他逻辑...
|
|
|
|
|
return Resp.scanSuccess("签收成功", "签收成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
return Resp.scanFail("包件信息不存在", "包件信息不存在"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
private Resp handleInventoryProduct(String type, Object billLadingId, String coding, DistributionBillLadingScanEntity distributionBillLadingScan) { |
|
|
|
|
|
|
|
|
|
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); |
|
|
|
|
if (ObjectUtils.isNull(myCurrentWarehouse)) { |
|
|
|
|
return Resp.scanFail("请选择仓库!", "请选择仓库!"); |
|
|
|
|
} |
|
|
|
|
// 查询订单是否已签收
|
|
|
|
|
List<DistributionParcelListEntity> list4 = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda() |
|
|
|
|
List<DistributionParcelListEntity> list4 = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query() |
|
|
|
|
.lambda() |
|
|
|
|
.eq(DistributionParcelListEntity::getOrderPackageCode, coding) |
|
|
|
|
.eq(DistributionParcelListEntity::getWarehouseId, myCurrentWarehouse.getId()) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (list4.isEmpty()) { |
|
|
|
|
return Resp.scanFail(PdaAudioLingoStatus.baojianbucunzai.getName(), PdaAudioLingoStatus.baojianbucunzai.getName()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (list4.size() > 1) { |
|
|
|
|
return Resp.scanFail("包件信息错误", "包件信息错误"); |
|
|
|
|
} |
|
|
|
@ -3109,7 +3136,6 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
if (ObjectUtils.isNull(one3)) { |
|
|
|
|
return Resp.scanFail("不是本客户的货!", "不是本客户的货!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("20".equals(one2.getConditions())) { |
|
|
|
|
return Resp.scanFail("当前提货任务," + list4.get(0).getOrderCode() + "已齐套!", "当前提货任务," + list4.get(0).getOrderCode() + "已齐套!"); |
|
|
|
|
} |
|
|
|
@ -3119,12 +3145,12 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
.eq(DistrilbutionBillStockEntity::getBillLadingId, billLadingId) |
|
|
|
|
.ne(DistrilbutionBillStockEntity::getOrderStatus, "2") |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
return Resp.scanFail("当前提货任务,订单不存在!", "当前提货任务,订单不存在!"); |
|
|
|
|
} else { |
|
|
|
|
AtomicBoolean n = new AtomicBoolean(false); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
AtomicBoolean n = new AtomicBoolean(false); |
|
|
|
|
// 获取订单的ID
|
|
|
|
|
List<Long> ls = list.stream() // 转换为Stream
|
|
|
|
|
.map(DistrilbutionBillStockEntity::getStockArticleId) // 提取每个元素的orderId
|
|
|
|
@ -3148,6 +3174,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
.eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.forEach(so -> { |
|
|
|
|
//查询包件信息
|
|
|
|
|
|
|
|
|
@ -3187,6 +3214,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
for (DistrilbutionBillStockEntity distrilbutionBillStockEntity : list) { |
|
|
|
|
if (distrilbutionBillStockEntity.getStockArticleId().equals(so.getStockArticleId()) && distrilbutionBillStockEntity.getConditions().equals(BillLadingStatusConstant.daitihuo.getValue())) { |
|
|
|
|
one1 = distrilbutionBillStockEntity; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3217,6 +3245,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
distributionBillLadingScan.setBillLadingId(Long.parseLong((String) billLadingId)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (n.get()) { |
|
|
|
@ -3224,21 +3253,21 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
} else { |
|
|
|
|
return Resp.scanFail("当前订单,包件不存在!!", "当前订单,包件不存在!!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//判断当前自提任务完成没有
|
|
|
|
|
String a = String.valueOf(billLadingId); |
|
|
|
|
distributionAsyncService.getStockUPstate(Long.parseLong(a)); |
|
|
|
|
|
|
|
|
|
log.info(coding + " > > 签收成功!!"); |
|
|
|
|
return Resp.scanSuccess("签收成功", "签收成功"); |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("自提扫描异常",e); |
|
|
|
|
return Resp.scanFail("系统异常!", "系统异常,请联系管理员"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* pda扫描 |
|
|
|
|
* |
|
|
|
|
* @param distrilbutionBillLading |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public Resp getScan(Map<String, Object> distrilbutionBillLading) { |
|
|
|
|
return this.getScanNew(distrilbutionBillLading); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -3454,7 +3483,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("回传工厂数据失败{}", e); |
|
|
|
|
log.error("回传工厂数据失败", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3539,6 +3568,8 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
//删除包件
|
|
|
|
|
iterator.remove(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|