| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?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.coffee.bus.mapper.BusDeviceMapper">
- <resultMap id="pageQueryResult" type="com.coffee.bus.service.dto.DeviceResult">
- <result column="id" property="id"/>
- <result column="device_id" property="deviceId"/>
- <result column="alias" property="alias"/>
- <result column="type" property="type"/>
- <result column="run_state" property="runState"/>
- <result column="alarm" property="alarm"/>
- <result column="config" property="config" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
- <result column="sim_iccid" property="simIccid"/>
- <result column="sim_mno" property="simMno"/>
- <result column="enable" property="enable"/>
- <result column="status" property="status"/>
- <result column="create_time" property="createTime"/>
- <result column="update_time" property="updateTime"/>
- <result column="tenant_id" property="tenantName" typeHandler="com.coffee.common.config.mybatis.TenantNameHandler"/>
- </resultMap>
- <resultMap id="deviceResult" type="com.coffee.bus.entity.BusDeviceEntity" autoMapping="true">
- <result property="config" column="config" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"></result>
- </resultMap>
- <select id="selectOneByDeviceId" resultMap="deviceResult">
- SELECT * from bus_device
- WHERE device_id = #{deviceId}
- </select>
- <update id="notDelete">
- UPDATE bus_device
- SET is_delete = 0
- WHERE device_id = #{deviceId}
- </update>
- <select id="pageQuery" resultMap="pageQueryResult" parameterType="com.coffee.bus.service.dto.DeviceQuery">
- select
- d.id as id,
- d.device_id as device_id,
- d.alias as alias,
- ifnull(i.type,3) as type,
- i.run_state as run_state,
- i.alarm as alarm,
- d.config as config,
- d.sim_iccid as sim_iccid,
- d.sim_mno as sim_mno,
- d.`enable` as enable,
- d.`status` as `status`,
- d.create_time as create_time,
- d.update_time as update_time,
- d.tenant_id as tenant_id
- from (select * from bus_device
- <where>
- <if test="query.deviceId!=null">
- and device_id like concat('%',#{query.deviceId},'%')
- </if>
- <if test="query.deviceTypes != null and query.deviceTypes.size > 0">
- and type in
- <foreach item="type" index="index" collection="query.deviceTypes" open="(" separator="," close=")">
- #{type, jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.alias!=null">
- and alias like concat('%',#{query.alias},'%')
- </if>
- </where>
- ) AS d
- LEFT JOIN (select * from bus_infusion_history
- <where>
- finished=0
- <if test="query.runStates != null and query.runStates.size > 0">
- and run_state in
- <foreach item="state" index="index" collection="query.runStates" open="(" separator="," close=")">
- #{state, jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.alarms != null and query.alarms.size > 0">
- and alarm in
- <foreach item="alarm" index="index" collection="query.alarms" open="(" separator="," close=")">
- #{alarm, jdbcType=VARCHAR}
- </foreach>
- </if>
- </where>
- ) as i
- on i.device_id=d.device_id
- order by d.create_time desc
- </select>
- </mapper>
|