<?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="org.dromara.system.mapper.TblCountDataMapper">


    <insert id="insertdata" parameterType="org.dromara.system.domain.CountData">
        INSERT INTO "${devicecode}" USING count_data TAGS (#{devicecode}, 1) VALUES (#{tslong}, #{incount}, #{outcount});
    </insert>
    <select id="selectdatabydate" parameterType="java.util.Map" resultType="org.dromara.system.domain.vo.CountDataVo">
        <![CDATA[
        SELECT sum(incount) as incount,sum(outcount) as outcount FROM count_data WHERE ts > #{start} AND ts < #{end}
        ]]>
        <if test="devicecodes != null and devicecodes != ''">
        <![CDATA[
        AND devicecode in (${devicecodes})
        ]]>
        </if>
    </select>

</mapper>
