From 7cddd6f7d21aa55e40c8aefeef78fc909e9143f3 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Thu, 10 Oct 2024 16:37:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=8C=85=E6=9D=A1=E7=A0=81=E5=8F=82=E7=9C=8B=E5=8C=85=E6=9D=A1?= =?UTF-8?q?=E7=A0=81=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=86=85=E5=AE=B9=20?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=85=A5=E5=BA=93=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=AE=B6=E7=AB=AF=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E7=89=B9=E6=AE=8A=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/DistributionParcelListEntity.java | 2 +- .../feign/IDistributionParcelListClient.java | 11 + .../impl/BusinessPreOrderServiceImpl.java | 13 +- .../feign/DistributionParcelListClient.java | 5 + .../mapper/DistributionParcelListMapper.java | 2 + .../mapper/DistributionParcelListMapper.xml | 19 + .../IDistributionParcelListService.java | 2 + .../impl/DistributionAsyncServiceImpl.java | 4 +- .../DistributionParcelListServiceImpl.java | 4 + .../impl/DistributionSignforServiceImpl.java | 3 +- .../trunkline/api/InComingApiController.java | 37 +- .../controller/OpenOrderController.java | 56 ++ .../mapper/TrunklineAdvanceMapper.java | 3 + .../mapper/TrunklineAdvanceMapper.xml | 64 +- .../trunkline/service/IOpenOrderService.java | 2 + .../service/ITrunklineAdvanceService.java | 3 + .../service/impl/InComingServiceImpl.java | 141 ++--- .../service/impl/OpenOrderServiceImpl.java | 14 + .../impl/TrunklineAdvanceServiceImpl.java | 597 ++++++++++++++++++ .../com/logpm/warehouse/api/OrderInfoApi.java | 52 ++ 20 files changed, 950 insertions(+), 84 deletions(-) create mode 100644 blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/OrderInfoApi.java diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionParcelListEntity.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionParcelListEntity.java index b9abba72c..8615e9c4b 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionParcelListEntity.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/DistributionParcelListEntity.java @@ -143,7 +143,7 @@ public class DistributionParcelListEntity extends TenantEntity { /** * 包件类型 1 定制品 2 库存品 3零担 */ - @ApiModelProperty(value = "状态") + @ApiModelProperty(value = "包件类型") private Integer conditions; /** * 包条码 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 a440bc873..5e4e16492 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 @@ -270,4 +270,15 @@ public interface IDistributionParcelListClient { */ @GetMapping(API_PREFIX + "/clearWaybillInfoByParceListIds") boolean maintainInWarehouse(@RequestParam("orderPackageId") Long orderPackageId,@RequestParam("taskCode") String taskCode); + + + /** + * 根据包条码合仓库查询信息 + * @param orderPackageCode + * @param warehouseId + * @return + */ + @GetMapping(API_PREFIX + "/findOrderInfoByOrderPackageCode") + Map findOrderInfoByOrderPackageCode(@RequestParam("orderPackageCode") String orderPackageCode,@RequestParam("warehouseId") Long warehouseId); } + diff --git a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java index 319124aec..fc53e6764 100644 --- a/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java +++ b/blade-service/logpm-business/src/main/java/com/logpm/business/service/impl/BusinessPreOrderServiceImpl.java @@ -378,6 +378,7 @@ public class BusinessPreOrderServiceImpl extends BaseServiceImpl findOrderInfoByOrderPackageCode(String orderPackageCode, Long warehouseId) { + return distributionParcelListService.findOrderInfoByOrderPackageCode(orderPackageCode,warehouseId); + } } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java index 772f402bd..e809cb894 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java @@ -311,4 +311,6 @@ public interface DistributionParcelListMapper extends BaseMapper findOrderCodeByWaybillId(@Param("waybillId") Long waybillId); void clearWaybillInfoByParceListIds(@Param("parceListIds") List parceListIds); + + Map findOrderInfoByOrderPackageCode(@Param("orderPackageCode") String orderPackageCode, @Param("warehouseId") Long warehouseId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml index 05902d41a..ac672100e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml @@ -1927,6 +1927,25 @@ where waybill_id = #{waybillId} group by order_code + + update logpm_distribution_parcel_list diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java index 25b23ab2a..d8b4102d4 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java @@ -282,4 +282,6 @@ public interface IDistributionParcelListService extends BaseService findOrderInfoByOrderPackageCode(String orderPackageCode, Long warehouseId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java index ae5b5e615..7e7f88df6 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java @@ -1224,11 +1224,11 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService { int outboundQuantity = parcelNumberEntities.stream().mapToInt(DistributionParcelNumberEntity::getOutboundQuantity).sum(); if (outboundQuantity > 0 && outboundQuantity < stockArticleEntity.getTotalNumber()) { stockArticleEntity.setOrderStatus(OrderStatusConstant.bufenchuku.getValue()); - stockArticleEntity.setDeliveryQuantity(stockArticleEntity.getDeliveryQuantity() + outboundQuantity); + stockArticleEntity.setDeliveryQuantity( outboundQuantity); } if (stockArticleEntity.getTotalNumber() == outboundQuantity) { stockArticleEntity.setOrderStatus(OrderStatusConstant.chuku.getValue()); - stockArticleEntity.setDeliveryQuantity(stockArticleEntity.getDeliveryQuantity() + outboundQuantity); + stockArticleEntity.setDeliveryQuantity(outboundQuantity); } distributionStockArticleService.updateById(stockArticleEntity); //维护预约客户和配送任务装车状态 diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java index e1fd3ba14..aa40e3172 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java @@ -1470,4 +1470,8 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl findOrderInfoByOrderPackageCode(String orderPackageCode, Long warehouseId) { + return baseMapper.findOrderInfoByOrderPackageCode(orderPackageCode,warehouseId); + } } 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 4cd2f581f..62dc62ac9 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 @@ -3829,7 +3829,8 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl warehouseIds = new ArrayList<>(); + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(!Objects.isNull(myCurrentWarehouse)){ + warehouseIds.add(myCurrentWarehouse.getId()); + }else{ + List myWatchWarehouse = warehouseClient.getMyWatchWarehouse(); + myWatchWarehouse.forEach(warehouse -> { + warehouseIds.add(warehouse.getId()); + }); + } + advanceDTO.setWarehouseIds(warehouseIds); + + if(Objects.isNull(pageNum)){ + advanceDTO.setPageNum(1); + } + if(Objects.isNull(pageSize)){ + advanceDTO.setPageNum(30); + } + if(StringUtil.isBlank(freezeStatus)){ + log.warn(method+"冻结状态不能为空 freezeStatus={}",freezeStatus); + return R.fail(400,"冻结状态不能为空"); + } + if(Objects.isNull(hasPackage)){ + log.warn(method+"有无包件数据不能为空 hasPackage={}",hasPackage); + return R.fail(400,"有无包件数据不能为空"); + } + + + IPage pages = openOrderService.advancePageListByBussiness(advanceDTO); + + return R.data(pages); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } + + @ResponseBody @PostMapping("/findCustomerInfoList") @ApiOperationSupport(order = 1) diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java index e58e6fa33..e141769f6 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.java @@ -47,4 +47,7 @@ public interface TrunklineAdvanceMapper extends BaseMapper advancePageListByBussiness(IPage page, @Param("param") AdvanceDTO advanceDTO); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml index fa4ee4fd4..0d85bd7e7 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml @@ -11,7 +11,7 @@ - select lta.*, lbc.client_name htMallName from logpm_trunkline_advance lta @@ -189,6 +189,68 @@ ) orderCodes where orderCodes.orderCode = lta.order_code) and lta.waybill_status = '0' + update logpm_trunkline_advance diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java index 3863dcb02..04c9390e6 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderService.java @@ -97,5 +97,7 @@ public interface IOpenOrderService { R cancleCheckWaybill(OpenOrderDTO openOrderDTO); + IPage advancePageListByBussiness(AdvanceDTO advanceDTO); + // R findWaybillInfo(String waybillNo); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java index e240361fe..2576b0167 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceService.java @@ -42,10 +42,13 @@ public interface ITrunklineAdvanceService extends BaseService findListByExistsAndOrderCodeSet(List orderCodeSet); boolean saveOrderAndPackages(List advanceDetailEntities, Long warehouseId); + boolean saveOrderAndPackagesByBussiness(List advanceDetailEntities, Long warehouseId); Boolean cancelOrder(String orderCode); void deleteByWaybillNo(String waybillNo); void clearWaybillInfoByWaybillId(Long waybillId); + + IPage advancePageListByBussiness(IPage page, AdvanceDTO advanceDTO); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java index a38d0be41..7ec614b02 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/InComingServiceImpl.java @@ -179,10 +179,10 @@ public class InComingServiceImpl implements IInComingService { .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) .content(Collections.singletonList(PushData.builder() - .packageCode(packageCode) - .warehouseName(warehouseName) - .orderCode(advanceDetailEntity.getOrderCode()) - .build())) + .packageCode(packageCode) + .warehouseName(warehouseName) + .orderCode(advanceDetailEntity.getOrderCode()) + .build())) .build(); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); } catch (Exception e) { @@ -194,14 +194,11 @@ public class InComingServiceImpl implements IInComingService { } - - - @Override @Transactional(rollbackFor = Exception.class) public R incomingPackage(InComingDTO inComingDTO) { AtomicReference audio = new AtomicReference<>(); - try{ + try { String orderPackageCode = inComingDTO.getOrderPackageCode();//包件码 Long warehouseId = inComingDTO.getWarehouseId();//仓库id String warehouseName = inComingDTO.getWarehouseName(); @@ -229,12 +226,12 @@ public class InComingServiceImpl implements IInComingService { return Resp.scanFail(405, "系统无编码", "系统无编码"); } - if(incomingType == 1 || incomingType == 2){ + if (incomingType == 1 || incomingType == 2) { for (TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity : advanceDetailEntityList) { String packageStatus = trunklineAdvanceDetailEntity.getPackageStatus(); - if("0".equals(packageStatus)){ + if ("0".equals(packageStatus)) { Long warehouseId1 = trunklineAdvanceDetailEntity.getWarehouseId(); - if(!warehouseId1.equals(warehouseId)){ + if (!warehouseId1.equals(warehouseId)) { log.warn("############incomingPackage: 包件数据不在当前仓 packageCodes={} warehouseId={}", packageCodes, warehouseId); return Resp.scanFail(405, "包件数据不在当前仓", "包件数据不在当前仓"); } @@ -242,10 +239,10 @@ public class InComingServiceImpl implements IInComingService { } } - if(StringUtil.isNotBlank(customerTrain)){ + if (StringUtil.isNotBlank(customerTrain)) { for (TrunklineAdvanceDetailEntity advanceDetailEntity : advanceDetailEntityList) { String trainNumber = advanceDetailEntity.getTrainNumber(); - if(!trainNumber.equals(customerTrain)){ + if (!trainNumber.equals(customerTrain)) { log.warn("############incomingPackage: 包件车次号不一致 packageCodes={} trainNumber={} trainNumber={}", packageCodes, trainNumber, customerTrain); return Resp.scanFail(405, "包件车次号不一致", "包件车次号不一致"); } @@ -253,7 +250,6 @@ public class InComingServiceImpl implements IInComingService { } - //把advanceDetailEntityList通过packageStatus分组 Map> advanceDetailEntityMap = advanceDetailEntityList.stream().collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getPackageStatus)); @@ -307,7 +303,7 @@ public class InComingServiceImpl implements IInComingService { Map> advanceDetailEntityWaybillNoMap = advanceDetailEntities.stream().filter(entity -> StringUtil.isNotBlank(entity.getWaybillNo())).collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getWaybillNo)); Set waybillNoSet = advanceDetailEntityWaybillNoMap.keySet(); - if(!waybillNoSet.isEmpty()){ + if (!waybillNoSet.isEmpty()) { List waybillEntityList = warehouseWaybillClient.findWaybillBilllByWaybillNos(new ArrayList<>(waybillNoSet)); //把waybillEntityList转化成waybillNo为key的map @@ -315,14 +311,14 @@ public class InComingServiceImpl implements IInComingService { advanceDetailEntityWaybillNoMap.keySet().forEach(waybillNo -> { List waybillNoAdvanceDetailEntities = advanceDetailEntityWaybillNoMap.get(waybillNo); - if(!waybillNoAdvanceDetailEntities.isEmpty()){ + if (!waybillNoAdvanceDetailEntities.isEmpty()) { WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo); - if(!Objects.isNull(waybillEntity)){ + if (!Objects.isNull(waybillEntity)) { Long departureWarehouseId = waybillEntity.getDepartureWarehouseId(); - if(departureWarehouseId!=null&&departureWarehouseId.equals(warehouseId)){ + if (departureWarehouseId != null && departureWarehouseId.equals(warehouseId)) { Integer totalCount = waybillEntity.getTotalCount(); Integer stockCount = waybillEntity.getStockCount(); - openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "20", "已入库", "运单入库:"+stockCount+"/"+totalCount+",入库类型:【"+IncomingTypeEnum.getValue(incomingType)+"】,入库时间:"+ CommonUtil.dateToStringGeneral(new Date()), AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, finalWarehouseName); + openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "20", "已入库", "运单入库:" + stockCount + "/" + totalCount + ",入库类型:【" + IncomingTypeEnum.getValue(incomingType) + "】,入库时间:" + CommonUtil.dateToStringGeneral(new Date()), AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, finalWarehouseName); } } } @@ -348,11 +344,11 @@ public class InComingServiceImpl implements IInComingService { map.put("orderPackageCode", packageCode); R r = warehouseTrayTypeClient.orderScanOrderPackageCodeReturnR(map); int code = r.getCode(); - if(code != 200){ + if (code != 200) { audio.set(r.getMsg()); - }else{ + } else { String data = (String) r.getData(); - if(StringUtil.isNotBlank(data)){ + if (StringUtil.isNotBlank(data)) { JSONObject parseObj = JSONUtil.parseObj(data); String audio1 = parseObj.getStr("audio"); audio.set(audio1); @@ -389,10 +385,10 @@ public class InComingServiceImpl implements IInComingService { .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) .content(Collections.singletonList(PushData.builder() - .packageCode(advanceDetailEntity.getOrderPackageCode()) - .orderCode(advanceDetailEntity.getOrderCode()) - .warehouseName(finalWarehouseName) - .build())) + .packageCode(advanceDetailEntity.getOrderPackageCode()) + .orderCode(advanceDetailEntity.getOrderCode()) + .warehouseName(finalWarehouseName) + .build())) .build(); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); } else if (tenant.getTenantType() == 2) { @@ -463,11 +459,11 @@ public class InComingServiceImpl implements IInComingService { map.put("orderPackageCode", packageCode); R r = warehouseTrayTypeClient.orderScanOrderPackageCodeReturnR(map); int code = r.getCode(); - if(code != 200){ + if (code != 200) { audio.set(r.getMsg()); - }else{ + } else { String data = (String) r.getData(); - if(StringUtil.isNotBlank(data)){ + if (StringUtil.isNotBlank(data)) { JSONObject parseObj = JSONUtil.parseObj(data); String audio1 = parseObj.getStr("audio"); audio.set(audio1); @@ -481,8 +477,8 @@ public class InComingServiceImpl implements IInComingService { }); int size = packageCodes.size(); - if(size == 1){ - if(incomingType == 2){ + if (size == 1) { + if (incomingType == 2) { //只有扫码入库才报服务仓库 String packageCode = packageCodes.get(0); TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailService.findEntityByOrderPackageCode(packageCode); @@ -492,48 +488,47 @@ public class InComingServiceImpl implements IInComingService { String dealerName = advanceEntity.getDealerName(); String dealerCode = advanceEntity.getDealerCode(); String brand = advanceEntity.getBrand(); - if(!Objects.isNull(waybillId)){ + if (!Objects.isNull(waybillId)) { WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillId(waybillId); - if(!Objects.isNull(waybillEntity)){ + if (!Objects.isNull(waybillEntity)) { String destinationWarehouseName = waybillEntity.getDestinationWarehouseName(); - return Resp.scanSuccess(dealerName+"的目的仓库为"+destinationWarehouseName,dealerName+"的目的仓库为"+destinationWarehouseName); - }else{ - return Resp.scanSuccess("商家为"+dealerName,"商家为"+dealerName); + return Resp.scanSuccess(dealerName + "的目的仓库为" + destinationWarehouseName, dealerName + "的目的仓库为" + destinationWarehouseName); + } else { + return Resp.scanSuccess("商家为" + dealerName, "商家为" + dealerName); } - }else{ - BasicdataTripartiteMallEntity tripartiteMallEntity = tripartiteMallClient.findEntityByDealerNameAndDealerCodeAndBrand(dealerName,dealerCode,brand); - if(!Objects.isNull(tripartiteMallEntity)){ + } else { + BasicdataTripartiteMallEntity tripartiteMallEntity = tripartiteMallClient.findEntityByDealerNameAndDealerCodeAndBrand(dealerName, dealerCode, brand); + if (!Objects.isNull(tripartiteMallEntity)) { Long clientId = tripartiteMallEntity.getClientId(); BasicdataStorageServicesEntity storageServicesEntity = storageServicesClient.findEntityBySendWarehouseIdAndClientId(warehouseId, clientId); - if(!Objects.isNull(storageServicesEntity)){ + if (!Objects.isNull(storageServicesEntity)) { String serveWarehouseName = storageServicesEntity.getServeWarehouseName(); - return Resp.scanSuccess(dealerName+"的服务仓库为"+serveWarehouseName,dealerName+"的服务仓库为"+serveWarehouseName); + return Resp.scanSuccess(dealerName + "的服务仓库为" + serveWarehouseName, dealerName + "的服务仓库为" + serveWarehouseName); } } - return Resp.scanSuccess("商家为"+dealerName,"商家为"+dealerName); + return Resp.scanSuccess("商家为" + dealerName, "商家为" + dealerName); } } } - }catch (Exception e){ - log.error("入库异常",e); + } catch (Exception e) { + log.error("入库异常", e); throw e; } String a = audio.get(); - if(StringUtil.isNotBlank(a)){ - return Resp.scanFail(200,a,a); + if (StringUtil.isNotBlank(a)) { + return Resp.scanFail(200, a, a); } return R.success("入库成功"); } - @Override @Transactional(rollbackFor = Exception.class) public R incomingPackageByTaryCode(InComingDTO inComingDTO) { - try{ + try { AtomicReference audio = new AtomicReference<>(); String orderPackageCode = inComingDTO.getOrderPackageCode();//包件码 Long warehouseId = inComingDTO.getWarehouseId();//仓库id @@ -561,10 +556,10 @@ public class InComingServiceImpl implements IInComingService { log.warn("############incomingPackage: 包件不存在 packageCodes={} warehouseId={}", packageCodes, warehouseId); return Resp.scanFail(405, "包件无数据", "包件无数据"); } - if(StringUtil.isNotBlank(customerTrain)){ + if (StringUtil.isNotBlank(customerTrain)) { for (TrunklineAdvanceDetailEntity advanceDetailEntity : advanceDetailEntityList) { String trainNumber = advanceDetailEntity.getTrainNumber(); - if(!trainNumber.equals(customerTrain)){ + if (!trainNumber.equals(customerTrain)) { log.warn("############incomingPackage: 包件车次号不一致 packageCodes={} trainNumber={} trainNumber={}", packageCodes, trainNumber, customerTrain); return Resp.scanFail(405, "包件车次号不一致", "包件车次号不一致"); } @@ -617,14 +612,14 @@ public class InComingServiceImpl implements IInComingService { //2.判断包件和订单是否已经存入在库订单 - boolean b = advanceService.saveOrderAndPackages(advanceDetailEntities, warehouseId); + boolean b = advanceService.saveOrderAndPackagesByBussiness(advanceDetailEntities, warehouseId); if (b) { //把advanceDetailEntities通过waybillNo进行分组 Map> advanceDetailEntityWaybillNoMap = advanceDetailEntities.stream().filter(entity -> StringUtil.isNotBlank(entity.getWaybillNo())).collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getWaybillNo)); Set waybillNoSet = advanceDetailEntityWaybillNoMap.keySet(); - if(!waybillNoSet.isEmpty()){ + if (!waybillNoSet.isEmpty()) { List waybillEntityList = warehouseWaybillClient.findWaybillBilllByWaybillNos(new ArrayList<>(waybillNoSet)); //把waybillEntityList转化成waybillNo为key的map @@ -632,14 +627,14 @@ public class InComingServiceImpl implements IInComingService { advanceDetailEntityWaybillNoMap.keySet().forEach(waybillNo -> { List waybillNoAdvanceDetailEntities = advanceDetailEntityWaybillNoMap.get(waybillNo); - if(!waybillNoAdvanceDetailEntities.isEmpty()){ + if (!waybillNoAdvanceDetailEntities.isEmpty()) { WarehouseWaybillEntity waybillEntity = waybillEntityMap.get(waybillNo); - if(!Objects.isNull(waybillEntity)){ + if (!Objects.isNull(waybillEntity)) { Long departureWarehouseId = waybillEntity.getDepartureWarehouseId(); - if(departureWarehouseId!=null&&departureWarehouseId.equals(warehouseId)){ + if (departureWarehouseId != null && departureWarehouseId.equals(warehouseId)) { Integer totalCount = waybillEntity.getTotalCount(); Integer stockCount = waybillEntity.getStockCount(); - openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "20", "已入库", "运单入库:"+stockCount+"/"+totalCount+",入库类型:【"+IncomingTypeEnum.getValue(incomingType)+"】,入库时间:"+ CommonUtil.dateToStringGeneral(new Date()), AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, finalWarehouseName); + openOrderAsyncService.saveLog(waybillEntity.getId(), waybillEntity.getWaybillNo(), "20", "已入库", "运单入库:" + stockCount + "/" + totalCount + ",入库类型:【" + IncomingTypeEnum.getValue(incomingType) + "】,入库时间:" + CommonUtil.dateToStringGeneral(new Date()), AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, finalWarehouseName); } } } @@ -657,11 +652,11 @@ public class InComingServiceImpl implements IInComingService { map.put("orderPackageCode", packageCode); R r = warehouseTrayTypeClient.orderScanOrderPackageCodeReturnR(map); int code = r.getCode(); - if(code != 200){ + if (code != 200) { audio.set(r.getMsg()); - }else{ + } else { String data = (String) r.getData(); - if(StringUtil.isNotBlank(data)){ + if (StringUtil.isNotBlank(data)) { JSONObject parseObj = JSONUtil.parseObj(data); String audio1 = parseObj.getStr("audio"); audio.set(audio1); @@ -672,7 +667,6 @@ public class InComingServiceImpl implements IInComingService { } - } else if ("1".equals(packageStatus)) { //已入库包件 if (incomingType != 1) { @@ -690,11 +684,11 @@ public class InComingServiceImpl implements IInComingService { map.put("orderPackageCode", packageCode); R r = warehouseTrayTypeClient.orderScanOrderPackageCodeReturnR(map); int code = r.getCode(); - if(code != 200){ + if (code != 200) { audio.set(r.getMsg()); - }else{ + } else { String data = (String) r.getData(); - if(StringUtil.isNotBlank(data)){ + if (StringUtil.isNotBlank(data)) { JSONObject parseObj = JSONUtil.parseObj(data); String audio1 = parseObj.getStr("audio"); audio.set(audio1); @@ -707,12 +701,12 @@ public class InComingServiceImpl implements IInComingService { } }); String a = audio.get(); - if(StringUtil.isNotBlank(a)){ - return Resp.scanFail(200,a,a); + if (StringUtil.isNotBlank(a)) { + return Resp.scanFail(200, a, a); } - }catch (Exception e){ - log.error("入库异常",e); + } catch (Exception e) { + log.error("入库异常", e); throw new CustomerException("系统异常,请联系管理员"); } @@ -783,13 +777,12 @@ public class InComingServiceImpl implements IInComingService { Set waybillIdSet = map.keySet(); - - if(CollUtil.isNotEmpty(waybillIdSet)){ + if (CollUtil.isNotEmpty(waybillIdSet)) { List waybillEntityList = warehouseWaybillClient.findListByWaybillIds(new ArrayList<>(waybillIdSet)); waybillEntityList.forEach(wb -> { Integer totalCount = wb.getTotalCount(); Integer stockCount = wb.getStockCount(); - openOrderAsyncService.saveLog(wb.getId(), wb.getWaybillNo(), "20", "已入库", "运单入库:"+stockCount+"/"+totalCount+",入库类型:【"+IncomingTypeEnum.getValue(incomingType)+"】,入库时间:"+ CommonUtil.dateToStringGeneral(new Date()), AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, warehouseName); + openOrderAsyncService.saveLog(wb.getId(), wb.getWaybillNo(), "20", "已入库", "运单入库:" + stockCount + "/" + totalCount + ",入库类型:【" + IncomingTypeEnum.getValue(incomingType) + "】,入库时间:" + CommonUtil.dateToStringGeneral(new Date()), AuthUtil.getNickName(), AuthUtil.getUserId(), warehouseId, warehouseName); }); } @@ -809,10 +802,10 @@ public class InComingServiceImpl implements IInComingService { .brand(BrandEnums.getByValue(advanceDetailEntity.getBrand())) .node(WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY) .content(Collections.singletonList(PushData.builder() - .packageCode(advanceDetailEntity.getOrderPackageCode()) - .orderCode(advanceDetailEntity.getOrderCode()) - .warehouseName(warehouseName) - .build())) + .packageCode(advanceDetailEntity.getOrderPackageCode()) + .orderCode(advanceDetailEntity.getOrderCode()) + .warehouseName(warehouseName) + .build())) .build(); factoryDataMessageSender.sendNodeDataByBrand(nodePushMsg); } 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 b13d74911..ad5a9f09b 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 @@ -113,6 +113,20 @@ public class OpenOrderServiceImpl implements IOpenOrderService { return advanceService.advancePageList(page, advanceDTO); } + /** + * 商家端暂存单列表 + * @param advanceDTO + * @return + */ + @Override + public IPage advancePageListByBussiness(AdvanceDTO advanceDTO) { + IPage page = new Page<>(); + page.setCurrent(advanceDTO.getPageNum()); + page.setSize(advanceDTO.getPageSize()); + + return advanceService.advancePageListByBussiness(page, advanceDTO); + } + @Override public List findAdvanceDetailList(Long advanceId) { return advanceDetailService.findList(advanceId); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java index 6e1ef8204..016668e52 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceServiceImpl.java @@ -363,6 +363,15 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl advancePageListByBussiness(IPage page, AdvanceDTO advanceDTO) { + advanceDTO.setStartCreateTime(CommonUtil.getStartByDateStr(advanceDTO.getStartCreateTimeStr())); + advanceDTO.setEndCreateTime(CommonUtil.getEndByDateStr(advanceDTO.getEndCreateTimeStr())); + IPage trunklineAdvanceVOIPage = baseMapper.advancePageListByBussiness(page, advanceDTO); + + return trunklineAdvanceVOIPage; + } + @Override public List findListByIds(List advanceIds) { return baseMapper.findListByIds(advanceIds); @@ -1297,6 +1306,594 @@ public class TrunklineAdvanceServiceImpl extends BaseServiceImpl advanceDetailEntities, Long warehouseId) { + BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if(Objects.isNull(warehouseEntity)){ + log.warn("############saveOrderAndPackages: 仓库信息不存在warehouseId={}",warehouseId); + throw new CustomerException(405,"仓库信息不存在"); + } + + TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailEntities.get(0); + String tenantId = advanceDetailEntity.getTenantId(); + Long userId = AuthUtil.getUserId(); + Long deptId = Func.firstLong(AuthUtil.getDeptId()); + if(Objects.isNull(userId)){ + userId = advanceDetailEntity.getCreateUser(); + } + if(Objects.isNull(deptId)){ + userId = advanceDetailEntity.getCreateDept(); + } + + //把advanceDetailEntities所有元素的orderCode作为key分组 + Map> orderCodeMap = advanceDetailEntities.stream().collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getOrderCode)); + Set orderCodeSet = orderCodeMap.keySet(); + + //把advanceDetailEntities中所有元素的waybillId提取到一个Set中 + Set waybillIdSet = advanceDetailEntities.stream().map(TrunklineAdvanceDetailEntity::getWaybillId).collect(Collectors.toSet()); + Map waybillEntityMap = new HashMap<>(); + if(!waybillIdSet.isEmpty()){ + List waybillEntityList = warehouseWaybillClient.findListByWaybillIds(new ArrayList<>(waybillIdSet)); + //把waybillEntityList转化成以id为key的Map + waybillEntityMap = waybillEntityList.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, Function.identity())); + } + + + //提取出advanceDetailEntities所有元素的advanceId存入Set + Set advanceIdSet = advanceDetailEntities.stream().map(TrunklineAdvanceDetailEntity::getAdvanceId).collect(Collectors.toSet()); + List advanceEntityList = findListByIds(new ArrayList<>(advanceIdSet)); + + Map advanceEntityMap = new HashMap<>(); + if(!advanceEntityList.isEmpty()){ + advanceEntityMap = advanceEntityList.stream().collect(Collectors.toMap(TrunklineAdvanceEntity::getOrderCode, Function.identity())); + } + + + FindParamterDTO findParamterDTO = new FindParamterDTO(); + findParamterDTO.setOrderCodeSet(orderCodeSet); + findParamterDTO.setWarehouseId(warehouseId); + List stockArticleEntities = stockArticleClient.findListByOrderCodesAndWarehouseId(findParamterDTO); + Map stockArticleMap = new HashMap<>(); + if(!stockArticleEntities.isEmpty()){ + stockArticleMap = stockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); + } + + FindParamterDTO findParamterD = new FindParamterDTO(); + findParamterD.setOrderCodeSet(orderCodeSet); + findParamterD.setWarehouseId(warehouseId); + List parcelListEntities = parcelListClient.findListByOrderCodesAndWarehouseId(findParamterD); + Map parcelListMap = new HashMap<>(); + if(!parcelListEntities.isEmpty()){ + parcelListMap = parcelListEntities.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, Function.identity())); + } + + Set hasOrderPackageCodes = parcelListMap.keySet(); + + Map finalStockArticleMap = stockArticleMap; + Map finalAdvanceEntityMap = advanceEntityMap; + Long finalUserId = userId; + Date date = new Date(); + + List addStockArticleEntities = new ArrayList<>(); + List updateStockArticleEntities = new ArrayList<>(); + + Map finalWaybillEntityMap = waybillEntityMap; + orderCodeSet.forEach(orderCode -> { + int total = baseMapper.getAllTotalNum(orderCode); + + DistributionStockArticleEntity stockArticleEntity = finalStockArticleMap.get(orderCode); + if(Objects.isNull(stockArticleEntity)){ + TrunklineAdvanceEntity advanceEntity = finalAdvanceEntityMap.get(orderCode); + if(!Objects.isNull(advanceEntity)){ + String waybillNo = advanceEntity.getWaybillNo(); + + stockArticleEntity = new DistributionStockArticleEntity(); + stockArticleEntity.setTenantId(tenantId); + stockArticleEntity.setCreateUser(finalUserId); + stockArticleEntity.setUpdateUser(finalUserId); + stockArticleEntity.setCreateDept(deptId); + stockArticleEntity.setOrderCode(orderCode); + stockArticleEntity.setServiceNumber(advanceEntity.getServiceNum()); + stockArticleEntity.setWaybillNumber(waybillNo); + stockArticleEntity.setTotalNumber(total); + stockArticleEntity.setHandQuantity(0); +// stockArticleEntity.setTenantId(TenantNum.HUITONGCODE);// 对应租户ID + stockArticleEntity.setWarehouse(warehouseEntity.getName()); + stockArticleEntity.setWarehouseId(warehouseId); + stockArticleEntity.setBrand(advanceEntity.getBrand()); + stockArticleEntity.setDescriptionGoods(advanceEntity.getPackName()); + stockArticleEntity.setWarehouseEntryTime(date); + stockArticleEntity.setGenre(1); + + String dealerName = advanceEntity.getDealerName();//暂存单经销商名称 + stockArticleEntity.setDealerCode(advanceEntity.getDealerCode()); + stockArticleEntity.setDealerName(advanceEntity.getDealerName()); + + stockArticleEntity.setTypeService("1");//默认商配 + + if(!StringUtil.isBlank(waybillNo)){ + WarehouseWaybillEntity waybillEntity = finalWaybillEntityMap.get(waybillNo); + if(!Objects.isNull(waybillEntity)){ + Long consigneeId = waybillEntity.getConsigneeId(); + String consigneeName1= waybillEntity.getConsignee(); + + BasicdataClientEntity clientEntity = basicdataClientClient.findByName(consigneeName1); + if(!Objects.isNull(clientEntity)){ + stockArticleEntity.setMallId(clientEntity.getId()); + stockArticleEntity.setMallName(clientEntity.getClientName()); + stockArticleEntity.setMallCode(clientEntity.getClientCode()); + } + String consignee = waybillEntity.getConsignee(); + String consigneeName = waybillEntity.getConsigneeName(); + String consigneeMobile = waybillEntity.getConsigneeMobile(); + String consigneeAddress = waybillEntity.getConsigneeAddress(); + stockArticleEntity.setConsigneeUnit(consignee); + stockArticleEntity.setConsigneePerson(consigneeName); + stockArticleEntity.setConsigneeMobile(consigneeMobile); + stockArticleEntity.setConsigneeAddress(consigneeAddress); + + BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(clientEntity.getId(), 3); + if(!Objects.isNull(basicdataStoreBusinessEntity)){ + stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); + } + } + }else{ + Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand()); + BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId); + if(!Objects.isNull(basicdataClientEntity)){ + String clientType = basicdataClientEntity.getClientType(); + if("5".equals(clientType)){ + stockArticleEntity.setStoreId(basicdataClientEntity.getId()); + stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode()); + stockArticleEntity.setStoreName(basicdataClientEntity.getClientName()); + //查询门店的父级商场 + Long pid = basicdataClientEntity.getPid(); + BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid); + if(!Objects.isNull(pidEntity)){ + String pidEntityClientType = pidEntity.getClientType(); + if("2".equals(pidEntityClientType)){ + //商城 + stockArticleEntity.setMallId(pidEntity.getId()); + stockArticleEntity.setMallName(pidEntity.getClientName()); + stockArticleEntity.setMallCode(pidEntity.getClientCode()); + + BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3); + if(!Objects.isNull(basicdataStoreBusinessEntity)){ + stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); + } + } + } + }else if("2".equals(clientType)){ + //商城 + stockArticleEntity.setMallId(basicdataClientEntity.getId()); + stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); + stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); + + BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3); + if(!Objects.isNull(basicdataStoreBusinessEntity)){ + stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); + } + } + } + } + stockArticleEntity.setCustomerName(advanceEntity.getCustomerName()); + stockArticleEntity.setCustomerTelephone(advanceEntity.getCustomerPhone()); + stockArticleEntity.setCustomerAddress(advanceEntity.getCustomerAddress()); + stockArticleEntity.setStockupStatus("10"); + stockArticleEntity.setReservationStatus("10"); + stockArticleEntity.setOrderStatus("0"); + stockArticleEntity.setGroundingStatus("10"); + stockArticleEntity.setOrderReceiveStatus("10"); + stockArticleEntity.setFreezeStatus("10"); + stockArticleEntity.setNotification(2); + stockArticleEntity.setIsHaveData(2); + stockArticleEntity.setTrainNumber(advanceEntity.getTrainNumber()); + stockArticleEntity.setSortingQuantity(0); + stockArticleEntity.setDeliveryQuantity(0); + stockArticleEntity.setTransferQuantity(0); + stockArticleEntity.setSigninQuantity(0); + addStockArticleEntities.add(stockArticleEntity); + } + }else{ + stockArticleEntity.setTotalNumber(total); + updateStockArticleEntities.add(stockArticleEntity); + } + }); + stockArticleClient.updateByBatchId(updateStockArticleEntities); + + List returnStockArticleEntities = stockArticleClient.addReturnList(addStockArticleEntities); + returnStockArticleEntities.addAll(updateStockArticleEntities); + + Map saMap = returnStockArticleEntities.stream().collect(Collectors.toMap(DistributionStockArticleEntity::getOrderCode, Function.identity())); + + List parcelListEntityList = new ArrayList<>(); + orderCodeMap.keySet().forEach(orderCode->{ + DistributionStockArticleEntity stockArticleEntity = saMap.get(orderCode); + if(!Objects.isNull(stockArticleEntity)){ + Long orderId = stockArticleEntity.getId(); + List adList = orderCodeMap.get(orderCode); + adList.forEach(ad->{ + String orderPackageCode = ad.getOrderPackageCode(); + if(!hasOrderPackageCodes.contains(orderPackageCode)){ + String trainNumber = ad.getTrainNumber(); + DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); + parcelList.setCreateUser(finalUserId); + parcelList.setUpdateUser(finalUserId); + parcelList.setCreateDept(deptId); + parcelList.setTenantId(tenantId); + parcelList.setWarehouse(warehouseEntity.getName()); + parcelList.setWarehouseId(warehouseId); + parcelList.setIsTransfer(0); +// String waybillNo = ad.getWaybillNo(); +// if(StringUtil.isNotBlank(waybillNo)){ +// WarehouseWaybillEntity waybillEntity = finalWaybillEntityMap.get(waybillNo); +// if(!Objects.isNull(waybillEntity)){ +// parcelList.setWaybillId(waybillEntity.getId()); +// parcelList.setWaybillNumber(waybillEntity.getWaybillNo()); +// parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId()); +// parcelList.setSendWarehouseName(waybillEntity.getDepartureWarehouseName()); +// Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); +// parcelList.setAcceptWarehouseId(destinationWarehouseId); +// parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName()); +// if(warehouseId.equals(destinationWarehouseId)){ +// parcelList.setIsTransfer(0); +// } +// +// } +// } + parcelList.setConditions(1); + parcelList.setOrderPackageCode(orderPackageCode); + parcelList.setFirsts(advanceDetailEntity.getFirstPackName()); + parcelList.setSecond(advanceDetailEntity.getSecondPackName()); + parcelList.setThirdProduct(advanceDetailEntity.getThirdPackName()); + parcelList.setQuantity(1); + parcelList.setStockArticleId(orderId); + parcelList.setOrderCode(orderCode); + parcelList.setServiceNumber(advanceDetailEntity.getServiceNum()); + parcelList.setTrainNumber(trainNumber); + parcelList.setAdvanceId(ad.getAdvanceId()); + + Long materialId = advanceDetailEntity.getMaterialId(); + String materialCode = advanceDetailEntity.getMaterialCode(); + String materialName = advanceDetailEntity.getMaterialName(); + if(Objects.isNull(materialId)){ + if(StringUtil.isNotBlank(materialCode)&& StringUtil.isNotBlank(materialName)){ + BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode,materialName); + if(!Objects.isNull(materialEntity)){ + parcelList.setMaterialId(materialEntity.getId()); + parcelList.setMaterialName(materialEntity.getName()); + parcelList.setMaterialCode(materialEntity.getProductCode()); + parcelList.setMaterialUnit(materialEntity.getSpecification()); + } + } + + }else{ + BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId); + if(!Objects.isNull(materialOwnId)){ + parcelList.setMaterialId(materialOwnId.getId()); + parcelList.setMaterialName(materialOwnId.getName()); + parcelList.setMaterialCode(materialOwnId.getProductCode()); + parcelList.setMaterialUnit(materialOwnId.getSpecification()); + } + + } + parcelList.setBrandName(advanceDetailEntity.getBrand()); + parcelList.setOrderPackageStatus("20"); + parcelList.setOrderPackageFreezeStatus("10"); + parcelList.setOrderPackageGroundingStatus("10"); + parcelList.setOrderPackageStockupStatus("10"); + parcelList.setOrderPackageReservationStatus("10"); + parcelList.setOrderPackageLoadingStatus("10"); + parcelList.setWarehouseEntryTimeEnd(date); + parcelList.setDealerCode(stockArticleEntity.getDealerCode()); + parcelList.setDealerName(stockArticleEntity.getDealerName()); + parcelListEntityList.add(parcelList); + } + }); + } + }); + + parcelListClient.addBatch(parcelListEntityList); + + //把parcelListEntityList中所有元素以waubillId分组 + Map> parcelListEntityMap = parcelListEntityList.stream().filter(pl->!Objects.isNull(pl.getWaybillNumber())).collect(Collectors.groupingBy(DistributionParcelListEntity::getWaybillNumber)); + + List updateWaybillList = new ArrayList<>(); + parcelListEntityMap.keySet().forEach(waybillNo->{ + WarehouseWaybillEntity updateWaybill = new WarehouseWaybillEntity(); + WarehouseWaybillEntity waybillEntity = finalWaybillEntityMap.get(waybillNo); + + if(!Objects.isNull(waybillEntity)){ + List pl = parcelListEntityMap.get(waybillNo); + Integer size = 0; + if(!pl.isEmpty()){ + size = pl.size(); + } + updateWaybill.setId(waybillEntity.getId()); + updateWaybill.setStockCount(waybillEntity.getStockCount() + size); +// updateWaybill.setBillladingNum(waybillEntity.getBillladingNum() + size); + updateWaybillList.add(updateWaybill); + } + }); + + if(!updateWaybillList.isEmpty()){ + warehouseWaybillClient.updateList(updateWaybillList); + } + + orderCodeSet.forEach(orderCode->{ + stockArticleClient.updateOrderInfo(orderCode,warehouseId); + }); + + +// String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); +// String orderCode = advanceDetailEntity.getOrderCode(); +// Long advanceId = advanceDetailEntity.getAdvanceId(); +// String tenantId = advanceDetailEntity.getTenantId(); +// log.info("############saveOrderAndPackage: 保存订单和包件信息 orderPackageCode={}",orderPackageCode); +// +// BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); +// if(Objects.isNull(warehouseEntity)){ +// log.warn("############saveOrderAndPackage: 仓库信息不存在warehouseId={}",warehouseId); +// throw new CustomerException(405,"仓库信息不存在"); +// } +// +// //1.判断包件是否已经存在 +// DistributionParcelListEntity parcelListEntity = parcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); +// if(!Objects.isNull(parcelListEntity)){ +// log.warn("############saveOrderAndPackage: 包件信息已存在 orderPackageCode={} warehouseId={}",orderPackageCode,warehouseId); +// return true; +// } +// +// TrunklineAdvanceEntity advanceEntity = getById(advanceId); +// if(Objects.isNull(advanceEntity)){ +// log.warn("############saveOrderAndPackage: 暂存单信息不存在 advanceId={} warehouseId={}",advanceId,warehouseId); +// throw new CustomerException(405,"暂存单信息不存在"); +// } +// +// Long userId = AuthUtil.getUserId(); +// Long deptId = null; +// String deptIds = AuthUtil.getDeptId(); +// String[] split = deptIds.split(","); +// if(Objects.isNull(userId)){ +// userId = advanceDetailEntity.getCreateUser(); +// } +// if(CollUtil.isEmpty(Arrays.asList(split))){ +// deptId = Long.parseLong(split[0]); +// } +// if(Objects.isNull(deptId)){ +// userId = advanceDetailEntity.getCreateDept(); +// } +// +// //2.查询订单信息 +// int total = baseMapper.getAllTotalNum(orderCode); +// +// Date date = new Date(); +// Long orderId = null; +// DistributionStockArticleEntity stockArticleEntity = stockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); +// if(Objects.isNull(stockArticleEntity)){ +// log.info("#############saveOrderAndPackage: 订单信息为空,同步订单信息"); +// //订单信息为空 +// String waybillNo = advanceEntity.getWaybillNo(); +// +// stockArticleEntity = new DistributionStockArticleEntity(); +// stockArticleEntity.setTenantId(tenantId); +// stockArticleEntity.setCreateUser(userId); +// stockArticleEntity.setUpdateUser(userId); +// stockArticleEntity.setCreateDept(deptId); +// stockArticleEntity.setOrderCode(orderCode); +// stockArticleEntity.setServiceNumber(advanceEntity.getServiceNum()); +// stockArticleEntity.setWaybillNumber(waybillNo); +// stockArticleEntity.setTotalNumber(total); +// stockArticleEntity.setHandQuantity(0); +//// stockArticleEntity.setTenantId(TenantNum.HUITONGCODE);// 对应租户ID +// stockArticleEntity.setWarehouse(warehouseEntity.getName()); +// stockArticleEntity.setWarehouseId(warehouseId); +// stockArticleEntity.setBrand(advanceEntity.getBrand()); +// stockArticleEntity.setDescriptionGoods(advanceEntity.getPackName()); +// stockArticleEntity.setWarehouseEntryTime(date); +// stockArticleEntity.setGenre(1); +// +// String dealerName = advanceEntity.getDealerName();//暂存单经销商名称 +// stockArticleEntity.setDealerCode(advanceEntity.getDealerCode()); +// stockArticleEntity.setDealerName(advanceEntity.getDealerName()); +// +// stockArticleEntity.setTypeService("1");//默认商配 +// +// if(!StringUtil.isBlank(waybillNo)){ +// WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); +// if(!Objects.isNull(waybillEntity)){ +// Long consigneeId = waybillEntity.getConsigneeId(); +// +// BasicdataClientEntity clientEntity = basicdataClientClient.findEntityById(consigneeId); +// if(!Objects.isNull(clientEntity)){ +// stockArticleEntity.setMallId(clientEntity.getId()); +// stockArticleEntity.setMallName(clientEntity.getClientName()); +// stockArticleEntity.setMallCode(clientEntity.getClientCode()); +// } +// String consignee = waybillEntity.getConsignee(); +// String consigneeName = waybillEntity.getConsigneeName(); +// String consigneeMobile = waybillEntity.getConsigneeMobile(); +// String consigneeAddress = waybillEntity.getConsigneeAddress(); +// stockArticleEntity.setConsigneeUnit(consignee); +// stockArticleEntity.setConsigneePerson(consigneeName); +// stockArticleEntity.setConsigneeMobile(consigneeMobile); +// stockArticleEntity.setConsigneeAddress(consigneeAddress); +// +// BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3); +// if(!Objects.isNull(basicdataStoreBusinessEntity)){ +// stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); +// } +// } +// }else{ +// Long clientId = basicdataTripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand()); +// BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(clientId); +// if(!Objects.isNull(basicdataClientEntity)){ +// String clientType = basicdataClientEntity.getClientType(); +// if("5".equals(clientType)){ +// stockArticleEntity.setStoreId(basicdataClientEntity.getId()); +// stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode()); +// stockArticleEntity.setStoreName(basicdataClientEntity.getClientName()); +// //查询门店的父级商场 +// Long pid = basicdataClientEntity.getPid(); +// BasicdataClientEntity pidEntity = basicdataClientClient.findEntityById(pid); +// if(!Objects.isNull(pidEntity)){ +// String pidEntityClientType = pidEntity.getClientType(); +// if("2".equals(pidEntityClientType)){ +// //商城 +// stockArticleEntity.setMallId(pidEntity.getId()); +// stockArticleEntity.setMallName(pidEntity.getClientName()); +// stockArticleEntity.setMallCode(pidEntity.getClientCode()); +// +// BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(pidEntity.getId(), 3); +// if(!Objects.isNull(basicdataStoreBusinessEntity)){ +// stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); +// } +// } +// } +// }else if("2".equals(clientType)){ +// //商城 +// stockArticleEntity.setMallId(basicdataClientEntity.getId()); +// stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); +// stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); +// +// BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(basicdataClientEntity.getId(), 3); +// if(!Objects.isNull(basicdataStoreBusinessEntity)){ +// stockArticleEntity.setTypeService(basicdataStoreBusinessEntity.getMold()); +// } +// } +// } +// } +// +// stockArticleEntity.setCustomerName(advanceEntity.getCustomerName()); +// stockArticleEntity.setCustomerTelephone(advanceEntity.getCustomerPhone()); +// stockArticleEntity.setCustomerAddress(advanceEntity.getCustomerAddress()); +// stockArticleEntity.setStockupStatus("10"); +// stockArticleEntity.setReservationStatus("10"); +// stockArticleEntity.setOrderStatus("0"); +// stockArticleEntity.setGroundingStatus("10"); +// stockArticleEntity.setOrderReceiveStatus("10"); +// stockArticleEntity.setFreezeStatus("10"); +// stockArticleEntity.setNotification(2); +// stockArticleEntity.setIsHaveData(2); +// stockArticleEntity.setTrainNumber(advanceEntity.getTrainNumber()); +// stockArticleEntity.setSortingQuantity(0); +// stockArticleEntity.setDeliveryQuantity(0); +// stockArticleEntity.setTransferQuantity(0); +// stockArticleEntity.setSigninQuantity(0); +// orderId = stockArticleClient.addData(stockArticleEntity); +// }else{ +// +// stockArticleEntity.setTotalNumber(total); +// stockArticleClient.saveOrUpdate(stockArticleEntity); +// orderId = stockArticleEntity.getId(); +// } +// if(Objects.isNull(orderId)){ +// log.warn("##############saveOrderAndPackage: 订单信息有误 orderId={}",orderId); +// throw new CustomerException(405,"订单信息有误"); +// } +// log.info("#############saveOrderAndPackage: 订单信息保存成功 orderId={}",orderId); +// +// //保存包件信息 +// DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); +// parcelList.setCreateUser(userId); +// parcelList.setUpdateUser(userId); +// parcelList.setCreateDept(deptId); +// parcelList.setTenantId(tenantId); +// parcelList.setWarehouse(warehouseEntity.getName()); +// parcelList.setWarehouseId(warehouseId); +// parcelList.setIsTransfer(1); +// String waybillNo = advanceEntity.getWaybillNo(); +// if(StringUtil.isNotBlank(waybillNo)){ +// WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); +// if(!Objects.isNull(waybillEntity)){ +// parcelList.setWaybillId(waybillEntity.getId()); +// parcelList.setWaybillNumber(waybillEntity.getWaybillNo()); +// parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId()); +// parcelList.setSendWarehouseName(waybillEntity.getDepartureWarehouseName()); +// Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); +// parcelList.setAcceptWarehouseId(destinationWarehouseId); +// parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName()); +// if(warehouseId.equals(destinationWarehouseId)){ +// parcelList.setIsTransfer(0); +// } +// } +// } +// parcelList.setConditions(1); +// parcelList.setOrderPackageCode(advanceDetailEntity.getOrderPackageCode()); +// parcelList.setFirsts(advanceDetailEntity.getFirstPackName()); +// parcelList.setSecond(advanceDetailEntity.getSecondPackName()); +// parcelList.setThirdProduct(advanceDetailEntity.getThirdPackName()); +// parcelList.setQuantity(1); +// parcelList.setStockArticleId(orderId); +// parcelList.setOrderCode(orderCode); +// parcelList.setServiceNumber(advanceDetailEntity.getServiceNum()); +// parcelList.setTrainNumber(advanceEntity.getTrainNumber()); +// parcelList.setAdvanceId(advanceId); +// +// Long materialId = advanceDetailEntity.getMaterialId(); +// String materialCode = advanceDetailEntity.getMaterialCode(); +// String materialName = advanceDetailEntity.getMaterialName(); +// if(Objects.isNull(materialId)){ +// BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode,materialName); +// if(!Objects.isNull(materialEntity)){ +// parcelList.setMaterialId(materialEntity.getId()); +// parcelList.setMaterialName(materialEntity.getName()); +// parcelList.setMaterialCode(materialEntity.getProductCode()); +// parcelList.setMaterialUnit(materialEntity.getSpecification()); +// } +// }else{ +// BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId); +// if(!Objects.isNull(materialOwnId)){ +// parcelList.setMaterialId(materialOwnId.getId()); +// parcelList.setMaterialName(materialOwnId.getName()); +// parcelList.setMaterialCode(materialOwnId.getProductCode()); +// parcelList.setMaterialUnit(materialOwnId.getSpecification()); +// } +// +// } +// parcelList.setBrandName(advanceDetailEntity.getBrand()); +// parcelList.setOrderPackageStatus("20"); +// parcelList.setOrderPackageFreezeStatus("10"); +// parcelList.setOrderPackageGroundingStatus("10"); +// parcelList.setOrderPackageStockupStatus("10"); +// parcelList.setOrderPackageReservationStatus("10"); +// parcelList.setOrderPackageLoadingStatus("10"); +// parcelList.setWarehouseEntryTimeEnd(date); +// parcelList.setDealerCode(stockArticleEntity.getDealerCode()); +// parcelList.setDealerName(stockArticleEntity.getDealerName()); +// Long orderPackageId = parcelListClient.addReturnId(parcelList); +// if(!Objects.isNull(orderPackageId)){ +// log.info("################saveOrderAndPackage: 包件信息保存成功 OrderPackageCode={}",advanceDetailEntity.getOrderPackageCode()); +// //1.修改订单在库件数和最后入库时间和入库状态 +// +//// List parcelListEntityList = parcelListClient.findEntityListByOrderCode(orderCode, warehouseId); +//// int size = parcelListEntityList.size(); +//// Integer totalNumber = stockArticleEntity.getTotalNumber();//总件数 +//// Integer handQuantity = stockArticleEntity.getHandQuantity();//在库件数 +//// Integer incomingNum = stockArticleEntity.getIncomingNum();//入库件数 +//// +//// if(size == 1){ +//// stockArticleEntity.setWarehouseEntryTime(date); +//// stockArticleEntity.setWarehouseEntryTimeEnd(new Date()); +//// stockArticleEntity.setHandQuantity(handQuantity+1); +//// stockArticleEntity.setIncomingNum(incomingNum+1); +//// }else{ +//// stockArticleEntity.setWarehouseEntryTimeEnd(new Date()); +//// stockArticleEntity.setHandQuantity(handQuantity+1); +//// stockArticleEntity.setIncomingNum(incomingNum+1); +//// } +//// +//// if(incomingNum+1 < totalNumber){ +//// stockArticleEntity.setOrderStatus("10"); +//// }else{ +//// stockArticleEntity.setOrderStatus("20"); +//// } +//// stockArticleClient.saveOrUpdate(stockArticleEntity); +// } +// log.info("#############saveOrderAndPackage: 订单包件信息保存完成 OrderPackageCode={}",advanceDetailEntity.getOrderPackageCode()); + return true; + } + @Override @Transactional(rollbackFor = Exception.class) public Boolean cancelOrder(String orderCode) { diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/OrderInfoApi.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/OrderInfoApi.java new file mode 100644 index 000000000..709b017df --- /dev/null +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/OrderInfoApi.java @@ -0,0 +1,52 @@ +package com.logpm.warehouse.api; + +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.distribution.feign.IDistributionParcelListClient; +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * @description: 该类用于包件信息查询 + * @author pref + * @date 2021/12/30 16:06 + */ +@Log4j2 +@RestController +@AllArgsConstructor +@RequestMapping("/api/orderInfo") +@Api(value = "订单信息查询", tags = "订单信息查询") +public class OrderInfoApi { + + private final IDistributionParcelListClient distributionParcelListClient; + + private final IBasicdataWarehouseClient basicdataWarehouseClient; + /** + * 通过包条码查询订单信息 构建PDA的二维码 + * @param orderPackageCode + * @return + */ + @RequestMapping(value = "/orderPackageCode/{orderPackageCode}",method = RequestMethod.GET) + public R findOrderInfoByOrderPackageCode(@PathVariable String orderPackageCode) { + + // 获取当前登陆人的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = basicdataWarehouseClient.getMyCurrentWarehouse(); + if (Func.isEmpty(myCurrentWarehouse)){ + log.error("未授权仓库"); + return R.fail(403,"未授权仓库!!!"); + } + Map orderInfoByOrderPackageCode = distributionParcelListClient.findOrderInfoByOrderPackageCode(orderPackageCode, myCurrentWarehouse.getId()); + + return R.data(orderInfoByOrderPackageCode); + } + +}