123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- <?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.EntRiskPointMapper">
- <resultMap id="RiskPointDtoResultMap" type="com.zhyc.xps.aqpt.dto.EntRiskPointDto">
- <result column="oc_id" property="ocId" jdbcType="BIGINT" />
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" />
- <result column="risk_point_title" property="riskPointTitle" jdbcType="VARCHAR" />
- <result column="risk_point_code" property="riskPointCode" jdbcType="VARCHAR" />
- <result column="risk_point_addr" property="riskPointAddr" jdbcType="VARCHAR" />
- <result column="risk_point_desc" property="riskPointDesc" jdbcType="VARCHAR" />
- <result column="risk_point_logo" property="riskPointLogo" jdbcType="VARCHAR" />
- <result column="risk_point_photo" property="riskPointPhoto" jdbcType="VARCHAR" />
- <result column="risk_point_level" property="riskPointLevel" jdbcType="BIGINT" />
- <result column="risk_point_cat_id" property="riskPointCatId" jdbcType="BIGINT" />
- <result column="is_major_hazard" property="isMajorHazard" jdbcType="BIGINT" />
- <result column="is_active" property="isActive" jdbcType="BIGINT" />
- <result column="active_start_time" property="activeStartTime" jdbcType="TIMESTAMP"/>
- <result column="active_end_time" property="activeEndTime" jdbcType="TIMESTAMP"/>
- <result column="status" property="status" jdbcType="BIGINT" />
- <result column="alert_num" property="alertNum" jdbcType="BIGINT" />
- <result column="danger_num" property="dangerNum" jdbcType="BIGINT" />
- <result column="checklist_num" property="checklistNum" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="risk_point_cat_title" property="riskPointCatTitle" jdbcType="VARCHAR" />
- <result column="grid_id" property="gridId" jdbcType="BIGINT" />
- <result column="grid_title" property="gridTitle" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="RiskPointDto_Cols">
- A.oc_id,
- A.group_id,
- B.group_name,
- A.risk_point_id,
- A.risk_point_title,
- A.risk_point_code,
- A.risk_point_addr,
- A.risk_point_desc,
- A.risk_point_logo,
- A.risk_point_photo,
- A.risk_point_level,
- A.risk_point_cat_id,
- C.risk_point_Cat_title,
- A.is_major_hazard,
- A.is_active,
- A.active_start_time,
- A.active_end_time,
- A.status,
- A.grid_id,
- D.grid_title,
- E.alert_num,
- F.danger_num,
- IFNULL(G.checklist_num, 0) AS checklist_num
- </sql>
- <!--根据ID获取信息-->
- <select id="getById" resultMap="RiskPointDtoResultMap">
- SELECT
- <include refid="RiskPointDto_Cols"/>
- FROM ent_risk_point AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN ent_risk_point_cat AS C ON (A.oc_id = C.oc_id AND A.risk_point_cat_id = C.risk_point_cat_id)
- LEFT JOIN ent_grid AS D ON (A.oc_id = D.oc_id AND A.grid_id = D.grid_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(alert_id) AS alert_num
- FROM alert
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- GROUP BY risk_point_id
- ) AS E ON (A.oc_id = E.oc_id AND A.risk_point_id = E.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(danger_id) AS danger_num
- FROM ent_danger
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- ) AS F ON (A.oc_id = F.oc_id AND A.risk_point_id = F.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- target_id,
- count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 2
- GROUP BY target_id
- ) AS G ON (A.oc_id = G.oc_id AND A.risk_point_id = G.target_id)
- WHERE A.deleted_flag = 0
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- AND A.risk_point_id = #{riskPointId, jdbcType=BIGINT}
- </select>
- <!--根据ID获取信息-->
- <select id="getByCode" resultMap="RiskPointDtoResultMap">
- SELECT
- <include refid="RiskPointDto_Cols"/>
- FROM ent_risk_point AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN ent_risk_point_cat AS C ON (A.oc_id = C.oc_id AND A.risk_point_cat_id = C.risk_point_cat_id)
- LEFT JOIN ent_grid AS D ON (A.oc_id = D.oc_id AND A.grid_id = D.grid_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(alert_id) AS alert_num
- FROM alert
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- GROUP BY risk_point_id
- ) AS E ON (A.oc_id = E.oc_id AND A.risk_point_id = E.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(danger_id) AS danger_num
- FROM ent_danger
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- ) AS F ON (A.oc_id = F.oc_id AND A.risk_point_id = F.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- target_id,
- count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 2
- GROUP BY target_id
- ) AS G ON (A.oc_id = G.oc_id AND A.risk_point_id = G.target_id)
- WHERE A.deleted_flag = 0
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- AND A.risk_point_code = #{riskPointCode, jdbcType=VARCHAR}
- </select>
- <!--分页查询信息-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="RiskPointDtoResultMap">
- SELECT
- <include refid="RiskPointDto_Cols"/>
- FROM ent_risk_point AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN ent_risk_point_cat AS C ON (A.oc_id = C.oc_id AND A.risk_point_cat_id = C.risk_point_cat_id)
- LEFT JOIN ent_grid AS D ON (A.oc_id = D.oc_id AND A.grid_id = D.grid_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(alert_id) AS alert_num
- FROM alert
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- GROUP BY risk_point_id
- ) AS E ON (A.oc_id = E.oc_id AND A.risk_point_id = E.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(danger_id) AS danger_num
- FROM ent_danger
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- ) AS F ON (A.oc_id = F.oc_id AND A.risk_point_id = F.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- target_id,
- count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 2
- GROUP BY target_id
- ) AS G ON (A.oc_id = G.oc_id AND A.risk_point_id = G.target_id)
- WHERE 1 = 1 AND A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="groupId != null and groupId !=''">
- AND A.group_id = #{groupId ,jdbcType=BIGINT}
- </if>
- <if test="riskPointLevel != null and riskPointLevel > 0">
- AND A.risk_point_level = #{riskPointLevel ,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="riskPointId != null">
- AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords !=''">
- AND A.risk_point_title LIKE "%"#{keywords, jdbcType=VARCHAR}"%"
- OR A.risk_point_addr LIKE "%"#{keywords, jdbcType=VARCHAR}"%"
- </if>
- ORDER BY A.created_at desc
- </select>
- <select id="getByList" parameterType="java.util.Map" resultMap="RiskPointDtoResultMap">
- SELECT
- <include refid="RiskPointDto_Cols"/>
- FROM ent_risk_point AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- LEFT JOIN ent_risk_point_cat AS C ON (A.oc_id = C.oc_id AND A.risk_point_cat_id = C.risk_point_cat_id)
- LEFT JOIN ent_grid AS D ON (A.oc_id = D.oc_id AND A.grid_id = D.grid_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(alert_id) AS alert_num
- FROM alert
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- GROUP BY risk_point_id
- ) AS E ON (A.oc_id = E.oc_id AND A.risk_point_id = E.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- risk_point_id,
- COUNT(danger_id) AS danger_num
- FROM ent_danger
- WHERE status = 0 AND oc_id = #{ocId, jdbcType=BIGINT}
- ) AS F ON (A.oc_id = F.oc_id AND A.risk_point_id = F.risk_point_id)
- LEFT JOIN (
- SELECT oc_id,
- target_id,
- count(*) AS checklist_num
- FROM checklist_target
- WHERE oc_id = #{ocId ,jdbcType=BIGINT} AND target_type = 2
- GROUP BY target_id
- ) AS G ON (A.oc_id = G.oc_id AND A.risk_point_id = G.target_id)
- WHERE 1 = 1 AND A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="groupId != null">
- AND A.group_id = #{groupId ,jdbcType=BIGINT}
- </if>
- <if test="isActive != null">
- AND A.is_active = #{isActive ,jdbcType=BIGINT}
- </if>
- <if test="riskPointLevel != null and riskPointLevel > 0">
- AND A.risk_point_level = #{riskPointLevel ,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND A.risk_point_id = #{riskPointId ,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>
- ORDER BY A.risk_point_id ASC
- </select>
- <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.EntRiskPoint">
- INSERT INTO ent_risk_point
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="groupId != null">
- group_id,
- </if>
- <if test="riskPointId != null">
- risk_point_id,
- </if>
- <if test="riskPointTitle != null and riskPointTitle != ''">
- risk_point_title,
- </if>
- <if test="riskPointCode != null and riskPointCode != ''">
- risk_point_code,
- </if>
- <if test="riskPointAddr != null and riskPointAddr != ''">
- risk_point_addr,
- </if>
- <if test="riskPointDesc != null and riskPointDesc != ''">
- risk_point_desc,
- </if>
- <if test="riskPointLogo != null and riskPointLogo != ''">
- risk_point_logo,
- </if>
- <if test="riskPointPhoto != null and riskPointPhoto != ''">
- risk_point_photo,
- </if>
- <if test="riskPointLevel != null">
- risk_point_level,
- </if>
- <if test="riskPointCatId != null">
- risk_point_cat_id,
- </if>
- <if test="isMajorHazard != null">
- is_major_hazard,
- </if>
- <if test="isActive != null">
- is_active,
- </if>
- <if test="activeStartTime != null">
- active_start_time,
- </if>
- <if test="activeEndTime != null">
- active_end_time,
- </if>
- <if test="status != null">
- status,
- </if>
- <if test="gridId != null">
- grid_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="groupId != null">
- #{groupId ,jdbcType=BIGINT},
- </if>
- <if test="riskPointId != null">
- #{riskPointId ,jdbcType=BIGINT},
- </if>
- <if test="riskPointTitle != null and riskPointTitle != ''">
- #{riskPointTitle ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointCode != null and riskPointCode != ''">
- #{riskPointCode ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointAddr != null and riskPointAddr != ''">
- #{riskPointAddr ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointDesc != null and riskPointDesc != ''">
- #{riskPointDesc ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointLogo != null and riskPointLogo != ''">
- #{riskPointLogo ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointPhoto != null and riskPointPhoto != ''">
- #{riskPointPhoto ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointLevel != null">
- #{riskPointLevel ,jdbcType=BIGINT},
- </if>
- <if test="riskPointCatId != null">
- #{riskPointCatId ,jdbcType=BIGINT},
- </if>
- <if test="isMajorHazard != null">
- #{isMajorHazard ,jdbcType=BIGINT},
- </if>
- <if test="isActive != null">
- #{isActive ,jdbcType=BIGINT},
- </if>
- <if test="activeStartTime != null">
- #{activeStartTime ,jdbcType=TIMESTAMP},
- </if>
- <if test="activeEndTime != null">
- #{activeEndTime ,jdbcType=TIMESTAMP},
- </if>
- <if test="status != null">
- #{status ,jdbcType=BIGINT},
- </if>
- <if test="gridId != null">
- #{gridId ,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.EntRiskPoint">
- UPDATE ent_risk_point
- <trim suffixOverrides=",">
- <set>
- <if test="riskPointTitle != null and riskPointTitle != ''">
- risk_point_title = #{riskPointTitle ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointCode != null and riskPointCode != ''">
- risk_point_code = #{riskPointCode, jdbcType=VARCHAR},
- </if>
- <if test="riskPointAddr != null and riskPointAddr != ''">
- risk_point_addr = #{riskPointAddr, jdbcType=VARCHAR},
- </if>
- <if test="riskPointDesc != null and riskPointDesc != ''">
- risk_point_desc = #{riskPointDesc, jdbcType=VARCHAR},
- </if>
- <if test="riskPointLogo != null and riskPointLogo != ''">
- risk_point_logo = #{riskPointLogo, jdbcType=VARCHAR},
- </if>
- <if test="riskPointPhoto != null and riskPointPhoto != ''">
- risk_point_photo = #{riskPointPhoto ,jdbcType=VARCHAR},
- </if>
- <if test="riskPointLevel != null ">
- risk_point_level = #{riskPointLevel, jdbcType=BIGINT},
- </if>
- <if test="groupId != null ">
- group_id = #{groupId, jdbcType=BIGINT},
- </if>
- <if test="riskPointCatId != null ">
- risk_point_cat_id = #{riskPointCatId, jdbcType=BIGINT},
- </if>
- <if test="isMajorHazard != null">
- is_major_hazard = #{isMajorHazard ,jdbcType=BIGINT},
- </if>
- <if test="isActive != null">
- is_active= #{isActive ,jdbcType=BIGINT},
- </if>
- <if test="activeStartTime != null">
- active_start_time = #{activeStartTime ,jdbcType=TIMESTAMP},
- </if>
- <if test="activeEndTime != null">
- active_end_time = #{activeEndTime ,jdbcType=TIMESTAMP},
- </if>
- <if test="status != null">
- status = #{status ,jdbcType=BIGINT},
- </if>
- <if test="gridId != null">
- grid_id = #{gridId ,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>
- </update>
- <!--删除-->
- <update id="delete" parameterType="java.util.Map">
- UPDATE ent_risk_point
- <trim suffixOverrides=",">
- <set>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag,jdbcType=BIGINT},
- </if>
- <if test="deletedAt != null">
- deleted_at = #{deletedAt,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="riskPointId != null">
- AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- </update>
- <!-- 根据条件统计风险点数据 -->
- <select id="getRiskPointStaticsData" resultType="java.util.Map" parameterType="java.util.Map">
- SELECT count(0) AS "total",
- SUM(IF ( A.risk_point_level = 1, 1, 0 )) AS "one",
- SUM(IF ( A.risk_point_level = 1 AND A.STATUS = 2, 1, 0 )) AS "wone",
- SUM(IF ( A.risk_point_level = 2, 1, 0 )) AS "two",
- SUM(IF ( A.risk_point_level = 2 AND A.STATUS = 2, 1, 0 )) AS "wtwo",
- SUM(IF ( A.risk_point_level = 3, 1, 0 )) AS "three",
- SUM(IF ( A.risk_point_level = 3 AND A.STATUS = 2, 1, 0 )) AS "wthree",
- SUM(IF ( A.risk_point_level = 4, 1, 0 )) AS "four" ,
- SUM(IF ( A.risk_point_level = 4 AND A.STATUS = 2, 1, 0 )) AS "wfour"
- FROM ent_risk_point AS A
- WHERE IF( A.is_active = 1,
- (
- A.active_end_time > NOW()
- OR A.active_end_time IS NULL
- ),
- '1=1'
- )
- AND A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- </if>
- </select>
- </mapper>
|