diff --git a/src/main/java/cn/palmte/work/bean/CashFlowBean.java b/src/main/java/cn/palmte/work/bean/CashFlowBean.java index 081e1bd..b0ad788 100644 --- a/src/main/java/cn/palmte/work/bean/CashFlowBean.java +++ b/src/main/java/cn/palmte/work/bean/CashFlowBean.java @@ -187,6 +187,38 @@ public class CashFlowBean { .add(financingCapitalCashflow); } + /** + * 获取所有现金流量决算总额 + * @return + */ + public BigDecimal getCashFluxTotal() { + BigDecimal saleIncomeCash = getSaleIncomeCash(); + BigDecimal taxReturn = getTaxReturn(); + BigDecimal earnestMoneyIncome = getEarnestMoneyIncome(); + BigDecimal purchaseCost = getPurchaseCost(); + BigDecimal taxCost = getTaxCost(); + BigDecimal earnestMoneyCost = getEarnestMoneyCost(); + BigDecimal netCashFlow = getNetCashFlow(); + BigDecimal cashInflowFromInvestingActivities = getCashInflowFromInvestingActivities(); + BigDecimal cashOutflowFromInvestingActivities = getCashOutflowFromInvestingActivities(); + BigDecimal netCashFromInvestingActivities = getNetCashFromInvestingActivities(); + BigDecimal financingCapitalInflow = getFinancingCapitalInflow(); + BigDecimal financingCapitalOutflow = getFinancingCapitalOutflow(); + BigDecimal financingCapitalCashflow = getFinancingCapitalCashflow(); + BigDecimal netIncreaseMonetaryFunds = getNetIncreaseMonetaryFunds(); + + if (null == saleIncomeCash || null == taxReturn || null == earnestMoneyIncome || null == purchaseCost || null == taxCost + || null == earnestMoneyCost || null == netCashFlow || null == cashInflowFromInvestingActivities || + null == cashOutflowFromInvestingActivities || null == netCashFromInvestingActivities || + null == financingCapitalInflow || null == financingCapitalOutflow || null == financingCapitalCashflow || null == netIncreaseMonetaryFunds) { + return new BigDecimal(0); + } + + return saleIncomeCash.add(taxReturn).add(earnestMoneyIncome).add(purchaseCost).add(taxCost).add(earnestMoneyCost) + .add(netCashFlow).add(cashInflowFromInvestingActivities).add(cashOutflowFromInvestingActivities).add(netCashFromInvestingActivities) + .add(financingCapitalInflow).add(financingCapitalOutflow).add(financingCapitalCashflow).add(netIncreaseMonetaryFunds); + } + /** * 处理特殊值 * null就返回0 diff --git a/src/main/java/cn/palmte/work/bean/IncomeCostBean.java b/src/main/java/cn/palmte/work/bean/IncomeCostBean.java index 1288065..950a910 100644 --- a/src/main/java/cn/palmte/work/bean/IncomeCostBean.java +++ b/src/main/java/cn/palmte/work/bean/IncomeCostBean.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; /** * 预算概算页面的公共属性 + * * @author xiongshiyan at 2021/11/1 , contact me with email yanshixiong@126.com or phone 15208384257 */ public abstract class IncomeCostBean { @@ -33,7 +34,7 @@ public abstract class IncomeCostBean { */ private BigDecimal incomeServiceTaxExclude; /** - *设备采购成本含税 + * 设备采购成本含税 */ private BigDecimal costPurchaseDeviceTaxInclude; /** @@ -54,7 +55,7 @@ public abstract class IncomeCostBean { */ private BigDecimal costOtherOtherTaxInclude; /** - *设备采购成本不含税 + * 设备采购成本不含税 */ private BigDecimal costPurchaseDeviceTaxExclude; /** @@ -83,7 +84,7 @@ public abstract class IncomeCostBean { */ private BigDecimal costExpropriationTaxExclude; /** - *公司管理成本不含税 + * 公司管理成本不含税 */ private BigDecimal costCompanyManageTaxExclude; @@ -174,6 +175,7 @@ public abstract class IncomeCostBean { public BigDecimal getCostPurchaseOtherTaxInclude() { return handleSpecial(costPurchaseOtherTaxInclude); } + public void setCostPurchaseOtherTaxInclude(BigDecimal costPurchaseOtherTaxInclude) { this.costPurchaseOtherTaxInclude = costPurchaseOtherTaxInclude; } @@ -251,6 +253,20 @@ public abstract class IncomeCostBean { this.costCompanyManageTaxExclude = costCompanyManageTaxExclude; } + /** + * 计算管理成本不含税 + * + * @return + */ + public BigDecimal getCostManageExclude() { + BigDecimal costExpropriationTaxExclude = getCostExpropriationTaxExclude(); + BigDecimal costCompanyManageTaxExclude = getCostCompanyManageTaxExclude(); + if (null == costExpropriationTaxExclude || null == costCompanyManageTaxExclude) { + return handleSpecial(null); + } + return costExpropriationTaxExclude.add(costCompanyManageTaxExclude); + } + /** * 计算所有的含税收入 @@ -259,7 +275,7 @@ public abstract class IncomeCostBean { BigDecimal incomeDeviceTaxInclude = getIncomeDeviceTaxInclude(); BigDecimal incomeEngineerTaxInclude = getIncomeEngineerTaxInclude(); BigDecimal incomeServiceTaxInclude = getIncomeServiceTaxInclude(); - if(null == incomeDeviceTaxInclude || null == incomeEngineerTaxInclude || null == incomeServiceTaxInclude){ + if (null == incomeDeviceTaxInclude || null == incomeEngineerTaxInclude || null == incomeServiceTaxInclude) { return handleSpecial(null); } return incomeDeviceTaxInclude.add(incomeEngineerTaxInclude) @@ -273,7 +289,7 @@ public abstract class IncomeCostBean { BigDecimal incomeDeviceTaxExclude = getIncomeDeviceTaxExclude(); BigDecimal incomeEngineerTaxExclude = getIncomeEngineerTaxExclude(); BigDecimal incomeServiceTaxExclude = getIncomeServiceTaxExclude(); - if(null == incomeDeviceTaxExclude || null == incomeEngineerTaxExclude || null == incomeServiceTaxExclude){ + if (null == incomeDeviceTaxExclude || null == incomeEngineerTaxExclude || null == incomeServiceTaxExclude) { return handleSpecial(null); } return incomeDeviceTaxExclude.add(incomeEngineerTaxExclude) @@ -290,12 +306,12 @@ public abstract class IncomeCostBean { BigDecimal costPurchaseOtherTaxInclude = getCostPurchaseOtherTaxInclude(); BigDecimal costProjectManageTaxInclude = getCostProjectManageTaxInclude(); BigDecimal costOtherOtherTaxInclude = getCostOtherOtherTaxInclude(); - if(null == costPurchaseDeviceTaxInclude + if (null == costPurchaseDeviceTaxInclude || null == costPurchaseBuildTaxInclude || null == costPurchaseServiceTaxInclude || null == costPurchaseOtherTaxInclude || null == costProjectManageTaxInclude - || null == costOtherOtherTaxInclude){ + || null == costOtherOtherTaxInclude) { return handleSpecial(null); } return costPurchaseDeviceTaxInclude @@ -316,12 +332,12 @@ public abstract class IncomeCostBean { BigDecimal costPurchaseOtherTaxExclude = getCostPurchaseOtherTaxExclude(); BigDecimal costProjectManageTaxExclude = getCostProjectManageTaxExclude(); BigDecimal costOtherOtherTaxExclude = getCostOtherOtherTaxExclude(); - if(null == costPurchaseDeviceTaxExclude + if (null == costPurchaseDeviceTaxExclude || null == costPurchaseBuildTaxExclude || null == costPurchaseServiceTaxExclude || null == costPurchaseOtherTaxExclude || null == costProjectManageTaxExclude - || null == costOtherOtherTaxExclude){ + || null == costOtherOtherTaxExclude) { return handleSpecial(null); } return costPurchaseDeviceTaxExclude @@ -340,7 +356,7 @@ public abstract class IncomeCostBean { BigDecimal incomeTotalTaxExclude = getIncomeTotalTaxExclude(); BigDecimal costTotalTaxExclude = getCostTotalTaxExclude(); BigDecimal costExpropriationTaxExclude = getCostExpropriationTaxExclude(); - if(null == incomeTotalTaxExclude || null == costTotalTaxExclude || null == costExpropriationTaxExclude){ + if (null == incomeTotalTaxExclude || null == costTotalTaxExclude || null == costExpropriationTaxExclude) { return handleSpecial(null); } return incomeTotalTaxExclude @@ -355,16 +371,16 @@ public abstract class IncomeCostBean { public BigDecimal getProjectGrossProfitRate() { BigDecimal projectGrossProfit = getProjectGrossProfit(); BigDecimal incomeTotalTaxExclude = getIncomeTotalTaxExclude(); - if(null == projectGrossProfit || null == incomeTotalTaxExclude){ + if (null == projectGrossProfit || null == incomeTotalTaxExclude) { return handleSpecial(null); } BigDecimal zero = new BigDecimal(0); - if(projectGrossProfit.compareTo(zero) == 0 || incomeTotalTaxExclude.compareTo(zero) == 0){ + if (projectGrossProfit.compareTo(zero) == 0 || incomeTotalTaxExclude.compareTo(zero) == 0) { return handleSpecial(null); } return projectGrossProfit .multiply(new BigDecimal(100)) - .divide(incomeTotalTaxExclude,2,BigDecimal.ROUND_HALF_UP); + .divide(incomeTotalTaxExclude, 2, BigDecimal.ROUND_HALF_UP); } /** @@ -374,11 +390,12 @@ public abstract class IncomeCostBean { public BigDecimal getProjectContributionProfit() { BigDecimal projectGrossProfit = getProjectGrossProfit(); BigDecimal costCompanyManageTaxExclude = getCostCompanyManageTaxExclude(); - if(null == projectGrossProfit || null == costCompanyManageTaxExclude){ + if (null == projectGrossProfit || null == costCompanyManageTaxExclude) { return null; } return projectGrossProfit.subtract(costCompanyManageTaxExclude); } + /** * 计算项目贡献利润率 * 贡献利润(不含税)/收入总计(不含税) @@ -386,20 +403,21 @@ public abstract class IncomeCostBean { public BigDecimal getProjectContributionProfitRate() { BigDecimal projectContributionProfit = getProjectContributionProfit(); BigDecimal incomeTotalTaxExclude = getIncomeTotalTaxExclude(); - if(null == projectContributionProfit || null == incomeTotalTaxExclude){ + if (null == projectContributionProfit || null == incomeTotalTaxExclude) { return handleSpecial(null); } BigDecimal zero = new BigDecimal(0); - if(projectContributionProfit.compareTo(zero) == 0 || incomeTotalTaxExclude.compareTo(zero) == 0){ + if (projectContributionProfit.compareTo(zero) == 0 || incomeTotalTaxExclude.compareTo(zero) == 0) { return handleSpecial(null); } return projectContributionProfit .multiply(new BigDecimal(100)) - .divide(incomeTotalTaxExclude, 2,BigDecimal.ROUND_HALF_UP); + .divide(incomeTotalTaxExclude, 2, BigDecimal.ROUND_HALF_UP); } /** * 对null值如何处理 + * * @param src 原值 * @return 特殊处理之后的值 */ diff --git a/src/main/java/cn/palmte/work/bean/SettleBean.java b/src/main/java/cn/palmte/work/bean/SettleBean.java index 240df73..9c30c55 100644 --- a/src/main/java/cn/palmte/work/bean/SettleBean.java +++ b/src/main/java/cn/palmte/work/bean/SettleBean.java @@ -92,6 +92,26 @@ public class SettleBean { .add(costPurchaseOther).add(costProjectManage).add(costOther); } + /** + * 获取所有成本总额 + * + * @return + */ + public BigDecimal getCostTotal2() { + BigDecimal costPurchaseDevice = getCostPurchaseDevice(); + BigDecimal costPurchaseBuild = getCostPurchaseBuild(); + BigDecimal costPurchaseService = getCostPurchaseService(); + BigDecimal costPurchaseOther = getCostPurchaseOther(); + + if (null == costPurchaseDevice || null == costPurchaseBuild || null == costPurchaseService + || null == costPurchaseOther) { + return new BigDecimal(0); + } + + return costPurchaseDevice.add(costPurchaseBuild).add(costPurchaseService) + .add(costPurchaseOther); + } + //========================管理表================================ /** @@ -250,8 +270,12 @@ public class SettleBean { private String projectName; + protected BigDecimal handleSpecial(BigDecimal src) { + return null == src ? new BigDecimal(0) : src; + } + public BigDecimal getIncomeDevice() { - return incomeDevice; + return handleSpecial(incomeDevice); } public void setIncomeDevice(BigDecimal incomeDevice) { @@ -259,7 +283,7 @@ public class SettleBean { } public BigDecimal getIncomeEngineer() { - return incomeEngineer; + return handleSpecial(incomeEngineer); } public void setIncomeEngineer(BigDecimal incomeEngineer) { @@ -267,7 +291,7 @@ public class SettleBean { } public BigDecimal getIncomeService() { - return incomeService; + return handleSpecial(incomeService); } public void setIncomeService(BigDecimal incomeService) { @@ -275,7 +299,7 @@ public class SettleBean { } public BigDecimal getCostPurchaseDevice() { - return costPurchaseDevice; + return handleSpecial(costPurchaseDevice); } public void setCostPurchaseDevice(BigDecimal costPurchaseDevice) { @@ -283,7 +307,7 @@ public class SettleBean { } public BigDecimal getCostPurchaseBuild() { - return costPurchaseBuild; + return handleSpecial(costPurchaseBuild); } public void setCostPurchaseBuild(BigDecimal costPurchaseBuild) { @@ -291,7 +315,7 @@ public class SettleBean { } public BigDecimal getCostPurchaseService() { - return costPurchaseService; + return handleSpecial(costPurchaseService); } public void setCostPurchaseService(BigDecimal costPurchaseService) { @@ -299,7 +323,7 @@ public class SettleBean { } public BigDecimal getCostPurchaseOther() { - return costPurchaseOther; + return handleSpecial(costPurchaseOther); } public void setCostPurchaseOther(BigDecimal costPurchaseOther) { @@ -307,7 +331,7 @@ public class SettleBean { } public BigDecimal getCostProjectManage() { - return costProjectManage; + return handleSpecial(costProjectManage); } public void setCostProjectManage(BigDecimal costProjectManage) { @@ -315,7 +339,7 @@ public class SettleBean { } public BigDecimal getCostOther() { - return costOther; + return handleSpecial(costOther); } public void setCostOther(BigDecimal costOther) { @@ -323,7 +347,7 @@ public class SettleBean { } public BigDecimal getCostExpropriation() { - return costExpropriation; + return handleSpecial(costExpropriation); } public void setCostExpropriation(BigDecimal costExpropriation) { @@ -331,7 +355,7 @@ public class SettleBean { } public BigDecimal getCostCompanyManage() { - return costCompanyManage; + return handleSpecial(costCompanyManage); } public void setCostCompanyManage(BigDecimal costCompanyManage) { @@ -339,7 +363,7 @@ public class SettleBean { } public BigDecimal getCostIncomeTax() { - return costIncomeTax; + return handleSpecial(costIncomeTax); } public void setCostIncomeTax(BigDecimal costIncomeTax) { @@ -347,7 +371,7 @@ public class SettleBean { } public BigDecimal getGrossProfit() { - return grossProfit; + return handleSpecial(grossProfit); } public void setGrossProfit(BigDecimal grossProfit) { @@ -355,7 +379,7 @@ public class SettleBean { } public BigDecimal getGrossProfitProfitMargin() { - return grossProfitProfitMargin; + return handleSpecial(grossProfitProfitMargin); } public void setGrossProfitProfitMargin(BigDecimal grossProfitProfitMargin) { @@ -363,7 +387,7 @@ public class SettleBean { } public BigDecimal getContributionProfit() { - return contributionProfit; + return handleSpecial(contributionProfit); } public void setContributionProfit(BigDecimal contributionProfit) { @@ -371,7 +395,7 @@ public class SettleBean { } public BigDecimal getContributionProfitProfitMargin() { - return contributionProfitProfitMargin; + return handleSpecial(contributionProfitProfitMargin); } public void setContributionProfitProfitMargin(BigDecimal contributionProfitProfitMargin) { @@ -379,7 +403,7 @@ public class SettleBean { } public BigDecimal getNetProfit() { - return netProfit; + return handleSpecial(netProfit); } public void setNetProfit(BigDecimal netProfit) { @@ -387,7 +411,7 @@ public class SettleBean { } public BigDecimal getNetProfitProfitMargin() { - return netProfitProfitMargin; + return handleSpecial(netProfitProfitMargin); } public void setNetProfitProfitMargin(BigDecimal netProfitProfitMargin) { @@ -395,7 +419,7 @@ public class SettleBean { } public BigDecimal getSaleIncomeCash() { - return saleIncomeCash; + return handleSpecial(saleIncomeCash); } public void setSaleIncomeCash(BigDecimal saleIncomeCash) { @@ -403,7 +427,7 @@ public class SettleBean { } public BigDecimal getTaxReturn() { - return taxReturn; + return handleSpecial(taxReturn); } public void setTaxReturn(BigDecimal taxReturn) { @@ -411,7 +435,7 @@ public class SettleBean { } public BigDecimal getEarnestMoneyIncome() { - return earnestMoneyIncome; + return handleSpecial(earnestMoneyIncome); } public void setEarnestMoneyIncome(BigDecimal earnestMoneyIncome) { @@ -419,7 +443,7 @@ public class SettleBean { } public BigDecimal getPurchaseCost() { - return purchaseCost; + return handleSpecial(purchaseCost); } public void setPurchaseCost(BigDecimal purchaseCost) { @@ -427,7 +451,7 @@ public class SettleBean { } public BigDecimal getTaxCost() { - return taxCost; + return handleSpecial(taxCost); } public void setTaxCost(BigDecimal taxCost) { @@ -435,7 +459,7 @@ public class SettleBean { } public BigDecimal getEarnestMoneyCost() { - return earnestMoneyCost; + return handleSpecial(earnestMoneyCost); } public void setEarnestMoneyCost(BigDecimal earnestMoneyCost) { @@ -443,7 +467,7 @@ public class SettleBean { } public BigDecimal getCashInflowFromInvestingActivities() { - return cashInflowFromInvestingActivities; + return handleSpecial(cashInflowFromInvestingActivities); } public void setCashInflowFromInvestingActivities(BigDecimal cashInflowFromInvestingActivities) { @@ -451,7 +475,7 @@ public class SettleBean { } public BigDecimal getCashOutflowFromInvestingActivities() { - return cashOutflowFromInvestingActivities; + return handleSpecial(cashOutflowFromInvestingActivities); } public void setCashOutflowFromInvestingActivities(BigDecimal cashOutflowFromInvestingActivities) { @@ -459,7 +483,7 @@ public class SettleBean { } public BigDecimal getNetCashFromInvestingActivities() { - return netCashFromInvestingActivities; + return handleSpecial(netCashFromInvestingActivities); } public void setNetCashFromInvestingActivities(BigDecimal netCashFromInvestingActivities) { @@ -467,7 +491,7 @@ public class SettleBean { } public BigDecimal getFinancingCapitalInflow() { - return financingCapitalInflow; + return handleSpecial(financingCapitalInflow); } public void setFinancingCapitalInflow(BigDecimal financingCapitalInflow) { @@ -475,7 +499,7 @@ public class SettleBean { } public BigDecimal getFinancingCapitalOutflow() { - return financingCapitalOutflow; + return handleSpecial(financingCapitalOutflow); } public void setFinancingCapitalOutflow(BigDecimal financingCapitalOutflow) { @@ -483,7 +507,7 @@ public class SettleBean { } public BigDecimal getFinancingCapitalCashflow() { - return financingCapitalCashflow; + return handleSpecial(financingCapitalCashflow); } public void setFinancingCapitalCashflow(BigDecimal financingCapitalCashflow) { @@ -491,7 +515,7 @@ public class SettleBean { } public BigDecimal getNetIncreaseMonetaryFunds() { - return netIncreaseMonetaryFunds; + return handleSpecial(netIncreaseMonetaryFunds); } public void setNetIncreaseMonetaryFunds(BigDecimal netIncreaseMonetaryFunds) { @@ -499,7 +523,7 @@ public class SettleBean { } public BigDecimal getNetCashFlow() { - return netCashFlow; + return handleSpecial(netCashFlow); } public void setNetCashFlow(BigDecimal netCashFlow) { diff --git a/src/main/java/cn/palmte/work/controller/backend/ProjectFinalController.java b/src/main/java/cn/palmte/work/controller/backend/ProjectFinalController.java index 0a4c908..65a8c01 100644 --- a/src/main/java/cn/palmte/work/controller/backend/ProjectFinalController.java +++ b/src/main/java/cn/palmte/work/controller/backend/ProjectFinalController.java @@ -3,7 +3,8 @@ package cn.palmte.work.controller.backend; import cn.palmte.work.bean.*; import cn.palmte.work.model.Project; import cn.palmte.work.model.ProjectBudgetPlanDetail; -import cn.palmte.work.model.ProjectRepository; +import cn.palmte.work.model.ProjectSettleIncome; +import cn.palmte.work.model.ProjectSettleIncomeRepository; import cn.palmte.work.service.*; import cn.palmte.work.utils.FreeMarkerUtil; import cn.palmte.work.utils.InterfaceUtil; @@ -12,7 +13,6 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import java.util.Date; import java.util.List; import java.util.Map; @@ -33,17 +33,38 @@ public class ProjectFinalController extends BaseController{ private ProjectBudgetService projectBudgetService; @Autowired - private ProjectInstanceService projectInstanceService; + private ProjectSettleIncomeRepository projectSettleIncomeRepository; + + @Autowired + private ProjectSettleService projectSettleService; + + @RequestMapping("/add") + public String add(@RequestParam("id") int id, Map model) { + Project project = projectService.getProject(id); + ProjectSettleIncome projectSettleIncome = projectSettleIncomeRepository.findNewByProjectId(id); + String time = projectSettleIncome.getTime(); + List projectBudgetPlanDetails = projectBudgetService.getProjectBudgetPlanDetails(project); + model.put("project", project); + model.put("estimateBean", projectEstimateService.getEstimate(project)); + model.put("budgetBean", projectBudgetService.getBudget(project)); + model.put("settleBean",projectSettleService.getCurrentSettle(project, time)); + model.put("finalBean",new FinalBean()); + //现金表 + model.put("cashFlowBean", projectBudgetService.getCashFlowBean(project, projectBudgetPlanDetails)); + //freemarker可以利用的静态方法 + model.put("Utils", FreeMarkerUtil.fromStaticPackage("cn.palmte.work.utils.Utils")); + return "admin/project_final_add"; + } @RequestMapping("/edit") - public String budget(@RequestParam("id") int id, Map model) { + public String edit(@RequestParam("id") int id, Map model) { Project project = projectService.getProject(id); List projectBudgetPlanDetails = projectBudgetService.getProjectBudgetPlanDetails(project); model.put("project", project); model.put("estimateBean", projectEstimateService.getEstimate(project)); model.put("budgetBean", projectBudgetService.getBudget(project)); model.put("settleBean",projectFinalSevice.getSettle(project)); - model.put("finalBean",new FinalBean()); + model.put("finalBean",projectFinalSevice.getFinal(project)); //现金表 model.put("cashFlowBean", projectBudgetService.getCashFlowBean(project, projectBudgetPlanDetails)); //freemarker可以利用的静态方法 @@ -54,7 +75,6 @@ public class ProjectFinalController extends BaseController{ @RequestMapping("/save") public String estimateAddSave(Project project, FinalBean finalBean, Map model) { projectFinalSevice.save(project,finalBean); - projectService.updateStatusAndApproveStatus(project.getId(), StatusEnum.FINAL_ACCOUNTS, ApproveStatusEnum.APPROVAL_UNCOMMIT); return "redirect:/project/list"; } @@ -69,12 +89,7 @@ public class ProjectFinalController extends BaseController{ */ @RequestMapping("/saveAndApprove") public String saveAndApprove(Project project, FinalBean finalBean, Map model) throws Exception{ - //保存 - projectFinalSevice.save(project,finalBean); - //更新项目和审批状态 - projectService.updateStatusAndApproveStatus(project.getId(), StatusEnum.FINAL_ACCOUNTS, ApproveStatusEnum.APPROVAL_PENDING); - //发起流程 - projectInstanceService.startFinalProcessInstance(project.getId(), InterfaceUtil.getAdmin()); + projectFinalSevice.saveAndApprove(project,finalBean); return "redirect:/project/list"; } diff --git a/src/main/java/cn/palmte/work/controller/backend/ProjectSummaryController.java b/src/main/java/cn/palmte/work/controller/backend/ProjectSummaryController.java index 4122873..95667a1 100644 --- a/src/main/java/cn/palmte/work/controller/backend/ProjectSummaryController.java +++ b/src/main/java/cn/palmte/work/controller/backend/ProjectSummaryController.java @@ -10,8 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import top.jfunc.common.db.bean.Page; -import top.jfunc.common.db.bean.Record; import java.util.Calendar; import java.util.Date; @@ -55,8 +53,9 @@ public class ProjectSummaryController extends BaseController { } else { time = searchInfo.get("time"); } - List> list = projectSummaryService.getList(searchInfo, pageNumber, pageSize, time); - model.put("pager", (list.size() > 0)? list.get(0) : new Page(pageNumber, pageSize)); + + List list = projectSummaryService.getList(searchInfo, time); + model.put("pager", list); return "admin/project_statistics"; } diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java index 9b87d06..8d17359 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java @@ -12,4 +12,7 @@ public interface ProjectBudgetCostManageRepository extends JpaRepository findAllByProjectIds(List projectInt); } diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java index 6972eb1..b291a96 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java @@ -15,4 +15,6 @@ public interface ProjectBudgetCostRepository extends JpaRepository findAllByProjectIds(List projectInt); } diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java index 57131fc..0bf35cf 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java @@ -15,5 +15,6 @@ public interface ProjectBudgetIncomeRepository extends JpaRepository findAllByProjectIds(List projectInt); } diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetPlanDetailRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetPlanDetailRepository.java index cf982ff..dc9c2ab 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetPlanDetailRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetPlanDetailRepository.java @@ -1,9 +1,13 @@ package cn.palmte.work.model; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.List; public interface ProjectBudgetPlanDetailRepository extends JpaRepository { List findAllByProjectIdEquals(int id); + + @Query(value = "select * from project_budget_plan_detail where project_id in ?1", nativeQuery = true) + List findAllByProjectIds(List projectInt); } diff --git a/src/main/java/cn/palmte/work/model/ProjectSettleCashFlowRepository.java b/src/main/java/cn/palmte/work/model/ProjectSettleCashFlowRepository.java index 3be0894..b889ce3 100644 --- a/src/main/java/cn/palmte/work/model/ProjectSettleCashFlowRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectSettleCashFlowRepository.java @@ -23,4 +23,7 @@ public interface ProjectSettleCashFlowRepository extends JpaRepository findAllByProjectsAndTime(List ids, String time); } diff --git a/src/main/java/cn/palmte/work/model/ProjectSettleCostManageRepository.java b/src/main/java/cn/palmte/work/model/ProjectSettleCostManageRepository.java index 10e2320..76dc3d3 100644 --- a/src/main/java/cn/palmte/work/model/ProjectSettleCostManageRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectSettleCostManageRepository.java @@ -23,4 +23,7 @@ public interface ProjectSettleCostManageRepository extends JpaRepository findAllByProjectId(int id); List findAllByTime(String time); + + @Query(value = "select * from project_settle_cost_manage where project_id in ?1 and time = ?2", nativeQuery = true) + List findAllByProjectsAndTime(List ids, String time); } diff --git a/src/main/java/cn/palmte/work/model/ProjectSettleCostRepository.java b/src/main/java/cn/palmte/work/model/ProjectSettleCostRepository.java index 9915527..c67afa6 100644 --- a/src/main/java/cn/palmte/work/model/ProjectSettleCostRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectSettleCostRepository.java @@ -23,4 +23,7 @@ public interface ProjectSettleCostRepository extends JpaRepository findAllByProjectId(int id); List findAllByTime(String time); + + @Query(value = "select * from project_settle_cost where project_id in ?1 and time = ?2", nativeQuery = true) + List findAllByProjectsAndTime(List ids, String time); } diff --git a/src/main/java/cn/palmte/work/model/ProjectSettleIncomeRepository.java b/src/main/java/cn/palmte/work/model/ProjectSettleIncomeRepository.java index 84e637a..fc31747 100644 --- a/src/main/java/cn/palmte/work/model/ProjectSettleIncomeRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectSettleIncomeRepository.java @@ -26,4 +26,7 @@ public interface ProjectSettleIncomeRepository extends JpaRepository findAllByProjectsAndTime(List ids, String time); } diff --git a/src/main/java/cn/palmte/work/model/ProjectSettleProfitMarginRepository.java b/src/main/java/cn/palmte/work/model/ProjectSettleProfitMarginRepository.java index f6ea062..ca5a72a 100644 --- a/src/main/java/cn/palmte/work/model/ProjectSettleProfitMarginRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectSettleProfitMarginRepository.java @@ -19,4 +19,7 @@ public interface ProjectSettleProfitMarginRepository extends JpaRepository findAllByProjectId(int id); List findAllByTime(String time); + + @Query(value = "select * from project_settle_profit_margin where project_id in ?1 and time = ?2", nativeQuery = true) + List findAllByProjectsAndTime(List ids, String time); } diff --git a/src/main/java/cn/palmte/work/service/ProjectFinalSevice.java b/src/main/java/cn/palmte/work/service/ProjectFinalSevice.java index cb43d38..d6b97ba 100644 --- a/src/main/java/cn/palmte/work/service/ProjectFinalSevice.java +++ b/src/main/java/cn/palmte/work/service/ProjectFinalSevice.java @@ -2,6 +2,7 @@ package cn.palmte.work.service; import cn.palmte.work.bean.*; import cn.palmte.work.model.*; +import cn.palmte.work.utils.InterfaceUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -44,6 +45,12 @@ public class ProjectFinalSevice { @Autowired private ProjectSettleCashFlowRepository projectSettleCashFlowRepository; + @Autowired + private ProjectService projectService; + + @Autowired + private ProjectInstanceService projectInstanceService; + @Transactional public void save(Project project, FinalBean finalBean) { //预算表数据 @@ -66,6 +73,37 @@ public class ProjectFinalSevice { //保存项目结算现金流量信息 saveProjectFinalCashFlux(project,finalBean,cashFlowBean); + projectService.updateStatusAndApproveStatus(project.getId(), StatusEnum.FINAL_ACCOUNTS, ApproveStatusEnum.APPROVAL_UNCOMMIT); + + } + + @Transactional + public void saveAndApprove(Project project, FinalBean finalBean) throws Exception { + //预算表数据 + EstimateBean estimate = projectEstimateService.getEstimate(project); + //概算表数据 + BudgetBean budget = projectBudgetService.getBudget(project); + //现金流量表数据 + List projectBudgetPlanDetails = projectBudgetService.getProjectBudgetPlanDetails(project); + CashFlowBean cashFlowBean = projectBudgetService.getCashFlowBean(project, projectBudgetPlanDetails); + + //保存项目决算收入信息 + saveProjectFinalIncome(project,finalBean,estimate,budget); + + //保存项目决算成本信息 + saveProjectFinalCost(project,finalBean,estimate,budget); + + //保存项目结算管理成本信息 + saveProjectFinalCostManage(project,finalBean,estimate,budget); + + //保存项目结算现金流量信息 + saveProjectFinalCashFlux(project,finalBean,cashFlowBean); + + //更新项目和审批状态 + projectService.updateStatusAndApproveStatus(project.getId(), StatusEnum.FINAL_ACCOUNTS, ApproveStatusEnum.APPROVAL_PENDING); + //发起流程 + projectInstanceService.startFinalProcessInstance(project.getId(), InterfaceUtil.getAdmin()); + } public void saveProjectFinalCostManage(Project project, FinalBean finalBean,EstimateBean estimate,BudgetBean budget){ diff --git a/src/main/java/cn/palmte/work/service/ProjectSettleService.java b/src/main/java/cn/palmte/work/service/ProjectSettleService.java index 7e7b0f8..bae636c 100644 --- a/src/main/java/cn/palmte/work/service/ProjectSettleService.java +++ b/src/main/java/cn/palmte/work/service/ProjectSettleService.java @@ -633,10 +633,10 @@ public class ProjectSettleService { return settleBean; } - public SettleBean getMonthTotalSettle(String time) { + public SettleBean getMonthTotalSettle(List projectInt, String time) { SettleBean settleBean = new SettleBean(); - List incomes = projectSettleIncomeRepository.findAllByTime(time); + List incomes = projectSettleIncomeRepository.findAllByProjectsAndTime(projectInt, time); if(CollectionUtil.isNotEmpty(incomes)){ BigDecimal incomeDevice = incomes.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); settleBean.setIncomeDevice(incomeDevice); @@ -648,7 +648,7 @@ public class ProjectSettleService { settleBean.setIncomeService(incomeService); } - List costs = projectSettleCostRepository.findAllByTime(time); + List costs = projectSettleCostRepository.findAllByProjectsAndTime(projectInt, time); if(CollectionUtil.isNotEmpty(costs)){ BigDecimal costDevice = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); settleBean.setCostPurchaseDevice(costDevice); @@ -669,7 +669,7 @@ public class ProjectSettleService { settleBean.setCostOther(costOtherOther); } - List manages = projectSettleCostManageRepository.findAllByTime(time); + List manages = projectSettleCostManageRepository.findAllByProjectsAndTime(projectInt, time); if(CollectionUtil.isNotEmpty(manages)){ BigDecimal costManageExpropriation = manages.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); settleBean.setCostExpropriation(costManageExpropriation); @@ -681,7 +681,7 @@ public class ProjectSettleService { settleBean.setCostIncomeTax(costIncomeTax); } - List profits = projectSettleProfitMarginRepository.findAllByTime(time); + List profits = projectSettleProfitMarginRepository.findAllByProjectsAndTime(projectInt, time); if(CollectionUtil.isNotEmpty(profits)) { BigDecimal grossProfit = profits.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_GROSS_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); settleBean.setGrossProfit(grossProfit); @@ -693,7 +693,7 @@ public class ProjectSettleService { settleBean.setNetProfit(netProfit); } - List cashFlows = projectSettleCashFlowRepository.findAllByTime(time); + List cashFlows = projectSettleCashFlowRepository.findAllByProjectsAndTime(projectInt, time); if(CollectionUtil.isNotEmpty(cashFlows)) { BigDecimal saleIncomeCash = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.SALE_INCOME_CASH).map(ProjectSettleCashFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); settleBean.setSaleIncomeCash(saleIncomeCash); diff --git a/src/main/java/cn/palmte/work/service/ProjectSummaryService.java b/src/main/java/cn/palmte/work/service/ProjectSummaryService.java index e1c8d48..8e3879c 100644 --- a/src/main/java/cn/palmte/work/service/ProjectSummaryService.java +++ b/src/main/java/cn/palmte/work/service/ProjectSummaryService.java @@ -1,14 +1,13 @@ package cn.palmte.work.service; import cn.palmte.work.bean.SettleBean; -import cn.palmte.work.model.Project; -import cn.palmte.work.model.ProjectSettleCostRepository; +import cn.palmte.work.model.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import top.jfunc.common.db.bean.Page; import top.jfunc.common.db.utils.Pagination; +import top.jfunc.common.utils.CollectionUtil; import java.math.BigDecimal; import java.util.ArrayList; @@ -26,10 +25,19 @@ public class ProjectSummaryService { private static final Logger logger = LoggerFactory.getLogger(ProjectSummaryService.class); @Autowired - private ProjectBudgetService projectBudgetService; + private ProjectBudgetIncomeRepository projectBudgetIncomeRepository; @Autowired - private ProjectSettleCostRepository projectSettleCostRepository; + private ProjectBudgetCostRepository projectBudgetCostRepository; + + @Autowired + private ProjectBudgetCostManageRepository projectBudgetCostManageRepository; + + @Autowired + private ProjectBudgetPlanDetailRepository projectBudgetPlanDetailRepository; + + @Autowired + private ProjectSettleIncomeRepository projectSettleIncomeRepository; @Autowired private ProjectSettleService projectSettleService; @@ -37,93 +45,143 @@ public class ProjectSummaryService { @Autowired private Pagination pagination; - public List> getList(ConcurrentHashMap searchInfo, int pageNumber, int pageSize, String time) { - List> pageList = new ArrayList<>(); - if (pageNumber == 1) { - //预算金额 - Map budget = new HashMap<>(40); - String sql = "select proj.id, proj.name from project_settle_cost psc left join project proj on psc.project_id = proj.id where psc.time = ? group by proj.id order by proj.id asc"; - List projects = pagination.find(sql, Project.class, time); -// for (Project project : projects) { -// BudgetBean budgetBean = projectBudgetService.getBudget(project); -// CashFlowBean cashFlowBean = projectBudgetService.getCashFlowBean(project, projectBudgetService.getProjectBudgetPlanDetails(project)); -// budget.put("incomeDevice", budget.getOrDefault("incomeDeviceTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeDeviceTaxExclude())); -// budget.put("incomeEngineer", budget.getOrDefault("incomeEngineerTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeEngineerTaxExclude())); -// budget.put("incomeService", budget.getOrDefault("incomeServiceTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeServiceTaxExclude())); -// budget.put("costPurchaseDevice", budget.getOrDefault("costPurchaseDeviceTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseDeviceTaxExclude())); -// budget.put("costPurchaseBuild", budget.getOrDefault("costPurchaseBuildTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseBuildTaxExclude())); -// budget.put("costPurchaseService", budget.getOrDefault("costPurchaseServiceTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseServiceTaxExclude())); -// budget.put("costPurchaseOther", budget.getOrDefault("costPurchaseOtherTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseOtherTaxExclude())); -// budget.put("costOtherOther", budget.getOrDefault("costOtherOtherTaxExclude", new BigDecimal(0)).add(budgetBean.getCostOtherOtherTaxExclude())); -// budget.put("costProjectManage", budget.getOrDefault("costProjectManageTaxExclude", new BigDecimal(0)).add(budgetBean.getCostProjectManageTaxExclude())); -// budget.put("costExpropriation", budget.getOrDefault("costExpropriationTaxExclude", new BigDecimal(0)).add(budgetBean.getCostExpropriationTaxExclude())); -// budget.put("costCompanyManage", budget.getOrDefault("costCompanyManageTaxExclude", new BigDecimal(0)).add(budgetBean.getCostCompanyManageTaxExclude())); -// -// budget.put("incomeTotal", budget.getOrDefault("incomeTotalTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeTotalTaxExclude())); -// budget.put("incomeTotalTaxInclude", budget.getOrDefault("incomeTotalTaxInclude", new BigDecimal(0)).add(budgetBean.getIncomeTotalTaxInclude())); -// budget.put("costTotal2", budget.getOrDefault("costTotalTaxExclude2", new BigDecimal(0)).add(budgetBean.getCostTotalTaxExclude())); -// budget.put("costTotalTaxInclude", budget.getOrDefault("costTotalTaxInclude", new BigDecimal(0)).add(budgetBean.getCostTotalTaxInclude())); -// budget.put("costTotal", budget.getOrDefault("costTotalTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseDeviceTaxExclude().add(budgetBean.getCostPurchaseBuildTaxExclude()).add(budgetBean.getCostPurchaseServiceTaxExclude()).add(budgetBean.getCostPurchaseOtherTaxExclude()))); -// budget.put("projectGrossProfit", budget.getOrDefault("projectGrossProfit", new BigDecimal(0)).add(budgetBean.getProjectGrossProfit())); -// budget.put("projectContributionProfit", budget.getOrDefault("projectContributionProfit", new BigDecimal(0)).add(budgetBean.getProjectContributionProfit())); -// -// budget.put("saleIncomeCash", budget.getOrDefault("saleIncomeCash", new BigDecimal(0)).add(cashFlowBean.getSaleIncomeCash())); -// budget.put("taxReturn", budget.getOrDefault("taxReturn", new BigDecimal(0)).add(cashFlowBean.getTaxReturn())); -// budget.put("earnestMoneyIncome", budget.getOrDefault("earnestMoneyIncome", new BigDecimal(0)).add(cashFlowBean.getEarnestMoneyIncome())); -// budget.put("purchaseCost", budget.getOrDefault("purchaseCost", new BigDecimal(0)).add(cashFlowBean.getPurchaseCost())); -// budget.put("taxCost", budget.getOrDefault("taxCost", new BigDecimal(0)).add(cashFlowBean.getTaxCost())); -// budget.put("earnestMoneyCost", budget.getOrDefault("earnestMoneyCost", new BigDecimal(0)).add(cashFlowBean.getEarnestMoneyCost())); -// budget.put("netCashFlow", budget.getOrDefault("netCashFlow", new BigDecimal(0)).add(cashFlowBean.getNetCashFlow())); -// budget.put("cashInflowFromInvestingActivities", budget.getOrDefault("cashInflowFromInvestingActivities", new BigDecimal(0)).add(cashFlowBean.getCashInflowFromInvestingActivities())); -// budget.put("cashOutflowFromInvestingActivities", budget.getOrDefault("cashOutflowFromInvestingActivities", new BigDecimal(0)).add(cashFlowBean.getCashOutflowFromInvestingActivities())); -// budget.put("netCashFromInvestingActivities", budget.getOrDefault("netCashFromInvestingActivities", new BigDecimal(0)).add(cashFlowBean.getNetCashFromInvestingActivities())); -// budget.put("financingCapitalInflow", budget.getOrDefault("financingCapitalInflow", new BigDecimal(0)).add(cashFlowBean.getFinancingCapitalInflow())); -// budget.put("financingCapitalOutflow", budget.getOrDefault("financingCapitalOutflow", new BigDecimal(0)).add(cashFlowBean.getFinancingCapitalOutflow())); -// budget.put("financingCapitalCashflow", budget.getOrDefault("financingCapitalCashflow", new BigDecimal(0)).add(cashFlowBean.getFinancingCapitalCashflow())); -// budget.put("netIncreaseMonetaryFunds", budget.getOrDefault("netIncreaseMonetaryFunds", new BigDecimal(0)).add(cashFlowBean.getNetIncreaseMonetaryFunds())); -// } -// Record budgetRecord = new Record(); -// budgetRecord.getColumns().putAll(budget); -// budgetRecord.set("projectName", "预算金额(不含税)"); -// budgetRecord.set("projectGrossProfitRate", budget.getOrDefault("projectGrossProfit", new BigDecimal(0)).divide(budget.getOrDefault("incomeTotalTaxExclude", new BigDecimal(1)))); -// budgetRecord.set("projectContributionProfitRate", budget.getOrDefault("projectContributionProfit", new BigDecimal(0)).divide(budget.getOrDefault("incomeTotalTaxExclude", new BigDecimal(1)))); -// budgetRecord.set("taxCost", budget.getOrDefault("incomeTotalTaxInclude", new BigDecimal(0)).subtract(budget.getOrDefault("incomeTotal", new BigDecimal(0))).subtract(budget.getOrDefault("costTotalTaxInclude", new BigDecimal(0))).add(budget.getOrDefault("costTotal2", new BigDecimal(0)))); -// budgetRecord.set("projectNetProfit", budget.getOrDefault("projectGrossProfit", new BigDecimal(0)).subtract(budgetRecord.getBigDecimal("taxCost"))); -// budgetRecord.set("projectContributionProfitRate", budgetRecord.getBigDecimal("projectNetProfit").divide(budget.getOrDefault("incomeTotalTaxExclude", new BigDecimal(1)))); - SettleBean budgetBean = new SettleBean(); - budgetBean.setProjectName("预算金额(不含税)"); - Page page = new Page<>(pageNumber, pageSize); - List list = new ArrayList<>(); - list.add(budgetBean); - - SettleBean totalSettle = projectSettleService.getMonthTotalSettle(time); - BigDecimal divide = totalSettle.getIncomeTotal(); - if (divide.equals(new BigDecimal(0))) { - divide = new BigDecimal(1); + public List getList(ConcurrentHashMap searchInfo, String time) { + //预算金额 + Map budget = new HashMap<>(40); + String sql = "select proj.id, proj.name, proj.approve_status_budget from project_settle_cost psc left join project proj on psc.project_id = proj.id where psc.time = ? group by proj.id order by proj.id asc"; + List projectList = pagination.find(sql, Project.class, time); + List projects = new ArrayList<>(); + List projectInt = new ArrayList<>(); + for (Project project : projectList) { + if (project.getApproveStatusBudget() == 2) { + projects.add(project); + projectInt.add(project.getId()); + continue; } - totalSettle.setGrossProfitProfitMargin(totalSettle.getGrossProfit().divide(divide, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); - totalSettle.setContributionProfitProfitMargin(totalSettle.getContributionProfit().divide(divide, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); - totalSettle.setNetProfitProfitMargin(totalSettle.getNetProfit().divide(divide, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); - totalSettle.setProjectName("实际累计(不含税)"); - list.add(totalSettle); - - for (Project project : projects) { - SettleBean monthSettle = projectSettleService.getMonthSettle(project, time); - BigDecimal divide2 = monthSettle.getIncomeTotal(); - if (divide2.equals(new BigDecimal(0))) { - divide2 = new BigDecimal(1); - } - monthSettle.setGrossProfitProfitMargin(monthSettle.getGrossProfit().divide(divide2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); - monthSettle.setContributionProfitProfitMargin(monthSettle.getContributionProfit().divide(divide2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); - monthSettle.setNetProfitProfitMargin(monthSettle.getNetProfit().divide(divide2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100))); - monthSettle.setProjectName(project.getName()); - list.add(monthSettle); + ProjectSettleIncome projectNewest = projectSettleIncomeRepository.findNewByProjectId(project.getId()); + if (!time.equals(projectNewest.getTime())) { + projects.add(project); + projectInt.add(project.getId()); } - page.setList(list); - pageList.add(page); - } else { - String sql = "select proj.id, proj.name from project_settle_cost psc left join project proj on psc.project_id = proj.id where psc.time = ? group by proj.id order by proj.id asc"; } - return pageList; + + SettleBean budgetBean = new SettleBean(); + if (projectInt.size() == 0) { + projectInt.add(0); + } + List incomes = projectBudgetIncomeRepository.findAllByProjectIds(projectInt); + BigDecimal taxTotal = new BigDecimal(0); + if(CollectionUtil.isNotEmpty(incomes)){ + BigDecimal incomeDevice = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_DEVICE).map(ProjectBudgetIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setIncomeDevice(incomeDevice); + BigDecimal incomeDeviceInclude = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_DEVICE).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal incomeEngineer = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_ENGINEER).map(ProjectBudgetIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setIncomeEngineer(incomeEngineer); + BigDecimal incomeEngineerInclude = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_ENGINEER).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal incomeService = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_SERVICE).map(ProjectBudgetIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setIncomeService(incomeService); + BigDecimal incomeServiceInclude = incomes.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_SERVICE).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + taxTotal = taxTotal.subtract(budgetBean.getIncomeTotal()).add(incomeDeviceInclude).add(incomeEngineerInclude).add(incomeServiceInclude); + } + + List costs = projectBudgetCostRepository.findAllByProjectIds(projectInt); + if(CollectionUtil.isNotEmpty(costs)){ + BigDecimal costDevice = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE).map(ProjectBudgetCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostPurchaseDevice(costDevice); + BigDecimal costDeviceInclude = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal costBuild = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_BUILDING).map(ProjectBudgetCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostPurchaseBuild(costBuild); + BigDecimal costBuildInclude = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_BUILDING).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal costService = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_SERVICE).map(ProjectBudgetCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostPurchaseService(costService); + BigDecimal costServiceInclude = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_SERVICE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal costOther = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_OTHER).map(ProjectBudgetCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostPurchaseOther(costOther); + BigDecimal costOtherInclude = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_OTHER).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal costProjectManage = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_PROJECT_MANAGE).map(ProjectBudgetCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostProjectManage(costProjectManage ); + BigDecimal costProjectManageInclude = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_PROJECT_MANAGE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal costOtherOther = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_OTHER_OTHER).map(ProjectBudgetCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostOther(costOtherOther); + BigDecimal costOtherOtherInclude = costs.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_OTHER_OTHER).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); + taxTotal = taxTotal.add(budgetBean.getCostTotal()).subtract(costDeviceInclude).subtract(costBuildInclude).subtract(costServiceInclude).subtract(costOtherInclude).subtract(costProjectManageInclude).subtract(costOtherOtherInclude); + } + + List manages = projectBudgetCostManageRepository.findAllByProjectIds(projectInt); + if(CollectionUtil.isNotEmpty(manages)){ + BigDecimal costManageExpropriation = manages.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_EXPROPRIATION).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostExpropriation(costManageExpropriation); + + BigDecimal costManageCompany = manages.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_COMPANY_MANAGE).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setCostCompanyManage(costManageCompany); + + budgetBean.setCostIncomeTax(taxTotal); + } + + budgetBean.setGrossProfit(budgetBean.getIncomeTotal().subtract(budgetBean.getCostTotal()).subtract(budgetBean.getCostExpropriation())); + budgetBean.setContributionProfit(budgetBean.getGrossProfit().subtract(budgetBean.getCostCompanyManage())); + budgetBean.setNetProfit(budgetBean.getContributionProfit().subtract(budgetBean.getCostIncomeTax())); + + List cashFlows = projectBudgetPlanDetailRepository.findAllByProjectIds(projectInt); + BigDecimal saleIncome = cashFlows.stream().map(ProjectBudgetPlanDetail::getSaleIncome).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setSaleIncomeCash(saleIncome); + + BigDecimal earnestMoneyIncome = cashFlows.stream().map(ProjectBudgetPlanDetail::getEarnestMoneyIncome).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setEarnestMoneyIncome(earnestMoneyIncome); + + BigDecimal deviceCost = cashFlows.stream().map(ProjectBudgetPlanDetail::getDeviceCost).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal engineerCost = cashFlows.stream().map(ProjectBudgetPlanDetail::getEngineerCost).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setPurchaseCost(deviceCost.add(engineerCost)); + + BigDecimal projectManageCost = cashFlows.stream().map(ProjectBudgetPlanDetail::getProjectManageCost).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal earnestMoneyCost = cashFlows.stream().map(ProjectBudgetPlanDetail::getEarnestMoneyCost).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal capitalInterest = cashFlows.stream().map(ProjectBudgetPlanDetail::getCapitalInterest).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setEarnestMoneyCost(projectManageCost.add(earnestMoneyCost).add(capitalInterest)); + + BigDecimal underWritten = cashFlows.stream().map(ProjectBudgetPlanDetail::getUnderwrittenPlan).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setFinancingCapitalInflow(underWritten); + + BigDecimal repaymentPlan = cashFlows.stream().map(ProjectBudgetPlanDetail::getRepaymentPlan).reduce(BigDecimal.ZERO, BigDecimal::add); + budgetBean.setFinancingCapitalOutflow(repaymentPlan); + + budgetBean.setNetCashFlow(saleIncome.add(earnestMoneyIncome).subtract(budgetBean.getEarnestMoneyCost())); + budgetBean.setFinancingCapitalCashflow(underWritten.subtract(repaymentPlan)); + budgetBean.setNetIncreaseMonetaryFunds(budgetBean.getNetCashFlow().add(budgetBean.getFinancingCapitalCashflow())); + + setProfitMargin(budgetBean); + budgetBean.setProjectName("预算金额(不含税)"); + List list = new ArrayList<>(); + list.add(budgetBean); + + SettleBean totalSettle = projectSettleService.getMonthTotalSettle(projectInt, time); + setProfitMargin(totalSettle); + totalSettle.setProjectName("实际累计(不含税)"); + list.add(totalSettle); + + for (Project project : projects) { + SettleBean monthSettle = projectSettleService.getMonthSettle(project, time); + setProfitMargin(monthSettle); + monthSettle.setProjectName(project.getName()); + list.add(monthSettle); + } + return list; + } + + private void setProfitMargin(SettleBean monthSettle) { + BigDecimal divide2 = monthSettle.getIncomeTotal(); + if (divide2.equals(new BigDecimal(0))) { + divide2 = new BigDecimal(1); + } + monthSettle.setGrossProfitProfitMargin(monthSettle.getGrossProfit().multiply(new BigDecimal(100).divide(divide2, BigDecimal.ROUND_HALF_UP))); + monthSettle.setContributionProfitProfitMargin(monthSettle.getContributionProfit().multiply(new BigDecimal(100).divide(divide2, BigDecimal.ROUND_HALF_UP))); + monthSettle.setNetProfitProfitMargin(monthSettle.getNetProfit().multiply(new BigDecimal(100).divide(divide2, BigDecimal.ROUND_HALF_UP))); } } diff --git a/src/main/resources/templates/admin/project_final_add.ftl b/src/main/resources/templates/admin/project_final_add.ftl new file mode 100644 index 0000000..dec8984 --- /dev/null +++ b/src/main/resources/templates/admin/project_final_add.ftl @@ -0,0 +1,394 @@ +<#assign base=request.contextPath /> + +<#import "../common/defaultLayout.ftl" as defaultLayout> +<@defaultLayout.layout> + + + +
+
+
+
项目决算表 / ${project.name}
+
+ +
+ +
+ +
+
+ + 收入 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
类别费用概算总额(元)预算总额(元)结算总额(元)决算总额(元)
收入设备类
收入工程类
收入服务类
合计
+ 成本 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
类别费用费用项目概算总额(元)预算总额(元)结算总额(元)决算总额(元)
成本采购成本设备
成本采购成本施工
成本采购成本服务
成本采购成本其他
成本项目管理成本项目管理成本
成本其他其他
合计
+ 管理 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
类别费用项目概算总额(元)预算总额(元)结算总额(元)决算总额(元)
财务费用资金占用成本
公司管理费用
所得税费用//
合计
+ + 利润率计算 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
类别概算总额(元)预算总额(元)结算总额(元)决算总额(元)利润率(%)
项目毛利
项目贡献利润
项目净利润/
+ + 现金流量表 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
类别预算总额(元)结算总额(元)决算总额(元)
销售商品、提供劳务收到的现金
收到的税费返还/
收到其他与经营活动有关的现金
购买商品、接受劳务支付的现金
支付的各项税费/
支付其他与经营活动有关的现金
经营活动产生的现金流量净额
投资活动现金流入/
投资活动现金流出/
投资活动产生的现金流量净额/
融资资金流入
还款资金流出
筹资活动产生的现金流量净额
货币资金净增加额
合计
+
+ +
+
+ + +
+ + + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/admin/project_final_edit.ftl b/src/main/resources/templates/admin/project_final_edit.ftl index 4c397d5..796991a 100644 --- a/src/main/resources/templates/admin/project_final_edit.ftl +++ b/src/main/resources/templates/admin/project_final_edit.ftl @@ -50,7 +50,7 @@ 设备类 - + @@ -58,7 +58,7 @@ 工程类 - + @@ -66,7 +66,7 @@ 服务类 - + @@ -74,8 +74,8 @@ - - + + @@ -97,7 +97,7 @@ 设备 - + @@ -106,7 +106,7 @@ 施工 - + @@ -115,7 +115,7 @@ 服务 - + @@ -124,7 +124,7 @@ 其他 - + @@ -133,7 +133,7 @@ 项目管理成本 - + @@ -142,7 +142,7 @@ 其他 - + @@ -151,8 +151,8 @@ - - + + @@ -172,7 +172,7 @@ 资金占用成本 - + @@ -180,7 +180,7 @@ - + @@ -194,10 +194,10 @@ 合计 - - + + - + @@ -225,7 +225,7 @@ 项目贡献利润 - + @@ -233,7 +233,7 @@ 项目净利润 / - + @@ -335,9 +335,9 @@ 合计 - + - + diff --git a/src/main/resources/templates/admin/project_list.ftl b/src/main/resources/templates/admin/project_list.ftl index 4f63189..92c0ec2 100644 --- a/src/main/resources/templates/admin/project_list.ftl +++ b/src/main/resources/templates/admin/project_list.ftl @@ -243,11 +243,17 @@ <#if (list.status== 10 && list.approveStatusSettle== 2) || (list.status== 15 && list.approveStatusFinal== 0) || (list.status== 15 && list.approveStatusFinal== 3)> + +