From da3f51b4a0fa55d18e41e6e96a96be28a2a1d256 Mon Sep 17 00:00:00 2001 From: hanbo <2608504783@qq.com> Date: Thu, 25 Nov 2021 16:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=9C=88=E7=BB=9F=E8=AE=A1=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../palmte/work/bean/ProfitAndLossBean.java | 80 ++++++++++++++ .../cn/palmte/work/bean/StatisticsBean.java | 16 +++ .../controller/backend/ProjectController.java | 12 +- .../backend/StatisticsController.java | 9 +- .../work/model/ProjectSettleProfitMargin.java | 11 ++ .../work/service/StatisticsService.java | 104 +++++++++++++++--- .../templates/admin/month_statistics.ftl | 31 +++--- 7 files changed, 227 insertions(+), 36 deletions(-) create mode 100644 src/main/java/cn/palmte/work/bean/ProfitAndLossBean.java create mode 100644 src/main/java/cn/palmte/work/bean/StatisticsBean.java diff --git a/src/main/java/cn/palmte/work/bean/ProfitAndLossBean.java b/src/main/java/cn/palmte/work/bean/ProfitAndLossBean.java new file mode 100644 index 0000000..9fa21ca --- /dev/null +++ b/src/main/java/cn/palmte/work/bean/ProfitAndLossBean.java @@ -0,0 +1,80 @@ +package cn.palmte.work.bean; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 损益表数据 + */ +@Data +public class ProfitAndLossBean { + + private String title; + + /** + * 营业收入 + */ + private BigDecimal income; + + /** + * 营业成本 + */ + private BigDecimal cost; + + /** + * 项目管理成本 + */ + private BigDecimal manageCost; + + /** + * 其他 + */ + private BigDecimal other; + + /** + * 财务费用 + */ + private BigDecimal expropriation; + + /** + * 项目毛利 + */ + private BigDecimal grossProfit; + + /** + * 项目毛利率 + */ + private BigDecimal grossProfitProfit; + + /** + * 公司管理费用 + */ + private BigDecimal CompanyManage; + + /** + * 项目贡献利润 + */ + private BigDecimal contributionMargin; + + /** + * 项目贡献利润率 + */ + private BigDecimal contributionMarginProfit; + + /** + * 所得税费用 + */ + private BigDecimal incomeTax; + + /** + * 项目净利润 + */ + private BigDecimal netMargin; + + /** + * 项目净利润率 + */ + private BigDecimal netMarginProfit; + +} diff --git a/src/main/java/cn/palmte/work/bean/StatisticsBean.java b/src/main/java/cn/palmte/work/bean/StatisticsBean.java new file mode 100644 index 0000000..3afc85d --- /dev/null +++ b/src/main/java/cn/palmte/work/bean/StatisticsBean.java @@ -0,0 +1,16 @@ +package cn.palmte.work.bean; + +import lombok.Data; + +import java.util.List; + +@Data +public class StatisticsBean { + + private List primaryIndicatorBeanList; + + private List profitAndLossBeanList; + + private List cashFlowStatisticsBeanList; + +} diff --git a/src/main/java/cn/palmte/work/controller/backend/ProjectController.java b/src/main/java/cn/palmte/work/controller/backend/ProjectController.java index 795e646..be1b8d6 100644 --- a/src/main/java/cn/palmte/work/controller/backend/ProjectController.java +++ b/src/main/java/cn/palmte/work/controller/backend/ProjectController.java @@ -66,6 +66,8 @@ public class ProjectController extends BaseController { private ProjectSettleService projectSettleService; @Autowired private ProcurementTypeService procurementTypeService; + @Autowired + private ProjectSettleIncomeRepository projectSettleIncomeRepository; /** * 项目列表 @@ -335,7 +337,6 @@ public class ProjectController extends BaseController { */ @RequestMapping("/approve") public String approve(@RequestParam("id") int id, @RequestParam String listFrom, Map model) { - String time = "2021-11"; Project project = projectService.getProject(id); //项目信息 @@ -367,10 +368,17 @@ public class ProjectController extends BaseController { model.put("cashFlowBean", projectBudgetService.getCashFlowBean(project, projectBudgetPlanDetails)); //结算信息 + ProjectSettleIncome projectSettleIncome = projectSettleIncomeRepository.findNewByProjectId(id); + String time = ""; + if(null == projectSettleIncome){ + model.put("time", time); + }else { + time = projectSettleIncome.getTime(); + model.put("time", time); + } model.put("formerBean", projectSettleService.getFormerSettle(project, time)); model.put("monthBean", projectSettleService.getMonthSettle(project, time)); model.put("currentBean", projectSettleService.getCurrentSettle(project, time)); - model.put("time", time); //决算信息 model.put("finalBean", projectFinalSevice.getFinal(project)); diff --git a/src/main/java/cn/palmte/work/controller/backend/StatisticsController.java b/src/main/java/cn/palmte/work/controller/backend/StatisticsController.java index e479455..f085742 100644 --- a/src/main/java/cn/palmte/work/controller/backend/StatisticsController.java +++ b/src/main/java/cn/palmte/work/controller/backend/StatisticsController.java @@ -2,6 +2,7 @@ package cn.palmte.work.controller.backend; import cn.palmte.work.bean.CashFlowStatisticsBean; import cn.palmte.work.bean.PrimaryIndicatorBean; +import cn.palmte.work.bean.StatisticsBean; import cn.palmte.work.service.StatisticsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -19,10 +20,10 @@ public class StatisticsController extends BaseController{ @RequestMapping("/month") public String month(Map model){ - List primaryIndicatorList = statisticsService.getPrimaryIndicator(); - List cashFlowList = statisticsService.getCashFlow(); - model.put("primaryIndicatorList",primaryIndicatorList); - model.put("cashFlowList",cashFlowList); + StatisticsBean statisticsData = statisticsService.getStatisticsData(); + model.put("primaryIndicatorList",statisticsData.getPrimaryIndicatorBeanList()); + model.put("profitAndLossList",statisticsData.getProfitAndLossBeanList()); + model.put("cashFlowList",statisticsData.getCashFlowStatisticsBeanList()); return "admin/month_statistics"; } diff --git a/src/main/java/cn/palmte/work/model/ProjectSettleProfitMargin.java b/src/main/java/cn/palmte/work/model/ProjectSettleProfitMargin.java index c903cae..b53bc5b 100644 --- a/src/main/java/cn/palmte/work/model/ProjectSettleProfitMargin.java +++ b/src/main/java/cn/palmte/work/model/ProjectSettleProfitMargin.java @@ -44,6 +44,17 @@ public class ProjectSettleProfitMargin { @Column(name = "budget") private BigDecimal budget; + @Column(name = "profit_margin") + private BigDecimal profitMargin; + + public BigDecimal getProfitMargin() { + return profitMargin; + } + + public void setProfitMargin(BigDecimal profitMargin) { + this.profitMargin = profitMargin; + } + public Integer getId() { return id; } diff --git a/src/main/java/cn/palmte/work/service/StatisticsService.java b/src/main/java/cn/palmte/work/service/StatisticsService.java index 3c74285..bbe6da8 100644 --- a/src/main/java/cn/palmte/work/service/StatisticsService.java +++ b/src/main/java/cn/palmte/work/service/StatisticsService.java @@ -2,6 +2,8 @@ package cn.palmte.work.service; import cn.palmte.work.bean.CashFlowStatisticsBean; import cn.palmte.work.bean.PrimaryIndicatorBean; +import cn.palmte.work.bean.ProfitAndLossBean; +import cn.palmte.work.bean.StatisticsBean; import cn.palmte.work.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -38,15 +40,26 @@ public class StatisticsService { @Autowired private ProjectSettleCashFlowRepository projectSettleCashFlowRepository; + @Autowired + private ProjectSettleProfitMarginRepository projectSettleProfitMarginRepository; + /** - * 分月项目统计 获取主要指标数据 + * 分月项目统计 获取主要指标数据、损益表 * * @return */ - public List getPrimaryIndicator() { + public StatisticsBean getStatisticsData() { + StatisticsBean statisticsBean = new StatisticsBean(); List list = new ArrayList<>(); + List profitAndLossList = new ArrayList<>(); + PrimaryIndicatorBean include = new PrimaryIndicatorBean(); PrimaryIndicatorBean exclude = new PrimaryIndicatorBean(); + + ProfitAndLossBean profitAndLossBeanInclude = new ProfitAndLossBean(); + ProfitAndLossBean profitAndLossBeanExclude = new ProfitAndLossBean(); + profitAndLossBeanInclude.setTitle("预算金额(含税)"); + profitAndLossBeanExclude.setTitle("预算金额(不含税)"); include.setTitle("预算金额(含税)"); exclude.setTitle("预算金额(不含税)"); //收入数据 @@ -68,6 +81,10 @@ public class StatisticsService { exclude.setIncomeEngineer(engineerIncomeTaxExcludeSum); exclude.setIncomeService(serviceIncomeTaxExcludeSum); + BigDecimal incomeInclude = allIncome.stream().map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + profitAndLossBeanInclude.setIncome(incomeInclude); + BigDecimal incomeExclude = allIncome.stream().map(ProjectBudgetIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + profitAndLossBeanExclude.setIncome(incomeExclude); } //成本数据 @@ -101,6 +118,18 @@ public class StatisticsService { exclude.setCostPurchaseOther(otherCostTaxExcludeSum); exclude.setCostProjectManage(projectManageCostTaxExcludeSum); exclude.setCostOtherOther(otherOtherCostTaxExcludeSum); + + BigDecimal costInclude = allCost.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE || d.getType() == ProjectBudgetCost.TYPE_BUILDING || d.getType() == ProjectBudgetCost.TYPE_SERVICE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal costExclude = allCost.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE || d.getType() == ProjectBudgetCost.TYPE_BUILDING || d.getType() == ProjectBudgetCost.TYPE_SERVICE).map(ProjectBudgetCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + profitAndLossBeanInclude.setCost(costInclude); + profitAndLossBeanInclude.setManageCost(projectManageCostTaxIncludeSum); + profitAndLossBeanInclude.setOther(otherCostTaxIncludeSum.add(otherOtherCostTaxIncludeSum)); + + profitAndLossBeanExclude.setCost(costExclude); + profitAndLossBeanInclude.setManageCost(projectManageCostTaxExcludeSum); + profitAndLossBeanExclude.setOther(otherCostTaxExcludeSum.add(otherOtherCostTaxExcludeSum)); + } //管理成本数据 @@ -111,13 +140,20 @@ public class StatisticsService { exclude.setCostExpropriation(expropriationSum); exclude.setCostCompanyManage(companyManageSum); + + profitAndLossBeanExclude.setExpropriation(expropriationSum); + profitAndLossBeanExclude.setCompanyManage(companyManageSum); } list.add(include); list.add(exclude); + profitAndLossList.add(profitAndLossBeanInclude); + profitAndLossList.add(profitAndLossBeanExclude); PrimaryIndicatorBean allSettle = new PrimaryIndicatorBean(); + ProfitAndLossBean allProfitAndLoss = new ProfitAndLossBean(); allSettle.setTitle("实际累计(不含税)"); + allProfitAndLoss.setTitle("实际累计(不含税)"); List allSettleIncome = projectSettleIncomeRepository.findAll(); if (CollectionUtil.isNotEmpty(allSettleIncome)) { @@ -128,6 +164,9 @@ public class StatisticsService { allSettle.setIncomeDevice(incomeDeviceAll); allSettle.setIncomeEngineer(incomeEngineerAll); allSettle.setIncomeService(incomeServiceAll); + + BigDecimal incomeExclude = allSettleIncome.stream().map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + allProfitAndLoss.setIncome(incomeExclude); } List allSettleCost = projectSettleCostRepository.findAll(); @@ -145,6 +184,12 @@ public class StatisticsService { allSettle.setCostPurchaseOther(costOtherAll); allSettle.setCostProjectManage(costProjectManageAll); allSettle.setCostOtherOther(costOtherOtherAll); + + BigDecimal cost = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE || d.getType() == ProjectSettleCost.TYPE_BUILDING || d.getType() == ProjectSettleCost.TYPE_SERVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + allProfitAndLoss.setCost(cost); + allProfitAndLoss.setManageCost(costProjectManageAll); + allProfitAndLoss.setOther(costOtherAll.add(costOtherOtherAll)); + } List allSettleCostManage = projectSettleCostManageRepository.findAll(); @@ -154,15 +199,33 @@ public class StatisticsService { allSettle.setCostExpropriation(expropriationAll); allSettle.setCostCompanyManage(companyManageAll); + + allProfitAndLoss.setExpropriation(expropriationAll); + allProfitAndLoss.setCompanyManage(companyManageAll); } + + List profitMargins = projectSettleProfitMarginRepository.findAll(); + 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 typeContributionProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal typeNetProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_NET_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + + allProfitAndLoss.setGrossProfit(typeGrossProfit); + allProfitAndLoss.setContributionMargin(typeContributionProfit); + allProfitAndLoss.setNetMargin(typeNetProfit); + } + list.add(allSettle); + profitAndLossList.add(allProfitAndLoss); List projectTime = projectSettleIncomeRepository.getProjectTime(); if (CollectionUtil.isNotEmpty(projectTime)) { for (String time : projectTime) { PrimaryIndicatorBean primaryIndicatorBean = new PrimaryIndicatorBean(); + ProfitAndLossBean profitAndLossBean = new ProfitAndLossBean(); primaryIndicatorBean.setTitle(time); + profitAndLossBean.setTitle(time); BigDecimal incomeDevice = allSettleIncome.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleIncome.TYPE_DEVICE).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal incomeEngineer = allSettleIncome.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleIncome.TYPE_ENGINEER).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); @@ -172,6 +235,9 @@ public class StatisticsService { primaryIndicatorBean.setIncomeEngineer(incomeEngineer); primaryIndicatorBean.setIncomeService(incomeService); + BigDecimal income = allSettleIncome.stream().filter(d -> d.getTime().equals(time)).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + profitAndLossBean.setIncome(income); + BigDecimal costDevice = allSettleCost.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleCost.TYPE_DEVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal costBuilding = allSettleCost.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleCost.TYPE_BUILDING).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal costService = allSettleCost.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleCost.TYPE_SERVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); @@ -179,7 +245,6 @@ public class StatisticsService { BigDecimal costProjectManage = allSettleCost.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleCost.TYPE_PROJECT_MANAGE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal costOtherOther = allSettleCost.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleCost.TYPE_OTHER_OTHER).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); - primaryIndicatorBean.setCostPurchaseDevice(costDevice); primaryIndicatorBean.setCostPurchaseBuild(costBuilding); primaryIndicatorBean.setCostPurchaseService(costService); @@ -187,28 +252,39 @@ public class StatisticsService { primaryIndicatorBean.setCostProjectManage(costProjectManage); primaryIndicatorBean.setCostOtherOther(costOtherOther); + BigDecimal cost = allSettleCost.stream().filter(d -> d.getTime().equals(time) && (d.getType() == ProjectSettleCost.TYPE_DEVICE || d.getType() == ProjectSettleCost.TYPE_BUILDING || d.getType() == ProjectSettleCost.TYPE_SERVICE)).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + profitAndLossBean.setCost(cost); + profitAndLossBean.setManageCost(costProjectManage); + profitAndLossBean.setOther(costOther.add(costOtherOther)); + BigDecimal expropriation = allSettleCostManage.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal companyManage = allSettleCostManage.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); primaryIndicatorBean.setCostExpropriation(expropriation); primaryIndicatorBean.setCostCompanyManage(companyManage); + profitAndLossBean.setExpropriation(expropriation); + profitAndLossBean.setCompanyManage(companyManage); + + BigDecimal typeGrossProfit = profitMargins.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleProfitMargin.TYPE_GROSS_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal typeContributionProfit = profitMargins.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal typeNetProfit = profitMargins.stream().filter(d -> d.getTime().equals(time) && d.getType() == ProjectSettleProfitMargin.TYPE_NET_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + + profitAndLossBean.setGrossProfit(typeGrossProfit); + profitAndLossBean.setContributionMargin(typeContributionProfit); + profitAndLossBean.setNetMargin(typeNetProfit); + list.add(primaryIndicatorBean); + profitAndLossList.add(profitAndLossBean); } } - return list; - } + List cashFlow = getCashFlow(); - /** - * 分月项目统计 获取损益表数据 - * - * @return - */ - public List getIncomeStatement() { - - - return null; + statisticsBean.setPrimaryIndicatorBeanList(list); + statisticsBean.setProfitAndLossBeanList(profitAndLossList); + statisticsBean.setCashFlowStatisticsBeanList(cashFlow); + return statisticsBean; } /** diff --git a/src/main/resources/templates/admin/month_statistics.ftl b/src/main/resources/templates/admin/month_statistics.ftl index 1d7d488..413f31c 100644 --- a/src/main/resources/templates/admin/month_statistics.ftl +++ b/src/main/resources/templates/admin/month_statistics.ftl @@ -84,24 +84,23 @@ - <#if (cashFlowList)?exists && (cashFlowList?size>0)> - <#list cashFlowList as list> + <#if (profitAndLossList)?exists && (profitAndLossList?size>0)> + <#list profitAndLossList as list> ${list.title!} - ${list.saleIncomeCash!} - ${list.taxReturn!} - ${list.earnestMoneyIncome!} - ${list.purchaseCost!} - ${list.taxCost!} - ${list.earnestMoneyCost!} - ${list.netCashFlow!} - ${list.cashInflowFromInvestingActivities!} - ${list.cashOutflowFromInvestingActivities!} - ${list.netCashFromInvestingActivities!} - ${list.financingCapitalInflow!} - ${list.financingCapitalOutflow!} - ${list.financingCapitalCashflow!} - ${list.netIncreaseMonetaryFunds!} + ${(list.cost!0)?string("0.##")} + ${(list.income!0)?string("0.##")} + ${(list.manageCost!0)?string("0.##")} + ${(list.other!0)?string("0.##")} + ${(list.expropriation!0)?string("0.##")} + ${(list.grossProfit!0)?string("0.##")} + ${(list.grossProfitProfit!0)?string("0.##")} + ${(list.companyManage!0)?string("0.##")} + ${(list.contributionMargin!0)?string("0.##")} + ${(list.contributionMarginProfit!0)?string("0.##")} + ${(list.incomeTax!0)?string("0.##")} + ${(list.netMargin!0)?string("0.##")} + ${(list.netMarginProfit!0)?string("0.##")}