btxtgxq-system-bigdata/target/classes/mybatis/mapper/deptassess/deptassess-mapper.xml
2021-01-11 14:16:26 +08:00

280 lines
10 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.cm.bigdata.dao.deptassess.IDeptAssessDao">
<resultMap id="deptAssessDTO" type="com.cm.bigdata.pojo.dtos.deptassess.DeptAssessDTO">
<id column="dept_assess_id" property="deptAssessId"/>
<result column="dept_id" property="deptId"/>
<result column="dept_name" property="deptName"/>
<result column="dept_case_num" property="deptCaseNum"/>
<result column="dept_case_timeout_num" property="deptCaseTimeoutNum"/>
<result column="dept_case_settle_score" property="deptCaseSettleScore"/>
<result column="dept_case_timeout_score" property="deptCaseTimeoutScore"/>
<result column="dept_case_gross_score" property="deptCaseGrossScore"/>
<result column="dept_case_total_score" property="deptCaseTotalScore"/>
<result column="dept_total_quarter" property="deptTotalQuarter"/>
<result column="dept_total_time" property="deptTotalTime"/>
<result column="dept_total_year" property="deptTotalYear"/>
</resultMap>
<resultMap id="deptAssessAllQuarterDTO" type="com.cm.bigdata.pojo.dtos.deptassess.DeptAssessAllQuarterDTO">
<result column="dept_id" property="deptId"/>
<result column="dept_name" property="deptName"/>
<result column="quarter_1" property="quarter1"/>
<result column="quarter_2" property="quarter2"/>
<result column="quarter_3" property="quarter3"/>
<result column="quarter_4" property="quarter4"/>
</resultMap>
<!-- 新增职能部门考核 -->
<insert id="saveDeptAssess" parameterType="map">
INSERT INTO gen_dept_assess(
dept_assess_id,
dept_id,
dept_name,
dept_case_num,
dept_case_timeout_num,
dept_case_settle_score,
dept_case_timeout_score,
dept_case_gross_score,
dept_case_total_score,
dept_total_quarter,
dept_total_time,
dept_total_year,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{deptAssessId},
#{deptId},
#{deptName},
#{deptCaseNum},
#{deptCaseTimeoutNum},
#{deptCaseSettleScore},
#{deptCaseTimeoutScore},
#{deptCaseGrossScore},
#{deptCaseTotalScore},
#{deptTotalQuarter},
#{deptTotalTime},
#{deptTotalYear},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除职能部门考核 -->
<update id="removeDeptAssess" parameterType="map">
UPDATE
gen_dept_assess
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
dept_assess_id IN
<foreach collection="deptAssessIds" index="index" open="(" separator="," close=")">
#{deptAssessIds[${index}]}
</foreach>
</update>
<!-- 删除职能部门考核(物理) -->
<update id="deleteDeptAssess" parameterType="map">
DELETE FROM
gen_dept_assess
WHERE
dept_assess_id IN
<foreach collection="deptAssessIds" index="index" open="(" separator="," close=")">
#{deptAssessIds[${index}]}
</foreach>
</update>
<!-- 修改职能部门考核 -->
<update id="updateDeptAssess" parameterType="map">
UPDATE
gen_dept_assess
SET
<if test="deptName != null and deptName != ''">
dept_name = #{deptName},
</if>
dept_case_num = #{deptCaseNum},
dept_case_timeout_num = #{deptCaseTimeoutNum},
dept_case_settle_score = #{deptCaseSettleScore},
dept_case_timeout_score = #{deptCaseTimeoutScore},
dept_case_gross_score = #{deptCaseGrossScore},
dept_total_quarter = #{deptTotalQuarter},
dept_total_time = #{deptTotalTime},
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
dept_assess_id = #{deptAssessId}
</update>
<!-- 修改职能部门考核 -->
<update id="updateDeptAssessGrossScore" parameterType="map">
UPDATE
gen_dept_assess
SET
dept_case_gross_score = #{deptCaseGrossScore}
WHERE
dept_assess_id = #{deptAssessId}
</update>
<!-- 修改总分 -->
<update id="updatedeptCaseTotalScore" parameterType="map">
UPDATE
gen_dept_assess
SET
dept_case_total_score = #{deptCaseTotalScore}
WHERE
dept_assess_id = #{deptAssessId}
</update>
<!--根据年份和季度和部门ID查询-->
<select id="getDeptAssessByYearAndQuarterAndDeptId" parameterType="map" resultMap="deptAssessDTO">
SELECT
t1.dept_assess_id,
t1.dept_id,
t1.dept_name,
t1.dept_case_num,
t1.dept_case_timeout_num,
t1.dept_case_settle_score,
t1.dept_case_timeout_score,
t1.dept_case_gross_score,
t1.dept_case_total_score,
t1.dept_total_time
FROM
gen_dept_assess t1
WHERE
t1.is_delete = 0
AND
t1.dept_total_year = #{deptTotalYear}
AND
t1.dept_total_quarter = #{deptTotalQuarter}
AND
t1.dept_id = #{deptId}
</select>
<!-- 职能部门考核详情 -->
<select id="getDeptAssess" parameterType="map" resultMap="deptAssessDTO">
SELECT
t1.dept_assess_id,
t1.dept_id,
t1.dept_name,
t1.dept_case_num,
t1.dept_case_timeout_num,
t1.dept_case_settle_score,
t1.dept_case_timeout_score,
t1.dept_case_gross_score,
t1.dept_case_total_score,
t1.dept_total_quarter,
t1.dept_total_time,
t1.dept_total_year
FROM
gen_dept_assess t1
WHERE
t1.is_delete = 0
<if test="deptAssessId != null and deptAssessId != ''">
AND
t1.dept_assess_id = #{deptAssessId}
</if>
</select>
<!-- 职能部门考核列表 -->
<select id="listDeptAssess" parameterType="map" resultMap="deptAssessDTO">
SELECT
dept_assess_id,
dept_id,
dept_name,
dept_case_num,
dept_case_timeout_num,
dept_case_settle_score,
dept_case_timeout_score,
dept_case_gross_score,
dept_case_total_score,
dept_total_quarter,
dept_total_time,
dept_total_year,
creator,
gmt_create,
modifier,
gmt_modified
FROM
gen_dept_assess t1
WHERE
t1.is_delete = 0 AND t1.dept_total_quarter = #{deptTotalQuarter} AND t1.dept_total_year = #{deptTotalYear}
<if test="keywords != null and keywords != ''">
AND (
t1.dept_name LIKE CONCAT('%', #{keywords}, '%')
<!-- 这里添加其他条件 -->
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="deptAssessIds != null and deptAssessIds.size > 0">
AND
t1.dept_assess_id IN
<foreach collection="deptAssessIds" index="index" open="(" separator="," close=")">
#{deptAssessIds[${index}]}
</foreach>
</if>
</select>
<!-- 职能部门考核统计 -->
<select id="countDeptAssess" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
gen_dept_assess t1
WHERE
t1.is_delete = 0
</select>
<!--查询所有部门指定年份全季度分数-->
<select id="listDeptAssessAllQuarterByYear" parameterType="map" resultMap="deptAssessAllQuarterDTO">
SELECT
t1.dept_name,
t1.dept_id,
(SELECT t2.dept_case_total_score FROM gen_dept_assess t2 WHERE t1.dept_id = t2.dept_id AND t2.dept_total_quarter = '1') quarter_1,
(SELECT t3.dept_case_total_score FROM gen_dept_assess t3 WHERE t1.dept_id = t3.dept_id AND t3.dept_total_quarter = '2') quarter_2,
(SELECT t4.dept_case_total_score FROM gen_dept_assess t4 WHERE t1.dept_id = t4.dept_id AND t4.dept_total_quarter = '3') quarter_3,
(SELECT t5.dept_case_total_score FROM gen_dept_assess t5 WHERE t1.dept_id = t5.dept_id AND t5.dept_total_quarter = '4') quarter_4
FROM
gen_dept_assess t1
WHERE
t1.is_delete = 0 AND t1.dept_total_year = #{deptTotalYear}
GROUP BY t1.dept_id
</select>
<!--查询所有部门指定年份全季度分数-->
<select id="getDeptAssessQuarterByYearAndDeptId" parameterType="map" resultMap="deptAssessAllQuarterDTO">
SELECT
t1.dept_name,
t1.dept_id,
(SELECT t2.dept_case_total_score FROM gen_dept_assess t2 WHERE t1.dept_id = t2.dept_id AND t2.dept_total_quarter = '1') quarter_1,
(SELECT t3.dept_case_total_score FROM gen_dept_assess t3 WHERE t1.dept_id = t3.dept_id AND t3.dept_total_quarter = '2') quarter_2,
(SELECT t4.dept_case_total_score FROM gen_dept_assess t4 WHERE t1.dept_id = t4.dept_id AND t4.dept_total_quarter = '3') quarter_3,
(SELECT t5.dept_case_total_score FROM gen_dept_assess t5 WHERE t1.dept_id = t5.dept_id AND t5.dept_total_quarter = '4') quarter_4
FROM
gen_dept_assess t1
WHERE
t1.is_delete = 0 AND t1.dept_total_year = #{deptTotalYear} AND t1.dept_id = #{deptId}
GROUP BY t1.dept_total_year
</select>
</mapper>