<?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.zc.business.mapper.StatusMapper" >
<resultMap id= "BaseResultMap" type= "com.zc.business.domain.Status" >
<result column= "id" jdbcType= "BIGINT" property= "id" />
<result column= "device_no" jdbcType= "VARCHAR" property= "deviceNo" />
<result column= "device_name" jdbcType= "VARCHAR" property= "deviceName" />
<result column= "device_status" jdbcType= "INTEGER" property= "deviceStatus" />
<result column= "device_id" jdbcType= "INTEGER" property= "deviceId" />
<result column= "device_ip" jdbcType= "VARCHAR" property= "deviceIp" />
<result column= "success_rate" jdbcType= "VARCHAR" property= "successRate" />
<result column= "lost_rate" jdbcType= "VARCHAR" property= "lostRate" />
<result column= "direction" jdbcType= "VARCHAR" property= "direction" />
<result column= "manufacturer" jdbcType= "VARCHAR" property= "production" />
<result column= "model" jdbcType= "VARCHAR" property= "model" />
<result column= "facilities_type" jdbcType= "VARCHAR" property= "network" />
<result column= "remark" jdbcType= "VARCHAR" property= "content" />
<result column= "type" jdbcType= "VARCHAR" property= "type" />
<result column= "use_state" jdbcType= "VARCHAR" property= "useState" />
</resultMap>
<insert id= "Add" parameterType= "com.zc.business.domain.Status" >
INSERT INTO status
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "status.deviceNo != null" >
device_no,
</if>
<if test= "status.deviceName != null" >
device_name,
</if>
<if test= "status.deviceStatus != null" >
device_status,
</if>
<if test= "status.deviceId != null" >
device_id,
</if>
<if test= "status.time != null" >
time,
</if>
<if test= "status.successRate != null" >
success_rate,
</if>
<if test= "status.lostRate != null" >
lost_rate,
</if>
<if test= "status.deviceIp != null" >
device_ip,
</if>
</trim>
<trim prefix= "VALUES (" suffix= ")" suffixOverrides= "," >
<if test= "status.deviceNo != null" >
#{status.deviceNo,jdbcType=VARCHAR},
</if>
<if test= "status.deviceName != null" >
#{status.deviceName,jdbcType=VARCHAR},
</if>
<if test= "status.deviceStatus != null" >
#{status.deviceStatus,jdbcType=INTEGER},
</if>
<if test= "status.deviceId != null" >
#{status.deviceId,jdbcType=BIGINT},
</if>
<if test= "status.time != null" >
#{status.time,jdbcType=DATE},
</if>
<if test= "status.successRate != null" >
#{status.successRate,jdbcType=VARCHAR},
</if>
<if test= "status.lostRate != null" >
#{status.lostRate,jdbcType=VARCHAR},
</if>
<if test= "status.deviceIp != null" >
#{status.deviceIp,jdbcType=VARCHAR}
</if>
</trim>
</insert>
<sql id= "selectStatus" >
select id, device_no, device_name, device_status, time from status
</sql>
<select id= "listStatus" parameterType= "com.zc.business.domain.Status" resultMap= "BaseResultMap" >
select s.id, s.device_no, s.device_name, s.device_status,s.time, d.device_ip,s.success_rate,s.lost_rate,d.direction,e.manufacturer,e.model,d.facilities_type,d.remark,COALESCE(d.child_type, d.device_type) AS type
from dc_device d
LEFT JOIN status s on (s.device_id=d.id)
LEFT JOIN dc_product e on e.id=d.product_id
<where >
<if test= "status.time != null" >
AND s.time BETWEEN #{status.startTime,jdbcType=DATE} AND #{status.time,jdbcType=DATE}
</if>
<if test= "status.deviceNo != null" >
AND s.device_no = #{status.deviceNo}
</if>
<if test= "status.type != null" >
AND (d.device_type = #{status.type} or d.child_type=#{status.type})
</if>
<if test= "status.deviceId != null" >
AND s.device_id = #{status.deviceId}
</if>
<if test= "status.useState != null and status.useState != 0" >
AND d.use_state = #{status.useState}
</if>
</where>
</select>
<select id= "deviceStatusListById" parameterType= "com.zc.business.domain.Status" resultMap= "BaseResultMap" >
select s.id,s.time,s.success_rate,s.lost_rate
from status s
<where >
<if test= "status.time != null" >
AND s.time BETWEEN #{status.startTime,jdbcType=DATE} AND #{status.time,jdbcType=DATE}
</if>
<if test= "status.deviceId != null" >
AND s.device_id = #{status.deviceId}
</if>
</where>
</select>
</mapper>