diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataClientClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataClientClient.java index d0d1d8858..ed441e362 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataClientClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataClientClient.java @@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSONObject; import com.logpm.basicdata.entity.BasicdataClientEntity; import com.logpm.basicdata.entity.BasicdataClientUserEntity; import com.logpm.basicdata.vo.BasicdataClientVO; +import org.springblade.common.annotations.ChangeAsync; import org.springblade.common.constant.ModuleNameConstant; import org.springblade.core.mp.support.BladePage; import org.springframework.cloud.openfeign.FeignClient; @@ -108,4 +109,14 @@ public interface IBasicdataClientClient { */ @GetMapping(API_PREFIX+"/findEntityByIds") List findEntityByIds(@RequestParam List clientIds); + + + /** + * 查询制定租户下面的客户结合 + * @param tenantId + * @return + */ + @GetMapping(API_PREFIX+"/findBasicdataClientEntitysTenantId") + List findBasicdataClientEntitysTenantId(@RequestParam String tenantId) ; + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/ChangeAsyncAnnotationAspect.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/ChangeAsyncAnnotationAspect.java new file mode 100644 index 000000000..ee6874ad0 --- /dev/null +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/ChangeAsyncAnnotationAspect.java @@ -0,0 +1,122 @@ +package com.logpm.basicdata.aspect; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; +import org.springblade.common.annotations.ChangeAsync; +import org.springblade.common.cache.CacheNames; +import org.springblade.common.component.MockLoginService; +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.utils.StringUtil; +import org.springblade.core.tool.utils.ThreadLocalUtil; +import org.springframework.core.annotation.Order; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.lang.reflect.Method; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +@Aspect +@Component +@Slf4j +@Order(-1) +@AllArgsConstructor +public class ChangeAsyncAnnotationAspect { + + private final MockLoginService mockLoginService; + + private final BladeRedis bladeRedis; + private final Environment environment; + private final RedisLockClient redisLockClient; + private final String account = "shujutongbu"; + + /** + * 定义一个切点,匹配所有带有@ChangeAsync注解的方法。 + * 注意:实际上Spring Framework自带对@ChangeAsync的处理,直接这样配置可能会导致预期之外的行为。 + */ + @Around("@annotation(org.springblade.common.annotations.ChangeAsync)") + public Object logAroundAsyncMethods(ProceedingJoinPoint joinPoint) throws Throwable { + + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + ChangeAsync myAsync = method.getAnnotation(ChangeAsync.class); + String annotationValue = myAsync.value(); + log.info(">>>>>>>>>>>>>>>>>> ChangeAsync={}", annotationValue); + + // 获取当前拦截方法的入参参数 + Object[] args = joinPoint.getArgs(); + // 获取入参名称 + String[] parameterNames = signature.getParameterNames(); + String tenantId = null; + // 获取参数名称 为tenantId 的值 + for (int i = 0; i < parameterNames.length; i++) { + if ("tenantId".equals(parameterNames[i])) { + tenantId = (String) args[i]; + log.info(">> tenandId {} ", tenantId); + break; + } + } + // 执行模拟登录 + if (StringUtil.isNotBlank(tenantId)) { + String key =CacheNames.LOCAL_SERVER_USER+tenantId+":"+account; + String lockKey =key+":lock"; + JSONObject data =bladeRedis.get(key); + if(Objects.isNull(data)){ + boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS); + if(flag){ + data =bladeRedis.get(key); + if(Objects.isNull(data)){ + data = mockLoginService.mockToken(tenantId,account); + bladeRedis.setEx(key,data,2591990L); + redisLockClient.unLock(lockKey, LockType.FAIR); + } + } + } + + MockHttpServletRequest mockRequest = new MockHttpServletRequest(); + mockRequest.addHeader("Blade-Auth", "bearer "+data.get("access_token")); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(mockRequest)); + + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.add("Blade-Auth","bearer "+data.get("access_token") ); + httpHeaders.add( "Authorization", "Basic bG9jYWw6bG9jYWxfc2VjcmV0"); + ThreadLocalUtil.put("bladeContext", httpHeaders); + + DynamicDataSourceContextHolder.push(data.getString("tenant_id")); + // 执行原方法 + Object result = joinPoint.proceed(); + // 在方法执行后,从数据源上下文中移除租户ID + DynamicDataSourceContextHolder.poll(); + return result; + }else{ + return joinPoint.proceed(); + } + + +// // 在方法执行前的操作 +// String tenantId = AuthUtil.getTenantId(); +// log.info(">> tenandId {} ",tenantId); +// DynamicDataSourceContextHolder.push("627683"); +// +// // 执行原方法 +// Object result = joinPoint.proceed(); +// +// // 在方法执行后的操作 +// DynamicDataSourceContextHolder.poll(); +// return result; + } + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java index 8f47ebf7e..638f523b8 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataDriverArteryController.java @@ -190,7 +190,7 @@ public class BasicdataDriverArteryController extends BladeController { .eq(BasicdataDriverArteryEntity::getUserId, basicdataDriverArtery.getUserId()) .eq(BasicdataDriverArteryEntity::getIsDeleted, 0) ); - if (list.size() > 0) { + if (!list.isEmpty()) { return R.fail("绑定的用户已存在!不要重复绑定!!!"); } String phone = basicdataDriverArtery.getPhone(); diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataClientClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataClientClient.java index 3d7cee748..3a94dab82 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataClientClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataClientClient.java @@ -17,6 +17,7 @@ package com.logpm.basicdata.feign; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; @@ -27,7 +28,9 @@ import com.logpm.basicdata.entity.BasicdataClientUserEntity; import com.logpm.basicdata.service.IBasicdataClientService; import com.logpm.basicdata.service.IBasicdataClientUserService; import com.logpm.basicdata.vo.BasicdataClientVO; +import com.logpm.distribution.entity.DistributionParcelListEntity; import lombok.AllArgsConstructor; +import org.springblade.common.annotations.ChangeAsync; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -141,4 +144,11 @@ public class BasicdataClientClient implements IBasicdataClientClient { return basicdataClientService.listByIds(clientIds); } + @ChangeAsync + @Override + public List findBasicdataClientEntitysTenantId(String tenantId) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(BasicdataClientEntity::getIsDeleted, 0);// 查询未删除的客户信息 + return basicdataClientService.list(lambdaQueryWrapper); + } } diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessAsyncServiceImpl.java b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessAsyncServiceImpl.java index 0e1930352..2cd4d291c 100644 --- a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessAsyncServiceImpl.java +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessAsyncServiceImpl.java @@ -26,7 +26,6 @@ public class BusinessAsyncServiceImpl implements IBusinessAsyncService { private final IBusinessPreOrderService businessPreOrderService; private final ISysClient sysClient; - private final IDistributionDeliveryListClient distributionDeliveryListClient; @ChangeAsync() @Override @@ -35,9 +34,9 @@ public class BusinessAsyncServiceImpl implements IBusinessAsyncService { List orderCodeList = dataResult.stream() .map(BusinessPreOrderEntity::getOrderCode) .collect(Collectors.toList()); - R tenantByName = sysClient.getTenantByName(mallName); - if (tenantByName.isSuccess()) { - Tenant tenant = tenantByName.getData(); + R tenant1 = sysClient.getTenant(tenantId); + if (tenant1.isSuccess()) { + Tenant tenant = tenant1.getData(); if (ObjectUtil.isEmpty(tenant)) { log.info(">>>>>>>>>>>>> saveOtherDataBaseNew 租户不存在"); return; @@ -46,10 +45,6 @@ public class BusinessAsyncServiceImpl implements IBusinessAsyncService { log.info(" saveOtherDataBaseNew dataResult 参数错误"); } - - - - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(BusinessPreOrderEntity::getInWarehouse, 0); lambdaQueryWrapper.in(BusinessPreOrderEntity::getOrderCode, orderCodeList); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/BusinessPreOrderDataQueueHandler.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/BusinessPreOrderDataQueueHandler.java index 308d9d459..e1795c42c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/BusinessPreOrderDataQueueHandler.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/BusinessPreOrderDataQueueHandler.java @@ -1,6 +1,8 @@ package com.logpm.distribution.receiver; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.logpm.basicdata.entity.BasicdataClientEntity; +import com.logpm.basicdata.feign.IBasicdataClientClient; import com.logpm.business.entity.BusinessPreOrderEntity; import com.logpm.business.feign.IBusinessPreOrderClient; import com.logpm.distribution.entity.*; @@ -24,7 +26,7 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @Slf4j @@ -42,6 +44,7 @@ public class BusinessPreOrderDataQueueHandler { private final IBusinessPreOrderClient businessPreOrderClient; private final IExtractedDataClient extractedDataClient; private final IDistributionLoadscanService distributionLoadscanService; + private final IBasicdataClientClient basicdataClientClient; private final IDistributionAsyncService distributionAsyncService; @@ -50,21 +53,146 @@ public class BusinessPreOrderDataQueueHandler { public void businessPreOrderDataHandler(Map map, Message message, Channel channel) { // plantA(map); R> tenantList = sysClient.getTenantList(); + if (tenantList.isSuccess()) { List data = tenantList.getData(); data.forEach(tenant -> { if (!ObjectUtil.isEmpty(tenant.getTenantType())) { if (2 == tenant.getTenantType()) { - String mallName = tenant.getTenantName(); - // 插入暂存单 - // 插入预计表 - plantA(map, mallName); + List basicdataClientEntitysTenantId = basicdataClientClient.findBasicdataClientEntitysTenantId(tenant.getTenantId()); + if (!basicdataClientEntitysTenantId.isEmpty()) { + // 寻找当前配送计划下的预约单 + Long t = (Long) map.get("messageData"); + if (ObjectUtil.isEmpty(t)) { + log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 配送ID为空"); + return; + } + DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListService.getById(t); + if (ObjectUtil.isEmpty(distributionDeliveryListEntity)) { + log.info(">>>>>>>>>>>>> BusinessPreOrderDataQueueHandler 配送对象为null"); + return; + } + List list = distributionReservationService.selectListByDeliveryId(distributionDeliveryListEntity.getId()); + if (list != null && !list.isEmpty()) { + resoveData(tenant,distributionDeliveryListEntity, basicdataClientEntitysTenantId, list); + } + + } } } }); } + + + } + private void resoveData(Tenant te,DistributionDeliveryListEntity distributionDeliveryListEntity, List allClientList, List allDistributionReservationEntity) { + + for (DistributionReservationEntity distributionReservationEntity : allDistributionReservationEntity) { + BasicdataClientEntity basicdataClient = checkAllClientList(allClientList, distributionReservationEntity); + + if (basicdataClient != null) { + List dataResult = new ArrayList<>(); + String mallName = basicdataClient.getClientName(); + // 判断需要进行推送商家名称 + log.info(">>>>> mallName TAG {}", mallName); + log.info(">>>>> distributionReservationEntity.getMallName() TAG {}", distributionReservationEntity.getMallName()); + if (mallName.equals(distributionReservationEntity.getMallName())) { + + // 将当前的预约单加入到需要推送的列表 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(DistributionReservationPackageEntity::getReservationId, distributionReservationEntity.getId()); + queryWrapper.ne(DistributionReservationPackageEntity::getPacketBarStatus, 2); + List distributionReservationPackageEntityList = distributionReservationPackageService.list(queryWrapper); + + for (DistributionReservationPackageEntity distributionReservationPackageEntity : distributionReservationPackageEntityList) { + + + DistributionParcelListEntity byId = distributionParcelListService.getById(distributionReservationPackageEntity.getParceListId()); + BusinessPreOrderEntity data = BeanUtil.copy(byId, BusinessPreOrderEntity.class); + + // 判断包件是否装车 + if ("20".equals(byId.getOrderPackageLoadingStatus())) { + data.setLoadNum(1); + } + data.setDriverName(distributionDeliveryListEntity.getDriverName()); + data.setVehicleName(distributionDeliveryListEntity.getVehicleName()); + data.setDistrCarNumber(distributionDeliveryListEntity.getTrainNumber()); + data.setFromTenantId(byId.getTenantId()); + data.setOperationStatus(0); + data.setInWarehouse(0); + data.setId(null); + data.setTenantId(null); + data.setReservationCode(distributionReservationEntity.getReservationCode()); + data.setTaskTime(distributionDeliveryListEntity.getTaskTime()); + dataResult.add(data); + } + + // 零担数据 + + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(DistributionReservationZeroPackageEntity::getReservationId, distributionReservationEntity.getId()); + lambdaQueryWrapper.ne(DistributionReservationZeroPackageEntity::getZeroPackageStatus, 2); + List list1 = distributionReservationZeroPackageService.list(lambdaQueryWrapper); + for (DistributionReservationZeroPackageEntity distributionReservationZeroPackageEntity : list1) { + // 查询包间 + DistributionParcelListEntity parcelListEntity = distributionParcelListService.getById(distributionReservationZeroPackageEntity.getParcelListId()); + if (parcelListEntity != null) { + BusinessPreOrderEntity data = BeanUtil.copy(parcelListEntity, BusinessPreOrderEntity.class); + // 计划数量 + data.setQuantity(distributionReservationZeroPackageEntity.getQuantity()); + + // 获取装车数量 + DistributionLoadscanEntity distributionLoadscanEntity = distributionLoadscanService.findLoadDataByRelationIdAndParcelListId(distributionReservationZeroPackageEntity.getReservationId(), distributionReservationZeroPackageEntity.getParcelListId()); + if (distributionLoadscanEntity != null) { + //设置装车数量 + data.setLoadNum(distributionLoadscanEntity.getLoadedNub()); + } + data.setConditions(3); + data.setDriverName(distributionDeliveryListEntity.getDriverName()); + data.setVehicleName(distributionDeliveryListEntity.getVehicleName()); + data.setDistrCarNumber(distributionDeliveryListEntity.getTrainNumber()); + data.setFromTenantId(parcelListEntity.getTenantId()); + data.setOperationStatus(0); + data.setInWarehouse(0); + data.setId(null); + data.setTenantId(null); + data.setReservationCode(distributionReservationEntity.getReservationCode()); + data.setTaskTime(distributionDeliveryListEntity.getTaskTime()); + dataResult.add(data); + } + + } + } + // 处理暂存但的数据 + + // 获取运单号集合 + List waybillNumberList = dataResult.stream().map(BusinessPreOrderEntity::getWaybillNumber).distinct().collect(Collectors.toList()); + // 发送数据 +// Tenant tenant = changeDataBase(mallName); + waybillNumberList.forEach(waybillNumber -> extractedDataClient.execute(te.getTenantId(), waybillNumber)); + + businessPreOrderClient.saveOtherDataBaseNew(te.getTenantId(), dataResult, mallName); + } + + } + } + + private BasicdataClientEntity checkAllClientList(List allClientList, DistributionReservationEntity distributionReservationEntity) { + + for (BasicdataClientEntity basicdataClient : allClientList) { + + if (basicdataClient.getClientName().equals(distributionReservationEntity.getMallName())) { + return basicdataClient; + } + + } + return null; + } + + + private void plantA(Map map, String mallName) { @@ -142,7 +270,7 @@ public class BusinessPreOrderDataQueueHandler { // 获取装车数量 DistributionLoadscanEntity distributionLoadscanEntity = distributionLoadscanService.findLoadDataByRelationIdAndParcelListId(distributionReservationZeroPackageEntity.getReservationId(), distributionReservationZeroPackageEntity.getParcelListId()); - if(distributionLoadscanEntity != null){ + if (distributionLoadscanEntity != null) { //设置装车数量 data.setLoadNum(distributionLoadscanEntity.getLoadedNub()); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java index 61f483cae..2e73c1354 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java @@ -4692,131 +4692,136 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl().lambda() - .eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .set(DistributionDeliveryTripartiteEntity::getDepartureTime, format)); - isEnd = true; - } - //处理最后一个司机进行发车 - //判断是否是最后一个司机点发车 - distributionDeliveryListEntity.setIsStart(DeliveryStartStatusConstant.bufenfache.getValue()); - if (isEnd) { - distributionDeliveryListEntity.setIsStart(DeliveryStartStatusConstant.yifache.getValue()); - //进行实际装车和计划数据比对 - if (Integer.parseInt(IsOrNoConstant.yes.getValue()) == isStrictLoading) { - contrastPlanAndLoading(distributionDeliveryListEntity, myCurrentWarehouse); - } - //进行发车日志记录 - } - bladeRedis.setEx(AuthUtil.getTenantId() + ":warehouseId:" + myCurrentWarehouse.getId() + ":trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + ":driverId:", user.getUserId(), 60L * 30L); - //修改主表状态 - distributionDeliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.peisongzhong.getValue()); - baseMapper.updateById(distributionDeliveryListEntity); - //查询配送计划的所有预约总数 - List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); + } else { + b = distributionDeliveryTripartiteService.update(new UpdateWrapper().lambda() + .eq(DistributionDeliveryTripartiteEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) + .set(DistributionDeliveryTripartiteEntity::getDepartureTime, format)); + isEnd = true; + } + //处理最后一个司机进行发车 + //判断是否是最后一个司机点发车 + distributionDeliveryListEntity.setIsStart(DeliveryStartStatusConstant.bufenfache.getValue()); + if (isEnd) { + distributionDeliveryListEntity.setIsStart(DeliveryStartStatusConstant.yifache.getValue()); + //进行实际装车和计划数据比对 + if (Integer.parseInt(IsOrNoConstant.yes.getValue()) == isStrictLoading) { + contrastPlanAndLoading(distributionDeliveryListEntity, myCurrentWarehouse); + } + //进行发车日志记录 + } + bladeRedis.setEx(AuthUtil.getTenantId() + ":warehouseId:" + myCurrentWarehouse.getId() + ":trainNumber:" + distributionDeliveryListEntity.getTrainNumber() + ":driverId:", user.getUserId(), 60L * 30L); + //修改主表状态 + distributionDeliveryListEntity.setDeliveryStatus(DeliveryStatusConstant.peisongzhong.getValue()); + baseMapper.updateById(distributionDeliveryListEntity); + //查询配送计划的所有预约总数 + List reservationEntityList = distributionDeliveryListMapper.selectReservationByDeliveryListId(distrilbutionloadingscanDTO.getDeliveryId()); // reservationEntityList.stream().collect(Collectors.reducing(0,DistributionReservationEntity::getReservationNum,Integer::sum)); - StringBuilder builder = new StringBuilder(); - AtomicInteger planCount = new AtomicInteger(); - reservationEntityList.forEach(r -> { - planCount.getAndAdd(r.getReservationNum() + r.getReservationStockListNum()); - }); - if (planCount.get() != 0) { - builder.append("计划" + planCount.get() + "件"); - } - Integer loadingCount = new Integer(0); - //查询配送任务的计划订单装车数 - Integer packageLoadingNum = distributionLoadscanMapper.statisticsLoadingNum(distrilbutionloadingscanDTO.getDeliveryId()); - if (packageLoadingNum != 0) { - loadingCount += packageLoadingNum; - } - Integer inventoryLoadingNum = 0; - if (distributionDeliveryListEntity.getType().equals(DistributionTypeConstant.shipie.getValue())) { - inventoryLoadingNum = distributionLoadscaninvnMapper.statisticsLoadingNum(distrilbutionloadingscanDTO.getDeliveryId()); - if (inventoryLoadingNum != 0) { - loadingCount += inventoryLoadingNum; + builder = new StringBuilder(); + AtomicInteger planCount = new AtomicInteger(); + reservationEntityList.forEach(r -> { + planCount.getAndAdd(r.getReservationNum() + r.getReservationStockListNum()); + }); + if (planCount.get() != 0) { + builder.append("计划" + planCount.get() + "件"); + } + Integer loadingCount = new Integer(0); + //查询配送任务的计划订单装车数 + Integer packageLoadingNum = distributionLoadscanMapper.statisticsLoadingNum(distrilbutionloadingscanDTO.getDeliveryId()); + if (packageLoadingNum != 0) { + loadingCount += packageLoadingNum; + } + Integer inventoryLoadingNum = 0; + if (distributionDeliveryListEntity.getType().equals(DistributionTypeConstant.shipie.getValue())) { + inventoryLoadingNum = distributionLoadscaninvnMapper.statisticsLoadingNum(distrilbutionloadingscanDTO.getDeliveryId()); + if (inventoryLoadingNum != 0) { + loadingCount += inventoryLoadingNum; + } + } + if (planCount.get() - loadingCount > 0) { + builder.append("未装" + (planCount.get() - packageLoadingNum - inventoryLoadingNum) + "件"); + } + if (loadingCount != 0) { + builder.append("装车" + loadingCount + "件"); } - } - if (planCount.get() - loadingCount > 0) { - builder.append("未装" + (planCount.get() - packageLoadingNum - inventoryLoadingNum) + "件"); - } - if (loadingCount != 0) { - builder.append("装车" + loadingCount + "件"); - } - distributionAsyncService.sendTrunkineLog(distributionDeliveryListEntity.getId(), null, AuthUtil.getUser(), warehouseClient.getMyCurrentWarehouse(), 1); - Map mapState = new HashMap(); - mapState.put("messageId", CommonUtil.getUUID()); - mapState.put("messageData", distributionDeliveryListEntity.getId()); - mapState.put("createTime", System.currentTimeMillis()); - try { - rabbitTemplate.convertAndSend(RabbitConstant.BUSINESS_PRE_CONVERSION_DATA_EXCHANGE, RabbitConstant.BUSINESS_PRE_CONVERSION_DATA_ROUTING, mapState, message -> { - message.getMessageProperties() - .setHeader("x-delay", 5000); - return message; - }); - } catch (Exception customerException) { - log.error(">>>>>>>>>>>>>>>>>>>>>>>>>> 消息推送失败~ 请联系管理员! ", customerException); + distributionAsyncService.sendTrunkineLog(distributionDeliveryListEntity.getId(), null, AuthUtil.getUser(), warehouseClient.getMyCurrentWarehouse(), 1); + Map mapState = new HashMap(); + mapState.put("messageId", CommonUtil.getUUID()); + mapState.put("messageData", distributionDeliveryListEntity.getId()); + mapState.put("createTime", System.currentTimeMillis()); + try { + rabbitTemplate.convertAndSend(RabbitConstant.BUSINESS_PRE_CONVERSION_DATA_EXCHANGE, RabbitConstant.BUSINESS_PRE_CONVERSION_DATA_ROUTING, mapState, message -> { + message.getMessageProperties() + .setHeader("x-delay", 5000); + return message; + }); + } catch (Exception customerException) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>> 消息推送失败~ 请联系管理员! ", customerException); + } + //发车日志记录 + handleLoadingStartLog(distributionDeliveryListEntity, user, myCurrentWarehouse, builder.toString()); + NodeFanoutMsg nodeFanoutMsg = builderNodeFanoutMsgByCarStart(distributionDeliveryListEntity, user); + distributionNodeWorkService.carStart(nodeFanoutMsg, user); + } catch (NumberFormatException e) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>> 发车异常", e); } - //发车日志记录 - handleLoadingStartLog(distributionDeliveryListEntity, user, myCurrentWarehouse, builder.toString()); - NodeFanoutMsg nodeFanoutMsg = builderNodeFanoutMsgByCarStart(distributionDeliveryListEntity, user); - distributionNodeWorkService.carStart(nodeFanoutMsg, user); // 推送数据 return Resp.scanSuccess("发车成功", builder.toString()); diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsLogServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsLogServiceImpl.java index b202e92fb..3d3112e39 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsLogServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayGoodsLogServiceImpl.java @@ -14,6 +14,7 @@ import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -29,7 +30,7 @@ public class WarehouseTrayGoodsLogServiceImpl extends BaseServiceImpl details = warehouseWayBillDetailService.findByWaybillId(waybillId); StringBuilder sb = new StringBuilder(); @@ -555,7 +556,7 @@ public class WarehouseWaybillServiceImpl extends BaseServiceImpl