From 643bf554cb171bcc5a00d4e7d06ff1d81989aa7e Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Thu, 26 Sep 2024 15:49:49 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=A2=9E=E5=8A=A0=E9=85=8D=E9=80=81?= =?UTF-8?q?=E5=9B=9E=E5=BA=93=E4=BD=9C=E4=B8=9A=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/workNode/RetentionDataByScanVO.java | 30 ++++ .../feign/IDistributionParcelListClient.java | 9 ++ .../feign/DistributionParcelListClient.java | 9 ++ .../impl/DistributionSignforServiceImpl.java | 2 +- .../service/IWarehouseNodeWorkService.java | 25 +++ .../impl/WarehouseNodeWorkServiceImpl.java | 33 ++++ .../WarehouseRetentionRecordServiceImpl.java | 147 +++++++++++++++--- 7 files changed, 230 insertions(+), 25 deletions(-) create mode 100644 blade-biz-common/src/main/java/org/springblade/common/model/workNode/RetentionDataByScanVO.java create mode 100644 blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseNodeWorkService.java create mode 100644 blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseNodeWorkServiceImpl.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/model/workNode/RetentionDataByScanVO.java b/blade-biz-common/src/main/java/org/springblade/common/model/workNode/RetentionDataByScanVO.java new file mode 100644 index 000000000..1e6ec0fb0 --- /dev/null +++ b/blade-biz-common/src/main/java/org/springblade/common/model/workNode/RetentionDataByScanVO.java @@ -0,0 +1,30 @@ +package org.springblade.common.model.workNode; + +import lombok.Data; +import org.springblade.common.model.PackageData; + +import java.util.List; + +/** + * 滞留扫描 + */ +@Data +public class RetentionDataByScanVO { + + + /** + * 配送车次号 + */ + private String trainNumber; + + /** + * 预约单号 + */ + private String reservationCode; + + /** + * 自提明细数据 + */ + private List packageDataList; + +} diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java index 3a5315530..d026aa5f0 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java @@ -176,6 +176,15 @@ public interface IDistributionParcelListClient { @GetMapping(API_PREFIX + "/getListByOrderPackageCode") List getListByOrderPackageCode(@RequestParam String orderPackageCode); + /** + * 根据仓库ID 和包件码 查询仓库数据 + * @param orderPackageCode 包件码 + * @param warehouseId 仓库ID + * @return 包件 + */ + @GetMapping(API_PREFIX + "/getListByOrderPackageCode") + DistributionParcelListEntity getListByOrderPackageCodeAndWarehouseId(@RequestParam String orderPackageCode,@RequestParam Long warehouseId); + @GetMapping(API_PREFIX + "/findAllStockListByOrderPackageCode") List findAllStockListByOrderPackageCode(String orderPackageCode); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java index d10de8671..d36da0880 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java @@ -351,6 +351,15 @@ public class DistributionParcelListClient implements IDistributionParcelListClie return distributionParcelListService.list(queryWrapper); } + @Override + public DistributionParcelListEntity getListByOrderPackageCodeAndWarehouseId(String orderPackageCode, Long warehouseId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("order_package_code", orderPackageCode); + queryWrapper.eq("warehouse_id", warehouseId); + queryWrapper.last(" limit 1"); + return distributionParcelListService.getOne(queryWrapper); + } + @Override public List findAllStockListByOrderPackageCode(String orderPackageCode) { QueryWrapper queryWrapper = new QueryWrapper<>(); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java index 789db2ca3..37a943d09 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java @@ -3072,7 +3072,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl nodeFanoutMsg, BladeUser user); + +} diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseNodeWorkServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseNodeWorkServiceImpl.java new file mode 100644 index 000000000..10380aa82 --- /dev/null +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseNodeWorkServiceImpl.java @@ -0,0 +1,33 @@ +package com.logpm.warehouse.service.impl; + +import com.logpm.warehouse.service.IWarehouseNodeWorkService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.broadcast.FanoutConstants; +import org.springblade.common.model.NodeFanoutMsg; +import org.springblade.common.model.workNode.RetentionDataByScanVO; +import org.springblade.core.secure.BladeUser; +import org.springframework.amqp.AmqpException; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@AllArgsConstructor +@Service +@Slf4j +public class WarehouseNodeWorkServiceImpl implements IWarehouseNodeWorkService { + + @Autowired + private RabbitTemplate rabbitTemplate; + + @Override + public void returnToTheWarehouse(NodeFanoutMsg nodeFanoutMsg, BladeUser user) { + try { + if(user != null){ + rabbitTemplate.convertAndSend(FanoutConstants.reservation.OwnReservation.EXCHANGE, null, com.alibaba.fastjson.JSONObject.toJSONString(nodeFanoutMsg)); + } + } catch (AmqpException e) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>> 消息推送失败~ 请联系管理员! ", e); + } + } +} diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseRetentionRecordServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseRetentionRecordServiceImpl.java index 106049713..504932e03 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseRetentionRecordServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseRetentionRecordServiceImpl.java @@ -25,6 +25,7 @@ import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.distribution.entity.DistributionLoadscanEntity; import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.distribution.entity.DistributionReservationEntity; +import com.logpm.distribution.entity.DistributionStockListEntity; import com.logpm.distribution.feign.*; import com.logpm.distribution.vo.DistributionDeliveryListVO; import com.logpm.warehouse.bean.Resp; @@ -33,6 +34,7 @@ import com.logpm.warehouse.entity.WarehouseRetentionRecordEntity; import com.logpm.warehouse.entity.WarehouseRetentionScanEntity; import com.logpm.warehouse.excel.WarehouseRetentionRecordExcel; import com.logpm.warehouse.mapper.WarehouseRetentionRecordMapper; +import com.logpm.warehouse.service.IWarehouseNodeWorkService; import com.logpm.warehouse.service.IWarehouseRetentionRecordService; import com.logpm.warehouse.service.IWarehouseRetentionScanService; import com.logpm.warehouse.vo.WarehouseRetentionRecordVO; @@ -43,9 +45,16 @@ import com.logpm.warehouse.wrapper.WarehouseRetentionScanWrapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.DictBizConstant; +import org.springblade.common.constant.WorkNodeEnums; import org.springblade.common.constant.common.IsOrNoConstant; import org.springblade.common.constant.retention.RetentionTypeConstant; +import org.springblade.common.enums.BizOperationEnums; +import org.springblade.common.enums.PackageTypeEnums; import org.springblade.common.exception.CustomerException; +import org.springblade.common.model.NodeFanoutMsg; +import org.springblade.common.model.PackageData; +import org.springblade.common.model.workNode.FinishDistributionTrainVO; +import org.springblade.common.model.workNode.RetentionDataByScanVO; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.redis.cache.BladeRedis; @@ -54,7 +63,9 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.cache.DictBizCache; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -86,6 +97,9 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl selectWarehouseRetentionRecordPage(IPage page, WarehouseRetentionRecordVO warehouseRetentionRecord) { @@ -439,10 +453,10 @@ public class WarehouseRetentionRecordServiceImpl extends BaseServiceImpl retentionScanEntityList = warehouseRetentionScanService.getEntityByCodeAndWarehouseId(orderPackageCode, myCurrentWarehouseAndConfig.getId()); if (retentionScanEntityList.isEmpty()) { - //返回当前包件的配送信息准备进行新增 + // 返回当前包件的配送信息准备进行新增 return R.fail(1500, "新增回库任务"); } + AtomicBoolean saveFlah = new AtomicBoolean(false); for (WarehouseRetentionScanEntity warehouseRetentionScanEntity : retentionScanEntityList) { - String isLock = redis.get(AuthUtil.getTenantId() + ":warehouse:" + warehouseRetentionScanEntity.getWarehouseId() + ":retentionTaskCode:" + warehouseRetentionScanEntity.getTaskCode() + ":orderPackageCode:" + warehouseRetentionScanEntity.getOrderPackageCode()); + String lockKey = AuthUtil.getTenantId() + ":warehouse:" + warehouseRetentionScanEntity.getWarehouseId() + ":retentionTaskCode:" + warehouseRetentionScanEntity.getTaskCode() + ":orderPackageCode:" + warehouseRetentionScanEntity.getOrderPackageCode(); + String isLock = redis.get(lockKey); if (!isLock.isEmpty()) { return Resp.scanFail("请勿频繁操作!!!", "请勿频繁操作!!!"); } + + boolean result = false; switch (warehouseRetentionScanEntity.getConditions()) { - case 1: - //订制品 - if (RetentionTypeConstant.yichangjuqian.getValue().equals(warehouseRetentionScanEntity.getRetentionType())){ - saveFlah.set(distributionDeliveryListClient.retentionDeliveryReservationPackage( + case 1: // 订制品 + if (RetentionTypeConstant.yichangjuqian.getValue().equals(warehouseRetentionScanEntity.getRetentionType())) { + result = distributionDeliveryListClient.retentionDeliveryReservationPackage( warehouseRetentionScanEntity.getDeliveryId(), warehouseRetentionScanEntity.getReservationId(), warehouseRetentionScanEntity.getOrderPackageId(), - warehouseRetentionScanEntity.getConditions()) + warehouseRetentionScanEntity.getConditions() ); + } else { + result = distributionParcelListClient.maintainInWarehouse(warehouseRetentionScanEntity.getOrderPackageId(), warehouseRetentionScanEntity.getTaskCode()); } - saveFlah.set(distributionParcelListClient.maintainInWarehouse(warehouseRetentionScanEntity.getOrderPackageId(),warehouseRetentionScanEntity.getTaskCode())); - break; - case 2: - //回库指定数量的零担包件 - saveFlah.set(distributionDeliveryListClient.retentionReservationZeroPackageByNum(warehouseRetentionScanEntity.getDeliveryId(), + case 2: // 回库指定数量的零担包件 + result = distributionDeliveryListClient.retentionReservationZeroPackageByNum( + warehouseRetentionScanEntity.getDeliveryId(), warehouseRetentionScanEntity.getReservationId(), warehouseRetentionScanEntity.getOrderPackageId(), warehouseRetentionScanEntity.getRetentionQuantity(), warehouseRetentionScanEntity.getOrderId(), - warehouseRetentionScanEntity.getLoadingId())); + warehouseRetentionScanEntity.getLoadingId() + ); break; - case 3: - //库存品 - saveFlah.set(distributionDeliveryListClient.retentionDeliveryReservationInventory(warehouseRetentionScanEntity.getDeliveryId(), warehouseRetentionScanEntity.getReservationId(), warehouseRetentionScanEntity.getOrderPackageId())); + case 3: // 库存品 + result = distributionDeliveryListClient.retentionDeliveryReservationInventory( + warehouseRetentionScanEntity.getDeliveryId(), + warehouseRetentionScanEntity.getReservationId(), + warehouseRetentionScanEntity.getOrderPackageId() + ); + break; + default: + log.error("{} >>>>> warehouseRetentionScanEntity.getConditions()={}", method, warehouseRetentionScanEntity.getConditions()); break; } - if (saveFlah.get()) { - redis.del(AuthUtil.getTenantId() + ":warehouse:" + warehouseRetentionScanEntity.getWarehouseId() + ":orderPackageCode:" + warehouseRetentionScanEntity.getOrderPackageCode()+ ":retentionSave:"+warehouseRetentionScanEntity.getTaskCode()); + + if (result) { + saveFlah.set(true); + String saveKey = AuthUtil.getTenantId() + ":warehouse:" + warehouseRetentionScanEntity.getWarehouseId() + ":orderPackageCode:" + warehouseRetentionScanEntity.getOrderPackageCode() + ":retentionSave:" + warehouseRetentionScanEntity.getTaskCode(); + redis.del(saveKey); warehouseRetentionScanEntity.setConfirmStatus(true); warehouseRetentionScanEntity.setRetentionScanUsername(AuthUtil.getNickName()); warehouseRetentionScanEntity.setRetentionScanUserId(AuthUtil.getUserId()); warehouseRetentionScanEntity.setRetentionScanTime(DateUtil.now()); warehouseRetentionScanService.updateById(warehouseRetentionScanEntity); - //维护签收表的异常状态 + + //推送作业数据 + NodeFanoutMsg nodeFanoutMsg = buildNodeFanoutMsgByRetentionDataByScanVO(warehouseRetentionScanEntity, AuthUtil.getUser()); + warehouseNodeWorkService.returnToTheWarehouse(nodeFanoutMsg, AuthUtil.getUser()); + + distributionSignforClient.maintainIsHaveAbnormalPackage(warehouseRetentionScanEntity.getReservationId()); - //对此回库任务绑定的异常标注完成 - if (Func.isNotEmpty(warehouseRetentionScanEntity.getAbnormalId())){ + if (Func.isNotEmpty(warehouseRetentionScanEntity.getAbnormalId())) { distributionLoadscanAbnormalClient.completeAbnormal(warehouseRetentionScanEntity.getAbnormalId()); } } - redis.setEx(AuthUtil.getTenantId() + ":warehouse:" + warehouseRetentionScanEntity.getWarehouseId() + ":retentionTaskCode:" , warehouseRetentionScanEntity.getTaskCode() + ":orderPackageCode:" + warehouseRetentionScanEntity.getOrderPackageCode(),60L); + + redis.setEx(lockKey, "1", 60L); } + if (saveFlah.get()) { return Resp.scanSuccess("操作成功", "操作成功"); } else { throw new CustomerException("服务器正忙..."); } + + } + + private NodeFanoutMsg buildNodeFanoutMsgByRetentionDataByScanVO(WarehouseRetentionScanEntity warehouseRetentionScanEntity, BladeUser user) { + + NodeFanoutMsg nodeFanoutMsg = new NodeFanoutMsg<>(); + + + nodeFanoutMsg.setBizOperation(BizOperationEnums.ADD); + nodeFanoutMsg.setNode(WorkNodeEnums.DISTRIBUTION_RETENTION); + nodeFanoutMsg.setWarehouse(warehouseRetentionScanEntity.getWarehouseName()); + nodeFanoutMsg.setWarehouseId(warehouseRetentionScanEntity.getWarehouseId()); + nodeFanoutMsg.setOperator(user.getNickName()); + nodeFanoutMsg.setOperatorTime(new Date()); + nodeFanoutMsg.setTenantId(user.getTenantId()); + + + RetentionDataByScanVO retentionDataByScanVO = new RetentionDataByScanVO(); + retentionDataByScanVO.setTrainNumber(warehouseRetentionScanEntity.getTrainNumber()); + retentionDataByScanVO.setReservationCode(warehouseRetentionScanEntity.getReservationCode()); + + + List packageDataList = new ArrayList<>(); + PackageData packageData = new PackageData(); + // 包件 + if (warehouseRetentionScanEntity.getConditions() == 1) { + packageData.setPackageCode(warehouseRetentionScanEntity.getOrderPackageCode()); + packageData.setPackageType(PackageTypeEnums.CMP); + packageData.setNumber(1); + DistributionParcelListEntity distributionParcelListEntity1 = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(warehouseRetentionScanEntity.getOrderPackageCode(), warehouseRetentionScanEntity.getWarehouseId()); + if (Func.isNotEmpty(distributionParcelListEntity1)) { + packageData.setBrand(distributionParcelListEntity1.getBrandName()); + } + // 零担 + } else if (warehouseRetentionScanEntity.getConditions() == 2) { + packageData.setPackageType(PackageTypeEnums.LTL); + packageData.setNumber(warehouseRetentionScanEntity.getRetentionQuantity()); + DistributionParcelListEntity byId = distributionParcelListClient.getParcelListId(warehouseRetentionScanEntity.getOrderPackageId() + ""); + if (Func.isNotEmpty(byId)) { + packageData.setOrderCode(byId.getOrderCode()); + packageData.setBrand(byId.getBrandName()); + packageData.setWaybillNumber(byId.getWaybillNumber()); + packageData.setProductName(byId.getFirsts()); + } + // 库存品 + } else if (warehouseRetentionScanEntity.getConditions() == 3) { + DistributionStockListEntity byIds = stockListClient.getStockListById(warehouseRetentionScanEntity.getInventoryId()); + if (Func.isNotEmpty(byIds)) { + packageData.setPackageCode(warehouseRetentionScanEntity.getOrderPackageCode()); + packageData.setBrand(byIds.getBrandName()); + packageData.setMallName(StringUtil.isBlank(byIds.getMallName()) ? byIds.getMarketName() : byIds.getMallName()); +// packageData.setProductName(byId.getDescriptionGoods()); + packageData.setMaterialCode(byIds.getCargoNumber()); + packageData.setMaterialName(byIds.getDescriptionGoods()); + packageData.setPickupBatch(byIds.getIncomingBatch()); + packageData.setPackageType(PackageTypeEnums.INV); + + } else { + log.error(" tage buildNodeFanoutMsgByRetentionDataByScanVO>>> 错误的数据类型"); + return null; + } + + packageDataList.add(packageData); + + } + return nodeFanoutMsg; } }