分月统计优化

master
hanbo 2021-11-25 16:49:28 +08:00
parent bef5ae36a1
commit da3f51b4a0
7 changed files with 227 additions and 36 deletions

View File

@ -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;
}

View File

@ -0,0 +1,16 @@
package cn.palmte.work.bean;
import lombok.Data;
import java.util.List;
@Data
public class StatisticsBean {
private List<PrimaryIndicatorBean> primaryIndicatorBeanList;
private List<ProfitAndLossBean> profitAndLossBeanList;
private List<CashFlowStatisticsBean> cashFlowStatisticsBeanList;
}

View File

@ -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<String, Object> 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));

View File

@ -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<String, Object> model){
List<PrimaryIndicatorBean> primaryIndicatorList = statisticsService.getPrimaryIndicator();
List<CashFlowStatisticsBean> 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";
}

View File

@ -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;
}

View File

@ -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<PrimaryIndicatorBean> getPrimaryIndicator() {
public StatisticsBean getStatisticsData() {
StatisticsBean statisticsBean = new StatisticsBean();
List<PrimaryIndicatorBean> list = new ArrayList<>();
List<ProfitAndLossBean> 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<ProjectSettleIncome> 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<ProjectSettleCost> 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<ProjectSettleCostManage> allSettleCostManage = projectSettleCostManageRepository.findAll();
@ -154,15 +199,33 @@ public class StatisticsService {
allSettle.setCostExpropriation(expropriationAll);
allSettle.setCostCompanyManage(companyManageAll);
allProfitAndLoss.setExpropriation(expropriationAll);
allProfitAndLoss.setCompanyManage(companyManageAll);
}
List<ProjectSettleProfitMargin> 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<String> 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<CashFlowStatisticsBean> cashFlow = getCashFlow();
/**
*
*
* @return
*/
public List getIncomeStatement() {
return null;
statisticsBean.setPrimaryIndicatorBeanList(list);
statisticsBean.setProfitAndLossBeanList(profitAndLossList);
statisticsBean.setCashFlowStatisticsBeanList(cashFlow);
return statisticsBean;
}
/**

View File

@ -84,24 +84,23 @@
</thead>
<tbody>
<#if (cashFlowList)?exists && (cashFlowList?size>0)>
<#list cashFlowList as list>
<#if (profitAndLossList)?exists && (profitAndLossList?size>0)>
<#list profitAndLossList as list>
<tr>
<td>${list.title!}</td>
<td>${list.saleIncomeCash!}</td>
<td>${list.taxReturn!}</td>
<td>${list.earnestMoneyIncome!}</td>
<td>${list.purchaseCost!}</td>
<td>${list.taxCost!}</td>
<td>${list.earnestMoneyCost!}</td>
<td>${list.netCashFlow!}</td>
<td>${list.cashInflowFromInvestingActivities!}</td>
<td>${list.cashOutflowFromInvestingActivities!}</td>
<td>${list.netCashFromInvestingActivities!}</td>
<td>${list.financingCapitalInflow!}</td>
<td>${list.financingCapitalOutflow!}</td>
<td>${list.financingCapitalCashflow!}</td>
<td>${list.netIncreaseMonetaryFunds!}</td>
<td>${(list.cost!0)?string("0.##")}</td>
<td>${(list.income!0)?string("0.##")}</td>
<td>${(list.manageCost!0)?string("0.##")}</td>
<td>${(list.other!0)?string("0.##")}</td>
<td>${(list.expropriation!0)?string("0.##")}</td>
<td>${(list.grossProfit!0)?string("0.##")}</td>
<td>${(list.grossProfitProfit!0)?string("0.##")}</td>
<td>${(list.companyManage!0)?string("0.##")}</td>
<td>${(list.contributionMargin!0)?string("0.##")}</td>
<td>${(list.contributionMarginProfit!0)?string("0.##")}</td>
<td>${(list.incomeTax!0)?string("0.##")}</td>
<td>${(list.netMargin!0)?string("0.##")}</td>
<td>${(list.netMarginProfit!0)?string("0.##")}</td>
</tr>
</#list>
</#if>