|
@ -39,7 +39,7 @@ public class BirBudgetTargetServiceImpl extends ServiceImpl<BirBudgetTargetMappe |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<BirBudgetTargetVo> listVo(BirBudgetTargetSo query) { |
|
|
public List<BirBudgetTargetVo> listVo(BirBudgetTargetSo query) { |
|
|
query.setLoadType(query.getLoadType()+1); |
|
|
query.setLoadType(query.getLoadType()-1); |
|
|
LocalDateTime endMonth = query.getYearMonthEnd(); |
|
|
LocalDateTime endMonth = query.getYearMonthEnd(); |
|
|
LocalDateTime startMonth = query.getYearMonthStart(); |
|
|
LocalDateTime startMonth = query.getYearMonthStart(); |
|
|
//格式化
|
|
|
//格式化
|
|
@ -112,22 +112,49 @@ public class BirBudgetTargetServiceImpl extends ServiceImpl<BirBudgetTargetMappe |
|
|
targetVo.setLastYearDispatchAmt(BigDecimal.ZERO); |
|
|
targetVo.setLastYearDispatchAmt(BigDecimal.ZERO); |
|
|
targetVo.setProvinceCityAmt(BigDecimal.ZERO); |
|
|
targetVo.setProvinceCityAmt(BigDecimal.ZERO); |
|
|
targetVo.setProvinceCityRegionAmt(BigDecimal.ZERO); |
|
|
targetVo.setProvinceCityRegionAmt(BigDecimal.ZERO); |
|
|
|
|
|
|
|
|
|
|
|
if(mList!=null) { |
|
|
|
|
|
Map<String, List<BirBudgetTarget>> brandMap = mList.stream().collect(Collectors.groupingBy(obj -> obj.getBrandId())); |
|
|
|
|
|
BigDecimal targetAmt = brandMap.values().stream().map(a -> a.get(0).getTargetAmt() == null ? BigDecimal.ZERO : a.get(0).getTargetAmt()).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
BigDecimal budgetAmt = brandMap.values().stream().map(a -> a.get(0).getBudgetAmt() == null ? BigDecimal.ZERO : a.get(0).getBudgetAmt()).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
|
|
|
|
targetVo.setTargetAmt(targetAmt); |
|
|
|
|
|
targetVo.setBudgetAmt(budgetAmt); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(sList!=null) { |
|
|
|
|
|
BigDecimal cityRegionAmt = sList.stream().map(a -> a.getProvinceCityAmt() == null ? BigDecimal.ZERO : a.getProvinceCityAmt()).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
targetVo.setProvinceCityAmt(cityRegionAmt); |
|
|
|
|
|
BigDecimal provinceCityRegionAmt = sList.stream().map(a -> a.getProvinceCityRegionAmt() == null ? BigDecimal.ZERO : a.getProvinceCityRegionAmt()).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
targetVo.setProvinceCityRegionAmt(provinceCityRegionAmt); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(mList)){ |
|
|
if(CollUtil.isNotEmpty(mList)){ |
|
|
for (BirBudgetTarget target : mList) { |
|
|
for (BirBudgetTarget target : mList) { |
|
|
// targetVo.setTargetAmt(targetVo.getTargetAmt().add(target.getTargetAmt()));
|
|
|
// targetVo.setTargetAmt(targetVo.getTargetAmt().add(target.getTargetAmt()));
|
|
|
// targetVo.setBudgetAmt(targetVo.getBudgetAmt().add(target.getBudgetAmt()));
|
|
|
// targetVo.setBudgetAmt(targetVo.getBudgetAmt().add(target.getBudgetAmt()));
|
|
|
targetVo.setTargetAmt(target.getTargetAmt()); |
|
|
// if(target.getTargetAmt()!=null){
|
|
|
targetVo.setBudgetAmt(target.getBudgetAmt()); |
|
|
// targetVo.setTargetAmt(target.getTargetAmt());
|
|
|
targetVo.setDispatchAmt(targetVo.getDispatchAmt().add(target.getDispatchAmt())); |
|
|
// }else{
|
|
|
targetVo.setTotalRealAmt(targetVo.getTotalRealAmt().add(target.getTotalRealAmt())); |
|
|
// targetVo.setTargetAmt(BigDecimal.ZERO);
|
|
|
targetVo.setLastYearDispatchAmt(targetVo.getLastYearDispatchAmt().add(target.getLastYearDispatchAmt())); |
|
|
// }
|
|
|
BigDecimal cityRegionAmt = sList.stream().map(a->a.getProvinceCityAmt()==null?BigDecimal.ZERO:a.getProvinceCityAmt()).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
// if(target.getBudgetAmt()!=null){
|
|
|
targetVo.setProvinceCityAmt(cityRegionAmt); |
|
|
// targetVo.setBudgetAmt(target.getBudgetAmt());
|
|
|
BigDecimal provinceCityRegionAmt = sList.stream().map(a->a.getProvinceCityRegionAmt()==null?BigDecimal.ZERO:a.getProvinceCityRegionAmt()).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
// }else{
|
|
|
targetVo.setProvinceCityRegionAmt(provinceCityRegionAmt); |
|
|
// targetVo.setBudgetAmt(BigDecimal.ZERO);
|
|
|
|
|
|
// }
|
|
|
|
|
|
if(target.getDispatchAmt()!=null) { |
|
|
|
|
|
targetVo.setDispatchAmt(targetVo.getDispatchAmt().add(target.getDispatchAmt())); |
|
|
|
|
|
} |
|
|
|
|
|
if(target.getTotalRealAmt()!=null) { |
|
|
|
|
|
targetVo.setTotalRealAmt(targetVo.getTotalRealAmt().add(target.getTotalRealAmt())); |
|
|
|
|
|
} |
|
|
|
|
|
if(target.getLastYearDispatchAmt()!=null) { |
|
|
|
|
|
targetVo.setLastYearDispatchAmt(targetVo.getLastYearDispatchAmt().add(target.getLastYearDispatchAmt())); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
//预算费率 = 预算费用/销售目标
|
|
|
//预算费率 = 预算费用/销售目标
|
|
|
if(targetVo.getTargetAmt().compareTo(BigDecimal.ZERO)!=0) { |
|
|
if(targetVo.getTargetAmt()!=null && targetVo.getTargetAmt().compareTo(BigDecimal.ZERO)!=0) { |
|
|
targetVo.setBudgetRate(targetVo.getBudgetAmt().divide(targetVo.getTargetAmt(), 2, RoundingMode.DOWN)); |
|
|
targetVo.setBudgetRate(targetVo.getBudgetAmt().divide(targetVo.getTargetAmt(), 2, RoundingMode.DOWN)); |
|
|
//发货达成率 = 实际发货/销售目标
|
|
|
//发货达成率 = 实际发货/销售目标
|
|
|
targetVo.setDispatchRate(targetVo.getDispatchAmt().divide(targetVo.getTargetAmt(), 2, RoundingMode.DOWN)); |
|
|
targetVo.setDispatchRate(targetVo.getDispatchAmt().divide(targetVo.getTargetAmt(), 2, RoundingMode.DOWN)); |
|
@ -136,7 +163,7 @@ public class BirBudgetTargetServiceImpl extends ServiceImpl<BirBudgetTargetMappe |
|
|
targetVo.setDispatchRate(BigDecimal.ZERO); |
|
|
targetVo.setDispatchRate(BigDecimal.ZERO); |
|
|
} |
|
|
} |
|
|
//(当前发货-去年同期发货)/去年同期发货
|
|
|
//(当前发货-去年同期发货)/去年同期发货
|
|
|
if(targetVo.getLastYearDispatchAmt().compareTo(BigDecimal.ZERO)!=0) { |
|
|
if(targetVo.getLastYearDispatchAmt()!=null && targetVo.getLastYearDispatchAmt().compareTo(BigDecimal.ZERO)!=0) { |
|
|
targetVo.setLastYearGrowRate( |
|
|
targetVo.setLastYearGrowRate( |
|
|
targetVo.getDispatchAmt() |
|
|
targetVo.getDispatchAmt() |
|
|
.subtract(targetVo.getLastYearDispatchAmt()) |
|
|
.subtract(targetVo.getLastYearDispatchAmt()) |
|
@ -146,7 +173,7 @@ public class BirBudgetTargetServiceImpl extends ServiceImpl<BirBudgetTargetMappe |
|
|
targetVo.setLastYearGrowRate(BigDecimal.ZERO); |
|
|
targetVo.setLastYearGrowRate(BigDecimal.ZERO); |
|
|
} |
|
|
} |
|
|
//实际费用率=实际费用/实际发货
|
|
|
//实际费用率=实际费用/实际发货
|
|
|
if(targetVo.getDispatchAmt().compareTo(BigDecimal.ZERO)!=0) { |
|
|
if(targetVo.getDispatchAmt()!=null && targetVo.getDispatchAmt().compareTo(BigDecimal.ZERO)!=0) { |
|
|
targetVo.setProvinceCityRate(targetVo.getProvinceCityAmt().divide(targetVo.getDispatchAmt(), 2, RoundingMode.DOWN)); |
|
|
targetVo.setProvinceCityRate(targetVo.getProvinceCityAmt().divide(targetVo.getDispatchAmt(), 2, RoundingMode.DOWN)); |
|
|
targetVo.setProvinceCityRegionRate(targetVo.getProvinceCityRegionAmt().divide(targetVo.getDispatchAmt(), 2, RoundingMode.DOWN)); |
|
|
targetVo.setProvinceCityRegionRate(targetVo.getProvinceCityRegionAmt().divide(targetVo.getDispatchAmt(), 2, RoundingMode.DOWN)); |
|
|
targetVo.setTotalRealRate(targetVo.getTotalRealAmt().divide(targetVo.getDispatchAmt(), 2, RoundingMode.DOWN)); |
|
|
targetVo.setTotalRealRate(targetVo.getTotalRealAmt().divide(targetVo.getDispatchAmt(), 2, RoundingMode.DOWN)); |
|
|