Merge remote-tracking branch 'origin/1.2.0' into 1.2.0

master
Harry Yang 2023-01-06 11:38:12 +08:00
commit 01f19c320f
6 changed files with 124 additions and 13 deletions

View File

@ -20,6 +20,9 @@ public interface ProjectSettleCashFlowRepository extends JpaRepository<ProjectSe
@Query(value = "select * from project_settle_cash_flow where project_id = ?1 and time <= ?2", nativeQuery = true)
List<ProjectSettleCashFlow> findAllByProjectIdAndTimeBeforeAndEquals(int id, String time);
@Query(value = "select min(time) from project_settle_cash_flow where project_id = ?1 and time > ?2", nativeQuery = true)
String findAfterMonthByProjectIdAndTime(int id, String time);
List<ProjectSettleCashFlow> findAllByProjectId(int id);
List<ProjectSettleCashFlow> findAllByTime(String time);

View File

@ -20,6 +20,9 @@ public interface ProjectSettleCostManageRepository extends JpaRepository<Project
@Query(value = "select * from project_settle_cost_manage where project_id = ?1 and time <= ?2", nativeQuery = true)
List<ProjectSettleCostManage> findAllByProjectIdAndTimeBeforeAndEquals(int id, String time);
@Query(value = "select min(time) from project_settle_cost_manage where project_id = ?1 and time > ?2", nativeQuery = true)
String findAfterMonthByProjectIdAndTime(int id, String time);
@Query(value = "select sum(cost_tax_exclude) from project_settle_cost_manage where project_id = ? and type = ?", nativeQuery = true)
BigDecimal costTaxExcludeSum(int projectId, int type);

View File

@ -20,6 +20,9 @@ public interface ProjectSettleCostRepository extends JpaRepository<ProjectSettle
@Query(value = "select * from project_settle_cost where project_id = ?1 and time <= ?2", nativeQuery = true)
List<ProjectSettleCost> findAllByProjectIdAndTimeBeforeAndEquals(int id, String time);
@Query(value = "select min(time) from project_settle_cost where project_id = ?1 and time > ?2", nativeQuery = true)
String findAfterMonthByProjectIdAndTime(int id, String time);
@Query(value = "select sum(cost_tax_exclude) from project_settle_cost where project_id = ? and type = ?", nativeQuery = true)
BigDecimal costTaxExcludeSum(int projectId, int type);

View File

@ -20,6 +20,9 @@ public interface ProjectSettleIncomeRepository extends JpaRepository<ProjectSett
@Query(value = "select * from project_settle_income where project_id = ?1 and time <= ?2", nativeQuery = true)
List<ProjectSettleIncome> findAllByProjectIdAndTimeBeforeAndEquals(int id, String time);
@Query(value = "select min(time) from project_settle_income where project_id = ?1 and time > ?2", nativeQuery = true)
String findAfterMonthByProjectIdAndTime(int id, String time);
@Query(value = "select sum(income_tax_exclude) from project_settle_income where project_id = ? and type = ?", nativeQuery = true)
BigDecimal incomeTaxExcludeSum(int projectId, int type);

View File

@ -19,6 +19,9 @@ public interface ProjectSettleProfitMarginRepository extends JpaRepository<Proje
@Query(value = "select * from project_settle_profit_margin where project_id = ?1 and time <= ?2", nativeQuery = true)
List<ProjectSettleProfitMargin> findAllByProjectIdAndTimeBeforeAndEquals(int id, String time);
@Query(value = "select min(time) from project_settle_profit_margin where project_id = ?1 and time > ?2", nativeQuery = true)
String findAfterMonthByProjectIdAndTime(int id, String time);
List<ProjectSettleProfitMargin> findAllByProjectId(int id);
List<ProjectSettleProfitMargin> findAllByTime(String time);

View File

@ -611,17 +611,32 @@ public class ProjectSettleService {
ProjectSettleIncome projectSettleIncomeDevice = incomes.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).collect(Collectors.toList()).get(0);
settleBean.setIncomeDevice(projectSettleIncomeDevice.getIncomeTaxExclude());
settleBean.setBudgetIncomeDevice(projectSettleIncomeDevice.getBudget());
settleBean.setEstimateIncomeDevice(projectSettleIncomeDevice.getEstimate());
// settleBean.setEstimateIncomeDevice(projectSettleIncomeDevice.getEstimate());
ProjectSettleIncome projectSettleIncomeEngineer = incomes.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_ENGINEER).collect(Collectors.toList()).get(0);
settleBean.setIncomeEngineer(projectSettleIncomeEngineer.getIncomeTaxExclude());
settleBean.setBudgetIncomeEngineer(projectSettleIncomeEngineer.getBudget());
settleBean.setEstimateIncomeEngineer(projectSettleIncomeEngineer.getEstimate());
// settleBean.setEstimateIncomeEngineer(projectSettleIncomeEngineer.getEstimate());
ProjectSettleIncome projectSettleIncomeService = incomes.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_SERVICE).collect(Collectors.toList()).get(0);
settleBean.setIncomeService(projectSettleIncomeService.getIncomeTaxExclude());
settleBean.setBudgetIncomeService(projectSettleIncomeService.getBudget());
settleBean.setEstimateIncomeService(projectSettleIncomeService.getEstimate());
// settleBean.setEstimateIncomeService(projectSettleIncomeService.getEstimate());
} else {
String afterMonth = projectSettleIncomeRepository.findAfterMonthByProjectIdAndTime(project.getId(), time);
if (afterMonth != null) {
List<ProjectSettleIncome> incomesBudget = projectSettleIncomeRepository.findAllByProjectIdAndTime(project.getId(), afterMonth);
if(CollectionUtil.isNotEmpty(incomesBudget)){
ProjectSettleIncome projectSettleIncomeDevice = incomesBudget.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).collect(Collectors.toList()).get(0);
settleBean.setBudgetIncomeDevice(projectSettleIncomeDevice.getBudget());
ProjectSettleIncome projectSettleIncomeEngineer = incomesBudget.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_ENGINEER).collect(Collectors.toList()).get(0);
settleBean.setBudgetIncomeEngineer(projectSettleIncomeEngineer.getBudget());
ProjectSettleIncome projectSettleIncomeService = incomesBudget.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_SERVICE).collect(Collectors.toList()).get(0);
settleBean.setBudgetIncomeService(projectSettleIncomeService.getBudget());
}
}
}
List<ProjectSettleCost> costs = projectSettleCostRepository.findAllByProjectIdAndTime(project.getId(), time);
@ -629,64 +644,112 @@ public class ProjectSettleService {
ProjectSettleCost projectSettleCostDevice = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseDevice(projectSettleCostDevice.getCostTaxExclude());
settleBean.setBudgetCostPurchaseDevice(projectSettleCostDevice.getBudget());
settleBean.setEstimateCostPurchaseDevice(projectSettleCostDevice.getEstimate());
// settleBean.setEstimateCostPurchaseDevice(projectSettleCostDevice.getEstimate());
ProjectSettleCost projectSettleCostBuild = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_BUILDING).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseBuild(projectSettleCostBuild.getCostTaxExclude());
settleBean.setBudgetCostPurchaseBuild(projectSettleCostBuild.getBudget());
settleBean.setEstimateCostPurchaseBuild(projectSettleCostBuild.getEstimate());
// settleBean.setEstimateCostPurchaseBuild(projectSettleCostBuild.getEstimate());
ProjectSettleCost projectSettleCostService = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_SERVICE).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseService(projectSettleCostService.getCostTaxExclude());
settleBean.setBudgetCostPurchaseService(projectSettleCostService.getBudget());
settleBean.setEstimateCostPurchaseService(projectSettleCostService.getEstimate());
// settleBean.setEstimateCostPurchaseService(projectSettleCostService.getEstimate());
ProjectSettleCost projectSettleCostOther = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_OTHER).collect(Collectors.toList()).get(0);
settleBean.setCostPurchaseOther(projectSettleCostOther.getCostTaxExclude());
settleBean.setBudgetCostPurchaseOther(projectSettleCostOther.getBudget());
settleBean.setEstimateCostPurchaseOther(projectSettleCostOther.getEstimate());
// settleBean.setEstimateCostPurchaseOther(projectSettleCostOther.getEstimate());
ProjectSettleCost projectSettleCostProjectManage = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_PROJECT_MANAGE).collect(Collectors.toList()).get(0);
settleBean.setCostProjectManage(projectSettleCostProjectManage.getCostTaxExclude());
settleBean.setBudgetCostProjectManage(projectSettleCostProjectManage.getBudget());
settleBean.setEstimateCostProjectManage(projectSettleCostProjectManage.getEstimate());
// settleBean.setEstimateCostProjectManage(projectSettleCostProjectManage.getEstimate());
ProjectSettleCost projectSettleCostOtherOther = costs.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_OTHER_OTHER).collect(Collectors.toList()).get(0);
settleBean.setCostOther(projectSettleCostOtherOther.getCostTaxExclude());
settleBean.setBudgetCostOther(projectSettleCostOtherOther.getBudget());
settleBean.setEstimateCostOther(projectSettleCostOtherOther.getEstimate());
// settleBean.setEstimateCostOther(projectSettleCostOtherOther.getEstimate());
} else {
String afterMonth = projectSettleCostRepository.findAfterMonthByProjectIdAndTime(project.getId(), time);
if (afterMonth != null) {
List<ProjectSettleCost> costBudget = projectSettleCostRepository.findAllByProjectIdAndTime(project.getId(), afterMonth);
if(CollectionUtil.isNotEmpty(costBudget)){
ProjectSettleCost projectSettleCostDevice = costBudget.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostPurchaseDevice(projectSettleCostDevice.getBudget());
ProjectSettleCost projectSettleCostBuild = costBudget.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_BUILDING).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostPurchaseBuild(projectSettleCostBuild.getBudget());
ProjectSettleCost projectSettleCostService = costBudget.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_SERVICE).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostPurchaseService(projectSettleCostService.getBudget());
ProjectSettleCost projectSettleCostOther = costBudget.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_OTHER).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostPurchaseOther(projectSettleCostOther.getBudget());
ProjectSettleCost projectSettleCostProjectManage = costBudget.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_PROJECT_MANAGE).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostProjectManage(projectSettleCostProjectManage.getBudget());
ProjectSettleCost projectSettleCostOtherOther = costBudget.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_OTHER_OTHER).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostOther(projectSettleCostOtherOther.getBudget());
}
}
}
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());
settleBean.setEstimateCostExpropriation(costManageExpropriation.getEstimate());
// settleBean.setEstimateCostExpropriation(costManageExpropriation.getEstimate());
settleBean.setBudgetCostExpropriation(costManageExpropriation.getBudget());
ProjectSettleCostManage costManageCompany = costManages.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).collect(Collectors.toList()).get(0);
settleBean.setCostCompanyManage(costManageCompany.getCostTaxExclude());
settleBean.setEstimateCostCompanyManage(costManageCompany.getEstimate());
// settleBean.setEstimateCostCompanyManage(costManageCompany.getEstimate());
settleBean.setBudgetCostCompanyManage(costManageCompany.getBudget());
ProjectSettleCostManage costIncomeTax = costManages.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_INCOME_TAX).collect(Collectors.toList()).get(0);
settleBean.setCostIncomeTax(costIncomeTax.getCostTaxExclude());
} else {
String afterMonth = projectSettleCostManageRepository.findAfterMonthByProjectIdAndTime(project.getId(), time);
if (afterMonth != null) {
List<ProjectSettleCostManage> costManagesBudget = projectSettleCostManageRepository.findAllByProjectIdAndTime(project.getId(), afterMonth);
if(CollectionUtil.isNotEmpty(costManagesBudget)){
ProjectSettleCostManage costManageExpropriation = costManagesBudget.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostExpropriation(costManageExpropriation.getBudget());
ProjectSettleCostManage costManageCompany = costManagesBudget.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).collect(Collectors.toList()).get(0);
settleBean.setBudgetCostCompanyManage(costManageCompany.getBudget());
}
}
}
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());
settleBean.setEstimateGrossProfit(grossProfit.getEstimate());
// settleBean.setEstimateGrossProfit(grossProfit.getEstimate());
settleBean.setBudgetGrossProfit(grossProfit.getBudget());
ProjectSettleProfitMargin contributionProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).collect(Collectors.toList()).get(0);
settleBean.setContributionProfit(contributionProfit.getAmount());
settleBean.setEstimateContributionProfit(contributionProfit.getEstimate());
// settleBean.setEstimateContributionProfit(contributionProfit.getEstimate());
settleBean.setBudgetContributionProfit(contributionProfit.getBudget());
ProjectSettleProfitMargin netProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_NET_PROFIT).collect(Collectors.toList()).get(0);
settleBean.setNetProfit(netProfit.getAmount());
} else {
String afterMonth = projectSettleProfitMarginRepository.findAfterMonthByProjectIdAndTime(project.getId(), time);
if (afterMonth != null) {
List<ProjectSettleProfitMargin> profitMarginsBudget = projectSettleProfitMarginRepository.findAllByProjectIdAndTime(project.getId(), afterMonth);
if(CollectionUtil.isNotEmpty(profitMarginsBudget)){
ProjectSettleProfitMargin grossProfit = profitMarginsBudget.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_GROSS_PROFIT).collect(Collectors.toList()).get(0);
settleBean.setBudgetGrossProfit(grossProfit.getBudget());
ProjectSettleProfitMargin contributionProfit = profitMarginsBudget.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).collect(Collectors.toList()).get(0);
settleBean.setBudgetContributionProfit(contributionProfit.getBudget());
}
}
}
List<ProjectSettleCashFlow> cashFlows = projectSettleCashFlowRepository.findAllByProjectIdAndTime(project.getId(), time);
@ -741,6 +804,39 @@ public class ProjectSettleService {
ProjectSettleCashFlow netIncreaseMonetaryFunds = cashFlows.stream().filter(d -> d.getType() == ProjectSettleCashFlow.NET_INCREASE_MONETARY_FUNDS).collect(Collectors.toList()).get(0);
settleBean.setNetIncreaseMonetaryFunds(netIncreaseMonetaryFunds.getAmount());
settleBean.setBudgetNetIncreaseMonetaryFunds(netIncreaseMonetaryFunds.getBudget());
} else {
String afterMonth = projectSettleCashFlowRepository.findAfterMonthByProjectIdAndTime(project.getId(), time);
if (afterMonth != null) {
List<ProjectSettleCashFlow> cashFlowsBudget = projectSettleCashFlowRepository.findAllByProjectIdAndTime(project.getId(), afterMonth);
if(CollectionUtil.isNotEmpty(cashFlowsBudget)){
ProjectSettleCashFlow saleIncomeCash = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.SALE_INCOME_CASH).collect(Collectors.toList()).get(0);
settleBean.setBudgetSaleIncomeCash(saleIncomeCash.getBudget());
ProjectSettleCashFlow earnestMoneyIncome = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.EARNEST_MONEY_INCOME).collect(Collectors.toList()).get(0);
settleBean.setBudgetEarnestMoneyIncome(earnestMoneyIncome.getBudget());
ProjectSettleCashFlow purchaseCost = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.PURCHASE_COST).collect(Collectors.toList()).get(0);
settleBean.setBudgetPurchaseCost(purchaseCost.getBudget());
ProjectSettleCashFlow earnestMoneyCost = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.EARNEST_MONEY_COST).collect(Collectors.toList()).get(0);
settleBean.setBudgetEarnestMoneyCost(earnestMoneyCost.getBudget());
ProjectSettleCashFlow netCashFlow = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.NET_CASH_FLOW).collect(Collectors.toList()).get(0);
settleBean.setBudgetNetCashFlow(netCashFlow.getBudget());
ProjectSettleCashFlow financingCapitalInflow = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.FINANCING_CAPITAL_INFLOW).collect(Collectors.toList()).get(0);
settleBean.setBudgetFinancingCapitalInflow(financingCapitalInflow.getBudget());
ProjectSettleCashFlow financingCapitalOutflow = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.FINANCING_CAPITAL_OUTFLOW).collect(Collectors.toList()).get(0);
settleBean.setBudgetFinancingCapitalOutflow(financingCapitalOutflow.getBudget());
ProjectSettleCashFlow financingCapitalCashflow = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.FINANCING_CAPITAL_CASHFLOW).collect(Collectors.toList()).get(0);
settleBean.setBudgetFinancingCapitalCashflow(financingCapitalCashflow.getBudget());
ProjectSettleCashFlow netIncreaseMonetaryFunds = cashFlowsBudget.stream().filter(d -> d.getType() == ProjectSettleCashFlow.NET_INCREASE_MONETARY_FUNDS).collect(Collectors.toList()).get(0);
settleBean.setBudgetNetIncreaseMonetaryFunds(netIncreaseMonetaryFunds.getBudget());
}
}
}
return settleBean;