625 lines
22 KiB
XML
625 lines
22 KiB
XML
<?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.ThemeEmploymentRegisterMapper">
|
|
|
|
<!--公共条件 -->
|
|
<sql id="commonConditions">
|
|
|
|
ADC110 BETWEEN #{startTime} AND #{endTime}
|
|
<if test="area != null and area != ''">
|
|
AND AAB301 = #{area}
|
|
</if>
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
<if test="industryList != null and industryList.size() > 0">
|
|
AND (
|
|
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
|
AAB022 LIKE #{industry} || '%'
|
|
</foreach>
|
|
)
|
|
</if>
|
|
|
|
AND (ABE585 IS NULL OR ABE585 > #{endTime})
|
|
</sql>
|
|
|
|
|
|
<select id="queryEmploymentCount"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="java.lang.Long">
|
|
|
|
SELECT COUNT(DISTINCT AAC044)
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
|
|
</select>
|
|
|
|
|
|
<select id="queryKindEmploymentCount"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.dto.EmploymentRegisterSqlDto">
|
|
|
|
SELECT
|
|
COUNT(DISTINCT AAC044) AS totalCount,
|
|
COUNT(DISTINCT CASE WHEN YCC035 = '1' THEN AAC044 END) AS totalTownEmploymentCount,
|
|
COUNT(DISTINCT CASE WHEN YCC036 = '1' THEN AAC044 END) AS unEmploymentEmploymentCount,
|
|
COUNT(DISTINCT CASE WHEN YAR02G = '1' THEN AAC044 END) AS employmentDifficultyEmploymentCount
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
|
|
</select>
|
|
|
|
<select id="queryStartupCompanyCount"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="java.lang.Long">
|
|
|
|
SELECT COUNT(DISTINCT AAB998)
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
AND ADC113 = '1'
|
|
</select>
|
|
|
|
<select id="queryStartupEmploymentCount"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="java.lang.Long">
|
|
|
|
SELECT COALESCE(SUM(ACC321), 0)
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
AND ADC113 = '1'
|
|
</select>
|
|
|
|
<select id="queryFlexibleEmploymentCount"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="java.lang.Long">
|
|
|
|
SELECT COUNT(DISTINCT AAC044)
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
AND ADC111 = '22'
|
|
</select>
|
|
|
|
<select id="queryAverageSalary"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="java.math.BigDecimal">
|
|
|
|
SELECT COALESCE(ROUND(AVG(ACC328), 2), 0)
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
</select>
|
|
|
|
<select id="scaleAndTrendYear"
|
|
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 - y.year_offset - 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,
|
|
COUNT(DISTINCT CASE WHEN r.year_offset = 0 THEN AAC044 END) AS current_count,
|
|
COUNT(DISTINCT CASE WHEN r.year_offset = 1 THEN AAC044 END) AS last_count
|
|
FROM month_ranges r
|
|
LEFT JOIN theme_employment_register
|
|
ON
|
|
ADC110 BETWEEN r.start_time AND r.end_time
|
|
<if test="area != null and area != ''">
|
|
AND AAB301 = #{area}
|
|
</if>
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
|
|
AND (ABE585 IS NULL OR ABE585 > r.end_time)
|
|
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="scaleAndTrendQuarter"
|
|
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,
|
|
COUNT(DISTINCT CASE WHEN r.year_offset = 0 THEN AAC044 END) AS current_count,
|
|
COUNT(DISTINCT CASE WHEN r.year_offset = 1 THEN AAC044 END) AS last_count
|
|
FROM month_ranges r
|
|
LEFT JOIN theme_employment_register
|
|
ON
|
|
ADC110 BETWEEN r.start_time AND r.end_time
|
|
<if test="area != null and area != ''">
|
|
AND AAB301 = #{area}
|
|
</if>
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
|
|
AND (ABE585 IS NULL OR ABE585 > r.end_time)
|
|
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="scaleAndTrendMonth"
|
|
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,
|
|
COUNT(DISTINCT CASE WHEN r.year_offset = 0 THEN AAC044 END) AS current_count,
|
|
COUNT(DISTINCT CASE WHEN r.year_offset = 1 THEN AAC044 END) AS last_count
|
|
FROM month_ranges r
|
|
LEFT JOIN theme_employment_register
|
|
ON
|
|
ADC110 BETWEEN r.start_time AND r.end_time
|
|
<if test="area != null and area != ''">
|
|
AND AAB301 = #{area}
|
|
</if>
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
|
|
AND (ABE585 IS NULL OR ABE585 > r.end_time)
|
|
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="structure"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
|
|
|
SELECT
|
|
code,
|
|
"desc",
|
|
COUNT(DISTINCT AAC044) AS count
|
|
FROM (
|
|
SELECT
|
|
AAC044,
|
|
ACA112 AS code,
|
|
ACA112 AS "desc"
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
) subquery
|
|
GROUP BY code,"desc"
|
|
ORDER BY code,"desc"
|
|
</select>
|
|
|
|
|
|
<select id="scaleComparison"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
|
|
|
SELECT
|
|
code,
|
|
COUNT(DISTINCT AAC044) AS count
|
|
FROM (
|
|
SELECT
|
|
AAC044,
|
|
SUBSTRING(AAB022 FROM 1 FOR 1) AS code
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
) subquery
|
|
GROUP BY code
|
|
ORDER BY code
|
|
</select>
|
|
|
|
|
|
<select id="ageStructure"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
|
|
|
SELECT
|
|
"desc",
|
|
COUNT(DISTINCT AAC044) AS count
|
|
FROM (
|
|
SELECT
|
|
AAC044,
|
|
CASE
|
|
WHEN EXTRACT(YEAR FROM AGE(#{endTime}, CAST(AAC006 AS DATE))) BETWEEN 15 AND 25 THEN '16-25岁'
|
|
WHEN EXTRACT(YEAR FROM AGE(#{endTime}, CAST(AAC006 AS DATE))) BETWEEN 26 AND 35 THEN '26-35岁'
|
|
WHEN EXTRACT(YEAR FROM AGE(#{endTime}, CAST(AAC006 AS DATE))) BETWEEN 36 AND 45 THEN '36-45岁'
|
|
WHEN EXTRACT(YEAR FROM AGE(#{endTime}, CAST(AAC006 AS DATE))) BETWEEN 46 AND 55 THEN '46-55岁'
|
|
WHEN EXTRACT(YEAR FROM AGE(#{endTime}, CAST(AAC006 AS DATE))) > 55 THEN '55岁以上'
|
|
ELSE '年龄未知'
|
|
END AS "desc"
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
) subquery
|
|
GROUP BY "desc"
|
|
ORDER BY
|
|
CASE "desc"
|
|
WHEN '16-25岁' THEN 1
|
|
WHEN '26-35岁' THEN 2
|
|
WHEN '36-45岁' THEN 3
|
|
WHEN '46-55岁' THEN 4
|
|
WHEN '55岁以上' THEN 5
|
|
ELSE 6
|
|
END
|
|
</select>
|
|
|
|
<select id="salaryLevel"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
|
|
|
SELECT
|
|
code,
|
|
COALESCE(ROUND(AVG(ACC328), 2), 0) AS amount,
|
|
COALESCE(ROUND((PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY ACC328))::NUMERIC, 2), 0) AS anotherAmount
|
|
FROM (
|
|
SELECT
|
|
AAC044,
|
|
SUBSTRING(AAB022 FROM 1 FOR 1) AS code,
|
|
ACC328
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
) subquery
|
|
GROUP BY code
|
|
ORDER BY code
|
|
</select>
|
|
|
|
<select id="qualityIndicator"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.dto.IndustryEmploymentInfoSqlDto">
|
|
|
|
SELECT
|
|
COUNT(DISTINCT AAC044) AS totalCount,
|
|
COUNT(DISTINCT CASE WHEN ACC22B = '1' THEN AAC044 END) AS signContractCount,
|
|
COUNT(DISTINCT CASE WHEN AAC008 = '1' THEN AAC044 END) AS socialInsuranceCount,
|
|
COUNT(DISTINCT CASE WHEN ACC22D = '1' THEN AAC044 END) AS stableSalaryCount,
|
|
COUNT(DISTINCT CASE WHEN ACC22C = '1' THEN AAC044 END) AS satisfiedWorkCount
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
|
|
</select>
|
|
|
|
<select id="heatmap"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.vo.HeatmapVo">
|
|
|
|
SELECT
|
|
areaCode,
|
|
COUNT(DISTINCT AAC044) AS count
|
|
FROM (
|
|
SELECT
|
|
AAC044,
|
|
AAB301 AS areaCode
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
) subquery
|
|
GROUP BY areaCode
|
|
ORDER BY areaCode
|
|
</select>
|
|
|
|
<select id="employmentTrendYear"
|
|
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,
|
|
COUNT(DISTINCT CASE WHEN 1 = 1
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
<if test="industryList != null and industryList.size() > 0">
|
|
AND (
|
|
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
|
AAB022 LIKE #{industry} || '%'
|
|
</foreach>
|
|
)
|
|
</if> THEN AAC044 END) AS employmentCount,
|
|
COUNT(DISTINCT CASE WHEN YCC035 = '1'
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
<if test="industryList != null and industryList.size() > 0">
|
|
AND (
|
|
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
|
AAB022 LIKE #{industry} || '%'
|
|
</foreach>
|
|
)
|
|
</if> THEN AAC044 END) AS townEmploymentCount,
|
|
COUNT(DISTINCT AAC044 ) AS cityAverageEmploymentCount
|
|
FROM month_ranges r
|
|
LEFT JOIN theme_employment_register
|
|
ON
|
|
ADC110 BETWEEN r.start_time AND r.end_time
|
|
<if test="area != null and area != ''">
|
|
AND AAB301 = #{area}
|
|
</if>
|
|
AND (ABE585 IS NULL OR ABE585 > #{endTime})
|
|
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(employmentCount, 0) AS employmentCount,
|
|
COALESCE(townEmploymentCount, 0) AS townEmploymentCount,
|
|
COALESCE(cityAverageEmploymentCount, 0) AS cityAverageEmploymentCount
|
|
FROM aggregated_data
|
|
ORDER BY sort ;
|
|
</select>
|
|
|
|
<select id="employmentTrendQuarter"
|
|
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,
|
|
COUNT(DISTINCT CASE WHEN 1 = 1
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
<if test="industryList != null and industryList.size() > 0">
|
|
AND (
|
|
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
|
AAB022 LIKE #{industry} || '%'
|
|
</foreach>
|
|
)
|
|
</if> THEN AAC044 END) AS employmentCount,
|
|
COUNT(DISTINCT CASE WHEN YCC035 = '1'
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
<if test="industryList != null and industryList.size() > 0">
|
|
AND (
|
|
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
|
AAB022 LIKE #{industry} || '%'
|
|
</foreach>
|
|
)
|
|
</if> THEN AAC044 END) AS townEmploymentCount,
|
|
COUNT(DISTINCT AAC044 ) AS cityAverageEmploymentCount
|
|
FROM month_ranges r
|
|
LEFT JOIN theme_employment_register
|
|
ON
|
|
ADC110 BETWEEN r.start_time AND r.end_time
|
|
<if test="area != null and area != ''">
|
|
AND AAB301 = #{area}
|
|
</if>
|
|
AND (ABE585 IS NULL OR ABE585 > #{endTime})
|
|
GROUP BY r.month_num
|
|
)
|
|
SELECT
|
|
month_num AS code,
|
|
month_num AS sort,
|
|
'第' || month_num || '季度' AS "desc",
|
|
COALESCE(employmentCount, 0) AS employmentCount,
|
|
COALESCE(townEmploymentCount, 0) AS townEmploymentCount,
|
|
COALESCE(cityAverageEmploymentCount, 0) AS cityAverageEmploymentCount
|
|
FROM aggregated_data
|
|
ORDER BY month_num;
|
|
</select>
|
|
|
|
<select id="employmentTrendMonth"
|
|
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,
|
|
COUNT(DISTINCT CASE WHEN 1 = 1
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
<if test="industryList != null and industryList.size() > 0">
|
|
AND (
|
|
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
|
AAB022 LIKE #{industry} || '%'
|
|
</foreach>
|
|
)
|
|
</if> THEN AAC044 END) AS employmentCount,
|
|
COUNT(DISTINCT CASE WHEN YCC035 = '1'
|
|
<if test="industry != null and industry != ''">
|
|
AND AAB022 LIKE #{industry} || '%'
|
|
</if>
|
|
<if test="industryList != null and industryList.size() > 0">
|
|
AND (
|
|
<foreach collection="industryList" item="industry" open="" separator=" OR " close="">
|
|
AAB022 LIKE #{industry} || '%'
|
|
</foreach>
|
|
)
|
|
</if> THEN AAC044 END) AS townEmploymentCount,
|
|
COUNT(DISTINCT AAC044 ) AS cityAverageEmploymentCount
|
|
FROM month_ranges r
|
|
LEFT JOIN theme_employment_register
|
|
ON
|
|
ADC110 BETWEEN r.start_time AND r.end_time
|
|
<if test="area != null and area != ''">
|
|
AND AAB301 = #{area}
|
|
</if>
|
|
AND (ABE585 IS NULL OR ABE585 > #{endTime})
|
|
GROUP BY r.month_num
|
|
)
|
|
SELECT
|
|
month_num AS code,
|
|
month_num AS sort,
|
|
month_num || '月' AS "desc",
|
|
COALESCE(employmentCount, 0) AS employmentCount,
|
|
COALESCE(townEmploymentCount, 0) AS townEmploymentCount,
|
|
COALESCE(cityAverageEmploymentCount, 0) AS cityAverageEmploymentCount
|
|
FROM aggregated_data
|
|
ORDER BY month_num;
|
|
</select>
|
|
|
|
|
|
<select id="queryEmploymentCountByIndustry"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
|
|
|
SELECT
|
|
code,
|
|
COUNT(DISTINCT AAC044) AS count
|
|
FROM (
|
|
SELECT
|
|
AAC044,
|
|
SUBSTRING(AAB022 FROM 1 FOR 3) AS code
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
) subquery
|
|
GROUP BY code
|
|
ORDER BY code
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="queryEmploymentCountByJobType"
|
|
parameterType="com.ruoyi.cms.domain.dto.QueryParamDto"
|
|
resultType="com.ruoyi.cms.domain.vo.QueryResultVo">
|
|
|
|
SELECT
|
|
code,
|
|
COUNT(DISTINCT AAC044) AS count
|
|
FROM (
|
|
SELECT
|
|
AAC044,
|
|
ACA112 AS code
|
|
FROM theme_employment_register
|
|
WHERE
|
|
<!-- 引入公共条件 -->
|
|
<include refid="commonConditions"/>
|
|
) subquery
|
|
GROUP BY code
|
|
ORDER BY code
|
|
|
|
</select>
|
|
</mapper> |