<?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.ruoyi.system.mapper.AisDatabaseMapper">

    <select id="queryDeviceStatic" resultType="java.util.Map">
        select Category point, count(1) count
        from sem_instrument
        where Category is not null
        group by Category;
    </select>

    <select id="queryDeviceCount" resultType="java.lang.Integer">
        select count(1)
        from sem_instrument
        where Category is not null
    </select>

    <select id="queryDeviceList" resultType="com.ruoyi.system.domain.DeviceBo">
        select id                               as deviceId,
               concat(Longitude, ',', Latitude) as latilongti,
               Remark                           as name,
               Category                         as monitorName,
               case Status
                   when 1 then '在线'
                   when 0 then '离线'
                   end                             status,
               'ais'                            as deviceType,
               now()                            as updateTime,
               'ais_illegal_ship'               as source
        from sem_instrument
        where Category is not null
    </select>

    <select id="queryById" resultType="java.util.Map">
        select id,
               sem_id                                          semId,
               s_percent                                       sPercent,
               s_percent                                       so2Percent,
               n_percent                                       nPercent,
               date_format(peak_time, '%Y-%m-%d %H:%i:%s')  as peakTime,
               date_format(peak_time, '%Y-%m-%d %H:%i:%s')  as createTime,
               date_format(start_time, '%Y-%m-%d %H:%i:%s') as startTime,
               date_format(end_time, '%Y-%m-%d %H:%i:%s')   as endTime,
               ship_mmsi                                       shipMmsi,
               ship_mmsi                                       mmsi,
               ship_name                                       shipName,
               error,
               distance,
               wind_speed                                      windSpeed,
               wind_angle                                      windAngle,
               confirmed
        from illegal_ship
        where id = #{id}
    </select>
</mapper>