|
@@ -0,0 +1,913 @@
|
|
|
|
|
+package com.happy.dao.Impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.happy.Model.Message_handler;
|
|
|
|
|
+import com.happy.Model.Secondplace;
|
|
|
|
|
+import com.happy.Model.Tour.CommonSql;
|
|
|
|
|
+import com.happy.Model.Tour.Hotel;
|
|
|
|
|
+import com.happy.Model.Tour.TourDayt;
|
|
|
|
|
+import com.happy.Model.Tour.Tourx;
|
|
|
|
|
+import com.happy.Model.Travel.*;
|
|
|
|
|
+import com.happy.Model.User;
|
|
|
|
|
+import com.happy.Until.TimeExchange;
|
|
|
|
|
+import com.happy.dao.TourDao;
|
|
|
|
|
+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;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+@Repository("TourDao")
|
|
|
|
|
+public class TourImplDao implements TourDao {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
|
|
|
|
+
|
|
|
|
|
+ public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {
|
|
|
|
|
+ return namedParameterJdbcTemplate;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setNamedParameterJdbcTemplate(
|
|
|
|
|
+ NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
|
|
|
|
|
+ this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 今日旅游人数
|
|
|
|
|
+ public TourDayt queryTotalTour(String sm_date){
|
|
|
|
|
+ String sql = "SELECT 'DATETIME' AS dateTime, COUNT(DISTINCT(UUID)) AS num FROM `sm_message` WHERE sm_date LIKE :sm_date AND protect_type =2 ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date);
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForObject(sql, sps,new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 本-月-年旅游人数
|
|
|
|
|
+ public TourDayt queryTotalTourOther(String sm_date){
|
|
|
|
|
+ String sql = "SELECT 'DATETIME' AS dateTime, COUNT(DISTINCT(UUID)) AS num FROM `sm_message` WHERE sm_date LIKE :sm_date AND protect_type =2 ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date+"%");
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForObject(sql, sps,new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 往日旅游人数
|
|
|
|
|
+ public TourDayt queryLastTour(String dateTime){
|
|
|
|
|
+ String sql = "select dateTime,ifnull(sum(num),0) as num from `tourdayt` where dateTime=:dateTime ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime);
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 往-月-年旅游人数
|
|
|
|
|
+ public TourDayt queryLastTourOther(String dateTime){
|
|
|
|
|
+ String sql = "select dateTime,ifnull(sum(num),0) as num from `tourdayt` where dateTime like :dateTime ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime+"%");
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-天-判断是否存在
|
|
|
|
|
+ public List<TourDayt> queryTourByDay(String dateTime){
|
|
|
|
|
+ String sql = "select * from `tourdayt` where dateTime=:dateTime ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime);
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-天-判断是否存在
|
|
|
|
|
+ public List<TourDayt> queryTourByOther(String dateTime){
|
|
|
|
|
+ String sql = "select * from `tourdayt` where dateTime like :dateTime ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime+"%");
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertToday(TourDayt tourDayt){
|
|
|
|
|
+ String sql = "insert into `tourdayt`(dateTime,num) values(:dateTime,:num)";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", tourDayt.getDateTime());
|
|
|
|
|
+ sps.addValue("num", tourDayt.getNum());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询景点累计数据
|
|
|
|
|
+ public TourDayt queryTourT(){
|
|
|
|
|
+ String sql = "select sum(num) as num from `tourdayt` where dateTime is not null ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询景点每日数据
|
|
|
|
|
+ public TourDayt queryTourDay(){
|
|
|
|
|
+ String sql = "select sm_date as dateTime,COUNT(*) as num from (select * from `sm_message` where sm_date=:sm_date "+ CommonSql.sql2 +" group by UUID ) a ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", TimeExchange.getDate());
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForObject(sql, sps,new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**==================缓存二================**/
|
|
|
|
|
+ // 今日某景点游客
|
|
|
|
|
+ public TravelT queryDayAndPlace(String sm_date,String sm_place){
|
|
|
|
|
+ String sql = "select sm_date as dateTime,sm_place as place,COUNT(*) as inCount from `sm_message` where sm_date=:sm_date and sm_place=:sm_place group by uuid ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date);
|
|
|
|
|
+ sps.addValue("sm_place", sm_place);
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-天-判断是否存在
|
|
|
|
|
+ public List<TravelT> queryDayAndPlaceExis(String dateTime,String place){
|
|
|
|
|
+ String sql = "select * from `travelt` where dateTime=:dateTime and place=:place ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime);
|
|
|
|
|
+ sps.addValue("place", place);
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertTodayAndPlace(TravelT travelT){
|
|
|
|
|
+ String sql = "insert into `travelt`(dateTime,place,inCount) values(:dateTime,:place,:inCount)";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelT.getDateTime());
|
|
|
|
|
+ sps.addValue("place", travelT.getPlace());
|
|
|
|
|
+ sps.addValue("inCount", travelT.getInCount());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各景点当日人流
|
|
|
|
|
+ public List<TravelT> queryTravelT(){
|
|
|
|
|
+ String sql = "select b.place_name as place,:sm_date as dateTime,ifnull(a.num,0) as inCount from (select sm_place as place,sm_date as dateTime,COUNT(*) as num from (select * from `sm_message` where sm_date=:sm_date "+ CommonSql.sql2 +" group by UUID,sm_place ) a group by sm_place ) a right join `secondplace` b on a.place=b.place_name ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", TimeExchange.getDate());
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 查询缓存日旅游统计
|
|
|
|
|
+ public List<TourDayt> queryTour(){
|
|
|
|
|
+ String sql = "select * from `tourdayt` order by dateTime desc limit 0,7 ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 分页查找景区每日人数
|
|
|
|
|
+ public List<TourDayt> queryTourPage(int page, int rows,String sqlx){
|
|
|
|
|
+ int start = (page - 1) * rows;// 每页的起始下标
|
|
|
|
|
+ String sql = "select * from `tourdayt` where 1=1 "+sqlx+" order by dateTime desc limit :start,:rows ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("start", start);
|
|
|
|
|
+ sps.addValue("rows", rows);
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 分页查找景区每日人数
|
|
|
|
|
+ public int queryTourPaget(String sqlx){
|
|
|
|
|
+ String sql = "select count(*) from `tourdayt` where 1=1 " + sqlx;
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**================月=======================**/
|
|
|
|
|
+ // 本月旅游人数
|
|
|
|
|
+ public TourDayt queryMonthTour(String sm_date){
|
|
|
|
|
+ String sql = "select SUBSTR(dateTime,1,7) as dateTime, SUM(num) as num from `tourdayt` where dateTime like :sm_date ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date+"%");
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForObject(sql, sps,new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-月-判断是否存在
|
|
|
|
|
+ public List<TourDayt> queryTourByMonth(String dateTime){
|
|
|
|
|
+ String sql = "select * from `tourdayw` where dateTime=:dateTime ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime);
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertMonth(TourDayt tourDayt){
|
|
|
|
|
+ String sql = "insert into `tourdayw`(dateTime,num) values(:dateTime,:num)";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", tourDayt.getDateTime());
|
|
|
|
|
+ sps.addValue("num", tourDayt.getNum());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存月旅游统计
|
|
|
|
|
+ public List<TourDayt> queryTourM(){
|
|
|
|
|
+ String sql = "select * from `tourdayw` order by dateTime desc limit 0,7 ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**================年=======================**/
|
|
|
|
|
+ // 本年旅游人数
|
|
|
|
|
+ public TourDayt queryYearTour(String sm_date){
|
|
|
|
|
+ String sql = "select SUBSTR(dateTime,1,4) as dateTime, SUM(num) as num from `tourdayt` where dateTime like :sm_date ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date+"%");
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForObject(sql, sps,new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-年-判断是否存在
|
|
|
|
|
+ public List<TourDayt> queryTourByYear(String dateTime){
|
|
|
|
|
+ String sql = "select * from `tourdayy` where dateTime=:dateTime ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime);
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertYear(TourDayt tourDayt){
|
|
|
|
|
+ String sql = "insert into `tourdayy`(dateTime,num) values(:dateTime,:num)";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", tourDayt.getDateTime());
|
|
|
|
|
+ sps.addValue("num", tourDayt.getNum());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存月旅游统计
|
|
|
|
|
+ public List<TourDayt> queryTourY(){
|
|
|
|
|
+ String sql = "select * from `tourdayy` order by dateTime desc limit 0,7 ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**================各省-年月日统计=================**/
|
|
|
|
|
+ // 各省日统计
|
|
|
|
|
+ public List<TravelProvin> queryTourProvince(String sm_date){
|
|
|
|
|
+ String sql = "select sm_date as dateTime,sm_from as province,COUNT(*) as num from (select * from `sm_message` where sm_date=:sm_date and sm_from!='江西省' and sm_from!='江西' and sm_from!='36' "+ CommonSql.sql2 +" group by UUID ) a group by sm_from order by num desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date);
|
|
|
|
|
+ List<TravelProvin> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelProvin.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-省-判断是否存在
|
|
|
|
|
+ public List<TravelProvin> queryTourByProvince(TravelProvin travelProvin){
|
|
|
|
|
+ String sql = "select * from `travelprovin` where dateTime=:dateTime and province=:province ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelProvin.getDateTime());
|
|
|
|
|
+ sps.addValue("province",travelProvin.getProvince());
|
|
|
|
|
+ List<TravelProvin> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelProvin.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertProvince(TravelProvin travelProvin){
|
|
|
|
|
+ String sql = "insert into `travelprovin`(dateTime,province,num,pro_lei) values(:dateTime,:province,:num,:pro_lei) ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelProvin.getDateTime());
|
|
|
|
|
+ sps.addValue("province",travelProvin.getProvince());
|
|
|
|
|
+ sps.addValue("num", travelProvin.getNum());
|
|
|
|
|
+ sps.addValue("pro_lei", travelProvin.getPro_lei());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各省月-年统计
|
|
|
|
|
+ public List<TravelProvin> queryTourProvinceM(String sm_date){
|
|
|
|
|
+ String sql = "select province,SUM(num) as num from `travelprovin` where dateTime like :sm_date group by province order by num desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date+"%");
|
|
|
|
|
+ List<TravelProvin> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelProvin.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各省月-累计统计
|
|
|
|
|
+ public List<TravelProvin> queryTourProvinceT(){
|
|
|
|
|
+ String sql = "select province,SUM(num) as num from `travelprovin` group by province order by num desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TravelProvin> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelProvin.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**====================近12小时人次记录===================**/
|
|
|
|
|
+ // 每小时人次
|
|
|
|
|
+ public TourDayt queryTotalHour(String sm_time){
|
|
|
|
|
+ String sql = "select sm_date as dateTime,COUNT(*) as num from (select * from `sm_message` where sm_time like :sm_time "+ CommonSql.sql2 +" group by UUID ) a ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_time", sm_time+"%");
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForObject(sql, sps,new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 缓存是否存在
|
|
|
|
|
+ public TourDayt queryExistHour(String sm_time){
|
|
|
|
|
+ String sql = "select * from `tourhourt` where `dateTime`=:sm_time ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_time", sm_time);
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 插入缓存
|
|
|
|
|
+ public int insertHour(TourDayt tourDayt){
|
|
|
|
|
+ String sql = "insert into `tourhourt`(dateTime,num) values(:dateTime,:num) ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", tourDayt.getDateTime());
|
|
|
|
|
+ sps.addValue("num", tourDayt.getNum());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询日12小时趋势
|
|
|
|
|
+ public List<TourDayt> queryHourHistory(String sm_date,String sm_time, int m){
|
|
|
|
|
+ String sql = "select `dateTime`,`num` from `tourhourt` where `dateTime` like :sm_date and `dateTime` < :sm_time GROUP BY `dateTime` order by `dateTime` desc limit 0,:m ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date+" %");
|
|
|
|
|
+ sps.addValue("sm_time", sm_time);
|
|
|
|
|
+ sps.addValue("m", m);
|
|
|
|
|
+ List<TourDayt> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TourDayt.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**================性别统计=======================**/
|
|
|
|
|
+ // 每日男女性统计
|
|
|
|
|
+ public TravelGender queryTourGenderD(String sm_date,String sm_gender){
|
|
|
|
|
+ String sql = "select sm_date as dateTime, sm_gender as gender,COUNT(*) as num from(select * from `sm_message` where sm_date=:sm_date and sm_gender=:sm_gender "+CommonSql.sql+" group by UUID ) a ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date);
|
|
|
|
|
+ sps.addValue("sm_gender", sm_gender);
|
|
|
|
|
+ List<TravelGender> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelGender.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-性别-判断是否存在
|
|
|
|
|
+ public List<TravelGender> queryTourByGender(TravelGender travelGender){
|
|
|
|
|
+ String sql = "select * from `travelgender` where dateTime=:dateTime and gender=:gender ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelGender.getDateTime());
|
|
|
|
|
+ sps.addValue("gender",travelGender.getGender());
|
|
|
|
|
+ List<TravelGender> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelGender.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertGender(TravelGender travelGender){
|
|
|
|
|
+ String sql = "insert into `travelgender`(dateTime,gender,num) values(:dateTime,:gender,:num) ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelGender.getDateTime());
|
|
|
|
|
+ sps.addValue("gender",travelGender.getGender());
|
|
|
|
|
+ sps.addValue("num", travelGender.getNum());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 男女性别年统计
|
|
|
|
|
+ public List<TravelGender> queryTourByGenderAndYear(String dateTime){
|
|
|
|
|
+ String sql = "select gender,SUM(num) as num from `travelgender` where dateTime like :dateTime group by gender ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime+"%");
|
|
|
|
|
+ List<TravelGender> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelGender.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 男女性别累计统计
|
|
|
|
|
+ public List<TravelGender> queryGenderT(){
|
|
|
|
|
+ String sql = "select gender,SUM(num) as num from `travelgender` where gender is not null group by gender ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TravelGender> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelGender.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**================年龄统计=======================**/
|
|
|
|
|
+ // 年龄时间统计
|
|
|
|
|
+ public TravelAge queryTourAge(String sm_date, String ageArea, String sqlx){
|
|
|
|
|
+ String sql = "select sm_date as dateTime,:ageArea as ageArea,COUNT(*) as num from (select * from `sm_message` where sm_date=:sm_date "+ CommonSql.sql + sqlx+" group by UUID ) a";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date);
|
|
|
|
|
+ sps.addValue("ageArea", ageArea);
|
|
|
|
|
+ List<TravelAge> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelAge.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-年龄-判断是否存在
|
|
|
|
|
+ public List<TravelAge> queryTourByAge(TravelAge travelAge){
|
|
|
|
|
+ String sql = "select * from `travelage` where dateTime=:dateTime and ageArea=:ageArea ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelAge.getDateTime());
|
|
|
|
|
+ sps.addValue("ageArea",travelAge.getAgeArea());
|
|
|
|
|
+ List<TravelAge> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelAge.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertAge(TravelAge travelAge){
|
|
|
|
|
+ String sql = "insert into `travelage`(dateTime,ageArea,num) values(:dateTime,:ageArea,:num) ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelAge.getDateTime());
|
|
|
|
|
+ sps.addValue("ageArea",travelAge.getAgeArea());
|
|
|
|
|
+ sps.addValue("num", travelAge.getNum());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 年龄年统计
|
|
|
|
|
+ public List<TravelAge> queryTourByAgeAndYear(String dateTime){
|
|
|
|
|
+ String sql = "select ageArea,SUM(num) as num from `travelage` where dateTime like :dateTime group by ageArea ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime+"%");
|
|
|
|
|
+ List<TravelAge> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelAge.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 年龄累计统计
|
|
|
|
|
+ public List<TravelAge> queryAgeT(){
|
|
|
|
|
+ String sql = "select ageArea,SUM(num) as num from `travelage` where ageArea is not null group by ageArea ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TravelAge> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelAge.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**================景区游客人数统计=======================**/
|
|
|
|
|
+ // 景区游客日人数统计
|
|
|
|
|
+ public List<TravelT> queryTourNum(String sm_date){
|
|
|
|
|
+ String sql = "select sm_place as place,sm_date as dateTime,COUNT(*) as inCount from (select * from `sm_message` where sm_date=:sm_date "+CommonSql.sql+" group by UUID ) a group by sm_place order by inCount desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date);
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-各景区当日-判断是否存在
|
|
|
|
|
+ public List<TravelT> queryTourByNum(TravelT travelT){
|
|
|
|
|
+ String sql = "select * from `travelt` where dateTime=:dateTime and place=:place ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelT.getDateTime());
|
|
|
|
|
+ sps.addValue("place",travelT.getPlace());
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertNum(TravelT travelT){
|
|
|
|
|
+ String sql = "insert into `travelt`(dateTime,place,inCount) values(:dateTime,:place,:inCount) ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelT.getDateTime());
|
|
|
|
|
+ sps.addValue("place",travelT.getPlace());
|
|
|
|
|
+ sps.addValue("inCount", travelT.getInCount());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各景点年月年统计
|
|
|
|
|
+ public List<TravelT> queryTourByNumAndTime(String dateTime){
|
|
|
|
|
+ String sql = "select place,SUM(inCount) as inCount from `travelt` where dateTime like :dateTime group by place order by inCount desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime+"%");
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 景区游客累积人数统计
|
|
|
|
|
+ public List<TravelT> queryTourNumT(){
|
|
|
|
|
+ String sql = "select SUM(inCount) as inCount from `travelt` ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各景区游客累积人数统计
|
|
|
|
|
+ public List<TravelT> queryGTourNumT(){
|
|
|
|
|
+ String sql = "select * from (select place,SUM(inCount+0) as inCount from `travelt` where dateTime<:dateTime group by place ) a where place is not null ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", TimeExchange.getDate()+" 24:00:00");
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各景区人数排行跨日期
|
|
|
|
|
+ public List<TravelT> queryTourNumByDate(String startTime, String endTime){
|
|
|
|
|
+ String sql = "select place,SUM(inCount) as inCount from `travelt` where dateTime between :startTime and :endTime and place is not null group by place order by inCount desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("startTime", startTime);
|
|
|
|
|
+ sps.addValue("endTime", endTime);
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**================景区过夜人数统计=======================**/
|
|
|
|
|
+ // 各镇过夜日人数统计
|
|
|
|
|
+ public List<Travelye> queryTourYe(String sm_date){
|
|
|
|
|
+ String sql = "select id,place,SUM(num) as num,dateTime from (select b.id,b.`town` as place,IFNULL(a.num,0) as num,a.dateTime as dateTime from (select town as place,sm_date as dateTime,COUNT(*) as num from `sm_message` where sm_date=:sm_date and place_type='酒店' group by UUID ) a right join towns b on a.place=b.town ) c group by place";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", sm_date);
|
|
|
|
|
+ List<Travelye> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(Travelye.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询缓存-各景区过夜-判断是否存在
|
|
|
|
|
+ public List<Travelye> queryTourByYe(Travelye travelye){
|
|
|
|
|
+ String sql = "select * from `travelye` where dateTime=:dateTime and place=:place ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelye.getDateTime());
|
|
|
|
|
+ sps.addValue("place",travelye.getPlace());
|
|
|
|
|
+ List<Travelye> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(Travelye.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int insertYe(Travelye travelye){
|
|
|
|
|
+ String sql = "insert into `travelye`(dateTime,place,num) values(:dateTime,:place,:num) ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", travelye.getDateTime());
|
|
|
|
|
+ sps.addValue("place",travelye.getPlace());
|
|
|
|
|
+ sps.addValue("num", travelye.getNum());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各镇过夜年月年统计
|
|
|
|
|
+ public List<Travelye> queryTourByNumAndYe(String dateTime){
|
|
|
|
|
+ String sql = "select place,SUM(num) as num from `travelye` where dateTime like :dateTime group by place order by num desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("dateTime", dateTime+"%");
|
|
|
|
|
+ List<Travelye> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(Travelye.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 过夜游客按时查找
|
|
|
|
|
+ public List<Travelye> queryTouYeByDate(String startTime, String endTime){
|
|
|
|
|
+ String sql = "select place,SUM(num) as num from `travelye` where dateTime between :startTime and :endTime and place is not null group by place order by num desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("startTime", startTime);
|
|
|
|
|
+ sps.addValue("endTime", endTime);
|
|
|
|
|
+ List<Travelye> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(Travelye.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各酒店过夜人数
|
|
|
|
|
+ public List<Hotel> queryHotel(int page, int rows, String startTime,String endTime,String sqlx){
|
|
|
|
|
+ int start = (page - 1) * rows;// 每页的起始下标
|
|
|
|
|
+ String sql = "select town,hotel,COUNT(*) as num from `sm_message` where `place_type`='酒店' and sm_date between :startTime and :endTime "+sqlx+" group by hotel order by sm_time desc limit :start,:rows ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("start", start);
|
|
|
|
|
+ sps.addValue("rows", rows);
|
|
|
|
|
+ sps.addValue("startTime", startTime);
|
|
|
|
|
+ sps.addValue("endTime", endTime);
|
|
|
|
|
+ List<Hotel> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(Hotel.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询用户表中的总记录数
|
|
|
|
|
+ public int queryHotelTotal(String startTime,String endTime,String s1) {
|
|
|
|
|
+ String sql = "select COUNT(*) from(select town,hotel,COUNT(*) as num from `sm_message` where `place_type`='酒店' and sm_date between :startTime and :endTime "+s1+" group by hotel ) a" ;
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("startTime", startTime);
|
|
|
|
|
+ sps.addValue("endTime", endTime);
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 最大访客量
|
|
|
|
|
+ public int queryMaxTour(String place_name){
|
|
|
|
|
+ String sql = "select sum(maxnum) from `secondplace` where place_name=:place_name ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("place_name", place_name);
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 景区游客日人数统计
|
|
|
|
|
+ public List<TravelT> queryTourNumByPlace(String sm_place){
|
|
|
|
|
+ String sql = "select sm_place as place,sm_date as dateTime,COUNT(*) as inCount from (select * from `sm_message` where sm_date=:sm_date and sm_place=:sm_place group by UUID ) a group by sm_place order by inCount desc ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("sm_date", TimeExchange.getDate());
|
|
|
|
|
+ sps.addValue("sm_place", sm_place);
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 景区游客累计人数统计
|
|
|
|
|
+ public List<TravelT> queryTourNumByPlaceT(String place){
|
|
|
|
|
+ String sql = "select IFNULL(SUM(inCount),0) as inCount from `travelt` where place=:place";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("place", place);
|
|
|
|
|
+ List<TravelT> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelT.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 景区最大人口修改
|
|
|
|
|
+ public int updateMaxT(String place_name,String maxnum){
|
|
|
|
|
+ String sql = "update `secondplace` set maxnum=:maxnum where place_name=:place_name ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("place_name", place_name);
|
|
|
|
|
+ sps.addValue("maxnum",maxnum);
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 36个景点
|
|
|
|
|
+ public List<Secondplace> queryTourPlace(){
|
|
|
|
|
+ String sql = "select * from `secondplace` ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<Secondplace> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(Secondplace.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 旅游数量参数
|
|
|
|
|
+ public List<Tourx> queryTx(){
|
|
|
|
|
+ String sql = "select * from `tourx` ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ List<Tourx> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(Tourx.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 景区参数修改
|
|
|
|
|
+ public int updateTx(Tourx tourx){
|
|
|
|
|
+ String sql = "update `tourx` set xs=:xs,xs2=:xs2,xs3=:xs3,xs4=:xs4,xs5=:xs5, " +
|
|
|
|
|
+ "xs6=:xs6,xs7=:xs7,xs8=:xs8,xs9=:xs9,xs10=:xs10,xs11=:xs11,xs_name=:xs_name where id=:id ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("id", tourx.getId());
|
|
|
|
|
+ sps.addValue("xs", tourx.getXs());
|
|
|
|
|
+ sps.addValue("xs2", tourx.getXs2());
|
|
|
|
|
+ sps.addValue("xs3", tourx.getXs3());
|
|
|
|
|
+ sps.addValue("xs4", tourx.getXs4());
|
|
|
|
|
+ sps.addValue("xs5", tourx.getXs5());
|
|
|
|
|
+ sps.addValue("xs6", tourx.getXs6());
|
|
|
|
|
+ sps.addValue("xs7", tourx.getXs7());
|
|
|
|
|
+ sps.addValue("xs8", tourx.getXs8());
|
|
|
|
|
+ sps.addValue("xs9", tourx.getXs9());
|
|
|
|
|
+ sps.addValue("xs10", tourx.getXs10());
|
|
|
|
|
+ sps.addValue("xs11", tourx.getXs11());
|
|
|
|
|
+ sps.addValue("xs_name", tourx.getXs_name());
|
|
|
|
|
+ int num = 0;
|
|
|
|
|
+ try{
|
|
|
|
|
+ num = namedParameterJdbcTemplate.update(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各省月游客统计-分页
|
|
|
|
|
+ public List<TravelProvin> queryTourProvincePage(String time1,String time2,String sqlx,int page,int rows){
|
|
|
|
|
+ int start = (page - 1) * rows;// 每页的起始下标
|
|
|
|
|
+ String sql = "select province,SUM(num) as num from `travelprovin` where dateTime between :time1 and :time2 "+sqlx+" group by province order by num desc limit :start,:rows ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("time1", time1);
|
|
|
|
|
+ sps.addValue("time2", time2);
|
|
|
|
|
+ sps.addValue("start", start);
|
|
|
|
|
+ sps.addValue("rows", rows);
|
|
|
|
|
+ List<TravelProvin> list = namedParameterJdbcTemplate.query(sql, sps,
|
|
|
|
|
+ new BeanPropertyRowMapper<>(TravelProvin.class));
|
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 各省游客总数-分页
|
|
|
|
|
+ public int queryTourProvinceTotal(String time1,String time2,String sqlx){
|
|
|
|
|
+ String sql = "select count(*) from(select * from `travelprovin` where dateTime between :time1 and :time2 "+sqlx+" group by province order by num desc) a ";
|
|
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
|
|
+ sps.addValue("time1", time1);
|
|
|
|
|
+ sps.addValue("time2", time2);
|
|
|
|
|
+ return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|