From ee87b10493ba8e9ebd6a667b828ff94aad4cd738 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Mon, 25 Nov 2024 18:58:21 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BFbug=E4=BF=AE=E5=A4=8D=202.?= =?UTF-8?q?=E9=85=8D=E8=BD=BD=E6=B8=85=E5=8D=95=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/ITrunklineCarsLoadClient.java | 3 + .../trunkline/vo/CarsLoadOrderInfoVO.java | 2 + .../logpm/trunkline/vo/LoadingListMainVO.java | 3 + .../logpm/trunkline/vo/OrderGoodsInfoVO.java | 16 + .../jobhandle/SyncOrderInfoToPlatform.java | 25 + .../controller/CarsLoadController.java | 10 + .../feign/TrunklineCarsLoadClient.java | 5 + .../mapper/TrunklineCarsLoadMapper.xml | 1 + .../mapper/TrunklineCarsLoadScanMapper.xml | 4 +- .../mapper/TrunklineCarsOrderMapper.java | 2 + .../mapper/TrunklineCarsOrderMapper.xml | 51 ++ .../mapper/TrunklineWaybillPacakgeMapper.xml | 66 ++ .../mapper/TrunklineWaybillPackageMapper.java | 6 + .../service/ITrunklineCarsLoadService.java | 3 + .../service/ITrunklineCarsOrderService.java | 2 + .../ITrunklineWaybillPackageService.java | 4 + .../impl/TrunklineCarsLoadServiceImpl.java | 729 ++++++++++++++---- .../TrunklineCarsOrderEntityServiceImpl.java | 6 +- .../TrunklineWaybillPackageServiceImpl.java | 14 +- 19 files changed, 807 insertions(+), 145 deletions(-) create mode 100644 blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/OrderGoodsInfoVO.java diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineCarsLoadClient.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineCarsLoadClient.java index b068d75c2..0221da4a1 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineCarsLoadClient.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/feign/ITrunklineCarsLoadClient.java @@ -21,4 +21,7 @@ public interface ITrunklineCarsLoadClient { @GetMapping(API_PREFIX+"/updateCardLoadNum") void updateCardLoadNum(@RequestParam Long loadId); + + @GetMapping(API_PREFIX+"/saveCostShareRecord") + void saveCostShareRecord(@RequestParam Long loadId); } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadOrderInfoVO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadOrderInfoVO.java index b8b4a37f9..d1e2a6edf 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadOrderInfoVO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadOrderInfoVO.java @@ -10,6 +10,8 @@ public class CarsLoadOrderInfoVO implements Serializable { private String orderCode; private String waybillNo; + private String originOrderGoodsName; + private String originOrderGoodsNum; private Integer orderNum = 0; private Integer planNum = 0; private Integer loadingNum = 0; diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/LoadingListMainVO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/LoadingListMainVO.java index e4045b220..1f2adddf7 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/LoadingListMainVO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/LoadingListMainVO.java @@ -23,7 +23,10 @@ public class LoadingListMainVO implements Serializable { private String consigneeMobile; private Integer unloadNum; private Integer planNum; + private Integer loadingNum; + private Integer stockNum; private Integer smallTotal; + private String goodsListStr; private List goodsList = new ArrayList<>(); diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/OrderGoodsInfoVO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/OrderGoodsInfoVO.java new file mode 100644 index 000000000..86eba56e6 --- /dev/null +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/OrderGoodsInfoVO.java @@ -0,0 +1,16 @@ +package com.logpm.trunkline.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class OrderGoodsInfoVO implements Serializable { + + private String waybillNo; + private String orderCode; + + private String originOrderGoodsName; + private String originOrderGoodsNum; + +} 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 aa4867601..7a919f2b8 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 @@ -1296,6 +1296,31 @@ public class SyncOrderInfoToPlatform { } + @XxlJob("saveCostShareRecord") + public ReturnT saveCostShareRecord(String param) { + log.info("############saveCostShareRecord: 保存成本分摊数据 开始"); + + List ls = warehouseMappingDataService.findAllDealWithWaybillNo(); + + ls.forEach(json -> { + Integer id = json.getInt("id"); + String carsNo = json.getStr("waybillNo"); + + log.info("###################saveCostShareRecord: 当前处理的车次号为 carsNo={}",carsNo); + + Long loadId = Long.parseLong(carsNo); + + carsLoadClient.saveCostShareRecord(loadId); + + warehouseMappingDataService.updateStatusDealwithWaybillById(id); + }); + + + log.info("############saveCostShareRecord: 保存成本分摊数据 完成"); + + return ReturnT.SUCCESS; + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java index 87642e298..47005a8d4 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java @@ -19,6 +19,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.exception.CustomerException; import org.springblade.core.excel.util.ExcelUtil; +import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.StringUtil; @@ -41,6 +42,7 @@ public class CarsLoadController { private final IBasicdataWarehouseClient warehouseClient; private final ITrunklineCarsLoadService carsLoadService; + private final BladeRedis redis; @ResponseBody @PostMapping("/loadCarsPageList") @@ -2188,7 +2190,13 @@ public class CarsLoadController { String method = "############manualLoading: "; log.info(method + "请求参数{}", loadCarsDTO); Long loadId = loadCarsDTO.getLoadId(); + String key = "manualLoading:loadId:"+loadId; + if(redis.exists(key)){ + log.warn(method+"当前车次还在处理中,请稍后loadId={}",loadId); + return R.fail(405,"当前车次还在处理中,请勿重复操作"); + } + redis.setEx(key,1,60L); try{ //当前登录人选择的仓库 @@ -2210,6 +2218,8 @@ public class CarsLoadController { }catch (Exception e){ log.error(method+"系统异常",e); return R.fail(500,"系统异常"); + }finally { + redis.del(key); } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineCarsLoadClient.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineCarsLoadClient.java index f71a5857d..fcc562be3 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineCarsLoadClient.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklineCarsLoadClient.java @@ -30,4 +30,9 @@ public class TrunklineCarsLoadClient implements ITrunklineCarsLoadClient{ public void updateCardLoadNum(Long loadId) { carsLoadService.updateCardLoadNum(loadId); } + + @Override + public void saveCostShareRecord(Long loadId) { + carsLoadService.saveCostShareRecord(loadId); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml index be8d0a194..4f3510ecf 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml @@ -517,6 +517,7 @@ left join logpm_trunkline_cars_load_scan ltcls on ltcls.load_id = ltcl.id and ltcls.scan_status = '3' where ltcl.is_deleted = 0 and ltcl.load_type = '4' + and ltcl.load_status != '100' and ltcl.start_warehouse_id = #{param.warehouseId} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml index 719f4dff6..8ca11cf0d 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml @@ -484,7 +484,9 @@ lww.consignee_name consigneeName, lww.consignee_mobile consigneeMobile, IFNULL(ltco.plan_num,0) AS planNum, - sum(case when ltcls.scan_status != 1 then ltcls.num else 0 end) unloadNum, + IFNULL(ltco.real_num,0) AS stockNum, + 0 AS loadingNum, + sum(case when ltcls.scan_status != 1 then ltcls.unload_num else 0 end) unloadNum, IFNULL(sum( ltcls.num ),0) AS smallTotal from logpm_trunkline_cars_load_scan ltcls left join logpm_trunkline_cars_order ltco on ltco.order_code = ltcls.order_code and ltco.waybill_no = ltcls.waybill_no and ltco.load_id = ltcls.load_id and ltco.node_id = ltcls.warehouse_id diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java index f1d16af28..76f5eefd9 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java @@ -76,4 +76,6 @@ public interface TrunklineCarsOrderMapper extends BaseMapper findLoadingOrderPlan(@Param("loadId") Long loadId, @Param("warehouseId") Long warehouseId); List findStartNumByOrderCodeAndWarehouseId(@Param("orderCode") String orderCode, @Param("warehouseId") Long warehouseId); + + List findLoadingListByLoadIdAndNodeId(@Param("loadId") Long loadId, @Param("warehouseId") Long warehouseId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml index 1be2684d0..3fde601ca 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml @@ -434,5 +434,56 @@ and ltco.start_num > 0 + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPacakgeMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPacakgeMapper.xml index 196c8fe90..095bd6736 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPacakgeMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPacakgeMapper.xml @@ -18,5 +18,71 @@ and package_status = #{packageStatus} + + + + + + + + + + + + + + + + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPackageMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPackageMapper.java index 940761296..ca3ef9f54 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPackageMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillPackageMapper.java @@ -2,9 +2,13 @@ package com.logpm.trunkline.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.logpm.trunkline.entity.TrunklineWaybillPackageEntity; +import com.logpm.trunkline.vo.OrderGoodsInfoVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; +import java.util.Set; + @Mapper public interface TrunklineWaybillPackageMapper extends BaseMapper { @@ -14,4 +18,6 @@ public interface TrunklineWaybillPackageMapper extends BaseMapper findOrderGoodsInfoList(@Param("allWaybillNoSet") Set allWaybillNoSet); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java index f3d80ccf3..b5d92667f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java @@ -282,4 +282,7 @@ public interface ITrunklineCarsLoadService extends BaseService loadScanIds, Long warehouseId, String warehouseName); + + void saveCostShareRecord(Long loadId); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java index b954059d0..599977917 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java @@ -73,4 +73,6 @@ public interface ITrunklineCarsOrderService extends BaseService findLoadingOrderPlan(Long loadId, Long warehouseId); List findStartNumByOrderCodeAndWarehouseId(String orderCode, Long warehouseId); + + List findLoadingListByLoadIdAndNodeId(Long loadId, Long warehouseId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillPackageService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillPackageService.java index 46527ad2c..0df941fff 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillPackageService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillPackageService.java @@ -2,12 +2,14 @@ package com.logpm.trunkline.service; import com.alibaba.fastjson.JSONObject; import com.logpm.trunkline.entity.TrunklineWaybillPackageEntity; +import com.logpm.trunkline.vo.OrderGoodsInfoVO; import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import org.springblade.core.mp.base.BaseService; import java.util.List; import java.util.Map; +import java.util.Set; public interface ITrunklineWaybillPackageService extends BaseService { void saveList(List list, WarehouseWaybillEntity waybillEntity); @@ -19,4 +21,6 @@ public interface ITrunklineWaybillPackageService extends BaseService findOrderGoodsInfoList(Set allWaybillNoSet); + } 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 d967efedc..b34325890 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 @@ -3369,7 +3369,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderPackageCodes = trunklineCarsLoadScanService.findPackageListByLoadId(loadId); @@ -5542,6 +5542,91 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl scanEntities = trunklineCarsLoadScanService.findListByLoadIdOrderByCreateTimeAsc(loadId); + + List saveNewBetch = new ArrayList<>(); + List updateList = new ArrayList<>(); + + for (TrunklineCarsLoadScanEntity scanEntity : scanEntities) { + Integer type = scanEntity.getType(); + String waybillNo = scanEntity.getWaybillNo(); + String orderCode = scanEntity.getOrderCode(); + String scanCode = scanEntity.getScanCode(); + Integer num = scanEntity.getUnloadNum(); + Long fromWarehouseId = scanEntity.getFromWarehouseId(); + Long warehouseId = scanEntity.getWarehouseId(); + String warehouseName = scanEntity.getWarehouseName(); + Long finalNodeId = scanEntity.getFinalNodeId(); + Long unloadNodeId = scanEntity.getUnloadNodeId(); + String unloadNodeName = scanEntity.getUnloadNodeName(); + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, fromWarehouseId); + + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + if (Objects.isNull(waybillEntity)) { + log.warn("##############saveCostShareRecord: 运单信息不存在 waybillNo={}", waybillNo); + continue; + } + Long waybillId = waybillEntity.getId(); + Long departureWarehouseId = waybillEntity.getDepartureWarehouseId(); + String departureWarehouseName = waybillEntity.getDepartureWarehouseName(); + Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); + String destinationWarehouseName = waybillEntity.getDestinationWarehouseName(); + + + TrunklineCostShareRecordEntity trunklineCostShareRecordEntity = null; + if (type.equals(1)) { + trunklineCostShareRecordEntity = trunklineCostShareRecordService.findPackageDataByLoadIdAndCode(scanCode, loadId, AuthUtil.getTenantId()); + } + + if (Objects.isNull(trunklineCostShareRecordEntity)) { + trunklineCostShareRecordEntity = new TrunklineCostShareRecordEntity(); + trunklineCostShareRecordEntity.setLoadId(loadId); + trunklineCostShareRecordEntity.setCarsNo(carsLoadEntity.getCarsNo()); + trunklineCostShareRecordEntity.setWaybillId(waybillId); + trunklineCostShareRecordEntity.setWaybillNo(waybillNo); + if (!Objects.isNull(stockArticleEntity)) { + trunklineCostShareRecordEntity.setOrderId(stockArticleEntity.getId()); + } + trunklineCostShareRecordEntity.setOrderCode(orderCode); + trunklineCostShareRecordEntity.setProductType(type); + trunklineCostShareRecordEntity.setProductCode(scanCode); + trunklineCostShareRecordEntity.setNum(num); + trunklineCostShareRecordEntity.setLoadingWarehouseId(warehouseId); + trunklineCostShareRecordEntity.setLoadingWarehouseName(warehouseName); + trunklineCostShareRecordEntity.setPlanUnloadWarehouseId(finalNodeId); + BasicdataWarehouseEntity finalWarehouse = basicdataWarehouseClient.getEntityWarehouseId(finalNodeId); + if (!Objects.isNull(finalWarehouse)) { + trunklineCostShareRecordEntity.setPlanUnloadWarehouseName(finalWarehouse.getName()); + } + trunklineCostShareRecordEntity.setRealUnloadWarehouseId(unloadNodeId); + trunklineCostShareRecordEntity.setRealUnloadWarehouseName(unloadNodeName); + trunklineCostShareRecordEntity.setWaybillStartWarehouseId(departureWarehouseId); + trunklineCostShareRecordEntity.setWaybillStartWarehouseName(departureWarehouseName); + trunklineCostShareRecordEntity.setWaybillEndWarehouseId(destinationWarehouseId); + trunklineCostShareRecordEntity.setWaybillEndWarehouseName(destinationWarehouseName); + saveNewBetch.add(trunklineCostShareRecordEntity); + } else { + trunklineCostShareRecordEntity.setRealUnloadWarehouseId(scanEntity.getUnloadNodeId()); + trunklineCostShareRecordEntity.setRealUnloadWarehouseName(scanEntity.getUnloadNodeName()); + updateList.add(trunklineCostShareRecordEntity); + } + + } + + if(CollUtil.isNotEmpty(saveNewBetch)){ + trunklineCostShareRecordService.saveBatch(saveNewBetch); + } + if(CollUtil.isNotEmpty(updateList)){ + trunklineCostShareRecordService.updateBatchById(updateList); + } + + } + private void updateParcelListToWarehouse(TrunklineAdvanceDetailEntity advanceDetailEntity, Long warehouseId, String status) { String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); String orderCode = advanceDetailEntity.getOrderCode(); @@ -5783,6 +5868,15 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl loadLineList = trunklineCarsLoadLineService.findListByLoadId(loadId); TrunklineCarsLoadVO trunklineCarsLoadVO = new TrunklineCarsLoadVO(); @@ -5791,164 +5885,387 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderCodeString = new ArrayList<>(); + //所有车辆配载计划 + List carsOrderList = trunklineCarsOrderService.findListByLoadId(loadId); + //把carsOrderList中所有waybillNo放入一个List + Set planWaybillNoSet = carsOrderList.stream().map(TrunklineCarsOrderEntity::getWaybillNo).collect(Collectors.toSet()); + //把carsOrderList通过waybillNo进行分组 + Map> carsOrderMapByWaybillNo = carsOrderList.stream().filter(item -> StringUtil.isNotBlank(item.getWaybillNo())).collect(Collectors.groupingBy(TrunklineCarsOrderEntity::getWaybillNo)); - List carsLoadWaybillInfoList = trunklineCarsOrderService.findWaybillOrderByloadId(loadId); - for (CarsLoadWaybillInfoVO carsLoadWaybillInfoVO : carsLoadWaybillInfoList) { - String waybillNo = carsLoadWaybillInfoVO.getWaybillNo(); - List wayBillDetails = warehouseWaybillDetailClient.findListByWaybillNo(waybillNo); - - String openPrice = null; - String productNames = null; - for (WarehouseWayBillDetail wayBillDetail : wayBillDetails) { - String productName = wayBillDetail.getProductName(); - Integer num = wayBillDetail.getNum(); - BigDecimal price = wayBillDetail.getPrice(); - if (StringUtil.isBlank(openPrice)) { - openPrice = price.toPlainString(); - } else { - openPrice = openPrice + "," + price.toPlainString(); - } - if (StringUtil.isBlank(productNames)) { - productNames = productName + "(" + num + ")"; - } else { - productNames = productNames + "," + productName + "(" + num + ")"; - } - } - carsLoadWaybillInfoVO.setOpenPrice(openPrice); - carsLoadWaybillInfoVO.setGoodsName(productNames); + //所有车辆配载实际装车 + List loadScanList = trunklineCarsLoadScanService.findListAndPriceByLoadId(loadId); + //把carsOrderList中所有waybillNo放入一个List + Set realWaybillNoSet = loadScanList.stream().filter(item -> StringUtil.isNotBlank(item.getWaybillNo())).map(TrunklineCarsLoadScanVO::getWaybillNo).collect(Collectors.toSet()); + //把loadScanList通过waybillNo分组 + Map> loadScanMapByWaybillNo = loadScanList.stream().filter(item -> StringUtil.isNotBlank(item.getWaybillNo())).collect(Collectors.groupingBy(TrunklineCarsLoadScanVO::getWaybillNo)); -// List carsLoadOrderInfoList = trunklineCarsOrderService.findCarsLoadOrderInfoList(loadId, waybillNo); - List carsLoadOrderInfoListPlan = trunklineCarsOrderService.findCarsLoadOrderInfoListPlan(loadId, waybillNo); + //提出loadScanList中运单号为空的记录 + List noWaybillLoadScanList = loadScanList.stream().filter(item -> StringUtil.isBlank(item.getWaybillNo())).collect(Collectors.toList()); - carsLoadOrderInfoListPlan.forEach(carsLoadOrderInfoVO -> { - orderCodeString.add(carsLoadOrderInfoVO.getOrderCode()); - carsLoadOrderInfoVO.setUnloadIncome(carsLoadOrderInfoVO.getUnloadIncome().setScale(2, BigDecimal.ROUND_HALF_UP)); - carsLoadOrderInfoVO.setOrderFreight(carsLoadOrderInfoVO.getOrderFreight().setScale(2, BigDecimal.ROUND_HALF_UP)); - }); + //先把所有需要查询的运单信息查出来 + Set allWaybillNoSet = new HashSet<>(); + allWaybillNoSet.addAll(planWaybillNoSet); + allWaybillNoSet.addAll(realWaybillNoSet); + List warehouseWaybillVOS = warehouseWaybillClient.findWaybillVOByWaybillNoSet(allWaybillNoSet); + //查询出所有运单下订单的品类信息 + List orderGoodsInfoVOList = waybillPackageService.findOrderGoodsInfoList(allWaybillNoSet); + //把orderGoodsInfoVOList通过运单号进行分组 + Map> orderGoodsInfoMapByWaybillNo = orderGoodsInfoVOList.stream().filter(item -> StringUtil.isNotBlank(item.getWaybillNo())).collect(Collectors.groupingBy(OrderGoodsInfoVO::getWaybillNo)); - carsLoadWaybillInfoVO.setCarsLoadOrderInfoList(carsLoadOrderInfoListPlan); -// carsLoadWaybillInfoVO.setCarsLoadOrderInfoListPlan(carsLoadOrderInfoListPlan); + List carsLoadWaybillInfoVOList = new ArrayList<>(); - TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNo(loadId, waybillNo); - carsLoadWaybillInfoVO.setCostPiece(costShareRecordEntity.getCostPiece()); - carsLoadWaybillInfoVO.setCostZhang(costShareRecordEntity.getCostZhang()); - carsLoadWaybillInfoVO.setCostNum(costShareRecordEntity.getNum()); - } + warehouseWaybillVOS.forEach(item -> { + CarsLoadWaybillInfoVO carsLoadWaybillInfoVO = new CarsLoadWaybillInfoVO(); + BeanUtil.copy(item,carsLoadWaybillInfoVO); + String waybillNo = carsLoadWaybillInfoVO.getWaybillNo(); + Integer waybillNum = carsLoadWaybillInfoVO.getWaybillNum(); + String goodsName = carsLoadWaybillInfoVO.getGoodsName(); + String productPrice = carsLoadWaybillInfoVO.getProductPrice(); + String productNum = carsLoadWaybillInfoVO.getProductNum(); + String productVolume = carsLoadWaybillInfoVO.getProductVolume(); + String productWeight = carsLoadWaybillInfoVO.getProductWeight(); + String chargeTypes = carsLoadWaybillInfoVO.getChargeTypes(); + + String[] nameArray = goodsName.split(","); + String[] priceArray = productPrice.split(","); + String[] numArray = productNum.split(","); + String[] volumeArray = productVolume.split(","); + String[] weightArray = productWeight.split(","); + String[] chargeTypeArray = chargeTypes.split(","); + + List orderGoodsInfoVOList1 = orderGoodsInfoMapByWaybillNo.get(waybillNo); + //把orderGoodsInfoVOList1转化成以orderCode为key的map + Map> orderGoodsInfoMapByOrderCode = orderGoodsInfoVOList1.stream().filter(item1 -> StringUtil.isNotBlank(item1.getOrderCode())).collect(Collectors.groupingBy(OrderGoodsInfoVO::getOrderCode)); + + //计算每个品类的单个价格 体积 重量 + Map priceMap = new HashMap<>(); + Map volumeMap = new HashMap<>(); + Map weightMap = new HashMap<>(); + Map chargeTypeMap = new HashMap<>(); + for (int i = 0; i < nameArray.length; i++) { + priceMap.put(nameArray[i],priceArray[i]); + String num = numArray[i]; + String volume = volumeArray[i]; + String weight = weightArray[i]; + volumeMap.put(nameArray[i],new BigDecimal(volume).divide(new BigDecimal(num),8, RoundingMode.HALF_UP).toPlainString()); + weightMap.put(nameArray[i],new BigDecimal(weight).divide(new BigDecimal(num),8, RoundingMode.HALF_UP).toPlainString()); + chargeTypeMap.put(nameArray[i],chargeTypeArray[i]); + } + List resulOrderList = new ArrayList<>(); - //查询异常的数据 - List carsLoadScanAbnormalList = trunklineCarsLoadScanService.findAbnormalData(loadId); - if(!carsLoadScanAbnormalList.isEmpty()){ + List carsOrderEntityList = carsOrderMapByWaybillNo.get(waybillNo);//计划订单列表 + List carsLoadOrderInfoVOList = new ArrayList<>(); + if(CollUtil.isNotEmpty(carsOrderEntityList)){ + carsOrderEntityList.forEach(carsOrderEntity -> { + Integer realNum = carsOrderEntity.getRealNum(); + String orderCode = carsOrderEntity.getOrderCode(); + List orderGoodsInfoVOList2 = orderGoodsInfoMapByOrderCode.get(orderCode); + CarsLoadOrderInfoVO carsLoadOrderInfoVO = new CarsLoadOrderInfoVO(); + carsLoadOrderInfoVO.setOrderCode(orderCode); + carsLoadOrderInfoVO.setWaybillNo(waybillNo); + carsLoadOrderInfoVO.setOrderNum(carsOrderEntity.getTotalNum()); + carsLoadOrderInfoVO.setPlanNum(carsOrderEntity.getPlanNum()); + carsLoadOrderInfoVO.setLoadingNum(realNum); + carsLoadOrderInfoVO.setUnloadNum(carsOrderEntity.getUnloadNum()); + carsLoadOrderInfoVO.setSignNum(carsOrderEntity.getSignNum()); + if(CollUtil.isNotEmpty(orderGoodsInfoVOList2)){ + String goodsListStr = orderGoodsInfoVOList2.stream().map(t -> t.getOriginOrderGoodsName() ).collect(Collectors.joining(",")); + String goodsNumListStr = orderGoodsInfoVOList2.stream().map(t -> t.getOriginOrderGoodsNum() ).collect(Collectors.joining(",")); + carsLoadOrderInfoVO.setOriginOrderGoodsName(goodsListStr); + carsLoadOrderInfoVO.setOriginOrderGoodsNum(goodsNumListStr); + } + carsLoadOrderInfoVO.setOrderFreight(freightPrice.multiply(new BigDecimal(realNum)).setScale(2, RoundingMode.HALF_UP)); + carsLoadOrderInfoVOList.add(carsLoadOrderInfoVO); + }); + } - // 这里需要 排除掉前面有计划的 且已经加入了当前这个配载信息集合里面的数据 + //把carsLoadOrderInfoVOList转化成以orderCode为key的Map + Map carsLoadOrderInfoVOMap = carsLoadOrderInfoVOList.stream().collect(Collectors.toMap(CarsLoadOrderInfoVO::getOrderCode, Function.identity())); + List trunklineCarsLoadScanEntities = loadScanMapByWaybillNo.get(waybillNo);//订单实际装车 + if(CollUtil.isNotEmpty(trunklineCarsLoadScanEntities)){ + //把trunklineCarsLoadScanEntities通过orderCode分组 + Map> trunklineCarsLoadScanMapByOrderCode = trunklineCarsLoadScanEntities.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanVO::getOrderCode)); - //把carsLoadScanAbnormalList过滤waybillNo等于--的数据后把waybillNo放入一个Set - Set waybillNoSet = carsLoadScanAbnormalList.stream().filter(carsLoadScanAbnormalVO -> !"--".equals(carsLoadScanAbnormalVO.getWaybillNo())) - .map(CarsLoadScanAbnormalVO::getWaybillNo) - .collect(Collectors.toSet()); + trunklineCarsLoadScanMapByOrderCode.keySet().forEach(orderCode -> { - List waybillEntityList = warehouseWaybillClient.findWaybillBilllByWaybillNos(new ArrayList<>(waybillNoSet)); - //把waybillEntityList转化成以waybillNo为key的map - Map waybillEntityMap = waybillEntityList.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, Function.identity())); - - //把carsLoadScanAbnormalList通过waybillNo分组 - Map> carsLoadScanAbnormalMap = carsLoadScanAbnormalList.stream().collect(Collectors.groupingBy(CarsLoadScanAbnormalVO::getWaybillNo)); - carsLoadScanAbnormalMap.keySet().forEach(waybillNo -> { - List carsLoadScanAbnormalVOS = carsLoadScanAbnormalMap.get(waybillNo); - WarehouseWaybillEntity warehouseWaybillEntity = waybillEntityMap.get(waybillNo); - BigDecimal freightPrice = BigDecimal.ZERO; - CarsLoadWaybillInfoVO carsLoadWaybillInfoVO = new CarsLoadWaybillInfoVO(); - carsLoadWaybillInfoVO.setWaybillNo(waybillNo); - if(!"--".equals(waybillNo)){ - if(!Objects.isNull(warehouseWaybillEntity)){ - Integer totalCount = warehouseWaybillEntity.getTotalCount(); - carsLoadWaybillInfoVO.setCreateTime(warehouseWaybillEntity.getCreateTime()); - carsLoadWaybillInfoVO.setDestination(warehouseWaybillEntity.getDestination()); - carsLoadWaybillInfoVO.setDestinationWarehouseName(warehouseWaybillEntity.getDestinationWarehouseName()); - carsLoadWaybillInfoVO.setShipper(warehouseWaybillEntity.getShipper()); - carsLoadWaybillInfoVO.setShipperName(warehouseWaybillEntity.getShipperName()); - carsLoadWaybillInfoVO.setConsignee(warehouseWaybillEntity.getConsignee()); - carsLoadWaybillInfoVO.setConsigneeName(warehouseWaybillEntity.getConsigneeName()); - carsLoadWaybillInfoVO.setWaybillNum(totalCount); - carsLoadWaybillInfoVO.setWaybillType(warehouseWaybillEntity.getWaybillType()); - carsLoadWaybillInfoVO.setWaybillId(warehouseWaybillEntity.getId()); - carsLoadWaybillInfoVO.setRemark(warehouseWaybillEntity.getRemark()); - BigDecimal totalFreight = warehouseWaybillEntity.getTotalFreight(); - BigDecimal deliveryFee = warehouseWaybillEntity.getDeliveryFee(); - BigDecimal pickupFee = warehouseWaybillEntity.getPickupFee(); - BigDecimal warehouseManagementFee = warehouseWaybillEntity.getWarehouseManagementFee(); - BigDecimal storageFee = warehouseWaybillEntity.getStorageFee(); - BigDecimal handlingFee = warehouseWaybillEntity.getHandlingFee(); - BigDecimal otherFee = warehouseWaybillEntity.getOtherFee(); - BigDecimal insuranceFee = warehouseWaybillEntity.getInsuranceFee(); - carsLoadWaybillInfoVO.setTotalFreight(totalFreight); - carsLoadWaybillInfoVO.setDeliveryFee(deliveryFee); - carsLoadWaybillInfoVO.setPickupFee(pickupFee); - carsLoadWaybillInfoVO.setWarehouseManagementFee(warehouseManagementFee); - carsLoadWaybillInfoVO.setStorageFee(storageFee); - carsLoadWaybillInfoVO.setHandlingFee(handlingFee); - carsLoadWaybillInfoVO.setOtherFee(otherFee); - carsLoadWaybillInfoVO.setInsuranceFee(insuranceFee); - carsLoadWaybillInfoVO.setOpenPrice(totalFreight.divide(new BigDecimal(totalCount),2, RoundingMode.HALF_UP).toPlainString()); - carsLoadWaybillInfoVO.setTotalFee(totalFreight.add(deliveryFee).add(pickupFee).add(warehouseManagementFee).add(storageFee).add(handlingFee).add(otherFee).add(insuranceFee)); - TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNo(loadId, waybillNo); - carsLoadWaybillInfoVO.setCostPiece(costShareRecordEntity.getCostPiece()); - carsLoadWaybillInfoVO.setCostZhang(costShareRecordEntity.getCostZhang()); - carsLoadWaybillInfoVO.setCostNum(costShareRecordEntity.getNum()); - freightPrice = totalFreight.divide(BigDecimal.valueOf(warehouseWaybillEntity.getTotalCount()),4, RoundingMode.HALF_UP); - } - } + List trunklineCarsLoadScanListByOrderCode = trunklineCarsLoadScanMapByOrderCode.get(orderCode);//订单实际装车 + //把trunklineCarsLoadScanListByOrderCode中所有元素num求和,num为空用0代替 + Integer loadingNum = trunklineCarsLoadScanListByOrderCode.stream().filter(t -> !Objects.isNull(t.getWarehouseId())).map(TrunklineCarsLoadScanVO::getNum).reduce(0, Integer::sum); + Integer unloadNum = trunklineCarsLoadScanListByOrderCode.stream().map(TrunklineCarsLoadScanVO::getUnloadNum).reduce(0, Integer::sum); + Integer signNum = trunklineCarsLoadScanListByOrderCode.stream().filter(t -> t.getScanStatus().equals("3")).map(TrunklineCarsLoadScanVO::getUnloadNum).reduce(0, Integer::sum); - List carsLoadOrderInfoList = new ArrayList<>(); - BigDecimal finalFreightPrice = freightPrice; - carsLoadScanAbnormalVOS.forEach(carsLoadScanAbnormalVO -> { - CarsLoadOrderInfoVO carsLoadOrderInfoVO = new CarsLoadOrderInfoVO(); - carsLoadOrderInfoVO.setOrderCode(carsLoadScanAbnormalVO.getOrderCode()); - if(!orderCodeString.contains(carsLoadScanAbnormalVO.getOrderCode())){ + CarsLoadOrderInfoVO carsLoadOrderInfoVO = carsLoadOrderInfoVOMap.get(orderCode); + if(Objects.isNull(carsLoadOrderInfoVO)){ + carsLoadOrderInfoVO = new CarsLoadOrderInfoVO(); + carsLoadOrderInfoVO.setOrderCode(orderCode); + List orderGoodsInfoVOList2 = orderGoodsInfoMapByOrderCode.get(orderCode); carsLoadOrderInfoVO.setWaybillNo(waybillNo); - carsLoadOrderInfoVO.setLoadingNum(carsLoadScanAbnormalVO.getLoadingNum()); - carsLoadOrderInfoVO.setUnloadNum(carsLoadScanAbnormalVO.getUnloadNum()); - BigDecimal unloadIncome = finalFreightPrice.multiply(BigDecimal.valueOf(carsLoadScanAbnormalVO.getUnloadNum())); - carsLoadOrderInfoVO.setUnloadIncome(unloadIncome.setScale(2,BigDecimal.ROUND_UP)); - carsLoadOrderInfoVO.setPlanNum(0); - String orderCode = carsLoadScanAbnormalVO.getOrderCode(); - if("--".equals(waybillNo) || "--".equals(orderCode)){ - carsLoadOrderInfoVO.setOrderNum(0); - carsLoadOrderInfoVO.setOrderFreight(BigDecimal.ZERO.setScale(2,BigDecimal.ROUND_UP)); + TrunklineWaybillOrderEntity trunklineWaybillOrder = trunklineWaybillOrderService.findEntityByWaybillNoAndOrderCode(waybillNo, orderCode); + if(!Objects.isNull(trunklineWaybillOrder)){ + carsLoadOrderInfoVO.setOrderNum(trunklineWaybillOrder.getTotalNumber()); }else{ - Integer num = trunklineWaybillOrderService.findTotalNumByWaybillAndOrderCode(waybillNo, orderCode); - carsLoadOrderInfoVO.setOrderNum(num); - carsLoadOrderInfoVO.setOrderFreight(finalFreightPrice.multiply(new BigDecimal(num)).setScale(2,BigDecimal.ROUND_UP)); + Integer totalNumber = advanceService.findTotalNumByWaybillNoAndOrderCode(waybillNo,orderCode); + if(Objects.isNull(totalNumber)){ + carsLoadOrderInfoVO.setOrderNum(0); + }else{ + carsLoadOrderInfoVO.setOrderNum(totalNumber); + } + + } + carsLoadOrderInfoVO.setLoadingNum(loadingNum); + carsLoadOrderInfoVO.setUnloadNum(unloadNum); + carsLoadOrderInfoVO.setSignNum(signNum); + if(CollUtil.isNotEmpty(orderGoodsInfoVOList2)){ + String goodsListStr = orderGoodsInfoVOList2.stream().map(t -> t.getOriginOrderGoodsName() ).collect(Collectors.joining(",")); + String goodsNumListStr = orderGoodsInfoVOList2.stream().map(t -> t.getOriginOrderGoodsNum() ).collect(Collectors.joining(",")); + carsLoadOrderInfoVO.setOriginOrderGoodsName(goodsListStr); + carsLoadOrderInfoVO.setOriginOrderGoodsNum(goodsNumListStr); } - TrunklineCostShareRecordEntity orderCostShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNoAndOrderCode(loadId,waybillNo,orderCode); - carsLoadOrderInfoVO.setCostZhang(orderCostShareRecordEntity.getCostZhang()); - carsLoadOrderInfoVO.setCostPiece(orderCostShareRecordEntity.getCostPiece()); -// carsLoadOrderInfoVO.setWeight(BigDecimal.ZERO); -// carsLoadOrderInfoVO.setVolume(BigDecimal.ZERO); - carsLoadOrderInfoList.add(carsLoadOrderInfoVO); + carsLoadOrderInfoVO.setOrderFreight(freightPrice.multiply(new BigDecimal(loadingNum)).setScale(2, RoundingMode.HALF_UP)); + }else{ + carsLoadOrderInfoVO.setLoadingNum(loadingNum); + carsLoadOrderInfoVO.setUnloadNum(unloadNum); + carsLoadOrderInfoVO.setSignNum(signNum); } + carsLoadOrderInfoVOMap.put(orderCode, carsLoadOrderInfoVO); + + //把trunklineCarsLoadScanListByOrderCode通过type分组 + Map> trunklineCarsLoadScanMapByType = trunklineCarsLoadScanListByOrderCode.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanVO::getType)); + + AtomicReference totalIncomingParice = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference totalVolume = new AtomicReference<>(BigDecimal.ZERO); + AtomicReference totalWeight = new AtomicReference<>(BigDecimal.ZERO); + Map goodsByNum = new HashMap<>(); + Map goodsByVolume = new HashMap<>(); + Map goodsByWeight = new HashMap<>(); + + trunklineCarsLoadScanMapByType.keySet().forEach(type -> { + List trunklineCarsLoadScanVOS = trunklineCarsLoadScanMapByType.get(type); + if(NumberUtil.equals(type,1)){ + //订制品 + trunklineCarsLoadScanVOS.forEach(trunklineCarsLoadScanVO -> { + String gn = trunklineCarsLoadScanVO.getGoodsName(); + Integer num = trunklineCarsLoadScanVO.getNum(); + Integer unloadNum1 = trunklineCarsLoadScanVO.getUnloadNum(); + if(Objects.isNull(unloadNum1)){ + unloadNum1 = 0; + } + String price = priceMap.get(gn); + if(StrUtil.isBlank(price)){ + price = "0"; + } + String oneVolume = volumeMap.get(gn); + if(StrUtil.isBlank(oneVolume)){ + oneVolume = "0"; + } + String oneWeight = weightMap.get(gn); + if(StrUtil.isBlank(oneWeight)){ + oneWeight = "0"; + } + String chargeType = chargeTypeMap.get(gn); + if(StringUtil.isBlank(chargeType)){ + chargeType = "1"; + } + if("1".equals(chargeType)){ + totalIncomingParice.set(totalIncomingParice.get().add(new BigDecimal(price).multiply(new BigDecimal(unloadNum1)))); + }else if("2".equals(chargeType)){ + totalIncomingParice.set(totalIncomingParice.get().add(new BigDecimal(price).multiply(new BigDecimal(oneVolume)))); + }else if("3".equals(chargeType)){ + totalIncomingParice.set(totalIncomingParice.get().add(new BigDecimal(price).multiply(new BigDecimal(oneWeight)))); + } + totalVolume.set(totalVolume.get().add(new BigDecimal(oneVolume).multiply(new BigDecimal(unloadNum1)))); + totalWeight.set(totalWeight.get().add(new BigDecimal(oneWeight).multiply(new BigDecimal(unloadNum1)))); + Integer n = goodsByNum.get(gn); + if(Objects.isNull(n)){ + goodsByNum.put(gn,num); + }else{ + goodsByNum.put(gn,n+num); + } + BigDecimal v = goodsByVolume.get(gn); + if(Objects.isNull(v)){ + goodsByVolume.put(gn,new BigDecimal(oneVolume).multiply(new BigDecimal(unloadNum1))); + }else{ + goodsByVolume.put(gn,v.add(new BigDecimal(oneVolume).multiply(new BigDecimal(unloadNum1)))); + } + BigDecimal w = goodsByWeight.get(gn); + if(Objects.isNull(w)){ + goodsByWeight.put(gn,new BigDecimal(oneWeight).multiply(new BigDecimal(unloadNum1))); + }else{ + goodsByWeight.put(gn,w.add(new BigDecimal(oneWeight).multiply(new BigDecimal(unloadNum1)))); + } + + }); + + + }else if(NumberUtil.equals(type,2)){ + + trunklineCarsLoadScanVOS.forEach(trunklineCarsLoadScanVO -> { +// String scanCode = trunklineCarsLoadScanVO.getScanCode(); +// Integer num = trunklineCarsLoadScanVO.getNum(); +// Integer unloadNum1 = trunklineCarsLoadScanVO.getUnloadNum(); + Long scanId = trunklineCarsLoadScanVO.getId(); + List zeroDetailVOList = scanZeroDetailService.findListByCarsLoadScanId(scanId); + + zeroDetailVOList.forEach(zeroDetailVO -> { + Integer unloadNum1 = zeroDetailVO.getUnloadNum(); + String goodsName1 = zeroDetailVO.getGoodsName(); + + if(Objects.isNull(unloadNum1)){ + unloadNum1 = 0; + } + String price = priceMap.get(goodsName1); + if(StrUtil.isBlank(price)){ + price = "0"; + } + String oneVolume = volumeMap.get(goodsName1); + if(StrUtil.isBlank(oneVolume)){ + oneVolume = "0"; + } + String oneWeight = weightMap.get(goodsName1); + if(StrUtil.isBlank(oneWeight)){ + oneWeight = "0"; + } + String chargeType = chargeTypeMap.get(goodsName1); + if(StringUtil.isBlank(chargeType)){ + chargeType = "1"; + } + if("1".equals(chargeType)){ + totalIncomingParice.set(totalIncomingParice.get().add(new BigDecimal(price).multiply(new BigDecimal(unloadNum1)))); + }else if("2".equals(chargeType)){ + totalIncomingParice.set(totalIncomingParice.get().add(new BigDecimal(price).multiply(new BigDecimal(oneVolume)).multiply(new BigDecimal(unloadNum1)))); + }else if("3".equals(chargeType)){ + totalIncomingParice.set(totalIncomingParice.get().add(new BigDecimal(price).multiply(new BigDecimal(oneWeight)).multiply(new BigDecimal(unloadNum1)))); + } + totalVolume.set(totalVolume.get().add(new BigDecimal(oneVolume).multiply(new BigDecimal(unloadNum1)))); + totalWeight.set(totalWeight.get().add(new BigDecimal(oneWeight).multiply(new BigDecimal(unloadNum1)))); + Integer n = goodsByNum.get(goodsName1); + if(Objects.isNull(n)){ + goodsByNum.put(goodsName1,unloadNum1); + }else{ + goodsByNum.put(goodsName1,n+unloadNum1); + } + BigDecimal v = goodsByVolume.get(goodsName1); + if(Objects.isNull(v)){ + goodsByVolume.put(goodsName1,new BigDecimal(oneVolume).multiply(new BigDecimal(unloadNum1))); + }else{ + goodsByVolume.put(goodsName1,v.add(new BigDecimal(oneVolume).multiply(new BigDecimal(unloadNum1)))); + } + BigDecimal w = goodsByWeight.get(goodsName1); + if(Objects.isNull(w)){ + goodsByWeight.put(goodsName1,new BigDecimal(oneWeight).multiply(new BigDecimal(unloadNum1))); + }else{ + goodsByWeight.put(goodsName1,w.add(new BigDecimal(oneWeight).multiply(new BigDecimal(unloadNum1)))); + } + }); + }); + } + }); + + List orderGoodsNameList = new ArrayList<>(); + List orderGoodsNumList = new ArrayList<>(); + List orderGoodsVolumeList = new ArrayList<>(); + List orderGoodsWeightList = new ArrayList<>(); + + goodsByNum.keySet().forEach(g -> { + orderGoodsNameList.add(g); + orderGoodsNumList.add(goodsByNum.get(g)+""); + orderGoodsVolumeList.add(goodsByVolume.get(g).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()); + orderGoodsWeightList.add(goodsByWeight.get(g).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()); + }); + + + carsLoadOrderInfoVO.setUnloadIncome(totalIncomingParice.get().setScale(2, BigDecimal.ROUND_HALF_UP)); + carsLoadOrderInfoVO.setWeight(totalWeight.get().setScale(2, BigDecimal.ROUND_HALF_UP)); + carsLoadOrderInfoVO.setVolume(totalVolume.get().setScale(2, BigDecimal.ROUND_HALF_UP)); + carsLoadOrderInfoVO.setOrderGoodsNum(String.join(",", orderGoodsNumList)); + carsLoadOrderInfoVO.setOrderGoodsName(String.join(",", orderGoodsNameList)); + carsLoadOrderInfoVO.setOrderGoodsVolume(String.join(",", orderGoodsVolumeList)); + carsLoadOrderInfoVO.setOrderGoodsWeight(String.join(",", orderGoodsWeightList)); + + resulOrderList.add(carsLoadOrderInfoVO); }); - carsLoadWaybillInfoVO.setCarsLoadOrderInfoList(carsLoadOrderInfoList); + }else{ + resulOrderList.addAll(carsLoadOrderInfoVOList); + } - carsLoadWaybillInfoList.add(carsLoadWaybillInfoVO); - }); + TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNo(loadId, waybillNo); + carsLoadWaybillInfoVO.setCostPiece(costShareRecordEntity.getCostPiece()); + carsLoadWaybillInfoVO.setCostZhang(costShareRecordEntity.getCostZhang()); + carsLoadWaybillInfoVO.setCostNum(costShareRecordEntity.getNum()); + + + carsLoadWaybillInfoVO.setCarsLoadOrderInfoList(resulOrderList); + carsLoadWaybillInfoVOList.add(carsLoadWaybillInfoVO); + }); + + //无系统编码的数据 + CarsLoadWaybillInfoVO noWaybillNoCarsLoadWaybillInfoVO = new CarsLoadWaybillInfoVO(); + noWaybillNoCarsLoadWaybillInfoVO.setCheckStatus(0); + noWaybillNoCarsLoadWaybillInfoVO.setWaybillNum(0); + noWaybillNoCarsLoadWaybillInfoVO.setTotalVolume(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setTotalWeight(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setWaybillType(1); + noWaybillNoCarsLoadWaybillInfoVO.setTotalFreight(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setDeliveryFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setPickupFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setWarehouseManagementFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setStorageFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setSortingFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setHandlingFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setOtherFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setInsuranceFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setTotalFee(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setCostPiece(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setCostZhang(BigDecimal.ZERO); + noWaybillNoCarsLoadWaybillInfoVO.setCostNum(0); - } + + List noWaybillOrderList = new ArrayList<>(); + //把noWaybillLoadScanList通过orderCode分组 + Map> noWaybillNoTrunklineCarsLoadScanMapByOrderCode = noWaybillLoadScanList.stream().collect(Collectors.groupingBy(TrunklineCarsLoadScanVO::getOrderCode)); + noWaybillNoTrunklineCarsLoadScanMapByOrderCode.keySet().forEach(orderCode -> { + List trunklineCarsLoadScanVOS = noWaybillNoTrunklineCarsLoadScanMapByOrderCode.get(orderCode); + //把trunklineCarsLoadScanVOS中所有元素的num加起来,如果num为空则用0代替 + Integer loadingNum = trunklineCarsLoadScanVOS.stream().filter(t-> !Objects.isNull(t.getWarehouseId())).map(TrunklineCarsLoadScanVO::getNum).reduce(0, Integer::sum); + Integer unloadNum = trunklineCarsLoadScanVOS.stream().map(TrunklineCarsLoadScanVO::getUnloadNum).reduce(0, Integer::sum); + Integer signNum = trunklineCarsLoadScanVOS.stream().filter(t-> t.getScanStatus().equals("3")).map(TrunklineCarsLoadScanVO::getUnloadNum).reduce(0, Integer::sum); + + + CarsLoadOrderInfoVO carsLoadOrderInfoVO = new CarsLoadOrderInfoVO(); + carsLoadOrderInfoVO.setOrderCode(orderCode); + carsLoadOrderInfoVO.setOrderNum(0); + carsLoadOrderInfoVO.setPlanNum(0); + carsLoadOrderInfoVO.setLoadingNum(loadingNum); + carsLoadOrderInfoVO.setUnloadNum(unloadNum); + carsLoadOrderInfoVO.setSignNum(signNum); + carsLoadOrderInfoVO.setUnloadIncome(BigDecimal.ZERO); + carsLoadOrderInfoVO.setCostPiece(BigDecimal.ZERO); + carsLoadOrderInfoVO.setCostPiece(BigDecimal.ZERO); + carsLoadOrderInfoVO.setWeight(BigDecimal.ZERO); + carsLoadOrderInfoVO.setVolume(BigDecimal.ZERO); + carsLoadOrderInfoVO.setIncome(BigDecimal.ZERO); + carsLoadOrderInfoVO.setOrderFreight(freightPrice.multiply(new BigDecimal(unloadNum))); + noWaybillOrderList.add(carsLoadOrderInfoVO); + }); + + noWaybillNoCarsLoadWaybillInfoVO.setCarsLoadOrderInfoList(noWaybillOrderList); //对元素中的waybillNo进行倒序排序 - carsLoadWaybillInfoList.sort(Comparator.comparing(CarsLoadWaybillInfoVO::getWaybillNo).reversed()); + carsLoadWaybillInfoVOList.sort(Comparator.comparing(CarsLoadWaybillInfoVO::getWaybillNo).reversed()); + + carsLoadWaybillInfoVOList.add(noWaybillNoCarsLoadWaybillInfoVO); - trunklineCarsLoadVO.setCarsLoadWaybillInfoList(carsLoadWaybillInfoList); + trunklineCarsLoadVO.setCarsLoadWaybillInfoList(carsLoadWaybillInfoVOList); return R.data(trunklineCarsLoadVO); } @@ -7085,11 +7402,11 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl mainVOList = trunklineCarsOrderService.findLoadingListByLoadIdAndNodeId(loadId, warehouseId); + //把mainVOList中所有元素的orderCode和waybillNo拼接起来作为key的map + Map mainVOMap = mainVOList.stream().collect(Collectors.toMap(item -> item.getOrderCode() +"&&"+ (StringUtil.isBlank(item.getWaybillNo())?"kong":item.getWaybillNo()), item -> item)); + + + List loadingMainList = trunklineCarsLoadScanService.findLoadingListDataMain(loadId, warehouseId); + loadingMainList.forEach(loadingListMainVO -> { + String orderCode = loadingListMainVO.getOrderCode(); + String waybillNo = loadingListMainVO.getWaybillNo(); + if(StringUtil.isBlank(waybillNo)){ + waybillNo = "kong"; + } + LoadingListMainVO loadingListMainVO1 = mainVOMap.get(orderCode + "&&" + waybillNo); + if(Objects.isNull(loadingListMainVO1)){ + loadingListMainVO.setLoadingNum(loadingListMainVO.getSmallTotal()); + mainVOMap.put(orderCode + "&&" + waybillNo, loadingListMainVO); + }else{ + loadingListMainVO1.setLoadingNum(loadingListMainVO.getSmallTotal()); + mainVOMap.put(orderCode + "&&" + waybillNo, loadingListMainVO1); + + } + }); + + List unloadMainList = trunklineCarsLoadScanService.findUnloadListDataMain(loadId, warehouseId); + + unloadMainList.forEach(unloadMainVO -> { + String orderCode = unloadMainVO.getOrderCode(); + String waybillNo = unloadMainVO.getWaybillNo(); + if(StringUtil.isBlank(waybillNo)){ + waybillNo = "kong"; + } + LoadingListMainVO loadingListMainVO1 = mainVOMap.get(orderCode + "&&" + waybillNo); + if(Objects.isNull(loadingListMainVO1)){ + mainVOMap.put(orderCode + "&&" + waybillNo, unloadMainVO); + }else{ + loadingListMainVO1.setUnloadNum(unloadMainVO.getUnloadNum()); + mainVOMap.put(orderCode + "&&" + waybillNo, loadingListMainVO1); + + } + }); + + + +// for (LoadingListMainVO loadingListMainVO : loadingMainList) { +// Integer type = loadingListMainVO.getType(); +// if (type.equals(1)) { +// String orderCode = loadingListMainVO.getOrderCode(); +// String waybillNo = loadingListMainVO.getWaybillNo(); +// List goodsList = trunklineCarsLoadScanService.findLoadingListGoods(loadId, warehouseId, orderCode, waybillNo); +//// loadingListMainVO.setGoodsList(goodsList); +// //把goodsList中所有元素的godsName和num拼起来后再用逗号拼起来 +// String goodsListStr = goodsList.stream().map(item -> item.getGoodsName() + "(" + item.getNum()+")").collect(Collectors.joining(",")); +// loadingListMainVO.setGoodsListStr(goodsListStr); +// } else if (type.equals(2)) { +//// List goodsList = new ArrayList<>(); +//// LoadingListGoodsVO loadingListGoodsVO = new LoadingListGoodsVO(); +//// loadingListGoodsVO.setGoodsName("零担"); +//// loadingListGoodsVO.setNum(loadingListMainVO.getSmallTotal()); +// String goodsListStr = "零担("+loadingListMainVO.getSmallTotal()+")"; +//// goodsList.add(loadingListGoodsVO); +//// loadingListMainVO.setGoodsList(goodsList); +// loadingListMainVO.setGoodsListStr(goodsListStr); +// } +// } +// +// +// for (LoadingListMainVO unloadMainVO : unloadMainList) { +// Integer type = unloadMainVO.getType(); +// if (type.equals(1)) { +// String orderCode = unloadMainVO.getOrderCode(); +// String waybillNo = unloadMainVO.getWaybillNo(); +// List goodsList = trunklineCarsLoadScanService.findUnloadGoods(loadId, warehouseId, orderCode, waybillNo); +//// unloadMainVO.setGoodsList(goodsList); +// String goodsListStr = goodsList.stream().map(item -> item.getGoodsName() + "(" + item.getNum()+")").collect(Collectors.joining(",")); +// unloadMainVO.setGoodsListStr(goodsListStr); +// } else if (type.equals(2)) { +//// List goodsList = new ArrayList<>(); +//// LoadingListGoodsVO loadingListGoodsVO = new LoadingListGoodsVO(); +//// loadingListGoodsVO.setGoodsName("零担"); +//// loadingListGoodsVO.setNum(unloadMainVO.getSmallTotal()); +//// goodsList.add(loadingListGoodsVO); +//// unloadMainVO.setGoodsList(goodsList); +// String goodsListStr = "零担("+unloadMainVO.getSmallTotal()+")"; +// unloadMainVO.setGoodsListStr(goodsListStr); +// } +// } +// loadingMainList.addAll(unloadMainList); + +// //把loadingMainList通过waybillNo进行排序 +// loadingMainList.sort(Comparator.comparing(LoadingListMainVO::getWaybillNo)); + + //把mainVOMap的values提取成List + List loadingListMainVOS = mainVOMap.values().stream().collect(Collectors.toList()); + + trunklineCarsLoadLoadingListVO.setMainList(loadingListMainVOS); + trunklineCarsLoadLoadingListVO.setCarsNoBase64(QRCodeUtil.getEmpAutograph(QRCodeUtil.createCodeToFileType(carsNo))); + return R.data(trunklineCarsLoadLoadingListVO); + } else { + log.warn("#############findLoadingListData: 仓库信息不正确"); + return R.fail(405, "仓库信息不正确"); + } + } + + @Transactional(rollbackFor = Exception.class) @Override public R signLoadScanByIds(List loadScanIds, Long warehouseId) { diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java index 2620d8e15..59bf760e4 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java @@ -12,7 +12,6 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; import org.springframework.stereotype.Service; -import java.util.Collections; import java.util.List; @Slf4j @@ -179,4 +178,9 @@ public class TrunklineCarsOrderEntityServiceImpl extends BaseServiceImpl findLoadingListByLoadIdAndNodeId(Long loadId, Long warehouseId) { + return baseMapper.findLoadingListByLoadIdAndNodeId(loadId,warehouseId); + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillPackageServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillPackageServiceImpl.java index f0dc3607c..2261f6630 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillPackageServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillPackageServiceImpl.java @@ -18,6 +18,7 @@ import com.logpm.trunkline.mapper.TrunklineWaybillPackageMapper; import com.logpm.trunkline.service.IPackageTrackLogAsyncService; import com.logpm.trunkline.service.ITrunklineAdvanceDetailService; import com.logpm.trunkline.service.ITrunklineWaybillPackageService; +import com.logpm.trunkline.vo.OrderGoodsInfoVO; import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.IWarehouseWaybillClient; @@ -31,13 +32,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; @Slf4j @@ -325,6 +320,11 @@ public class TrunklineWaybillPackageServiceImpl extends BaseServiceImpl findOrderGoodsInfoList(Set allWaybillNoSet) { + return baseMapper.findOrderGoodsInfoList(allWaybillNoSet); + } + @Override public void updatePackageStatus(List orderPackageCodes, Integer workNode, Long warehouseId, Map map) {