|
@ -14,6 +14,7 @@ import com.qs.serve.common.util.model.DateFormatString; |
|
|
import com.qs.serve.modules.bir.entity.BirActivityCenterGoods; |
|
|
import com.qs.serve.modules.bir.entity.BirActivityCenterGoods; |
|
|
import com.qs.serve.modules.bir.entity.dto.BirRoiCostDTO; |
|
|
import com.qs.serve.modules.bir.entity.dto.BirRoiCostDTO; |
|
|
import com.qs.serve.modules.bir.entity.vo.YtdQtdToOAVo; |
|
|
import com.qs.serve.modules.bir.entity.vo.YtdQtdToOAVo; |
|
|
|
|
|
import com.qs.serve.modules.bir.service.BirActivityCenterGoodsService; |
|
|
import com.qs.serve.modules.bir.service.BirRoiRateService; |
|
|
import com.qs.serve.modules.bir.service.BirRoiRateService; |
|
|
import com.qs.serve.modules.bms.entity.BmsRegion; |
|
|
import com.qs.serve.modules.bms.entity.BmsRegion; |
|
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
|
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
|
@ -89,6 +90,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
private TbsCostPercentMapper tbsCostPercentMapper; |
|
|
private TbsCostPercentMapper tbsCostPercentMapper; |
|
|
private TbsScheduleItemBudgetMapper tbsScheduleItemBudgetMapper; |
|
|
private TbsScheduleItemBudgetMapper tbsScheduleItemBudgetMapper; |
|
|
private final ErpDispatchDataMapper dispatchDataMapper; |
|
|
private final ErpDispatchDataMapper dispatchDataMapper; |
|
|
|
|
|
private BirActivityCenterGoodsService birActivityCenterGoodsService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -425,21 +427,12 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
List<TbsBudgetCostItem> tbsBudgetCostItems = result.getBudgetMatchList(); |
|
|
List<TbsBudgetCostItem> tbsBudgetCostItems = result.getBudgetMatchList(); |
|
|
List<Long> scheduleItemBudgetIds = tbsBudgetCostItems.stream().map(a->a.getScheduleItemBudgetId()).distinct().collect(Collectors.toList()); |
|
|
List<Long> scheduleItemBudgetIds = tbsBudgetCostItems.stream().map(a->a.getScheduleItemBudgetId()).distinct().collect(Collectors.toList()); |
|
|
List<TbsScheduleItemBudget> tbsScheduleItemBudgets = tbsScheduleItemBudgetMapper.selectBatchIds(scheduleItemBudgetIds); |
|
|
List<TbsScheduleItemBudget> tbsScheduleItemBudgets = tbsScheduleItemBudgetMapper.selectBatchIds(scheduleItemBudgetIds); |
|
|
/*for(TbsScheduleItemBudget tbsScheduleItemBudget : tbsScheduleItemBudgets){ |
|
|
|
|
|
subList.add( |
|
|
|
|
|
new TbsCostSubItem.Amount( |
|
|
|
|
|
tbsScheduleItemBudget.getBudgetAmount(), |
|
|
|
|
|
tbsScheduleItemBudget.getPreDispatchAmount(), |
|
|
|
|
|
tbsScheduleItemBudget.compareTargetExpenseRate() |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
//查询发货金额,并按月份分割
|
|
|
//查询发货金额,并按月份分割
|
|
|
int year = LocalDate.now().getYear(); |
|
|
int year = LocalDate.now().getYear(); |
|
|
int month = LocalDate.now().getMonthValue(); |
|
|
int month = LocalDate.now().getMonthValue(); |
|
|
int startMonthNum = Integer.parseInt(year+"01"); |
|
|
int startMonthNum = year*100 + 1; |
|
|
int endMonthNum = Integer.parseInt(year+"01"); |
|
|
int endMonthNum = year*100 + month; |
|
|
tbsActivityCenters.stream().collect(Collectors.groupingBy(TbsActivityCenter::getCenterType)); |
|
|
tbsActivityCenters.stream().collect(Collectors.groupingBy(TbsActivityCenter::getCenterType)); |
|
|
BirRoiRateService roiRateService = SpringUtils.getBean(BirRoiRateService.class); |
|
|
BirRoiRateService roiRateService = SpringUtils.getBean(BirRoiRateService.class); |
|
|
BirRoiCostDTO costDTO = new BirRoiCostDTO(); |
|
|
BirRoiCostDTO costDTO = new BirRoiCostDTO(); |
|
@ -465,6 +458,9 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
|
|
|
|
|
|
//查询ROI底表,并拼接DTO
|
|
|
//查询ROI底表,并拼接DTO
|
|
|
List<TbsCenterGoodBirDTO> centerGoodDTOS = new ArrayList<>(); |
|
|
List<TbsCenterGoodBirDTO> centerGoodDTOS = new ArrayList<>(); |
|
|
|
|
|
// LambdaQueryWrapper<BirActivityCenterGoods> birLwq = new LambdaQueryWrapper<>();
|
|
|
|
|
|
// birLwq.in(BirActivityCenterGoods::getCenterId,tbsActivityCenters.stream().map(a->a.getCenterId()).collect(Collectors.toList()));
|
|
|
|
|
|
// List<BirActivityCenterGoods> birActivityCenterGoodsList = birActivityCenterGoodsService.list(birLwq);
|
|
|
List<BirActivityCenterGoods> birActivityCenterGoodsList = new ArrayList<>(); |
|
|
List<BirActivityCenterGoods> birActivityCenterGoodsList = new ArrayList<>(); |
|
|
//按成本中心维度分组
|
|
|
//按成本中心维度分组
|
|
|
Map<String,List<BirActivityCenterGoods>> birGroupByCenter = birActivityCenterGoodsList.stream() |
|
|
Map<String,List<BirActivityCenterGoods>> birGroupByCenter = birActivityCenterGoodsList.stream() |
|
@ -492,7 +488,10 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@NotNull |
|
|
@NotNull |
|
|
private TbsCostSubItem.CostCenter buildCostCenterParam(TbsBudgetCostResult result, List<TbsScheduleItemBudget> tbsScheduleItemBudgets, int year, int month, Map<String, List<ErpDispatchSumVo>> supplierCodeMapWithCenterType, Map<String, List<BirActivityCenterGoods>> birGroupByCenter, TbsActivityCenter activityCenter, String centerKey) { |
|
|
private TbsCostSubItem.CostCenter buildCostCenterParam(TbsBudgetCostResult result, List<TbsScheduleItemBudget> tbsScheduleItemBudgets, |
|
|
|
|
|
int year, int month, Map<String, List<ErpDispatchSumVo>> supplierCodeMapWithCenterType, |
|
|
|
|
|
Map<String, List<BirActivityCenterGoods>> birGroupByCenter, |
|
|
|
|
|
TbsActivityCenter activityCenter, String centerKey) { |
|
|
TbsCostSubItem.CostCenter costCenter = new TbsCostSubItem.CostCenter(activityCenter.getCenterName(), |
|
|
TbsCostSubItem.CostCenter costCenter = new TbsCostSubItem.CostCenter(activityCenter.getCenterName(), |
|
|
activityCenter.getCenterType()+"_"+ activityCenter.getCenterId()); |
|
|
activityCenter.getCenterType()+"_"+ activityCenter.getCenterId()); |
|
|
//设置目标销量、目标预算
|
|
|
//设置目标销量、目标预算
|
|
@ -502,6 +501,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
if (eqType && eqCost) { |
|
|
if (eqType && eqCost) { |
|
|
BigDecimal totalBudgetAmount = BigDecimal.ZERO; |
|
|
BigDecimal totalBudgetAmount = BigDecimal.ZERO; |
|
|
BigDecimal totalPreDispatchAmount = BigDecimal.ZERO; |
|
|
BigDecimal totalPreDispatchAmount = BigDecimal.ZERO; |
|
|
|
|
|
//从命中的预算周期中取出目标发货 和 目标预算 进行合计
|
|
|
for (TbsScheduleItemBudget itemBudget : tbsScheduleItemBudgets) { |
|
|
for (TbsScheduleItemBudget itemBudget : tbsScheduleItemBudgets) { |
|
|
if (itemBudget.getBudgetId().equals(budget.getId())) { |
|
|
if (itemBudget.getBudgetId().equals(budget.getId())) { |
|
|
if (itemBudget.getBudgetAmount() != null) { |
|
|
if (itemBudget.getBudgetAmount() != null) { |
|
@ -515,15 +515,15 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
costCenter.setAreaBudget(totalBudgetAmount); |
|
|
costCenter.setAreaBudget(totalBudgetAmount); |
|
|
costCenter.setTargetSales(totalPreDispatchAmount); |
|
|
costCenter.setTargetSales(totalPreDispatchAmount); |
|
|
if (totalPreDispatchAmount.compareTo(BigDecimal.ZERO) != 0) { |
|
|
if (totalPreDispatchAmount.compareTo(BigDecimal.ZERO) != 0) { |
|
|
costCenter.setTargetExpenseRate(totalBudgetAmount.divide(totalPreDispatchAmount, BigDecimal.ROUND_DOWN)); |
|
|
costCenter.setTargetExpenseRate(totalBudgetAmount.divide(totalPreDispatchAmount,2, BigDecimal.ROUND_DOWN)); |
|
|
} |
|
|
} |
|
|
//暂保持目标相关数据一致
|
|
|
//暂保持目标相关数据一致
|
|
|
costCenter.setYtdTargetSales(costCenter.getTargetSales()); |
|
|
costCenter.setYtdTargetSales(costCenter.getTargetSales()); |
|
|
costCenter.setYtdTargetBudget(costCenter.getAreaBudget()); |
|
|
costCenter.setYtdTargetBudget(costCenter.getAreaBudget()); |
|
|
costCenter.setYtdTargetExpenseRate(costCenter.getTargetExpenseRate()); |
|
|
costCenter.setYtdTargetExpenseRate(costCenter.getTargetExpenseRate()); |
|
|
costCenter.setQtdTargetSales(costCenter.getTargetSales()); |
|
|
// costCenter.setQtdTargetSales(costCenter.getTargetSales());
|
|
|
costCenter.setQtdTargetBudget(costCenter.getAreaBudget()); |
|
|
// costCenter.setQtdTargetBudget(costCenter.getAreaBudget());
|
|
|
costCenter.setQtdTargetExpenseRate(costCenter.getTargetExpenseRate()); |
|
|
// costCenter.setQtdTargetExpenseRate(costCenter.getTargetExpenseRate());
|
|
|
// costCenter.setMtdTargetSales();
|
|
|
// costCenter.setMtdTargetSales();
|
|
|
// costCenter.setMtdTargetBudget();
|
|
|
// costCenter.setMtdTargetBudget();
|
|
|
// costCenter.setMtdTargetExpenseRate();
|
|
|
// costCenter.setMtdTargetExpenseRate();
|
|
|