sonar校验,去掉不必要的逻辑

master
OathK1per 2021-12-06 14:39:04 +08:00
parent d49ac9495a
commit a2ef87106d
3 changed files with 8 additions and 144 deletions

View File

@ -91,11 +91,14 @@ public class ProjectSettleController extends BaseController{
public String edit(@RequestParam("id") int id, Map<String, Object> model) {
Project project = projectService.getProject(id);
ProjectSettleIncome projectSettleIncome = projectSettleIncomeRepository.findNewByProjectId(id);
List<ProjectBudgetPlanDetail> projectBudgetPlanDetails = projectBudgetService.getProjectBudgetPlanDetails(project);
String time = projectSettleIncome.getTime();
model.put("time", time);
model.put("project", project);
projectSettleService.getEstimateAndBudgetAndMonthSettle(project, time, model);
model.put("estimateBean", projectEstimateService.getEstimate(project));
model.put("budgetBean", projectBudgetService.getBudget(project));
model.put("formerBean", projectSettleService.getFormerSettle(project, time));
model.put("monthBean", projectSettleService.getMonthSettle(project, time));
model.put("currentBean", projectSettleService.getCurrentSettle(project, time));
List<ProjectUserTime> projectUserTimes = projectUserTimeRepository.findByProjectIdAndTime(project.getId(), time);
if(CollectionUtil.isNotEmpty(projectUserTimes)){
@ -104,6 +107,8 @@ public class ProjectSettleController extends BaseController{
} else {
model.put("salary", new BigDecimal(0));
}
//现金表
model.put("cashFlowBean", projectBudgetService.getCashFlowBean(project, projectBudgetPlanDetails));
//freemarker可以利用的静态方法
model.put("Utils", FreeMarkerUtil.fromStaticPackage("cn.palmte.work.utils.Utils"));
return "admin/project_settle_edit";

View File

@ -737,145 +737,4 @@ public class ProjectSettleService {
}
return settleBean;
}
public void getEstimateAndBudgetAndMonthSettle(Project project, String time, Map<String, Object> model) {
SettleBean settleBean = new SettleBean();
BudgetBean budgetBean = new BudgetBean();
EstimateBean estimateBean = new EstimateBean();
CashFlowBean cashFlowBean = new CashFlowBean();
List<ProjectSettleIncome> incomes = projectSettleIncomeRepository.findAllByProjectIdAndTime(project.getId(), time);
if(CollectionUtil.isNotEmpty(incomes)){
ProjectSettleIncome projectSettleIncomeDevice = incomes.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).collect(Collectors.toList()).get(0);
settleBean.setIncomeDevice(projectSettleIncomeDevice.getIncomeTaxExclude());
budgetBean.setIncomeDeviceTaxExclude(projectSettleIncomeDevice.getBudget());
estimateBean.setIncomeDeviceTaxExclude(projectSettleIncomeDevice.getEstimate());
ProjectSettleIncome projectSettleIncomeEngineer = incomes.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_ENGINEER).collect(Collectors.toList()).get(0);
settleBean.setIncomeEngineer(projectSettleIncomeEngineer.getIncomeTaxExclude());
budgetBean.setIncomeEngineerTaxExclude(projectSettleIncomeEngineer.getBudget());
estimateBean.setIncomeEngineerTaxExclude(projectSettleIncomeEngineer.getEstimate());
ProjectSettleIncome projectSettleIncomeService = incomes.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_SERVICE).collect(Collectors.toList()).get(0);
settleBean.setIncomeService(projectSettleIncomeService.getIncomeTaxExclude());
budgetBean.setIncomeServiceTaxExclude(projectSettleIncomeService.getBudget());
estimateBean.setIncomeServiceTaxExclude(projectSettleIncomeService.getEstimate());
}
List<ProjectSettleCost> costs = projectSettleCostRepository.findAllByProjectIdAndTime(project.getId(), time);
if(CollectionUtil.isNotEmpty(costs)){
ProjectSettleCost projectSettleCostDevice = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseDevice(projectSettleCostDevice.getCostTaxExclude());
budgetBean.setCostPurchaseDeviceTaxExclude(projectSettleCostDevice.getBudget());
estimateBean.setCostPurchaseDeviceTaxExclude(projectSettleCostDevice.getEstimate());
ProjectSettleCost projectSettleCostBuild = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_BUILDING).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseBuild(projectSettleCostBuild.getCostTaxExclude());
budgetBean.setCostPurchaseBuildTaxExclude(projectSettleCostBuild.getBudget());
estimateBean.setCostPurchaseBuildTaxExclude(projectSettleCostBuild.getEstimate());
ProjectSettleCost projectSettleCostService = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_SERVICE).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseService(projectSettleCostService.getCostTaxExclude());
budgetBean.setCostPurchaseServiceTaxExclude(projectSettleCostService.getBudget());
estimateBean.setCostPurchaseServiceTaxExclude(projectSettleCostService.getEstimate());
ProjectSettleCost projectSettleCostOther = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_OTHER).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseOther(projectSettleCostOther.getCostTaxExclude());
budgetBean.setCostPurchaseOtherTaxExclude(projectSettleCostOther.getBudget());
estimateBean.setCostPurchaseOtherTaxExclude(projectSettleCostOther.getEstimate());
ProjectSettleCost projectSettleCostProjectManage = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_PROJECT_MANAGE).collect(Collectors.toList()).get(0);
settleBean.setCostProjectManage(projectSettleCostProjectManage.getCostTaxExclude());
budgetBean.setCostProjectManageTaxExclude(projectSettleCostProjectManage.getBudget());
estimateBean.setCostProjectManageTaxExclude(projectSettleCostProjectManage.getEstimate());
ProjectSettleCost projectSettleCostOtherOther = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_OTHER_OTHER).collect(Collectors.toList()).get(0);
settleBean.setCostOther(projectSettleCostOtherOther.getCostTaxExclude());
budgetBean.setCostOtherOtherTaxExclude(projectSettleCostOtherOther.getBudget());
estimateBean.setCostOtherOtherTaxExclude(projectSettleCostOtherOther.getEstimate());
}
List<ProjectSettleCostManage> costManages = projectSettleCostManageRepository.findAllByProjectIdAndTime(project.getId(), time);
if(CollectionUtil.isNotEmpty(costManages)){
ProjectSettleCostManage costManageExpropriation = costManages.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).collect(Collectors.toList()).get(0);
settleBean.setCostExpropriation(costManageExpropriation.getCostTaxExclude());
budgetBean.setCostExpropriationTaxExclude(costManageExpropriation.getBudget());
estimateBean.setCostExpropriationTaxExclude(costManageExpropriation.getEstimate());
ProjectSettleCostManage costManageCompany = costManages.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).collect(Collectors.toList()).get(0);
settleBean.setCostCompanyManage(costManageCompany.getCostTaxExclude());
budgetBean.setCostCompanyManageTaxExclude(costManageCompany.getBudget());
estimateBean.setCostCompanyManageTaxExclude(costManageCompany.getEstimate());
ProjectSettleCostManage costIncomeTax = costManages.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_INCOME_TAX).collect(Collectors.toList()).get(0);
settleBean.setCostIncomeTax(costIncomeTax.getCostTaxExclude());
}
List<ProjectSettleProfitMargin> profitMargins = projectSettleProfitMarginRepository.findAllByProjectIdAndTime(project.getId(), time);
if(CollectionUtil.isNotEmpty(profitMargins)){
ProjectSettleProfitMargin grossProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_GROSS_PROFIT).collect(Collectors.toList()).get(0);
settleBean.setGrossProfit(grossProfit.getAmount());
ProjectSettleProfitMargin contributionProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).collect(Collectors.toList()).get(0);
settleBean.setContributionProfit(contributionProfit.getAmount());
ProjectSettleProfitMargin netProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_NET_PROFIT).collect(Collectors.toList()).get(0);
settleBean.setNetProfit(netProfit.getAmount());
}
List<ProjectSettleCashFlow> cashFlows = projectSettleCashFlowRepository.findAllByProjectIdAndTime(project.getId(), time);
if(CollectionUtil.isNotEmpty(cashFlows)){
ProjectSettleCashFlow saleIncomeCash = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.SALE_INCOME_CASH).collect(Collectors.toList()).get(0);
settleBean.setSaleIncomeCash(saleIncomeCash.getAmount());
cashFlowBean.setSaleIncomeCash(saleIncomeCash.getBudget());
ProjectSettleCashFlow taxReturn = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.TAX_RETURN).collect(Collectors.toList()).get(0);
settleBean.setTaxReturn(taxReturn.getAmount());
ProjectSettleCashFlow earnestMoneyIncome = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.EARNEST_MONEY_INCOME).collect(Collectors.toList()).get(0);
settleBean.setEarnestMoneyIncome(earnestMoneyIncome.getAmount());
cashFlowBean.setEarnestMoneyIncome(earnestMoneyIncome.getBudget());
ProjectSettleCashFlow purchaseCost = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.PURCHASE_COST).collect(Collectors.toList()).get(0);
settleBean.setPurchaseCost(purchaseCost.getAmount());
cashFlowBean.setPurchaseCost(purchaseCost.getBudget());
ProjectSettleCashFlow taxCost = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.TAX_COST).collect(Collectors.toList()).get(0);
settleBean.setTaxCost(taxCost.getAmount());
ProjectSettleCashFlow earnestMoneyCost = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.EARNEST_MONEY_COST).collect(Collectors.toList()).get(0);
settleBean.setEarnestMoneyCost(earnestMoneyCost.getAmount());
cashFlowBean.setEarnestMoneyCost(earnestMoneyCost.getBudget());
ProjectSettleCashFlow netCashFlow = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.NET_CASH_FLOW).collect(Collectors.toList()).get(0);
settleBean.setNetCashFlow(netCashFlow.getAmount());
ProjectSettleCashFlow cashInflowFromInvestingActivities = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.CASH_INFLOW_FROM_INVESTING_ACTIVITIES).collect(Collectors.toList()).get(0);
settleBean.setCashInflowFromInvestingActivities(cashInflowFromInvestingActivities.getAmount());
ProjectSettleCashFlow cashOutflowFromInvestingActivities = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.CASH_OUTFLOW_FROM_INVESTING_ACTIVITIES).collect(Collectors.toList()).get(0);
settleBean.setCashOutflowFromInvestingActivities(cashOutflowFromInvestingActivities.getAmount());
ProjectSettleCashFlow netCashFromInvestingActivities = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.NET_CASH_FROM_INVESTING_ACTIVITIES).collect(Collectors.toList()).get(0);
settleBean.setNetCashFromInvestingActivities(netCashFromInvestingActivities.getAmount());
ProjectSettleCashFlow financingCapitalInflow = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.FINANCING_CAPITAL_INFLOW).collect(Collectors.toList()).get(0);
settleBean.setFinancingCapitalInflow(financingCapitalInflow.getAmount());
cashFlowBean.setFinancingCapitalInflow(financingCapitalInflow.getBudget());
ProjectSettleCashFlow financingCapitalOutflow = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.FINANCING_CAPITAL_OUTFLOW).collect(Collectors.toList()).get(0);
settleBean.setFinancingCapitalOutflow(financingCapitalOutflow.getAmount());
cashFlowBean.setFinancingCapitalOutflow(financingCapitalOutflow.getBudget());
ProjectSettleCashFlow financingCapitalCashflow = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.FINANCING_CAPITAL_CASHFLOW).collect(Collectors.toList()).get(0);
settleBean.setFinancingCapitalCashflow(financingCapitalCashflow.getAmount());
ProjectSettleCashFlow netIncreaseMonetaryFunds = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.NET_INCREASE_MONETARY_FUNDS).collect(Collectors.toList()).get(0);
settleBean.setNetIncreaseMonetaryFunds(netIncreaseMonetaryFunds.getAmount());
}
model.put("estimateBean", estimateBean);
model.put("budgetBean", budgetBean);
model.put("monthBean", settleBean);
model.put("cashFlowBean", cashFlowBean);
}
}

View File

@ -179,9 +179,9 @@ public class ProjectSummaryService {
private void setProfitMargin(SettleBean monthSettle) {
BigDecimal divide2 = monthSettle.getIncomeTotal();
BigDecimal min = new BigDecimal(0.01);
BigDecimal min = BigDecimal.valueOf(0.01);
if (divide2.compareTo(min) < 0) {
divide2 = new BigDecimal(1);
divide2 = BigDecimal.valueOf(1);
}
monthSettle.setGrossProfitProfitMargin(monthSettle.getGrossProfit().multiply(new BigDecimal(100).divide(divide2, 4, BigDecimal.ROUND_HALF_UP)));
monthSettle.setContributionProfitProfitMargin(monthSettle.getContributionProfit().multiply(new BigDecimal(100).divide(divide2, 4, BigDecimal.ROUND_HALF_UP)));