RtEqAlarmMapper.xml 10.1 KB
Newer Older
葛齐林's avatar
葛齐林 committed
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
<?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.devplatform.routes.modules.eqequipment.dao.RtEqAlarmDao">
  <!-- Result Map -->
  <resultMap id="BaseResultMap" type="com.devplatform.routes.modules.eqequipment.bean.RtEqAlarm">
    <result column="id" property="id"/>
    <result column="eq_id" property="eqId"/>
    <result column="eq_name" property="eqName"/>
    <result column="station_id" property="stationId"/>
    <result column="station_name" property="stationName"/>
    <result column="name" property="name"/>
    <result column="code" property="code"/>
    <result column="type" property="type"/>
    <result column="level" property="level"/>
    <result column="times" property="times"/>
    <result column="report_time" property="reportTime"/>
    <result column="remark" property="remark"/>
    <result column="status" property="status"/>
    <result column="deleted" property="deleted"/>
    <result column="create_user_id" property="createUserId"/>
    <result column="create_time" property="createTime"/>
    <result column="update_user_id" property="updateUserId"/>
    <result column="update_time" property="updateTime"/>
    <result column="byx1" property="byx1"/>
    <result column="byx2" property="byx2"/>
    <result column="byx3" property="byx3"/>
    <result column="sys_sign" property="sysSign"/>
  </resultMap>

  <!-- eq_alarm table all fields -->
  <sql id="Base_Column_List">
		id,eq_id,eq_name,station_id,station_name,name,code,type,level,times,report_time,remark,status,deleted,create_user_id,create_time,update_user_id,update_time,byx1,byx2,byx3,sys_sign
	</sql>

  <!-- 公共查询条件 -->
  <sql id="Example_Where_Clause">
    where deleted=0
    <if test="id!=null and id!=''">and id = #{id}</if>
    <if test="eqId!=null and eqId!=''">and eq_id = #{eqId}</if>
    <if test="eqName!=null and eqName!=''">and eq_name = #{eqName}</if>
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
    <if test="stationName!=null and stationName!=''">and station_name = #{stationName}</if>
    <if test="name!=null and name!=''">and name = #{name}</if>
    <if test="code!=null and code!=''">and code = #{code}</if>
    <if test="type!=null ">and type = #{type}</if>
    <if test="level!=null ">and level = #{level}</if>
    <if test="times!=null ">and times = #{times}</if>
    <if test="reportTime!=null ">and report_time = #{reportTime}</if>
    <if test="remark!=null and remark!=''">and remark = #{remark}</if>
    <if test="status!=null ">and status = #{status}</if>
    <if test="deleted!=null ">and deleted = #{deleted}</if>
    <if test="createUserId!=null and createUserId!=''">and create_user_id = #{createUserId}</if>
    <if test="createTime!=null ">and create_time = #{createTime}</if>
    <if test="updateUserId!=null and updateUserId!=''">and update_user_id = #{updateUserId}</if>
    <if test="updateTime!=null ">and update_time = #{updateTime}</if>
    <if test="byx1!=null and byx1!=''">and byx1 = #{byx1}</if>
    <if test="byx2!=null and byx2!=''">and byx2 = #{byx2}</if>
    <if test="byx3!=null and byx3!=''">and byx3 = #{byx3}</if>
    <if test="sysSign!=null and sysSign!=''">and sys_sign = #{sysSign}</if>
  </sql>

  <!--查询总数-->
  <select id="queryPageByCount" parameterType="Object" resultType="java.lang.Integer">
    select count(1) from rt_eq_alarm eq
    <include refid="queryPageByListClause"></include>
  </select>

  <select id="queryPageByList" parameterType="Object" resultMap="BaseResultMap">
    SELECT
      DISTINCT(eq.id),
      eq.*,
      eqy.`name` AS typeName,
      equ.`level`  AS eqLevel,
      CASE
      equ.`level`
      WHEN 1 THEN lil.name
      WHEN 2 THEN '路网'
      WHEN 3 THEN li.station_name
      END AS sname
    FROM
      rt_eq_alarm eq
      LEFT JOIN rt_eq_alarm_type eqy ON eq.type = eqy.`value`
      LEFT JOIN rt_eq_equipment equ ON equ.id = eq.eq_id
      LEFT JOIN li_station li ON li.id = eq.station_name
      LEFT JOIN li_line lil ON lil.id = eq.station_name
    <include refid="queryPageByListClause"></include>
    <if test="pager.orderCondition != null and pager.orderCondition != ''">
      ${pager.orderCondition}
    </if>
    <if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ''">
      ${pager.mysqlQueryCondition}
    </if>
  </select>

  <select id="queryPageRoutesByList" parameterType="Object" resultMap="BaseResultMap">
    SELECT
    DISTINCT(eq.id),
    eq.*,
    eqy.`name` AS typeName,
    equ.`level` AS eqLevel,
    CASE
    equ.`level`
    WHEN 1 THEN '路网'
    WHEN 3 THEN lil.name
    END AS sname
    FROM
    rt_eq_alarm eq
    LEFT JOIN rt_eq_alarm_type eqy ON eq.type = eqy.`value`
    LEFT JOIN rt_eq_equipment equ ON equ.id = eq.eq_id
    LEFT JOIN li_line lil ON lil.id = eq.station_name
    <include refid="queryPageByListClause"></include>
    <if test="pager.orderCondition != null and pager.orderCondition != ''">
      ${pager.orderCondition}
    </if>
    <if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ''">
      ${pager.mysqlQueryCondition}
    </if>
  </select>

  <sql id="queryPageByListClause">
    where eq.deleted=0
    <if test="id!=null and id!=''">and eq.id = #{id}</if>
    <if test="eqId!=null and eqId!=''">and eq.eq_id = #{eqId}</if>
    <if test="eqName!=null and eqName!=''">and eq.eq_name = #{eqName}</if>
    <if test="stationId!=null and stationId!=''">and eq.station_id = #{stationId}</if>
    <if test="stationName!=null and stationName!=''">and eq.station_name = #{stationName}</if>
    <if test="name!=null and name!=''">and eq.name = #{name}</if>
    <if test="code!=null and code!=''">and eq.code = #{code}</if>
    <if test="type!=null ">and eq.type = #{type}</if>
    <if test="level!=null ">and eq.level = #{level}</if>
    <if test="times!=null ">and eq.times = #{times}</if>
    <if test="reportTime!=null ">and eq.report_time = #{reportTime}</if>
    <if test="remark!=null and remark!=''">and eq.remark = #{remark}</if>
    <if test="status!=null ">and eq.status = #{status}</if>
    <if test="deleted!=null ">and eq.deleted = #{deleted}</if>
    <if test="createUserId!=null and createUserId!=''">and eq.create_user_id = #{createUserId}</if>
    <if test="createTime!=null ">and eq.create_time = #{createTime}</if>
    <if test="updateUserId!=null and updateUserId!=''">and eq.update_user_id = #{updateUserId}</if>
    <if test="updateTime!=null ">and eq.update_time = #{updateTime}</if>
    <if test="byx1!=null and byx1!=''">and eq.byx1 = #{byx1}</if>
    <if test="byx2!=null and byx2!=''">and eq.byx2 = #{byx2}</if>
    <if test="byx3!=null and byx3!=''">and eq.byx3 = #{byx3}</if>
    <if test="startTime != null and startTime != ''">and eq.report_time &gt;= #{startTime}</if>
    <if test="endTime != null and endTime != ''">and eq.report_time &lt;= #{endTime}</if>

  </sql>

  <!--查询总数-->
  <select id="getPieStatisticsDataTotal" parameterType="Object" resultType="java.lang.Integer">
    select count(1) as total from rt_eq_alarm
    <include refid="queryStatisticsClause"/>
  </select>

  <!--查询总数-->
  <select id="getPieStatisticsData" parameterType="Object" resultType="map">
    SELECT type,COUNT(id) AS typeCount FROM rt_eq_alarm
    <include refid="queryStatisticsClause"/>
    GROUP BY type
  </select>

  <!--查询总数-->
  <select id="getLineStatisticsData" parameterType="Object" resultType="map">
    SELECT type,COUNT(id) AS typeCount,DATE(report_time) as reportTime FROM rt_eq_alarm
    <include refid="queryStatisticsClause"/>
    GROUP BY type,DATE(report_time)
  </select>

  <sql id="queryStatisticsClause">
    where deleted=0
    <if test="startTime != null and startTime != ''">and report_time &gt;= #{startTime}</if>
    <if test="endTime != null and endTime != ''">and report_time &lt;= DATE_ADD(#{endTime},INTERVAL 1 day)</if>
    <if test="stationId !=null and stationId !=''">and station_id = #{stationId}</if>
  </sql>

  <!--查询总数-->
  <select id="getAlarmEquipmentList" parameterType="Object" resultMap="BaseResultMap">
		SELECT eq_id,eq_name FROM rt_eq_alarm
		GROUP BY eq_id
	</select>

  <update id="updateStatusById" parameterType="object">
		update rt_eq_alarm set status = #{status},sys_sign = #{sysSign} where id =#{id}
	</update>

  <update id="updateRemarkById" parameterType="object">
		update rt_eq_alarm set update_time = #{updateTime},report_time = #{reportTime},remark = #{remark},sys_sign = #{sysSign}
        <if test="byx1 != null and byx1 !=''">
          ,byx1 = #{byx1}
        </if>
        <if test="byx2 != null and byx2 !=''">
          ,byx2 = #{byx2}
        </if>
		where id =#{id}
	</update>

  <update id="updateStatusByEqId" parameterType="object">
		update rt_eq_alarm set status = #{status},sys_sign = #{sysSign} where eq_id =#{eqId} and level in (1,2,3) and status = 2
	</update>

  <select id="queryAlarmByReportTime" resultMap="BaseResultMap" parameterType="object">
    SELECT
      eq.*,
      equ.`level`,
      CASE
      equ.`level`
      WHEN 1 THEN lil.name
      WHEN 2 THEN '路网'
      WHEN 3 THEN li.station_name
      END AS sname
    FROM
    rt_eq_alarm eq
    LEFT JOIN rt_eq_equipment equ ON equ.id = eq.eq_id
    LEFT JOIN li_station li ON li.id = eq.station_name
    LEFT JOIN li_line lil ON lil.id = eq.station_name
    where eq.station_id = #{stationId} and eq.report_time >= #{reportTime} and eq.`status` = '2'
    GROUP BY eq.id
    ORDER BY report_time desc
  </select>

  <select id="queryAlarmRoutesByReportTime" resultMap="BaseResultMap" parameterType="object">
    SELECT
      eq.*,
      equ.`level`,
      CASE
      equ.`level`
      WHEN 1 THEN '路网'
      WHEN 3 THEN lil.name
      END AS sname
    FROM
    rt_eq_alarm eq
    LEFT JOIN rt_eq_equipment equ ON equ.id = eq.eq_id
    LEFT JOIN li_line lil ON lil.id = eq.station_name
    where eq.station_id = #{stationId} and eq.report_time >= #{reportTime} and eq.`status` = '2'
    GROUP BY eq.id
    ORDER BY report_time desc
  </select>
  <select id="queryEquipmentType" resultType="java.util.Map">
    select
    eq.eq_id as id,
    eq.eq_name as name
    from
    rt_eq_alarm eq
    group by eq.eq_id,eq.eq_name
  </select>

</mapper>