<?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.ycl.mapper.equipment.OrgGridMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ycl.entity.equipment.OrgGrid">
|
<id column="id" property="id" />
|
<result column="worker" property="worker" />
|
<result column="contact" property="contact" />
|
<result column="area" property="area" />
|
<result column="region" property="region" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, worker, contact, area, region
|
</sql>
|
<select id="statisticsGridMap" resultType="com.ycl.vo.cockpit.statisticsEvents.GridMapVO">
|
SELECT
|
*
|
FROM
|
(
|
SELECT
|
og.id,
|
og.`name`,
|
og.region,
|
COUNT( DISTINCT v.id ) eventCount ,
|
sum(case WHEN v.video_point_id is not null then 1 else 0 END ) aiCount
|
FROM
|
ums_org_grid og
|
LEFT JOIN ums_base_case bc ON og.id = bc.grid_id
|
LEFT JOIN ums_violations v ON v.id = bc.id
|
|
<if test="beginTime!=null">
|
and bc.alarm_time BETWEEN #{beginTime} and #{endTime}
|
</if>
|
GROUP BY
|
og.id,
|
og.`name`
|
) v_case
|
LEFT JOIN ( SELECT grid_id, COUNT( id ) videoCount FROM ums_video_point GROUP BY grid_id ) AS v_video ON v_case.id = v_video.grid_id
|
</select>
|
|
</mapper>
|