Merge remote-tracking branch 'origin/master'

master
xxssyyyyssxx 2021-12-10 10:52:11 +08:00
commit c35413805d
7 changed files with 39 additions and 11 deletions

View File

@ -32,4 +32,7 @@ public interface ProjectSettleCashFlowRepository extends JpaRepository<ProjectSe
@Query(value = "SELECT time FROM project_settle_cash_flow GROUP BY time ORDER BY time", nativeQuery = true) @Query(value = "SELECT time FROM project_settle_cash_flow GROUP BY time ORDER BY time", nativeQuery = true)
List<String> getProjectTime(); List<String> getProjectTime();
@Query(value = "select * from project_settle_cash_flow where project_id in ?1", nativeQuery = true)
List<ProjectSettleCashFlow> findAllByProjectIds(List<Integer> projectIds);
} }

View File

@ -35,4 +35,7 @@ public interface ProjectSettleCostManageRepository extends JpaRepository<Project
@Query(value = "select sum(cost_tax_exclude) from project_settle_cost_manage where type = ?", nativeQuery = true) @Query(value = "select sum(cost_tax_exclude) from project_settle_cost_manage where type = ?", nativeQuery = true)
BigDecimal costManageTaxExcludeSumByType(int type); BigDecimal costManageTaxExcludeSumByType(int type);
@Query(value = "select * from project_settle_cost_manage where project_id in ?1", nativeQuery = true)
List<ProjectSettleCostManage> findAllByProjectIds(List<Integer> projectIds);
} }

View File

@ -35,4 +35,7 @@ public interface ProjectSettleCostRepository extends JpaRepository<ProjectSettle
@Query(value = "select sum(cost_tax_exclude) from project_settle_cost where type = ?", nativeQuery = true) @Query(value = "select sum(cost_tax_exclude) from project_settle_cost where type = ?", nativeQuery = true)
BigDecimal costTaxExcludeSumByType(int type); BigDecimal costTaxExcludeSumByType(int type);
@Query(value = "select * from project_settle_cost where project_id in ?1", nativeQuery = true)
List<ProjectSettleCost> findAllByProjectIds(List<Integer> projectIds);
} }

View File

@ -41,4 +41,7 @@ public interface ProjectSettleIncomeRepository extends JpaRepository<ProjectSett
@Query(value = "select sum(income_tax_exclude) from project_settle_income where type = ?", nativeQuery = true) @Query(value = "select sum(income_tax_exclude) from project_settle_income where type = ?", nativeQuery = true)
BigDecimal incomeTaxExcludeSumByType(int type); BigDecimal incomeTaxExcludeSumByType(int type);
@Query(value = "select * from project_settle_income where project_id in ?1", nativeQuery = true)
List<ProjectSettleIncome> findAllByProjectIds(List<Integer> projectInt);
} }

View File

@ -25,4 +25,7 @@ public interface ProjectSettleProfitMarginRepository extends JpaRepository<Proje
@Query(value = "select * from project_settle_profit_margin where project_id in ?1 and time = ?2", nativeQuery = true) @Query(value = "select * from project_settle_profit_margin where project_id in ?1 and time = ?2", nativeQuery = true)
List<ProjectSettleProfitMargin> findAllByProjectsAndTime(List<Integer> ids, String time); List<ProjectSettleProfitMargin> findAllByProjectsAndTime(List<Integer> ids, String time);
@Query(value = "select * from project_settle_profit_margin where project_id in ?1", nativeQuery = true)
List<ProjectSettleProfitMargin> findAllByProjectIds(List<Integer> projectIds);
} }

View File

@ -2,10 +2,15 @@ package cn.palmte.work.model;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List; import java.util.List;
public interface ProjectVisibleRepository extends JpaRepository<ProjectVisible, Integer> { public interface ProjectVisibleRepository extends JpaRepository<ProjectVisible, Integer> {
List<ProjectVisible> findAllByProjectIdEqualsAndTypeEquals(int projectId, int type); List<ProjectVisible> findAllByProjectIdEqualsAndTypeEquals(int projectId, int type);
List<ProjectVisible> findAllByProjectIdEquals(int projectId); List<ProjectVisible> findAllByProjectIdEquals(int projectId);
@Query(value = "SELECT project_id FROM project_visible WHERE type = ?1 and tid = ?2", nativeQuery = true)
List<Integer> findProjectIdByTypeAndTid(int type,int tid);
} }

View File

@ -5,6 +5,7 @@ import cn.palmte.work.bean.PrimaryIndicatorBean;
import cn.palmte.work.bean.ProfitAndLossBean; import cn.palmte.work.bean.ProfitAndLossBean;
import cn.palmte.work.bean.StatisticsBean; import cn.palmte.work.bean.StatisticsBean;
import cn.palmte.work.model.*; import cn.palmte.work.model.*;
import cn.palmte.work.utils.InterfaceUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import top.jfunc.common.utils.CollectionUtil; import top.jfunc.common.utils.CollectionUtil;
@ -43,6 +44,9 @@ public class StatisticsService {
@Autowired @Autowired
private ProjectSettleProfitMarginRepository projectSettleProfitMarginRepository; private ProjectSettleProfitMarginRepository projectSettleProfitMarginRepository;
@Autowired
private ProjectVisibleRepository projectVisibleRepository;
/** /**
* *
* *
@ -62,8 +66,12 @@ public class StatisticsService {
profitAndLossBeanExclude.setTitle("预算金额(不含税)"); profitAndLossBeanExclude.setTitle("预算金额(不含税)");
include.setTitle("预算金额(含税)"); include.setTitle("预算金额(含税)");
exclude.setTitle("预算金额(不含税)"); exclude.setTitle("预算金额(不含税)");
int adminId = InterfaceUtil.getAdminId();
List<Integer> projectIds = projectVisibleRepository.findProjectIdByTypeAndTid(ProjectVisible.TYPE_USER, adminId);
//收入数据 //收入数据
List<ProjectBudgetIncome> allIncome = projectBudgetIncomeRepository.findAll(); List<ProjectBudgetIncome> allIncome = projectBudgetIncomeRepository.findAllByProjectIds(projectIds);
if (CollectionUtil.isNotEmpty(allIncome)) { if (CollectionUtil.isNotEmpty(allIncome)) {
BigDecimal deviceIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_DEVICE).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal deviceIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_DEVICE).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal engineerIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_ENGINEER).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal engineerIncomeTaxIncludeSum = allIncome.stream().filter(d -> d.getType() == ProjectBudgetIncome.TYPE_ENGINEER).map(ProjectBudgetIncome::getIncomeTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
@ -88,7 +96,7 @@ public class StatisticsService {
} }
//成本数据 //成本数据
List<ProjectBudgetCost> allCost = projectBudgetCostRepository.findAll(); List<ProjectBudgetCost> allCost = projectBudgetCostRepository.findAllByProjectIds(projectIds);
if (CollectionUtil.isNotEmpty(allCost)) { if (CollectionUtil.isNotEmpty(allCost)) {
BigDecimal deviceCostTaxIncludeSum = allCost.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal deviceCostTaxIncludeSum = allCost.stream().filter(d -> d.getType() == ProjectBudgetCost.TYPE_DEVICE).map(ProjectBudgetCost::getCostTaxInclude).reduce(BigDecimal.ZERO, BigDecimal::add);
@ -133,7 +141,7 @@ public class StatisticsService {
} }
//管理成本数据 //管理成本数据
List<ProjectBudgetCostManage> allCostManage = projectBudgetCostManageRepository.findAll(); List<ProjectBudgetCostManage> allCostManage = projectBudgetCostManageRepository.findAllByProjectIds(projectIds);
if (CollectionUtil.isNotEmpty(allCostManage)) { if (CollectionUtil.isNotEmpty(allCostManage)) {
BigDecimal expropriationSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_EXPROPRIATION).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal expropriationSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_EXPROPRIATION).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal companyManageSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_COMPANY_MANAGE).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal companyManageSum = allCostManage.stream().filter(d -> d.getType() == ProjectBudgetCostManage.TYPE_COMPANY_MANAGE).map(ProjectBudgetCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
@ -155,7 +163,7 @@ public class StatisticsService {
allSettle.setTitle("实际累计(不含税)"); allSettle.setTitle("实际累计(不含税)");
allProfitAndLoss.setTitle("实际累计(不含税)"); allProfitAndLoss.setTitle("实际累计(不含税)");
List<ProjectSettleIncome> allSettleIncome = projectSettleIncomeRepository.findAll(); List<ProjectSettleIncome> allSettleIncome = projectSettleIncomeRepository.findAllByProjectIds(projectIds);
if (CollectionUtil.isNotEmpty(allSettleIncome)) { if (CollectionUtil.isNotEmpty(allSettleIncome)) {
BigDecimal incomeDeviceAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal incomeDeviceAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_DEVICE).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal incomeEngineerAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_ENGINEER).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal incomeEngineerAll = allSettleIncome.stream().filter(d -> d.getType() == ProjectSettleIncome.TYPE_ENGINEER).map(ProjectSettleIncome::getIncomeTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
@ -169,7 +177,7 @@ public class StatisticsService {
allProfitAndLoss.setIncome(incomeExclude); allProfitAndLoss.setIncome(incomeExclude);
} }
List<ProjectSettleCost> allSettleCost = projectSettleCostRepository.findAll(); List<ProjectSettleCost> allSettleCost = projectSettleCostRepository.findAllByProjectIds(projectIds);
if (CollectionUtil.isNotEmpty(allSettleCost)) { if (CollectionUtil.isNotEmpty(allSettleCost)) {
BigDecimal costDeviceAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal costDeviceAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_DEVICE).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal costBuildingAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_BUILDING).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal costBuildingAll = allSettleCost.stream().filter(d -> d.getType() == ProjectSettleCost.TYPE_BUILDING).map(ProjectSettleCost::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
@ -192,7 +200,7 @@ public class StatisticsService {
} }
List<ProjectSettleCostManage> allSettleCostManage = projectSettleCostManageRepository.findAll(); List<ProjectSettleCostManage> allSettleCostManage = projectSettleCostManageRepository.findAllByProjectIds(projectIds);
if (CollectionUtil.isNotEmpty(allSettleCostManage)) { if (CollectionUtil.isNotEmpty(allSettleCostManage)) {
BigDecimal expropriationAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal expropriationAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_EXPROPRIATION).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal companyManageAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal companyManageAll = allSettleCostManage.stream().filter(d -> d.getType() == ProjectSettleCostManage.TYPE_COMPANY_MANAGE).map(ProjectSettleCostManage::getCostTaxExclude).reduce(BigDecimal.ZERO, BigDecimal::add);
@ -204,7 +212,7 @@ public class StatisticsService {
allProfitAndLoss.setCompanyManage(companyManageAll); allProfitAndLoss.setCompanyManage(companyManageAll);
} }
List<ProjectSettleProfitMargin> profitMargins = projectSettleProfitMarginRepository.findAll(); List<ProjectSettleProfitMargin> profitMargins = projectSettleProfitMarginRepository.findAllByProjectIds(projectIds);
if(CollectionUtil.isNotEmpty(profitMargins)){ 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 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 typeContributionProfit = profitMargins.stream().filter(d -> d.getType() == ProjectSettleProfitMargin.TYPE_CONTRIBUTION_PROFIT).map(ProjectSettleProfitMargin::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
@ -279,7 +287,7 @@ public class StatisticsService {
} }
} }
List<CashFlowStatisticsBean> cashFlow = getCashFlow(); List<CashFlowStatisticsBean> cashFlow = getCashFlow(projectIds);
statisticsBean.setPrimaryIndicatorBeanList(list); statisticsBean.setPrimaryIndicatorBeanList(list);
statisticsBean.setProfitAndLossBeanList(profitAndLossList); statisticsBean.setProfitAndLossBeanList(profitAndLossList);
@ -292,12 +300,12 @@ public class StatisticsService {
* *
* @return * @return
*/ */
public List<CashFlowStatisticsBean> getCashFlow() { public List<CashFlowStatisticsBean> getCashFlow(List<Integer> projectIds) {
List<CashFlowStatisticsBean> list = new ArrayList<>(); List<CashFlowStatisticsBean> list = new ArrayList<>();
CashFlowStatisticsBean cashFlowStatisticsBean = new CashFlowStatisticsBean(); CashFlowStatisticsBean cashFlowStatisticsBean = new CashFlowStatisticsBean();
cashFlowStatisticsBean.setTitle("预算金额"); cashFlowStatisticsBean.setTitle("预算金额");
List<ProjectBudgetPlanDetail> cashFlows = projectBudgetPlanDetailRepository.findAll(); List<ProjectBudgetPlanDetail> cashFlows = projectBudgetPlanDetailRepository.findAllByProjectIds(projectIds);
BigDecimal saleIncome = cashFlows.stream().map(ProjectBudgetPlanDetail::getSaleIncome).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal saleIncome = cashFlows.stream().map(ProjectBudgetPlanDetail::getSaleIncome).reduce(BigDecimal.ZERO, BigDecimal::add);
cashFlowStatisticsBean.setSaleIncomeCash(saleIncome); cashFlowStatisticsBean.setSaleIncomeCash(saleIncome);
@ -327,7 +335,7 @@ public class StatisticsService {
list.add(cashFlowStatisticsBean); list.add(cashFlowStatisticsBean);
List<String> projectTime = projectSettleCashFlowRepository.getProjectTime(); List<String> projectTime = projectSettleCashFlowRepository.getProjectTime();
List<ProjectSettleCashFlow> all = projectSettleCashFlowRepository.findAll(); List<ProjectSettleCashFlow> all = projectSettleCashFlowRepository.findAllByProjectIds(projectIds);
CashFlowStatisticsBean cashFlowStatisticsAll = new CashFlowStatisticsBean(); CashFlowStatisticsBean cashFlowStatisticsAll = new CashFlowStatisticsBean();
cashFlowStatisticsAll.setTitle("实际累计"); cashFlowStatisticsAll.setTitle("实际累计");