From bdb3064ce85d6c4bc41825935bb70b49b625735d Mon Sep 17 00:00:00 2001 From: xxssyyyyssxx Date: Fri, 5 Nov 2021 14:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=AE=97=E9=A1=B5=E9=9D=A2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A0=B9=E6=8D=AE=E6=98=8E=E7=BB=86=E8=A1=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=EF=BC=8C=E9=98=B2=E6=AD=A2=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/service/ProjectBudgetService.java | 167 +++++++++++++----- .../templates/admin/project_budget_edit.ftl | 80 ++++----- 2 files changed, 166 insertions(+), 81 deletions(-) diff --git a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java index 7c6d99e..1eb52f2 100644 --- a/src/main/java/cn/palmte/work/service/ProjectBudgetService.java +++ b/src/main/java/cn/palmte/work/service/ProjectBudgetService.java @@ -160,60 +160,145 @@ public class ProjectBudgetService { public BudgetBean getBudget(Project project) { BudgetBean budgetBean = new BudgetBean(); - List incomes = projectBudgetIncomeRepository.findAllByProjectIdEquals(project.getId()); - - List collect = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_DEVICE).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(collect)){ - //要么全部,要么没有 - return budgetBean; + List incomeDetails = projectBudgetIncomeDetailRepository.findAllByProjectIdEquals(project.getId()); + if(CollectionUtil.isNotEmpty(incomeDetails)){ + //设备类收入,含税和不含税 + List collectDevice = incomeDetails.stream().filter(d -> d.getType() == ProjectBudgetIncomeDetail.TYPE_DEVICE).collect(Collectors.toList()); + budgetBean.setIncomeDeviceTaxInclude(getIncomeTotalTaxInclude(collectDevice)); + budgetBean.setIncomeDeviceTaxExclude(getIncomeTotalTaxExclude(collectDevice)); + //工程类收入,含税和不含税 + List collectEngineer = incomeDetails.stream().filter(d -> d.getType() == ProjectBudgetIncomeDetail.TYPE_ENGINEER).collect(Collectors.toList()); + budgetBean.setIncomeEngineerTaxInclude(getIncomeTotalTaxInclude(collectEngineer)); + budgetBean.setIncomeEngineerTaxExclude(getIncomeTotalTaxExclude(collectEngineer)); + //服务类收入,含税和不含税 + List collectService = incomeDetails.stream().filter(d -> d.getType() == ProjectBudgetIncomeDetail.TYPE_SERVICE).collect(Collectors.toList()); + budgetBean.setIncomeServiceTaxInclude(getIncomeTotalTaxInclude(collectService)); + budgetBean.setIncomeServiceTaxExclude(getIncomeTotalTaxExclude(collectService)); } - ProjectBudgetIncome projectBudgetIncomeDevice = collect.get(0); - budgetBean.setIncomeDeviceTaxInclude(projectBudgetIncomeDevice.getIncomeTaxInclude()); - budgetBean.setIncomeDeviceTaxExclude(projectBudgetIncomeDevice.getIncomeTaxExclude()); - ProjectBudgetIncome projectBudgetIncomeEngineer = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_ENGINEER).collect(Collectors.toList()).get(0); - budgetBean.setIncomeEngineerTaxInclude(projectBudgetIncomeEngineer.getIncomeTaxInclude()); - budgetBean.setIncomeEngineerTaxExclude(projectBudgetIncomeEngineer.getIncomeTaxExclude()); + List projectBudgetCostDetails = projectBudgetCostDetailRepository.findAllByProjectIdEquals(project.getId()); + if(CollectionUtil.isNotEmpty(projectBudgetCostDetails)){ + //采购成本-设备,含税和不含税 + List collectDevice = projectBudgetCostDetails.stream().filter(d -> d.getType() == ProjectBudgetCostDetail.TYPE_DEVICE).collect(Collectors.toList()); + budgetBean.setCostPurchaseDeviceTaxInclude(getCostTotalTaxInclude(collectDevice)); + budgetBean.setCostPurchaseDeviceTaxExclude(getCostTotalTaxExclude(collectDevice)); + //采购成本-施工,含税和不含税 + List collectBuild = projectBudgetCostDetails.stream().filter(d -> d.getType() == ProjectBudgetCostDetail.TYPE_BUILD).collect(Collectors.toList()); + budgetBean.setCostPurchaseBuildTaxInclude(getCostTotalTaxInclude(collectBuild)); + budgetBean.setCostPurchaseBuildTaxExclude(getCostTotalTaxExclude(collectBuild)); + //采购成本-服务,含税和不含税 + List collectService = projectBudgetCostDetails.stream().filter(d -> d.getType() == ProjectBudgetCostDetail.TYPE_SERVICE).collect(Collectors.toList()); + budgetBean.setCostPurchaseServiceTaxInclude(getCostTotalTaxInclude(collectService)); + budgetBean.setCostPurchaseServiceTaxExclude(getCostTotalTaxExclude(collectService)); + //采购成本-其他,含税和不含税 + List collectOther = projectBudgetCostDetails.stream().filter(d -> d.getType() == ProjectBudgetCostDetail.TYPE_OHTER).collect(Collectors.toList()); + budgetBean.setCostPurchaseOtherTaxInclude(getCostTotalTaxInclude(collectOther)); + budgetBean.setCostPurchaseOtherTaxExclude(getCostTotalTaxExclude(collectOther)); + } - ProjectBudgetIncome projectBudgetIncomeService = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_SERVICE).collect(Collectors.toList()).get(0); - budgetBean.setIncomeServiceTaxInclude(projectBudgetIncomeService.getIncomeTaxInclude()); - budgetBean.setIncomeServiceTaxExclude(projectBudgetIncomeService.getIncomeTaxExclude()); + //项目管理成本 + List projectManageDetails = projectBudgetCostProjectManageDetailRepository.findAllByProjectIdEquals(project.getId()); + if(CollectionUtil.isNotEmpty(projectManageDetails)){ + budgetBean.setCostProjectManageTaxExclude(getCostProjectManageTotalTaxExclude(projectManageDetails)); + } + //其他其他成本 List costs = projectBudgetCostRepository.findAllByProjectIdEquals(project.getId()); + if(CollectionUtil.isNotEmpty(costs)){ + ProjectBudgetCost projectBudgetCostOtherOther = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_OTHER_OTHER).collect(Collectors.toList()).get(0); + budgetBean.setCostOtherOtherTaxInclude(projectBudgetCostOtherOther.getCostTaxInclude()); + budgetBean.setCostOtherOtherTaxExclude(projectBudgetCostOtherOther.getCostTaxExclude()); + } - ProjectBudgetCost projectBudgetCostDevice = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE).collect(Collectors.toList()).get(0); - budgetBean.setCostPurchaseDeviceTaxInclude(projectBudgetCostDevice.getCostTaxInclude()); - budgetBean.setCostPurchaseDeviceTaxExclude(projectBudgetCostDevice.getCostTaxExclude()); - ProjectBudgetCost projectBudgetCostBuild = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_BUILDING).collect(Collectors.toList()).get(0); - budgetBean.setCostPurchaseBuildTaxInclude(projectBudgetCostBuild.getCostTaxInclude()); - budgetBean.setCostPurchaseBuildTaxExclude(projectBudgetCostBuild.getCostTaxExclude()); - - ProjectBudgetCost projectBudgetCostService = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_SERVICE).collect(Collectors.toList()).get(0); - budgetBean.setCostPurchaseServiceTaxInclude(projectBudgetCostService.getCostTaxInclude()); - budgetBean.setCostPurchaseServiceTaxExclude(projectBudgetCostService.getCostTaxExclude()); - - ProjectBudgetCost projectBudgetCostOther = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_OTHER).collect(Collectors.toList()).get(0); - budgetBean.setCostPurchaseOtherTaxInclude(projectBudgetCostOther.getCostTaxInclude()); - budgetBean.setCostPurchaseOtherTaxExclude(projectBudgetCostOther.getCostTaxExclude()); - - ProjectBudgetCost projectBudgetCostProjectManage = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_PROJECT_MANAGE).collect(Collectors.toList()).get(0); - /*budgetBean.setCostProjectManageTaxInclude(projectBudgetCostProjectManage.getCostTaxInclude());*/ - budgetBean.setCostProjectManageTaxExclude(projectBudgetCostProjectManage.getCostTaxExclude()); - - ProjectBudgetCost projectBudgetCostOtherOther = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_OTHER_OTHER).collect(Collectors.toList()).get(0); - budgetBean.setCostOtherOtherTaxInclude(projectBudgetCostOtherOther.getCostTaxInclude()); - budgetBean.setCostOtherOtherTaxExclude(projectBudgetCostOtherOther.getCostTaxExclude()); + //资金占用成本 + List budgetPlanDetails = projectBudgetPlanDetailRepository.findAllByProjectIdEquals(project.getId()); + if(CollectionUtil.isNotEmpty(budgetPlanDetails)){ + budgetBean.setCostExpropriationTaxExclude(getTotalCapitalInterest(budgetPlanDetails)); + } + //公司管理成本 List manages = projectBudgetCostManageRepository.findAllByProjectIdEquals(project.getId()); - ProjectBudgetCostManage costManageExpropriation = manages.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_EXPROPRIATION).collect(Collectors.toList()).get(0); - budgetBean.setCostExpropriationTaxExclude(costManageExpropriation.getCostTaxExclude()); - ProjectBudgetCostManage costManageCompany = manages.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_COMPANY_MANAGE).collect(Collectors.toList()).get(0); - budgetBean.setCostCompanyManageTaxExclude(costManageCompany.getCostTaxExclude()); + if(CollectionUtil.isNotEmpty(manages)){ + ProjectBudgetCostManage costManageCompany = manages.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_COMPANY_MANAGE).collect(Collectors.toList()).get(0); + budgetBean.setCostCompanyManageTaxExclude(costManageCompany.getCostTaxExclude()); + } return budgetBean; } + private BigDecimal getIncomeTotalTaxInclude(List list){ + BigDecimal total = new BigDecimal(0); + if(CollectionUtil.isEmpty(list)){ + return total; + } + + for (ProjectBudgetIncomeDetail detail : list) { + total = total.add(detail.getTotalTaxInclude()); + } + + return total; + } + private BigDecimal getIncomeTotalTaxExclude(List list){ + BigDecimal total = new BigDecimal(0); + if(CollectionUtil.isEmpty(list)){ + return total; + } + + for (ProjectBudgetIncomeDetail detail : list) { + total = total.add(detail.getTotalTaxExclude()); + } + + return total; + } + private BigDecimal getCostTotalTaxInclude(List list){ + BigDecimal total = new BigDecimal(0); + if(CollectionUtil.isEmpty(list)){ + return total; + } + + for (ProjectBudgetCostDetail detail : list) { + total = total.add(detail.getTotalTaxInclude()); + } + + return total; + } + private BigDecimal getCostTotalTaxExclude(List list){ + BigDecimal total = new BigDecimal(0); + if(CollectionUtil.isEmpty(list)){ + return total; + } + + for (ProjectBudgetCostDetail detail : list) { + total = total.add(detail.getTotalTaxExclude()); + } + + return total; + } + private BigDecimal getCostProjectManageTotalTaxExclude(List list){ + BigDecimal total = new BigDecimal(0); + if(CollectionUtil.isEmpty(list)){ + return total; + } + + for (ProjectBudgetCostProjectManageDetail detail : list) { + total = total.add(detail.getTotal()); + } + + return total; + } + private BigDecimal getTotalCapitalInterest(List list){ + BigDecimal total = new BigDecimal(0); + if(CollectionUtil.isEmpty(list)){ + return total; + } + + for (ProjectBudgetPlanDetail detail : list) { + total = total.add(detail.getCapitalInterest()); + } + + return total; + } /** * 清空项目的收入明细 diff --git a/src/main/resources/templates/admin/project_budget_edit.ftl b/src/main/resources/templates/admin/project_budget_edit.ftl index ecb1212..2a584f5 100644 --- a/src/main/resources/templates/admin/project_budget_edit.ftl +++ b/src/main/resources/templates/admin/project_budget_edit.ftl @@ -208,26 +208,26 @@ 收入 设备类 - - + + 收入 工程类 - - + + 收入 服务类 - - + + 合计 - - + + @@ -247,50 +247,50 @@ 成本 采购成本 设备 - - + + 成本 采购成本 施工 - - + + 成本 采购成本 服务 - - + + 成本 采购成本 其他 - - + + 成本 项目管理成本 项目管理成本 <#---->/ - + 成本 其他 其他 - - + + 合计 - - + + @@ -306,12 +306,12 @@ 财务费用 资金占用成本 - + 公司管理费用 - + @@ -326,13 +326,13 @@ 项目毛利 - - + + 项目贡献利润率 - - + + @@ -441,11 +441,11 @@ - - - - - + + + + + @@ -506,11 +506,11 @@ - - - - - + + + + + @@ -560,9 +560,9 @@ readonly> - - - + + +