Browse Source

自提订单已签订单移除BUG修复

dist.1.3.0
汤建军 6 months ago
parent
commit
8f29c7189f
  1. 50
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java
  2. 72
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillStockServiceImpl.java

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

@ -1109,6 +1109,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
log.error(method + "参数缺少PackageIds:{}", distrilbutionBillLading);
return R.fail("请联系管理员处理");
}
//查询选择包件是否存在有效数据
List<Long> list = Func.toLongList(distrilbutionBillLading.getPackageIds());
List<DistributionParcelListEntity> distributionParcelListEntities = distributionParcelListService.listByIds(list);
@ -1354,7 +1355,12 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
public List<DistributionBillLadingScanEntity> handleSignPackage(Map<Integer, List<DistributionParcelListEntity>> packageMap, Long id, BasicdataWarehouseEntity myCurrentWarehouse) {
String method = "###################DistributionBillLadingServiceImpl.handleSignPackage";
List<DistributionBillLadingScanEntity> ladingScanEntities = new ArrayList<>();
//查询自提信息
DistrilbutionBillLadingEntity billLadingEntity = this.getById(id);
List<String> orderCodes = new ArrayList<>();
List<Long> packageLockIds = new ArrayList<>();
packageMap.forEach((k, v) -> {
switch (k) {
case 1:
@ -1390,6 +1396,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
String singleTime = simpleDateFormat.format(new Date());
// 推送自提作业节点数据
sendNodeWorkDataBroadcast(parcelListEntity,id,singleTime,myCurrentWarehouse);
packageLockIds.add(parcelListEntity.getId());
}
break;
case 2:
@ -1462,6 +1469,22 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
}
});
//添加缓存
if (!packageLockIds.isEmpty()) {
List<Long> a = redis.get("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:");
if (Func.isNotEmpty(a)) {
boolean flag = a.stream().anyMatch(any -> packageLockIds.contains(any));
if (flag) {
//正在操作,请稍后重试
throw new RuntimeException("该包件正在被操作,请稍后再试!!!");
} else {
packageLockIds.addAll(a);
redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L);
}
} else {
redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L);
}
}
if (!orderCodes.isEmpty()) {
String collect = orderCodes.stream().distinct().collect(Collectors.joining(","));
log.info(method + "维护订单,orderCodes:{}", collect);
@ -3130,6 +3153,10 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
if (ObjectUtils.isNull(myCurrentWarehouse)) {
return Resp.scanFail("请选择仓库!", "请选择仓库!");
}
DistrilbutionBillLadingEntity billLadingEntity = this.getById(billLadingId);
// 查询订单是否已签收
List<DistributionParcelListEntity> list4 = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query()
.lambda()
@ -3172,7 +3199,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
if (list.isEmpty()) {
return Resp.scanFail("当前提货任务,订单不存在!", "当前提货任务,订单不存在!");
}
List<Long> packageLockIds = new ArrayList<>();
AtomicBoolean n = new AtomicBoolean(false);
// 获取订单的ID
List<Long> ls = list.stream() // 转换为Stream
@ -3266,7 +3293,7 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
distributionBillLadingScan.setStockArticleId(one.getId());
distributionBillLadingScan.setQuantity(1);
distributionBillLadingScan.setBillLadingId( billLadingId);
packageLockIds.add(distributionParcelListEntity.getId());
String signTime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date());
sendNodeWorkDataBroadcast(distributionParcelListEntity,billLadingId,signTime, myCurrentWarehouse);
@ -3305,9 +3332,22 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
.setHeader("x-delay", 3000);
return message;
});
//添加缓存
if (!packageLockIds.isEmpty()) {
List<Long> a = redis.get("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:");
if (Func.isNotEmpty(a)) {
boolean flag = a.stream().anyMatch(any -> packageLockIds.contains(any));
if (flag) {
//正在操作,请稍后重试
throw new RuntimeException("该包件正在被操作,请稍后再试!!!");
} else {
packageLockIds.addAll(a);
redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L);
}
} else {
redis.setEx("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:", packageLockIds, 60L);
}
}
return Resp.scanSuccess("签收成功", "签收成功");
}

72
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillStockServiceImpl.java

@ -27,26 +27,26 @@ import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.distribution.dto.DistrilbutionBillStockDTO;
import com.logpm.distribution.dto.app.StockupDTO;
import com.logpm.distribution.entity.DistributionBillLadingScanEntity;
import com.logpm.distribution.entity.DistrilbutionBillPackageEntity;
import com.logpm.distribution.entity.DistrilbutionBillStockEntity;
import com.logpm.distribution.entity.*;
import com.logpm.distribution.excel.DistributionBillOrderExcel;
import com.logpm.distribution.excel.DistributionBillOrderPackExcel;
import com.logpm.distribution.excel.DistrilbutionBillStockExcel;
import com.logpm.distribution.mapper.DistrilbutionBillStockMapper;
import com.logpm.distribution.service.IDistributionBillLadingScanService;
import com.logpm.distribution.service.IDistrilbutionBillPackageService;
import com.logpm.distribution.service.IDistrilbutionBillStockService;
import com.logpm.distribution.service.*;
import com.logpm.distribution.vo.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.DictBizConstant;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;
import org.springblade.system.entity.User;
import org.springblade.system.feign.IUserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -62,14 +62,30 @@ import java.util.stream.Collectors;
* @since 2023-07-25
*/
@Service
@AllArgsConstructor
@Slf4j
public class DistrilbutionBillStockServiceImpl extends BaseServiceImpl<DistrilbutionBillStockMapper, DistrilbutionBillStockEntity> implements IDistrilbutionBillStockService {
private final IUserClient userClient;
@Autowired
private IUserClient userClient;
private final IDistrilbutionBillPackageService distrilbutionBillPackageService;
@Autowired
private BladeRedis redis;
private final IDistributionBillLadingScanService distributionBillLadingScanService;
@Autowired
private IBasicdataWarehouseClient warehouseClient;
@Autowired
private IDistrilbutionBillPackageService distrilbutionBillPackageService;
@Autowired
@Lazy
private IDistributionBillLadingScanService distributionBillLadingScanService;
@Autowired
@Lazy
private IDistrilbutionBillLadingService distrilbutionBillLadingService;
@Autowired
@Lazy
private IDistributionStockArticleService distributionStockArticleService;
@ -266,11 +282,47 @@ public class DistrilbutionBillStockServiceImpl extends BaseServiceImpl<Distrilbu
@Override
public boolean judgmentRemove(Long billLadingId, Long orderId) {
//校验是否正在被签收操作
DistrilbutionBillLadingEntity billLadingEntity = distrilbutionBillLadingService.getById(billLadingId);
if (Func.isEmpty(billLadingEntity)){
log.error("billLading info is null,billLading error ID:{}",billLadingId);
return false;
}
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
if (Func.isEmpty(myCurrentWarehouse)){
log.error("warehosue is not choice");
return false;
}
//此订单存在扫描记录既无法进行取消操作
List<DistributionBillLadingScanEntity> ladingScanEntities = distributionBillLadingScanService.list(Wrappers.<DistributionBillLadingScanEntity>query().lambda()
.eq(DistributionBillLadingScanEntity::getBillLadingId, billLadingId)
.eq(DistributionBillLadingScanEntity::getStockArticleId, orderId)
);
if (!ladingScanEntities.isEmpty()) {
//判断是否存在别人在进行签收操作
List<Long> a = redis.get("warehouseId:" + myCurrentWarehouse.getId() + "pickupBatch:" + billLadingEntity.getPickupBatch() + "orderPackageCode:");
List<Long> packageIds = ladingScanEntities.stream().map(DistributionBillLadingScanEntity::getParcelListId).collect(Collectors.toList());
if (!packageIds.isEmpty() && !a.isEmpty()) {
boolean flag = a.stream().anyMatch(any -> packageIds.contains(any));
if (flag){
List<Long> ids = a.stream().filter(f -> packageIds.contains(f)).collect(Collectors.toList());
List<Long> orderIds = ladingScanEntities.stream().filter(f -> ids.contains(f.getParcelListId())).map(DistributionBillLadingScanEntity::getStockArticleId).distinct().collect(Collectors.toList());
List<DistributionStockArticleEntity> distributionStockArticleEntities = distributionStockArticleService.listByIds(orderIds);
if (!distributionStockArticleEntities.isEmpty()) {
String orderCodes = distributionStockArticleEntities.stream().map(DistributionStockArticleEntity::getOrderCode).collect(Collectors.joining(","));
log.error("these orderCodes is operated on by now:{}",orderCodes);
throw new RuntimeException(orderCodes+"订单正在进行操作,请稍后再试!!!");
}
}
}
}
return ladingScanEntities.isEmpty();
}

Loading…
Cancel
Save