package com.cloud.count.dao;
|
import com.cloud.count.model.Config;
|
import com.cloud.count.model.CountState;
|
import com.cloud.count.model.People;
|
import org.apache.ibatis.annotations.*;
|
import org.springframework.stereotype.Repository;
|
import java.util.List;
|
|
@Repository
|
@Mapper
|
public interface CountDao {
|
/**
|
* 查询进出信息
|
*
|
* @return
|
*/
|
@Select("select * from people where timestamp< #{end} and timestamp>#{begin}")
|
List<People> listPeoples( @Param("begin") long begin,@Param("end") long end);
|
|
/**
|
* 统计进入人数
|
*
|
* @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 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);
|
|
/**
|
* 统计出去人数
|
*
|
* @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 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数据
|
* @param people
|
* @return
|
*/
|
@Insert("INSERT INTO people(dateStr, startTime, endTime, enters,exits,timestamp) VALUES(#{dateStr},#{startTime},#{endTime},#{enters},#{exits},#{timestamp})")
|
boolean savePeople(People people);
|
|
@Update("update config set initialTime =#{initialTime},password=#{password},initialPeople=#{initialPeople},correctionPeople=#{correctionPeople},countStartTime=#{countStartTime},init=#{init},cor=#{cor} where id=1")
|
boolean updateConfig(Config config);
|
|
@Select("select * from config where id=1")
|
Config getConfig();
|
|
@Delete("truncate TABLE people")
|
void reset();
|
|
// @Update("update OldNew set oldin =#{oldin},oldout=#{oldout},realoldin=#{realoldin},realoldout=#{realoldout} where id=1")
|
// boolean updateOldNew(OldNew OldNew);
|
|
// @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")
|
boolean updateCountState(CountState state);
|
|
@Select("select * from CountState where id=1")
|
CountState getCountState();
|
}
|