Browse Source

1.优化代码结构

dist.1.3.0
pref_mail@163.com 10 months ago
parent
commit
1f77487f41
  1. 7
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionBillLadingAppController.java
  2. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java
  3. 521
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java

7
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionBillLadingAppController.java

@ -127,12 +127,7 @@ public class DistributionBillLadingAppController extends BladeController {
@ApiOperation(value = "自提扫描id")
@GetMapping("/scan")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "自提单ID", required = true),
@ApiImplicitParam(name = "coding", value = "包条码", required = true),
@ApiImplicitParam(name = "type", value = "类型 2 订单 1 库存品", required = true)
})
public Resp scan(@ApiIgnore @RequestParam Map<String, Object> distrilbutionBillLading){
public R scan(@ApiIgnore @RequestParam Map<String, Object> distrilbutionBillLading){
Resp scan = distrilbutionBillLadingService.getScan(distrilbutionBillLading);
//获取传入类型

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java

@ -2385,7 +2385,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
List<DistributionAppDeliveryListVO> distributionAppDeliveryListVOS = new ArrayList<>();
try {
//获取当前登录人
//获取当前登录人
BladeUser user = AuthUtil.getUser();
String roleId = user.getRoleId();
//判断当前登录人是否为司机

521
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java

@ -1179,7 +1179,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
//维护自提单状态
distrilbutionBillLading.setConditions(BillLadingStatusConstant.yitihuo.getValue());
distributionBillLadingScanService.list(Wrappers.<DistributionBillLadingScanEntity>query().lambda()
.eq(DistributionBillLadingScanEntity::getBillLadingId,distrilbutionBillLading.getId())
.eq(DistributionBillLadingScanEntity::getBillLadingId, distrilbutionBillLading.getId())
);
return R.success("操作成功");
@ -1381,7 +1381,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
case 1:
//定制品
for (DistributionParcelListEntity parcelListEntity : v) {
if (OrderPackageStatusConstant.yiqianshou.getValue().equals(parcelListEntity.getOrderPackageStatus())){
if (OrderPackageStatusConstant.yiqianshou.getValue().equals(parcelListEntity.getOrderPackageStatus())) {
continue;
}
DistributionBillLadingScanEntity distributionBillLadingScanEntity = new DistributionBillLadingScanEntity();
@ -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);
@ -2826,7 +2825,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
//查询提货信息
List<DistrilbutionBillStockEntity> list = distrilbutionBillStockService.list(Wrappers.<DistrilbutionBillStockEntity>query().lambda()
.eq(DistrilbutionBillStockEntity::getBillLadingId, distrilbutionBillLadingEntity.getId())
.in(DistrilbutionBillStockEntity::getOrderStatus, "1","3")
.in(DistrilbutionBillStockEntity::getOrderStatus, "1", "3")
.or(eq -> eq.eq(DistrilbutionBillStockEntity::getBillLadingId, distrilbutionBillLadingEntity.getId()).eq(DistrilbutionBillStockEntity::getOrderStatus, "3"))
);
list.forEach(i -> {
@ -2961,284 +2960,314 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
}
/**
* pda扫描
*
* @param distrilbutionBillLading
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Resp getScan(Map<String, Object> distrilbutionBillLading) {
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())) {
return Resp.scanFail("提货任务已完成!", "提货任务已完成!");
}
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse();
if (ObjectUtils.isNull(myCurrentWarehouse)) {
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()) {
return Resp.scanFail("该包件已签收!", "该包件已签收!");
}
public Resp getScanNew(Map<String, Object> distributionBillLading) {
// 参数校验
if (!isValidParameters(distributionBillLading)) {
return Resp.scanFail("3000", "参数不完整或无效!!");
}
//添加扫描记录
DistributionBillLadingScanEntity distributionBillLadingScan = new DistributionBillLadingScanEntity();
distributionBillLadingScan.setMaterialType((String) type);
distributionBillLadingScan.setBillLadingId(Long.parseLong(billLadingId.toString()));
distributionBillLadingScan.setScanType(1);
distributionBillLadingScan.setScanUser(AuthUtil.getUser().getNickName());
//扫描
if ("1".equals(type)) {
//查询该自提单存在几种品类的库存品
List<DistrilbutionBillLadingInventoryAppVO> inventoryAppVO = distributionDeliveryDetailsService.listCode(String.valueOf(billLadingId));
if (ObjectUtils.isNotNull(inventoryAppVO)) {
List<Long> stocklistIds = inventoryAppVO.stream().map(DistrilbutionBillLadingInventoryAppVO::getStockListId).collect(Collectors.toList());
//查询该自提单所有的库存品包件信息
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 (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());
Object billLadingId = distributionBillLading.get("id");
String coding = distributionBillLading.get("coding").toString();
String type = distributionBillLading.get("type").toString();
try {
DistrilbutionBillLadingEntity billLadingEntity1 = baseMapper.selectById((Serializable) billLadingId);
DistrilbutionAppBillLadingOrderMainVO billLadingOrderMainVO = baseMapper.getBillLadingOrderMainVO(Long.parseLong(billLadingId.toString()));
} else {
//不满足签收,记录为什么不满足
if (collect.size() > 1) {
//已备货库存品包件存在多条一样的
if (isTaskCompleted(billLadingOrderMainVO, billLadingEntity1)) {
return Resp.scanFail("提货任务已完成!", "提货任务已完成!");
}
log.info("########################PDA签收库存品包件存在多条一样的备货码值:{}", coding);
return Resp.scanFail("系统无此编码!", "系统无此编码");
} else {
//备货库存品不存在
return Resp.scanFail("系统无此编码!", "系统无此编码");
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse();
if (myCurrentWarehouse == null) {
return Resp.scanFail("请选择仓库!", "请选择仓库!");
}
}
}
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)
);
List<DistrilbutionBillLadingInventoryAppVO> billLadingInventoryAppVOS = stockListMap.get(stockListId);
if (Func.isNotEmpty(billLadingInventoryAppVOS)) {
DistrilbutionBillLadingInventoryAppVO distrilbutionBillLadingInventoryAppVO = billLadingInventoryAppVOS.get(0);
if (list.size() == distrilbutionBillLadingInventoryAppVO.getQuantity()) {
//修改完成状态
distributionAsyncService.getInventoryOrderSelfPickup(distrilbutionBillLadingInventoryAppVO.getLdddId());
}
if (list.size() > distrilbutionBillLadingInventoryAppVO.getQuantity()) {
return Resp.scanFail("已完成!", "已完成!!");
}
//修改库存品签收
distributionAsyncService.getInventorySelfPickup(distrilbutionBillLadingInventoryAppVO.getStockArticleId());
}
if (isAlreadySigned(billLadingId, coding, type)) {
return Resp.scanFail("该包件已签收!", "该包件已签收!");
}
} else {
return Resp.scanFail("库存品暂未备货请联系库管人员!", "库存品暂未备货请联系库管人员");
// 添加扫描记录
DistributionBillLadingScanEntity distributionBillLadingScan = new DistributionBillLadingScanEntity();
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("系统异常!", "系统异常,请联系管理员");
}
}
} else {
return Resp.scanFail("包件信息不存在", "包件信息不存在");
}
} else {
private boolean isValidParameters(Map<String, Object> distributionBillLading) {
return Func.isNotEmpty(distributionBillLading.get("id")) &&
Func.isNotEmpty(distributionBillLading.get("coding")) &&
Func.isNotEmpty(distributionBillLading.get("type"));
}
//查询订单是否已签收
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("包件信息错误", "包件信息错误");
}
private boolean isTaskCompleted(DistrilbutionAppBillLadingOrderMainVO billLadingOrderMainVO, DistrilbutionBillLadingEntity billLadingEntity1) {
return (billLadingOrderMainVO.getPlanNum() + billLadingOrderMainVO.getInventoryNub()) == billLadingOrderMainVO.getSignedNum() ||
("30".equals(billLadingEntity1.getConditions()));
}
DistrilbutionBillStockEntity one2 = distrilbutionBillStockService.getOne(Wrappers.<DistrilbutionBillStockEntity>query().lambda()
.eq(DistrilbutionBillStockEntity::getBillLadingId, billLadingId)
.apply("order_status in ('1' , '3')")
.eq(DistrilbutionBillStockEntity::getStockArticleId, list4.get(0).getStockArticleId())
);
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();
}
DistrilbutionBillPackageEntity one3 = distrilbutionBillPackageService.getOne(Wrappers.<DistrilbutionBillPackageEntity>query().lambda()
.eq(DistrilbutionBillPackageEntity::getBillLadingId, billLadingId)
.ne(DistrilbutionBillPackageEntity::getPacketBarStatus, 2)
.eq(DistrilbutionBillPackageEntity::getParceListId, list4.get(0).getId())
);
if (ObjectUtils.isNull(one3)) {
return Resp.scanFail("不是本客户的货!", "不是本客户的货!");
}
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);
}
}
if ("20".equals(one2.getConditions())) {
return Resp.scanFail("当前提货任务," + list4.get(0).getOrderCode() + "已齐套!", "当前提货任务," + list4.get(0).getOrderCode() + "已齐套!");
}
private Resp handleOrderProduct(String type, Object billLadingId, String coding, DistributionBillLadingScanEntity distributionBillLadingScan) {
List<DistrilbutionBillLadingInventoryAppVO> inventoryAppVO = distributionDeliveryDetailsService.listCode(String.valueOf(billLadingId));
if (inventoryAppVO == null) {
return Resp.scanFail("包件信息不存在", "包件信息不存在");
}
//查询订单存在吗
List<DistrilbutionBillStockEntity> list = distrilbutionBillStockService.list(Wrappers.<DistrilbutionBillStockEntity>query().lambda()
.eq(DistrilbutionBillStockEntity::getBillLadingId, billLadingId)
.ne(DistrilbutionBillStockEntity::getOrderStatus, "2")
);
if (list.isEmpty()) {
return Resp.scanFail("当前提货任务,订单不存在!", "当前提货任务,订单不存在!");
} else {
AtomicBoolean n = new AtomicBoolean(false);
List<Long> stocklistIds = inventoryAppVO.stream().map(DistrilbutionBillLadingInventoryAppVO::getStockListId).collect(Collectors.toList());
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())
);
if (inventoryPackage == null || inventoryPackage.isEmpty()) {
return Resp.scanFail("库存品暂未备货,请联系库管人员!", "库存品暂未备货,请联系库管人员");
}
// 获取订单的ID
List<Long> ls = list.stream() // 转换为Stream
.map(DistrilbutionBillStockEntity::getStockArticleId) // 提取每个元素的orderId
.collect(Collectors.toList()); // 收集到新的List<String>
// 检查库存品包件是否完成备货
boolean flag = inventoryPackage.stream().anyMatch(f -> StringUtils.isBlank(f.getStockPackageCode()));
if (flag) {
return Resp.scanFail("库存品备货未完成,请联系库管人员!", "库存品备货未完成,请联系库管人员");
}
DisStockListDetailEntity matchedPackage = inventoryPackage.stream()
.filter(f -> coding.equals(f.getStockPackageCode()))
.findFirst()
.orElse(null);
List<DistributionStockArticleEntity> distributionStockArticleEntityList = distributionStockArticleService.list(Wrappers.<DistributionStockArticleEntity>query().lambda()
.in(DistributionStockArticleEntity::getId, ls)
.ne(DistributionStockArticleEntity::getIsZero, "1")
);
if (matchedPackage == null) {
return Resp.scanFail("系统无此编码!", "系统无此编码");
}
List<DistributionParcelListEntity> list1 = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda()
.in(DistributionParcelListEntity::getStockArticleId, ls)
.eq(DistributionParcelListEntity::getConditions, 1)
);
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, matchedPackage.getStockListId())
);
List<DistrilbutionBillLadingInventoryAppVO> billLadingInventoryAppVOS = stockListMap.get(matchedPackage.getStockListId());
if (Func.isNotEmpty(billLadingInventoryAppVOS)) {
DistrilbutionBillLadingInventoryAppVO distrilbutionBillLadingInventoryAppVO = billLadingInventoryAppVOS.get(0);
if (list.size() == distrilbutionBillLadingInventoryAppVO.getQuantity()) {
//修改完成状态
distributionAsyncService.getInventoryOrderSelfPickup(distrilbutionBillLadingInventoryAppVO.getLdddId());
}
if (list.size() > distrilbutionBillLadingInventoryAppVO.getQuantity()) {
return Resp.scanFail("已完成!", "已完成!!");
}
//修改库存品签收
distributionAsyncService.getInventorySelfPickup(distrilbutionBillLadingInventoryAppVO.getStockArticleId());
}
List<DistributionBillLadingScanEntity> distributionBillLadingScanEntities = distributionBillLadingScanService.list(Wrappers.<DistributionBillLadingScanEntity>query().lambda()
.in(DistributionBillLadingScanEntity::getStockArticleId, ls)
.eq(DistributionBillLadingScanEntity::getMaterialType, "2")
.eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId)
);
// 其他逻辑...
return Resp.scanSuccess("签收成功", "签收成功");
}
list.forEach(so -> {
//查询包件信息
DistributionParcelListEntity distributionParcelListEntity = null;
private Resp handleInventoryProduct(String type, Object billLadingId, String coding, DistributionBillLadingScanEntity distributionBillLadingScan) {
for (DistributionParcelListEntity parcelListEntity : list1) {
log.debug("getScan parcelListEntity >>>> {}", parcelListEntity);
log.debug("getScan so >>>> {}", so);
log.debug("getScan coding >>>> {}", coding);
if (parcelListEntity.getStockArticleId().equals(so.getStockArticleId()) && parcelListEntity.getOrderPackageCode().equals(coding)) {
distributionParcelListEntity = parcelListEntity;
break;
}
}
BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse();
if (ObjectUtils.isNull(myCurrentWarehouse)) {
return Resp.scanFail("请选择仓库!", "请选择仓库!");
}
// 查询订单是否已签收
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 (distributionParcelListEntity != null) {
n.set(true);
//查询订单包件数量签收的信息
DistributionStockArticleEntity one = distributionStockArticleEntityList.stream().filter(s -> s.getId().equals(so.getStockArticleId())).findFirst().orElse(null);
if (list4.size() > 1) {
return Resp.scanFail("包件信息错误", "包件信息错误");
}
DistrilbutionBillStockEntity one2 = distrilbutionBillStockService.getOne(Wrappers.<DistrilbutionBillStockEntity>query().lambda()
.eq(DistrilbutionBillStockEntity::getBillLadingId, billLadingId)
.apply("order_status in ('1' , '3')")
.eq(DistrilbutionBillStockEntity::getStockArticleId, list4.get(0).getStockArticleId())
);
List<DistributionBillLadingScanEntity> list2 = new ArrayList<>();
for (DistributionBillLadingScanEntity distributionBillLadingScanEntity : distributionBillLadingScanEntities) {
if (distributionBillLadingScanEntity.getStockArticleId().equals(so.getStockArticleId())) {
list2.add(distributionBillLadingScanEntity);
}
}
DistrilbutionBillPackageEntity one3 = distrilbutionBillPackageService.getOne(Wrappers.<DistrilbutionBillPackageEntity>query().lambda()
.eq(DistrilbutionBillPackageEntity::getBillLadingId, billLadingId)
.ne(DistrilbutionBillPackageEntity::getPacketBarStatus, 2)
.eq(DistrilbutionBillPackageEntity::getParceListId, list4.get(0).getId())
);
if (ObjectUtils.isNull(one3)) {
return Resp.scanFail("不是本客户的货!", "不是本客户的货!");
}
if ("20".equals(one2.getConditions())) {
return Resp.scanFail("当前提货任务," + list4.get(0).getOrderCode() + "已齐套!", "当前提货任务," + list4.get(0).getOrderCode() + "已齐套!");
}
one.setOrderStatus(OrderStatusConstant.bufenqianshou.getValue());
//查询订单存在吗
List<DistrilbutionBillStockEntity> list = distrilbutionBillStockService.list(Wrappers.<DistrilbutionBillStockEntity>query().lambda()
.eq(DistrilbutionBillStockEntity::getBillLadingId, billLadingId)
.ne(DistrilbutionBillStockEntity::getOrderStatus, "2")
);
//判断当前签收数 修改订单和备货订单状态
if (one.getTotalNumber().equals(list2.size() + 1)) {
//
DistrilbutionBillStockEntity one1 = null;
if (list.isEmpty()) {
return Resp.scanFail("当前提货任务,订单不存在!", "当前提货任务,订单不存在!");
}
for (DistrilbutionBillStockEntity distrilbutionBillStockEntity : list) {
if (distrilbutionBillStockEntity.getStockArticleId().equals(so.getStockArticleId()) && distrilbutionBillStockEntity.getConditions().equals(BillLadingStatusConstant.daitihuo.getValue())) {
one1 = distrilbutionBillStockEntity;
}
}
AtomicBoolean n = new AtomicBoolean(false);
// 获取订单的ID
List<Long> ls = list.stream() // 转换为Stream
.map(DistrilbutionBillStockEntity::getStockArticleId) // 提取每个元素的orderId
.collect(Collectors.toList()); // 收集到新的List<String>
if (one1 != null) {
distributionAsyncService.updateBillStock(one1.getId());
}
one.setOrderStatus(OrderStatusConstant.qianshou.getValue());
}
//修改在库数量
if (ObjectUtils.isNotNull(one.getHandQuantity()) && one.getHandQuantity() > 0) {
int i = one.getHandQuantity() - 1;
int i2 = ObjectUtils.isNull(one.getSigninQuantity()) ? 1 : one.getSigninQuantity() + 1;
one.setHandQuantity(i);
one.setSigninQuantity(i2);
}
List<DistributionStockArticleEntity> distributionStockArticleEntityList = distributionStockArticleService.list(Wrappers.<DistributionStockArticleEntity>query().lambda()
.in(DistributionStockArticleEntity::getId, ls)
.ne(DistributionStockArticleEntity::getIsZero, "1")
);
// 修改订单状态
distributionStockArticleService.updateById(one);
List<DistributionParcelListEntity> list1 = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda()
.in(DistributionParcelListEntity::getStockArticleId, ls)
.eq(DistributionParcelListEntity::getConditions, 1)
);
//修改包件状态
distributionAsyncService.getSelfPickup(distributionParcelListEntity.getId());
distributionBillLadingScan.setParcelListId(distributionParcelListEntity.getId());
distributionBillLadingScan.setPacketBarCode(String.valueOf(coding));
//订单
distributionBillLadingScan.setStockArticleId(one.getId());
distributionBillLadingScan.setQuantity(1);
distributionBillLadingScan.setBillLadingId(Long.parseLong((String) billLadingId));
}
});
List<DistributionBillLadingScanEntity> distributionBillLadingScanEntities = distributionBillLadingScanService.list(Wrappers.<DistributionBillLadingScanEntity>query().lambda()
.in(DistributionBillLadingScanEntity::getStockArticleId, ls)
.eq(DistributionBillLadingScanEntity::getMaterialType, "2")
.eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId)
);
if (n.get()) {
distributionBillLadingScanService.save(distributionBillLadingScan);
} else {
return Resp.scanFail("当前订单,包件不存在!!", "当前订单,包件不存在!!");
list.forEach(so -> {
//查询包件信息
DistributionParcelListEntity distributionParcelListEntity = null;
for (DistributionParcelListEntity parcelListEntity : list1) {
log.debug("getScan parcelListEntity >>>> {}", parcelListEntity);
log.debug("getScan so >>>> {}", so);
log.debug("getScan coding >>>> {}", coding);
if (parcelListEntity.getStockArticleId().equals(so.getStockArticleId()) && parcelListEntity.getOrderPackageCode().equals(coding)) {
distributionParcelListEntity = parcelListEntity;
break;
}
}
if (distributionParcelListEntity != null) {
n.set(true);
//查询订单包件数量签收的信息
DistributionStockArticleEntity one = distributionStockArticleEntityList.stream().filter(s -> s.getId().equals(so.getStockArticleId())).findFirst().orElse(null);
List<DistributionBillLadingScanEntity> list2 = new ArrayList<>();
for (DistributionBillLadingScanEntity distributionBillLadingScanEntity : distributionBillLadingScanEntities) {
if (distributionBillLadingScanEntity.getStockArticleId().equals(so.getStockArticleId())) {
list2.add(distributionBillLadingScanEntity);
}
}
one.setOrderStatus(OrderStatusConstant.bufenqianshou.getValue());
//判断当前签收数 修改订单和备货订单状态
if (one.getTotalNumber().equals(list2.size() + 1)) {
//
DistrilbutionBillStockEntity one1 = null;
for (DistrilbutionBillStockEntity distrilbutionBillStockEntity : list) {
if (distrilbutionBillStockEntity.getStockArticleId().equals(so.getStockArticleId()) && distrilbutionBillStockEntity.getConditions().equals(BillLadingStatusConstant.daitihuo.getValue())) {
one1 = distrilbutionBillStockEntity;
break;
}
}
if (one1 != null) {
distributionAsyncService.updateBillStock(one1.getId());
}
one.setOrderStatus(OrderStatusConstant.qianshou.getValue());
}
//判断当前自提任务完成没有
String a = String.valueOf(billLadingId);
distributionAsyncService.getStockUPstate(Long.parseLong(a));
//修改在库数量
if (ObjectUtils.isNotNull(one.getHandQuantity()) && one.getHandQuantity() > 0) {
int i = one.getHandQuantity() - 1;
int i2 = ObjectUtils.isNull(one.getSigninQuantity()) ? 1 : one.getSigninQuantity() + 1;
one.setHandQuantity(i);
one.setSigninQuantity(i2);
}
// 修改订单状态
distributionStockArticleService.updateById(one);
//修改包件状态
distributionAsyncService.getSelfPickup(distributionParcelListEntity.getId());
distributionBillLadingScan.setParcelListId(distributionParcelListEntity.getId());
distributionBillLadingScan.setPacketBarCode(String.valueOf(coding));
//订单
distributionBillLadingScan.setStockArticleId(one.getId());
distributionBillLadingScan.setQuantity(1);
distributionBillLadingScan.setBillLadingId(Long.parseLong((String) billLadingId));
log.info(coding + " > > 签收成功!!");
return Resp.scanSuccess("签收成功", "签收成功");
}
}catch (Exception e){
log.error("自提扫描异常",e);
return Resp.scanFail("系统异常!", "系统异常,请联系管理员");
});
if (n.get()) {
distributionBillLadingScanService.save(distributionBillLadingScan);
} else {
return Resp.scanFail("当前订单,包件不存在!!", "当前订单,包件不存在!!");
}
return Resp.scanSuccess("签收成功", "签收成功");
}
/**
* pda扫描
*
* @param distrilbutionBillLading
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Resp getScan(Map<String, Object> distrilbutionBillLading) {
return this.getScanNew(distrilbutionBillLading);
}
/**
@ -3304,7 +3333,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
return false;
}
Set<Long> parcelListIds = new HashSet<>();
try{
try {
for (int i = 0; i < split.length; i++) {
String s = split[i];
//查询是不是上传图片
@ -3383,8 +3412,8 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
// 回传老系统自提数据
sendOldSystem(Long.parseLong(s));
}
}catch (Exception e){
log.error(">>>>>",e);
} catch (Exception e) {
log.error(">>>>>", e);
return false;
}
@ -3454,7 +3483,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
}
}
} catch (Exception e) {
log.error("回传工厂数据失败{}", e);
log.error("回传工厂数据失败", e);
}
}
@ -3527,18 +3556,20 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
Iterator<DistrilbutionBillPackageEntity> iterator = list.iterator();
while (iterator.hasNext()) {
DistrilbutionBillPackageEntity next = iterator.next();
if(ObjectUtils.isNotNull(next.getParceListId())){
if (ObjectUtils.isNotNull(next.getParceListId())) {
boolean b = list1.stream().anyMatch(q -> {
if(ObjectUtils.isNotNull(q.getParcelListId())){
if (ObjectUtils.isNotNull(q.getParcelListId())) {
return q.getParcelListId().equals(next.getParceListId());
}
return false;
});
});
if (b) {
//删除包件
iterator.remove();
}
}
}

Loading…
Cancel
Save