📄 statvarsservice.java
字号:
Map<String,String> statvars = getFinalMap("onlines",dataBaseDao);
tempS = statvars.get("lastupdate");
int lastupdate = tempS == null ? 0 : Integer.parseInt(tempS);
if(timestamp - lastupdate > statscachelife){
statvars.clear();
statvars.put("lastupdate", timestamp+"");
newstatvars.add("'onlines', 'lastupdate', '"+timestamp+"'");
}
DataParse dataParse = ((DataParse)BeanFactory.getBean("dataParse"));
Stats_onlineCompositorVO stats_onlineCompositorVO = new Stats_onlineCompositorVO();
List<Map<String, Map<String,String>>> compositorMapList = stats_onlineCompositorVO.getCompositorMapList();
Map<Integer,Map<String,String>> total = null;
Map<Integer,Map<String,String>> thismonth = null;
List<Map<String,String>> tempML = null;
tempS = statvars.get("total");
int tempI = 0;
if(tempS != null){
total = dataParse.characterParse(tempS, false);
}else{
total = new HashMap<Integer, Map<String,String>>();
tempML = dataBaseDao.executeQuery("SELECT o.uid, m.username, o.total AS time " +
"FROM "+tableprefix+"onlinetime o " +
"LEFT JOIN "+tableprefix+"members m USING (uid) " +
"ORDER BY o.total DESC LIMIT 20");
if(tempML!=null){
for(Map<String,String> tempM : tempML){
tempM.put("time", (Math.round(Double.parseDouble(tempM.get("time"))/60*100)/100D)+"");
total.put(tempI++, tempM);
}
}
newstatvars.add("'onlines', 'total', '"+dataParse.combinationChar(total)+"'");
}
tempS = statvars.get("thismonth");
tempI = 0;
if(tempS != null){
thismonth = dataParse.characterParse(tempS, false);
}else{
thismonth = new HashMap<Integer, Map<String,String>>();
Calendar calendar = Common.getGMTCalendar();
calendar.set(Calendar.DAY_OF_MONTH, 1);
tempML = dataBaseDao.executeQuery("SELECT o.uid, m.username, o.thismonth AS time " +
"FROM "+tableprefix+"onlinetime o, "+tableprefix+"members m " +
"WHERE o.uid=m.uid AND m.lastactivity>='"+(calendar.getTimeInMillis()/1000)+"' " +
"ORDER BY o.thismonth DESC LIMIT 20");
if(tempML!=null){
for(Map<String,String> tempM : tempML){
tempM.put("time", (Math.round(Double.parseDouble(tempM.get("time"))/60*100)/100D)+"");
thismonth.put(tempI++, tempM);
}
}
newstatvars.add("'onlines', 'thismonth', '"+dataParse.combinationChar(thismonth)+"'");
}
Map<String,Map<String,String>> resultMap = null;
Map<String,String> totalMapTemp = null;
Map<String, String> totalResultMap = null;
Map<String,String> thismonthMapTemp = null;
Map<String, String> thismonthResultMap = null;
if(total!=null ){
tempI = total.size();
for(int i = 0;i<tempI;i++){
resultMap = new HashMap<String, Map<String,String>>();
totalMapTemp = total.get(i);
totalResultMap = new HashMap<String, String>();
totalResultMap.put("username", totalMapTemp.get("username"));
totalResultMap.put("uid", totalMapTemp.get("uid"));
totalResultMap.put("onlineTime", totalMapTemp.get("time"));
resultMap.put("total", totalResultMap);
if(thismonth!=null){
thismonthMapTemp = thismonth.get(i);
if(thismonthMapTemp!=null){
thismonthResultMap = new HashMap<String, String>();
thismonthResultMap.put("username", (String)thismonthMapTemp.get("username"));
thismonthResultMap.put("uid", (String)thismonthMapTemp.get("uid"));
thismonthResultMap.put("onlineTime", thismonthMapTemp.get("time").toString());
resultMap.put("thisMonth", thismonthResultMap);
}
}
compositorMapList.add(resultMap);
}
}
compositorMapList = null;
resultMap = null;
totalMapTemp = null;
totalResultMap = null;
thismonthMapTemp = null;
thismonthResultMap = null;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
tempI = Integer.parseInt(statvars.get("lastupdate"));
stats_onlineCompositorVO.setLastTime(Common.gmdate(dateFormat, tempI, timeoffset));
stats_onlineCompositorVO.setNextTime(Common.gmdate(dateFormat, (tempI+statscachelife.intValue()), timeoffset));
setNavbarVO(stats_onlineCompositorVO.getNavbar(), statstatus, modworkstatus, "onlinetime");
updateNewStatvars(newstatvars, dataBaseDao);
return stats_onlineCompositorVO;
}
public Stats_manageTeamVO getFinalStats_manageTeamVO (Map<String, String> settingMap,int timestamp,float timeoffset){
Double statscachelife = Double.valueOf(settingMap.get("statscachelife"));
statscachelife = statscachelife * 60;
boolean oltimespan = Double.valueOf(settingMap.get("oltimespan"))>0;
String tempS = settingMap.get("statstatus");
boolean statstatus = tempS!=null && !tempS.equals("0")&& !tempS.equals("");
tempS = settingMap.get("modworkstatus");
boolean modworkstatus = tempS!=null && !tempS.equals("") && !tempS.equals("0");
DataBaseDao dataBaseDao = (DataBaseDao)BeanFactory.getBean("dataBaseDao");
List<String> newstatvars = new ArrayList<String>();
DataParse dataParse = ((DataParse)BeanFactory.getBean("dataParse"));
SimpleDateFormat dateFormat = new SimpleDateFormat();
Map<String,String> statvars = getFinalMap("team" ,dataBaseDao);
tempS = statvars.get("lastupdate");
int lastupdate = tempS == null ? 0 : Integer.parseInt(tempS);
if(timestamp - lastupdate > statscachelife){
statvars.clear();
statvars.put("lastupdate", timestamp+"");
newstatvars.add("'team', 'lastupdate', '"+timestamp+"'");
}
Map<Integer,Map<Integer,Map<String,String>>> forums = null;
Map<Integer,Map<Integer,String>> moderators = null;
Map<Integer,Map<String,String>> members = null;
Map<Integer,Map<String,String>> categories = null;
Map<Integer,String> admins = null;
double avgoffdays = 0D;
double avgthismonthposts = 0D;
double avgtotalol = 0D;
double avgthismonthol = 0D;
double avgmodactions = 0D;
Map<String,Object> team = null;
tempS = statvars.get("team");
int tempI = 0;
if(tempS != null){
team = dataParse.characterParse(tempS, false);
forums = (Map<Integer,Map<Integer,Map<String,String>>>)team.get("forums");
categories = (Map<Integer,Map<String,String>>)team.get("categories");
admins = (Map<Integer,String>)team.get("admins");
moderators = (Map<Integer,Map<Integer,String>>)team.get("moderators");
members = (Map<Integer,Map<String,String>>)team.get("members");
avgoffdays = (Float)team.get("avgoffdays");
avgthismonthposts = Float.parseFloat(team.get("avgthismonthposts")+"");
avgtotalol = Float.parseFloat(team.get("avgtotalol")+"");
avgthismonthol = Float.parseFloat(team.get("avgthismonthol")+"");
avgmodactions = Float.parseFloat(team.get("avgmodactions")+"");
}else{
team = new HashMap<String, Object>();
forums = new HashMap<Integer, Map<Integer,Map<String,String>>>();
moderators = new HashMap<Integer, Map<Integer,String>>();
members = new HashMap<Integer, Map<String,String>>();
categories = new HashMap<Integer, Map<String,String>>();
Map<Integer,Integer> fuptemp = new HashMap<Integer, Integer>();;
Map<String,String> tempM_SS = new HashMap<String, String>();
tempM_SS.put("fid", "0");
tempM_SS.put("fup", "0");
tempM_SS.put("type", "group");
tempM_SS.put("name", settingMap.get("bbname"));
categories.put(0, tempM_SS);
StringBuffer uids = new StringBuffer("0");
List<Map<String,String>> tempML = dataBaseDao.executeQuery("SELECT fid, uid FROM "+tableprefix+"moderators WHERE inherited='0' ORDER BY displayorder");
if(tempML!=null){
Map<Integer,String> tempM_IS = null;
for(Map<String,String> moderator : tempML){
tempS = moderator.get("uid");
tempM_IS = moderators.get(Integer.parseInt(moderator.get("fid")));
if(tempM_IS == null){
tempM_IS = new HashMap<Integer, String>();
moderators.put(Integer.parseInt(moderator.get("fid")), tempM_IS);
}
tempM_IS.put(tempM_IS.size(), tempS);
uids.append(","+tempS);
}
}
String oltimeadd1 = "";
String oltimeadd2 = "";
if(oltimespan){
oltimeadd1 = ", o.thismonth AS thismonthol, o.total AS totalol";
oltimeadd2 = "LEFT JOIN "+tableprefix+"onlinetime o ON o.uid=m.uid";
}
int totaloffdays = 0;
int totalol = 0;
int totalthismonthol = 0;
tempML = dataBaseDao.executeQuery("SELECT m.uid, m.username, m.adminid, m.lastactivity, m.credits, m.posts "+oltimeadd1+" " +
"FROM "+tableprefix+"members m "+oltimeadd2+" " +
"WHERE m.uid IN ("+uids.toString()+") OR m.adminid IN (1, 2) ORDER BY m.adminid");
admins = new HashMap<Integer, String>();
if(tempML!=null){
dateFormat.applyPattern("yyyyM");
tempI = 0;
int offdays = 0;
double tempD = 0D;
for(Map<String,String> member : tempML){
tempS = member.get("adminid");
if("1".equals(tempS) || "2".equals(tempS)){
admins.put(tempI++, member.get("uid"));
}
offdays = (timestamp - Integer.parseInt(member.get("lastactivity")))/86400;
member.put("offdays", offdays+"");
totaloffdays += offdays;
if(oltimespan){
tempS = member.get("totalol");
if(tempS == null){
tempS = "0";
}
tempD = (Math.round(Double.parseDouble(tempS)/60*100) / 100D);
member.put("totalol", tempD+"");
totalol += tempD;
if(dateFormat.format(Long.parseLong(member.get("lastactivity"))*1000L).equals(dateFormat.format(timestamp*1000L))){
tempS = member.get("thismonthol");
if(tempS == null){
tempS = "0";
}
tempD = (Math.round(Double.parseDouble(tempS)*100/60) / 100D);
tempS = tempD+"";
}else{
tempD = 0D;
tempS = "0";
}
member.put("thismonthol", tempS);
totalthismonthol += tempD;
}
tempS = member.get("uid");
members.put(Integer.valueOf(tempS), member);
uids.append(","+tempS);
}
}
int totalthismonthposts = 0;
tempML = dataBaseDao.executeQuery("SELECT authorid, COUNT(*) AS posts FROM "+tableprefix+"posts " +
"WHERE dateline>="+timestamp+"-86400*30 AND authorid IN ("+uids+") AND invisible='0' GROUP BY authorid");
if(tempML!=null){
for(Map<String,String> post : tempML){
tempS = post.get("posts");
tempM_SS = members.get(Integer.parseInt(post.get("authorid")));
if(tempM_SS != null){
tempM_SS.put("thismonthposts", tempS);
}
totalthismonthposts += Integer.parseInt(tempS);
}
}
int totalmodactions = 0;
if(modworkstatus){
dateFormat.applyPattern("yyyy-MM-01");
tempS = dateFormat.format(timestamp*1000L);
tempML = dataBaseDao.executeQuery("SELECT uid, SUM(count) AS actioncount FROM "+tableprefix+"modworks " +
"WHERE dateline>='"+tempS+"' GROUP BY uid");
if(tempML!=null){
for(Map<String,String> member : tempML){
tempS = member.get("actioncount");
tempM_SS = members.get(Integer.valueOf(member.get("uid")));
if(tempM_SS != null){
tempM_SS.put("modactions", tempS);
}
totalmodactions += Integer.parseInt(tempS);
}
}
}
tempML = dataBaseDao.executeQuery("SELECT fid, fup, type, name, inheritedmod FROM "+tableprefix+"forums WHERE status>0 ORDER BY type, displayorder");
if(tempML!=null){
Map<Integer,Map<String,String>> tempM_I_SS = null;
Map<Integer,String> tempM_IS = null;
int temp_fid = 0;
int temp_fup = 0;
for(Map<String,String> forum : tempML){
temp_fid = Integer.valueOf(forum.get("fid"));
temp_fup = Integer.valueOf(forum.get("fup"));
tempM_IS = moderators.get(temp_fid);
if(tempM_IS == null){
forum.put("moderators", "0");
}else{
forum.put("moderators", tempM_IS.size()+"");
}
tempS = forum.get("type");
if("group".equals(tempS)){
categories.put(temp_fid, forum);
tempM_I_SS = forums.get(temp_fid);
if(tempM_I_SS == null){
tempM_I_SS = new HashMap<Integer, Map<String,String>>();
forums.put(temp_fid, tempM_I_SS);
}
tempM_I_SS.put(temp_fid, forum);
tempI = temp_fid;
}else if("forum".equals(tempS)){
tempM_I_SS = forums.get(temp_fup);
if(tempM_I_SS == null){
tempM_I_SS = new HashMap<Integer, Map<String,String>>();
forums.put(temp_fup, tempM_I_SS);
}
tempM_I_SS.put(temp_fid, forum);
fuptemp.put(temp_fid, temp_fup);
tempI = temp_fup;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -