package com.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import com.toolsbean.DB; import com.valuebean.AreaBean; public class AreaDao { private DB mydb=null; public AreaDao(){ mydb=new DB(); } public List getAreas(){ String sql="select a.*,t.num from tb_area as a left join (select voter_ip,count(id) as num from tb_voter group by voter_ip) t on (t.voter_ip between a.area_ipStart and a.area_ipEnd)"; List options=getList(sql,null); return options; } public List getAreasForDay(){ String sql="select a.*,t.num from tb_area as a left join (select voter_ip,count(id) as num from tb_voter where day(voter_votetime)=day(getdate()) group by voter_ip) t on (t.voter_ip between a.area_ipStart and a.area_ipEnd)"; List options =getList(sql,null); return options; } public List getAreasForMonth(){ String sql="select a.*,t.num from tb_area as a left join (select voter_ip,count(id) as num from tb_voter where month(voter_votetime)=month(getdate()) group by voter_ip) t on (t.voter_ip between a.area_ipStart and a.area_ipEnd)"; List options =getList(sql,null); return options; } private List getList(String sql,Object[] params){ List options=null; DB mydb=new DB(); mydb.doPstm(sql,params); try { ResultSet rs = mydb.getRs(); if(rs!=null){ options=new ArrayList(); while(rs.next()){ AreaBean single=new AreaBean(); single.setAreaIpStart(rs.getLong(1)); single.setAreaIpEnd(rs.getLong(2)); single.setAreaName(rs.getString(3)); single.setAreaBallot(rs.getInt(4)); options.add(single); } rs.close(); } } catch (SQLException e) { e.printStackTrace(); } return options; } public void closed(){ mydb.closed(); } }
最近下载更多
ming_123_9715 LV23
2022年11月27日
微信网友_6181845028360192 LV1
2022年10月19日
3273591624 LV6
2022年8月27日
evagsd LV6
2022年7月8日
chengjuan LV2
2022年6月29日
eniu_27 LV5
2022年5月30日
微信网友_5980754345857024 LV1
2022年5月30日
太菜了多吃肉 LV2
2022年4月18日
panpan2018ok LV9
2021年12月23日
taijh999 LV13
2021年8月30日
最近浏览更多
pangzhihui LV12
4月16日
liuxing_aa
4月15日
暂无贡献等级
wananall LV13
3月13日
laishaofe LV7
1月16日
shanmian
1月9日
暂无贡献等级
Liang朝伟 LV1
1月6日
asddwh LV12
2023年12月29日
17693282606 LV11
2023年12月20日
weilaizhisheng LV21
2023年12月5日
阿凡达 LV9
2023年11月11日