package jihe.jiheinfo;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;public class Score { public int Ids;
int a,b,c,d;
int UserId;
String Today;
String Lastday;
DBconn db=new DBconn();
List score_max=new ArrayList();
public void time(){
Calendar today=Calendar.getInstance();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Today=sdf.format(today.getTime()); today.add(Calendar.DATE,-60);
Lastday=sdf.format(today.getTime());
}//时间方法
public List scores() throws SQLException,Exception{
String SQL="select Id,count(Id) as Ids from Users where LastTimes between '"+Lastday+"' and '"+Today+"'";
ResultSet rs=db.executeQuery(SQL);
while(rs.next()){
Ids=Integer.parseInt(rs.getString("Ids"));
ScoreBean sb=new ScoreBean();
sb.setId(rs.getString("Id"));
score_max.add(sb);
}
return score_max;
}//有多少人员处理
//查询表积分有3个方法
public int getC_score(int UserId)
throws NumberFormatException, SQLException {
String SQL="select count(HostManId) as jifen from costumecomm " +
"where HostManId='"+UserId+"' " +
"and Times between '"+Lastday+"' and '"+Today+"'";
ResultSet rs=db.executeQuery(SQL);
while(rs.next()){
a=Integer.parseInt(rs.getString(1));
}
return a;
}
public int getO_score(int UserId)
throws NumberFormatException, SQLException {
String SQL1="select count(HostManId) as jifen from ornamentcomm " +
"where HostManId='"+UserId+"' " +
"and Times between '"+Lastday+"' and '"+Today+"'";
ResultSet rs1=db.executeQuery(SQL1);
while(rs1.next()){
b=Integer.parseInt(rs1.getString(1));
}
return b;
}
public int getT_score(int UserId)
throws NumberFormatException, SQLException{
String SQL2="select count(HostManId) as jifen from toiletrycomm " +
"where HostManId='"+UserId+"' " +
"and Times between '"+Lastday+"' and '"+Today+"'";
ResultSet rs2=db.executeQuery(SQL2);
while(rs2.next()){
c=Integer.parseInt(rs2.getString(1));
}
return c;
}
public int getSum(int UserId) throws NumberFormatException, SQLException{
d=getT_score(UserId)+getC_score(UserId)+getO_score(UserId);
return d;
}//每个人的总积分
}
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;public class Score { public int Ids;
int a,b,c,d;
int UserId;
String Today;
String Lastday;
DBconn db=new DBconn();
List score_max=new ArrayList();
public void time(){
Calendar today=Calendar.getInstance();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Today=sdf.format(today.getTime()); today.add(Calendar.DATE,-60);
Lastday=sdf.format(today.getTime());
}//时间方法
public List scores() throws SQLException,Exception{
String SQL="select Id,count(Id) as Ids from Users where LastTimes between '"+Lastday+"' and '"+Today+"'";
ResultSet rs=db.executeQuery(SQL);
while(rs.next()){
Ids=Integer.parseInt(rs.getString("Ids"));
ScoreBean sb=new ScoreBean();
sb.setId(rs.getString("Id"));
score_max.add(sb);
}
return score_max;
}//有多少人员处理
//查询表积分有3个方法
public int getC_score(int UserId)
throws NumberFormatException, SQLException {
String SQL="select count(HostManId) as jifen from costumecomm " +
"where HostManId='"+UserId+"' " +
"and Times between '"+Lastday+"' and '"+Today+"'";
ResultSet rs=db.executeQuery(SQL);
while(rs.next()){
a=Integer.parseInt(rs.getString(1));
}
return a;
}
public int getO_score(int UserId)
throws NumberFormatException, SQLException {
String SQL1="select count(HostManId) as jifen from ornamentcomm " +
"where HostManId='"+UserId+"' " +
"and Times between '"+Lastday+"' and '"+Today+"'";
ResultSet rs1=db.executeQuery(SQL1);
while(rs1.next()){
b=Integer.parseInt(rs1.getString(1));
}
return b;
}
public int getT_score(int UserId)
throws NumberFormatException, SQLException{
String SQL2="select count(HostManId) as jifen from toiletrycomm " +
"where HostManId='"+UserId+"' " +
"and Times between '"+Lastday+"' and '"+Today+"'";
ResultSet rs2=db.executeQuery(SQL2);
while(rs2.next()){
c=Integer.parseInt(rs2.getString(1));
}
return c;
}
public int getSum(int UserId) throws NumberFormatException, SQLException{
d=getT_score(UserId)+getC_score(UserId)+getO_score(UserId);
return d;
}//每个人的总积分
}
import java.sql.*;
import java.util.*;
import java.text.*;
public class Score1 {
public int Sum,Id;
Score Score=new Score();
SortedMap sm=new TreeMap();
//登陆人数
public SortedMap scoress() throws Exception{
for(int i=Score.Ids;i>0;i--){
Iterator iter=Score.scores().iterator();
while(iter.hasNext()){
ScoreBean sb=(ScoreBean)iter.next();
Id=Integer.parseInt(sb.getId());
}
Sum=Score.getSum(Id);
sm.put(Sum,Id);
}
return sm;
}
}
private String Id;
public void setId(String newId){
this.Id=newId;
}
public String getId(){
return Id;
}
}在页面上打印是空值"[]",不知道如何做?---out.print(Score1.scoress().keySet());功能是在时间断内不同的人员发表评论,人员我给放到了Score()的scores中了,getC_score,getO_score,getT_score是三种评论的积分(一个人的),我把积分d=getT_score(UserId)+getC_score(UserId)+getO_score(UserId);和人的ID好放到了treemap中排序,但是取不出值来,怀疑是不是没有插进去值?
String SQL="select Id,count(Id) as Ids from Users where LastTimes between '"+Lastday+"' and '"+Today+"'";