|
|
@@ -163,35 +163,52 @@ 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(), "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());
|
|
|
- routeCostItem.setUseBoxCost(boxCost.divide(routeCostItem.getExrate(), 4, RoundingMode.HALF_UP));
|
|
|
+ if ("SOC".equals(routeCost.getBusinessType())) {
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(costFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POL杂费收入
|
|
|
+ routeCostItem.setPolIncome(computationalIncome(costFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(costFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费收入
|
|
|
+ routeCostItem.setPodIncome(computationalIncome(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());
|
|
|
+ routeCostItem.setUseBoxCost(boxCost);
|
|
|
+ } else {
|
|
|
+ routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
+ routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
+ .add(routeCostItem.getUseBoxCost()));
|
|
|
+ //一程合计利润
|
|
|
+ routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().add(routeCostItem.getPolIncome())
|
|
|
+ .add(routeCostItem.getPodIncome()).subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(costFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POL杂费收入
|
|
|
+ routeCostItem.setPolIncomeTwo(computationalIncome(costFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(costFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费收入
|
|
|
+ routeCostItem.setPodIncomeTwo(computationalIncome(costFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().add(routeCostItem.getPolIncomeTwo())
|
|
|
+ .add(routeCostItem.getPodIncomeTwo()).subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
} else {
|
|
|
- routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
- }
|
|
|
- // 一程成本价 = 一程海运费+一程用箱成本+一程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.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit());
|
|
|
}
|
|
|
- //合计利润
|
|
|
- routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
if (routeCostItem.getId() == null) {
|
|
|
routeCostItem.setPid(routeCost.getId());
|
|
|
routeCostItem.setCreateTime(new Date());
|
|
|
@@ -466,35 +483,52 @@ 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(), "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());
|
|
|
- routeCostItem.setUseBoxCost(boxCost.divide(routeCostItem.getExrate(), 4, RoundingMode.HALF_UP));
|
|
|
+ if ("SOC".equals(routeCost.getBusinessType())) {
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POL杂费收入
|
|
|
+ routeCostItem.setPolIncome(computationalIncome(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费收入
|
|
|
+ routeCostItem.setPodIncome(computationalIncome(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());
|
|
|
+ routeCostItem.setUseBoxCost(boxCost);
|
|
|
+ } else {
|
|
|
+ routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
+ routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
+ .add(routeCostItem.getUseBoxCost()));
|
|
|
+ //一程合计利润
|
|
|
+ routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().add(routeCostItem.getPolIncome())
|
|
|
+ .add(routeCostItem.getPodIncome()).subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POL杂费收入
|
|
|
+ routeCostItem.setPolIncomeTwo(computationalIncome(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费收入
|
|
|
+ routeCostItem.setPodIncomeTwo(computationalIncome(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().add(routeCostItem.getPolIncomeTwo())
|
|
|
+ .add(routeCostItem.getPodIncomeTwo()).subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
} else {
|
|
|
- routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
- }
|
|
|
- // 一程成本价 = 一程海运费+一程用箱成本+一程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.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit());
|
|
|
}
|
|
|
- //合计利润
|
|
|
- routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
if (routeCostItem.getId() == null) {
|
|
|
routeCostItem.setPid(routeCost.getId());
|
|
|
routeCostItem.setCreateTime(new Date());
|
|
|
@@ -535,35 +569,53 @@ 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(), "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());
|
|
|
- routeCostItem.setUseBoxCost(boxCost.divide(routeCostItem.getExrate(), 4, RoundingMode.HALF_UP));
|
|
|
+ if ("SOC".equals(routeCost.getBusinessType())) {
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POL杂费收入
|
|
|
+ routeCostItem.setPolIncome(computationalIncome(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费收入
|
|
|
+ routeCostItem.setPodIncome(computationalIncome(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());
|
|
|
+ routeCostItem.setUseBoxCost(boxCost);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
+ routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
+ .add(routeCostItem.getUseBoxCost()));
|
|
|
+ //一程合计利润
|
|
|
+ routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().add(routeCostItem.getPolIncome())
|
|
|
+ .add(routeCostItem.getPodIncome()).subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POL杂费收入
|
|
|
+ routeCostItem.setPolIncomeTwo(computationalIncome(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费收入
|
|
|
+ routeCostItem.setPodIncomeTwo(computationalIncome(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().add(routeCostItem.getPolIncomeTwo())
|
|
|
+ .add(routeCostItem.getPodIncomeTwo()).subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
} else {
|
|
|
- routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
+ //一程合计利润
|
|
|
+ routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit());
|
|
|
}
|
|
|
- // 一程成本价 = 一程海运费+一程用箱成本+一程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());
|
|
|
@@ -583,7 +635,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
routeCost.setTotalProfit(routeCost.getProfit20().add(routeCost.getProfit40()).add(routeCost.getProfitHc()).add(routeCost.getOtherProfit()));
|
|
|
baseMapper.updateById(routeCost);
|
|
|
}
|
|
|
- this.removeByIds(longList);
|
|
|
+ routeCostFeeService.removeByIds(longList);
|
|
|
}
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
@@ -599,35 +651,52 @@ 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(), "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());
|
|
|
- routeCostItem.setUseBoxCost(boxCost.divide(routeCostItem.getExrate(), 4, RoundingMode.HALF_UP));
|
|
|
+ if ("SOC".equals(routeCost.getBusinessType())) {
|
|
|
+ //一程POL杂费成本
|
|
|
+ routeCostItem.setPolCost(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POL杂费收入
|
|
|
+ routeCostItem.setPolIncome(computationalIncome(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费成本
|
|
|
+ routeCostItem.setPodCost(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "0"));
|
|
|
+ //一程POD杂费收入
|
|
|
+ routeCostItem.setPodIncome(computationalIncome(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());
|
|
|
+ routeCostItem.setUseBoxCost(boxCost);
|
|
|
+ } else {
|
|
|
+ routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
+ // 一程成本价 = 一程海运费+一程用箱成本+一程pol杂费+一程pod成本
|
|
|
+ routeCostItem.setCostPrice(routeCostItem.getOceanFreight().add(routeCostItem.getPodCost()).add(routeCostItem.getPolCost())
|
|
|
+ .add(routeCostItem.getUseBoxCost()));
|
|
|
+ //一程合计利润
|
|
|
+ routeCostItem.setTotalProfit(routeCostItem.getSalesPrice().add(routeCostItem.getPolIncome())
|
|
|
+ .add(routeCostItem.getPodIncome()).subtract(routeCostItem.getCostPrice()));
|
|
|
+ if ("转船".equals(routeCost.getFlightType()) && "自转".equals(routeCost.getChangeShipType())) {
|
|
|
+ //二程POL杂费成本
|
|
|
+ routeCostItem.setPolCostTwo(computationalCost(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POL杂费收入
|
|
|
+ routeCostItem.setPolIncomeTwo(computationalIncome(routeCostFeeList, "POL", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费成本
|
|
|
+ routeCostItem.setPodCostTwo(computationalCost(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ //二程POD杂费收入
|
|
|
+ routeCostItem.setPodIncomeTwo(computationalIncome(routeCostFeeList, "POD", routeCostItem.getBoxType(), routeCostItem.getExrate(), "1"));
|
|
|
+ // 二程成本价 = 二程海运费+二程pol杂费+二程pod成本
|
|
|
+ routeCostItem.setCostPriceTwo(routeCostItem.getOceanFreightTwo().add(routeCostItem.getPodCostTwo()).add(routeCostItem.getPolCostTwo()));
|
|
|
+ //二程合计利润
|
|
|
+ routeCostItem.setTotalProfitTwo(routeCostItem.getSalesPriceTwo().add(routeCostItem.getPolIncomeTwo())
|
|
|
+ .add(routeCostItem.getPodIncomeTwo()).subtract(routeCostItem.getCostPriceTwo()));
|
|
|
+ }
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
} else {
|
|
|
- routeCostItem.setUseBoxCost(new BigDecimal("0.00"));
|
|
|
- }
|
|
|
- // 一程成本价 = 一程海运费+一程用箱成本+一程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.setTotalProfit(routeCostItem.getSalesPrice().subtract(routeCostItem.getCostPrice()));
|
|
|
+ //合计利润
|
|
|
+ routeCostItem.setProfit(routeCostItem.getTotalProfit());
|
|
|
}
|
|
|
- //合计利润
|
|
|
- routeCostItem.setProfit(routeCostItem.getTotalProfit().add(routeCostItem.getTotalProfitTwo()));
|
|
|
if (routeCostItem.getId() == null) {
|
|
|
routeCostItem.setPid(routeCost.getId());
|
|
|
routeCostItem.setCreateTime(new Date());
|
|
|
@@ -677,7 +746,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 合计费用
|
|
|
+ * 合计费用成本
|
|
|
*
|
|
|
* @param routeCostFeeList 费用明细
|
|
|
* @param type 费用类型
|
|
|
@@ -699,6 +768,28 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 合计费用收入
|
|
|
+ *
|
|
|
+ * @param routeCostFeeList 费用明细
|
|
|
+ * @param type 费用类型
|
|
|
+ * @param boxType 箱型
|
|
|
+ * @param exrate 汇率
|
|
|
+ */
|
|
|
+ public BigDecimal computationalIncome(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()) && srcType.equals(e.getSrcType())).reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getExrate().multiply(y.getSalesPrice())), BigDecimal::add);
|
|
|
+ if (new BigDecimal("0.00").compareTo(amount) != 0) {
|
|
|
+ amount = amount.divide(exrate, 4, RoundingMode.HALF_UP);
|
|
|
+ } else {
|
|
|
+ amount = new BigDecimal("0.00");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return amount;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 合计利润
|
|
|
*
|
|
|
* @param routeCostItemList 箱明细
|