<?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.system.mapper.TbScoreMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TbScore">
|
<id column="id" property="id"/>
|
<result column="basic_data_config_id" property="basicDataConfigId"/>
|
<result column="basic_data_id" property="basicDataId"/>
|
<result column="score" property="score"/>
|
<result column="del_flag" property="delFlag"/>
|
<result column="create_time" property="createTime"/>
|
<result column="update_time" property="updateTime"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, basic_data_config_id, basic_data_id, score, del_flag, create_by, create_time, update_by, update_time
|
</sql>
|
<select id="pageScore" resultType="com.ruoyi.system.vo.ScoreVO">
|
SELECT
|
tbdc.type_name,
|
tbdc.calculate_type,
|
ts.score
|
FROM
|
tb_score ts
|
LEFT JOIN tb_basic_data tbd ON ts.basic_data_id = tbd.id
|
LEFT JOIN tb_basic_data_config tbdc ON ts.basic_data_config_id = tbdc.id
|
WHERE
|
1=1
|
AND tbd.id = #{query.basicDataId}
|
<if test="query.typeName !=null and query.typeName!=''">
|
AND tbdc.type_name like Concat('%',#{query.typeName},'%')
|
</if>
|
<if test="query.typeName !=null and query.typeName!=''">
|
AND tbdc.calculate_type = #{query.type}
|
</if>
|
|
</select>
|
<select id="scoreCalculateDetail" resultType="com.ruoyi.system.vo.ScoreDetailVO">
|
SELECT
|
su.area_name,
|
su.area_code,
|
ts.score,
|
su.person_in_charge,
|
su.phone_number
|
FROM tb_score ts
|
LEFT JOIN tb_basic_data tbd ON ts.basic_data_id = tbd.id
|
LEFT JOIN sys_user su ON tbd.dept_area_code = su.area_code
|
<where>
|
ts.basic_data_config_id = #{query.id} AND su.area_name IS NOT NULL
|
<if test="query.areaName != null and query.areaName != ''">
|
AND su.area_name LIKE CONCAT('%',#{query.areaName},'%')
|
</if>
|
</where>
|
</select>
|
<select id="queryTotalScoreList" resultType="com.ruoyi.system.vo.ScoreRankVO">
|
|
</select>
|
<select id="queryRankAndScoreByAreaCode" resultType="com.ruoyi.system.vo.ScoreRankVO">
|
SET @rank = 0;
|
SELECT dept_area_code AS areaCode,
|
COALESCE(score, 0) AS score,
|
`rank`
|
FROM (SELECT tbc.dept_area_code,
|
SUM(ts.score) AS score,
|
(@rank := @rank + 1) AS `rank`
|
FROM tb_score ts
|
LEFT JOIN tb_basic_data tbc ON ts.basic_data_id = tbc.id
|
LEFT JOIN tb_basic_data_config tbdc ON ts.basic_data_config_id = tbdc.id
|
WHERE YEAR(tbc.reporting_time) = YEAR(
|
CURDATE())
|
GROUP BY tbc.dept_area_code
|
ORDER BY score
|
DESC) AS ranked_data
|
WHERE dept_area_code = #{areaCode}
|
</select>
|
<select id="deptCalculateDetail" resultType="com.ruoyi.system.vo.DeptCalculateDetailVO">
|
SELECT bdc.id,
|
ts.score,
|
bdc.type_name,
|
bdc.calculate_type
|
FROM tb_basic_data_category tbdc
|
LEFT JOIN tb_basic_data_config bdc ON tbdc.id = bdc.basic_data_category_id
|
LEFT JOIN tb_score ts ON ts.basic_data_config_id = bdc.id
|
LEFT JOIN tb_basic_data tbd ON tbd.id = ts.basic_data_id
|
WHERE 1 = 1
|
AND tbdc.id = #{query.basicDataCategoryId}
|
AND tbd.quarter = #{nowQuarter}
|
<if test="query.areaCode != null and query.areaCode !=''">
|
AND tbd.dept_area_code = #{query.areaCode}
|
</if>
|
</select>
|
<select id="fieldsDetail" resultType="com.ruoyi.system.vo.ScoreDetailVO">
|
SELECT
|
su.area_name,
|
su.area_code,
|
ts.score,
|
su.person_in_charge,
|
su.phone_number
|
FROM tb_score ts
|
LEFT JOIN tb_basic_data tbd ON ts.basic_data_id = tbd.id
|
LEFT JOIN sys_user su ON tbd.dept_area_code = su.area_code
|
<where>
|
ts.basic_data_config_id = #{query.id} AND su.area_name IS NOT NULL
|
AND su.area_code IN
|
<foreach collection="countyList" item="code" open="(" separator="," close=")">
|
#{code}
|
</foreach>
|
<if test="query.areaCode != null and query.areaCode != ''">
|
AND su.area_code=#{query.areaCode}
|
</if>
|
</where>
|
</select>
|
</mapper>
|