generated from root/miduo_server
开服时间 在线人数
parent
c110b17749
commit
756b73774a
|
|
@ -17,7 +17,9 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -44,13 +46,9 @@ public class ServerInfoController {
|
|||
serverInfoVo.setIsnew(Integer.valueOf(serverInfo.getIs_new()));
|
||||
}
|
||||
|
||||
CServerOpenTime cServerOpenTime = RedisUtil.getInstence().getObject(RedisUserKey.SERVER_OPEN_TIME_KEY, serverInfo.getServer_id(),
|
||||
CServerOpenTime.class, GlobalsDef.REDIS_OVER_TIME);
|
||||
if (cServerOpenTime !=null){
|
||||
long time = (long) cServerOpenTime.getOpenTime() * 1000;
|
||||
serverInfoVo.setOpen_time(JsonUtil.timeStamp2Date(String.valueOf(time)));
|
||||
}else{
|
||||
serverInfoVo.setOpen_time(serverInfo.getOpen_time());
|
||||
CServerOpenTime cServerOpenTime = serverInfoDao.getOpenServerTime(Integer.valueOf(serverInfo.getServer_id()));
|
||||
if(null!=cServerOpenTime){
|
||||
serverInfoVo.setOpen_time(cServerOpenTime.getOpenTime());
|
||||
}
|
||||
serverInfoVos.add(serverInfoVo);
|
||||
}
|
||||
|
|
@ -69,6 +67,10 @@ public class ServerInfoController {
|
|||
@RequestMapping(value = "/toServerInfoEdit", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String toServerInfoEdit(HttpSession session, ModelMap map, int id) throws Exception {
|
||||
ServerInfo serverInfo = serverInfoDao.getServerinfo(id);
|
||||
CServerOpenTime cServerOpenTime = serverInfoDao.getOpenServerTime(Integer.valueOf(serverInfo.getServer_id()));
|
||||
if(null!=cServerOpenTime){
|
||||
serverInfo.setOpen_time(cServerOpenTime.getOpenTime());
|
||||
}
|
||||
map.addAttribute("serverInfo",serverInfo);
|
||||
return "serverInfoEdit";
|
||||
}
|
||||
|
|
@ -79,8 +81,16 @@ public class ServerInfoController {
|
|||
String name = request.getParameter("name");
|
||||
int server_id = Integer.parseInt(request.getParameter("server_id"));
|
||||
int isnew = Integer.parseInt(request.getParameter("isnew"));
|
||||
// int isCommend = Integer.parseInt(request.getParameter("isCommend"));
|
||||
String opentime = request.getParameter("startTime");
|
||||
|
||||
serverInfoDao.updateServerInfo(server_id,status,0,isnew,name);
|
||||
|
||||
CServerOpenTime cServerOpenTime = serverInfoDao.getOpenServerTime(server_id);
|
||||
if(null!=cServerOpenTime){
|
||||
cServerOpenTime.setOpenTime(opentime);
|
||||
serverInfoDao.updateOpenServerTime(cServerOpenTime,server_id);
|
||||
}
|
||||
|
||||
ServerInfo serverInfo = serverInfoDao.getServerinfo(server_id);
|
||||
if (serverInfo != null){
|
||||
ServerInfoVo serverInfoVo = new ServerInfoVo();
|
||||
|
|
@ -88,6 +98,7 @@ public class ServerInfoController {
|
|||
serverInfoVo.setName(serverInfo.getName());
|
||||
serverInfoVo.setStatus(Integer.valueOf(serverInfo.getStatus()));
|
||||
serverInfoVo.setIsnew(isnew);
|
||||
serverInfoVo.setOpen_time(opentime);
|
||||
serverInfoVos.add(serverInfoVo);
|
||||
}else{
|
||||
return "404";
|
||||
|
|
@ -95,35 +106,6 @@ public class ServerInfoController {
|
|||
map.addAttribute("serverInfos", serverInfoVos);
|
||||
return "findServerInfo";
|
||||
}
|
||||
@RequestMapping(value = "/toSetOpenServerTime", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String toSetOpenServerTime(HttpSession session, ModelMap map, int id) throws Exception {
|
||||
ServerInfo serverInfo = serverInfoDao.getServerinfo(id);
|
||||
map.addAttribute("serverInfo",serverInfo);
|
||||
return "setOpenServerTime";
|
||||
}
|
||||
@RequestMapping(value = "/setOpenServerTime", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody int setOpenServerTime(HttpSession session,HttpServletRequest request){
|
||||
try {
|
||||
int serverId = Integer.parseInt(request.getParameter("serverId"));
|
||||
long time = Long.parseLong(JsonUtil.date3TimeStamp(request.getParameter("openTime")));
|
||||
long zero = JsonUtil.getAppointTimeInXDay(time, 0);
|
||||
int openTime = (int) (zero / 1000);
|
||||
CServerOpenTime cServerOpenTime = serverInfoDao.getOpenServerTime(serverId);
|
||||
if (cServerOpenTime == null){
|
||||
cServerOpenTime = new CServerOpenTime();
|
||||
cServerOpenTime.setId(serverId);
|
||||
cServerOpenTime.setOpenTime(openTime);
|
||||
serverInfoDao.addOpenServerTime(cServerOpenTime);
|
||||
}else {
|
||||
cServerOpenTime.setOpenTime(openTime);
|
||||
serverInfoDao.updateOpenServerTime(cServerOpenTime);
|
||||
}
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/serverNumberInfo", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String serverNumberInfo(HttpSession session, ModelMap map) throws Exception {
|
||||
|
|
|
|||
|
|
@ -17,11 +17,10 @@ public interface ServerInfoDao {
|
|||
|
||||
void updateServerInfo(int server_id, int status,int isWhite,int isnew,String name) throws Exception;
|
||||
|
||||
void updateOpenServerTime(CServerOpenTime cServerOpenTime) throws Exception;
|
||||
void updateOpenServerTime(CServerOpenTime cServerOpenTime,int serverId) throws Exception;
|
||||
|
||||
CServerOpenTime getOpenServerTime(int serverId) throws Exception;
|
||||
|
||||
void addOpenServerTime(CServerOpenTime cServerOpenTime) throws Exception;
|
||||
|
||||
long getRegisterNum(int server_id) throws Exception;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.jmfy.model.Constant;
|
|||
import com.jmfy.model.ServerInfo;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import com.jmfy.utils.Connect;
|
||||
import com.jmfy.utils.MongoName;
|
||||
import com.jmfy.utils.RedisUtil;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
|
|
@ -72,32 +73,28 @@ public class ServerInfoDaoImpl implements ServerInfoDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateOpenServerTime(CServerOpenTime cServerOpenTime) throws Exception {
|
||||
RedisUtil.getInstence().putObject(RedisUserKey.SERVER_OPEN_TIME_KEY, Integer.toString(cServerOpenTime.getId()), cServerOpenTime,-1);
|
||||
public void updateOpenServerTime(CServerOpenTime cServerOpenTime,int serverId) throws Exception {
|
||||
String dbName = MongoName.getMongoDBName(serverId);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query(Criteria.where("server_id").is(String.valueOf(cServerOpenTime.getId())));
|
||||
Query query = new Query(Criteria.where("_id").is(1));
|
||||
Update update = new Update();
|
||||
update.set("openTime",cServerOpenTime.getOpenTime());
|
||||
mongoTemplate.updateMulti(query, update, ServerInfo.class);
|
||||
update.set("open_time",cServerOpenTime.getOpenTime());
|
||||
mongoTemplate.updateMulti(query, update, CServerOpenTime.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CServerOpenTime getOpenServerTime(int serverId) throws Exception {
|
||||
CServerOpenTime cServerOpenTime = RedisUtil.getInstence().getObject(RedisUserKey.SERVER_OPEN_TIME_KEY, Integer.toString(serverId),
|
||||
CServerOpenTime.class, -1);
|
||||
if (cServerOpenTime == null) {
|
||||
try {
|
||||
String dbName = MongoName.getMongoDBName(serverId);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
cServerOpenTime = mongoTemplate.findById(serverId, CServerOpenTime.class);
|
||||
}
|
||||
CServerOpenTime cServerOpenTime = mongoTemplate.findById(1, CServerOpenTime.class);
|
||||
return cServerOpenTime;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOpenServerTime(CServerOpenTime cServerOpenTime) throws Exception {
|
||||
RedisUtil.getInstence().putObject(RedisUserKey.SERVER_OPEN_TIME_KEY, Integer.toString(cServerOpenTime.getId()), cServerOpenTime,-1);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
mongoTemplate.insert(cServerOpenTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRegisterNum(int server_id) throws Exception {
|
||||
|
|
@ -108,7 +105,7 @@ public class ServerInfoDaoImpl implements ServerInfoDao {
|
|||
|
||||
@Override
|
||||
public long getOnlineNum(int server_id) {
|
||||
Integer num = RedisUtil.getInstence().getObject(String.valueOf(server_id), "OnlineNum:core1", Integer.class, -1);
|
||||
Integer num = RedisUtil.getInstence().getObject("ONLINE_NUM", String.valueOf(server_id), Integer.class, -1);
|
||||
if (num == null){
|
||||
num = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ import org.springframework.data.annotation.Id;
|
|||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
@Document(collection="c_server_open_time")
|
||||
@Document(collection="server_config")
|
||||
public class CServerOpenTime {
|
||||
|
||||
@Id
|
||||
private int id; // serverId
|
||||
|
||||
@Field(value = "openTime")
|
||||
private int openTime; // 精确到秒的时间戳
|
||||
@Field(value = "open_time")
|
||||
private String openTime; // 精确到秒的时间戳
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
|
@ -21,11 +21,11 @@ public class CServerOpenTime {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public int getOpenTime() {
|
||||
public String getOpenTime() {
|
||||
return openTime;
|
||||
}
|
||||
|
||||
public void setOpenTime(int openTime) {
|
||||
public void setOpenTime(String openTime) {
|
||||
this.openTime = openTime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ public class RedisUserKey {
|
|||
public static final String QUESTION_FROMBACK_ALL = "QUESTION_FROMBACK_ALL";//所有问卷
|
||||
public static final String READY_TO_USER_MAIL = "READY_TO_USER_MAIL";
|
||||
|
||||
/**
|
||||
* 在线人数 updata/min
|
||||
*/
|
||||
public static final String ONLINE_NUM = "ONLINE_NUM";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
服务器id:</label>
|
||||
服务器name:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" name="name" placeholder="" th:value="*{name}" class="input-text"/>
|
||||
</div>
|
||||
|
|
@ -85,6 +85,15 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
开服时间:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" name="startTime" placeholder="" th:value="*{open_time}" class="input-text"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp" />
|
||||
<link rel="Bookmark" href="/favicon.ico" />
|
||||
<link rel="Shortcut Icon" href="/favicon.ico" />
|
||||
<!--[if lt IE 9]>
|
||||
<script type="text/javascript" src="../static/lib/html5shiv.js"></script>
|
||||
<script type="text/javascript" src="../static/lib/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../static/lib/Hui-iconfont/1.0.8/iconfont.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
|
||||
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
|
||||
<!--[if IE 6]>
|
||||
<script type="text/javascript" src="../static/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
|
||||
<script>DD_belatedPNG.fix('*');</script>
|
||||
<![endif]-->
|
||||
<!--/meta 作为公共模版分离出去-->
|
||||
|
||||
<title>基本设置</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="breadcrumb">
|
||||
<a href="javascript:;" onclick="history.go(-1)"><i class="Hui-iconfont"></i> 首页</a>
|
||||
<span class="c-gray en">></span>
|
||||
服务器管理
|
||||
<span class="c-gray en">></span>
|
||||
服务器列表信息
|
||||
<!--<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace('/findServerInfo');" title="刷新" ><i class="Hui-iconfont"></i></a>-->
|
||||
</nav>
|
||||
|
||||
<div class="page-container">
|
||||
<form class="form form-horizontal" th:object="${serverInfo}" method="post">
|
||||
<div id="tab-system" class="HuiTab">
|
||||
<div class="tabBar cl">
|
||||
<span>设置开服时间</span>
|
||||
</div>
|
||||
<div class="tabCon">
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
服务器id:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" name="serverId" placeholder="" th:value="*{server_id}" class="input-text"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
开服时间:</label>
|
||||
<input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss', minDate:'#F{$dp.$D(\'openTime\')||\'%y-%M-%d\'}' })" id="openTime" name="openTime" class="input-text Wdate" style="width:180px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
|
||||
<button class="btn btn-primary radius" type="button" onclick="return setOpenTime();" >
|
||||
<i class="Hui-iconfont"></i> 保存</button>
|
||||
<button class="btn btn-default radius" type="button"><a href="/findServerInfo"> 取消 </a></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!--_footer 作为公共模版分离出去-->
|
||||
<script type="text/javascript" src="../static/lib/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../static/lib/layer/2.4/layer.js"></script>
|
||||
<script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
|
||||
<script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
|
||||
|
||||
<!--请在下方写此页面业务相关的脚本-->
|
||||
<script type="text/javascript" src="../static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
|
||||
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
|
||||
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/validate-methods.js"></script>
|
||||
<script type="text/javascript" src="../static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('.skin-minimal input').iCheck({
|
||||
checkboxClass: 'icheckbox-blue',
|
||||
radioClass: 'iradio-blue',
|
||||
increaseArea: '20%'
|
||||
});
|
||||
$("#tab-system").Huitab({
|
||||
index:0
|
||||
});
|
||||
});
|
||||
|
||||
function setOpenTime() {
|
||||
var serverId = $("input[name='serverId']").val();
|
||||
var openTime = $("input[name='openTime']").val();
|
||||
if (openTime === '' || openTime == null) {
|
||||
erroCode = $('.ENDTIME');
|
||||
erroCode.html('<span style="color: red; ">开服时间不能为空!</span>');
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data: {
|
||||
"serverId": serverId ,
|
||||
"openTime": openTime
|
||||
},
|
||||
url: "/setOpenServerTime",
|
||||
success: function (data) {
|
||||
if (data === 0) {
|
||||
layer.msg('设置开服时间成功!', {icon: 6, time: 1000});
|
||||
}
|
||||
if (data === 1) {
|
||||
layer.msg('设置开服时间失败!', {icon: 6, time: 1000});
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
<!--/请在上方写此页面业务相关的脚本-->
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue