231 lines
8.4 KiB
XML
231 lines
8.4 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.ModelWarningIndicatorDataMapper">
|
|
|
|
<insert id="insert" parameterType="com.ruoyi.cms.domain.ModelWarningIndicatorData">
|
|
INSERT INTO model_warning_indicator_data (indicator_code, data_value, year, month, region_code, region_name,
|
|
remark)
|
|
VALUES (#{indicatorCode}, #{dataValue}, #{year}, #{month}, #{regionCode}, #{regionName}, #{remark})
|
|
</insert>
|
|
|
|
|
|
<insert id="update" parameterType="com.ruoyi.cms.domain.ModelWarningIndicatorData">
|
|
UPDATE
|
|
model_warning_indicator_data
|
|
SET indicator_code = #{indicatorCode},
|
|
data_value = #{dataValue},
|
|
year = #{year},
|
|
month = #{month},
|
|
region_code = #{regionCode},
|
|
region_name = #{regionName},
|
|
remark = #{remark}
|
|
WHERE id = #{id}
|
|
</insert>
|
|
|
|
<insert id="deleteById" parameterType="java.lang.Long">
|
|
DELETE
|
|
FROM model_warning_indicator_data
|
|
WHERE id = #{id}
|
|
</insert>
|
|
|
|
<select id="selectById" parameterType="com.ruoyi.cms.domain.ModelWarningIndicatorData"
|
|
resultType="com.ruoyi.cms.domain.ModelWarningIndicatorData">
|
|
SELECT a.id,
|
|
a.indicator_code,
|
|
a.data_value,
|
|
a.year,
|
|
a.month,
|
|
a.region_code,
|
|
a.region_name,
|
|
a.remark,
|
|
b.indicator_name
|
|
FROM model_warning_indicator_data a
|
|
LEFT JOIN model_warning_indicator b ON a.indicator_code = b.indicator_code
|
|
WHERE id = #{id}
|
|
</select>
|
|
|
|
<select id="findUnique" parameterType="com.ruoyi.cms.domain.ModelWarningIndicatorData"
|
|
resultType="com.ruoyi.cms.domain.ModelWarningIndicatorData">
|
|
SELECT *
|
|
FROM model_warning_indicator_data
|
|
WHERE indicator_code = #{indicatorCode}
|
|
AND year = #{year}
|
|
AND month = #{month}
|
|
AND region_code = #{regionCode}
|
|
</select>
|
|
|
|
<select id="selectByIndicatorCode"
|
|
resultType="com.ruoyi.cms.domain.ModelWarningIndicatorData">
|
|
SELECT *
|
|
FROM model_warning_indicator_data
|
|
<where>
|
|
<if test="indicatorCode != null and indicatorCode != ''">
|
|
AND indicator_code = #{indicatorCode}
|
|
</if>
|
|
<if test="regionCode != null and regionCode != ''">
|
|
AND region_code = #{regionCode}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<select id="list" parameterType="com.ruoyi.cms.domain.ModelWarningIndicatorData"
|
|
resultType="com.ruoyi.cms.domain.ModelWarningIndicatorData">
|
|
SELECT a.id,
|
|
a.indicator_code,
|
|
a.data_value,
|
|
a.year,
|
|
a.month,
|
|
a.region_code,
|
|
a.region_name,
|
|
a.remark,
|
|
b.indicator_name
|
|
FROM model_warning_indicator_data a
|
|
LEFT JOIN model_warning_indicator b ON a.indicator_code = b.indicator_code
|
|
<where>
|
|
<if test="id != null ">
|
|
AND a.id = #{id}
|
|
</if>
|
|
<if test="indicatorCode != null and indicatorCode != ''">
|
|
AND a.indicator_code = #{indicatorCode}
|
|
</if>
|
|
<if test="year != null">
|
|
AND a.year = #{year}
|
|
</if>
|
|
<if test="month != null">
|
|
AND a.month = #{month}
|
|
</if>
|
|
<if test="regionCode != null and regionCode != ''">
|
|
AND a.region_code = #{regionCode}
|
|
</if>
|
|
<if test="regionName != null and regionName != ''">
|
|
AND a.region_name LIKE '%'||#{regionName}||'%'
|
|
</if>
|
|
</where>
|
|
ORDER BY a.year DESC, a.month DESC, a.indicator_code
|
|
</select>
|
|
|
|
|
|
<select id="listUnemploymentRateMonitor" parameterType="java.lang.String"
|
|
resultType="com.ruoyi.cms.domain.dto.ModelWarningIndicatorDataResultDto">
|
|
|
|
WITH ranked_data AS (
|
|
SELECT
|
|
a.year,
|
|
a.month,
|
|
ROW_NUMBER() OVER (ORDER BY year DESC, month DESC) as row_num,
|
|
COUNT(*) OVER () as total_count
|
|
FROM model_warning_indicator_data a
|
|
INNER JOIN model_unemployment_rate_monitor b ON a.indicator_code = b.indicator_code
|
|
WHERE a.region_code = #{regionCode}
|
|
group by a.year,a.month
|
|
),
|
|
year_month AS (
|
|
SELECT
|
|
year,
|
|
month
|
|
FROM ranked_data
|
|
WHERE row_num = LEAST(36, total_count) LIMIT 1 )
|
|
|
|
SELECT a.id,
|
|
a.indicator_code,
|
|
a.data_value,
|
|
a.year,
|
|
a.month,
|
|
a.region_code,
|
|
a.region_name,
|
|
a.remark,
|
|
c.indicator_name
|
|
FROM year_month d
|
|
LEFT JOIN model_warning_indicator_data a
|
|
ON a.year >= d.year AND a.month >= d.month
|
|
AND a.region_code = #{regionCode}
|
|
INNER JOIN model_unemployment_rate_monitor b ON a.indicator_code = b.indicator_code
|
|
LEFT JOIN model_warning_indicator c ON a.indicator_code = c.indicator_code;
|
|
</select>
|
|
|
|
|
|
|
|
<select id="listEmploymentMonitorComposite" parameterType="java.lang.String"
|
|
resultType="com.ruoyi.cms.domain.dto.ModelWarningIndicatorDataResultDto">
|
|
|
|
WITH ranked_data AS (
|
|
SELECT
|
|
a.year,
|
|
a.month,
|
|
ROW_NUMBER() OVER (ORDER BY year DESC, month DESC) as row_num,
|
|
COUNT(*) OVER () as total_count
|
|
FROM model_warning_indicator_data a
|
|
INNER JOIN model_employment_monitor_composite b ON a.indicator_code = b.indicator_code
|
|
WHERE a.region_code = #{regionCode}
|
|
group by a.year,a.month
|
|
),
|
|
year_month AS (
|
|
SELECT
|
|
year,
|
|
month
|
|
FROM ranked_data
|
|
WHERE row_num = LEAST(36, total_count) LIMIT 1 )
|
|
|
|
SELECT a.id,
|
|
a.indicator_code,
|
|
a.data_value,
|
|
a.year,
|
|
a.month,
|
|
a.region_code,
|
|
a.region_name,
|
|
a.remark,
|
|
c.indicator_name,
|
|
b.indicator_weight,
|
|
b.indicator_type
|
|
FROM year_month d
|
|
LEFT JOIN model_warning_indicator_data a
|
|
ON a.year >= d.year AND a.month >= d.month
|
|
AND a.region_code = #{regionCode}
|
|
INNER JOIN model_employment_monitor_composite b ON a.indicator_code = b.indicator_code
|
|
LEFT JOIN model_warning_indicator c ON a.indicator_code = c.indicator_code;
|
|
</select>
|
|
|
|
|
|
<select id="listUnemploymentWarningDiffusion" parameterType="java.lang.String"
|
|
resultType="com.ruoyi.cms.domain.dto.ModelWarningIndicatorDataResultDto">
|
|
|
|
WITH ranked_data AS (
|
|
SELECT
|
|
a.year,
|
|
a.month,
|
|
ROW_NUMBER() OVER (ORDER BY year DESC, month DESC) as row_num,
|
|
COUNT(*) OVER () as total_count
|
|
FROM model_warning_indicator_data a
|
|
INNER JOIN model_unemployment_warning_diffusion b ON a.indicator_code = b.indicator_code
|
|
WHERE a.region_code = #{regionCode}
|
|
group by a.year,a.month
|
|
),
|
|
year_month AS (
|
|
SELECT
|
|
year,
|
|
month
|
|
FROM ranked_data
|
|
WHERE row_num = LEAST(36, total_count) LIMIT 1 )
|
|
|
|
SELECT a.id,
|
|
a.indicator_code,
|
|
a.data_value,
|
|
a.year,
|
|
a.month,
|
|
a.region_code,
|
|
a.region_name,
|
|
a.remark,
|
|
c.indicator_name,
|
|
b.indicator_weight,
|
|
b.indicator_type,
|
|
b.lead_period
|
|
FROM year_month d
|
|
LEFT JOIN model_warning_indicator_data a
|
|
ON a.year >= d.year AND a.month >= d.month
|
|
AND a.region_code = #{regionCode}
|
|
INNER JOIN model_unemployment_warning_diffusion b ON a.indicator_code = b.indicator_code
|
|
LEFT JOIN model_warning_indicator c ON a.indicator_code = c.indicator_code;
|
|
</select>
|
|
|
|
</mapper> |