|
|
@@ -163,13 +163,11 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
int days = routeCost.getNavigateDay() + routeCost.getExistStationDay();
|
|
|
List<RouteCostFee> costFeeList = routeCost.getCostFeeList();
|
|
|
for (RouteCostItem routeCostItem : routeCost.getCostItemList()) {
|
|
|
- //POL杂费成本
|
|
|
- routeCostItem.setPolCost(computationalCost(costFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POD杂费成本
|
|
|
- routeCostItem.setPodCost(computationalCost(costFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POT杂费成本
|
|
|
- routeCostItem.setPotCost(computationalCost(costFeeList, "POT", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //用箱成本
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(costFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(costFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程用箱成本
|
|
|
if (0 != days && ObjectUtils.isNotNull(routeCostItem.getBoxCost()) &&
|
|
|
routeCostItem.getBoxCost().compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
BigDecimal boxCost = new BigDecimal(days).multiply(routeCostItem.getBoxCost());
|
|
|
@@ -177,11 +175,23 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
} else {
|
|
|
routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
}
|
|
|
- // 成本价 = 海运费+用箱成本+pol杂费+pod成本
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
.add(routeCostItem.getUseBoxCost()));
|
|
|
- //合计利润
|
|
|
+ //一程合计利润
|
|
|
routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(costFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(costFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
if (routeCostItem.getId() == null) {
|
|
|
routeCostItem.setPid(routeCost.getId());
|
|
|
routeCostItem.setCreateTime(new Date());
|
|
|
@@ -456,13 +466,11 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
if (ObjectUtils.isNotNull(routeCostItemList)) {
|
|
|
int days = routeCost.getNavigateDay() + routeCost.getExistStationDay();
|
|
|
for (RouteCostItem routeCostItem : routeCostItemList) {
|
|
|
- //POL杂费成本
|
|
|
- routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POD杂费成本
|
|
|
- routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POT杂费成本
|
|
|
- routeCostItem.setPotCost(computationalCost(routeCostFeeList, "POT", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //用箱成本
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程用箱成本
|
|
|
if (0 != days && ObjectUtils.isNotNull(routeCostItem.getBoxCost()) &&
|
|
|
routeCostItem.getBoxCost().compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
BigDecimal boxCost = new BigDecimal(days).multiply(routeCostItem.getBoxCost());
|
|
|
@@ -470,11 +478,23 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
} else {
|
|
|
routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
}
|
|
|
- // 成本价 = 海运费+用箱成本+pol杂费+pod成本
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
.add(routeCostItem.getUseBoxCost()));
|
|
|
- //合计利润
|
|
|
+ //一程合计利润
|
|
|
routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
if (routeCostItem.getId() == null) {
|
|
|
routeCostItem.setPid(routeCost.getId());
|
|
|
routeCostItem.setCreateTime(new Date());
|
|
|
@@ -507,8 +527,6 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
.eq(RouteCostFee::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(RouteCostFee::getIsDeleted, 0)
|
|
|
.eq(RouteCostFee::getPid, routeCostFee.getPid()));
|
|
|
- List<RouteCostFee> routeCostFeeListNew = routeCostFeeList.stream().filter(e -> !longList.contains(e.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
RouteCost routeCost = baseMapper.selectById(routeCostFee.getPid());
|
|
|
List<RouteCostItem> routeCostItemList = routeCostItemService.list(new LambdaQueryWrapper<RouteCostItem>()
|
|
|
.eq(RouteCostItem::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -517,14 +535,11 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
if (ObjectUtils.isNotNull(routeCostItemList)) {
|
|
|
int days = routeCost.getNavigateDay() + routeCost.getExistStationDay();
|
|
|
for (RouteCostItem routeCostItem : routeCostItemList) {
|
|
|
- //POL杂费成本
|
|
|
- routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POD杂费成本
|
|
|
- routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POT杂费成本
|
|
|
- routeCostItem.setPotCost(computationalCost(routeCostFeeList, "POT", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
-
|
|
|
- //用箱成本
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程用箱成本
|
|
|
if (0 != days && ObjectUtils.isNotNull(routeCostItem.getBoxCost()) &&
|
|
|
routeCostItem.getBoxCost().compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
BigDecimal boxCost = new BigDecimal(days).multiply(routeCostItem.getBoxCost());
|
|
|
@@ -532,11 +547,23 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
} else {
|
|
|
routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
}
|
|
|
- // 成本价 = 海运费+用箱成本+pol杂费+pod成本
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
.add(routeCostItem.getUseBoxCost()));
|
|
|
- //合计利润
|
|
|
+ //一程合计利润
|
|
|
routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
if (routeCostItem.getId() == null) {
|
|
|
routeCostItem.setPid(routeCost.getId());
|
|
|
routeCostItem.setCreateTime(new Date());
|
|
|
@@ -572,13 +599,11 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
.eq(RouteCostFee::getPid, routeCostItemList.get(0).getPid()));
|
|
|
int days = routeCost.getNavigateDay() + routeCost.getExistStationDay();
|
|
|
for (RouteCostItem routeCostItem : routeCostItemList) {
|
|
|
- //POL杂费成本
|
|
|
- routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POD杂费成本
|
|
|
- routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //POT杂费成本
|
|
|
- routeCostItem.setPotCost(computationalCost(routeCostFeeList, "POT", routeCostItem.getBoxType(), routeCostItem.getExrate()));
|
|
|
- //用箱成本
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程用箱成本
|
|
|
if (0 != days && ObjectUtils.isNotNull(routeCostItem.getBoxCost()) &&
|
|
|
routeCostItem.getBoxCost().compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
BigDecimal boxCost = new BigDecimal(days).multiply(routeCostItem.getBoxCost());
|
|
|
@@ -586,11 +611,23 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
} else {
|
|
|
routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
}
|
|
|
- // 成本价 = 海运费+用箱成本+pol杂费+pod成本
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
.add(routeCostItem.getUseBoxCost()));
|
|
|
- //合计利润
|
|
|
+ //一程合计利润
|
|
|
routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
if (routeCostItem.getId() == null) {
|
|
|
routeCostItem.setPid(routeCost.getId());
|
|
|
routeCostItem.setCreateTime(new Date());
|
|
|
@@ -647,11 +684,11 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
* @param boxType 箱型
|
|
|
* @param exrate 汇率
|
|
|
*/
|
|
|
- public BigDecimal computationalCost(List<RouteCostFee> routeCostFeeList, String type, String boxType, BigDecimal exrate) {
|
|
|
+ public BigDecimal computationalCost(List<RouteCostFee> routeCostFeeList, String type, String boxType, BigDecimal exrate, String srcType) {
|
|
|
BigDecimal amount = new BigDecimal("0.00");
|
|
|
if (!routeCostFeeList.isEmpty()) {
|
|
|
amount = routeCostFeeList.stream().filter(e -> e.getBoxType().equals(boxType)
|
|
|
- && type.equals(e.getBusType())).reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getExrate().multiply(y.getCostPrice())), BigDecimal::add);
|
|
|
+ && type.equals(e.getBusType()) && srcType.equals(e.getSrcType())).reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getExrate().multiply(y.getCostPrice())), BigDecimal::add);
|
|
|
if (new BigDecimal("0.00").compareTo(amount) != 0) {
|
|
|
amount = amount.divide(exrate, 4, RoundingMode.HALF_UP);
|
|
|
} else {
|
|
|
@@ -672,17 +709,17 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
if (!routeCostItemList.isEmpty()) {
|
|
|
if ("20".equals(type)) {
|
|
|
profit = routeCostItemList.stream().filter(e -> e.getBoxType().contains("20"))
|
|
|
- .map(RouteCostItem::getTotalProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ .map(RouteCostItem::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
} else if ("40".equals(type)) {
|
|
|
profit = routeCostItemList.stream().filter(e -> e.getBoxType().contains("40") &&
|
|
|
- !e.getBoxType().equals("40HC")).map(RouteCostItem::getTotalProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ !e.getBoxType().equals("40HC")).map(RouteCostItem::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
} else if ("40HC".equals(type)) {
|
|
|
profit = routeCostItemList.stream().filter(e -> e.getBoxType().contains("40HC"))
|
|
|
- .map(RouteCostItem::getTotalProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ .map(RouteCostItem::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
} else {
|
|
|
profit = routeCostItemList.stream().filter(e -> !e.getBoxType().equals("40HC") &&
|
|
|
!e.getBoxType().contains("20") && !e.getBoxType().contains("40"))
|
|
|
- .map(RouteCostItem::getTotalProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ .map(RouteCostItem::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
}
|
|
|
} else {
|
|
|
profit = new BigDecimal("0.00");
|