添加功能
This commit is contained in:
@@ -332,4 +332,479 @@
|
||||
GROUP BY areaCode
|
||||
ORDER BY areaCode
|
||||
</select>
|
||||
|
||||
<select id="recruitmentTrendYear"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
y.year_offset,
|
||||
(make_timestamp(p.current_year - y.year_offset - 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 0 AS year_offset UNION ALL SELECT 1) y
|
||||
CROSS JOIN (SELECT generate_series(1, 5) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 0 THEN vacancies END), 0) AS current_count,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 1 THEN vacancies END), 0) AS last_count
|
||||
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(current_count, 0) AS currentCount,
|
||||
COALESCE(last_count, 0) AS lastYearCount
|
||||
FROM aggregated_data
|
||||
ORDER BY sort ;
|
||||
</select>
|
||||
|
||||
<select id="recruitmentTrendQuarter"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
y.year_offset,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ (m.month_num - 1) * 3 * INTERVAL '1 month') AS start_time,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ m.month_num * 3 * INTERVAL '1 month' - INTERVAL '1 second') AS end_time
|
||||
FROM params p
|
||||
CROSS JOIN (SELECT 0 AS year_offset UNION ALL SELECT 1) y
|
||||
CROSS JOIN (SELECT generate_series(1, 4) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 0 THEN vacancies END), 0) AS current_count,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 1 THEN vacancies END), 0) AS last_count
|
||||
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(current_count, 0) AS currentCount,
|
||||
COALESCE(last_count, 0) AS lastYearCount
|
||||
FROM aggregated_data
|
||||
ORDER BY month_num;
|
||||
</select>
|
||||
|
||||
<select id="recruitmentTrendMonth"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
y.year_offset,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ (m.month_num - 1) * INTERVAL '1 month') AS start_time,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ m.month_num * INTERVAL '1 month' - INTERVAL '1 second') AS end_time
|
||||
FROM params p
|
||||
CROSS JOIN (SELECT 0 AS year_offset UNION ALL SELECT 1) y
|
||||
CROSS JOIN (SELECT generate_series(1, 12) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 0 THEN vacancies END), 0) AS current_count,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 1 THEN vacancies END), 0) AS last_count
|
||||
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(current_count, 0) AS currentCount,
|
||||
COALESCE(last_count, 0) AS lastYearCount
|
||||
FROM aggregated_data
|
||||
ORDER BY month_num;
|
||||
</select>
|
||||
|
||||
<select id="majorIndustryRecruitment"
|
||||
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="majorIndustryLaborForceTreadYear"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
y.year_offset,
|
||||
(make_timestamp(p.current_year - y.year_offset - 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 0 AS year_offset UNION ALL SELECT 1) y
|
||||
CROSS JOIN (SELECT generate_series(1, 5) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
SUBSTRING(industry FROM 1 FOR 3) AS another_code,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 0 THEN vacancies END), 0) AS current_count,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 1 THEN vacancies END), 0) AS last_count
|
||||
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,SUBSTRING(industry FROM 1 FOR 3)
|
||||
)
|
||||
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",
|
||||
another_code AS anotherCode,
|
||||
COALESCE(current_count, 0) AS currentCount,
|
||||
COALESCE(last_count, 0) AS lastYearCount
|
||||
FROM aggregated_data
|
||||
ORDER BY sort ;
|
||||
</select>
|
||||
|
||||
<select id="majorIndustryLaborForceTreadQuarter"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
y.year_offset,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ (m.month_num - 1) * 3 * INTERVAL '1 month') AS start_time,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ m.month_num * 3 * INTERVAL '1 month' - INTERVAL '1 second') AS end_time
|
||||
FROM params p
|
||||
CROSS JOIN (SELECT 0 AS year_offset UNION ALL SELECT 1) y
|
||||
CROSS JOIN (SELECT generate_series(1, 4) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
SUBSTRING(industry FROM 1 FOR 3) AS another_code,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 0 THEN vacancies END), 0) AS current_count,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 1 THEN vacancies END), 0) AS last_count
|
||||
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,SUBSTRING(industry FROM 1 FOR 3)
|
||||
)
|
||||
SELECT
|
||||
month_num AS code,
|
||||
month_num AS sort,
|
||||
'第' || month_num || '季度' AS "desc",
|
||||
another_code AS anotherCode,
|
||||
COALESCE(current_count, 0) AS currentCount,
|
||||
COALESCE(last_count, 0) AS lastYearCount
|
||||
FROM aggregated_data
|
||||
ORDER BY month_num;
|
||||
</select>
|
||||
|
||||
<select id="majorIndustryLaborForceTreadMonth"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
WITH params AS (
|
||||
SELECT CAST(EXTRACT(YEAR FROM #{endTime}) AS INT) AS current_year
|
||||
),
|
||||
-- 一次性生成两年(当前年、去年)的所有月度时间范围
|
||||
month_ranges AS (
|
||||
SELECT
|
||||
m.month_num,
|
||||
y.year_offset,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ (m.month_num - 1) * INTERVAL '1 month') AS start_time,
|
||||
(make_timestamp(p.current_year - y.year_offset, 1, 1, 0, 0, 0)
|
||||
+ m.month_num * INTERVAL '1 month' - INTERVAL '1 second') AS end_time
|
||||
FROM params p
|
||||
CROSS JOIN (SELECT 0 AS year_offset UNION ALL SELECT 1) y
|
||||
CROSS JOIN (SELECT generate_series(1, 12) AS month_num) m
|
||||
),
|
||||
-- 一次扫描表,按条件区分当前年和去年数据
|
||||
aggregated_data AS (
|
||||
SELECT
|
||||
r.month_num,
|
||||
SUBSTRING(industry FROM 1 FOR 3) AS another_code,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 0 THEN vacancies END), 0) AS current_count,
|
||||
COALESCE(SUM(CASE WHEN r.year_offset = 1 THEN vacancies END), 0) AS last_count
|
||||
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,SUBSTRING(industry FROM 1 FOR 3)
|
||||
)
|
||||
SELECT
|
||||
month_num AS code,
|
||||
month_num AS sort,
|
||||
month_num || '月' AS "desc",
|
||||
another_code AS anotherCode,
|
||||
COALESCE(current_count, 0) AS currentCount,
|
||||
COALESCE(last_count, 0) AS lastYearCount
|
||||
FROM aggregated_data
|
||||
ORDER BY month_num;
|
||||
</select>
|
||||
|
||||
<select id="companyRecruitmentCount"
|
||||
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,
|
||||
nature AS code
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code
|
||||
ORDER BY code
|
||||
</select>
|
||||
|
||||
<select id="companyRecruitmentWay"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
|
||||
SELECT
|
||||
code,
|
||||
anotherCode,
|
||||
COALESCE(SUM(vacancies), 0) AS currentCount
|
||||
FROM (
|
||||
SELECT
|
||||
vacancies,
|
||||
nature AS code,
|
||||
recruitment_way AS anotherCode
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code,anotherCode
|
||||
ORDER BY code,anotherCode
|
||||
</select>
|
||||
|
||||
<select id="companyRecruitmentEducationLevel"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.TreadVo">
|
||||
|
||||
SELECT
|
||||
code,
|
||||
anotherCode,
|
||||
COALESCE(SUM(vacancies), 0) AS currentCount
|
||||
FROM (
|
||||
SELECT
|
||||
vacancies,
|
||||
nature AS code,
|
||||
education AS anotherCode
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code,anotherCode
|
||||
ORDER BY code,anotherCode
|
||||
</select>
|
||||
|
||||
<select id="recruitmentArea"
|
||||
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_location_area_code AS code
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY code
|
||||
ORDER BY code
|
||||
</select>
|
||||
|
||||
<select id="commitmentSalary"
|
||||
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
||||
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
||||
SELECT
|
||||
code,
|
||||
"desc",
|
||||
count
|
||||
FROM(
|
||||
SELECT
|
||||
"desc" AS code,
|
||||
"desc",
|
||||
COALESCE(SUM(vacancies), 0) AS count
|
||||
FROM (
|
||||
SELECT
|
||||
vacancies,
|
||||
CASE
|
||||
WHEN COALESCE(ROUND(AVG(((min_salary + max_salary)/2)), 2), 0) < 5000 THEN '5K以下'
|
||||
WHEN COALESCE(ROUND(AVG(((min_salary + max_salary)/2)), 2), 0) BETWEEN 5000 AND 8000 THEN '5-8K'
|
||||
WHEN COALESCE(ROUND(AVG(((min_salary + max_salary)/2)), 2), 0) BETWEEN 8001 AND 12000 THEN '8-12K'
|
||||
WHEN COALESCE(ROUND(AVG(((min_salary + max_salary)/2)), 2), 0) BETWEEN 12001 AND 15000 THEN '12-15K'
|
||||
WHEN COALESCE(ROUND(AVG(((min_salary + max_salary)/2)), 2), 0) > 15000 THEN '15K以上'
|
||||
ELSE '未知'
|
||||
END AS "desc"
|
||||
FROM theme_recruitment_job
|
||||
WHERE
|
||||
<!-- 引入公共条件 -->
|
||||
<include refid="commonConditions"/>
|
||||
) subquery
|
||||
GROUP BY "desc"
|
||||
)
|
||||
WHERE
|
||||
COALESCE(SUM(vacancies), 0) > 0;
|
||||
ORDER BY
|
||||
CASE "desc"
|
||||
WHEN '5K以下' THEN 1
|
||||
WHEN '5-8K' THEN 2
|
||||
WHEN '8-12K' THEN 3
|
||||
WHEN '12-15K' THEN 4
|
||||
WHEN '15K以上' THEN 5
|
||||
ELSE 6
|
||||
END
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user