From 80e3905180b45b7b11abac5edd91dca8569f28f7 Mon Sep 17 00:00:00 2001 From: hanbo <2608504783@qq.com> Date: Wed, 17 Nov 2021 10:42:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=9C=88=E9=A1=B9=E7=9B=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E9=A1=B5=E9=9D=A2=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/bean/PrimaryIndicatorBean.java | 71 +++++++++ .../backend/StatisticsController.java | 26 ++++ .../ProjectBudgetCostManageRepository.java | 5 + .../model/ProjectBudgetCostRepository.java | 8 + .../model/ProjectBudgetIncomeRepository.java | 9 ++ .../work/service/StatisticsService.java | 118 ++++++++++++++ .../templates/admin/month_statistics.ftl | 144 ++++++++++++++++++ 7 files changed, 381 insertions(+) create mode 100644 src/main/java/cn/palmte/work/bean/PrimaryIndicatorBean.java create mode 100644 src/main/java/cn/palmte/work/controller/backend/StatisticsController.java create mode 100644 src/main/java/cn/palmte/work/service/StatisticsService.java create mode 100644 src/main/resources/templates/admin/month_statistics.ftl diff --git a/src/main/java/cn/palmte/work/bean/PrimaryIndicatorBean.java b/src/main/java/cn/palmte/work/bean/PrimaryIndicatorBean.java new file mode 100644 index 0000000..2a9d9a9 --- /dev/null +++ b/src/main/java/cn/palmte/work/bean/PrimaryIndicatorBean.java @@ -0,0 +1,71 @@ +package cn.palmte.work.bean; + +import lombok.Data; + +/** + * 主要指标数据 + */ +@Data +public class PrimaryIndicatorBean { + + /** + * + */ + private String title; + + /** + * 收入--设备类 + */ + private long incomeDevice; + + /** + * 收入--施工类 + */ + private long incomeEngineer; + + /** + * 收入--服务类 + */ + private long incomeService; + + /** + * 采购成本--设备类 + */ + private long costPurchaseDevice; + + /** + * 采购成本--施工类 + */ + private long costPurchaseBuild; + + /** + * 采购成本--服务类 + */ + private long costPurchaseService; + + /** + * 采购成本--其他 + */ + private long costPurchaseOther; + + /** + * 成本--其他 + */ + private long costOtherOther; + + /** + * 成本--项目管理成本 + */ + private long costProjectManage; + + /** + * 财务费用--资金占用成本 + */ + private long costExpropriation; + + /** + * 公司管理费用 + */ + private long costCompanyManage; + +} diff --git a/src/main/java/cn/palmte/work/controller/backend/StatisticsController.java b/src/main/java/cn/palmte/work/controller/backend/StatisticsController.java new file mode 100644 index 0000000..e944b78 --- /dev/null +++ b/src/main/java/cn/palmte/work/controller/backend/StatisticsController.java @@ -0,0 +1,26 @@ +package cn.palmte.work.controller.backend; + +import cn.palmte.work.bean.PrimaryIndicatorBean; +import cn.palmte.work.service.StatisticsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.List; +import java.util.Map; + +@Controller +@RequestMapping("/statistics") +public class StatisticsController extends BaseController{ + + @Autowired + private StatisticsService statisticsService; + + @RequestMapping("/month") + public String month(Map<String, Object> model){ + List<PrimaryIndicatorBean> primaryIndicatorList = statisticsService.getPrimaryIndicator(); + model.put("primaryIndicatorList",primaryIndicatorList); + return "admin/month_statistics"; + } + +} diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java index 3940fe5..305e1f9 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetCostManageRepository.java @@ -1,9 +1,14 @@ package cn.palmte.work.model; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.List; public interface ProjectBudgetCostManageRepository extends JpaRepository<ProjectBudgetCostManage,Integer> { List<ProjectBudgetCostManage> findAllByProjectIdEquals(int id); + + @Query(value = "select sum(cost_tax_exclude) from project_budget_cost_manage where type = ?", nativeQuery = true) + long costTaxExcludeSum(int type); + } diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java index 5609bf1..35c14d4 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetCostRepository.java @@ -1,9 +1,17 @@ package cn.palmte.work.model; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.List; public interface ProjectBudgetCostRepository extends JpaRepository<ProjectBudgetCost,Integer> { List<ProjectBudgetCost> findAllByProjectIdEquals(int id); + + @Query(value = "select sum(cost_tax_include) from project_budget_cost where type = ?", nativeQuery = true) + long costTaxIncludeSum(int type); + + @Query(value = "select sum(cost_tax_exclude) from project_budget_cost where type = ?", nativeQuery = true) + long costTaxExcludeSum(int type); + } diff --git a/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java b/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java index 67eea29..0842139 100644 --- a/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java +++ b/src/main/java/cn/palmte/work/model/ProjectBudgetIncomeRepository.java @@ -1,9 +1,18 @@ package cn.palmte.work.model; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.List; public interface ProjectBudgetIncomeRepository extends JpaRepository<ProjectBudgetIncome,Integer> { List<ProjectBudgetIncome> findAllByProjectIdEquals(int id); + + @Query(value = "select sum(income_tax_include) from project_budget_income where type = ?", nativeQuery = true) + long incomeTaxIncludeSum(int type); + + @Query(value = "select sum(income_tax_exclude) from project_budget_income where type = ?", nativeQuery = true) + long incomeTaxExcludeSum(int type); + + } diff --git a/src/main/java/cn/palmte/work/service/StatisticsService.java b/src/main/java/cn/palmte/work/service/StatisticsService.java new file mode 100644 index 0000000..56a5ca2 --- /dev/null +++ b/src/main/java/cn/palmte/work/service/StatisticsService.java @@ -0,0 +1,118 @@ +package cn.palmte.work.service; + +import cn.palmte.work.bean.PrimaryIndicatorBean; +import cn.palmte.work.model.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class StatisticsService { + + @Autowired + private ProjectBudgetCostRepository projectBudgetCostRepository; + + @Autowired + private ProjectBudgetIncomeRepository projectBudgetIncomeRepository; + + @Autowired + private ProjectBudgetCostManageRepository projectBudgetCostManageRepository; + + /** + * 分月项目统计 获取主要指标数据 + * + * @return + */ + public List<PrimaryIndicatorBean> getPrimaryIndicator() { + List<PrimaryIndicatorBean> list = new ArrayList<>(); + PrimaryIndicatorBean include = new PrimaryIndicatorBean(); + include.setTitle("预算金额(含税)"); + //收入数据 + long deviceIncomeTaxIncludeSum = projectBudgetIncomeRepository.incomeTaxIncludeSum(ProjectBudgetIncome.TYPE_DEVICE); + long engineerIncomeTaxIncludeSum = projectBudgetIncomeRepository.incomeTaxIncludeSum(ProjectBudgetIncome.TYPE_ENGINEER); + long serviceIncomeTaxIncludeSum = projectBudgetIncomeRepository.incomeTaxIncludeSum(ProjectBudgetIncome.TYPE_SERVICE); + + include.setIncomeDevice(deviceIncomeTaxIncludeSum); + include.setIncomeEngineer(engineerIncomeTaxIncludeSum); + include.setIncomeService(serviceIncomeTaxIncludeSum); + + //成本 + long deviceCostTaxIncludeSum = projectBudgetCostRepository.costTaxIncludeSum(ProjectBudgetCost.TYPE_DEVICE); + long buildingCostTaxIncludeSum = projectBudgetCostRepository.costTaxIncludeSum(ProjectBudgetCost.TYPE_BUILDING); + long serviceCostTaxIncludeSum = projectBudgetCostRepository.costTaxIncludeSum(ProjectBudgetCost.TYPE_SERVICE); + long otherCostTaxIncludeSum = projectBudgetCostRepository.costTaxIncludeSum(ProjectBudgetCost.TYPE_OTHER); + long projectManageCostTaxIncludeSum = projectBudgetCostRepository.costTaxIncludeSum(ProjectBudgetCost.TYPE_PROJECT_MANAGE); + long otherOtherCostTaxIncludeSum = projectBudgetCostRepository.costTaxIncludeSum(ProjectBudgetCost.TYPE_OTHER_OTHER); + + include.setCostPurchaseDevice(deviceCostTaxIncludeSum); + include.setCostPurchaseBuild(buildingCostTaxIncludeSum); + include.setCostPurchaseService(serviceCostTaxIncludeSum); + include.setCostPurchaseOther(otherCostTaxIncludeSum); + include.setCostProjectManage(projectManageCostTaxIncludeSum); + include.setCostOtherOther(otherOtherCostTaxIncludeSum); + + list.add(include); + + PrimaryIndicatorBean exclude = new PrimaryIndicatorBean(); + exclude.setTitle("预算金额(不含税)"); + //收入数据 + long deviceIncomeTaxExcludeSum = projectBudgetIncomeRepository.incomeTaxExcludeSum(ProjectBudgetIncome.TYPE_DEVICE); + long engineerIncomeTaxExcludeSum = projectBudgetIncomeRepository.incomeTaxExcludeSum(ProjectBudgetIncome.TYPE_ENGINEER); + long serviceIncomeTaxExcludeSum = projectBudgetIncomeRepository.incomeTaxExcludeSum(ProjectBudgetIncome.TYPE_SERVICE); + + exclude.setIncomeDevice(deviceIncomeTaxExcludeSum); + exclude.setIncomeEngineer(engineerIncomeTaxExcludeSum); + exclude.setIncomeService(serviceIncomeTaxExcludeSum); + + //成本 + long deviceCostTaxExcludeSum = projectBudgetCostRepository.costTaxExcludeSum(ProjectBudgetCost.TYPE_DEVICE); + long buildingCostTaxExcludeSum = projectBudgetCostRepository.costTaxExcludeSum(ProjectBudgetCost.TYPE_BUILDING); + long serviceCostTaxExcludeSum = projectBudgetCostRepository.costTaxExcludeSum(ProjectBudgetCost.TYPE_SERVICE); + long otherCostTaxExcludeSum = projectBudgetCostRepository.costTaxExcludeSum(ProjectBudgetCost.TYPE_OTHER); + long projectManageCostTaxExcludeSum = projectBudgetCostRepository.costTaxExcludeSum(ProjectBudgetCost.TYPE_PROJECT_MANAGE); + long otherOtherCostTaxExcludeSum = projectBudgetCostRepository.costTaxExcludeSum(ProjectBudgetCost.TYPE_OTHER_OTHER); + + exclude.setCostPurchaseDevice(deviceCostTaxExcludeSum); + exclude.setCostPurchaseBuild(buildingCostTaxExcludeSum); + exclude.setCostPurchaseService(serviceCostTaxExcludeSum); + exclude.setCostPurchaseOther(otherCostTaxExcludeSum); + exclude.setCostProjectManage(projectManageCostTaxExcludeSum); + exclude.setCostOtherOther(otherOtherCostTaxExcludeSum); + + //管理 + long expropriationSum = projectBudgetCostManageRepository.costTaxExcludeSum(ProjectBudgetCostManage.TYPE_EXPROPRIATION); + long companyManageSum = projectBudgetCostManageRepository.costTaxExcludeSum(ProjectBudgetCostManage.TYPE_COMPANY_MANAGE); + + exclude.setCostExpropriation(expropriationSum); + exclude.setCostCompanyManage(companyManageSum); + + list.add(exclude); + + return list; + } + + /** + * 分月项目统计 获取损益表数据 + * + * @return + */ + public List getIncomeStatement() { + + + return null; + } + + /** + * 分月项目统计 获取现金流量表数据 + * + * @return + */ + public List getCashFlow() { + + + return null; + } + +} diff --git a/src/main/resources/templates/admin/month_statistics.ftl b/src/main/resources/templates/admin/month_statistics.ftl new file mode 100644 index 0000000..af19732 --- /dev/null +++ b/src/main/resources/templates/admin/month_statistics.ftl @@ -0,0 +1,144 @@ +<#assign base=request.contextPath /> +<#import "../common/defaultLayout.ftl" as defaultLayout> +<@defaultLayout.layout> + <div class="admin-content"> + <div class="admin-content-body"> + <div class="am-cf am-padding"> + <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">项目统计</strong> / + <small>分月项目统计</small></div> + </div> + + <form method="post" class="am-form" id="pmsForm"> + <!--选项卡(tabs)begin--> + <div class="am-tabs am-margin" data-am-tabs> + <ul class="am-tabs-nav am-nav am-nav-tabs"> + <li class="am-active"><a href="#tab1">主要指标</a></li> + <li><a href="#tab2">损益表</a></li> + <li><a href="#tab3">现金流量表</a></li> + </ul> + <div class="am-tabs-bd"> + <div class="am-tab-panel am-fade am-in am-active" id="tab1"> + <table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;"> + <thead> + <tr class="am-text-nowrap"> + <td>类别</td> + <td>收入--设备类</td> + <td>收入--施工类</td> + <td>收入--服务类</td> + <td>采购成本--设备类</td> + <td>采购成本--施工类</td> + <td>采购成本--服务类</td> + <td>采购成本--其他</td> + <td>成本--其他</td> + <td>成本--项目管理成本</td> + <td>财务费用--资金占用成本</td> + <td>公司管理费用</td> + </tr> + </thead> + + <tbody> + <#if (primaryIndicatorList)?exists && (primaryIndicatorList?size>0)> + <#list primaryIndicatorList as list> + <tr> + <td>${list.title!}</td> + <td>${list.incomeDevice!}</td> + <td>${list.incomeEngineer!}</td> + <td>${list.incomeService!}</td> + <td>${list.costPurchaseDevice!}</td> + <td>${list.costPurchaseBuild!}</td> + <td>${list.costPurchaseService!}</td> + <td>${list.costPurchaseOther!}</td> + <td>${list.costOtherOther!}</td> + <td>${list.costProjectManage!}</td> + <td>${list.costExpropriation!}</td> + <td>${list.costCompanyManage!}</td> + </tr> + </#list> + </#if> + </tbody> + </table> + </div> + </div> + + + <div class="am-tabs-bd"> + <div class="am-tab-panel am-fade am-in" id="tab2"> + <table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;"> + <tbody> + <tr> + <td>/</td> + <td>营业收入</td> + <td>营业成本</td> + <td>项目管理成本</td> + <td>其他</td> + <td>财务费用</td> + <td>项目毛利</td> + <td>项目毛利率</td> + <td>公司管理费用</td> + <td>项目贡献利润</td> + <td>项目贡献利润率</td> + <td>所得税费用</td> + <td>项目净利润</td> + <td>项目净利润率</td> + </tr> + </tbody> + </table> + </div> + </div> + + <div class="am-tabs-bd"> + <div class="am-tab-panel am-fade am-in" id="tab3"> + <table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;"> + <tbody> + <tr> + <td>/</td> + <td>销售商品、提供劳务收到的现金</td> + <td>收到的税费返还</td> + <td>收到其他与经营活动有关的现金</td> + <td>购买商品、接受劳务支付的现金</td> + <td>支付的各项税费</td> + <td>支付其他与经营活动有关的现金</td> + <td>经营活动产生的现金流量净额</td> + <td>投资活动现金流入</td> + <td>投资活动现金流出</td> + <td>投资活动产生的现金流量净额</td> + <td>借款资金流入</td> + <td>还款资金流出</td> + <td>筹资活动产生的现金流量净额</td> + <td>货币资金净增加额</td> + </tr> + </tbody> + </table> + </div> + </div> + </div> + + <!--选项卡(tabs)end--> + <div class="am-margin"> + <button type="button" class="am-btn am-btn-warning am-btn-xs" onclick="javascript:history.go(-1);"> + 返回上一级 + </button> + </div> + </form> + + </div> + </div> + <script> + var base = "${base}"; + </script> +</@defaultLayout.layout> + + + + + + + + + + + + + + +