98 lines
8.7 KiB
Java
98 lines
8.7 KiB
Java
package cn.palmte.work.service;
|
|
|
|
import cn.palmte.work.bean.BudgetBean;
|
|
import cn.palmte.work.bean.CashFlowBean;
|
|
import cn.palmte.work.model.Project;
|
|
import cn.palmte.work.model.ProjectSettleCostRepository;
|
|
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.bean.Record;
|
|
import top.jfunc.common.db.utils.Pagination;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
/**
|
|
* @author Yuanping Zhang
|
|
* @date 2021/11/10
|
|
*/
|
|
@Service
|
|
public class ProjectSummaryService {
|
|
private static final Logger logger = LoggerFactory.getLogger(ProjectSummaryService.class);
|
|
|
|
@Autowired
|
|
private ProjectBudgetService projectBudgetService;
|
|
|
|
@Autowired
|
|
private ProjectSettleCostRepository projectSettleCostRepository;
|
|
|
|
@Autowired
|
|
private Pagination pagination;
|
|
|
|
public List<Page<Record>> getList(ConcurrentHashMap<String, String> searchInfo, int pageNumber, int pageSize) {
|
|
List<Page<Record>> pageList = new ArrayList<>();
|
|
if (pageNumber == 1) {
|
|
//预算金额
|
|
Map<String, BigDecimal> 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<Project> projects = pagination.find(sql, Project.class, searchInfo.getOrDefault("time", "2021-00"));
|
|
for (Project project : projects) {
|
|
BudgetBean budgetBean = projectBudgetService.getBudget(project);
|
|
CashFlowBean cashFlowBean = projectBudgetService.getCashFlowBean(project, projectBudgetService.getProjectBudgetPlanDetails(project));
|
|
budget.put("incomeDeviceTaxExclude", budget.getOrDefault("incomeDeviceTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeDeviceTaxExclude()));
|
|
budget.put("incomeEngineerTaxExclude", budget.getOrDefault("incomeEngineerTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeEngineerTaxExclude()));
|
|
budget.put("incomeServiceTaxExclude", budget.getOrDefault("incomeServiceTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeServiceTaxExclude()));
|
|
budget.put("costPurchaseDeviceTaxExclude", budget.getOrDefault("costPurchaseDeviceTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseDeviceTaxExclude()));
|
|
budget.put("costPurchaseBuildTaxExclude", budget.getOrDefault("costPurchaseBuildTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseBuildTaxExclude()));
|
|
budget.put("costPurchaseServiceTaxExclude", budget.getOrDefault("costPurchaseServiceTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseServiceTaxExclude()));
|
|
budget.put("costPurchaseOtherTaxExclude", budget.getOrDefault("costPurchaseOtherTaxExclude", new BigDecimal(0)).add(budgetBean.getCostPurchaseOtherTaxExclude()));
|
|
budget.put("costOtherOtherTaxExclude", budget.getOrDefault("costOtherOtherTaxExclude", new BigDecimal(0)).add(budgetBean.getCostOtherOtherTaxExclude()));
|
|
budget.put("costProjectManageTaxExclude", budget.getOrDefault("costProjectManageTaxExclude", new BigDecimal(0)).add(budgetBean.getCostProjectManageTaxExclude()));
|
|
budget.put("costExpropriationTaxExclude", budget.getOrDefault("costExpropriationTaxExclude", new BigDecimal(0)).add(budgetBean.getCostExpropriationTaxExclude()));
|
|
budget.put("costCompanyManageTaxExclude", budget.getOrDefault("costCompanyManageTaxExclude", new BigDecimal(0)).add(budgetBean.getCostCompanyManageTaxExclude()));
|
|
|
|
budget.put("incomeTotalTaxExclude", budget.getOrDefault("incomeTotalTaxExclude", new BigDecimal(0)).add(budgetBean.getIncomeTotalTaxExclude()));
|
|
budget.put("incomeTotalTaxInclude", budget.getOrDefault("incomeTotalTaxInclude", new BigDecimal(0)).add(budgetBean.getIncomeTotalTaxInclude()));
|
|
budget.put("costTotalTaxExclude2", budget.getOrDefault("costTotalTaxExclude2", new BigDecimal(0)).add(budgetBean.getCostTotalTaxExclude()));
|
|
budget.put("costTotalTaxInclude", budget.getOrDefault("costTotalTaxInclude", new BigDecimal(0)).add(budgetBean.getCostTotalTaxInclude()));
|
|
budget.put("costTotalTaxExclude", 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("incomeTotalTaxExclude", new BigDecimal(0))).subtract(budget.getOrDefault("costTotalTaxInclude", new BigDecimal(0))).add(budget.getOrDefault("costTotalTaxExclude2", 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))));
|
|
} 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;
|
|
}
|
|
}
|