<?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.GasCommonMapper">
    <insert id="saveHuiHAisInfo" parameterType="huiHAisInfo">
        insert into ais_ship_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="ship_no != null">ship_no,</if>
            <if test="mmsi != null">mmsi,</if>
            <if test="speed != null">speed,</if>
            <if test="head != null">head,</if>
            <if test="rate != null">rate,</if>
            <if test="course != null">course,</if>
            <if test="tel != null">tel,</if>
            <if test="power != null">power,</if>
            <if test="lat != null">lat,</if>
            <if test="lng != null">lng,</if>
            <if test="ship_id != null">ship_id,</if>
            <if test="receive != null">receive,</if>
            <if test="length != null">length,</if>
            <if test="shipname_cn != null">shipname_cn,</if>
            <if test="ship_type != null">ship_type,</if>
            <if test="ship_reg_no != null">ship_reg_no,</if>
            <if test="depth != null">depth,</if>
            <if test="draught != null">draught,</if>
            <if test="width != null">width,</if>
            <if test="ship_type_code != null">ship_type_code,</if>
            <if test="shipname != null">shipname,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="ship_no != null">#{ship_no},</if>
            <if test="mmsi != null">#{mmsi},</if>
            <if test="speed != null">#{speed},</if>
            <if test="head != null">#{head},</if>
            <if test="rate != null">#{rate},</if>
            <if test="course != null">#{course},</if>
            <if test="tel != null">#{tel},</if>
            <if test="power != null">#{power},</if>
            <if test="lat != null">#{lat},</if>
            <if test="lng != null">#{lng},</if>
            <if test="ship_id != null">#{ship_id},</if>
            <if test="receive != null">#{receive},</if>
            <if test="length != null">#{length},</if>
            <if test="shipname_cn != null">#{shipname_cn},</if>
            <if test="ship_type != null">#{ship_type},</if>
            <if test="ship_reg_no != null">#{ship_reg_no},</if>
            <if test="depth != null">#{depth},</if>
            <if test="draught != null">#{draught},</if>
            <if test="width != null">#{width},</if>
            <if test="ship_type_code != null">#{ship_type_code},</if>
            <if test="shipname != null">#{shipname},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <select id="querySemInstrument" resultType="java.util.Map">
        select id,
               name,
               ip,
               longitude,
               latitude,
               remark,
               pattern,
               windDirection,
               windSpeed,
               spreadTime,
               delayTime,
               sMax,
               relyMmsi,
               relyShow,
               radius,
               pMode,
               nFlag,
               sensitiveType,
               autoType,
               category
        from ${table}
    </select>

    <select id="queryIllegalShip" resultType="java.util.Map">
        select t1.id,
               sem_id                                          semId,
               t2.Name                                         semName,
               t2.Category                                     monitorPointName,
               s_percent                                       sPercent,
               n_percent                                       nPercent,
               date_format(peak_time, '%Y-%m-%d %H:%i:%S')  as peakTime,
               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_name                                       shipName,
               error,
               distance,
               t1.wind_speed                                as windSpeed,
               wind_angle                                      windAngle,
               confirmed
        from illegal_ship t1
                 left join sem_instrument t2 on t1.sem_id = t2.id
    </select>

    <select id="queryShipRecognition" resultType="java.util.Map">
        select id,
        createBy,
        date_format(createTime,'%Y-%m-%d %H:%i:%S') as createTime,
        updateBy,
        date_format(updateTime,'%Y-%m-%d %H:%i:%S') as updateTime,
        aisDist,
        aisDrt,
        aisDst,
        aisMmsi,
        aisShipLen,
        aisShipName,
        aisShipSpd,
        aisShipType,
        aisShipWidth,
        isAbnormalSize,
        latitude,
        rcgSoot,
        lockSeq,
        longitude,
        rcgCargoType,
        rcgDeadweightTon,
        rcgDist,
        rcgDrt,
        rcgIsFleet,
        rcgLoadSts,
        rcgShipHeightAboveWater,
        rcgShipLen,
        rcgShipName,
        rcgShipSpd,
        rcgShipType,
        rcgShipWidth,
        regportName,
        remark,
        snapImPath,
        snapPos,
        snapTime,
        snapTimeFmt,
        status,
        textFeatureLabel,
        textImgUrl,
        rcgShipTypeDetail,
        useWarn,
        warnLabelList,
        qrcode,
        shipNameDirection,
        shipNameValid,
        sootFeatureLabel,
        sootImgUrl
        from ship_recognition
        <where>
            <if test="syncPost.startTime != null and syncPost.startTime != ''">
                createTime &gt;= #{syncPost.startTime}
            </if>
            <if test="syncPost.endTime != null and syncPost.endTime != ''">
                createTime &lt;= #{syncPost.endTime}
            </if>
        </where>
    </select>

    <select id="queryAlert" resultType="java.util.Map">
        select t1.id,
        monitor_point_id monitorPointId,
        t2.name monitorPointName,
        t1.mmsi,
        t1.device_id as deviceId,
        t3.name shipName,
        t3.destination,
        t1.no2_concentration no2Concentration,
        t1.so2_concentration so2Concentration,
        t1.co2_concentration co2Concentration,
        so2_percent so2Percent,
        date_format(create_time, '%Y-%m-%d %H:%i:%S') as createTime
        from alert t1
        left join monitor_point t2 on t1.monitor_point_id = t2.id
        left join ship_static_info t3 on t1.mmsi = t3.mmsi
        <where>
            <if test="syncPost.startTime != null and syncPost.startTime != ''">
                create_time &gt;= #{syncPost.startTime}
            </if>
            <if test="syncPost.endTime != null and syncPost.endTime != ''">
                create_time &lt;= #{syncPost.endTime}
            </if>
        </where>
    </select>

    <select id="queryMonitorPoint" resultType="java.util.Map">
        select id,
               name,
               organization,
               longitude,
               latitude,
               remark
        from monitor_point
    </select>

    <select id="queryShipStaticInfo" resultType="java.util.Map">
        select id,
               MMSI,
               name,
               type,
            size,
            destination,
            ETA,
            IMO
        from ship_static_info
    </select>

</mapper>