123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <?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.zhyc.xps.aqpt.mapper.EntRiskPointHazardMapper">
- <resultMap id="RiskPointHazardDtoMap" type="com.zhyc.xps.aqpt.dto.EntRiskPointHazardDto" >
- <result column="oc_id" property="ocId" jdbcType="BIGINT" />
- <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" />
- <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
- <result column="hazard_id" property="hazardId" jdbcType="BIGINT" />
- <result column="status" property="status" jdbcType="BIGINT" />
- <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR" />
- <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR" />
- <result column="hazard_image" property="hazardImage" jdbcType="VARCHAR" />
- <result column="hazard_desc" property="hazardDesc" jdbcType="VARCHAR" />
- <result column="hazard_type_id" property="hazardTypeId" jdbcType="BIGINT" />
- <result column="hazard_type_title" property="hazardTypeTitle" jdbcType="VARCHAR" />
- <result column="hazard_level" property="hazardLevel" jdbcType="BIGINT" />
- </resultMap>
- <sql id="RiskPointHazardDto_Cols">
- A.oc_id,
- A.risk_point_id,
- A.checklist_id,
- A.hazard_id,
- A.status,
- B.hazard_title,
- B.hazard_code,
- B.hazard_image,
- B.hazard_desc,
- B.hazard_type_id,
- C.hazard_type_title,
- B.hazard_level
- </sql>
- <!--基于ID查询-->
- <select id="getById" resultMap="RiskPointHazardDtoMap">
- SELECT
- <include refid="RiskPointHazardDto_Cols"/>
- FROM ent_risk_point_hazard AS A
- LEFT JOIN checklist_hazard AS B ON (A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
- LEFT JOIN hazard_type AS C ON (B.hazard_type_id = C.hazard_type_id)
- WHERE 1 = 1 AND A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="hazardId != null">
- AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- <if test="status != null">
- AND A.status = #{status ,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- </select>
- <!--分页查询-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="RiskPointHazardDtoMap">
- SELECT
- <include refid="RiskPointHazardDto_Cols"/>
- FROM ent_risk_point_hazard AS A
- LEFT JOIN checklist_hazard AS B ON (A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
- LEFT JOIN hazard_type AS C ON (B.hazard_type_id = C.hazard_type_id)
- WHERE 1 = 1 AND A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="status != null">
- AND A.status = #{status ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND B.hazard_title LIKE "%"#{keywords}"%"
- </if>
- ORDER BY A.risk_point_id ASC
- </select>
- <!--列表查询-->
- <select id="getByList" parameterType="java.util.Map" resultMap="RiskPointHazardDtoMap">
- SELECT
- <include refid="RiskPointHazardDto_Cols"/>
- FROM ent_risk_point_hazard AS A
- LEFT JOIN checklist_hazard AS B ON (A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
- LEFT JOIN hazard_type AS C ON (B.hazard_type_id = C.hazard_type_id)
- WHERE 1 = 1 AND A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="hazardId != null">
- AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND B.hazard_title LIKE "%"#{keywords}"%"
- </if>
- <if test="status != null">
- AND A.status = #{status,jdbcType=BIGINT}
- </if>
- ORDER BY A.risk_point_id ASC
- </select>
- <!--新增-->
- <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.EntRiskPointHazard">
- INSERT INTO ent_risk_point_hazard
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="riskPointId != null">
- risk_point_id,
- </if>
- <if test="checklistId != null">
- checklist_id,
- </if>
- <if test="hazardId != null">
- hazard_id,
- </if>
- <if test="status != null">
- status,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId ,jdbcType=BIGINT},
- </if>
- <if test="riskPointId != null">
- #{riskPointId ,jdbcType=BIGINT},
- </if>
- <if test="checklistId != null">
- #{checklistId ,jdbcType=BIGINT},
- </if>
- <if test="hazardId != null">
- #{hazardId ,jdbcType=BIGINT},
- </if>
- <if test="status != null">
- #{status ,jdbcType=BIGINT},
- </if>
- <if test="createdBy != null">
- #{createdBy ,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt ,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--更新-->
- <update id="update" parameterType="com.zhyc.xps.aqpt.entity.EntRiskPointHazard">
- UPDATE ent_risk_point_hazard
- <trim suffixOverrides=",">
- <set>
- <if test="status != null ">
- is_enabled = #{status, jdbcType=BIGINT},
- </if>
- <if test="updatedBy != null ">
- updated_by = #{updatedBy ,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="hazardId != null">
- AND hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--删除-->
- <delete id="delete" parameterType="java.util.Map">
- DELETE from ent_risk_point_hazard
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="hazardId != null">
- AND hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- </delete>
- <resultMap id="HazardDtoMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardDto" >
- <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
- <result column="checklist_id" property="checklistId" jdbcType="BIGINT"/>
- <result column="hazard_id" property="hazardId" jdbcType="BIGINT"/>
- <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR"/>
- <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR"/>
- <result column="hazard_image" property="hazardImage" jdbcType="VARCHAR"/>
- <result column="hazard_desc" property="hazardDesc" jdbcType="VARCHAR"/>
- <result column="hazard_cat_id" property="hazardCatId" jdbcType="BIGINT"/>
- <result column="hazard_type_id" property="hazardTypeId" jdbcType="BIGINT"/>
- <result column="hazard_type_title" property="hazardTypeTitle" jdbcType="VARCHAR"/>
- <result column="hazard_level" property="hazardLevel" jdbcType="BIGINT"/>
- <result column="parent_id" property="parentId" jdbcType="BIGINT"/>
- <result column="is_fixed" property="isFixed" jdbcType="BIGINT"/>
- <result column="root_id" property="rootId" jdbcType="BIGINT"/>
- <result column="node_left" property="nodeLeft" jdbcType="BIGINT"/>
- <result column="node_right" property="nodeRight" jdbcType="BIGINT"/>
- <result column="node_level" property="nodeLevel" jdbcType="BIGINT"/>
- <result column="is_leaf" property="isLeaf" jdbcType="BIGINT"/>
- </resultMap>
- <select id="getSelectByList" parameterType="java.util.Map" resultMap="HazardDtoMap">
- SELECT
- A.oc_id,
- A.checklist_id,
- A.hazard_id,
- A.hazard_title,
- A.hazard_code,
- A.hazard_image,
- A.hazard_desc,
- B.hazard_type_title,
- A.hazard_type_id,
- A.hazard_level,
- A.parent_id,
- A.is_fixed,
- A.root_id,
- A.node_left,
- A.node_right,
- A.node_level,
- A.is_leaf
- FROM checklist_hazard AS A
- LEFT JOIN hazard_type AS B ON (A.hazard_type_id = B.hazard_type_id)
- WHERE 1 = 1 AND A.deleted_flag = 0
- AND NOT EXISTS (
- SELECT
- *
- FROM ent_risk_point_hazard AS C
- WHERE A.oc_id = C.oc_id
- AND A.checklist_id = C.checklist_id
- AND A.hazard_id = C.hazard_id
- AND C.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- )
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="hazardTypeId != null">
- AND A.hazard_type_id = #{hazardTypeId ,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND A.hazard_title LIKE "%"#{keywords}"%"
- </if>
- ORDER BY A.hazard_id ASC
- </select>
- </mapper>
|