Browse Source

1.修复老系统推送包件没有运单信息的bug

dist.1.2.0^2
zhenghaoyu 7 months ago
parent
commit
0a0f106a9a
  1. 57
      blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java

57
blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java

@ -53,6 +53,8 @@ import org.springblade.common.constant.orderpackage.*;
import org.springblade.common.exception.CustomerException;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.redis.lock.LockType;
import org.springblade.core.redis.lock.RedisLockClient;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
@ -62,6 +64,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Slf4j
@AllArgsConstructor
@ -110,6 +113,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
private final BladeRedis redis;
private final RedisLockClient redisLockClient;
private final IRegionFeign regionFeign;
private final IBasicdataBrandClient basicdataBrandClient;
@ -813,7 +817,9 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo);
if(!Objects.isNull(warehouseWaybillEntity)){
entity.setWaybillId(warehouseWaybillEntity.getId());
entity.setWaybillNumber(waybillNo);
}else{
Long waybillId = saveWaybillEntity(waybillNo);
entity.setWaybillId(waybillId);
}
String brand = distributionStockArticleEntity.getBrand();
@ -894,24 +900,33 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
}
}
private void saveWaybillEntity(String waybillNo) {
private Long saveWaybillEntity(String waybillNo) {
log.info("#################handleDataToPlatform.saveWaybillEntity: {}", waybillNo);
if (StringUtil.isBlank(waybillNo)) {
return;
return null;
}
if(redis.exists("dealwithWaybillNo:"+waybillNo)){
log.info("###########saveWaybillEntity: 已有保存数据 waybillNo={}",waybillNo);
return;
}
// if (redis.exists("dealwithWaybillNo:" + waybillNo)) {
// log.info("###########saveWaybillEntity: 已有保存数据 waybillNo={}", waybillNo);
// return waybillId;
// }
String lockKey = "dealwithWaybillNo:" + waybillNo;
Long aLong = null;
boolean flag = false;
try {
flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 20000, 30000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if(flag){
//通过运单号先去查询新系统是否存在这个运单号
WarehouseWaybillEntity warehouseWaybill = warehouseWaybillClient.findByWaybillNo(waybillNo);
log.info("#################handleDataToPlatform.warehouseWaybill: {}", warehouseWaybill);
if (Objects.isNull(warehouseWaybill)) {
redis.setEx("dealwithWaybillNo:"+waybillNo,waybillNo,30L);
redis.setEx("dealwithWaybillNo:" + waybillNo, waybillNo, 30L);
//如果新系统中不存在这个运单,那么就去查询老系统的运单数据
WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNo);
log.info("#################handleDataToPlatform.wayBillEntity: {}", wayBillEntity);
@ -997,18 +1012,18 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
warehouseWaybill.setOtherFee(wayBillEntity.getOtherFee());
warehouseWaybill.setInsuranceFee(wayBillEntity.getPriceProtectionFee());
warehouseWaybill.setClaimingValue(wayBillEntity.getValue());
warehouseWaybill.setPayType(wayBillEntity.getPayType()+"");
warehouseWaybill.setPayWay(wayBillEntity.getPaymentMethod()+"");
warehouseWaybill.setPayType(wayBillEntity.getPayType() + "");
warehouseWaybill.setPayWay(wayBillEntity.getPaymentMethod() + "");
warehouseWaybill.setXPay(wayBillEntity.getXPay());
warehouseWaybill.setDPay(wayBillEntity.getDPay());
warehouseWaybill.setHPay(wayBillEntity.getHPay());
warehouseWaybill.setYPay(wayBillEntity.getYPay());
warehouseWaybill.setThirdOperationFee(wayBillEntity.getThreeHandleFee());
warehouseWaybill.setDeliveryWay(wayBillEntity.getSendType()+"");
warehouseWaybill.setUrgency(wayBillEntity.getUrgency()+"");
warehouseWaybill.setDeliveryWay(wayBillEntity.getSendType() + "");
warehouseWaybill.setUrgency(wayBillEntity.getUrgency() + "");
warehouseWaybill.setReceipt(wayBillEntity.getReceiptAsk());
warehouseWaybill.setReceiptNum(wayBillEntity.getReceiptNum());
warehouseWaybill.setTransportType(wayBillEntity.getShippingType()+"");
warehouseWaybill.setTransportType(wayBillEntity.getShippingType() + "");
warehouseWaybill.setRebate(wayBillEntity.getRebate());
BasicdataClientEntity agentClient = basicdataClientClient.findByName(agent);
@ -1026,9 +1041,9 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
warehouseWaybill.setIsDeleted(0);
warehouseWaybill.setCreateTime(date);
warehouseWaybill.setUpdateTime(date);
Long aLong = warehouseWaybillClient.addEnntity(warehouseWaybill);
if(aLong != 0){
aLong = warehouseWaybillClient.addEnntity(warehouseWaybill);
if (aLong != 0) {
redis.setEx("dealwithWaybillNoId:" + waybillNo,aLong, 30L);
List<WaybillDesEntity> desList = waybillDesClient.getDesList(waybillNo);
List<WarehouseWayBillDetail> warehouseWayBillDetails = new ArrayList<>();
for (WaybillDesEntity waybillDesEntity : desList) {
@ -1040,7 +1055,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
warehouseWayBillDetail.setWaybillNo(waybillNo);
String goodsName = waybillDesEntity.getName();
BasicdataCategoryEntity categoryEntity = categoryClient.findByName(goodsName);
if(Objects.isNull(categoryEntity)){
if (Objects.isNull(categoryEntity)) {
categoryEntity = new BasicdataCategoryEntity();
categoryEntity.setName(goodsName);
categoryEntity.setType(1);
@ -1050,7 +1065,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
categoryEntity.setCreateDept(1649331096241836033L);
Long categoryId = categoryClient.addReturnId(categoryEntity);
warehouseWayBillDetail.setProductId(categoryId);
}else{
} else {
warehouseWayBillDetail.setProductId(categoryEntity.getId());
}
warehouseWayBillDetail.setProductName(goodsName);
@ -1069,11 +1084,13 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
warehouseWaybill.setStockCount(warehouseWaybill.getStockCount() + 1);
warehouseWaybill.setUpdateTime(new Date());
warehouseWaybillClient.updateEntity(warehouseWaybill);
aLong = warehouseWaybill.getId();
}
//暂存单与运单的关联
saveAdvanceData(warehouseWaybill);
redisLockClient.unLock(lockKey, LockType.FAIR);
}
return aLong;
}
private void saveAdvanceData(WarehouseWaybillEntity warehouseWaybill) {

Loading…
Cancel
Save