|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.imed.costaccount.common.exception.CostException;
|
|
|
import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import com.imed.costaccount.common.util.DateUtils;
|
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
@@ -13,15 +14,13 @@ import com.imed.costaccount.constants.NumberConstant;
|
|
|
import com.imed.costaccount.enums.DateStyleEnum;
|
|
|
import com.imed.costaccount.mapper.CostDepartmentProfitMapper;
|
|
|
import com.imed.costaccount.model.*;
|
|
|
+import com.imed.costaccount.model.vo.AllocationQueryReportVO;
|
|
|
import com.imed.costaccount.model.vo.CostDepartmentProfitVO;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -41,14 +40,17 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
private final AllocationService allocationService;
|
|
|
|
|
|
+ private final AllocationQueryService allocationQueryService;
|
|
|
|
|
|
- public CostDepartmentProfitServiceImpl(ReportFormService reportFormService, IncomeCollectionService incomeCollectionService, CostShareLevelService costShareLevelService, ResponsibilityService responsibilityService, ReportRelationService reportRelationService, AllocationService allocationService) {
|
|
|
+
|
|
|
+ public CostDepartmentProfitServiceImpl(ReportFormService reportFormService, IncomeCollectionService incomeCollectionService, CostShareLevelService costShareLevelService, ResponsibilityService responsibilityService, ReportRelationService reportRelationService, AllocationService allocationService, AllocationQueryService allocationQueryService) {
|
|
|
this.reportFormService = reportFormService;
|
|
|
this.incomeCollectionService = incomeCollectionService;
|
|
|
this.costShareLevelService = costShareLevelService;
|
|
|
this.responsibilityService = responsibilityService;
|
|
|
this.reportRelationService = reportRelationService;
|
|
|
this.allocationService = allocationService;
|
|
|
+ this.allocationQueryService = allocationQueryService;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -71,11 +73,12 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
month = DateUtil.month(dateTime) + 1;
|
|
|
}
|
|
|
Page<CostDepartmentProfit> departmentProfitPage = new Page<>(current, pageSize);
|
|
|
+ // 查询的时候过过滤那些计算方式是不设置的数据
|
|
|
Page<CostDepartmentProfit> pages = this.page(departmentProfitPage, new QueryWrapper<CostDepartmentProfit>().lambda()
|
|
|
.eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
.eq(StrUtil.isNotBlank(responsibilityCode), CostDepartmentProfit::getResponsibilityCode, responsibilityCode)
|
|
|
.eq(StrUtil.isNotBlank(date), CostDepartmentProfit::getYear, year)
|
|
|
- .eq(StrUtil.isNotBlank(date), CostDepartmentProfit::getMonth, month));
|
|
|
+ .eq(StrUtil.isNotBlank(date), CostDepartmentProfit::getMonth, month).ne(CostDepartmentProfit::getCalcFormula,NumberConstant.ZERO));
|
|
|
List<CostDepartmentProfit> records = pages.getRecords();
|
|
|
List<CostDepartmentProfitVO> costDepartmentProfitVOList = BeanUtil.convertList(records, CostDepartmentProfitVO.class);
|
|
|
PageUtils pageUtils = new PageUtils(pages);
|
|
@@ -98,27 +101,39 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
year = DateUtil.year(dateTime);
|
|
|
month = DateUtil.month(dateTime) + 1;
|
|
|
}
|
|
|
- // 先查询指定条件的报表数据
|
|
|
+ // 先查询指定条件的报表数据 查询损益表的数据
|
|
|
List<ReportForm> reportFormList = reportFormService.list(new QueryWrapper<ReportForm>().lambda()
|
|
|
.eq(ReportForm::getHospId, hospId)
|
|
|
- .eq(ReportForm::getReportType, NumberConstant.ZERO).ne(ReportForm::getCalcType, NumberConstant.ZERO));
|
|
|
+ .eq(ReportForm::getReportType, NumberConstant.ZERO));
|
|
|
+
|
|
|
// 遍历报表数据根据报表数据计算方式进行计算
|
|
|
+
|
|
|
// 查询最后一个层级的责任中心
|
|
|
List<CostShareLevel> costShareLevelList = costShareLevelService.list(new QueryWrapper<CostShareLevel>().lambda()
|
|
|
.eq(CostShareLevel::getHospId, hospId).orderByDesc(CostShareLevel::getLeverSort));
|
|
|
Long id = costShareLevelList.get(0).getId();
|
|
|
// 查询责任中心里面是这个层级的所有的收益中心
|
|
|
List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
|
|
|
- .eq(Responsibility::getHospId, hospId).eq(Responsibility::getResponsibilityType, NumberConstant.ONE));
|
|
|
- // 归集前
|
|
|
+ .eq(Responsibility::getHospId, hospId).eq(Responsibility::getResponsibilityType, NumberConstant.ONE).eq(Responsibility::getShareId,id));
|
|
|
+ // 归集后
|
|
|
List<IncomeCollection> incomeList = incomeCollectionService.list(new QueryWrapper<IncomeCollection>().lambda()
|
|
|
.eq(IncomeCollection::getHospId, hospId)
|
|
|
.eq(year > 0, IncomeCollection::getYear, year).eq(month > 0, IncomeCollection::getMonth, month));
|
|
|
|
|
|
Map<Long, List<ReportRelation>> reportRelationMap = reportRelationService.list(new QueryWrapper<ReportRelation>().lambda().eq(ReportRelation::getHospId, hospId)).stream().collect(Collectors.groupingBy(ReportRelation::getReportId));
|
|
|
- // TODO 需要查询归集后的数据
|
|
|
+ // 分摊后的数据getOriginType等于2说明是分摊后的数据
|
|
|
+ List<AllocationQuery> allocationQueryList = allocationQueryService.list(new QueryWrapper<AllocationQuery>().lambda().eq(AllocationQuery::getHospId, hospId)
|
|
|
+ .eq(year > 0, AllocationQuery::getDateYear, year)
|
|
|
+ .eq(month > 0, AllocationQuery::getDateMonth, month)
|
|
|
+ .eq(AllocationQuery::getOriginType,NumberConstant.TWO));
|
|
|
+ // 封装数据
|
|
|
+ List<AllocationQueryReportVO> allocationQueryReportVOList = BeanUtil.convertList(allocationQueryList, AllocationQueryReportVO.class);
|
|
|
+ allocationQueryReportVOList.forEach(i->{
|
|
|
+ i.setAccountingCodes(Arrays.asList(i.getAccountingCode().split(StrUtil.COMMA)));
|
|
|
+ i.setAccountingNames(Arrays.asList(i.getAccountingName().split(StrUtil.COMMA)));
|
|
|
+ });
|
|
|
|
|
|
- // 查询分摊的报表数据
|
|
|
+ // 查询分摊的报表数据 后面的计算方式需要使用 小计等需要使用
|
|
|
List<Allocation> allocationList = allocationService.list(new QueryWrapper<Allocation>().lambda().eq(Allocation::getHospId, hospId)
|
|
|
.eq(year > 0, Allocation::getDateYear, year).eq(month > 0, Allocation::getDateMonth, month));
|
|
|
|
|
@@ -128,14 +143,15 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
List<CostDepartmentProfitVO> list = new ArrayList<>();
|
|
|
int finalYear = year;
|
|
|
int finalMonth = month;
|
|
|
- responsibilityList.forEach(i->{
|
|
|
- reportFormList.forEach(j->{
|
|
|
+ responsibilityList.forEach(i -> {
|
|
|
+ reportFormList.forEach(j -> {
|
|
|
CostDepartmentProfitVO costDepartmentProfitVO = new CostDepartmentProfitVO();
|
|
|
costDepartmentProfitVO.setYear(finalYear);
|
|
|
costDepartmentProfitVO.setMonth(finalMonth);
|
|
|
costDepartmentProfitVO.setReportNum(j.getNum());
|
|
|
costDepartmentProfitVO.setCostType(j.getCalcType());
|
|
|
costDepartmentProfitVO.setReportName(j.getReportName());
|
|
|
+ costDepartmentProfitVO.setCalcFormula(j.getCalcFormula());
|
|
|
costDepartmentProfitVO.setResponsibilityCode(i.getResponsibilityCode());
|
|
|
costDepartmentProfitVO.setResponsibilityName(i.getResponsibilityName());
|
|
|
costDepartmentProfitVO.setReportParentId(i.getParentId());
|
|
@@ -145,81 +161,205 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
list.add(costDepartmentProfitVO);
|
|
|
});
|
|
|
});
|
|
|
- list.forEach(i->{
|
|
|
+ Map<Integer, List<CostDepartmentProfitVO>> listMap = list.stream().collect(Collectors.groupingBy(CostDepartmentProfitVO::getReportNum));
|
|
|
+ // 记录每一次计算的钱
|
|
|
+ list.forEach(i -> {
|
|
|
Integer calcType = i.getCostType();
|
|
|
- switch (calcType){
|
|
|
+ switch (calcType) {
|
|
|
case 1:
|
|
|
// TODO 按照会计科目进行计算
|
|
|
- setAccountReportData(i,incomeList,reportRelationMap);
|
|
|
+ i.setAmount(setAccountReportData(i, incomeList, allocationQueryReportVOList, reportRelationMap));
|
|
|
break;
|
|
|
case 2:
|
|
|
// TODO 按照分摊层级进行计算
|
|
|
+ i.setAmount(setShareLevelReportData(i,costShareLevelList,reportRelationMap,allocationList));
|
|
|
break;
|
|
|
case 3:
|
|
|
- // TODO 按照小计进行计算
|
|
|
+ // TODO 按照小计进行计算
|
|
|
+ i.setAmount(setSubtotal(i,costShareLevelList,listMap,list,incomeList,allocationQueryReportVOList,reportRelationMap,allocationList));
|
|
|
break;
|
|
|
case 4:
|
|
|
// TODO 按照计算公式进行计算
|
|
|
+ i.setAmount(setCalculation(i,costShareLevelList,listMap,incomeList,allocationQueryReportVOList,reportRelationMap,allocationList));
|
|
|
break;
|
|
|
case 5:
|
|
|
// TODO 按照责任中心进行计算
|
|
|
+ i.setAmount(setResponsibilityCode(i,reportRelationMap,allocationList));
|
|
|
break;
|
|
|
default:
|
|
|
i.setAmount(new BigDecimal("0.0000"));
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
+ // 删除这个年月的数据
|
|
|
+ List<CostDepartmentProfit> list1 = this.list(new QueryWrapper<CostDepartmentProfit>().lambda().eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
+ .eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month));
|
|
|
+ this.removeByIds(list1);
|
|
|
+ // 添加数据
|
|
|
+ List<CostDepartmentProfit> costDepartmentProfits = BeanUtil.convertList(list, CostDepartmentProfit.class);
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ costDepartmentProfits.forEach(i->{
|
|
|
+ i.setCreateTime(l);
|
|
|
+ });
|
|
|
+ this.saveBatch(costDepartmentProfits);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按照会计科目进行计算
|
|
|
+ *
|
|
|
* @param i
|
|
|
*/
|
|
|
- private void setAccountReportData(CostDepartmentProfitVO i,List<IncomeCollection> list,Map<Long, List<ReportRelation>> reportRelationMap) {
|
|
|
+ private BigDecimal setAccountReportData(CostDepartmentProfitVO i, List<IncomeCollection> list, List<AllocationQueryReportVO> allocationQueryReportVOList , Map<Long, List<ReportRelation>> reportRelationMap) {
|
|
|
// 在报表关联里面查询当前报表关联的
|
|
|
List<ReportRelation> reportRelationList = reportRelationMap.get(i.getId());
|
|
|
- if (CollUtil.isNotEmpty(reportRelationList)){
|
|
|
+ AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.000"));
|
|
|
+ if (CollUtil.isNotEmpty(reportRelationList)) {
|
|
|
// 获取对应的会计科目信息 筛选会计科目的Code
|
|
|
List<String> accountList = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
|
// 查找在归集数据里面当前责任中心对应的这些会计科目的金额
|
|
|
List<IncomeCollection> incomeCollectionList = list.stream().filter(income -> income.getResponsibilityCode().equals(i.getResponsibilityCode()) && accountList.contains(income.getAccountingCode())).collect(Collectors.toList());
|
|
|
- AtomicReference<BigDecimal> sum= new AtomicReference<>(new BigDecimal("0.000"));
|
|
|
- incomeCollectionList.forEach(m->{
|
|
|
- sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
- });
|
|
|
- // TODO 需要查询分摊后的表
|
|
|
-
|
|
|
- i.setAmount(new BigDecimal(sum.toString()));
|
|
|
- }else {
|
|
|
- i.setAmount(new BigDecimal("0.0000"));
|
|
|
+ // 需要查询分摊后的表
|
|
|
+ List<AllocationQueryReportVO> reportVOList = allocationQueryReportVOList.stream().filter(m -> m.getResponsibilityCode().equals(i.getResponsibilityCode()) && !Collections.disjoint(accountList, m.getAccountingCodes())).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isNotEmpty(incomeCollectionList)) {
|
|
|
+ incomeCollectionList.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(reportVOList)){
|
|
|
+ reportVOList.forEach(m->{
|
|
|
+ sum.updateAndGet(v->v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ i.setAmount(new BigDecimal(sum.toString()));
|
|
|
+// numMap.put(i.getReportNum()+i.getResponsibilityCode(),new BigDecimal(sum.toString()));
|
|
|
+ return new BigDecimal(sum.toString());
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 按照分摊层级进行计算
|
|
|
+ * 按照分摊层级计算 报表分摊层级是当前的层级 并且目标责任中心失败当前责任中心
|
|
|
*/
|
|
|
- private void setShareLevelReportData(CostDepartmentProfitVO i,Map<Long, List<ReportRelation>> reportRelationMap,List<Allocation> allocationList){
|
|
|
+ private BigDecimal setShareLevelReportData(CostDepartmentProfitVO i,List<CostShareLevel> costShareLevelList, Map<Long, List<ReportRelation>> reportRelationMap, List<Allocation> allocationList) {
|
|
|
List<ReportRelation> reportRelationList = reportRelationMap.get(i.getId());
|
|
|
- // 找到对应的分摊层级的Id
|
|
|
- List<String> shareLevelIds = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
|
- if (CollUtil.isNotEmpty(shareLevelIds)){
|
|
|
+ // 找到对应的分摊层级的Id 但是分摊报表里面存的是分摊层级的序号
|
|
|
+ List<Long> shareLevelIds = reportRelationList.stream().map(ReportRelation::getRelationCode).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ List<Integer> levelShortList = costShareLevelList.stream().filter(m -> shareLevelIds.contains(m.getId())).map(CostShareLevel::getLeverSort).collect(Collectors.toList());
|
|
|
+ AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.000"));
|
|
|
+ if (CollUtil.isNotEmpty(shareLevelIds)) {
|
|
|
// 查询报表里面是当前分摊层级的数据
|
|
|
- AtomicReference<BigDecimal> sum= new AtomicReference<>(new BigDecimal("0.000"));
|
|
|
- List<Allocation> allocations = allocationList.stream().filter(m -> m.getLevelSort().equals(i.getLevelSort()) && m.getTargetResponsibilityCode().equals(i.getResponsibilityCode())).collect(Collectors.toList());
|
|
|
- allocations.forEach(m->{
|
|
|
- sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
- });
|
|
|
- i.setAmount(new BigDecimal(sum.toString()));
|
|
|
- }else {
|
|
|
- i.setAmount(new BigDecimal("0.0000"));
|
|
|
+ List<Allocation> allocations = allocationList.stream().filter(m -> levelShortList.contains(m.getLevelSort()) && m.getTargetResponsibilityCode().equals(i.getResponsibilityCode())).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isNotEmpty(allocations)) {
|
|
|
+ allocations.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
+ i.setAmount(new BigDecimal(sum.toString()));
|
|
|
+ return new BigDecimal(sum.toString());
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 按照责任中心进行计算
|
|
|
* 原始责任中心是设置的责任中心 目标责任中心是报表的责任中心
|
|
|
+ * 查询分摊报表里面目标责任中心是当前责任中心 报表责任中心是当前设置的责任中心
|
|
|
*/
|
|
|
- public void setResponsibilityCode(){
|
|
|
+ public BigDecimal setResponsibilityCode(CostDepartmentProfitVO costDepartmentProfitVO, Map<Long, List<ReportRelation>> reportRelationMap, List<Allocation> allocationList) {
|
|
|
+ // 获取当前报表对应的责任中心
|
|
|
+ List<ReportRelation> reportRelationList = reportRelationMap.get(costDepartmentProfitVO.getId());
|
|
|
+ // 获取对应的责任中心的Code集合 这个是设置的责任中心
|
|
|
+ List<String> responsibilityCodes = reportRelationList.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList());
|
|
|
+ AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.000"));
|
|
|
+ if (CollUtil.isNotEmpty(responsibilityCodes)) {
|
|
|
+ // 查询报表里面是当前分摊层级的数据
|
|
|
+ List<Allocation> allocations = allocationList.stream().filter(i -> i.getTargetResponsibilityCode().equals(costDepartmentProfitVO.getResponsibilityCode()) && responsibilityCodes.contains(i.getResponsibilityCode())).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isNotEmpty(allocations)) {
|
|
|
+ allocations.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ costDepartmentProfitVO.setAmount(new BigDecimal(sum.toString()));
|
|
|
+ return new BigDecimal(sum.toString());
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 按照小计的计算方式
|
|
|
+ * 同一个目录下相同的其他金额的和
|
|
|
+ */
|
|
|
+ public BigDecimal setSubtotal(CostDepartmentProfitVO costDepartmentProfitVO,
|
|
|
+ List<CostShareLevel> costShareLevelList,
|
|
|
+ Map<Integer, List<CostDepartmentProfitVO>> listMap,
|
|
|
+ List<CostDepartmentProfitVO> profitVOS,
|
|
|
+ List<IncomeCollection> list,
|
|
|
+ List<AllocationQueryReportVO> allocationQueryReportVOList ,
|
|
|
+ Map<Long, List<ReportRelation>> reportRelationMap, List<Allocation> allocationList) {
|
|
|
+ // 因为报表是按照报表项目的升序进行排序的 前面的报表是已经进行计算了的
|
|
|
+ // 查询当前报表的父层级id
|
|
|
+ Long reportParentId = costDepartmentProfitVO.getReportParentId();
|
|
|
+ String responsibilityCode = costDepartmentProfitVO.getResponsibilityCode();
|
|
|
+ // 查询报表里面在当前父层级下的并且不是自己的报表项目
|
|
|
+ List<CostDepartmentProfitVO> costDepartmentProfitVOS = profitVOS.stream().filter(i -> i.getReportParentId().equals(reportParentId) && i.getResponsibilityCode().equals(costDepartmentProfitVO.getResponsibilityCode()) && !NumberConstant.THREE.equals(i.getCostType())).collect(Collectors.toList());
|
|
|
+ BigDecimal sum = new BigDecimal("0.0000");
|
|
|
+ // 遍历数据 之前的已经经过了计算
|
|
|
+ costDepartmentProfitVOS.forEach(i->{
|
|
|
+ Integer num = i.getReportNum();
|
|
|
+ List<CostDepartmentProfitVO> costDepartmentProfitVOS1 = listMap.get(num);
|
|
|
+ if (CollUtil.isEmpty(costDepartmentProfitVOS1)){
|
|
|
+ throw new CostException(500,"报表未找到");
|
|
|
+ }
|
|
|
+ sum.add(getAmount(profitVOS,costShareLevelList,responsibilityCode,list,allocationQueryReportVOList,reportRelationMap,allocationList,listMap));
|
|
|
+ });
|
|
|
+ costDepartmentProfitVO.setAmount(new BigDecimal(sum.toString()));
|
|
|
+ return new BigDecimal(sum.toString());
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * 按照计算方式进行计算
|
|
|
+ */
|
|
|
+ public BigDecimal setCalculation(CostDepartmentProfitVO costDepartmentProfitVO,List<CostShareLevel> costShareLevelList,Map<Integer, List<CostDepartmentProfitVO>> listMap,List<IncomeCollection> list,List<AllocationQueryReportVO> allocationQueryReportVOList , Map<Long, List<ReportRelation>> reportRelationMap, List<Allocation> allocationList){
|
|
|
+ // 获取当前报表的计算方式 [1]+[2]类型
|
|
|
+ String calcFormula = costDepartmentProfitVO.getCalcFormula();
|
|
|
+ String responsibilityCode = costDepartmentProfitVO.getResponsibilityCode();
|
|
|
+ String replace = calcFormula.replace("[", "").replace("]", "").replace("+", ",");
|
|
|
+ List<Integer> calcFormulaList = Arrays.stream(replace.split(StrUtil.COMMA)).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
+ BigDecimal bigDecimal = new BigDecimal("0.0000");
|
|
|
+ calcFormulaList.forEach(i->{
|
|
|
+ List<CostDepartmentProfitVO> profitVOS = listMap.get(i);
|
|
|
+ if (CollUtil.isEmpty(profitVOS)){
|
|
|
+ throw new CostException(500,"报表未找到");
|
|
|
+ }
|
|
|
+ bigDecimal.add(getAmount(profitVOS,costShareLevelList,responsibilityCode,list,allocationQueryReportVOList,reportRelationMap,allocationList,listMap));
|
|
|
+ });
|
|
|
+ return bigDecimal;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 判断是那种计算方式 调用方法进行计算
|
|
|
+ */
|
|
|
+ public BigDecimal getAmount(List<CostDepartmentProfitVO> profitVOS,
|
|
|
+ List<CostShareLevel> costShareLevelList,
|
|
|
+ String responsibilityCode,List<IncomeCollection> list,
|
|
|
+ List<AllocationQueryReportVO> allocationQueryReportVOList ,
|
|
|
+ Map<Long, List<ReportRelation>> reportRelationMap, List<Allocation> allocationList,
|
|
|
+ Map<Integer, List<CostDepartmentProfitVO>> listMap){
|
|
|
+ BigDecimal bigDecimal = new BigDecimal("0.0000");
|
|
|
+ // 在对这个报表进行过滤
|
|
|
+ List<CostDepartmentProfitVO> costDepartmentProfitVOS = profitVOS.stream().filter(i -> i.getResponsibilityCode().equals(responsibilityCode)).collect(Collectors.toList());
|
|
|
+ // 都一个就是
|
|
|
+ CostDepartmentProfitVO costDepartmentProfitVO = costDepartmentProfitVOS.get(0);
|
|
|
+ Integer costType = costDepartmentProfitVO.getCostType();
|
|
|
+ if (NumberConstant.ONE.equals(costType)){
|
|
|
+ // 调用计算的方法 按照会计科目
|
|
|
+ bigDecimal=setAccountReportData(costDepartmentProfitVO,list,allocationQueryReportVOList,reportRelationMap);
|
|
|
+ }else if (NumberConstant.TWO.equals(costType)){
|
|
|
+ // 按照分摊层级
|
|
|
+ bigDecimal=setShareLevelReportData(costDepartmentProfitVO,costShareLevelList,reportRelationMap,allocationList);
|
|
|
+ }else if (NumberConstant.THREE.equals(costType)){
|
|
|
+ // 小计
|
|
|
+ bigDecimal=setSubtotal(costDepartmentProfitVO,costShareLevelList,listMap,profitVOS,list,allocationQueryReportVOList,reportRelationMap,allocationList);
|
|
|
+ }else if (NumberConstant.FIVE.equals(costType)){
|
|
|
+ // 按照责任中心
|
|
|
+ bigDecimal=setResponsibilityCode(costDepartmentProfitVO,reportRelationMap,allocationList);
|
|
|
+ }
|
|
|
+ return bigDecimal;
|
|
|
}
|
|
|
}
|