diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java index 59b753f90..d96d55c4c 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java @@ -38,6 +38,6 @@ public interface IBasicdataPriceClient { String PRICE = API_PREFIX + "/pirce"; @PostMapping(PRICE) - PriceClientVO pirce(@RequestBody BasicdatPriceApiVO param); + PriceClientVO price(@RequestBody BasicdatPriceApiVO param); } diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java index 226557d19..82ead77f5 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java @@ -17,6 +17,7 @@ package com.logpm.basicdata.vo; import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; import lombok.Data; import javax.validation.constraints.NotEmpty; @@ -28,6 +29,7 @@ import java.io.Serializable; * @author cyz * @since 2023-06-08 */ +@Builder @Data public class BasicdatPriceApiVO implements Serializable { private static final long serialVersionUID = 1L; diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsDistributionPackageEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsDistributionPackageEntity.java index 2577923b8..bef4baa60 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsDistributionPackageEntity.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsDistributionPackageEntity.java @@ -90,6 +90,12 @@ public class StatisticsDistributionPackageEntity extends TenantEntity { @ApiModelProperty(value = "品类Id") private String productId; + /** + * 配送车次号 + */ + @ApiModelProperty(value = "配送车次号") + private String trainNumber; + /** * 件数 */ diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsWarehousePackageEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsWarehousePackageEntity.java index 602534bce..a07e655a2 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsWarehousePackageEntity.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsWarehousePackageEntity.java @@ -108,6 +108,10 @@ public class StatisticsWarehousePackageEntity extends TenantEntity { private BigDecimal openPrice; private BigDecimal totalPrice; private Date incomingTime; + @ApiModelProperty(value = "签收时间") + private Date signTime; + @ApiModelProperty(value = "末端仓入库时间") + private Date warehouseEntryTimeEnd; private Date outingTime; private String warehouseFeeInterval; private BigDecimal warehouseServiceFee; diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java index 2a415a4ca..7ab497112 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java @@ -37,7 +37,7 @@ public class BasicdataPriceClient implements IBasicdataPriceClient { private final IBasicdataPriceService basicdataPriceService; @Override - public PriceClientVO pirce(BasicdatPriceApiVO param) { + public PriceClientVO price(BasicdatPriceApiVO param) { return basicdataPriceService.price(param); } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java index be9c401dd..b885ed845 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java @@ -43,7 +43,6 @@ import com.logpm.basicdata.entity.BasicdataPriceTemplateEntity; import com.logpm.basicdata.entity.BasicdataStoreBrandEntity; import com.logpm.basicdata.enums.CostTypeEnums; import com.logpm.basicdata.enums.DispatchPricingTypeEnums; -import com.logpm.basicdata.enums.DispatchTypeEnums; import com.logpm.basicdata.enums.FullVehicleTypeEnums; import com.logpm.basicdata.enums.GeneralServiceTypeEnums; import com.logpm.basicdata.enums.PickupPricingTypeEnums; @@ -415,6 +414,9 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl wrapper = Wrappers.lambdaQuery() .eq(BasicdataPriceEntity::getClientId, clientId) @@ -581,7 +583,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl vehicleTypeMap = new HashMap<>(); initVehicleTypeMap(vehicleTypeMap); - //整车 + // 整车 checkFullExcel(fullVehicleExcels, clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, provinceCityAearMap, vehicleTypeMap, message, sheet6); if (StrUtil.isNotEmpty(message.toString())) { return message.toString(); @@ -661,7 +663,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl vehicleTypeMap = new HashMap<>(); initVehicleTypeMap(vehicleTypeMap); - //整车 + // 整车 checkFullExcelV2(fullVehicleExcels, clientEntityMap, priceEntityMap, provinceMap, provinceCityMap, provinceCityAearMap, vehicleTypeMap, message, sheet2, clientBrandMap, templateMap); if (StrUtil.isNotEmpty(message.toString())) { @@ -3351,7 +3353,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl brandEntityMap, Map priceEntityMap, Map clientBrandMap, Map> checkPriceEntityMap) { if (CollUtil.isNotEmpty(priceExcels)) { - Map checkRepeatMap = new HashMap<>(); + Map checkRepeatMap = new HashMap<>(); for (int i = 0; i < priceExcels.size(); i++) { StringBuilder rowMessage = new StringBuilder(); int rowNum = i + 2; @@ -3378,7 +3380,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl fullVehicleEntities, Map> dispatchMap, List generalEntities, List generalEntities1) { PriceDispatchVO priceDispatchVO = new PriceDispatchVO(); String dispatchPricingType = templateEntity.getDispatchPricingType(); - //品类 + // 品类 Map> categoryBasicMap = new HashMap<>(); List dispatchEntities = dispatchMap.get(CostTypeEnums.NOMAL.getCode()); if (CollUtil.isNotEmpty(dispatchEntities)) { @@ -3583,7 +3585,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl basicVOList = new ArrayList<>(); @@ -3660,7 +3662,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl basicVOList = new ArrayList<>(); List basicEntities = categoryBasicMap.get(DispatchPricingTypeEnums.TON_PER_KILOMETER.getCode()); @@ -3675,7 +3677,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl dispatchEntities1 = dispatchMap.get(CostTypeEnums.ADD.getCode()); if (CollUtil.isNotEmpty(dispatchEntities1)) { List basicVOList = new ArrayList<>(); 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 feecdd5c7..4de0af6fd 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 @@ -16,6 +16,8 @@ */ package com.logpm.distribution.service.impl; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -32,14 +34,94 @@ import com.logpm.basicdata.feign.IBasicdataClientClient; import com.logpm.basicdata.feign.IBasicdataDriverArteryClient; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.distribution.bean.Resp; -import com.logpm.distribution.dto.*; +import com.logpm.distribution.dto.DistributionAddvalueDTO; +import com.logpm.distribution.dto.DistributionDeliverySelfDTO; +import com.logpm.distribution.dto.DistributionNumberDetailDTO; +import com.logpm.distribution.dto.DistributionParcelNumberDTO; +import com.logpm.distribution.dto.DistributionSignforDTO; +import com.logpm.distribution.dto.DistributionSignforExcelDTO; +import com.logpm.distribution.dto.DistrilbutionAppsignforDTO; import com.logpm.distribution.dto.app.DistributionAppDeliveryListDTO; -import com.logpm.distribution.entity.*; -import com.logpm.distribution.excel.*; -import com.logpm.distribution.mapper.*; -import com.logpm.distribution.service.*; -import com.logpm.distribution.vo.*; -import com.logpm.distribution.vo.app.*; +import com.logpm.distribution.entity.DisStockListDetailEntity; +import com.logpm.distribution.entity.DistributionAddvaluePackageEntity; +import com.logpm.distribution.entity.DistributionBillLadingScanEntity; +import com.logpm.distribution.entity.DistributionDeliveryListEntity; +import com.logpm.distribution.entity.DistributionDeliverySelfEntity; +import com.logpm.distribution.entity.DistributionDeliveryTripartiteEntity; +import com.logpm.distribution.entity.DistributionLoadscanAbnormalEntity; +import com.logpm.distribution.entity.DistributionLoadscanEntity; +import com.logpm.distribution.entity.DistributionLoadscaninvnEntity; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionParcelNumberEntity; +import com.logpm.distribution.entity.DistributionReservationEntity; +import com.logpm.distribution.entity.DistributionReservationPackageEntity; +import com.logpm.distribution.entity.DistributionReservationStockarticleEntity; +import com.logpm.distribution.entity.DistributionReservationStocklistEntity; +import com.logpm.distribution.entity.DistributionReservationZeroPackageEntity; +import com.logpm.distribution.entity.DistributionSignPrintEntity; +import com.logpm.distribution.entity.DistributionSignforEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; +import com.logpm.distribution.entity.DistributionStockEntity; +import com.logpm.distribution.entity.DistributionStockListEntity; +import com.logpm.distribution.entity.DistributionStockupEntity; +import com.logpm.distribution.entity.DistrilbutionBillLadingEntity; +import com.logpm.distribution.excel.DistributionSignforExcel; +import com.logpm.distribution.excel.DistributionSignforInventoryExcel; +import com.logpm.distribution.excel.DistributionSignforOrderExcel; +import com.logpm.distribution.excel.DistributionSignforOwnExcel; +import com.logpm.distribution.excel.DistributionSignforPackageExcel; +import com.logpm.distribution.mapper.DistributionAddvalueMapper; +import com.logpm.distribution.mapper.DistributionDeliveryListMapper; +import com.logpm.distribution.mapper.DistributionDeliverySelfMapper; +import com.logpm.distribution.mapper.DistributionDeliveryTripartiteMapper; +import com.logpm.distribution.mapper.DistributionLoadscanMapper; +import com.logpm.distribution.mapper.DistributionLoadscaninvnMapper; +import com.logpm.distribution.mapper.DistributionParcelListMapper; +import com.logpm.distribution.mapper.DistributionReservationMapper; +import com.logpm.distribution.mapper.DistributionSignforMapper; +import com.logpm.distribution.mapper.DistributionStockArticleMapper; +import com.logpm.distribution.mapper.DistributionStockListMapper; +import com.logpm.distribution.mapper.DistributionStockMapper; +import com.logpm.distribution.mapper.DistributionStockupMapper; +import com.logpm.distribution.mapper.DistrilbutionBillLadingMapper; +import com.logpm.distribution.service.IDisStockListDetailService; +import com.logpm.distribution.service.IDistributionAddvaluePackageService; +import com.logpm.distribution.service.IDistributionAddvalueService; +import com.logpm.distribution.service.IDistributionAsyncService; +import com.logpm.distribution.service.IDistributionBillLadingScanService; +import com.logpm.distribution.service.IDistributionDeliveryListService; +import com.logpm.distribution.service.IDistributionLoadscanAbnormalService; +import com.logpm.distribution.service.IDistributionParcelListService; +import com.logpm.distribution.service.IDistributionParcelNumberService; +import com.logpm.distribution.service.IDistributionReservationPackageService; +import com.logpm.distribution.service.IDistributionReservationService; +import com.logpm.distribution.service.IDistributionReservationStockarticleService; +import com.logpm.distribution.service.IDistributionReservationZeroPackageService; +import com.logpm.distribution.service.IDistributionSignPrintService; +import com.logpm.distribution.service.IDistributionSignforService; +import com.logpm.distribution.service.IDistributionStockArticleService; +import com.logpm.distribution.service.IDistributionStockListService; +import com.logpm.distribution.service.IDistributionStockupService; +import com.logpm.distribution.service.IDistrilbutionBillLadingService; +import com.logpm.distribution.vo.DeliveryNodeVo; +import com.logpm.distribution.vo.DistributionAddvaluePackageVO; +import com.logpm.distribution.vo.DistributionAddvalueVO; +import com.logpm.distribution.vo.DistributionDeliverySelfVO; +import com.logpm.distribution.vo.DistributionLoadscanAbnormalVO; +import com.logpm.distribution.vo.DistributionParcelListVO; +import com.logpm.distribution.vo.DistributionParcelNumberVO; +import com.logpm.distribution.vo.DistributionSignPrintVO; +import com.logpm.distribution.vo.DistributionSignforStockListVO; +import com.logpm.distribution.vo.DistributionSignforVO; +import com.logpm.distribution.vo.DistributionSignforsnmbVO; +import com.logpm.distribution.vo.DistributionStockArticleVO; +import com.logpm.distribution.vo.SignforPageCountVO; +import com.logpm.distribution.vo.app.DistributionAppDeliveryListVO; +import com.logpm.distribution.vo.app.DistributionAppDeliverySelfVO; +import com.logpm.distribution.vo.app.DistributionAppPackageDetailVO; +import com.logpm.distribution.vo.app.DistributionAppParcelListVO; +import com.logpm.distribution.vo.app.DistributionAppSignforVO; +import com.logpm.distribution.vo.app.DistributionAppStockArticleVO; import com.logpm.distribution.wrapper.DistributionParcelListAppWrapper; import com.logpm.distribution.wrapper.DistributionParcelListWrapper; import com.logpm.distribution.wrapper.DistributionStockArticleWrapper; @@ -69,8 +151,16 @@ import org.springblade.common.constant.loading.LoadScanSigningStatusConstant; import org.springblade.common.constant.loading.LoadingAbnormalAuditingStatusConstant; import org.springblade.common.constant.loading.LoadingIsInsertConstant; import org.springblade.common.constant.loading.LoadingStatusConstant; -import org.springblade.common.constant.orderpackage.*; -import org.springblade.common.constant.reservation.*; +import org.springblade.common.constant.orderpackage.OrderPackageFreezeStatusConstant; +import org.springblade.common.constant.orderpackage.OrderPackageLoadingStatusConstant; +import org.springblade.common.constant.orderpackage.OrderPackageReservationStatusConstant; +import org.springblade.common.constant.orderpackage.OrderPackageStatusConstant; +import org.springblade.common.constant.orderpackage.OrderPackageStockupStatusConstant; +import org.springblade.common.constant.reservation.ReservationLoadingStatusConstant; +import org.springblade.common.constant.reservation.ReservationOrderStatusConstant; +import org.springblade.common.constant.reservation.ReservationPackageStatusConstant; +import org.springblade.common.constant.reservation.ReservationSigningStatusConstant; +import org.springblade.common.constant.reservation.ReservationStatusConstant; import org.springblade.common.constant.signing.SignforDriverSigningStatusConstant; import org.springblade.common.constant.signing.SignforStatusConstant; import org.springblade.common.constant.stockup.StockAssignStatusConstant; @@ -110,7 +200,15 @@ import java.io.IOException; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; @@ -2499,7 +2597,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImplquery().lambda() .ne(DistributionLoadscanEntity::getScanStatus, 1) .eq(DistributionLoadscanEntity::getReservationId, distrilbutionloadingscanDTO.getReservationId()) .eq(DistributionLoadscanEntity::getDeliveryId, distrilbutionloadingscanDTO.getDeliveryId()) - .eq(DistributionLoadscanEntity::getOrderPackageCode, collect.get(0).getOrderPackageCode())); + .eq(DistributionLoadscanEntity::getOrderPackageCode, parcelListEntity.getOrderPackageCode())); if (Func.isNotEmpty(loadscanEntity)) { if (loadscanEntity.getSignforState().equals(2)) { return Resp.scanFail("重复扫描", "重复扫描"); @@ -2790,7 +2889,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl pages = statisticsOrderInfoService.pageList(merchantStatisticsDTO); 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,"系统异常"); + } 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, "系统异常"); } } @@ -60,52 +66,51 @@ public class MerchantStatisticsController { @ApiOperation(value = "查询订单详情", notes = "传入merchantStatisticsDTO") public R findOrderDetail(@RequestBody MerchantStatisticsDTO merchantStatisticsDTO) { String method = "############findOrderDetail: "; - log.info(method+"请求参数{}",merchantStatisticsDTO); - try{ + log.info(method + "请求参数{}", merchantStatisticsDTO); + try { Long orderInfoId = merchantStatisticsDTO.getOrderInfoId(); - if(Objects.isNull(orderInfoId)){ - log.warn(method+"请选择正确的订单 orderInfoId={}",orderInfoId); - return R.fail(405,"请选择正确的订单"); + if (Objects.isNull(orderInfoId)) { + log.warn(method + "请选择正确的订单 orderInfoId={}", orderInfoId); + return R.fail(405, "请选择正确的订单"); } StatisticsOrderInfoVO statisticsOrderInfoVO = statisticsOrderInfoService.findOrderDetail(orderInfoId); return R.data(statisticsOrderInfoVO); - }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,"系统异常"); + } 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("/findChangesRecordList") @ApiOperationSupport(order = 1) @ApiOperation(value = "查询订单异动记录列表", notes = "传入merchantStatisticsDTO") public R findChangesRecordList(@RequestBody MerchantStatisticsDTO merchantStatisticsDTO) { String method = "############findChangesRecordList: "; - log.info(method+"请求参数{}",merchantStatisticsDTO); - try{ + log.info(method + "请求参数{}", merchantStatisticsDTO); + try { Long orderInfoId = merchantStatisticsDTO.getOrderInfoId(); - if(Objects.isNull(orderInfoId)){ - log.warn(method+"订单id为空 orderInfoId={}",orderInfoId); - return R.fail(405,"订单id为空"); + if (Objects.isNull(orderInfoId)) { + log.warn(method + "订单id为空 orderInfoId={}", orderInfoId); + return R.fail(405, "订单id为空"); } List list = statisticsOrderInfoService.findChangesRecordList(merchantStatisticsDTO); return R.data(list); - }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,"系统异常"); + } 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, "系统异常"); } } @@ -116,29 +121,29 @@ public class MerchantStatisticsController { @ApiOperation(value = "新增异动金额", notes = "传入waybillDTO") public R addChangesRecord(@RequestBody ChangesRecordDTO changesRecordDTO) { String method = "############addChangesRecord: "; - log.info(method+"请求参数{}",changesRecordDTO); - try{ + log.info(method + "请求参数{}", changesRecordDTO); + try { Long orderInfoId = changesRecordDTO.getOrderInfoId(); - if(Objects.isNull(orderInfoId)){ - log.warn(method+"订单id为空 orderInfoId={}",orderInfoId); - return R.fail(405,"订单id为空"); + if (Objects.isNull(orderInfoId)) { + log.warn(method + "订单id为空 orderInfoId={}", orderInfoId); + return R.fail(405, "订单id为空"); } Long statisticsWarehouseId = changesRecordDTO.getStatisticsWarehouseId(); - if(Objects.isNull(statisticsWarehouseId)){ - log.warn(method+"仓库id为空 statisticsWarehouseId={}",statisticsWarehouseId); - return R.fail(405,"仓库id为空"); + if (Objects.isNull(statisticsWarehouseId)) { + log.warn(method + "仓库id为空 statisticsWarehouseId={}", statisticsWarehouseId); + return R.fail(405, "仓库id为空"); } return statisticsOrderInfoService.addChangesRecord(changesRecordDTO); - }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,"系统异常"); + } 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, "系统异常"); } } @@ -149,25 +154,35 @@ public class MerchantStatisticsController { @ApiOperation(value = "确认结算", notes = "传入merchantStatisticsDTO") public R checkBalance(@RequestBody MerchantStatisticsDTO merchantStatisticsDTO) { String method = "############checkBalance: "; - log.info(method+"请求参数{}",merchantStatisticsDTO); - try{ + log.info(method + "请求参数{}", merchantStatisticsDTO); + try { List orderInfoIds = merchantStatisticsDTO.getOrderInfoIds(); - if(orderInfoIds.isEmpty()){ - log.warn(method+"订单集合为空 orderInfoIds={}",orderInfoIds); - return R.fail(405,"订单集合为空"); + if (orderInfoIds.isEmpty()) { + log.warn(method + "订单集合为空 orderInfoIds={}", orderInfoIds); + return R.fail(405, "订单集合为空"); } return statisticsOrderInfoService.checkBalance(merchantStatisticsDTO); - }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,"系统异常"); + } 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 + @PatchMapping("/real/{id}") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "计算实际费用", notes = "计算实际费用") + public R calculateRealCost(@PathVariable("id") Long id) { + String method = "############calculateRealCost: "; + log.info(method + "请求参数{}", id); + return R.status(statisticsOrderInfoService.calculateRealCost(id)); + } + } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/PackageFanoutListener.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/PackageFanoutListener.java index e183d8ad0..984a8bc4d 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/PackageFanoutListener.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/PackageFanoutListener.java @@ -1,12 +1,18 @@ package com.logpm.statistics.listener.mq; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.statistics.entity.StatisticsDistributionPackageEntity; import com.logpm.statistics.entity.StatisticsOrderInfoEntity; +import com.logpm.statistics.entity.StatisticsWarehousePackageEntity; import com.logpm.statistics.service.IStatisticsDistributionPackageService; import com.logpm.statistics.service.IStatisticsOrderInfoService; +import com.logpm.statistics.service.IStatisticsWarehousePackageService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.WorkNodeEnums; @@ -20,7 +26,12 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; @Slf4j @@ -29,6 +40,7 @@ import java.util.stream.Collectors; public class PackageFanoutListener { private final IStatisticsDistributionPackageService statisticsDistributionPackageService; + private final IStatisticsWarehousePackageService warehousePackageService; private final IStatisticsOrderInfoService statisticsOrderInfoService; @RabbitListener(bindings = @QueueBinding( @@ -38,23 +50,49 @@ public class PackageFanoutListener { @Transactional(rollbackFor = Exception.class) public void packageSignFanout(String msg) { JSONObject jsonObject = JSONUtil.parseObj(msg); + JSONObject trainNumberMap = jsonObject.getJSONObject("mainMap"); Integer workNode = jsonObject.getInt("workNode"); - if(WorkNodeEnums.SIGN_DIRECT_SHIPPER.getCode().equals(workNode) + if (WorkNodeEnums.SIGN_DIRECT_SHIPPER.getCode().equals(workNode) || WorkNodeEnums.SIGN_TRIPARTITE_TRANSFER_DEPART.getCode().equals(workNode) - || WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode().equals(workNode)){ + || WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode().equals(workNode)) { JSONArray orderPackageCodes = jsonObject.getJSONArray("orderPackageCodes"); List orderPackageCodeList = orderPackageCodes.toList(String.class); + // 配送签收时将签收时间写入 + if (WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode().equals(workNode)) { + List list = warehousePackageService.list(Wrappers.lambdaQuery().in(StatisticsWarehousePackageEntity::getOrderPackageCode, orderPackageCodeList)); + if (CollUtil.isNotEmpty(list)) { + for (StatisticsWarehousePackageEntity statisticsWarehousePackageEntity : list) { + statisticsWarehousePackageEntity.setSignTime(new Date()); + if (ObjectUtil.isNotEmpty(trainNumberMap)) { + if (trainNumberMap.containsKey(statisticsWarehousePackageEntity.getOrderPackageCode())) { + JSONObject entries = JSONUtil.parseObj(trainNumberMap.get(statisticsWarehousePackageEntity.getOrderPackageCode())); + if (ObjectUtil.isNotEmpty(entries) && entries.containsKey("warehouseEntryTimeEnd")) { + statisticsWarehousePackageEntity.setWarehouseEntryTimeEnd(DateUtil.parseDate(entries.getStr("warehouseEntryTimeEnd"))); + } + } + } + } + warehousePackageService.updateBatchById(list); + } + } - //如果是签收 + + // 如果是签收 List statisticsDistributionList = statisticsDistributionPackageService.findListByOrderPackageCodes(orderPackageCodeList); - //修改statisticsDistributionList中所有元素的isSign为1 + // 修改statisticsDistributionList中所有元素的isSign为1 Set orderInfoSet = new HashSet<>(); statisticsDistributionList.forEach(statisticsDistributionPackageEntity -> { + if (ObjectUtil.isNotEmpty(trainNumberMap)) { + if (trainNumberMap.containsKey(statisticsDistributionPackageEntity.getOrderPackageCode())) { + JSONObject entries = JSONUtil.parseObj(trainNumberMap.get(statisticsDistributionPackageEntity.getOrderPackageCode())); + statisticsDistributionPackageEntity.setTrainNumber(entries.getStr("trainNumber")); + } + } statisticsDistributionPackageEntity.setIsSign(1); statisticsDistributionPackageEntity.setSignTime(new Date()); String typeService = statisticsDistributionPackageEntity.getTypeService(); - if("3".equals(typeService)){ + if ("3".equals(typeService)) { statisticsDistributionPackageEntity.setRealDeliveryFee(BigDecimal.ZERO); statisticsDistributionPackageEntity.setRealDeliveryDistance(BigDecimal.ZERO); statisticsDistributionPackageEntity.setRealDeliveryCrossingFee(BigDecimal.ZERO); @@ -69,12 +107,12 @@ public class PackageFanoutListener { statisticsDistributionPackageService.updateBatchById(statisticsDistributionList); List statisticsList = statisticsDistributionPackageService.findListByOrderInfoSet(orderInfoSet); - //把statisticsList通过元素的orderInfoId进行map分组 + // 把statisticsList通过元素的orderInfoId进行map分组 Map> groupedStatisticsList = statisticsList.stream() .collect(Collectors.groupingBy(StatisticsDistributionPackageEntity::getOrderInfoId)); List orderInfoList = statisticsOrderInfoService.findListByOrderInfoIdsSet(orderInfoSet); - //把orderInfoList转成以id为key的map + // 把orderInfoList转成以id为key的map Map orderInfoMap = orderInfoList.stream() .collect(Collectors.toMap(StatisticsOrderInfoEntity::getId, statisticsOrderInfoEntity -> statisticsOrderInfoEntity)); @@ -85,20 +123,20 @@ public class PackageFanoutListener { List statisticsDistributionPackageEntities = groupedStatisticsList.get(orderInfoId); int allSize = statisticsDistributionPackageEntities.size(); - //过滤出statisticsDistributionPackageEntities中isSign等于0的元素 + // 过滤出statisticsDistributionPackageEntities中isSign等于0的元素 List unSignStatisticsDistributionPackageEntities = statisticsDistributionPackageEntities.stream() .filter(statisticsDistributionPackageEntity -> !statisticsDistributionPackageEntity.getIsSign().equals(1)) .collect(Collectors.toList()); int unSignSize = unSignStatisticsDistributionPackageEntities.size(); - if(unSignSize == 0){ - if(signStatus != 2){ + if (unSignSize == 0) { + if (signStatus != 2) { statisticsOrderInfoEntity.setSignStatus(2); } - }else{ - if(unSignSize != allSize){ - if(signStatus != 1){ + } else { + if (unSignSize != allSize) { + if (signStatus != 1) { statisticsOrderInfoEntity.setSignStatus(1); } } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java index 448139174..17c142cf6 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java @@ -26,4 +26,12 @@ public interface IStatisticsOrderInfoService extends BaseService findListByWaybillId(Long waybillId) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("waybill_id",waybillId); + queryWrapper.eq("waybill_id", waybillId); return baseMapper.selectList(queryWrapper); } @Override public List findListByOrderInfoIdsSet(Set orderInfoSet) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.in("id",orderInfoSet); + queryWrapper.in("id", orderInfoSet); return baseMapper.selectList(queryWrapper); } @@ -69,7 +99,7 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("order_info_id",orderInfoId); + queryWrapper.eq("order_info_id", orderInfoId); List list = changesRecordService.list(queryWrapper); - if(list.isEmpty()){ + if (list.isEmpty()) { return CollUtil.newArrayList(); } - //获取list中所有元素的id + // 获取list中所有元素的id List changesRecordIdList = list.stream().map(StatisticsChangesRecordEntity::getId).collect(Collectors.toList()); QueryWrapper changesPhotoEntityQueryWrapper = new QueryWrapper<>(); - changesPhotoEntityQueryWrapper.in("changes_record_id",changesRecordIdList); + changesPhotoEntityQueryWrapper.in("changes_record_id", changesRecordIdList); List changesPhotoEntityList = changesPhotoService.list(changesPhotoEntityQueryWrapper); - //把changesPhotoEntityList中的元素通过changesRecordId为key进行分组 + // 把changesPhotoEntityList中的元素通过changesRecordId为key进行分组 Map> groupedEntities = changesPhotoEntityList.stream() .collect(Collectors.groupingBy(StatisticsChangesPhotoEntity::getChangesRecordId)); @@ -100,7 +130,7 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl ls = new ArrayList<>(); list.forEach(statisticsChangesRecordEntity -> { StatisticsChangesRecordVO statisticsChangesRecordVO = new StatisticsChangesRecordVO(); - BeanUtil.copy(statisticsChangesRecordEntity,statisticsChangesRecordVO); + BeanUtil.copy(statisticsChangesRecordEntity, statisticsChangesRecordVO); List statisticsChangesPhotoEntities = groupedEntities.get(statisticsChangesRecordEntity.getId()); statisticsChangesRecordVO.setChangesPhotoEntityList(statisticsChangesPhotoEntities); ls.add(statisticsChangesRecordVO); @@ -111,7 +141,7 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl orderInfoIds = merchantStatisticsDTO.getOrderInfoIds(); - //查询对应订单的数据 + // 查询对应订单的数据 List list = baseMapper.findStatementListByOrderInfoIds(orderInfoIds); Set brands = new HashSet<>(); @@ -167,60 +197,59 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl destinationWarehouseNames = new HashSet<>(); Set payTypes = new HashSet<>(); Set payWays = new HashSet<>(); - AtomicReference totalCount = new AtomicReference<>(0);//总数量 + AtomicReference totalCount = new AtomicReference<>(0);// 总数量 - List totalWeights = new ArrayList<>();//总重量 - List totalVolumes = new ArrayList();//总体积 + List totalWeights = new ArrayList<>();// 总重量 + List totalVolumes = new ArrayList();// 总体积 List totalFees = new ArrayList(); List openFees = new ArrayList(); - List pickupFees = new ArrayList();//提货费 - List freightFees = new ArrayList();//运费 - List warehouseServiceFees = new ArrayList();//仓库服务费 - List warehouseFees = new ArrayList();//仓储费 - List warehouseManageFees = new ArrayList();//仓储管理费 - List warehouseSortingFees = new ArrayList();//仓储分拣费 - List warehouseOperatingFees = new ArrayList();//仓储操作费 - - List deliveryServiceFees = new ArrayList();//配送服务费 - List deliveryFees = new ArrayList();//配送费 - List deliveryLoadingFees = new ArrayList();//配送装卸费 - List deliverySortingFees = new ArrayList();//配送分拣费 - List deliveryUpfloorFees = new ArrayList();//配送上楼费 - List deliveryMoveFees = new ArrayList();//配送平移费 - List deliveryCrossingFees = new ArrayList();//超区费 - - List installFees = new ArrayList();//安装费 - List quotationFees = new ArrayList();//保价费 - List claimingValues = new ArrayList();//申明价值 - List otherFees = new ArrayList();//其他费 - List returnFees = new ArrayList();//回扣 - List thirdOprationFees = new ArrayList();//三方操作费 - List xPays = new ArrayList();//现付 - List dPays = new ArrayList();//到付 - List hPays = new ArrayList();//回付 - List yPays = new ArrayList();//月结 - + List pickupFees = new ArrayList();// 提货费 + List freightFees = new ArrayList();// 运费 + List warehouseServiceFees = new ArrayList();// 仓库服务费 + List warehouseFees = new ArrayList();// 仓储费 + List warehouseManageFees = new ArrayList();// 仓储管理费 + List warehouseSortingFees = new ArrayList();// 仓储分拣费 + List warehouseOperatingFees = new ArrayList();// 仓储操作费 + + List deliveryServiceFees = new ArrayList();// 配送服务费 + List deliveryFees = new ArrayList();// 配送费 + List deliveryLoadingFees = new ArrayList();// 配送装卸费 + List deliverySortingFees = new ArrayList();// 配送分拣费 + List deliveryUpfloorFees = new ArrayList();// 配送上楼费 + List deliveryMoveFees = new ArrayList();// 配送平移费 + List deliveryCrossingFees = new ArrayList();// 超区费 + + List installFees = new ArrayList();// 安装费 + List quotationFees = new ArrayList();// 保价费 + List claimingValues = new ArrayList();// 申明价值 + List otherFees = new ArrayList();// 其他费 + List returnFees = new ArrayList();// 回扣 + List thirdOprationFees = new ArrayList();// 三方操作费 + List xPays = new ArrayList();// 现付 + List dPays = new ArrayList();// 到付 + List hPays = new ArrayList();// 回付 + List yPays = new ArrayList();// 月结 list.forEach(statisticsOrderInfoVO -> { Long orderInfoId = statisticsOrderInfoVO.getOrderInfoId(); Integer confirmStatisticsOrder = statisticsOrderInfoVO.getConfirmStatisticsOrder(); - if(confirmStatisticsOrder.equals(1)){ - log.warn("############checkBalance: 订单id={} 已经确认对账",orderInfoId); - throw new CustomerException(405,"存在已经确认对账的订单"); + if (confirmStatisticsOrder.equals(1)) { + log.warn("############checkBalance: 订单id={} 已经确认对账", orderInfoId); + throw new CustomerException(405, "存在已经确认对账的订单"); } brands.add(statisticsOrderInfoVO.getBrand()); waybillNos.add(statisticsOrderInfoVO.getWaybillNo()); orderCodes.add(statisticsOrderInfoVO.getOrderNo()); - typeServices.add(DictBizCache.getValue(DictBizConstant.BASIC_FREIGHT_TYPE,statisticsOrderInfoVO.getTypeService())); + typeServices.add(DictBizCache.getValue(DictBizConstant.BASIC_FREIGHT_TYPE, statisticsOrderInfoVO.getTypeService())); String goodsName = statisticsOrderInfoVO.getGoodsName(); - if(goodsName.contains(",")){ + if (goodsName.contains(",")) { String[] split = goodsName.split(","); for (int i = 0; i < split.length; i++) { productGoods.add(split[i]); } - }else{ + } else { productGoods.add(goodsName); } shippers.add(statisticsOrderInfoVO.getShipper()); @@ -271,66 +300,66 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl statisticsOrderInfoEntities = baseMapper.selectList(new QueryWrapper().lambda().in(StatisticsOrderInfoEntity::getId, orderInfoIds)); statisticsOrderInfoEntities.forEach(statisticsOrderInfoEntity -> { statisticsOrderInfoEntity.setBalanceOrderNo(statisticsBalanceOrderInfoEntity.getBalanceOrderNo()); @@ -393,12 +422,449 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl().lambda().eq(StatisticsOrderInfoEntity::getId, id)); + if (ObjectUtil.isEmpty(orderInfoEntity)) { + log.warn("#############calculateRealCost: 订单信息不存在"); + throw new CustomerException("订单信息不存在"); + } + Long brandId = orderInfoEntity.getBrandId(); + Long consigneeId = orderInfoEntity.getConsigneeId(); + if (!ObjectUtil.isAllNotEmpty(brandId, consigneeId)) { + log.warn("#############calculateRealCost: 品牌{} 收货单位{}", brandId, consigneeId); + throw new CustomerException("结算单信息不完整,缺少品牌和收货单位,请联系系统管理员。"); + } + Date createTime = orderInfoEntity.getCreateTime(); + // 根据 品牌 收货单位 开单时间 获取价格体系 + PriceClientVO price = priceClient.price(BasicdatPriceApiVO.builder() + .clientId(consigneeId.toString()) + .brandId(brandId.toString()) + .time(DateUtil.formatTime(createTime)) + .build()); + if (ObjectUtil.isEmpty(price)) { + log.warn("#############calculateRealCost: 未维护价格,无法计算。"); + throw new CustomerException("未维护价格,无法计算。"); + } + // 查询包件数据 + List distributionPackageEntities = distributionPackageService.list(new QueryWrapper().lambda().eq(StatisticsDistributionPackageEntity::getOrderInfoId, id)); + // 校验是否全部配送完成 + if (distributionPackageEntities.stream().anyMatch(distributionPackageEntity -> distributionPackageEntity.getIsSign() == 0)) { + log.warn("#############calculateRealCost: 订单未全部配送完成,无法计算。"); + throw new CustomerException("订单未全部配送完成,无法计算。"); + } + List warehousePackageEntities = warehousePackageService.list(new QueryWrapper().lambda().eq(StatisticsWarehousePackageEntity::getOrderInfoId, id)); + PriceDispatchVO dispatch = price.getDispatch(); + PriceWarehouseVO warehouse = price.getWarehouse(); + + BasicdataPriceTemplateEntity template = price.getTemplate(); + if (ObjectUtil.isEmpty(template)) { + log.warn("#############calculateRealCost: 未维护模版,无法计算。"); + throw new CustomerException("未维护模版,无法计算。"); + } + String serviceType = template.getServiceType(); + Integer dispatchIsMinCost = template.getDispatchIsMinCost(); + + // 模版的服务类型 + String typeService = orderInfoEntity.getTypeService(); + if (StrUtil.isNotEmpty(serviceType)) { + // 模版是否有仓储 + if (StrUtil.contains(serviceType, "3")) { + if (CollUtil.isNotEmpty(warehousePackageEntities)) { + calculateWarehouseCost(warehouse, warehousePackageEntities, template); + } + } + // 模版是否有配送 + if (StrUtil.contains(serviceType, "4")) { + if (CollUtil.isNotEmpty(distributionPackageEntities)) { + calculateDispatchCost(template, typeService, distributionPackageEntities, dispatch, dispatchIsMinCost); + } + } + } + return Boolean.TRUE; + } + + private void calculateWarehouseCost(PriceWarehouseVO warehouse, List warehousePackageEntities, BasicdataPriceTemplateEntity template) { + if (ObjectUtil.isNotEmpty(warehouse)) { + // 取出 warehousePackageEntities 中的最小的入库时间 warehouseEntryTimeEnd 和最大的签收时间 signTime。两个时间相差的天数为在库周期 + // 过滤掉无用无用数据 + warehousePackageEntities.removeIf(entity -> entity.getWarehouseEntryTimeEnd() == null || entity.getSignTime() == null); + Long diff = null; + if (CollUtil.isNotEmpty(warehousePackageEntities)) { + // 找到最早的入库结束时间和最晚的签收时间 + StatisticsWarehousePackageEntity earliestEntity = Collections.min(warehousePackageEntities, Comparator.comparing(StatisticsWarehousePackageEntity::getWarehouseEntryTimeEnd)); + StatisticsWarehousePackageEntity latestEntity = Collections.max(warehousePackageEntities, Comparator.comparing(StatisticsWarehousePackageEntity::getSignTime)); + Date warehouseEntryTimeEnd = earliestEntity.getWarehouseEntryTimeEnd(); + Date signTime = latestEntity.getSignTime(); + // 计算在库周期(相差天数) + long diffInMillies = Math.abs(signTime.getTime() - warehouseEntryTimeEnd.getTime()); + diff = (diffInMillies + TimeUnit.DAYS.toMillis(1) - 1) / TimeUnit.DAYS.toMillis(1); + } + if (diff != null && diff > 0) { + for (StatisticsWarehousePackageEntity warehousePackageEntity : warehousePackageEntities) { + buildBasicWarehouseCost(warehousePackageEntity, warehouse, template, diff); + } + if (CollUtil.isNotEmpty(warehousePackageEntities)) { + // 计算配送服务费 realDeliveryServiceFee = 所有real费用的和 + warehousePackageEntities.stream().forEach(entity -> { + entity.setRealWarehouseServiceFee(entity.getRealWarehouseFee() + .add(entity.getRealWarehouseManageFee()) + .add(entity.getRealWarehouseSortingFee()) + .add(entity.getRealWarehouseOperatingFee()) + ); + }); + warehousePackageService.updateBatchById(warehousePackageEntities); + } + } + } + } + + private void calculateDispatchCost(BasicdataPriceTemplateEntity template, String typeService, List distributionPackageEntities, PriceDispatchVO dispatch, Integer dispatchIsMinCost) { + String dispatchPricingType = template.getDispatchPricingType(); + // 服务类型与模版的服务类型一致 + if (StrUtil.equals(dispatchPricingType, typeService)) { + // 计算基础配送费 + Integer dispatchIsByCategory = template.getDispatchIsByCategory(); + if (ObjectUtil.isNotEmpty(dispatch)) { + for (StatisticsDistributionPackageEntity statisticsDistributionPackageEntity : distributionPackageEntities) { + buildBasicDispatchCost(statisticsDistributionPackageEntity, dispatch, dispatchIsByCategory); + } + } + // 保底价 + // 1 是否有最低价 2 最低价的计费类型是按订单还是按配送任务 3 按价格还是件方重量 + if (ObjectUtil.equals(BooleanZeroOneEnums.YES.getCode(), dispatchIsMinCost)) { + // 1 订单 2 配送任务 + Integer dispatchMinCostMode = template.getDispatchMinCostMode(); + // 1 价格 2 件 3 方 4 重量 + Integer dispatchMinCostType = template.getDispatchMinCostType(); + // 最低价 + Double minCost = dispatch.getMinCost(); + // 加算价格 + Double additionalCost = dispatch.getAdditionalCost(); + if (ObjectUtil.equals(1, dispatchMinCostMode)) { + buildDispatchCostToPackage(dispatchMinCostType, distributionPackageEntities, minCost, additionalCost); + } else if (ObjectUtil.equals(2, dispatchMinCostMode)) { + Map> map = distributionPackageEntities.stream().collect(Collectors.groupingBy(StatisticsDistributionPackageEntity::getTrainNumber)); + if (CollUtil.isNotEmpty(map)) { + for (Map.Entry> entry : map.entrySet()) { + List value = entry.getValue(); + buildDispatchCostToPackage(dispatchMinCostType, value, minCost, additionalCost); + } + } + } + // 保存配送包件信息 + if (CollUtil.isNotEmpty(distributionPackageEntities)) { + // 计算配送服务费 realDeliveryServiceFee = 所有real费用的和 + distributionPackageEntities.stream().forEach(entity -> { + entity.setRealDeliveryServiceFee(entity.getRealDeliveryFee() + .add(entity.getRealDeliveryLoadingFee()) + .add(entity.getRealDeliveryMoveFee()) + .add(entity.getRealDeliveryCrossingFee()) + .add(entity.getRealDeliverySortingFee()) + .add(entity.getRealDeliveryUpfloorFee()) + .add(entity.getRealDeliveryDistance())); + }); + distributionPackageService.saveOrUpdateBatch(distributionPackageEntities); + } + } + } + } + + private void buildBasicDispatchCost(StatisticsDistributionPackageEntity statisticsDistributionPackageEntity, PriceDispatchVO dispatch, Integer dispatchIsByCategory) { + List pieceCategory = dispatch.getPieceCategory(); + if (CollUtil.isNotEmpty(pieceCategory)) { + List pieceList = pieceCategory; + if (1 == dispatchIsByCategory) { + pieceList = pieceCategory.stream().filter(priceDispatchBasicVO -> { + return StrUtil.equals(String.valueOf(priceDispatchBasicVO.getCategoryId()), statisticsDistributionPackageEntity.getProductId()); + }).collect(Collectors.toList()); + } + if (CollUtil.isNotEmpty(pieceList)) { + PriceDispatchBasicVO priceDispatchBasicVO = pieceList.get(0); + // TODO 如果是遗留件 按遗留件单价来计算 目前只有欧派有遗留件 + Double price1 = priceDispatchBasicVO.getPrice(); + // 配送费 = 按件单价 + statisticsDistributionPackageEntity.setRealDeliveryFee(NumberUtil.toBigDecimal(price1)); + } + } + + List cubeCategory = dispatch.getCubeCategory(); + if (CollUtil.isNotEmpty(cubeCategory)) { + List cubeList = cubeCategory; + if (1 == dispatchIsByCategory) { + cubeList = cubeCategory.stream().filter(priceDispatchBasicVO -> { + return StrUtil.equals(String.valueOf(priceDispatchBasicVO.getCategoryId()), statisticsDistributionPackageEntity.getProductId()); + }).collect(Collectors.toList()); + } + if (CollUtil.isNotEmpty(cubeList)) { + PriceDispatchBasicVO priceDispatchBasicVO = cubeList.get(0); + // TODO 如果是遗留件 按遗留件单价来计算 目前只有欧派有遗留件 + Double price1 = priceDispatchBasicVO.getPrice(); + BigDecimal totalVolume = statisticsDistributionPackageEntity.getTotalVolume(); + // 配送费 = 按方单价 * 体积 + if (ObjectUtil.isNotEmpty(totalVolume)) { + statisticsDistributionPackageEntity.setRealDeliveryFee(NumberUtil.toBigDecimal(price1).multiply(totalVolume)); + } + } + } + + List weightCategory = dispatch.getWeightCategory(); + if (CollUtil.isNotEmpty(weightCategory)) { + List weightList = weightCategory; + if (1 == dispatchIsByCategory) { + weightList = weightCategory.stream().filter(priceDispatchBasicVO -> { + return StrUtil.equals(String.valueOf(priceDispatchBasicVO.getCategoryId()), statisticsDistributionPackageEntity.getProductId()); + }).collect(Collectors.toList()); + } + if (CollUtil.isNotEmpty(weightList)) { + PriceDispatchBasicVO priceDispatchBasicVO = weightList.get(0); + // TODO 如果是遗留件 按遗留件单价来计算 目前只有欧派有遗留件 + Double price1 = priceDispatchBasicVO.getPrice(); + BigDecimal totalWeight = statisticsDistributionPackageEntity.getTotalWeight(); + // 配送费 = 按重量单价 * 重量 + if (ObjectUtil.isNotEmpty(totalWeight)) { + statisticsDistributionPackageEntity.setRealDeliveryFee(NumberUtil.toBigDecimal(price1).multiply(totalWeight)); + } + } + } + } + + private void buildBasicWarehouseCost(StatisticsWarehousePackageEntity statisticsDistributionPackageEntity, PriceWarehouseVO warehouseVO, BasicdataPriceTemplateEntity template, Long diff) { + // 1 按件 2 按方 3 按重量 + Integer warehousePricingType = template.getWarehousePricingType(); + // 1 分段式 2 最高标准 + Integer warehousePricingMode = template.getWarehousePricingMode(); + // 计费标准 1 按件/天 2 按件/月 + Integer warehouseCalculationBasis = template.getWarehouseCalculationBasis(); + if (!ObjectUtil.isAllNotEmpty(warehousePricingType, warehousePricingMode, warehouseCalculationBasis)) { + log.warn("模版参数不全不计算"); + return; + } + // 仓储费是否按品类计费 1 是 0 否 + Integer warehouseIsByCategory = template.getWarehouseIsByCategory(); + List catergory = warehouseVO.getCatergory(); + if (CollUtil.isNotEmpty(catergory)) { + List pieceList = catergory; + if (1 == warehouseIsByCategory) { + pieceList = catergory.stream().filter(priceDispatchBasicVO -> { + return StrUtil.equals(String.valueOf(priceDispatchBasicVO.getCategoryId()), statisticsDistributionPackageEntity.getProductId()); + }).collect(Collectors.toList()); + } + if (CollUtil.isNotEmpty(pieceList)) { + BigDecimal totalVolume = statisticsDistributionPackageEntity.getTotalVolume(); + BigDecimal totalWeight = statisticsDistributionPackageEntity.getTotalWeight(); + PriceWarehouseBasicVO priceDispatchBasicVO = pieceList.get(0); + Double withinThirtyPrice = priceDispatchBasicVO.getWithinThirtyPrice(); + Double betweenThirtySixtyPrice = priceDispatchBasicVO.getBetweenThirtySixtyPrice(); + Double beyondSixtyPrice = priceDispatchBasicVO.getBeyondSixtyPrice(); + Double beyondNinetyPrice = priceDispatchBasicVO.getBeyondNinetyPrice(); + // 计算仓储费 + if (ObjectUtil.equals(1, warehousePricingType)) { + if (ObjectUtil.equals(1, warehousePricingMode)) { + fenDuan(statisticsDistributionPackageEntity, diff, warehouseCalculationBasis, withinThirtyPrice, BigDecimal.ONE, betweenThirtySixtyPrice, beyondSixtyPrice, beyondNinetyPrice); + } else if (ObjectUtil.equals(2, warehousePricingMode)) { + zuiGao(statisticsDistributionPackageEntity, diff, warehouseCalculationBasis, withinThirtyPrice, BigDecimal.ONE, betweenThirtySixtyPrice, beyondSixtyPrice, beyondNinetyPrice); + } + } else if (ObjectUtil.equals(2, warehousePricingType)) { + if (ObjectUtil.equals(1, warehousePricingMode)) { + fenDuan(statisticsDistributionPackageEntity, diff, warehouseCalculationBasis, withinThirtyPrice, totalVolume, betweenThirtySixtyPrice, beyondSixtyPrice, beyondNinetyPrice); + } else if (ObjectUtil.equals(2, warehousePricingMode)) { + zuiGao(statisticsDistributionPackageEntity, diff, warehouseCalculationBasis, withinThirtyPrice, totalVolume, betweenThirtySixtyPrice, beyondSixtyPrice, beyondNinetyPrice); + } + } else if (ObjectUtil.equals(3, warehousePricingType)) { + if (ObjectUtil.equals(1, warehousePricingMode)) { + fenDuan(statisticsDistributionPackageEntity, diff, warehouseCalculationBasis, withinThirtyPrice, totalWeight, betweenThirtySixtyPrice, beyondSixtyPrice, beyondNinetyPrice); + } else if (ObjectUtil.equals(2, warehousePricingMode)) { + zuiGao(statisticsDistributionPackageEntity, diff, warehouseCalculationBasis, withinThirtyPrice, totalWeight, betweenThirtySixtyPrice, beyondSixtyPrice, beyondNinetyPrice); + } + } + Integer warehouseIsAddFee = template.getWarehouseIsAddFee(); + if (ObjectUtil.equals(BooleanZeroOneEnums.YES.getCode(), warehouseIsAddFee)) { + // 是否有管理费 + Integer warehouseIsManageFee = template.getWarehouseIsManageFee(); + // 是否有分拣费 + Integer warehouseIsSortFee = template.getWarehouseIsSortFee(); + // 是否有操作费 + Integer warehouseIsOperatingFee = template.getWarehouseIsOperateFee(); + // 是否按品类附加费 + Integer warehouseIsCategorySubjoin = template.getWarehouseIsCategorySubjoin(); + List additionalCategory = warehouseVO.getAdditionalCategory(); + if (CollUtil.isNotEmpty(additionalCategory)) { + List additionalList = additionalCategory; + if (ObjectUtil.equals(BooleanZeroOneEnums.YES.getCode(), warehouseIsCategorySubjoin)) { + additionalList = additionalCategory.stream().filter(additionalVO -> { + return StrUtil.equals(String.valueOf(additionalVO.getCategoryId()), statisticsDistributionPackageEntity.getProductId()); + }).collect(Collectors.toList()); + } + if (CollUtil.isNotEmpty(additionalList)) { + PriceWarehouseAdditionalVO additionalVO = additionalList.get(0); + Double operatePrice = additionalVO.getOperatePrice(); + Double managementPrice = additionalVO.getWarehouseManagementPrice(); + Double warehouseSortPrice = additionalVO.getWarehouseSortPrice(); + if (ObjectUtil.equals(BooleanZeroOneEnums.YES.getCode(), warehouseIsManageFee)) { + statisticsDistributionPackageEntity.setRealWarehouseManageFee(NumberUtil.toBigDecimal(managementPrice)); + } + if (ObjectUtil.equals(BooleanZeroOneEnums.YES.getCode(), warehouseIsSortFee)) { + statisticsDistributionPackageEntity.setRealWarehouseSortingFee(NumberUtil.toBigDecimal(warehouseSortPrice)); + } + if (ObjectUtil.equals(BooleanZeroOneEnums.YES.getCode(), warehouseIsOperatingFee)) { + statisticsDistributionPackageEntity.setRealWarehouseOperatingFee(NumberUtil.toBigDecimal(operatePrice)); + } + } + } + } + } + } + } + + private static void zuiGao(StatisticsWarehousePackageEntity statisticsDistributionPackageEntity, Long diff, Integer warehouseCalculationBasis, Double withinThirtyPrice, BigDecimal number, Double betweenThirtySixtyPrice, Double beyondSixtyPrice, Double beyondNinetyPrice) { + if (ObjectUtil.equals(1, warehouseCalculationBasis)) { + // 方 最高 天 + BigDecimal realWarehouseFee = BigDecimal.ZERO; + if (diff <= 30) { + realWarehouseFee = NumberUtil.mul(withinThirtyPrice, diff, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("30天内"); + } else if (diff <= 60) { + realWarehouseFee = NumberUtil.mul(betweenThirtySixtyPrice, diff, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("31-60天"); + } else if (diff <= 90) { + realWarehouseFee = NumberUtil.mul(beyondSixtyPrice, diff, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("61-90天"); + } else if (diff > 90) { + realWarehouseFee = NumberUtil.mul(beyondNinetyPrice, diff, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("91天以上"); + } + statisticsDistributionPackageEntity.setRealWarehouseFee(realWarehouseFee); + } else if (ObjectUtil.equals(2, warehouseCalculationBasis)) { + // 方 最高 月 + BigDecimal realWarehouseFee = BigDecimal.ZERO; + if (diff <= 30) { + realWarehouseFee = NumberUtil.mul(withinThirtyPrice, 1, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("30天内"); + } else if (diff <= 60) { + realWarehouseFee = NumberUtil.mul(betweenThirtySixtyPrice, 2, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("31-60天"); + } else if (diff <= 90) { + realWarehouseFee = NumberUtil.mul(beyondSixtyPrice, 3, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("61-90天"); + } else if (diff > 90) { + long time = diff - 90; + // time 以 30 天为维度 计算 ,向上取整 + Double ceil = Math.ceil(time / 30); + realWarehouseFee = NumberUtil.mul(beyondNinetyPrice, NumberUtil.add(ceil, 3, BigDecimal.ZERO), number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("91天以上"); + } + statisticsDistributionPackageEntity.setRealWarehouseFee(realWarehouseFee); + } + } + + private static void fenDuan(StatisticsWarehousePackageEntity statisticsDistributionPackageEntity, Long diff, Integer warehouseCalculationBasis, Double withinThirtyPrice, BigDecimal number, Double betweenThirtySixtyPrice, Double beyondSixtyPrice, Double beyondNinetyPrice) { + if (ObjectUtil.equals(1, warehouseCalculationBasis)) { + // 方 分段 天 + BigDecimal realWarehouseFee = BigDecimal.ZERO; + if (diff <= 30) { + realWarehouseFee = NumberUtil.mul(withinThirtyPrice, diff, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("30天内"); + } else if (diff <= 60) { + realWarehouseFee = NumberUtil.add( + NumberUtil.mul(withinThirtyPrice, 30, number), + NumberUtil.mul(betweenThirtySixtyPrice, NumberUtil.sub(diff, 30, BigDecimal.ZERO), number) + ); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("31-60天"); + } else if (diff <= 90) { + realWarehouseFee = NumberUtil.add( + NumberUtil.mul(withinThirtyPrice, 30, number), + NumberUtil.mul(betweenThirtySixtyPrice, 30, number), + NumberUtil.mul(beyondSixtyPrice, NumberUtil.sub(diff, 60, BigDecimal.ZERO), number) + ); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("61-90天"); + } else if (diff > 90) { + realWarehouseFee = NumberUtil.add( + NumberUtil.mul(withinThirtyPrice, 30, number), + NumberUtil.mul(betweenThirtySixtyPrice, 30, number), + NumberUtil.mul(beyondSixtyPrice, 30, number), + NumberUtil.mul(beyondNinetyPrice, NumberUtil.sub(diff, 90, BigDecimal.ZERO), number) + ); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("91天以上"); + } + statisticsDistributionPackageEntity.setRealWarehouseFee(realWarehouseFee); + } else if (ObjectUtil.equals(2, warehouseCalculationBasis)) { + // 方 分段 月 + BigDecimal realWarehouseFee = BigDecimal.ZERO; + if (diff <= 30) { + realWarehouseFee = NumberUtil.mul(withinThirtyPrice, number); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("30天内"); + } else if (diff <= 60) { + realWarehouseFee = NumberUtil.mul(number, NumberUtil.add(withinThirtyPrice, betweenThirtySixtyPrice, BigDecimal.ZERO)); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("31-60天"); + } else if (diff <= 90) { + realWarehouseFee = NumberUtil.mul(number, NumberUtil.add(withinThirtyPrice, betweenThirtySixtyPrice, beyondSixtyPrice)); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("61-90天"); + } else if (diff > 90) { + long time = diff - 90; + // time 以 30 天为维度 计算 ,向上取整 + Double ceil = Math.ceil(time / 30); + realWarehouseFee = NumberUtil.mul(number, NumberUtil.add(withinThirtyPrice, betweenThirtySixtyPrice, beyondSixtyPrice, NumberUtil.mul(ceil, beyondNinetyPrice))); + statisticsDistributionPackageEntity.setRealWarehouseFeeInterval("91天以上"); + } + statisticsDistributionPackageEntity.setRealWarehouseFee(realWarehouseFee); + } + } + + private void buildDispatchCostToPackage(Integer dispatchMinCostType, List distributionPackageEntities, Double minCost, Double additionalCost) { + if (ObjectUtil.equals(1, dispatchMinCostType)) { + // 计算总价 + BigDecimal sumDeliveryFee = distributionPackageEntities.stream().map(StatisticsDistributionPackageEntity::getRealDeliveryFee).reduce(BigDecimal.ZERO, BigDecimal::add); + // 总价和最低价 取大的值 + BigDecimal max = NumberUtil.max(sumDeliveryFee, NumberUtil.toBigDecimal(minCost)); + // 分摊价格个到包件上 + // max - sumDeliveryFee 大于 0 则分摊价格个到包件上 + if (max.compareTo(sumDeliveryFee) > 0) { + // 分摊价格个到包件上 (原单价 + (max - sumDeliveryFee)/件数) + BigDecimal divide = max.subtract(sumDeliveryFee).divide(NumberUtil.toBigDecimal(distributionPackageEntities.size()), 2, BigDecimal.ROUND_HALF_UP); + distributionPackageEntities.forEach(statisticsDistributionPackageEntity -> { + statisticsDistributionPackageEntity.setRealDeliveryFee(statisticsDistributionPackageEntity.getRealDeliveryFee().add(divide)); + }); + } + } else if (ObjectUtil.equals(2, dispatchMinCostType)) { + // 总件数 + int size = distributionPackageEntities.size(); + // 总件数 < 最低价 则计算保底价 + if (size < minCost) { + // 分摊到包件上 原单价 + 加算价格 + distributionPackageEntities.forEach(statisticsDistributionPackageEntity -> { + statisticsDistributionPackageEntity.setRealDeliveryFee(statisticsDistributionPackageEntity.getRealDeliveryFee().add(NumberUtil.toBigDecimal(additionalCost))); + }); + } + } else if (ObjectUtil.equals(3, dispatchMinCostType)) { + // 总体积 + BigDecimal totalVolume = distributionPackageEntities.stream().map(StatisticsDistributionPackageEntity::getTotalVolume).reduce(BigDecimal.ZERO, BigDecimal::add); + // 总件数 < 最低价 则计算保底价 + if (NumberUtil.compare(NumberUtil.toDouble(totalVolume), minCost) < 0) { + // 分摊到包件上 原单价 + 加算价格 + distributionPackageEntities.forEach(statisticsDistributionPackageEntity -> { + statisticsDistributionPackageEntity.setRealDeliveryFee(statisticsDistributionPackageEntity.getRealDeliveryFee().add(NumberUtil.toBigDecimal(additionalCost))); + }); + } + } else if (ObjectUtil.equals(4, dispatchMinCostType)) { + // 总重量 + BigDecimal totalWeight = distributionPackageEntities.stream().map(StatisticsDistributionPackageEntity::getTotalWeight).reduce(BigDecimal.ZERO, BigDecimal::add); + // 总件数 < 最低价 则计算保底价 + if (NumberUtil.compare(NumberUtil.toDouble(totalWeight), minCost) < 0) { + // 分摊到包件上 原单价 + 加算价格 + distributionPackageEntities.forEach(statisticsDistributionPackageEntity -> { + statisticsDistributionPackageEntity.setRealDeliveryFee(statisticsDistributionPackageEntity.getRealDeliveryFee().add(NumberUtil.toBigDecimal(additionalCost))); + }); + } + } + } + private void updateOrderChangesFee(Long orderInfoId) { StatisticsOrderInfoEntity statisticsOrderInfoEntity = baseMapper.selectById(orderInfoId); - if(Objects.isNull(statisticsOrderInfoEntity)){ - log.warn("#############updateOrderChangesFee: 订单信息不存在 statisticsOrderInfoEntity={}",statisticsOrderInfoEntity); - throw new CustomerException(405,"订单信息不存在"); + if (Objects.isNull(statisticsOrderInfoEntity)) { + log.warn("#############updateOrderChangesFee: 订单信息不存在 statisticsOrderInfoEntity={}", statisticsOrderInfoEntity); + throw new CustomerException(405, "订单信息不存在"); } BigDecimal changesFee = changesRecordService.findChangesFeeByOrderInfoId(orderInfoId); @@ -414,102 +880,102 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl ls = new ArrayList<>(); List orderPackageCodes = new ArrayList<>(); final Integer[] workNode = {null}; - + Map map = new HashMap<>(); addPackageTrackLogList.forEach(jsonObject -> { WarehousePackageTrackLogEntity warehousePackageTrackLogEntity = jsonObject.toJavaObject(WarehousePackageTrackLogEntity.class); + JSONObject js = new JSONObject(); + if (jsonObject.containsKey("trainNumber")) { + js.put("trainNumber", jsonObject.getString("trainNumber")); + } + if(jsonObject.containsKey("warehouseEntryTimeEnd")){ + js.put("warehouseEntryTimeEnd", jsonObject.getString("warehouseEntryTimeEnd")); + } + map.put(warehousePackageTrackLogEntity.getOrderPackageCode(), js); orderPackageCodes.add(warehousePackageTrackLogEntity.getOrderPackageCode()); - if (Objects.isNull(workNode[0])){ + if (Objects.isNull(workNode[0])) { workNode[0] = warehousePackageTrackLogEntity.getWorkNode(); } ls.add(warehousePackageTrackLogEntity); }); - packageTrackLogAsyncService.addBatchPackageTrackLog(ls, orderPackageCodes, workNode[0]); + packageTrackLogAsyncService.addBatchPackageTrackLog(ls, orderPackageCodes, workNode[0], map); } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java index 0bec90e8d..76b1d080c 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java @@ -1,15 +1,17 @@ package com.logpm.trunkline.service; +import com.alibaba.fastjson.JSONObject; import com.logpm.warehouse.entity.WarehousePackageTrackLogEntity; import java.util.List; +import java.util.Map; public interface IPackageTrackLogAsyncService { void addPackageTrackLog(String tenantId, Long userId, Long deptId, String nickName, List orderPackageCodes, Long warehouseId, String warehouseName, Integer workNode, String content); - void addBatchPackageTrackLog(List addPackageTrackLogList, List orderPackageCodes, Integer code); + void addBatchPackageTrackLog(List addPackageTrackLogList, List orderPackageCodes, Integer code, Map map); - void sendPackageWorkNodeFanout(List orderPackageCodes,Integer workNode,Long warehouseId); + void sendPackageWorkNodeFanout(List orderPackageCodes, Integer workNode, Long warehouseId, Map map); } 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 64746a4c3..a27003cc2 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 @@ -1,11 +1,13 @@ package com.logpm.trunkline.service; +import com.alibaba.fastjson.JSONObject; import com.logpm.trunkline.entity.TrunklineWaybillPackageEntity; 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; public interface ITrunklineWaybillPackageService extends BaseService { void saveList(List list, WarehouseWaybillEntity waybillEntity); @@ -13,6 +15,6 @@ public interface ITrunklineWaybillPackageService extends BaseService orderPackageCodes, Integer workNode,Long warehouseId); + void updatePackageStatus(List orderPackageCodes, Integer workNode, Long warehouseId, Map map); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java index e83e6c1a5..fda6216ef 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java @@ -1,11 +1,13 @@ package com.logpm.trunkline.service.impl; +import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSONObject; import com.logpm.trunkline.service.IPackageTrackLogAsyncService; import com.logpm.trunkline.service.ISendFanoutService; import com.logpm.trunkline.service.ITrunklineWaybillPackageService; import com.logpm.warehouse.entity.WarehousePackageTrackLogEntity; import com.logpm.warehouse.feign.IWarehousePackageTrackLogClient; +import io.prometheus.client.CollectorRegistry; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.annotations.LogpmAsync; @@ -16,6 +18,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; @Service @Slf4j @@ -25,6 +28,7 @@ public class PackageTrackLogAsyncServiceImpl implements IPackageTrackLogAsyncSer private final IWarehousePackageTrackLogClient warehousePackageTrackLogClient; private final ITrunklineWaybillPackageService waybillPackageService; private final ISendFanoutService sendFanoutService; + private final CollectorRegistry collectorRegistry; @LogpmAsync("asyncExecutor") @Override @@ -51,26 +55,29 @@ public class PackageTrackLogAsyncServiceImpl implements IPackageTrackLogAsyncSer } warehousePackageTrackLogClient.addLogList(list); - waybillPackageService.updatePackageStatus(orderPackageCodes, workNode,warehouseId); + waybillPackageService.updatePackageStatus(orderPackageCodes, workNode,warehouseId, null); } @LogpmAsync("asyncExecutor") @Override - public void addBatchPackageTrackLog(List addPackageTrackLogList, List orderPackageCodes, Integer workNode) { + public void addBatchPackageTrackLog(List addPackageTrackLogList, List orderPackageCodes, Integer workNode, Map map) { warehousePackageTrackLogClient.addLogList(addPackageTrackLogList); WarehousePackageTrackLogEntity warehousePackageTrackLogEntity = addPackageTrackLogList.get(0); Long warehouseId = warehousePackageTrackLogEntity.getWarehouseId(); - waybillPackageService.updatePackageStatus(orderPackageCodes, workNode,warehouseId); + waybillPackageService.updatePackageStatus(orderPackageCodes, workNode,warehouseId, map); } @LogpmAsync("asyncExecutor") @Override - public void sendPackageWorkNodeFanout(List orderPackageCodes,Integer workNode,Long warehouseId) { + public void sendPackageWorkNodeFanout(List orderPackageCodes, Integer workNode, Long warehouseId, Map map) { JSONObject jsonObject = new JSONObject(); jsonObject.put("orderPackageCodes",orderPackageCodes); jsonObject.put("workNode",workNode); jsonObject.put("warehouseId",warehouseId); + if(CollUtil.isNotEmpty(map)){ + jsonObject.put("mainMap",map); + } FanoutMsg build = FanoutMsg.builder().msg(jsonObject.toJSONString()) .exchange(FanoutConstants.trunkline.PACKAGNODE.EXCHANGE).build(); 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 fb885e124..a092d6819 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 @@ -4757,7 +4757,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl orderPackageCodes, Integer workNode,Long warehouseId) { + public void updatePackageStatus(List orderPackageCodes, Integer workNode, Long warehouseId, Map map) { Integer packageStatus = null; if(WorkNodeEnums.INITIAL_WAREHOUSE_DEPART.getCode().equals(workNode)){ @@ -189,7 +190,7 @@ public class TrunklineWaybillPackageServiceImpl extends BaseServiceImpl