diff --git a/src/main/java/com/cm/systemcity/service/userlocation/impl/UserLocationServiceImpl.java b/src/main/java/com/cm/systemcity/service/userlocation/impl/UserLocationServiceImpl.java index 088fb58..c9d451d 100755 --- a/src/main/java/com/cm/systemcity/service/userlocation/impl/UserLocationServiceImpl.java +++ b/src/main/java/com/cm/systemcity/service/userlocation/impl/UserLocationServiceImpl.java @@ -502,23 +502,23 @@ public class UserLocationServiceImpl extends BaseService implements IUserLocatio @Override public List listOnlineUserLastLocation(Map params) throws SearchException { + /** 默认查询一个小时内的在线人员数据 **/ setManagingUsers(params, securityComponent.getCurrentUser().getUserId(), communityBossService); - // 如果有关键字检索 - boolean hasTime = (Objects.isNull(params.get("startTime")) || StringUtils.isBlank(params.get("startTime").toString())) && - (Objects.isNull(params.get("endTime")) || StringUtils.isBlank(params.get("endTime").toString())); - if (hasTime) { - DateTime endTime = DateTime.now(); - DateTime startTime = endTime.minusMinutes(10); + // 是否有时间条件 + String day = DateUtil.getDay(); + DateTime knowTime = DateTime.now(); + // 处理开始时间 + if(params.get("startTime") == null || params.get("startTime").toString().length() == 0){ + DateTime startTime = knowTime.minusMinutes(60); params.put("startTime", startTime.toString(DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"))); - params.put("endTime", endTime.toString(DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"))); - } else { - String day = DateUtil.getDay(); - if (!Objects.isNull(params.get("startTime")) && !StringUtils.isBlank(params.get("startTime").toString())) { - params.put("startTime", String.format("%s %s", day, params.get("startTime").toString())); - } - if (!Objects.isNull(params.get("endTime")) && !StringUtils.isBlank(params.get("endTime").toString())) { - params.put("endTime", String.format("%s %s", day, params.get("endTime").toString())); - } + } else if(params.get("startTime") != null && params.get("startTime").toString().length() > 0){ + params.put("startTime", String.format("%s %s", day, params.get("startTime").toString())); + } + // 处理结束时间 + if(params.get("endTime") == null || params.get("endTime").toString().length() == 0){ + params.put("endTime", knowTime.toString(DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"))); + } else if(params.get("endTime") != null || params.get("endTime").toString().length() > 0){ + params.put("endTime", String.format("%s %s", day, params.get("endTime").toString())); } return listUserLocationWithSign(params); } diff --git a/src/main/resources/static/route/userlocation/list.html b/src/main/resources/static/route/userlocation/list.html index 6de858c..8d1985c 100755 --- a/src/main/resources/static/route/userlocation/list.html +++ b/src/main/resources/static/route/userlocation/list.html @@ -101,7 +101,6 @@ } // 格式化是否越界 function isOverstepFormatter(val, row) { - debugger var value; switch (val) { case '1': diff --git a/src/main/resources/static/route/userlocation/map_online.html b/src/main/resources/static/route/userlocation/map_online.html index 7d8192c..eb66c9f 100755 --- a/src/main/resources/static/route/userlocation/map_online.html +++ b/src/main/resources/static/route/userlocation/map_online.html @@ -84,7 +84,13 @@ var startTime = null; var endTime = null; - // 重置页面大小 + function init(){ + resizePage(); + initDate(); + } + init(); + + // 初始化高度 function resizePage() { $('#areaConfigBox').css({ height: ($win.height() - 50) +'px' @@ -94,7 +100,98 @@ }); } - resizePage(); + // 初始化日期 + function initDate() { + // 日期选择 + laydate.render({ + elem: '#startTime', + type: 'time', + done: function(value, date, endDate){ + startTime = value; + } + }); + laydate.render({ + elem: '#endTime', + type: 'time', + done: function(value, date, endDate){ + endTime = value; + } + }); + } + + // 事件 - 重新加载 + $(document).on('click', '#refresh', function() { + window.location.reload(); + }); + + // 事件 - 搜索 + $(document).on('click', '#search', function() { + search(); + }); + + function search() { + isLoad = true; + initUserCurrentPoint(); + } + + // 监听-页面变化 + window.onresize = function(){ + window.location.reload(); + }; + + // 开始摇人 + function initUserCurrentPoint() { + var keywords = $('#keywords').val(); + var startTime = $('#startTime').val(); + var endTime = $('#endTime').val(); + var params = { + keywords : encodeURI(keywords), + startTime : startTime, + endTime : endTime, + }; + // 清空用户点列表 + markUserPoints.splice(0, markUserPoints.length); + top.restAjax.get(top.restAjax.path('api/userlocation/listonlineuserlastlocation', []), params, null, function(code, data) { + // 清空地图 + map.clearMap(); + takeBaseArea(); + var users = []; + var userIds = []; + var points = []; + for(var i = 0, item = data[i]; item = data[i++];) { + points.push({ + lng: item.userLongitude, + lat: item.userLatitude + }); + users.push({ + valueField: item.creator, + textField: item.userName, + sign: item.sign, + lng: item.userLongitude, + lat: item.userLatitude + }); + userIds.push(item.creator); + markUserPoints.push({ + userId: item.creator, + markPoint: markWithUserAvatarAndUserName(map, new BMap.Point(item.userLongitude, item.userLatitude), { + id: item.creator, + name: item.userName, + phone: item.userPhone, + avatar: item.userAvatar, + }, '时间:'+ item.gmtCreate, function(data) { + openUserLocus(data); + }) + }); + } + for(var i = 0, item = markUserPoints[i]; item = markUserPoints[i++];) { + map.map.addOverlay(item.markPoint); + } + initUserArea(userIds, points); + initLeftMenu(data); + }, function(code, data) { + top.dialog.msg(data.msg); + }); + } // 初始化当前人员列表 function initLeftMenu(data) { @@ -126,25 +223,6 @@ onClickRow(valueField, lng, lat) }) - // 事件 - 搜索 - $(document).on('click', '#refresh', function() { - window.location.reload(); - }); - - // 事件 - 搜索 - $(document).on('click', '#search', function() { - search(); - }); - - window.onresize = function(){ - window.location.reload(); - }; - - function search() { - isLoad = true; - initUserCurrentPoint(); - } - function openUserLocus(data) { top.dialog.open({ url: top.restAjax.path('route/userlocation/map_userlocus.html?userId={id}&date={date}&startTime={startTime}&endTime={endTime}', [data.id, (date == null ? '' : date), (startTime == null ? '' : startTime), (endTime == null ? '' : endTime)]), @@ -233,65 +311,7 @@ } } - function initUserCurrentPoint() { - var keywords = $('#keywords').val(); - var startTime = $('#startTime').val(); - var endTime = $('#endTime').val(); - var params = {}; - if(keywords != null && keywords != '') { - params.keywords = encodeURI(keywords); - } - if(startTime != null && startTime != '') { - params.startTime = startTime; - } - if(endTime != null && endTime != '') { - params.endTime = endTime; - } - markUserPoints.splice(0, markUserPoints.length); - top.restAjax.get(top.restAjax.path('api/userlocation/listonlineuserlastlocation', []), params, null, function(code, data) { - // 清空地图 - map.clearMap(); - takeBaseArea(); - var users = []; - var userIds = []; - var points = []; - for(var i = 0, item = data[i]; item = data[i++];) { - points.push({ - lng: item.userLongitude, - lat: item.userLatitude - }); - users.push({ - valueField: item.creator, - textField: item.userName, - sign: item.sign, - lng: item.userLongitude, - lat: item.userLatitude - }); - userIds.push(item.creator); - markUserPoints.push({ - userId: item.creator, - markPoint: markWithUserAvatarAndUserName(map, new BMap.Point(item.userLongitude, item.userLatitude), { - id: item.creator, - name: item.userName, - phone: item.userPhone, - avatar: item.userAvatar, - }, '时间:'+ item.gmtCreate, function(data) { - openUserLocus(data); - }) - }); - } - for(var i = 0, item = markUserPoints[i]; item = markUserPoints[i++];) { - map.map.addOverlay(item.markPoint); - } - initUserArea(userIds, points); - initLeftMenu(data); - }, function(code, data) { - top.dialog.msg(data.msg); - }); - } - function textFormatter(value, row, index) { - debugger value = (index + 1) +'.' + value; if(row.leave) { value += '【已请假】'; @@ -404,38 +424,9 @@ initMap(); - // 初始化日期 - function initDate() { - // 日期选择 - laydate.render({ - elem: '#startTime', - type: 'time', - done: function(value, date, endDate){ - startTime = value; - } - }); - laydate.render({ - elem: '#endTime', - type: 'time', - done: function(value, date, endDate){ - endTime = value; - } - }); - } - - initDate(); /** * 标记用户,包括头像,用户名等 - * @param map - * @param point - * @param avatar - * @param name - * @param phone - * @param explainText - * @param user - * @param callback - * @returns {UserAvatarAndUserName} */ function markWithUserAvatarAndUserName(map, point, user, explainText, callback) { @@ -496,7 +487,7 @@ } else { userAvatar.setAttribute('src', 'route/file/downloadfile/true/' + user.avatar); } - userAvatar.onclick = function() { + /*userAvatar.onclick = function() { top.dialog.open({ url: top.restAjax.path('route/userlocation/get-user-detail.html?userId={userId}', [self.user.id]), title: '人员详情', @@ -505,7 +496,7 @@ onClose: function() {} }) stopPaoPao(); - } + }*/ userInfoBox.appendChild(userAvatar); var infoBox = this.infoBox = document.createElement('div'); diff --git a/src/main/resources/static/route/usersignin/list.html b/src/main/resources/static/route/usersignin/list.html index 0d428f8..050f9d6 100755 --- a/src/main/resources/static/route/usersignin/list.html +++ b/src/main/resources/static/route/usersignin/list.html @@ -175,13 +175,13 @@ {field: 'amPm', width: 80, title: '上下午', align:'center', templet: function(row) { var rowData = row[this.field]; - if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { + if(typeof(rowData) === 'undefined' || rowData == null || rowData === '') { return '-'; } if(rowData == 'AM'){ return '上午' } - if(rowData == 'AM'){ + if(rowData == 'PM'){ return '下午' } } @@ -220,7 +220,7 @@ return '' } }, - {field: 'communityBossLevel', width: 100, title: '网格长等级', align:'center', + {field: 'communityBossLevel', width: 100, title: '网格等级', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {