|
|
|
@ -23,6 +23,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
@ -34,8 +35,11 @@ import com.logpm.basicdata.feign.IWarehouseLeasingClient;
|
|
|
|
|
import com.logpm.distribution.entity.QualityDeliverEntity; |
|
|
|
|
import com.logpm.distribution.mapper.QualityDeliverMapper; |
|
|
|
|
import com.logpm.distribution.service.IQualityDeliverService; |
|
|
|
|
import com.logpm.statistics.entity.ExpenseDispatchOrderDetailEntity; |
|
|
|
|
import com.logpm.statistics.entity.ExpenseDispatchTrainDetailEntity; |
|
|
|
|
import com.logpm.statistics.entity.ExpenseWarehouseOrderEntity; |
|
|
|
|
import com.logpm.statistics.feign.IExpenseDispatchClient; |
|
|
|
|
import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
@ -47,6 +51,7 @@ import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -445,4 +450,175 @@ public class QualityDeliverServiceImpl extends BaseServiceImpl<QualityDeliverMap
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void orderExpenseDispatchDetailFinal(JSONArray objects) { |
|
|
|
|
// 生成配送订单总成本
|
|
|
|
|
if (CollUtil.isNotEmpty(objects)) { |
|
|
|
|
List<TrunklineWaybillOrderEntity> list = JSONUtil.toList(objects, TrunklineWaybillOrderEntity.class); |
|
|
|
|
TrunklineWaybillOrderEntity entity = list.get(0); |
|
|
|
|
List<QualityDeliverEntity> qualityDeliverEntities = baseMapper.selectList(Wrappers.<QualityDeliverEntity>lambdaQuery() |
|
|
|
|
.eq(QualityDeliverEntity::getOrderCode, entity.getOrderCode()) |
|
|
|
|
.eq(QualityDeliverEntity::getWaybillNumber, entity.getWaybillNo()) |
|
|
|
|
.orderByDesc(QualityDeliverEntity::getCarComplateTime) |
|
|
|
|
); |
|
|
|
|
if (CollUtil.isNotEmpty(qualityDeliverEntities)) { |
|
|
|
|
QualityDeliverEntity qualityDeliverEntity = qualityDeliverEntities.get(0); |
|
|
|
|
// 订单运单总数
|
|
|
|
|
Integer totalNumber = qualityDeliverEntity.getOrderWaybillNumber(); |
|
|
|
|
// 计算签收总数
|
|
|
|
|
Integer reduce = qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.map(QualityDeliverEntity::getSignNum) |
|
|
|
|
.filter(Objects::nonNull) |
|
|
|
|
.reduce(0, Integer::sum); |
|
|
|
|
// 全部计算完成之后生成订单总成本
|
|
|
|
|
if (NumberUtil.equals(totalNumber, reduce)) { |
|
|
|
|
ExpenseDispatchOrderDetailEntity orderDetailEntity = new ExpenseDispatchOrderDetailEntity(); |
|
|
|
|
orderDetailEntity.setBrand(qualityDeliverEntity.getBrandName()); |
|
|
|
|
orderDetailEntity.setOrderCode(qualityDeliverEntity.getOrderCode()); |
|
|
|
|
orderDetailEntity.setWaybillNumber(qualityDeliverEntity.getWaybillNumber()); |
|
|
|
|
orderDetailEntity.setDestinationWarehouse(qualityDeliverEntity.getWarehouseName()); |
|
|
|
|
orderDetailEntity.setShippingOrg(qualityDeliverEntity.getShipperUnit()); |
|
|
|
|
orderDetailEntity.setConsigneeOrg(qualityDeliverEntity.getConsigneeUnit()); |
|
|
|
|
orderDetailEntity.setWaybillType(qualityDeliverEntity.getCustomType()); |
|
|
|
|
orderDetailEntity.setDocumentCreationTime(DateUtil.formatDateTime(qualityDeliverEntity.getOpenOrderTime())); |
|
|
|
|
orderDetailEntity.setTotalQuantity(totalNumber); |
|
|
|
|
orderDetailEntity.setReviewNumber(reduce); |
|
|
|
|
orderDetailEntity.setTotalWeight(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getWeight())) |
|
|
|
|
.map(QualityDeliverEntity::getWeight) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setTotalVolume(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getVolume())) |
|
|
|
|
.map(QualityDeliverEntity::getVolume) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setTotalDistributionCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getTotalDistributionCost())) |
|
|
|
|
.map(QualityDeliverEntity::getTotalDistributionCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setDistributionCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getDistributionCost())) |
|
|
|
|
.map(QualityDeliverEntity::getDistributionCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setStairCarryingFee(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getApstairsCost())) |
|
|
|
|
.map(QualityDeliverEntity::getApstairsCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setGoodsAllocationCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getApartCost())) |
|
|
|
|
.map(QualityDeliverEntity::getApartCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setRepositioningCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getMoveCost())) |
|
|
|
|
.map(QualityDeliverEntity::getMoveCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setHandlingCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getStevedoreCost())) |
|
|
|
|
.map(QualityDeliverEntity::getStevedoreCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setMileageCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getKiloAllowCost())) |
|
|
|
|
.map(QualityDeliverEntity::getKiloAllowCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setSubsidizedKilometerCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getAllowKiloAllowCost())) |
|
|
|
|
.map(QualityDeliverEntity::getAllowKiloAllowCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setExcessZoneMileageCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getUltrAllpwCost())) |
|
|
|
|
.map(QualityDeliverEntity::getUltrAllpwCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setLocationSubsidyCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getPointAllowCost())) |
|
|
|
|
.map(QualityDeliverEntity::getPointAllowCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setMinimumGuaranteeCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getGuarCost())) |
|
|
|
|
.map(QualityDeliverEntity::getGuarCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setFuelCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getFuelCost())) |
|
|
|
|
.map(QualityDeliverEntity::getFuelCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setOtherCosts(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getOtherCost())) |
|
|
|
|
.map(QualityDeliverEntity::getOtherCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
orderDetailEntity.setShipper(qualityDeliverEntity.getShipperPerson()); |
|
|
|
|
orderDetailEntity.setShippingPhone(qualityDeliverEntity.getShipperMobile()); |
|
|
|
|
orderDetailEntity.setShippingAddress(qualityDeliverEntity.getShipperAddress()); |
|
|
|
|
orderDetailEntity.setArrivalStation(qualityDeliverEntity.getConsigneeStation()); |
|
|
|
|
orderDetailEntity.setDepartureWarehouse(qualityDeliverEntity.getShipperStation()); |
|
|
|
|
orderDetailEntity.setConsignee(qualityDeliverEntity.getConsigneePerson()); |
|
|
|
|
orderDetailEntity.setConsigneePhone(qualityDeliverEntity.getConsigneeMobile()); |
|
|
|
|
orderDetailEntity.setConsigneeAddress(qualityDeliverEntity.getConsigneeAddress()); |
|
|
|
|
orderDetailEntity.setCustomerTrip(qualityDeliverEntity.getTrainNumber()); |
|
|
|
|
orderDetailEntity.setReviewCompletionTime(DateUtil.formatDateTime(qualityDeliverEntity.getReviewTime())); |
|
|
|
|
expenseDispatchClient.saveDispatchOrderDetailEntity(orderDetailEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void expenseWarehouseOrder(JSONArray objects) { |
|
|
|
|
// 生成仓储订单总成本
|
|
|
|
|
if (CollUtil.isNotEmpty(objects)) { |
|
|
|
|
List<TrunklineWaybillOrderEntity> list = JSONUtil.toList(objects, TrunklineWaybillOrderEntity.class); |
|
|
|
|
TrunklineWaybillOrderEntity entity = list.get(0); |
|
|
|
|
List<QualityDeliverEntity> qualityDeliverEntities = baseMapper.selectList(Wrappers.<QualityDeliverEntity>lambdaQuery() |
|
|
|
|
.eq(QualityDeliverEntity::getOrderCode, entity.getOrderCode()) |
|
|
|
|
.eq(QualityDeliverEntity::getWaybillNumber, entity.getWaybillNo()) |
|
|
|
|
.orderByDesc(QualityDeliverEntity::getReviewTime) |
|
|
|
|
); |
|
|
|
|
if (CollUtil.isNotEmpty(qualityDeliverEntities)) { |
|
|
|
|
QualityDeliverEntity qualityDeliverEntity = qualityDeliverEntities.get(0); |
|
|
|
|
// 订单运单总数
|
|
|
|
|
Integer totalNumber = qualityDeliverEntity.getOrderWaybillNumber(); |
|
|
|
|
// 计算签收总数
|
|
|
|
|
Integer reduce = qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getReviewUserName())) |
|
|
|
|
.map(QualityDeliverEntity::getSignNum) |
|
|
|
|
.filter(Objects::nonNull) |
|
|
|
|
.reduce(0, Integer::sum); |
|
|
|
|
// 全部计算完成之后生成订单总成本
|
|
|
|
|
if (NumberUtil.equals(totalNumber, reduce)) { |
|
|
|
|
ExpenseWarehouseOrderEntity orderDetailEntity = new ExpenseWarehouseOrderEntity(); |
|
|
|
|
orderDetailEntity.setBusinessUnit(qualityDeliverEntity.getBusinessUnit()); |
|
|
|
|
orderDetailEntity.setWarehouseName(qualityDeliverEntity.getWarehouseName()); |
|
|
|
|
orderDetailEntity.setOrderCode(qualityDeliverEntity.getOrderCode()); |
|
|
|
|
orderDetailEntity.setShipmentNumber(qualityDeliverEntity.getWaybillNumber()); |
|
|
|
|
orderDetailEntity.setReceivingUnit(qualityDeliverEntity.getConsigneeUnit()); |
|
|
|
|
orderDetailEntity.setShippingUnit(qualityDeliverEntity.getShipperUnit()); |
|
|
|
|
orderDetailEntity.setWaybillType(qualityDeliverEntity.getCustomType()); |
|
|
|
|
orderDetailEntity.setTotalNumber(totalNumber); |
|
|
|
|
orderDetailEntity.setOutNumber(totalNumber); |
|
|
|
|
orderDetailEntity.setOriginWarehouse(qualityDeliverEntity.getShipperStation()); |
|
|
|
|
orderDetailEntity.setReviewCompletionTime(DateUtil.formatDateTime(qualityDeliverEntity.getReviewTime())); |
|
|
|
|
orderDetailEntity.setWarehouseRentalCost(Convert.toDouble(qualityDeliverEntities.stream() |
|
|
|
|
.filter(item -> ObjectUtil.isNotEmpty(item.getReviewUserName())) |
|
|
|
|
.filter(item -> Objects.nonNull(item.getWarehouseCost())) |
|
|
|
|
.map(QualityDeliverEntity::getWarehouseCost) |
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add))); |
|
|
|
|
expenseDispatchClient.saveWarehouseOrderEntity(orderDetailEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|