|
|
@ -121,16 +121,49 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
|
|
|
|
|
List<BirRoiCostItemVo> costItemVoList = this.queryRoiCostItems(costDTO); |
|
|
|
|
|
|
|
//整体费率,不添加过滤条件
|
|
|
|
BirRoiCostDTO costDTO2 = new BirRoiCostDTO(); |
|
|
|
costDTO2.setStartMonthNum(startMonthNum); |
|
|
|
costDTO2.setEndMonthNum(currMonthNum); |
|
|
|
List<BirRoiCostItemVo> DataCountAllList = baseMapper.queryRoiCostItems(costDTO2); |
|
|
|
for (BirRoiCostItemVo data1 : DataCountAllList) { |
|
|
|
for (BirRoiCostItemVo data2 : costItemVoList) { |
|
|
|
if(data1.getYearMonth().equals(data2.getYearMonth())){ |
|
|
|
data2.setAllCostAmt(data1.getCostAmt()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//构建大区费率
|
|
|
|
this.buildRegionCostAndRate(supplier, currMonthNum, startMonthNum, supplierCodeList, costItemVoList); |
|
|
|
|
|
|
|
//发货单
|
|
|
|
//客户发货单
|
|
|
|
List<ErpDispatchSumVo> dispatchSumVos = null; |
|
|
|
if(supplierCodeList!=null&&supplierCodeList.size()>0){ |
|
|
|
dispatchSumVos = dispatchDataMapper.querySumCost(startMonthNum,currMonthNum,supplierCodeList); |
|
|
|
} |
|
|
|
//整体发货单
|
|
|
|
List<ErpDispatchSumVo> allDispatch = dispatchDataMapper.querySumCost(startMonthNum,currMonthNum,null); |
|
|
|
|
|
|
|
for (BirRoiCostItemVo costItemVo : costItemVoList) { |
|
|
|
costItemVo.setDispatchAmt(BigDecimal.ZERO); |
|
|
|
costItemVo.setAllDispatchAmt(BigDecimal.ZERO); |
|
|
|
//关联 整体发货单
|
|
|
|
for (ErpDispatchSumVo dispatch : allDispatch) { |
|
|
|
if(dispatch.getYearMonth().equals(costItemVo.getYearMonth())){ |
|
|
|
// 发货金额=原发货金额)
|
|
|
|
costItemVo.setAllDispatchAmt(dispatch.getDispatchSumCost()); |
|
|
|
//设置整体维度ROI
|
|
|
|
if (costItemVo.getAllCostAmt()!=null |
|
|
|
&&costItemVo.getAllDispatchAmt()!=null |
|
|
|
&&costItemVo.getAllDispatchAmt().compareTo(BigDecimal.ZERO)!=0){ |
|
|
|
costItemVo.setAllRoiRate(costItemVo.getAllCostAmt().divide(costItemVo.getAllDispatchAmt(),2,RoundingMode.DOWN)); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//关联 客户发货单
|
|
|
|
if(dispatchSumVos!=null){ |
|
|
|
for (ErpDispatchSumVo dispatchSumVo : dispatchSumVos) { |
|
|
|
if(dispatchSumVo.getYearMonth().equals(costItemVo.getYearMonth())){ |
|
|
@ -141,6 +174,8 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//补充数据0的项
|
|
|
|
List<BirRoiCostItemVo> costItemVos = new ArrayList<>(); |
|
|
|
for (int i = startMonthNum; i <= currMonthNum; i++) { |
|
|
@ -269,6 +304,66 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
|
return ytdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Float getYtdAllPercent(List<BirRoiCostItemVo> list) { |
|
|
|
Float ytdPercent = null; |
|
|
|
|
|
|
|
LocalDate currMonth = LocalDate.now(); |
|
|
|
if(currMonth.getMonthValue()==1){ |
|
|
|
return ytdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
BigDecimal costAmt = BigDecimal.ZERO; |
|
|
|
BigDecimal dispatchAmt = BigDecimal.ZERO; |
|
|
|
|
|
|
|
currMonth = currMonth.plusMonths(-1); |
|
|
|
int currMonthNum = currMonth.getYear()*100 + currMonth.getMonthValue(); |
|
|
|
int startMonthNum = currMonth.getYear()*100 + 1; |
|
|
|
|
|
|
|
for(BirRoiCostItemVo vo:list){ |
|
|
|
if(vo.getYearMonth()<=currMonthNum && vo.getYearMonth()>=startMonthNum){ |
|
|
|
costAmt = costAmt.add(vo.getAllCostAmt()); |
|
|
|
dispatchAmt = dispatchAmt.add(vo.getAllDispatchAmt()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(dispatchAmt.compareTo(BigDecimal.ZERO)>0) { |
|
|
|
ytdPercent = costAmt.divide(dispatchAmt,4, RoundingMode.HALF_UP).floatValue(); |
|
|
|
} |
|
|
|
|
|
|
|
return ytdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Float getYtdRegionPercent(List<BirRoiCostItemVo> list) { |
|
|
|
Float ytdPercent = null; |
|
|
|
|
|
|
|
LocalDate currMonth = LocalDate.now(); |
|
|
|
if(currMonth.getMonthValue()==1){ |
|
|
|
return ytdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
BigDecimal costAmt = BigDecimal.ZERO; |
|
|
|
BigDecimal dispatchAmt = BigDecimal.ZERO; |
|
|
|
|
|
|
|
currMonth = currMonth.plusMonths(-1); |
|
|
|
int currMonthNum = currMonth.getYear()*100 + currMonth.getMonthValue(); |
|
|
|
int startMonthNum = currMonth.getYear()*100 + 1; |
|
|
|
|
|
|
|
for(BirRoiCostItemVo vo:list){ |
|
|
|
if(vo.getYearMonth()<=currMonthNum && vo.getYearMonth()>=startMonthNum){ |
|
|
|
costAmt = costAmt.add(vo.getRegionTotalCostAmt()); |
|
|
|
dispatchAmt = dispatchAmt.add(vo.getRegionTotalDispatchAmt()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(dispatchAmt.compareTo(BigDecimal.ZERO)>0) { |
|
|
|
ytdPercent = costAmt.divide(dispatchAmt,4, RoundingMode.HALF_UP).floatValue(); |
|
|
|
} |
|
|
|
|
|
|
|
return ytdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Float getQtdPercent(List<BirRoiCostItemVo> list){ |
|
|
|
Float qtdPercent = null; |
|
|
@ -307,6 +402,81 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa |
|
|
|
return qtdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Float getQtdAllPercent(List<BirRoiCostItemVo> list) { |
|
|
|
Float qtdPercent = null; |
|
|
|
|
|
|
|
LocalDate currMonth = LocalDate.now(); |
|
|
|
if(currMonth.getMonthValue()==1){ |
|
|
|
return 0F; |
|
|
|
} |
|
|
|
// 获取当前季度的第一个月
|
|
|
|
Month firstMonthOfQuarter = currMonth.getMonth().firstMonthOfQuarter(); |
|
|
|
// 获取当季第一个月的整数表示
|
|
|
|
int firstMonthInteger = firstMonthOfQuarter.getValue(); |
|
|
|
|
|
|
|
if(firstMonthInteger == currMonth.getMonthValue()){ |
|
|
|
return 0F; |
|
|
|
} |
|
|
|
|
|
|
|
currMonth = currMonth.plusMonths(-1); |
|
|
|
int currMonthNum = currMonth.getYear()*100 + currMonth.getMonthValue(); |
|
|
|
int startMonthNum = currMonth.getYear()*100 + firstMonthInteger; |
|
|
|
|
|
|
|
BigDecimal costAmt = BigDecimal.ZERO; |
|
|
|
BigDecimal dispatchAmt = BigDecimal.ZERO; |
|
|
|
|
|
|
|
for(BirRoiCostItemVo vo:list){ |
|
|
|
if(vo.getYearMonth()<=currMonthNum && vo.getYearMonth()>=startMonthNum){ |
|
|
|
costAmt = costAmt.add(vo.getAllCostAmt()); |
|
|
|
dispatchAmt = dispatchAmt.add(vo.getAllDispatchAmt()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(dispatchAmt.compareTo(BigDecimal.ZERO)>0) { |
|
|
|
qtdPercent = costAmt.divide(dispatchAmt,4, RoundingMode.HALF_UP).floatValue(); |
|
|
|
} |
|
|
|
|
|
|
|
return qtdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Float getQtdRegionPercent(List<BirRoiCostItemVo> list) { |
|
|
|
Float qtdPercent = null; |
|
|
|
|
|
|
|
LocalDate currMonth = LocalDate.now(); |
|
|
|
if(currMonth.getMonthValue()==1){ |
|
|
|
return 0F; |
|
|
|
} |
|
|
|
// 获取当前季度的第一个月
|
|
|
|
Month firstMonthOfQuarter = currMonth.getMonth().firstMonthOfQuarter(); |
|
|
|
// 获取当季第一个月的整数表示
|
|
|
|
int firstMonthInteger = firstMonthOfQuarter.getValue(); |
|
|
|
|
|
|
|
if(firstMonthInteger == currMonth.getMonthValue()){ |
|
|
|
return 0F; |
|
|
|
} |
|
|
|
|
|
|
|
currMonth = currMonth.plusMonths(-1); |
|
|
|
int currMonthNum = currMonth.getYear()*100 + currMonth.getMonthValue(); |
|
|
|
int startMonthNum = currMonth.getYear()*100 + firstMonthInteger; |
|
|
|
|
|
|
|
BigDecimal costAmt = BigDecimal.ZERO; |
|
|
|
BigDecimal dispatchAmt = BigDecimal.ZERO; |
|
|
|
|
|
|
|
for(BirRoiCostItemVo vo:list){ |
|
|
|
if(vo.getYearMonth()<=currMonthNum && vo.getYearMonth()>=startMonthNum){ |
|
|
|
costAmt = costAmt.add(vo.getRegionTotalCostAmt()); |
|
|
|
dispatchAmt = dispatchAmt.add(vo.getRegionTotalDispatchAmt()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(dispatchAmt.compareTo(BigDecimal.ZERO)>0) { |
|
|
|
qtdPercent = costAmt.divide(dispatchAmt,4, RoundingMode.HALF_UP).floatValue(); |
|
|
|
} |
|
|
|
|
|
|
|
return qtdPercent; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public YtdQtdToOAVo buildYtdAndQtdData(TbsCostApply apply){ |
|
|
|