添加功能
This commit is contained in:
@@ -0,0 +1,310 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.cms.mapper.ThemeRecruitmentJobMapper">
|
||||
|
||||
<!--公共条件 -->
|
||||
<sql id="commonConditions">
|
||||
posting_date BETWEEN #{startTime} AND #{endTime}
|
||||
<if test="area != null and area != ''">
|
||||
AND job_location_area_code = #{area}
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry LIKE #{industry} || '%'
|
||||
</if>
|
||||
<if test="industryList != null and industryList.size() > 0">
|
||||
AND (
|
||||
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
||||
industry LIKE #{industry} || '%'
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="queryMonitorIndustryCount"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="java.lang.Long">
|
||||
|
||||
SELECT COUNT(DISTINCT SUBSTRING(industry FROM 1 FOR 3))
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="queryMonitorCompanyCount"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="java.lang.Long">
|
||||
|
||||
SELECT COUNT(DISTINCT code)
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="queryEmploymentDemandCount"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="java.lang.Long">
|
||||
|
||||
SELECT COALESCE(SUM(vacancies), 0)
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="laborDemandTrendYear"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.MajorIndustryEmploymentMonitorTreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
(make_timestamp(p.current_year - month_num + 1, 1, 1, 0, 0, 0) ) AS start_time,
|
||||
(make_timestamp(p.current_year - month_num + 1 , 12, 31, 23, 59, 59) ) AS end_time
|
||||
FROM params p
|
||||
CROSS JOIN (SELECT generate_series(1, 5) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
COALESCE(SUM(vacancies), 0) AS laborDemandCount
|
||||
FROM month_ranges r
|
||||
LEFT JOIN theme_recruitment_job
|
||||
ON
|
||||
posting_date BETWEEN r.start_time AND r.end_time
|
||||
<if test="area != null and area != ''">
|
||||
AND job_location_area_code = #{area}
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry LIKE #{industry} || '%'
|
||||
</if>
|
||||
<if test="industryList != null and industryList.size() > 0">
|
||||
AND (
|
||||
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
||||
industry LIKE #{industry} || '%'
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
GROUP BY r.month_num
|
||||
)
|
||||
SELECT
|
||||
(CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) +1 - month_num) AS code,
|
||||
(CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) +1 - month_num) AS sort,
|
||||
(CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) +1 - month_num) || '年' AS "desc",
|
||||
COALESCE(laborDemandCount, 0) AS laborDemandCount
|
||||
FROM aggregated_data
|
||||
ORDER BY sort ;
|
||||
</select>
|
||||
|
||||
<select id="laborDemandTrendQuarter"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.MajorIndustryEmploymentMonitorTreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
(make_timestamp(p.current_year , 1, 1, 0, 0, 0)
|
||||
+ (m.month_num - 1) * 3 * INTERVAL '1 month') AS start_time,
|
||||
(make_timestamp(p.current_year , 1, 1, 0, 0, 0)
|
||||
+ m.month_num * 3 * INTERVAL '1 month' - INTERVAL '1 second') AS end_time
|
||||
FROM params p
|
||||
CROSS JOIN (SELECT generate_series(1, 4) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
COALESCE(SUM(vacancies), 0) AS laborDemandCount
|
||||
FROM month_ranges r
|
||||
LEFT JOIN theme_recruitment_job
|
||||
ON
|
||||
posting_date BETWEEN r.start_time AND r.end_time
|
||||
<if test="area != null and area != ''">
|
||||
AND job_location_area_code = #{area}
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry LIKE #{industry} || '%'
|
||||
</if>
|
||||
<if test="industryList != null and industryList.size() > 0">
|
||||
AND (
|
||||
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
||||
industry LIKE #{industry} || '%'
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
GROUP BY r.month_num
|
||||
)
|
||||
SELECT
|
||||
month_num AS code,
|
||||
month_num AS sort,
|
||||
'第' || month_num || '季度' AS "desc",
|
||||
COALESCE(laborDemandCount, 0) AS laborDemandCount
|
||||
FROM aggregated_data
|
||||
ORDER BY month_num;
|
||||
</select>
|
||||
|
||||
<select id="laborDemandTrendMonth"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.MajorIndustryEmploymentMonitorTreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
(make_timestamp(p.current_year , 1, 1, 0, 0, 0)
|
||||
+ (m.month_num - 1) * INTERVAL '1 month') AS start_time,
|
||||
(make_timestamp(p.current_year , 1, 1, 0, 0, 0)
|
||||
+ m.month_num * INTERVAL '1 month' - INTERVAL '1 second') AS end_time
|
||||
FROM params p
|
||||
CROSS JOIN (SELECT generate_series(1, 12) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
COALESCE(SUM(vacancies), 0) AS laborDemandCount
|
||||
FROM month_ranges r
|
||||
LEFT JOIN theme_recruitment_job
|
||||
ON
|
||||
posting_date BETWEEN r.start_time AND r.end_time
|
||||
<if test="area != null and area != ''">
|
||||
AND job_location_area_code = #{area}
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry LIKE #{industry} || '%'
|
||||
</if>
|
||||
<if test="industryList != null and industryList.size() > 0">
|
||||
AND (
|
||||
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
||||
industry LIKE #{industry} || '%'
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
GROUP BY r.month_num
|
||||
)
|
||||
SELECT
|
||||
month_num AS code,
|
||||
month_num AS sort,
|
||||
month_num || '月' AS "desc",
|
||||
COALESCE(laborDemandCount, 0) AS laborDemandCount
|
||||
FROM aggregated_data
|
||||
ORDER BY month_num;
|
||||
</select>
|
||||
|
||||
<select id="queryEmploymentDemandCountByIndustry"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
||||
|
||||
SELECT
|
||||
code,
|
||||
COALESCE(SUM(vacancies), 0) AS count
|
||||
FROM (
|
||||
SELECT
|
||||
vacancies,
|
||||
SUBSTRING(industry FROM 1 FOR 3) AS code
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code
|
||||
ORDER BY code
|
||||
</select>
|
||||
|
||||
<select id="salaryLevel"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
||||
|
||||
SELECT
|
||||
code,
|
||||
COALESCE(ROUND(AVG((salary)), 2), 0) AS amount,
|
||||
COALESCE(ROUND((PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY salary))::NUMERIC, 2), 0) AS anotherAmount
|
||||
FROM (
|
||||
SELECT
|
||||
industry AS code,
|
||||
(min_salary + max_salary)/2 AS salary
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code
|
||||
ORDER BY code
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryEmploymentDemandCountByJobType"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
||||
|
||||
SELECT
|
||||
code,
|
||||
COALESCE(SUM(vacancies), 0) AS count
|
||||
FROM (
|
||||
SELECT
|
||||
vacancies,
|
||||
job_category AS code
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code
|
||||
ORDER BY code
|
||||
</select>
|
||||
|
||||
<select id="queryLaborGapCountByIndustry"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
||||
|
||||
SELECT
|
||||
code,
|
||||
COALESCE(SUM(vacancies), 0) AS count
|
||||
FROM (
|
||||
SELECT
|
||||
vacancies,
|
||||
SUBSTRING(industry FROM 1 FOR 3) AS code
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code
|
||||
ORDER BY code
|
||||
</select>
|
||||
|
||||
<select id="heatmap"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.HeatmapVo">
|
||||
|
||||
SELECT
|
||||
areaCode,
|
||||
COUNT(DISTINCT code) AS count
|
||||
FROM (
|
||||
SELECT
|
||||
code,
|
||||
job_location_area_code AS areaCode
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY areaCode
|
||||
ORDER BY areaCode
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user