From 7723f33924251eb56728e8966cfde24f5eae836f Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Fri, 6 Sep 2024 11:58:17 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=8E=A8=E9=80=81=E6=95=B0=E6=8D=AE=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E8=BF=90=E5=8D=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PanFactoryDataServiceImpl.java | 401 ++++++++---------- 1 file changed, 182 insertions(+), 219 deletions(-) diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java index cab9914fd..56343ed2c 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java @@ -9,16 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.logpm.basic.entity.BasicMaterialEntity; import com.logpm.basic.feign.IBasicMaterialClient; -import com.logpm.basicdata.entity.BasicdataBrandEntity; -import com.logpm.basicdata.entity.BasicdataCategoryEntity; -import com.logpm.basicdata.entity.BasicdataClientEntity; -import com.logpm.basicdata.entity.BasicdataStoreBusinessEntity; -import com.logpm.basicdata.entity.BasicdataWarehouseEntity; -import com.logpm.basicdata.feign.IBasicdataBrandClient; -import com.logpm.basicdata.feign.IBasicdataCategoryClient; -import com.logpm.basicdata.feign.IBasicdataClientClient; -import com.logpm.basicdata.feign.IBasicdataStoreBusinessClient; -import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.basicdata.entity.*; +import com.logpm.basicdata.feign.*; import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.distribution.entity.DistributionStockArticleEntity; import com.logpm.distribution.feign.IDistributionParcelListClient; @@ -37,23 +29,8 @@ import com.logpm.factory.snm.bean.Resp; import com.logpm.factory.snm.entity.PanFactoryOrder; import com.logpm.factory.snm.entity.PanPackageInfo; import com.logpm.factory.snm.entity.PanPackageList; -import com.logpm.oldproject.entity.AdvanceDetailEntity; -import com.logpm.oldproject.entity.AdvanceEntity; -import com.logpm.oldproject.entity.DetailProductEntity; -import com.logpm.oldproject.entity.OrderDetailEntity; -import com.logpm.oldproject.entity.TrayScanDesEntity; -import com.logpm.oldproject.entity.TrayScanEntity; -import com.logpm.oldproject.entity.WayBillEntity; -import com.logpm.oldproject.entity.WaybillDesEntity; -import com.logpm.oldproject.feign.IAdvanceClient; -import com.logpm.oldproject.feign.IAdvanceDetailClient; -import com.logpm.oldproject.feign.IDetailProductClient; -import com.logpm.oldproject.feign.IOrderDetailClient; -import com.logpm.oldproject.feign.ITrayScanClient; -import com.logpm.oldproject.feign.ITrayScanDesClient; -import com.logpm.oldproject.feign.IWarehouseClient; -import com.logpm.oldproject.feign.IWayBillClient; -import com.logpm.oldproject.feign.IWaybillDesClient; +import com.logpm.oldproject.entity.*; +import com.logpm.oldproject.feign.*; import com.logpm.oldproject.vo.DistributionParcelListEntityVO; import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; @@ -70,23 +47,13 @@ import com.logpm.warehouse.feign.IWarehouseWaybillClient; import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; import org.springblade.common.constant.TenantNum; -import org.springblade.common.constant.order.OrderFreezeStatusConstant; -import org.springblade.common.constant.order.OrderGroundingStatusConstant; -import org.springblade.common.constant.order.OrderReceiveStatusConstant; -import org.springblade.common.constant.order.OrderReservationStatusConstant; -import org.springblade.common.constant.order.OrderStatusConstant; -import org.springblade.common.constant.order.OrderStockupStatusConstant; -import org.springblade.common.constant.orderpackage.OrderPackageFreezeStatusConstant; -import org.springblade.common.constant.orderpackage.OrderPackageGroundingStatusConstant; -import org.springblade.common.constant.orderpackage.OrderPackageReservationStatusConstant; -import org.springblade.common.constant.orderpackage.OrderPackageStatusConstant; -import org.springblade.common.constant.orderpackage.OrderPackageStockupStatusConstant; +import org.springblade.common.constant.order.*; +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; @@ -96,12 +63,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; +import java.util.concurrent.TimeUnit; @Slf4j @AllArgsConstructor @@ -151,7 +114,6 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { private final BladeRedis redis; private final RedisLockClient redisLockClient; - private final RedissonClient redissonClient; private final IRegionFeign regionFeign; private final IBasicdataBrandClient basicdataBrandClient; @@ -536,7 +498,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { String takeCompany= ""; if(ObjectUtil.isNotEmpty(supplyData)){ destinationWarehouse = supplyData.get("destinationWarehouse");//目的仓名称 - takeCompany = supplyData.get("takeCompany"); + takeCompany = supplyData.get("takeCompany"); } // OrderDetailEntity orderDetailEntity = orderDetailClient.findByUnitNo(unitNo); @@ -564,7 +526,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { if (Objects.isNull(distributionStockArticleEntity)) { Date date = new Date(); if(StringUtil.isNoneBlank(operationTime)){ - date = CommonUtil.StringToDate(operationTime); + date = CommonUtil.StringToDate(operationTime); } log.info("#################handleDataToPlatform.waybillNoNum: {}", waybillNoNum); @@ -596,9 +558,9 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { distributionStockArticleEntity.setCompleteSet(0); } log.info("############basicdataWarehouseEntity {}", basicdataWarehouseEntity); - distributionStockArticleEntity.setCreateDept(basicdataWarehouseEntity.getDepartment()); + distributionStockArticleEntity.setCreateDept(basicdataWarehouseEntity.getDepartment()); - WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNoNum); + WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNoNum); if(Objects.isNull(wayBillEntity)){ @@ -949,187 +911,188 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { // log.info("###########saveWaybillEntity: 已有保存数据 waybillNo={}", waybillNo); // return waybillId; // } - //通过运单号先去查询新系统是否存在这个运单号 - WarehouseWaybillEntity warehouseWaybill = warehouseWaybillClient.findByWaybillNo(waybillNo); - String lockKey = "dealwithWaybillNo:lock:" + waybillNo; + + String lockKey = "dealwithWaybillNo:" + waybillNo; Long aLong = null; boolean flag = false; - RLock lock = redissonClient.getLock(lockKey); try { + flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 20000, 30000, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + log.info("##############我的flag状态 ================================{}",flag); + if(flag){ + log.info("##############我走的新增运单 ================================1"); + //通过运单号先去查询新系统是否存在这个运单号 + WarehouseWaybillEntity warehouseWaybill = warehouseWaybillClient.findByWaybillNo(waybillNo); + log.info("#################handleDataToPlatform.warehouseWaybill: {}", warehouseWaybill); + if (Objects.isNull(warehouseWaybill)) { - lock.lock(); - warehouseWaybill = warehouseWaybillClient.findByWaybillNo(waybillNo); - log.info("#################handleDataToPlatform.warehouseWaybill: {}", warehouseWaybill); - if (Objects.isNull(warehouseWaybill)) { - redis.setEx("dealwithWaybillNo:" + waybillNo, waybillNo, 30L); - //如果新系统中不存在这个运单,那么就去查询老系统的运单数据 - WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNo); - log.info("#################handleDataToPlatform.wayBillEntity: {}", wayBillEntity); - if (Objects.isNull(wayBillEntity)) { - log.warn("##############saveWaybillEntity: 老系统中未找到对应运单waybillNo={}", waybillNo); - throw new CustomerException("老系统中未找到对应运单"); - } - String startSite = wayBillEntity.getStartSite();//始发仓名称 - BasicdataWarehouseEntity starthouse = basicdataWarehouseClient.findByName(startSite); - String warehouseName = wayBillEntity.getWarehouseName();//目的仓 - BasicdataWarehouseEntity endhouse = basicdataWarehouseClient.findByName(warehouseName); - Integer number = wayBillEntity.getNumber();//运单总数量 - String packname = wayBillEntity.getPackname(); - String agent = wayBillEntity.getAgent(); - - warehouseWaybill = new WarehouseWaybillEntity(); - warehouseWaybill.setTenantId(TenantNum.HUITONGCODE); - warehouseWaybill.setCreateUser(1714696768639311873L); - warehouseWaybill.setUpdateUser(1714696768639311873L); - warehouseWaybill.setCreateDept(1649331096241836033L); - warehouseWaybill.setWaybillNo(waybillNo); - warehouseWaybill.setDestinationWarehouseName(warehouseName); - warehouseWaybill.setDestinationWarehouseId(Objects.isNull(endhouse) ? null : endhouse.getId()); - warehouseWaybill.setDepartureWarehouseName(startSite); - warehouseWaybill.setDepartureWarehouseId(Objects.isNull(starthouse) ? null : starthouse.getId()); - warehouseWaybill.setCustomerTrain(wayBillEntity.getCarNo()); - warehouseWaybill.setBrand(wayBillEntity.getBrand()); - String sendCompany = wayBillEntity.getSendCompany();//发货单位 - String takeCompany = wayBillEntity.getTakeCompany();//收货单位 - BasicdataClientEntity sendClient = basicdataClientClient.findByName(sendCompany); - BasicdataClientEntity takeClient = basicdataClientClient.findByName(takeCompany); - if (!Objects.isNull(sendClient)) { - Long clientEntityId = sendClient.getId();//基础客户 - warehouseWaybill.setShipperId(clientEntityId); - } - if (!Objects.isNull(takeClient)) { - Long clientEntityId = takeClient.getId();//基础客户 - BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(clientEntityId, 3); - if (!Objects.isNull(basicdataStoreBusinessEntity)) { - warehouseWaybill.setServiceType(Integer.parseInt(basicdataStoreBusinessEntity.getMold())); - } - warehouseWaybill.setConsigneeId(clientEntityId); +// redis.setEx("dealwithWaybillNo:" + waybillNo, waybillNo, 30L); + //如果新系统中不存在这个运单,那么就去查询老系统的运单数据 + WayBillEntity wayBillEntity = wayBillClient.getByWaybillNo(waybillNo); + log.info("#################handleDataToPlatform.wayBillEntity: {}", wayBillEntity); + if (Objects.isNull(wayBillEntity)) { + log.warn("##############saveWaybillEntity: 老系统中未找到对应运单waybillNo={}", waybillNo); + throw new CustomerException("老系统中未找到对应运单"); + } + String startSite = wayBillEntity.getStartSite();//始发仓名称 + BasicdataWarehouseEntity starthouse = basicdataWarehouseClient.findByName(startSite); + String warehouseName = wayBillEntity.getWarehouseName();//目的仓 + BasicdataWarehouseEntity endhouse = basicdataWarehouseClient.findByName(warehouseName); + Integer number = wayBillEntity.getNumber();//运单总数量 + String packname = wayBillEntity.getPackname(); + String agent = wayBillEntity.getAgent(); + + warehouseWaybill = new WarehouseWaybillEntity(); + warehouseWaybill.setTenantId(TenantNum.HUITONGCODE); + warehouseWaybill.setCreateUser(1714696768639311873L); + warehouseWaybill.setUpdateUser(1714696768639311873L); + warehouseWaybill.setCreateDept(1649331096241836033L); + warehouseWaybill.setWaybillNo(waybillNo); + warehouseWaybill.setDestinationWarehouseName(warehouseName); + warehouseWaybill.setDestinationWarehouseId(Objects.isNull(endhouse) ? null : endhouse.getId()); + warehouseWaybill.setDepartureWarehouseName(startSite); + warehouseWaybill.setDepartureWarehouseId(Objects.isNull(starthouse) ? null : starthouse.getId()); + warehouseWaybill.setCustomerTrain(wayBillEntity.getCarNo()); + warehouseWaybill.setBrand(wayBillEntity.getBrand()); + String sendCompany = wayBillEntity.getSendCompany();//发货单位 + String takeCompany = wayBillEntity.getTakeCompany();//收货单位 + BasicdataClientEntity sendClient = basicdataClientClient.findByName(sendCompany); + BasicdataClientEntity takeClient = basicdataClientClient.findByName(takeCompany); + if (!Objects.isNull(sendClient)) { + Long clientEntityId = sendClient.getId();//基础客户 + warehouseWaybill.setShipperId(clientEntityId); + } + if (!Objects.isNull(takeClient)) { + Long clientEntityId = takeClient.getId();//基础客户 + BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(clientEntityId, 3); + if (!Objects.isNull(basicdataStoreBusinessEntity)) { + warehouseWaybill.setServiceType(Integer.parseInt(basicdataStoreBusinessEntity.getMold())); } - warehouseWaybill.setShipper(sendCompany); - warehouseWaybill.setShipperName(wayBillEntity.getSendPerson()); - warehouseWaybill.setShipperMobile(wayBillEntity.getSendMobile()); - warehouseWaybill.setShipperAddress(wayBillEntity.getSendAddress()); - warehouseWaybill.setConsignee(takeCompany); - warehouseWaybill.setConsigneeName(wayBillEntity.getTakePerson()); - warehouseWaybill.setConsigneeMobile(wayBillEntity.getTakeMobile()); - warehouseWaybill.setConsigneeAddress(wayBillEntity.getTakeAddress()); + warehouseWaybill.setConsigneeId(clientEntityId); + } + warehouseWaybill.setShipper(sendCompany); + warehouseWaybill.setShipperName(wayBillEntity.getSendPerson()); + warehouseWaybill.setShipperMobile(wayBillEntity.getSendMobile()); + warehouseWaybill.setShipperAddress(wayBillEntity.getSendAddress()); + warehouseWaybill.setConsignee(takeCompany); + warehouseWaybill.setConsigneeName(wayBillEntity.getTakePerson()); + warehouseWaybill.setConsigneeMobile(wayBillEntity.getTakeMobile()); + warehouseWaybill.setConsigneeAddress(wayBillEntity.getTakeAddress()); // String arriveSite = wayBillEntity.getArriveSite(); - Integer arriveSiteId = wayBillEntity.getArriveSiteId(); - String code = wayBillClient.findAreaCodeByArriveSiteId(arriveSiteId); + Integer arriveSiteId = wayBillEntity.getArriveSiteId(); + String code = wayBillClient.findAreaCodeByArriveSiteId(arriveSiteId); // String code = regionFeign.getCode(arriveSite); - warehouseWaybill.setDestinationCode(code); - warehouseWaybill.setDestination(wayBillEntity.getArriveSite()); - warehouseWaybill.setGoodsName(packname); - warehouseWaybill.setTotalCount(number); - warehouseWaybill.setStockCount(1); - warehouseWaybill.setWaybillType(1); - warehouseWaybill.setTotalWeight(wayBillEntity.getWeight()); - warehouseWaybill.setTotalVolume(wayBillEntity.getVolume()); - warehouseWaybill.setDeliveryMethod(wayBillEntity.getSendType()); - warehouseWaybill.setUrgency(wayBillEntity.getUrgency()); - warehouseWaybill.setReceiptCount(wayBillEntity.getReceiptNum()); - warehouseWaybill.setReceiptRequirement(wayBillEntity.getReceiptAsk()); - //--------------2023-07-28------------- - warehouseWaybill.setCollectPay(wayBillEntity.getDPay()); - warehouseWaybill.setReceivedCollectPay(BigDecimal.ZERO); - warehouseWaybill.setReplacePrice(wayBillEntity.getReplacePrice()); - warehouseWaybill.setReceivedReplacePrice(BigDecimal.ZERO); - warehouseWaybill.setReceivedTotalPrice(BigDecimal.ZERO); - warehouseWaybill.setWaybillType(wayBillEntity.getType()); - warehouseWaybill.setReceivedStatus(0); - - warehouseWaybill.setTotalFreight(wayBillEntity.getFreight()); - warehouseWaybill.setDeliveryFee(wayBillEntity.getDeliveryCost()); - warehouseWaybill.setPickupFee(wayBillEntity.getTakeCost()); - warehouseWaybill.setWarehouseManagementFee(wayBillEntity.getWarehouseManagementFee()); - warehouseWaybill.setStorageFee(wayBillEntity.getWarehousingFee()); - warehouseWaybill.setHandlingFee(wayBillEntity.getPretendCost()); - warehouseWaybill.setOtherFee(wayBillEntity.getOtherFee()); - warehouseWaybill.setInsuranceFee(wayBillEntity.getPriceProtectionFee()); - warehouseWaybill.setClaimingValue(wayBillEntity.getValue()); - 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.setReceipt(wayBillEntity.getReceiptAsk()); - warehouseWaybill.setReceiptNum(wayBillEntity.getReceiptNum()); - warehouseWaybill.setTransportType(wayBillEntity.getShippingType() + ""); - warehouseWaybill.setRebate(wayBillEntity.getRebate()); - - BasicdataClientEntity agentClient = basicdataClientClient.findByName(agent); - if (!Objects.isNull(agentClient)) { - Long clientEntityId = agentClient.getId();//基础客户 - warehouseWaybill.setAgentId(clientEntityId); - } - Date date = new Date(); - warehouseWaybill.setAgent(agent); - warehouseWaybill.setDocumentMakingTime(wayBillEntity.getPreparationTime()); - warehouseWaybill.setRemark(wayBillEntity.getMsg()); - warehouseWaybill.setBatchNo(wayBillEntity.getStartCarsNo()); - warehouseWaybill.setFreezeStatus(0); - warehouseWaybill.setStatus(0); - warehouseWaybill.setIsDeleted(0); - warehouseWaybill.setCreateTime(date); - warehouseWaybill.setUpdateTime(date); - aLong = warehouseWaybillClient.addEnntity(warehouseWaybill); - if (aLong != 0) { - redis.setEx("dealwithWaybillNoId:" + waybillNo,aLong, 30L); - List desList = waybillDesClient.getDesList(waybillNo); - List warehouseWayBillDetails = new ArrayList<>(); - for (WaybillDesEntity waybillDesEntity : desList) { - WarehouseWayBillDetail warehouseWayBillDetail = new WarehouseWayBillDetail(); - warehouseWayBillDetail.setCreateUser(1714696768639311873L); - warehouseWayBillDetail.setUpdateUser(1714696768639311873L); - warehouseWayBillDetail.setCreateDept(1649331096241836033L); - warehouseWayBillDetail.setWaybillId(aLong); - warehouseWayBillDetail.setWaybillNo(waybillNo); - String goodsName = waybillDesEntity.getName(); - BasicdataCategoryEntity categoryEntity = categoryClient.findByName(goodsName); - if (Objects.isNull(categoryEntity)) { - categoryEntity = new BasicdataCategoryEntity(); - categoryEntity.setName(goodsName); - categoryEntity.setType(1); - categoryEntity.setTenantId(TenantNum.HUITONGCODE); - categoryEntity.setCreateUser(1714696768639311873L); - categoryEntity.setUpdateUser(1714696768639311873L); - categoryEntity.setCreateDept(1649331096241836033L); - Long categoryId = categoryClient.addReturnId(categoryEntity); - warehouseWayBillDetail.setProductId(categoryId); - } else { - warehouseWayBillDetail.setProductId(categoryEntity.getId()); - } - warehouseWayBillDetail.setProductName(goodsName); - warehouseWayBillDetail.setNum(waybillDesEntity.getNum()); - warehouseWayBillDetail.setPrice(waybillDesEntity.getPrice()); - warehouseWayBillDetail.setVolume(waybillDesEntity.getVolume()); - warehouseWayBillDetail.setWeight(waybillDesEntity.getWeight()); - warehouseWayBillDetail.setSubtotalFreight(waybillDesEntity.getTotalDesPrice()); - warehouseWayBillDetail.setChargeType(waybillDesEntity.getPic()); - warehouseWayBillDetails.add(warehouseWayBillDetail); + warehouseWaybill.setDestinationCode(code); + warehouseWaybill.setDestination(wayBillEntity.getArriveSite()); + warehouseWaybill.setGoodsName(packname); + warehouseWaybill.setTotalCount(number); + warehouseWaybill.setStockCount(1); + warehouseWaybill.setWaybillType(1); + warehouseWaybill.setTotalWeight(wayBillEntity.getWeight()); + warehouseWaybill.setTotalVolume(wayBillEntity.getVolume()); + warehouseWaybill.setDeliveryMethod(wayBillEntity.getSendType()); + warehouseWaybill.setUrgency(wayBillEntity.getUrgency()); + warehouseWaybill.setReceiptCount(wayBillEntity.getReceiptNum()); + warehouseWaybill.setReceiptRequirement(wayBillEntity.getReceiptAsk()); + //--------------2023-07-28------------- + warehouseWaybill.setCollectPay(wayBillEntity.getDPay()); + warehouseWaybill.setReceivedCollectPay(BigDecimal.ZERO); + warehouseWaybill.setReplacePrice(wayBillEntity.getReplacePrice()); + warehouseWaybill.setReceivedReplacePrice(BigDecimal.ZERO); + warehouseWaybill.setReceivedTotalPrice(BigDecimal.ZERO); + warehouseWaybill.setWaybillType(wayBillEntity.getType()); + warehouseWaybill.setReceivedStatus(0); + + warehouseWaybill.setTotalFreight(wayBillEntity.getFreight()); + warehouseWaybill.setDeliveryFee(wayBillEntity.getDeliveryCost()); + warehouseWaybill.setPickupFee(wayBillEntity.getTakeCost()); + warehouseWaybill.setWarehouseManagementFee(wayBillEntity.getWarehouseManagementFee()); + warehouseWaybill.setStorageFee(wayBillEntity.getWarehousingFee()); + warehouseWaybill.setHandlingFee(wayBillEntity.getPretendCost()); + warehouseWaybill.setOtherFee(wayBillEntity.getOtherFee()); + warehouseWaybill.setInsuranceFee(wayBillEntity.getPriceProtectionFee()); + warehouseWaybill.setClaimingValue(wayBillEntity.getValue()); + 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.setReceipt(wayBillEntity.getReceiptAsk()); + warehouseWaybill.setReceiptNum(wayBillEntity.getReceiptNum()); + warehouseWaybill.setTransportType(wayBillEntity.getShippingType() + ""); + warehouseWaybill.setRebate(wayBillEntity.getRebate()); + + BasicdataClientEntity agentClient = basicdataClientClient.findByName(agent); + if (!Objects.isNull(agentClient)) { + Long clientEntityId = agentClient.getId();//基础客户 + warehouseWaybill.setAgentId(clientEntityId); + } + Date date = new Date(); + warehouseWaybill.setAgent(agent); + warehouseWaybill.setDocumentMakingTime(wayBillEntity.getPreparationTime()); + warehouseWaybill.setRemark(wayBillEntity.getMsg()); + warehouseWaybill.setBatchNo(wayBillEntity.getStartCarsNo()); + warehouseWaybill.setFreezeStatus(0); + warehouseWaybill.setStatus(0); + warehouseWaybill.setIsDeleted(0); + warehouseWaybill.setCreateTime(date); + warehouseWaybill.setUpdateTime(date); + aLong = warehouseWaybillClient.addEnntity(warehouseWaybill); + if (aLong != 0) { + redis.setEx("dealwithWaybillNoId:" + waybillNo,aLong, 30L); + List desList = waybillDesClient.getDesList(waybillNo); + List warehouseWayBillDetails = new ArrayList<>(); + for (WaybillDesEntity waybillDesEntity : desList) { + WarehouseWayBillDetail warehouseWayBillDetail = new WarehouseWayBillDetail(); + warehouseWayBillDetail.setCreateUser(1714696768639311873L); + warehouseWayBillDetail.setUpdateUser(1714696768639311873L); + warehouseWayBillDetail.setCreateDept(1649331096241836033L); + warehouseWayBillDetail.setWaybillId(aLong); + warehouseWayBillDetail.setWaybillNo(waybillNo); + String goodsName = waybillDesEntity.getName(); + BasicdataCategoryEntity categoryEntity = categoryClient.findByName(goodsName); + if (Objects.isNull(categoryEntity)) { + categoryEntity = new BasicdataCategoryEntity(); + categoryEntity.setName(goodsName); + categoryEntity.setType(1); + categoryEntity.setTenantId(TenantNum.HUITONGCODE); + categoryEntity.setCreateUser(1714696768639311873L); + categoryEntity.setUpdateUser(1714696768639311873L); + categoryEntity.setCreateDept(1649331096241836033L); + Long categoryId = categoryClient.addReturnId(categoryEntity); + warehouseWayBillDetail.setProductId(categoryId); + } else { + warehouseWayBillDetail.setProductId(categoryEntity.getId()); } - warehouseWaybillDetailClient.addList(warehouseWayBillDetails); + warehouseWayBillDetail.setProductName(goodsName); + warehouseWayBillDetail.setNum(waybillDesEntity.getNum()); + warehouseWayBillDetail.setPrice(waybillDesEntity.getPrice()); + warehouseWayBillDetail.setVolume(waybillDesEntity.getVolume()); + warehouseWayBillDetail.setWeight(waybillDesEntity.getWeight()); + warehouseWayBillDetail.setSubtotalFreight(waybillDesEntity.getTotalDesPrice()); + warehouseWayBillDetail.setChargeType(waybillDesEntity.getPic()); + warehouseWayBillDetails.add(warehouseWayBillDetail); } - - } else { - warehouseWaybill.setStockCount(warehouseWaybill.getStockCount() + 1); - warehouseWaybill.setUpdateTime(new Date()); - warehouseWaybillClient.updateEntity(warehouseWaybill); - aLong = warehouseWaybill.getId(); + warehouseWaybillDetailClient.addList(warehouseWayBillDetails); } //暂存单与运单的关联 saveAdvanceData(warehouseWaybill); - // redisLockClient.unLock(lockKey, LockType.FAIR); - + } else { + log.info("##############我走的新增运单 ================================2"); + warehouseWaybill.setStockCount(warehouseWaybill.getStockCount() + 1); + warehouseWaybill.setUpdateTime(new Date()); + warehouseWaybillClient.updateEntity(warehouseWaybill); + aLong = warehouseWaybill.getId(); } - } catch (Exception e) { - throw new RuntimeException(e); - }finally { - lock.unlock(); + log.info("##############我走的准备解锁 ================================3"); + redisLockClient.unLock(lockKey, LockType.FAIR); + log.info("##############我走的解锁 ================================4 {}",aLong); } return aLong; }