|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.qs.serve.modules.bir.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.qs.serve.common.enums.BudgetLogOptFlag; |
|
|
|
import com.qs.serve.common.enums.MonthValues; |
|
|
@ -389,13 +390,14 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { |
|
|
|
int[] currQ = MonthValues.getQArr(curMonth); |
|
|
|
|
|
|
|
//更变客户维度为总公司维度
|
|
|
|
List<String> supplierCode4Group = new ArrayList<>(); |
|
|
|
Set<String> supplierCode4Group = new HashSet<>(); |
|
|
|
supplierCode4Group.add(supplierCode); |
|
|
|
LambdaQueryWrapper<BmsSupplier> supplierLqw = new LambdaQueryWrapper<>(); |
|
|
|
supplierLqw.eq(BmsSupplier::getCode,supplierCode); |
|
|
|
BmsSupplier supplier = supplierMapper.selectOne(supplierLqw); |
|
|
|
if(supplier.getComRegionCode()!=null){ |
|
|
|
LambdaQueryWrapper<BmsSupplier> supplierLqw4Group = new LambdaQueryWrapper<>(); |
|
|
|
supplierLqw4Group.select(BmsSupplier::getCode); |
|
|
|
supplierLqw4Group.eq(BmsSupplier::getComRegionCode,supplier.getComRegionCode()); |
|
|
|
List<BmsSupplier> supplierList = supplierMapper.selectList(supplierLqw4Group); |
|
|
|
for (BmsSupplier bmsSupplier : supplierList) { |
|
|
@ -403,19 +405,23 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//年目标费率(已做拆分处理)
|
|
|
|
CusTargetRateDTO targetRateDTO = this.buildCusCenterTargetData(supplierCode4Group); |
|
|
|
|
|
|
|
|
|
|
|
BirMonthCusCenterSo queryCusCenterRate = new BirMonthCusCenterSo(); |
|
|
|
queryCusCenterRate.setSupplierCodeList(supplierCode4Group); |
|
|
|
queryCusCenterRate.setCenterType(centerType); |
|
|
|
queryCusCenterRate.setCenterId(centerId); |
|
|
|
queryCusCenterRate.setStartYearMonth(startMonth); |
|
|
|
queryCusCenterRate.setEndYearMonth(endMonth); |
|
|
|
//年目标费率
|
|
|
|
CusTargetRateDTO targetRateDTO = this.buildCusCenterTargetData(supplierCode4Group); |
|
|
|
List<BirActivityCenterGoodsMonthVo> centerGoodsMonthVoList = birActivityCenterGoodsMapper.listMonthCusCenterVo(queryCusCenterRate); |
|
|
|
|
|
|
|
// (已做拆分处理)
|
|
|
|
List<BirActivityCenterGoodsMonthVo> centerGoodsMonthVoList = getBirActivityCenterGoodsMonthVos(supplierCode4Group, queryCusCenterRate); |
|
|
|
|
|
|
|
BigDecimal totalCostQty = BigDecimal.ZERO; |
|
|
|
BigDecimal totalDispatchQty = BigDecimal.ZERO; |
|
|
|
|
|
|
|
List<ErpDispatchSumVo> dispatchSumVos = dispatchDataMapper.querySumCost(startMonth,endMonth,supplierCode4Group); |
|
|
|
List<ErpDispatchSumVo> dispatchSumVos = dispatchDataMapper.querySumCost(startMonth,endMonth,new ArrayList<>(supplierCode4Group)); |
|
|
|
for (int monthNumber : currQ) { |
|
|
|
String tmp = monthNumber>9?monthNumber+"":"0"+monthNumber; |
|
|
|
int currYearMonth = Integer.parseInt(curYear+tmp); |
|
|
@ -460,22 +466,61 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { |
|
|
|
costCenter.setYtdCusCenterTargetExpenseRate(targetRateDTO.getCusTargetRate()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取客户维度月度目标数据(按客户编码分组再合计) |
|
|
|
* @param supplierCode4Group |
|
|
|
* @param queryCusCenterRate |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<BirActivityCenterGoodsMonthVo> getBirActivityCenterGoodsMonthVos(Set<String> supplierCode4Group, BirMonthCusCenterSo queryCusCenterRate) { |
|
|
|
List<BirActivityCenterGoodsMonthVo> allList = new ArrayList<>(); |
|
|
|
for (List<String> cusCodes : CollUtil.split(supplierCode4Group, 800)) { |
|
|
|
queryCusCenterRate.setSupplierCodeList(cusCodes); |
|
|
|
allList.addAll(birActivityCenterGoodsMapper.listMonthCusCenterVo(queryCusCenterRate)); |
|
|
|
} |
|
|
|
Map<Integer, List<BirActivityCenterGoodsMonthVo>> map = allList.stream().collect(Collectors.groupingBy(BirActivityCenterGoodsMonthVo::getKeyNum)); |
|
|
|
List<BirActivityCenterGoodsMonthVo> rs = new ArrayList<>(); |
|
|
|
for (Integer integer : map.keySet()) { |
|
|
|
List<BirActivityCenterGoodsMonthVo> list = map.get(integer); |
|
|
|
BigDecimal costAmt = BigDecimal.ZERO; |
|
|
|
BigDecimal releaseAmt = BigDecimal.ZERO; |
|
|
|
BigDecimal usedAmt = BigDecimal.ZERO; |
|
|
|
for (BirActivityCenterGoodsMonthVo item : list) { |
|
|
|
costAmt = costAmt.add(item.getTotalCostAmt()); |
|
|
|
releaseAmt = releaseAmt.add(item.getTotalReleaseAmt()); |
|
|
|
usedAmt = usedAmt.add(item.getTotalUsedAmt()); |
|
|
|
} |
|
|
|
BirActivityCenterGoodsMonthVo rsItem = new BirActivityCenterGoodsMonthVo(); |
|
|
|
rsItem.setKeyNum(integer); |
|
|
|
rsItem.setTotalCostAmt(costAmt); |
|
|
|
rsItem.setTotalReleaseAmt(releaseAmt); |
|
|
|
rsItem.setTotalUsedAmt(usedAmt); |
|
|
|
rs.add(rsItem); |
|
|
|
} |
|
|
|
return rs; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算客户目标费率 |
|
|
|
* @param supplierCodes |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public CusTargetRateDTO buildCusCenterTargetData(List<String> supplierCodes){ |
|
|
|
public CusTargetRateDTO buildCusCenterTargetData(Set<String> supplierCodes){ |
|
|
|
String cusTargetRateQty=null; |
|
|
|
String cusTargetRate=null; |
|
|
|
LocalDate nowTime = LocalDate.now(); |
|
|
|
int curYear = nowTime.getYear(); |
|
|
|
int curMonth = nowTime.getMonthValue(); |
|
|
|
int[] currQ = MonthValues.getQArr(curMonth); |
|
|
|
List<BmsSupplierTarget> supplierTargetList = bmsSupplierTargetMapper.selectList( |
|
|
|
new LambdaQueryWrapper<BmsSupplierTarget>() |
|
|
|
.in(BmsSupplierTarget::getSupplierCode, supplierCodes) |
|
|
|
); |
|
|
|
List<BmsSupplierTarget> supplierTargetList = new ArrayList<>(); |
|
|
|
for (List<String> strings : CollUtil.split(supplierCodes, 1000)) { |
|
|
|
List<BmsSupplierTarget> supplierTargetListBySplit = bmsSupplierTargetMapper.selectList( |
|
|
|
new LambdaQueryWrapper<BmsSupplierTarget>() |
|
|
|
.in(BmsSupplierTarget::getSupplierCode, strings) |
|
|
|
); |
|
|
|
supplierTargetList.addAll(supplierTargetListBySplit); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> scheduleItemIds = supplierTargetList.stream().map(BmsSupplierTarget::getScheduleItemId).collect(Collectors.toList()); |
|
|
|
List<Long> scheduleIds = supplierTargetList.stream().map(BmsSupplierTarget::getScheduleId).collect(Collectors.toList()); |
|
|
|
Map<Long,TbsScheduleItem> scheduleItems = new HashMap<>(); |
|
|
|