|
@ -65,6 +65,9 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
itemVo.setCheckRealAmt(itemVo.getCheckAmt()); |
|
|
itemVo.setCheckRealAmt(itemVo.getCheckAmt()); |
|
|
//实际金额使用核销金额
|
|
|
//实际金额使用核销金额
|
|
|
itemVo.setCostAmt(itemVo.getCheckAmt()); |
|
|
itemVo.setCostAmt(itemVo.getCheckAmt()); |
|
|
|
|
|
if(itemVo.getPreAmt()==null){ |
|
|
|
|
|
itemVo.setPreAmt(BigDecimal.ZERO); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
//预估金额
|
|
|
//预估金额
|
|
|
List<BirRoiCostItemVo> forecastDataList = baseMapper.queryForecastRoiCostItems(param); |
|
|
List<BirRoiCostItemVo> forecastDataList = baseMapper.queryForecastRoiCostItems(param); |
|
@ -103,6 +106,7 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
public List<BirRoiCostItemVo> getCostRoiOfYearMonth(BirCostRoiSo param) { |
|
|
public List<BirRoiCostItemVo> getCostRoiOfYearMonth(BirCostRoiSo param) { |
|
|
Integer loadType = param.getLoadType(); |
|
|
Integer loadType = param.getLoadType(); |
|
|
String supplierId = param.getSupplierId(); |
|
|
String supplierId = param.getSupplierId(); |
|
|
|
|
|
BmsSupplier supplier = bmsSupplierMapper.selectById(supplierId); |
|
|
//最近12个月
|
|
|
//最近12个月
|
|
|
LocalDate currMonth = LocalDate.now(); |
|
|
LocalDate currMonth = LocalDate.now(); |
|
|
int currMonthNum = currMonth.getYear()*100 + currMonth.getMonthValue(); |
|
|
int currMonthNum = currMonth.getYear()*100 + currMonth.getMonthValue(); |
|
@ -117,6 +121,9 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
|
|
|
|
|
|
List<BirRoiCostItemVo> costItemVoList = this.queryRoiCostItems(costDTO); |
|
|
List<BirRoiCostItemVo> costItemVoList = this.queryRoiCostItems(costDTO); |
|
|
|
|
|
|
|
|
|
|
|
//构建大区费率
|
|
|
|
|
|
this.buildRegionCostAndRate(supplier, currMonthNum, startMonthNum, supplierCodeList, costItemVoList); |
|
|
|
|
|
|
|
|
//发货单
|
|
|
//发货单
|
|
|
List<ErpDispatchSumVo> dispatchSumVos = null; |
|
|
List<ErpDispatchSumVo> dispatchSumVos = null; |
|
|
if(supplierCodeList!=null&&supplierCodeList.size()>0){ |
|
|
if(supplierCodeList!=null&&supplierCodeList.size()>0){ |
|
@ -162,10 +169,13 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
itemVo.setYearMonth(i); |
|
|
itemVo.setYearMonth(i); |
|
|
itemVo.setYearMonthDate(LocalDate.of(i/100,month,1)); |
|
|
itemVo.setYearMonthDate(LocalDate.of(i/100,month,1)); |
|
|
itemVo.setCostAmt(BigDecimal.ZERO); |
|
|
itemVo.setCostAmt(BigDecimal.ZERO); |
|
|
|
|
|
itemVo.setPreAmt(BigDecimal.ZERO); |
|
|
itemVo.setCheckAmt(BigDecimal.ZERO); |
|
|
itemVo.setCheckAmt(BigDecimal.ZERO); |
|
|
itemVo.setCostRealAmt(BigDecimal.ZERO); |
|
|
itemVo.setCostRealAmt(BigDecimal.ZERO); |
|
|
itemVo.setCheckRealAmt(BigDecimal.ZERO); |
|
|
itemVo.setCheckRealAmt(BigDecimal.ZERO); |
|
|
itemVo.setReturnAmt(BigDecimal.ZERO); |
|
|
itemVo.setReturnAmt(BigDecimal.ZERO); |
|
|
|
|
|
itemVo.setRegionTotalCostAmt(BigDecimal.ZERO); |
|
|
|
|
|
itemVo.setRegionTotalDispatchAmt(BigDecimal.ZERO); |
|
|
itemVo.setDispatchAmt(dispatchAmt); |
|
|
itemVo.setDispatchAmt(dispatchAmt); |
|
|
costItemVos.add(itemVo); |
|
|
costItemVos.add(itemVo); |
|
|
} |
|
|
} |
|
@ -175,6 +185,57 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
return costItemVoList; |
|
|
return costItemVoList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 构建大区费率 |
|
|
|
|
|
* @param supplier |
|
|
|
|
|
* @param currMonthNum |
|
|
|
|
|
* @param startMonthNum |
|
|
|
|
|
* @param supplierCodeList |
|
|
|
|
|
* @param costItemVoList |
|
|
|
|
|
*/ |
|
|
|
|
|
private void buildRegionCostAndRate(BmsSupplier supplier, int currMonthNum, int startMonthNum, List<String> supplierCodeList, List<BirRoiCostItemVo> costItemVoList) { |
|
|
|
|
|
//加载公司内所有客户的编码
|
|
|
|
|
|
LambdaQueryWrapper<BmsSupplier> regionSupplierLqw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
regionSupplierLqw.eq(BmsSupplier::getComRegionCode, supplier.getComRegion()); |
|
|
|
|
|
regionSupplierLqw.select(BmsSupplier::getId,BmsSupplier::getCode); |
|
|
|
|
|
List<BmsSupplier> regionSupplierList = bmsSupplierMapper.selectList(regionSupplierLqw); |
|
|
|
|
|
List<String> regionSupplierIds = regionSupplierList.stream().map(BmsSupplier::getId).collect(Collectors.toList()); |
|
|
|
|
|
regionSupplierIds.add("0"); |
|
|
|
|
|
//加载公司内费用
|
|
|
|
|
|
BirRoiCostDTO costDTO4Com = new BirRoiCostDTO(); |
|
|
|
|
|
costDTO4Com.setStartMonthNum(startMonthNum); |
|
|
|
|
|
costDTO4Com.setEndMonthNum(currMonthNum); |
|
|
|
|
|
costDTO4Com.setSupplierIds(regionSupplierIds); |
|
|
|
|
|
List<BirRoiCostItemVo> costItemVoCom = this.queryRoiCostItems(costDTO4Com); |
|
|
|
|
|
//合并项
|
|
|
|
|
|
for (BirRoiCostItemVo itemVo : costItemVoList) { |
|
|
|
|
|
itemVo.setRegionTotalCostAmt(BigDecimal.ZERO); |
|
|
|
|
|
for (BirRoiCostItemVo costItemVo : costItemVoCom) { |
|
|
|
|
|
if(itemVo.getYearMonth().equals(costItemVo.getYearMonth())){ |
|
|
|
|
|
itemVo.setRegionTotalCostAmt(costItemVo.getCostRealAmt()); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//加载公司发货单
|
|
|
|
|
|
List<ErpDispatchSumVo> dispatchSumComVos = null; |
|
|
|
|
|
if(supplierCodeList !=null&& supplierCodeList.size()>0){ |
|
|
|
|
|
dispatchSumComVos = dispatchDataMapper.querySumCost(startMonthNum, currMonthNum, supplierCodeList); |
|
|
|
|
|
} |
|
|
|
|
|
for (BirRoiCostItemVo costItemVo : costItemVoList) { |
|
|
|
|
|
costItemVo.setRegionTotalDispatchAmt(BigDecimal.ZERO); |
|
|
|
|
|
if(dispatchSumComVos!=null){ |
|
|
|
|
|
for (ErpDispatchSumVo dispatchSumVo : dispatchSumComVos) { |
|
|
|
|
|
if(dispatchSumVo.getYearMonth().equals(costItemVo.getYearMonth())){ |
|
|
|
|
|
// 发货金额=原发货金额)
|
|
|
|
|
|
costItemVo.setRegionTotalDispatchAmt(dispatchSumVo.getDispatchSumCost()); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private boolean checkNotNullVale(String val){ |
|
|
private boolean checkNotNullVale(String val){ |
|
|
return val!=null&&!val.equals("0"); |
|
|
return val!=null&&!val.equals("0"); |
|
|
} |
|
|
} |
|
@ -381,8 +442,11 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
}else { |
|
|
}else { |
|
|
lqw.eq(BmsSupplier::getId,"0"); |
|
|
lqw.eq(BmsSupplier::getId,"0"); |
|
|
} |
|
|
} |
|
|
|
|
|
}else if(loadType.equals(4)){ |
|
|
|
|
|
//4->公司维度统计
|
|
|
|
|
|
lqw.eq(BmsSupplier::getComRegionCode,bmsSupplier.getComRegionCode()); |
|
|
} |
|
|
} |
|
|
if (loadType.equals(2)||loadType.equals(3)){ |
|
|
if (loadType.equals(2)||loadType.equals(3)||loadType.equals(4)){ |
|
|
List<BmsSupplier> supplierList = bmsSupplierMapper.selectList(lqw); |
|
|
List<BmsSupplier> supplierList = bmsSupplierMapper.selectList(lqw); |
|
|
List<String> supplierIds = supplierList.stream().map(BmsSupplier::getId) |
|
|
List<String> supplierIds = supplierList.stream().map(BmsSupplier::getId) |
|
|
.distinct().collect(Collectors.toList()); |
|
|
.distinct().collect(Collectors.toList()); |
|
|