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 23 import org.apache.poi.hssf.usermodel.HSSFRow;
24 24 import org.apache.poi.hssf.usermodel.HSSFSheet;
25 25 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  26 +import org.springframework.beans.BeanUtils;
26 27 import org.springframework.beans.factory.annotation.Autowired;
27 28 import org.springframework.util.StringUtils;
28 29 import org.springframework.web.bind.annotation.PathVariable;
... ... @@ -37,6 +38,7 @@ import com.bsth.data.gpsdata.GpsRealData;
37 38 import com.fasterxml.jackson.core.JsonParseException;
38 39 import com.fasterxml.jackson.databind.JsonMappingException;
39 40 import com.fasterxml.jackson.databind.ObjectMapper;
  41 +import com.fasterxml.jackson.databind.util.BeanUtil;
40 42  
41 43 @RestController
42 44 @RequestMapping("devicegps")
... ... @@ -148,11 +150,18 @@ public class DeviceGpsController {
148 150 try {
149 151 data = new ObjectMapper().readValue(json, List.class);
150 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 167 List<Header> head = new ArrayList<>();
... ...
src/main/resources/static/pages/device/connection_search.html
... ... @@ -232,7 +232,7 @@
232 232 </script>
233 233 <script>
234 234 $(function(){
235   - var opened;
  235 + var opened,filtered;
236 236 $('#myTab li:eq(0) a').tab('show');
237 237 $('#fileinput').fileinput({
238 238 'showPreview' : false,
... ... @@ -252,10 +252,11 @@ $(function(){
252 252 $(this).html(moment(parseInt($(this).html())).format('YYYY-M-D HH:mm:ss'));
253 253 });
254 254 opened = new Array();
  255 + filtered = new Array();
255 256 for (var j = 0,len = r.data.length;j < len;j++) {
256 257 var item = r.data[j];
257   - delete item.detail;
258 258 opened.push(item);
  259 + filtered.push(item);
259 260 }
260 261 }
261 262 $(this).fileinput('clear').fileinput('enable');
... ... @@ -281,7 +282,8 @@ $(function(){
281 282 $post('/devicegps/opened', params, function(r){
282 283 if(r.errCode) layer.msg(r.msg);
283 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 287 switch(val) {
286 288 case '1':
287 289 filtered = r.data;
... ... @@ -323,8 +325,8 @@ $(function(){
323 325 }
324 326  
325 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 330 var form = $('#export_form');
329 331 form.submit();
330 332 }
... ...