Răsfoiți Sursa

完成首页接口(3个)

ljx 1 lună în urmă
părinte
comite
e352c0d391

+ 16 - 1
enteprise-admin/src/main/java/com/enteprise/industry_oveview/controller/IndustryOverviewController.java

@@ -2,6 +2,8 @@ package com.enteprise.industry_oveview.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.enteprise.industry_oveview.domain.IndustryCount;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -41,8 +43,21 @@ public class IndustryOverviewController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(IndustryOverview industryOverview)
     {
+
         startPage();
-        List<IndustryOverview> list = industryOverviewService.selectIndustryOverviewList(industryOverview);
+        List<IndustryOverview> industryOverviews = industryOverviewService.selectIndustryOverviewList(industryOverview);
+        return getDataTable(industryOverviews);
+    }
+
+    /**
+     * 查询行业数量列表
+     */
+    @PreAuthorize("@ss.hasPermi('industry_oveview:industry_oveview:list')")
+    @GetMapping("/i_list")
+    public TableDataInfo i_list()
+    {
+        startPage();
+        List<IndustryCount> list = industryOverviewService.selectIndustryCountList();
         return getDataTable(list);
     }
 

+ 39 - 0
enteprise-admin/src/main/java/com/enteprise/industry_oveview/domain/IndustryCount.java

@@ -0,0 +1,39 @@
+package com.enteprise.industry_oveview.domain;
+
+import com.enteprise.common.annotation.Excel;
+
+public class IndustryCount {
+    private static final long serialVersionUID = 1L;
+    /** 行业大类 */
+    private String industryName;
+
+    /** 行业代码 */
+    private String code;
+
+    /** 企业数量 */
+    private int number;
+
+    public String getIndustryName() {
+        return industryName;
+    }
+
+    public void setIndustryName(String industryName) {
+        this.industryName = industryName;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public int getNumber() {
+        return number;
+    }
+
+    public void setNumber(int number) {
+        this.number = number;
+    }
+}

+ 7 - 3
enteprise-admin/src/main/java/com/enteprise/industry_oveview/domain/IndustryOverview.java

@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.enteprise.common.annotation.Excel;
 import com.enteprise.common.core.domain.BaseEntity;
 
+import java.util.List;
+
 /**
  * industry_oveview对象 industry_overview
  * 
@@ -20,7 +22,7 @@ public class IndustryOverview extends BaseEntity
 
     /** 年份 */
     @Excel(name = "年份")
-    private String year;
+    private int year;
 
     /** 用地面积 */
     @Excel(name = "用地面积")
@@ -62,6 +64,7 @@ public class IndustryOverview extends BaseEntity
     @Excel(name = "实缴税金")
     private Long paidTaxSum;
 
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -71,12 +74,12 @@ public class IndustryOverview extends BaseEntity
     {
         return id;
     }
-    public void setYear(String year) 
+    public void setYear(Integer year)
     {
         this.year = year;
     }
 
-    public String getYear() 
+    public Integer getYear()
     {
         return year;
     }
@@ -171,6 +174,7 @@ public class IndustryOverview extends BaseEntity
         return paidTaxSum;
     }
 
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 6 - 0
enteprise-admin/src/main/java/com/enteprise/industry_oveview/mapper/IndustryOverviewMapper.java

@@ -1,6 +1,8 @@
 package com.enteprise.industry_oveview.mapper;
 
 import java.util.List;
+
+import com.enteprise.industry_oveview.domain.IndustryCount;
 import com.enteprise.industry_oveview.domain.IndustryOverview;
 
 /**
@@ -58,4 +60,8 @@ public interface IndustryOverviewMapper
      * @return 结果
      */
     public int deleteIndustryOverviewByIds(Long[] ids);
+
+    public List<IndustryCount> selectIndustryCount();
+
+    public List<IndustryOverview> countAllIndustryOverview();
 }

+ 4 - 0
enteprise-admin/src/main/java/com/enteprise/industry_oveview/service/IIndustryOverviewService.java

@@ -1,6 +1,8 @@
 package com.enteprise.industry_oveview.service;
 
 import java.util.List;
+
+import com.enteprise.industry_oveview.domain.IndustryCount;
 import com.enteprise.industry_oveview.domain.IndustryOverview;
 
 /**
@@ -27,6 +29,8 @@ public interface IIndustryOverviewService
      */
     public List<IndustryOverview> selectIndustryOverviewList(IndustryOverview industryOverview);
 
+    public List<IndustryCount> selectIndustryCountList();
+
     /**
      * 新增industry_oveview
      * 

+ 31 - 1
enteprise-admin/src/main/java/com/enteprise/industry_oveview/service/impl/IndustryOverviewServiceImpl.java

@@ -1,6 +1,11 @@
 package com.enteprise.industry_oveview.service.impl;
 
 import java.util.List;
+import java.util.stream.Collectors;
+
+import com.enteprise.enterprise.domain.Enterprise;
+import com.enteprise.enterprise.mapper.EnterpriseMapper;
+import com.enteprise.industry_oveview.domain.IndustryCount;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.enteprise.industry_oveview.mapper.IndustryOverviewMapper;
@@ -19,6 +24,9 @@ public class IndustryOverviewServiceImpl implements IIndustryOverviewService
     @Autowired
     private IndustryOverviewMapper industryOverviewMapper;
 
+    @Autowired
+    private EnterpriseMapper enterpriseMapper;
+
     /**
      * 查询industry_oveview
      * 
@@ -40,7 +48,29 @@ public class IndustryOverviewServiceImpl implements IIndustryOverviewService
     @Override
     public List<IndustryOverview> selectIndustryOverviewList(IndustryOverview industryOverview)
     {
-        return industryOverviewMapper.selectIndustryOverviewList(industryOverview);
+        List<IndustryOverview> list;
+        if (industryOverview.getYear() == 0){
+            //求总和
+            list = industryOverviewMapper.countAllIndustryOverview().stream().limit(1).collect(Collectors.toList());
+        }else {
+            //求某年
+            list  = industryOverviewMapper.selectIndustryOverviewList(industryOverview);
+        }
+        return list;
+    }
+
+    @Override
+    public List<IndustryCount> selectIndustryCountList() {
+        List<IndustryCount> collect = industryOverviewMapper.selectIndustryCount().stream().limit(10).collect(Collectors.toList());
+        IndustryCount industryCount = new IndustryCount();
+        //计算企业剩余数
+        industryCount.setCode("others");
+        industryCount.setIndustryName("其他");
+        List<Enterprise> enterprises = enterpriseMapper.selectEnterpriseList(new Enterprise());
+        int i = enterprises.size() + 1 - collect.stream().mapToInt(IndustryCount::getNumber).sum();
+        industryCount.setNumber(i);
+        collect.add(industryCount);
+        return collect;
     }
 
     /**

+ 37 - 0
enteprise-admin/src/main/resources/mapper/industry_oveview/IndustryOverviewMapper.xml

@@ -103,4 +103,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <select id="selectIndustryCount" resultType="IndustryCount">
+        SELECT
+            i.code AS code,
+            i.industry_name AS industry_name,
+            COUNT(e.id) AS number
+        FROM
+            industry i
+                LEFT JOIN
+            enterprise e ON i.code = e.code
+        GROUP BY
+            i.code, i.industry_name
+        ORDER BY
+            number DESC
+    </select>
+
+    <select id="countAllIndustryOverview" resultMap="IndustryOverviewResult">
+        SELECT
+            id,
+            year,
+            land_area,
+            sum(power_consume_sum) as power_consume_sum,
+            sum(energy_consume_sum) as energy_consume_sum,
+            sum(funding_sum) as funding_sum,
+            employee_number_sum,
+            profit_sum,
+            enterprise_numbers,
+            sum(total_industrial_value_sum) as total_industrial_value_sum,
+            sum(taxable_income_sum) as taxable_income_sum,
+            sum(paid_tax_sum) as paid_tax_sum
+        FROM
+            industry_overview
+        WHERE
+            year = (SELECT MAX(year) FROM industry_overview)
+        GROUP BY
+            year, id, land_area, employee_number_sum, enterprise_numbers
+    </select>
 </mapper>