liuxiaolong
2019-11-02 046305f178960ad0024f111e7f042e54befc66c7
src/main/java/com/cloud/count/dao/CountDao.java
@@ -23,8 +23,8 @@
     * @return
     */
//    @Select("select COALESCE(sum(enters),0) from people where  timestamp BETWEEN #{begin} AND #{end}")
    @Select("SELECT COALESCE(p2.enters-p1.enters,0) FROM (SELECT enters from people where  timestamp BETWEEN #{begin} AND #{end} ORDER BY id ASC LIMIT 1)p1,(SELECT enters from people where  timestamp BETWEEN #{begin} AND #{end} ORDER BY id DESC LIMIT 1)p2")
    Integer countInPeople(@Param("begin") long begin,@Param("end") long end);
    @Select("SELECT COALESCE(p2.enters-p1.enters,0) FROM (SELECT enters from people where dateStr=#{todayStr} and timestamp BETWEEN #{begin} AND #{end} ORDER BY id ASC LIMIT 1)p1,(SELECT enters from people where dateStr=#{todayStr} and timestamp BETWEEN #{begin} AND #{end} ORDER BY id DESC LIMIT 1)p2")
    Integer countInPeople(@Param("begin") long begin,@Param("end") long end,@Param("todayStr") String todayStr);
    /**
     * 统计出去人数
@@ -32,8 +32,8 @@
     * @return
     */
   // @Select("select COALESCE(sum(exits),0) from people where timestamp BETWEEN #{begin} AND #{end}")
    @Select("SELECT COALESCE(p2.exits-p1.exits,0) FROM (SELECT exits from people where  timestamp BETWEEN #{begin} AND #{end} ORDER BY id ASC LIMIT 1)p1,(SELECT exits from people where  timestamp BETWEEN #{begin} AND #{end} ORDER BY id DESC LIMIT 1)p2")
    Integer countOutPeople( @Param("begin") long begin,@Param("end") long end);
    @Select("SELECT COALESCE(p2.exits-p1.exits,0) FROM (SELECT exits from people where dateStr=#{todayStr} and timestamp BETWEEN #{begin} AND #{end} ORDER BY id ASC LIMIT 1)p1,(SELECT exits from people where dateStr=#{todayStr} and timestamp BETWEEN #{begin} AND #{end} ORDER BY id DESC LIMIT 1)p2")
    Integer countOutPeople( @Param("begin") long begin,@Param("end") long end,@Param("todayStr") String todayStr);
    /**
     * 插入一条People数据
@@ -58,9 +58,9 @@
//    @Select("select * from OldNew where id=1")
//    OldNew getOldNew();
    @Update("update CountState set baseEnters=#{baseEnters},baseExits=#{baseExits},totalEnters=#{totalEnters},totalExits=#{totalExits},realtimeBaseEnters=#{realtimeBaseEnters},realtimeBaseExits=#{realtimeBaseExits},errorCount=#{errorCount}, baseTime=#{baseTime} where id=1")
    @Update("update countstate set baseEnters=#{baseEnters},baseExits=#{baseExits},totalEnters=#{totalEnters},totalExits=#{totalExits},realtimeBaseEnters=#{realtimeBaseEnters},realtimeBaseExits=#{realtimeBaseExits},errorCount=#{errorCount}, baseTime=#{baseTime} where id=1")
    boolean updateCountState(CountState state);
    @Select("select * from CountState where id=1")
    @Select("select * from countstate where id=1")
    CountState getCountState();
}