📄 clubcounter.java
字号:
package com.gamvan.club;import com.gamvan.conn.*;import com.gamvan.tools.*;import com.gamvan.club.ClubClassInfo;import java.sql.*;import java.util.*;public class ClubCounter{ private int clubHits=0; private String clubToday=""; private int clubTodayPV=0; private int clubYesterPV=0; private int clubTopic=0; private int clubReply=0; private int clubTodayTopic=0; private int clubTodayReply=0; private int clubYesterTopic=0; private int clubYesterReply=0; private int clubBoy=0; private int clubGirl=0; private int clubMostOnline=0; private String clubNewUser=""; private String message = ""; ConnClub bridge = new ConnClub(); //格式化当前时间 java.text.SimpleDateFormat isNow = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private String now = isNow.format(new java.util.Date()); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd"); private String isDate = sdf.format(new java.util.Date()); public void counterUpdate(int hits, int tpv, int ct, int cr, int cb, int cg, int cm, String nu) throws Exception { Connection con = bridge.getConnection(); String sqlCommand = new String(); try{ counterInfo(); sqlCommand = "Update GVclubCounter set clubTemp=0"; if(hits!=0){sqlCommand += ", clubHits = clubHits + "+ hits +"";} if(cb!=0){sqlCommand += ", clubBoy = clubBoy +" + cb +"";} if(cg!=0){sqlCommand += ", clubGirl = clubGirl +" + cg +"";} if(tpv!=0){sqlCommand += ", clubTopicPV = clubTopicPV + "+ tpv +"";} sqlCommand += ", clubTopic = clubTopic + "+ ct +""; sqlCommand += ", clubReply = clubReply + "+ cr +""; if(clubToday!=null && !clubToday.equals("")){ java.util.Date date1 = sdf.parse(clubToday); java.util.Date date0 = sdf.parse(isDate); if(date0.after(date1)){ sqlCommand += ", clubToday ='"+ now +"'"; sqlCommand += ", clubYesterPV = "+ clubTodayPV+ ""; sqlCommand += ", clubTodayPV = "+ tpv +""; sqlCommand += ", clubYesterTopic = "+ clubTodayTopic +""; sqlCommand += ", clubYesterReply = "+ clubTodayReply +""; sqlCommand += ", clubTodayTopic = "+ ct +""; sqlCommand += ", clubTodayReply = "+ cr +""; ClubClassInfo cci = new ClubClassInfo(); cci.classCounter(0,0,0); }else{ if(tpv!=0){sqlCommand += ", clubTodayPV = clubTodayPV + "+ tpv +"";} if(ct!=0){sqlCommand += ", clubTodayTopic = clubTodayTopic + "+ ct +"";} if(cr!=0){sqlCommand += ", clubTodayReply = clubTodayReply + "+ cr +"";} } }else{ sqlCommand += ", clubToday ='"+ now +"'"; } if(cm!=0){sqlCommand += ", clubMostOnline = clubMostOnline +" + cm +"";} if(!nu.equals("")){sqlCommand += ", clubNewUser = '" + nu.trim() +"'";} PreparedStatement pps = con.prepareStatement(sqlCommand); pps.executeUpdate(); pps.close(); message = sqlCommand; }catch(Exception e){ message = e.toString(); con.close(); }finally{ con.close(); } } public void counterInfo() throws Exception{ String sqlCommand = new String(); Connection con = bridge.getConnection(); try{ ResultSet rs; sqlCommand = "Select * From GVclubCounter"; PreparedStatement pps = con.prepareStatement(sqlCommand); rs = pps.executeQuery(); if(rs.next()){ clubHits = rs.getInt(1); clubTodayPV = rs.getInt(2); clubYesterPV = rs.getInt(3); clubTopic = rs.getInt(4); clubReply = rs.getInt(5); clubYesterTopic = rs.getInt(6); clubYesterReply = rs.getInt(7); clubTodayTopic = rs.getInt(8); clubTodayReply = rs.getInt(9); clubBoy = rs.getInt(10); clubGirl = rs.getInt(11); clubToday = String.valueOf(rs.getDate(12)); clubMostOnline = rs.getInt(13); clubNewUser = rs.getString(14); } rs.close(); pps.close(); }catch(Exception e){ con.close(); }finally{ con.close(); } } public String getMessage(){ return this.message; } public String getClubNewUser(){ return this.clubNewUser; } public int getClubHits(){ return this.clubHits; } public int getClubTodayPV(){ return this.clubTodayPV; } public int getClubYesterPV(){ return this.clubYesterPV; } public int getClubTopic(){ return this.clubTopic; } public int getClubReply(){ return this.clubReply; } public int getClubTodayTopic(){ return this.clubTodayTopic; } public int getClubTodayReply(){ return this.clubTodayReply; } public int getClubYesterTopic(){ return this.clubYesterTopic; } public int getClubYesterReply(){ return this.clubYesterReply; } public int getClubBoy(){ return this.clubBoy; } public int getClubGirl(){ return this.clubGirl; } public String getClubToday(){ return this.clubToday; } public int getClubMostOnline(){ return this.clubMostOnline; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -