From ef973df5fb1e0223da684d4b116903283a7824fb Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Thu, 5 Dec 2024 17:53:56 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BFbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/logpm/trunkline/dto/AdvanceDTO.java | 1 + .../feign/ITrunklineAdvanceDetailClient.java | 6 + .../jobhandle/SyncOrderInfoToPlatform.java | 47 ++++ .../controller/OpenOrderController.java | 1 + .../feign/TrunklineAdvanceDetailClient.java | 11 +- .../ITrunklineAdvanceDetailService.java | 5 + .../service/impl/OpenOrderServiceImpl.java | 106 +++++++- .../TrunklineAdvanceDetailServiceImpl.java | 233 +++++++++++++++++- 8 files changed, 405 insertions(+), 5 deletions(-) diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java index c679eea76..fe352db75 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java @@ -14,6 +14,7 @@ public class AdvanceDTO implements Serializable { private Integer pageSize; private Long warehouseId; + private String warehouseName; private List warehouseIds; private Long advanceId; diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java index a0b30c01e..c691980fe 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineAdvanceDetailClient.java @@ -37,4 +37,10 @@ public interface ITrunklineAdvanceDetailClient { */ @GetMapping(API_PREFIX+"/selectByOrderCodeAndWarehouseId") List selectByOrderCodeAndWarehouseId(@RequestParam String orderCode); + + @GetMapping(API_PREFIX+"/saveBasicdata") + void saveBasicdata(@RequestParam Long advanceId); + + @GetMapping(API_PREFIX+"/saveBasicdataZero") + void saveBasicdataZero(@RequestParam String waybillNo); } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java index 7a919f2b8..e9eae61a5 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java @@ -1322,5 +1322,52 @@ public class SyncOrderInfoToPlatform { } + @XxlJob("saveBasicdata") + public ReturnT saveBasicdata(String param) { + log.info("############saveBasicdata: 保存包件基础数据数据 开始"); + + List ls = warehouseMappingDataService.findAllDealWithWaybillNo(); + + ls.forEach(json -> { + Integer id = json.getInt("id"); + Long advanceId = Long.parseLong(json.getStr("waybillNo")); + + log.info("###################saveBasicdata: 当前处理的暂存单id为 advanceId={}",advanceId); + + trunklineAdvanceDetailClient.saveBasicdata(advanceId); + + warehouseMappingDataService.updateStatusDealwithWaybillById(id); + }); + + + log.info("############saveBasicdata: 保存包件基础数据数据 完成"); + + return ReturnT.SUCCESS; + } + + @XxlJob("saveBasicdataZero") + public ReturnT saveBasicdataZero(String param) { + log.info("############saveBasicdataZero: 保存零担基础数据数据 开始"); + + List ls = warehouseMappingDataService.findAllDealWithWaybillNo(); + + ls.forEach(json -> { + Integer id = json.getInt("id"); + String waybillNo = json.getStr("waybillNo"); + + log.info("###################saveBasicdataZero: 当前处理的运单为 waybillNo={}",waybillNo); + + trunklineAdvanceDetailClient.saveBasicdataZero(waybillNo); + + warehouseMappingDataService.updateStatusDealwithWaybillById(id); + }); + + + log.info("############saveBasicdataZero: 保存零担基础数据数据 完成"); + + return ReturnT.SUCCESS; + } + + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java index 0cd087429..5ce301c5d 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/OpenOrderController.java @@ -279,6 +279,7 @@ public class OpenOrderController { return R.fail(405, "多仓权限无法操作,请选择仓库"); } advanceDTO.setWarehouseId(myCurrentWarehouse.getId()); + advanceDTO.setWarehouseName(myCurrentWarehouse.getName()); if (advanceIds.isEmpty()) { log.warn(method + "请选择暂存单 advanceIds={}", advanceIds); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceDetailClient.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceDetailClient.java index 381f99d7a..125a370fd 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceDetailClient.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineAdvanceDetailClient.java @@ -8,7 +8,6 @@ import com.logpm.trunkline.service.ITrunklineAdvanceDetailService; import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.Func; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; @@ -55,4 +54,14 @@ public class TrunklineAdvanceDetailClient implements ITrunklineAdvanceDetailClie .eq(TrunklineAdvanceDetailEntity::getOrderCode,orderCode) ); } + + @Override + public void saveBasicdata(Long advanceId) { + advanceDetailService.saveBasicdata(advanceId); + } + + @Override + public void saveBasicdataZero(String waybillNo) { + advanceDetailService.saveBasicdataZero(waybillNo); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java index 8cb1aae86..059787c98 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java @@ -117,4 +117,9 @@ public interface ITrunklineAdvanceDetailService extends BaseService findListByWaybillId(Long waybillId); + + void saveBasicdata(Long advanceId); + + void saveBasicdataZero(String waybillNo); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index e453345f3..c49857952 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -127,6 +127,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { private final FactoryDataMessageSender factoryDataMessageSender; private final IWarehouseWaybillAbolishClient waybillAbolishClient; private final IWarehouseWaybillDetailAbolishClient waybillDetailAbolishClient; + private final IPackageTrackLogAsyncService packageTrackLogAsyncService; @Override @@ -516,8 +517,45 @@ public class OpenOrderServiceImpl implements IOpenOrderService { @Override public R openWaybill(OpenOrderDTO openOrderDTO) { log.info("############openWaybill: 开单开始 openOrderDTO={}", openOrderDTO); + + String openAdvanceIds = AuthUtil.getTenantId()+":advanceIds"; + + List advanceIdList = new ArrayList<>(); String waybillNo = openOrderDTO.getWaybillNo();//运单号 Long warehouseId = openOrderDTO.getWarehouseId(); + List advanceIds = openOrderDTO.getAdvanceIds(); + + //查询开单订单缓存是否存在 + Boolean exists = bladeRedis.exists(openAdvanceIds); + if(exists){ + String jsonList = bladeRedis.get(openAdvanceIds); + advanceIdList = JSON.parseArray(jsonList, Long.class); + }else{ + bladeRedis.set(openAdvanceIds, JSON.toJSONString(advanceIdList)); + } + + + + + List advanceEntities = advanceService.findListByIds(advanceIds); + //判断advanceEntities中是否有已经开单的暂存单 + List finalAdvanceIdList = advanceIdList; + advanceEntities.forEach(advanceEntity -> { + String waybillStatus = advanceEntity.getWaybillStatus(); + String orderCode = advanceEntity.getOrderCode(); + Long advanceId = advanceEntity.getId(); + if (waybillStatus.equals("1")) { + log.warn("#############openWaybill: 暂存单已开单 orderCode={}", orderCode); + throw new CustomerException(405,"暂存单["+orderCode+"]已开单"); + } + + if(finalAdvanceIdList.contains(advanceId)){ + log.warn("#############openWaybill: 暂存单正在开单 orderCode={}", orderCode); + throw new CustomerException(405,"暂存单["+orderCode+"]正在开单"); + }else{ + bladeRedis.rPush(openAdvanceIds, advanceId); + } + }); BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); if (Objects.isNull(basicdataWarehouseEntity)) { @@ -614,7 +652,6 @@ public class OpenOrderServiceImpl implements IOpenOrderService { waybillEntity.setDealerName(openOrderDTO.getDealerName()); waybillEntity.setWaybillStatus("0"); //统计当前订单的在库数 - List advanceIds = openOrderDTO.getAdvanceIds(); AdvanceDetailStockNumVO advanceDetailStockNumVO = advanceDetailService.findStockNumByAdvanceIds(advanceIds); waybillEntity.setStockCount(advanceDetailStockNumVO.getStockNum()); waybillEntity.setStockWeight(advanceDetailStockNumVO.getStockWeight()); @@ -868,6 +905,10 @@ public class OpenOrderServiceImpl implements IOpenOrderService { advanceDetailService.sendReportAdvanceOpenData(AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, warehouseName, updateAdvanceDetailList, waybillEntity); + advanceIds.forEach(advanceId ->{ + bladeRedis.lRem(openAdvanceIds,0,advanceId); + }); + return R.data(waybillId); } @@ -1239,8 +1280,71 @@ public class OpenOrderServiceImpl implements IOpenOrderService { advanceDetailService.deleteByAdvanceIds(advanceIds); advanceService.deletedAdvance(advanceIds); + packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodeList, advanceDTO.getWarehouseId(), advanceDTO.getWarehouseName(), WorkNodeEnums.DELETE_DATA_ENTRY.getCode(), "包件删除"); + + if(CollUtil.isNotEmpty(detailEntityList)){ + //删除发送广播 + sendDeleteReportBasicdataFanout(AuthUtil.getNickName(), AuthUtil.getUserId(), new Date(),advanceDTO.getWarehouseId(),advanceDTO.getWarehouseName(), detailEntityList); + } + + } + private void sendDeleteReportBasicdataFanout(String nickName, Long userId, Date date,Long warehouseId, String warehouseName, List deleteList) { + String key = AuthUtil.getTenantId()+":brandList"; + + Map brandMap = bladeRedis.hGetAll(key); + + if(CollUtil.isEmpty(brandMap)){ + List allList = basicdataBrandClient.findAllList(); + Map brandIdMap = new HashMap<>(); + allList.forEach(jsonObject -> { + brandIdMap.put(jsonObject.getString("brandName"),jsonObject.getLong("brandId")); + }); + brandMap.putAll(brandIdMap); + } + + NodeFanoutMsg nodeFanoutMsg = new NodeFanoutMsg(); + nodeFanoutMsg.setNode(WorkNodeEnums.INITIAL_DATA_ENTRY); + nodeFanoutMsg.setBizOperation(BizOperationEnums.DELETE); + nodeFanoutMsg.setOperator(nickName); + nodeFanoutMsg.setOperatorId(userId); + nodeFanoutMsg.setWarehouse(warehouseName); + nodeFanoutMsg.setWarehouseId(warehouseId); + nodeFanoutMsg.setOperatorTime(date); + + //组装包件数据 + List packageDataList = new ArrayList<>(); + deleteList.forEach(detailEntity -> { + PackageData packageData = new PackageData(); + packageData.setPackageCode(detailEntity.getOrderPackageCode()); + packageData.setOrderCode(detailEntity.getOrderCode()); + packageData.setServiceNo(detailEntity.getServiceNum()); + packageData.setMaterialId(detailEntity.getMaterialId()); + packageData.setMaterialCode(detailEntity.getMaterialCode()); + packageData.setMaterialName(detailEntity.getMaterialName()); + packageData.setNumber(detailEntity.getQuantity()); + packageData.setWeight(detailEntity.getWeight()); + packageData.setVolume(detailEntity.getVolume()); + packageData.setPackageType(PackageTypeEnums.CMP); + packageData.setCustomerTrain(detailEntity.getTrainNumber()); + String brand = detailEntity.getBrand(); + packageData.setBrandId(brandMap.get(brand)); + packageData.setBrandName(brand); + packageData.setSystemType(detailEntity.getSystemType()); + packageDataList.add(packageData); + }); + nodeFanoutMsg.setMain(packageDataList); + + FanoutMsg fanoutMsg = FanoutMsg.builder().exchange(FanoutConstants.trunkline.REPORTDATA.EXCHANGE).msg(JSONObject.toJSONString(nodeFanoutMsg)).build(); + + sendFanoutService.sendFanoutMsg(fanoutMsg); + + } + + + + @Override public R openZeroWaybillInfo(Long warehouseId) { diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java index d28713e73..7d3f7a941 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java @@ -16,16 +16,18 @@ import com.logpm.distribution.vo.OrderPackgeCodeDataVO; import com.logpm.trunkline.dto.AdvanceDTO; import com.logpm.trunkline.dto.AdvanceDetailDTO; import com.logpm.trunkline.dto.OrderDetailsDTO; +import com.logpm.trunkline.entity.ReportPackageBasicEntity; import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; +import com.logpm.trunkline.entity.TrunklineAdvanceMergeEntity; import com.logpm.trunkline.mapper.TrunklineAdvanceDetailMapper; import com.logpm.trunkline.mapper.TrunklineAdvanceMapper; -import com.logpm.trunkline.service.IPackageTrackLogAsyncService; -import com.logpm.trunkline.service.ISendFanoutService; -import com.logpm.trunkline.service.ITrunklineAdvanceDetailService; +import com.logpm.trunkline.service.*; import com.logpm.trunkline.vo.*; +import com.logpm.warehouse.entity.WarehouseWayBillDetail; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.IWarehouseWaybillClient; +import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.WorkNodeEnums; import org.springblade.common.constant.broadcast.FanoutConstants; @@ -51,6 +53,7 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; @Slf4j @@ -72,6 +75,12 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl findListByWaybillId(Long waybillId) { return baseMapper.findListByWaybillId(waybillId); } + + @Override + public void saveBasicdata(Long advanceId) { + + String key = AuthUtil.getTenantId()+":brandList"; + + Map brandMap = bladeRedis.hGetAll(key); + + if(CollUtil.isEmpty(brandMap)){ + List allList = basicdataBrandClient.findAllList(); + Map brandIdMap = new HashMap<>(); + allList.forEach(jsonObject -> { + brandIdMap.put(jsonObject.getString("brandName"),jsonObject.getLong("brandId")); + }); + brandMap.putAll(brandIdMap); + } + + TrunklineAdvanceEntity advanceEntity = advanceMapper.selectById(advanceId); + + String createUserName = advanceEntity.getCreateUserName(); + String brand = advanceEntity.getBrand(); + String waybillNo = advanceEntity.getWaybillNo(); + WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("advance_id", advanceId); + List advanceDetailEntities = baseMapper.selectList(queryWrapper); + //把advanceDetailEntities中所有元素的orderPackageCode组成一个List + List orderPackageCodes = advanceDetailEntities.stream() + .map(TrunklineAdvanceDetailEntity::getOrderPackageCode) + .collect(Collectors.toList()); + + QueryWrapper queryWrapper1 = new QueryWrapper<>(); + queryWrapper1.in("order_package_code", orderPackageCodes); + List advanceMergeEntityList = advanceMergeService.list(queryWrapper1); + //把advanceMergeEntityList转化成以orderPackageCode为key的Map + Map advanceMergeEntityMap = advanceMergeEntityList.stream() + .collect(Collectors.toMap(TrunklineAdvanceMergeEntity::getOrderPackageCode, Function.identity())); + + + List packageBasicEntityList = reportPackageBasicService.findByOrderPackageCodes(orderPackageCodes); + List addList = new ArrayList<>(); + if(CollUtil.isNotEmpty(packageBasicEntityList)){ + //把packageBasicEntityList转化为以orderPackageCode为key的Map + Map packageBasicEntityMap = packageBasicEntityList.stream() + .collect(Collectors.toMap(ReportPackageBasicEntity::getOrderPackageCode, reportPackageBasicEntity -> reportPackageBasicEntity)); + + advanceDetailEntities.forEach(detailEntity -> { + String orderPackageCode = detailEntity.getOrderPackageCode(); + + ReportPackageBasicEntity reportPackageBasicEntity1 = packageBasicEntityMap.get(orderPackageCode); + if(Objects.isNull(reportPackageBasicEntity1)){ + ReportPackageBasicEntity reportPackageBasicEntity = new ReportPackageBasicEntity(); + reportPackageBasicEntity.setServiceNo(detailEntity.getServiceNum()); + reportPackageBasicEntity.setOrderCode(detailEntity.getOrderCode()); + reportPackageBasicEntity.setOrderPackageCode(orderPackageCode); + TrunklineAdvanceMergeEntity trunklineAdvanceMergeEntity = advanceMergeEntityMap.get(orderPackageCode); + if(!Objects.isNull(trunklineAdvanceMergeEntity)){ + reportPackageBasicEntity.setMergePackageCode(trunklineAdvanceMergeEntity.getMergeCode()); + } + reportPackageBasicEntity.setNum(detailEntity.getQuantity()); + reportPackageBasicEntity.setWeight(detailEntity.getWeight()); + reportPackageBasicEntity.setVolume(detailEntity.getVolume()); + reportPackageBasicEntity.setMaterialId(detailEntity.getMaterialId()); + reportPackageBasicEntity.setMaterialCode(detailEntity.getMaterialCode()); + reportPackageBasicEntity.setMaterialName(detailEntity.getMaterialName()); + reportPackageBasicEntity.setDealerCode(advanceEntity.getDealerCode()); + reportPackageBasicEntity.setDealerName(advanceEntity.getDealerName()); + reportPackageBasicEntity.setPushUserId(detailEntity.getCreateUser()); + reportPackageBasicEntity.setPushUserName(createUserName); + reportPackageBasicEntity.setPushTime(detailEntity.getCreateTime()); + reportPackageBasicEntity.setDataType(PackageTypeEnums.CMP.getCode()); + reportPackageBasicEntity.setSystemType(detailEntity.getSystemType()); + reportPackageBasicEntity.setCustomerTrain(advanceEntity.getTrainNumber()); + reportPackageBasicEntity.setBrandId(brandMap.get(brand)); + reportPackageBasicEntity.setBrand(brand); + reportPackageBasicEntity.setWarehouse(detailEntity.getWarehouseName()); + reportPackageBasicEntity.setWarehouseId(detailEntity.getWarehouseId()); + reportPackageBasicEntity.setIncomingType(detailEntity.getIncomingType()); + reportPackageBasicEntity.setIncomingStatus(Integer.parseInt(detailEntity.getPackageStatus())); + if(!Objects.isNull(warehouseWaybillEntity)){ + reportPackageBasicEntity.setOpenTime(warehouseWaybillEntity.getDocumentMakingTime()); + reportPackageBasicEntity.setOpenUserName(warehouseWaybillEntity.getAgent()); + reportPackageBasicEntity.setOpenUserId(warehouseWaybillEntity.getCreateUser()); + reportPackageBasicEntity.setConsigneeId(warehouseWaybillEntity.getConsigneeId()); + reportPackageBasicEntity.setConsigneeId(warehouseWaybillEntity.getConsigneeId()); + reportPackageBasicEntity.setShipper(warehouseWaybillEntity.getShipper()); + reportPackageBasicEntity.setShipperId(warehouseWaybillEntity.getShipperId()); + reportPackageBasicEntity.setDepartureWarehouseId(warehouseWaybillEntity.getDepartureWarehouseId()); + reportPackageBasicEntity.setDepartureWarehouseName(warehouseWaybillEntity.getDepartureWarehouseName()); + reportPackageBasicEntity.setDestinationWarehouseId(warehouseWaybillEntity.getDestinationWarehouseId()); + reportPackageBasicEntity.setDestinationWarehouseName(warehouseWaybillEntity.getDestinationWarehouseName()); + reportPackageBasicEntity.setDeparture(warehouseWaybillEntity.getDeparture()); + reportPackageBasicEntity.setDestination(warehouseWaybillEntity.getDestination()); + + } + addList.add(reportPackageBasicEntity); + } + }); + + + }else{ + advanceDetailEntities.forEach(detailEntity -> { + String orderPackageCode = detailEntity.getOrderPackageCode(); + ReportPackageBasicEntity reportPackageBasicEntity = new ReportPackageBasicEntity(); + reportPackageBasicEntity.setServiceNo(detailEntity.getServiceNum()); + reportPackageBasicEntity.setOrderCode(detailEntity.getOrderCode()); + reportPackageBasicEntity.setOrderPackageCode(orderPackageCode); + TrunklineAdvanceMergeEntity trunklineAdvanceMergeEntity = advanceMergeEntityMap.get(orderPackageCode); + if(!Objects.isNull(trunklineAdvanceMergeEntity)){ + reportPackageBasicEntity.setMergePackageCode(trunklineAdvanceMergeEntity.getMergeCode()); + } + reportPackageBasicEntity.setNum(detailEntity.getQuantity()); + reportPackageBasicEntity.setWeight(detailEntity.getWeight()); + reportPackageBasicEntity.setVolume(detailEntity.getVolume()); + reportPackageBasicEntity.setMaterialId(detailEntity.getMaterialId()); + reportPackageBasicEntity.setMaterialCode(detailEntity.getMaterialCode()); + reportPackageBasicEntity.setMaterialName(detailEntity.getMaterialName()); + reportPackageBasicEntity.setDealerCode(advanceEntity.getDealerCode()); + reportPackageBasicEntity.setDealerName(advanceEntity.getDealerName()); + reportPackageBasicEntity.setPushUserId(detailEntity.getCreateUser()); + reportPackageBasicEntity.setPushUserName(createUserName); + reportPackageBasicEntity.setPushTime(detailEntity.getCreateTime()); + reportPackageBasicEntity.setDataType(PackageTypeEnums.CMP.getCode()); + reportPackageBasicEntity.setSystemType(detailEntity.getSystemType()); + reportPackageBasicEntity.setCustomerTrain(advanceEntity.getTrainNumber()); + reportPackageBasicEntity.setBrandId(brandMap.get(brand)); + reportPackageBasicEntity.setBrand(brand); + reportPackageBasicEntity.setWarehouse(detailEntity.getWarehouseName()); + reportPackageBasicEntity.setWarehouseId(detailEntity.getWarehouseId()); + reportPackageBasicEntity.setIncomingType(detailEntity.getIncomingType()); + reportPackageBasicEntity.setIncomingStatus(Integer.parseInt(detailEntity.getPackageStatus())); + if(!Objects.isNull(warehouseWaybillEntity)){ + reportPackageBasicEntity.setOpenTime(warehouseWaybillEntity.getDocumentMakingTime()); + reportPackageBasicEntity.setOpenUserName(warehouseWaybillEntity.getAgent()); + reportPackageBasicEntity.setOpenUserId(warehouseWaybillEntity.getCreateUser()); + reportPackageBasicEntity.setConsigneeId(warehouseWaybillEntity.getConsigneeId()); + reportPackageBasicEntity.setConsigneeId(warehouseWaybillEntity.getConsigneeId()); + reportPackageBasicEntity.setShipper(warehouseWaybillEntity.getShipper()); + reportPackageBasicEntity.setShipperId(warehouseWaybillEntity.getShipperId()); + reportPackageBasicEntity.setDepartureWarehouseId(warehouseWaybillEntity.getDepartureWarehouseId()); + reportPackageBasicEntity.setDepartureWarehouseName(warehouseWaybillEntity.getDepartureWarehouseName()); + reportPackageBasicEntity.setDestinationWarehouseId(warehouseWaybillEntity.getDestinationWarehouseId()); + reportPackageBasicEntity.setDestinationWarehouseName(warehouseWaybillEntity.getDestinationWarehouseName()); + reportPackageBasicEntity.setDeparture(warehouseWaybillEntity.getDeparture()); + reportPackageBasicEntity.setDestination(warehouseWaybillEntity.getDestination()); + + } + addList.add(reportPackageBasicEntity); + }); + } + if(CollUtil.isNotEmpty(addList)){ + reportPackageBasicService.saveBatch(addList); + } + + } + + @Override + public void saveBasicdataZero(String waybillNo) { + + WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + + Long waybillId = warehouseWaybillEntity.getId(); + + List wayBillDetailList = iWarehouseWaybillDetailClient.findByWaybillId(waybillId); + + List listByWaybillNo = reportPackageBasicService.findListByWaybillNo(waybillNo); + //把listByWaybillNo转化为以productName为key 的Map + Map productNameMap = listByWaybillNo.stream() + .collect(Collectors.toMap(ReportPackageBasicEntity::getProductName, reportPackageBasicEntity -> reportPackageBasicEntity)); + List addList = new ArrayList<>(); + wayBillDetailList.forEach(wayBillDetail -> { + String productName = wayBillDetail.getProductName(); + ReportPackageBasicEntity entity = productNameMap.get(productName); + if(Objects.isNull(entity)){ + ReportPackageBasicEntity reportPackageBasicEntity = new ReportPackageBasicEntity(); + reportPackageBasicEntity.setWaybillNo(waybillNo); + reportPackageBasicEntity.setOrderCode(waybillNo); + reportPackageBasicEntity.setNum(wayBillDetail.getNum()); + reportPackageBasicEntity.setWeight(wayBillDetail.getWeight()); + reportPackageBasicEntity.setVolume(wayBillDetail.getVolume()); + reportPackageBasicEntity.setPushUserId(warehouseWaybillEntity.getCreateUser()); + reportPackageBasicEntity.setPushUserName(warehouseWaybillEntity.getAgent()); + reportPackageBasicEntity.setPushTime(warehouseWaybillEntity.getDocumentMakingTime()); + reportPackageBasicEntity.setOpenTime(warehouseWaybillEntity.getDocumentMakingTime()); + reportPackageBasicEntity.setOpenUserName(warehouseWaybillEntity.getAgent()); + reportPackageBasicEntity.setOpenUserId(warehouseWaybillEntity.getCreateUser()); + reportPackageBasicEntity.setIncomingTime(warehouseWaybillEntity.getDocumentMakingTime()); + reportPackageBasicEntity.setIncomingUserName(warehouseWaybillEntity.getAgent()); + reportPackageBasicEntity.setIncomingUserId(warehouseWaybillEntity.getCreateUser()); + reportPackageBasicEntity.setDataType(PackageTypeEnums.LTL.getCode()); + reportPackageBasicEntity.setSystemType("线下"); + reportPackageBasicEntity.setBrandId(warehouseWaybillEntity.getBrandId()); + reportPackageBasicEntity.setBrand(warehouseWaybillEntity.getBrand()); + reportPackageBasicEntity.setWarehouse(warehouseWaybillEntity.getDepartureWarehouseName()); + reportPackageBasicEntity.setWarehouseId(warehouseWaybillEntity.getDepartureWarehouseId()); + reportPackageBasicEntity.setIncomingType(3); + reportPackageBasicEntity.setShipper(warehouseWaybillEntity.getShipper()); + reportPackageBasicEntity.setShipperId(warehouseWaybillEntity.getShipperId()); + reportPackageBasicEntity.setConsignee(warehouseWaybillEntity.getConsignee()); + reportPackageBasicEntity.setConsigneeId(warehouseWaybillEntity.getConsigneeId()); + reportPackageBasicEntity.setDepartureWarehouseId(warehouseWaybillEntity.getDepartureWarehouseId()); + reportPackageBasicEntity.setDepartureWarehouseName(warehouseWaybillEntity.getDepartureWarehouseName()); + reportPackageBasicEntity.setDestinationWarehouseId(warehouseWaybillEntity.getDestinationWarehouseId()); + reportPackageBasicEntity.setDestinationWarehouseName(warehouseWaybillEntity.getDestinationWarehouseName()); + reportPackageBasicEntity.setDeparture(warehouseWaybillEntity.getDeparture()); + reportPackageBasicEntity.setDestination(warehouseWaybillEntity.getDestination()); + reportPackageBasicEntity.setIncomingStatus(1); + addList.add(reportPackageBasicEntity); + } + }); + + if(CollUtil.isNotEmpty(addList)){ + reportPackageBasicService.saveBatch(addList); + } + + } }