Commit 4c4f471eb48cda9764b097bee102b6c237c9ab15

Authored by 王通
1 parent 217f4da1

修正

src/main/java/com/bsth/controller/DeviceGpsController.java
@@ -23,6 +23,7 @@ import org.apache.poi.hssf.usermodel.HSSFRichTextString; @@ -23,6 +23,7 @@ import org.apache.poi.hssf.usermodel.HSSFRichTextString;
23 import org.apache.poi.hssf.usermodel.HSSFRow; 23 import org.apache.poi.hssf.usermodel.HSSFRow;
24 import org.apache.poi.hssf.usermodel.HSSFSheet; 24 import org.apache.poi.hssf.usermodel.HSSFSheet;
25 import org.apache.poi.hssf.usermodel.HSSFWorkbook; 25 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  26 +import org.springframework.beans.BeanUtils;
26 import org.springframework.beans.factory.annotation.Autowired; 27 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.util.StringUtils; 28 import org.springframework.util.StringUtils;
28 import org.springframework.web.bind.annotation.PathVariable; 29 import org.springframework.web.bind.annotation.PathVariable;
@@ -37,6 +38,7 @@ import com.bsth.data.gpsdata.GpsRealData; @@ -37,6 +38,7 @@ import com.bsth.data.gpsdata.GpsRealData;
37 import com.fasterxml.jackson.core.JsonParseException; 38 import com.fasterxml.jackson.core.JsonParseException;
38 import com.fasterxml.jackson.databind.JsonMappingException; 39 import com.fasterxml.jackson.databind.JsonMappingException;
39 import com.fasterxml.jackson.databind.ObjectMapper; 40 import com.fasterxml.jackson.databind.ObjectMapper;
  41 +import com.fasterxml.jackson.databind.util.BeanUtil;
40 42
41 @RestController 43 @RestController
42 @RequestMapping("devicegps") 44 @RequestMapping("devicegps")
@@ -148,11 +150,18 @@ public class DeviceGpsController { @@ -148,11 +150,18 @@ public class DeviceGpsController {
148 try { 150 try {
149 data = new ObjectMapper().readValue(json, List.class); 151 data = new ObjectMapper().readValue(json, List.class);
150 for (Map<String, Object> info : data) { 152 for (Map<String, Object> info : data) {
151 - GpsEntity gps = gpsRealData.findByDeviceId((String)info.get("deviceId"));  
152 - info.put("lineId", gps.getLineId());  
153 - info.put("valid", gps.getValid() == 0 ? "有效" : "无效");  
154 - info.put("timestamp", sdf.format(new Date(gps.getTimestamp())));  
155 - info.put("version", gps.getVersion()); 153 + Map<String, Object> detail = (Map<String, Object>)info.get("detail");
  154 + if (detail != null) {
  155 + info.put("lineId", detail.get("lineId"));
  156 + info.put("valid", (int)detail.get("valid") == 0 ? "有效" : "无效");
  157 + info.put("timestamp", sdf.format(new Date((Long)detail.get("timestamp"))));
  158 + info.put("version", detail.get("version"));
  159 + } else {
  160 + info.put("lineId", "");
  161 + info.put("valid", "");
  162 + info.put("timestamp", "");
  163 + info.put("version", "");
  164 + }
156 } 165 }
157 166
158 List<Header> head = new ArrayList<>(); 167 List<Header> head = new ArrayList<>();
src/main/resources/static/pages/device/connection_search.html
@@ -232,7 +232,7 @@ @@ -232,7 +232,7 @@
232 </script> 232 </script>
233 <script> 233 <script>
234 $(function(){ 234 $(function(){
235 - var opened; 235 + var opened,filtered;
236 $('#myTab li:eq(0) a').tab('show'); 236 $('#myTab li:eq(0) a').tab('show');
237 $('#fileinput').fileinput({ 237 $('#fileinput').fileinput({
238 'showPreview' : false, 238 'showPreview' : false,
@@ -252,10 +252,11 @@ $(function(){ @@ -252,10 +252,11 @@ $(function(){
252 $(this).html(moment(parseInt($(this).html())).format('YYYY-M-D HH:mm:ss')); 252 $(this).html(moment(parseInt($(this).html())).format('YYYY-M-D HH:mm:ss'));
253 }); 253 });
254 opened = new Array(); 254 opened = new Array();
  255 + filtered = new Array();
255 for (var j = 0,len = r.data.length;j < len;j++) { 256 for (var j = 0,len = r.data.length;j < len;j++) {
256 var item = r.data[j]; 257 var item = r.data[j];
257 - delete item.detail;  
258 opened.push(item); 258 opened.push(item);
  259 + filtered.push(item);
259 } 260 }
260 } 261 }
261 $(this).fileinput('clear').fileinput('enable'); 262 $(this).fileinput('clear').fileinput('enable');
@@ -281,7 +282,8 @@ $(function(){ @@ -281,7 +282,8 @@ $(function(){
281 $post('/devicegps/opened', params, function(r){ 282 $post('/devicegps/opened', params, function(r){
282 if(r.errCode) layer.msg(r.msg); 283 if(r.errCode) layer.msg(r.msg);
283 else { 284 else {
284 - var filtered = new Array(), val = $('input[type=radio][name=filterOption]:checked').val(), version = $('#version').val(), i = 0,item = null; 285 + var val = $('input[type=radio][name=filterOption]:checked').val(), version = $('#version').val(), i = 0,item = null;
  286 + filtered = new Array();
285 switch(val) { 287 switch(val) {
286 case '1': 288 case '1':
287 filtered = r.data; 289 filtered = r.data;
@@ -323,8 +325,8 @@ $(function(){ @@ -323,8 +325,8 @@ $(function(){
323 } 325 }
324 326
325 function exportResult() { 327 function exportResult() {
326 - if (!opened) return false;  
327 - $('#json').val(JSON.stringify(opened)); 328 + if (!filtered) return false;
  329 + $('#json').val(JSON.stringify(filtered));
328 var form = $('#export_form'); 330 var form = $('#export_form');
329 form.submit(); 331 form.submit();
330 } 332 }