ZhiYeJianKang/职业健康平台后端/bin/mappings/modules/assessment/taskMapper.xml

207 lines
5.5 KiB
XML
Raw Normal View History

2025-02-20 15:25:59 +08:00
<?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.hx.slj.modules.assessment.dao.TaskDao">
<resultMap id="taskPOJO" type="com.hx.slj.modules.assessment.entity.Task">
<id property="id" column="id"/>
<result property="standardPlanId" column="standard_plan_id"/>
<result property="sysOfficeId" column="sys_office_id"/>
<result property="sort" column="sort"/>
</resultMap>
<sql id="taskColumns">
a.id,
a.standard_plan_id AS "standardPlanId",
a.sys_office_id AS "sysOfficeId",
a.sort,
a.create_by AS "createBy.id",
a.create_date,
a.update_by AS "updateBy.id",
a.update_date,
a.remarks,
a.del_flag,
a.status,
p.title AS "plan.title",
s.name AS "plan.assessmentSystem.name",
o.name AS "office.name",
st.final_score as "subtask.finalScore"
</sql>
<sql id="taskJoins">
LEFT JOIN standard_plan p ON p.id= a.standard_plan_id
LEFT JOIN assessment_system s ON s.id = p.assessment_system_id
LEFT JOIN sys_office o ON o.id = a.sys_office_id
LEFT JOIN (SELECT max(a.final_score) AS "final_score",a.standard_task_id as "standard_task_id" from standard_subtask a GROUP BY a.standard_task_id) st
ON st.standard_task_id = a.id
</sql>
<select id="get" resultType="com.hx.slj.modules.assessment.entity.Task">
SELECT
<include refid="taskColumns"/>
FROM standard_task a
<include refid="taskJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="com.hx.slj.modules.assessment.entity.Task">
SELECT
<include refid="taskColumns"/>
FROM standard_task a
<include refid="taskJoins"/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
AND p.del_flag = #{DEL_FLAG_NORMAL}
AND o.DEL_FLAG = #{DEL_FLAG_NORMAL}
/*根据计划id筛选*/
<if test="standardPlanId !=null and standardPlanId !=''">
AND a.standard_plan_id=#{standardPlanId}
</if>
<if test="status !=null and status !=''">
AND a.status=#{status}
</if>
<if test="sysOfficeId !=null and sysOfficeId !=''">
AND a.sys_office_id=#{sysOfficeId}
</if>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date
</otherwise>
</choose>
</select>
<!--根据机构id,计划id,获取任务发布列表-->
<select id="findPublishList" resultType="com.hx.slj.modules.assessment.entity.Task">
SELECT
<include refid="taskColumns"/>
FROM standard_task a
<include refid="taskJoins"/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
AND p.del_flag = #{DEL_FLAG_NORMAL}
AND o.DEL_FLAG = #{DEL_FLAG_NORMAL}
/*根据计划id筛选*/
<if test="standardPlanId !=null and standardPlanId !=''">
AND a.standard_plan_id=#{standardPlanId}
</if>
<if test="status !=null and status !=''">
AND a.status=#{status}
</if>
<if test="currentUser !=null and currentUser.office !=null and currentUser.office.id!=null and currentUser.office.id!=''">
and o.PARENT_ID =#{currentUser.office.id}
</if>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date
</otherwise>
</choose>
</select>
<!--根据机构id,计划id,获取任务接收列表-->
<select id="findReceiveList" resultType="com.hx.slj.modules.assessment.entity.Task">
SELECT
<include refid="taskColumns"/>
FROM standard_task a
<include refid="taskJoins"/>
WHERE a.del_flag = #{DEL_FLAG_NORMAL}
AND p.del_flag = #{DEL_FLAG_NORMAL}
AND o.DEL_FLAG = #{DEL_FLAG_NORMAL}
/*根据计划id筛选*/
<if test="standardPlanId !=null and standardPlanId !=''">
AND a.standard_plan_id=#{standardPlanId}
</if>
<if test="status !=null and status !=''">
AND a.status=#{status}
</if>
<if test="currentUser !=null and currentUser.office !=null and currentUser.office.id!=null and currentUser.office.id!=''">
and o.id =#{currentUser.office.id}
</if>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.update_date
</otherwise>
</choose>
</select>
<insert id="save">
INSERT INTO standard_task(
id,
standard_plan_id,
sys_office_id,
sort,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag,
status
) VALUES (
#{id},
#{standardPlanId},
#{sysOfficeId},
#{sort},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag},
#{status}
)
</insert>
<insert id="insert">
INSERT INTO standard_task(
id,
standard_plan_id,
sys_office_id,
sort,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag,
status
) VALUES (
#{id},
#{standardPlanId},
#{sysOfficeId},
#{sort},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag},
#{status}
)
</insert>
<update id="update">
UPDATE standard_task SET
standard_plan_id = #{standardPlanId},
sys_office_id = #{sysOfficeId},
sort = #{sort},
create_by = #{createBy.id},
create_date = #{createDate},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks},
del_flag = #{delFlag},
status =#{status}
WHERE id = #{id}
</update>
<update id="delete">
UPDATE standard_task SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<update id="updateStatus">
UPDATE standard_task SET
status = #{status}
WHERE id = #{id}
</update>
</mapper>