|
|
@ -5,6 +5,7 @@ import cn.palmte.work.bean.PrimaryIndicatorBean;
|
|
|
|
import cn.palmte.work.bean.ProfitAndLossBean;
|
|
|
|
import cn.palmte.work.bean.ProfitAndLossBean;
|
|
|
|
import cn.palmte.work.bean.StatisticsBean;
|
|
|
|
import cn.palmte.work.bean.StatisticsBean;
|
|
|
|
import cn.palmte.work.model.*;
|
|
|
|
import cn.palmte.work.model.*;
|
|
|
|
|
|
|
|
import cn.palmte.work.utils.InterfaceUtil;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import top.jfunc.common.utils.CollectionUtil;
|
|
|
|
import top.jfunc.common.utils.CollectionUtil;
|
|
|
@ -43,6 +44,9 @@ public class StatisticsService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ProjectSettleProfitMarginRepository projectSettleProfitMarginRepository;
|
|
|
|
private ProjectSettleProfitMarginRepository projectSettleProfitMarginRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ProjectVisibleRepository projectVisibleRepository;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 分月项目统计 获取主要指标数据、损益表
|
|
|
|
* 分月项目统计 获取主要指标数据、损益表
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -62,8 +66,12 @@ public class StatisticsService {
|
|
|
|
profitAndLossBeanExclude.setTitle("预算金额(不含税)");
|
|
|
|
profitAndLossBeanExclude.setTitle("预算金额(不含税)");
|
|
|
|
include.setTitle("预算金额(含税)");
|
|
|
|
include.setTitle("预算金额(含税)");
|
|
|
|
exclude.setTitle("预算金额(不含税)");
|
|
|
|
exclude.setTitle("预算金额(不含税)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int adminId = InterfaceUtil.getAdminId();
|
|
|
|
|
|
|
|
List<Integer> projectIds = projectVisibleRepository.findProjectIdByTypeAndTid(ProjectVisible.TYPE_USER, adminId);
|
|
|
|
|
|
|
|
|
|
|
|
//收入数据
|
|
|
|
//收入数据
|
|
|
|
List<ProjectBudgetIncome> allIncome = projectBudgetIncomeRepository.findAll();
|
|
|
|
List<ProjectBudgetIncome> allIncome = projectBudgetIncomeRepository.findAllByProjectIds(projectIds);
|
|
|
|
if (CollectionUtil.isNotEmpty(allIncome)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(allIncome)) {
|
|
|
|
BigDecimal deviceIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_DEVICE).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal deviceIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_DEVICE).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal engineerIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_ENGINEER).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal engineerIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_ENGINEER).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
@ -88,7 +96,7 @@ public class StatisticsService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//成本数据
|
|
|
|
//成本数据
|
|
|
|
List<ProjectBudgetCost> allCost = projectBudgetCostRepository.findAll();
|
|
|
|
List<ProjectBudgetCost> allCost = projectBudgetCostRepository.findAllByProjectIds(projectIds);
|
|
|
|
if (CollectionUtil.isNotEmpty(allCost)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(allCost)) {
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal deviceCostTaxIncludeSum = allCost.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal deviceCostTaxIncludeSum = allCost.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
@ -133,7 +141,7 @@ public class StatisticsService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//管理成本数据
|
|
|
|
//管理成本数据
|
|
|
|
List<ProjectBudgetCostManage> allCostManage = projectBudgetCostManageRepository.findAll();
|
|
|
|
List<ProjectBudgetCostManage> allCostManage = projectBudgetCostManageRepository.findAllByProjectIds(projectIds);
|
|
|
|
if (CollectionUtil.isNotEmpty(allCostManage)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(allCostManage)) {
|
|
|
|
BigDecimal expropriationSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_EXPROPRIATION).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal expropriationSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_EXPROPRIATION).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal companyManageSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_COMPANY_MANAGE).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal companyManageSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_COMPANY_MANAGE).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
@ -155,7 +163,7 @@ public class StatisticsService {
|
|
|
|
allSettle.setTitle("实际累计(不含税)");
|
|
|
|
allSettle.setTitle("实际累计(不含税)");
|
|
|
|
allProfitAndLoss.setTitle("实际累计(不含税)");
|
|
|
|
allProfitAndLoss.setTitle("实际累计(不含税)");
|
|
|
|
|
|
|
|
|
|
|
|
List<ProjectSettleIncome> allSettleIncome = projectSettleIncomeRepository.findAll();
|
|
|
|
List<ProjectSettleIncome> allSettleIncome = projectSettleIncomeRepository.findAllByProjectIds(projectIds);
|
|
|
|
if (CollectionUtil.isNotEmpty(allSettleIncome)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(allSettleIncome)) {
|
|
|
|
BigDecimal incomeDeviceAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal incomeDeviceAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal incomeEngineerAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_ENGINEER).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal incomeEngineerAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_ENGINEER).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
@ -169,7 +177,7 @@ public class StatisticsService {
|
|
|
|
allProfitAndLoss.setIncome(incomeExclude);
|
|
|
|
allProfitAndLoss.setIncome(incomeExclude);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ProjectSettleCost> allSettleCost = projectSettleCostRepository.findAll();
|
|
|
|
List<ProjectSettleCost> allSettleCost = projectSettleCostRepository.findAllByProjectIds(projectIds);
|
|
|
|
if (CollectionUtil.isNotEmpty(allSettleCost)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(allSettleCost)) {
|
|
|
|
BigDecimal costDeviceAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal costDeviceAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal costBuildingAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_BUILDING).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal costBuildingAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_BUILDING).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
@ -192,7 +200,7 @@ public class StatisticsService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ProjectSettleCostManage> allSettleCostManage = projectSettleCostManageRepository.findAll();
|
|
|
|
List<ProjectSettleCostManage> allSettleCostManage = projectSettleCostManageRepository.findAllByProjectIds(projectIds);
|
|
|
|
if (CollectionUtil.isNotEmpty(allSettleCostManage)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(allSettleCostManage)) {
|
|
|
|
BigDecimal expropriationAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal expropriationAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal companyManageAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal companyManageAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
@ -204,7 +212,7 @@ public class StatisticsService {
|
|
|
|
allProfitAndLoss.setCompanyManage(companyManageAll);
|
|
|
|
allProfitAndLoss.setCompanyManage(companyManageAll);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<ProjectSettleProfitMargin> profitMargins = projectSettleProfitMarginRepository.findAll();
|
|
|
|
List<ProjectSettleProfitMargin> profitMargins = projectSettleProfitMarginRepository.findAllByProjectIds(projectIds);
|
|
|
|
if(CollectionUtil.isNotEmpty(profitMargins)){
|
|
|
|
if(CollectionUtil.isNotEmpty(profitMargins)){
|
|
|
|
BigDecimal typeGrossProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_GROSS_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal typeGrossProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_GROSS_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal typeContributionProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal typeContributionProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
@ -279,7 +287,7 @@ public class StatisticsService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<CashFlowStatisticsBean> cashFlow = getCashFlow();
|
|
|
|
List<CashFlowStatisticsBean> cashFlow = getCashFlow(projectIds);
|
|
|
|
|
|
|
|
|
|
|
|
statisticsBean.setPrimaryIndicatorBeanList(list);
|
|
|
|
statisticsBean.setPrimaryIndicatorBeanList(list);
|
|
|
|
statisticsBean.setProfitAndLossBeanList(profitAndLossList);
|
|
|
|
statisticsBean.setProfitAndLossBeanList(profitAndLossList);
|
|
|
@ -292,12 +300,12 @@ public class StatisticsService {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<CashFlowStatisticsBean> getCashFlow() {
|
|
|
|
public List<CashFlowStatisticsBean> getCashFlow(List<Integer> projectIds) {
|
|
|
|
List<CashFlowStatisticsBean> list = new ArrayList<>();
|
|
|
|
List<CashFlowStatisticsBean> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
CashFlowStatisticsBean cashFlowStatisticsBean = new CashFlowStatisticsBean();
|
|
|
|
CashFlowStatisticsBean cashFlowStatisticsBean = new CashFlowStatisticsBean();
|
|
|
|
cashFlowStatisticsBean.setTitle("预算金额");
|
|
|
|
cashFlowStatisticsBean.setTitle("预算金额");
|
|
|
|
List<ProjectBudgetPlanDetail> cashFlows = projectBudgetPlanDetailRepository.findAll();
|
|
|
|
List<ProjectBudgetPlanDetail> cashFlows = projectBudgetPlanDetailRepository.findAllByProjectIds(projectIds);
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal saleIncome = cashFlows.stream().map(ProjectBudgetPlanDetail::getSaleIncome).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal saleIncome = cashFlows.stream().map(ProjectBudgetPlanDetail::getSaleIncome).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
cashFlowStatisticsBean.setSaleIncomeCash(saleIncome);
|
|
|
|
cashFlowStatisticsBean.setSaleIncomeCash(saleIncome);
|
|
|
@ -327,7 +335,7 @@ public class StatisticsService {
|
|
|
|
list.add(cashFlowStatisticsBean);
|
|
|
|
list.add(cashFlowStatisticsBean);
|
|
|
|
|
|
|
|
|
|
|
|
List<String> projectTime = projectSettleCashFlowRepository.getProjectTime();
|
|
|
|
List<String> projectTime = projectSettleCashFlowRepository.getProjectTime();
|
|
|
|
List<ProjectSettleCashFlow> all = projectSettleCashFlowRepository.findAll();
|
|
|
|
List<ProjectSettleCashFlow> all = projectSettleCashFlowRepository.findAllByProjectIds(projectIds);
|
|
|
|
|
|
|
|
|
|
|
|
CashFlowStatisticsBean cashFlowStatisticsAll = new CashFlowStatisticsBean();
|
|
|
|
CashFlowStatisticsBean cashFlowStatisticsAll = new CashFlowStatisticsBean();
|
|
|
|
cashFlowStatisticsAll.setTitle("实际累计");
|
|
|
|
cashFlowStatisticsAll.setTitle("实际累计");
|
|
|
|