添加功能

This commit is contained in:
马宝龙
2026-06-29 20:01:46 +08:00
parent dd57a43aac
commit 0d417b2393
16 changed files with 2384 additions and 126 deletions

View File

@@ -12,6 +12,13 @@
<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 &gt; #{endTime})
</sql>
@@ -29,6 +36,23 @@
</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">
@@ -359,4 +383,243 @@
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 &gt; #{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 &gt; #{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 &gt; #{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>