1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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.testor.module.safeCheck.dao.TSafeHazardCheckResultDao">
<!-- 开启二级缓存 -->
<!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.testor.module.safeCheck.model.domain.TSafeHazardCheckResult">
<id column="id" property="id"/>
<id column="check_obj_id" property="checkObjId"/>
<id column="task_id" property="taskId"/>
<id column="result_status" property="resultStatus"/>
</resultMap>
<sql id="select_base_column">
cr.id, cr.check_obj_id checkObjId, cr.task_id taskId,
cr.result_status resultStatus,
cr.status, cr.remarks, cr.create_by createBy, cr.create_date createDate,
cr.update_by as updateBy, cr.update_date updateDate
</sql>
<sql id="common_where_if">
<if test="query.id!=null and query.id!=''">
and cr.id=#{query.id}
</if>
<if test="query.checkObjId!=null and query.checkObjId!=''">
and cr.check_obj_id=#{query.checkObjId}
</if>
<if test="query.taskId!='' and query.taskId!=null">
and cr.task_id=#{query.taskId}
</if>
<if test="query.resultStatus!='' and query.resultStatus!=null">
and cr.result_status=#{query.resultStatus}
</if>
</sql>
<select id="listByTask" resultType="com.testor.module.safeCheck.model.vo.SafeHazardCheckResultVO">
select
( case
when rs.type =1 then (select se.name from t_safe_equipment se where rs.obj_id = se.id)
when rs.type =2 then (select ss.name from t_safe_space ss where rs.obj_id = ss.id)
when rs.type =3 then ''
else ''
end ) objName,
hs.standard_name standardName,
( case
when rs.type =1 then (select et.name from t_safe_equipment_type et where rs.obj_type_id = et.id)
when rs.type =2 then (select st.name from t_safe_space_type st where rs.obj_type_id = st.id)
when rs.type =3 then (select hst.category_item from t_safe_hazard_standard_type hst where rs.obj_type_id = hst.id)
else ''
end ) objTypeName,
<include refid="select_base_column" />
from t_safe_hazard_check_result cr,t_safe_hazard_check_object rs
left join t_safe_hazard_standard hs on rs.standard_id = hs.id
<where>
cr.status = '0' and cr.check_obj_id = rs.id
and cr.task_id=#{taskId}
</where>
</select>
</mapper>