| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- package com.happy.dao.Impl;
- import com.happy.Model.*;
- import com.happy.Model.Common.Common;
- import com.happy.Model.Tour.TravelSecond;
- import com.happy.Until.TimeExchange;
- import com.happy.dao.SecondBuffertDao;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.jdbc.core.BeanPropertyRowMapper;
- import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
- import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
- import org.springframework.stereotype.Repository;
- import java.util.List;
- @Repository("SecondBuffertDao")
- public class SecondBuffertImplDao implements SecondBuffertDao {
- @Autowired
- private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
- public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {
- return namedParameterJdbcTemplate;
- }
- public void setNamedParameterJdbcTemplate(
- NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
- this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
- }
- public int insertSecondBufferT(SecondBufferT secondBufferT){
- String sql = "insert into secondbuffert(dateT,smT,smT_increase,smLt,red_count,red_increase,yellow_count,yellow_increase,green_count,green_increase) values(:dateT,:smT,:smT_increase,:smLt,:red_count,:red_increase,:yellow_count,:yellow_increase,:green_count,:green_increase)";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("dateT", secondBufferT.getDateT());
- sps.addValue("smT", secondBufferT.getSmT());
- sps.addValue("smT_increase", secondBufferT.getSmT_increase());
- sps.addValue("smLt", secondBufferT.getSmLt());
- sps.addValue("red_count", secondBufferT.getRed_count());
- sps.addValue("red_increase", secondBufferT.getRed_increase());
- sps.addValue("yellow_count", secondBufferT.getYellow_count());
- sps.addValue("yellow_increase", secondBufferT.getYellow_increase());
- sps.addValue("green_count", secondBufferT.getGreen_count());
- sps.addValue("green_increase", secondBufferT.getGreen_increase());
- int num = 0;
- try{
- num = namedParameterJdbcTemplate.update(sql, sps);
- }
- catch(Exception e){
- e.printStackTrace();
- }
- return num;
- }
- // 人数统计
- public int insertSecondBufferC(SecondBufferC secondBufferC){
- String sql = "insert into secondbufferc(dateT,dateTime,smT,smT_increase,smLt,red_count,red_increase,yellow_count,yellow_increase,green_count,green_increase) values(:dateT,:dateTime,:smT,:smT_increase,:smLt,:red_count,:red_increase,:yellow_count,:yellow_increase,:green_count,:green_increase)";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("dateT", secondBufferC.getDateT());
- sps.addValue("dateTime", secondBufferC.getDateTime());
- sps.addValue("smT", secondBufferC.getSmT());
- sps.addValue("smT_increase", secondBufferC.getSmT_increase());
- sps.addValue("smLt", secondBufferC.getSmLt());
- sps.addValue("red_count", secondBufferC.getRed_count());
- sps.addValue("red_increase", secondBufferC.getRed_increase());
- sps.addValue("yellow_count", secondBufferC.getYellow_count());
- sps.addValue("yellow_increase", secondBufferC.getYellow_increase());
- sps.addValue("green_count", secondBufferC.getGreen_count());
- sps.addValue("green_increase", secondBufferC.getGreen_increase());
- int num = 0;
- try{
- num = namedParameterJdbcTemplate.update(sql, sps);
- }
- catch(Exception e){
- e.printStackTrace();
- }
- return num;
- }
- // 第二道防线扫描汇总
- public List<SecondBufferT> querySecondBufferT(){
- String sql = "select * from secondbuffert where id in(select MAX(id) from secondbuffert) ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- List<SecondBufferT> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<SecondBufferT>(SecondBufferT.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线景点当日绿码人数统计
- public List<SecondBufferT> querySpjdGreen(String sm_date){
- String sql = "select IFNULL(SUM(IF(sm_color='绿码',1,0)),0) as green_count from(select * from `sm_message` where sm_date=:sm_date and sm_color='绿码' and sm_place in (select place_name from `secondplace`) group by UUID ) a ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", sm_date);
- List<SecondBufferT> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<>(SecondBufferT.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线扫描汇总------红黄码发热汇总
- public List<SecondBufferT> querySecondBufferRy(){
- String sql = "select IFNULL(SUM(IF(sm_color='红码',1,0)),0) as red_count, IFNULL(SUM(IF(sm_color='黄码',1,0)),0) as yellow_count,IFNULL(SUM(IF(ishot='1',1,0)),0) as hot_count from `sm_message_x` where protect_type='2' and (sm_color in ('红码', '黄码') or ishot='1') and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- List<SecondBufferT> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<SecondBufferT>(SecondBufferT.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线扫描汇总------红黄码发热汇总
- public List<SecondBufferT> querySbRyByDate(String sm_date){
- String sql = "select IFNULL(SUM(IF(sm_color='红码',1,0)),0) as red_count, IFNULL(SUM(IF(sm_color='黄码',1,0)),0) as yellow_count,IFNULL(SUM(IF(ishot='1',1,0)),0) as hot_count from `sm_message_x` where protect_type='2' and (sm_color in ('红码', '黄码') or ishot='1') and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", sm_date);
- List<SecondBufferT> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<SecondBufferT>(SecondBufferT.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 最近7天人员分布
- public List<SecondBufferT> querySecondBufferTLastSeven(){
- String sql = "select * from `secondbuffert` where id in(select id from(select dateT,MAX(id) as id from secondbuffert group by dateT order by dateT desc limit 0, 7) a) ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- List<SecondBufferT> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<SecondBufferT>(SecondBufferT.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线扫码人数汇总
- public List<SecondBufferC> querySecondBufferC(){
- String sql = "select * from `secondbufferc` where id in(select MAX(id) from `secondbufferc`) ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- List<SecondBufferC> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<SecondBufferC>(SecondBufferC.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线处理情况
- public List<Handlde> queryHandler(){
- String sql = "select IFNULL(SUM(IF(handler_state2=0,1,0)),0) as unhandled, IFNULL(SUM(IF(handler_state2=1,1,0)),0) as handled from `sm_message_x` where protect_type='2' and (sm_color in('红码','黄码') or ishot='1') and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- System.out.println(TimeExchange.getDate());
- List<Handlde> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<Handlde>(Handlde.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线发热人员
- public int queryHot(){
- String sql = "select count(*) from `sm_message_x` where ishot='1' and protect_type='2' and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- return namedParameterJdbcTemplate.queryForInt(sql, sps);
- }
- // 第二道防线红码人员详情
- public List<User> queryRed(String startDate, String endDate){
- String sql = "select * from `sm_message_x` where protect_type='2' and sm_color='红码' and sm_date between :startDate and :endDate order by sm_time desc ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("startDate", startDate);
- sps.addValue("endDate", endDate);
- List<User> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<User>(User.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线黄码人员详情
- public List<User> queryYellow(String startDate,String endDate,int page, int rows){
- int start = (page - 1) * rows;// 每页的起始下标
- String sql = "select * from `sm_message_x` where protect_type='2' and sm_color='黄码' and sm_date between :startDate and :endDate order by sm_time desc limit :start,:rows ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("startDate", startDate);
- sps.addValue("endDate", endDate);
- sps.addValue("start", start);
- sps.addValue("rows", rows);
- List<User> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<User>(User.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第一道防线黄码人员总数-分页
- public int queryYellowTotal(String startDate,String endDate){
- String sql = "select count(*) from `sm_message_x` where protect_type='2' and sm_color='黄码' and sm_date between :startDate and :endDate ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("startDate", startDate);
- sps.addValue("endDate", endDate);
- return namedParameterJdbcTemplate.queryForInt(sql, sps);
- }
- // 第二道防线地址类型
- public List<Secondplacetype> queryPt(){
- String sql = "select * from `secondplacetype` ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- List<Secondplacetype> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<Secondplacetype>(Secondplacetype.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线景点名称
- public List<Secondplace> queryJd(){
- String sql = "select * from `secondplace` ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- List<Secondplace> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<Secondplace>(Secondplace.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 第二道防线景点名称
- public List<Secondplace> queryJdByname(String place_name){
- String sql = "select * from `secondplace` where place_name like :place_name ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("place_name", "%"+place_name+"%");
- List<Secondplace> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<Secondplace>(Secondplace.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- //插入TravelSecond
- public int insertTravelSecond(TravelSecond travelSecond,String dayId){
- String sql = "SELECT * from travel_second where place_name = :place_name and day_id= :dayId limit 1";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("place_name", travelSecond.getPlaceName());
- sps.addValue("place_id", travelSecond.getPlaceId());
- sps.addValue("dayNum", travelSecond.getDayNum());
- sps.addValue("totalNum", travelSecond.getTotalNum());
- sps.addValue("maxValue", travelSecond.getMaxValue());
- sps.addValue("dayId", dayId);
- List<TravelSecond> travelSecondList= namedParameterJdbcTemplate.query(sql, sps, new BeanPropertyRowMapper<>(TravelSecond.class));
- if(travelSecondList==null||travelSecondList.size()<1){
- sql = "INSERT INTO `travel_second`(`place_name`, `dayNum`, `totalNum`, `maxValue`,day_id,place_id) VALUES (:place_name,:dayNum, :totalNum, :maxValue,:dayId,:place_id)";
- }else {
- sps.addValue("id", travelSecondList.get(0).getId());
- sql = "update travel_second set dayNum = :dayNum, totalNum = :totalNum,`maxValue` = :maxValue where id = :id";
- }
- int num = 0;
- try{
- num = namedParameterJdbcTemplate.update(sql, sps);
- }
- catch(Exception e){
- e.printStackTrace();
- }
- return num;
- }
- public TravelSecond queryTravelSecond(String place_name){
- String sql = "SELECT * from travel_second where place_name = :place_name and day_id= :dayId limit 1";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("place_name", place_name);
- sps.addValue("dayId", TimeExchange.getDate());
- List<TravelSecond> travelSecondList= namedParameterJdbcTemplate.query(sql, sps, new BeanPropertyRowMapper<>(TravelSecond.class));
- if(travelSecondList!=null&&travelSecondList.size()>0){
- return travelSecondList.get(0);
- }
- return null;
- }
- // 第二道防线各场所详情
- public SecondPlaceJc querySpjc(String place_type){
- String sql = "select IFNULL(SUM(IF(sm_color='红码',1,0)),0) as red_count,IFNULL(SUM(IF(sm_color='黄码',1,0)),0) as yellow_count,IFNULL(SUM(IF(ishot='1',1,0)),0) as hot_count,IFNULL(SUM(IF(iskey='1',1,0)),0) as key_count from `sm_message_x` where place_type=:place_type and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("place_type", place_type);
- sps.addValue("sm_date", TimeExchange.getDate());
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 第二道防线亮码详情
- public SecondPlaceJc querySl(){
- String sql = "select IFNULL(SUM(IF(sm_color='红码',1,0)),0) as red_count,IFNULL(SUM(IF(sm_color='黄码',1,0)),0) as yellow_count,IFNULL(SUM(IF(ishot='1',1,0)),0) as hot_count,IFNULL(SUM(IF(iskey='1',1,0)),0) as key_count from `sm_message_x` where sm_type='亮码' and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 第二道防线亮码绿码详情
- public SecondPlaceJc querySlGreen(){
- String sql = "select IFNULL(COUNT(distinct UUID,sm_date,protect_type),0) as green_count from `sm_message` where sm_color='绿码' and sm_type='亮码' and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 第二道防线各景点详情
- public SecondPlaceJc querySpjd(){
- String sql = "select IFNULL(SUM(IF(sm_color='红码',1,0)),0) as red_count,IFNULL(SUM(IF(sm_color='黄码',1,0)),0) as yellow_count,IFNULL(SUM(IF(ishot='1',1,0)),0) as hot_count,IFNULL(SUM(IF(iskey='1',1,0)),0) as key_count from `sm_message_x` where sm_place in (select place_name from `secondplace`) and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 各酒店医院详细名称
- public List<Common> queryCommon(String place_type){
- String sql = "select distinct hotel as common from `sm_message` where sm_date=:sm_date and place_type=:place_type ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- sps.addValue("place_type", place_type);
- List<Common> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<>(Common.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 根据详细名称查红黄码详情
- public SecondPlaceJc queryByCommon(String place_type,String hotel){
- String sql = "select IFNULL(SUM(IF(sm_color='红码',1,0)),0) as red_count,IFNULL(SUM(IF(sm_color='黄码',1,0)),0) as yellow_count,IFNULL(SUM(IF(ishot='1',1,0)),0) as hot_count,IFNULL(SUM(IF(iskey='1',1,0)),0) as key_count from `sm_message_x` where sm_date=:sm_date and place_type=:place_type and hotel=:hotel ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- sps.addValue("place_type", place_type);
- sps.addValue("hotel", hotel);
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 第二道防线各场所绿码详情
- public SecondPlaceJc queryGreen(String place_type){
- String sql = "select IFNULL(COUNT(distinct UUID,sm_date,protect_type),0) as green_count from `sm_message` where sm_color='绿码' and place_type=:place_type and sm_date=:sm_date ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("place_type", place_type);
- sps.addValue("sm_date", TimeExchange.getDate());
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 第二道防线各门店绿码详情
- public SecondPlaceJc queryGreenByCommon(String place_type,String hotel){
- String sql = "select IFNULL(COUNT(distinct UUID,sm_date,protect_type),0) as green_count from `sm_message` where sm_color='绿码' and place_type=:place_type and sm_date=:sm_date and hotel=:hotel ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("place_type", place_type);
- sps.addValue("sm_date", TimeExchange.getDate());
- sps.addValue("hotel", hotel);
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 第二道防线发热加时间搜索
- public List<User> queryByTime(int page, int rows,String sqlx){
- int start = (page - 1) * rows;// 每页的起始下标
- String sql = "select * from `sm_message_x` where protect_type='2' and ishot='1' " + sqlx +" order by sm_time desc limit :start,:rows ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("start", start);
- sps.addValue("rows", rows);
- List<User> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<User>(User.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 查询用户表中的总记录数
- public int findUsersTotal(String s1) {
- String sql = "select count(*) from `sm_message_x` where protect_type='2' and ishot='1' "+s1;
- MapSqlParameterSource sps = new MapSqlParameterSource();
- return namedParameterJdbcTemplate.queryForInt(sql, sps);
- }
- // 第二道防线累积加时间搜索
- public List<User> queryLjByTime(int page, int rows,String sqlx){
- int start = (page - 1) * rows;// 每页的起始下标
- String sql = "select * from `sm_message_x` where protect_type='2' " + sqlx +" order by sm_time desc limit :start,:rows ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("start", start);
- sps.addValue("rows", rows);
- List<User> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<User>(User.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 查询用户表中的累积总记录数
- public int findLjUsersTotal(String s1) {
- String sql = "select count(*) from `sm_message_x` where protect_type='2' "+s1;
- MapSqlParameterSource sps = new MapSqlParameterSource();
- return namedParameterJdbcTemplate.queryForInt(sql, sps);
- }
- // 第二道防线累积红黄码详情
- public SecondPlaceJc queryLjRy(){
- String sql = "select IFNULL(SUM(IF(sm_color='红码',1,0)),0) as red_count,IFNULL(SUM(IF(sm_color='黄码',1,0)),0) as yellow_count,IFNULL(SUM(IF(ishot='1',1,0)),0) as hot_count from `sm_message_x` where protect_type='2' ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", TimeExchange.getDate());
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 第二道防线累积绿码详情
- public SecondPlaceJc queryLjGreen(){
- String sql = "select IFNULL(COUNT(distinct UUID,sm_date,protect_type),0) as green_count from `sm_message` where sm_color='绿码' and protect_type='2' ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<>(SecondPlaceJc.class));
- }
- // 各景点日、月、年统计
- public Tz queryView(String sm_place){
- String sql = "select IFNULL(SUM(IF(sm_date=:sm_day,1,0)),0) as daycount, IFNULL(SUM(IF(sm_date like :sm_month, 1,0)),0) as monthcount,IFNULL(SUM(IF(sm_date like :sm_year, 1,0)),0) as yearcount from `sm_message` where sm_place=:sm_place ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_day", TimeExchange.getDate());
- sps.addValue("sm_month", TimeExchange.getMonth()+"%");
- sps.addValue("sm_year", TimeExchange.getYear()+"%");
- sps.addValue("sm_place", sm_place);
- return namedParameterJdbcTemplate.queryForObject(sql,sps,new BeanPropertyRowMapper<Tz>(Tz.class));
- }
- /** =================昨日累积缓存 =============================**/
- // 第二道防线昨日累积扫描汇总
- public SecondBufferT querySbYesLj(String sm_date){
- String sql = "select COUNT(*) as smT from (select * from `sm_message` where protect_type=2 and sm_date=:sm_date group by UUID ) a ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("sm_date", sm_date);
- List<SecondBufferT> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<SecondBufferT>(SecondBufferT.class));
- if (list != null && list.size() > 0) {
- return list.get(0);
- }
- return null;
- }
- // 第二道防线查询缓存数据
- public List<SecondBufferT> querySbCache(String dateT){
- String sql = "select * from `secondbuffert` where dateT=:dateT ";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("dateT", dateT);
- List<SecondBufferT> list = namedParameterJdbcTemplate.query(sql, sps,
- new BeanPropertyRowMapper<SecondBufferT>(SecondBufferT.class));
- if (list != null && list.size() > 0) {
- return list;
- }
- return null;
- }
- // 插入缓存
- public int insertSbT(SecondBufferT secondBufferT){
- String sql = "insert into secondbuffert(dateT,smT,smT_increase,smLt,red_count,red_increase,yellow_count,yellow_increase,green_count,green_increase) values(:dateT,:smT,:smT_increase,:smLt,:red_count,:red_increase,:yellow_count,:yellow_increase,:green_count,:green_increase)";
- MapSqlParameterSource sps = new MapSqlParameterSource();
- sps.addValue("dateT", secondBufferT.getDateT());
- sps.addValue("smT", secondBufferT.getSmT());
- sps.addValue("smT_increase", secondBufferT.getSmT_increase());
- sps.addValue("smLt", secondBufferT.getSmLt());
- sps.addValue("red_count", secondBufferT.getRed_count());
- sps.addValue("red_increase", secondBufferT.getRed_increase());
- sps.addValue("yellow_count", secondBufferT.getYellow_count());
- sps.addValue("yellow_increase", secondBufferT.getYellow_increase());
- sps.addValue("green_count", secondBufferT.getGreen_count());
- sps.addValue("green_increase", secondBufferT.getGreen_increase());
- int num = 0;
- try{
- num = namedParameterJdbcTemplate.update(sql, sps);
- }
- catch(Exception e){
- e.printStackTrace();
- }
- return num;
- }
- }
|