Browse Source

feat(all): 结算计算配送费和仓储费

master
zhaoqiaobo 10 months ago
parent
commit
7e398c38d1
  1. 2
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java
  2. 2
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/BasicdatPriceApiVO.java
  3. 6
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsDistributionPackageEntity.java
  4. 4
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsWarehousePackageEntity.java
  5. 2
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java
  6. 4
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java
  7. 159
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java
  8. 19
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/MerchantStatisticsController.java
  9. 40
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/PackageFanoutListener.java
  10. 8
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java
  11. 470
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java
  12. 14
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklinePackageTrackLogClient.java
  13. 6
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IPackageTrackLogAsyncService.java
  14. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillPackageService.java
  15. 15
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/PackageTrackLogAsyncServiceImpl.java
  16. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java
  17. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillPackageServiceImpl.java

2
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);
}

2
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;

6
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;
/**
* 件数
*/

4
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;

2
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);
}

4
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<BasicdataPriceMap
// 根据客户信息查找价格
String clientId = param.getClientId();
String brandId = param.getBrandId();
if (!ObjectUtil.isAllNotEmpty(clientId, brandId)) {
return null;
}
BasicdataPriceEntity priceEntity = null;
LambdaQueryWrapper<BasicdataPriceEntity> wrapper = Wrappers.<BasicdataPriceEntity>lambdaQuery()
.eq(BasicdataPriceEntity::getClientId, clientId)

159
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 BaseServiceImpl<Distribution
warehouseUpdownTypeClient.downPackageOrDelTray(loadscanEntity.getOrderPackageCode(), myCurrentWarehouse.getId(), "签收下架解托");
//维护订单状态
String content = "包件在"+myCurrentWarehouse.getName()+"由"+loadscanEntity.getSigningUser()+"扫描签收,装车方式:扫描装车,配送车次号:"+deliveryListEntity.getTrainNumber()+"预约任务号:"+distributionReservationEntity.getReservationCode();
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode());
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode(), deliveryListEntity.getTrainNumber(),parcelListEntity.getWarehouseEntryTimeEnd());
aaa.add(trunklinePackageTrackLog);
orderPackageCodes.add(loadscanEntity.getOrderPackageCode());
} else {
@ -2576,7 +2674,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
packageLockIds.add(distributionLoadscanEntity.getPackageId());
String content = "包件在"+myCurrentWarehouse.getName()+"由"+distributionLoadscanEntity.getSigningUser()+"扫描签收,装车方式:补录装车,配送车次号:"+deliveryListEntity.getTrainNumber()+"预约任务号:"+distributionReservationEntity.getReservationCode();
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode());
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode(), deliveryListEntity.getTrainNumber(), parcelListEntity.getWarehouseEntryTimeEnd());
aaa.add(trunklinePackageTrackLog);
orderPackageCodes.add(distributionLoadscanEntity.getOrderPackageCode());
}
@ -2759,12 +2857,13 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
String content = "";
if (Func.isNotEmpty(collect) && collect.size() == 1) {
//存在则查询该包件是否进行装车
DistributionParcelListEntity parcelListEntity = collect.get(0);
JSONObject trunklinePackageTrackLog= new JSONObject();
DistributionLoadscanEntity loadscanEntity = distributionLoadscanMapper.selectOne(Wrappers.<DistributionLoadscanEntity>query().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<Distribution
warehouseUpdownTypeClient.downPackageOrDelTray(loadscanEntity.getOrderPackageCode(), myCurrentWarehouse.getId(), "签收下架解托");
content = "包件在"+myCurrentWarehouse.getName()+"由"+AuthUtil.getNickName()+"后台签收,装车方式:扫描装车,配送车次号:"+deliveryListEntity.getTrainNumber()+"预约任务号:"+distributionReservationEntity.getReservationCode();
try {
trunklinePackageTrackLog =handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),loadscanEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode());
trunklinePackageTrackLog =handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),loadscanEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode(), deliveryListEntity.getTrainNumber(), parcelListEntity.getWarehouseEntryTimeEnd());
}catch (Exception e){
log.error("装车日志数据错误",e);
}
@ -2835,20 +2934,20 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
}
Date loadScanTime = new Date();
distributionLoadscanEntity.setScanTime(simpleDateFormat.format(loadScanTime));
distributionLoadscanEntity.setPackageId(collect.get(0).getId());
distributionLoadscanEntity.setOrderPackageCode(collect.get(0).getOrderPackageCode());
distributionLoadscanEntity.setPackageId(parcelListEntity.getId());
distributionLoadscanEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode());
Date signingTime = new Date(System.currentTimeMillis() + (1000 * 60));
distributionLoadscanEntity.setSigningTime(simpleDateFormat.format(signingTime));
distributionLoadscanEntity.setReceivedQuantity(collect.get(0).getQuantity());
distributionLoadscanEntity.setReceivedQuantity(parcelListEntity.getQuantity());
distributionLoadscanEntity.setReservationId(distrilbutionloadingscanDTO.getReservationId());
distributionLoadscanEntity.setIsSignfor(2);
distributionLoadscanEntity.setIsInsert(2);
distributionLoadscanEntity.setWarehouseId(myCurrentWarehouse.getId());
distributionLoadscanEntity.setWarehouseName(myCurrentWarehouse.getName());
distributionLoadscanEntity.setSignforState(2);
distributionLoadscanEntity.setPackageNub(collect.get(0).getQuantity());
distributionLoadscanEntity.setOrderId(collect.get(0).getStockArticleId());
distributionLoadscanEntity.setLoadedNub(collect.get(0).getQuantity());
distributionLoadscanEntity.setPackageNub(parcelListEntity.getQuantity());
distributionLoadscanEntity.setOrderId(parcelListEntity.getStockArticleId());
distributionLoadscanEntity.setLoadedNub(parcelListEntity.getQuantity());
distributionLoadscanEntity.setReservationId(distrilbutionloadingscanDTO.getReservationId());
distributionLoadscanEntity.setDeliveryId(distrilbutionloadingscanDTO.getDeliveryId());
distributionLoadscanEntity.setScanUser(AuthUtil.getUser().getNickName());
@ -2874,21 +2973,21 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
// 包件解托下架
content = "包件在"+myCurrentWarehouse.getName()+"由"+AuthUtil.getNickName()+"后台签收,装车方式:补录装车,配送车次号:"+deliveryListEntity.getTrainNumber()+"预约任务号:"+distributionReservationEntity.getReservationCode();
try {
trunklinePackageTrackLog =handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),distributionLoadscanEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode());
trunklinePackageTrackLog =handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),distributionLoadscanEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode(), deliveryListEntity.getTrainNumber(), parcelListEntity.getWarehouseEntryTimeEnd());
}catch (Exception e){
log.error("装车日志数据错误",e);
}
aaa.add(trunklinePackageTrackLog);
}
//修改包件状态为装车、签收
DistributionParcelListEntity updatePackage = collect.get(0);
DistributionParcelListEntity updatePackage = parcelListEntity;
updatePackage.setOrderPackageLoadingStatus(OrderPackageLoadingStatusConstant.yizhuangche.getValue());
updatePackage.setOrderPackageStatus(OrderPackageStatusConstant.yiqianshou.getValue());
distributionParcelListService.updateById(updatePackage);
//维护签收包件状态
distributionStockArticleService.maintenanceOrderInfo(collect.get(0).getOrderCode(), myCurrentWarehouse.getId());
distributionStockArticleService.maintenanceOrderInfo(parcelListEntity.getOrderCode(), myCurrentWarehouse.getId());
//推送信息至工厂
distributionAsyncService.sendFactory(collect.get(0), simpleDateFormat.format(new Date()), distributionReservationEntity.getId(), distributionReservationEntity.getReservationCode(), myCurrentWarehouse.getName(), nickName);
distributionAsyncService.sendFactory(parcelListEntity, simpleDateFormat.format(new Date()), distributionReservationEntity.getId(), distributionReservationEntity.getReservationCode(), myCurrentWarehouse.getName(), nickName);
//收集包件
orderpackages.add(updatePackage.getOrderPackageCode());
} else {
@ -3187,7 +3286,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
distributionLoadscanService.updateById(distributionLoadscanEntity);
distributionSignforMapper.updateSignforNum(distributionLoadscanEntity.getDeliveryId(), distributionLoadscanEntity.getReservationId(), distributionLoadscanEntity.getPackageNub());
}
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode());
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode(), distributionDeliveryListEntity.getTrainNumber(), parcelListEntity.getWarehouseEntryTimeEnd());
aaa.add(trunklinePackageTrackLog);
assert loadscanEntity != null;
@ -3260,7 +3359,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
Integer i = distributionDeliveryListMapper.updateloadingTimeById(distrilbutionloadingscanDTO.getDeliveryId());
//修改包件装车、签收状态
packageLockIds.add(distributionLoadscanEntity.getPackageId());
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode());
JSONObject trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode(), distributionDeliveryListEntity.getTrainNumber(), parcelListEntity.getWarehouseEntryTimeEnd());
aaa.add(trunklinePackageTrackLog);
} else {
@ -5078,7 +5177,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
jsonObject.put("remark","批量签收下架");
jsonObjects.add(jsonObject);
content = "包件在"+myCurrentWarehouse.getName()+"由"+loadscanEntity.getSigningUser()+"司机司机批量签收,装车方式:扫描装车,配送车次号:"+distributionDeliveryListEntity.getTrainNumber()+"预约任务号:"+reservationEntity.getReservationCode();
trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode());
trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode(), distributionDeliveryListEntity.getTrainNumber(), parcelListEntity.getWarehouseEntryTimeEnd());
} else {
//存在装车数据
@ -5100,7 +5199,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
distributionLoadscanService.updateById(loadscanEntities);
packageLockIds.add(loadscanEntities.getPackageId());
content = "包件在"+myCurrentWarehouse.getName()+"由"+loadscanEntities.getSigningUser()+"司机批量签收,装车方式:补录装车,配送车次号:"+distributionDeliveryListEntity.getTrainNumber()+"预约任务号:"+reservationEntity.getReservationCode();
trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode());
trunklinePackageTrackLog= handleLogJSONObject(myCurrentWarehouse,AuthUtil.getUser(),parcelListEntity.getOrderPackageCode(),content,WorkNodeEnums.DISTRIBUTION_ABNORMAL_SIGN_FOR.getCode(),distributionDeliveryListEntity.getTrainNumber(), parcelListEntity.getWarehouseEntryTimeEnd());
}
}
@ -6398,7 +6497,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
}
private JSONObject handleLogJSONObject(BasicdataWarehouseEntity warehouse,BladeUser user,String orderPackageCode,String content,Integer node) {
private JSONObject handleLogJSONObject(BasicdataWarehouseEntity warehouse, BladeUser user, String orderPackageCode, String content, Integer node, String trainNumber, Date warehouseEntryTimeEnd) {
JSONObject trunklinePackageTrackLog = new JSONObject();
trunklinePackageTrackLog.put("tenantId",user.getTenantId());
trunklinePackageTrackLog.put("createTime",new Date());
@ -6413,6 +6512,8 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl<Distribution
trunklinePackageTrackLog.put("warehouseName",warehouse.getName());
trunklinePackageTrackLog.put("workNode",node);
trunklinePackageTrackLog.put("content",content);
trunklinePackageTrackLog.put("trainNumber",trainNumber);
trunklinePackageTrackLog.put("warehouseEntryTimeEnd", DateUtil.format(warehouseEntryTimeEnd, DatePattern.NORM_DATETIME_PATTERN));
trunklinePackageTrackLog.put("operator",user.getNickName());
return trunklinePackageTrackLog;
}

19
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/MerchantStatisticsController.java

@ -13,7 +13,13 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
@ -81,7 +87,6 @@ public class MerchantStatisticsController {
}
@ResponseBody
@PostMapping("/findChangesRecordList")
@ApiOperationSupport(order = 1)
@ -169,5 +174,15 @@ public class MerchantStatisticsController {
}
}
@ResponseBody
@PatchMapping("/real/{id}")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "计算实际费用", notes = "计算实际费用")
public R<Boolean> calculateRealCost(@PathVariable("id") Long id) {
String method = "############calculateRealCost: ";
log.info(method + "请求参数{}", id);
return R.status(statisticsOrderInfoService.calculateRealCost(id));
}
}

40
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,6 +50,7 @@ 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)
|| WorkNodeEnums.SIGN_TRIPARTITE_TRANSFER_DEPART.getCode().equals(workNode)
@ -45,12 +58,37 @@ public class PackageFanoutListener {
JSONArray orderPackageCodes = jsonObject.getJSONArray("orderPackageCodes");
List<String> orderPackageCodeList = orderPackageCodes.toList(String.class);
// 配送签收时将签收时间写入
if (WorkNodeEnums.DISTRIBUTION_SIGN_FOR.getCode().equals(workNode)) {
List<StatisticsWarehousePackageEntity> list = warehousePackageService.list(Wrappers.<StatisticsWarehousePackageEntity>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<StatisticsDistributionPackageEntity> statisticsDistributionList = statisticsDistributionPackageService.findListByOrderPackageCodes(orderPackageCodeList);
// 修改statisticsDistributionList中所有元素的isSign为1
Set<Long> 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();

8
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java

@ -26,4 +26,12 @@ public interface IStatisticsOrderInfoService extends BaseService<StatisticsOrder
R checkBalance(MerchantStatisticsDTO merchantStatisticsDTO);
StatisticsOrderInfoVO findOrderDetail(Long orderInfoId);
/**
* 计算实际费用
* @param id 订单id
* @Return boolean 计算是否成功
* @Author zqb 2024/6/17
**/
boolean calculateRealCost(Long id);
}

470
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java

@ -1,39 +1,66 @@
package com.logpm.statistics.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.basicdata.entity.BasicdataPriceTemplateEntity;
import com.logpm.basicdata.feign.IBasicdataCodeClient;
import com.logpm.basicdata.feign.IBasicdataPriceClient;
import com.logpm.basicdata.vo.BasicdatPriceApiVO;
import com.logpm.basicdata.vo.PriceClientVO;
import com.logpm.basicdata.vo.PriceDispatchBasicVO;
import com.logpm.basicdata.vo.PriceDispatchVO;
import com.logpm.basicdata.vo.PriceWarehouseAdditionalVO;
import com.logpm.basicdata.vo.PriceWarehouseBasicVO;
import com.logpm.basicdata.vo.PriceWarehouseVO;
import com.logpm.statistics.dto.ChangesRecordDTO;
import com.logpm.statistics.dto.MerchantStatisticsDTO;
import com.logpm.statistics.entity.StatisticsBalanceOrderInfoEntity;
import com.logpm.statistics.entity.StatisticsChangesPhotoEntity;
import com.logpm.statistics.entity.StatisticsChangesRecordEntity;
import com.logpm.statistics.entity.StatisticsDistributionPackageEntity;
import com.logpm.statistics.entity.StatisticsOrderInfoEntity;
import com.logpm.statistics.entity.StatisticsWarehousePackageEntity;
import com.logpm.statistics.mapper.StatisticsOrderInfoMapper;
import com.logpm.statistics.service.IStatisticsBalanceOrderInfoService;
import com.logpm.statistics.service.IStatisticsChangesPhotoService;
import com.logpm.statistics.service.IStatisticsChangesRecordService;
import com.logpm.statistics.service.IStatisticsDistributionPackageService;
import com.logpm.statistics.service.IStatisticsOrderInfoService;
import com.logpm.statistics.service.IStatisticsWarehousePackageService;
import com.logpm.statistics.vo.StatisticsChangesRecordVO;
import com.logpm.statistics.vo.StatisticsOrderInfoVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.CodeNumConstant;
import org.springblade.common.constant.DictBizConstant;
import org.springblade.common.enums.BooleanZeroOneEnums;
import org.springblade.common.exception.CustomerException;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.system.cache.DictBizCache;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
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.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@ -46,6 +73,9 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
private final IStatisticsChangesPhotoService changesPhotoService;
private final IBasicdataCodeClient basicdataCodeClient;
private final IStatisticsBalanceOrderInfoService balanceOrderInfoService;
private final IBasicdataPriceClient priceClient;
private final IStatisticsDistributionPackageService distributionPackageService;
private final IStatisticsWarehousePackageService warehousePackageService;
@Override
public List<StatisticsOrderInfoEntity> findListByWaybillId(Long waybillId) {
@ -201,7 +231,6 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
List<BigDecimal> yPays = new ArrayList();// 月结
list.forEach(statisticsOrderInfoVO -> {
Long orderInfoId = statisticsOrderInfoVO.getOrderInfoId();
Integer confirmStatisticsOrder = statisticsOrderInfoVO.getConfirmStatisticsOrder();
@ -393,6 +422,443 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
return statementListByOrderInfoIds.get(0);
}
@Override
public boolean calculateRealCost(Long id) {
StatisticsOrderInfoEntity orderInfoEntity = this.getOne(new QueryWrapper<StatisticsOrderInfoEntity>().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<StatisticsDistributionPackageEntity> distributionPackageEntities = distributionPackageService.list(new QueryWrapper<StatisticsDistributionPackageEntity>().lambda().eq(StatisticsDistributionPackageEntity::getOrderInfoId, id));
// 校验是否全部配送完成
if (distributionPackageEntities.stream().anyMatch(distributionPackageEntity -> distributionPackageEntity.getIsSign() == 0)) {
log.warn("#############calculateRealCost: 订单未全部配送完成,无法计算。");
throw new CustomerException("订单未全部配送完成,无法计算。");
}
List<StatisticsWarehousePackageEntity> warehousePackageEntities = warehousePackageService.list(new QueryWrapper<StatisticsWarehousePackageEntity>().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<StatisticsWarehousePackageEntity> 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<StatisticsDistributionPackageEntity> 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<String, List<StatisticsDistributionPackageEntity>> map = distributionPackageEntities.stream().collect(Collectors.groupingBy(StatisticsDistributionPackageEntity::getTrainNumber));
if (CollUtil.isNotEmpty(map)) {
for (Map.Entry<String, List<StatisticsDistributionPackageEntity>> entry : map.entrySet()) {
List<StatisticsDistributionPackageEntity> 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<PriceDispatchBasicVO> pieceCategory = dispatch.getPieceCategory();
if (CollUtil.isNotEmpty(pieceCategory)) {
List<PriceDispatchBasicVO> 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<PriceDispatchBasicVO> cubeCategory = dispatch.getCubeCategory();
if (CollUtil.isNotEmpty(cubeCategory)) {
List<PriceDispatchBasicVO> 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<PriceDispatchBasicVO> weightCategory = dispatch.getWeightCategory();
if (CollUtil.isNotEmpty(weightCategory)) {
List<PriceDispatchBasicVO> 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<PriceWarehouseBasicVO> catergory = warehouseVO.getCatergory();
if (CollUtil.isNotEmpty(catergory)) {
List<PriceWarehouseBasicVO> 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<PriceWarehouseAdditionalVO> additionalCategory = warehouseVO.getAdditionalCategory();
if (CollUtil.isNotEmpty(additionalCategory)) {
List<PriceWarehouseAdditionalVO> 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<StatisticsDistributionPackageEntity> 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);

14
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/feign/TrunklinePackageTrackLogClient.java

@ -9,7 +9,9 @@ import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Slf4j
@ -25,9 +27,17 @@ public class TrunklinePackageTrackLogClient implements ITrunklinePackageTrackLog
List<WarehousePackageTrackLogEntity> ls = new ArrayList<>();
List<String> orderPackageCodes = new ArrayList<>();
final Integer[] workNode = {null};
Map<String, JSONObject> 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])) {
workNode[0] = warehousePackageTrackLogEntity.getWorkNode();
@ -35,7 +45,7 @@ public class TrunklinePackageTrackLogClient implements ITrunklinePackageTrackLog
ls.add(warehousePackageTrackLogEntity);
});
packageTrackLogAsyncService.addBatchPackageTrackLog(ls, orderPackageCodes, workNode[0]);
packageTrackLogAsyncService.addBatchPackageTrackLog(ls, orderPackageCodes, workNode[0], map);
}
}

6
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<String> orderPackageCodes, Long warehouseId, String warehouseName, Integer workNode, String content);
void addBatchPackageTrackLog(List<WarehousePackageTrackLogEntity> addPackageTrackLogList, List<String> orderPackageCodes, Integer code);
void addBatchPackageTrackLog(List<WarehousePackageTrackLogEntity> addPackageTrackLogList, List<String> orderPackageCodes, Integer code, Map<String, JSONObject> map);
void sendPackageWorkNodeFanout(List<String> orderPackageCodes,Integer workNode,Long warehouseId);
void sendPackageWorkNodeFanout(List<String> orderPackageCodes, Integer workNode, Long warehouseId, Map<String, JSONObject> map);
}

4
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<TrunklineWaybillPackageEntity> {
void saveList(List<TrunklineAdvanceDetailVO> list, WarehouseWaybillEntity waybillEntity);
@ -13,6 +15,6 @@ public interface ITrunklineWaybillPackageService extends BaseService<TrunklineWa
void updateWaybillStatus(WarehouseWaybillEntity waybillEntity);
void updatePackageStatus(List<String> orderPackageCodes, Integer workNode,Long warehouseId);
void updatePackageStatus(List<String> orderPackageCodes, Integer workNode, Long warehouseId, Map<String, JSONObject> map);
}

15
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<WarehousePackageTrackLogEntity> addPackageTrackLogList, List<String> orderPackageCodes, Integer workNode) {
public void addBatchPackageTrackLog(List<WarehousePackageTrackLogEntity> addPackageTrackLogList, List<String> orderPackageCodes, Integer workNode, Map<String, JSONObject> 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<String> orderPackageCodes,Integer workNode,Long warehouseId) {
public void sendPackageWorkNodeFanout(List<String> orderPackageCodes, Integer workNode, Long warehouseId, Map<String, JSONObject> 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();

4
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

@ -4757,7 +4757,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
1, 1, 0, null, null, null, e.getFromWarehouseId(), e.getId(), remark);
});
packageTrackLogAsyncService.addBatchPackageTrackLog(addPackageTrackLogList, orderPackageCodes, WorkNodeEnums.INITIAL_WAREHOUSE_LOADING.getCode());
packageTrackLogAsyncService.addBatchPackageTrackLog(addPackageTrackLogList, orderPackageCodes, WorkNodeEnums.INITIAL_WAREHOUSE_LOADING.getCode(), null);
return R.success("装车完成");
}
@ -4908,7 +4908,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
//包件签收状态修改
distributionParcelListClient.updatePackageStatus(orderPackageCodes, warehouseId, "70");
waybillPackageService.updatePackageStatus(orderPackageCodes, WorkNodeEnums.SIGN_TRIPARTITE_TRANSFER_DEPART.getCode(),warehouseId);
waybillPackageService.updatePackageStatus(orderPackageCodes, WorkNodeEnums.SIGN_TRIPARTITE_TRANSFER_DEPART.getCode(),warehouseId, null);
try {
String content = "包件在" + warehouseEntity.getName() + "被三方中转签收";

5
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillPackageServiceImpl.java

@ -1,5 +1,6 @@
package com.logpm.trunkline.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.trunkline.entity.TrunklineWaybillPackageEntity;
import com.logpm.trunkline.mapper.TrunklineWaybillPackageMapper;
@ -147,7 +148,7 @@ public class TrunklineWaybillPackageServiceImpl extends BaseServiceImpl<Trunklin
}
@Override
public void updatePackageStatus(List<String> orderPackageCodes, Integer workNode,Long warehouseId) {
public void updatePackageStatus(List<String> orderPackageCodes, Integer workNode, Long warehouseId, Map<String, JSONObject> map) {
Integer packageStatus = null;
if(WorkNodeEnums.INITIAL_WAREHOUSE_DEPART.getCode().equals(workNode)){
@ -189,7 +190,7 @@ public class TrunklineWaybillPackageServiceImpl extends BaseServiceImpl<Trunklin
}
packageTrackLogAsyncService.sendPackageWorkNodeFanout(orderPackageCodes,workNode,warehouseId);
packageTrackLogAsyncService.sendPackageWorkNodeFanout(orderPackageCodes,workNode,warehouseId, map);
}
}

Loading…
Cancel
Save