Browse Source

fix: 驿站服务数量查询优化

zhangying 7 months ago
parent
commit
ce1e794d45

+ 11 - 0
src/main/java/com/hz/employmentsite/controller/statistics/StatisticsController.java

@@ -7,6 +7,7 @@ import com.hz.employmentsite.util.DateUtils;
 import com.hz.employmentsite.util.ExcelHelper;
 import com.hz.employmentsite.vo.statistics.HourNewAddCount;
 import com.hz.employmentsite.vo.statistics.RegionSystemDataCount;
+import com.hz.employmentsite.vo.statistics.SiteServiceCount;
 import com.hz.employmentsite.vo.statistics.SystemDataCount;
 import com.hz.employmentsite.vo.statistics.company.ModelCompanyCount;
 import com.hz.employmentsite.vo.statistics.jobUser.*;
@@ -205,6 +206,16 @@ public class StatisticsController {
         return RespGenerstor.success(result);
     }
 
+    /**
+     * 查询各驿站的服务数量
+     */
+    @GetMapping("/siteServiceCount")
+    public BaseResponse getSiteServiceCount(@RequestParam(required = false) Date startDate,
+                                            @RequestParam(required = false) Date endDate) {
+        List<SiteServiceCount> siteServiceCount = statisticsService.findSiteServiceCount(startDate, endDate);
+        return RespGenerstor.success(siteServiceCount);
+    }
+
     /**
      * 导出指定时间段的系统使用情况
      *

+ 9 - 0
src/main/java/com/hz/employmentsite/mapper/cquery/StatisticsCQuery.java

@@ -2,6 +2,7 @@ package com.hz.employmentsite.mapper.cquery;
 
 import com.hz.employmentsite.vo.statistics.HourNewAddCount;
 import com.hz.employmentsite.vo.statistics.RegionSystemDataCount;
+import com.hz.employmentsite.vo.statistics.SiteServiceCount;
 import com.hz.employmentsite.vo.statistics.SystemDataCount;
 import com.hz.employmentsite.vo.statistics.company.ModelCompanyCount;
 import com.hz.employmentsite.vo.statistics.jobUser.AgeRangeJobUserCount;
@@ -176,4 +177,12 @@ public interface StatisticsCQuery {
      * 查询某一天24小时的岗位新增数量
      */
     List<HourNewAddCount> findPostHourNewAddCount(@Param("day") Date day);
+
+    /**
+     * 查询各驿站的服务总数
+     */
+    List<SiteServiceCount> findSiteCompanyServiceCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
+    List<SiteServiceCount> findSitePostServiceCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
+    List<SiteServiceCount> findSiteJobUserServiceCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
+    List<SiteServiceCount> findSitePostRecruitServiceCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
 }

+ 32 - 0
src/main/java/com/hz/employmentsite/services/impl/statistics/StatisticsServiceImpl.java

@@ -8,6 +8,7 @@ import com.hz.employmentsite.util.StringUtils;
 import com.hz.employmentsite.vo.jobUserManager.JobUserServiceVo;
 import com.hz.employmentsite.vo.statistics.HourNewAddCount;
 import com.hz.employmentsite.vo.statistics.RegionSystemDataCount;
+import com.hz.employmentsite.vo.statistics.SiteServiceCount;
 import com.hz.employmentsite.vo.statistics.SystemDataCount;
 import com.hz.employmentsite.vo.statistics.company.ModelCompanyCount;
 import com.hz.employmentsite.vo.statistics.jobUser.*;
@@ -585,4 +586,35 @@ public class StatisticsServiceImpl implements StatisticsService {
         });
         return new ArrayList<>(resultMap.values());
     }
+
+    /**
+     * 查询各驿站的服务数量
+     */
+    @Override
+    public List<SiteServiceCount> findSiteServiceCount(Date startDate, Date endDate) {
+        List<SiteServiceCount> companyServiceCount = statisticsCQuery.findSiteCompanyServiceCount(startDate, endDate);
+        List<SiteServiceCount> postServiceCount = statisticsCQuery.findSitePostServiceCount(startDate, endDate);
+        List<SiteServiceCount> jobUserServiceCount = statisticsCQuery.findSiteJobUserServiceCount(startDate, endDate);
+        List<SiteServiceCount> postRecruitServiceCount = statisticsCQuery.findSitePostRecruitServiceCount(startDate, endDate);
+        Map<String, SiteServiceCount> resultMap = new HashMap<>();
+
+        // 合并四个个结果
+        companyServiceCount.forEach(item -> {
+            resultMap.computeIfAbsent(item.getSiteName(), k -> new SiteServiceCount(item.getSiteID(), item.getSiteName()))
+                    .setCompanyCount(item.getCompanyCount());
+        });
+        postServiceCount.forEach(item -> {
+            resultMap.computeIfAbsent(item.getSiteName(), k -> new SiteServiceCount(item.getSiteID(), item.getSiteName()))
+                    .setPostCount(item.getPostCount());
+        });
+        jobUserServiceCount.forEach(item -> {
+            resultMap.computeIfAbsent(item.getSiteName(), k -> new SiteServiceCount(item.getSiteID(), item.getSiteName()))
+                    .setJobUserCount(item.getJobUserCount());
+        });
+        postRecruitServiceCount.forEach(item -> {
+            resultMap.computeIfAbsent(item.getSiteName(), k -> new SiteServiceCount(item.getSiteID(), item.getSiteName()))
+                    .setPostRecruitCount(item.getPostRecruitCount());
+        });
+        return new ArrayList<>(resultMap.values());
+    }
 }

+ 27 - 0
src/main/java/com/hz/employmentsite/vo/statistics/SiteServiceCount.java

@@ -0,0 +1,27 @@
+package com.hz.employmentsite.vo.statistics;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SiteServiceCount {
+    private String siteID;
+
+    private String siteName;
+
+    private int companyCount;
+
+    private int postCount;
+
+    private int postRecruitCount;
+
+    private int jobUserCount;
+
+    public SiteServiceCount(String siteID, String siteName) {
+        this.siteID = siteID;
+        this.siteName = siteName;
+    }
+}

+ 86 - 0
src/main/resources/mapping/cquery/StatisticsCQuery.xml

@@ -779,4 +779,90 @@
         ORDER BY
             `Hour`
     </select>
+
+    <select id="findSiteCompanyServiceCount" resultType="com.hz.employmentsite.vo.statistics.SiteServiceCount">
+        SELECT
+            site.SiteID,
+            site.SiteName,
+            COUNT(CompanyID) AS companyCount
+        FROM
+            pc_site site
+                LEFT JOIN pc_company company ON company.SiteID = site.SiteID
+        WHERE
+            1=1
+            <if test="startDate != null">
+                and DATE(company.CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
+            </if>
+            <if test="endDate != null ">
+                and DATE(company.CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
+            </if>
+        GROUP BY
+            site.SiteID,
+            site.SiteName
+    </select>
+
+    <select id="findSitePostServiceCount" resultType="com.hz.employmentsite.vo.statistics.SiteServiceCount">
+        SELECT
+            site.SiteID,
+            site.SiteName,
+            COUNT(PostID) AS postCount
+        FROM
+            pc_site site
+                LEFT JOIN pc_company company ON company.SiteID = site.SiteID
+                LEFT JOIN pc_post post ON company.CompanyID = post.CompanyID
+        WHERE
+            1=1
+            <if test="startDate != null">
+                and DATE(post.CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
+            </if>
+            <if test="endDate != null ">
+                and DATE(post.CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
+            </if>
+        GROUP BY
+            site.SiteID,
+            site.SiteName
+    </select>
+
+    <select id="findSiteJobUserServiceCount" resultType="com.hz.employmentsite.vo.statistics.SiteServiceCount">
+        SELECT
+            site.SiteID,
+            site.SiteName,
+            COUNT(JobuserID) AS jobUserCount
+        FROM
+            pc_site site
+                LEFT JOIN pc_jobuser jobUser ON jobUser.SiteID = site.SiteID
+        WHERE
+            1=1
+            <if test="startDate != null">
+                and DATE(jobUser.CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
+            </if>
+            <if test="endDate != null ">
+                and DATE(jobUser.CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
+            </if>
+        GROUP BY
+            site.SiteID,
+            site.SiteName
+    </select>
+
+    <select id="findSitePostRecruitServiceCount" resultType="com.hz.employmentsite.vo.statistics.SiteServiceCount">
+        SELECT
+            site.SiteID,
+            site.SiteName,
+            SUM(post.RecruitCount) AS postRecruitCount
+        FROM
+            pc_site site
+                LEFT JOIN pc_company company ON company.SiteID = site.SiteID
+                LEFT JOIN pc_post post ON company.CompanyID = post.CompanyID
+        WHERE
+            1=1
+            <if test="startDate != null">
+                and DATE(post.CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
+            </if>
+            <if test="endDate != null ">
+                and DATE(post.CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
+            </if>
+        GROUP BY
+            site.SiteID,
+            site.SiteName
+    </select>
 </mapper>

+ 16 - 0
vue/src/api/statistics/index.ts

@@ -276,3 +276,19 @@ export function getOneDaySystemDataCount(day: any) {
     },
   );
 }
+
+/**
+ * 查询各驿站的服务数量
+ */
+export function getSiteServiceCount(params: any) {
+  return request<object>(
+    {
+      url: 'statistics/siteServiceCount',
+      method: 'get',
+      params: params,
+    },
+    {
+      isNew: true,
+    },
+  );
+}

+ 4 - 4
vue/src/views/dataScreen/html/index.vue

@@ -150,7 +150,7 @@
 <script setup lang="ts">
 import {
   getEmployedJobUserCount,
-  getJobUserByRegionAndDifficulty,
+  getJobUserByRegionAndDifficulty, getSiteServiceCount,
   getSystemApplyCountBySite,
   getYearSystemDataCount
 } from "@/api/statistics";
@@ -463,11 +463,11 @@ function changeRegionTab(value: any) {
 
 // 查询驿站服务榜
 function loadSiteTop(params: any) {
-  getSystemApplyCountBySite(params).then((result: any) => {
+  getSiteServiceCount(params).then((result: any) => {
     let countMap: { [key: string]: number } = {}
     result.forEach((item: any) => {
-      if (item.regionName != '市本级' && item.siteName != '惠州市就业驿站') {
-        countMap[item.siteName] = item.companyCount + item.postRecruitCount + item.jobUserCount;
+      if (item.siteName != '惠州市就业驿站') {
+        countMap[item.siteName] = item.companyCount + item.postRecruitCount + item.jobUserCount + item.postCount;
       }
     })
     siteServiceData.value = Object.entries(countMap)

+ 4 - 4
vue/src/views/dataScreen/html/sysService.vue

@@ -169,7 +169,7 @@ import {
   getDifficultyUserServiceCount,
   getOneDaySystemDataCount,
   getSiteAndSiteUserCountByRegion,
-  getSiteJobUserCount, getSystemApplyCountBySite, getYearSystemDataCount
+  getSiteJobUserCount, getSiteServiceCount, getSystemApplyCountBySite, getYearSystemDataCount
 } from "@/api/statistics";
 import {initDataSetBarImageTable, initLineImageTable, initRingPieImageTable} from "@/views/dataScreen/echarts";
 import {getSystemServiceList} from "@/api/jobUserManager/jobuser/jobUserService";
@@ -426,11 +426,11 @@ function changeRegionTab(value: any) {
 
 // 查询驿站服务榜
 function loadSiteTop(params: any) {
-  getSystemApplyCountBySite(params).then((result: any) => {
+  getSiteServiceCount(params).then((result: any) => {
     let countMap: { [key: string]: number } = {}
     result.forEach((item: any) => {
-      if (item.regionName != '市本级' && item.siteName != '惠州市就业驿站') {
-        countMap[item.siteName] = item.companyCount + item.postRecruitCount + item.jobUserCount;
+      if (item.siteName != '惠州市就业驿站') {
+        countMap[item.siteName] = item.companyCount + item.postRecruitCount + item.jobUserCount + item.postCount;
       }
     })
     siteServiceData.value = Object.entries(countMap)