diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java b/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java index 6a041b053..13a14e86a 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/broadcast/FanoutConstants.java @@ -142,6 +142,21 @@ public abstract class FanoutConstants { } + /** + * 备货节点 + * + * @see org.springblade.common.model.StockUpVO + **/ + interface tripartite { + + String EXCHANGE = "fanout.trunkline.tripartite" + ModuleNameConstant.DEVAUTH; + + interface QUEUE { + String SIGN = "fanout.trunkline.tripartite.sign" + ModuleNameConstant.DEVAUTH; + } + } + + } diff --git a/blade-biz-common/src/main/java/org/springblade/common/model/TripartiteVO.java b/blade-biz-common/src/main/java/org/springblade/common/model/TripartiteVO.java new file mode 100644 index 000000000..8d5eb0584 --- /dev/null +++ b/blade-biz-common/src/main/java/org/springblade/common/model/TripartiteVO.java @@ -0,0 +1,50 @@ +package org.springblade.common.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +@Data +public class TripartiteVO implements Serializable { + + /** 发车批次号 */ + private String carsNo ; + + /** 司机id */ + private Long driverId ; + /** 司机名称 */ + private String driverName ; + /** 司机电话 */ + private String driverMobile ; + /** 副驾id */ + private Long assistantId ; + /** 副驾i名称 */ + private String assistantName ; + /** 副驾i电话 */ + private String assistantMobile ; + + /** 车辆id */ + private Long carId ; + + /** 送货方式:1=自提,2=送货 */ + private String deliveryType ; + + /** 客户类型:1=商场,2=C端客户[多选] */ + private String customerType ; + + /** 承运商id */ + private Long carrierId ; + /** 承运商名称 */ + private String carrierName ; + /** 承运单号 */ + private String carrierOrderCode ; + /** 承运时间 */ + private Date carrierTime ; + /** 车牌号 */ + private String carNumber ; + + private List packageDataList; + +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 08f25ae25..9631e1f09 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -54,12 +54,19 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.springblade.common.annotations.RepeatSubmit; import org.springblade.common.constant.*; +import org.springblade.common.constant.broadcast.FanoutConstants; import org.springblade.common.constant.carsload.CarsLoadLogTypeConstant; +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.TripartiteVO; import org.springblade.common.utils.CommonUtil; import org.springblade.common.utils.QRCodeUtil; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.BeanUtil; @@ -9746,6 +9753,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl packageDataList = new ArrayList<>(); + List loadScanEntityList = trunklineCarsLoadScanService.findListByIds(loadScanIds); //把loadScanEntityList中所有元素通过type进行分组 Map> map = loadScanEntityList.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanEntity::getType)); @@ -9757,30 +9766,107 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl scanCodes = trunklineCarsLoadScanEntities.stream().map(TrunklineCarsLoadScanEntity::getScanCode).collect(Collectors.toList()); //TODO 暂时注释 // carsLoadAsyncService.sendReportPackageSignData(AuthUtil.getNickName(),AuthUtil.getUserId(),warehouseId,warehouseName,carsLoadEntity,scanCodes); + + + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderPackageCodeList(scanCodes); + findParamterDTO.setWarehouseId(warehouseId); + List parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); + parcelListEntityList.forEach(parcelListEntity -> { + PackageData packageData = new PackageData(); + packageData.setWaybillNumber(parcelListEntity.getWaybillNumber()); + packageData.setBrand(parcelListEntity.getBrandName()); + packageData.setPackageCode(parcelListEntity.getOrderPackageCode()); + packageData.setMaterialCode(parcelListEntity.getMaterialCode()); + packageData.setMaterialName(parcelListEntity.getMaterialName()); + packageData.setNumber(1); + packageData.setOrderCode(parcelListEntity.getOrderCode()); + packageData.setPackageType(PackageTypeEnums.CMP); + packageDataList.add(packageData); + }); + }else{ trunklineCarsLoadScanEntities.forEach(carsLoadScanEntity -> { Long scanId = carsLoadScanEntity.getId(); List zeroDetailVOList = scanZeroDetailService.findListByCarsLoadScanId(scanId); + + //把zeroDetailList中所有元素的packageId放入一个List + List packageIds = zeroDetailVOList.stream().map(TrunklineScanZeroDetailEntity::getPackageId).collect(Collectors.toList()); + List parcelListEntityList = distributionParcelListClient.findListByIds(packageIds); + //把parcelListEntityList转成以id为key的Map + Map parcelListMap = parcelListEntityList.stream().collect(Collectors.toMap(DistributionParcelListEntity::getId, Function.identity())); + List zeroDetailList = new ArrayList<>(); zeroDetailVOList.forEach(zeroDetailVO -> { TrunklineScanZeroDetailEntity entity = new TrunklineScanZeroDetailEntity(); BeanUtil.copy(zeroDetailVO, entity); zeroDetailList.add(entity); + Long packageId = zeroDetailVO.getPackageId(); + DistributionParcelListEntity parcelList = parcelListMap.get(packageId); + if(!Objects.isNull(parcelList)){ + PackageData packageData = new PackageData(); + packageData.setWaybillNumber(parcelList.getWaybillNumber()); + packageData.setBrand(parcelList.getBrandName()); + packageData.setProductId(zeroDetailVO.getGoodsId()); + packageData.setProductName(zeroDetailVO.getGoodsName()); + packageData.setNumber(zeroDetailVO.getUnloadNum()); + packageData.setOrderCode(parcelList.getOrderCode()); + packageData.setPackageType(PackageTypeEnums.LTL); + packageDataList.add(packageData); + } + + }); //TODO 暂时注释 // carsLoadAsyncService.sendReportZeroPackageSignData(AuthUtil.getUserId(), AuthUtil.getNickName(), warehouseId, warehouseName, zeroDetailList, carsLoadScanEntity, carsLoadEntity); + + + }); } }); + NodeFanoutMsg tripartiteVONodeFanoutMsg = buildNodeFanoutMessage(carsLoadEntity, packageDataList, warehouseId); + if(!Objects.isNull(tripartiteVONodeFanoutMsg)){ + rabbitTemplate.convertAndSend(FanoutConstants.trunkline.tripartite.EXCHANGE, null, com.alibaba.fastjson.JSONObject.toJSONString(tripartiteVONodeFanoutMsg)); + } return R.success("签收成功"); } + private NodeFanoutMsg buildNodeFanoutMessage(TrunklineCarsLoadEntity carsLoadEntity, List packageDataList,Long warehouseId) { + try { + BladeUser user = AuthUtil.getUser(); + NodeFanoutMsg nodeFanoutMsg = new NodeFanoutMsg(); + nodeFanoutMsg.setBizOperation(BizOperationEnums.ADD); + nodeFanoutMsg.setNode(WorkNodeEnums.SIGN_TRIPARTITE_TRANSFER_DEPART); + BasicdataWarehouseEntity entityWarehouse = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if (entityWarehouse != null) { + nodeFanoutMsg.setWarehouse(entityWarehouse.getName()); + } + nodeFanoutMsg.setWarehouseId(warehouseId); + nodeFanoutMsg.setOperator(user.getNickName()); + nodeFanoutMsg.setOperatorTime(new Date()); + TripartiteVO tripartiteVO = new TripartiteVO(); + BeanUtil.copy(carsLoadEntity, tripartiteVO); +// ReservationVO reservationVO = distributionReservationService.getReservationVO(reservationEntity); + + tripartiteVO.setPackageDataList(packageDataList); + nodeFanoutMsg.setMain(tripartiteVO); + nodeFanoutMsg.setTenantId(AuthUtil.getTenantId()); + + return nodeFanoutMsg; + } catch (Exception e) { + log.warn("三方中转签收:发送三方中转签收节点消息失败", e); + } + return null; + + } + private void sendFactorySignTriparite(Long warehouseId, List orderPackageCodes, BasicdataWarehouseEntity warehouseEntity) { try { FindParamterDTO paramterDTO = new FindParamterDTO();