cjl
2025-01-06 8490eb11583ffdc586436f165860de5cfc39f915
screen-api/src/main/resources/mapper/HistorySecondCruiserMapper.xml
@@ -20,4 +20,70 @@
        ORDER BY `time`
    </select>
    <select id="getCruiserData" resultType="java.util.Map">
        SELECT
        DATE_FORMAT(`time`, #{dateFormat}) AS `time`,
        `value`
        FROM `history_second_cruiser`
        WHERE mac = #{mac}
        AND `time` <![CDATA[>=]]> #{time1}
        AND `time` <![CDATA[<=]]> #{time2}
        AND organization_id = #{orgId}
    </select>
    <select id="getCruiserDataNewAvg" resultType="com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserListDTO">
        select  DATE_FORMAT(`time`, #{dateFormat}) AS time,value ->>'$.flylat' as flyLat,value ->>'$.flylon' as flyLon ,
           value ->> #{type} as num
        from history_second_cruiser
        WHERE mac = #{mac}
          AND `time` <![CDATA[>=]]> #{time1}
          AND `time` <![CDATA[<=]]> #{time2}
        <if test="orgId !=null and orgId != 0">
            AND organization_id = #{orgId}
        </if>
        <if test="orgIds != null and orgIds.size !=0">
            and organization_id in
            <foreach collection="orgIds" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
        order by time
    </select>
    <select id="getDaily" resultType="java.lang.String">
        select AVG(JSON_EXTRACT(value,'$.dustld'))
        from `history_second_cruiser`
        WHERE mac = #{mac}
          AND `time` <![CDATA[>=]]> #{time1}
          AND `time` <![CDATA[<=]]> #{time2}
    </select>
    <select id="getDust" resultType="java.lang.String">
        select value ->>'$.dustld'
        from `history_second_cruiser`
        WHERE mac = #{mac}
          AND `time` <![CDATA[>=]]> #{start}
          AND `time` <![CDATA[<=]]> #{end}
    </select>
    <select id="getAllCruiserData" resultType="java.util.Map">
        SELECT
        `value`
        FROM `history_second_cruiser`
        WHERE mac = #{mac}
        AND `time` <![CDATA[>=]]> #{time1}
        AND `time` <![CDATA[<=]]> #{time2}
    </select>
    <select id="getDusts" resultType="java.util.Map">
        SELECT
            value ->>'$.flylat' as flyLat,value ->>'$.flylon' as flyLon,value ->>'$.dustld' as dustld,
            `time`
        FROM `history_second_cruiser`
        WHERE mac = #{mac}
          AND `time` <![CDATA[>=]]> #{startTime}
          AND `time` <![CDATA[<=]]> #{endTime}
    </select>
</mapper>