Browse Source

feat(all): 车次成本明细报表

1 修改报表逻辑
fix-sign
zhaoqiaobo 4 months ago
parent
commit
e166ca2ab7
  1. 4
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionAddvaluePackageMapper.java
  2. 18
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionAddvaluePackageMapper.xml
  3. 28
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java
  4. 36
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAddvaluePackageServiceImpl.java

4
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionAddvaluePackageMapper.java

@ -16,6 +16,7 @@
*/
package com.logpm.distribution.mapper;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -24,6 +25,7 @@ import com.logpm.distribution.excel.DistributionAddvaluePackageExcel;
import com.logpm.distribution.vo.DistributionAddvaluePackageVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* 增值服务包件表 Mapper 接口
@ -73,4 +75,6 @@ public interface DistributionAddvaluePackageMapper extends BaseMapper<Distributi
* @param addvalueDetailId
*/
void deleteAddvaluePackageByDetailId(@Param("reservationId")Long reservationId,@Param("packageId") Long id,@Param("addvalueDetailId") Long addvalueDetailId);
List<JSONObject> findMapByPackageCode(@Param("collect1") Set<String> collect1);
}

18
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionAddvaluePackageMapper.xml

@ -47,4 +47,22 @@
resultType="com.logpm.distribution.excel.DistributionAddvaluePackageExcel">
SELECT * FROM logpm_distribution_addvalue_package ${ew.customSqlSegment}
</select>
<select id="findMapByPackageCode" resultType="cn.hutool.json.JSONObject">
select ldap.order_package_code orderPackageCode,
a.addvalue_id addvalueId,
case
when a.addvalue_id = '1' then ifnull(ad.flool_num, 0)
when a.addvalue_id = '3' then ifnull(ad.distance, 0)
end num
from logpm_distribution_addvalue_package ldap
left join logpm_distribution_addvalue_detail ad on ad.id = ldap.addvalue_detail_id and ad.is_deleted = 0
left join logpm_distribution_addvalue a on a.id = ad.addvalue_id
where ldap.is_deleted = 0
and ldap.order_package_code in
<foreach collection="collect1" item="item" open="(" close=")" index="index" separator=",">
#{item}
</foreach>
and a.addvalue_id in ('1', '3')
</select>
</mapper>

28
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java

@ -174,7 +174,7 @@ public class DeliverFinishReportListener implements ReportService {
if (StrUtil.isNotEmpty(deliveryKind) && StrUtil.equals(deliveryKind, "自主配送")) {
if (StrUtil.isNotEmpty(qualityDeliverEntity.getDeliveryType())
&& (StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "商配") || StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "市配"))) {
if(StrUtil.isEmpty(qualityDeliverEntity.getSignCarType())){
if (StrUtil.isEmpty(qualityDeliverEntity.getSignCarType())) {
continue;
}
ExpenseDispatchClientDTO expenseDispatchClientDTO = expenseDispatchClient.findPriceByDriverId(qualityDeliverEntity.getWarehouseId(), driverId, qualityDeliverEntity.getSignCarTypeId(), qualityDeliverEntity.getDeliveryType());
@ -186,7 +186,7 @@ public class DeliverFinishReportListener implements ReportService {
// 整车计费,则车内的每个包件分摊整车成本费用
if (ynWholeVehicle) {
String wholeVehicleCost = priceVO.getWholeVehicleCost();
if(StrUtil.isNotEmpty(wholeVehicleCost)){
if (StrUtil.isNotEmpty(wholeVehicleCost)) {
BigDecimal div = NumberUtil.div(new BigDecimal(wholeVehicleCost), totalNum);
for (Map.Entry<Long, QualityDeliverEntity> entityEntry : valueMap.entrySet()) {
QualityDeliverEntity value2 = entityEntry.getValue();
@ -283,10 +283,14 @@ public class DeliverFinishReportListener implements ReportService {
// 装卸费单价
String loadingUnloadingFee = expenseDispatchPriceCategoryVO.getLoadingUnloadingFee();
// 上楼层数
//
Integer stairsNumber = 0;
if (addvaluePackageMap.containsKey(entity.getOrderPackageCode())) {
stairsNumber = Convert.toInt(addvaluePackageMap.get(entity.getOrderPackageCode()));
if (addvaluePackageMap.containsKey(entity.getOrderPackageCode() + "1")) {
stairsNumber = Convert.toInt(addvaluePackageMap.get(entity.getOrderPackageCode() + "1"));
}
// 平移米数
Integer translationNumber = 0;
if (addvaluePackageMap.containsKey(entity.getOrderPackageCode() + "3")) {
translationNumber = Convert.toInt(addvaluePackageMap.get(entity.getOrderPackageCode() + "3"));
}
// 签收数量
Integer signNum = entity.getSignNum();
@ -294,15 +298,15 @@ public class DeliverFinishReportListener implements ReportService {
// 上楼费成本 = 上楼费单价 * 上楼层数 * 签收件数
QualityDeliverEntity qualityDeliverEntity1 = valueMap.get(entity.getId());
if (ObjectUtil.isNotEmpty(stairsNumber) && StrUtil.isNotEmpty(stairsCharge)) {
qualityDeliverEntity1.setApstairsCost(NumberUtil.mul(stairsNumber, new BigDecimal(stairsCharge)));
qualityDeliverEntity1.setApstairsCost(NumberUtil.mul(stairsNumber, new BigDecimal(stairsCharge), signNum));
}
// 分货费成本 = 分货费单价 * 签收件数
if (StrUtil.isNotEmpty(cargoSplittingFee)) {
qualityDeliverEntity1.setApartCost(NumberUtil.mul(signNum, new BigDecimal(cargoSplittingFee)));
}
// 平移费成本 = 平移费单价 * 签收件数
// 平移费成本 = 平移费单价 * 平移米数 * 签收件数
if (StrUtil.isNotEmpty(translationFee)) {
qualityDeliverEntity1.setMoveCost(NumberUtil.mul(signNum, new BigDecimal(translationFee)));
qualityDeliverEntity1.setMoveCost(NumberUtil.mul(translationNumber, new BigDecimal(translationFee), signNum));
}
// 装卸费成本 = 装卸费单价 * 签收件数
if (StrUtil.isNotEmpty(loadingUnloadingFee)) {
@ -742,18 +746,22 @@ public class DeliverFinishReportListener implements ReportService {
}
}
// 是否点位补贴成本 是 计算成本
// 是否点位补贴成本 是 打卡点位数 * 单价 / 总件数
Integer ynSiteSubsidy = rule.getYnSiteSubsidy();
if (NumberUtil.equals(ynSiteSubsidy, BooleanZeroOneEnums.YES.getCode())) {
if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) {
initRule(value, allRouteMap, firstRouteMap);
}
Set<Long> longs = valueMap.keySet();
Integer dkp = 0;
if(CollUtil.isNotEmpty(allRouteMap)){
dkp = allRouteMap.keySet().size();
}
for (Map.Entry<Long, QualityDeliverEntity> entityEntry : valueMap.entrySet()) {
QualityDeliverEntity value2 = entityEntry.getValue();
String siteSubsidyCost = priceVO.getSiteSubsidyCost();
if (StrUtil.isNotEmpty(siteSubsidyCost)) {
value2.setPointAllowCost(NumberUtil.div(NumberUtil.mul(longs.size(), new BigDecimal(siteSubsidyCost)), totalNum));
value2.setPointAllowCost(NumberUtil.div(NumberUtil.mul(dkp, new BigDecimal(siteSubsidyCost)), totalNum));
}
}
}

36
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAddvaluePackageServiceImpl.java

@ -17,10 +17,9 @@
package com.logpm.distribution.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.distribution.entity.DistributionAddvalueDetailEntity;
import com.logpm.distribution.entity.DistributionAddvaluePackageEntity;
import com.logpm.distribution.excel.DistributionAddvaluePackageExcel;
import com.logpm.distribution.mapper.DistributionAddvaluePackageMapper;
@ -28,7 +27,6 @@ import com.logpm.distribution.service.IDistributionAddvalueDetailService;
import com.logpm.distribution.service.IDistributionAddvaluePackageService;
import com.logpm.distribution.vo.DistributionAddvaluePackageVO;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -36,7 +34,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 增值服务包件表 服务实现类
@ -68,29 +65,14 @@ public class DistributionAddvaluePackageServiceImpl extends BaseServiceImpl<Dist
@Override
public Map<String, String> findMapByPackageCode(Set<String> collect1) {
Map<String, String> result = new HashMap<>();
List<DistributionAddvaluePackageEntity> list = this.list(Wrappers.<DistributionAddvaluePackageEntity>lambdaQuery()
.select(DistributionAddvaluePackageEntity::getAddvalueDetailId, DistributionAddvaluePackageEntity::getOrderPackageCode)
.in(DistributionAddvaluePackageEntity::getOrderPackageCode, collect1));
if (CollUtil.isNotEmpty(list)) {
// 转map
Map<Long, String> map = list.stream()
.filter(it -> ObjectUtil.isNotEmpty(it.getAddvalueDetailId()))
.collect(Collectors.toMap(
DistributionAddvaluePackageEntity::getAddvalueDetailId,
DistributionAddvaluePackageEntity::getOrderPackageCode,
(existingValue, newValue) -> existingValue // 处理键冲突
));
List<DistributionAddvalueDetailEntity> list1 = addvalueDetailService.list(
Wrappers.<DistributionAddvalueDetailEntity>lambdaQuery()
.select(DistributionAddvalueDetailEntity::getFloolNum, DistributionAddvalueDetailEntity::getId)
.in(DistributionAddvalueDetailEntity::getId, map.keySet())
);
if (CollUtil.isNotEmpty(list1)) {
Map<Long, Integer> map1 = list1.stream().collect(Collectors.toMap(DistributionAddvalueDetailEntity::getId, DistributionAddvalueDetailEntity::getFloolNum));
map.forEach((k, v) -> {
result.put(v, map1.get(k) + "");
});
}
if(CollUtil.isEmpty(collect1)){
return null;
}
List<JSONObject> list = baseMapper.findMapByPackageCode(collect1);
if(CollUtil.isNotEmpty(list)){
list.stream().forEach(item -> {
result.put(item.getStr("orderPackageCode") + item.getStr("addvalueId"), item.getStr("num"));
});
}
return result;
}

Loading…
Cancel
Save