Commit 542030765f8de227ed2bbd1f70aaaf3dabfdf502

Authored by zb
1 parent 85371678

超速异常更新

src/main/java/com/bsth/controller/gps/GpsController.java
... ... @@ -195,12 +195,10 @@ public class GpsController {
195 195 }
196 196  
197 197 @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
198   - public PageObject<GpsSpeed> pagequery(@RequestParam Map<String, Object> map){
199   - PageObject<GpsSpeed> pageObject = null;
  198 + public Map<String, Object> pagequery(@RequestParam Map<String, Object> map){
200 199 map.put("curPage", map.get("page").toString());
201 200 map.put("pageData","10");
202   - pageObject=gpsService.Pagequery(map);
203   - return pageObject;
  201 + return gpsService.Pagequery(map);
204 202 }
205 203  
206 204 }
... ...
src/main/java/com/bsth/service/gps/GpsService.java
... ... @@ -47,5 +47,5 @@ public interface GpsService {
47 47 List<GpsSpeed> findPosition(String deviceid, String startdate,
48 48 String enddate) throws ParseException;
49 49  
50   - PageObject<GpsSpeed> Pagequery(Map<String, Object> map);
  50 + Map<String, Object> Pagequery(Map<String, Object> map);
51 51 }
... ...
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
... ... @@ -1053,16 +1053,19 @@ public class GpsServiceImpl implements GpsService {
1053 1053 }
1054 1054  
1055 1055 @Override
1056   - public PageObject<GpsSpeed> Pagequery(Map<String, Object> map) {
1057   -
  1056 + public Map<String, Object> Pagequery(Map<String, Object> map) {
1058 1057 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1058 + Integer totalDays = 0;//数据跨越天数
  1059 + try {
  1060 + totalDays = (int) ((sdf.parse(map.get("endDate").toString()+" 23:59:59").getTime()-sdf.parse(map.get("startDate").toString()+" 00:00:00").getTime()+1)/(3600*24*1000))+1;
  1061 + } catch (ParseException e) {
  1062 + e.printStackTrace();
  1063 + }//总页数
  1064 + map.put("totalDays",totalDays);
1059 1065 List<GpsSpeed> list=findAll(map);
1060 1066 List<GpsSpeed> listResult = new ArrayList<GpsSpeed>();
1061   - int curPage;//页码
1062   - int pageData;//每页的记录条数
1063   - int start;//起始数据下标
1064   - int totalPage;//总页数
1065   - int totalData = 0;
  1067 + int curPage = 0;//页码
  1068 + int pageData = 0;//每页的记录条数
1066 1069 if(list.size()>1){
1067 1070 GpsSpeed GpsSpeedNow;//下标为i的车辆行驶记录
1068 1071 GpsSpeed GpsSpeedLast;//下标为i-1的车辆行驶记录
... ... @@ -1099,49 +1102,35 @@ public class GpsServiceImpl implements GpsService {
1099 1102 }
1100 1103 }
1101 1104 }
1102   - Iterator<GpsSpeed> speedIt = listResult.iterator();
1103   - while(speedIt.hasNext()){
1104   - GpsSpeed GpsSpeed = speedIt.next();
1105   - if(GpsSpeed.getEndtimestamp()-GpsSpeed.getTimestamp()<=1000){
1106   - speedIt.remove();
1107   - }
1108   - }
1109   -
1110   - totalData = listResult.size();//总记录条数。
1111   - if(map.get("curPage") == null || map.get("curPage").equals("0")){
1112   - curPage = 0;
1113   - }else{
1114   - curPage = Integer.parseInt((String) map.get("curPage"));
1115   - }
1116   - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
1117   - start = (curPage - 0) * pageData; //起始记录下标。
1118   - totalPage = totalData % pageData == 0 ? totalData / pageData : totalData / pageData +1;//总页数
1119   - if(curPage == totalPage-1){//如果当前页等于总页数。
1120   - listResult = listResult.subList(start, totalData);
1121   - }else{
1122   - listResult = listResult.subList(start, start+pageData);
  1105 + if(listResult.size()>0){
  1106 + Iterator<GpsSpeed> speedIt = listResult.iterator();
  1107 + while(speedIt.hasNext()){
  1108 + GpsSpeed GpsSpeed = speedIt.next();
  1109 + if(GpsSpeed.getEndtimestamp()-GpsSpeed.getTimestamp()<=1000){
  1110 + speedIt.remove();
  1111 + }
  1112 + }
1123 1113 }
1124   - }else{
1125   - curPage = 1;
1126   - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
1127   - totalPage =1;
1128 1114 }
  1115 + if(map.get("curPage") == null || map.get("curPage").equals("0")){
  1116 + curPage = 0;
  1117 + }else{
  1118 + curPage = Integer.parseInt((String) map.get("curPage"));
  1119 + }
  1120 + Integer totalPage = totalDays;
  1121 + pageData = listResult.size();//每页的记录条数就是当前页查出的全部数据。
1129 1122 Map<String,Object> paramMap = new HashMap<String,Object>();
1130 1123 paramMap.put("totalPage", totalPage);
1131   - paramMap.put("curPage", curPage);
  1124 + paramMap.put("page", curPage);
1132 1125 paramMap.put("pageData", pageData);
1133   - PageHelper pageHelper = new PageHelper(totalData, paramMap);
1134   - pageHelper.getMap();
1135   - PageObject<GpsSpeed> pageObject = pageHelper.getPageObject();
1136   - pageObject.setDataList(listResult);
1137   - return pageObject;
  1126 + paramMap.put("list", listResult);
  1127 + return paramMap;
1138 1128 }
1139 1129  
1140 1130 static List<GpsSpeed> findAll(Map<String, Object> map) {
1141 1131 Connection conn = null;
1142 1132 PreparedStatement ps = null;
1143 1133 ResultSet rs = null;
1144   - int page=Integer.parseInt(map.get("page").toString());
1145 1134 List<GpsSpeed> list=new ArrayList<GpsSpeed>();
1146 1135 String sql="select * from bsth_c_gps_info where 1=1 ";
1147 1136 Object line=map.get("line");
... ... @@ -1149,6 +1138,13 @@ public class GpsServiceImpl implements GpsService {
1149 1138 Object updown=map.get("updown");
1150 1139 Object startDate=map.get("startDate");
1151 1140 Object endDate=map.get("endDate");
  1141 + Integer totalDays = Integer.valueOf(map.get("totalDays").toString());
  1142 + Integer curPage = 0;//页码
  1143 + if(map.get("curPage") == null || map.get("curPage").equals("0")){
  1144 + curPage = 0;
  1145 + }else{
  1146 + curPage = Integer.parseInt((String) map.get("curPage"));
  1147 + }
1152 1148  
1153 1149 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
1154 1150 if(line!=null){
... ... @@ -1167,7 +1163,7 @@ public class GpsServiceImpl implements GpsService {
1167 1163 if(startDate!=null){
1168 1164 if (startDate.toString().length()>0) {
1169 1165 try {
1170   - Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();
  1166 + Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime()+curPage*3600*24*1000;
1171 1167 sql += " and ts >="+t1;
1172 1168 } catch (ParseException e) {
1173 1169 e.printStackTrace();
... ... @@ -1178,7 +1174,7 @@ public class GpsServiceImpl implements GpsService {
1178 1174 if(endDate!=null){
1179 1175 if (endDate.toString().length()>0) {
1180 1176 try {
1181   - Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();
  1177 + Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime()-(totalDays-1-curPage)*3600*24*1000;
1182 1178 sql += " and ts <="+t2;
1183 1179 } catch (ParseException e) {
1184 1180 e.printStackTrace();
... ...
src/main/resources/static/pages/excep/speedingList.html
... ... @@ -20,30 +20,6 @@
20 20 class="caption-subject font-dark sbold uppercase">超速异常数据表</span>
21 21 </div>
22 22 <div class="actions">
23   -<!-- <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加用户</a> -->
24   - <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> ɾ���û�</button> -->
25   - <!-- <div class="btn-group">
26   - <a class="btn red btn-outline btn-circle" href="javascript:;"
27   - data-toggle="dropdown"> <i class="fa fa-share"></i> <span
28   - class="hidden-xs"> 系统工具</span> <i class="fa fa-angle-down"></i>
29   - </a>
30   - <ul class="dropdown-menu pull-right" id="datatable_ajax_tools">
31   - <li><a href="javascript:;" data-action="0"
32   - class="tool-action"> <i class="fa fa-print"></i>打印
33   - </a></li>
34   - <li><a href="javascript:;" data-action="1"
35   - class="tool-action"> <i class="fa fa-copy"></i> 复制
36   - </a></li>
37   - <li><a href="javascript:;" data-action="3"
38   - class="tool-action"> <i class="fa fa-file-excel-o"></i>
39   - 导出Excel
40   - </a></li>
41   - <li class="divider"></li>
42   - <li><a href="javascript:;" data-action="5"
43   - class="tool-action"> <i class="fa fa-refresh"></i> 刷新数据
44   - </a></li>
45   - </ul>
46   - </div> -->
47 23 </div>
48 24 </div>
49 25 <div class="portlet-body">
... ... @@ -54,23 +30,22 @@
54 30 <thead>
55 31 <tr role="row" class="heading">
56 32 <th width="3%">#</th>
57   - <th width="8%">线路</th>
58   - <th width="10%">车辆自编号</th>
59   - <!-- <th width="100">工号/名字</th>
60   - <th width="11%">路牌名</th> -->
61   - <th width="10%">上下行</th>
62   - <th width="20%">超速时间</th>
63   - <th width="6%">持续时间</th>
64   - <th width="10%">查看轨迹</th>
65   - <th width="18%">操作</th>
  33 + <th width="4%">线路</th>
  34 + <th width="6%">车辆自编号</th>
  35 + <th width="8%">上下行</th>
  36 + <th width="10%">开始时间</th>
  37 + <th width="10%">结束时间</th>
  38 + <th width="8%">持续时间</th>
  39 + <th width="8%">查看轨迹</th>
  40 + <th width="6%">操作</th>
66 41 </tr>
67 42 <tr role="row" class="filter">
68 43 <td></td>
69 44 <td>
70   - <select class="form-control" name="line" id="line" style="width: 180px;"></select>
  45 + <select class="form-control" name="line" id="line" style="width: 100px;"></select>
71 46 </td>
72 47 <td>
73   - <select class="form-control" name="nbbm" id="nbbm" style="width: 150px;"></select>
  48 + <select class="form-control" name="nbbm" id="nbbm" style="width: 100px;"></select>
74 49 </td>
75 50 <!-- <td>
76 51  
... ... @@ -78,18 +53,19 @@
78 53 <td>
79 54 </td> -->
80 55 <td>
81   - <select class="form-control form-filter " name="updown">
  56 + <select class="form-control form-filter " name="updown" style="width: 90px;">
82 57 <option value="">请选择...</option>
83 58 <option value="0">上行</option>
84 59 <option value="1">下行</option>
85 60 <option value="-1">无效</option>
86 61 </select>
87 62 </td>
88   - <td nowrap="nowrap">
89   - <input class="form-control" type="date" name="startDate" style="width: 180px;"/>
  63 + <td>
  64 + <input class="form-control" type="date" name="startDate" />
90 65 -
91   - <input class="form-control" type="date" name="endDate" style="width: 180px;"/>
92   -
  66 + <input class="form-control" type="date" name="endDate" />
  67 + </td>
  68 + <td>
93 69 </td>
94 70 <td>
95 71 </td>
... ... @@ -128,9 +104,9 @@
128 104 {{obj.vehicle}}
129 105 </td>
130 106 <td>
131   - {{if obj.upDown==0}}
  107 + {{if obj.up_down==0}}
132 108 上行
133   - {{else if obj.upDown==1}}
  109 + {{else if obj.up_down==1}}
134 110 下行
135 111 {{else}}
136 112 无效
... ... @@ -140,10 +116,18 @@
140 116 {{obj.timestampDate}}
141 117 </td>
142 118 <td>
143   - {{obj.durationTime}}秒
  119 + {{obj.endtimestampDate}}
144 120 </td>
145 121 <td>
146   -
  122 + {{(obj.endtimestamp-obj.timestamp)/1000}}秒
  123 + </td>
  124 + <td>
  125 + <a class="btn default blue-stripe btn-sm lookTrajectory" data-vehicle ="{{obj.vehicle}}"
  126 + data-startdate="{{obj.timestampDate}}" data-enddate="{{obj.endtimestampDate}}"
  127 + data-lon="{{obj.lon}}" data-lat="{{obj.lat}}"
  128 + data-endlon="{{obj.endlon}}" data-endlat="{{obj.endlat}}" >
  129 + 查看轨迹
  130 + </a>
147 131 </td>
148 132 <td>
149 133  
... ... @@ -157,6 +141,8 @@
157 141 {{/if}}
158 142 </script>
159 143  
  144 +<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script>
  145 +
160 146 <script>
161 147 $(function(){
162 148 var page = 0, initPagination;
... ... @@ -171,7 +157,6 @@ $(function(){
171 157  
172 158 var endTime = dateTime-week*24*3600*1000;//上周末、格式为时间戳。
173 159 var startTime = endTime-6*24*3600*1000;//上周一、格式为时间戳。
174   -
175 160 var endDate = timeToData(endTime);
176 161 var startDate = timeToData(startTime);
177 162 //表单默认选择上周一到上周日的超速信息。
... ... @@ -180,15 +165,27 @@ $(function(){
180 165 var parameter = new Object();
181 166 parameter.endDate = $("input[name='endDate']")[0].value;
182 167 parameter.startDate = $("input[name='startDate']")[0].value;
183   - //jsDoQuery(parameter,true);
184   - jsDoQuery(null,true);
  168 +
  169 + //搜索线路
  170 + $.get('/basic/lineCode2Name',function(result){
  171 + var data=[];
  172 + data.push({id: " ", text: "全部线路"});
  173 + for(var code in result){
  174 + data.push({id: code, text: result[code]});
  175 + }
  176 + initPinYinSelect2($('#line'),data,function(ldmcSelector) {
  177 + ldmcSelector.select2("val",data[1].id);//因为数据量太大,所以默认一条线路作为查询参数
  178 + });
  179 + parameter.line = data[1].id;
  180 + jsDoQuery(parameter,true);
  181 + });
185 182  
186 183 //时间戳转换为年月日
187 184 function timeToData(time){
188 185 var date = new Date(time);
189 186 var year = date.getFullYear();
190 187 var Month = date.getMonth()+1>10?date.getMonth()+1:"0"+(date.getMonth()+1);
191   - var Day = date.getDate()>10?date.getDate():"0"+date.getDate();
  188 + var Day = date.getDate()>9?date.getDate():"0"+date.getDate();
192 189 return year+"-"+Month+"-"+Day;
193 190 }
194 191  
... ... @@ -219,7 +216,7 @@ $(function(){
219 216 /*
220 217 * 获取数据 p: 要提交的参数, pagination: 是否重新分页
221 218 */
222   - function jsDoQuery(p, pagination){
  219 + function jsDoQuery(p, pagination){
223 220 var params = {};
224 221 if(p)
225 222 params = p;
... ... @@ -227,20 +224,40 @@ $(function(){
227 224 params['order'] = 'lastLoginDate';
228 225 params['page'] = page;
229 226 var i = layer.load(2);
230   - $get('/speeding/pagequery' ,params, function(data){
231   -// $.each(data.content, function(i, obj) {
232   -// obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss");
233   -// });
234   - var bodyHtm = template('speeding_list_temp', {list: data.dataList});
  227 + $.get('/gps/pagequery' ,params, function(data){
  228 + var bodyHtm = template('speeding_list_temp', {list: data.list});
235 229 $('#datatable_speeding tbody').html(bodyHtm)
236 230 .find('.icheck').iCheck(icheckOptions)
237 231 .on('ifChanged', iCheckChange);
238   - if(pagination && data.dataList.length > 0){
  232 + if(pagination){
239 233 //重新分页
240 234 initPagination = true;
241 235 showPagination(data);
242 236 }
243 237 layer.close(i);
  238 + $(".lookTrajectory").click(function(){
  239 + var vehicle = $(this).data('vehicle');
  240 + var startDate = $(this).data('startdate');
  241 + var endDate = $(this).data('enddate');
  242 + var lon = $(this).data('lon');
  243 + var lat = $(this).data('lat');
  244 + var endLon = $(this).data('endlon');
  245 + var endLat = $(this).data('endlat');
  246 + var storage = window.localStorage;
  247 + storage.setItem("zbhAndDate",vehicle+","+startDate+","+endDate+","+lon+","+lat+","+endLon+","+endLat);
  248 + $.get('/pages/excep/speedingMap.html?',function (result) {
  249 + layer.open({
  250 + type: 1,
  251 + title:'<i class="uk-icon-play-circle"></i>轨迹回放',
  252 + shadeClose: true,
  253 + shade: true,
  254 + scrollbar: false,
  255 + maxmin: false, //开启最大化最小化按钮
  256 + area: ['100%', '100%'],
  257 + content:result,//内容
  258 + });
  259 + });
  260 + })
244 261 });
245 262 }
246 263  
... ... @@ -291,6 +308,7 @@ $(function(){
291 308 });
292 309 }
293 310  
  311 +
294 312 //删除
295 313 $('#removeButton').on('click', function(){
296 314 if($(this).attr('disabled'))
... ... @@ -302,17 +320,6 @@ $(function(){
302 320 $('tr.filter .filter-submit').click();
303 321 });
304 322 });
305   -
306   - //搜索线路
307   - $.get('/basic/lineCode2Name',function(result){
308   - var data=[];
309   - data.push({id: " ", text: "全部线路"});
310   - for(var code in result){
311   - data.push({id: code, text: result[code]});
312   - }
313   - initPinYinSelect2('#line',data,'');
314   -
315   - });
316 323  
317 324 $("#line").on("change",initXl);
318 325 function initXl(){
... ... @@ -329,6 +336,7 @@ $(&#39;#nbbm&#39;).select2({
329 336 xlbm:$('#line').val()};
330 337 },
331 338 processResults: function (data) {
  339 + console.log(data);
332 340 return {
333 341 results: data
334 342 };
... ... @@ -365,7 +373,6 @@ $(&#39;#nbbm&#39;).select2({
365 373  
366 374 //改变状态
367 375 function changeEnabled(id,enabled){
368   - debugger
369 376 $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){
370 377 jsDoQuery(null, true);
371 378 })
... ...
src/main/resources/static/pages/excep/speedingListmh.html
... ... @@ -20,30 +20,6 @@
20 20 class="caption-subject font-dark sbold uppercase">超速异常数据表</span>
21 21 </div>
22 22 <div class="actions">
23   -<!-- <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加用户</a> -->
24   - <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> ɾ���û�</button> -->
25   - <!-- <div class="btn-group">
26   - <a class="btn red btn-outline btn-circle" href="javascript:;"
27   - data-toggle="dropdown"> <i class="fa fa-share"></i> <span
28   - class="hidden-xs"> 系统工具</span> <i class="fa fa-angle-down"></i>
29   - </a>
30   - <ul class="dropdown-menu pull-right" id="datatable_ajax_tools">
31   - <li><a href="javascript:;" data-action="0"
32   - class="tool-action"> <i class="fa fa-print"></i>打印
33   - </a></li>
34   - <li><a href="javascript:;" data-action="1"
35   - class="tool-action"> <i class="fa fa-copy"></i> 复制
36   - </a></li>
37   - <li><a href="javascript:;" data-action="3"
38   - class="tool-action"> <i class="fa fa-file-excel-o"></i>
39   - 导出Excel
40   - </a></li>
41   - <li class="divider"></li>
42   - <li><a href="javascript:;" data-action="5"
43   - class="tool-action"> <i class="fa fa-refresh"></i> 刷新数据
44   - </a></li>
45   - </ul>
46   - </div> -->
47 23 </div>
48 24 </div>
49 25 <div class="portlet-body">
... ... @@ -181,7 +157,6 @@ $(function(){
181 157  
182 158 var endTime = dateTime-week*24*3600*1000;//上周末、格式为时间戳。
183 159 var startTime = endTime-6*24*3600*1000;//上周一、格式为时间戳。
184   - debugger;
185 160 var endDate = timeToData(endTime);
186 161 var startDate = timeToData(startTime);
187 162 //表单默认选择上周一到上周日的超速信息。
... ... @@ -249,12 +224,12 @@ $(function(){
249 224 params['order'] = 'lastLoginDate';
250 225 params['page'] = page;
251 226 var i = layer.load(2);
252   - $get('/gps/pagequery' ,params, function(data){
253   - var bodyHtm = template('speeding_list_temp', {list: data.dataList});
  227 + $.get('/gps/pagequery' ,params, function(data){
  228 + var bodyHtm = template('speeding_list_temp', {list: data.list});
254 229 $('#datatable_speeding tbody').html(bodyHtm)
255 230 .find('.icheck').iCheck(icheckOptions)
256 231 .on('ifChanged', iCheckChange);
257   - if(pagination && data.dataList.length > 0){
  232 + if(pagination){
258 233 //重新分页
259 234 initPagination = true;
260 235 showPagination(data);
... ...