Files
sdwu_dw/ruoyi-dw/src/main/resources/mapper/dw/DwIndexConfigMapper.xml

135 lines
5.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.dw.mapper.DwIndexConfigMapper">
<resultMap type="DwIndexConfig" id="DwIndexConfigResult">
<result property="id" column="id" />
<result property="indexName" column="index_name" />
<result property="indexTitle" column="index_title" />
<result property="questionId" column="question_id" />
<result property="infoId" column="info_id" />
<result property="indexType" column="index_type" />
</resultMap>
<resultMap type="AnswerCountVo" id="answerCountVo">
<result property="answer" column="answer" />
<result property="answerCount" column="answer_count" />
</resultMap>
<resultMap type="BynfVo" id="bynfVo">
<result property="bynf" column="bynf" />
<result property="bynfCount" column="bynf_count" />
</resultMap>
<resultMap type="SydVo" id="sydVo">
<result property="city" column="city" />
<result property="studentCount" column="student_count" />
</resultMap>
<resultMap type="DwxzVo" id="dwxzVo">
<result property="dwxz" column="dwxz" />
<result property="dwxzCount" column="dwxz_count" />
</resultMap>
<sql id="selectDwIndexConfigVo">
select id, index_name,index_title, question_id, info_id, index_type from dw_index_config
</sql>
<select id="selectDwIndexConfigList" parameterType="DwIndexConfig" resultMap="DwIndexConfigResult">
<include refid="selectDwIndexConfigVo"/>
<where>
<if test="indexName != null and indexName != ''"> and index_name like concat('%', #{indexName}, '%')</if>
<if test="questionId != null and questionId != ''"> and question_id = #{questionId}</if>
<if test="infoId != null "> and info_id = #{infoId}</if>
<if test="indexType != null "> and index_type = #{indexType}</if>
</where>
</select>
<select id="selectDwIndexConfigById" parameterType="Long" resultMap="DwIndexConfigResult">
<include refid="selectDwIndexConfigVo"/>
where id = #{id}
</select>
<insert id="insertDwIndexConfig" parameterType="DwIndexConfig" useGeneratedKeys="true" keyProperty="id">
insert into dw_index_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="indexName != null">index_name,</if>
<if test="indexTitle != null">index_title,</if>
<if test="questionId != null">question_id,</if>
<if test="infoId != null">info_id,</if>
<if test="indexType != null">index_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="indexName != null">#{indexName},</if>
<if test="indexTitle != null">#{indexTitle},</if>
<if test="questionId != null">#{questionId},</if>
<if test="infoId != null">#{infoId},</if>
<if test="indexType != null">#{indexType},</if>
</trim>
</insert>
<update id="updateDwIndexConfig" parameterType="DwIndexConfig">
update dw_index_config
<trim prefix="SET" suffixOverrides=",">
<if test="indexName != null">index_name = #{indexName},</if>
<if test="indexTitle != null">index_title = #{indexTitle},</if>
<if test="questionId != null">question_id = #{questionId},</if>
<if test="infoId != null">info_id = #{infoId},</if>
<if test="indexType != null">index_type = #{indexType},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDwIndexConfigById" parameterType="Long">
delete from dw_index_config where id = #{id}
</delete>
<delete id="deleteDwIndexConfigByIds" parameterType="String">
delete from dw_index_config where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectIndex" resultMap="answerCountVo">
select answer, count(0) as answer_count
from dw_answer
where info_id = #{infoId}
and question_id = #{questionId}
group by answer
</select>
<select id="selectBynf" resultMap="bynfVo" parameterType="int">
select bynf,count(0) as bynf_count
from cj_student
where sfqr = 1
and cast(bynf as unsigned)
between YEAR(CURRENT_DATE) - #{year} + 1 and YEAR(CURRENT_DATE)
group by bynf order by bynf desc
</select>
<select id="selectSyd" resultMap="sydVo" parameterType="int">
SELECT
CASE
WHEN sydsh = '山东' THEN sydshi
ELSE '省外'
END AS city,
COUNT(*) AS student_count
FROM cj_student
where sfqr = 1 and sydsh is not null
and cast(bynf as unsigned)
between YEAR(CURRENT_DATE) - #{year} + 1 and YEAR(CURRENT_DATE)
GROUP BY
CASE
WHEN sydsh = '山东' THEN sydshi
ELSE '省外'
END
</select>
<select id="selectDwxz" resultMap="dwxzVo">
select dwxz,count(0) as dwxz_count from cj_student where sfqr = 1 and dwxz is not null group by dwxz
</select>
</mapper>