123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- <?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.ChecklistHazardRiskMapper">
- <resultMap id="RiskDtoResultMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardRiskDto">
- <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="risk_id" property="riskId" jdbcType="BIGINT"/>
- <result column="risk_code" property="riskCode" jdbcType="VARCHAR"/>
- <result column="risk_source" property="riskSource" jdbcType="VARCHAR"/>
- <result column="risk_reason" property="riskReason" jdbcType="VARCHAR"/>
- <result column="risk_consequence" property="riskConsequence" jdbcType="VARCHAR"/>
- <result column="risk_level" property="riskLevel" jdbcType="BIGINT"/>
- <result column="risk_type_id" property="riskTypeId" jdbcType="BIGINT"/>
- <result column="ctrl_level_id" property="ctrlLevelId" jdbcType="BIGINT"/>
- <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR"/>
- <result column="position_id_list" property="positionIdList" jdbcType="VARCHAR"/>
- <result column="position_name_list" property="positionNameList" jdbcType="VARCHAR"/>
- <result column="ctrl_level_title" property="ctrlLevelTitle" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="RiskDto_Cols">
- A.oc_id,
- A.checklist_id,
- A.hazard_id,
- B.hazard_title,
- A.risk_id,
- A.risk_code,
- A.risk_source,
- A.risk_reason,
- A.risk_consequence,
- A.risk_level,
- A.risk_type_id,
- A.ctrl_level_id,
- C.ctrl_level_title,
- E.position_id_list,
- E.position_name_list
- </sql>
- <!--根据ID获取信息-->
- <select id="getById" resultMap="RiskDtoResultMap">
- SELECT
- <include refid="RiskDto_Cols"/>
- FROM checklist_hazard_risk AS A
- LEFT JOIN checklist_hazard AS B ON ( A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id )
- LEFT JOIN ent_ctrl_level AS C ON ( A.oc_id = C.oc_id AND A.ctrl_level_id = C.ctrl_level_id )
- LEFT JOIN (
- SELECT
- GROUP_CONCAT( DISTINCT N.position_id ) AS position_id_list,
- GROUP_CONCAT( DISTINCT N.position_name ) AS position_name_list,
- M.oc_id,
- M.checklist_id,
- M.hazard_id,
- M.risk_id
- FROM checklist_hazard_risk_position AS M
- LEFT JOIN s_position AS N ON ( M.oc_id = N.oc_id AND M.position_id = N.position_id )
- WHERE 1 = 1
- <if test="ocId != null">
- AND M.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND M.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="hazardId != null">
- AND M.hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- <if test="riskId != null">
- AND M.risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- GROUP BY
- M.oc_id,
- M.checklist_id,
- M.hazard_id,
- M.risk_id
- ) AS E ON ( A.oc_id = E.oc_id AND A.checklist_id = E.checklist_id AND A.hazard_id = E.hazard_id AND A.risk_id = E.risk_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="riskId != null">
- AND A.risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- </select>
- <!--分页查询信息-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="RiskDtoResultMap">
- SELECT
- <include refid="RiskDto_Cols"/>
- FROM checklist_hazard_risk AS A
- LEFT JOIN checklist_hazard AS B ON ( A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id )
- LEFT JOIN ent_ctrl_level AS C ON ( A.oc_id = C.oc_id AND A.ctrl_level_id = C.ctrl_level_id )
- LEFT JOIN (
- SELECT
- GROUP_CONCAT( DISTINCT N.position_name ) AS position_name_list,
- GROUP_CONCAT( DISTINCT N.position_id ) AS position_id_list,
- M.oc_id,
- M.checklist_id,
- M.hazard_id,
- M.risk_id
- FROM checklist_hazard_risk_position AS M
- LEFT JOIN s_position AS N ON ( M.oc_id = N.oc_id AND M.position_id = N.position_id )
- LEFT JOIN checklist_hazard AS K ON ( M.oc_id = K.oc_id AND M.checklist_id = K.checklist_id AND M.hazard_id = K.hazard_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND M.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND M.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND K.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND K.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="hazardId != null">
- AND M.hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- <if test="riskId != null">
- AND M.risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- GROUP BY
- M.oc_id,
- M.checklist_id,
- M.hazard_id,
- M.risk_id
- ) AS E ON ( A.oc_id = E.oc_id AND A.checklist_id = E.checklist_id AND A.hazard_id = E.hazard_id AND A.risk_id = E.risk_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="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="riskId != null">
- AND A.risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- <if test="riskLevel != null and riskLevel > 0">
- AND A.risk_level = #{riskLevel ,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- and A.risk_source like "%"#{keywords}"%"
- </if>
- ORDER BY A.risk_id ASC
- </select>
- <select id="getByList" parameterType="java.util.Map" resultMap="RiskDtoResultMap">
- SELECT
- <include refid="RiskDto_Cols"/>
- FROM checklist_hazard_risk AS A
- LEFT JOIN checklist_hazard AS B ON ( A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id )
- LEFT JOIN ent_ctrl_level AS C ON ( A.oc_id = C.oc_id AND A.ctrl_level_id = C.ctrl_level_id )
- LEFT JOIN (
- SELECT
- GROUP_CONCAT( DISTINCT N.position_name ) AS position_name_list,
- GROUP_CONCAT( DISTINCT N.position_id ) AS position_id_list,
- M.oc_id,
- M.checklist_id,
- M.hazard_id,
- M.risk_id
- FROM checklist_hazard_risk_position AS M
- LEFT JOIN s_position AS N ON ( M.oc_id = N.oc_id AND M.position_id = N.position_id )
- LEFT JOIN checklist_hazard AS K ON ( M.oc_id = K.oc_id AND M.checklist_id = K.checklist_id AND M.hazard_id = K.hazard_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND M.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND M.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND K.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND K.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="hazardId != null">
- AND M.hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- <if test="riskId != null">
- AND M.risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- GROUP BY
- M.oc_id,
- M.checklist_id,
- M.hazard_id,
- M.risk_id
- ) AS E ON ( A.oc_id = E.oc_id AND A.checklist_id = E.checklist_id AND A.hazard_id = E.hazard_id AND A.risk_id = E.risk_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="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="riskId != null">
- AND A.risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- <if test="ctrlLevelId != null">
- <![CDATA[
- AND A.ctrl_level_id <= #{ctrlLevelId ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="riskPointId != null">
- AND EXISTS (
- SELECT
- *
- FROM ent_risk_point_hazard AS R
- WHERE R.deleted_flag = 0
- AND A.oc_id = R.oc_id
- AND A.checklist_id = R.checklist_id
- AND A.hazard_id = R.hazard_id
- AND R.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- )
- </if>
- <if test="waitingTaskId != null">
- AND EXISTS (
- SELECT
- *
- FROM check_task_doing AS R
- WHERE 1 = 1
- AND A.oc_id = R.oc_id
- AND A.hazard_id = R.hazard_id
- AND R.task_id = #{waitingTaskId ,jdbcType=BIGINT}
- )
- </if>
- <if test="handledTaskId != null">
- AND EXISTS (
- SELECT
- *
- FROM check_record AS R
- WHERE 1 = 1
- AND A.oc_id = R.oc_id
- AND A.hazard_id = R.hazard_id
- AND R.task_id = #{handledTaskId ,jdbcType=BIGINT}
- )
- </if>
- <if test="riskLevel != null and riskLevel > 0">
- AND A.risk_level = #{riskLevel ,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND A.risk_source like "%"#{keywords}"%"
- </if>
- ORDER BY A.risk_id ASC
- </select>
- <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.ChecklistHazardRisk">
- INSERT INTO checklist_hazard_risk
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="checklistId != null">
- checklist_id,
- </if>
- <if test="hazardId != null">
- hazard_id,
- </if>
- <if test="riskId != null">
- risk_id,
- </if>
- <if test="riskCode != null and riskCode != ''">
- risk_code,
- </if>
- <if test="riskSource != null and riskSource != ''">
- risk_source,
- </if>
- <if test="riskReason != null and riskReason != ''">
- risk_reason,
- </if>
- <if test="riskConsequence != null and riskConsequence != ''">
- risk_consequence,
- </if>
- <if test="riskLevel != null">
- risk_level,
- </if>
- <if test="riskTypeId != null">
- risk_type_id,
- </if>
- <if test="ctrlLevelId != null">
- ctrl_level_id,
- </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="checklistId != null">
- #{checklistId ,jdbcType=BIGINT},
- </if>
- <if test="hazardId != null">
- #{hazardId ,jdbcType=BIGINT},
- </if>
- <if test="riskId != null">
- #{riskId ,jdbcType=BIGINT},
- </if>
- <if test="riskCode != null and riskCode != ''">
- #{riskCode ,jdbcType=VARCHAR},
- </if>
- <if test="riskSource != null and riskSource != ''">
- #{riskSource ,jdbcType=VARCHAR},
- </if>
- <if test="riskReason != null and riskReason != ''">
- #{riskReason ,jdbcType=VARCHAR},
- </if>
- <if test="riskConsequence != null and riskConsequence != ''">
- #{riskConsequence ,jdbcType=VARCHAR},
- </if>
- <if test="riskLevel != null">
- #{riskLevel ,jdbcType=BIGINT},
- </if>
- <if test="riskTypeId != null">
- #{riskTypeId ,jdbcType=BIGINT},
- </if>
- <if test="ctrlLevelId != null">
- #{ctrlLevelId,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.ChecklistHazardRisk">
- UPDATE checklist_hazard_risk
- <trim suffixOverrides=",">
- <set>
- <if test="riskCode != null and riskCode != ''">
- risk_code = #{riskCode, jdbcType=VARCHAR},
- </if>
- <if test="riskSource != null and riskSource != ''">
- risk_source = #{riskSource, jdbcType=VARCHAR},
- </if>
- <if test="riskReason != null and riskReason != ''">
- risk_reason = #{riskReason, jdbcType=VARCHAR},
- </if>
- <if test="riskConsequence != null and riskConsequence != ''">
- risk_consequence = #{riskConsequence, jdbcType=VARCHAR},
- </if>
- <if test="riskLevel != null ">
- risk_level = #{riskLevel, jdbcType=BIGINT},
- </if>
- <if test="riskTypeId != null ">
- risk_type_id = #{riskTypeId, jdbcType=BIGINT},
- </if>
- <if test="ctrlLevelId != null">
- ctrl_level_id = #{ctrlLevelId,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="checklistId != null">
- AND checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="hazardId != null">
- AND hazard_id = #{hazardId ,jdbcType=BIGINT}
- </if>
- <if test="riskId != null">
- AND risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--删除-->
- <update id="delete" parameterType="java.util.Map">
- UPDATE checklist_hazard_risk
- <trim suffixOverrides=",">
- <set>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag,jdbcType=BIGINT},
- </if>
- <if test="deletedTime != null">
- deleted_time = #{deletedTime,jdbcType=VARCHAR},
- </if>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_id = #{ocId ,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>
- <if test="riskId != null">
- AND risk_id = #{riskId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--获取成员数目-->
- <select id="getMemberCountOfHazard" parameterType="java.util.Map" resultType="java.lang.Long">
- SELECT
- count(*)
- FROM checklist_hazard_risk AS A
- LEFT JOIN checklist_hazard AS B ON ( A.hazard_id = B.hazard_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>
- </select>
- </mapper>
|